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

render.js in Gutenberg 23.5.0, at build/widgets/quick-draft/render.js

31,166 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/autop
32 var require_autop = __commonJS({
33 "package-external:@wordpress/autop"(exports, module) {
34 module.exports = window.wp.autop;
35 }
36 });
37
38 // package-external:@wordpress/core-data
39 var require_core_data = __commonJS({
40 "package-external:@wordpress/core-data"(exports, module) {
41 module.exports = window.wp.coreData;
42 }
43 });
44
45 // package-external:@wordpress/data
46 var require_data = __commonJS({
47 "package-external:@wordpress/data"(exports, module) {
48 module.exports = window.wp.data;
49 }
50 });
51
52 // package-external:@wordpress/element
53 var require_element = __commonJS({
54 "package-external:@wordpress/element"(exports, module) {
55 module.exports = window.wp.element;
56 }
57 });
58
59 // package-external:@wordpress/compose
60 var require_compose = __commonJS({
61 "package-external:@wordpress/compose"(exports, module) {
62 module.exports = window.wp.compose;
63 }
64 });
65
66 // vendor-external:react
67 var require_react = __commonJS({
68 "vendor-external:react"(exports, module) {
69 module.exports = window.React;
70 }
71 });
72
73 // vendor-external:react/jsx-runtime
74 var require_jsx_runtime = __commonJS({
75 "vendor-external:react/jsx-runtime"(exports, module) {
76 module.exports = window.ReactJSXRuntime;
77 }
78 });
79
80 // vendor-external:react-dom
81 var require_react_dom = __commonJS({
82 "vendor-external:react-dom"(exports, module) {
83 module.exports = window.ReactDOM;
84 }
85 });
86
87 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
88 var require_use_sync_external_store_shim_development = __commonJS({
89 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
90 "use strict";
91 (function() {
92 function is(x2, y2) {
93 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
94 }
95 function useSyncExternalStore$2(subscribe2, getSnapshot) {
96 didWarnOld18Alpha || void 0 === React60.startTransition || (didWarnOld18Alpha = true, console.error(
97 "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."
98 ));
99 var value = getSnapshot();
100 if (!didWarnUncachedGetSnapshot) {
101 var cachedValue = getSnapshot();
102 objectIs(value, cachedValue) || (console.error(
103 "The result of getSnapshot should be cached to avoid an infinite loop"
104 ), didWarnUncachedGetSnapshot = true);
105 }
106 cachedValue = useState47({
107 inst: { value, getSnapshot }
108 });
109 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
110 useLayoutEffect5(
111 function() {
112 inst.value = value;
113 inst.getSnapshot = getSnapshot;
114 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
115 },
116 [subscribe2, value, getSnapshot]
117 );
118 useEffect40(
119 function() {
120 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
121 return subscribe2(function() {
122 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
123 });
124 },
125 [subscribe2]
126 );
127 useDebugValue2(value);
128 return value;
129 }
130 function checkIfSnapshotChanged(inst) {
131 var latestGetSnapshot = inst.getSnapshot;
132 inst = inst.value;
133 try {
134 var nextValue = latestGetSnapshot();
135 return !objectIs(inst, nextValue);
136 } catch (error2) {
137 return true;
138 }
139 }
140 function useSyncExternalStore$1(subscribe2, getSnapshot) {
141 return getSnapshot();
142 }
143 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
144 var React60 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState47 = React60.useState, useEffect40 = 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;
145 exports.useSyncExternalStore = void 0 !== React60.useSyncExternalStore ? React60.useSyncExternalStore : shim;
146 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
147 })();
148 }
149 });
150
151 // node_modules/use-sync-external-store/shim/index.js
152 var require_shim = __commonJS({
153 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
154 "use strict";
155 if (false) {
156 module.exports = null;
157 } else {
158 module.exports = require_use_sync_external_store_shim_development();
159 }
160 }
161 });
162
163 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
164 var require_with_selector_development = __commonJS({
165 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
166 "use strict";
167 (function() {
168 function is(x2, y2) {
169 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
170 }
171 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
172 var React60 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef55 = React60.useRef, useEffect40 = React60.useEffect, useMemo53 = React60.useMemo, useDebugValue2 = React60.useDebugValue;
173 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
174 var instRef = useRef55(null);
175 if (null === instRef.current) {
176 var inst = { hasValue: false, value: null };
177 instRef.current = inst;
178 } else inst = instRef.current;
179 instRef = useMemo53(
180 function() {
181 function memoizedSelector(nextSnapshot) {
182 if (!hasMemo) {
183 hasMemo = true;
184 memoizedSnapshot = nextSnapshot;
185 nextSnapshot = selector2(nextSnapshot);
186 if (void 0 !== isEqual && inst.hasValue) {
187 var currentSelection = inst.value;
188 if (isEqual(currentSelection, nextSnapshot))
189 return memoizedSelection = currentSelection;
190 }
191 return memoizedSelection = nextSnapshot;
192 }
193 currentSelection = memoizedSelection;
194 if (objectIs(memoizedSnapshot, nextSnapshot))
195 return currentSelection;
196 var nextSelection = selector2(nextSnapshot);
197 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
198 return memoizedSnapshot = nextSnapshot, currentSelection;
199 memoizedSnapshot = nextSnapshot;
200 return memoizedSelection = nextSelection;
201 }
202 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
203 return [
204 function() {
205 return memoizedSelector(getSnapshot());
206 },
207 null === maybeGetServerSnapshot ? void 0 : function() {
208 return memoizedSelector(maybeGetServerSnapshot());
209 }
210 ];
211 },
212 [getSnapshot, getServerSnapshot, selector2, isEqual]
213 );
214 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
215 useEffect40(
216 function() {
217 inst.hasValue = true;
218 inst.value = value;
219 },
220 [value]
221 );
222 useDebugValue2(value);
223 return value;
224 };
225 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
226 })();
227 }
228 });
229
230 // node_modules/use-sync-external-store/shim/with-selector.js
231 var require_with_selector = __commonJS({
232 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
233 "use strict";
234 if (false) {
235 module.exports = null;
236 } else {
237 module.exports = require_with_selector_development();
238 }
239 }
240 });
241
242 // package-external:@wordpress/i18n
243 var require_i18n = __commonJS({
244 "package-external:@wordpress/i18n"(exports, module) {
245 module.exports = window.wp.i18n;
246 }
247 });
248
249 // package-external:@wordpress/primitives
250 var require_primitives = __commonJS({
251 "package-external:@wordpress/primitives"(exports, module) {
252 module.exports = window.wp.primitives;
253 }
254 });
255
256 // package-external:@wordpress/theme
257 var require_theme = __commonJS({
258 "package-external:@wordpress/theme"(exports, module) {
259 module.exports = window.wp.theme;
260 }
261 });
262
263 // package-external:@wordpress/private-apis
264 var require_private_apis = __commonJS({
265 "package-external:@wordpress/private-apis"(exports, module) {
266 module.exports = window.wp.privateApis;
267 }
268 });
269
270 // package-external:@wordpress/components
271 var require_components = __commonJS({
272 "package-external:@wordpress/components"(exports, module) {
273 module.exports = window.wp.components;
274 }
275 });
276
277 // package-external:@wordpress/keycodes
278 var require_keycodes = __commonJS({
279 "package-external:@wordpress/keycodes"(exports, module) {
280 module.exports = window.wp.keycodes;
281 }
282 });
283
284 // node_modules/remove-accents/index.js
285 var require_remove_accents = __commonJS({
286 "node_modules/remove-accents/index.js"(exports, module) {
287 var characterMap = {
288 "\xC0": "A",
289 "\xC1": "A",
290 "\xC2": "A",
291 "\xC3": "A",
292 "\xC4": "A",
293 "\xC5": "A",
294 "\u1EA4": "A",
295 "\u1EAE": "A",
296 "\u1EB2": "A",
297 "\u1EB4": "A",
298 "\u1EB6": "A",
299 "\xC6": "AE",
300 "\u1EA6": "A",
301 "\u1EB0": "A",
302 "\u0202": "A",
303 "\u1EA2": "A",
304 "\u1EA0": "A",
305 "\u1EA8": "A",
306 "\u1EAA": "A",
307 "\u1EAC": "A",
308 "\xC7": "C",
309 "\u1E08": "C",
310 "\xC8": "E",
311 "\xC9": "E",
312 "\xCA": "E",
313 "\xCB": "E",
314 "\u1EBE": "E",
315 "\u1E16": "E",
316 "\u1EC0": "E",
317 "\u1E14": "E",
318 "\u1E1C": "E",
319 "\u0206": "E",
320 "\u1EBA": "E",
321 "\u1EBC": "E",
322 "\u1EB8": "E",
323 "\u1EC2": "E",
324 "\u1EC4": "E",
325 "\u1EC6": "E",
326 "\xCC": "I",
327 "\xCD": "I",
328 "\xCE": "I",
329 "\xCF": "I",
330 "\u1E2E": "I",
331 "\u020A": "I",
332 "\u1EC8": "I",
333 "\u1ECA": "I",
334 "\xD0": "D",
335 "\xD1": "N",
336 "\xD2": "O",
337 "\xD3": "O",
338 "\xD4": "O",
339 "\xD5": "O",
340 "\xD6": "O",
341 "\xD8": "O",
342 "\u1ED0": "O",
343 "\u1E4C": "O",
344 "\u1E52": "O",
345 "\u020E": "O",
346 "\u1ECE": "O",
347 "\u1ECC": "O",
348 "\u1ED4": "O",
349 "\u1ED6": "O",
350 "\u1ED8": "O",
351 "\u1EDC": "O",
352 "\u1EDE": "O",
353 "\u1EE0": "O",
354 "\u1EDA": "O",
355 "\u1EE2": "O",
356 "\xD9": "U",
357 "\xDA": "U",
358 "\xDB": "U",
359 "\xDC": "U",
360 "\u1EE6": "U",
361 "\u1EE4": "U",
362 "\u1EEC": "U",
363 "\u1EEE": "U",
364 "\u1EF0": "U",
365 "\xDD": "Y",
366 "\xE0": "a",
367 "\xE1": "a",
368 "\xE2": "a",
369 "\xE3": "a",
370 "\xE4": "a",
371 "\xE5": "a",
372 "\u1EA5": "a",
373 "\u1EAF": "a",
374 "\u1EB3": "a",
375 "\u1EB5": "a",
376 "\u1EB7": "a",
377 "\xE6": "ae",
378 "\u1EA7": "a",
379 "\u1EB1": "a",
380 "\u0203": "a",
381 "\u1EA3": "a",
382 "\u1EA1": "a",
383 "\u1EA9": "a",
384 "\u1EAB": "a",
385 "\u1EAD": "a",
386 "\xE7": "c",
387 "\u1E09": "c",
388 "\xE8": "e",
389 "\xE9": "e",
390 "\xEA": "e",
391 "\xEB": "e",
392 "\u1EBF": "e",
393 "\u1E17": "e",
394 "\u1EC1": "e",
395 "\u1E15": "e",
396 "\u1E1D": "e",
397 "\u0207": "e",
398 "\u1EBB": "e",
399 "\u1EBD": "e",
400 "\u1EB9": "e",
401 "\u1EC3": "e",
402 "\u1EC5": "e",
403 "\u1EC7": "e",
404 "\xEC": "i",
405 "\xED": "i",
406 "\xEE": "i",
407 "\xEF": "i",
408 "\u1E2F": "i",
409 "\u020B": "i",
410 "\u1EC9": "i",
411 "\u1ECB": "i",
412 "\xF0": "d",
413 "\xF1": "n",
414 "\xF2": "o",
415 "\xF3": "o",
416 "\xF4": "o",
417 "\xF5": "o",
418 "\xF6": "o",
419 "\xF8": "o",
420 "\u1ED1": "o",
421 "\u1E4D": "o",
422 "\u1E53": "o",
423 "\u020F": "o",
424 "\u1ECF": "o",
425 "\u1ECD": "o",
426 "\u1ED5": "o",
427 "\u1ED7": "o",
428 "\u1ED9": "o",
429 "\u1EDD": "o",
430 "\u1EDF": "o",
431 "\u1EE1": "o",
432 "\u1EDB": "o",
433 "\u1EE3": "o",
434 "\xF9": "u",
435 "\xFA": "u",
436 "\xFB": "u",
437 "\xFC": "u",
438 "\u1EE7": "u",
439 "\u1EE5": "u",
440 "\u1EED": "u",
441 "\u1EEF": "u",
442 "\u1EF1": "u",
443 "\xFD": "y",
444 "\xFF": "y",
445 "\u0100": "A",
446 "\u0101": "a",
447 "\u0102": "A",
448 "\u0103": "a",
449 "\u0104": "A",
450 "\u0105": "a",
451 "\u0106": "C",
452 "\u0107": "c",
453 "\u0108": "C",
454 "\u0109": "c",
455 "\u010A": "C",
456 "\u010B": "c",
457 "\u010C": "C",
458 "\u010D": "c",
459 "C\u0306": "C",
460 "c\u0306": "c",
461 "\u010E": "D",
462 "\u010F": "d",
463 "\u0110": "D",
464 "\u0111": "d",
465 "\u0112": "E",
466 "\u0113": "e",
467 "\u0114": "E",
468 "\u0115": "e",
469 "\u0116": "E",
470 "\u0117": "e",
471 "\u0118": "E",
472 "\u0119": "e",
473 "\u011A": "E",
474 "\u011B": "e",
475 "\u011C": "G",
476 "\u01F4": "G",
477 "\u011D": "g",
478 "\u01F5": "g",
479 "\u011E": "G",
480 "\u011F": "g",
481 "\u0120": "G",
482 "\u0121": "g",
483 "\u0122": "G",
484 "\u0123": "g",
485 "\u0124": "H",
486 "\u0125": "h",
487 "\u0126": "H",
488 "\u0127": "h",
489 "\u1E2A": "H",
490 "\u1E2B": "h",
491 "\u0128": "I",
492 "\u0129": "i",
493 "\u012A": "I",
494 "\u012B": "i",
495 "\u012C": "I",
496 "\u012D": "i",
497 "\u012E": "I",
498 "\u012F": "i",
499 "\u0130": "I",
500 "\u0131": "i",
501 "\u0132": "IJ",
502 "\u0133": "ij",
503 "\u0134": "J",
504 "\u0135": "j",
505 "\u0136": "K",
506 "\u0137": "k",
507 "\u1E30": "K",
508 "\u1E31": "k",
509 "K\u0306": "K",
510 "k\u0306": "k",
511 "\u0139": "L",
512 "\u013A": "l",
513 "\u013B": "L",
514 "\u013C": "l",
515 "\u013D": "L",
516 "\u013E": "l",
517 "\u013F": "L",
518 "\u0140": "l",
519 "\u0141": "l",
520 "\u0142": "l",
521 "\u1E3E": "M",
522 "\u1E3F": "m",
523 "M\u0306": "M",
524 "m\u0306": "m",
525 "\u0143": "N",
526 "\u0144": "n",
527 "\u0145": "N",
528 "\u0146": "n",
529 "\u0147": "N",
530 "\u0148": "n",
531 "\u0149": "n",
532 "N\u0306": "N",
533 "n\u0306": "n",
534 "\u014C": "O",
535 "\u014D": "o",
536 "\u014E": "O",
537 "\u014F": "o",
538 "\u0150": "O",
539 "\u0151": "o",
540 "\u0152": "OE",
541 "\u0153": "oe",
542 "P\u0306": "P",
543 "p\u0306": "p",
544 "\u0154": "R",
545 "\u0155": "r",
546 "\u0156": "R",
547 "\u0157": "r",
548 "\u0158": "R",
549 "\u0159": "r",
550 "R\u0306": "R",
551 "r\u0306": "r",
552 "\u0212": "R",
553 "\u0213": "r",
554 "\u015A": "S",
555 "\u015B": "s",
556 "\u015C": "S",
557 "\u015D": "s",
558 "\u015E": "S",
559 "\u0218": "S",
560 "\u0219": "s",
561 "\u015F": "s",
562 "\u0160": "S",
563 "\u0161": "s",
564 "\u0162": "T",
565 "\u0163": "t",
566 "\u021B": "t",
567 "\u021A": "T",
568 "\u0164": "T",
569 "\u0165": "t",
570 "\u0166": "T",
571 "\u0167": "t",
572 "T\u0306": "T",
573 "t\u0306": "t",
574 "\u0168": "U",
575 "\u0169": "u",
576 "\u016A": "U",
577 "\u016B": "u",
578 "\u016C": "U",
579 "\u016D": "u",
580 "\u016E": "U",
581 "\u016F": "u",
582 "\u0170": "U",
583 "\u0171": "u",
584 "\u0172": "U",
585 "\u0173": "u",
586 "\u0216": "U",
587 "\u0217": "u",
588 "V\u0306": "V",
589 "v\u0306": "v",
590 "\u0174": "W",
591 "\u0175": "w",
592 "\u1E82": "W",
593 "\u1E83": "w",
594 "X\u0306": "X",
595 "x\u0306": "x",
596 "\u0176": "Y",
597 "\u0177": "y",
598 "\u0178": "Y",
599 "Y\u0306": "Y",
600 "y\u0306": "y",
601 "\u0179": "Z",
602 "\u017A": "z",
603 "\u017B": "Z",
604 "\u017C": "z",
605 "\u017D": "Z",
606 "\u017E": "z",
607 "\u017F": "s",
608 "\u0192": "f",
609 "\u01A0": "O",
610 "\u01A1": "o",
611 "\u01AF": "U",
612 "\u01B0": "u",
613 "\u01CD": "A",
614 "\u01CE": "a",
615 "\u01CF": "I",
616 "\u01D0": "i",
617 "\u01D1": "O",
618 "\u01D2": "o",
619 "\u01D3": "U",
620 "\u01D4": "u",
621 "\u01D5": "U",
622 "\u01D6": "u",
623 "\u01D7": "U",
624 "\u01D8": "u",
625 "\u01D9": "U",
626 "\u01DA": "u",
627 "\u01DB": "U",
628 "\u01DC": "u",
629 "\u1EE8": "U",
630 "\u1EE9": "u",
631 "\u1E78": "U",
632 "\u1E79": "u",
633 "\u01FA": "A",
634 "\u01FB": "a",
635 "\u01FC": "AE",
636 "\u01FD": "ae",
637 "\u01FE": "O",
638 "\u01FF": "o",
639 "\xDE": "TH",
640 "\xFE": "th",
641 "\u1E54": "P",
642 "\u1E55": "p",
643 "\u1E64": "S",
644 "\u1E65": "s",
645 "X\u0301": "X",
646 "x\u0301": "x",
647 "\u0403": "\u0413",
648 "\u0453": "\u0433",
649 "\u040C": "\u041A",
650 "\u045C": "\u043A",
651 "A\u030B": "A",
652 "a\u030B": "a",
653 "E\u030B": "E",
654 "e\u030B": "e",
655 "I\u030B": "I",
656 "i\u030B": "i",
657 "\u01F8": "N",
658 "\u01F9": "n",
659 "\u1ED2": "O",
660 "\u1ED3": "o",
661 "\u1E50": "O",
662 "\u1E51": "o",
663 "\u1EEA": "U",
664 "\u1EEB": "u",
665 "\u1E80": "W",
666 "\u1E81": "w",
667 "\u1EF2": "Y",
668 "\u1EF3": "y",
669 "\u0200": "A",
670 "\u0201": "a",
671 "\u0204": "E",
672 "\u0205": "e",
673 "\u0208": "I",
674 "\u0209": "i",
675 "\u020C": "O",
676 "\u020D": "o",
677 "\u0210": "R",
678 "\u0211": "r",
679 "\u0214": "U",
680 "\u0215": "u",
681 "B\u030C": "B",
682 "b\u030C": "b",
683 "\u010C\u0323": "C",
684 "\u010D\u0323": "c",
685 "\xCA\u030C": "E",
686 "\xEA\u030C": "e",
687 "F\u030C": "F",
688 "f\u030C": "f",
689 "\u01E6": "G",
690 "\u01E7": "g",
691 "\u021E": "H",
692 "\u021F": "h",
693 "J\u030C": "J",
694 "\u01F0": "j",
695 "\u01E8": "K",
696 "\u01E9": "k",
697 "M\u030C": "M",
698 "m\u030C": "m",
699 "P\u030C": "P",
700 "p\u030C": "p",
701 "Q\u030C": "Q",
702 "q\u030C": "q",
703 "\u0158\u0329": "R",
704 "\u0159\u0329": "r",
705 "\u1E66": "S",
706 "\u1E67": "s",
707 "V\u030C": "V",
708 "v\u030C": "v",
709 "W\u030C": "W",
710 "w\u030C": "w",
711 "X\u030C": "X",
712 "x\u030C": "x",
713 "Y\u030C": "Y",
714 "y\u030C": "y",
715 "A\u0327": "A",
716 "a\u0327": "a",
717 "B\u0327": "B",
718 "b\u0327": "b",
719 "\u1E10": "D",
720 "\u1E11": "d",
721 "\u0228": "E",
722 "\u0229": "e",
723 "\u0190\u0327": "E",
724 "\u025B\u0327": "e",
725 "\u1E28": "H",
726 "\u1E29": "h",
727 "I\u0327": "I",
728 "i\u0327": "i",
729 "\u0197\u0327": "I",
730 "\u0268\u0327": "i",
731 "M\u0327": "M",
732 "m\u0327": "m",
733 "O\u0327": "O",
734 "o\u0327": "o",
735 "Q\u0327": "Q",
736 "q\u0327": "q",
737 "U\u0327": "U",
738 "u\u0327": "u",
739 "X\u0327": "X",
740 "x\u0327": "x",
741 "Z\u0327": "Z",
742 "z\u0327": "z",
743 "\u0439": "\u0438",
744 "\u0419": "\u0418",
745 "\u0451": "\u0435",
746 "\u0401": "\u0415"
747 };
748 var chars = Object.keys(characterMap).join("|");
749 var allAccents = new RegExp(chars, "g");
750 var firstAccent = new RegExp(chars, "");
751 function matcher(match2) {
752 return characterMap[match2];
753 }
754 var removeAccents2 = function(string) {
755 return string.replace(allAccents, matcher);
756 };
757 var hasAccents = function(string) {
758 return !!string.match(firstAccent);
759 };
760 module.exports = removeAccents2;
761 module.exports.has = hasAccents;
762 module.exports.remove = removeAccents2;
763 }
764 });
765
766 // node_modules/fast-deep-equal/es6/index.js
767 var require_es6 = __commonJS({
768 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
769 "use strict";
770 module.exports = function equal(a2, b2) {
771 if (a2 === b2) return true;
772 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
773 if (a2.constructor !== b2.constructor) return false;
774 var length, i2, keys;
775 if (Array.isArray(a2)) {
776 length = a2.length;
777 if (length != b2.length) return false;
778 for (i2 = length; i2-- !== 0; )
779 if (!equal(a2[i2], b2[i2])) return false;
780 return true;
781 }
782 if (a2 instanceof Map && b2 instanceof Map) {
783 if (a2.size !== b2.size) return false;
784 for (i2 of a2.entries())
785 if (!b2.has(i2[0])) return false;
786 for (i2 of a2.entries())
787 if (!equal(i2[1], b2.get(i2[0]))) return false;
788 return true;
789 }
790 if (a2 instanceof Set && b2 instanceof Set) {
791 if (a2.size !== b2.size) return false;
792 for (i2 of a2.entries())
793 if (!b2.has(i2[0])) return false;
794 return true;
795 }
796 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
797 length = a2.length;
798 if (length != b2.length) return false;
799 for (i2 = length; i2-- !== 0; )
800 if (a2[i2] !== b2[i2]) return false;
801 return true;
802 }
803 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
804 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
805 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
806 keys = Object.keys(a2);
807 length = keys.length;
808 if (length !== Object.keys(b2).length) return false;
809 for (i2 = length; i2-- !== 0; )
810 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
811 for (i2 = length; i2-- !== 0; ) {
812 var key = keys[i2];
813 if (!equal(a2[key], b2[key])) return false;
814 }
815 return true;
816 }
817 return a2 !== a2 && b2 !== b2;
818 };
819 }
820 });
821
822 // package-external:@wordpress/date
823 var require_date = __commonJS({
824 "package-external:@wordpress/date"(exports, module) {
825 module.exports = window.wp.date;
826 }
827 });
828
829 // package-external:@wordpress/warning
830 var require_warning = __commonJS({
831 "package-external:@wordpress/warning"(exports, module) {
832 module.exports = window.wp.warning;
833 }
834 });
835
836 // node_modules/deepmerge/dist/cjs.js
837 var require_cjs = __commonJS({
838 "node_modules/deepmerge/dist/cjs.js"(exports, module) {
839 "use strict";
840 var isMergeableObject = function isMergeableObject2(value) {
841 return isNonNullObject(value) && !isSpecial(value);
842 };
843 function isNonNullObject(value) {
844 return !!value && typeof value === "object";
845 }
846 function isSpecial(value) {
847 var stringValue = Object.prototype.toString.call(value);
848 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
849 }
850 var canUseSymbol = typeof Symbol === "function" && Symbol.for;
851 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
852 function isReactElement(value) {
853 return value.$$typeof === REACT_ELEMENT_TYPE;
854 }
855 function emptyTarget(val) {
856 return Array.isArray(val) ? [] : {};
857 }
858 function cloneUnlessOtherwiseSpecified(value, options) {
859 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
860 }
861 function defaultArrayMerge(target, source, options) {
862 return target.concat(source).map(function(element) {
863 return cloneUnlessOtherwiseSpecified(element, options);
864 });
865 }
866 function getMergeFunction(key, options) {
867 if (!options.customMerge) {
868 return deepmerge;
869 }
870 var customMerge = options.customMerge(key);
871 return typeof customMerge === "function" ? customMerge : deepmerge;
872 }
873 function getEnumerableOwnPropertySymbols(target) {
874 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) {
875 return Object.propertyIsEnumerable.call(target, symbol3);
876 }) : [];
877 }
878 function getKeys2(target) {
879 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
880 }
881 function propertyIsOnObject(object, property) {
882 try {
883 return property in object;
884 } catch (_) {
885 return false;
886 }
887 }
888 function propertyIsUnsafe(target, key) {
889 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
890 }
891 function mergeObject(target, source, options) {
892 var destination = {};
893 if (options.isMergeableObject(target)) {
894 getKeys2(target).forEach(function(key) {
895 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
896 });
897 }
898 getKeys2(source).forEach(function(key) {
899 if (propertyIsUnsafe(target, key)) {
900 return;
901 }
902 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
903 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
904 } else {
905 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
906 }
907 });
908 return destination;
909 }
910 function deepmerge(target, source, options) {
911 options = options || {};
912 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
913 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
914 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
915 var sourceIsArray = Array.isArray(source);
916 var targetIsArray = Array.isArray(target);
917 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
918 if (!sourceAndTargetTypesMatch) {
919 return cloneUnlessOtherwiseSpecified(source, options);
920 } else if (sourceIsArray) {
921 return options.arrayMerge(target, source, options);
922 } else {
923 return mergeObject(target, source, options);
924 }
925 }
926 deepmerge.all = function deepmergeAll(array, options) {
927 if (!Array.isArray(array)) {
928 throw new Error("first argument should be an array");
929 }
930 return array.reduce(function(prev, next) {
931 return deepmerge(prev, next, options);
932 }, {});
933 };
934 var deepmerge_1 = deepmerge;
935 module.exports = deepmerge_1;
936 }
937 });
938
939 // package-external:@wordpress/escape-html
940 var require_escape_html = __commonJS({
941 "package-external:@wordpress/escape-html"(exports, module) {
942 module.exports = window.wp.escapeHtml;
943 }
944 });
945
946 // package-external:@wordpress/html-entities
947 var require_html_entities = __commonJS({
948 "package-external:@wordpress/html-entities"(exports, module) {
949 module.exports = window.wp.htmlEntities;
950 }
951 });
952
953 // package-external:@wordpress/url
954 var require_url = __commonJS({
955 "package-external:@wordpress/url"(exports, module) {
956 module.exports = window.wp.url;
957 }
958 });
959
960 // node_modules/clsx/dist/clsx.mjs
961 function r(e2) {
962 var t2, f2, n2 = "";
963 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
964 else if ("object" == typeof e2) if (Array.isArray(e2)) {
965 var o2 = e2.length;
966 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
967 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
968 return n2;
969 }
970 function clsx() {
971 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
972 return n2;
973 }
974 var clsx_default = clsx;
975
976 // widgets/quick-draft/render.tsx
977 var import_autop = __toESM(require_autop());
978 var import_core_data2 = __toESM(require_core_data());
979 var import_data7 = __toESM(require_data());
980
981 // packages/dataviews/build-module/dataviews/index.mjs
982 var import_element99 = __toESM(require_element(), 1);
983 var import_compose13 = __toESM(require_compose(), 1);
984
985 // packages/ui/build-module/badge/badge.mjs
986 var import_element11 = __toESM(require_element(), 1);
987
988 // node_modules/@base-ui/utils/esm/useControlled.js
989 var React = __toESM(require_react(), 1);
990
991 // node_modules/@base-ui/utils/esm/error.js
992 var set;
993 if (true) {
994 set = /* @__PURE__ */ new Set();
995 }
996 function error(...messages) {
997 if (true) {
998 const messageKey = messages.join(" ");
999 if (!set.has(messageKey)) {
1000 set.add(messageKey);
1001 console.error(`Base UI: ${messageKey}`);
1002 }
1003 }
1004 }
1005
1006 // node_modules/@base-ui/utils/esm/useControlled.js
1007 function useControlled({
1008 controlled,
1009 default: defaultProp,
1010 name,
1011 state = "value"
1012 }) {
1013 const {
1014 current: isControlled
1015 } = React.useRef(controlled !== void 0);
1016 const [valueState, setValue] = React.useState(defaultProp);
1017 const value = isControlled ? controlled : valueState;
1018 if (true) {
1019 React.useEffect(() => {
1020 if (isControlled !== (controlled !== void 0)) {
1021 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"));
1022 }
1023 }, [state, name, controlled]);
1024 const {
1025 current: defaultValue2
1026 } = React.useRef(defaultProp);
1027 React.useEffect(() => {
1028 if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) {
1029 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"));
1030 }
1031 }, [defaultProp]);
1032 }
1033 const setValueIfUncontrolled = React.useCallback((newValue) => {
1034 if (!isControlled) {
1035 setValue(newValue);
1036 }
1037 }, []);
1038 return [value, setValueIfUncontrolled];
1039 }
1040 function serializeToDevModeString(input) {
1041 let nextId = 0;
1042 const seen = /* @__PURE__ */ new WeakMap();
1043 try {
1044 const result = JSON.stringify(input, function replacer(key, value) {
1045 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) {
1046 return void 0;
1047 }
1048 if (typeof value === "bigint") {
1049 return `__bigint__:${value}`;
1050 }
1051 if (value !== null && typeof value === "object") {
1052 const id = seen.get(value);
1053 if (id !== void 0) {
1054 return `__object__:${id}`;
1055 }
1056 seen.set(value, nextId);
1057 nextId += 1;
1058 }
1059 return value;
1060 });
1061 return result ?? `__top__:${typeof input}`;
1062 } catch {
1063 return "__unserializable__";
1064 }
1065 }
1066
1067 // node_modules/@base-ui/utils/esm/safeReact.js
1068 var React2 = __toESM(require_react(), 1);
1069 var SafeReact = {
1070 ...React2
1071 };
1072
1073 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1074 var React3 = __toESM(require_react(), 1);
1075 var UNINITIALIZED = {};
1076 function useRefWithInit(init2, initArg) {
1077 const ref = React3.useRef(UNINITIALIZED);
1078 if (ref.current === UNINITIALIZED) {
1079 ref.current = init2(initArg);
1080 }
1081 return ref;
1082 }
1083
1084 // node_modules/@base-ui/utils/esm/useStableCallback.js
1085 var useInsertionEffect = SafeReact.useInsertionEffect;
1086 var useSafeInsertionEffect = (
1087 // React 17 doesn't have useInsertionEffect.
1088 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1089 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1090 );
1091 function useStableCallback(callback) {
1092 const stable = useRefWithInit(createStableCallback).current;
1093 stable.next = callback;
1094 useSafeInsertionEffect(stable.effect);
1095 return stable.trampoline;
1096 }
1097 function createStableCallback() {
1098 const stable = {
1099 next: void 0,
1100 callback: assertNotCalled,
1101 trampoline: (...args) => stable.callback?.(...args),
1102 effect: () => {
1103 stable.callback = stable.next;
1104 }
1105 };
1106 return stable;
1107 }
1108 function assertNotCalled() {
1109 if (true) {
1110 throw (
1111 /* minify-error-disabled */
1112 new Error("Base UI: Cannot call an event handler while rendering.")
1113 );
1114 }
1115 }
1116
1117 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1118 var React4 = __toESM(require_react(), 1);
1119 var noop = () => {
1120 };
1121 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
1122
1123 // node_modules/@base-ui/utils/esm/warn.js
1124 var set2;
1125 if (true) {
1126 set2 = /* @__PURE__ */ new Set();
1127 }
1128 function warn(...messages) {
1129 if (true) {
1130 const messageKey = messages.join(" ");
1131 if (!set2.has(messageKey)) {
1132 set2.add(messageKey);
1133 console.warn(`Base UI: ${messageKey}`);
1134 }
1135 }
1136 }
1137
1138 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1139 var React5 = __toESM(require_react(), 1);
1140 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
1141 if (true) DirectionContext.displayName = "DirectionContext";
1142 function useDirection() {
1143 const context = React5.useContext(DirectionContext);
1144 return context?.direction ?? "ltr";
1145 }
1146
1147 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1148 var React8 = __toESM(require_react(), 1);
1149
1150 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1151 function useMergedRefs(a2, b2, c2, d2) {
1152 const forkRef = useRefWithInit(createForkRef).current;
1153 if (didChange(forkRef, a2, b2, c2, d2)) {
1154 update(forkRef, [a2, b2, c2, d2]);
1155 }
1156 return forkRef.callback;
1157 }
1158 function useMergedRefsN(refs) {
1159 const forkRef = useRefWithInit(createForkRef).current;
1160 if (didChangeN(forkRef, refs)) {
1161 update(forkRef, refs);
1162 }
1163 return forkRef.callback;
1164 }
1165 function createForkRef() {
1166 return {
1167 callback: null,
1168 cleanup: null,
1169 refs: []
1170 };
1171 }
1172 function didChange(forkRef, a2, b2, c2, d2) {
1173 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1174 }
1175 function didChangeN(forkRef, newRefs) {
1176 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1177 }
1178 function update(forkRef, refs) {
1179 forkRef.refs = refs;
1180 if (refs.every((ref) => ref == null)) {
1181 forkRef.callback = null;
1182 return;
1183 }
1184 forkRef.callback = (instance) => {
1185 if (forkRef.cleanup) {
1186 forkRef.cleanup();
1187 forkRef.cleanup = null;
1188 }
1189 if (instance != null) {
1190 const cleanupCallbacks = Array(refs.length).fill(null);
1191 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1192 const ref = refs[i2];
1193 if (ref == null) {
1194 continue;
1195 }
1196 switch (typeof ref) {
1197 case "function": {
1198 const refCleanup = ref(instance);
1199 if (typeof refCleanup === "function") {
1200 cleanupCallbacks[i2] = refCleanup;
1201 }
1202 break;
1203 }
1204 case "object": {
1205 ref.current = instance;
1206 break;
1207 }
1208 default:
1209 }
1210 }
1211 forkRef.cleanup = () => {
1212 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1213 const ref = refs[i2];
1214 if (ref == null) {
1215 continue;
1216 }
1217 switch (typeof ref) {
1218 case "function": {
1219 const cleanupCallback = cleanupCallbacks[i2];
1220 if (typeof cleanupCallback === "function") {
1221 cleanupCallback();
1222 } else {
1223 ref(null);
1224 }
1225 break;
1226 }
1227 case "object": {
1228 ref.current = null;
1229 break;
1230 }
1231 default:
1232 }
1233 }
1234 };
1235 }
1236 };
1237 }
1238
1239 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1240 var React7 = __toESM(require_react(), 1);
1241
1242 // node_modules/@base-ui/utils/esm/reactVersion.js
1243 var React6 = __toESM(require_react(), 1);
1244 var majorVersion = parseInt(React6.version, 10);
1245 function isReactVersionAtLeast(reactVersionToCheck) {
1246 return majorVersion >= reactVersionToCheck;
1247 }
1248
1249 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1250 function getReactElementRef(element) {
1251 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1252 return null;
1253 }
1254 const reactElement = element;
1255 const propsWithRef = reactElement.props;
1256 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1257 }
1258
1259 // node_modules/@base-ui/utils/esm/mergeObjects.js
1260 function mergeObjects(a2, b2) {
1261 if (a2 && !b2) {
1262 return a2;
1263 }
1264 if (!a2 && b2) {
1265 return b2;
1266 }
1267 if (a2 || b2) {
1268 return {
1269 ...a2,
1270 ...b2
1271 };
1272 }
1273 return void 0;
1274 }
1275
1276 // node_modules/@base-ui/utils/esm/empty.js
1277 function NOOP() {
1278 }
1279 var EMPTY_ARRAY = Object.freeze([]);
1280 var EMPTY_OBJECT = Object.freeze({});
1281
1282 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1283 function getStateAttributesProps(state, customMapping) {
1284 const props = {};
1285 for (const key in state) {
1286 const value = state[key];
1287 if (customMapping?.hasOwnProperty(key)) {
1288 const customProps = customMapping[key](value);
1289 if (customProps != null) {
1290 Object.assign(props, customProps);
1291 }
1292 continue;
1293 }
1294 if (value === true) {
1295 props[`data-${key.toLowerCase()}`] = "";
1296 } else if (value) {
1297 props[`data-${key.toLowerCase()}`] = value.toString();
1298 }
1299 }
1300 return props;
1301 }
1302
1303 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1304 function resolveClassName(className, state) {
1305 return typeof className === "function" ? className(state) : className;
1306 }
1307
1308 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1309 function resolveStyle(style, state) {
1310 return typeof style === "function" ? style(state) : style;
1311 }
1312
1313 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1314 var EMPTY_PROPS = {};
1315 function mergeProps(a2, b2, c2, d2, e2) {
1316 if (!c2 && !d2 && !e2 && !a2) {
1317 return createInitialMergedProps(b2);
1318 }
1319 let merged = createInitialMergedProps(a2);
1320 if (b2) {
1321 merged = mergeInto(merged, b2);
1322 }
1323 if (c2) {
1324 merged = mergeInto(merged, c2);
1325 }
1326 if (d2) {
1327 merged = mergeInto(merged, d2);
1328 }
1329 if (e2) {
1330 merged = mergeInto(merged, e2);
1331 }
1332 return merged;
1333 }
1334 function mergePropsN(props) {
1335 if (props.length === 0) {
1336 return EMPTY_PROPS;
1337 }
1338 if (props.length === 1) {
1339 return createInitialMergedProps(props[0]);
1340 }
1341 let merged = createInitialMergedProps(props[0]);
1342 for (let i2 = 1; i2 < props.length; i2 += 1) {
1343 merged = mergeInto(merged, props[i2]);
1344 }
1345 return merged;
1346 }
1347 function createInitialMergedProps(inputProps) {
1348 if (isPropsGetter(inputProps)) {
1349 return {
1350 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1351 };
1352 }
1353 return copyInitialProps(inputProps);
1354 }
1355 function mergeInto(merged, inputProps) {
1356 if (isPropsGetter(inputProps)) {
1357 return resolvePropsGetter(inputProps, merged);
1358 }
1359 return mutablyMergeInto(merged, inputProps);
1360 }
1361 function copyInitialProps(inputProps) {
1362 const copiedProps = {
1363 ...inputProps
1364 };
1365 for (const propName in copiedProps) {
1366 const propValue = copiedProps[propName];
1367 if (isEventHandler(propName, propValue)) {
1368 copiedProps[propName] = wrapEventHandler(propValue);
1369 }
1370 }
1371 return copiedProps;
1372 }
1373 function mutablyMergeInto(mergedProps, externalProps) {
1374 if (!externalProps) {
1375 return mergedProps;
1376 }
1377 for (const propName in externalProps) {
1378 const externalPropValue = externalProps[propName];
1379 switch (propName) {
1380 case "style": {
1381 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1382 break;
1383 }
1384 case "className": {
1385 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1386 break;
1387 }
1388 default: {
1389 if (isEventHandler(propName, externalPropValue)) {
1390 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1391 } else {
1392 mergedProps[propName] = externalPropValue;
1393 }
1394 }
1395 }
1396 }
1397 return mergedProps;
1398 }
1399 function isEventHandler(key, value) {
1400 const code0 = key.charCodeAt(0);
1401 const code1 = key.charCodeAt(1);
1402 const code2 = key.charCodeAt(2);
1403 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1404 }
1405 function isPropsGetter(inputProps) {
1406 return typeof inputProps === "function";
1407 }
1408 function resolvePropsGetter(inputProps, previousProps) {
1409 if (isPropsGetter(inputProps)) {
1410 return inputProps(previousProps);
1411 }
1412 return inputProps ?? EMPTY_PROPS;
1413 }
1414 function mergeEventHandlers(ourHandler, theirHandler) {
1415 if (!theirHandler) {
1416 return ourHandler;
1417 }
1418 if (!ourHandler) {
1419 return wrapEventHandler(theirHandler);
1420 }
1421 return (...args) => {
1422 const event = args[0];
1423 if (isSyntheticEvent(event)) {
1424 const baseUIEvent = event;
1425 makeEventPreventable(baseUIEvent);
1426 const result2 = theirHandler(...args);
1427 if (!baseUIEvent.baseUIHandlerPrevented) {
1428 ourHandler?.(...args);
1429 }
1430 return result2;
1431 }
1432 const result = theirHandler(...args);
1433 ourHandler?.(...args);
1434 return result;
1435 };
1436 }
1437 function wrapEventHandler(handler) {
1438 if (!handler) {
1439 return handler;
1440 }
1441 return (...args) => {
1442 const event = args[0];
1443 if (isSyntheticEvent(event)) {
1444 makeEventPreventable(event);
1445 }
1446 return handler(...args);
1447 };
1448 }
1449 function makeEventPreventable(event) {
1450 event.preventBaseUIHandler = () => {
1451 event.baseUIHandlerPrevented = true;
1452 };
1453 return event;
1454 }
1455 function mergeClassNames(ourClassName, theirClassName) {
1456 if (theirClassName) {
1457 if (ourClassName) {
1458 return theirClassName + " " + ourClassName;
1459 }
1460 return theirClassName;
1461 }
1462 return ourClassName;
1463 }
1464 function isSyntheticEvent(event) {
1465 return event != null && typeof event === "object" && "nativeEvent" in event;
1466 }
1467
1468 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1469 var import_react = __toESM(require_react(), 1);
1470 function useRenderElement(element, componentProps, params = {}) {
1471 const renderProp = componentProps.render;
1472 const outProps = useRenderElementProps(componentProps, params);
1473 if (params.enabled === false) {
1474 return null;
1475 }
1476 const state = params.state ?? EMPTY_OBJECT;
1477 return evaluateRenderProp(element, renderProp, outProps, state);
1478 }
1479 function useRenderElementProps(componentProps, params = {}) {
1480 const {
1481 className: classNameProp,
1482 style: styleProp,
1483 render: renderProp
1484 } = componentProps;
1485 const {
1486 state = EMPTY_OBJECT,
1487 ref,
1488 props,
1489 stateAttributesMapping: stateAttributesMapping4,
1490 enabled = true
1491 } = params;
1492 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1493 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1494 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping4) : EMPTY_OBJECT;
1495 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1496 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1497 if (typeof document !== "undefined") {
1498 if (!enabled) {
1499 useMergedRefs(null, null);
1500 } else if (Array.isArray(ref)) {
1501 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1502 } else {
1503 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1504 }
1505 }
1506 if (!enabled) {
1507 return EMPTY_OBJECT;
1508 }
1509 if (className !== void 0) {
1510 outProps.className = mergeClassNames(outProps.className, className);
1511 }
1512 if (style !== void 0) {
1513 outProps.style = mergeObjects(outProps.style, style);
1514 }
1515 return outProps;
1516 }
1517 function resolveRenderFunctionProps(props) {
1518 if (Array.isArray(props)) {
1519 return mergePropsN(props);
1520 }
1521 return mergeProps(void 0, props);
1522 }
1523 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1524 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1525 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1526 function evaluateRenderProp(element, render4, props, state) {
1527 if (render4) {
1528 if (typeof render4 === "function") {
1529 if (true) {
1530 warnIfRenderPropLooksLikeComponent(render4);
1531 }
1532 return render4(props, state);
1533 }
1534 const mergedProps = mergeProps(props, render4.props);
1535 mergedProps.ref = props.ref;
1536 let newElement = render4;
1537 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1538 const children = React8.Children.toArray(render4);
1539 newElement = children[0];
1540 }
1541 if (true) {
1542 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1543 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"));
1544 }
1545 }
1546 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1547 }
1548 if (element) {
1549 if (typeof element === "string") {
1550 return renderTag(element, props);
1551 }
1552 }
1553 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1554 }
1555 function warnIfRenderPropLooksLikeComponent(renderFn) {
1556 const functionName = renderFn.name;
1557 if (functionName.length === 0) {
1558 return;
1559 }
1560 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1561 return;
1562 }
1563 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1564 return;
1565 }
1566 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");
1567 }
1568 function renderTag(Tag, props) {
1569 if (Tag === "button") {
1570 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1571 type: "button",
1572 ...props,
1573 key: props.key
1574 });
1575 }
1576 if (Tag === "img") {
1577 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1578 alt: "",
1579 ...props,
1580 key: props.key
1581 });
1582 }
1583 return /* @__PURE__ */ React8.createElement(Tag, props);
1584 }
1585
1586 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1587 var reason_parts_exports = {};
1588 __export(reason_parts_exports, {
1589 cancelOpen: () => cancelOpen,
1590 chipRemovePress: () => chipRemovePress,
1591 clearPress: () => clearPress,
1592 closePress: () => closePress,
1593 closeWatcher: () => closeWatcher,
1594 decrementPress: () => decrementPress,
1595 disabled: () => disabled,
1596 drag: () => drag,
1597 escapeKey: () => escapeKey,
1598 focusOut: () => focusOut,
1599 imperativeAction: () => imperativeAction,
1600 incrementPress: () => incrementPress,
1601 initial: () => initial,
1602 inputBlur: () => inputBlur,
1603 inputChange: () => inputChange,
1604 inputClear: () => inputClear,
1605 inputPaste: () => inputPaste,
1606 inputPress: () => inputPress,
1607 itemPress: () => itemPress,
1608 keyboard: () => keyboard,
1609 linkPress: () => linkPress,
1610 listNavigation: () => listNavigation,
1611 missing: () => missing,
1612 none: () => none,
1613 outsidePress: () => outsidePress,
1614 pointer: () => pointer,
1615 scrub: () => scrub,
1616 siblingOpen: () => siblingOpen,
1617 swipe: () => swipe,
1618 trackPress: () => trackPress,
1619 triggerFocus: () => triggerFocus,
1620 triggerHover: () => triggerHover,
1621 triggerPress: () => triggerPress,
1622 wheel: () => wheel,
1623 windowResize: () => windowResize
1624 });
1625 var none = "none";
1626 var triggerPress = "trigger-press";
1627 var triggerHover = "trigger-hover";
1628 var triggerFocus = "trigger-focus";
1629 var outsidePress = "outside-press";
1630 var itemPress = "item-press";
1631 var closePress = "close-press";
1632 var linkPress = "link-press";
1633 var clearPress = "clear-press";
1634 var chipRemovePress = "chip-remove-press";
1635 var trackPress = "track-press";
1636 var incrementPress = "increment-press";
1637 var decrementPress = "decrement-press";
1638 var inputChange = "input-change";
1639 var inputClear = "input-clear";
1640 var inputBlur = "input-blur";
1641 var inputPaste = "input-paste";
1642 var inputPress = "input-press";
1643 var focusOut = "focus-out";
1644 var escapeKey = "escape-key";
1645 var closeWatcher = "close-watcher";
1646 var listNavigation = "list-navigation";
1647 var keyboard = "keyboard";
1648 var pointer = "pointer";
1649 var drag = "drag";
1650 var wheel = "wheel";
1651 var scrub = "scrub";
1652 var cancelOpen = "cancel-open";
1653 var siblingOpen = "sibling-open";
1654 var disabled = "disabled";
1655 var missing = "missing";
1656 var initial = "initial";
1657 var imperativeAction = "imperative-action";
1658 var swipe = "swipe";
1659 var windowResize = "window-resize";
1660
1661 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1662 function createChangeEventDetails(reason, event, trigger, customProperties) {
1663 let canceled = false;
1664 let allowPropagation = false;
1665 const custom = customProperties ?? EMPTY_OBJECT;
1666 const details = {
1667 reason,
1668 event: event ?? new Event("base-ui"),
1669 cancel() {
1670 canceled = true;
1671 },
1672 allowPropagation() {
1673 allowPropagation = true;
1674 },
1675 get isCanceled() {
1676 return canceled;
1677 },
1678 get isPropagationAllowed() {
1679 return allowPropagation;
1680 },
1681 trigger,
1682 ...custom
1683 };
1684 return details;
1685 }
1686
1687 // node_modules/@base-ui/utils/esm/useId.js
1688 var React9 = __toESM(require_react(), 1);
1689 var globalId = 0;
1690 function useGlobalId(idOverride, prefix = "mui") {
1691 const [defaultId, setDefaultId] = React9.useState(idOverride);
1692 const id = idOverride || defaultId;
1693 React9.useEffect(() => {
1694 if (defaultId == null) {
1695 globalId += 1;
1696 setDefaultId(`${prefix}-${globalId}`);
1697 }
1698 }, [defaultId, prefix]);
1699 return id;
1700 }
1701 var maybeReactUseId = SafeReact.useId;
1702 function useId(idOverride, prefix) {
1703 if (maybeReactUseId !== void 0) {
1704 const reactId = maybeReactUseId();
1705 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1706 }
1707 return useGlobalId(idOverride, prefix);
1708 }
1709
1710 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1711 function useBaseUiId(idOverride) {
1712 return useId(idOverride, "base-ui");
1713 }
1714
1715 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1716 var React12 = __toESM(require_react(), 1);
1717
1718 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1719 var React11 = __toESM(require_react(), 1);
1720
1721 // node_modules/@base-ui/utils/esm/useOnMount.js
1722 var React10 = __toESM(require_react(), 1);
1723 var EMPTY = [];
1724 function useOnMount(fn) {
1725 React10.useEffect(fn, EMPTY);
1726 }
1727
1728 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1729 var EMPTY2 = null;
1730 var LAST_RAF = globalThis.requestAnimationFrame;
1731 var Scheduler = class {
1732 /* This implementation uses an array as a backing data-structure for frame callbacks.
1733 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1734 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1735 * be much more efficient if there is a call pattern that alterns as
1736 * "request-cancel-request-cancel-…".
1737 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1738 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1739 callbacks = [];
1740 callbacksCount = 0;
1741 nextId = 1;
1742 startId = 1;
1743 isScheduled = false;
1744 tick = (timestamp) => {
1745 this.isScheduled = false;
1746 const currentCallbacks = this.callbacks;
1747 const currentCallbacksCount = this.callbacksCount;
1748 this.callbacks = [];
1749 this.callbacksCount = 0;
1750 this.startId = this.nextId;
1751 if (currentCallbacksCount > 0) {
1752 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1753 currentCallbacks[i2]?.(timestamp);
1754 }
1755 }
1756 };
1757 request(fn) {
1758 const id = this.nextId;
1759 this.nextId += 1;
1760 this.callbacks.push(fn);
1761 this.callbacksCount += 1;
1762 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1763 if (!this.isScheduled || didRAFChange) {
1764 requestAnimationFrame(this.tick);
1765 this.isScheduled = true;
1766 }
1767 return id;
1768 }
1769 cancel(id) {
1770 const index2 = id - this.startId;
1771 if (index2 < 0 || index2 >= this.callbacks.length) {
1772 return;
1773 }
1774 this.callbacks[index2] = null;
1775 this.callbacksCount -= 1;
1776 }
1777 };
1778 var scheduler = new Scheduler();
1779 var AnimationFrame = class _AnimationFrame {
1780 static create() {
1781 return new _AnimationFrame();
1782 }
1783 static request(fn) {
1784 return scheduler.request(fn);
1785 }
1786 static cancel(id) {
1787 return scheduler.cancel(id);
1788 }
1789 currentId = EMPTY2;
1790 /**
1791 * Executes `fn` after `delay`, clearing any previously scheduled call.
1792 */
1793 request(fn) {
1794 this.cancel();
1795 this.currentId = scheduler.request(() => {
1796 this.currentId = EMPTY2;
1797 fn();
1798 });
1799 }
1800 cancel = () => {
1801 if (this.currentId !== EMPTY2) {
1802 scheduler.cancel(this.currentId);
1803 this.currentId = EMPTY2;
1804 }
1805 };
1806 disposeEffect = () => {
1807 return this.cancel;
1808 };
1809 };
1810 function useAnimationFrame() {
1811 const timeout = useRefWithInit(AnimationFrame.create).current;
1812 useOnMount(timeout.disposeEffect);
1813 return timeout;
1814 }
1815
1816 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1817 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1818 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1819 const [mounted, setMounted] = React11.useState(open);
1820 if (open && !mounted) {
1821 setMounted(true);
1822 setTransitionStatus("starting");
1823 }
1824 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1825 setTransitionStatus("ending");
1826 }
1827 if (!open && !mounted && transitionStatus === "ending") {
1828 setTransitionStatus(void 0);
1829 }
1830 useIsoLayoutEffect(() => {
1831 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1832 const frame = AnimationFrame.request(() => {
1833 setTransitionStatus("ending");
1834 });
1835 return () => {
1836 AnimationFrame.cancel(frame);
1837 };
1838 }
1839 return void 0;
1840 }, [open, mounted, transitionStatus, deferEndingState]);
1841 useIsoLayoutEffect(() => {
1842 if (!open || enableIdleState) {
1843 return void 0;
1844 }
1845 const frame = AnimationFrame.request(() => {
1846 setTransitionStatus(void 0);
1847 });
1848 return () => {
1849 AnimationFrame.cancel(frame);
1850 };
1851 }, [enableIdleState, open]);
1852 useIsoLayoutEffect(() => {
1853 if (!open || !enableIdleState) {
1854 return void 0;
1855 }
1856 if (open && mounted && transitionStatus !== "idle") {
1857 setTransitionStatus("starting");
1858 }
1859 const frame = AnimationFrame.request(() => {
1860 setTransitionStatus("idle");
1861 });
1862 return () => {
1863 AnimationFrame.cancel(frame);
1864 };
1865 }, [enableIdleState, open, mounted, transitionStatus]);
1866 return {
1867 mounted,
1868 setMounted,
1869 transitionStatus
1870 };
1871 }
1872
1873 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1874 function useCollapsibleRoot(parameters) {
1875 const {
1876 open: openParam,
1877 defaultOpen,
1878 onOpenChange,
1879 disabled: disabled2
1880 } = parameters;
1881 const [open, setOpen] = useControlled({
1882 controlled: openParam,
1883 default: defaultOpen,
1884 name: "Collapsible",
1885 state: "open"
1886 });
1887 const {
1888 mounted,
1889 setMounted,
1890 transitionStatus
1891 } = useTransitionStatus(open, true, true);
1892 const defaultPanelId = useBaseUiId();
1893 const [panelIdState, setPanelIdState] = React12.useState();
1894 const panelId = panelIdState ?? defaultPanelId;
1895 const handleTrigger = useStableCallback((event) => {
1896 const nextOpen = !open;
1897 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent);
1898 onOpenChange(nextOpen, eventDetails);
1899 if (eventDetails.isCanceled) {
1900 return;
1901 }
1902 setOpen(nextOpen);
1903 });
1904 return React12.useMemo(() => ({
1905 disabled: disabled2,
1906 handleTrigger,
1907 mounted,
1908 open,
1909 panelId,
1910 setMounted,
1911 setOpen,
1912 setPanelIdState,
1913 transitionStatus
1914 }), [disabled2, handleTrigger, mounted, open, panelId, setMounted, setOpen, setPanelIdState, transitionStatus]);
1915 }
1916
1917 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRootContext.js
1918 var React13 = __toESM(require_react(), 1);
1919 var CollapsibleRootContext = /* @__PURE__ */ React13.createContext(void 0);
1920 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext";
1921 function useCollapsibleRootContext() {
1922 const context = React13.useContext(CollapsibleRootContext);
1923 if (context === void 0) {
1924 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15));
1925 }
1926 return context;
1927 }
1928
1929 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1930 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1931 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1932 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1933 return TransitionStatusDataAttributes2;
1934 })({});
1935 var STARTING_HOOK = {
1936 [TransitionStatusDataAttributes.startingStyle]: ""
1937 };
1938 var ENDING_HOOK = {
1939 [TransitionStatusDataAttributes.endingStyle]: ""
1940 };
1941 var transitionStatusMapping = {
1942 transitionStatus(value) {
1943 if (value === "starting") {
1944 return STARTING_HOOK;
1945 }
1946 if (value === "ending") {
1947 return ENDING_HOOK;
1948 }
1949 return null;
1950 }
1951 };
1952
1953 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelDataAttributes.js
1954 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) {
1955 CollapsiblePanelDataAttributes2["open"] = "data-open";
1956 CollapsiblePanelDataAttributes2["closed"] = "data-closed";
1957 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
1958 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
1959 return CollapsiblePanelDataAttributes2;
1960 })({});
1961
1962 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTriggerDataAttributes.js
1963 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) {
1964 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open";
1965 return CollapsibleTriggerDataAttributes2;
1966 })({});
1967
1968 // node_modules/@base-ui/react/esm/utils/collapsibleOpenStateMapping.js
1969 var PANEL_OPEN_HOOK = {
1970 [CollapsiblePanelDataAttributes.open]: ""
1971 };
1972 var PANEL_CLOSED_HOOK = {
1973 [CollapsiblePanelDataAttributes.closed]: ""
1974 };
1975 var triggerOpenStateMapping = {
1976 open(value) {
1977 if (value) {
1978 return {
1979 [CollapsibleTriggerDataAttributes.panelOpen]: ""
1980 };
1981 }
1982 return null;
1983 }
1984 };
1985 var collapsibleOpenStateMapping = {
1986 open(value) {
1987 if (value) {
1988 return PANEL_OPEN_HOOK;
1989 }
1990 return PANEL_CLOSED_HOOK;
1991 }
1992 };
1993
1994 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
1995 var React16 = __toESM(require_react(), 1);
1996
1997 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1998 function hasWindow() {
1999 return typeof window !== "undefined";
2000 }
2001 function getNodeName(node) {
2002 if (isNode(node)) {
2003 return (node.nodeName || "").toLowerCase();
2004 }
2005 return "#document";
2006 }
2007 function getWindow(node) {
2008 var _node$ownerDocument;
2009 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2010 }
2011 function getDocumentElement(node) {
2012 var _ref;
2013 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2014 }
2015 function isNode(value) {
2016 if (!hasWindow()) {
2017 return false;
2018 }
2019 return value instanceof Node || value instanceof getWindow(value).Node;
2020 }
2021 function isElement(value) {
2022 if (!hasWindow()) {
2023 return false;
2024 }
2025 return value instanceof Element || value instanceof getWindow(value).Element;
2026 }
2027 function isHTMLElement(value) {
2028 if (!hasWindow()) {
2029 return false;
2030 }
2031 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2032 }
2033 function isShadowRoot(value) {
2034 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2035 return false;
2036 }
2037 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2038 }
2039 function isOverflowElement(element) {
2040 const {
2041 overflow,
2042 overflowX,
2043 overflowY,
2044 display
2045 } = getComputedStyle2(element);
2046 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2047 }
2048 function isTableElement(element) {
2049 return /^(table|td|th)$/.test(getNodeName(element));
2050 }
2051 function isTopLayer(element) {
2052 try {
2053 if (element.matches(":popover-open")) {
2054 return true;
2055 }
2056 } catch (_e) {
2057 }
2058 try {
2059 return element.matches(":modal");
2060 } catch (_e) {
2061 return false;
2062 }
2063 }
2064 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2065 var containRe = /paint|layout|strict|content/;
2066 var isNotNone = (value) => !!value && value !== "none";
2067 var isWebKitValue;
2068 function isContainingBlock(elementOrCss) {
2069 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2070 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 || "");
2071 }
2072 function getContainingBlock(element) {
2073 let currentNode = getParentNode(element);
2074 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2075 if (isContainingBlock(currentNode)) {
2076 return currentNode;
2077 } else if (isTopLayer(currentNode)) {
2078 return null;
2079 }
2080 currentNode = getParentNode(currentNode);
2081 }
2082 return null;
2083 }
2084 function isWebKit() {
2085 if (isWebKitValue == null) {
2086 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2087 }
2088 return isWebKitValue;
2089 }
2090 function isLastTraversableNode(node) {
2091 return /^(html|body|#document)$/.test(getNodeName(node));
2092 }
2093 function getComputedStyle2(element) {
2094 return getWindow(element).getComputedStyle(element);
2095 }
2096 function getNodeScroll(element) {
2097 if (isElement(element)) {
2098 return {
2099 scrollLeft: element.scrollLeft,
2100 scrollTop: element.scrollTop
2101 };
2102 }
2103 return {
2104 scrollLeft: element.scrollX,
2105 scrollTop: element.scrollY
2106 };
2107 }
2108 function getParentNode(node) {
2109 if (getNodeName(node) === "html") {
2110 return node;
2111 }
2112 const result = (
2113 // Step into the shadow DOM of the parent of a slotted node.
2114 node.assignedSlot || // DOM Element detected.
2115 node.parentNode || // ShadowRoot detected.
2116 isShadowRoot(node) && node.host || // Fallback.
2117 getDocumentElement(node)
2118 );
2119 return isShadowRoot(result) ? result.host : result;
2120 }
2121 function getNearestOverflowAncestor(node) {
2122 const parentNode = getParentNode(node);
2123 if (isLastTraversableNode(parentNode)) {
2124 return node.ownerDocument ? node.ownerDocument.body : node.body;
2125 }
2126 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2127 return parentNode;
2128 }
2129 return getNearestOverflowAncestor(parentNode);
2130 }
2131 function getOverflowAncestors(node, list, traverseIframes) {
2132 var _node$ownerDocument2;
2133 if (list === void 0) {
2134 list = [];
2135 }
2136 if (traverseIframes === void 0) {
2137 traverseIframes = true;
2138 }
2139 const scrollableAncestor = getNearestOverflowAncestor(node);
2140 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2141 const win = getWindow(scrollableAncestor);
2142 if (isBody) {
2143 const frameElement = getFrameElement(win);
2144 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2145 } else {
2146 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2147 }
2148 }
2149 function getFrameElement(win) {
2150 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2151 }
2152
2153 // node_modules/@base-ui/react/esm/internals/composite/root/CompositeRootContext.js
2154 var React14 = __toESM(require_react(), 1);
2155 var CompositeRootContext = /* @__PURE__ */ React14.createContext(void 0);
2156 if (true) CompositeRootContext.displayName = "CompositeRootContext";
2157 function useCompositeRootContext(optional = false) {
2158 const context = React14.useContext(CompositeRootContext);
2159 if (context === void 0 && !optional) {
2160 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16));
2161 }
2162 return context;
2163 }
2164
2165 // node_modules/@base-ui/react/esm/utils/useFocusableWhenDisabled.js
2166 var React15 = __toESM(require_react(), 1);
2167 function useFocusableWhenDisabled(parameters) {
2168 const {
2169 focusableWhenDisabled,
2170 disabled: disabled2,
2171 composite = false,
2172 tabIndex: tabIndexProp = 0,
2173 isNativeButton
2174 } = parameters;
2175 const isFocusableComposite = composite && focusableWhenDisabled !== false;
2176 const isNonFocusableComposite = composite && focusableWhenDisabled === false;
2177 const props = React15.useMemo(() => {
2178 const additionalProps = {
2179 // allow Tabbing away from focusableWhenDisabled elements
2180 onKeyDown(event) {
2181 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") {
2182 event.preventDefault();
2183 }
2184 }
2185 };
2186 if (!composite) {
2187 additionalProps.tabIndex = tabIndexProp;
2188 if (!isNativeButton && disabled2) {
2189 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
2190 }
2191 }
2192 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) {
2193 additionalProps["aria-disabled"] = disabled2;
2194 }
2195 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
2196 additionalProps.disabled = disabled2;
2197 }
2198 return additionalProps;
2199 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);
2200 return {
2201 props
2202 };
2203 }
2204
2205 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
2206 function useButton(parameters = {}) {
2207 const {
2208 disabled: disabled2 = false,
2209 focusableWhenDisabled,
2210 tabIndex = 0,
2211 native: isNativeButton = true,
2212 composite: compositeProp
2213 } = parameters;
2214 const elementRef = React16.useRef(null);
2215 const compositeRootContext = useCompositeRootContext(true);
2216 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
2217 const {
2218 props: focusableWhenDisabledProps
2219 } = useFocusableWhenDisabled({
2220 focusableWhenDisabled,
2221 disabled: disabled2,
2222 composite: isCompositeItem,
2223 tabIndex,
2224 isNativeButton
2225 });
2226 if (true) {
2227 React16.useEffect(() => {
2228 if (!elementRef.current) {
2229 return;
2230 }
2231 const isButtonTag = isButtonElement(elementRef.current);
2232 if (isNativeButton) {
2233 if (!isButtonTag) {
2234 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2235 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`.";
2236 error(`${message2}${ownerStackMessage}`);
2237 }
2238 } else if (isButtonTag) {
2239 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2240 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`.";
2241 error(`${message2}${ownerStackMessage}`);
2242 }
2243 }, [isNativeButton]);
2244 }
2245 const updateDisabled = React16.useCallback(() => {
2246 const element = elementRef.current;
2247 if (!isButtonElement(element)) {
2248 return;
2249 }
2250 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
2251 element.disabled = false;
2252 }
2253 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]);
2254 useIsoLayoutEffect(updateDisabled, [updateDisabled]);
2255 const getButtonProps = React16.useCallback((externalProps = {}) => {
2256 const {
2257 onClick: externalOnClick,
2258 onMouseDown: externalOnMouseDown,
2259 onKeyUp: externalOnKeyUp,
2260 onKeyDown: externalOnKeyDown,
2261 onPointerDown: externalOnPointerDown,
2262 ...otherExternalProps
2263 } = externalProps;
2264 return mergeProps({
2265 onClick(event) {
2266 if (disabled2) {
2267 event.preventDefault();
2268 return;
2269 }
2270 externalOnClick?.(event);
2271 },
2272 onMouseDown(event) {
2273 if (!disabled2) {
2274 externalOnMouseDown?.(event);
2275 }
2276 },
2277 onKeyDown(event) {
2278 if (disabled2) {
2279 return;
2280 }
2281 makeEventPreventable(event);
2282 externalOnKeyDown?.(event);
2283 if (event.baseUIHandlerPrevented) {
2284 return;
2285 }
2286 const isCurrentTarget = event.target === event.currentTarget;
2287 const currentTarget = event.currentTarget;
2288 const isButton2 = isButtonElement(currentTarget);
2289 const isLink = !isNativeButton && isValidLinkElement(currentTarget);
2290 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink);
2291 const isEnterKey = event.key === "Enter";
2292 const isSpaceKey = event.key === " ";
2293 const role = currentTarget.getAttribute("role");
2294 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
2295 if (isCurrentTarget && isCompositeItem && isSpaceKey) {
2296 if (event.defaultPrevented && isTextNavigationRole) {
2297 return;
2298 }
2299 event.preventDefault();
2300 if (isLink || isNativeButton && isButton2) {
2301 currentTarget.click();
2302 event.preventBaseUIHandler();
2303 } else if (shouldClick) {
2304 externalOnClick?.(event);
2305 event.preventBaseUIHandler();
2306 }
2307 return;
2308 }
2309 if (shouldClick) {
2310 if (!isNativeButton && (isSpaceKey || isEnterKey)) {
2311 event.preventDefault();
2312 }
2313 if (!isNativeButton && isEnterKey) {
2314 externalOnClick?.(event);
2315 }
2316 }
2317 },
2318 onKeyUp(event) {
2319 if (disabled2) {
2320 return;
2321 }
2322 makeEventPreventable(event);
2323 externalOnKeyUp?.(event);
2324 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
2325 event.preventDefault();
2326 return;
2327 }
2328 if (event.baseUIHandlerPrevented) {
2329 return;
2330 }
2331 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") {
2332 externalOnClick?.(event);
2333 }
2334 },
2335 onPointerDown(event) {
2336 if (disabled2) {
2337 event.preventDefault();
2338 return;
2339 }
2340 externalOnPointerDown?.(event);
2341 }
2342 }, isNativeButton ? {
2343 type: "button"
2344 } : {
2345 role: "button"
2346 }, focusableWhenDisabledProps, otherExternalProps);
2347 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
2348 const buttonRef = useStableCallback((element) => {
2349 elementRef.current = element;
2350 updateDisabled();
2351 });
2352 return {
2353 getButtonProps,
2354 buttonRef
2355 };
2356 }
2357 function isButtonElement(elem) {
2358 return isHTMLElement(elem) && elem.tagName === "BUTTON";
2359 }
2360 function isValidLinkElement(elem) {
2361 return Boolean(elem?.tagName === "A" && elem?.href);
2362 }
2363
2364 // node_modules/@base-ui/utils/esm/detectBrowser.js
2365 var hasNavigator = typeof navigator !== "undefined";
2366 var nav = getNavigatorData();
2367 var platform = getPlatform();
2368 var userAgent = getUserAgent();
2369 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2370 var isIOS = (
2371 // iPads can claim to be MacIntel
2372 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2373 );
2374 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2375 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2376 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2377 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2378 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2379 var isJSDOM = userAgent.includes("jsdom/");
2380 function getNavigatorData() {
2381 if (!hasNavigator) {
2382 return {
2383 platform: "",
2384 maxTouchPoints: -1
2385 };
2386 }
2387 const uaData = navigator.userAgentData;
2388 if (uaData?.platform) {
2389 return {
2390 platform: uaData.platform,
2391 maxTouchPoints: navigator.maxTouchPoints
2392 };
2393 }
2394 return {
2395 platform: navigator.platform ?? "",
2396 maxTouchPoints: navigator.maxTouchPoints ?? -1
2397 };
2398 }
2399 function getUserAgent() {
2400 if (!hasNavigator) {
2401 return "";
2402 }
2403 const uaData = navigator.userAgentData;
2404 if (uaData && Array.isArray(uaData.brands)) {
2405 return uaData.brands.map(({
2406 brand,
2407 version: version2
2408 }) => `${brand}/${version2}`).join(" ");
2409 }
2410 return navigator.userAgent;
2411 }
2412 function getPlatform() {
2413 if (!hasNavigator) {
2414 return "";
2415 }
2416 const uaData = navigator.userAgentData;
2417 if (uaData?.platform) {
2418 return uaData.platform;
2419 }
2420 return navigator.platform ?? "";
2421 }
2422
2423 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2424 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2425 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2426
2427 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2428 function activeElement(doc) {
2429 let element = doc.activeElement;
2430 while (element?.shadowRoot?.activeElement != null) {
2431 element = element.shadowRoot.activeElement;
2432 }
2433 return element;
2434 }
2435 function contains(parent, child) {
2436 if (!parent || !child) {
2437 return false;
2438 }
2439 const rootNode = child.getRootNode?.();
2440 if (parent.contains(child)) {
2441 return true;
2442 }
2443 if (rootNode && isShadowRoot(rootNode)) {
2444 let next = child;
2445 while (next) {
2446 if (parent === next) {
2447 return true;
2448 }
2449 next = next.parentNode || next.host;
2450 }
2451 }
2452 return false;
2453 }
2454 function getTarget(event) {
2455 if ("composedPath" in event) {
2456 return event.composedPath()[0];
2457 }
2458 return event.target;
2459 }
2460
2461 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2462 function isTargetInsideEnabledTrigger(target, triggerElements) {
2463 if (!isElement(target)) {
2464 return false;
2465 }
2466 const targetElement = target;
2467 if (triggerElements.hasElement(targetElement)) {
2468 return !targetElement.hasAttribute("data-trigger-disabled");
2469 }
2470 for (const [, trigger] of triggerElements.entries()) {
2471 if (contains(trigger, targetElement)) {
2472 return !trigger.hasAttribute("data-trigger-disabled");
2473 }
2474 }
2475 return false;
2476 }
2477 function isEventTargetWithin(event, node) {
2478 if (node == null) {
2479 return false;
2480 }
2481 if ("composedPath" in event) {
2482 return event.composedPath().includes(node);
2483 }
2484 const eventAgain = event;
2485 return eventAgain.target != null && node.contains(eventAgain.target);
2486 }
2487 function isRootElement(element) {
2488 return element.matches("html,body");
2489 }
2490 function isTypeableElement(element) {
2491 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2492 }
2493 function isInteractiveElement(element) {
2494 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2495 }
2496 function matchesFocusVisible(element) {
2497 if (!element || isJSDOM) {
2498 return true;
2499 }
2500 try {
2501 return element.matches(":focus-visible");
2502 } catch (_e) {
2503 return true;
2504 }
2505 }
2506
2507 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2508 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2509 const directChildren = nodes.filter((node) => node.parentId === id);
2510 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2511 }
2512
2513 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2514 function isReactEvent(event) {
2515 return "nativeEvent" in event;
2516 }
2517 function isMouseLikePointerType(pointerType, strict) {
2518 const values = ["mouse", "pen"];
2519 if (!strict) {
2520 values.push("", void 0);
2521 }
2522 return values.includes(pointerType);
2523 }
2524 function isClickLikeEvent(event) {
2525 const type = event.type;
2526 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2527 }
2528
2529 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2530 var sides = ["top", "right", "bottom", "left"];
2531 var min = Math.min;
2532 var max = Math.max;
2533 var round = Math.round;
2534 var floor = Math.floor;
2535 var createCoords = (v2) => ({
2536 x: v2,
2537 y: v2
2538 });
2539 var oppositeSideMap = {
2540 left: "right",
2541 right: "left",
2542 bottom: "top",
2543 top: "bottom"
2544 };
2545 function clamp(start, value, end) {
2546 return max(start, min(value, end));
2547 }
2548 function evaluate(value, param) {
2549 return typeof value === "function" ? value(param) : value;
2550 }
2551 function getSide(placement) {
2552 return placement.split("-")[0];
2553 }
2554 function getAlignment(placement) {
2555 return placement.split("-")[1];
2556 }
2557 function getOppositeAxis(axis) {
2558 return axis === "x" ? "y" : "x";
2559 }
2560 function getAxisLength(axis) {
2561 return axis === "y" ? "height" : "width";
2562 }
2563 function getSideAxis(placement) {
2564 const firstChar = placement[0];
2565 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2566 }
2567 function getAlignmentAxis(placement) {
2568 return getOppositeAxis(getSideAxis(placement));
2569 }
2570 function getAlignmentSides(placement, rects, rtl) {
2571 if (rtl === void 0) {
2572 rtl = false;
2573 }
2574 const alignment = getAlignment(placement);
2575 const alignmentAxis = getAlignmentAxis(placement);
2576 const length = getAxisLength(alignmentAxis);
2577 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2578 if (rects.reference[length] > rects.floating[length]) {
2579 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2580 }
2581 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2582 }
2583 function getExpandedPlacements(placement) {
2584 const oppositePlacement = getOppositePlacement(placement);
2585 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2586 }
2587 function getOppositeAlignmentPlacement(placement) {
2588 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2589 }
2590 var lrPlacement = ["left", "right"];
2591 var rlPlacement = ["right", "left"];
2592 var tbPlacement = ["top", "bottom"];
2593 var btPlacement = ["bottom", "top"];
2594 function getSideList(side, isStart, rtl) {
2595 switch (side) {
2596 case "top":
2597 case "bottom":
2598 if (rtl) return isStart ? rlPlacement : lrPlacement;
2599 return isStart ? lrPlacement : rlPlacement;
2600 case "left":
2601 case "right":
2602 return isStart ? tbPlacement : btPlacement;
2603 default:
2604 return [];
2605 }
2606 }
2607 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2608 const alignment = getAlignment(placement);
2609 let list = getSideList(getSide(placement), direction === "start", rtl);
2610 if (alignment) {
2611 list = list.map((side) => side + "-" + alignment);
2612 if (flipAlignment) {
2613 list = list.concat(list.map(getOppositeAlignmentPlacement));
2614 }
2615 }
2616 return list;
2617 }
2618 function getOppositePlacement(placement) {
2619 const side = getSide(placement);
2620 return oppositeSideMap[side] + placement.slice(side.length);
2621 }
2622 function expandPaddingObject(padding) {
2623 return {
2624 top: 0,
2625 right: 0,
2626 bottom: 0,
2627 left: 0,
2628 ...padding
2629 };
2630 }
2631 function getPaddingObject(padding) {
2632 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2633 top: padding,
2634 right: padding,
2635 bottom: padding,
2636 left: padding
2637 };
2638 }
2639 function rectToClientRect(rect) {
2640 const {
2641 x: x2,
2642 y: y2,
2643 width,
2644 height
2645 } = rect;
2646 return {
2647 width,
2648 height,
2649 top: y2,
2650 left: x2,
2651 right: x2 + width,
2652 bottom: y2 + height,
2653 x: x2,
2654 y: y2
2655 };
2656 }
2657
2658 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2659 function isHiddenByStyles(styles) {
2660 return styles.visibility === "hidden" || styles.visibility === "collapse";
2661 }
2662 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2663 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2664 return false;
2665 }
2666 if (typeof element.checkVisibility === "function") {
2667 return element.checkVisibility();
2668 }
2669 return styles.display !== "none" && styles.display !== "contents";
2670 }
2671
2672 // node_modules/@base-ui/utils/esm/owner.js
2673 function ownerDocument(node) {
2674 return node?.ownerDocument || document;
2675 }
2676
2677 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2678 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2679 function getParentElement(element) {
2680 const assignedSlot = element.assignedSlot;
2681 if (assignedSlot) {
2682 return assignedSlot;
2683 }
2684 if (element.parentElement) {
2685 return element.parentElement;
2686 }
2687 const rootNode = element.getRootNode();
2688 return isShadowRoot(rootNode) ? rootNode.host : null;
2689 }
2690 function getDetailsSummary(details) {
2691 for (const child of Array.from(details.children)) {
2692 if (getNodeName(child) === "summary") {
2693 return child;
2694 }
2695 }
2696 return null;
2697 }
2698 function isWithinOpenDetailsSummary(element, details) {
2699 const summary = getDetailsSummary(details);
2700 return !!summary && (element === summary || contains(summary, element));
2701 }
2702 function isFocusableCandidate(element) {
2703 const nodeName = element ? getNodeName(element) : "";
2704 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");
2705 }
2706 function isFocusableElement(element) {
2707 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2708 return false;
2709 }
2710 for (let current = element; current; current = getParentElement(current)) {
2711 const isAncestor = current !== element;
2712 const isSlot = getNodeName(current) === "slot";
2713 if (current.hasAttribute("inert")) {
2714 return false;
2715 }
2716 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2717 return false;
2718 }
2719 }
2720 return true;
2721 }
2722 function isVisibleInTabbableTree(element, isAncestor) {
2723 const styles = getComputedStyle2(element);
2724 if (!isAncestor) {
2725 return isElementVisible(element, styles);
2726 }
2727 return styles.display !== "none";
2728 }
2729 function getTabIndex(element) {
2730 const tabIndex = element.tabIndex;
2731 if (tabIndex < 0) {
2732 const nodeName = getNodeName(element);
2733 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2734 return 0;
2735 }
2736 }
2737 return tabIndex;
2738 }
2739 function getNamedRadioInput(element) {
2740 if (getNodeName(element) !== "input") {
2741 return null;
2742 }
2743 const input = element;
2744 return input.type === "radio" && input.name !== "" ? input : null;
2745 }
2746 function isTabbableRadio(element, candidates) {
2747 const input = getNamedRadioInput(element);
2748 if (!input) {
2749 return true;
2750 }
2751 const checkedRadio = candidates.find((candidate) => {
2752 const radio = getNamedRadioInput(candidate);
2753 return radio?.name === input.name && radio.form === input.form && radio.checked;
2754 });
2755 if (checkedRadio) {
2756 return checkedRadio === input;
2757 }
2758 return candidates.find((candidate) => {
2759 const radio = getNamedRadioInput(candidate);
2760 return radio?.name === input.name && radio.form === input.form;
2761 }) === input;
2762 }
2763 function getComposedChildren(container) {
2764 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2765 const assignedElements = container.assignedElements({
2766 flatten: true
2767 });
2768 if (assignedElements.length > 0) {
2769 return assignedElements;
2770 }
2771 }
2772 if (isHTMLElement(container) && container.shadowRoot) {
2773 return Array.from(container.shadowRoot.children);
2774 }
2775 return Array.from(container.children);
2776 }
2777 function appendCandidates(container, list) {
2778 getComposedChildren(container).forEach((child) => {
2779 if (isFocusableCandidate(child)) {
2780 list.push(child);
2781 }
2782 appendCandidates(child, list);
2783 });
2784 }
2785 function appendMatchingElements(container, selector2, list) {
2786 getComposedChildren(container).forEach((child) => {
2787 if (isHTMLElement(child) && child.matches(selector2)) {
2788 list.push(child);
2789 }
2790 appendMatchingElements(child, selector2, list);
2791 });
2792 }
2793 function focusable(container) {
2794 const candidates = [];
2795 appendCandidates(container, candidates);
2796 return candidates.filter(isFocusableElement);
2797 }
2798 function tabbable(container) {
2799 const candidates = focusable(container);
2800 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2801 }
2802 function getTabbableIn(container, dir) {
2803 const list = tabbable(container);
2804 const len = list.length;
2805 if (len === 0) {
2806 return void 0;
2807 }
2808 const active = activeElement(ownerDocument(container));
2809 const index2 = list.indexOf(active);
2810 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2811 return list[nextIndex];
2812 }
2813 function getNextTabbable(referenceElement) {
2814 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2815 }
2816 function getPreviousTabbable(referenceElement) {
2817 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2818 }
2819 function isOutsideEvent(event, container) {
2820 const containerElement = container || event.currentTarget;
2821 const relatedTarget = event.relatedTarget;
2822 return !relatedTarget || !contains(containerElement, relatedTarget);
2823 }
2824 function disableFocusInside(container) {
2825 const tabbableElements = tabbable(container);
2826 tabbableElements.forEach((element) => {
2827 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2828 element.setAttribute("tabindex", "-1");
2829 });
2830 }
2831 function enableFocusInside(container) {
2832 const elements = [];
2833 appendMatchingElements(container, "[data-tabindex]", elements);
2834 elements.forEach((element) => {
2835 const tabindex = element.dataset.tabindex;
2836 delete element.dataset.tabindex;
2837 if (tabindex) {
2838 element.setAttribute("tabindex", tabindex);
2839 } else {
2840 element.removeAttribute("tabindex");
2841 }
2842 });
2843 }
2844
2845 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
2846 var React18 = __toESM(require_react(), 1);
2847
2848 // node_modules/@base-ui/utils/esm/addEventListener.js
2849 function addEventListener(target, type, listener, options) {
2850 target.addEventListener(type, listener, options);
2851 return () => {
2852 target.removeEventListener(type, listener, options);
2853 };
2854 }
2855
2856 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2857 function useValueAsRef(value) {
2858 const latest = useRefWithInit(createLatestRef, value).current;
2859 latest.next = value;
2860 useIsoLayoutEffect(latest.effect);
2861 return latest;
2862 }
2863 function createLatestRef(value) {
2864 const latest = {
2865 current: value,
2866 next: value,
2867 effect: () => {
2868 latest.current = latest.next;
2869 }
2870 };
2871 return latest;
2872 }
2873
2874 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2875 var React17 = __toESM(require_react(), 1);
2876
2877 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2878 var ReactDOM = __toESM(require_react_dom(), 1);
2879
2880 // node_modules/@base-ui/react/esm/utils/resolveRef.js
2881 function resolveRef(maybeRef) {
2882 if (maybeRef == null) {
2883 return maybeRef;
2884 }
2885 return "current" in maybeRef ? maybeRef.current : maybeRef;
2886 }
2887
2888 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2889 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2890 const frame = useAnimationFrame();
2891 return useStableCallback((fnToExecute, signal = null) => {
2892 frame.cancel();
2893 const element = resolveRef(elementOrRef);
2894 if (element == null) {
2895 return;
2896 }
2897 const resolvedElement = element;
2898 const done = () => {
2899 ReactDOM.flushSync(fnToExecute);
2900 };
2901 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2902 fnToExecute();
2903 return;
2904 }
2905 function exec() {
2906 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2907 if (!signal?.aborted) {
2908 done();
2909 }
2910 }).catch(() => {
2911 if (treatAbortedAsFinished) {
2912 if (!signal?.aborted) {
2913 done();
2914 }
2915 return;
2916 }
2917 const currentAnimations = resolvedElement.getAnimations();
2918 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2919 exec();
2920 }
2921 });
2922 }
2923 if (waitForStartingStyleRemoved) {
2924 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2925 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2926 frame.request(exec);
2927 return;
2928 }
2929 const attributeObserver = new MutationObserver(() => {
2930 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2931 attributeObserver.disconnect();
2932 exec();
2933 }
2934 });
2935 attributeObserver.observe(resolvedElement, {
2936 attributes: true,
2937 attributeFilter: [startingStyleAttribute]
2938 });
2939 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2940 once: true
2941 });
2942 return;
2943 }
2944 frame.request(exec);
2945 });
2946 }
2947
2948 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2949 function useOpenChangeComplete(parameters) {
2950 const {
2951 enabled = true,
2952 open,
2953 ref,
2954 onComplete: onCompleteParam
2955 } = parameters;
2956 const onComplete = useStableCallback(onCompleteParam);
2957 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2958 React17.useEffect(() => {
2959 if (!enabled) {
2960 return void 0;
2961 }
2962 const abortController = new AbortController();
2963 runOnceAnimationsFinish(onComplete, abortController.signal);
2964 return () => {
2965 abortController.abort();
2966 };
2967 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2968 }
2969
2970 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
2971 var EMPTY_DIMENSIONS = {
2972 height: void 0,
2973 width: void 0
2974 };
2975 function useCollapsiblePanel(parameters) {
2976 const {
2977 externalRef,
2978 hiddenUntilFound,
2979 id: idParam,
2980 keepMounted,
2981 mounted,
2982 onOpenChange,
2983 open,
2984 setMounted,
2985 setOpen,
2986 transitionStatus
2987 } = parameters;
2988 const panelRef = React18.useRef(null);
2989 const animationTypeRef = React18.useRef(null);
2990 const [dimensions, setDimensionsUnwrapped] = React18.useState(EMPTY_DIMENSIONS);
2991 const lastMeasuredDimensionsRef = React18.useRef(EMPTY_DIMENSIONS);
2992 const shouldSkipNextOpenRef = React18.useRef(false);
2993 const shouldPreventMountAnimationRef = React18.useRef(open);
2994 const shouldPreventActivityResumeAnimationRef = React18.useRef(false);
2995 const [forcePanelIdle, setForcePanelIdle] = React18.useState(false);
2996 const pendingTemporaryStyleRestoreRef = React18.useRef(null);
2997 const mergedPanelRef = useMergedRefs(externalRef, panelRef);
2998 const latestStateRef = useValueAsRef({
2999 mounted,
3000 open
3001 });
3002 const runOnceCloseAnimationsFinish = useAnimationsFinished(panelRef, false, false);
3003 const hidden = !open && !mounted;
3004 const panelTransitionStatus = forcePanelIdle ? "idle" : transitionStatus;
3005 const shouldPreventOpenAnimation = open && // These 2 refs are safe to read in render, they are only written from committed
3006 // layout/effect paths and gate one-shot motion suppression for the next open
3007 // lifecycle. They intentionally expose the last committed motion snapshot.
3008 (shouldPreventMountAnimationRef.current || shouldPreventActivityResumeAnimationRef.current);
3009 const renderedDimensions = !open && mounted && // These 2 refs are also safe to read in render, both hold the last committed
3010 // animation mode and measurement. This fallback only restores a previously
3011 // measured pixel size after the live dimensions state has been reset back to `auto`.
3012 animationTypeRef.current === "css-animation" && dimensions.height === void 0 && dimensions.width === void 0 ? lastMeasuredDimensionsRef.current : dimensions;
3013 const shouldPersistHiddenTransitionStyles = hiddenUntilFound && hidden && animationTypeRef.current !== "css-animation";
3014 const setDimensions = useStableCallback((nextDimensions, shouldCacheMeasurement = true) => {
3015 if (shouldCacheMeasurement) {
3016 lastMeasuredDimensionsRef.current = nextDimensions;
3017 }
3018 setDimensionsUnwrapped(nextDimensions);
3019 });
3020 const restorePendingTemporaryStyle = useStableCallback(() => {
3021 pendingTemporaryStyleRestoreRef.current?.();
3022 pendingTemporaryStyleRestoreRef.current = null;
3023 });
3024 const setPendingTemporaryStyleRestore = useStableCallback((restore) => {
3025 restorePendingTemporaryStyle();
3026 pendingTemporaryStyleRestoreRef.current = () => {
3027 pendingTemporaryStyleRestoreRef.current = null;
3028 restore();
3029 };
3030 });
3031 const markActivityResumeAnimationSuppressed = useStableCallback(() => {
3032 if (open && mounted && animationTypeRef.current === "css-animation") {
3033 shouldPreventActivityResumeAnimationRef.current = true;
3034 }
3035 });
3036 useIsoLayoutEffect(() => {
3037 if (!forcePanelIdle || transitionStatus === "starting") {
3038 return;
3039 }
3040 setForcePanelIdle(false);
3041 }, [forcePanelIdle, transitionStatus]);
3042 React18.useEffect(() => {
3043 return () => {
3044 markActivityResumeAnimationSuppressed();
3045 restorePendingTemporaryStyle();
3046 };
3047 }, [markActivityResumeAnimationSuppressed, restorePendingTemporaryStyle]);
3048 useIsoLayoutEffect(() => {
3049 const panel = panelRef.current;
3050 if (!panel) {
3051 return void 0;
3052 }
3053 if (!open && pendingTemporaryStyleRestoreRef.current) {
3054 restorePendingTemporaryStyle();
3055 }
3056 const animationType = getAnimationType(panel, shouldPreventOpenAnimation);
3057 animationTypeRef.current = animationType;
3058 if (open && transitionStatus === "idle" && shouldPreventMountAnimationRef.current && animationType === "css-animation") {
3059 lastMeasuredDimensionsRef.current = getDimensions(panel);
3060 return void 0;
3061 }
3062 if (open && transitionStatus === "starting") {
3063 const skipNextOpen = shouldSkipNextOpenRef.current;
3064 shouldSkipNextOpenRef.current = false;
3065 if (animationType === "none") {
3066 setDimensions(getDimensions(panel));
3067 setForcePanelIdle(true);
3068 return void 0;
3069 }
3070 if (animationType === "css-transition") {
3071 const restoreLayoutStyles = resetLayoutStyles(panel);
3072 setDimensions(getDimensions(panel));
3073 if (!skipNextOpen) {
3074 return restoreLayoutStyles;
3075 }
3076 const restoreTransitionDuration = setTemporaryStyle(panel, "transition-duration", "0s");
3077 setPendingTemporaryStyleRestore(restoreTransitionDuration);
3078 setForcePanelIdle(true);
3079 return restoreLayoutStyles;
3080 }
3081 if (animationType === "css-animation") {
3082 setDimensions(getDimensions(panel));
3083 if (!skipNextOpen) {
3084 const restoreAnimationName2 = setTemporaryStyle(panel, "animation-name", "none");
3085 restoreAnimationName2();
3086 return void 0;
3087 }
3088 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
3089 const restoreAnimationDuration = setTemporaryStyle(panel, "animation-duration", "0s");
3090 restoreAnimationName();
3091 setPendingTemporaryStyleRestore(restoreAnimationDuration);
3092 setForcePanelIdle(true);
3093 return void 0;
3094 }
3095 }
3096 if (!open && mounted && (transitionStatus === "idle" || transitionStatus === "starting")) {
3097 if (animationType === "none") {
3098 setDimensions(EMPTY_DIMENSIONS, false);
3099 setMounted(false);
3100 return void 0;
3101 }
3102 if (animationType === "css-animation") {
3103 shouldPreventMountAnimationRef.current = false;
3104 shouldPreventActivityResumeAnimationRef.current = false;
3105 }
3106 setDimensions(getDimensions(panel));
3107 return void 0;
3108 }
3109 if (transitionStatus !== "ending") {
3110 return void 0;
3111 }
3112 if (animationType === "none") {
3113 setMounted(false);
3114 return void 0;
3115 }
3116 const nextDimensions = getDimensions(panel);
3117 const hasMeasuredSize = (nextDimensions.height ?? 0) > 0 || (nextDimensions.width ?? 0) > 0;
3118 if (!hasMeasuredSize) {
3119 setMounted(false);
3120 return void 0;
3121 }
3122 setDimensions(nextDimensions);
3123 if (animationType === "css-animation") {
3124 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
3125 restoreAnimationName();
3126 }
3127 return void 0;
3128 }, [mounted, open, restorePendingTemporaryStyle, setDimensions, setMounted, setPendingTemporaryStyleRestore, shouldPreventOpenAnimation, transitionStatus]);
3129 useOpenChangeComplete({
3130 enabled: open && mounted && panelTransitionStatus === "idle",
3131 open: true,
3132 ref: panelRef,
3133 onComplete() {
3134 if (!open) {
3135 return;
3136 }
3137 setDimensions(EMPTY_DIMENSIONS, false);
3138 }
3139 });
3140 React18.useEffect(() => {
3141 if (open || !mounted || panelTransitionStatus !== "ending") {
3142 return void 0;
3143 }
3144 const panel = panelRef.current;
3145 if (!panel) {
3146 return void 0;
3147 }
3148 const abortController = new AbortController();
3149 let endingStyleFrame = -1;
3150 function handleComplete() {
3151 if (latestStateRef.current.open) {
3152 return;
3153 }
3154 setMounted(false);
3155 setDimensions(EMPTY_DIMENSIONS, false);
3156 }
3157 endingStyleFrame = AnimationFrame.request(() => {
3158 if (!abortController.signal.aborted) {
3159 runOnceCloseAnimationsFinish(handleComplete, abortController.signal);
3160 }
3161 });
3162 return () => {
3163 AnimationFrame.cancel(endingStyleFrame);
3164 abortController.abort();
3165 };
3166 }, [latestStateRef, mounted, open, panelTransitionStatus, runOnceCloseAnimationsFinish, setDimensions, setMounted]);
3167 useIsoLayoutEffect(() => {
3168 const panel = panelRef.current;
3169 if (!panel || !hiddenUntilFound || !hidden) {
3170 return;
3171 }
3172 panel.setAttribute("hidden", "until-found");
3173 }, [hidden, hiddenUntilFound]);
3174 React18.useEffect(function registerBeforeMatchListener() {
3175 const panel = panelRef.current;
3176 if (!panel) {
3177 return void 0;
3178 }
3179 function handleBeforeMatch(event) {
3180 shouldSkipNextOpenRef.current = true;
3181 setOpen(true);
3182 onOpenChange(true, createChangeEventDetails(reason_parts_exports.none, event));
3183 }
3184 return addEventListener(panel, "beforematch", handleBeforeMatch);
3185 }, [onOpenChange, setOpen]);
3186 const shouldRender = keepMounted || hiddenUntilFound || mounted || open;
3187 return {
3188 height: renderedDimensions.height,
3189 props: {
3190 ...shouldPersistHiddenTransitionStyles ? {
3191 [CollapsiblePanelDataAttributes.startingStyle]: ""
3192 } : void 0,
3193 hidden,
3194 id: idParam
3195 },
3196 ref: mergedPanelRef,
3197 shouldPreventOpenAnimation,
3198 shouldRender,
3199 transitionStatus: panelTransitionStatus,
3200 width: renderedDimensions.width
3201 };
3202 }
3203 function getDimensions(element) {
3204 return {
3205 height: element.scrollHeight,
3206 width: element.scrollWidth
3207 };
3208 }
3209 function getAnimationType(element, hasSuppressedMountAnimation = false) {
3210 const panelStyles = getWindow(element).getComputedStyle(element);
3211 const hasAnimation = (panelStyles.animationName.split(",").map((name) => name.trim()).some((name) => name !== "" && name !== "none") || hasSuppressedMountAnimation) && hasNonZeroDuration(panelStyles.animationDuration);
3212 const hasTransition = hasNonZeroDuration(panelStyles.transitionDuration);
3213 if (hasAnimation && hasTransition) {
3214 if (true) {
3215 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used.");
3216 }
3217 return "css-transition";
3218 }
3219 if (hasTransition) {
3220 return "css-transition";
3221 }
3222 if (hasAnimation) {
3223 return "css-animation";
3224 }
3225 return "none";
3226 }
3227 function hasNonZeroDuration(value) {
3228 return value.split(",").map((part) => part.trim()).some((part) => part !== "" && Number.parseFloat(part) > 0);
3229 }
3230 function setTemporaryStyle(element, property, value) {
3231 const previousValue = element.style.getPropertyValue(property);
3232 const previousPriority = element.style.getPropertyPriority(property);
3233 element.style.setProperty(property, value);
3234 return () => {
3235 if (previousValue === "") {
3236 element.style.removeProperty(property);
3237 return;
3238 }
3239 element.style.setProperty(property, previousValue, previousPriority);
3240 };
3241 }
3242 function resetLayoutStyles(element) {
3243 const originalLayoutStyles = {
3244 "justify-content": element.style.justifyContent,
3245 "align-items": element.style.alignItems,
3246 "align-content": element.style.alignContent,
3247 "justify-items": element.style.justifyItems
3248 };
3249 Object.keys(originalLayoutStyles).forEach((key) => {
3250 element.style.setProperty(key, "initial", "important");
3251 });
3252 function restoreLayoutStyles() {
3253 Object.entries(originalLayoutStyles).forEach(([key, value]) => {
3254 if (value === "") {
3255 element.style.removeProperty(key);
3256 return;
3257 }
3258 element.style.setProperty(key, value);
3259 });
3260 }
3261 const frame = AnimationFrame.request(restoreLayoutStyles);
3262 return () => {
3263 AnimationFrame.cancel(frame);
3264 restoreLayoutStyles();
3265 };
3266 }
3267
3268 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
3269 var React19 = __toESM(require_react(), 1);
3270 function useOnFirstRender(fn) {
3271 const ref = React19.useRef(true);
3272 if (ref.current) {
3273 ref.current = false;
3274 fn();
3275 }
3276 }
3277
3278 // node_modules/@base-ui/utils/esm/useTimeout.js
3279 var EMPTY3 = 0;
3280 var Timeout = class _Timeout {
3281 static create() {
3282 return new _Timeout();
3283 }
3284 currentId = EMPTY3;
3285 /**
3286 * Executes `fn` after `delay`, clearing any previously scheduled call.
3287 */
3288 start(delay, fn) {
3289 this.clear();
3290 this.currentId = setTimeout(() => {
3291 this.currentId = EMPTY3;
3292 fn();
3293 }, delay);
3294 }
3295 isStarted() {
3296 return this.currentId !== EMPTY3;
3297 }
3298 clear = () => {
3299 if (this.currentId !== EMPTY3) {
3300 clearTimeout(this.currentId);
3301 this.currentId = EMPTY3;
3302 }
3303 };
3304 disposeEffect = () => {
3305 return this.clear;
3306 };
3307 };
3308 function useTimeout() {
3309 const timeout = useRefWithInit(Timeout.create).current;
3310 useOnMount(timeout.disposeEffect);
3311 return timeout;
3312 }
3313
3314 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
3315 var React20 = __toESM(require_react(), 1);
3316
3317 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
3318 function resolveValue(value, pointerType) {
3319 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
3320 return 0;
3321 }
3322 if (typeof value === "function") {
3323 return value();
3324 }
3325 return value;
3326 }
3327 function getDelay(value, prop, pointerType) {
3328 const result = resolveValue(value, pointerType);
3329 if (typeof result === "number") {
3330 return result;
3331 }
3332 return result?.[prop];
3333 }
3334 function getRestMs(value) {
3335 if (typeof value === "function") {
3336 return value();
3337 }
3338 return value;
3339 }
3340 function isClickLikeOpenEvent(openEventType, interactedInside) {
3341 return interactedInside || openEventType === "click" || openEventType === "mousedown";
3342 }
3343 function isHoverOpenEvent(openEventType) {
3344 return openEventType?.includes("mouse") && openEventType !== "mousedown";
3345 }
3346
3347 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
3348 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
3349 var FloatingDelayGroupContext = /* @__PURE__ */ React20.createContext({
3350 hasProvider: false,
3351 timeoutMs: 0,
3352 delayRef: {
3353 current: 0
3354 },
3355 initialDelayRef: {
3356 current: 0
3357 },
3358 timeout: new Timeout(),
3359 currentIdRef: {
3360 current: null
3361 },
3362 currentContextRef: {
3363 current: null
3364 }
3365 });
3366 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
3367 function FloatingDelayGroup(props) {
3368 const {
3369 children,
3370 delay,
3371 timeoutMs = 0
3372 } = props;
3373 const delayRef = React20.useRef(delay);
3374 const initialDelayRef = React20.useRef(delay);
3375 const currentIdRef = React20.useRef(null);
3376 const currentContextRef = React20.useRef(null);
3377 const timeout = useTimeout();
3378 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
3379 value: React20.useMemo(() => ({
3380 hasProvider: true,
3381 delayRef,
3382 initialDelayRef,
3383 currentIdRef,
3384 timeoutMs,
3385 currentContextRef,
3386 timeout
3387 }), [timeoutMs, timeout]),
3388 children
3389 });
3390 }
3391 function useDelayGroup(context, options = {
3392 open: false
3393 }) {
3394 const {
3395 open
3396 } = options;
3397 const store = "rootStore" in context ? context.rootStore : context;
3398 const floatingId = store.useState("floatingId");
3399 const groupContext = React20.useContext(FloatingDelayGroupContext);
3400 const {
3401 currentIdRef,
3402 delayRef,
3403 timeoutMs,
3404 initialDelayRef,
3405 currentContextRef,
3406 hasProvider,
3407 timeout
3408 } = groupContext;
3409 const [isInstantPhase, setIsInstantPhase] = React20.useState(false);
3410 useIsoLayoutEffect(() => {
3411 function unset() {
3412 setIsInstantPhase(false);
3413 currentContextRef.current?.setIsInstantPhase(false);
3414 currentIdRef.current = null;
3415 currentContextRef.current = null;
3416 delayRef.current = initialDelayRef.current;
3417 }
3418 if (!currentIdRef.current) {
3419 return void 0;
3420 }
3421 if (!open && currentIdRef.current === floatingId) {
3422 setIsInstantPhase(false);
3423 if (timeoutMs) {
3424 const closingId = floatingId;
3425 timeout.start(timeoutMs, () => {
3426 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3427 return;
3428 }
3429 unset();
3430 });
3431 return () => {
3432 timeout.clear();
3433 };
3434 }
3435 unset();
3436 }
3437 return void 0;
3438 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
3439 useIsoLayoutEffect(() => {
3440 if (!open) {
3441 return;
3442 }
3443 const prevContext = currentContextRef.current;
3444 const prevId = currentIdRef.current;
3445 timeout.clear();
3446 currentContextRef.current = {
3447 onOpenChange: store.setOpen,
3448 setIsInstantPhase
3449 };
3450 currentIdRef.current = floatingId;
3451 delayRef.current = {
3452 open: 0,
3453 close: getDelay(initialDelayRef.current, "close")
3454 };
3455 if (prevId !== null && prevId !== floatingId) {
3456 setIsInstantPhase(true);
3457 prevContext?.setIsInstantPhase(true);
3458 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3459 } else {
3460 setIsInstantPhase(false);
3461 prevContext?.setIsInstantPhase(false);
3462 }
3463 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
3464 useIsoLayoutEffect(() => {
3465 return () => {
3466 currentContextRef.current = null;
3467 };
3468 }, [currentContextRef]);
3469 return React20.useMemo(() => ({
3470 hasProvider,
3471 delayRef,
3472 isInstantPhase
3473 }), [hasProvider, delayRef, isInstantPhase]);
3474 }
3475
3476 // node_modules/@base-ui/utils/esm/mergeCleanups.js
3477 function mergeCleanups(...cleanups) {
3478 return () => {
3479 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3480 const cleanup = cleanups[i2];
3481 if (cleanup) {
3482 cleanup();
3483 }
3484 }
3485 };
3486 }
3487
3488 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3489 var React21 = __toESM(require_react(), 1);
3490
3491 // node_modules/@base-ui/utils/esm/visuallyHidden.js
3492 var visuallyHiddenBase = {
3493 clipPath: "inset(50%)",
3494 overflow: "hidden",
3495 whiteSpace: "nowrap",
3496 border: 0,
3497 padding: 0,
3498 width: 1,
3499 height: 1,
3500 margin: -1
3501 };
3502 var visuallyHidden = {
3503 ...visuallyHiddenBase,
3504 position: "fixed",
3505 top: 0,
3506 left: 0
3507 };
3508 var visuallyHiddenInput = {
3509 ...visuallyHiddenBase,
3510 position: "absolute"
3511 };
3512
3513 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3514 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3515 var FocusGuard = /* @__PURE__ */ React21.forwardRef(function FocusGuard2(props, ref) {
3516 const [role, setRole] = React21.useState();
3517 useIsoLayoutEffect(() => {
3518 if (isSafari) {
3519 setRole("button");
3520 }
3521 }, []);
3522 const restProps = {
3523 tabIndex: 0,
3524 // Role is only for VoiceOver
3525 role
3526 };
3527 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
3528 ...props,
3529 ref,
3530 style: visuallyHidden,
3531 "aria-hidden": role ? void 0 : true,
3532 ...restProps,
3533 "data-base-ui-focus-guard": ""
3534 });
3535 });
3536 if (true) FocusGuard.displayName = "FocusGuard";
3537
3538 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
3539 function createAttribute(name) {
3540 return `data-base-ui-${name}`;
3541 }
3542
3543 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3544 var React22 = __toESM(require_react(), 1);
3545 var ReactDOM2 = __toESM(require_react_dom(), 1);
3546
3547 // node_modules/@base-ui/react/esm/internals/constants.js
3548 var DISABLED_TRANSITIONS_STYLE = {
3549 style: {
3550 transition: "none"
3551 }
3552 };
3553 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3554 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3555 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3556 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3557 var POPUP_COLLISION_AVOIDANCE = {
3558 fallbackAxisSide: "end"
3559 };
3560 var ownerVisuallyHidden = {
3561 clipPath: "inset(50%)",
3562 position: "fixed",
3563 top: 0,
3564 left: 0
3565 };
3566
3567 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3568 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3569 var PortalContext = /* @__PURE__ */ React22.createContext(null);
3570 if (true) PortalContext.displayName = "PortalContext";
3571 var usePortalContext = () => React22.useContext(PortalContext);
3572 var attr = createAttribute("portal");
3573 function useFloatingPortalNode(props = {}) {
3574 const {
3575 ref,
3576 container: containerProp,
3577 componentProps = EMPTY_OBJECT,
3578 elementProps
3579 } = props;
3580 const uniqueId = useId();
3581 const portalContext = usePortalContext();
3582 const parentPortalNode = portalContext?.portalNode;
3583 const [containerElement, setContainerElement] = React22.useState(null);
3584 const [portalNode, setPortalNode] = React22.useState(null);
3585 const setPortalNodeRef = useStableCallback((node) => {
3586 if (node !== null) {
3587 setPortalNode(node);
3588 }
3589 });
3590 const containerRef = React22.useRef(null);
3591 useIsoLayoutEffect(() => {
3592 if (containerProp === null) {
3593 if (containerRef.current) {
3594 containerRef.current = null;
3595 setPortalNode(null);
3596 setContainerElement(null);
3597 }
3598 return;
3599 }
3600 if (uniqueId == null) {
3601 return;
3602 }
3603 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3604 if (resolvedContainer == null) {
3605 if (containerRef.current) {
3606 containerRef.current = null;
3607 setPortalNode(null);
3608 setContainerElement(null);
3609 }
3610 return;
3611 }
3612 if (containerRef.current !== resolvedContainer) {
3613 containerRef.current = resolvedContainer;
3614 setPortalNode(null);
3615 setContainerElement(resolvedContainer);
3616 }
3617 }, [containerProp, parentPortalNode, uniqueId]);
3618 const portalElement = useRenderElement("div", componentProps, {
3619 ref: [ref, setPortalNodeRef],
3620 props: [{
3621 id: uniqueId,
3622 [attr]: ""
3623 }, elementProps]
3624 });
3625 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3626 return {
3627 portalNode,
3628 portalSubtree
3629 };
3630 }
3631 var FloatingPortal = /* @__PURE__ */ React22.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3632 const {
3633 render: render4,
3634 className,
3635 style,
3636 children,
3637 container,
3638 renderGuards,
3639 ...elementProps
3640 } = componentProps;
3641 const {
3642 portalNode,
3643 portalSubtree
3644 } = useFloatingPortalNode({
3645 container,
3646 ref: forwardedRef,
3647 componentProps,
3648 elementProps
3649 });
3650 const beforeOutsideRef = React22.useRef(null);
3651 const afterOutsideRef = React22.useRef(null);
3652 const beforeInsideRef = React22.useRef(null);
3653 const afterInsideRef = React22.useRef(null);
3654 const [focusManagerState, setFocusManagerState] = React22.useState(null);
3655 const focusInsideDisabledRef = React22.useRef(false);
3656 const modal = focusManagerState?.modal;
3657 const open = focusManagerState?.open;
3658 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3659 React22.useEffect(() => {
3660 if (!portalNode || modal) {
3661 return void 0;
3662 }
3663 function onFocus(event) {
3664 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3665 if (event.type === "focusin") {
3666 if (focusInsideDisabledRef.current) {
3667 enableFocusInside(portalNode);
3668 focusInsideDisabledRef.current = false;
3669 }
3670 } else {
3671 disableFocusInside(portalNode);
3672 focusInsideDisabledRef.current = true;
3673 }
3674 }
3675 }
3676 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3677 }, [portalNode, modal]);
3678 React22.useEffect(() => {
3679 if (!portalNode || open !== false) {
3680 return;
3681 }
3682 enableFocusInside(portalNode);
3683 focusInsideDisabledRef.current = false;
3684 }, [open, portalNode]);
3685 const portalContextValue = React22.useMemo(() => ({
3686 beforeOutsideRef,
3687 afterOutsideRef,
3688 beforeInsideRef,
3689 afterInsideRef,
3690 portalNode,
3691 setFocusManagerState
3692 }), [portalNode]);
3693 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React22.Fragment, {
3694 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
3695 value: portalContextValue,
3696 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3697 "data-type": "outside",
3698 ref: beforeOutsideRef,
3699 onFocus: (event) => {
3700 if (isOutsideEvent(event, portalNode)) {
3701 beforeInsideRef.current?.focus();
3702 } else {
3703 const domReference = focusManagerState ? focusManagerState.domReference : null;
3704 const prevTabbable = getPreviousTabbable(domReference);
3705 prevTabbable?.focus();
3706 }
3707 }
3708 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3709 "aria-owns": portalNode.id,
3710 style: ownerVisuallyHidden
3711 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3712 "data-type": "outside",
3713 ref: afterOutsideRef,
3714 onFocus: (event) => {
3715 if (isOutsideEvent(event, portalNode)) {
3716 afterInsideRef.current?.focus();
3717 } else {
3718 const domReference = focusManagerState ? focusManagerState.domReference : null;
3719 const nextTabbable = getNextTabbable(domReference);
3720 nextTabbable?.focus();
3721 if (focusManagerState?.closeOnFocusOut) {
3722 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3723 }
3724 }
3725 }
3726 })]
3727 })]
3728 });
3729 });
3730 if (true) FloatingPortal.displayName = "FloatingPortal";
3731
3732 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3733 var React23 = __toESM(require_react(), 1);
3734
3735 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3736 function createEventEmitter() {
3737 const map = /* @__PURE__ */ new Map();
3738 return {
3739 emit(event, data) {
3740 map.get(event)?.forEach((listener) => listener(data));
3741 },
3742 on(event, listener) {
3743 if (!map.has(event)) {
3744 map.set(event, /* @__PURE__ */ new Set());
3745 }
3746 map.get(event).add(listener);
3747 },
3748 off(event, listener) {
3749 map.get(event)?.delete(listener);
3750 }
3751 };
3752 }
3753
3754 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3755 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3756 var FloatingNodeContext = /* @__PURE__ */ React23.createContext(null);
3757 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3758 var FloatingTreeContext = /* @__PURE__ */ React23.createContext(null);
3759 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3760 var useFloatingParentNodeId = () => React23.useContext(FloatingNodeContext)?.id || null;
3761 var useFloatingTree = (externalTree) => {
3762 const contextTree = React23.useContext(FloatingTreeContext);
3763 return externalTree ?? contextTree;
3764 };
3765
3766 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3767 var React24 = __toESM(require_react(), 1);
3768 function createVirtualElement(domElement, data) {
3769 let offsetX = null;
3770 let offsetY = null;
3771 let isAutoUpdateEvent = false;
3772 return {
3773 contextElement: domElement || void 0,
3774 getBoundingClientRect() {
3775 const domRect = domElement?.getBoundingClientRect() || {
3776 width: 0,
3777 height: 0,
3778 x: 0,
3779 y: 0
3780 };
3781 const isXAxis = data.axis === "x" || data.axis === "both";
3782 const isYAxis = data.axis === "y" || data.axis === "both";
3783 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3784 let width = domRect.width;
3785 let height = domRect.height;
3786 let x2 = domRect.x;
3787 let y2 = domRect.y;
3788 if (offsetX == null && data.x && isXAxis) {
3789 offsetX = domRect.x - data.x;
3790 }
3791 if (offsetY == null && data.y && isYAxis) {
3792 offsetY = domRect.y - data.y;
3793 }
3794 x2 -= offsetX || 0;
3795 y2 -= offsetY || 0;
3796 width = 0;
3797 height = 0;
3798 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3799 width = data.axis === "y" ? domRect.width : 0;
3800 height = data.axis === "x" ? domRect.height : 0;
3801 x2 = isXAxis && data.x != null ? data.x : x2;
3802 y2 = isYAxis && data.y != null ? data.y : y2;
3803 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3804 height = data.axis === "x" ? domRect.height : height;
3805 width = data.axis === "y" ? domRect.width : width;
3806 }
3807 isAutoUpdateEvent = true;
3808 return {
3809 width,
3810 height,
3811 x: x2,
3812 y: y2,
3813 top: y2,
3814 right: x2 + width,
3815 bottom: y2 + height,
3816 left: x2
3817 };
3818 }
3819 };
3820 }
3821 function isMouseBasedEvent(event) {
3822 return event != null && event.clientX != null;
3823 }
3824 function useClientPoint(context, props = {}) {
3825 const {
3826 enabled = true,
3827 axis = "both"
3828 } = props;
3829 const store = "rootStore" in context ? context.rootStore : context;
3830 const open = store.useState("open");
3831 const floating = store.useState("floatingElement");
3832 const domReference = store.useState("domReferenceElement");
3833 const dataRef = store.context.dataRef;
3834 const initialRef = React24.useRef(false);
3835 const cleanupListenerRef = React24.useRef(null);
3836 const [pointerType, setPointerType] = React24.useState();
3837 const [reactive, setReactive] = React24.useState([]);
3838 const resetReference = useStableCallback((reference2) => {
3839 store.set("positionReference", reference2);
3840 });
3841 const setReference = useStableCallback((newX, newY, referenceElement) => {
3842 if (initialRef.current) {
3843 return;
3844 }
3845 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3846 return;
3847 }
3848 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3849 x: newX,
3850 y: newY,
3851 axis,
3852 dataRef,
3853 pointerType
3854 }));
3855 });
3856 const handleReferenceEnterOrMove = useStableCallback((event) => {
3857 if (!open) {
3858 setReference(event.clientX, event.clientY, event.currentTarget);
3859 } else if (!cleanupListenerRef.current) {
3860 setReference(event.clientX, event.clientY, event.currentTarget);
3861 setReactive([]);
3862 }
3863 });
3864 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3865 React24.useEffect(() => {
3866 if (!enabled) {
3867 resetReference(domReference);
3868 return void 0;
3869 }
3870 if (!openCheck) {
3871 return void 0;
3872 }
3873 function cleanupListener() {
3874 cleanupListenerRef.current?.();
3875 cleanupListenerRef.current = null;
3876 }
3877 const win = getWindow(floating);
3878 function handleMouseMove(event) {
3879 const target = getTarget(event);
3880 if (!contains(floating, target)) {
3881 setReference(event.clientX, event.clientY);
3882 } else {
3883 cleanupListener();
3884 }
3885 }
3886 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3887 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3888 } else {
3889 resetReference(domReference);
3890 }
3891 return cleanupListener;
3892 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3893 React24.useEffect(() => () => {
3894 store.set("positionReference", null);
3895 }, [store]);
3896 React24.useEffect(() => {
3897 if (enabled && !floating) {
3898 initialRef.current = false;
3899 }
3900 }, [enabled, floating]);
3901 React24.useEffect(() => {
3902 if (!enabled && open) {
3903 initialRef.current = true;
3904 }
3905 }, [enabled, open]);
3906 const reference = React24.useMemo(() => {
3907 function setPointerTypeRef(event) {
3908 setPointerType(event.pointerType);
3909 }
3910 return {
3911 onPointerDown: setPointerTypeRef,
3912 onPointerEnter: setPointerTypeRef,
3913 onMouseMove: handleReferenceEnterOrMove,
3914 onMouseEnter: handleReferenceEnterOrMove
3915 };
3916 }, [handleReferenceEnterOrMove]);
3917 return React24.useMemo(() => enabled ? {
3918 reference,
3919 trigger: reference
3920 } : {}, [enabled, reference]);
3921 }
3922
3923 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3924 var React25 = __toESM(require_react(), 1);
3925 var bubbleHandlerKeys = {
3926 intentional: "onClick",
3927 sloppy: "onPointerDown"
3928 };
3929 function alwaysFalse() {
3930 return false;
3931 }
3932 function normalizeProp(normalizable) {
3933 return {
3934 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3935 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3936 };
3937 }
3938 function useDismiss(context, props = {}) {
3939 const {
3940 enabled = true,
3941 escapeKey: escapeKey2 = true,
3942 outsidePress: outsidePressProp = true,
3943 outsidePressEvent = "sloppy",
3944 referencePress = alwaysFalse,
3945 referencePressEvent = "sloppy",
3946 bubbles,
3947 externalTree
3948 } = props;
3949 const store = "rootStore" in context ? context.rootStore : context;
3950 const open = store.useState("open");
3951 const floatingElement = store.useState("floatingElement");
3952 const {
3953 dataRef
3954 } = store.context;
3955 const tree = useFloatingTree(externalTree);
3956 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3957 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3958 const outsidePressEnabled = outsidePress2 !== false;
3959 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3960 const {
3961 escapeKey: escapeKeyBubbles,
3962 outsidePress: outsidePressBubbles
3963 } = normalizeProp(bubbles);
3964 const pressStartedInsideRef = React25.useRef(false);
3965 const pressStartPreventedRef = React25.useRef(false);
3966 const suppressNextOutsideClickRef = React25.useRef(false);
3967 const isComposingRef = React25.useRef(false);
3968 const currentPointerTypeRef = React25.useRef("");
3969 const touchStateRef = React25.useRef(null);
3970 const cancelDismissOnEndTimeout = useTimeout();
3971 const clearInsideReactTreeTimeout = useTimeout();
3972 const clearInsideReactTree = useStableCallback(() => {
3973 clearInsideReactTreeTimeout.clear();
3974 dataRef.current.insideReactTree = false;
3975 });
3976 const hasBlockingChild = useStableCallback((bubbleKey) => {
3977 const nodeId = dataRef.current.floatingContext?.nodeId;
3978 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3979 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3980 });
3981 const isEventWithinOwnElements = useStableCallback((event) => {
3982 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
3983 });
3984 const closeOnReferencePress = useStableCallback((event) => {
3985 if (!referencePress()) {
3986 return;
3987 }
3988 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3989 });
3990 const closeOnEscapeKeyDown = useStableCallback((event) => {
3991 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3992 return;
3993 }
3994 if (isComposingRef.current) {
3995 return;
3996 }
3997 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3998 return;
3999 }
4000 const native = isReactEvent(event) ? event.nativeEvent : event;
4001 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
4002 store.setOpen(false, eventDetails);
4003 if (!eventDetails.isCanceled) {
4004 event.preventDefault();
4005 }
4006 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
4007 event.stopPropagation();
4008 }
4009 });
4010 const markInsideReactTree = useStableCallback(() => {
4011 dataRef.current.insideReactTree = true;
4012 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
4013 });
4014 const markPressStartedInsideReactTree = useStableCallback((event) => {
4015 if (!open || !enabled || event.button !== 0) {
4016 return;
4017 }
4018 const target = getTarget(event.nativeEvent);
4019 if (!contains(store.select("floatingElement"), target)) {
4020 return;
4021 }
4022 if (!pressStartedInsideRef.current) {
4023 pressStartedInsideRef.current = true;
4024 pressStartPreventedRef.current = false;
4025 }
4026 });
4027 const markInsidePressStartPrevented = useStableCallback((event) => {
4028 if (!open || !enabled) {
4029 return;
4030 }
4031 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
4032 return;
4033 }
4034 if (pressStartedInsideRef.current) {
4035 pressStartPreventedRef.current = true;
4036 }
4037 });
4038 React25.useEffect(() => {
4039 if (!open || !enabled) {
4040 return void 0;
4041 }
4042 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
4043 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
4044 const compositionTimeout = new Timeout();
4045 const preventedPressSuppressionTimeout = new Timeout();
4046 function handleCompositionStart() {
4047 compositionTimeout.clear();
4048 isComposingRef.current = true;
4049 }
4050 function handleCompositionEnd() {
4051 compositionTimeout.start(
4052 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
4053 // Only apply to WebKit for the test to remain 0ms.
4054 isWebKit() ? 5 : 0,
4055 () => {
4056 isComposingRef.current = false;
4057 }
4058 );
4059 }
4060 function suppressImmediateOutsideClickAfterPreventedStart() {
4061 suppressNextOutsideClickRef.current = true;
4062 preventedPressSuppressionTimeout.start(0, () => {
4063 suppressNextOutsideClickRef.current = false;
4064 });
4065 }
4066 function resetPressStartState() {
4067 pressStartedInsideRef.current = false;
4068 pressStartPreventedRef.current = false;
4069 }
4070 function getOutsidePressEvent() {
4071 const type = currentPointerTypeRef.current;
4072 const computedType = type === "pen" || !type ? "mouse" : type;
4073 const outsidePressEventValue = getOutsidePressEventProp();
4074 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
4075 if (typeof resolved === "string") {
4076 return resolved;
4077 }
4078 return resolved[computedType];
4079 }
4080 function shouldIgnoreEvent(event) {
4081 const computedOutsidePressEvent = getOutsidePressEvent();
4082 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
4083 }
4084 function isEventWithinFloatingTree(event) {
4085 const nodeId = dataRef.current.floatingContext?.nodeId;
4086 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
4087 return isEventWithinOwnElements(event) || targetIsInsideChildren;
4088 }
4089 function closeOnPressOutside(event) {
4090 if (shouldIgnoreEvent(event)) {
4091 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
4092 preventedPressSuppressionTimeout.clear();
4093 suppressNextOutsideClickRef.current = false;
4094 }
4095 clearInsideReactTree();
4096 return;
4097 }
4098 if (dataRef.current.insideReactTree) {
4099 clearInsideReactTree();
4100 return;
4101 }
4102 const target = getTarget(event);
4103 const inertSelector = `[${createAttribute("inert")}]`;
4104 const targetRoot = isElement(target) ? target.getRootNode() : null;
4105 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
4106 const triggers = store.context.triggerElements;
4107 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
4108 return;
4109 }
4110 let targetRootAncestor = isElement(target) ? target : null;
4111 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
4112 const nextParent = getParentNode(targetRootAncestor);
4113 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
4114 break;
4115 }
4116 targetRootAncestor = nextParent;
4117 }
4118 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
4119 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
4120 // element was injected after the floating element rendered.
4121 markers.every((marker) => !contains(targetRootAncestor, marker))) {
4122 return;
4123 }
4124 if (isHTMLElement(target) && !("touches" in event)) {
4125 const lastTraversableNode = isLastTraversableNode(target);
4126 const style = getComputedStyle2(target);
4127 const scrollRe = /auto|scroll/;
4128 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
4129 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
4130 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
4131 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
4132 const isRTL7 = style.direction === "rtl";
4133 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
4134 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
4135 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
4136 return;
4137 }
4138 }
4139 if (isEventWithinFloatingTree(event)) {
4140 return;
4141 }
4142 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
4143 preventedPressSuppressionTimeout.clear();
4144 suppressNextOutsideClickRef.current = false;
4145 return;
4146 }
4147 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4148 return;
4149 }
4150 if (hasBlockingChild("__outsidePressBubbles")) {
4151 return;
4152 }
4153 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
4154 clearInsideReactTree();
4155 }
4156 function handlePointerDown(event) {
4157 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4158 return;
4159 }
4160 closeOnPressOutside(event);
4161 }
4162 function handleTouchStart(event) {
4163 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4164 return;
4165 }
4166 const touch = event.touches[0];
4167 if (touch) {
4168 touchStateRef.current = {
4169 startTime: Date.now(),
4170 startX: touch.clientX,
4171 startY: touch.clientY,
4172 dismissOnTouchEnd: false,
4173 dismissOnMouseDown: true
4174 };
4175 cancelDismissOnEndTimeout.start(1e3, () => {
4176 if (touchStateRef.current) {
4177 touchStateRef.current.dismissOnTouchEnd = false;
4178 touchStateRef.current.dismissOnMouseDown = false;
4179 }
4180 });
4181 }
4182 }
4183 function addTargetEventListenerOnce(event, listener) {
4184 const target = getTarget(event);
4185 if (!target) {
4186 return;
4187 }
4188 const unsubscribe2 = addEventListener(target, event.type, () => {
4189 listener(event);
4190 unsubscribe2();
4191 });
4192 }
4193 function handleTouchStartCapture(event) {
4194 currentPointerTypeRef.current = "touch";
4195 addTargetEventListenerOnce(event, handleTouchStart);
4196 }
4197 function closeOnPressOutsideCapture(event) {
4198 cancelDismissOnEndTimeout.clear();
4199 if (event.type === "pointerdown") {
4200 currentPointerTypeRef.current = event.pointerType;
4201 }
4202 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
4203 return;
4204 }
4205 addTargetEventListenerOnce(event, (targetEvent) => {
4206 if (targetEvent.type === "pointerdown") {
4207 handlePointerDown(targetEvent);
4208 } else {
4209 closeOnPressOutside(targetEvent);
4210 }
4211 });
4212 }
4213 function handlePressEndCapture(event) {
4214 if (!pressStartedInsideRef.current) {
4215 return;
4216 }
4217 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
4218 resetPressStartState();
4219 if (getOutsidePressEvent() !== "intentional") {
4220 return;
4221 }
4222 if (event.type === "pointercancel") {
4223 if (pressStartedInsideDefaultPrevented) {
4224 suppressImmediateOutsideClickAfterPreventedStart();
4225 }
4226 return;
4227 }
4228 if (isEventWithinFloatingTree(event)) {
4229 return;
4230 }
4231 if (pressStartedInsideDefaultPrevented) {
4232 suppressImmediateOutsideClickAfterPreventedStart();
4233 return;
4234 }
4235 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4236 return;
4237 }
4238 preventedPressSuppressionTimeout.clear();
4239 suppressNextOutsideClickRef.current = true;
4240 clearInsideReactTree();
4241 }
4242 function handleTouchMove(event) {
4243 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4244 return;
4245 }
4246 const touch = event.touches[0];
4247 if (!touch) {
4248 return;
4249 }
4250 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
4251 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
4252 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
4253 if (distance > 5) {
4254 touchStateRef.current.dismissOnTouchEnd = true;
4255 }
4256 if (distance > 10) {
4257 closeOnPressOutside(event);
4258 cancelDismissOnEndTimeout.clear();
4259 touchStateRef.current = null;
4260 }
4261 }
4262 function handleTouchMoveCapture(event) {
4263 addTargetEventListenerOnce(event, handleTouchMove);
4264 }
4265 function handleTouchEnd(event) {
4266 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4267 return;
4268 }
4269 if (touchStateRef.current.dismissOnTouchEnd) {
4270 closeOnPressOutside(event);
4271 }
4272 cancelDismissOnEndTimeout.clear();
4273 touchStateRef.current = null;
4274 }
4275 function handleTouchEndCapture(event) {
4276 addTargetEventListenerOnce(event, handleTouchEnd);
4277 }
4278 const doc = ownerDocument(floatingElement);
4279 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)));
4280 return () => {
4281 unsubscribe();
4282 compositionTimeout.clear();
4283 preventedPressSuppressionTimeout.clear();
4284 resetPressStartState();
4285 suppressNextOutsideClickRef.current = false;
4286 };
4287 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
4288 React25.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
4289 const reference = React25.useMemo(() => ({
4290 onKeyDown: closeOnEscapeKeyDown,
4291 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress,
4292 ...referencePressEvent !== "intentional" && {
4293 onClick: closeOnReferencePress
4294 }
4295 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]);
4296 const floating = React25.useMemo(() => ({
4297 onKeyDown: closeOnEscapeKeyDown,
4298 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
4299 // `onPointerDown`, such as with <NumberField.ScrubArea>.
4300 // See https://github.com/mui/base-ui/pull/3379
4301 onPointerDown: markInsidePressStartPrevented,
4302 onMouseDown: markInsidePressStartPrevented,
4303 onClickCapture: markInsideReactTree,
4304 onMouseDownCapture(event) {
4305 markInsideReactTree();
4306 markPressStartedInsideReactTree(event);
4307 },
4308 onPointerDownCapture(event) {
4309 markInsideReactTree();
4310 markPressStartedInsideReactTree(event);
4311 },
4312 onMouseUpCapture: markInsideReactTree,
4313 onTouchEndCapture: markInsideReactTree,
4314 onTouchMoveCapture: markInsideReactTree
4315 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
4316 return React25.useMemo(() => enabled ? {
4317 reference,
4318 floating,
4319 trigger: reference
4320 } : {}, [enabled, reference, floating]);
4321 }
4322
4323 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
4324 var React32 = __toESM(require_react(), 1);
4325
4326 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
4327 function computeCoordsFromPlacement(_ref, placement, rtl) {
4328 let {
4329 reference,
4330 floating
4331 } = _ref;
4332 const sideAxis = getSideAxis(placement);
4333 const alignmentAxis = getAlignmentAxis(placement);
4334 const alignLength = getAxisLength(alignmentAxis);
4335 const side = getSide(placement);
4336 const isVertical = sideAxis === "y";
4337 const commonX = reference.x + reference.width / 2 - floating.width / 2;
4338 const commonY = reference.y + reference.height / 2 - floating.height / 2;
4339 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4340 let coords;
4341 switch (side) {
4342 case "top":
4343 coords = {
4344 x: commonX,
4345 y: reference.y - floating.height
4346 };
4347 break;
4348 case "bottom":
4349 coords = {
4350 x: commonX,
4351 y: reference.y + reference.height
4352 };
4353 break;
4354 case "right":
4355 coords = {
4356 x: reference.x + reference.width,
4357 y: commonY
4358 };
4359 break;
4360 case "left":
4361 coords = {
4362 x: reference.x - floating.width,
4363 y: commonY
4364 };
4365 break;
4366 default:
4367 coords = {
4368 x: reference.x,
4369 y: reference.y
4370 };
4371 }
4372 switch (getAlignment(placement)) {
4373 case "start":
4374 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
4375 break;
4376 case "end":
4377 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
4378 break;
4379 }
4380 return coords;
4381 }
4382 async function detectOverflow(state, options) {
4383 var _await$platform$isEle;
4384 if (options === void 0) {
4385 options = {};
4386 }
4387 const {
4388 x: x2,
4389 y: y2,
4390 platform: platform3,
4391 rects,
4392 elements,
4393 strategy
4394 } = state;
4395 const {
4396 boundary = "clippingAncestors",
4397 rootBoundary = "viewport",
4398 elementContext = "floating",
4399 altBoundary = false,
4400 padding = 0
4401 } = evaluate(options, state);
4402 const paddingObject = getPaddingObject(padding);
4403 const altContext = elementContext === "floating" ? "reference" : "floating";
4404 const element = elements[altBoundary ? altContext : elementContext];
4405 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
4406 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)),
4407 boundary,
4408 rootBoundary,
4409 strategy
4410 }));
4411 const rect = elementContext === "floating" ? {
4412 x: x2,
4413 y: y2,
4414 width: rects.floating.width,
4415 height: rects.floating.height
4416 } : rects.reference;
4417 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4418 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4419 x: 1,
4420 y: 1
4421 } : {
4422 x: 1,
4423 y: 1
4424 };
4425 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4426 elements,
4427 rect,
4428 offsetParent,
4429 strategy
4430 }) : rect);
4431 return {
4432 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4433 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4434 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4435 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4436 };
4437 }
4438 var MAX_RESET_COUNT = 50;
4439 var computePosition = async (reference, floating, config) => {
4440 const {
4441 placement = "bottom",
4442 strategy = "absolute",
4443 middleware = [],
4444 platform: platform3
4445 } = config;
4446 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4447 ...platform3,
4448 detectOverflow
4449 };
4450 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4451 let rects = await platform3.getElementRects({
4452 reference,
4453 floating,
4454 strategy
4455 });
4456 let {
4457 x: x2,
4458 y: y2
4459 } = computeCoordsFromPlacement(rects, placement, rtl);
4460 let statefulPlacement = placement;
4461 let resetCount = 0;
4462 const middlewareData = {};
4463 for (let i2 = 0; i2 < middleware.length; i2++) {
4464 const currentMiddleware = middleware[i2];
4465 if (!currentMiddleware) {
4466 continue;
4467 }
4468 const {
4469 name,
4470 fn
4471 } = currentMiddleware;
4472 const {
4473 x: nextX,
4474 y: nextY,
4475 data,
4476 reset
4477 } = await fn({
4478 x: x2,
4479 y: y2,
4480 initialPlacement: placement,
4481 placement: statefulPlacement,
4482 strategy,
4483 middlewareData,
4484 rects,
4485 platform: platformWithDetectOverflow,
4486 elements: {
4487 reference,
4488 floating
4489 }
4490 });
4491 x2 = nextX != null ? nextX : x2;
4492 y2 = nextY != null ? nextY : y2;
4493 middlewareData[name] = {
4494 ...middlewareData[name],
4495 ...data
4496 };
4497 if (reset && resetCount < MAX_RESET_COUNT) {
4498 resetCount++;
4499 if (typeof reset === "object") {
4500 if (reset.placement) {
4501 statefulPlacement = reset.placement;
4502 }
4503 if (reset.rects) {
4504 rects = reset.rects === true ? await platform3.getElementRects({
4505 reference,
4506 floating,
4507 strategy
4508 }) : reset.rects;
4509 }
4510 ({
4511 x: x2,
4512 y: y2
4513 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4514 }
4515 i2 = -1;
4516 }
4517 }
4518 return {
4519 x: x2,
4520 y: y2,
4521 placement: statefulPlacement,
4522 strategy,
4523 middlewareData
4524 };
4525 };
4526 var flip = function(options) {
4527 if (options === void 0) {
4528 options = {};
4529 }
4530 return {
4531 name: "flip",
4532 options,
4533 async fn(state) {
4534 var _middlewareData$arrow, _middlewareData$flip;
4535 const {
4536 placement,
4537 middlewareData,
4538 rects,
4539 initialPlacement,
4540 platform: platform3,
4541 elements
4542 } = state;
4543 const {
4544 mainAxis: checkMainAxis = true,
4545 crossAxis: checkCrossAxis = true,
4546 fallbackPlacements: specifiedFallbackPlacements,
4547 fallbackStrategy = "bestFit",
4548 fallbackAxisSideDirection = "none",
4549 flipAlignment = true,
4550 ...detectOverflowOptions
4551 } = evaluate(options, state);
4552 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4553 return {};
4554 }
4555 const side = getSide(placement);
4556 const initialSideAxis = getSideAxis(initialPlacement);
4557 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4558 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4559 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4560 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4561 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4562 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4563 }
4564 const placements2 = [initialPlacement, ...fallbackPlacements];
4565 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4566 const overflows = [];
4567 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4568 if (checkMainAxis) {
4569 overflows.push(overflow[side]);
4570 }
4571 if (checkCrossAxis) {
4572 const sides2 = getAlignmentSides(placement, rects, rtl);
4573 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4574 }
4575 overflowsData = [...overflowsData, {
4576 placement,
4577 overflows
4578 }];
4579 if (!overflows.every((side2) => side2 <= 0)) {
4580 var _middlewareData$flip2, _overflowsData$filter;
4581 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4582 const nextPlacement = placements2[nextIndex];
4583 if (nextPlacement) {
4584 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4585 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4586 // overflows the main axis.
4587 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4588 return {
4589 data: {
4590 index: nextIndex,
4591 overflows: overflowsData
4592 },
4593 reset: {
4594 placement: nextPlacement
4595 }
4596 };
4597 }
4598 }
4599 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;
4600 if (!resetPlacement) {
4601 switch (fallbackStrategy) {
4602 case "bestFit": {
4603 var _overflowsData$filter2;
4604 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4605 if (hasFallbackAxisSideDirection) {
4606 const currentSideAxis = getSideAxis(d2.placement);
4607 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4608 // reading directions favoring greater width.
4609 currentSideAxis === "y";
4610 }
4611 return true;
4612 }).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];
4613 if (placement2) {
4614 resetPlacement = placement2;
4615 }
4616 break;
4617 }
4618 case "initialPlacement":
4619 resetPlacement = initialPlacement;
4620 break;
4621 }
4622 }
4623 if (placement !== resetPlacement) {
4624 return {
4625 reset: {
4626 placement: resetPlacement
4627 }
4628 };
4629 }
4630 }
4631 return {};
4632 }
4633 };
4634 };
4635 function getSideOffsets(overflow, rect) {
4636 return {
4637 top: overflow.top - rect.height,
4638 right: overflow.right - rect.width,
4639 bottom: overflow.bottom - rect.height,
4640 left: overflow.left - rect.width
4641 };
4642 }
4643 function isAnySideFullyClipped(overflow) {
4644 return sides.some((side) => overflow[side] >= 0);
4645 }
4646 var hide = function(options) {
4647 if (options === void 0) {
4648 options = {};
4649 }
4650 return {
4651 name: "hide",
4652 options,
4653 async fn(state) {
4654 const {
4655 rects,
4656 platform: platform3
4657 } = state;
4658 const {
4659 strategy = "referenceHidden",
4660 ...detectOverflowOptions
4661 } = evaluate(options, state);
4662 switch (strategy) {
4663 case "referenceHidden": {
4664 const overflow = await platform3.detectOverflow(state, {
4665 ...detectOverflowOptions,
4666 elementContext: "reference"
4667 });
4668 const offsets = getSideOffsets(overflow, rects.reference);
4669 return {
4670 data: {
4671 referenceHiddenOffsets: offsets,
4672 referenceHidden: isAnySideFullyClipped(offsets)
4673 }
4674 };
4675 }
4676 case "escaped": {
4677 const overflow = await platform3.detectOverflow(state, {
4678 ...detectOverflowOptions,
4679 altBoundary: true
4680 });
4681 const offsets = getSideOffsets(overflow, rects.floating);
4682 return {
4683 data: {
4684 escapedOffsets: offsets,
4685 escaped: isAnySideFullyClipped(offsets)
4686 }
4687 };
4688 }
4689 default: {
4690 return {};
4691 }
4692 }
4693 }
4694 };
4695 };
4696 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4697 async function convertValueToCoords(state, options) {
4698 const {
4699 placement,
4700 platform: platform3,
4701 elements
4702 } = state;
4703 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4704 const side = getSide(placement);
4705 const alignment = getAlignment(placement);
4706 const isVertical = getSideAxis(placement) === "y";
4707 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4708 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4709 const rawValue = evaluate(options, state);
4710 let {
4711 mainAxis,
4712 crossAxis,
4713 alignmentAxis
4714 } = typeof rawValue === "number" ? {
4715 mainAxis: rawValue,
4716 crossAxis: 0,
4717 alignmentAxis: null
4718 } : {
4719 mainAxis: rawValue.mainAxis || 0,
4720 crossAxis: rawValue.crossAxis || 0,
4721 alignmentAxis: rawValue.alignmentAxis
4722 };
4723 if (alignment && typeof alignmentAxis === "number") {
4724 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4725 }
4726 return isVertical ? {
4727 x: crossAxis * crossAxisMulti,
4728 y: mainAxis * mainAxisMulti
4729 } : {
4730 x: mainAxis * mainAxisMulti,
4731 y: crossAxis * crossAxisMulti
4732 };
4733 }
4734 var offset = function(options) {
4735 if (options === void 0) {
4736 options = 0;
4737 }
4738 return {
4739 name: "offset",
4740 options,
4741 async fn(state) {
4742 var _middlewareData$offse, _middlewareData$arrow;
4743 const {
4744 x: x2,
4745 y: y2,
4746 placement,
4747 middlewareData
4748 } = state;
4749 const diffCoords = await convertValueToCoords(state, options);
4750 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4751 return {};
4752 }
4753 return {
4754 x: x2 + diffCoords.x,
4755 y: y2 + diffCoords.y,
4756 data: {
4757 ...diffCoords,
4758 placement
4759 }
4760 };
4761 }
4762 };
4763 };
4764 var shift = function(options) {
4765 if (options === void 0) {
4766 options = {};
4767 }
4768 return {
4769 name: "shift",
4770 options,
4771 async fn(state) {
4772 const {
4773 x: x2,
4774 y: y2,
4775 placement,
4776 platform: platform3
4777 } = state;
4778 const {
4779 mainAxis: checkMainAxis = true,
4780 crossAxis: checkCrossAxis = false,
4781 limiter = {
4782 fn: (_ref) => {
4783 let {
4784 x: x3,
4785 y: y3
4786 } = _ref;
4787 return {
4788 x: x3,
4789 y: y3
4790 };
4791 }
4792 },
4793 ...detectOverflowOptions
4794 } = evaluate(options, state);
4795 const coords = {
4796 x: x2,
4797 y: y2
4798 };
4799 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4800 const crossAxis = getSideAxis(getSide(placement));
4801 const mainAxis = getOppositeAxis(crossAxis);
4802 let mainAxisCoord = coords[mainAxis];
4803 let crossAxisCoord = coords[crossAxis];
4804 if (checkMainAxis) {
4805 const minSide = mainAxis === "y" ? "top" : "left";
4806 const maxSide = mainAxis === "y" ? "bottom" : "right";
4807 const min2 = mainAxisCoord + overflow[minSide];
4808 const max2 = mainAxisCoord - overflow[maxSide];
4809 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4810 }
4811 if (checkCrossAxis) {
4812 const minSide = crossAxis === "y" ? "top" : "left";
4813 const maxSide = crossAxis === "y" ? "bottom" : "right";
4814 const min2 = crossAxisCoord + overflow[minSide];
4815 const max2 = crossAxisCoord - overflow[maxSide];
4816 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4817 }
4818 const limitedCoords = limiter.fn({
4819 ...state,
4820 [mainAxis]: mainAxisCoord,
4821 [crossAxis]: crossAxisCoord
4822 });
4823 return {
4824 ...limitedCoords,
4825 data: {
4826 x: limitedCoords.x - x2,
4827 y: limitedCoords.y - y2,
4828 enabled: {
4829 [mainAxis]: checkMainAxis,
4830 [crossAxis]: checkCrossAxis
4831 }
4832 }
4833 };
4834 }
4835 };
4836 };
4837 var limitShift = function(options) {
4838 if (options === void 0) {
4839 options = {};
4840 }
4841 return {
4842 options,
4843 fn(state) {
4844 const {
4845 x: x2,
4846 y: y2,
4847 placement,
4848 rects,
4849 middlewareData
4850 } = state;
4851 const {
4852 offset: offset4 = 0,
4853 mainAxis: checkMainAxis = true,
4854 crossAxis: checkCrossAxis = true
4855 } = evaluate(options, state);
4856 const coords = {
4857 x: x2,
4858 y: y2
4859 };
4860 const crossAxis = getSideAxis(placement);
4861 const mainAxis = getOppositeAxis(crossAxis);
4862 let mainAxisCoord = coords[mainAxis];
4863 let crossAxisCoord = coords[crossAxis];
4864 const rawOffset = evaluate(offset4, state);
4865 const computedOffset = typeof rawOffset === "number" ? {
4866 mainAxis: rawOffset,
4867 crossAxis: 0
4868 } : {
4869 mainAxis: 0,
4870 crossAxis: 0,
4871 ...rawOffset
4872 };
4873 if (checkMainAxis) {
4874 const len = mainAxis === "y" ? "height" : "width";
4875 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4876 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4877 if (mainAxisCoord < limitMin) {
4878 mainAxisCoord = limitMin;
4879 } else if (mainAxisCoord > limitMax) {
4880 mainAxisCoord = limitMax;
4881 }
4882 }
4883 if (checkCrossAxis) {
4884 var _middlewareData$offse, _middlewareData$offse2;
4885 const len = mainAxis === "y" ? "width" : "height";
4886 const isOriginSide = originSides.has(getSide(placement));
4887 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);
4888 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);
4889 if (crossAxisCoord < limitMin) {
4890 crossAxisCoord = limitMin;
4891 } else if (crossAxisCoord > limitMax) {
4892 crossAxisCoord = limitMax;
4893 }
4894 }
4895 return {
4896 [mainAxis]: mainAxisCoord,
4897 [crossAxis]: crossAxisCoord
4898 };
4899 }
4900 };
4901 };
4902 var size = function(options) {
4903 if (options === void 0) {
4904 options = {};
4905 }
4906 return {
4907 name: "size",
4908 options,
4909 async fn(state) {
4910 var _state$middlewareData, _state$middlewareData2;
4911 const {
4912 placement,
4913 rects,
4914 platform: platform3,
4915 elements
4916 } = state;
4917 const {
4918 apply = () => {
4919 },
4920 ...detectOverflowOptions
4921 } = evaluate(options, state);
4922 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4923 const side = getSide(placement);
4924 const alignment = getAlignment(placement);
4925 const isYAxis = getSideAxis(placement) === "y";
4926 const {
4927 width,
4928 height
4929 } = rects.floating;
4930 let heightSide;
4931 let widthSide;
4932 if (side === "top" || side === "bottom") {
4933 heightSide = side;
4934 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4935 } else {
4936 widthSide = side;
4937 heightSide = alignment === "end" ? "top" : "bottom";
4938 }
4939 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4940 const maximumClippingWidth = width - overflow.left - overflow.right;
4941 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4942 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4943 const noShift = !state.middlewareData.shift;
4944 let availableHeight = overflowAvailableHeight;
4945 let availableWidth = overflowAvailableWidth;
4946 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4947 availableWidth = maximumClippingWidth;
4948 }
4949 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4950 availableHeight = maximumClippingHeight;
4951 }
4952 if (noShift && !alignment) {
4953 const xMin = max(overflow.left, 0);
4954 const xMax = max(overflow.right, 0);
4955 const yMin = max(overflow.top, 0);
4956 const yMax = max(overflow.bottom, 0);
4957 if (isYAxis) {
4958 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4959 } else {
4960 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4961 }
4962 }
4963 await apply({
4964 ...state,
4965 availableWidth,
4966 availableHeight
4967 });
4968 const nextDimensions = await platform3.getDimensions(elements.floating);
4969 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4970 return {
4971 reset: {
4972 rects: true
4973 }
4974 };
4975 }
4976 return {};
4977 }
4978 };
4979 };
4980
4981 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4982 function getCssDimensions(element) {
4983 const css = getComputedStyle2(element);
4984 let width = parseFloat(css.width) || 0;
4985 let height = parseFloat(css.height) || 0;
4986 const hasOffset = isHTMLElement(element);
4987 const offsetWidth = hasOffset ? element.offsetWidth : width;
4988 const offsetHeight = hasOffset ? element.offsetHeight : height;
4989 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4990 if (shouldFallback) {
4991 width = offsetWidth;
4992 height = offsetHeight;
4993 }
4994 return {
4995 width,
4996 height,
4997 $: shouldFallback
4998 };
4999 }
5000 function unwrapElement(element) {
5001 return !isElement(element) ? element.contextElement : element;
5002 }
5003 function getScale(element) {
5004 const domElement = unwrapElement(element);
5005 if (!isHTMLElement(domElement)) {
5006 return createCoords(1);
5007 }
5008 const rect = domElement.getBoundingClientRect();
5009 const {
5010 width,
5011 height,
5012 $: $2
5013 } = getCssDimensions(domElement);
5014 let x2 = ($2 ? round(rect.width) : rect.width) / width;
5015 let y2 = ($2 ? round(rect.height) : rect.height) / height;
5016 if (!x2 || !Number.isFinite(x2)) {
5017 x2 = 1;
5018 }
5019 if (!y2 || !Number.isFinite(y2)) {
5020 y2 = 1;
5021 }
5022 return {
5023 x: x2,
5024 y: y2
5025 };
5026 }
5027 var noOffsets = /* @__PURE__ */ createCoords(0);
5028 function getVisualOffsets(element) {
5029 const win = getWindow(element);
5030 if (!isWebKit() || !win.visualViewport) {
5031 return noOffsets;
5032 }
5033 return {
5034 x: win.visualViewport.offsetLeft,
5035 y: win.visualViewport.offsetTop
5036 };
5037 }
5038 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
5039 if (isFixed === void 0) {
5040 isFixed = false;
5041 }
5042 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
5043 return false;
5044 }
5045 return isFixed;
5046 }
5047 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5048 if (includeScale === void 0) {
5049 includeScale = false;
5050 }
5051 if (isFixedStrategy === void 0) {
5052 isFixedStrategy = false;
5053 }
5054 const clientRect = element.getBoundingClientRect();
5055 const domElement = unwrapElement(element);
5056 let scale = createCoords(1);
5057 if (includeScale) {
5058 if (offsetParent) {
5059 if (isElement(offsetParent)) {
5060 scale = getScale(offsetParent);
5061 }
5062 } else {
5063 scale = getScale(element);
5064 }
5065 }
5066 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5067 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
5068 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
5069 let width = clientRect.width / scale.x;
5070 let height = clientRect.height / scale.y;
5071 if (domElement) {
5072 const win = getWindow(domElement);
5073 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5074 let currentWin = win;
5075 let currentIFrame = getFrameElement(currentWin);
5076 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5077 const iframeScale = getScale(currentIFrame);
5078 const iframeRect = currentIFrame.getBoundingClientRect();
5079 const css = getComputedStyle2(currentIFrame);
5080 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5081 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5082 x2 *= iframeScale.x;
5083 y2 *= iframeScale.y;
5084 width *= iframeScale.x;
5085 height *= iframeScale.y;
5086 x2 += left;
5087 y2 += top;
5088 currentWin = getWindow(currentIFrame);
5089 currentIFrame = getFrameElement(currentWin);
5090 }
5091 }
5092 return rectToClientRect({
5093 width,
5094 height,
5095 x: x2,
5096 y: y2
5097 });
5098 }
5099 function getWindowScrollBarX(element, rect) {
5100 const leftScroll = getNodeScroll(element).scrollLeft;
5101 if (!rect) {
5102 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5103 }
5104 return rect.left + leftScroll;
5105 }
5106 function getHTMLOffset(documentElement, scroll) {
5107 const htmlRect = documentElement.getBoundingClientRect();
5108 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5109 const y2 = htmlRect.top + scroll.scrollTop;
5110 return {
5111 x: x2,
5112 y: y2
5113 };
5114 }
5115 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5116 let {
5117 elements,
5118 rect,
5119 offsetParent,
5120 strategy
5121 } = _ref;
5122 const isFixed = strategy === "fixed";
5123 const documentElement = getDocumentElement(offsetParent);
5124 const topLayer = elements ? isTopLayer(elements.floating) : false;
5125 if (offsetParent === documentElement || topLayer && isFixed) {
5126 return rect;
5127 }
5128 let scroll = {
5129 scrollLeft: 0,
5130 scrollTop: 0
5131 };
5132 let scale = createCoords(1);
5133 const offsets = createCoords(0);
5134 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5135 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5136 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5137 scroll = getNodeScroll(offsetParent);
5138 }
5139 if (isOffsetParentAnElement) {
5140 const offsetRect = getBoundingClientRect(offsetParent);
5141 scale = getScale(offsetParent);
5142 offsets.x = offsetRect.x + offsetParent.clientLeft;
5143 offsets.y = offsetRect.y + offsetParent.clientTop;
5144 }
5145 }
5146 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5147 return {
5148 width: rect.width * scale.x,
5149 height: rect.height * scale.y,
5150 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5151 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5152 };
5153 }
5154 function getClientRects(element) {
5155 return Array.from(element.getClientRects());
5156 }
5157 function getDocumentRect(element) {
5158 const html = getDocumentElement(element);
5159 const scroll = getNodeScroll(element);
5160 const body = element.ownerDocument.body;
5161 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5162 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5163 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
5164 const y2 = -scroll.scrollTop;
5165 if (getComputedStyle2(body).direction === "rtl") {
5166 x2 += max(html.clientWidth, body.clientWidth) - width;
5167 }
5168 return {
5169 width,
5170 height,
5171 x: x2,
5172 y: y2
5173 };
5174 }
5175 var SCROLLBAR_MAX = 25;
5176 function getViewportRect(element, strategy) {
5177 const win = getWindow(element);
5178 const html = getDocumentElement(element);
5179 const visualViewport = win.visualViewport;
5180 let width = html.clientWidth;
5181 let height = html.clientHeight;
5182 let x2 = 0;
5183 let y2 = 0;
5184 if (visualViewport) {
5185 width = visualViewport.width;
5186 height = visualViewport.height;
5187 const visualViewportBased = isWebKit();
5188 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
5189 x2 = visualViewport.offsetLeft;
5190 y2 = visualViewport.offsetTop;
5191 }
5192 }
5193 const windowScrollbarX = getWindowScrollBarX(html);
5194 if (windowScrollbarX <= 0) {
5195 const doc = html.ownerDocument;
5196 const body = doc.body;
5197 const bodyStyles = getComputedStyle(body);
5198 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5199 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5200 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5201 width -= clippingStableScrollbarWidth;
5202 }
5203 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5204 width += windowScrollbarX;
5205 }
5206 return {
5207 width,
5208 height,
5209 x: x2,
5210 y: y2
5211 };
5212 }
5213 function getInnerBoundingClientRect(element, strategy) {
5214 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5215 const top = clientRect.top + element.clientTop;
5216 const left = clientRect.left + element.clientLeft;
5217 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5218 const width = element.clientWidth * scale.x;
5219 const height = element.clientHeight * scale.y;
5220 const x2 = left * scale.x;
5221 const y2 = top * scale.y;
5222 return {
5223 width,
5224 height,
5225 x: x2,
5226 y: y2
5227 };
5228 }
5229 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5230 let rect;
5231 if (clippingAncestor === "viewport") {
5232 rect = getViewportRect(element, strategy);
5233 } else if (clippingAncestor === "document") {
5234 rect = getDocumentRect(getDocumentElement(element));
5235 } else if (isElement(clippingAncestor)) {
5236 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5237 } else {
5238 const visualOffsets = getVisualOffsets(element);
5239 rect = {
5240 x: clippingAncestor.x - visualOffsets.x,
5241 y: clippingAncestor.y - visualOffsets.y,
5242 width: clippingAncestor.width,
5243 height: clippingAncestor.height
5244 };
5245 }
5246 return rectToClientRect(rect);
5247 }
5248 function hasFixedPositionAncestor(element, stopNode) {
5249 const parentNode = getParentNode(element);
5250 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5251 return false;
5252 }
5253 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
5254 }
5255 function getClippingElementAncestors(element, cache) {
5256 const cachedResult = cache.get(element);
5257 if (cachedResult) {
5258 return cachedResult;
5259 }
5260 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5261 let currentContainingBlockComputedStyle = null;
5262 const elementIsFixed = getComputedStyle2(element).position === "fixed";
5263 let currentNode = elementIsFixed ? getParentNode(element) : element;
5264 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5265 const computedStyle = getComputedStyle2(currentNode);
5266 const currentNodeIsContaining = isContainingBlock(currentNode);
5267 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
5268 currentContainingBlockComputedStyle = null;
5269 }
5270 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5271 if (shouldDropCurrentNode) {
5272 result = result.filter((ancestor) => ancestor !== currentNode);
5273 } else {
5274 currentContainingBlockComputedStyle = computedStyle;
5275 }
5276 currentNode = getParentNode(currentNode);
5277 }
5278 cache.set(element, result);
5279 return result;
5280 }
5281 function getClippingRect(_ref) {
5282 let {
5283 element,
5284 boundary,
5285 rootBoundary,
5286 strategy
5287 } = _ref;
5288 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5289 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5290 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
5291 let top = firstRect.top;
5292 let right = firstRect.right;
5293 let bottom = firstRect.bottom;
5294 let left = firstRect.left;
5295 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
5296 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
5297 top = max(rect.top, top);
5298 right = min(rect.right, right);
5299 bottom = min(rect.bottom, bottom);
5300 left = max(rect.left, left);
5301 }
5302 return {
5303 width: right - left,
5304 height: bottom - top,
5305 x: left,
5306 y: top
5307 };
5308 }
5309 function getDimensions2(element) {
5310 const {
5311 width,
5312 height
5313 } = getCssDimensions(element);
5314 return {
5315 width,
5316 height
5317 };
5318 }
5319 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5320 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5321 const documentElement = getDocumentElement(offsetParent);
5322 const isFixed = strategy === "fixed";
5323 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5324 let scroll = {
5325 scrollLeft: 0,
5326 scrollTop: 0
5327 };
5328 const offsets = createCoords(0);
5329 function setLeftRTLScrollbarOffset() {
5330 offsets.x = getWindowScrollBarX(documentElement);
5331 }
5332 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5333 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5334 scroll = getNodeScroll(offsetParent);
5335 }
5336 if (isOffsetParentAnElement) {
5337 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5338 offsets.x = offsetRect.x + offsetParent.clientLeft;
5339 offsets.y = offsetRect.y + offsetParent.clientTop;
5340 } else if (documentElement) {
5341 setLeftRTLScrollbarOffset();
5342 }
5343 }
5344 if (isFixed && !isOffsetParentAnElement && documentElement) {
5345 setLeftRTLScrollbarOffset();
5346 }
5347 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5348 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5349 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5350 return {
5351 x: x2,
5352 y: y2,
5353 width: rect.width,
5354 height: rect.height
5355 };
5356 }
5357 function isStaticPositioned(element) {
5358 return getComputedStyle2(element).position === "static";
5359 }
5360 function getTrueOffsetParent(element, polyfill) {
5361 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
5362 return null;
5363 }
5364 if (polyfill) {
5365 return polyfill(element);
5366 }
5367 let rawOffsetParent = element.offsetParent;
5368 if (getDocumentElement(element) === rawOffsetParent) {
5369 rawOffsetParent = rawOffsetParent.ownerDocument.body;
5370 }
5371 return rawOffsetParent;
5372 }
5373 function getOffsetParent(element, polyfill) {
5374 const win = getWindow(element);
5375 if (isTopLayer(element)) {
5376 return win;
5377 }
5378 if (!isHTMLElement(element)) {
5379 let svgOffsetParent = getParentNode(element);
5380 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5381 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5382 return svgOffsetParent;
5383 }
5384 svgOffsetParent = getParentNode(svgOffsetParent);
5385 }
5386 return win;
5387 }
5388 let offsetParent = getTrueOffsetParent(element, polyfill);
5389 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5390 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5391 }
5392 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5393 return win;
5394 }
5395 return offsetParent || getContainingBlock(element) || win;
5396 }
5397 var getElementRects = async function(data) {
5398 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5399 const getDimensionsFn = this.getDimensions;
5400 const floatingDimensions = await getDimensionsFn(data.floating);
5401 return {
5402 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5403 floating: {
5404 x: 0,
5405 y: 0,
5406 width: floatingDimensions.width,
5407 height: floatingDimensions.height
5408 }
5409 };
5410 };
5411 function isRTL(element) {
5412 return getComputedStyle2(element).direction === "rtl";
5413 }
5414 var platform2 = {
5415 convertOffsetParentRelativeRectToViewportRelativeRect,
5416 getDocumentElement,
5417 getClippingRect,
5418 getOffsetParent,
5419 getElementRects,
5420 getClientRects,
5421 getDimensions: getDimensions2,
5422 getScale,
5423 isElement,
5424 isRTL
5425 };
5426 function rectsAreEqual(a2, b2) {
5427 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
5428 }
5429 function observeMove(element, onMove) {
5430 let io = null;
5431 let timeoutId;
5432 const root = getDocumentElement(element);
5433 function cleanup() {
5434 var _io;
5435 clearTimeout(timeoutId);
5436 (_io = io) == null || _io.disconnect();
5437 io = null;
5438 }
5439 function refresh(skip, threshold) {
5440 if (skip === void 0) {
5441 skip = false;
5442 }
5443 if (threshold === void 0) {
5444 threshold = 1;
5445 }
5446 cleanup();
5447 const elementRectForRootMargin = element.getBoundingClientRect();
5448 const {
5449 left,
5450 top,
5451 width,
5452 height
5453 } = elementRectForRootMargin;
5454 if (!skip) {
5455 onMove();
5456 }
5457 if (!width || !height) {
5458 return;
5459 }
5460 const insetTop = floor(top);
5461 const insetRight = floor(root.clientWidth - (left + width));
5462 const insetBottom = floor(root.clientHeight - (top + height));
5463 const insetLeft = floor(left);
5464 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5465 const options = {
5466 rootMargin,
5467 threshold: max(0, min(1, threshold)) || 1
5468 };
5469 let isFirstUpdate = true;
5470 function handleObserve(entries) {
5471 const ratio = entries[0].intersectionRatio;
5472 if (ratio !== threshold) {
5473 if (!isFirstUpdate) {
5474 return refresh();
5475 }
5476 if (!ratio) {
5477 timeoutId = setTimeout(() => {
5478 refresh(false, 1e-7);
5479 }, 1e3);
5480 } else {
5481 refresh(false, ratio);
5482 }
5483 }
5484 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5485 refresh();
5486 }
5487 isFirstUpdate = false;
5488 }
5489 try {
5490 io = new IntersectionObserver(handleObserve, {
5491 ...options,
5492 // Handle <iframe>s
5493 root: root.ownerDocument
5494 });
5495 } catch (_e) {
5496 io = new IntersectionObserver(handleObserve, options);
5497 }
5498 io.observe(element);
5499 }
5500 refresh(true);
5501 return cleanup;
5502 }
5503 function autoUpdate(reference, floating, update2, options) {
5504 if (options === void 0) {
5505 options = {};
5506 }
5507 const {
5508 ancestorScroll = true,
5509 ancestorResize = true,
5510 elementResize = typeof ResizeObserver === "function",
5511 layoutShift = typeof IntersectionObserver === "function",
5512 animationFrame = false
5513 } = options;
5514 const referenceEl = unwrapElement(reference);
5515 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5516 ancestors.forEach((ancestor) => {
5517 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5518 passive: true
5519 });
5520 ancestorResize && ancestor.addEventListener("resize", update2);
5521 });
5522 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5523 let reobserveFrame = -1;
5524 let resizeObserver = null;
5525 if (elementResize) {
5526 resizeObserver = new ResizeObserver((_ref) => {
5527 let [firstEntry] = _ref;
5528 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5529 resizeObserver.unobserve(floating);
5530 cancelAnimationFrame(reobserveFrame);
5531 reobserveFrame = requestAnimationFrame(() => {
5532 var _resizeObserver;
5533 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5534 });
5535 }
5536 update2();
5537 });
5538 if (referenceEl && !animationFrame) {
5539 resizeObserver.observe(referenceEl);
5540 }
5541 if (floating) {
5542 resizeObserver.observe(floating);
5543 }
5544 }
5545 let frameId;
5546 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5547 if (animationFrame) {
5548 frameLoop();
5549 }
5550 function frameLoop() {
5551 const nextRefRect = getBoundingClientRect(reference);
5552 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5553 update2();
5554 }
5555 prevRefRect = nextRefRect;
5556 frameId = requestAnimationFrame(frameLoop);
5557 }
5558 update2();
5559 return () => {
5560 var _resizeObserver2;
5561 ancestors.forEach((ancestor) => {
5562 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5563 ancestorResize && ancestor.removeEventListener("resize", update2);
5564 });
5565 cleanupIo == null || cleanupIo();
5566 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5567 resizeObserver = null;
5568 if (animationFrame) {
5569 cancelAnimationFrame(frameId);
5570 }
5571 };
5572 }
5573 var offset2 = offset;
5574 var shift2 = shift;
5575 var flip2 = flip;
5576 var size2 = size;
5577 var hide2 = hide;
5578 var limitShift2 = limitShift;
5579 var computePosition2 = (reference, floating, options) => {
5580 const cache = /* @__PURE__ */ new Map();
5581 const mergedOptions = {
5582 platform: platform2,
5583 ...options
5584 };
5585 const platformWithCache = {
5586 ...mergedOptions.platform,
5587 _c: cache
5588 };
5589 return computePosition(reference, floating, {
5590 ...mergedOptions,
5591 platform: platformWithCache
5592 });
5593 };
5594
5595 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5596 var React26 = __toESM(require_react(), 1);
5597 var import_react2 = __toESM(require_react(), 1);
5598 var ReactDOM3 = __toESM(require_react_dom(), 1);
5599 var isClient = typeof document !== "undefined";
5600 var noop2 = function noop3() {
5601 };
5602 var index = isClient ? import_react2.useLayoutEffect : noop2;
5603 function deepEqual(a2, b2) {
5604 if (a2 === b2) {
5605 return true;
5606 }
5607 if (typeof a2 !== typeof b2) {
5608 return false;
5609 }
5610 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5611 return true;
5612 }
5613 let length;
5614 let i2;
5615 let keys;
5616 if (a2 && b2 && typeof a2 === "object") {
5617 if (Array.isArray(a2)) {
5618 length = a2.length;
5619 if (length !== b2.length) return false;
5620 for (i2 = length; i2-- !== 0; ) {
5621 if (!deepEqual(a2[i2], b2[i2])) {
5622 return false;
5623 }
5624 }
5625 return true;
5626 }
5627 keys = Object.keys(a2);
5628 length = keys.length;
5629 if (length !== Object.keys(b2).length) {
5630 return false;
5631 }
5632 for (i2 = length; i2-- !== 0; ) {
5633 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5634 return false;
5635 }
5636 }
5637 for (i2 = length; i2-- !== 0; ) {
5638 const key = keys[i2];
5639 if (key === "_owner" && a2.$$typeof) {
5640 continue;
5641 }
5642 if (!deepEqual(a2[key], b2[key])) {
5643 return false;
5644 }
5645 }
5646 return true;
5647 }
5648 return a2 !== a2 && b2 !== b2;
5649 }
5650 function getDPR(element) {
5651 if (typeof window === "undefined") {
5652 return 1;
5653 }
5654 const win = element.ownerDocument.defaultView || window;
5655 return win.devicePixelRatio || 1;
5656 }
5657 function roundByDPR(element, value) {
5658 const dpr = getDPR(element);
5659 return Math.round(value * dpr) / dpr;
5660 }
5661 function useLatestRef(value) {
5662 const ref = React26.useRef(value);
5663 index(() => {
5664 ref.current = value;
5665 });
5666 return ref;
5667 }
5668 function useFloating(options) {
5669 if (options === void 0) {
5670 options = {};
5671 }
5672 const {
5673 placement = "bottom",
5674 strategy = "absolute",
5675 middleware = [],
5676 platform: platform3,
5677 elements: {
5678 reference: externalReference,
5679 floating: externalFloating
5680 } = {},
5681 transform = true,
5682 whileElementsMounted,
5683 open
5684 } = options;
5685 const [data, setData] = React26.useState({
5686 x: 0,
5687 y: 0,
5688 strategy,
5689 placement,
5690 middlewareData: {},
5691 isPositioned: false
5692 });
5693 const [latestMiddleware, setLatestMiddleware] = React26.useState(middleware);
5694 if (!deepEqual(latestMiddleware, middleware)) {
5695 setLatestMiddleware(middleware);
5696 }
5697 const [_reference, _setReference] = React26.useState(null);
5698 const [_floating, _setFloating] = React26.useState(null);
5699 const setReference = React26.useCallback((node) => {
5700 if (node !== referenceRef.current) {
5701 referenceRef.current = node;
5702 _setReference(node);
5703 }
5704 }, []);
5705 const setFloating = React26.useCallback((node) => {
5706 if (node !== floatingRef.current) {
5707 floatingRef.current = node;
5708 _setFloating(node);
5709 }
5710 }, []);
5711 const referenceEl = externalReference || _reference;
5712 const floatingEl = externalFloating || _floating;
5713 const referenceRef = React26.useRef(null);
5714 const floatingRef = React26.useRef(null);
5715 const dataRef = React26.useRef(data);
5716 const hasWhileElementsMounted = whileElementsMounted != null;
5717 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5718 const platformRef = useLatestRef(platform3);
5719 const openRef = useLatestRef(open);
5720 const update2 = React26.useCallback(() => {
5721 if (!referenceRef.current || !floatingRef.current) {
5722 return;
5723 }
5724 const config = {
5725 placement,
5726 strategy,
5727 middleware: latestMiddleware
5728 };
5729 if (platformRef.current) {
5730 config.platform = platformRef.current;
5731 }
5732 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5733 const fullData = {
5734 ...data2,
5735 // The floating element's position may be recomputed while it's closed
5736 // but still mounted (such as when transitioning out). To ensure
5737 // `isPositioned` will be `false` initially on the next open, avoid
5738 // setting it to `true` when `open === false` (must be specified).
5739 isPositioned: openRef.current !== false
5740 };
5741 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5742 dataRef.current = fullData;
5743 ReactDOM3.flushSync(() => {
5744 setData(fullData);
5745 });
5746 }
5747 });
5748 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5749 index(() => {
5750 if (open === false && dataRef.current.isPositioned) {
5751 dataRef.current.isPositioned = false;
5752 setData((data2) => ({
5753 ...data2,
5754 isPositioned: false
5755 }));
5756 }
5757 }, [open]);
5758 const isMountedRef = React26.useRef(false);
5759 index(() => {
5760 isMountedRef.current = true;
5761 return () => {
5762 isMountedRef.current = false;
5763 };
5764 }, []);
5765 index(() => {
5766 if (referenceEl) referenceRef.current = referenceEl;
5767 if (floatingEl) floatingRef.current = floatingEl;
5768 if (referenceEl && floatingEl) {
5769 if (whileElementsMountedRef.current) {
5770 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5771 }
5772 update2();
5773 }
5774 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5775 const refs = React26.useMemo(() => ({
5776 reference: referenceRef,
5777 floating: floatingRef,
5778 setReference,
5779 setFloating
5780 }), [setReference, setFloating]);
5781 const elements = React26.useMemo(() => ({
5782 reference: referenceEl,
5783 floating: floatingEl
5784 }), [referenceEl, floatingEl]);
5785 const floatingStyles = React26.useMemo(() => {
5786 const initialStyles = {
5787 position: strategy,
5788 left: 0,
5789 top: 0
5790 };
5791 if (!elements.floating) {
5792 return initialStyles;
5793 }
5794 const x2 = roundByDPR(elements.floating, data.x);
5795 const y2 = roundByDPR(elements.floating, data.y);
5796 if (transform) {
5797 return {
5798 ...initialStyles,
5799 transform: "translate(" + x2 + "px, " + y2 + "px)",
5800 ...getDPR(elements.floating) >= 1.5 && {
5801 willChange: "transform"
5802 }
5803 };
5804 }
5805 return {
5806 position: strategy,
5807 left: x2,
5808 top: y2
5809 };
5810 }, [strategy, transform, elements.floating, data.x, data.y]);
5811 return React26.useMemo(() => ({
5812 ...data,
5813 update: update2,
5814 refs,
5815 elements,
5816 floatingStyles
5817 }), [data, update2, refs, elements, floatingStyles]);
5818 }
5819 var offset3 = (options, deps) => {
5820 const result = offset2(options);
5821 return {
5822 name: result.name,
5823 fn: result.fn,
5824 options: [options, deps]
5825 };
5826 };
5827 var shift3 = (options, deps) => {
5828 const result = shift2(options);
5829 return {
5830 name: result.name,
5831 fn: result.fn,
5832 options: [options, deps]
5833 };
5834 };
5835 var limitShift3 = (options, deps) => {
5836 const result = limitShift2(options);
5837 return {
5838 fn: result.fn,
5839 options: [options, deps]
5840 };
5841 };
5842 var flip3 = (options, deps) => {
5843 const result = flip2(options);
5844 return {
5845 name: result.name,
5846 fn: result.fn,
5847 options: [options, deps]
5848 };
5849 };
5850 var size3 = (options, deps) => {
5851 const result = size2(options);
5852 return {
5853 name: result.name,
5854 fn: result.fn,
5855 options: [options, deps]
5856 };
5857 };
5858 var hide3 = (options, deps) => {
5859 const result = hide2(options);
5860 return {
5861 name: result.name,
5862 fn: result.fn,
5863 options: [options, deps]
5864 };
5865 };
5866
5867 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5868 var React31 = __toESM(require_react(), 1);
5869
5870 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5871 var React30 = __toESM(require_react(), 1);
5872
5873 // node_modules/@base-ui/utils/esm/store/createSelector.js
5874 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5875 if (other.length > 0) {
5876 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5877 }
5878 let selector2;
5879 if (a2 && b2 && c2 && d2 && e2 && f2) {
5880 selector2 = (state, a1, a22, a3) => {
5881 const va = a2(state, a1, a22, a3);
5882 const vb = b2(state, a1, a22, a3);
5883 const vc = c2(state, a1, a22, a3);
5884 const vd = d2(state, a1, a22, a3);
5885 const ve = e2(state, a1, a22, a3);
5886 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5887 };
5888 } else if (a2 && b2 && c2 && d2 && e2) {
5889 selector2 = (state, a1, a22, a3) => {
5890 const va = a2(state, a1, a22, a3);
5891 const vb = b2(state, a1, a22, a3);
5892 const vc = c2(state, a1, a22, a3);
5893 const vd = d2(state, a1, a22, a3);
5894 return e2(va, vb, vc, vd, a1, a22, a3);
5895 };
5896 } else if (a2 && b2 && c2 && d2) {
5897 selector2 = (state, a1, a22, a3) => {
5898 const va = a2(state, a1, a22, a3);
5899 const vb = b2(state, a1, a22, a3);
5900 const vc = c2(state, a1, a22, a3);
5901 return d2(va, vb, vc, a1, a22, a3);
5902 };
5903 } else if (a2 && b2 && c2) {
5904 selector2 = (state, a1, a22, a3) => {
5905 const va = a2(state, a1, a22, a3);
5906 const vb = b2(state, a1, a22, a3);
5907 return c2(va, vb, a1, a22, a3);
5908 };
5909 } else if (a2 && b2) {
5910 selector2 = (state, a1, a22, a3) => {
5911 const va = a2(state, a1, a22, a3);
5912 return b2(va, a1, a22, a3);
5913 };
5914 } else if (a2) {
5915 selector2 = a2;
5916 } else {
5917 throw (
5918 /* minify-error-disabled */
5919 new Error("Missing arguments")
5920 );
5921 }
5922 return selector2;
5923 };
5924
5925 // node_modules/@base-ui/utils/esm/store/useStore.js
5926 var React28 = __toESM(require_react(), 1);
5927 var import_shim = __toESM(require_shim(), 1);
5928 var import_with_selector = __toESM(require_with_selector(), 1);
5929
5930 // node_modules/@base-ui/utils/esm/fastHooks.js
5931 var React27 = __toESM(require_react(), 1);
5932 var hooks = [];
5933 var currentInstance = void 0;
5934 function getInstance() {
5935 return currentInstance;
5936 }
5937 function register(hook) {
5938 hooks.push(hook);
5939 }
5940 function fastComponent(fn) {
5941 const FastComponent = (props, forwardedRef) => {
5942 const instance = useRefWithInit(createInstance).current;
5943 let result;
5944 try {
5945 currentInstance = instance;
5946 for (const hook of hooks) {
5947 hook.before(instance);
5948 }
5949 result = fn(props, forwardedRef);
5950 for (const hook of hooks) {
5951 hook.after(instance);
5952 }
5953 instance.didInitialize = true;
5954 } finally {
5955 currentInstance = void 0;
5956 }
5957 return result;
5958 };
5959 FastComponent.displayName = fn.displayName || fn.name;
5960 return FastComponent;
5961 }
5962 function fastComponentRef(fn) {
5963 return /* @__PURE__ */ React27.forwardRef(fastComponent(fn));
5964 }
5965 function createInstance() {
5966 return {
5967 didInitialize: false
5968 };
5969 }
5970
5971 // node_modules/@base-ui/utils/esm/store/useStore.js
5972 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5973 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5974 function useStore(store, selector2, a1, a2, a3) {
5975 return useStoreImplementation(store, selector2, a1, a2, a3);
5976 }
5977 function useStoreR19(store, selector2, a1, a2, a3) {
5978 const getSelection = React28.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5979 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5980 }
5981 register({
5982 before(instance) {
5983 instance.syncIndex = 0;
5984 if (!instance.didInitialize) {
5985 instance.syncTick = 1;
5986 instance.syncHooks = [];
5987 instance.didChangeStore = true;
5988 instance.getSnapshot = () => {
5989 let didChange2 = false;
5990 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5991 const hook = instance.syncHooks[i2];
5992 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5993 if (hook.didChange || !Object.is(hook.value, value)) {
5994 didChange2 = true;
5995 hook.value = value;
5996 hook.didChange = false;
5997 }
5998 }
5999 if (didChange2) {
6000 instance.syncTick += 1;
6001 }
6002 return instance.syncTick;
6003 };
6004 }
6005 },
6006 after(instance) {
6007 if (instance.syncHooks.length > 0) {
6008 if (instance.didChangeStore) {
6009 instance.didChangeStore = false;
6010 instance.subscribe = (onStoreChange) => {
6011 const stores = /* @__PURE__ */ new Set();
6012 for (const hook of instance.syncHooks) {
6013 stores.add(hook.store);
6014 }
6015 const unsubscribes = [];
6016 for (const store of stores) {
6017 unsubscribes.push(store.subscribe(onStoreChange));
6018 }
6019 return () => {
6020 for (const unsubscribe of unsubscribes) {
6021 unsubscribe();
6022 }
6023 };
6024 };
6025 }
6026 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
6027 }
6028 }
6029 });
6030 function useStoreFast(store, selector2, a1, a2, a3) {
6031 const instance = getInstance();
6032 if (!instance) {
6033 return useStoreR19(store, selector2, a1, a2, a3);
6034 }
6035 const index2 = instance.syncIndex;
6036 instance.syncIndex += 1;
6037 let hook;
6038 if (!instance.didInitialize) {
6039 hook = {
6040 store,
6041 selector: selector2,
6042 a1,
6043 a2,
6044 a3,
6045 value: selector2(store.getSnapshot(), a1, a2, a3),
6046 didChange: false
6047 };
6048 instance.syncHooks.push(hook);
6049 } else {
6050 hook = instance.syncHooks[index2];
6051 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
6052 if (hook.store !== store) {
6053 instance.didChangeStore = true;
6054 }
6055 hook.store = store;
6056 hook.selector = selector2;
6057 hook.a1 = a1;
6058 hook.a2 = a2;
6059 hook.a3 = a3;
6060 hook.didChange = true;
6061 }
6062 }
6063 return hook.value;
6064 }
6065 function useStoreLegacy(store, selector2, a1, a2, a3) {
6066 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
6067 }
6068
6069 // node_modules/@base-ui/utils/esm/store/Store.js
6070 var Store = class {
6071 /**
6072 * The current state of the store.
6073 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
6074 * 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).
6075 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
6076 *
6077 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
6078 */
6079 // Internal state to handle recursive `setState()` calls
6080 constructor(state) {
6081 this.state = state;
6082 this.listeners = /* @__PURE__ */ new Set();
6083 this.updateTick = 0;
6084 }
6085 /**
6086 * Registers a listener that will be called whenever the store's state changes.
6087 *
6088 * @param fn The listener function to be called on state changes.
6089 * @returns A function to unsubscribe the listener.
6090 */
6091 subscribe = (fn) => {
6092 this.listeners.add(fn);
6093 return () => {
6094 this.listeners.delete(fn);
6095 };
6096 };
6097 /**
6098 * Returns the current state of the store.
6099 */
6100 getSnapshot = () => {
6101 return this.state;
6102 };
6103 /**
6104 * Updates the entire store's state and notifies all registered listeners.
6105 *
6106 * @param newState The new state to set for the store.
6107 */
6108 setState(newState) {
6109 if (this.state === newState) {
6110 return;
6111 }
6112 this.state = newState;
6113 this.updateTick += 1;
6114 const currentTick = this.updateTick;
6115 for (const listener of this.listeners) {
6116 if (currentTick !== this.updateTick) {
6117 return;
6118 }
6119 listener(newState);
6120 }
6121 }
6122 /**
6123 * Merges the provided changes into the current state and notifies listeners if there are changes.
6124 *
6125 * @param changes An object containing the changes to apply to the current state.
6126 */
6127 update(changes) {
6128 for (const key in changes) {
6129 if (!Object.is(this.state[key], changes[key])) {
6130 this.setState({
6131 ...this.state,
6132 ...changes
6133 });
6134 return;
6135 }
6136 }
6137 }
6138 /**
6139 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
6140 *
6141 * @param key The key in the store's state to update.
6142 * @param value The new value to set for the specified key.
6143 */
6144 set(key, value) {
6145 if (!Object.is(this.state[key], value)) {
6146 this.setState({
6147 ...this.state,
6148 [key]: value
6149 });
6150 }
6151 }
6152 /**
6153 * Gives the state a new reference and updates all registered listeners.
6154 */
6155 notifyAll() {
6156 const newState = {
6157 ...this.state
6158 };
6159 this.setState(newState);
6160 }
6161 use(selector2, a1, a2, a3) {
6162 return useStore(this, selector2, a1, a2, a3);
6163 }
6164 };
6165
6166 // node_modules/@base-ui/utils/esm/store/ReactStore.js
6167 var React29 = __toESM(require_react(), 1);
6168 var ReactStore = class extends Store {
6169 /**
6170 * Creates a new ReactStore instance.
6171 *
6172 * @param state Initial state of the store.
6173 * @param context Non-reactive context values.
6174 * @param selectors Optional selectors for use with `useState`.
6175 */
6176 constructor(state, context = {}, selectors3) {
6177 super(state);
6178 this.context = context;
6179 this.selectors = selectors3;
6180 }
6181 /**
6182 * Non-reactive values such as refs, callbacks, etc.
6183 */
6184 /**
6185 * Synchronizes a single external value into the store.
6186 *
6187 * Note that the while the value in `state` is updated immediately, the value returned
6188 * by `useState` is updated before the next render (similarly to React's `useState`).
6189 */
6190 useSyncedValue(key, value) {
6191 React29.useDebugValue(key);
6192 const store = this;
6193 useIsoLayoutEffect(() => {
6194 if (store.state[key] !== value) {
6195 store.set(key, value);
6196 }
6197 }, [store, key, value]);
6198 }
6199 /**
6200 * Synchronizes a single external value into the store and
6201 * cleans it up (sets to `undefined`) on unmount.
6202 *
6203 * Note that the while the value in `state` is updated immediately, the value returned
6204 * by `useState` is updated before the next render (similarly to React's `useState`).
6205 */
6206 useSyncedValueWithCleanup(key, value) {
6207 const store = this;
6208 useIsoLayoutEffect(() => {
6209 if (store.state[key] !== value) {
6210 store.set(key, value);
6211 }
6212 return () => {
6213 store.set(key, void 0);
6214 };
6215 }, [store, key, value]);
6216 }
6217 /**
6218 * Synchronizes multiple external values into the store.
6219 *
6220 * Note that the while the values in `state` are updated immediately, the values returned
6221 * by `useState` are updated before the next render (similarly to React's `useState`).
6222 */
6223 useSyncedValues(statePart) {
6224 const store = this;
6225 if (true) {
6226 React29.useDebugValue(statePart, (p2) => Object.keys(p2));
6227 const keys = React29.useRef(Object.keys(statePart)).current;
6228 const nextKeys = Object.keys(statePart);
6229 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
6230 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
6231 }
6232 }
6233 const dependencies = Object.values(statePart);
6234 useIsoLayoutEffect(() => {
6235 store.update(statePart);
6236 }, [store, ...dependencies]);
6237 }
6238 /**
6239 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
6240 * is non-undefined, the store's state at `key` is updated to match `controlled`.
6241 */
6242 useControlledProp(key, controlled) {
6243 React29.useDebugValue(key);
6244 const store = this;
6245 const isControlled = controlled !== void 0;
6246 useIsoLayoutEffect(() => {
6247 if (isControlled && !Object.is(store.state[key], controlled)) {
6248 store.setState({
6249 ...store.state,
6250 [key]: controlled
6251 });
6252 }
6253 }, [store, key, controlled, isControlled]);
6254 if (true) {
6255 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
6256 if (!cache.has(key)) {
6257 cache.set(key, isControlled);
6258 }
6259 const previouslyControlled = cache.get(key);
6260 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
6261 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).`);
6262 }
6263 }
6264 }
6265 /** Gets the current value from the store using a selector with the provided key.
6266 *
6267 * @param key Key of the selector to use.
6268 */
6269 select(key, a1, a2, a3) {
6270 const selector2 = this.selectors[key];
6271 return selector2(this.state, a1, a2, a3);
6272 }
6273 /**
6274 * Returns a value from the store's state using a selector function.
6275 * Used to subscribe to specific parts of the state.
6276 * This methods causes a rerender whenever the selected state changes.
6277 *
6278 * @param key Key of the selector to use.
6279 */
6280 useState(key, a1, a2, a3) {
6281 React29.useDebugValue(key);
6282 return useStore(this, this.selectors[key], a1, a2, a3);
6283 }
6284 /**
6285 * Wraps a function with `useStableCallback` to ensure it has a stable reference
6286 * and assigns it to the context.
6287 *
6288 * @param key Key of the event callback. Must be a function in the context.
6289 * @param fn Function to assign.
6290 */
6291 useContextCallback(key, fn) {
6292 React29.useDebugValue(key);
6293 const stableFunction = useStableCallback(fn ?? NOOP);
6294 this.context[key] = stableFunction;
6295 }
6296 /**
6297 * Returns a stable setter function for a specific key in the store's state.
6298 * It's commonly used to pass as a ref callback to React elements.
6299 *
6300 * @param key Key of the state to set.
6301 */
6302 useStateSetter(key) {
6303 const ref = React29.useRef(void 0);
6304 if (ref.current === void 0) {
6305 ref.current = (value) => {
6306 this.set(key, value);
6307 };
6308 }
6309 return ref.current;
6310 }
6311 /**
6312 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
6313 *
6314 * @param key Key of the selector to observe.
6315 * @param listener Listener function called when the selector result changes.
6316 */
6317 observe(selector2, listener) {
6318 let selectFn;
6319 if (typeof selector2 === "function") {
6320 selectFn = selector2;
6321 } else {
6322 selectFn = this.selectors[selector2];
6323 }
6324 let prevValue = selectFn(this.state);
6325 listener(prevValue, prevValue, this);
6326 return this.subscribe((nextState) => {
6327 const nextValue = selectFn(nextState);
6328 if (!Object.is(prevValue, nextValue)) {
6329 const oldValue = prevValue;
6330 prevValue = nextValue;
6331 listener(nextValue, oldValue, this);
6332 }
6333 });
6334 }
6335 };
6336
6337 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
6338 var selectors = {
6339 open: createSelector((state) => state.open),
6340 transitionStatus: createSelector((state) => state.transitionStatus),
6341 domReferenceElement: createSelector((state) => state.domReferenceElement),
6342 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
6343 floatingElement: createSelector((state) => state.floatingElement),
6344 floatingId: createSelector((state) => state.floatingId)
6345 };
6346 var FloatingRootStore = class extends ReactStore {
6347 constructor(options) {
6348 const {
6349 syncOnly,
6350 nested,
6351 onOpenChange,
6352 triggerElements,
6353 ...initialState
6354 } = options;
6355 super({
6356 ...initialState,
6357 positionReference: initialState.referenceElement,
6358 domReferenceElement: initialState.referenceElement
6359 }, {
6360 onOpenChange,
6361 dataRef: {
6362 current: {}
6363 },
6364 events: createEventEmitter(),
6365 nested,
6366 triggerElements
6367 }, selectors);
6368 this.syncOnly = syncOnly;
6369 }
6370 /**
6371 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
6372 */
6373 syncOpenEvent = (newOpen, event) => {
6374 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
6375 // click events to upgrade a hover-open.
6376 event != null && isClickLikeEvent(event)) {
6377 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
6378 }
6379 };
6380 /**
6381 * Runs the root-owned side effects for an open state change.
6382 */
6383 dispatchOpenChange = (newOpen, eventDetails) => {
6384 this.syncOpenEvent(newOpen, eventDetails.event);
6385 const details = {
6386 open: newOpen,
6387 reason: eventDetails.reason,
6388 nativeEvent: eventDetails.event,
6389 nested: this.context.nested,
6390 triggerElement: eventDetails.trigger
6391 };
6392 this.context.events.emit("openchange", details);
6393 };
6394 /**
6395 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
6396 *
6397 * @param newOpen The new open state.
6398 * @param eventDetails Details about the event that triggered the open state change.
6399 */
6400 setOpen = (newOpen, eventDetails) => {
6401 if (this.syncOnly) {
6402 this.context.onOpenChange?.(newOpen, eventDetails);
6403 return;
6404 }
6405 this.dispatchOpenChange(newOpen, eventDetails);
6406 this.context.onOpenChange?.(newOpen, eventDetails);
6407 };
6408 };
6409
6410 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
6411 function useSyncedFloatingRootContext(options) {
6412 const {
6413 popupStore,
6414 treatPopupAsFloatingElement = false,
6415 floatingRootContext: floatingRootContextProp,
6416 floatingId,
6417 nested,
6418 onOpenChange
6419 } = options;
6420 const open = popupStore.useState("open");
6421 const referenceElement = popupStore.useState("activeTriggerElement");
6422 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6423 const triggerElements = popupStore.context.triggerElements;
6424 const handleOpenChange = onOpenChange;
6425 const internalStoreRef = React30.useRef(null);
6426 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
6427 internalStoreRef.current = new FloatingRootStore({
6428 open,
6429 transitionStatus: void 0,
6430 referenceElement,
6431 floatingElement,
6432 triggerElements,
6433 onOpenChange: handleOpenChange,
6434 floatingId,
6435 syncOnly: true,
6436 nested
6437 });
6438 }
6439 const store = floatingRootContextProp ?? internalStoreRef.current;
6440 popupStore.useSyncedValue("floatingId", floatingId);
6441 useIsoLayoutEffect(() => {
6442 const valuesToSync = {
6443 open,
6444 floatingId,
6445 referenceElement,
6446 floatingElement
6447 };
6448 if (isElement(referenceElement)) {
6449 valuesToSync.domReferenceElement = referenceElement;
6450 }
6451 if (store.state.positionReference === store.state.referenceElement) {
6452 valuesToSync.positionReference = referenceElement;
6453 }
6454 store.update(valuesToSync);
6455 }, [open, floatingId, referenceElement, floatingElement, store]);
6456 store.context.onOpenChange = handleOpenChange;
6457 store.context.nested = nested;
6458 return store;
6459 }
6460
6461 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
6462 var FOCUSABLE_POPUP_PROPS = {
6463 tabIndex: -1,
6464 [FOCUSABLE_ATTRIBUTE]: ""
6465 };
6466 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
6467 const floatingId = useId();
6468 const nested = useFloatingParentNodeId() != null;
6469 const internalStoreRef = React31.useRef(null);
6470 if (externalStore === void 0 && internalStoreRef.current === null) {
6471 internalStoreRef.current = createStore2(floatingId, nested);
6472 }
6473 const store = externalStore ?? internalStoreRef.current;
6474 useSyncedFloatingRootContext({
6475 popupStore: store,
6476 treatPopupAsFloatingElement,
6477 floatingRootContext: store.state.floatingRootContext,
6478 floatingId,
6479 nested,
6480 onOpenChange: store.setOpen
6481 });
6482 return {
6483 store,
6484 internalStore: internalStoreRef.current
6485 };
6486 }
6487 function useTriggerRegistration(id, store) {
6488 const registeredElementIdRef = React31.useRef(null);
6489 const registeredElementRef = React31.useRef(null);
6490 return React31.useCallback((element) => {
6491 if (id === void 0) {
6492 return;
6493 }
6494 let shouldSyncTriggerCount = false;
6495 if (registeredElementIdRef.current !== null) {
6496 const registeredId = registeredElementIdRef.current;
6497 const registeredElement = registeredElementRef.current;
6498 const currentElement = store.context.triggerElements.getById(registeredId);
6499 if (registeredElement && currentElement === registeredElement) {
6500 store.context.triggerElements.delete(registeredId);
6501 shouldSyncTriggerCount = true;
6502 }
6503 registeredElementIdRef.current = null;
6504 registeredElementRef.current = null;
6505 }
6506 if (element !== null) {
6507 registeredElementIdRef.current = id;
6508 registeredElementRef.current = element;
6509 store.context.triggerElements.add(id, element);
6510 shouldSyncTriggerCount = true;
6511 }
6512 if (shouldSyncTriggerCount) {
6513 const triggerCount = store.context.triggerElements.size;
6514 if (store.select("open") && store.state.triggerCount !== triggerCount) {
6515 store.set("triggerCount", triggerCount);
6516 }
6517 }
6518 }, [store, id]);
6519 }
6520 function setOpenTriggerState(state, open, trigger) {
6521 const triggerId = trigger?.id ?? null;
6522 if (triggerId || open) {
6523 state.activeTriggerId = triggerId;
6524 state.activeTriggerElement = trigger ?? null;
6525 }
6526 }
6527 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6528 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6529 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6530 const registerTrigger = useStableCallback((element) => {
6531 baseRegisterTrigger(element);
6532 if (!element) {
6533 return;
6534 }
6535 const open = store.select("open");
6536 const activeTriggerId = store.select("activeTriggerId");
6537 if (activeTriggerId === triggerId) {
6538 store.update({
6539 activeTriggerElement: element,
6540 ...open ? stateUpdates : null
6541 });
6542 return;
6543 }
6544 if (activeTriggerId == null && open) {
6545 store.update({
6546 activeTriggerId: triggerId,
6547 activeTriggerElement: element,
6548 ...stateUpdates
6549 });
6550 }
6551 });
6552 useIsoLayoutEffect(() => {
6553 if (isMountedByThisTrigger) {
6554 store.update({
6555 activeTriggerElement: triggerElementRef.current,
6556 ...stateUpdates
6557 });
6558 }
6559 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6560 return {
6561 registerTrigger,
6562 isMountedByThisTrigger
6563 };
6564 }
6565 function useImplicitActiveTrigger(store) {
6566 const open = store.useState("open");
6567 const reactiveTriggerCount = store.useState("triggerCount");
6568 useIsoLayoutEffect(() => {
6569 if (!open) {
6570 if (store.state.triggerCount !== 0) {
6571 store.set("triggerCount", 0);
6572 }
6573 return;
6574 }
6575 const triggerCount = store.context.triggerElements.size;
6576 const stateUpdates = {};
6577 if (store.state.triggerCount !== triggerCount) {
6578 stateUpdates.triggerCount = triggerCount;
6579 }
6580 if (!store.select("activeTriggerId") && triggerCount === 1) {
6581 const iteratorResult = store.context.triggerElements.entries().next();
6582 if (!iteratorResult.done) {
6583 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6584 stateUpdates.activeTriggerId = implicitTriggerId;
6585 stateUpdates.activeTriggerElement = implicitTriggerElement;
6586 }
6587 }
6588 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) {
6589 store.update(stateUpdates);
6590 }
6591 }, [open, store, reactiveTriggerCount]);
6592 }
6593 function useOpenStateTransitions(open, store, onUnmount) {
6594 const {
6595 mounted,
6596 setMounted,
6597 transitionStatus
6598 } = useTransitionStatus(open);
6599 store.useSyncedValues({
6600 mounted,
6601 transitionStatus
6602 });
6603 const forceUnmount = useStableCallback(() => {
6604 setMounted(false);
6605 store.update({
6606 activeTriggerId: null,
6607 activeTriggerElement: null,
6608 mounted: false,
6609 preventUnmountingOnClose: false
6610 });
6611 onUnmount?.();
6612 store.context.onOpenChangeComplete?.(false);
6613 });
6614 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6615 useOpenChangeComplete({
6616 enabled: mounted && !open && !preventUnmountingOnClose,
6617 open,
6618 ref: store.context.popupRef,
6619 onComplete() {
6620 if (!open) {
6621 forceUnmount();
6622 }
6623 }
6624 });
6625 return {
6626 forceUnmount,
6627 transitionStatus
6628 };
6629 }
6630 function usePopupInteractionProps(store, statePart) {
6631 store.useSyncedValues(statePart);
6632 useIsoLayoutEffect(() => () => {
6633 store.update({
6634 activeTriggerProps: EMPTY_OBJECT,
6635 inactiveTriggerProps: EMPTY_OBJECT,
6636 popupProps: EMPTY_OBJECT
6637 });
6638 }, [store]);
6639 }
6640
6641 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
6642 var PopupTriggerMap = class {
6643 constructor() {
6644 this.elementsSet = /* @__PURE__ */ new Set();
6645 this.idMap = /* @__PURE__ */ new Map();
6646 }
6647 /**
6648 * Adds a trigger element with the given ID.
6649 *
6650 * Note: The provided element is assumed to not be registered under multiple IDs.
6651 */
6652 add(id, element) {
6653 const existingElement = this.idMap.get(id);
6654 if (existingElement === element) {
6655 return;
6656 }
6657 if (existingElement !== void 0) {
6658 this.elementsSet.delete(existingElement);
6659 }
6660 this.elementsSet.add(element);
6661 this.idMap.set(id, element);
6662 if (true) {
6663 if (this.elementsSet.size !== this.idMap.size) {
6664 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6665 }
6666 }
6667 }
6668 /**
6669 * Removes the trigger element with the given ID.
6670 */
6671 delete(id) {
6672 const element = this.idMap.get(id);
6673 if (element) {
6674 this.elementsSet.delete(element);
6675 this.idMap.delete(id);
6676 }
6677 }
6678 /**
6679 * Whether the given element is registered as a trigger.
6680 */
6681 hasElement(element) {
6682 return this.elementsSet.has(element);
6683 }
6684 /**
6685 * Whether there is a registered trigger element matching the given predicate.
6686 */
6687 hasMatchingElement(predicate) {
6688 for (const element of this.elementsSet) {
6689 if (predicate(element)) {
6690 return true;
6691 }
6692 }
6693 return false;
6694 }
6695 /**
6696 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6697 */
6698 getById(id) {
6699 return this.idMap.get(id);
6700 }
6701 /**
6702 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6703 */
6704 entries() {
6705 return this.idMap.entries();
6706 }
6707 /**
6708 * Returns an iterable of all registered trigger elements.
6709 */
6710 elements() {
6711 return this.elementsSet.values();
6712 }
6713 /**
6714 * Returns the number of registered trigger elements.
6715 */
6716 get size() {
6717 return this.idMap.size;
6718 }
6719 };
6720
6721 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
6722 function getEmptyRootContext() {
6723 return new FloatingRootStore({
6724 open: false,
6725 transitionStatus: void 0,
6726 floatingElement: null,
6727 referenceElement: null,
6728 triggerElements: new PopupTriggerMap(),
6729 floatingId: void 0,
6730 syncOnly: false,
6731 nested: false,
6732 onOpenChange: void 0
6733 });
6734 }
6735
6736 // node_modules/@base-ui/react/esm/utils/popups/store.js
6737 function createInitialPopupStoreState() {
6738 return {
6739 open: false,
6740 openProp: void 0,
6741 mounted: false,
6742 transitionStatus: void 0,
6743 floatingRootContext: getEmptyRootContext(),
6744 floatingId: void 0,
6745 triggerCount: 0,
6746 preventUnmountingOnClose: false,
6747 payload: void 0,
6748 activeTriggerId: null,
6749 activeTriggerElement: null,
6750 triggerIdProp: void 0,
6751 popupElement: null,
6752 positionerElement: null,
6753 activeTriggerProps: EMPTY_OBJECT,
6754 inactiveTriggerProps: EMPTY_OBJECT,
6755 popupProps: EMPTY_OBJECT
6756 };
6757 }
6758 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6759 return new FloatingRootStore({
6760 open: false,
6761 transitionStatus: void 0,
6762 floatingElement: null,
6763 referenceElement: null,
6764 triggerElements,
6765 floatingId,
6766 syncOnly: true,
6767 nested,
6768 onOpenChange: void 0
6769 });
6770 }
6771 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6772 var openSelector = createSelector((state) => state.openProp ?? state.open);
6773 var popupIdSelector = createSelector((state) => {
6774 const popupId = state.popupElement?.id ?? state.floatingId;
6775 return popupId || void 0;
6776 });
6777 function triggerOwnsOpenPopup(state, triggerId) {
6778 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6779 }
6780 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6781 if (triggerOwnsOpenPopup(state, triggerId)) {
6782 return true;
6783 }
6784 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6785 }
6786 var popupStoreSelectors = {
6787 open: openSelector,
6788 mounted: createSelector((state) => state.mounted),
6789 transitionStatus: createSelector((state) => state.transitionStatus),
6790 floatingRootContext: createSelector((state) => state.floatingRootContext),
6791 triggerCount: createSelector((state) => state.triggerCount),
6792 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6793 payload: createSelector((state) => state.payload),
6794 activeTriggerId: activeTriggerIdSelector,
6795 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6796 popupId: popupIdSelector,
6797 /**
6798 * Whether the trigger with the given ID was used to open the popup.
6799 */
6800 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6801 /**
6802 * Whether the popup is open and was activated by a trigger with the given ID.
6803 */
6804 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6805 /**
6806 * Whether the popup is mounted and was activated by a trigger with the given ID.
6807 */
6808 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6809 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6810 /**
6811 * Popup id for the trigger that currently owns the open popup.
6812 */
6813 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6814 popupProps: createSelector((state) => state.popupProps),
6815 popupElement: createSelector((state) => state.popupElement),
6816 positionerElement: createSelector((state) => state.positionerElement)
6817 };
6818
6819 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
6820 function useFloatingRootContext(options) {
6821 const {
6822 open = false,
6823 onOpenChange,
6824 elements = {}
6825 } = options;
6826 const floatingId = useId();
6827 const nested = useFloatingParentNodeId() != null;
6828 if (true) {
6829 const optionDomReference = elements.reference;
6830 if (optionDomReference && !isElement(optionDomReference)) {
6831 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6832 }
6833 }
6834 const store = useRefWithInit(() => new FloatingRootStore({
6835 open,
6836 transitionStatus: void 0,
6837 onOpenChange,
6838 referenceElement: elements.reference ?? null,
6839 floatingElement: elements.floating ?? null,
6840 triggerElements: new PopupTriggerMap(),
6841 floatingId,
6842 syncOnly: false,
6843 nested
6844 })).current;
6845 useIsoLayoutEffect(() => {
6846 const valuesToSync = {
6847 open,
6848 floatingId
6849 };
6850 if (elements.reference !== void 0) {
6851 valuesToSync.referenceElement = elements.reference;
6852 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6853 }
6854 if (elements.floating !== void 0) {
6855 valuesToSync.floatingElement = elements.floating;
6856 }
6857 store.update(valuesToSync);
6858 }, [open, floatingId, elements.reference, elements.floating, store]);
6859 store.context.onOpenChange = onOpenChange;
6860 store.context.nested = nested;
6861 return store;
6862 }
6863
6864 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6865 function useFloating2(options = {}) {
6866 const {
6867 nodeId,
6868 externalTree
6869 } = options;
6870 const internalStore = useFloatingRootContext(options);
6871 const store = options.rootContext || internalStore;
6872 const referenceElement = store.useState("referenceElement");
6873 const floatingElement = store.useState("floatingElement");
6874 const domReferenceElement = store.useState("domReferenceElement");
6875 const open = store.useState("open");
6876 const floatingId = store.useState("floatingId");
6877 const [positionReference, setPositionReferenceRaw] = React32.useState(null);
6878 const [localDomReference, setLocalDomReference] = React32.useState(void 0);
6879 const [localFloatingElement, setLocalFloatingElement] = React32.useState(void 0);
6880 const domReferenceRef = React32.useRef(null);
6881 const tree = useFloatingTree(externalTree);
6882 const storeElements = React32.useMemo(() => ({
6883 reference: referenceElement,
6884 floating: floatingElement,
6885 domReference: domReferenceElement
6886 }), [referenceElement, floatingElement, domReferenceElement]);
6887 const position = useFloating({
6888 ...options,
6889 elements: {
6890 ...storeElements,
6891 ...positionReference && {
6892 reference: positionReference
6893 }
6894 }
6895 });
6896 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6897 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
6898 store.useSyncedValue("referenceElement", localDomReference ?? null);
6899 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6900 store.useSyncedValue("floatingElement", syncedFloatingElement);
6901 const setPositionReference = React32.useCallback((node) => {
6902 const computedPositionReference = isElement(node) ? {
6903 getBoundingClientRect: () => node.getBoundingClientRect(),
6904 getClientRects: () => node.getClientRects(),
6905 contextElement: node
6906 } : node;
6907 setPositionReferenceRaw(computedPositionReference);
6908 position.refs.setReference(computedPositionReference);
6909 }, [position.refs]);
6910 const setReference = React32.useCallback((node) => {
6911 if (isElement(node) || node === null) {
6912 domReferenceRef.current = node;
6913 setLocalDomReference(node);
6914 }
6915 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6916 // `null` to support `positionReference` + an unstable `reference`
6917 // callback ref.
6918 node !== null && !isElement(node)) {
6919 position.refs.setReference(node);
6920 }
6921 }, [position.refs, setLocalDomReference]);
6922 const setFloating = React32.useCallback((node) => {
6923 setLocalFloatingElement(node);
6924 position.refs.setFloating(node);
6925 }, [position.refs]);
6926 const refs = React32.useMemo(() => ({
6927 ...position.refs,
6928 setReference,
6929 setFloating,
6930 setPositionReference,
6931 domReference: domReferenceRef
6932 }), [position.refs, setReference, setFloating, setPositionReference]);
6933 const elements = React32.useMemo(() => ({
6934 ...position.elements,
6935 domReference: domReferenceElement
6936 }), [position.elements, domReferenceElement]);
6937 const context = React32.useMemo(() => ({
6938 ...position,
6939 dataRef: store.context.dataRef,
6940 open,
6941 onOpenChange: store.setOpen,
6942 events: store.context.events,
6943 floatingId,
6944 refs,
6945 elements,
6946 nodeId,
6947 rootStore: store
6948 }), [position, refs, elements, nodeId, store, open, floatingId]);
6949 useIsoLayoutEffect(() => {
6950 if (domReferenceElement) {
6951 domReferenceRef.current = domReferenceElement;
6952 }
6953 }, [domReferenceElement]);
6954 useIsoLayoutEffect(() => {
6955 store.context.dataRef.current.floatingContext = context;
6956 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6957 if (node) {
6958 node.context = context;
6959 }
6960 });
6961 return React32.useMemo(() => ({
6962 ...position,
6963 context,
6964 refs,
6965 elements,
6966 rootStore: store
6967 }), [position, refs, elements, context, store]);
6968 }
6969
6970 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6971 var React33 = __toESM(require_react(), 1);
6972 var isMacSafari = isMac && isSafari;
6973 function useFocus(context, props = {}) {
6974 const {
6975 enabled = true,
6976 delay
6977 } = props;
6978 const store = "rootStore" in context ? context.rootStore : context;
6979 const {
6980 events,
6981 dataRef
6982 } = store.context;
6983 const blockFocusRef = React33.useRef(false);
6984 const blockedReferenceRef = React33.useRef(null);
6985 const keyboardModalityRef = React33.useRef(true);
6986 const timeout = useTimeout();
6987 React33.useEffect(() => {
6988 const domReference = store.select("domReferenceElement");
6989 if (!enabled) {
6990 return void 0;
6991 }
6992 const win = getWindow(domReference);
6993 function onBlur() {
6994 const currentDomReference = store.select("domReferenceElement");
6995 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6996 blockFocusRef.current = true;
6997 }
6998 }
6999 function onKeyDown() {
7000 keyboardModalityRef.current = true;
7001 }
7002 function onPointerDown() {
7003 keyboardModalityRef.current = false;
7004 }
7005 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
7006 }, [store, enabled]);
7007 React33.useEffect(() => {
7008 if (!enabled) {
7009 return void 0;
7010 }
7011 function onOpenChangeLocal(details) {
7012 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
7013 const referenceElement = store.select("domReferenceElement");
7014 if (isElement(referenceElement)) {
7015 blockedReferenceRef.current = referenceElement;
7016 blockFocusRef.current = true;
7017 }
7018 }
7019 }
7020 events.on("openchange", onOpenChangeLocal);
7021 return () => {
7022 events.off("openchange", onOpenChangeLocal);
7023 };
7024 }, [events, enabled, store]);
7025 const reference = React33.useMemo(() => {
7026 function resetBlockedFocus() {
7027 blockFocusRef.current = false;
7028 blockedReferenceRef.current = null;
7029 }
7030 return {
7031 onMouseLeave() {
7032 resetBlockedFocus();
7033 },
7034 onFocus(event) {
7035 const focusTarget = event.currentTarget;
7036 if (blockFocusRef.current) {
7037 if (blockedReferenceRef.current === focusTarget) {
7038 return;
7039 }
7040 resetBlockedFocus();
7041 }
7042 const target = getTarget(event.nativeEvent);
7043 if (isElement(target)) {
7044 if (isMacSafari && !event.relatedTarget) {
7045 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
7046 return;
7047 }
7048 } else if (!matchesFocusVisible(target)) {
7049 return;
7050 }
7051 }
7052 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
7053 const {
7054 nativeEvent,
7055 currentTarget
7056 } = event;
7057 const delayValue = typeof delay === "function" ? delay() : delay;
7058 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
7059 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7060 return;
7061 }
7062 timeout.start(delayValue, () => {
7063 if (blockFocusRef.current) {
7064 return;
7065 }
7066 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7067 });
7068 },
7069 onBlur(event) {
7070 resetBlockedFocus();
7071 const relatedTarget = event.relatedTarget;
7072 const nativeEvent = event.nativeEvent;
7073 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
7074 timeout.start(0, () => {
7075 const domReference = store.select("domReferenceElement");
7076 const activeEl = activeElement(ownerDocument(domReference));
7077 if (!relatedTarget && activeEl === domReference) {
7078 return;
7079 }
7080 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
7081 return;
7082 }
7083 const nextFocusedElement = relatedTarget ?? activeEl;
7084 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
7085 return;
7086 }
7087 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
7088 });
7089 }
7090 };
7091 }, [dataRef, delay, store, timeout]);
7092 return React33.useMemo(() => enabled ? {
7093 reference,
7094 trigger: reference
7095 } : {}, [enabled, reference]);
7096 }
7097
7098 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
7099 var React34 = __toESM(require_react(), 1);
7100
7101 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
7102 var HoverInteraction = class _HoverInteraction {
7103 constructor() {
7104 this.pointerType = void 0;
7105 this.interactedInside = false;
7106 this.handler = void 0;
7107 this.blockMouseMove = true;
7108 this.performedPointerEventsMutation = false;
7109 this.pointerEventsScopeElement = null;
7110 this.pointerEventsReferenceElement = null;
7111 this.pointerEventsFloatingElement = null;
7112 this.restTimeoutPending = false;
7113 this.openChangeTimeout = new Timeout();
7114 this.restTimeout = new Timeout();
7115 this.handleCloseOptions = void 0;
7116 }
7117 static create() {
7118 return new _HoverInteraction();
7119 }
7120 dispose = () => {
7121 this.openChangeTimeout.clear();
7122 this.restTimeout.clear();
7123 };
7124 disposeEffect = () => {
7125 return this.dispose;
7126 };
7127 };
7128 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
7129 function clearSafePolygonPointerEventsMutation(instance) {
7130 if (!instance.performedPointerEventsMutation) {
7131 return;
7132 }
7133 const scopeElement = instance.pointerEventsScopeElement;
7134 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
7135 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
7136 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
7137 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
7138 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
7139 }
7140 instance.performedPointerEventsMutation = false;
7141 instance.pointerEventsScopeElement = null;
7142 instance.pointerEventsReferenceElement = null;
7143 instance.pointerEventsFloatingElement = null;
7144 }
7145 function applySafePolygonPointerEventsMutation(instance, options) {
7146 const {
7147 scopeElement,
7148 referenceElement,
7149 floatingElement
7150 } = options;
7151 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
7152 if (existingOwner && existingOwner !== instance) {
7153 clearSafePolygonPointerEventsMutation(existingOwner);
7154 }
7155 clearSafePolygonPointerEventsMutation(instance);
7156 instance.performedPointerEventsMutation = true;
7157 instance.pointerEventsScopeElement = scopeElement;
7158 instance.pointerEventsReferenceElement = referenceElement;
7159 instance.pointerEventsFloatingElement = floatingElement;
7160 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
7161 scopeElement.style.pointerEvents = "none";
7162 referenceElement.style.pointerEvents = "auto";
7163 floatingElement.style.pointerEvents = "auto";
7164 }
7165 function useHoverInteractionSharedState(store) {
7166 const data = store.context.dataRef.current;
7167 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
7168 if (!data.hoverInteractionState) {
7169 data.hoverInteractionState = instance;
7170 }
7171 useOnMount(data.hoverInteractionState.disposeEffect);
7172 return data.hoverInteractionState;
7173 }
7174
7175 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
7176 function useHoverFloatingInteraction(context, parameters = {}) {
7177 const {
7178 enabled = true,
7179 closeDelay: closeDelayProp = 0,
7180 nodeId: nodeIdProp
7181 } = parameters;
7182 const store = "rootStore" in context ? context.rootStore : context;
7183 const open = store.useState("open");
7184 const floatingElement = store.useState("floatingElement");
7185 const domReferenceElement = store.useState("domReferenceElement");
7186 const {
7187 dataRef
7188 } = store.context;
7189 const tree = useFloatingTree();
7190 const parentId = useFloatingParentNodeId();
7191 const instance = useHoverInteractionSharedState(store);
7192 const childClosedTimeout = useTimeout();
7193 const isClickLikeOpenEvent2 = useStableCallback(() => {
7194 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7195 });
7196 const isHoverOpen = useStableCallback(() => {
7197 return isHoverOpenEvent(dataRef.current.openEvent?.type);
7198 });
7199 const clearPointerEvents = useStableCallback(() => {
7200 clearSafePolygonPointerEventsMutation(instance);
7201 });
7202 useIsoLayoutEffect(() => {
7203 if (!open) {
7204 instance.pointerType = void 0;
7205 instance.restTimeoutPending = false;
7206 instance.interactedInside = false;
7207 clearPointerEvents();
7208 }
7209 }, [open, instance, clearPointerEvents]);
7210 React34.useEffect(() => {
7211 return clearPointerEvents;
7212 }, [clearPointerEvents]);
7213 useIsoLayoutEffect(() => {
7214 if (!enabled) {
7215 return void 0;
7216 }
7217 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
7218 const ref = domReferenceElement;
7219 const floatingEl = floatingElement;
7220 const doc = ownerDocument(floatingElement);
7221 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
7222 if (parentFloating) {
7223 parentFloating.style.pointerEvents = "";
7224 }
7225 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
7226 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
7227 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
7228 applySafePolygonPointerEventsMutation(instance, {
7229 scopeElement,
7230 referenceElement: ref,
7231 floatingElement: floatingEl
7232 });
7233 return () => {
7234 clearPointerEvents();
7235 };
7236 }
7237 return void 0;
7238 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
7239 React34.useEffect(() => {
7240 if (!enabled) {
7241 return void 0;
7242 }
7243 function hasParentChildren() {
7244 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
7245 }
7246 function closeWithDelay(event) {
7247 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
7248 const close = () => {
7249 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7250 tree?.events.emit("floating.closed", event);
7251 };
7252 if (closeDelay) {
7253 instance.openChangeTimeout.start(closeDelay, close);
7254 } else {
7255 instance.openChangeTimeout.clear();
7256 close();
7257 }
7258 }
7259 function handleInteractInside(event) {
7260 const target = getTarget(event);
7261 if (!isInteractiveElement(target)) {
7262 instance.interactedInside = false;
7263 return;
7264 }
7265 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
7266 }
7267 function onFloatingMouseEnter() {
7268 instance.openChangeTimeout.clear();
7269 childClosedTimeout.clear();
7270 tree?.events.off("floating.closed", onNodeClosed);
7271 clearPointerEvents();
7272 }
7273 function onFloatingMouseLeave(event) {
7274 if (hasParentChildren() && tree) {
7275 tree.events.on("floating.closed", onNodeClosed);
7276 return;
7277 }
7278 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7279 return;
7280 }
7281 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
7282 const relatedTarget = event.relatedTarget;
7283 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
7284 if (isMovingIntoDescendantFloating) {
7285 return;
7286 }
7287 if (instance.handler) {
7288 instance.handler(event);
7289 return;
7290 }
7291 clearPointerEvents();
7292 if (!isClickLikeOpenEvent2()) {
7293 closeWithDelay(event);
7294 }
7295 }
7296 function onNodeClosed(event) {
7297 if (!tree || !parentId || hasParentChildren()) {
7298 return;
7299 }
7300 childClosedTimeout.start(0, () => {
7301 tree.events.off("floating.closed", onNodeClosed);
7302 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7303 tree.events.emit("floating.closed", event);
7304 });
7305 }
7306 const floating = floatingElement;
7307 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
7308 tree?.events.off("floating.closed", onNodeClosed);
7309 });
7310 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
7311 }
7312
7313 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
7314 var React35 = __toESM(require_react(), 1);
7315 var ReactDOM4 = __toESM(require_react_dom(), 1);
7316 var EMPTY_REF = {
7317 current: null
7318 };
7319 function useHoverReferenceInteraction(context, props = {}) {
7320 const {
7321 enabled = true,
7322 delay = 0,
7323 handleClose = null,
7324 mouseOnly = false,
7325 restMs = 0,
7326 move = true,
7327 triggerElementRef = EMPTY_REF,
7328 externalTree,
7329 isActiveTrigger = true,
7330 getHandleCloseContext,
7331 isClosing,
7332 shouldOpen: shouldOpenProp
7333 } = props;
7334 const store = "rootStore" in context ? context.rootStore : context;
7335 const {
7336 dataRef,
7337 events
7338 } = store.context;
7339 const tree = useFloatingTree(externalTree);
7340 const instance = useHoverInteractionSharedState(store);
7341 const isHoverCloseActiveRef = React35.useRef(false);
7342 const handleCloseRef = useValueAsRef(handleClose);
7343 const delayRef = useValueAsRef(delay);
7344 const restMsRef = useValueAsRef(restMs);
7345 const enabledRef = useValueAsRef(enabled);
7346 const shouldOpenRef = useValueAsRef(shouldOpenProp);
7347 const isClosingRef = useValueAsRef(isClosing);
7348 const isClickLikeOpenEvent2 = useStableCallback(() => {
7349 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7350 });
7351 const checkShouldOpen = useStableCallback(() => {
7352 return shouldOpenRef.current?.() !== false;
7353 });
7354 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7355 const allTriggers = store.context.triggerElements;
7356 if (allTriggers.hasElement(currentTarget)) {
7357 return !currentDomReference || !contains(currentDomReference, currentTarget);
7358 }
7359 if (!isElement(target)) {
7360 return false;
7361 }
7362 const targetElement = target;
7363 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7364 });
7365 const cleanupMouseMoveHandler = useStableCallback(() => {
7366 if (!instance.handler) {
7367 return;
7368 }
7369 const doc = ownerDocument(store.select("domReferenceElement"));
7370 doc.removeEventListener("mousemove", instance.handler);
7371 instance.handler = void 0;
7372 });
7373 const clearPointerEvents = useStableCallback(() => {
7374 clearSafePolygonPointerEventsMutation(instance);
7375 });
7376 if (isActiveTrigger) {
7377 instance.handleCloseOptions = handleCloseRef.current?.__options;
7378 }
7379 React35.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7380 React35.useEffect(() => {
7381 if (!enabled) {
7382 return void 0;
7383 }
7384 function onOpenChangeLocal(details) {
7385 if (!details.open) {
7386 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7387 cleanupMouseMoveHandler();
7388 instance.openChangeTimeout.clear();
7389 instance.restTimeout.clear();
7390 instance.blockMouseMove = true;
7391 instance.restTimeoutPending = false;
7392 } else {
7393 isHoverCloseActiveRef.current = false;
7394 }
7395 }
7396 events.on("openchange", onOpenChangeLocal);
7397 return () => {
7398 events.off("openchange", onOpenChangeLocal);
7399 };
7400 }, [enabled, events, instance, cleanupMouseMoveHandler]);
7401 React35.useEffect(() => {
7402 if (!enabled) {
7403 return void 0;
7404 }
7405 function closeWithDelay(event, runElseBranch = true) {
7406 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7407 if (closeDelay) {
7408 instance.openChangeTimeout.start(closeDelay, () => {
7409 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7410 tree?.events.emit("floating.closed", event);
7411 });
7412 } else if (runElseBranch) {
7413 instance.openChangeTimeout.clear();
7414 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7415 tree?.events.emit("floating.closed", event);
7416 }
7417 }
7418 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
7419 if (!isElement(trigger)) {
7420 return void 0;
7421 }
7422 function onMouseEnter(event) {
7423 instance.openChangeTimeout.clear();
7424 instance.blockMouseMove = false;
7425 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7426 return;
7427 }
7428 const restMsValue = getRestMs(restMsRef.current);
7429 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7430 const eventTarget = getTarget(event);
7431 const currentTarget = event.currentTarget ?? null;
7432 const currentDomReference = store.select("domReferenceElement");
7433 let triggerNode = currentTarget;
7434 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
7435 for (const triggerElement of store.context.triggerElements.elements()) {
7436 if (contains(triggerElement, eventTarget)) {
7437 triggerNode = triggerElement;
7438 break;
7439 }
7440 }
7441 }
7442 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7443 triggerNode = currentDomReference;
7444 }
7445 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7446 const isOpen = store.select("open");
7447 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
7448 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
7449 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7450 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7451 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7452 const shouldOpen = !isOpen || isOverInactive;
7453 if (shouldOpenImmediately) {
7454 if (checkShouldOpen()) {
7455 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7456 }
7457 return;
7458 }
7459 if (isRestOnlyDelay) {
7460 return;
7461 }
7462 if (openDelay) {
7463 instance.openChangeTimeout.start(openDelay, () => {
7464 if (shouldOpen && checkShouldOpen()) {
7465 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7466 }
7467 });
7468 } else if (shouldOpen) {
7469 if (checkShouldOpen()) {
7470 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7471 }
7472 }
7473 }
7474 function onMouseLeave(event) {
7475 if (isClickLikeOpenEvent2()) {
7476 clearPointerEvents();
7477 return;
7478 }
7479 cleanupMouseMoveHandler();
7480 const domReferenceElement = store.select("domReferenceElement");
7481 const doc = ownerDocument(domReferenceElement);
7482 instance.restTimeout.clear();
7483 instance.restTimeoutPending = false;
7484 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7485 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7486 return;
7487 }
7488 if (handleCloseRef.current && handleCloseContextBase) {
7489 if (!store.select("open")) {
7490 instance.openChangeTimeout.clear();
7491 }
7492 const currentTrigger = triggerElementRef.current;
7493 instance.handler = handleCloseRef.current({
7494 ...handleCloseContextBase,
7495 tree,
7496 x: event.clientX,
7497 y: event.clientY,
7498 onClose() {
7499 clearPointerEvents();
7500 cleanupMouseMoveHandler();
7501 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7502 closeWithDelay(event, true);
7503 }
7504 }
7505 });
7506 doc.addEventListener("mousemove", instance.handler);
7507 instance.handler(event);
7508 return;
7509 }
7510 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7511 if (shouldClose) {
7512 closeWithDelay(event);
7513 }
7514 }
7515 if (move) {
7516 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7517 once: true
7518 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7519 }
7520 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7521 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
7522 return React35.useMemo(() => {
7523 if (!enabled) {
7524 return void 0;
7525 }
7526 function setPointerRef(event) {
7527 instance.pointerType = event.pointerType;
7528 }
7529 return {
7530 onPointerDown: setPointerRef,
7531 onPointerEnter: setPointerRef,
7532 onMouseMove(event) {
7533 const {
7534 nativeEvent
7535 } = event;
7536 const trigger = event.currentTarget;
7537 const currentDomReference = store.select("domReferenceElement");
7538 const currentOpen = store.select("open");
7539 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7540 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7541 return;
7542 }
7543 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7544 const floatingElement = store.select("floatingElement");
7545 if (floatingElement) {
7546 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7547 applySafePolygonPointerEventsMutation(instance, {
7548 scopeElement,
7549 referenceElement: trigger,
7550 floatingElement
7551 });
7552 }
7553 }
7554 const restMsValue = getRestMs(restMsRef.current);
7555 if (currentOpen && !isOverInactive || restMsValue === 0) {
7556 return;
7557 }
7558 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7559 return;
7560 }
7561 instance.restTimeout.clear();
7562 function handleMouseMove() {
7563 instance.restTimeoutPending = false;
7564 if (isClickLikeOpenEvent2()) {
7565 return;
7566 }
7567 const latestOpen = store.select("open");
7568 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7569 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7570 }
7571 }
7572 if (instance.pointerType === "touch") {
7573 ReactDOM4.flushSync(() => {
7574 handleMouseMove();
7575 });
7576 } else if (isOverInactive && currentOpen) {
7577 handleMouseMove();
7578 } else {
7579 instance.restTimeoutPending = true;
7580 instance.restTimeout.start(restMsValue, handleMouseMove);
7581 }
7582 }
7583 };
7584 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
7585 }
7586
7587 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
7588 var CURSOR_SPEED_THRESHOLD = 0.1;
7589 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7590 var POLYGON_BUFFER = 0.5;
7591 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7592 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7593 }
7594 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7595 let isInsideValue = false;
7596 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7597 isInsideValue = !isInsideValue;
7598 }
7599 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7600 isInsideValue = !isInsideValue;
7601 }
7602 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7603 isInsideValue = !isInsideValue;
7604 }
7605 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7606 isInsideValue = !isInsideValue;
7607 }
7608 return isInsideValue;
7609 }
7610 function isInsideRect(pointX, pointY, rect) {
7611 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7612 }
7613 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7614 const minX = Math.min(x1, x2);
7615 const maxX = Math.max(x1, x2);
7616 const minY = Math.min(y1, y2);
7617 const maxY = Math.max(y1, y2);
7618 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7619 }
7620 function safePolygon(options = {}) {
7621 const {
7622 blockPointerEvents = false
7623 } = options;
7624 const timeout = new Timeout();
7625 const fn = ({
7626 x: x2,
7627 y: y2,
7628 placement,
7629 elements,
7630 onClose,
7631 nodeId,
7632 tree
7633 }) => {
7634 const side = placement?.split("-")[0];
7635 let hasLanded = false;
7636 let lastX = null;
7637 let lastY = null;
7638 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7639 function isCursorMovingSlowly(nextX, nextY) {
7640 const currentTime = performance.now();
7641 const elapsedTime = currentTime - lastCursorTime;
7642 if (lastX === null || lastY === null || elapsedTime === 0) {
7643 lastX = nextX;
7644 lastY = nextY;
7645 lastCursorTime = currentTime;
7646 return false;
7647 }
7648 const deltaX = nextX - lastX;
7649 const deltaY = nextY - lastY;
7650 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7651 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7652 lastX = nextX;
7653 lastY = nextY;
7654 lastCursorTime = currentTime;
7655 return distanceSquared < thresholdSquared;
7656 }
7657 function close() {
7658 timeout.clear();
7659 onClose();
7660 }
7661 return function onMouseMove(event) {
7662 timeout.clear();
7663 const domReference = elements.domReference;
7664 const floating = elements.floating;
7665 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7666 return void 0;
7667 }
7668 const {
7669 clientX,
7670 clientY
7671 } = event;
7672 const target = getTarget(event);
7673 const isLeave = event.type === "mouseleave";
7674 const isOverFloatingEl = contains(floating, target);
7675 const isOverReferenceEl = contains(domReference, target);
7676 if (isOverFloatingEl) {
7677 hasLanded = true;
7678 if (!isLeave) {
7679 return void 0;
7680 }
7681 }
7682 if (isOverReferenceEl) {
7683 hasLanded = false;
7684 if (!isLeave) {
7685 hasLanded = true;
7686 return void 0;
7687 }
7688 }
7689 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7690 return void 0;
7691 }
7692 function hasOpenChildNode() {
7693 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7694 }
7695 function closeIfNoOpenChild() {
7696 if (!hasOpenChildNode()) {
7697 close();
7698 }
7699 }
7700 if (hasOpenChildNode()) {
7701 return void 0;
7702 }
7703 const refRect = domReference.getBoundingClientRect();
7704 const rect = floating.getBoundingClientRect();
7705 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7706 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7707 const isFloatingWider = rect.width > refRect.width;
7708 const isFloatingTaller = rect.height > refRect.height;
7709 const left = (isFloatingWider ? refRect : rect).left;
7710 const right = (isFloatingWider ? refRect : rect).right;
7711 const top = (isFloatingTaller ? refRect : rect).top;
7712 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7713 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) {
7714 closeIfNoOpenChild();
7715 return void 0;
7716 }
7717 let isInsideTroughRect = false;
7718 switch (side) {
7719 case "top":
7720 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7721 break;
7722 case "bottom":
7723 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7724 break;
7725 case "left":
7726 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7727 break;
7728 case "right":
7729 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7730 break;
7731 default:
7732 }
7733 if (isInsideTroughRect) {
7734 return void 0;
7735 }
7736 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7737 closeIfNoOpenChild();
7738 return void 0;
7739 }
7740 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7741 closeIfNoOpenChild();
7742 return void 0;
7743 }
7744 let isInsidePolygon = false;
7745 switch (side) {
7746 case "top": {
7747 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7748 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7749 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7750 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7751 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7752 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7753 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7754 break;
7755 }
7756 case "bottom": {
7757 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7758 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7759 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7760 const cursorPointY = y2 - POLYGON_BUFFER;
7761 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7762 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7763 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7764 break;
7765 }
7766 case "left": {
7767 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7768 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7769 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7770 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7771 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7772 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7773 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7774 break;
7775 }
7776 case "right": {
7777 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7778 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7779 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7780 const cursorPointX = x2 - POLYGON_BUFFER;
7781 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7782 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7783 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7784 break;
7785 }
7786 default:
7787 }
7788 if (!isInsidePolygon) {
7789 closeIfNoOpenChild();
7790 } else if (!hasLanded) {
7791 timeout.start(40, closeIfNoOpenChild);
7792 }
7793 return void 0;
7794 };
7795 };
7796 fn.__options = {
7797 ...options,
7798 blockPointerEvents
7799 };
7800 return fn;
7801 }
7802
7803 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7804 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7805 CommonPopupDataAttributes2["open"] = "data-open";
7806 CommonPopupDataAttributes2["closed"] = "data-closed";
7807 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7808 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7809 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7810 CommonPopupDataAttributes2["side"] = "data-side";
7811 CommonPopupDataAttributes2["align"] = "data-align";
7812 return CommonPopupDataAttributes2;
7813 })({});
7814 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7815 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7816 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7817 return CommonTriggerDataAttributes2;
7818 })({});
7819 var TRIGGER_HOOK = {
7820 [CommonTriggerDataAttributes.popupOpen]: ""
7821 };
7822 var PRESSABLE_TRIGGER_HOOK = {
7823 [CommonTriggerDataAttributes.popupOpen]: "",
7824 [CommonTriggerDataAttributes.pressed]: ""
7825 };
7826 var POPUP_OPEN_HOOK = {
7827 [CommonPopupDataAttributes.open]: ""
7828 };
7829 var POPUP_CLOSED_HOOK = {
7830 [CommonPopupDataAttributes.closed]: ""
7831 };
7832 var ANCHOR_HIDDEN_HOOK = {
7833 [CommonPopupDataAttributes.anchorHidden]: ""
7834 };
7835 var triggerOpenStateMapping2 = {
7836 open(value) {
7837 if (value) {
7838 return TRIGGER_HOOK;
7839 }
7840 return null;
7841 }
7842 };
7843 var popupStateMapping = {
7844 open(value) {
7845 if (value) {
7846 return POPUP_OPEN_HOOK;
7847 }
7848 return POPUP_CLOSED_HOOK;
7849 },
7850 anchorHidden(value) {
7851 if (value) {
7852 return ANCHOR_HIDDEN_HOOK;
7853 }
7854 return null;
7855 }
7856 };
7857
7858 // node_modules/@base-ui/utils/esm/inertValue.js
7859 function inertValue(value) {
7860 if (isReactVersionAtLeast(19)) {
7861 return value;
7862 }
7863 return value ? "true" : void 0;
7864 }
7865
7866 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7867 var React36 = __toESM(require_react(), 1);
7868
7869 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7870 var baseArrow = (options) => ({
7871 name: "arrow",
7872 options,
7873 async fn(state) {
7874 const {
7875 x: x2,
7876 y: y2,
7877 placement,
7878 rects,
7879 platform: platform3,
7880 elements,
7881 middlewareData
7882 } = state;
7883 const {
7884 element,
7885 padding = 0,
7886 offsetParent = "real"
7887 } = evaluate(options, state) || {};
7888 if (element == null) {
7889 return {};
7890 }
7891 const paddingObject = getPaddingObject(padding);
7892 const coords = {
7893 x: x2,
7894 y: y2
7895 };
7896 const axis = getAlignmentAxis(placement);
7897 const length = getAxisLength(axis);
7898 const arrowDimensions = await platform3.getDimensions(element);
7899 const isYAxis = axis === "y";
7900 const minProp = isYAxis ? "top" : "left";
7901 const maxProp = isYAxis ? "bottom" : "right";
7902 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7903 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7904 const startDiff = coords[axis] - rects.reference[axis];
7905 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7906 let clientSize = elements.floating[clientProp] || rects.floating[length];
7907 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7908 clientSize = elements.floating[clientProp] || rects.floating[length];
7909 }
7910 const centerToReference = endDiff / 2 - startDiff / 2;
7911 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7912 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7913 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7914 const min2 = minPadding;
7915 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7916 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7917 const offset4 = clamp(min2, center, max2);
7918 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7919 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7920 return {
7921 [axis]: coords[axis] + alignmentOffset,
7922 data: {
7923 [axis]: offset4,
7924 centerOffset: center - offset4 - alignmentOffset,
7925 ...shouldAddOffset && {
7926 alignmentOffset
7927 }
7928 },
7929 reset: shouldAddOffset
7930 };
7931 }
7932 });
7933 var arrow4 = (options, deps) => ({
7934 ...baseArrow(options),
7935 options: [options, deps]
7936 });
7937
7938 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7939 var hide4 = {
7940 name: "hide",
7941 async fn(state) {
7942 const {
7943 width,
7944 height,
7945 x: x2,
7946 y: y2
7947 } = state.rects.reference;
7948 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7949 const nativeHideResult = await hide3().fn(state);
7950 return {
7951 data: {
7952 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7953 }
7954 };
7955 }
7956 };
7957
7958 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7959 var DEFAULT_SIDES = {
7960 sideX: "left",
7961 sideY: "top"
7962 };
7963 var adaptiveOrigin = {
7964 name: "adaptiveOrigin",
7965 async fn(state) {
7966 const {
7967 x: rawX,
7968 y: rawY,
7969 rects: {
7970 floating: floatRect
7971 },
7972 elements: {
7973 floating
7974 },
7975 platform: platform3,
7976 strategy,
7977 placement
7978 } = state;
7979 const win = getWindow(floating);
7980 const styles = win.getComputedStyle(floating);
7981 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7982 if (!hasTransition) {
7983 return {
7984 x: rawX,
7985 y: rawY,
7986 data: DEFAULT_SIDES
7987 };
7988 }
7989 const offsetParent = await platform3.getOffsetParent?.(floating);
7990 let offsetDimensions = {
7991 width: 0,
7992 height: 0
7993 };
7994 if (strategy === "fixed" && win?.visualViewport) {
7995 offsetDimensions = {
7996 width: win.visualViewport.width,
7997 height: win.visualViewport.height
7998 };
7999 } else if (offsetParent === win) {
8000 const doc = ownerDocument(floating);
8001 offsetDimensions = {
8002 width: doc.documentElement.clientWidth,
8003 height: doc.documentElement.clientHeight
8004 };
8005 } else if (await platform3.isElement?.(offsetParent)) {
8006 offsetDimensions = await platform3.getDimensions(offsetParent);
8007 }
8008 const currentSide = getSide(placement);
8009 let x2 = rawX;
8010 let y2 = rawY;
8011 if (currentSide === "left") {
8012 x2 = offsetDimensions.width - (rawX + floatRect.width);
8013 }
8014 if (currentSide === "top") {
8015 y2 = offsetDimensions.height - (rawY + floatRect.height);
8016 }
8017 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
8018 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
8019 return {
8020 x: x2,
8021 y: y2,
8022 data: {
8023 sideX,
8024 sideY
8025 }
8026 };
8027 }
8028 };
8029
8030 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
8031 function getLogicalSide(sideParam, renderedSide, isRtl) {
8032 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
8033 const logicalRight = isRtl ? "inline-start" : "inline-end";
8034 const logicalLeft = isRtl ? "inline-end" : "inline-start";
8035 return {
8036 top: "top",
8037 right: isLogicalSideParam ? logicalRight : "right",
8038 bottom: "bottom",
8039 left: isLogicalSideParam ? logicalLeft : "left"
8040 }[renderedSide];
8041 }
8042 function getOffsetData(state, sideParam, isRtl) {
8043 const {
8044 rects,
8045 placement
8046 } = state;
8047 const data = {
8048 side: getLogicalSide(sideParam, getSide(placement), isRtl),
8049 align: getAlignment(placement) || "center",
8050 anchor: {
8051 width: rects.reference.width,
8052 height: rects.reference.height
8053 },
8054 positioner: {
8055 width: rects.floating.width,
8056 height: rects.floating.height
8057 }
8058 };
8059 return data;
8060 }
8061 function useAnchorPositioning(params) {
8062 const {
8063 // Public parameters
8064 anchor,
8065 positionMethod = "absolute",
8066 side: sideParam = "bottom",
8067 sideOffset = 0,
8068 align = "center",
8069 alignOffset = 0,
8070 collisionBoundary,
8071 collisionPadding: collisionPaddingParam = 5,
8072 sticky = false,
8073 arrowPadding = 5,
8074 disableAnchorTracking = false,
8075 inline: inlineMiddleware,
8076 // Private parameters
8077 keepMounted = false,
8078 floatingRootContext,
8079 mounted,
8080 collisionAvoidance,
8081 shiftCrossAxis = false,
8082 nodeId,
8083 adaptiveOrigin: adaptiveOrigin2,
8084 lazyFlip = false,
8085 externalTree
8086 } = params;
8087 const [mountSide, setMountSide] = React36.useState(null);
8088 if (!mounted && mountSide !== null) {
8089 setMountSide(null);
8090 }
8091 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
8092 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
8093 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
8094 const anchorFn = typeof anchor === "function" ? anchor : void 0;
8095 const anchorFnCallback = useStableCallback(anchorFn);
8096 const anchorDep = anchorFn ? anchorFnCallback : anchor;
8097 const anchorValueRef = useValueAsRef(anchor);
8098 const mountedRef = useValueAsRef(mounted);
8099 const direction = useDirection();
8100 const isRtl = direction === "rtl";
8101 const side = mountSide || {
8102 top: "top",
8103 right: "right",
8104 bottom: "bottom",
8105 left: "left",
8106 "inline-end": isRtl ? "left" : "right",
8107 "inline-start": isRtl ? "right" : "left"
8108 }[sideParam];
8109 const placement = align === "center" ? side : `${side}-${align}`;
8110 let collisionPadding = collisionPaddingParam;
8111 const bias = 1;
8112 const biasTop = sideParam === "bottom" ? bias : 0;
8113 const biasBottom = sideParam === "top" ? bias : 0;
8114 const biasLeft = sideParam === "right" ? bias : 0;
8115 const biasRight = sideParam === "left" ? bias : 0;
8116 if (typeof collisionPadding === "number") {
8117 collisionPadding = {
8118 top: collisionPadding + biasTop,
8119 right: collisionPadding + biasRight,
8120 bottom: collisionPadding + biasBottom,
8121 left: collisionPadding + biasLeft
8122 };
8123 } else if (collisionPadding) {
8124 collisionPadding = {
8125 top: (collisionPadding.top || 0) + biasTop,
8126 right: (collisionPadding.right || 0) + biasRight,
8127 bottom: (collisionPadding.bottom || 0) + biasBottom,
8128 left: (collisionPadding.left || 0) + biasLeft
8129 };
8130 }
8131 const commonCollisionProps = {
8132 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
8133 padding: collisionPadding
8134 };
8135 const arrowRef = React36.useRef(null);
8136 const sideOffsetRef = useValueAsRef(sideOffset);
8137 const alignOffsetRef = useValueAsRef(alignOffset);
8138 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
8139 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
8140 const middleware = [];
8141 if (inlineMiddleware) {
8142 middleware.push(inlineMiddleware);
8143 }
8144 middleware.push(offset3((state) => {
8145 const data = getOffsetData(state, sideParam, isRtl);
8146 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
8147 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
8148 return {
8149 mainAxis: sideAxis,
8150 crossAxis: alignAxis,
8151 alignmentAxis: alignAxis
8152 };
8153 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
8154 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
8155 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
8156 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
8157 ...commonCollisionProps,
8158 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
8159 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
8160 padding: {
8161 top: collisionPadding.top + bias,
8162 right: collisionPadding.right + bias,
8163 bottom: collisionPadding.bottom + bias,
8164 left: collisionPadding.left + bias
8165 },
8166 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
8167 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
8168 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
8169 });
8170 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
8171 const html = ownerDocument(data.elements.floating).documentElement;
8172 return {
8173 ...commonCollisionProps,
8174 // Use the Layout Viewport to avoid shifting around when pinch-zooming
8175 // for context menus.
8176 rootBoundary: shiftCrossAxis ? {
8177 x: 0,
8178 y: 0,
8179 width: html.clientWidth,
8180 height: html.clientHeight
8181 } : void 0,
8182 mainAxis: collisionAvoidanceAlign !== "none",
8183 crossAxis: crossAxisShiftEnabled,
8184 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
8185 if (!arrowRef.current) {
8186 return {};
8187 }
8188 const {
8189 width,
8190 height
8191 } = arrowRef.current.getBoundingClientRect();
8192 const sideAxis = getSideAxis(getSide(limitData.placement));
8193 const arrowSize = sideAxis === "y" ? width : height;
8194 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
8195 return {
8196 offset: arrowSize / 2 + offsetAmount / 2
8197 };
8198 })
8199 };
8200 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
8201 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
8202 middleware.push(shiftMiddleware, flipMiddleware);
8203 } else {
8204 middleware.push(flipMiddleware, shiftMiddleware);
8205 }
8206 middleware.push(size3({
8207 ...commonCollisionProps,
8208 apply({
8209 elements: {
8210 floating
8211 },
8212 availableWidth,
8213 availableHeight,
8214 rects
8215 }) {
8216 if (!mountedRef.current) {
8217 return;
8218 }
8219 const floatingStyle = floating.style;
8220 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
8221 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
8222 const dpr = getWindow(floating).devicePixelRatio || 1;
8223 const {
8224 x: x3,
8225 y: y3,
8226 width,
8227 height
8228 } = rects.reference;
8229 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
8230 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
8231 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
8232 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
8233 }
8234 }), arrow4((state) => ({
8235 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
8236 // we'll create a fake element.
8237 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
8238 padding: arrowPadding,
8239 offsetParent: "floating"
8240 }), [arrowPadding]), {
8241 name: "transformOrigin",
8242 fn(state) {
8243 const {
8244 elements: elements2,
8245 middlewareData: middlewareData2,
8246 placement: renderedPlacement2,
8247 rects,
8248 y: y3
8249 } = state;
8250 const currentRenderedSide = getSide(renderedPlacement2);
8251 const currentRenderedAxis = getSideAxis(currentRenderedSide);
8252 const arrowEl = arrowRef.current;
8253 const arrowX = middlewareData2.arrow?.x || 0;
8254 const arrowY = middlewareData2.arrow?.y || 0;
8255 const arrowWidth = arrowEl?.clientWidth || 0;
8256 const arrowHeight = arrowEl?.clientHeight || 0;
8257 const transformX = arrowX + arrowWidth / 2;
8258 const transformY = arrowY + arrowHeight / 2;
8259 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
8260 const halfAnchorHeight = rects.reference.height / 2;
8261 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
8262 const isOverlappingAnchor = shiftY > sideOffsetValue;
8263 const adjacentTransformOrigin = {
8264 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
8265 bottom: `${transformX}px ${-sideOffsetValue}px`,
8266 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
8267 right: `${-sideOffsetValue}px ${transformY}px`
8268 }[currentRenderedSide];
8269 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
8270 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
8271 return {};
8272 }
8273 }, hide4, adaptiveOrigin2);
8274 useIsoLayoutEffect(() => {
8275 if (!mounted && floatingRootContext) {
8276 floatingRootContext.update({
8277 referenceElement: null,
8278 floatingElement: null,
8279 domReferenceElement: null,
8280 positionReference: null
8281 });
8282 }
8283 }, [mounted, floatingRootContext]);
8284 const autoUpdateOptions = React36.useMemo(() => ({
8285 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
8286 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
8287 }), [disableAnchorTracking]);
8288 const {
8289 refs,
8290 elements,
8291 x: x2,
8292 y: y2,
8293 middlewareData,
8294 update: update2,
8295 placement: renderedPlacement,
8296 context,
8297 isPositioned,
8298 floatingStyles: originalFloatingStyles
8299 } = useFloating2({
8300 rootContext: floatingRootContext,
8301 open: keepMounted ? mounted : void 0,
8302 placement,
8303 middleware,
8304 strategy: positionMethod,
8305 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
8306 nodeId,
8307 externalTree
8308 });
8309 const {
8310 sideX,
8311 sideY
8312 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
8313 const resolvedPosition = isPositioned ? positionMethod : "fixed";
8314 const floatingStyles = React36.useMemo(() => {
8315 const base = adaptiveOrigin2 ? {
8316 position: resolvedPosition,
8317 [sideX]: x2,
8318 [sideY]: y2
8319 } : {
8320 position: resolvedPosition,
8321 ...originalFloatingStyles
8322 };
8323 if (!isPositioned) {
8324 base.opacity = 0;
8325 }
8326 return base;
8327 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
8328 const registeredPositionReferenceRef = React36.useRef(null);
8329 useIsoLayoutEffect(() => {
8330 if (!mounted) {
8331 return;
8332 }
8333 const anchorValue = anchorValueRef.current;
8334 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
8335 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
8336 const finalAnchor = unwrappedElement || null;
8337 if (finalAnchor !== registeredPositionReferenceRef.current) {
8338 refs.setPositionReference(finalAnchor);
8339 registeredPositionReferenceRef.current = finalAnchor;
8340 }
8341 }, [mounted, refs, anchorDep, anchorValueRef]);
8342 React36.useEffect(() => {
8343 if (!mounted) {
8344 return;
8345 }
8346 const anchorValue = anchorValueRef.current;
8347 if (typeof anchorValue === "function") {
8348 return;
8349 }
8350 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
8351 refs.setPositionReference(anchorValue.current);
8352 registeredPositionReferenceRef.current = anchorValue.current;
8353 }
8354 }, [mounted, refs, anchorDep, anchorValueRef]);
8355 React36.useEffect(() => {
8356 if (keepMounted && mounted && elements.domReference && elements.floating) {
8357 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
8358 }
8359 return void 0;
8360 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
8361 const renderedSide = getSide(renderedPlacement);
8362 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
8363 const renderedAlign = getAlignment(renderedPlacement) || "center";
8364 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
8365 useIsoLayoutEffect(() => {
8366 if (lazyFlip && mounted && isPositioned) {
8367 setMountSide(renderedSide);
8368 }
8369 }, [lazyFlip, mounted, isPositioned, renderedSide]);
8370 const arrowStyles = React36.useMemo(() => ({
8371 position: "absolute",
8372 top: middlewareData.arrow?.y,
8373 left: middlewareData.arrow?.x
8374 }), [middlewareData.arrow]);
8375 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
8376 return React36.useMemo(() => ({
8377 positionerStyles: floatingStyles,
8378 arrowStyles,
8379 arrowRef,
8380 arrowUncentered,
8381 side: logicalRenderedSide,
8382 align: renderedAlign,
8383 physicalSide: renderedSide,
8384 anchorHidden,
8385 refs,
8386 context,
8387 isPositioned,
8388 update: update2
8389 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
8390 }
8391 function isRef(param) {
8392 return param != null && "current" in param;
8393 }
8394
8395 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
8396 function getDisabledMountTransitionStyles(transitionStatus) {
8397 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
8398 }
8399
8400 // node_modules/@base-ui/react/esm/utils/usePositioner.js
8401 function usePositioner(componentProps, state, {
8402 styles,
8403 transitionStatus,
8404 props,
8405 refs,
8406 hidden,
8407 inert = false
8408 }) {
8409 const style = {
8410 ...styles
8411 };
8412 if (inert) {
8413 style.pointerEvents = "none";
8414 }
8415 return useRenderElement("div", componentProps, {
8416 state,
8417 ref: refs,
8418 props: [{
8419 role: "presentation",
8420 hidden,
8421 style
8422 }, getDisabledMountTransitionStyles(transitionStatus), props],
8423 stateAttributesMapping: popupStateMapping
8424 });
8425 }
8426
8427 // node_modules/@base-ui/react/esm/button/Button.js
8428 var React37 = __toESM(require_react(), 1);
8429 var Button = /* @__PURE__ */ React37.forwardRef(function Button2(componentProps, forwardedRef) {
8430 const {
8431 render: render4,
8432 className,
8433 disabled: disabled2 = false,
8434 focusableWhenDisabled = false,
8435 nativeButton = true,
8436 style,
8437 ...elementProps
8438 } = componentProps;
8439 const {
8440 getButtonProps,
8441 buttonRef
8442 } = useButton({
8443 disabled: disabled2,
8444 focusableWhenDisabled,
8445 native: nativeButton
8446 });
8447 const state = {
8448 disabled: disabled2
8449 };
8450 return useRenderElement("button", componentProps, {
8451 state,
8452 ref: [forwardedRef, buttonRef],
8453 props: [elementProps, getButtonProps]
8454 });
8455 });
8456 if (true) Button.displayName = "Button";
8457
8458 // node_modules/@base-ui/react/esm/collapsible/index.parts.js
8459 var index_parts_exports = {};
8460 __export(index_parts_exports, {
8461 Panel: () => CollapsiblePanel,
8462 Root: () => CollapsibleRoot,
8463 Trigger: () => CollapsibleTrigger
8464 });
8465
8466 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
8467 var React38 = __toESM(require_react(), 1);
8468
8469 // node_modules/@base-ui/react/esm/collapsible/root/stateAttributesMapping.js
8470 var collapsibleStateAttributesMapping = {
8471 ...collapsibleOpenStateMapping,
8472 ...transitionStatusMapping
8473 };
8474
8475 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
8476 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8477 var CollapsibleRoot = /* @__PURE__ */ React38.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) {
8478 const {
8479 render: render4,
8480 className,
8481 defaultOpen = false,
8482 disabled: disabled2 = false,
8483 onOpenChange: onOpenChangeProp,
8484 open,
8485 style,
8486 ...elementProps
8487 } = componentProps;
8488 const onOpenChange = useStableCallback(onOpenChangeProp);
8489 const collapsible = useCollapsibleRoot({
8490 open,
8491 defaultOpen,
8492 onOpenChange,
8493 disabled: disabled2
8494 });
8495 const state = React38.useMemo(() => ({
8496 open: collapsible.open,
8497 disabled: collapsible.disabled,
8498 transitionStatus: collapsible.transitionStatus
8499 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]);
8500 const contextValue = React38.useMemo(() => ({
8501 ...collapsible,
8502 onOpenChange,
8503 state
8504 }), [collapsible, onOpenChange, state]);
8505 const element = useRenderElement("div", componentProps, {
8506 state,
8507 ref: forwardedRef,
8508 props: elementProps,
8509 stateAttributesMapping: collapsibleStateAttributesMapping
8510 });
8511 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollapsibleRootContext.Provider, {
8512 value: contextValue,
8513 children: element
8514 });
8515 });
8516 if (true) CollapsibleRoot.displayName = "CollapsibleRoot";
8517
8518 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTrigger.js
8519 var React39 = __toESM(require_react(), 1);
8520 var stateAttributesMapping = {
8521 ...triggerOpenStateMapping,
8522 ...transitionStatusMapping
8523 };
8524 var CollapsibleTrigger = /* @__PURE__ */ React39.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) {
8525 const {
8526 panelId,
8527 open,
8528 handleTrigger,
8529 state,
8530 disabled: contextDisabled
8531 } = useCollapsibleRootContext();
8532 const {
8533 className,
8534 disabled: disabled2 = contextDisabled,
8535 id,
8536 render: render4,
8537 nativeButton = true,
8538 style,
8539 ...elementProps
8540 } = componentProps;
8541 const {
8542 getButtonProps,
8543 buttonRef
8544 } = useButton({
8545 disabled: disabled2,
8546 focusableWhenDisabled: true,
8547 native: nativeButton
8548 });
8549 const element = useRenderElement("button", componentProps, {
8550 state,
8551 ref: [forwardedRef, buttonRef],
8552 props: [{
8553 "aria-controls": open ? panelId : void 0,
8554 "aria-expanded": open,
8555 onClick: handleTrigger
8556 }, elementProps, getButtonProps],
8557 stateAttributesMapping
8558 });
8559 return element;
8560 });
8561 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger";
8562
8563 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
8564 var React40 = __toESM(require_react(), 1);
8565
8566 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelCssVars.js
8567 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) {
8568 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height";
8569 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width";
8570 return CollapsiblePanelCssVars2;
8571 })({});
8572
8573 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
8574 var CollapsiblePanel = /* @__PURE__ */ React40.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) {
8575 const {
8576 className,
8577 hiddenUntilFound: hiddenUntilFoundProp,
8578 keepMounted: keepMountedProp,
8579 render: render4,
8580 id: idProp,
8581 style,
8582 ...elementProps
8583 } = componentProps;
8584 if (true) {
8585 useIsoLayoutEffect(() => {
8586 if (hiddenUntilFoundProp && keepMountedProp === false) {
8587 warn("The `keepMounted={false}` prop on `Collapsible.Panel` is ignored when `hiddenUntilFound` is enabled, since the panel must remain mounted while closed.");
8588 }
8589 }, [hiddenUntilFoundProp, keepMountedProp]);
8590 }
8591 const {
8592 mounted,
8593 onOpenChange,
8594 open,
8595 panelId,
8596 setMounted,
8597 setPanelIdState,
8598 setOpen,
8599 state,
8600 transitionStatus
8601 } = useCollapsibleRootContext();
8602 const hiddenUntilFound = hiddenUntilFoundProp ?? false;
8603 const keepMounted = keepMountedProp ?? false;
8604 useIsoLayoutEffect(() => {
8605 if (idProp) {
8606 setPanelIdState(idProp);
8607 return () => {
8608 setPanelIdState(void 0);
8609 };
8610 }
8611 return void 0;
8612 }, [idProp, setPanelIdState]);
8613 const {
8614 height,
8615 props,
8616 ref,
8617 shouldPreventOpenAnimation,
8618 shouldRender,
8619 transitionStatus: panelTransitionStatus,
8620 width
8621 } = useCollapsiblePanel({
8622 externalRef: forwardedRef,
8623 hiddenUntilFound,
8624 id: panelId,
8625 keepMounted,
8626 mounted,
8627 onOpenChange,
8628 open,
8629 setMounted,
8630 setOpen,
8631 transitionStatus
8632 });
8633 const panelState = {
8634 ...state,
8635 transitionStatus: panelTransitionStatus
8636 };
8637 const resolvedStyle = resolveStyle(style, panelState);
8638 const element = useRenderElement("div", {
8639 ...componentProps,
8640 style: void 0
8641 }, {
8642 state: panelState,
8643 ref,
8644 props: [
8645 props,
8646 {
8647 style: {
8648 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `${height}px`,
8649 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `${width}px`
8650 }
8651 },
8652 elementProps,
8653 resolvedStyle ? {
8654 style: resolvedStyle
8655 } : void 0,
8656 // Resolve the public `style` prop so temporary `animationName: 'none'`
8657 // can still win after user's inline styles have been merged.
8658 shouldPreventOpenAnimation ? {
8659 style: {
8660 animationName: "none"
8661 }
8662 } : void 0
8663 ],
8664 stateAttributesMapping: collapsibleStateAttributesMapping
8665 });
8666 if (!shouldRender) {
8667 return null;
8668 }
8669 return element;
8670 });
8671 if (true) CollapsiblePanel.displayName = "CollapsiblePanel";
8672
8673 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
8674 var React43 = __toESM(require_react(), 1);
8675 var ReactDOM5 = __toESM(require_react_dom(), 1);
8676
8677 // node_modules/@base-ui/utils/esm/usePreviousValue.js
8678 var React41 = __toESM(require_react(), 1);
8679 function usePreviousValue(value) {
8680 const [state, setState] = React41.useState({
8681 current: value,
8682 previous: null
8683 });
8684 if (value !== state.current) {
8685 setState({
8686 current: value,
8687 previous: state.current
8688 });
8689 }
8690 return state.previous;
8691 }
8692
8693 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
8694 var React42 = __toESM(require_react(), 1);
8695
8696 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
8697 function getCssDimensions2(element) {
8698 const css = getComputedStyle2(element);
8699 let width = parseFloat(css.width) || 0;
8700 let height = parseFloat(css.height) || 0;
8701 const hasOffset = isHTMLElement(element);
8702 const offsetWidth = hasOffset ? element.offsetWidth : width;
8703 const offsetHeight = hasOffset ? element.offsetHeight : height;
8704 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
8705 if (shouldFallback) {
8706 width = offsetWidth;
8707 height = offsetHeight;
8708 }
8709 return {
8710 width,
8711 height
8712 };
8713 }
8714
8715 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
8716 var DEFAULT_ENABLED = () => true;
8717 function usePopupAutoResize(parameters) {
8718 const {
8719 popupElement,
8720 positionerElement,
8721 content,
8722 mounted,
8723 enabled = DEFAULT_ENABLED,
8724 onMeasureLayout: onMeasureLayoutParam,
8725 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8726 side,
8727 direction
8728 } = parameters;
8729 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8730 const animationFrame = useAnimationFrame();
8731 const committedDimensionsRef = React42.useRef(null);
8732 const liveDimensionsRef = React42.useRef(null);
8733 const isInitialRenderRef = React42.useRef(true);
8734 const restoreAnchoringStylesRef = React42.useRef(NOOP);
8735 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8736 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8737 const anchoringStyles = React42.useMemo(() => {
8738 let isOriginSide = side === "top";
8739 let isPhysicalLeft = side === "left";
8740 if (direction === "rtl") {
8741 isOriginSide = isOriginSide || side === "inline-end";
8742 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8743 } else {
8744 isOriginSide = isOriginSide || side === "inline-start";
8745 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8746 }
8747 return isOriginSide ? {
8748 position: "absolute",
8749 [side === "top" ? "bottom" : "top"]: "0",
8750 [isPhysicalLeft ? "right" : "left"]: "0"
8751 } : EMPTY_OBJECT;
8752 }, [side, direction]);
8753 useIsoLayoutEffect(() => {
8754 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
8755 restoreAnchoringStylesRef.current = NOOP;
8756 isInitialRenderRef.current = true;
8757 committedDimensionsRef.current = null;
8758 liveDimensionsRef.current = null;
8759 return void 0;
8760 }
8761 if (!popupElement || !positionerElement) {
8762 return void 0;
8763 }
8764 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8765 const observer = new ResizeObserver((entries) => {
8766 const entry = entries[0];
8767 if (entry) {
8768 liveDimensionsRef.current = {
8769 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
8770 height: Math.ceil(entry.borderBoxSize[0].blockSize)
8771 };
8772 }
8773 });
8774 observer.observe(popupElement);
8775 setPopupCssSize(popupElement, "auto");
8776 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8777 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8778 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8779 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8780 "--available-width": "max-content",
8781 "--available-height": "max-content"
8782 });
8783 function restoreMeasurementOverrides() {
8784 restorePopupPosition();
8785 restorePopupTransform();
8786 restorePositionerAvailableSize();
8787 }
8788 function restoreMeasurementOverridesIncludingScale() {
8789 restoreMeasurementOverrides();
8790 restorePopupScale();
8791 }
8792 onMeasureLayout?.();
8793 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8794 setPositionerCssSize(positionerElement, "max-content");
8795 const dimensions = getCssDimensions2(popupElement);
8796 committedDimensionsRef.current = dimensions;
8797 setPositionerCssSize(positionerElement, dimensions);
8798 restoreMeasurementOverridesIncludingScale();
8799 onMeasureLayoutComplete?.(null, dimensions);
8800 isInitialRenderRef.current = false;
8801 return () => {
8802 observer.disconnect();
8803 restoreAnchoringStylesRef.current();
8804 restoreAnchoringStylesRef.current = NOOP;
8805 };
8806 }
8807 setPopupCssSize(popupElement, "auto");
8808 setPositionerCssSize(positionerElement, "max-content");
8809 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
8810 const newDimensions = getCssDimensions2(popupElement);
8811 committedDimensionsRef.current = newDimensions;
8812 if (!previousDimensions) {
8813 setPositionerCssSize(positionerElement, newDimensions);
8814 restoreMeasurementOverridesIncludingScale();
8815 onMeasureLayoutComplete?.(null, newDimensions);
8816 return () => {
8817 observer.disconnect();
8818 animationFrame.cancel();
8819 restoreAnchoringStylesRef.current();
8820 restoreAnchoringStylesRef.current = NOOP;
8821 };
8822 }
8823 setPopupCssSize(popupElement, previousDimensions);
8824 restoreMeasurementOverridesIncludingScale();
8825 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8826 setPositionerCssSize(positionerElement, newDimensions);
8827 const abortController = new AbortController();
8828 animationFrame.request(() => {
8829 setPopupCssSize(popupElement, newDimensions);
8830 runOnceAnimationsFinish(() => {
8831 popupElement.style.setProperty("--popup-width", "auto");
8832 popupElement.style.setProperty("--popup-height", "auto");
8833 }, abortController.signal);
8834 });
8835 return () => {
8836 observer.disconnect();
8837 abortController.abort();
8838 animationFrame.cancel();
8839 restoreAnchoringStylesRef.current();
8840 restoreAnchoringStylesRef.current = NOOP;
8841 };
8842 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8843 }
8844 function overrideElementStyle(element, property, value) {
8845 const originalValue = element.style.getPropertyValue(property);
8846 element.style.setProperty(property, value);
8847 return () => {
8848 element.style.setProperty(property, originalValue);
8849 };
8850 }
8851 function applyElementStyles(element, styles) {
8852 const restorers = [];
8853 for (const [key, value] of Object.entries(styles)) {
8854 restorers.push(overrideElementStyle(element, key, value));
8855 }
8856 return restorers.length ? () => {
8857 restorers.forEach((restore) => restore());
8858 } : NOOP;
8859 }
8860 function setPopupCssSize(popupElement, size4) {
8861 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8862 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8863 popupElement.style.setProperty("--popup-width", width);
8864 popupElement.style.setProperty("--popup-height", height);
8865 }
8866 function setPositionerCssSize(positionerElement, size4) {
8867 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8868 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8869 positionerElement.style.setProperty("--positioner-width", width);
8870 positionerElement.style.setProperty("--positioner-height", height);
8871 }
8872
8873 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
8874 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8875 function usePopupViewport(parameters) {
8876 const {
8877 store,
8878 side,
8879 cssVars,
8880 children
8881 } = parameters;
8882 const direction = useDirection();
8883 const activeTrigger = store.useState("activeTriggerElement");
8884 const activeTriggerId = store.useState("activeTriggerId");
8885 const open = store.useState("open");
8886 const payload = store.useState("payload");
8887 const mounted = store.useState("mounted");
8888 const popupElement = store.useState("popupElement");
8889 const positionerElement = store.useState("positionerElement");
8890 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8891 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8892 const capturedNodeRef = React43.useRef(null);
8893 const [previousContentNode, setPreviousContentNode] = React43.useState(null);
8894 const [newTriggerOffset, setNewTriggerOffset] = React43.useState(null);
8895 const currentContainerRef = React43.useRef(null);
8896 const previousContainerRef = React43.useRef(null);
8897 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8898 const cleanupFrame = useAnimationFrame();
8899 const [previousContentDimensions, setPreviousContentDimensions] = React43.useState(null);
8900 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React43.useState(false);
8901 useIsoLayoutEffect(() => {
8902 store.set("hasViewport", true);
8903 return () => {
8904 store.set("hasViewport", false);
8905 };
8906 }, [store]);
8907 const handleMeasureLayout = useStableCallback(() => {
8908 currentContainerRef.current?.style.setProperty("animation", "none");
8909 currentContainerRef.current?.style.setProperty("transition", "none");
8910 previousContainerRef.current?.style.setProperty("display", "none");
8911 });
8912 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8913 currentContainerRef.current?.style.removeProperty("animation");
8914 currentContainerRef.current?.style.removeProperty("transition");
8915 previousContainerRef.current?.style.removeProperty("display");
8916 if (previousDimensions) {
8917 setPreviousContentDimensions(previousDimensions);
8918 }
8919 });
8920 const lastHandledTriggerRef = React43.useRef(null);
8921 useIsoLayoutEffect(() => {
8922 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8923 setPreviousContentNode(capturedNodeRef.current);
8924 setShowStartingStyleAttribute(true);
8925 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8926 setNewTriggerOffset(offset4);
8927 cleanupFrame.request(() => {
8928 ReactDOM5.flushSync(() => {
8929 setShowStartingStyleAttribute(false);
8930 });
8931 onAnimationsFinished(() => {
8932 setPreviousContentNode(null);
8933 setPreviousContentDimensions(null);
8934 capturedNodeRef.current = null;
8935 });
8936 });
8937 lastHandledTriggerRef.current = activeTrigger;
8938 }
8939 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8940 useIsoLayoutEffect(() => {
8941 const source = currentContainerRef.current;
8942 if (!source) {
8943 return;
8944 }
8945 const wrapper = ownerDocument(source).createElement("div");
8946 for (const child of Array.from(source.childNodes)) {
8947 wrapper.appendChild(child.cloneNode(true));
8948 }
8949 capturedNodeRef.current = wrapper;
8950 });
8951 const isTransitioning = previousContentNode != null;
8952 let childrenToRender;
8953 if (!isTransitioning) {
8954 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
8955 "data-current": true,
8956 ref: currentContainerRef,
8957 children
8958 }, currentContentKey);
8959 } else {
8960 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React43.Fragment, {
8961 children: [/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
8962 "data-previous": true,
8963 inert: inertValue(true),
8964 ref: previousContainerRef,
8965 style: {
8966 ...previousContentDimensions ? {
8967 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8968 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8969 } : null,
8970 position: "absolute"
8971 },
8972 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8973 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
8974 "data-current": true,
8975 ref: currentContainerRef,
8976 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8977 children
8978 }, currentContentKey)]
8979 });
8980 }
8981 useIsoLayoutEffect(() => {
8982 const container = previousContainerRef.current;
8983 if (!container || !previousContentNode) {
8984 return;
8985 }
8986 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8987 }, [previousContentNode]);
8988 usePopupAutoResize({
8989 popupElement,
8990 positionerElement,
8991 mounted,
8992 content: payload,
8993 onMeasureLayout: handleMeasureLayout,
8994 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8995 side,
8996 direction
8997 });
8998 const state = {
8999 activationDirection: getActivationDirection(newTriggerOffset),
9000 transitioning: isTransitioning
9001 };
9002 return {
9003 children: childrenToRender,
9004 state
9005 };
9006 }
9007 function getActivationDirection(offset4) {
9008 if (!offset4) {
9009 return void 0;
9010 }
9011 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
9012 }
9013 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
9014 if (value > tolerance) {
9015 return positiveLabel;
9016 }
9017 if (value < -tolerance) {
9018 return negativeLabel;
9019 }
9020 return "";
9021 }
9022 function calculateRelativePosition(from, to) {
9023 const fromRect = from.getBoundingClientRect();
9024 const toRect = to.getBoundingClientRect();
9025 const fromCenter = {
9026 x: fromRect.left + fromRect.width / 2,
9027 y: fromRect.top + fromRect.height / 2
9028 };
9029 const toCenter = {
9030 x: toRect.left + toRect.width / 2,
9031 y: toRect.top + toRect.height / 2
9032 };
9033 return {
9034 horizontal: toCenter.x - fromCenter.x,
9035 vertical: toCenter.y - fromCenter.y
9036 };
9037 }
9038 function usePopupContentKey(activeTriggerId, payload) {
9039 const [contentKey, setContentKey] = React43.useState(0);
9040 const previousActiveTriggerIdRef = React43.useRef(activeTriggerId);
9041 const previousPayloadRef = React43.useRef(payload);
9042 const pendingPayloadUpdateRef = React43.useRef(false);
9043 useIsoLayoutEffect(() => {
9044 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
9045 const previousPayload = previousPayloadRef.current;
9046 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
9047 const payloadChanged = payload !== previousPayload;
9048 if (triggerIdChanged) {
9049 setContentKey((value) => value + 1);
9050 pendingPayloadUpdateRef.current = !payloadChanged;
9051 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
9052 setContentKey((value) => value + 1);
9053 pendingPayloadUpdateRef.current = false;
9054 }
9055 previousActiveTriggerIdRef.current = activeTriggerId;
9056 previousPayloadRef.current = payload;
9057 }, [activeTriggerId, payload]);
9058 return `${activeTriggerId ?? "current"}-${contentKey}`;
9059 }
9060
9061 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
9062 var React44 = __toESM(require_react(), 1);
9063 var ReactDOM6 = __toESM(require_react_dom(), 1);
9064 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
9065 var FloatingPortalLite = /* @__PURE__ */ React44.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
9066 const {
9067 children,
9068 container,
9069 className,
9070 render: render4,
9071 style,
9072 ...elementProps
9073 } = componentProps;
9074 const {
9075 portalNode,
9076 portalSubtree
9077 } = useFloatingPortalNode({
9078 container,
9079 ref: forwardedRef,
9080 componentProps,
9081 elementProps
9082 });
9083 if (!portalSubtree && !portalNode) {
9084 return null;
9085 }
9086 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(React44.Fragment, {
9087 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
9088 });
9089 });
9090 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
9091
9092 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
9093 var index_parts_exports2 = {};
9094 __export(index_parts_exports2, {
9095 Arrow: () => TooltipArrow,
9096 Handle: () => TooltipHandle,
9097 Popup: () => TooltipPopup,
9098 Portal: () => TooltipPortal,
9099 Positioner: () => TooltipPositioner,
9100 Provider: () => TooltipProvider,
9101 Root: () => TooltipRoot,
9102 Trigger: () => TooltipTrigger,
9103 Viewport: () => TooltipViewport,
9104 createHandle: () => createTooltipHandle
9105 });
9106
9107 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
9108 var React47 = __toESM(require_react(), 1);
9109
9110 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
9111 var React45 = __toESM(require_react(), 1);
9112 var TooltipRootContext = /* @__PURE__ */ React45.createContext(void 0);
9113 if (true) TooltipRootContext.displayName = "TooltipRootContext";
9114 function useTooltipRootContext(optional) {
9115 const context = React45.useContext(TooltipRootContext);
9116 if (context === void 0 && !optional) {
9117 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
9118 }
9119 return context;
9120 }
9121
9122 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
9123 var React46 = __toESM(require_react(), 1);
9124 var ReactDOM7 = __toESM(require_react_dom(), 1);
9125 var selectors2 = {
9126 ...popupStoreSelectors,
9127 disabled: createSelector((state) => state.disabled),
9128 instantType: createSelector((state) => state.instantType),
9129 isInstantPhase: createSelector((state) => state.isInstantPhase),
9130 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
9131 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
9132 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
9133 closeOnClick: createSelector((state) => state.closeOnClick),
9134 closeDelay: createSelector((state) => state.closeDelay),
9135 hasViewport: createSelector((state) => state.hasViewport)
9136 };
9137 var TooltipStore = class _TooltipStore extends ReactStore {
9138 constructor(initialState, floatingId, nested = false) {
9139 const triggerElements = new PopupTriggerMap();
9140 const state = {
9141 ...createInitialState(),
9142 ...initialState
9143 };
9144 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
9145 super(state, {
9146 popupRef: /* @__PURE__ */ React46.createRef(),
9147 onOpenChange: void 0,
9148 onOpenChangeComplete: void 0,
9149 triggerElements
9150 }, selectors2);
9151 }
9152 setOpen = (nextOpen, eventDetails) => {
9153 const reason = eventDetails.reason;
9154 const isHover = reason === reason_parts_exports.triggerHover;
9155 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
9156 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
9157 eventDetails.preventUnmountOnClose = () => {
9158 this.set("preventUnmountingOnClose", true);
9159 };
9160 this.context.onOpenChange?.(nextOpen, eventDetails);
9161 if (eventDetails.isCanceled) {
9162 return;
9163 }
9164 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
9165 const changeState = () => {
9166 const updatedState = {
9167 open: nextOpen,
9168 openChangeReason: reason
9169 };
9170 if (isFocusOpen) {
9171 updatedState.instantType = "focus";
9172 } else if (isDismissClose) {
9173 updatedState.instantType = "dismiss";
9174 } else if (reason === reason_parts_exports.triggerHover) {
9175 updatedState.instantType = void 0;
9176 }
9177 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
9178 this.update(updatedState);
9179 };
9180 if (isHover) {
9181 ReactDOM7.flushSync(changeState);
9182 } else {
9183 changeState();
9184 }
9185 };
9186 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
9187 cancelPendingOpen(event) {
9188 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
9189 }
9190 static useStore(externalStore, initialState) {
9191 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
9192 return store;
9193 }
9194 };
9195 function createInitialState() {
9196 return {
9197 ...createInitialPopupStoreState(),
9198 disabled: false,
9199 instantType: void 0,
9200 isInstantPhase: false,
9201 trackCursorAxis: "none",
9202 disableHoverablePopup: false,
9203 openChangeReason: null,
9204 closeOnClick: true,
9205 closeDelay: 0,
9206 hasViewport: false
9207 };
9208 }
9209
9210 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
9211 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
9212 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
9213 const {
9214 disabled: disabled2 = false,
9215 defaultOpen = false,
9216 open: openProp,
9217 disableHoverablePopup = false,
9218 trackCursorAxis = "none",
9219 actionsRef,
9220 onOpenChange,
9221 onOpenChangeComplete,
9222 handle,
9223 triggerId: triggerIdProp,
9224 defaultTriggerId: defaultTriggerIdProp = null,
9225 children
9226 } = props;
9227 const store = TooltipStore.useStore(handle?.store, {
9228 open: defaultOpen,
9229 openProp,
9230 activeTriggerId: defaultTriggerIdProp,
9231 triggerIdProp
9232 });
9233 useOnFirstRender(() => {
9234 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
9235 store.update({
9236 open: true,
9237 activeTriggerId: defaultTriggerIdProp
9238 });
9239 }
9240 });
9241 store.useControlledProp("openProp", openProp);
9242 store.useControlledProp("triggerIdProp", triggerIdProp);
9243 store.useContextCallback("onOpenChange", onOpenChange);
9244 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
9245 const openState = store.useState("open");
9246 const open = !disabled2 && openState;
9247 const activeTriggerId = store.useState("activeTriggerId");
9248 const mounted = store.useState("mounted");
9249 const payload = store.useState("payload");
9250 store.useSyncedValues({
9251 trackCursorAxis,
9252 disableHoverablePopup
9253 });
9254 store.useSyncedValue("disabled", disabled2);
9255 useImplicitActiveTrigger(store);
9256 const {
9257 forceUnmount,
9258 transitionStatus
9259 } = useOpenStateTransitions(open, store);
9260 const isInstantPhase = store.useState("isInstantPhase");
9261 const instantType = store.useState("instantType");
9262 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
9263 const previousInstantTypeRef = React47.useRef(null);
9264 useIsoLayoutEffect(() => {
9265 if (openState && disabled2) {
9266 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
9267 }
9268 }, [openState, disabled2, store]);
9269 useIsoLayoutEffect(() => {
9270 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
9271 if (instantType !== "delay") {
9272 previousInstantTypeRef.current = instantType;
9273 }
9274 store.set("instantType", "delay");
9275 } else if (previousInstantTypeRef.current !== null) {
9276 store.set("instantType", previousInstantTypeRef.current);
9277 previousInstantTypeRef.current = null;
9278 }
9279 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
9280 useIsoLayoutEffect(() => {
9281 if (open) {
9282 if (activeTriggerId == null) {
9283 store.set("payload", void 0);
9284 }
9285 }
9286 }, [store, activeTriggerId, open]);
9287 const handleImperativeClose = React47.useCallback(() => {
9288 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
9289 }, [store]);
9290 React47.useImperativeHandle(actionsRef, () => ({
9291 unmount: forceUnmount,
9292 close: handleImperativeClose
9293 }), [forceUnmount, handleImperativeClose]);
9294 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
9295 return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(TooltipRootContext.Provider, {
9296 value: store,
9297 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipInteractions, {
9298 store,
9299 disabled: disabled2,
9300 trackCursorAxis
9301 }), typeof children === "function" ? children({
9302 payload
9303 }) : children]
9304 });
9305 });
9306 if (true) TooltipRoot.displayName = "TooltipRoot";
9307 function TooltipInteractions({
9308 store,
9309 disabled: disabled2,
9310 trackCursorAxis
9311 }) {
9312 const floatingRootContext = store.useState("floatingRootContext");
9313 const dismiss = useDismiss(floatingRootContext, {
9314 enabled: !disabled2,
9315 referencePress: () => store.select("closeOnClick")
9316 });
9317 const clientPoint = useClientPoint(floatingRootContext, {
9318 enabled: !disabled2 && trackCursorAxis !== "none",
9319 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
9320 });
9321 const activeTriggerProps = React47.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
9322 const inactiveTriggerProps = React47.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
9323 const popupProps = React47.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
9324 usePopupInteractionProps(store, {
9325 activeTriggerProps,
9326 inactiveTriggerProps,
9327 popupProps
9328 });
9329 return null;
9330 }
9331
9332 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
9333 var React49 = __toESM(require_react(), 1);
9334
9335 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
9336 var React48 = __toESM(require_react(), 1);
9337 var TooltipProviderContext = /* @__PURE__ */ React48.createContext(void 0);
9338 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
9339 function useTooltipProviderContext() {
9340 return React48.useContext(TooltipProviderContext);
9341 }
9342
9343 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
9344 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
9345 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
9346 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
9347 return TooltipTriggerDataAttributes2;
9348 })({});
9349
9350 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
9351 var OPEN_DELAY = 600;
9352
9353 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
9354 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
9355 function getTargetElement(event) {
9356 if ("composedPath" in event) {
9357 const path = event.composedPath();
9358 for (let i2 = 0; i2 < path.length; i2 += 1) {
9359 const element = path[i2];
9360 if (isElement(element)) {
9361 return element;
9362 }
9363 }
9364 }
9365 const target = event.target;
9366 if (isElement(target)) {
9367 return target;
9368 }
9369 return null;
9370 }
9371 function closestEnabledTooltipTrigger(element) {
9372 let current = element;
9373 while (current) {
9374 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
9375 return current;
9376 }
9377 const parentElement = current.parentElement;
9378 if (parentElement) {
9379 current = parentElement;
9380 continue;
9381 }
9382 const root = current.getRootNode();
9383 current = "host" in root && isElement(root.host) ? root.host : null;
9384 }
9385 return null;
9386 }
9387 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
9388 const {
9389 render: render4,
9390 className,
9391 style,
9392 handle,
9393 payload,
9394 disabled: disabledProp,
9395 delay,
9396 closeOnClick = true,
9397 closeDelay,
9398 id: idProp,
9399 ...elementProps
9400 } = componentProps;
9401 const rootContext = useTooltipRootContext(true);
9402 const store = handle?.store ?? rootContext;
9403 if (!store) {
9404 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));
9405 }
9406 const thisTriggerId = useBaseUiId(idProp);
9407 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
9408 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
9409 const floatingRootContext = store.useState("floatingRootContext");
9410 const triggerElementRef = React49.useRef(null);
9411 const delayWithDefault = delay ?? OPEN_DELAY;
9412 const closeDelayWithDefault = closeDelay ?? 0;
9413 const {
9414 registerTrigger,
9415 isMountedByThisTrigger
9416 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
9417 payload,
9418 closeOnClick,
9419 closeDelay: closeDelayWithDefault
9420 });
9421 const providerContext = useTooltipProviderContext();
9422 const {
9423 delayRef,
9424 isInstantPhase,
9425 hasProvider
9426 } = useDelayGroup(floatingRootContext, {
9427 open: isOpenedByThisTrigger
9428 });
9429 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
9430 store.useSyncedValue("isInstantPhase", isInstantPhase);
9431 const rootDisabled = store.useState("disabled");
9432 const disabled2 = disabledProp ?? rootDisabled;
9433 const disabledRef = useValueAsRef(disabled2);
9434 const trackCursorAxis = store.useState("trackCursorAxis");
9435 const disableHoverablePopup = store.useState("disableHoverablePopup");
9436 const isNestedTriggerHoveredRef = React49.useRef(false);
9437 const nestedTriggerOpenTimeout = useTimeout();
9438 const pointerTypeRef = React49.useRef(void 0);
9439 function getOpenDelay() {
9440 const providerDelay = providerContext?.delay;
9441 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
9442 let computedOpenDelay = delayWithDefault;
9443 if (hasProvider) {
9444 if (groupOpenValue !== 0) {
9445 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
9446 } else {
9447 computedOpenDelay = 0;
9448 }
9449 }
9450 return computedOpenDelay;
9451 }
9452 function isEnabledNestedTriggerTarget(target) {
9453 const triggerEl = triggerElementRef.current;
9454 if (!triggerEl || !target) {
9455 return false;
9456 }
9457 const nearestTrigger = closestEnabledTooltipTrigger(target);
9458 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
9459 }
9460 function detectNestedTriggerHover(target) {
9461 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
9462 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
9463 if (nestedTriggerHovered) {
9464 hoverInteraction.openChangeTimeout.clear();
9465 hoverInteraction.restTimeout.clear();
9466 hoverInteraction.restTimeoutPending = false;
9467 nestedTriggerOpenTimeout.clear();
9468 }
9469 return nestedTriggerHovered;
9470 }
9471 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
9472 enabled: !disabled2,
9473 mouseOnly: true,
9474 move: false,
9475 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
9476 restMs: getOpenDelay,
9477 delay() {
9478 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
9479 let computedCloseDelay = closeDelayWithDefault;
9480 if (closeDelay == null && hasProvider) {
9481 computedCloseDelay = closeValue;
9482 }
9483 return {
9484 close: computedCloseDelay
9485 };
9486 },
9487 triggerElementRef,
9488 isActiveTrigger: isTriggerActive,
9489 isClosing: () => store.select("transitionStatus") === "ending",
9490 shouldOpen() {
9491 return !isNestedTriggerHoveredRef.current;
9492 }
9493 });
9494 const focusProps = useFocus(floatingRootContext, {
9495 enabled: !disabled2
9496 }).reference;
9497 const handleNestedTriggerHover = (event) => {
9498 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
9499 const target = getTargetElement(event);
9500 const nestedTriggerHovered = detectNestedTriggerHover(target);
9501 const triggerEl = triggerElementRef.current;
9502 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
9503 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
9504 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
9505 return;
9506 }
9507 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
9508 isMouseLikePointerType(pointerTypeRef.current)) {
9509 const open = () => {
9510 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
9511 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
9512 }
9513 };
9514 const openDelay = getOpenDelay();
9515 if (openDelay === 0) {
9516 nestedTriggerOpenTimeout.clear();
9517 open();
9518 } else {
9519 nestedTriggerOpenTimeout.start(openDelay, open);
9520 }
9521 }
9522 };
9523 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
9524 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
9525 const state = {
9526 open: isOpenedByThisTrigger
9527 };
9528 const element = useRenderElement("button", componentProps, {
9529 state,
9530 ref: [forwardedRef, registerTrigger, triggerElementRef],
9531 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
9532 onMouseOver(event) {
9533 handleNestedTriggerHover(event.nativeEvent);
9534 },
9535 onFocus(event) {
9536 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
9537 event.preventBaseUIHandler();
9538 }
9539 },
9540 onMouseLeave() {
9541 isNestedTriggerHoveredRef.current = false;
9542 nestedTriggerOpenTimeout.clear();
9543 pointerTypeRef.current = void 0;
9544 },
9545 onPointerEnter(event) {
9546 pointerTypeRef.current = event.pointerType;
9547 },
9548 onPointerDown(event) {
9549 pointerTypeRef.current = event.pointerType;
9550 store.set("closeOnClick", closeOnClick);
9551 if (closeOnClick && !store.select("open")) {
9552 store.cancelPendingOpen(event.nativeEvent);
9553 }
9554 },
9555 onClick(event) {
9556 if (closeOnClick && !store.select("open")) {
9557 store.cancelPendingOpen(event.nativeEvent);
9558 }
9559 },
9560 id: thisTriggerId,
9561 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
9562 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
9563 }, elementProps],
9564 stateAttributesMapping: triggerOpenStateMapping2
9565 });
9566 return element;
9567 });
9568 if (true) TooltipTrigger.displayName = "TooltipTrigger";
9569
9570 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
9571 var React51 = __toESM(require_react(), 1);
9572
9573 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
9574 var React50 = __toESM(require_react(), 1);
9575 var TooltipPortalContext = /* @__PURE__ */ React50.createContext(void 0);
9576 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
9577 function useTooltipPortalContext() {
9578 const value = React50.useContext(TooltipPortalContext);
9579 if (value === void 0) {
9580 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
9581 }
9582 return value;
9583 }
9584
9585 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
9586 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
9587 var TooltipPortal = /* @__PURE__ */ React51.forwardRef(function TooltipPortal2(props, forwardedRef) {
9588 const {
9589 keepMounted = false,
9590 ...portalProps
9591 } = props;
9592 const store = useTooltipRootContext();
9593 const mounted = store.useState("mounted");
9594 const shouldRender = mounted || keepMounted;
9595 if (!shouldRender) {
9596 return null;
9597 }
9598 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPortalContext.Provider, {
9599 value: keepMounted,
9600 children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloatingPortalLite, {
9601 ref: forwardedRef,
9602 ...portalProps
9603 })
9604 });
9605 });
9606 if (true) TooltipPortal.displayName = "TooltipPortal";
9607
9608 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
9609 var React53 = __toESM(require_react(), 1);
9610
9611 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
9612 var React52 = __toESM(require_react(), 1);
9613 var TooltipPositionerContext = /* @__PURE__ */ React52.createContext(void 0);
9614 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
9615 function useTooltipPositionerContext() {
9616 const context = React52.useContext(TooltipPositionerContext);
9617 if (context === void 0) {
9618 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
9619 }
9620 return context;
9621 }
9622
9623 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
9624 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
9625 var TooltipPositioner = /* @__PURE__ */ React53.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
9626 const {
9627 render: render4,
9628 className,
9629 anchor,
9630 positionMethod = "absolute",
9631 side = "top",
9632 align = "center",
9633 sideOffset = 0,
9634 alignOffset = 0,
9635 collisionBoundary = "clipping-ancestors",
9636 collisionPadding = 5,
9637 arrowPadding = 5,
9638 sticky = false,
9639 disableAnchorTracking = false,
9640 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
9641 style,
9642 ...elementProps
9643 } = componentProps;
9644 const store = useTooltipRootContext();
9645 const keepMounted = useTooltipPortalContext();
9646 const open = store.useState("open");
9647 const mounted = store.useState("mounted");
9648 const trackCursorAxis = store.useState("trackCursorAxis");
9649 const disableHoverablePopup = store.useState("disableHoverablePopup");
9650 const floatingRootContext = store.useState("floatingRootContext");
9651 const instantType = store.useState("instantType");
9652 const transitionStatus = store.useState("transitionStatus");
9653 const hasViewport = store.useState("hasViewport");
9654 const positioning = useAnchorPositioning({
9655 anchor,
9656 positionMethod,
9657 floatingRootContext,
9658 mounted,
9659 side,
9660 sideOffset,
9661 align,
9662 alignOffset,
9663 collisionBoundary,
9664 collisionPadding,
9665 sticky,
9666 arrowPadding,
9667 disableAnchorTracking,
9668 keepMounted,
9669 collisionAvoidance,
9670 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
9671 });
9672 const state = React53.useMemo(() => ({
9673 open,
9674 side: positioning.side,
9675 align: positioning.align,
9676 anchorHidden: positioning.anchorHidden,
9677 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
9678 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
9679 const element = usePositioner(componentProps, state, {
9680 styles: positioning.positionerStyles,
9681 transitionStatus,
9682 props: elementProps,
9683 refs: [forwardedRef, store.useStateSetter("positionerElement")],
9684 hidden: !mounted,
9685 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
9686 });
9687 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipPositionerContext.Provider, {
9688 value: positioning,
9689 children: element
9690 });
9691 });
9692 if (true) TooltipPositioner.displayName = "TooltipPositioner";
9693
9694 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
9695 var React54 = __toESM(require_react(), 1);
9696 var stateAttributesMapping2 = {
9697 ...popupStateMapping,
9698 ...transitionStatusMapping
9699 };
9700 var TooltipPopup = /* @__PURE__ */ React54.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
9701 const {
9702 render: render4,
9703 className,
9704 style,
9705 ...elementProps
9706 } = componentProps;
9707 const store = useTooltipRootContext();
9708 const {
9709 side,
9710 align
9711 } = useTooltipPositionerContext();
9712 const open = store.useState("open");
9713 const instantType = store.useState("instantType");
9714 const transitionStatus = store.useState("transitionStatus");
9715 const popupProps = store.useState("popupProps");
9716 const floatingContext = store.useState("floatingRootContext");
9717 const disabled2 = store.useState("disabled");
9718 const closeDelay = store.useState("closeDelay");
9719 useOpenChangeComplete({
9720 open,
9721 ref: store.context.popupRef,
9722 onComplete() {
9723 if (open) {
9724 store.context.onOpenChangeComplete?.(true);
9725 }
9726 }
9727 });
9728 useHoverFloatingInteraction(floatingContext, {
9729 enabled: !disabled2,
9730 closeDelay
9731 });
9732 const setPopupElement = store.useStateSetter("popupElement");
9733 const state = {
9734 open,
9735 side,
9736 align,
9737 instant: instantType,
9738 transitionStatus
9739 };
9740 const element = useRenderElement("div", componentProps, {
9741 state,
9742 ref: [forwardedRef, store.context.popupRef, setPopupElement],
9743 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9744 stateAttributesMapping: stateAttributesMapping2
9745 });
9746 return element;
9747 });
9748 if (true) TooltipPopup.displayName = "TooltipPopup";
9749
9750 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
9751 var React55 = __toESM(require_react(), 1);
9752 var TooltipArrow = /* @__PURE__ */ React55.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9753 const {
9754 render: render4,
9755 className,
9756 style,
9757 ...elementProps
9758 } = componentProps;
9759 const store = useTooltipRootContext();
9760 const {
9761 arrowRef,
9762 side,
9763 align,
9764 arrowUncentered,
9765 arrowStyles
9766 } = useTooltipPositionerContext();
9767 const open = store.useState("open");
9768 const instantType = store.useState("instantType");
9769 const state = {
9770 open,
9771 side,
9772 align,
9773 uncentered: arrowUncentered,
9774 instant: instantType
9775 };
9776 const element = useRenderElement("div", componentProps, {
9777 state,
9778 ref: [forwardedRef, arrowRef],
9779 props: [{
9780 style: arrowStyles,
9781 "aria-hidden": true
9782 }, elementProps],
9783 stateAttributesMapping: popupStateMapping
9784 });
9785 return element;
9786 });
9787 if (true) TooltipArrow.displayName = "TooltipArrow";
9788
9789 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
9790 var React56 = __toESM(require_react(), 1);
9791 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
9792 var TooltipProvider = function TooltipProvider2(props) {
9793 const {
9794 delay,
9795 closeDelay,
9796 timeout = 400
9797 } = props;
9798 const contextValue = React56.useMemo(() => ({
9799 delay,
9800 closeDelay
9801 }), [delay, closeDelay]);
9802 const delayValue = React56.useMemo(() => ({
9803 open: delay,
9804 close: closeDelay
9805 }), [delay, closeDelay]);
9806 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipProviderContext.Provider, {
9807 value: contextValue,
9808 children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatingDelayGroup, {
9809 delay: delayValue,
9810 timeoutMs: timeout,
9811 children: props.children
9812 })
9813 });
9814 };
9815 if (true) TooltipProvider.displayName = "TooltipProvider";
9816
9817 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
9818 var React57 = __toESM(require_react(), 1);
9819
9820 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
9821 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9822 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9823 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9824 return TooltipViewportCssVars2;
9825 })({});
9826
9827 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
9828 var stateAttributesMapping3 = {
9829 activationDirection: (value) => value ? {
9830 "data-activation-direction": value
9831 } : null
9832 };
9833 var TooltipViewport = /* @__PURE__ */ React57.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9834 const {
9835 render: render4,
9836 className,
9837 style,
9838 children,
9839 ...elementProps
9840 } = componentProps;
9841 const store = useTooltipRootContext();
9842 const positioner = useTooltipPositionerContext();
9843 const instantType = store.useState("instantType");
9844 const {
9845 children: childrenToRender,
9846 state: viewportState
9847 } = usePopupViewport({
9848 store,
9849 side: positioner.side,
9850 cssVars: TooltipViewportCssVars,
9851 children
9852 });
9853 const state = {
9854 activationDirection: viewportState.activationDirection,
9855 transitioning: viewportState.transitioning,
9856 instant: instantType
9857 };
9858 return useRenderElement("div", componentProps, {
9859 state,
9860 ref: forwardedRef,
9861 props: [elementProps, {
9862 children: childrenToRender
9863 }],
9864 stateAttributesMapping: stateAttributesMapping3
9865 });
9866 });
9867 if (true) TooltipViewport.displayName = "TooltipViewport";
9868
9869 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
9870 var TooltipHandle = class {
9871 /**
9872 * Internal store holding the tooltip state.
9873 * @internal
9874 */
9875 constructor() {
9876 this.store = new TooltipStore();
9877 }
9878 /**
9879 * Opens the tooltip and associates it with the trigger with the given ID.
9880 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9881 *
9882 * This method should only be called in an event handler or an effect (not during rendering).
9883 *
9884 * @param triggerId ID of the trigger to associate with the tooltip.
9885 */
9886 open(triggerId) {
9887 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9888 if (triggerId && !triggerElement) {
9889 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9890 }
9891 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9892 }
9893 /**
9894 * Closes the tooltip.
9895 */
9896 close() {
9897 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9898 }
9899 /**
9900 * Indicates whether the tooltip is currently open.
9901 */
9902 get isOpen() {
9903 return this.store.select("open");
9904 }
9905 };
9906 function createTooltipHandle() {
9907 return new TooltipHandle();
9908 }
9909
9910 // node_modules/@base-ui/react/esm/use-render/useRender.js
9911 function useRender(params) {
9912 return useRenderElement(params.defaultTagName ?? "div", params, params);
9913 }
9914
9915 // packages/ui/build-module/text/text.mjs
9916 var import_element10 = __toESM(require_element(), 1);
9917 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9918 function getRuntime() {
9919 const globalScope = globalThis;
9920 if (globalScope.__wpStyleRuntime) {
9921 return globalScope.__wpStyleRuntime;
9922 }
9923 globalScope.__wpStyleRuntime = {
9924 documents: /* @__PURE__ */ new Map(),
9925 styles: /* @__PURE__ */ new Map(),
9926 injectedStyles: /* @__PURE__ */ new WeakMap()
9927 };
9928 if (typeof document !== "undefined") {
9929 registerDocument(document);
9930 }
9931 return globalScope.__wpStyleRuntime;
9932 }
9933 function documentContainsStyleHash(targetDocument, hash) {
9934 if (!targetDocument.head) {
9935 return false;
9936 }
9937 for (const style of targetDocument.head.querySelectorAll(
9938 `style[${STYLE_HASH_ATTRIBUTE}]`
9939 )) {
9940 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9941 return true;
9942 }
9943 }
9944 return false;
9945 }
9946 function injectStyle(targetDocument, hash, css) {
9947 if (!targetDocument.head) {
9948 return;
9949 }
9950 const runtime = getRuntime();
9951 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9952 if (!injectedStyles) {
9953 injectedStyles = /* @__PURE__ */ new Set();
9954 runtime.injectedStyles.set(targetDocument, injectedStyles);
9955 }
9956 if (injectedStyles.has(hash)) {
9957 return;
9958 }
9959 if (documentContainsStyleHash(targetDocument, hash)) {
9960 injectedStyles.add(hash);
9961 return;
9962 }
9963 const style = targetDocument.createElement("style");
9964 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9965 style.appendChild(targetDocument.createTextNode(css));
9966 targetDocument.head.appendChild(style);
9967 injectedStyles.add(hash);
9968 }
9969 function registerDocument(targetDocument) {
9970 const runtime = getRuntime();
9971 runtime.documents.set(
9972 targetDocument,
9973 (runtime.documents.get(targetDocument) ?? 0) + 1
9974 );
9975 for (const [hash, css] of runtime.styles) {
9976 injectStyle(targetDocument, hash, css);
9977 }
9978 return () => {
9979 const count = runtime.documents.get(targetDocument);
9980 if (count === void 0) {
9981 return;
9982 }
9983 if (count <= 1) {
9984 runtime.documents.delete(targetDocument);
9985 return;
9986 }
9987 runtime.documents.set(targetDocument, count - 1);
9988 };
9989 }
9990 function registerStyle(hash, css) {
9991 const runtime = getRuntime();
9992 runtime.styles.set(hash, css);
9993 for (const targetDocument of runtime.documents.keys()) {
9994 injectStyle(targetDocument, hash, css);
9995 }
9996 }
9997 if (typeof process === "undefined" || true) {
9998 registerStyle("0c5702ddca", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}');
9999 }
10000 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" };
10001 if (typeof process === "undefined" || true) {
10002 registerStyle("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
10003 }
10004 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" };
10005 var Text = (0, import_element10.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
10006 const element = useRender({
10007 render: render4,
10008 defaultTagName: "span",
10009 ref,
10010 props: mergeProps(props, {
10011 className: clsx_default(
10012 style_default.text,
10013 global_css_defense_default.heading,
10014 global_css_defense_default.p,
10015 style_default[variant],
10016 className
10017 )
10018 })
10019 });
10020 return element;
10021 });
10022
10023 // packages/ui/build-module/badge/badge.mjs
10024 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
10025 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
10026 function getRuntime2() {
10027 const globalScope = globalThis;
10028 if (globalScope.__wpStyleRuntime) {
10029 return globalScope.__wpStyleRuntime;
10030 }
10031 globalScope.__wpStyleRuntime = {
10032 documents: /* @__PURE__ */ new Map(),
10033 styles: /* @__PURE__ */ new Map(),
10034 injectedStyles: /* @__PURE__ */ new WeakMap()
10035 };
10036 if (typeof document !== "undefined") {
10037 registerDocument2(document);
10038 }
10039 return globalScope.__wpStyleRuntime;
10040 }
10041 function documentContainsStyleHash2(targetDocument, hash) {
10042 if (!targetDocument.head) {
10043 return false;
10044 }
10045 for (const style of targetDocument.head.querySelectorAll(
10046 `style[${STYLE_HASH_ATTRIBUTE2}]`
10047 )) {
10048 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
10049 return true;
10050 }
10051 }
10052 return false;
10053 }
10054 function injectStyle2(targetDocument, hash, css) {
10055 if (!targetDocument.head) {
10056 return;
10057 }
10058 const runtime = getRuntime2();
10059 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10060 if (!injectedStyles) {
10061 injectedStyles = /* @__PURE__ */ new Set();
10062 runtime.injectedStyles.set(targetDocument, injectedStyles);
10063 }
10064 if (injectedStyles.has(hash)) {
10065 return;
10066 }
10067 if (documentContainsStyleHash2(targetDocument, hash)) {
10068 injectedStyles.add(hash);
10069 return;
10070 }
10071 const style = targetDocument.createElement("style");
10072 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
10073 style.appendChild(targetDocument.createTextNode(css));
10074 targetDocument.head.appendChild(style);
10075 injectedStyles.add(hash);
10076 }
10077 function registerDocument2(targetDocument) {
10078 const runtime = getRuntime2();
10079 runtime.documents.set(
10080 targetDocument,
10081 (runtime.documents.get(targetDocument) ?? 0) + 1
10082 );
10083 for (const [hash, css] of runtime.styles) {
10084 injectStyle2(targetDocument, hash, css);
10085 }
10086 return () => {
10087 const count = runtime.documents.get(targetDocument);
10088 if (count === void 0) {
10089 return;
10090 }
10091 if (count <= 1) {
10092 runtime.documents.delete(targetDocument);
10093 return;
10094 }
10095 runtime.documents.set(targetDocument, count - 1);
10096 };
10097 }
10098 function registerStyle2(hash, css) {
10099 const runtime = getRuntime2();
10100 runtime.styles.set(hash, css);
10101 for (const targetDocument of runtime.documents.keys()) {
10102 injectStyle2(targetDocument, hash, css);
10103 }
10104 }
10105 if (typeof process === "undefined" || true) {
10106 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))}}}");
10107 }
10108 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" };
10109 var Badge = (0, import_element11.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) {
10110 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10111 Text,
10112 {
10113 ref,
10114 className: clsx_default(
10115 style_default2.badge,
10116 style_default2[`is-${intent}-intent`],
10117 className
10118 ),
10119 ...props,
10120 variant: "body-sm"
10121 }
10122 );
10123 });
10124
10125 // packages/ui/build-module/button/button.mjs
10126 var import_element12 = __toESM(require_element(), 1);
10127 var import_i18n = __toESM(require_i18n(), 1);
10128 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
10129 import { speak } from "@wordpress/a11y";
10130 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
10131 function getRuntime3() {
10132 const globalScope = globalThis;
10133 if (globalScope.__wpStyleRuntime) {
10134 return globalScope.__wpStyleRuntime;
10135 }
10136 globalScope.__wpStyleRuntime = {
10137 documents: /* @__PURE__ */ new Map(),
10138 styles: /* @__PURE__ */ new Map(),
10139 injectedStyles: /* @__PURE__ */ new WeakMap()
10140 };
10141 if (typeof document !== "undefined") {
10142 registerDocument3(document);
10143 }
10144 return globalScope.__wpStyleRuntime;
10145 }
10146 function documentContainsStyleHash3(targetDocument, hash) {
10147 if (!targetDocument.head) {
10148 return false;
10149 }
10150 for (const style of targetDocument.head.querySelectorAll(
10151 `style[${STYLE_HASH_ATTRIBUTE3}]`
10152 )) {
10153 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
10154 return true;
10155 }
10156 }
10157 return false;
10158 }
10159 function injectStyle3(targetDocument, hash, css) {
10160 if (!targetDocument.head) {
10161 return;
10162 }
10163 const runtime = getRuntime3();
10164 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10165 if (!injectedStyles) {
10166 injectedStyles = /* @__PURE__ */ new Set();
10167 runtime.injectedStyles.set(targetDocument, injectedStyles);
10168 }
10169 if (injectedStyles.has(hash)) {
10170 return;
10171 }
10172 if (documentContainsStyleHash3(targetDocument, hash)) {
10173 injectedStyles.add(hash);
10174 return;
10175 }
10176 const style = targetDocument.createElement("style");
10177 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
10178 style.appendChild(targetDocument.createTextNode(css));
10179 targetDocument.head.appendChild(style);
10180 injectedStyles.add(hash);
10181 }
10182 function registerDocument3(targetDocument) {
10183 const runtime = getRuntime3();
10184 runtime.documents.set(
10185 targetDocument,
10186 (runtime.documents.get(targetDocument) ?? 0) + 1
10187 );
10188 for (const [hash, css] of runtime.styles) {
10189 injectStyle3(targetDocument, hash, css);
10190 }
10191 return () => {
10192 const count = runtime.documents.get(targetDocument);
10193 if (count === void 0) {
10194 return;
10195 }
10196 if (count <= 1) {
10197 runtime.documents.delete(targetDocument);
10198 return;
10199 }
10200 runtime.documents.set(targetDocument, count - 1);
10201 };
10202 }
10203 function registerStyle3(hash, css) {
10204 const runtime = getRuntime3();
10205 runtime.styles.set(hash, css);
10206 for (const targetDocument of runtime.documents.keys()) {
10207 injectStyle3(targetDocument, hash, css);
10208 }
10209 }
10210 if (typeof process === "undefined" || true) {
10211 registerStyle3("4c317b0736", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._97b0fc33c028be1a__button,.abbb272e2ce49bd6__is-unstyled{appearance:none;padding:0}._97b0fc33c028be1a__button{--wp-ui-button-font-weight:var(--wpds-typography-font-weight-medium,499);--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-strong-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 93%,#000));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-strong-disabled,#8d8d8d);--wp-ui-button-padding-block:var(--wpds-dimension-padding-xs,4px);--wp-ui-button-padding-inline:var(--wpds-dimension-padding-md,12px);--wp-ui-button-height:var(--wpds-dimension-size-lg,40px);--wp-ui-button-aspect-ratio:auto;--wp-ui-button-font-size:var(--wpds-typography-font-size-md,13px);--wp-ui-button-min-width:calc(4ch + var(--wp-ui-button-padding-inline)*2);--wp-ui-button-icon-margin:calc((var(--wpds-dimension-size-2xs, 16px) - var(--wpds-dimension-size-sm, 24px))/2);--wp-ui-button-border-color:var(--wp-ui-button-background-color);--wp-ui-button-border-color-active:var(--wp-ui-button-background-color-active);--wp-ui-button-border-color-disabled:var(--wp-ui-button-background-color-disabled);--_gcd-button-font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);--_gcd-button-font-size:var(--wp-ui-button-font-size);--_gcd-button-font-weight:var(--wp-ui-button-font-weight);align-items:center;aspect-ratio:var(--wp-ui-button-aspect-ratio);background-clip:padding-box;background-color:var(--wp-ui-button-background-color);border-color:var(--wp-ui-button-border-color);border-radius:var(--wpds-border-radius-sm,2px);border-style:solid;border-width:1px;color:var(--wp-ui-button-foreground-color);display:inline-flex;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(--wp-ui-button-font-size);font-weight:var(--wp-ui-button-font-weight);gap:var(--wpds-dimension-gap-sm,8px);justify-content:center;line-height:var(--wpds-typography-line-height-sm,20px);max-width:100%;min-height:var(--wp-ui-button-height);min-width:var(--wp-ui-button-min-width);overflow-wrap:anywhere;padding-block:var(--wp-ui-button-padding-block);padding-inline:var(--wp-ui-button-padding-inline);position:relative;text-align:center;text-decoration:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}@media not (prefers-reduced-motion){transition:color .1s ease-out;*{transition:opacity .1s ease-out}}&[href]{cursor:pointer}[href]{color:inherit;text-decoration:inherit}&:not([data-disabled]):is(:hover,:active,:focus){background-color:var(--wp-ui-button-background-color-active);border-color:var(--wp-ui-button-border-color-active);color:var(--wp-ui-button-foreground-color-active)}&[data-disabled]:not(._914b42f315c0e580__is-loading){background-color:var(--wp-ui-button-background-color-disabled);border-color:var(--wp-ui-button-border-color-disabled);color:var(--wp-ui-button-foreground-color-disabled);@media (forced-colors:active){border-bottom-color:GrayText;border-left-color:GrayText;border-right-color:GrayText;border-top-color:GrayText;color:GrayText}}&:before{aspect-ratio:1;border:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid;border-block-end-color:transparent;border-block-start-color:var(--wp-ui-button-foreground-color);border-inline-end-color:var(--wp-ui-button-foreground-color);border-inline-start-color:transparent;border-radius:50%;box-sizing:border-box;content:"";display:block;height:var(--wp-ui-button-font-size);inset-inline-start:50%;opacity:0;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);@media not (prefers-reduced-motion){transition:opacity .1s ease-out}@media (forced-colors:active){border-block-end-style:none;border-bottom-color:ButtonText;border-inline-start-style:none;border-left-color:ButtonText;border-right-color:ButtonText;border-top-color:ButtonText}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-block:0;--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:var(--wpds-dimension-size-sm,24px)}._9f6fc6553aeb36fe__icon{margin:var(--wp-ui-button-icon-margin)}.dd460c965226cc77__is-brand{&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 85%,#000));--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-brand-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.ad0619a3217c6a5b__is-minimal[aria-pressed=true],&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-neutral-active,#6e6e6e);--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:var(--wpds-dimension-size-md,32px)}._914b42f315c0e580__is-loading:not(.abbb272e2ce49bd6__is-unstyled){color:transparent;&:not([data-disabled]):is(:hover,:active,:focus){color:transparent}@media (forced-colors:active){color:ButtonFace}*{opacity:0}&:before{opacity:1;transition-delay:.05s;@media not (prefers-reduced-motion){animation:_5a1d53da6f830c8d__loading-animation 1s linear infinite}}}}@keyframes _5a1d53da6f830c8d__loading-animation{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}}');
10212 }
10213 var style_default3 = { "button": "_97b0fc33c028be1a__button", "is-unstyled": "abbb272e2ce49bd6__is-unstyled", "is-loading": "_914b42f315c0e580__is-loading", "is-small": "_908205475f9f2a92__is-small", "icon": "_9f6fc6553aeb36fe__icon", "is-brand": "dd460c965226cc77__is-brand", "is-outline": "_62d5a778b7b258ee__is-outline", "is-minimal": "ad0619a3217c6a5b__is-minimal", "is-neutral": "e722a8f96726aa99__is-neutral", "is-solid": "b50b3358c5fb4d0b__is-solid", "is-compact": "cf59cf1b69629838__is-compact", "loading-animation": "_5a1d53da6f830c8d__loading-animation" };
10214 if (typeof process === "undefined" || true) {
10215 registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10216 }
10217 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10218 if (typeof process === "undefined" || true) {
10219 registerStyle3("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))}}}");
10220 }
10221 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" };
10222 if (typeof process === "undefined" || true) {
10223 registerStyle3("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
10224 }
10225 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" };
10226 var Button3 = (0, import_element12.forwardRef)(
10227 function Button22({
10228 tone = "brand",
10229 variant = "solid",
10230 size: size4 = "default",
10231 className,
10232 focusableWhenDisabled = true,
10233 disabled: disabled2,
10234 loading,
10235 loadingAnnouncement = (0, import_i18n.__)("Loading"),
10236 children,
10237 ...props
10238 }, ref) {
10239 const mergedClassName = clsx_default(
10240 global_css_defense_default2.button,
10241 resets_default["box-sizing"],
10242 focus_default["outset-ring--focus-except-active"],
10243 variant !== "unstyled" && style_default3.button,
10244 style_default3[`is-${tone}`],
10245 style_default3[`is-${variant}`],
10246 style_default3[`is-${size4}`],
10247 loading && style_default3["is-loading"],
10248 className
10249 );
10250 (0, import_element12.useEffect)(() => {
10251 if (loading && loadingAnnouncement) {
10252 speak(loadingAnnouncement);
10253 }
10254 }, [loading, loadingAnnouncement]);
10255 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
10256 Button,
10257 {
10258 ref,
10259 className: mergedClassName,
10260 focusableWhenDisabled,
10261 disabled: disabled2 ?? loading,
10262 ...props,
10263 children
10264 }
10265 );
10266 }
10267 );
10268
10269 // packages/ui/build-module/button/icon.mjs
10270 var import_element14 = __toESM(require_element(), 1);
10271
10272 // packages/ui/build-module/icon/icon.mjs
10273 var import_element13 = __toESM(require_element(), 1);
10274 var import_primitives = __toESM(require_primitives(), 1);
10275 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
10276 var Icon = (0, import_element13.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
10277 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
10278 import_primitives.SVG,
10279 {
10280 ref,
10281 ...icon.props,
10282 ...restProps,
10283 width: size4,
10284 height: size4
10285 }
10286 );
10287 });
10288
10289 // packages/ui/build-module/button/icon.mjs
10290 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
10291 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
10292 function getRuntime4() {
10293 const globalScope = globalThis;
10294 if (globalScope.__wpStyleRuntime) {
10295 return globalScope.__wpStyleRuntime;
10296 }
10297 globalScope.__wpStyleRuntime = {
10298 documents: /* @__PURE__ */ new Map(),
10299 styles: /* @__PURE__ */ new Map(),
10300 injectedStyles: /* @__PURE__ */ new WeakMap()
10301 };
10302 if (typeof document !== "undefined") {
10303 registerDocument4(document);
10304 }
10305 return globalScope.__wpStyleRuntime;
10306 }
10307 function documentContainsStyleHash4(targetDocument, hash) {
10308 if (!targetDocument.head) {
10309 return false;
10310 }
10311 for (const style of targetDocument.head.querySelectorAll(
10312 `style[${STYLE_HASH_ATTRIBUTE4}]`
10313 )) {
10314 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
10315 return true;
10316 }
10317 }
10318 return false;
10319 }
10320 function injectStyle4(targetDocument, hash, css) {
10321 if (!targetDocument.head) {
10322 return;
10323 }
10324 const runtime = getRuntime4();
10325 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10326 if (!injectedStyles) {
10327 injectedStyles = /* @__PURE__ */ new Set();
10328 runtime.injectedStyles.set(targetDocument, injectedStyles);
10329 }
10330 if (injectedStyles.has(hash)) {
10331 return;
10332 }
10333 if (documentContainsStyleHash4(targetDocument, hash)) {
10334 injectedStyles.add(hash);
10335 return;
10336 }
10337 const style = targetDocument.createElement("style");
10338 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
10339 style.appendChild(targetDocument.createTextNode(css));
10340 targetDocument.head.appendChild(style);
10341 injectedStyles.add(hash);
10342 }
10343 function registerDocument4(targetDocument) {
10344 const runtime = getRuntime4();
10345 runtime.documents.set(
10346 targetDocument,
10347 (runtime.documents.get(targetDocument) ?? 0) + 1
10348 );
10349 for (const [hash, css] of runtime.styles) {
10350 injectStyle4(targetDocument, hash, css);
10351 }
10352 return () => {
10353 const count = runtime.documents.get(targetDocument);
10354 if (count === void 0) {
10355 return;
10356 }
10357 if (count <= 1) {
10358 runtime.documents.delete(targetDocument);
10359 return;
10360 }
10361 runtime.documents.set(targetDocument, count - 1);
10362 };
10363 }
10364 function registerStyle4(hash, css) {
10365 const runtime = getRuntime4();
10366 runtime.styles.set(hash, css);
10367 for (const targetDocument of runtime.documents.keys()) {
10368 injectStyle4(targetDocument, hash, css);
10369 }
10370 }
10371 if (typeof process === "undefined" || true) {
10372 registerStyle4("4c317b0736", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._97b0fc33c028be1a__button,.abbb272e2ce49bd6__is-unstyled{appearance:none;padding:0}._97b0fc33c028be1a__button{--wp-ui-button-font-weight:var(--wpds-typography-font-weight-medium,499);--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-strong-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 93%,#000));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-strong-disabled,#8d8d8d);--wp-ui-button-padding-block:var(--wpds-dimension-padding-xs,4px);--wp-ui-button-padding-inline:var(--wpds-dimension-padding-md,12px);--wp-ui-button-height:var(--wpds-dimension-size-lg,40px);--wp-ui-button-aspect-ratio:auto;--wp-ui-button-font-size:var(--wpds-typography-font-size-md,13px);--wp-ui-button-min-width:calc(4ch + var(--wp-ui-button-padding-inline)*2);--wp-ui-button-icon-margin:calc((var(--wpds-dimension-size-2xs, 16px) - var(--wpds-dimension-size-sm, 24px))/2);--wp-ui-button-border-color:var(--wp-ui-button-background-color);--wp-ui-button-border-color-active:var(--wp-ui-button-background-color-active);--wp-ui-button-border-color-disabled:var(--wp-ui-button-background-color-disabled);--_gcd-button-font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);--_gcd-button-font-size:var(--wp-ui-button-font-size);--_gcd-button-font-weight:var(--wp-ui-button-font-weight);align-items:center;aspect-ratio:var(--wp-ui-button-aspect-ratio);background-clip:padding-box;background-color:var(--wp-ui-button-background-color);border-color:var(--wp-ui-button-border-color);border-radius:var(--wpds-border-radius-sm,2px);border-style:solid;border-width:1px;color:var(--wp-ui-button-foreground-color);display:inline-flex;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(--wp-ui-button-font-size);font-weight:var(--wp-ui-button-font-weight);gap:var(--wpds-dimension-gap-sm,8px);justify-content:center;line-height:var(--wpds-typography-line-height-sm,20px);max-width:100%;min-height:var(--wp-ui-button-height);min-width:var(--wp-ui-button-min-width);overflow-wrap:anywhere;padding-block:var(--wp-ui-button-padding-block);padding-inline:var(--wp-ui-button-padding-inline);position:relative;text-align:center;text-decoration:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}@media not (prefers-reduced-motion){transition:color .1s ease-out;*{transition:opacity .1s ease-out}}&[href]{cursor:pointer}[href]{color:inherit;text-decoration:inherit}&:not([data-disabled]):is(:hover,:active,:focus){background-color:var(--wp-ui-button-background-color-active);border-color:var(--wp-ui-button-border-color-active);color:var(--wp-ui-button-foreground-color-active)}&[data-disabled]:not(._914b42f315c0e580__is-loading){background-color:var(--wp-ui-button-background-color-disabled);border-color:var(--wp-ui-button-border-color-disabled);color:var(--wp-ui-button-foreground-color-disabled);@media (forced-colors:active){border-bottom-color:GrayText;border-left-color:GrayText;border-right-color:GrayText;border-top-color:GrayText;color:GrayText}}&:before{aspect-ratio:1;border:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid;border-block-end-color:transparent;border-block-start-color:var(--wp-ui-button-foreground-color);border-inline-end-color:var(--wp-ui-button-foreground-color);border-inline-start-color:transparent;border-radius:50%;box-sizing:border-box;content:"";display:block;height:var(--wp-ui-button-font-size);inset-inline-start:50%;opacity:0;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);@media not (prefers-reduced-motion){transition:opacity .1s ease-out}@media (forced-colors:active){border-block-end-style:none;border-bottom-color:ButtonText;border-inline-start-style:none;border-left-color:ButtonText;border-right-color:ButtonText;border-top-color:ButtonText}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-block:0;--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:var(--wpds-dimension-size-sm,24px)}._9f6fc6553aeb36fe__icon{margin:var(--wp-ui-button-icon-margin)}.dd460c965226cc77__is-brand{&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-brand-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 85%,#000));--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-brand-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-background-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-brand-weak-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 12%,#fff));--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-brand-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.ad0619a3217c6a5b__is-minimal[aria-pressed=true],&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-foreground-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000);--wp-ui-button-border-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d);--wp-ui-button-border-color-active:var(--wpds-color-stroke-interactive-neutral-active,#6e6e6e);--wp-ui-button-border-color-disabled:var(--wpds-color-stroke-interactive-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-background-color:var(--wpds-color-background-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-background-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-background-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:var(--wpds-dimension-size-md,32px)}._914b42f315c0e580__is-loading:not(.abbb272e2ce49bd6__is-unstyled){color:transparent;&:not([data-disabled]):is(:hover,:active,:focus){color:transparent}@media (forced-colors:active){color:ButtonFace}*{opacity:0}&:before{opacity:1;transition-delay:.05s;@media not (prefers-reduced-motion){animation:_5a1d53da6f830c8d__loading-animation 1s linear infinite}}}}@keyframes _5a1d53da6f830c8d__loading-animation{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}}');
10373 }
10374 var style_default4 = { "button": "_97b0fc33c028be1a__button", "is-unstyled": "abbb272e2ce49bd6__is-unstyled", "is-loading": "_914b42f315c0e580__is-loading", "is-small": "_908205475f9f2a92__is-small", "icon": "_9f6fc6553aeb36fe__icon", "is-brand": "dd460c965226cc77__is-brand", "is-outline": "_62d5a778b7b258ee__is-outline", "is-minimal": "ad0619a3217c6a5b__is-minimal", "is-neutral": "e722a8f96726aa99__is-neutral", "is-solid": "b50b3358c5fb4d0b__is-solid", "is-compact": "cf59cf1b69629838__is-compact", "loading-animation": "_5a1d53da6f830c8d__loading-animation" };
10375 var ButtonIcon = (0, import_element14.forwardRef)(
10376 function ButtonIcon2({ className, icon, ...props }, ref) {
10377 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
10378 Icon,
10379 {
10380 ref,
10381 icon,
10382 className: clsx_default(style_default4.icon, className),
10383 size: 24,
10384 ...props
10385 }
10386 );
10387 }
10388 );
10389
10390 // packages/ui/build-module/button/index.mjs
10391 ButtonIcon.displayName = "Button.Icon";
10392 var Button4 = Object.assign(Button3, {
10393 /**
10394 * An icon component specifically designed to work well when rendered inside
10395 * a `Button` component.
10396 */
10397 Icon: ButtonIcon
10398 });
10399
10400 // packages/ui/build-module/card/index.mjs
10401 var card_exports = {};
10402 __export(card_exports, {
10403 Content: () => Content,
10404 FullBleed: () => FullBleed,
10405 Header: () => Header,
10406 Root: () => Root,
10407 Title: () => Title
10408 });
10409
10410 // packages/ui/build-module/card/root.mjs
10411 var import_element15 = __toESM(require_element(), 1);
10412 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
10413 function getRuntime5() {
10414 const globalScope = globalThis;
10415 if (globalScope.__wpStyleRuntime) {
10416 return globalScope.__wpStyleRuntime;
10417 }
10418 globalScope.__wpStyleRuntime = {
10419 documents: /* @__PURE__ */ new Map(),
10420 styles: /* @__PURE__ */ new Map(),
10421 injectedStyles: /* @__PURE__ */ new WeakMap()
10422 };
10423 if (typeof document !== "undefined") {
10424 registerDocument5(document);
10425 }
10426 return globalScope.__wpStyleRuntime;
10427 }
10428 function documentContainsStyleHash5(targetDocument, hash) {
10429 if (!targetDocument.head) {
10430 return false;
10431 }
10432 for (const style of targetDocument.head.querySelectorAll(
10433 `style[${STYLE_HASH_ATTRIBUTE5}]`
10434 )) {
10435 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
10436 return true;
10437 }
10438 }
10439 return false;
10440 }
10441 function injectStyle5(targetDocument, hash, css) {
10442 if (!targetDocument.head) {
10443 return;
10444 }
10445 const runtime = getRuntime5();
10446 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10447 if (!injectedStyles) {
10448 injectedStyles = /* @__PURE__ */ new Set();
10449 runtime.injectedStyles.set(targetDocument, injectedStyles);
10450 }
10451 if (injectedStyles.has(hash)) {
10452 return;
10453 }
10454 if (documentContainsStyleHash5(targetDocument, hash)) {
10455 injectedStyles.add(hash);
10456 return;
10457 }
10458 const style = targetDocument.createElement("style");
10459 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
10460 style.appendChild(targetDocument.createTextNode(css));
10461 targetDocument.head.appendChild(style);
10462 injectedStyles.add(hash);
10463 }
10464 function registerDocument5(targetDocument) {
10465 const runtime = getRuntime5();
10466 runtime.documents.set(
10467 targetDocument,
10468 (runtime.documents.get(targetDocument) ?? 0) + 1
10469 );
10470 for (const [hash, css] of runtime.styles) {
10471 injectStyle5(targetDocument, hash, css);
10472 }
10473 return () => {
10474 const count = runtime.documents.get(targetDocument);
10475 if (count === void 0) {
10476 return;
10477 }
10478 if (count <= 1) {
10479 runtime.documents.delete(targetDocument);
10480 return;
10481 }
10482 runtime.documents.set(targetDocument, count - 1);
10483 };
10484 }
10485 function registerStyle5(hash, css) {
10486 const runtime = getRuntime5();
10487 runtime.styles.set(hash, css);
10488 for (const targetDocument of runtime.documents.keys()) {
10489 injectStyle5(targetDocument, hash, css);
10490 }
10491 }
10492 if (typeof process === "undefined" || true) {
10493 registerStyle5("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10494 }
10495 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10496 if (typeof process === "undefined" || true) {
10497 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)}}}");
10498 }
10499 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10500 var Root = (0, import_element15.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
10501 const mergedClassName = clsx_default(style_default5.root, resets_default2["box-sizing"]);
10502 const element = useRender({
10503 defaultTagName: "div",
10504 render: render4,
10505 ref,
10506 props: mergeProps({ className: mergedClassName }, restProps)
10507 });
10508 return element;
10509 });
10510
10511 // packages/ui/build-module/card/header.mjs
10512 var import_element16 = __toESM(require_element(), 1);
10513 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
10514 function getRuntime6() {
10515 const globalScope = globalThis;
10516 if (globalScope.__wpStyleRuntime) {
10517 return globalScope.__wpStyleRuntime;
10518 }
10519 globalScope.__wpStyleRuntime = {
10520 documents: /* @__PURE__ */ new Map(),
10521 styles: /* @__PURE__ */ new Map(),
10522 injectedStyles: /* @__PURE__ */ new WeakMap()
10523 };
10524 if (typeof document !== "undefined") {
10525 registerDocument6(document);
10526 }
10527 return globalScope.__wpStyleRuntime;
10528 }
10529 function documentContainsStyleHash6(targetDocument, hash) {
10530 if (!targetDocument.head) {
10531 return false;
10532 }
10533 for (const style of targetDocument.head.querySelectorAll(
10534 `style[${STYLE_HASH_ATTRIBUTE6}]`
10535 )) {
10536 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
10537 return true;
10538 }
10539 }
10540 return false;
10541 }
10542 function injectStyle6(targetDocument, hash, css) {
10543 if (!targetDocument.head) {
10544 return;
10545 }
10546 const runtime = getRuntime6();
10547 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10548 if (!injectedStyles) {
10549 injectedStyles = /* @__PURE__ */ new Set();
10550 runtime.injectedStyles.set(targetDocument, injectedStyles);
10551 }
10552 if (injectedStyles.has(hash)) {
10553 return;
10554 }
10555 if (documentContainsStyleHash6(targetDocument, hash)) {
10556 injectedStyles.add(hash);
10557 return;
10558 }
10559 const style = targetDocument.createElement("style");
10560 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
10561 style.appendChild(targetDocument.createTextNode(css));
10562 targetDocument.head.appendChild(style);
10563 injectedStyles.add(hash);
10564 }
10565 function registerDocument6(targetDocument) {
10566 const runtime = getRuntime6();
10567 runtime.documents.set(
10568 targetDocument,
10569 (runtime.documents.get(targetDocument) ?? 0) + 1
10570 );
10571 for (const [hash, css] of runtime.styles) {
10572 injectStyle6(targetDocument, hash, css);
10573 }
10574 return () => {
10575 const count = runtime.documents.get(targetDocument);
10576 if (count === void 0) {
10577 return;
10578 }
10579 if (count <= 1) {
10580 runtime.documents.delete(targetDocument);
10581 return;
10582 }
10583 runtime.documents.set(targetDocument, count - 1);
10584 };
10585 }
10586 function registerStyle6(hash, css) {
10587 const runtime = getRuntime6();
10588 runtime.styles.set(hash, css);
10589 for (const targetDocument of runtime.documents.keys()) {
10590 injectStyle6(targetDocument, hash, css);
10591 }
10592 }
10593 if (typeof process === "undefined" || true) {
10594 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)}}}");
10595 }
10596 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10597 var Header = (0, import_element16.forwardRef)(
10598 function CardHeader({ render: render4, ...props }, ref) {
10599 const element = useRender({
10600 defaultTagName: "div",
10601 render: render4,
10602 ref,
10603 props: mergeProps({ className: style_default6.header }, props)
10604 });
10605 return element;
10606 }
10607 );
10608
10609 // packages/ui/build-module/card/content.mjs
10610 var import_element17 = __toESM(require_element(), 1);
10611 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
10612 function getRuntime7() {
10613 const globalScope = globalThis;
10614 if (globalScope.__wpStyleRuntime) {
10615 return globalScope.__wpStyleRuntime;
10616 }
10617 globalScope.__wpStyleRuntime = {
10618 documents: /* @__PURE__ */ new Map(),
10619 styles: /* @__PURE__ */ new Map(),
10620 injectedStyles: /* @__PURE__ */ new WeakMap()
10621 };
10622 if (typeof document !== "undefined") {
10623 registerDocument7(document);
10624 }
10625 return globalScope.__wpStyleRuntime;
10626 }
10627 function documentContainsStyleHash7(targetDocument, hash) {
10628 if (!targetDocument.head) {
10629 return false;
10630 }
10631 for (const style of targetDocument.head.querySelectorAll(
10632 `style[${STYLE_HASH_ATTRIBUTE7}]`
10633 )) {
10634 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
10635 return true;
10636 }
10637 }
10638 return false;
10639 }
10640 function injectStyle7(targetDocument, hash, css) {
10641 if (!targetDocument.head) {
10642 return;
10643 }
10644 const runtime = getRuntime7();
10645 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10646 if (!injectedStyles) {
10647 injectedStyles = /* @__PURE__ */ new Set();
10648 runtime.injectedStyles.set(targetDocument, injectedStyles);
10649 }
10650 if (injectedStyles.has(hash)) {
10651 return;
10652 }
10653 if (documentContainsStyleHash7(targetDocument, hash)) {
10654 injectedStyles.add(hash);
10655 return;
10656 }
10657 const style = targetDocument.createElement("style");
10658 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
10659 style.appendChild(targetDocument.createTextNode(css));
10660 targetDocument.head.appendChild(style);
10661 injectedStyles.add(hash);
10662 }
10663 function registerDocument7(targetDocument) {
10664 const runtime = getRuntime7();
10665 runtime.documents.set(
10666 targetDocument,
10667 (runtime.documents.get(targetDocument) ?? 0) + 1
10668 );
10669 for (const [hash, css] of runtime.styles) {
10670 injectStyle7(targetDocument, hash, css);
10671 }
10672 return () => {
10673 const count = runtime.documents.get(targetDocument);
10674 if (count === void 0) {
10675 return;
10676 }
10677 if (count <= 1) {
10678 runtime.documents.delete(targetDocument);
10679 return;
10680 }
10681 runtime.documents.set(targetDocument, count - 1);
10682 };
10683 }
10684 function registerStyle7(hash, css) {
10685 const runtime = getRuntime7();
10686 runtime.styles.set(hash, css);
10687 for (const targetDocument of runtime.documents.keys()) {
10688 injectStyle7(targetDocument, hash, css);
10689 }
10690 }
10691 if (typeof process === "undefined" || true) {
10692 registerStyle7("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)}}}");
10693 }
10694 var style_default7 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10695 var Content = (0, import_element17.forwardRef)(
10696 function CardContent({ render: render4, ...props }, ref) {
10697 const element = useRender({
10698 defaultTagName: "div",
10699 render: render4,
10700 ref,
10701 props: mergeProps({ className: style_default7.content }, props)
10702 });
10703 return element;
10704 }
10705 );
10706
10707 // packages/ui/build-module/card/full-bleed.mjs
10708 var import_element18 = __toESM(require_element(), 1);
10709 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
10710 function getRuntime8() {
10711 const globalScope = globalThis;
10712 if (globalScope.__wpStyleRuntime) {
10713 return globalScope.__wpStyleRuntime;
10714 }
10715 globalScope.__wpStyleRuntime = {
10716 documents: /* @__PURE__ */ new Map(),
10717 styles: /* @__PURE__ */ new Map(),
10718 injectedStyles: /* @__PURE__ */ new WeakMap()
10719 };
10720 if (typeof document !== "undefined") {
10721 registerDocument8(document);
10722 }
10723 return globalScope.__wpStyleRuntime;
10724 }
10725 function documentContainsStyleHash8(targetDocument, hash) {
10726 if (!targetDocument.head) {
10727 return false;
10728 }
10729 for (const style of targetDocument.head.querySelectorAll(
10730 `style[${STYLE_HASH_ATTRIBUTE8}]`
10731 )) {
10732 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
10733 return true;
10734 }
10735 }
10736 return false;
10737 }
10738 function injectStyle8(targetDocument, hash, css) {
10739 if (!targetDocument.head) {
10740 return;
10741 }
10742 const runtime = getRuntime8();
10743 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10744 if (!injectedStyles) {
10745 injectedStyles = /* @__PURE__ */ new Set();
10746 runtime.injectedStyles.set(targetDocument, injectedStyles);
10747 }
10748 if (injectedStyles.has(hash)) {
10749 return;
10750 }
10751 if (documentContainsStyleHash8(targetDocument, hash)) {
10752 injectedStyles.add(hash);
10753 return;
10754 }
10755 const style = targetDocument.createElement("style");
10756 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
10757 style.appendChild(targetDocument.createTextNode(css));
10758 targetDocument.head.appendChild(style);
10759 injectedStyles.add(hash);
10760 }
10761 function registerDocument8(targetDocument) {
10762 const runtime = getRuntime8();
10763 runtime.documents.set(
10764 targetDocument,
10765 (runtime.documents.get(targetDocument) ?? 0) + 1
10766 );
10767 for (const [hash, css] of runtime.styles) {
10768 injectStyle8(targetDocument, hash, css);
10769 }
10770 return () => {
10771 const count = runtime.documents.get(targetDocument);
10772 if (count === void 0) {
10773 return;
10774 }
10775 if (count <= 1) {
10776 runtime.documents.delete(targetDocument);
10777 return;
10778 }
10779 runtime.documents.set(targetDocument, count - 1);
10780 };
10781 }
10782 function registerStyle8(hash, css) {
10783 const runtime = getRuntime8();
10784 runtime.styles.set(hash, css);
10785 for (const targetDocument of runtime.documents.keys()) {
10786 injectStyle8(targetDocument, hash, css);
10787 }
10788 }
10789 if (typeof process === "undefined" || true) {
10790 registerStyle8("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)}}}");
10791 }
10792 var style_default8 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10793 var FullBleed = (0, import_element18.forwardRef)(
10794 function CardFullBleed({ render: render4, ...props }, ref) {
10795 const element = useRender({
10796 defaultTagName: "div",
10797 render: render4,
10798 ref,
10799 props: mergeProps(
10800 { className: style_default8.fullbleed },
10801 props
10802 )
10803 });
10804 return element;
10805 }
10806 );
10807
10808 // packages/ui/build-module/card/title.mjs
10809 var import_element19 = __toESM(require_element(), 1);
10810 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
10811 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", {});
10812 var Title = (0, import_element19.forwardRef)(
10813 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
10814 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
10815 Text,
10816 {
10817 ref,
10818 variant: "heading-lg",
10819 render: render4,
10820 ...props,
10821 children
10822 }
10823 );
10824 }
10825 );
10826
10827 // packages/ui/build-module/collapsible/panel.mjs
10828 var import_element20 = __toESM(require_element(), 1);
10829 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
10830 var Panel = (0, import_element20.forwardRef)(
10831 function CollapsiblePanel3(props, forwardedRef) {
10832 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props });
10833 }
10834 );
10835
10836 // packages/ui/build-module/collapsible/root.mjs
10837 var import_element21 = __toESM(require_element(), 1);
10838 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
10839 var Root2 = (0, import_element21.forwardRef)(
10840 function CollapsibleRoot3(props, forwardedRef) {
10841 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props });
10842 }
10843 );
10844
10845 // packages/ui/build-module/collapsible/trigger.mjs
10846 var import_element22 = __toESM(require_element(), 1);
10847 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
10848 var Trigger = (0, import_element22.forwardRef)(
10849 function CollapsibleTrigger3(props, forwardedRef) {
10850 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props });
10851 }
10852 );
10853
10854 // packages/ui/build-module/collapsible-card/index.mjs
10855 var collapsible_card_exports = {};
10856 __export(collapsible_card_exports, {
10857 Content: () => Content2,
10858 Header: () => Header2,
10859 HeaderDescription: () => HeaderDescription,
10860 Root: () => Root3
10861 });
10862
10863 // packages/ui/build-module/collapsible-card/root.mjs
10864 var import_element23 = __toESM(require_element(), 1);
10865 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
10866 var Root3 = (0, import_element23.forwardRef)(
10867 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) {
10868 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
10869 Root2,
10870 {
10871 ref,
10872 render: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Root, { render: render4 }),
10873 ...restProps
10874 }
10875 );
10876 }
10877 );
10878
10879 // packages/ui/build-module/collapsible-card/header.mjs
10880 var import_element25 = __toESM(require_element(), 1);
10881
10882 // packages/icons/build-module/library/arrow-down.mjs
10883 var import_primitives2 = __toESM(require_primitives(), 1);
10884 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
10885 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.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" }) });
10886
10887 // packages/icons/build-module/library/arrow-left.mjs
10888 var import_primitives3 = __toESM(require_primitives(), 1);
10889 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
10890 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime22.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" }) });
10891
10892 // packages/icons/build-module/library/arrow-right.mjs
10893 var import_primitives4 = __toESM(require_primitives(), 1);
10894 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
10895 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime23.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" }) });
10896
10897 // packages/icons/build-module/library/arrow-up.mjs
10898 var import_primitives5 = __toESM(require_primitives(), 1);
10899 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
10900 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
10901
10902 // packages/icons/build-module/library/block-table.mjs
10903 var import_primitives6 = __toESM(require_primitives(), 1);
10904 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
10905 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives6.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) });
10906
10907 // packages/icons/build-module/library/category.mjs
10908 var import_primitives7 = __toESM(require_primitives(), 1);
10909 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
10910 var category_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives7.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) });
10911
10912 // packages/icons/build-module/library/check.mjs
10913 var import_primitives8 = __toESM(require_primitives(), 1);
10914 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
10915 var check_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives8.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
10916
10917 // packages/icons/build-module/library/chevron-down.mjs
10918 var import_primitives9 = __toESM(require_primitives(), 1);
10919 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
10920 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives9.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
10921
10922 // packages/icons/build-module/library/chevron-left.mjs
10923 var import_primitives10 = __toESM(require_primitives(), 1);
10924 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
10925 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives10.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) });
10926
10927 // packages/icons/build-module/library/chevron-right.mjs
10928 var import_primitives11 = __toESM(require_primitives(), 1);
10929 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
10930 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives11.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) });
10931
10932 // packages/icons/build-module/library/close-small.mjs
10933 var import_primitives12 = __toESM(require_primitives(), 1);
10934 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
10935 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives12.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" }) });
10936
10937 // packages/icons/build-module/library/cog.mjs
10938 var import_primitives13 = __toESM(require_primitives(), 1);
10939 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
10940 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives13.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" }) });
10941
10942 // packages/icons/build-module/library/drafts.mjs
10943 var import_primitives14 = __toESM(require_primitives(), 1);
10944 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
10945 var drafts_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives14.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 0Zm8 4a4 4 0 0 0 4-4H8a4 4 0 0 0 4 4Z" }) });
10946
10947 // packages/icons/build-module/library/envelope.mjs
10948 var import_primitives15 = __toESM(require_primitives(), 1);
10949 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
10950 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives15.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" }) });
10951
10952 // packages/icons/build-module/library/error.mjs
10953 var import_primitives16 = __toESM(require_primitives(), 1);
10954 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
10955 var error_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives16.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" }) });
10956
10957 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
10958 var import_primitives17 = __toESM(require_primitives(), 1);
10959 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
10960 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives17.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" }) });
10961
10962 // packages/icons/build-module/library/format-list-bullets.mjs
10963 var import_primitives18 = __toESM(require_primitives(), 1);
10964 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
10965 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives18.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" }) });
10966
10967 // packages/icons/build-module/library/funnel.mjs
10968 var import_primitives19 = __toESM(require_primitives(), 1);
10969 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
10970 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives19.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
10971
10972 // packages/icons/build-module/library/link.mjs
10973 var import_primitives20 = __toESM(require_primitives(), 1);
10974 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
10975 var link_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives20.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) });
10976
10977 // packages/icons/build-module/library/mobile.mjs
10978 var import_primitives21 = __toESM(require_primitives(), 1);
10979 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
10980 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives21.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) });
10981
10982 // packages/icons/build-module/library/more-vertical.mjs
10983 var import_primitives22 = __toESM(require_primitives(), 1);
10984 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10985 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
10986
10987 // packages/icons/build-module/library/next.mjs
10988 var import_primitives23 = __toESM(require_primitives(), 1);
10989 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10990 var next_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives23.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) });
10991
10992 // packages/icons/build-module/library/pencil.mjs
10993 var import_primitives24 = __toESM(require_primitives(), 1);
10994 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10995 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives24.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) });
10996
10997 // packages/icons/build-module/library/post-featured-image.mjs
10998 var import_primitives25 = __toESM(require_primitives(), 1);
10999 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
11000 var post_featured_image_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives25.Path, { d: "M19 3H5c-.6 0-1 .4-1 1v7c0 .5.4 1 1 1h14c.5 0 1-.4 1-1V4c0-.6-.4-1-1-1zM5.5 10.5v-.4l1.8-1.3 1.3.8c.3.2.7.2.9-.1L11 8.1l2.4 2.4H5.5zm13 0h-2.9l-4-4c-.3-.3-.8-.3-1.1 0L8.9 8l-1.2-.8c-.3-.2-.6-.2-.9 0l-1.3 1V4.5h13v6zM4 20h9v-1.5H4V20zm0-4h16v-1.5H4V16z" }) });
11001
11002 // packages/icons/build-module/library/previous.mjs
11003 var import_primitives26 = __toESM(require_primitives(), 1);
11004 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
11005 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives26.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" }) });
11006
11007 // packages/icons/build-module/library/scheduled.mjs
11008 var import_primitives27 = __toESM(require_primitives(), 1);
11009 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
11010 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives27.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" }) });
11011
11012 // packages/icons/build-module/library/search.mjs
11013 var import_primitives28 = __toESM(require_primitives(), 1);
11014 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
11015 var search_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives28.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" }) });
11016
11017 // packages/icons/build-module/library/seen.mjs
11018 var import_primitives29 = __toESM(require_primitives(), 1);
11019 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
11020 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives29.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" }) });
11021
11022 // packages/icons/build-module/library/trash.mjs
11023 var import_primitives30 = __toESM(require_primitives(), 1);
11024 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
11025 var trash_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives30.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" }) });
11026
11027 // packages/icons/build-module/library/unseen.mjs
11028 var import_primitives31 = __toESM(require_primitives(), 1);
11029 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11030 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives31.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives31.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" }) });
11031
11032 // packages/ui/build-module/collapsible-card/context.mjs
11033 var import_element24 = __toESM(require_element(), 1);
11034 var HeaderDescriptionIdContext = (0, import_element24.createContext)({
11035 setDescriptionId: () => {
11036 }
11037 });
11038
11039 // packages/ui/build-module/collapsible-card/header.mjs
11040 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11041 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
11042 function getRuntime9() {
11043 const globalScope = globalThis;
11044 if (globalScope.__wpStyleRuntime) {
11045 return globalScope.__wpStyleRuntime;
11046 }
11047 globalScope.__wpStyleRuntime = {
11048 documents: /* @__PURE__ */ new Map(),
11049 styles: /* @__PURE__ */ new Map(),
11050 injectedStyles: /* @__PURE__ */ new WeakMap()
11051 };
11052 if (typeof document !== "undefined") {
11053 registerDocument9(document);
11054 }
11055 return globalScope.__wpStyleRuntime;
11056 }
11057 function documentContainsStyleHash9(targetDocument, hash) {
11058 if (!targetDocument.head) {
11059 return false;
11060 }
11061 for (const style of targetDocument.head.querySelectorAll(
11062 `style[${STYLE_HASH_ATTRIBUTE9}]`
11063 )) {
11064 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
11065 return true;
11066 }
11067 }
11068 return false;
11069 }
11070 function injectStyle9(targetDocument, hash, css) {
11071 if (!targetDocument.head) {
11072 return;
11073 }
11074 const runtime = getRuntime9();
11075 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11076 if (!injectedStyles) {
11077 injectedStyles = /* @__PURE__ */ new Set();
11078 runtime.injectedStyles.set(targetDocument, injectedStyles);
11079 }
11080 if (injectedStyles.has(hash)) {
11081 return;
11082 }
11083 if (documentContainsStyleHash9(targetDocument, hash)) {
11084 injectedStyles.add(hash);
11085 return;
11086 }
11087 const style = targetDocument.createElement("style");
11088 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
11089 style.appendChild(targetDocument.createTextNode(css));
11090 targetDocument.head.appendChild(style);
11091 injectedStyles.add(hash);
11092 }
11093 function registerDocument9(targetDocument) {
11094 const runtime = getRuntime9();
11095 runtime.documents.set(
11096 targetDocument,
11097 (runtime.documents.get(targetDocument) ?? 0) + 1
11098 );
11099 for (const [hash, css] of runtime.styles) {
11100 injectStyle9(targetDocument, hash, css);
11101 }
11102 return () => {
11103 const count = runtime.documents.get(targetDocument);
11104 if (count === void 0) {
11105 return;
11106 }
11107 if (count <= 1) {
11108 runtime.documents.delete(targetDocument);
11109 return;
11110 }
11111 runtime.documents.set(targetDocument, count - 1);
11112 };
11113 }
11114 function registerStyle9(hash, css) {
11115 const runtime = getRuntime9();
11116 runtime.styles.set(hash, css);
11117 for (const targetDocument of runtime.documents.keys()) {
11118 injectStyle9(targetDocument, hash, css);
11119 }
11120 }
11121 if (typeof process === "undefined" || true) {
11122 registerStyle9("ee46794e90", "@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;&._165c4572592944b2__overflowVisible{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)}}}}");
11123 }
11124 var style_default9 = { "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", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
11125 if (typeof process === "undefined" || true) {
11126 registerStyle9("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
11127 }
11128 var global_css_defense_default3 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
11129 if (typeof process === "undefined" || true) {
11130 registerStyle9("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))}}}");
11131 }
11132 var focus_default2 = { "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" };
11133 var Header2 = (0, import_element25.forwardRef)(
11134 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) {
11135 const [descriptionId, setDescriptionId] = (0, import_element25.useState)();
11136 const contextValue = (0, import_element25.useMemo)(
11137 () => ({ setDescriptionId }),
11138 [setDescriptionId]
11139 );
11140 return useRender({
11141 defaultTagName: "div",
11142 render: render4,
11143 ref,
11144 props: mergeProps(restProps, {
11145 className: clsx_default(
11146 global_css_defense_default3.heading,
11147 style_default9["heading-wrapper"],
11148 className
11149 ),
11150 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
11151 Trigger,
11152 {
11153 className: style_default9.header,
11154 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Header, {}),
11155 nativeButton: false,
11156 "aria-describedby": descriptionId,
11157 children: [
11158 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: style_default9["header-content"], children }),
11159 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11160 "div",
11161 {
11162 className: clsx_default(
11163 style_default9["header-trigger-positioner"]
11164 ),
11165 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11166 "div",
11167 {
11168 className: clsx_default(
11169 style_default9["header-trigger-wrapper"],
11170 global_css_defense_default3.div,
11171 // While the interactive trigger element is the whole header,
11172 // the focus ring will be displayed only on the icon to visually
11173 // emulate it being the button.
11174 focus_default2["outset-ring--focus-parent-visible"]
11175 ),
11176 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11177 Icon,
11178 {
11179 icon: chevron_down_default,
11180 className: style_default9["header-trigger"]
11181 }
11182 )
11183 }
11184 )
11185 }
11186 )
11187 ]
11188 }
11189 ) })
11190 })
11191 });
11192 }
11193 );
11194
11195 // packages/ui/build-module/collapsible-card/header-description.mjs
11196 var import_element26 = __toESM(require_element(), 1);
11197 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11198 var HeaderDescription = (0, import_element26.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) {
11199 const descriptionId = (0, import_element26.useId)();
11200 const { setDescriptionId } = (0, import_element26.useContext)(HeaderDescriptionIdContext);
11201 (0, import_element26.useEffect)(() => {
11202 setDescriptionId(descriptionId);
11203 return () => setDescriptionId(void 0);
11204 }, [descriptionId, setDescriptionId]);
11205 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11206 "div",
11207 {
11208 ref,
11209 id: descriptionId,
11210 "aria-hidden": "true",
11211 className,
11212 ...restProps,
11213 children
11214 }
11215 );
11216 });
11217
11218 // packages/ui/build-module/collapsible-card/content.mjs
11219 var import_element27 = __toESM(require_element(), 1);
11220 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11221 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
11222 function getRuntime10() {
11223 const globalScope = globalThis;
11224 if (globalScope.__wpStyleRuntime) {
11225 return globalScope.__wpStyleRuntime;
11226 }
11227 globalScope.__wpStyleRuntime = {
11228 documents: /* @__PURE__ */ new Map(),
11229 styles: /* @__PURE__ */ new Map(),
11230 injectedStyles: /* @__PURE__ */ new WeakMap()
11231 };
11232 if (typeof document !== "undefined") {
11233 registerDocument10(document);
11234 }
11235 return globalScope.__wpStyleRuntime;
11236 }
11237 function documentContainsStyleHash10(targetDocument, hash) {
11238 if (!targetDocument.head) {
11239 return false;
11240 }
11241 for (const style of targetDocument.head.querySelectorAll(
11242 `style[${STYLE_HASH_ATTRIBUTE10}]`
11243 )) {
11244 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
11245 return true;
11246 }
11247 }
11248 return false;
11249 }
11250 function injectStyle10(targetDocument, hash, css) {
11251 if (!targetDocument.head) {
11252 return;
11253 }
11254 const runtime = getRuntime10();
11255 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11256 if (!injectedStyles) {
11257 injectedStyles = /* @__PURE__ */ new Set();
11258 runtime.injectedStyles.set(targetDocument, injectedStyles);
11259 }
11260 if (injectedStyles.has(hash)) {
11261 return;
11262 }
11263 if (documentContainsStyleHash10(targetDocument, hash)) {
11264 injectedStyles.add(hash);
11265 return;
11266 }
11267 const style = targetDocument.createElement("style");
11268 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
11269 style.appendChild(targetDocument.createTextNode(css));
11270 targetDocument.head.appendChild(style);
11271 injectedStyles.add(hash);
11272 }
11273 function registerDocument10(targetDocument) {
11274 const runtime = getRuntime10();
11275 runtime.documents.set(
11276 targetDocument,
11277 (runtime.documents.get(targetDocument) ?? 0) + 1
11278 );
11279 for (const [hash, css] of runtime.styles) {
11280 injectStyle10(targetDocument, hash, css);
11281 }
11282 return () => {
11283 const count = runtime.documents.get(targetDocument);
11284 if (count === void 0) {
11285 return;
11286 }
11287 if (count <= 1) {
11288 runtime.documents.delete(targetDocument);
11289 return;
11290 }
11291 runtime.documents.set(targetDocument, count - 1);
11292 };
11293 }
11294 function registerStyle10(hash, css) {
11295 const runtime = getRuntime10();
11296 runtime.styles.set(hash, css);
11297 for (const targetDocument of runtime.documents.keys()) {
11298 injectStyle10(targetDocument, hash, css);
11299 }
11300 }
11301 if (typeof process === "undefined" || true) {
11302 registerStyle10("ee46794e90", "@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;&._165c4572592944b2__overflowVisible{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)}}}}");
11303 }
11304 var style_default10 = { "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", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
11305 var Content2 = (0, import_element27.forwardRef)(
11306 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) {
11307 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11308 Panel,
11309 {
11310 ref,
11311 className: (state) => clsx_default(
11312 style_default10.content,
11313 state.open && state.transitionStatus === "idle" && style_default10.overflowVisible,
11314 className
11315 ),
11316 hiddenUntilFound,
11317 ...restProps,
11318 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11319 Content,
11320 {
11321 className: style_default10["content-inner"],
11322 render: render4,
11323 children
11324 }
11325 )
11326 }
11327 );
11328 }
11329 );
11330
11331 // packages/ui/build-module/utils/render-slot-with-children.mjs
11332 var import_element28 = __toESM(require_element(), 1);
11333 function renderSlotWithChildren(slot, defaultSlot, children) {
11334 return (0, import_element28.cloneElement)(slot ?? defaultSlot, { children });
11335 }
11336
11337 // packages/ui/build-module/utils/theme-provider.mjs
11338 var theme = __toESM(require_theme(), 1);
11339
11340 // packages/ui/build-module/lock-unlock.mjs
11341 var import_private_apis = __toESM(require_private_apis(), 1);
11342 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
11343 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
11344 "@wordpress/ui"
11345 );
11346
11347 // packages/ui/build-module/utils/theme-provider.mjs
11348 function getThemeProvider() {
11349 const themePackage = theme;
11350 if (themePackage.ThemeProvider) {
11351 return themePackage.ThemeProvider;
11352 }
11353 if (!themePackage.privateApis) {
11354 throw new Error(
11355 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
11356 );
11357 }
11358 return unlock(
11359 themePackage.privateApis
11360 ).ThemeProvider;
11361 }
11362 var ThemeProvider = getThemeProvider();
11363
11364 // packages/ui/build-module/stack/stack.mjs
11365 var import_element29 = __toESM(require_element(), 1);
11366 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
11367 function getRuntime11() {
11368 const globalScope = globalThis;
11369 if (globalScope.__wpStyleRuntime) {
11370 return globalScope.__wpStyleRuntime;
11371 }
11372 globalScope.__wpStyleRuntime = {
11373 documents: /* @__PURE__ */ new Map(),
11374 styles: /* @__PURE__ */ new Map(),
11375 injectedStyles: /* @__PURE__ */ new WeakMap()
11376 };
11377 if (typeof document !== "undefined") {
11378 registerDocument11(document);
11379 }
11380 return globalScope.__wpStyleRuntime;
11381 }
11382 function documentContainsStyleHash11(targetDocument, hash) {
11383 if (!targetDocument.head) {
11384 return false;
11385 }
11386 for (const style of targetDocument.head.querySelectorAll(
11387 `style[${STYLE_HASH_ATTRIBUTE11}]`
11388 )) {
11389 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
11390 return true;
11391 }
11392 }
11393 return false;
11394 }
11395 function injectStyle11(targetDocument, hash, css) {
11396 if (!targetDocument.head) {
11397 return;
11398 }
11399 const runtime = getRuntime11();
11400 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11401 if (!injectedStyles) {
11402 injectedStyles = /* @__PURE__ */ new Set();
11403 runtime.injectedStyles.set(targetDocument, injectedStyles);
11404 }
11405 if (injectedStyles.has(hash)) {
11406 return;
11407 }
11408 if (documentContainsStyleHash11(targetDocument, hash)) {
11409 injectedStyles.add(hash);
11410 return;
11411 }
11412 const style = targetDocument.createElement("style");
11413 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
11414 style.appendChild(targetDocument.createTextNode(css));
11415 targetDocument.head.appendChild(style);
11416 injectedStyles.add(hash);
11417 }
11418 function registerDocument11(targetDocument) {
11419 const runtime = getRuntime11();
11420 runtime.documents.set(
11421 targetDocument,
11422 (runtime.documents.get(targetDocument) ?? 0) + 1
11423 );
11424 for (const [hash, css] of runtime.styles) {
11425 injectStyle11(targetDocument, hash, css);
11426 }
11427 return () => {
11428 const count = runtime.documents.get(targetDocument);
11429 if (count === void 0) {
11430 return;
11431 }
11432 if (count <= 1) {
11433 runtime.documents.delete(targetDocument);
11434 return;
11435 }
11436 runtime.documents.set(targetDocument, count - 1);
11437 };
11438 }
11439 function registerStyle11(hash, css) {
11440 const runtime = getRuntime11();
11441 runtime.styles.set(hash, css);
11442 for (const targetDocument of runtime.documents.keys()) {
11443 injectStyle11(targetDocument, hash, css);
11444 }
11445 }
11446 if (typeof process === "undefined" || true) {
11447 registerStyle11("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
11448 }
11449 var style_default11 = { "stack": "_19ce0419607e1896__stack" };
11450 var gapTokens = {
11451 xs: "var(--wpds-dimension-gap-xs, 4px)",
11452 sm: "var(--wpds-dimension-gap-sm, 8px)",
11453 md: "var(--wpds-dimension-gap-md, 12px)",
11454 lg: "var(--wpds-dimension-gap-lg, 16px)",
11455 xl: "var(--wpds-dimension-gap-xl, 24px)",
11456 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
11457 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
11458 };
11459 var Stack = (0, import_element29.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
11460 const style = {
11461 gap: gap && gapTokens[gap],
11462 alignItems: align,
11463 justifyContent: justify,
11464 flexDirection: direction,
11465 flexWrap: wrap
11466 };
11467 const element = useRender({
11468 render: render4,
11469 ref,
11470 props: mergeProps(props, { style, className: style_default11.stack })
11471 });
11472 return element;
11473 });
11474
11475 // packages/ui/build-module/icon-button/icon-button.mjs
11476 var import_element34 = __toESM(require_element(), 1);
11477
11478 // packages/ui/build-module/tooltip/index.mjs
11479 var tooltip_exports = {};
11480 __export(tooltip_exports, {
11481 Popup: () => Popup,
11482 Portal: () => Portal,
11483 Positioner: () => Positioner,
11484 Provider: () => Provider,
11485 Root: () => Root4,
11486 Trigger: () => Trigger2
11487 });
11488
11489 // packages/ui/build-module/tooltip/popup.mjs
11490 var import_element32 = __toESM(require_element(), 1);
11491
11492 // packages/ui/build-module/tooltip/portal.mjs
11493 var import_element30 = __toESM(require_element(), 1);
11494
11495 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
11496 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
11497 function getRuntime12() {
11498 const globalScope = globalThis;
11499 if (globalScope.__wpStyleRuntime) {
11500 return globalScope.__wpStyleRuntime;
11501 }
11502 globalScope.__wpStyleRuntime = {
11503 documents: /* @__PURE__ */ new Map(),
11504 styles: /* @__PURE__ */ new Map(),
11505 injectedStyles: /* @__PURE__ */ new WeakMap()
11506 };
11507 if (typeof document !== "undefined") {
11508 registerDocument12(document);
11509 }
11510 return globalScope.__wpStyleRuntime;
11511 }
11512 function documentContainsStyleHash12(targetDocument, hash) {
11513 if (!targetDocument.head) {
11514 return false;
11515 }
11516 for (const style of targetDocument.head.querySelectorAll(
11517 `style[${STYLE_HASH_ATTRIBUTE12}]`
11518 )) {
11519 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
11520 return true;
11521 }
11522 }
11523 return false;
11524 }
11525 function injectStyle12(targetDocument, hash, css) {
11526 if (!targetDocument.head) {
11527 return;
11528 }
11529 const runtime = getRuntime12();
11530 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11531 if (!injectedStyles) {
11532 injectedStyles = /* @__PURE__ */ new Set();
11533 runtime.injectedStyles.set(targetDocument, injectedStyles);
11534 }
11535 if (injectedStyles.has(hash)) {
11536 return;
11537 }
11538 if (documentContainsStyleHash12(targetDocument, hash)) {
11539 injectedStyles.add(hash);
11540 return;
11541 }
11542 const style = targetDocument.createElement("style");
11543 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
11544 style.appendChild(targetDocument.createTextNode(css));
11545 targetDocument.head.appendChild(style);
11546 injectedStyles.add(hash);
11547 }
11548 function registerDocument12(targetDocument) {
11549 const runtime = getRuntime12();
11550 runtime.documents.set(
11551 targetDocument,
11552 (runtime.documents.get(targetDocument) ?? 0) + 1
11553 );
11554 for (const [hash, css] of runtime.styles) {
11555 injectStyle12(targetDocument, hash, css);
11556 }
11557 return () => {
11558 const count = runtime.documents.get(targetDocument);
11559 if (count === void 0) {
11560 return;
11561 }
11562 if (count <= 1) {
11563 runtime.documents.delete(targetDocument);
11564 return;
11565 }
11566 runtime.documents.set(targetDocument, count - 1);
11567 };
11568 }
11569 function registerStyle12(hash, css) {
11570 const runtime = getRuntime12();
11571 runtime.styles.set(hash, css);
11572 for (const targetDocument of runtime.documents.keys()) {
11573 injectStyle12(targetDocument, hash, css);
11574 }
11575 }
11576 if (typeof process === "undefined" || true) {
11577 registerStyle12("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}}}");
11578 }
11579 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
11580 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
11581 function resolveOwnerDocument() {
11582 return typeof document === "undefined" ? null : document;
11583 }
11584 function isInWordPressEnvironment() {
11585 let topWp;
11586 try {
11587 topWp = window.top?.wp;
11588 } catch {
11589 }
11590 const wp = topWp ?? window.wp;
11591 return typeof wp?.components === "object" && wp.components !== null;
11592 }
11593 var cachedSlot = null;
11594 function createSlot(ownerDocument2) {
11595 const element = ownerDocument2.createElement("div");
11596 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
11597 if (wp_compat_overlay_slot_default.slot) {
11598 element.classList.add(wp_compat_overlay_slot_default.slot);
11599 }
11600 ownerDocument2.body.appendChild(element);
11601 return element;
11602 }
11603 function getWpCompatOverlaySlot() {
11604 if (typeof window === "undefined") {
11605 return void 0;
11606 }
11607 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
11608 return void 0;
11609 }
11610 const ownerDocument2 = resolveOwnerDocument();
11611 if (!ownerDocument2 || !ownerDocument2.body) {
11612 return void 0;
11613 }
11614 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
11615 return cachedSlot;
11616 }
11617 const existing = ownerDocument2.querySelector(
11618 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
11619 );
11620 if (existing instanceof HTMLDivElement) {
11621 cachedSlot = existing;
11622 return existing;
11623 }
11624 if (cachedSlot?.isConnected) {
11625 cachedSlot.remove();
11626 }
11627 cachedSlot = createSlot(ownerDocument2);
11628 return cachedSlot;
11629 }
11630
11631 // packages/ui/build-module/tooltip/portal.mjs
11632 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11633 var Portal = (0, import_element30.forwardRef)(
11634 function TooltipPortal3({ container, ...restProps }, ref) {
11635 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11636 index_parts_exports2.Portal,
11637 {
11638 container: container ?? getWpCompatOverlaySlot(),
11639 ...restProps,
11640 ref
11641 }
11642 );
11643 }
11644 );
11645
11646 // packages/ui/build-module/tooltip/positioner.mjs
11647 var import_element31 = __toESM(require_element(), 1);
11648 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11649 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
11650 function getRuntime13() {
11651 const globalScope = globalThis;
11652 if (globalScope.__wpStyleRuntime) {
11653 return globalScope.__wpStyleRuntime;
11654 }
11655 globalScope.__wpStyleRuntime = {
11656 documents: /* @__PURE__ */ new Map(),
11657 styles: /* @__PURE__ */ new Map(),
11658 injectedStyles: /* @__PURE__ */ new WeakMap()
11659 };
11660 if (typeof document !== "undefined") {
11661 registerDocument13(document);
11662 }
11663 return globalScope.__wpStyleRuntime;
11664 }
11665 function documentContainsStyleHash13(targetDocument, hash) {
11666 if (!targetDocument.head) {
11667 return false;
11668 }
11669 for (const style of targetDocument.head.querySelectorAll(
11670 `style[${STYLE_HASH_ATTRIBUTE13}]`
11671 )) {
11672 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
11673 return true;
11674 }
11675 }
11676 return false;
11677 }
11678 function injectStyle13(targetDocument, hash, css) {
11679 if (!targetDocument.head) {
11680 return;
11681 }
11682 const runtime = getRuntime13();
11683 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11684 if (!injectedStyles) {
11685 injectedStyles = /* @__PURE__ */ new Set();
11686 runtime.injectedStyles.set(targetDocument, injectedStyles);
11687 }
11688 if (injectedStyles.has(hash)) {
11689 return;
11690 }
11691 if (documentContainsStyleHash13(targetDocument, hash)) {
11692 injectedStyles.add(hash);
11693 return;
11694 }
11695 const style = targetDocument.createElement("style");
11696 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
11697 style.appendChild(targetDocument.createTextNode(css));
11698 targetDocument.head.appendChild(style);
11699 injectedStyles.add(hash);
11700 }
11701 function registerDocument13(targetDocument) {
11702 const runtime = getRuntime13();
11703 runtime.documents.set(
11704 targetDocument,
11705 (runtime.documents.get(targetDocument) ?? 0) + 1
11706 );
11707 for (const [hash, css] of runtime.styles) {
11708 injectStyle13(targetDocument, hash, css);
11709 }
11710 return () => {
11711 const count = runtime.documents.get(targetDocument);
11712 if (count === void 0) {
11713 return;
11714 }
11715 if (count <= 1) {
11716 runtime.documents.delete(targetDocument);
11717 return;
11718 }
11719 runtime.documents.set(targetDocument, count - 1);
11720 };
11721 }
11722 function registerStyle13(hash, css) {
11723 const runtime = getRuntime13();
11724 runtime.styles.set(hash, css);
11725 for (const targetDocument of runtime.documents.keys()) {
11726 injectStyle13(targetDocument, hash, css);
11727 }
11728 }
11729 if (typeof process === "undefined" || true) {
11730 registerStyle13("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
11731 }
11732 var resets_default3 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
11733 if (typeof process === "undefined" || true) {
11734 registerStyle13("789467362f", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
11735 }
11736 var style_default12 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
11737 var Positioner = (0, import_element31.forwardRef)(
11738 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
11739 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11740 index_parts_exports2.Positioner,
11741 {
11742 ref,
11743 align,
11744 side,
11745 sideOffset,
11746 ...props,
11747 className: clsx_default(
11748 resets_default3["box-sizing"],
11749 style_default12.positioner,
11750 className
11751 )
11752 }
11753 );
11754 }
11755 );
11756
11757 // packages/ui/build-module/tooltip/popup.mjs
11758 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
11759 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
11760 function getRuntime14() {
11761 const globalScope = globalThis;
11762 if (globalScope.__wpStyleRuntime) {
11763 return globalScope.__wpStyleRuntime;
11764 }
11765 globalScope.__wpStyleRuntime = {
11766 documents: /* @__PURE__ */ new Map(),
11767 styles: /* @__PURE__ */ new Map(),
11768 injectedStyles: /* @__PURE__ */ new WeakMap()
11769 };
11770 if (typeof document !== "undefined") {
11771 registerDocument14(document);
11772 }
11773 return globalScope.__wpStyleRuntime;
11774 }
11775 function documentContainsStyleHash14(targetDocument, hash) {
11776 if (!targetDocument.head) {
11777 return false;
11778 }
11779 for (const style of targetDocument.head.querySelectorAll(
11780 `style[${STYLE_HASH_ATTRIBUTE14}]`
11781 )) {
11782 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
11783 return true;
11784 }
11785 }
11786 return false;
11787 }
11788 function injectStyle14(targetDocument, hash, css) {
11789 if (!targetDocument.head) {
11790 return;
11791 }
11792 const runtime = getRuntime14();
11793 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11794 if (!injectedStyles) {
11795 injectedStyles = /* @__PURE__ */ new Set();
11796 runtime.injectedStyles.set(targetDocument, injectedStyles);
11797 }
11798 if (injectedStyles.has(hash)) {
11799 return;
11800 }
11801 if (documentContainsStyleHash14(targetDocument, hash)) {
11802 injectedStyles.add(hash);
11803 return;
11804 }
11805 const style = targetDocument.createElement("style");
11806 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
11807 style.appendChild(targetDocument.createTextNode(css));
11808 targetDocument.head.appendChild(style);
11809 injectedStyles.add(hash);
11810 }
11811 function registerDocument14(targetDocument) {
11812 const runtime = getRuntime14();
11813 runtime.documents.set(
11814 targetDocument,
11815 (runtime.documents.get(targetDocument) ?? 0) + 1
11816 );
11817 for (const [hash, css] of runtime.styles) {
11818 injectStyle14(targetDocument, hash, css);
11819 }
11820 return () => {
11821 const count = runtime.documents.get(targetDocument);
11822 if (count === void 0) {
11823 return;
11824 }
11825 if (count <= 1) {
11826 runtime.documents.delete(targetDocument);
11827 return;
11828 }
11829 runtime.documents.set(targetDocument, count - 1);
11830 };
11831 }
11832 function registerStyle14(hash, css) {
11833 const runtime = getRuntime14();
11834 runtime.styles.set(hash, css);
11835 for (const targetDocument of runtime.documents.keys()) {
11836 injectStyle14(targetDocument, hash, css);
11837 }
11838 }
11839 if (typeof process === "undefined" || true) {
11840 registerStyle14("789467362f", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
11841 }
11842 var style_default13 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
11843 var POPUP_COLOR = { background: "#1e1e1e" };
11844 var Popup = (0, import_element32.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
11845 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
11846 index_parts_exports2.Popup,
11847 {
11848 ref,
11849 className: clsx_default(style_default13.popup, className),
11850 ...props,
11851 children
11852 }
11853 ) });
11854 const positionedPopup = renderSlotWithChildren(
11855 positioner,
11856 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Positioner, {}),
11857 popupContent
11858 );
11859 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Portal, {}), positionedPopup);
11860 });
11861
11862 // packages/ui/build-module/tooltip/trigger.mjs
11863 var import_element33 = __toESM(require_element(), 1);
11864 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
11865 var Trigger2 = (0, import_element33.forwardRef)(
11866 function TooltipTrigger3(props, ref) {
11867 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(index_parts_exports2.Trigger, { ref, ...props });
11868 }
11869 );
11870
11871 // packages/ui/build-module/tooltip/root.mjs
11872 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
11873 function Root4(props) {
11874 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(index_parts_exports2.Root, { ...props });
11875 }
11876
11877 // packages/ui/build-module/tooltip/provider.mjs
11878 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
11879 function Provider({ ...props }) {
11880 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(index_parts_exports2.Provider, { ...props });
11881 }
11882
11883 // packages/ui/build-module/icon-button/icon-button.mjs
11884 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
11885 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash";
11886 function getRuntime15() {
11887 const globalScope = globalThis;
11888 if (globalScope.__wpStyleRuntime) {
11889 return globalScope.__wpStyleRuntime;
11890 }
11891 globalScope.__wpStyleRuntime = {
11892 documents: /* @__PURE__ */ new Map(),
11893 styles: /* @__PURE__ */ new Map(),
11894 injectedStyles: /* @__PURE__ */ new WeakMap()
11895 };
11896 if (typeof document !== "undefined") {
11897 registerDocument15(document);
11898 }
11899 return globalScope.__wpStyleRuntime;
11900 }
11901 function documentContainsStyleHash15(targetDocument, hash) {
11902 if (!targetDocument.head) {
11903 return false;
11904 }
11905 for (const style of targetDocument.head.querySelectorAll(
11906 `style[${STYLE_HASH_ATTRIBUTE15}]`
11907 )) {
11908 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) {
11909 return true;
11910 }
11911 }
11912 return false;
11913 }
11914 function injectStyle15(targetDocument, hash, css) {
11915 if (!targetDocument.head) {
11916 return;
11917 }
11918 const runtime = getRuntime15();
11919 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11920 if (!injectedStyles) {
11921 injectedStyles = /* @__PURE__ */ new Set();
11922 runtime.injectedStyles.set(targetDocument, injectedStyles);
11923 }
11924 if (injectedStyles.has(hash)) {
11925 return;
11926 }
11927 if (documentContainsStyleHash15(targetDocument, hash)) {
11928 injectedStyles.add(hash);
11929 return;
11930 }
11931 const style = targetDocument.createElement("style");
11932 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash);
11933 style.appendChild(targetDocument.createTextNode(css));
11934 targetDocument.head.appendChild(style);
11935 injectedStyles.add(hash);
11936 }
11937 function registerDocument15(targetDocument) {
11938 const runtime = getRuntime15();
11939 runtime.documents.set(
11940 targetDocument,
11941 (runtime.documents.get(targetDocument) ?? 0) + 1
11942 );
11943 for (const [hash, css] of runtime.styles) {
11944 injectStyle15(targetDocument, hash, css);
11945 }
11946 return () => {
11947 const count = runtime.documents.get(targetDocument);
11948 if (count === void 0) {
11949 return;
11950 }
11951 if (count <= 1) {
11952 runtime.documents.delete(targetDocument);
11953 return;
11954 }
11955 runtime.documents.set(targetDocument, count - 1);
11956 };
11957 }
11958 function registerStyle15(hash, css) {
11959 const runtime = getRuntime15();
11960 runtime.styles.set(hash, css);
11961 for (const targetDocument of runtime.documents.keys()) {
11962 injectStyle15(targetDocument, hash, css);
11963 }
11964 }
11965 if (typeof process === "undefined" || true) {
11966 registerStyle15("65cec4cf71", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer compositions{._28cfdc260e755391__icon-button{--wp-ui-button-aspect-ratio:1;--wp-ui-button-padding-inline:0;--wp-ui-button-min-width:unset}.f1c70d719989a85a__icon{margin:-1px}}}");
11967 }
11968 var style_default14 = { "icon-button": "_28cfdc260e755391__icon-button", "icon": "f1c70d719989a85a__icon" };
11969 var IconButton = (0, import_element34.forwardRef)(
11970 function IconButton2({
11971 label,
11972 className,
11973 // Prevent accidental forwarding of `children`
11974 children: _children,
11975 disabled: disabled2,
11976 focusableWhenDisabled = true,
11977 icon,
11978 size: size4,
11979 shortcut,
11980 positioner,
11981 ...restProps
11982 }, ref) {
11983 const classes = clsx_default(style_default14["icon-button"], className);
11984 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Provider, { delay: 0, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Root4, { children: [
11985 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
11986 Trigger2,
11987 {
11988 ref,
11989 disabled: disabled2 && !focusableWhenDisabled,
11990 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
11991 Button4,
11992 {
11993 ...restProps,
11994 size: size4,
11995 "aria-label": label,
11996 "aria-keyshortcuts": shortcut?.ariaKeyShortcut,
11997 disabled: disabled2,
11998 focusableWhenDisabled
11999 }
12000 ),
12001 className: classes,
12002 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12003 Icon,
12004 {
12005 icon,
12006 size: 24,
12007 className: style_default14.icon
12008 }
12009 )
12010 }
12011 ),
12012 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Popup, { positioner, children: [
12013 label,
12014 shortcut && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
12015 " ",
12016 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { "aria-hidden": "true", children: shortcut.displayShortcut })
12017 ] })
12018 ] })
12019 ] }) });
12020 }
12021 );
12022
12023 // packages/ui/build-module/empty-state/index.mjs
12024 var empty_state_exports = {};
12025 __export(empty_state_exports, {
12026 Actions: () => Actions,
12027 Description: () => Description,
12028 Icon: () => Icon3,
12029 Root: () => Root5,
12030 Title: () => Title2,
12031 Visual: () => Visual
12032 });
12033
12034 // packages/ui/build-module/empty-state/root.mjs
12035 var import_element35 = __toESM(require_element(), 1);
12036 var STYLE_HASH_ATTRIBUTE16 = "data-wp-hash";
12037 function getRuntime16() {
12038 const globalScope = globalThis;
12039 if (globalScope.__wpStyleRuntime) {
12040 return globalScope.__wpStyleRuntime;
12041 }
12042 globalScope.__wpStyleRuntime = {
12043 documents: /* @__PURE__ */ new Map(),
12044 styles: /* @__PURE__ */ new Map(),
12045 injectedStyles: /* @__PURE__ */ new WeakMap()
12046 };
12047 if (typeof document !== "undefined") {
12048 registerDocument16(document);
12049 }
12050 return globalScope.__wpStyleRuntime;
12051 }
12052 function documentContainsStyleHash16(targetDocument, hash) {
12053 if (!targetDocument.head) {
12054 return false;
12055 }
12056 for (const style of targetDocument.head.querySelectorAll(
12057 `style[${STYLE_HASH_ATTRIBUTE16}]`
12058 )) {
12059 if (style.getAttribute(STYLE_HASH_ATTRIBUTE16) === hash) {
12060 return true;
12061 }
12062 }
12063 return false;
12064 }
12065 function injectStyle16(targetDocument, hash, css) {
12066 if (!targetDocument.head) {
12067 return;
12068 }
12069 const runtime = getRuntime16();
12070 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12071 if (!injectedStyles) {
12072 injectedStyles = /* @__PURE__ */ new Set();
12073 runtime.injectedStyles.set(targetDocument, injectedStyles);
12074 }
12075 if (injectedStyles.has(hash)) {
12076 return;
12077 }
12078 if (documentContainsStyleHash16(targetDocument, hash)) {
12079 injectedStyles.add(hash);
12080 return;
12081 }
12082 const style = targetDocument.createElement("style");
12083 style.setAttribute(STYLE_HASH_ATTRIBUTE16, hash);
12084 style.appendChild(targetDocument.createTextNode(css));
12085 targetDocument.head.appendChild(style);
12086 injectedStyles.add(hash);
12087 }
12088 function registerDocument16(targetDocument) {
12089 const runtime = getRuntime16();
12090 runtime.documents.set(
12091 targetDocument,
12092 (runtime.documents.get(targetDocument) ?? 0) + 1
12093 );
12094 for (const [hash, css] of runtime.styles) {
12095 injectStyle16(targetDocument, hash, css);
12096 }
12097 return () => {
12098 const count = runtime.documents.get(targetDocument);
12099 if (count === void 0) {
12100 return;
12101 }
12102 if (count <= 1) {
12103 runtime.documents.delete(targetDocument);
12104 return;
12105 }
12106 runtime.documents.set(targetDocument, count - 1);
12107 };
12108 }
12109 function registerStyle16(hash, css) {
12110 const runtime = getRuntime16();
12111 runtime.styles.set(hash, css);
12112 for (const targetDocument of runtime.documents.keys()) {
12113 injectStyle16(targetDocument, hash, css);
12114 }
12115 }
12116 if (typeof process === "undefined" || true) {
12117 registerStyle16("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12118 }
12119 var style_default15 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12120 var Root5 = (0, import_element35.forwardRef)(
12121 function EmptyStateRoot({ render: render4, ...props }, ref) {
12122 const className = clsx_default(style_default15.root);
12123 const element = useRender({
12124 defaultTagName: "div",
12125 render: render4,
12126 ref,
12127 props: mergeProps({ className }, props)
12128 });
12129 return element;
12130 }
12131 );
12132
12133 // packages/ui/build-module/empty-state/visual.mjs
12134 var import_element36 = __toESM(require_element(), 1);
12135 var STYLE_HASH_ATTRIBUTE17 = "data-wp-hash";
12136 function getRuntime17() {
12137 const globalScope = globalThis;
12138 if (globalScope.__wpStyleRuntime) {
12139 return globalScope.__wpStyleRuntime;
12140 }
12141 globalScope.__wpStyleRuntime = {
12142 documents: /* @__PURE__ */ new Map(),
12143 styles: /* @__PURE__ */ new Map(),
12144 injectedStyles: /* @__PURE__ */ new WeakMap()
12145 };
12146 if (typeof document !== "undefined") {
12147 registerDocument17(document);
12148 }
12149 return globalScope.__wpStyleRuntime;
12150 }
12151 function documentContainsStyleHash17(targetDocument, hash) {
12152 if (!targetDocument.head) {
12153 return false;
12154 }
12155 for (const style of targetDocument.head.querySelectorAll(
12156 `style[${STYLE_HASH_ATTRIBUTE17}]`
12157 )) {
12158 if (style.getAttribute(STYLE_HASH_ATTRIBUTE17) === hash) {
12159 return true;
12160 }
12161 }
12162 return false;
12163 }
12164 function injectStyle17(targetDocument, hash, css) {
12165 if (!targetDocument.head) {
12166 return;
12167 }
12168 const runtime = getRuntime17();
12169 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12170 if (!injectedStyles) {
12171 injectedStyles = /* @__PURE__ */ new Set();
12172 runtime.injectedStyles.set(targetDocument, injectedStyles);
12173 }
12174 if (injectedStyles.has(hash)) {
12175 return;
12176 }
12177 if (documentContainsStyleHash17(targetDocument, hash)) {
12178 injectedStyles.add(hash);
12179 return;
12180 }
12181 const style = targetDocument.createElement("style");
12182 style.setAttribute(STYLE_HASH_ATTRIBUTE17, hash);
12183 style.appendChild(targetDocument.createTextNode(css));
12184 targetDocument.head.appendChild(style);
12185 injectedStyles.add(hash);
12186 }
12187 function registerDocument17(targetDocument) {
12188 const runtime = getRuntime17();
12189 runtime.documents.set(
12190 targetDocument,
12191 (runtime.documents.get(targetDocument) ?? 0) + 1
12192 );
12193 for (const [hash, css] of runtime.styles) {
12194 injectStyle17(targetDocument, hash, css);
12195 }
12196 return () => {
12197 const count = runtime.documents.get(targetDocument);
12198 if (count === void 0) {
12199 return;
12200 }
12201 if (count <= 1) {
12202 runtime.documents.delete(targetDocument);
12203 return;
12204 }
12205 runtime.documents.set(targetDocument, count - 1);
12206 };
12207 }
12208 function registerStyle17(hash, css) {
12209 const runtime = getRuntime17();
12210 runtime.styles.set(hash, css);
12211 for (const targetDocument of runtime.documents.keys()) {
12212 injectStyle17(targetDocument, hash, css);
12213 }
12214 }
12215 if (typeof process === "undefined" || true) {
12216 registerStyle17("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12217 }
12218 var style_default16 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12219 var Visual = (0, import_element36.forwardRef)(
12220 function EmptyStateVisual({ render: render4, ...props }, ref) {
12221 const className = clsx_default(style_default16.visual);
12222 const element = useRender({
12223 defaultTagName: "div",
12224 render: render4,
12225 ref,
12226 props: mergeProps({ className }, props)
12227 });
12228 return element;
12229 }
12230 );
12231
12232 // packages/ui/build-module/empty-state/icon.mjs
12233 var import_element37 = __toESM(require_element(), 1);
12234 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
12235 var STYLE_HASH_ATTRIBUTE18 = "data-wp-hash";
12236 function getRuntime18() {
12237 const globalScope = globalThis;
12238 if (globalScope.__wpStyleRuntime) {
12239 return globalScope.__wpStyleRuntime;
12240 }
12241 globalScope.__wpStyleRuntime = {
12242 documents: /* @__PURE__ */ new Map(),
12243 styles: /* @__PURE__ */ new Map(),
12244 injectedStyles: /* @__PURE__ */ new WeakMap()
12245 };
12246 if (typeof document !== "undefined") {
12247 registerDocument18(document);
12248 }
12249 return globalScope.__wpStyleRuntime;
12250 }
12251 function documentContainsStyleHash18(targetDocument, hash) {
12252 if (!targetDocument.head) {
12253 return false;
12254 }
12255 for (const style of targetDocument.head.querySelectorAll(
12256 `style[${STYLE_HASH_ATTRIBUTE18}]`
12257 )) {
12258 if (style.getAttribute(STYLE_HASH_ATTRIBUTE18) === hash) {
12259 return true;
12260 }
12261 }
12262 return false;
12263 }
12264 function injectStyle18(targetDocument, hash, css) {
12265 if (!targetDocument.head) {
12266 return;
12267 }
12268 const runtime = getRuntime18();
12269 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12270 if (!injectedStyles) {
12271 injectedStyles = /* @__PURE__ */ new Set();
12272 runtime.injectedStyles.set(targetDocument, injectedStyles);
12273 }
12274 if (injectedStyles.has(hash)) {
12275 return;
12276 }
12277 if (documentContainsStyleHash18(targetDocument, hash)) {
12278 injectedStyles.add(hash);
12279 return;
12280 }
12281 const style = targetDocument.createElement("style");
12282 style.setAttribute(STYLE_HASH_ATTRIBUTE18, hash);
12283 style.appendChild(targetDocument.createTextNode(css));
12284 targetDocument.head.appendChild(style);
12285 injectedStyles.add(hash);
12286 }
12287 function registerDocument18(targetDocument) {
12288 const runtime = getRuntime18();
12289 runtime.documents.set(
12290 targetDocument,
12291 (runtime.documents.get(targetDocument) ?? 0) + 1
12292 );
12293 for (const [hash, css] of runtime.styles) {
12294 injectStyle18(targetDocument, hash, css);
12295 }
12296 return () => {
12297 const count = runtime.documents.get(targetDocument);
12298 if (count === void 0) {
12299 return;
12300 }
12301 if (count <= 1) {
12302 runtime.documents.delete(targetDocument);
12303 return;
12304 }
12305 runtime.documents.set(targetDocument, count - 1);
12306 };
12307 }
12308 function registerStyle18(hash, css) {
12309 const runtime = getRuntime18();
12310 runtime.styles.set(hash, css);
12311 for (const targetDocument of runtime.documents.keys()) {
12312 injectStyle18(targetDocument, hash, css);
12313 }
12314 }
12315 if (typeof process === "undefined" || true) {
12316 registerStyle18("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12317 }
12318 var style_default17 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12319 var Icon3 = (0, import_element37.forwardRef)(
12320 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
12321 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
12322 Visual,
12323 {
12324 ref,
12325 className: clsx_default(style_default17.icon, className),
12326 ...restProps,
12327 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Icon, { icon })
12328 }
12329 );
12330 }
12331 );
12332
12333 // packages/ui/build-module/empty-state/title.mjs
12334 var import_element38 = __toESM(require_element(), 1);
12335 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
12336 var STYLE_HASH_ATTRIBUTE19 = "data-wp-hash";
12337 function getRuntime19() {
12338 const globalScope = globalThis;
12339 if (globalScope.__wpStyleRuntime) {
12340 return globalScope.__wpStyleRuntime;
12341 }
12342 globalScope.__wpStyleRuntime = {
12343 documents: /* @__PURE__ */ new Map(),
12344 styles: /* @__PURE__ */ new Map(),
12345 injectedStyles: /* @__PURE__ */ new WeakMap()
12346 };
12347 if (typeof document !== "undefined") {
12348 registerDocument19(document);
12349 }
12350 return globalScope.__wpStyleRuntime;
12351 }
12352 function documentContainsStyleHash19(targetDocument, hash) {
12353 if (!targetDocument.head) {
12354 return false;
12355 }
12356 for (const style of targetDocument.head.querySelectorAll(
12357 `style[${STYLE_HASH_ATTRIBUTE19}]`
12358 )) {
12359 if (style.getAttribute(STYLE_HASH_ATTRIBUTE19) === hash) {
12360 return true;
12361 }
12362 }
12363 return false;
12364 }
12365 function injectStyle19(targetDocument, hash, css) {
12366 if (!targetDocument.head) {
12367 return;
12368 }
12369 const runtime = getRuntime19();
12370 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12371 if (!injectedStyles) {
12372 injectedStyles = /* @__PURE__ */ new Set();
12373 runtime.injectedStyles.set(targetDocument, injectedStyles);
12374 }
12375 if (injectedStyles.has(hash)) {
12376 return;
12377 }
12378 if (documentContainsStyleHash19(targetDocument, hash)) {
12379 injectedStyles.add(hash);
12380 return;
12381 }
12382 const style = targetDocument.createElement("style");
12383 style.setAttribute(STYLE_HASH_ATTRIBUTE19, hash);
12384 style.appendChild(targetDocument.createTextNode(css));
12385 targetDocument.head.appendChild(style);
12386 injectedStyles.add(hash);
12387 }
12388 function registerDocument19(targetDocument) {
12389 const runtime = getRuntime19();
12390 runtime.documents.set(
12391 targetDocument,
12392 (runtime.documents.get(targetDocument) ?? 0) + 1
12393 );
12394 for (const [hash, css] of runtime.styles) {
12395 injectStyle19(targetDocument, hash, css);
12396 }
12397 return () => {
12398 const count = runtime.documents.get(targetDocument);
12399 if (count === void 0) {
12400 return;
12401 }
12402 if (count <= 1) {
12403 runtime.documents.delete(targetDocument);
12404 return;
12405 }
12406 runtime.documents.set(targetDocument, count - 1);
12407 };
12408 }
12409 function registerStyle19(hash, css) {
12410 const runtime = getRuntime19();
12411 runtime.styles.set(hash, css);
12412 for (const targetDocument of runtime.documents.keys()) {
12413 injectStyle19(targetDocument, hash, css);
12414 }
12415 }
12416 if (typeof process === "undefined" || true) {
12417 registerStyle19("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12418 }
12419 var style_default18 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12420 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("h2", {});
12421 var Title2 = (0, import_element38.forwardRef)(
12422 function EmptyStateTitle({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
12423 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
12424 Text,
12425 {
12426 ref,
12427 variant: "heading-lg",
12428 render: render4,
12429 className: clsx_default(style_default18.title, className),
12430 ...props,
12431 children
12432 }
12433 );
12434 }
12435 );
12436
12437 // packages/ui/build-module/empty-state/description.mjs
12438 var import_element39 = __toESM(require_element(), 1);
12439 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
12440 var STYLE_HASH_ATTRIBUTE20 = "data-wp-hash";
12441 function getRuntime20() {
12442 const globalScope = globalThis;
12443 if (globalScope.__wpStyleRuntime) {
12444 return globalScope.__wpStyleRuntime;
12445 }
12446 globalScope.__wpStyleRuntime = {
12447 documents: /* @__PURE__ */ new Map(),
12448 styles: /* @__PURE__ */ new Map(),
12449 injectedStyles: /* @__PURE__ */ new WeakMap()
12450 };
12451 if (typeof document !== "undefined") {
12452 registerDocument20(document);
12453 }
12454 return globalScope.__wpStyleRuntime;
12455 }
12456 function documentContainsStyleHash20(targetDocument, hash) {
12457 if (!targetDocument.head) {
12458 return false;
12459 }
12460 for (const style of targetDocument.head.querySelectorAll(
12461 `style[${STYLE_HASH_ATTRIBUTE20}]`
12462 )) {
12463 if (style.getAttribute(STYLE_HASH_ATTRIBUTE20) === hash) {
12464 return true;
12465 }
12466 }
12467 return false;
12468 }
12469 function injectStyle20(targetDocument, hash, css) {
12470 if (!targetDocument.head) {
12471 return;
12472 }
12473 const runtime = getRuntime20();
12474 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12475 if (!injectedStyles) {
12476 injectedStyles = /* @__PURE__ */ new Set();
12477 runtime.injectedStyles.set(targetDocument, injectedStyles);
12478 }
12479 if (injectedStyles.has(hash)) {
12480 return;
12481 }
12482 if (documentContainsStyleHash20(targetDocument, hash)) {
12483 injectedStyles.add(hash);
12484 return;
12485 }
12486 const style = targetDocument.createElement("style");
12487 style.setAttribute(STYLE_HASH_ATTRIBUTE20, hash);
12488 style.appendChild(targetDocument.createTextNode(css));
12489 targetDocument.head.appendChild(style);
12490 injectedStyles.add(hash);
12491 }
12492 function registerDocument20(targetDocument) {
12493 const runtime = getRuntime20();
12494 runtime.documents.set(
12495 targetDocument,
12496 (runtime.documents.get(targetDocument) ?? 0) + 1
12497 );
12498 for (const [hash, css] of runtime.styles) {
12499 injectStyle20(targetDocument, hash, css);
12500 }
12501 return () => {
12502 const count = runtime.documents.get(targetDocument);
12503 if (count === void 0) {
12504 return;
12505 }
12506 if (count <= 1) {
12507 runtime.documents.delete(targetDocument);
12508 return;
12509 }
12510 runtime.documents.set(targetDocument, count - 1);
12511 };
12512 }
12513 function registerStyle20(hash, css) {
12514 const runtime = getRuntime20();
12515 runtime.styles.set(hash, css);
12516 for (const targetDocument of runtime.documents.keys()) {
12517 injectStyle20(targetDocument, hash, css);
12518 }
12519 }
12520 if (typeof process === "undefined" || true) {
12521 registerStyle20("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12522 }
12523 var style_default19 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12524 var DEFAULT_TAG3 = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", {});
12525 var Description = (0, import_element39.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG3, className, children, ...props }, ref) {
12526 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
12527 Text,
12528 {
12529 ref,
12530 variant: "body-md",
12531 render: render4,
12532 className: clsx_default(style_default19.description, className),
12533 ...props,
12534 children
12535 }
12536 );
12537 });
12538
12539 // packages/ui/build-module/empty-state/actions.mjs
12540 var import_element40 = __toESM(require_element(), 1);
12541 var STYLE_HASH_ATTRIBUTE21 = "data-wp-hash";
12542 function getRuntime21() {
12543 const globalScope = globalThis;
12544 if (globalScope.__wpStyleRuntime) {
12545 return globalScope.__wpStyleRuntime;
12546 }
12547 globalScope.__wpStyleRuntime = {
12548 documents: /* @__PURE__ */ new Map(),
12549 styles: /* @__PURE__ */ new Map(),
12550 injectedStyles: /* @__PURE__ */ new WeakMap()
12551 };
12552 if (typeof document !== "undefined") {
12553 registerDocument21(document);
12554 }
12555 return globalScope.__wpStyleRuntime;
12556 }
12557 function documentContainsStyleHash21(targetDocument, hash) {
12558 if (!targetDocument.head) {
12559 return false;
12560 }
12561 for (const style of targetDocument.head.querySelectorAll(
12562 `style[${STYLE_HASH_ATTRIBUTE21}]`
12563 )) {
12564 if (style.getAttribute(STYLE_HASH_ATTRIBUTE21) === hash) {
12565 return true;
12566 }
12567 }
12568 return false;
12569 }
12570 function injectStyle21(targetDocument, hash, css) {
12571 if (!targetDocument.head) {
12572 return;
12573 }
12574 const runtime = getRuntime21();
12575 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12576 if (!injectedStyles) {
12577 injectedStyles = /* @__PURE__ */ new Set();
12578 runtime.injectedStyles.set(targetDocument, injectedStyles);
12579 }
12580 if (injectedStyles.has(hash)) {
12581 return;
12582 }
12583 if (documentContainsStyleHash21(targetDocument, hash)) {
12584 injectedStyles.add(hash);
12585 return;
12586 }
12587 const style = targetDocument.createElement("style");
12588 style.setAttribute(STYLE_HASH_ATTRIBUTE21, hash);
12589 style.appendChild(targetDocument.createTextNode(css));
12590 targetDocument.head.appendChild(style);
12591 injectedStyles.add(hash);
12592 }
12593 function registerDocument21(targetDocument) {
12594 const runtime = getRuntime21();
12595 runtime.documents.set(
12596 targetDocument,
12597 (runtime.documents.get(targetDocument) ?? 0) + 1
12598 );
12599 for (const [hash, css] of runtime.styles) {
12600 injectStyle21(targetDocument, hash, css);
12601 }
12602 return () => {
12603 const count = runtime.documents.get(targetDocument);
12604 if (count === void 0) {
12605 return;
12606 }
12607 if (count <= 1) {
12608 runtime.documents.delete(targetDocument);
12609 return;
12610 }
12611 runtime.documents.set(targetDocument, count - 1);
12612 };
12613 }
12614 function registerStyle21(hash, css) {
12615 const runtime = getRuntime21();
12616 runtime.styles.set(hash, css);
12617 for (const targetDocument of runtime.documents.keys()) {
12618 injectStyle21(targetDocument, hash, css);
12619 }
12620 }
12621 if (typeof process === "undefined" || true) {
12622 registerStyle21("7b60a246cc", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-foreground-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}}');
12623 }
12624 var style_default20 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12625 var Actions = (0, import_element40.forwardRef)(
12626 function EmptyStateActions({ render: render4, ...props }, ref) {
12627 const className = clsx_default(style_default20.actions);
12628 const element = useRender({
12629 defaultTagName: "div",
12630 render: render4,
12631 ref,
12632 props: mergeProps({ className }, props)
12633 });
12634 return element;
12635 }
12636 );
12637
12638 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
12639 var import_element41 = __toESM(require_element(), 1);
12640 var STYLE_HASH_ATTRIBUTE22 = "data-wp-hash";
12641 function getRuntime22() {
12642 const globalScope = globalThis;
12643 if (globalScope.__wpStyleRuntime) {
12644 return globalScope.__wpStyleRuntime;
12645 }
12646 globalScope.__wpStyleRuntime = {
12647 documents: /* @__PURE__ */ new Map(),
12648 styles: /* @__PURE__ */ new Map(),
12649 injectedStyles: /* @__PURE__ */ new WeakMap()
12650 };
12651 if (typeof document !== "undefined") {
12652 registerDocument22(document);
12653 }
12654 return globalScope.__wpStyleRuntime;
12655 }
12656 function documentContainsStyleHash22(targetDocument, hash) {
12657 if (!targetDocument.head) {
12658 return false;
12659 }
12660 for (const style of targetDocument.head.querySelectorAll(
12661 `style[${STYLE_HASH_ATTRIBUTE22}]`
12662 )) {
12663 if (style.getAttribute(STYLE_HASH_ATTRIBUTE22) === hash) {
12664 return true;
12665 }
12666 }
12667 return false;
12668 }
12669 function injectStyle22(targetDocument, hash, css) {
12670 if (!targetDocument.head) {
12671 return;
12672 }
12673 const runtime = getRuntime22();
12674 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12675 if (!injectedStyles) {
12676 injectedStyles = /* @__PURE__ */ new Set();
12677 runtime.injectedStyles.set(targetDocument, injectedStyles);
12678 }
12679 if (injectedStyles.has(hash)) {
12680 return;
12681 }
12682 if (documentContainsStyleHash22(targetDocument, hash)) {
12683 injectedStyles.add(hash);
12684 return;
12685 }
12686 const style = targetDocument.createElement("style");
12687 style.setAttribute(STYLE_HASH_ATTRIBUTE22, hash);
12688 style.appendChild(targetDocument.createTextNode(css));
12689 targetDocument.head.appendChild(style);
12690 injectedStyles.add(hash);
12691 }
12692 function registerDocument22(targetDocument) {
12693 const runtime = getRuntime22();
12694 runtime.documents.set(
12695 targetDocument,
12696 (runtime.documents.get(targetDocument) ?? 0) + 1
12697 );
12698 for (const [hash, css] of runtime.styles) {
12699 injectStyle22(targetDocument, hash, css);
12700 }
12701 return () => {
12702 const count = runtime.documents.get(targetDocument);
12703 if (count === void 0) {
12704 return;
12705 }
12706 if (count <= 1) {
12707 runtime.documents.delete(targetDocument);
12708 return;
12709 }
12710 runtime.documents.set(targetDocument, count - 1);
12711 };
12712 }
12713 function registerStyle22(hash, css) {
12714 const runtime = getRuntime22();
12715 runtime.styles.set(hash, css);
12716 for (const targetDocument of runtime.documents.keys()) {
12717 injectStyle22(targetDocument, hash, css);
12718 }
12719 }
12720 if (typeof process === "undefined" || true) {
12721 registerStyle22("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}}}");
12722 }
12723 var style_default21 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
12724 var VisuallyHidden = (0, import_element41.forwardRef)(
12725 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
12726 const element = useRender({
12727 render: render4,
12728 ref,
12729 props: mergeProps(
12730 { className: style_default21["visually-hidden"] },
12731 restProps,
12732 {
12733 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
12734 "data-visually-hidden": ""
12735 }
12736 )
12737 });
12738 return element;
12739 }
12740 );
12741
12742 // packages/ui/build-module/link/link.mjs
12743 var import_element42 = __toESM(require_element(), 1);
12744 var import_i18n2 = __toESM(require_i18n(), 1);
12745 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
12746 var STYLE_HASH_ATTRIBUTE23 = "data-wp-hash";
12747 function getRuntime23() {
12748 const globalScope = globalThis;
12749 if (globalScope.__wpStyleRuntime) {
12750 return globalScope.__wpStyleRuntime;
12751 }
12752 globalScope.__wpStyleRuntime = {
12753 documents: /* @__PURE__ */ new Map(),
12754 styles: /* @__PURE__ */ new Map(),
12755 injectedStyles: /* @__PURE__ */ new WeakMap()
12756 };
12757 if (typeof document !== "undefined") {
12758 registerDocument23(document);
12759 }
12760 return globalScope.__wpStyleRuntime;
12761 }
12762 function documentContainsStyleHash23(targetDocument, hash) {
12763 if (!targetDocument.head) {
12764 return false;
12765 }
12766 for (const style of targetDocument.head.querySelectorAll(
12767 `style[${STYLE_HASH_ATTRIBUTE23}]`
12768 )) {
12769 if (style.getAttribute(STYLE_HASH_ATTRIBUTE23) === hash) {
12770 return true;
12771 }
12772 }
12773 return false;
12774 }
12775 function injectStyle23(targetDocument, hash, css) {
12776 if (!targetDocument.head) {
12777 return;
12778 }
12779 const runtime = getRuntime23();
12780 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12781 if (!injectedStyles) {
12782 injectedStyles = /* @__PURE__ */ new Set();
12783 runtime.injectedStyles.set(targetDocument, injectedStyles);
12784 }
12785 if (injectedStyles.has(hash)) {
12786 return;
12787 }
12788 if (documentContainsStyleHash23(targetDocument, hash)) {
12789 injectedStyles.add(hash);
12790 return;
12791 }
12792 const style = targetDocument.createElement("style");
12793 style.setAttribute(STYLE_HASH_ATTRIBUTE23, hash);
12794 style.appendChild(targetDocument.createTextNode(css));
12795 targetDocument.head.appendChild(style);
12796 injectedStyles.add(hash);
12797 }
12798 function registerDocument23(targetDocument) {
12799 const runtime = getRuntime23();
12800 runtime.documents.set(
12801 targetDocument,
12802 (runtime.documents.get(targetDocument) ?? 0) + 1
12803 );
12804 for (const [hash, css] of runtime.styles) {
12805 injectStyle23(targetDocument, hash, css);
12806 }
12807 return () => {
12808 const count = runtime.documents.get(targetDocument);
12809 if (count === void 0) {
12810 return;
12811 }
12812 if (count <= 1) {
12813 runtime.documents.delete(targetDocument);
12814 return;
12815 }
12816 runtime.documents.set(targetDocument, count - 1);
12817 };
12818 }
12819 function registerStyle23(hash, css) {
12820 const runtime = getRuntime23();
12821 runtime.styles.set(hash, css);
12822 for (const targetDocument of runtime.documents.keys()) {
12823 injectStyle23(targetDocument, hash, css);
12824 }
12825 }
12826 if (typeof process === "undefined" || true) {
12827 registerStyle23("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
12828 }
12829 var resets_default4 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
12830 if (typeof process === "undefined" || true) {
12831 registerStyle23("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))}}}");
12832 }
12833 var focus_default3 = { "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" };
12834 if (typeof process === "undefined" || true) {
12835 registerStyle23("7e0119b657", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-regular,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}}');
12836 }
12837 var style_default22 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
12838 if (typeof process === "undefined" || true) {
12839 registerStyle23("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
12840 }
12841 var global_css_defense_default4 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
12842 var Link = (0, import_element42.forwardRef)(function Link2({
12843 children,
12844 variant = "default",
12845 tone = "brand",
12846 openInNewTab = false,
12847 render: render4,
12848 className,
12849 ...props
12850 }, ref) {
12851 const element = useRender({
12852 render: render4,
12853 defaultTagName: "a",
12854 ref,
12855 props: mergeProps(props, {
12856 className: clsx_default(
12857 global_css_defense_default4.a,
12858 resets_default4["box-sizing"],
12859 focus_default3["outset-ring--focus"],
12860 variant !== "unstyled" && style_default22.link,
12861 variant !== "unstyled" && style_default22[`is-${tone}`],
12862 variant === "unstyled" && style_default22["is-unstyled"],
12863 className
12864 ),
12865 target: openInNewTab ? "_blank" : void 0,
12866 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
12867 children,
12868 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
12869 "span",
12870 {
12871 className: style_default22["link-icon"],
12872 role: "img",
12873 "aria-label": (
12874 /* translators: accessibility text appended to link text */
12875 (0, import_i18n2.__)("(opens in a new tab)")
12876 )
12877 }
12878 )
12879 ] })
12880 })
12881 });
12882 return element;
12883 });
12884
12885 // packages/dataviews/build-module/components/dataviews-context/index.mjs
12886 var import_element43 = __toESM(require_element(), 1);
12887
12888 // packages/dataviews/build-module/constants.mjs
12889 var import_i18n3 = __toESM(require_i18n(), 1);
12890 var OPERATOR_IS_ANY = "isAny";
12891 var OPERATOR_IS_NONE = "isNone";
12892 var OPERATOR_IS_ALL = "isAll";
12893 var OPERATOR_IS_NOT_ALL = "isNotAll";
12894 var OPERATOR_BETWEEN = "between";
12895 var OPERATOR_IN_THE_PAST = "inThePast";
12896 var OPERATOR_OVER = "over";
12897 var OPERATOR_IS = "is";
12898 var OPERATOR_IS_NOT = "isNot";
12899 var OPERATOR_LESS_THAN = "lessThan";
12900 var OPERATOR_GREATER_THAN = "greaterThan";
12901 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
12902 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
12903 var OPERATOR_BEFORE = "before";
12904 var OPERATOR_AFTER = "after";
12905 var OPERATOR_BEFORE_INC = "beforeInc";
12906 var OPERATOR_AFTER_INC = "afterInc";
12907 var OPERATOR_CONTAINS = "contains";
12908 var OPERATOR_NOT_CONTAINS = "notContains";
12909 var OPERATOR_STARTS_WITH = "startsWith";
12910 var OPERATOR_ON = "on";
12911 var OPERATOR_NOT_ON = "notOn";
12912 var SORTING_DIRECTIONS = ["asc", "desc"];
12913 var sortArrows = { asc: "\u2191", desc: "\u2193" };
12914 var sortValues = { asc: "ascending", desc: "descending" };
12915 var sortLabels = {
12916 asc: (0, import_i18n3.__)("Sort ascending"),
12917 desc: (0, import_i18n3.__)("Sort descending")
12918 };
12919 var sortIcons = {
12920 asc: arrow_up_default,
12921 desc: arrow_down_default
12922 };
12923 var LAYOUT_TABLE = "table";
12924 var LAYOUT_GRID = "grid";
12925 var LAYOUT_LIST = "list";
12926 var LAYOUT_ACTIVITY = "activity";
12927 var LAYOUT_PICKER_GRID = "pickerGrid";
12928 var LAYOUT_PICKER_TABLE = "pickerTable";
12929 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
12930
12931 // packages/dataviews/build-module/components/dataviews-context/index.mjs
12932 var DataViewsContext = (0, import_element43.createContext)({
12933 view: { type: LAYOUT_TABLE },
12934 onChangeView: () => {
12935 },
12936 fields: [],
12937 data: [],
12938 paginationInfo: {
12939 totalItems: 0,
12940 totalPages: 0
12941 },
12942 selection: [],
12943 onChangeSelection: () => {
12944 },
12945 setOpenedFilter: () => {
12946 },
12947 openedFilter: null,
12948 getItemId: (item) => item.id,
12949 isItemClickable: () => true,
12950 renderItemLink: void 0,
12951 containerWidth: 0,
12952 containerRef: (0, import_element43.createRef)(),
12953 resizeObserverRef: () => {
12954 },
12955 defaultLayouts: { list: {}, grid: {}, table: {} },
12956 filters: [],
12957 isShowingFilter: false,
12958 setIsShowingFilter: () => {
12959 },
12960 hasInitiallyLoaded: false,
12961 config: {
12962 perPageSizes: []
12963 },
12964 intersectionObserver: null
12965 });
12966 DataViewsContext.displayName = "DataViewsContext";
12967 var dataviews_context_default = DataViewsContext;
12968
12969 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
12970 var import_i18n24 = __toESM(require_i18n(), 1);
12971
12972 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
12973 var import_i18n11 = __toESM(require_i18n(), 1);
12974 var import_components6 = __toESM(require_components(), 1);
12975 var import_element51 = __toESM(require_element(), 1);
12976 var import_keycodes = __toESM(require_keycodes(), 1);
12977
12978 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
12979 var import_components = __toESM(require_components(), 1);
12980 var import_i18n4 = __toESM(require_i18n(), 1);
12981 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
12982 function DataViewsSelectionCheckbox({
12983 selection,
12984 onChangeSelection,
12985 item,
12986 getItemId,
12987 titleField,
12988 disabled: disabled2,
12989 ...extraProps
12990 }) {
12991 const id = getItemId(item);
12992 const isInSelectionArray = selection.includes(id);
12993 const checked = !disabled2 && isInSelectionArray;
12994 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n4.__)("(no title)");
12995 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
12996 import_components.CheckboxControl,
12997 {
12998 className: "dataviews-selection-checkbox",
12999 "aria-label": selectionLabel,
13000 "aria-disabled": disabled2,
13001 checked,
13002 onChange: () => {
13003 if (disabled2) {
13004 return;
13005 }
13006 onChangeSelection(
13007 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
13008 );
13009 },
13010 ...extraProps
13011 }
13012 );
13013 }
13014
13015 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
13016 var import_components2 = __toESM(require_components(), 1);
13017 var import_i18n5 = __toESM(require_i18n(), 1);
13018 var import_element44 = __toESM(require_element(), 1);
13019 var import_data = __toESM(require_data(), 1);
13020 var import_compose = __toESM(require_compose(), 1);
13021
13022 // packages/dataviews/build-module/lock-unlock.mjs
13023 var import_private_apis2 = __toESM(require_private_apis(), 1);
13024 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
13025 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
13026 "@wordpress/dataviews"
13027 );
13028
13029 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
13030 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13031 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
13032 function ButtonTrigger({
13033 action,
13034 onClick,
13035 items,
13036 variant
13037 }) {
13038 const label = typeof action.label === "string" ? action.label : action.label(items);
13039 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13040 import_components2.Button,
13041 {
13042 disabled: !!action.disabled,
13043 accessibleWhenDisabled: true,
13044 size: "compact",
13045 variant,
13046 onClick,
13047 children: label
13048 }
13049 );
13050 }
13051 function MenuItemTrigger({
13052 action,
13053 onClick,
13054 items
13055 }) {
13056 const label = typeof action.label === "string" ? action.label : action.label(items);
13057 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Menu.ItemLabel, { children: label }) });
13058 }
13059 function ActionModal({
13060 action,
13061 items,
13062 closeModal
13063 }) {
13064 const label = typeof action.label === "string" ? action.label : action.label(items);
13065 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
13066 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13067 import_components2.Modal,
13068 {
13069 title: modalHeader || label,
13070 __experimentalHideHeader: !!action.hideModalHeader,
13071 onRequestClose: closeModal,
13072 focusOnMount: action.modalFocusOnMount ?? true,
13073 size: action.modalSize || "medium",
13074 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
13075 action.id
13076 )}`,
13077 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(action.RenderModal, { items, closeModal })
13078 }
13079 );
13080 }
13081 function ActionsMenuGroup({
13082 actions,
13083 item,
13084 registry,
13085 setActiveModalAction
13086 }) {
13087 const { primaryActions, regularActions } = (0, import_element44.useMemo)(() => {
13088 return actions.reduce(
13089 (acc, action) => {
13090 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
13091 return acc;
13092 },
13093 {
13094 primaryActions: [],
13095 regularActions: []
13096 }
13097 );
13098 }, [actions]);
13099 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13100 MenuItemTrigger,
13101 {
13102 action,
13103 onClick: () => {
13104 if ("RenderModal" in action) {
13105 setActiveModalAction(action);
13106 return;
13107 }
13108 action.callback([item], { registry });
13109 },
13110 items: [item]
13111 },
13112 action.id
13113 ));
13114 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Menu.Group, { children: [
13115 renderActionGroup(primaryActions),
13116 renderActionGroup(regularActions)
13117 ] });
13118 }
13119 function ItemActions({
13120 item,
13121 actions,
13122 isCompact
13123 }) {
13124 const registry = (0, import_data.useRegistry)();
13125 const { primaryActions, eligibleActions } = (0, import_element44.useMemo)(() => {
13126 const _eligibleActions = actions.filter(
13127 (action) => !action.isEligible || action.isEligible(item)
13128 );
13129 const _primaryActions = _eligibleActions.filter(
13130 (action) => action.isPrimary
13131 );
13132 return {
13133 primaryActions: _primaryActions,
13134 eligibleActions: _eligibleActions
13135 };
13136 }, [actions, item]);
13137 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
13138 if (isCompact) {
13139 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13140 CompactItemActions,
13141 {
13142 item,
13143 actions: eligibleActions,
13144 isSmall: true,
13145 registry
13146 }
13147 );
13148 }
13149 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
13150 Stack,
13151 {
13152 direction: "row",
13153 justify: "flex-end",
13154 className: "dataviews-item-actions",
13155 style: {
13156 flexShrink: 0,
13157 width: "auto"
13158 },
13159 children: [
13160 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13161 PrimaryActions,
13162 {
13163 item,
13164 actions: primaryActions,
13165 registry
13166 }
13167 ),
13168 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13169 // there if there are any actions at all.
13170 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13171 CompactItemActions,
13172 {
13173 item,
13174 actions: eligibleActions,
13175 registry
13176 }
13177 )
13178 ]
13179 }
13180 );
13181 }
13182 function CompactItemActions({
13183 item,
13184 actions,
13185 isSmall,
13186 registry
13187 }) {
13188 const [activeModalAction, setActiveModalAction] = (0, import_element44.useState)(
13189 null
13190 );
13191 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
13192 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Menu, { placement: "bottom-end", children: [
13193 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13194 Menu.TriggerButton,
13195 {
13196 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13197 import_components2.Button,
13198 {
13199 size: isSmall ? "small" : "compact",
13200 icon: more_vertical_default,
13201 label: (0, import_i18n5.__)("Actions"),
13202 accessibleWhenDisabled: true,
13203 disabled: !actions.length,
13204 className: "dataviews-all-actions-button"
13205 }
13206 )
13207 }
13208 ),
13209 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13210 ActionsMenuGroup,
13211 {
13212 actions,
13213 item,
13214 registry,
13215 setActiveModalAction
13216 }
13217 ) })
13218 ] }),
13219 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13220 ActionModal,
13221 {
13222 action: activeModalAction,
13223 items: [item],
13224 closeModal: () => setActiveModalAction(null)
13225 }
13226 )
13227 ] });
13228 }
13229 function PrimaryActions({
13230 item,
13231 actions,
13232 registry,
13233 buttonVariant
13234 }) {
13235 const [activeModalAction, setActiveModalAction] = (0, import_element44.useState)(null);
13236 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
13237 if (isMobileViewport) {
13238 return null;
13239 }
13240 if (!Array.isArray(actions) || actions.length === 0) {
13241 return null;
13242 }
13243 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
13244 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13245 ButtonTrigger,
13246 {
13247 action,
13248 onClick: () => {
13249 if ("RenderModal" in action) {
13250 setActiveModalAction(action);
13251 return;
13252 }
13253 action.callback([item], { registry });
13254 },
13255 items: [item],
13256 variant: buttonVariant
13257 },
13258 action.id
13259 )),
13260 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13261 ActionModal,
13262 {
13263 action: activeModalAction,
13264 items: [item],
13265 closeModal: () => setActiveModalAction(null)
13266 }
13267 )
13268 ] });
13269 }
13270
13271 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
13272 var import_components3 = __toESM(require_components(), 1);
13273 var import_i18n7 = __toESM(require_i18n(), 1);
13274 var import_element45 = __toESM(require_element(), 1);
13275 var import_data2 = __toESM(require_data(), 1);
13276 var import_compose2 = __toESM(require_compose(), 1);
13277
13278 // packages/dataviews/build-module/utils/get-footer-message.mjs
13279 var import_i18n6 = __toESM(require_i18n(), 1);
13280 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
13281 if (selectionCount > 0) {
13282 return (0, import_i18n6.sprintf)(
13283 /* translators: %d: number of items. */
13284 (0, import_i18n6._n)("%d Item selected", "%d Items selected", selectionCount),
13285 selectionCount
13286 );
13287 }
13288 if (onlyTotalCount || totalItems <= itemsCount) {
13289 return (0, import_i18n6.sprintf)(
13290 /* translators: %d: number of items. */
13291 (0, import_i18n6._n)("%d Item", "%d Items", totalItems),
13292 totalItems
13293 );
13294 }
13295 return (0, import_i18n6.sprintf)(
13296 /* translators: %1$d: number of items. %2$d: total number of items. */
13297 (0, import_i18n6._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
13298 itemsCount,
13299 totalItems
13300 );
13301 }
13302
13303 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
13304 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
13305 function ActionWithModal({
13306 action,
13307 items,
13308 ActionTriggerComponent
13309 }) {
13310 const [isModalOpen, setIsModalOpen] = (0, import_element45.useState)(false);
13311 const actionTriggerProps = {
13312 action,
13313 onClick: () => {
13314 setIsModalOpen(true);
13315 },
13316 items
13317 };
13318 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
13319 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
13320 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13321 ActionModal,
13322 {
13323 action,
13324 items,
13325 closeModal: () => setIsModalOpen(false)
13326 }
13327 )
13328 ] });
13329 }
13330 function useHasAPossibleBulkAction(actions, item) {
13331 return (0, import_element45.useMemo)(() => {
13332 return actions.some((action) => {
13333 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
13334 });
13335 }, [actions, item]);
13336 }
13337 function useSomeItemHasAPossibleBulkAction(actions, data) {
13338 return (0, import_element45.useMemo)(() => {
13339 return data.some((item) => {
13340 return actions.some((action) => {
13341 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
13342 });
13343 });
13344 }, [actions, data]);
13345 }
13346 function BulkSelectionCheckbox({
13347 selection,
13348 onChangeSelection,
13349 data,
13350 actions,
13351 getItemId,
13352 disableSelectAll = false
13353 }) {
13354 const selectableItems = (0, import_element45.useMemo)(() => {
13355 return data.filter((item) => {
13356 return actions.some(
13357 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
13358 );
13359 });
13360 }, [data, actions]);
13361 const selectedItems = data.filter(
13362 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
13363 );
13364 const hasSelection = selection.length > 0;
13365 const areAllSelected = selectedItems.length === selectableItems.length;
13366 if (disableSelectAll) {
13367 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13368 import_components3.CheckboxControl,
13369 {
13370 className: "dataviews-view-table-selection-checkbox",
13371 checked: hasSelection,
13372 disabled: !hasSelection,
13373 onChange: () => {
13374 onChangeSelection([]);
13375 },
13376 "aria-label": (0, import_i18n7.__)("Deselect all")
13377 }
13378 );
13379 }
13380 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13381 import_components3.CheckboxControl,
13382 {
13383 className: "dataviews-view-table-selection-checkbox",
13384 checked: areAllSelected,
13385 indeterminate: !areAllSelected && !!selectedItems.length,
13386 onChange: () => {
13387 if (areAllSelected) {
13388 onChangeSelection([]);
13389 } else {
13390 onChangeSelection(
13391 selectableItems.map((item) => getItemId(item))
13392 );
13393 }
13394 },
13395 "aria-label": areAllSelected ? (0, import_i18n7.__)("Deselect all") : (0, import_i18n7.__)("Select all")
13396 }
13397 );
13398 }
13399 function ActionTrigger({
13400 action,
13401 onClick,
13402 isBusy,
13403 items
13404 }) {
13405 const label = typeof action.label === "string" ? action.label : action.label(items);
13406 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
13407 if (isMobile) {
13408 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13409 import_components3.Button,
13410 {
13411 disabled: isBusy,
13412 accessibleWhenDisabled: true,
13413 label,
13414 icon: action.icon,
13415 size: "compact",
13416 onClick,
13417 isBusy
13418 }
13419 );
13420 }
13421 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13422 import_components3.Button,
13423 {
13424 disabled: isBusy,
13425 accessibleWhenDisabled: true,
13426 size: "compact",
13427 onClick,
13428 isBusy,
13429 children: label
13430 }
13431 );
13432 }
13433 var EMPTY_ARRAY2 = [];
13434 function ActionButton({
13435 action,
13436 selectedItems,
13437 actionInProgress,
13438 setActionInProgress
13439 }) {
13440 const registry = (0, import_data2.useRegistry)();
13441 const selectedEligibleItems = (0, import_element45.useMemo)(() => {
13442 return selectedItems.filter((item) => {
13443 return !action.isEligible || action.isEligible(item);
13444 });
13445 }, [action, selectedItems]);
13446 if ("RenderModal" in action) {
13447 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13448 ActionWithModal,
13449 {
13450 action,
13451 items: selectedEligibleItems,
13452 ActionTriggerComponent: ActionTrigger
13453 },
13454 action.id
13455 );
13456 }
13457 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13458 ActionTrigger,
13459 {
13460 action,
13461 onClick: async () => {
13462 setActionInProgress(action.id);
13463 await action.callback(selectedItems, {
13464 registry
13465 });
13466 setActionInProgress(null);
13467 },
13468 items: selectedEligibleItems,
13469 isBusy: actionInProgress === action.id
13470 },
13471 action.id
13472 );
13473 }
13474 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
13475 const message2 = getFooterMessage(
13476 selection.length,
13477 data.length,
13478 paginationInfo.totalItems,
13479 isInfiniteScroll
13480 );
13481 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
13482 Stack,
13483 {
13484 direction: "row",
13485 className: "dataviews-bulk-actions-footer__container",
13486 gap: "md",
13487 align: "center",
13488 children: [
13489 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13490 BulkSelectionCheckbox,
13491 {
13492 selection,
13493 onChangeSelection,
13494 data,
13495 actions,
13496 getItemId,
13497 disableSelectAll: isInfiniteScroll
13498 }
13499 ),
13500 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
13501 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
13502 Stack,
13503 {
13504 direction: "row",
13505 className: "dataviews-bulk-actions-footer__action-buttons",
13506 gap: "xs",
13507 children: [
13508 actionsToShow.map((action) => {
13509 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13510 ActionButton,
13511 {
13512 action,
13513 selectedItems,
13514 actionInProgress,
13515 setActionInProgress
13516 },
13517 action.id
13518 );
13519 }),
13520 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13521 import_components3.Button,
13522 {
13523 icon: close_small_default,
13524 showTooltip: true,
13525 tooltipPosition: "top",
13526 size: "compact",
13527 label: (0, import_i18n7.__)("Cancel"),
13528 disabled: !!actionInProgress,
13529 accessibleWhenDisabled: false,
13530 onClick: () => {
13531 onChangeSelection(EMPTY_ARRAY2);
13532 }
13533 }
13534 )
13535 ]
13536 }
13537 )
13538 ]
13539 }
13540 );
13541 }
13542 function FooterContent({
13543 selection,
13544 actions,
13545 onChangeSelection,
13546 data,
13547 getItemId,
13548 isInfiniteScroll,
13549 paginationInfo
13550 }) {
13551 const [actionInProgress, setActionInProgress] = (0, import_element45.useState)(
13552 null
13553 );
13554 const footerContentRef = (0, import_element45.useRef)(void 0);
13555 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
13556 const bulkActions = (0, import_element45.useMemo)(
13557 () => actions.filter((action) => action.supportsBulk),
13558 [actions]
13559 );
13560 const selectableItems = (0, import_element45.useMemo)(() => {
13561 return data.filter((item) => {
13562 return bulkActions.some(
13563 (action) => !action.isEligible || action.isEligible(item)
13564 );
13565 });
13566 }, [data, bulkActions]);
13567 const selectedItems = (0, import_element45.useMemo)(() => {
13568 return data.filter(
13569 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
13570 );
13571 }, [selection, data, getItemId, selectableItems]);
13572 const actionsToShow = (0, import_element45.useMemo)(
13573 () => actions.filter((action) => {
13574 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
13575 (item) => !action.isEligible || action.isEligible(item)
13576 );
13577 }),
13578 [actions, selectedItems, isMobile]
13579 );
13580 if (!actionInProgress) {
13581 if (footerContentRef.current) {
13582 footerContentRef.current = void 0;
13583 }
13584 return renderFooterContent(
13585 data,
13586 actions,
13587 getItemId,
13588 isInfiniteScroll,
13589 selection,
13590 actionsToShow,
13591 selectedItems,
13592 actionInProgress,
13593 setActionInProgress,
13594 onChangeSelection,
13595 paginationInfo
13596 );
13597 } else if (!footerContentRef.current) {
13598 footerContentRef.current = renderFooterContent(
13599 data,
13600 actions,
13601 getItemId,
13602 isInfiniteScroll,
13603 selection,
13604 actionsToShow,
13605 selectedItems,
13606 actionInProgress,
13607 setActionInProgress,
13608 onChangeSelection,
13609 paginationInfo
13610 );
13611 }
13612 return footerContentRef.current;
13613 }
13614 function BulkActionsFooter() {
13615 const {
13616 data,
13617 selection,
13618 actions = EMPTY_ARRAY2,
13619 onChangeSelection,
13620 getItemId,
13621 paginationInfo,
13622 view
13623 } = (0, import_element45.useContext)(dataviews_context_default);
13624 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13625 FooterContent,
13626 {
13627 selection,
13628 onChangeSelection,
13629 data,
13630 actions,
13631 getItemId,
13632 isInfiniteScroll: !!view.infiniteScrollEnabled,
13633 paginationInfo
13634 }
13635 );
13636 }
13637
13638 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
13639 var import_i18n8 = __toESM(require_i18n(), 1);
13640 var import_components4 = __toESM(require_components(), 1);
13641 var import_element46 = __toESM(require_element(), 1);
13642
13643 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
13644 function getHideableFields(view, fields) {
13645 const togglableFields = [
13646 view?.titleField,
13647 view?.mediaField,
13648 view?.descriptionField
13649 ].filter(Boolean);
13650 return fields.filter(
13651 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
13652 );
13653 }
13654
13655 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
13656 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
13657 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
13658 function WithMenuSeparators({ children }) {
13659 return import_element46.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_element46.Fragment, { children: [
13660 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Separator, {}),
13661 child
13662 ] }, i2));
13663 }
13664 var _HeaderMenu = (0, import_element46.forwardRef)(function HeaderMenu({
13665 fieldId,
13666 view,
13667 fields,
13668 onChangeView,
13669 onHide,
13670 setOpenedFilter,
13671 canMove = true,
13672 canInsertLeft = true,
13673 canInsertRight = true
13674 }, ref) {
13675 const visibleFieldIds = view.fields ?? [];
13676 const index2 = visibleFieldIds?.indexOf(fieldId);
13677 const isSorted = view.sort?.field === fieldId;
13678 let isHidable = false;
13679 let isSortable = false;
13680 let canAddFilter = false;
13681 let operators = [];
13682 const field = fields.find((f2) => f2.id === fieldId);
13683 const { setIsShowingFilter } = (0, import_element46.useContext)(dataviews_context_default);
13684 if (!field) {
13685 return null;
13686 }
13687 isHidable = field.enableHiding !== false;
13688 isSortable = field.enableSorting !== false;
13689 const header = field.header;
13690 operators = !!field.filterBy && field.filterBy?.operators || [];
13691 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
13692 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
13693 return header;
13694 }
13695 const hiddenFields = getHideableFields(view, fields).filter(
13696 (f2) => !visibleFieldIds.includes(f2.id)
13697 );
13698 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
13699 const isRtl = (0, import_i18n8.isRTL)();
13700 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2, { children: [
13701 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
13702 Menu2.TriggerButton,
13703 {
13704 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13705 import_components4.Button,
13706 {
13707 size: "compact",
13708 className: "dataviews-view-table-header-button",
13709 ref,
13710 variant: "tertiary"
13711 }
13712 ),
13713 children: [
13714 header,
13715 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
13716 ]
13717 }
13718 ),
13719 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(WithMenuSeparators, { children: [
13720 isSortable && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
13721 (direction) => {
13722 const isChecked = view.sort && isSorted && view.sort.direction === direction;
13723 const value = `${fieldId}-${direction}`;
13724 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13725 Menu2.RadioItem,
13726 {
13727 name: "view-table-sorting",
13728 value,
13729 checked: isChecked,
13730 onChange: () => {
13731 onChangeView({
13732 ...view,
13733 sort: {
13734 field: fieldId,
13735 direction
13736 },
13737 showLevels: false
13738 });
13739 },
13740 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
13741 },
13742 value
13743 );
13744 }
13745 ) }),
13746 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13747 Menu2.Item,
13748 {
13749 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: funnel_default }),
13750 onClick: () => {
13751 setOpenedFilter(fieldId);
13752 setIsShowingFilter(true);
13753 onChangeView({
13754 ...view,
13755 page: 1,
13756 filters: [
13757 ...view.filters || [],
13758 {
13759 field: fieldId,
13760 value: void 0,
13761 operator: operators[0]
13762 }
13763 ]
13764 });
13765 },
13766 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Add filter") })
13767 }
13768 ) }),
13769 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2.Group, { children: [
13770 canMove && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13771 Menu2.Item,
13772 {
13773 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: arrow_left_default }),
13774 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
13775 onClick: () => {
13776 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
13777 const newFields = [
13778 ...visibleFieldIds
13779 ];
13780 newFields.splice(index2, 1);
13781 newFields.splice(
13782 targetIndex,
13783 0,
13784 fieldId
13785 );
13786 onChangeView({
13787 ...view,
13788 fields: newFields
13789 });
13790 },
13791 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Move left") })
13792 }
13793 ),
13794 canMove && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13795 Menu2.Item,
13796 {
13797 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: arrow_right_default }),
13798 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
13799 onClick: () => {
13800 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
13801 const newFields = [
13802 ...visibleFieldIds
13803 ];
13804 newFields.splice(index2, 1);
13805 newFields.splice(
13806 targetIndex,
13807 0,
13808 fieldId
13809 );
13810 onChangeView({
13811 ...view,
13812 fields: newFields
13813 });
13814 },
13815 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Move right") })
13816 }
13817 ),
13818 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2, { children: [
13819 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Insert left") }) }),
13820 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
13821 const insertIndex = isRtl ? index2 + 1 : index2;
13822 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13823 Menu2.Item,
13824 {
13825 onClick: () => {
13826 onChangeView({
13827 ...view,
13828 fields: [
13829 ...visibleFieldIds.slice(
13830 0,
13831 insertIndex
13832 ),
13833 hiddenField.id,
13834 ...visibleFieldIds.slice(
13835 insertIndex
13836 )
13837 ]
13838 });
13839 },
13840 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
13841 },
13842 hiddenField.id
13843 );
13844 }) })
13845 ] }),
13846 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2, { children: [
13847 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Insert right") }) }),
13848 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
13849 const insertIndex = isRtl ? index2 : index2 + 1;
13850 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13851 Menu2.Item,
13852 {
13853 onClick: () => {
13854 onChangeView({
13855 ...view,
13856 fields: [
13857 ...visibleFieldIds.slice(
13858 0,
13859 insertIndex
13860 ),
13861 hiddenField.id,
13862 ...visibleFieldIds.slice(
13863 insertIndex
13864 )
13865 ]
13866 });
13867 },
13868 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
13869 },
13870 hiddenField.id
13871 );
13872 }) })
13873 ] }),
13874 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13875 Menu2.Item,
13876 {
13877 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: unseen_default }),
13878 onClick: () => {
13879 onHide(field);
13880 onChangeView({
13881 ...view,
13882 fields: visibleFieldIds.filter(
13883 (id) => id !== fieldId
13884 )
13885 });
13886 },
13887 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Hide column") })
13888 }
13889 )
13890 ] })
13891 ] }) })
13892 ] });
13893 });
13894 var ColumnHeaderMenu = _HeaderMenu;
13895 var column_header_menu_default = ColumnHeaderMenu;
13896
13897 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
13898 var import_element47 = __toESM(require_element(), 1);
13899 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
13900 function getClickableItemProps({
13901 item,
13902 isItemClickable,
13903 onClickItem,
13904 className
13905 }) {
13906 if (!isItemClickable(item) || !onClickItem) {
13907 return { className };
13908 }
13909 return {
13910 className: className ? `${className} ${className}--clickable` : void 0,
13911 role: "button",
13912 tabIndex: 0,
13913 onClick: (event) => {
13914 event.stopPropagation();
13915 onClickItem(item);
13916 },
13917 onKeyDown: (event) => {
13918 if (event.key === "Enter" || event.key === "" || event.key === " ") {
13919 event.stopPropagation();
13920 onClickItem(item);
13921 }
13922 }
13923 };
13924 }
13925 function ItemClickWrapper({
13926 item,
13927 isItemClickable,
13928 onClickItem,
13929 renderItemLink,
13930 className,
13931 children,
13932 ...extraProps
13933 }) {
13934 if (!isItemClickable(item)) {
13935 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className, ...extraProps, children });
13936 }
13937 if (renderItemLink) {
13938 const renderedElement = renderItemLink({
13939 item,
13940 className: `${className} ${className}--clickable`,
13941 ...extraProps,
13942 children
13943 });
13944 return (0, import_element47.cloneElement)(renderedElement, {
13945 onClick: (event) => {
13946 event.stopPropagation();
13947 if (renderedElement.props.onClick) {
13948 renderedElement.props.onClick(event);
13949 }
13950 },
13951 onKeyDown: (event) => {
13952 if (event.key === "Enter" || event.key === "" || event.key === " ") {
13953 event.stopPropagation();
13954 if (renderedElement.props.onKeyDown) {
13955 renderedElement.props.onKeyDown(event);
13956 }
13957 }
13958 }
13959 });
13960 }
13961 const clickProps = getClickableItemProps({
13962 item,
13963 isItemClickable,
13964 onClickItem,
13965 className
13966 });
13967 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { ...clickProps, ...extraProps, children });
13968 }
13969
13970 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
13971 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
13972 function ColumnPrimary({
13973 item,
13974 level,
13975 titleField,
13976 mediaField,
13977 descriptionField,
13978 onClickItem,
13979 renderItemLink,
13980 isItemClickable
13981 }) {
13982 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
13983 mediaField && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
13984 ItemClickWrapper,
13985 {
13986 item,
13987 isItemClickable,
13988 onClickItem,
13989 renderItemLink,
13990 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
13991 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
13992 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
13993 mediaField.render,
13994 {
13995 item,
13996 field: mediaField,
13997 config: { sizes: "32px" }
13998 }
13999 )
14000 }
14001 ),
14002 /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
14003 Stack,
14004 {
14005 direction: "column",
14006 align: "flex-start",
14007 className: "dataviews-view-table__primary-column-content",
14008 children: [
14009 titleField && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
14010 ItemClickWrapper,
14011 {
14012 item,
14013 isItemClickable,
14014 onClickItem,
14015 renderItemLink,
14016 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
14017 children: [
14018 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "dataviews-view-table__level", children: [
14019 Array(level).fill("\u2014").join(" "),
14020 "\xA0"
14021 ] }),
14022 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(titleField.render, { item, field: titleField })
14023 ]
14024 }
14025 ),
14026 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14027 descriptionField.render,
14028 {
14029 item,
14030 field: descriptionField
14031 }
14032 )
14033 ]
14034 }
14035 )
14036 ] });
14037 }
14038 var column_primary_default = ColumnPrimary;
14039
14040 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
14041 var import_element48 = __toESM(require_element(), 1);
14042 var import_i18n9 = __toESM(require_i18n(), 1);
14043 var isScrolledToEnd = (element) => {
14044 if ((0, import_i18n9.isRTL)()) {
14045 const scrollLeft = Math.abs(element.scrollLeft);
14046 return scrollLeft <= 1;
14047 }
14048 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
14049 };
14050 function useScrollState({
14051 scrollContainerRef,
14052 enabledHorizontal = false
14053 }) {
14054 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element48.useState)(false);
14055 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element48.useState)(false);
14056 const handleScroll = (0, import_element48.useCallback)(() => {
14057 const scrollContainer = scrollContainerRef.current;
14058 if (!scrollContainer) {
14059 return;
14060 }
14061 if (enabledHorizontal) {
14062 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
14063 }
14064 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
14065 }, [scrollContainerRef, enabledHorizontal]);
14066 (0, import_element48.useEffect)(() => {
14067 if (typeof window === "undefined" || !scrollContainerRef.current) {
14068 return () => {
14069 };
14070 }
14071 const scrollContainer = scrollContainerRef.current;
14072 handleScroll();
14073 scrollContainer.addEventListener("scroll", handleScroll);
14074 window.addEventListener("resize", handleScroll);
14075 return () => {
14076 scrollContainer.removeEventListener("scroll", handleScroll);
14077 window.removeEventListener("resize", handleScroll);
14078 };
14079 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
14080 return { isHorizontalScrollEnd, isVerticallyScrolled };
14081 }
14082
14083 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
14084 function getDataByGroup(data, groupByField) {
14085 return data.reduce((groups, item) => {
14086 const groupName = groupByField.getValue({ item });
14087 if (!groups.has(groupName)) {
14088 groups.set(groupName, []);
14089 }
14090 groups.get(groupName)?.push(item);
14091 return groups;
14092 }, /* @__PURE__ */ new Map());
14093 }
14094
14095 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
14096 var import_components5 = __toESM(require_components(), 1);
14097 var import_i18n10 = __toESM(require_i18n(), 1);
14098 var import_element49 = __toESM(require_element(), 1);
14099 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
14100 function FieldItem({
14101 field,
14102 isVisible: isVisible2,
14103 onToggleVisibility
14104 }) {
14105 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
14106 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components5.Icon, { icon: check_default }) }),
14107 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
14108 ] }) });
14109 }
14110 function isDefined(item) {
14111 return !!item;
14112 }
14113 function PropertiesSection({
14114 showLabel = true
14115 }) {
14116 const { view, fields, onChangeView } = (0, import_element49.useContext)(dataviews_context_default);
14117 const regularFields = getHideableFields(view, fields);
14118 if (!regularFields?.length) {
14119 return null;
14120 }
14121 const titleField = fields.find((f2) => f2.id === view.titleField);
14122 const previewField = fields.find((f2) => f2.id === view.mediaField);
14123 const descriptionField = fields.find(
14124 (f2) => f2.id === view.descriptionField
14125 );
14126 const lockedFields = [
14127 {
14128 field: titleField,
14129 isVisibleFlag: "showTitle"
14130 },
14131 {
14132 field: previewField,
14133 isVisibleFlag: "showMedia"
14134 },
14135 {
14136 field: descriptionField,
14137 isVisibleFlag: "showDescription"
14138 }
14139 ].filter(({ field }) => isDefined(field));
14140 const visibleFieldIds = view.fields ?? [];
14141 const visibleRegularFieldsCount = regularFields.filter(
14142 (f2) => visibleFieldIds.includes(f2.id)
14143 ).length;
14144 const visibleLockedFields = lockedFields.filter(
14145 ({ isVisibleFlag }) => (
14146 // @ts-expect-error
14147 view[isVisibleFlag] ?? true
14148 )
14149 );
14150 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
14151 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
14152 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
14153 showLabel && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n10.__)("Properties") }),
14154 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14155 Stack,
14156 {
14157 direction: "column",
14158 className: "dataviews-view-config__properties",
14159 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
14160 lockedFields.map(({ field, isVisibleFlag }) => {
14161 const isVisible2 = view[isVisibleFlag] ?? true;
14162 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
14163 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14164 FieldItem,
14165 {
14166 field: fieldToRender,
14167 isVisible: isVisible2,
14168 onToggleVisibility: () => {
14169 onChangeView({
14170 ...view,
14171 [isVisibleFlag]: !isVisible2
14172 });
14173 }
14174 },
14175 field.id
14176 );
14177 }),
14178 regularFields.map((field) => {
14179 const isVisible2 = visibleFieldIds.includes(field.id);
14180 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
14181 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14182 FieldItem,
14183 {
14184 field: fieldToRender,
14185 isVisible: isVisible2,
14186 onToggleVisibility: () => {
14187 onChangeView({
14188 ...view,
14189 fields: isVisible2 ? visibleFieldIds.filter(
14190 (fieldId) => fieldId !== field.id
14191 ) : [...visibleFieldIds, field.id]
14192 });
14193 }
14194 },
14195 field.id
14196 );
14197 })
14198 ] })
14199 }
14200 )
14201 ] });
14202 }
14203
14204 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
14205 var import_element50 = __toESM(require_element(), 1);
14206 function useDelayedLoading(isLoading, options = { delay: 400 }) {
14207 const [showLoader, setShowLoader] = (0, import_element50.useState)(false);
14208 (0, import_element50.useEffect)(() => {
14209 if (!isLoading) {
14210 return;
14211 }
14212 const timeout = setTimeout(() => {
14213 setShowLoader(true);
14214 }, options.delay);
14215 return () => {
14216 clearTimeout(timeout);
14217 setShowLoader(false);
14218 };
14219 }, [isLoading, options.delay]);
14220 return showLoader;
14221 }
14222
14223 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
14224 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
14225 function getEffectiveAlign(explicitAlign, fieldType) {
14226 if (explicitAlign) {
14227 return explicitAlign;
14228 }
14229 if (fieldType === "integer" || fieldType === "number") {
14230 return "end";
14231 }
14232 return void 0;
14233 }
14234 function TableColumnField({
14235 item,
14236 fields,
14237 column,
14238 align
14239 }) {
14240 const field = fields.find((f2) => f2.id === column);
14241 if (!field) {
14242 return null;
14243 }
14244 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14245 "dataviews-view-table__cell-align-end": align === "end",
14246 "dataviews-view-table__cell-align-center": align === "center"
14247 });
14248 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(field.render, { item, field }) });
14249 }
14250 function TableRow({
14251 hasBulkActions,
14252 item,
14253 level,
14254 actions,
14255 fields,
14256 id,
14257 view,
14258 titleField,
14259 mediaField,
14260 descriptionField,
14261 selection,
14262 getItemId,
14263 isItemClickable,
14264 onClickItem,
14265 renderItemLink,
14266 onChangeSelection,
14267 isActionsColumnSticky,
14268 posinset
14269 }) {
14270 const { paginationInfo } = (0, import_element51.useContext)(dataviews_context_default);
14271 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
14272 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
14273 const {
14274 showTitle = true,
14275 showMedia = true,
14276 showDescription = true,
14277 infiniteScrollEnabled
14278 } = view;
14279 const isTouchDeviceRef = (0, import_element51.useRef)(false);
14280 const columns = view.fields ?? [];
14281 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14282 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14283 "tr",
14284 {
14285 className: clsx_default("dataviews-view-table__row", {
14286 "is-selected": hasPossibleBulkAction && isSelected2,
14287 "has-bulk-actions": hasPossibleBulkAction
14288 }),
14289 onTouchStart: () => {
14290 isTouchDeviceRef.current = true;
14291 },
14292 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
14293 "aria-posinset": posinset,
14294 role: infiniteScrollEnabled ? "article" : void 0,
14295 onMouseDown: (event) => {
14296 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
14297 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
14298 event?.preventDefault();
14299 }
14300 },
14301 onClick: (event) => {
14302 if (!hasPossibleBulkAction) {
14303 return;
14304 }
14305 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
14306 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
14307 onChangeSelection(
14308 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
14309 );
14310 }
14311 },
14312 children: [
14313 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14314 DataViewsSelectionCheckbox,
14315 {
14316 item,
14317 selection,
14318 onChangeSelection,
14319 getItemId,
14320 titleField,
14321 disabled: !hasPossibleBulkAction
14322 }
14323 ) }) }),
14324 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14325 column_primary_default,
14326 {
14327 item,
14328 level,
14329 titleField: showTitle ? titleField : void 0,
14330 mediaField: showMedia ? mediaField : void 0,
14331 descriptionField: showDescription ? descriptionField : void 0,
14332 isItemClickable,
14333 onClickItem,
14334 renderItemLink
14335 }
14336 ) }),
14337 columns.map((column) => {
14338 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14339 const field = fields.find((f2) => f2.id === column);
14340 const effectiveAlign = getEffectiveAlign(align, field?.type);
14341 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14342 "td",
14343 {
14344 style: {
14345 width,
14346 maxWidth,
14347 minWidth
14348 },
14349 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14350 TableColumnField,
14351 {
14352 fields,
14353 item,
14354 column,
14355 align: effectiveAlign
14356 }
14357 )
14358 },
14359 column
14360 );
14361 }),
14362 !!actions?.length && // Disable reason: we are not making the element interactive,
14363 // but preventing any click events from bubbling up to the
14364 // table row. This allows us to add a click handler to the row
14365 // itself (to toggle row selection) without erroneously
14366 // intercepting click events from ItemActions.
14367 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14368 "td",
14369 {
14370 className: clsx_default("dataviews-view-table__actions-column", {
14371 "dataviews-view-table__actions-column--sticky": true,
14372 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
14373 }),
14374 onClick: (e2) => e2.stopPropagation(),
14375 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ItemActions, { item, actions })
14376 }
14377 )
14378 ]
14379 }
14380 );
14381 }
14382 function ViewTable({
14383 actions,
14384 data,
14385 fields,
14386 getItemId,
14387 getItemLevel,
14388 isLoading = false,
14389 onChangeView,
14390 onChangeSelection,
14391 selection,
14392 setOpenedFilter,
14393 onClickItem,
14394 isItemClickable,
14395 renderItemLink,
14396 view,
14397 className,
14398 empty
14399 }) {
14400 const { containerRef } = (0, import_element51.useContext)(dataviews_context_default);
14401 const isDelayedLoading = useDelayedLoading(isLoading);
14402 const headerMenuRefs = (0, import_element51.useRef)(/* @__PURE__ */ new Map());
14403 const headerMenuToFocusRef = (0, import_element51.useRef)(void 0);
14404 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element51.useState)();
14405 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element51.useState)(null);
14406 (0, import_element51.useEffect)(() => {
14407 if (headerMenuToFocusRef.current) {
14408 headerMenuToFocusRef.current.focus();
14409 headerMenuToFocusRef.current = void 0;
14410 }
14411 });
14412 const tableNoticeId = (0, import_element51.useId)();
14413 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
14414 scrollContainerRef: containerRef,
14415 enabledHorizontal: !!actions?.length
14416 });
14417 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
14418 if (nextHeaderMenuToFocus) {
14419 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14420 setNextHeaderMenuToFocus(void 0);
14421 return;
14422 }
14423 const onHide = (field) => {
14424 const hidden = headerMenuRefs.current.get(field.id);
14425 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14426 setNextHeaderMenuToFocus(fallback?.node);
14427 };
14428 const handleHeaderContextMenu = (event) => {
14429 event.preventDefault();
14430 event.stopPropagation();
14431 const virtualAnchor = {
14432 getBoundingClientRect: () => ({
14433 x: event.clientX,
14434 y: event.clientY,
14435 top: event.clientY,
14436 left: event.clientX,
14437 right: event.clientX,
14438 bottom: event.clientY,
14439 width: 0,
14440 height: 0,
14441 toJSON: () => ({})
14442 })
14443 };
14444 window.requestAnimationFrame(() => {
14445 setContextMenuAnchor(virtualAnchor);
14446 });
14447 };
14448 const hasData = !!data?.length;
14449 const titleField = fields.find((field) => field.id === view.titleField);
14450 const mediaField = fields.find((field) => field.id === view.mediaField);
14451 const descriptionField = fields.find(
14452 (field) => field.id === view.descriptionField
14453 );
14454 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14455 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14456 const { showTitle = true, showMedia = true, showDescription = true } = view;
14457 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14458 const columns = view.fields ?? [];
14459 const headerMenuRef = (column, index2) => (node) => {
14460 if (node) {
14461 headerMenuRefs.current.set(column, {
14462 node,
14463 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14464 });
14465 } else {
14466 headerMenuRefs.current.delete(column);
14467 }
14468 };
14469 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14470 const isRtl = (0, import_i18n11.isRTL)();
14471 if (!hasData) {
14472 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14473 "div",
14474 {
14475 className: clsx_default("dataviews-no-results", {
14476 "is-refreshing": isDelayedLoading
14477 }),
14478 id: tableNoticeId,
14479 children: empty
14480 }
14481 );
14482 }
14483 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
14484 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14485 "table",
14486 {
14487 className: clsx_default("dataviews-view-table", className, {
14488 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14489 view.layout.density
14490 ),
14491 "has-bulk-actions": hasBulkActions,
14492 "is-refreshing": !isInfiniteScroll && isDelayedLoading
14493 }),
14494 "aria-busy": isLoading,
14495 "aria-describedby": tableNoticeId,
14496 role: isInfiniteScroll ? "feed" : void 0,
14497 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
14498 children: [
14499 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("colgroup", { children: [
14500 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
14501 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
14502 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14503 "col",
14504 {
14505 className: clsx_default(
14506 `dataviews-view-table__col-${column}`,
14507 {
14508 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
14509 }
14510 )
14511 },
14512 `col-${column}`
14513 )),
14514 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("col", { className: "dataviews-view-table__col-actions" })
14515 ] }),
14516 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14517 import_components6.Popover,
14518 {
14519 anchor: contextMenuAnchor,
14520 onClose: () => setContextMenuAnchor(null),
14521 placement: "bottom-start",
14522 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(PropertiesSection, { showLabel: false })
14523 }
14524 ),
14525 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14526 "thead",
14527 {
14528 className: clsx_default({
14529 "dataviews-view-table__thead--stuck": isVerticallyScrolled
14530 }),
14531 onContextMenu: handleHeaderContextMenu,
14532 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("tr", { className: "dataviews-view-table__row", children: [
14533 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14534 "th",
14535 {
14536 className: "dataviews-view-table__checkbox-column",
14537 scope: "col",
14538 onContextMenu: handleHeaderContextMenu,
14539 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14540 BulkSelectionCheckbox,
14541 {
14542 selection,
14543 onChangeSelection,
14544 data,
14545 actions,
14546 getItemId
14547 }
14548 )
14549 }
14550 ),
14551 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14552 column_header_menu_default,
14553 {
14554 ref: headerMenuRef(
14555 titleField.id,
14556 0
14557 ),
14558 fieldId: titleField.id,
14559 view,
14560 fields,
14561 onChangeView,
14562 onHide,
14563 setOpenedFilter,
14564 canMove: false,
14565 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
14566 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
14567 }
14568 ) }),
14569 columns.map((column, index2) => {
14570 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14571 const field = fields.find(
14572 (f2) => f2.id === column
14573 );
14574 const effectiveAlign = getEffectiveAlign(
14575 align,
14576 field?.type
14577 );
14578 const canInsertOrMove = view.layout?.enableMoving ?? true;
14579 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14580 "th",
14581 {
14582 style: {
14583 width,
14584 maxWidth,
14585 minWidth,
14586 textAlign: effectiveAlign
14587 },
14588 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14589 scope: "col",
14590 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14591 column_header_menu_default,
14592 {
14593 ref: headerMenuRef(column, index2),
14594 fieldId: column,
14595 view,
14596 fields,
14597 onChangeView,
14598 onHide,
14599 setOpenedFilter,
14600 canMove: canInsertOrMove,
14601 canInsertLeft: canInsertOrMove,
14602 canInsertRight: canInsertOrMove
14603 }
14604 )
14605 },
14606 column
14607 );
14608 }),
14609 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14610 "th",
14611 {
14612 className: clsx_default(
14613 "dataviews-view-table__actions-column",
14614 {
14615 "dataviews-view-table__actions-column--sticky": true,
14616 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
14617 }
14618 ),
14619 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n11.__)("Actions") })
14620 }
14621 )
14622 ] })
14623 }
14624 ),
14625 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14626 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("tbody", { children: [
14627 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14628 "td",
14629 {
14630 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
14631 className: "dataviews-view-table__group-header-cell",
14632 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n11.sprintf)(
14633 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14634 (0, import_i18n11.__)("%1$s: %2$s"),
14635 groupField.label,
14636 groupName
14637 )
14638 }
14639 ) }),
14640 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14641 TableRow,
14642 {
14643 item,
14644 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
14645 hasBulkActions,
14646 actions,
14647 fields,
14648 id: getItemId(item) || index2.toString(),
14649 view,
14650 titleField,
14651 mediaField,
14652 descriptionField,
14653 selection,
14654 getItemId,
14655 onChangeSelection,
14656 onClickItem,
14657 renderItemLink,
14658 isItemClickable,
14659 isActionsColumnSticky: !isHorizontalScrollEnd
14660 },
14661 getItemId(item)
14662 ))
14663 ] }, `group-${groupName}`)
14664 ) : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14665 TableRow,
14666 {
14667 item,
14668 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
14669 hasBulkActions,
14670 actions,
14671 fields,
14672 id: getItemId(item) || index2.toString(),
14673 view,
14674 titleField,
14675 mediaField,
14676 descriptionField,
14677 selection,
14678 getItemId,
14679 onChangeSelection,
14680 onClickItem,
14681 renderItemLink,
14682 isItemClickable,
14683 isActionsColumnSticky: !isHorizontalScrollEnd,
14684 posinset: isInfiniteScroll ? index2 + 1 : void 0
14685 },
14686 getItemId(item)
14687 )) })
14688 ]
14689 }
14690 ),
14691 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components6.Spinner, {}) }) })
14692 ] });
14693 }
14694 var table_default = ViewTable;
14695
14696 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
14697 var import_components9 = __toESM(require_components(), 1);
14698 var import_i18n14 = __toESM(require_i18n(), 1);
14699
14700 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
14701 var import_components8 = __toESM(require_components(), 1);
14702 var import_i18n13 = __toESM(require_i18n(), 1);
14703 var import_compose3 = __toESM(require_compose(), 1);
14704 var import_keycodes2 = __toESM(require_keycodes(), 1);
14705 var import_element55 = __toESM(require_element(), 1);
14706
14707 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
14708 var import_components7 = __toESM(require_components(), 1);
14709 var import_i18n12 = __toESM(require_i18n(), 1);
14710 var import_element52 = __toESM(require_element(), 1);
14711 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
14712 var imageSizes = [
14713 {
14714 value: 120,
14715 breakpoint: 1
14716 },
14717 {
14718 value: 170,
14719 breakpoint: 1
14720 },
14721 {
14722 value: 230,
14723 breakpoint: 1
14724 },
14725 {
14726 value: 290,
14727 breakpoint: 1112
14728 // at minimum image width, 4 images display at this container size
14729 },
14730 {
14731 value: 350,
14732 breakpoint: 1636
14733 // at minimum image width, 6 images display at this container size
14734 },
14735 {
14736 value: 430,
14737 breakpoint: 588
14738 // at minimum image width, 2 images display at this container size
14739 }
14740 ];
14741 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
14742 function useGridColumns() {
14743 const context = (0, import_element52.useContext)(dataviews_context_default);
14744 const view = context.view;
14745 return (0, import_element52.useMemo)(() => {
14746 const containerWidth = context.containerWidth;
14747 const gap = 32;
14748 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
14749 const columns = Math.floor(
14750 (containerWidth + gap) / (previewSize + gap)
14751 );
14752 return Math.max(1, columns);
14753 }, [context.containerWidth, view.layout?.previewSize]);
14754 }
14755
14756 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
14757 var import_element53 = __toESM(require_element(), 1);
14758 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
14759 var GridItems = (0, import_element53.forwardRef)(({ className, previewSize, ...props }, ref) => {
14760 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
14761 "div",
14762 {
14763 ref,
14764 className: clsx_default("dataviews-view-grid-items", className),
14765 style: {
14766 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
14767 },
14768 ...props
14769 }
14770 );
14771 });
14772
14773 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
14774 var import_element54 = __toESM(require_element(), 1);
14775 function useIntersectionObserver(elementRef, posinset) {
14776 const { intersectionObserver } = (0, import_element54.useContext)(dataviews_context_default);
14777 (0, import_element54.useEffect)(() => {
14778 const element = elementRef.current;
14779 if (!element || posinset === void 0 || !intersectionObserver) {
14780 return;
14781 }
14782 intersectionObserver.observe(element);
14783 return () => {
14784 intersectionObserver.unobserve(element);
14785 };
14786 }, [elementRef, intersectionObserver, posinset]);
14787 }
14788 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
14789 const hasData = !!data?.length;
14790 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
14791 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
14792 }
14793
14794 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
14795 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
14796 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
14797 function chunk(array, size4) {
14798 const chunks = [];
14799 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
14800 chunks.push(array.slice(i2, i2 + size4));
14801 }
14802 return chunks;
14803 }
14804 var GridItem = (0, import_element55.forwardRef)(
14805 function GridItem2({
14806 view,
14807 selection,
14808 onChangeSelection,
14809 onClickItem,
14810 isItemClickable,
14811 renderItemLink,
14812 getItemId,
14813 item,
14814 actions,
14815 mediaField,
14816 titleField,
14817 descriptionField,
14818 regularFields,
14819 badgeFields,
14820 hasBulkActions,
14821 config,
14822 posinset,
14823 setsize,
14824 ...props
14825 }, forwardedRef) {
14826 const {
14827 showTitle = true,
14828 showMedia = true,
14829 showDescription = true
14830 } = view;
14831 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
14832 const id = getItemId(item);
14833 const elementRef = (0, import_element55.useRef)(null);
14834 const setRefs = (0, import_element55.useCallback)(
14835 (node) => {
14836 elementRef.current = node;
14837 if (typeof forwardedRef === "function") {
14838 forwardedRef(node);
14839 } else if (forwardedRef) {
14840 forwardedRef.current = node;
14841 }
14842 },
14843 [forwardedRef]
14844 );
14845 useIntersectionObserver(elementRef, posinset);
14846 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
14847 const isSelected2 = selection.includes(id);
14848 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
14849 const rendersMediaField = showMedia && mediaField?.render;
14850 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14851 mediaField.render,
14852 {
14853 item,
14854 field: mediaField,
14855 config
14856 }
14857 ) : mediaPlaceholder;
14858 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(titleField.render, { item, field: titleField }) : null;
14859 let mediaA11yProps;
14860 let titleA11yProps;
14861 if (isItemClickable(item) && onClickItem) {
14862 if (renderedTitleField) {
14863 mediaA11yProps = {
14864 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
14865 };
14866 titleA11yProps = {
14867 id: `dataviews-view-grid__title-field-${instanceId}`
14868 };
14869 } else {
14870 mediaA11yProps = {
14871 "aria-label": (0, import_i18n13.__)("Navigate to item")
14872 };
14873 }
14874 }
14875 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
14876 Stack,
14877 {
14878 direction: "column",
14879 ...props,
14880 ref: setRefs,
14881 "aria-setsize": setsize,
14882 "aria-posinset": posinset,
14883 className: clsx_default(
14884 props.className,
14885 "dataviews-view-grid__row__gridcell",
14886 "dataviews-view-grid__card",
14887 {
14888 "is-selected": hasBulkAction && isSelected2
14889 }
14890 ),
14891 onClickCapture: (event) => {
14892 props.onClickCapture?.(event);
14893 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
14894 event.stopPropagation();
14895 event.preventDefault();
14896 if (!hasBulkAction) {
14897 return;
14898 }
14899 onChangeSelection(
14900 isSelected2 ? selection.filter(
14901 (itemId) => id !== itemId
14902 ) : [...selection, id]
14903 );
14904 }
14905 },
14906 children: [
14907 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14908 ItemClickWrapper,
14909 {
14910 item,
14911 isItemClickable,
14912 onClickItem,
14913 renderItemLink,
14914 className: clsx_default("dataviews-view-grid__media", {
14915 "dataviews-view-grid__media--placeholder": !rendersMediaField
14916 }),
14917 ...mediaA11yProps,
14918 children: renderedMediaField
14919 }
14920 ),
14921 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14922 DataViewsSelectionCheckbox,
14923 {
14924 item,
14925 selection,
14926 onChangeSelection,
14927 getItemId,
14928 titleField,
14929 disabled: !hasBulkAction
14930 }
14931 ),
14932 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14933 ItemActions,
14934 {
14935 item,
14936 actions,
14937 isCompact: true
14938 }
14939 ) }),
14940 showTitle && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14941 ItemClickWrapper,
14942 {
14943 item,
14944 isItemClickable,
14945 onClickItem,
14946 renderItemLink,
14947 className: "dataviews-view-grid__title-field dataviews-title-field",
14948 ...titleA11yProps,
14949 title: titleField?.getValueFormatted({
14950 item,
14951 field: titleField
14952 }) || void 0,
14953 children: renderedTitleField
14954 }
14955 ) }),
14956 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Stack, { direction: "column", gap: "xs", children: [
14957 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14958 descriptionField.render,
14959 {
14960 item,
14961 field: descriptionField
14962 }
14963 ),
14964 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14965 Stack,
14966 {
14967 direction: "row",
14968 className: "dataviews-view-grid__badge-fields",
14969 gap: "sm",
14970 wrap: "wrap",
14971 align: "top",
14972 justify: "flex-start",
14973 children: badgeFields.map((field) => {
14974 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14975 WCBadge,
14976 {
14977 className: "dataviews-view-grid__field-value",
14978 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14979 field.render,
14980 {
14981 item,
14982 field
14983 }
14984 )
14985 },
14986 field.id
14987 );
14988 })
14989 }
14990 ),
14991 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14992 Stack,
14993 {
14994 direction: "column",
14995 className: "dataviews-view-grid__fields",
14996 gap: "xs",
14997 children: regularFields.map((field) => {
14998 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14999 import_components8.Flex,
15000 {
15001 className: "dataviews-view-grid__field",
15002 gap: 1,
15003 justify: "flex-start",
15004 expanded: true,
15005 style: { height: "auto" },
15006 direction: "row",
15007 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
15008 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(tooltip_exports.Root, { children: [
15009 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15010 tooltip_exports.Trigger,
15011 {
15012 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
15013 }
15014 ),
15015 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(tooltip_exports.Popup, { children: field.label })
15016 ] }),
15017 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15018 import_components8.FlexItem,
15019 {
15020 className: "dataviews-view-grid__field-value",
15021 style: { maxHeight: "none" },
15022 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15023 field.render,
15024 {
15025 item,
15026 field
15027 }
15028 )
15029 }
15030 )
15031 ] })
15032 },
15033 field.id
15034 );
15035 })
15036 }
15037 )
15038 ] })
15039 ]
15040 }
15041 );
15042 }
15043 );
15044 function CompositeGrid({
15045 data,
15046 isInfiniteScroll,
15047 className,
15048 inert,
15049 isLoading,
15050 view,
15051 fields,
15052 selection,
15053 onChangeSelection,
15054 onClickItem,
15055 isItemClickable,
15056 renderItemLink,
15057 getItemId,
15058 actions
15059 }) {
15060 const { paginationInfo, resizeObserverRef } = (0, import_element55.useContext)(dataviews_context_default);
15061 const gridColumns = useGridColumns();
15062 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
15063 const titleField = fields.find(
15064 (field) => field.id === view?.titleField
15065 );
15066 const mediaField = fields.find(
15067 (field) => field.id === view?.mediaField
15068 );
15069 const descriptionField = fields.find(
15070 (field) => field.id === view?.descriptionField
15071 );
15072 const otherFields = view.fields ?? [];
15073 const { regularFields, badgeFields } = otherFields.reduce(
15074 (accumulator, fieldId) => {
15075 const field = fields.find((f2) => f2.id === fieldId);
15076 if (!field) {
15077 return accumulator;
15078 }
15079 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
15080 accumulator[key].push(field);
15081 return accumulator;
15082 },
15083 { regularFields: [], badgeFields: [] }
15084 );
15085 const size4 = "900px";
15086 const totalRows = Math.ceil(data.length / gridColumns);
15087 const placeholdersNeeded = usePlaceholdersNeeded(
15088 data,
15089 isInfiniteScroll,
15090 gridColumns
15091 );
15092 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, {
15093 // Render infinite scroll layout (no rows, feed semantics)
15094 children: [
15095 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
15096 import_components8.Composite,
15097 {
15098 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15099 GridItems,
15100 {
15101 className: clsx_default(
15102 "dataviews-view-grid-infinite-scroll",
15103 className,
15104 {
15105 [`has-${view.layout?.density}-density`]: view.layout?.density && [
15106 "compact",
15107 "comfortable"
15108 ].includes(view.layout.density)
15109 }
15110 ),
15111 previewSize: view.layout?.previewSize,
15112 "aria-busy": isLoading,
15113 ref: resizeObserverRef
15114 }
15115 ),
15116 role: "feed",
15117 focusWrap: true,
15118 inert,
15119 children: [
15120 Array.from({ length: placeholdersNeeded }).map(
15121 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15122 import_components8.Composite.Item,
15123 {
15124 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15125 Stack,
15126 {
15127 ...props,
15128 direction: "column",
15129 role: "article",
15130 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
15131 }
15132 ),
15133 "aria-hidden": true,
15134 tabIndex: -1
15135 },
15136 `placeholder-${index2}`
15137 )
15138 ),
15139 data.map((item) => {
15140 const itemId = getItemId(item);
15141 const stablePosition = item.position;
15142 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15143 import_components8.Composite.Item,
15144 {
15145 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15146 GridItem,
15147 {
15148 ...props,
15149 id: itemId,
15150 role: "article",
15151 view,
15152 selection,
15153 onChangeSelection,
15154 onClickItem,
15155 isItemClickable,
15156 renderItemLink,
15157 getItemId,
15158 item,
15159 actions,
15160 mediaField,
15161 titleField,
15162 descriptionField,
15163 regularFields,
15164 badgeFields,
15165 hasBulkActions,
15166 posinset: stablePosition,
15167 setsize: paginationInfo.totalItems,
15168 config: {
15169 sizes: size4
15170 }
15171 }
15172 )
15173 },
15174 itemId
15175 );
15176 })
15177 ]
15178 }
15179 ),
15180 // Render standard grid layout (with rows, grid semantics)
15181 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15182 import_components8.Composite,
15183 {
15184 role: "grid",
15185 className: clsx_default("dataviews-view-grid", className, {
15186 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
15187 view.layout.density
15188 )
15189 }),
15190 focusWrap: true,
15191 "aria-busy": isLoading,
15192 "aria-rowcount": totalRows,
15193 ref: resizeObserverRef,
15194 inert,
15195 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15196 import_components8.Composite.Row,
15197 {
15198 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15199 "div",
15200 {
15201 role: "row",
15202 "aria-rowindex": i2 + 1,
15203 "aria-label": (0, import_i18n13.sprintf)(
15204 /* translators: %d: The row number in the grid */
15205 (0, import_i18n13.__)("Row %d"),
15206 i2 + 1
15207 ),
15208 className: "dataviews-view-grid__row",
15209 style: {
15210 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
15211 }
15212 }
15213 ),
15214 children: row.map((item) => {
15215 const itemId = getItemId(item);
15216 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15217 import_components8.Composite.Item,
15218 {
15219 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15220 GridItem,
15221 {
15222 ...props,
15223 id: itemId,
15224 role: "gridcell",
15225 view,
15226 selection,
15227 onChangeSelection,
15228 onClickItem,
15229 isItemClickable,
15230 renderItemLink,
15231 getItemId,
15232 item,
15233 actions,
15234 mediaField,
15235 titleField,
15236 descriptionField,
15237 regularFields,
15238 badgeFields,
15239 hasBulkActions,
15240 config: {
15241 sizes: size4
15242 }
15243 }
15244 )
15245 },
15246 itemId
15247 );
15248 })
15249 },
15250 i2
15251 ))
15252 }
15253 )
15254 ]
15255 });
15256 }
15257
15258 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
15259 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
15260 function ViewGrid({
15261 actions,
15262 data,
15263 fields,
15264 getItemId,
15265 isLoading,
15266 onChangeSelection,
15267 onClickItem,
15268 isItemClickable,
15269 renderItemLink,
15270 selection,
15271 view,
15272 className,
15273 empty
15274 }) {
15275 const isDelayedLoading = useDelayedLoading(!!isLoading);
15276 const hasData = !!data?.length;
15277 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
15278 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
15279 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
15280 if (!hasData) {
15281 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15282 "div",
15283 {
15284 className: clsx_default("dataviews-no-results", {
15285 "is-refreshing": isDelayedLoading
15286 }),
15287 children: empty
15288 }
15289 );
15290 }
15291 const gridProps = {
15292 className: clsx_default(className, {
15293 "is-refreshing": !isInfiniteScroll && isDelayedLoading
15294 }),
15295 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
15296 isLoading,
15297 view,
15298 fields,
15299 selection,
15300 onChangeSelection,
15301 onClickItem,
15302 isItemClickable,
15303 renderItemLink,
15304 getItemId,
15305 actions
15306 };
15307 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, {
15308 // Render multiple groups.
15309 children: [
15310 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
15311 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
15312 Stack,
15313 {
15314 direction: "column",
15315 gap: "sm",
15316 children: [
15317 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
15318 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15319 (0, import_i18n14.__)("%1$s: %2$s"),
15320 groupField.label,
15321 groupName
15322 ) }),
15323 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15324 CompositeGrid,
15325 {
15326 ...gridProps,
15327 data: groupItems,
15328 isInfiniteScroll: false
15329 }
15330 )
15331 ]
15332 },
15333 groupName
15334 )
15335 ) }),
15336 // Render a single grid with all data.
15337 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15338 CompositeGrid,
15339 {
15340 ...gridProps,
15341 data,
15342 isInfiniteScroll: !!isInfiniteScroll
15343 }
15344 ),
15345 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components9.Spinner, {}) })
15346 ]
15347 });
15348 }
15349 var grid_default = ViewGrid;
15350
15351 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
15352 var import_compose4 = __toESM(require_compose(), 1);
15353 var import_components10 = __toESM(require_components(), 1);
15354 var import_element56 = __toESM(require_element(), 1);
15355 var import_i18n15 = __toESM(require_i18n(), 1);
15356 var import_data3 = __toESM(require_data(), 1);
15357 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
15358 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
15359 function generateItemWrapperCompositeId(idPrefix) {
15360 return `${idPrefix}-item-wrapper`;
15361 }
15362 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
15363 return `${idPrefix}-primary-action-${primaryActionId}`;
15364 }
15365 function generateDropdownTriggerCompositeId(idPrefix) {
15366 return `${idPrefix}-dropdown`;
15367 }
15368 function PrimaryActionGridCell({
15369 idPrefix,
15370 primaryAction,
15371 item
15372 }) {
15373 const registry = (0, import_data3.useRegistry)();
15374 const [isModalOpen, setIsModalOpen] = (0, import_element56.useState)(false);
15375 const compositeItemId = generatePrimaryActionCompositeId(
15376 idPrefix,
15377 primaryAction.id
15378 );
15379 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
15380 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15381 import_components10.Composite.Item,
15382 {
15383 id: compositeItemId,
15384 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15385 import_components10.Button,
15386 {
15387 disabled: !!primaryAction.disabled,
15388 accessibleWhenDisabled: true,
15389 text: label,
15390 size: "small",
15391 onClick: () => setIsModalOpen(true)
15392 }
15393 ),
15394 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15395 ActionModal,
15396 {
15397 action: primaryAction,
15398 items: [item],
15399 closeModal: () => setIsModalOpen(false)
15400 }
15401 )
15402 }
15403 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15404 import_components10.Composite.Item,
15405 {
15406 id: compositeItemId,
15407 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15408 import_components10.Button,
15409 {
15410 disabled: !!primaryAction.disabled,
15411 accessibleWhenDisabled: true,
15412 size: "small",
15413 onClick: () => {
15414 primaryAction.callback([item], { registry });
15415 },
15416 children: label
15417 }
15418 )
15419 }
15420 ) }, primaryAction.id);
15421 }
15422 function ListItem({
15423 view,
15424 actions,
15425 idPrefix,
15426 isSelected: isSelected2,
15427 item,
15428 titleField,
15429 mediaField,
15430 descriptionField,
15431 onSelect,
15432 otherFields,
15433 onDropdownTriggerKeyDown,
15434 posinset
15435 }) {
15436 const {
15437 showTitle = true,
15438 showMedia = true,
15439 showDescription = true,
15440 infiniteScrollEnabled
15441 } = view;
15442 const itemRef = (0, import_element56.useRef)(null);
15443 const labelId = `${idPrefix}-label`;
15444 const descriptionId = `${idPrefix}-description`;
15445 const registry = (0, import_data3.useRegistry)();
15446 const [isHovered, setIsHovered] = (0, import_element56.useState)(false);
15447 const [activeModalAction, setActiveModalAction] = (0, import_element56.useState)(
15448 null
15449 );
15450 const handleHover = ({ type }) => {
15451 const isHover = type === "mouseenter";
15452 setIsHovered(isHover);
15453 };
15454 const { paginationInfo } = (0, import_element56.useContext)(dataviews_context_default);
15455 (0, import_element56.useEffect)(() => {
15456 if (isSelected2) {
15457 itemRef.current?.scrollIntoView({
15458 behavior: "auto",
15459 block: "nearest",
15460 inline: "nearest"
15461 });
15462 }
15463 }, [isSelected2]);
15464 const { primaryAction, eligibleActions } = (0, import_element56.useMemo)(() => {
15465 const _eligibleActions = actions.filter(
15466 (action) => !action.isEligible || action.isEligible(item)
15467 );
15468 const _primaryActions = _eligibleActions.filter(
15469 (action) => action.isPrimary
15470 );
15471 return {
15472 primaryAction: _primaryActions[0],
15473 eligibleActions: _eligibleActions
15474 };
15475 }, [actions, item]);
15476 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
15477 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15478 mediaField.render,
15479 {
15480 item,
15481 field: mediaField,
15482 config: { sizes: "52px" }
15483 }
15484 ) }) : null;
15485 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(titleField.render, { item, field: titleField }) : null;
15486 const renderDescription = showDescription && descriptionField?.render;
15487 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
15488 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15489 Stack,
15490 {
15491 direction: "row",
15492 gap: "md",
15493 className: "dataviews-view-list__item-actions",
15494 children: [
15495 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15496 PrimaryActionGridCell,
15497 {
15498 idPrefix,
15499 primaryAction,
15500 item
15501 }
15502 ),
15503 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { role: "gridcell", children: [
15504 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Menu3, { placement: "bottom-end", children: [
15505 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15506 Menu3.TriggerButton,
15507 {
15508 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15509 import_components10.Composite.Item,
15510 {
15511 id: generateDropdownTriggerCompositeId(
15512 idPrefix
15513 ),
15514 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15515 import_components10.Button,
15516 {
15517 size: "small",
15518 icon: more_vertical_default,
15519 label: (0, import_i18n15.__)("Actions"),
15520 accessibleWhenDisabled: true,
15521 disabled: !actions.length,
15522 onKeyDown: onDropdownTriggerKeyDown
15523 }
15524 )
15525 }
15526 )
15527 }
15528 ),
15529 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15530 ActionsMenuGroup,
15531 {
15532 actions: eligibleActions,
15533 item,
15534 registry,
15535 setActiveModalAction
15536 }
15537 ) })
15538 ] }),
15539 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15540 ActionModal,
15541 {
15542 action: activeModalAction,
15543 items: [item],
15544 closeModal: () => setActiveModalAction(null)
15545 }
15546 )
15547 ] })
15548 ]
15549 }
15550 );
15551 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15552 import_components10.Composite.Row,
15553 {
15554 ref: itemRef,
15555 render: (
15556 /* aria-posinset breaks Composite.Row if passed to it directly. */
15557 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15558 "div",
15559 {
15560 "aria-posinset": posinset,
15561 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
15562 }
15563 )
15564 ),
15565 role: infiniteScrollEnabled ? "article" : "row",
15566 className: clsx_default({
15567 "is-selected": isSelected2,
15568 "is-hovered": isHovered
15569 }),
15570 onMouseEnter: handleHover,
15571 onMouseLeave: handleHover,
15572 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15573 Stack,
15574 {
15575 direction: "row",
15576 className: "dataviews-view-list__item-wrapper",
15577 children: [
15578 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15579 import_components10.Composite.Item,
15580 {
15581 id: generateItemWrapperCompositeId(idPrefix),
15582 "aria-pressed": isSelected2,
15583 "aria-labelledby": labelId,
15584 "aria-describedby": descriptionId,
15585 className: "dataviews-view-list__item",
15586 onClick: () => onSelect(item)
15587 }
15588 ) }),
15589 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15590 Stack,
15591 {
15592 direction: "row",
15593 gap: "md",
15594 justify: "start",
15595 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
15596 style: { flex: 1, minWidth: 0 },
15597 children: [
15598 renderedMediaField,
15599 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15600 Stack,
15601 {
15602 direction: "column",
15603 gap: "xs",
15604 className: "dataviews-view-list__field-wrapper",
15605 children: [
15606 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "row", align: "center", children: [
15607 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15608 "div",
15609 {
15610 className: "dataviews-title-field dataviews-view-list__title-field",
15611 id: labelId,
15612 children: renderedTitleField
15613 }
15614 ),
15615 usedActions
15616 ] }),
15617 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15618 descriptionField.render,
15619 {
15620 item,
15621 field: descriptionField
15622 }
15623 ) }),
15624 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15625 "div",
15626 {
15627 className: "dataviews-view-list__fields",
15628 id: descriptionId,
15629 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15630 "div",
15631 {
15632 className: "dataviews-view-list__field",
15633 children: [
15634 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15635 VisuallyHidden,
15636 {
15637 className: "dataviews-view-list__field-label",
15638 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", {}),
15639 children: field.label
15640 }
15641 ),
15642 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15643 field.render,
15644 {
15645 item,
15646 field
15647 }
15648 ) })
15649 ]
15650 },
15651 field.id
15652 ))
15653 }
15654 )
15655 ]
15656 }
15657 )
15658 ]
15659 }
15660 )
15661 ]
15662 }
15663 )
15664 }
15665 );
15666 }
15667 function isDefined2(item) {
15668 return !!item;
15669 }
15670 function ViewList(props) {
15671 const {
15672 actions,
15673 data,
15674 fields,
15675 getItemId,
15676 isLoading,
15677 onChangeSelection,
15678 selection,
15679 view,
15680 className,
15681 empty
15682 } = props;
15683 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
15684 const isDelayedLoading = useDelayedLoading(!!isLoading);
15685 const selectedItem = data?.findLast(
15686 (item) => selection.includes(getItemId(item))
15687 );
15688 const titleField = fields.find((field) => field.id === view.titleField);
15689 const mediaField = fields.find((field) => field.id === view.mediaField);
15690 const descriptionField = fields.find(
15691 (field) => field.id === view.descriptionField
15692 );
15693 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
15694 const onSelect = (item) => onChangeSelection([getItemId(item)]);
15695 const generateCompositeItemIdPrefix = (0, import_element56.useCallback)(
15696 (item) => `${baseId}-${getItemId(item)}`,
15697 [baseId, getItemId]
15698 );
15699 const isActiveCompositeItem = (0, import_element56.useCallback)(
15700 (item, idToCheck) => {
15701 return idToCheck.startsWith(
15702 generateCompositeItemIdPrefix(item)
15703 );
15704 },
15705 [generateCompositeItemIdPrefix]
15706 );
15707 const [activeCompositeId, setActiveCompositeId] = (0, import_element56.useState)(void 0);
15708 const compositeRef = (0, import_element56.useRef)(null);
15709 (0, import_element56.useEffect)(() => {
15710 if (selectedItem) {
15711 setActiveCompositeId(
15712 generateItemWrapperCompositeId(
15713 generateCompositeItemIdPrefix(selectedItem)
15714 )
15715 );
15716 }
15717 }, [selectedItem, generateCompositeItemIdPrefix]);
15718 const activeItemIndex = data.findIndex(
15719 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
15720 );
15721 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
15722 const isActiveIdInList = activeItemIndex !== -1;
15723 const selectCompositeItem = (0, import_element56.useCallback)(
15724 (targetIndex, generateCompositeId) => {
15725 const clampedIndex = Math.min(
15726 data.length - 1,
15727 Math.max(0, targetIndex)
15728 );
15729 if (!data[clampedIndex]) {
15730 return;
15731 }
15732 const itemIdPrefix = generateCompositeItemIdPrefix(
15733 data[clampedIndex]
15734 );
15735 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
15736 setActiveCompositeId(targetCompositeItemId);
15737 if (compositeRef.current?.contains(
15738 compositeRef.current.ownerDocument.activeElement
15739 )) {
15740 document.getElementById(targetCompositeItemId)?.focus();
15741 }
15742 },
15743 [data, generateCompositeItemIdPrefix]
15744 );
15745 (0, import_element56.useEffect)(() => {
15746 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
15747 if (!isActiveIdInList && wasActiveIdInList) {
15748 selectCompositeItem(
15749 previousActiveItemIndex,
15750 generateItemWrapperCompositeId
15751 );
15752 }
15753 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
15754 const onDropdownTriggerKeyDown = (0, import_element56.useCallback)(
15755 (event) => {
15756 if (event.key === "ArrowDown") {
15757 event.preventDefault();
15758 selectCompositeItem(
15759 activeItemIndex + 1,
15760 generateDropdownTriggerCompositeId
15761 );
15762 }
15763 if (event.key === "ArrowUp") {
15764 event.preventDefault();
15765 selectCompositeItem(
15766 activeItemIndex - 1,
15767 generateDropdownTriggerCompositeId
15768 );
15769 }
15770 },
15771 [selectCompositeItem, activeItemIndex]
15772 );
15773 const hasData = !!data?.length;
15774 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
15775 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
15776 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
15777 if (!hasData) {
15778 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15779 "div",
15780 {
15781 className: clsx_default("dataviews-no-results", {
15782 "is-refreshing": isDelayedLoading
15783 }),
15784 children: empty
15785 }
15786 );
15787 }
15788 if (hasData && groupField && dataByGroup) {
15789 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15790 import_components10.Composite,
15791 {
15792 ref: compositeRef,
15793 id: `${baseId}`,
15794 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", {}),
15795 className: "dataviews-view-list__group",
15796 role: "grid",
15797 activeId: activeCompositeId,
15798 setActiveId: setActiveCompositeId,
15799 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15800 Stack,
15801 {
15802 direction: "column",
15803 gap: "lg",
15804 className: clsx_default("dataviews-view-list", className),
15805 children: Array.from(dataByGroup.entries()).map(
15806 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15807 Stack,
15808 {
15809 direction: "column",
15810 gap: "sm",
15811 children: [
15812 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n15.sprintf)(
15813 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15814 (0, import_i18n15.__)("%1$s: %2$s"),
15815 groupField.label,
15816 groupName
15817 ) }),
15818 groupItems.map((item) => {
15819 const id = generateCompositeItemIdPrefix(item);
15820 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15821 ListItem,
15822 {
15823 view,
15824 idPrefix: id,
15825 actions,
15826 item,
15827 isSelected: item === selectedItem,
15828 onSelect,
15829 mediaField,
15830 titleField,
15831 descriptionField,
15832 otherFields,
15833 onDropdownTriggerKeyDown
15834 },
15835 id
15836 );
15837 })
15838 ]
15839 },
15840 groupName
15841 )
15842 )
15843 }
15844 )
15845 }
15846 );
15847 }
15848 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { children: [
15849 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15850 import_components10.Composite,
15851 {
15852 ref: compositeRef,
15853 id: baseId,
15854 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", {}),
15855 className: clsx_default("dataviews-view-list", className, {
15856 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
15857 view.layout.density
15858 ),
15859 "is-refreshing": !isInfiniteScroll && isDelayedLoading
15860 }),
15861 role: view.infiniteScrollEnabled ? "feed" : "grid",
15862 activeId: activeCompositeId,
15863 setActiveId: setActiveCompositeId,
15864 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
15865 children: data.map((item, index2) => {
15866 const id = generateCompositeItemIdPrefix(item);
15867 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15868 ListItem,
15869 {
15870 view,
15871 idPrefix: id,
15872 actions,
15873 item,
15874 isSelected: item === selectedItem,
15875 onSelect,
15876 mediaField,
15877 titleField,
15878 descriptionField,
15879 otherFields,
15880 onDropdownTriggerKeyDown,
15881 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
15882 },
15883 id
15884 );
15885 })
15886 }
15887 ),
15888 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components10.Spinner, {}) })
15889 ] });
15890 }
15891
15892 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
15893 var import_components11 = __toESM(require_components(), 1);
15894
15895 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
15896 var import_i18n16 = __toESM(require_i18n(), 1);
15897 var import_element57 = __toESM(require_element(), 1);
15898 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
15899 function ActivityGroup({
15900 groupName,
15901 groupData,
15902 groupField,
15903 showLabel = true,
15904 children
15905 }) {
15906 const groupHeader = showLabel ? (0, import_element57.createInterpolateElement)(
15907 // translators: %s: The label of the field e.g. "Status".
15908 (0, import_i18n16.sprintf)((0, import_i18n16.__)("%s: <groupName />"), groupField.label).trim(),
15909 {
15910 groupName: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15911 groupField.render,
15912 {
15913 item: groupData[0],
15914 field: groupField
15915 }
15916 )
15917 }
15918 ) : /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(groupField.render, { item: groupData[0], field: groupField });
15919 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
15920 Stack,
15921 {
15922 direction: "column",
15923 className: "dataviews-view-activity__group",
15924 children: [
15925 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
15926 children
15927 ]
15928 },
15929 groupName
15930 );
15931 }
15932
15933 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
15934 var import_element58 = __toESM(require_element(), 1);
15935 var import_data4 = __toESM(require_data(), 1);
15936 var import_compose5 = __toESM(require_compose(), 1);
15937 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
15938 function ActivityItem(props) {
15939 const {
15940 view,
15941 actions,
15942 item,
15943 titleField,
15944 mediaField,
15945 descriptionField,
15946 otherFields,
15947 posinset,
15948 onClickItem,
15949 renderItemLink,
15950 isItemClickable
15951 } = props;
15952 const {
15953 showTitle = true,
15954 showMedia = true,
15955 showDescription = true,
15956 infiniteScrollEnabled
15957 } = view;
15958 const itemRef = (0, import_element58.useRef)(null);
15959 const registry = (0, import_data4.useRegistry)();
15960 const { paginationInfo } = (0, import_element58.useContext)(dataviews_context_default);
15961 const { primaryActions, eligibleActions } = (0, import_element58.useMemo)(() => {
15962 const _eligibleActions = actions.filter(
15963 (action) => !action.isEligible || action.isEligible(item)
15964 );
15965 const _primaryActions = _eligibleActions.filter(
15966 (action) => action.isPrimary
15967 );
15968 return {
15969 primaryActions: _primaryActions,
15970 eligibleActions: _eligibleActions
15971 };
15972 }, [actions, item]);
15973 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
15974 const density = view.layout?.density ?? "balanced";
15975 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15976 mediaField.render,
15977 {
15978 item,
15979 field: mediaField,
15980 config: {
15981 sizes: density === "comfortable" ? "32px" : "24px"
15982 }
15983 }
15984 ) : null;
15985 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15986 "span",
15987 {
15988 className: "dataviews-view-activity__item-bullet",
15989 "aria-hidden": "true"
15990 }
15991 ) });
15992 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(titleField.render, { item, field: titleField }) : null;
15993 const verticalGap = (0, import_element58.useMemo)(() => {
15994 switch (density) {
15995 case "comfortable":
15996 return "md";
15997 default:
15998 return "sm";
15999 }
16000 }, [density]);
16001 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16002 "div",
16003 {
16004 ref: itemRef,
16005 role: infiniteScrollEnabled ? "article" : void 0,
16006 "aria-posinset": posinset,
16007 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
16008 className: clsx_default(
16009 "dataviews-view-activity__item",
16010 density === "compact" && "is-compact",
16011 density === "balanced" && "is-balanced",
16012 density === "comfortable" && "is-comfortable"
16013 ),
16014 children: /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
16015 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16016 Stack,
16017 {
16018 direction: "column",
16019 gap: "xs",
16020 align: "center",
16021 className: "dataviews-view-activity__item-type",
16022 children: renderedMediaField
16023 }
16024 ),
16025 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
16026 Stack,
16027 {
16028 direction: "column",
16029 gap: verticalGap,
16030 align: "flex-start",
16031 className: "dataviews-view-activity__item-content",
16032 children: [
16033 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16034 ItemClickWrapper,
16035 {
16036 item,
16037 isItemClickable,
16038 onClickItem,
16039 renderItemLink,
16040 className: "dataviews-view-activity__item-title",
16041 children: renderedTitleField
16042 }
16043 ),
16044 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16045 descriptionField.render,
16046 {
16047 item,
16048 field: descriptionField
16049 }
16050 ) }),
16051 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
16052 "div",
16053 {
16054 className: "dataviews-view-activity__item-field",
16055 children: [
16056 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16057 VisuallyHidden,
16058 {
16059 className: "dataviews-view-activity__item-field-label",
16060 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", {}),
16061 children: field.label
16062 }
16063 ),
16064 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16065 field.render,
16066 {
16067 item,
16068 field
16069 }
16070 ) })
16071 ]
16072 },
16073 field.id
16074 )) }),
16075 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16076 PrimaryActions,
16077 {
16078 item,
16079 actions: primaryActions,
16080 registry,
16081 buttonVariant: "secondary"
16082 }
16083 )
16084 ]
16085 }
16086 ),
16087 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
16088 // there if there are any actions at all.
16089 isMobileViewport && // At the same time, only show the menu if there are actions to show.
16090 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16091 ItemActions,
16092 {
16093 item,
16094 actions: eligibleActions,
16095 isCompact: true
16096 }
16097 ) })
16098 ] })
16099 }
16100 );
16101 }
16102 var activity_item_default = ActivityItem;
16103
16104 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
16105 var import_react15 = __toESM(require_react(), 1);
16106 function isDefined3(item) {
16107 return !!item;
16108 }
16109 function ActivityItems(props) {
16110 const { data, fields, getItemId, view } = props;
16111 const titleField = fields.find((field) => field.id === view.titleField);
16112 const mediaField = fields.find((field) => field.id === view.mediaField);
16113 const descriptionField = fields.find(
16114 (field) => field.id === view.descriptionField
16115 );
16116 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
16117 return data.map((item, index2) => {
16118 return /* @__PURE__ */ (0, import_react15.createElement)(
16119 activity_item_default,
16120 {
16121 ...props,
16122 key: getItemId(item),
16123 item,
16124 mediaField,
16125 titleField,
16126 descriptionField,
16127 otherFields,
16128 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
16129 }
16130 );
16131 });
16132 }
16133
16134 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
16135 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
16136 function ViewActivity(props) {
16137 const { empty, data, fields, isLoading, view, className } = props;
16138 const isDelayedLoading = useDelayedLoading(!!isLoading);
16139 const hasData = !!data?.length;
16140 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
16141 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
16142 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
16143 if (!hasData) {
16144 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16145 "div",
16146 {
16147 className: clsx_default("dataviews-no-results", {
16148 "is-refreshing": isDelayedLoading
16149 }),
16150 children: empty
16151 }
16152 );
16153 }
16154 const isInert = !isInfiniteScroll && !!isLoading;
16155 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
16156 "is-refreshing": !isInfiniteScroll && isDelayedLoading
16157 });
16158 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
16159 if (hasData && groupField && dataByGroup) {
16160 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16161 Stack,
16162 {
16163 direction: "column",
16164 gap: "sm",
16165 className: wrapperClassName,
16166 inert: isInert ? "true" : void 0,
16167 children: groupedEntries.map(
16168 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16169 ActivityGroup,
16170 {
16171 groupName,
16172 groupData,
16173 groupField,
16174 showLabel: view.groupBy?.showLabel !== false,
16175 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16176 ActivityItems,
16177 {
16178 ...props,
16179 data: groupData
16180 }
16181 )
16182 },
16183 groupName
16184 )
16185 )
16186 }
16187 );
16188 }
16189 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(import_jsx_runtime80.Fragment, { children: [
16190 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16191 "div",
16192 {
16193 className: wrapperClassName,
16194 role: view.infiniteScrollEnabled ? "feed" : void 0,
16195 inert: isInert ? "true" : void 0,
16196 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ActivityItems, { ...props })
16197 }
16198 ),
16199 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components11.Spinner, {}) })
16200 ] });
16201 }
16202
16203 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
16204 var import_components14 = __toESM(require_components(), 1);
16205 var import_i18n19 = __toESM(require_i18n(), 1);
16206 var import_compose6 = __toESM(require_compose(), 1);
16207 var import_element61 = __toESM(require_element(), 1);
16208
16209 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
16210 var import_components13 = __toESM(require_components(), 1);
16211 var import_data5 = __toESM(require_data(), 1);
16212 var import_element60 = __toESM(require_element(), 1);
16213 var import_i18n18 = __toESM(require_i18n(), 1);
16214
16215 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
16216 var import_components12 = __toESM(require_components(), 1);
16217 var import_element59 = __toESM(require_element(), 1);
16218 var import_i18n17 = __toESM(require_i18n(), 1);
16219 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
16220 function DataViewsPagination() {
16221 const {
16222 view,
16223 onChangeView,
16224 paginationInfo: { totalItems = 0, totalPages }
16225 } = (0, import_element59.useContext)(dataviews_context_default);
16226 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
16227 return null;
16228 }
16229 const currentPage = view.page ?? 1;
16230 const pageSelectOptions = Array.from(Array(totalPages)).map(
16231 (_, i2) => {
16232 const page = i2 + 1;
16233 return {
16234 value: page.toString(),
16235 label: page.toString(),
16236 "aria-label": currentPage === page ? (0, import_i18n17.sprintf)(
16237 // translators: 1: current page number. 2: total number of pages.
16238 (0, import_i18n17.__)("Page %1$d of %2$d"),
16239 currentPage,
16240 totalPages
16241 ) : page.toString()
16242 };
16243 }
16244 );
16245 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
16246 Stack,
16247 {
16248 direction: "row",
16249 className: "dataviews-pagination",
16250 justify: "end",
16251 align: "center",
16252 gap: "xl",
16253 children: [
16254 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16255 Stack,
16256 {
16257 direction: "row",
16258 justify: "flex-start",
16259 align: "center",
16260 gap: "xs",
16261 className: "dataviews-pagination__page-select",
16262 children: (0, import_element59.createInterpolateElement)(
16263 (0, import_i18n17.sprintf)(
16264 // translators: 1: Current page number, 2: Total number of pages.
16265 (0, import_i18n17._x)(
16266 "<div>Page</div>%1$s<div>of %2$d</div>",
16267 "paging"
16268 ),
16269 "<CurrentPage />",
16270 totalPages
16271 ),
16272 {
16273 div: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { "aria-hidden": true }),
16274 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
16275 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16276 import_components12.SelectControl,
16277 {
16278 "aria-label": (0, import_i18n17.__)("Current page"),
16279 value: currentPage.toString(),
16280 options: pageSelectOptions,
16281 onChange: (newValue) => {
16282 onChangeView({
16283 ...view,
16284 page: +newValue
16285 });
16286 },
16287 size: "small",
16288 variant: "minimal"
16289 }
16290 )
16291 }
16292 )
16293 }
16294 ),
16295 /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
16296 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16297 import_components12.Button,
16298 {
16299 onClick: () => onChangeView({
16300 ...view,
16301 page: currentPage - 1
16302 }),
16303 disabled: currentPage === 1,
16304 accessibleWhenDisabled: true,
16305 label: (0, import_i18n17.__)("Previous page"),
16306 icon: (0, import_i18n17.isRTL)() ? next_default : previous_default,
16307 showTooltip: true,
16308 size: "compact",
16309 tooltipPosition: "top"
16310 }
16311 ),
16312 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16313 import_components12.Button,
16314 {
16315 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
16316 disabled: currentPage >= totalPages,
16317 accessibleWhenDisabled: true,
16318 label: (0, import_i18n17.__)("Next page"),
16319 icon: (0, import_i18n17.isRTL)() ? previous_default : next_default,
16320 showTooltip: true,
16321 size: "compact",
16322 tooltipPosition: "top"
16323 }
16324 )
16325 ] })
16326 ]
16327 }
16328 );
16329 }
16330 var dataviews_pagination_default = (0, import_element59.memo)(DataViewsPagination);
16331
16332 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
16333 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
16334 function useIsMultiselectPicker(actions) {
16335 return (0, import_element60.useMemo)(() => {
16336 return !!actions?.length && actions?.every((action) => action.supportsBulk);
16337 }, [actions]);
16338 }
16339
16340 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
16341 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
16342 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
16343 function GridItem3({
16344 view,
16345 multiselect,
16346 selection,
16347 onChangeSelection,
16348 getItemId,
16349 item,
16350 mediaField,
16351 titleField,
16352 descriptionField,
16353 regularFields,
16354 badgeFields,
16355 config,
16356 posinset,
16357 setsize
16358 }) {
16359 const { showTitle = true, showMedia = true, showDescription = true } = view;
16360 const id = getItemId(item);
16361 const elementRef = (0, import_element61.useRef)(null);
16362 const isSelected2 = selection.includes(id);
16363 useIntersectionObserver(elementRef, posinset);
16364 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16365 mediaField.render,
16366 {
16367 item,
16368 field: mediaField,
16369 config
16370 }
16371 ) : null;
16372 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(titleField.render, { item, field: titleField }) : null;
16373 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
16374 import_components14.Composite.Item,
16375 {
16376 ref: elementRef,
16377 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n19.__)("(no title)") : void 0,
16378 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Stack, { direction: "column", children, ...props }),
16379 role: "option",
16380 "aria-posinset": posinset,
16381 "aria-setsize": setsize,
16382 className: clsx_default("dataviews-view-picker-grid__card", {
16383 "is-selected": isSelected2
16384 }),
16385 "aria-selected": isSelected2,
16386 onClick: () => {
16387 if (isSelected2) {
16388 onChangeSelection(
16389 selection.filter((itemId) => id !== itemId)
16390 );
16391 } else {
16392 const newSelection = multiselect ? [...selection, id] : [id];
16393 onChangeSelection(newSelection);
16394 }
16395 },
16396 children: [
16397 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
16398 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16399 DataViewsSelectionCheckbox,
16400 {
16401 item,
16402 selection,
16403 onChangeSelection,
16404 getItemId,
16405 titleField,
16406 disabled: false,
16407 "aria-hidden": true,
16408 tabIndex: -1
16409 }
16410 ),
16411 showTitle && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16412 Stack,
16413 {
16414 direction: "row",
16415 justify: "space-between",
16416 className: "dataviews-view-picker-grid__title-actions",
16417 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
16418 }
16419 ),
16420 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Stack, { direction: "column", gap: "xs", children: [
16421 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16422 descriptionField.render,
16423 {
16424 item,
16425 field: descriptionField
16426 }
16427 ),
16428 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16429 Stack,
16430 {
16431 direction: "row",
16432 className: "dataviews-view-picker-grid__badge-fields",
16433 gap: "sm",
16434 wrap: "wrap",
16435 align: "top",
16436 justify: "flex-start",
16437 children: badgeFields.map((field) => {
16438 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16439 WCBadge2,
16440 {
16441 className: "dataviews-view-picker-grid__field-value",
16442 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16443 field.render,
16444 {
16445 item,
16446 field
16447 }
16448 )
16449 },
16450 field.id
16451 );
16452 })
16453 }
16454 ),
16455 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16456 Stack,
16457 {
16458 direction: "column",
16459 className: "dataviews-view-picker-grid__fields",
16460 gap: "xs",
16461 children: regularFields.map((field) => {
16462 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16463 import_components14.Flex,
16464 {
16465 className: "dataviews-view-picker-grid__field",
16466 gap: 1,
16467 justify: "flex-start",
16468 expanded: true,
16469 style: { height: "auto" },
16470 direction: "row",
16471 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, { children: [
16472 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
16473 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16474 import_components14.FlexItem,
16475 {
16476 className: "dataviews-view-picker-grid__field-value",
16477 style: { maxHeight: "none" },
16478 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16479 field.render,
16480 {
16481 item,
16482 field
16483 }
16484 )
16485 }
16486 )
16487 ] })
16488 },
16489 field.id
16490 );
16491 })
16492 }
16493 )
16494 ] })
16495 ]
16496 },
16497 id
16498 );
16499 }
16500 function GridGroup({
16501 groupName,
16502 groupField,
16503 showLabel = true,
16504 children
16505 }) {
16506 const headerId = (0, import_compose6.useInstanceId)(
16507 GridGroup,
16508 "dataviews-view-picker-grid-group__header"
16509 );
16510 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
16511 Stack,
16512 {
16513 direction: "column",
16514 gap: "sm",
16515 role: "group",
16516 "aria-labelledby": headerId,
16517 children: [
16518 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16519 "h3",
16520 {
16521 className: "dataviews-view-picker-grid-group__header",
16522 id: headerId,
16523 children: showLabel ? (0, import_i18n19.sprintf)(
16524 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
16525 (0, import_i18n19.__)("%1$s: %2$s"),
16526 groupField.label,
16527 groupName
16528 ) : groupName
16529 }
16530 ),
16531 children
16532 ]
16533 },
16534 groupName
16535 );
16536 }
16537 function ViewPickerGrid({
16538 actions,
16539 data,
16540 fields,
16541 getItemId,
16542 isLoading,
16543 onChangeSelection,
16544 selection,
16545 view,
16546 className,
16547 empty
16548 }) {
16549 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element61.useContext)(dataviews_context_default);
16550 const titleField = fields.find(
16551 (field) => field.id === view?.titleField
16552 );
16553 const mediaField = fields.find(
16554 (field) => field.id === view?.mediaField
16555 );
16556 const descriptionField = fields.find(
16557 (field) => field.id === view?.descriptionField
16558 );
16559 const otherFields = view.fields ?? [];
16560 const { regularFields, badgeFields } = otherFields.reduce(
16561 (accumulator, fieldId) => {
16562 const field = fields.find((f2) => f2.id === fieldId);
16563 if (!field) {
16564 return accumulator;
16565 }
16566 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
16567 accumulator[key].push(field);
16568 return accumulator;
16569 },
16570 { regularFields: [], badgeFields: [] }
16571 );
16572 const hasData = !!data?.length;
16573 const usedPreviewSize = view.layout?.previewSize;
16574 const isMultiselect = useIsMultiselectPicker(actions);
16575 const size4 = "900px";
16576 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
16577 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
16578 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
16579 const currentPage = view?.page ?? 1;
16580 const perPage = view?.perPage ?? 0;
16581 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
16582 const gridColumns = useGridColumns();
16583 const placeholdersNeeded = usePlaceholdersNeeded(
16584 data,
16585 isInfiniteScroll,
16586 gridColumns
16587 );
16588 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, {
16589 // Render multiple groups.
16590 children: [
16591 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16592 import_components14.Composite,
16593 {
16594 virtualFocus: true,
16595 orientation: "horizontal",
16596 role: "listbox",
16597 "aria-multiselectable": isMultiselect,
16598 className: clsx_default(
16599 "dataviews-view-picker-grid",
16600 className,
16601 {
16602 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
16603 view.layout.density
16604 )
16605 }
16606 ),
16607 "aria-label": itemListLabel,
16608 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16609 Stack,
16610 {
16611 direction: "column",
16612 gap: "lg",
16613 children,
16614 ...props
16615 }
16616 ),
16617 children: Array.from(dataByGroup.entries()).map(
16618 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16619 GridGroup,
16620 {
16621 groupName,
16622 groupField,
16623 showLabel: view.groupBy?.showLabel !== false,
16624 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16625 GridItems,
16626 {
16627 previewSize: usedPreviewSize,
16628 style: {
16629 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
16630 },
16631 "aria-busy": isLoading,
16632 ref: resizeObserverRef,
16633 children: groupItems.map((item) => {
16634 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
16635 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16636 GridItem3,
16637 {
16638 view,
16639 multiselect: isMultiselect,
16640 selection,
16641 onChangeSelection,
16642 getItemId,
16643 item,
16644 mediaField,
16645 titleField,
16646 descriptionField,
16647 regularFields,
16648 badgeFields,
16649 config: {
16650 sizes: size4
16651 },
16652 posinset: posInSet,
16653 setsize: setSize
16654 },
16655 getItemId(item)
16656 );
16657 })
16658 }
16659 )
16660 },
16661 groupName
16662 )
16663 )
16664 }
16665 ),
16666 // Render a single grid with all data.
16667 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
16668 import_components14.Composite,
16669 {
16670 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16671 GridItems,
16672 {
16673 className: clsx_default(
16674 "dataviews-view-picker-grid",
16675 className,
16676 {
16677 [`has-${view.layout?.density}-density`]: view.layout?.density && [
16678 "compact",
16679 "comfortable"
16680 ].includes(view.layout.density)
16681 }
16682 ),
16683 previewSize: usedPreviewSize,
16684 "aria-busy": isLoading,
16685 ref: resizeObserverRef
16686 }
16687 ),
16688 virtualFocus: true,
16689 orientation: "horizontal",
16690 role: "listbox",
16691 "aria-multiselectable": isMultiselect,
16692 "aria-label": itemListLabel,
16693 children: [
16694 Array.from({ length: placeholdersNeeded }).map(
16695 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16696 import_components14.Composite.Item,
16697 {
16698 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16699 Stack,
16700 {
16701 direction: "column",
16702 children,
16703 ...props
16704 }
16705 ),
16706 role: "option",
16707 "aria-hidden": true,
16708 tabIndex: -1,
16709 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
16710 },
16711 `placeholder-${index2}`
16712 )
16713 ),
16714 data.map((item) => {
16715 const posinset = item.position;
16716 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16717 GridItem3,
16718 {
16719 view,
16720 multiselect: isMultiselect,
16721 selection,
16722 onChangeSelection,
16723 getItemId,
16724 item,
16725 mediaField,
16726 titleField,
16727 descriptionField,
16728 regularFields,
16729 badgeFields,
16730 config: {
16731 sizes: size4
16732 },
16733 posinset,
16734 setsize: setSize
16735 },
16736 getItemId(item)
16737 );
16738 })
16739 ]
16740 }
16741 ),
16742 // Render empty state.
16743 !hasData && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16744 "div",
16745 {
16746 className: clsx_default({
16747 "dataviews-loading": isLoading,
16748 "dataviews-no-results": !isLoading
16749 }),
16750 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components14.Spinner, {}) }) : empty
16751 }
16752 ),
16753 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components14.Spinner, {}) })
16754 ]
16755 });
16756 }
16757 var picker_grid_default = ViewPickerGrid;
16758
16759 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
16760 var import_i18n20 = __toESM(require_i18n(), 1);
16761 var import_components15 = __toESM(require_components(), 1);
16762 var import_element62 = __toESM(require_element(), 1);
16763 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
16764 function TableColumnField2({
16765 item,
16766 fields,
16767 column,
16768 align
16769 }) {
16770 const field = fields.find((f2) => f2.id === column);
16771 if (!field) {
16772 return null;
16773 }
16774 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
16775 "dataviews-view-table__cell-align-end": align === "end",
16776 "dataviews-view-table__cell-align-center": align === "center"
16777 });
16778 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(field.render, { item, field }) });
16779 }
16780 function TableRow2({
16781 item,
16782 fields,
16783 id,
16784 view,
16785 titleField,
16786 mediaField,
16787 descriptionField,
16788 selection,
16789 getItemId,
16790 onChangeSelection,
16791 multiselect,
16792 posinset
16793 }) {
16794 const { paginationInfo } = (0, import_element62.useContext)(dataviews_context_default);
16795 const isSelected2 = selection.includes(id);
16796 const [isHovered, setIsHovered] = (0, import_element62.useState)(false);
16797 const elementRef = (0, import_element62.useRef)(null);
16798 useIntersectionObserver(elementRef, posinset);
16799 const {
16800 showTitle = true,
16801 showMedia = true,
16802 showDescription = true,
16803 infiniteScrollEnabled
16804 } = view;
16805 const handleMouseEnter = () => {
16806 setIsHovered(true);
16807 };
16808 const handleMouseLeave = () => {
16809 setIsHovered(false);
16810 };
16811 const columns = view.fields ?? [];
16812 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
16813 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
16814 import_components15.Composite.Item,
16815 {
16816 ref: elementRef,
16817 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16818 "tr",
16819 {
16820 className: clsx_default("dataviews-view-table__row", {
16821 "is-selected": isSelected2,
16822 "is-hovered": isHovered
16823 }),
16824 onMouseEnter: handleMouseEnter,
16825 onMouseLeave: handleMouseLeave,
16826 children,
16827 ...props
16828 }
16829 ),
16830 "aria-selected": isSelected2,
16831 "aria-setsize": paginationInfo.totalItems || void 0,
16832 "aria-posinset": posinset,
16833 role: infiniteScrollEnabled ? "article" : "option",
16834 onMouseDown: (event) => {
16835 if (event.button !== 0) {
16836 return;
16837 }
16838 event.currentTarget.parentElement?.focus({
16839 preventScroll: true
16840 });
16841 },
16842 onClick: () => {
16843 if (isSelected2) {
16844 onChangeSelection(
16845 selection.filter((itemId) => id !== itemId)
16846 );
16847 } else {
16848 const newSelection = multiselect ? [...selection, id] : [id];
16849 onChangeSelection(newSelection);
16850 }
16851 },
16852 children: [
16853 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16854 "td",
16855 {
16856 className: "dataviews-view-table__checkbox-column",
16857 role: "presentation",
16858 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16859 DataViewsSelectionCheckbox,
16860 {
16861 item,
16862 selection,
16863 onChangeSelection,
16864 getItemId,
16865 titleField,
16866 disabled: false,
16867 "aria-hidden": true,
16868 tabIndex: -1
16869 }
16870 ) })
16871 }
16872 ),
16873 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16874 "td",
16875 {
16876 role: "presentation",
16877 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16878 column_primary_default,
16879 {
16880 item,
16881 titleField: showTitle ? titleField : void 0,
16882 mediaField: showMedia ? mediaField : void 0,
16883 descriptionField: showDescription ? descriptionField : void 0,
16884 isItemClickable: () => false
16885 }
16886 )
16887 }
16888 ),
16889 columns.map((column) => {
16890 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
16891 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16892 "td",
16893 {
16894 style: {
16895 width,
16896 maxWidth,
16897 minWidth
16898 },
16899 role: "presentation",
16900 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16901 TableColumnField2,
16902 {
16903 fields,
16904 item,
16905 column,
16906 align
16907 }
16908 )
16909 },
16910 column
16911 );
16912 })
16913 ]
16914 },
16915 id
16916 );
16917 }
16918 function ViewPickerTable({
16919 actions,
16920 data,
16921 fields,
16922 getItemId,
16923 isLoading = false,
16924 onChangeView,
16925 onChangeSelection,
16926 selection,
16927 setOpenedFilter,
16928 view,
16929 className,
16930 empty
16931 }) {
16932 const headerMenuRefs = (0, import_element62.useRef)(/* @__PURE__ */ new Map());
16933 const headerMenuToFocusRef = (0, import_element62.useRef)(void 0);
16934 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element62.useState)();
16935 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
16936 (0, import_element62.useEffect)(() => {
16937 if (headerMenuToFocusRef.current) {
16938 headerMenuToFocusRef.current.focus();
16939 headerMenuToFocusRef.current = void 0;
16940 }
16941 });
16942 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
16943 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
16944 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
16945 const tableNoticeId = (0, import_element62.useId)();
16946 if (nextHeaderMenuToFocus) {
16947 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
16948 setNextHeaderMenuToFocus(void 0);
16949 return;
16950 }
16951 const onHide = (field) => {
16952 const hidden = headerMenuRefs.current.get(field.id);
16953 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
16954 setNextHeaderMenuToFocus(fallback?.node);
16955 };
16956 const hasData = !!data?.length;
16957 const titleField = fields.find((field) => field.id === view.titleField);
16958 const mediaField = fields.find((field) => field.id === view.mediaField);
16959 const descriptionField = fields.find(
16960 (field) => field.id === view.descriptionField
16961 );
16962 const { showTitle = true, showMedia = true, showDescription = true } = view;
16963 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
16964 const columns = view.fields ?? [];
16965 const headerMenuRef = (column, index2) => (node) => {
16966 if (node) {
16967 headerMenuRefs.current.set(column, {
16968 node,
16969 fallback: columns[index2 > 0 ? index2 - 1 : 1]
16970 });
16971 } else {
16972 headerMenuRefs.current.delete(column);
16973 }
16974 };
16975 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_jsx_runtime84.Fragment, { children: [
16976 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
16977 "table",
16978 {
16979 className: clsx_default(
16980 "dataviews-view-table",
16981 "dataviews-view-picker-table",
16982 className,
16983 {
16984 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
16985 view.layout.density
16986 )
16987 }
16988 ),
16989 "aria-busy": isLoading,
16990 "aria-describedby": tableNoticeId,
16991 role: isInfiniteScroll ? "feed" : "listbox",
16992 children: [
16993 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
16994 "tr",
16995 {
16996 className: "dataviews-view-table__row",
16997 role: "presentation",
16998 children: [
16999 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17000 BulkSelectionCheckbox,
17001 {
17002 selection,
17003 onChangeSelection,
17004 data,
17005 actions,
17006 getItemId,
17007 disableSelectAll: isInfiniteScroll
17008 }
17009 ) }),
17010 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17011 column_header_menu_default,
17012 {
17013 ref: headerMenuRef(
17014 titleField.id,
17015 0
17016 ),
17017 fieldId: titleField.id,
17018 view,
17019 fields,
17020 onChangeView,
17021 onHide,
17022 setOpenedFilter,
17023 canMove: false
17024 }
17025 ) }),
17026 columns.map((column, index2) => {
17027 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
17028 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17029 "th",
17030 {
17031 style: {
17032 width,
17033 maxWidth,
17034 minWidth,
17035 textAlign: align
17036 },
17037 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
17038 scope: "col",
17039 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17040 column_header_menu_default,
17041 {
17042 ref: headerMenuRef(column, index2),
17043 fieldId: column,
17044 view,
17045 fields,
17046 onChangeView,
17047 onHide,
17048 setOpenedFilter,
17049 canMove: view.layout?.enableMoving ?? true
17050 }
17051 )
17052 },
17053 column
17054 );
17055 })
17056 ]
17057 }
17058 ) }),
17059 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
17060 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
17061 import_components15.Composite,
17062 {
17063 virtualFocus: true,
17064 orientation: "vertical",
17065 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("tbody", { role: "group" }),
17066 children: [
17067 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17068 "tr",
17069 {
17070 className: "dataviews-view-table__group-header-row",
17071 role: "presentation",
17072 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17073 "td",
17074 {
17075 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
17076 className: "dataviews-view-table__group-header-cell",
17077 role: "presentation",
17078 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n20.sprintf)(
17079 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
17080 (0, import_i18n20.__)("%1$s: %2$s"),
17081 groupField.label,
17082 groupName
17083 )
17084 }
17085 )
17086 }
17087 ),
17088 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17089 TableRow2,
17090 {
17091 item,
17092 fields,
17093 id: getItemId(item) || index2.toString(),
17094 view,
17095 titleField,
17096 mediaField,
17097 descriptionField,
17098 selection,
17099 getItemId,
17100 onChangeSelection,
17101 multiselect: isMultiselect
17102 },
17103 getItemId(item)
17104 ))
17105 ]
17106 },
17107 `group-${groupName}`
17108 )
17109 ) : /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17110 import_components15.Composite,
17111 {
17112 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("tbody", { role: "presentation" }),
17113 virtualFocus: true,
17114 orientation: "vertical",
17115 children: hasData && data.map((item, index2) => {
17116 const itemId = getItemId(item);
17117 const posinset = item.position;
17118 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17119 TableRow2,
17120 {
17121 item,
17122 fields,
17123 id: itemId || index2.toString(),
17124 view,
17125 titleField,
17126 mediaField,
17127 descriptionField,
17128 selection,
17129 getItemId,
17130 onChangeSelection,
17131 multiselect: isMultiselect,
17132 posinset
17133 },
17134 itemId
17135 );
17136 })
17137 }
17138 )
17139 ]
17140 }
17141 ),
17142 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
17143 "div",
17144 {
17145 className: clsx_default({
17146 "dataviews-loading": isLoading,
17147 "dataviews-no-results": !hasData && !isLoading
17148 }),
17149 id: tableNoticeId,
17150 children: [
17151 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_components15.Spinner, {}) }) : empty),
17152 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_components15.Spinner, {}) })
17153 ]
17154 }
17155 )
17156 ] });
17157 }
17158 var picker_table_default = ViewPickerTable;
17159
17160 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
17161 var import_components16 = __toESM(require_components(), 1);
17162 var import_element63 = __toESM(require_element(), 1);
17163 var import_compose7 = __toESM(require_compose(), 1);
17164 var import_i18n21 = __toESM(require_i18n(), 1);
17165 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
17166 function isDefined4(item) {
17167 return !!item;
17168 }
17169 function PickerActivityItem({
17170 view,
17171 multiselect,
17172 selection,
17173 onChangeSelection,
17174 getItemId,
17175 item,
17176 titleField,
17177 mediaField,
17178 descriptionField,
17179 otherFields,
17180 posinset,
17181 setsize
17182 }) {
17183 const elementRef = (0, import_element63.useRef)(null);
17184 useIntersectionObserver(elementRef, posinset);
17185 const { showTitle = true, showMedia = true, showDescription = true } = view;
17186 const id = getItemId(item);
17187 const isSelected2 = selection.includes(id);
17188 const density = view.layout?.density ?? "balanced";
17189 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17190 mediaField.render,
17191 {
17192 item,
17193 field: mediaField,
17194 config: {
17195 sizes: density === "comfortable" ? "32px" : "24px"
17196 }
17197 }
17198 ) : null;
17199 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17200 "span",
17201 {
17202 className: "dataviews-view-picker-activity__item-bullet",
17203 "aria-hidden": "true"
17204 }
17205 ) });
17206 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(titleField.render, { item, field: titleField }) : null;
17207 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
17208 const verticalGap = (0, import_element63.useMemo)(() => {
17209 switch (density) {
17210 case "comfortable":
17211 return "md";
17212 default:
17213 return "sm";
17214 }
17215 }, [density]);
17216 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17217 import_components16.Composite.Item,
17218 {
17219 ref: elementRef,
17220 role: "option",
17221 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
17222 "aria-posinset": posinset,
17223 "aria-setsize": setsize,
17224 "aria-selected": isSelected2,
17225 className: clsx_default(
17226 "dataviews-view-picker-activity__item",
17227 density === "compact" && "is-compact",
17228 density === "balanced" && "is-balanced",
17229 density === "comfortable" && "is-comfortable",
17230 isSelected2 && "is-selected"
17231 ),
17232 onClick: () => {
17233 if (isSelected2) {
17234 onChangeSelection(
17235 selection.filter((itemId) => id !== itemId)
17236 );
17237 } else {
17238 const newSelection = multiselect ? [...selection, id] : [id];
17239 onChangeSelection(newSelection);
17240 }
17241 },
17242 render: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", {}),
17243 children: /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
17244 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17245 Stack,
17246 {
17247 direction: "column",
17248 gap: "xs",
17249 align: "center",
17250 className: "dataviews-view-picker-activity__item-type",
17251 children: renderedMediaField
17252 }
17253 ),
17254 /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
17255 Stack,
17256 {
17257 direction: "column",
17258 gap: verticalGap,
17259 align: "flex-start",
17260 className: "dataviews-view-picker-activity__item-content",
17261 children: [
17262 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
17263 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
17264 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
17265 "div",
17266 {
17267 className: "dataviews-view-picker-activity__item-field",
17268 children: [
17269 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17270 VisuallyHidden,
17271 {
17272 render: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", {}),
17273 className: "dataviews-view-picker-activity__item-field-label",
17274 children: field.label
17275 }
17276 ),
17277 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17278 field.render,
17279 {
17280 item,
17281 field
17282 }
17283 ) })
17284 ]
17285 },
17286 field.id
17287 )) })
17288 ]
17289 }
17290 )
17291 ] })
17292 }
17293 );
17294 }
17295 function PickerActivityGroup({
17296 groupName,
17297 groupField,
17298 showLabel = true,
17299 children
17300 }) {
17301 const headerId = (0, import_compose7.useInstanceId)(
17302 PickerActivityGroup,
17303 "dataviews-view-picker-activity-group__header"
17304 );
17305 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
17306 Stack,
17307 {
17308 direction: "column",
17309 role: "group",
17310 "aria-labelledby": headerId,
17311 className: "dataviews-view-picker-activity-group",
17312 children: [
17313 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17314 "h3",
17315 {
17316 className: "dataviews-view-picker-activity-group__header",
17317 id: headerId,
17318 children: showLabel ? (0, import_i18n21.sprintf)(
17319 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
17320 (0, import_i18n21.__)("%1$s: %2$s"),
17321 groupField.label,
17322 groupName
17323 ) : groupName
17324 }
17325 ),
17326 children
17327 ]
17328 }
17329 );
17330 }
17331 function ViewPickerActivity({
17332 data,
17333 fields,
17334 getItemId,
17335 isLoading,
17336 onChangeSelection,
17337 selection,
17338 view,
17339 actions,
17340 className,
17341 empty
17342 }) {
17343 const { itemListLabel, paginationInfo } = (0, import_element63.useContext)(dataviews_context_default);
17344 const isMultiselect = useIsMultiselectPicker(actions);
17345 const titleField = fields.find(
17346 (field) => field.id === view?.titleField
17347 );
17348 const mediaField = fields.find(
17349 (field) => field.id === view?.mediaField
17350 );
17351 const descriptionField = fields.find(
17352 (field) => field.id === view?.descriptionField
17353 );
17354 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
17355 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
17356 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
17357 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
17358 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
17359 const hasData = !!data?.length;
17360 const isGrouped = !!(groupField && dataByGroup);
17361 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17362 PickerActivityItem,
17363 {
17364 view,
17365 multiselect: isMultiselect,
17366 selection,
17367 onChangeSelection,
17368 getItemId,
17369 item,
17370 titleField,
17371 mediaField,
17372 descriptionField,
17373 otherFields,
17374 posinset: item.position,
17375 setsize
17376 },
17377 getItemId(item)
17378 );
17379 if (!hasData) {
17380 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17381 "div",
17382 {
17383 className: clsx_default({
17384 "dataviews-loading": isLoading,
17385 "dataviews-no-results": !isLoading
17386 }),
17387 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_components16.Spinner, {}) }) : empty
17388 }
17389 );
17390 }
17391 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_jsx_runtime85.Fragment, { children: [
17392 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17393 import_components16.Composite,
17394 {
17395 virtualFocus: true,
17396 orientation: "vertical",
17397 role: "listbox",
17398 "aria-multiselectable": isMultiselect,
17399 "aria-label": itemListLabel,
17400 "aria-busy": isLoading,
17401 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
17402 className: clsx_default(
17403 "dataviews-view-picker-activity",
17404 className
17405 ),
17406 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
17407 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17408 PickerActivityGroup,
17409 {
17410 groupName,
17411 groupField,
17412 showLabel: view.groupBy?.showLabel !== false,
17413 children: groupItems.map(renderItem)
17414 },
17415 groupName
17416 )
17417 ) : data.map(renderItem)
17418 }
17419 ),
17420 isLoading && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_components16.Spinner, {}) })
17421 ] });
17422 }
17423
17424 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
17425 var import_components17 = __toESM(require_components(), 1);
17426 var import_i18n22 = __toESM(require_i18n(), 1);
17427 var import_element64 = __toESM(require_element(), 1);
17428 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
17429 function DensityPicker() {
17430 const context = (0, import_element64.useContext)(dataviews_context_default);
17431 const view = context.view;
17432 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
17433 import_components17.__experimentalToggleGroupControl,
17434 {
17435 size: "__unstable-large",
17436 label: (0, import_i18n22.__)("Density"),
17437 value: view.layout?.density || "balanced",
17438 onChange: (value) => {
17439 context.onChangeView({
17440 ...view,
17441 layout: {
17442 ...view.layout,
17443 density: value
17444 }
17445 });
17446 },
17447 isBlock: true,
17448 children: [
17449 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
17450 import_components17.__experimentalToggleGroupControlOption,
17451 {
17452 value: "comfortable",
17453 label: (0, import_i18n22._x)(
17454 "Comfortable",
17455 "Density option for DataView layout"
17456 )
17457 },
17458 "comfortable"
17459 ),
17460 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
17461 import_components17.__experimentalToggleGroupControlOption,
17462 {
17463 value: "balanced",
17464 label: (0, import_i18n22._x)("Balanced", "Density option for DataView layout")
17465 },
17466 "balanced"
17467 ),
17468 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
17469 import_components17.__experimentalToggleGroupControlOption,
17470 {
17471 value: "compact",
17472 label: (0, import_i18n22._x)("Compact", "Density option for DataView layout")
17473 },
17474 "compact"
17475 )
17476 ]
17477 }
17478 );
17479 }
17480
17481 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
17482 var import_components18 = __toESM(require_components(), 1);
17483 var import_i18n23 = __toESM(require_i18n(), 1);
17484 var import_element65 = __toESM(require_element(), 1);
17485 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
17486 var imageSizes2 = [
17487 {
17488 value: 120,
17489 breakpoint: 1
17490 },
17491 {
17492 value: 170,
17493 breakpoint: 1
17494 },
17495 {
17496 value: 230,
17497 breakpoint: 1
17498 },
17499 {
17500 value: 290,
17501 breakpoint: 1112
17502 // at minimum image width, 4 images display at this container size
17503 },
17504 {
17505 value: 350,
17506 breakpoint: 1636
17507 // at minimum image width, 6 images display at this container size
17508 },
17509 {
17510 value: 430,
17511 breakpoint: 588
17512 // at minimum image width, 2 images display at this container size
17513 }
17514 ];
17515 function PreviewSizePicker() {
17516 const context = (0, import_element65.useContext)(dataviews_context_default);
17517 const view = context.view;
17518 const breakValues = imageSizes2.filter((size4) => {
17519 return context.containerWidth >= size4.breakpoint;
17520 });
17521 const layoutPreviewSize = view.layout?.previewSize ?? 230;
17522 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
17523 const marks = breakValues.map((size4, index2) => {
17524 return {
17525 value: index2
17526 };
17527 });
17528 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
17529 import_components18.RangeControl,
17530 {
17531 __next40pxDefaultSize: true,
17532 showTooltip: false,
17533 label: (0, import_i18n23.__)("Preview size"),
17534 value: previewSizeToUse,
17535 min: 0,
17536 max: breakValues.length - 1,
17537 withInputField: false,
17538 onChange: (value = 0) => {
17539 context.onChangeView({
17540 ...view,
17541 layout: {
17542 ...view.layout,
17543 previewSize: breakValues[value].value
17544 }
17545 });
17546 },
17547 step: 1,
17548 marks
17549 }
17550 );
17551 }
17552
17553 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
17554 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
17555 function GridConfigOptions() {
17556 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [
17557 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(DensityPicker, {}),
17558 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(PreviewSizePicker, {})
17559 ] });
17560 }
17561
17562 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
17563 var VIEW_LAYOUTS = [
17564 {
17565 type: LAYOUT_TABLE,
17566 label: (0, import_i18n24.__)("Table"),
17567 component: table_default,
17568 icon: block_table_default,
17569 viewConfigOptions: DensityPicker
17570 },
17571 {
17572 type: LAYOUT_GRID,
17573 label: (0, import_i18n24.__)("Grid"),
17574 component: grid_default,
17575 icon: category_default,
17576 viewConfigOptions: GridConfigOptions
17577 },
17578 {
17579 type: LAYOUT_LIST,
17580 label: (0, import_i18n24.__)("List"),
17581 component: ViewList,
17582 icon: (0, import_i18n24.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
17583 viewConfigOptions: DensityPicker
17584 },
17585 {
17586 type: LAYOUT_ACTIVITY,
17587 label: (0, import_i18n24.__)("Activity"),
17588 component: ViewActivity,
17589 icon: scheduled_default,
17590 viewConfigOptions: DensityPicker
17591 },
17592 {
17593 type: LAYOUT_PICKER_GRID,
17594 label: (0, import_i18n24.__)("Grid"),
17595 component: picker_grid_default,
17596 icon: category_default,
17597 viewConfigOptions: GridConfigOptions,
17598 isPicker: true
17599 },
17600 {
17601 type: LAYOUT_PICKER_TABLE,
17602 label: (0, import_i18n24.__)("Table"),
17603 component: picker_table_default,
17604 icon: block_table_default,
17605 viewConfigOptions: DensityPicker,
17606 isPicker: true
17607 },
17608 {
17609 type: LAYOUT_PICKER_ACTIVITY,
17610 label: (0, import_i18n24.__)("Activity"),
17611 component: ViewPickerActivity,
17612 icon: scheduled_default,
17613 viewConfigOptions: DensityPicker,
17614 isPicker: true
17615 }
17616 ];
17617
17618 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
17619 var import_element73 = __toESM(require_element(), 1);
17620
17621 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
17622 var import_components21 = __toESM(require_components(), 1);
17623 var import_i18n27 = __toESM(require_i18n(), 1);
17624 var import_element70 = __toESM(require_element(), 1);
17625
17626 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
17627 var import_react16 = __toESM(require_react(), 1);
17628 var FocusableContext = (0, import_react16.createContext)(true);
17629
17630 // node_modules/@ariakit/utils/dist/index.js
17631 function toArray(arg) {
17632 if (Array.isArray(arg)) return arg;
17633 return typeof arg !== "undefined" ? [arg] : [];
17634 }
17635 function flatten2DArray(array) {
17636 const flattened = [];
17637 for (const row of array) flattened.push(...row);
17638 return flattened;
17639 }
17640 function reverseArray(array) {
17641 return array.slice().reverse();
17642 }
17643 var canUseDOM = checkIsBrowser();
17644 function checkIsBrowser() {
17645 return typeof window !== "undefined" && !!window.document?.createElement;
17646 }
17647 function getDocument(node) {
17648 if (!node) return document;
17649 if ("self" in node) return node.document;
17650 return node.ownerDocument || document;
17651 }
17652 function getActiveElement(node, activeDescendant = false) {
17653 const { activeElement: activeElement2 } = getDocument(node);
17654 if (!activeElement2?.nodeName) return null;
17655 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
17656 if (activeDescendant) {
17657 const id = activeElement2.getAttribute("aria-activedescendant");
17658 if (id) {
17659 const element = getDocument(activeElement2).getElementById(id);
17660 if (element) return element;
17661 }
17662 }
17663 return activeElement2;
17664 }
17665 function contains2(parent, child) {
17666 return parent === child || parent.contains(child);
17667 }
17668 function isElement2(target) {
17669 return target?.nodeType === 1;
17670 }
17671 function isNode2(target) {
17672 return typeof target?.nodeType === "number";
17673 }
17674 function isFrame(element) {
17675 return element.tagName === "IFRAME";
17676 }
17677 function isButton(element) {
17678 const tagName = element.tagName.toLowerCase();
17679 if (tagName === "button") return true;
17680 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
17681 return false;
17682 }
17683 var buttonInputTypes = [
17684 "button",
17685 "color",
17686 "file",
17687 "image",
17688 "reset",
17689 "submit"
17690 ];
17691 function isVisible(element) {
17692 if (typeof element.checkVisibility === "function") return element.checkVisibility();
17693 const htmlElement = element;
17694 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
17695 }
17696 function isTextField(element) {
17697 try {
17698 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
17699 const isTextArea = element.tagName === "TEXTAREA";
17700 return isTextInput || isTextArea || false;
17701 } catch (_error) {
17702 return false;
17703 }
17704 }
17705 function isTextbox(element) {
17706 return element.isContentEditable || isTextField(element);
17707 }
17708 function getTextboxValue(element) {
17709 if (isTextField(element)) return element.value;
17710 if (element.isContentEditable) {
17711 const range = getDocument(element).createRange();
17712 range.selectNodeContents(element);
17713 return range.toString();
17714 }
17715 return "";
17716 }
17717 function getTextboxSelection(element) {
17718 let start = 0;
17719 let end = 0;
17720 if (isTextField(element)) {
17721 start = element.selectionStart || 0;
17722 end = element.selectionEnd || 0;
17723 } else if (element.isContentEditable) {
17724 const selection = getDocument(element).getSelection();
17725 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
17726 const range = selection.getRangeAt(0);
17727 const nextRange = range.cloneRange();
17728 nextRange.selectNodeContents(element);
17729 nextRange.setEnd(range.startContainer, range.startOffset);
17730 start = nextRange.toString().length;
17731 nextRange.setEnd(range.endContainer, range.endOffset);
17732 end = nextRange.toString().length;
17733 }
17734 }
17735 return {
17736 start,
17737 end
17738 };
17739 }
17740 function getPopupRole(element, fallback) {
17741 const allowedPopupRoles = [
17742 "dialog",
17743 "menu",
17744 "listbox",
17745 "tree",
17746 "grid"
17747 ];
17748 const role = element?.getAttribute("role");
17749 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
17750 return fallback;
17751 }
17752 function getScrollingElement(element) {
17753 if (!element) return null;
17754 const isScrollableOverflow = (overflow) => {
17755 if (overflow === "auto") return true;
17756 if (overflow === "scroll") return true;
17757 return false;
17758 };
17759 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
17760 const { overflowY } = getComputedStyle(element);
17761 if (isScrollableOverflow(overflowY)) return element;
17762 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
17763 const { overflowX } = getComputedStyle(element);
17764 if (isScrollableOverflow(overflowX)) return element;
17765 }
17766 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
17767 }
17768 function setSelectionRange(element, ...args) {
17769 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
17770 }
17771 function sortBasedOnDOMPosition(items, getElement) {
17772 const pairs = items.map((item, index2) => [index2, item]);
17773 let isOrderDifferent = false;
17774 pairs.sort(([indexA, a2], [indexB, b2]) => {
17775 const elementA = getElement(a2);
17776 const elementB = getElement(b2);
17777 if (elementA === elementB) return 0;
17778 if (!elementA || !elementB) return 0;
17779 if (isElementPreceding(elementA, elementB)) {
17780 if (indexA > indexB) isOrderDifferent = true;
17781 return -1;
17782 }
17783 if (indexA < indexB) isOrderDifferent = true;
17784 return 1;
17785 });
17786 if (isOrderDifferent) return pairs.map(([_, item]) => item);
17787 return items;
17788 }
17789 function isElementPreceding(a2, b2) {
17790 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
17791 }
17792 function isTouchDevice() {
17793 return canUseDOM && !!navigator.maxTouchPoints;
17794 }
17795 function isApple() {
17796 if (!canUseDOM) return false;
17797 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
17798 }
17799 function isSafari2() {
17800 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
17801 }
17802 function isFirefox2() {
17803 return canUseDOM && /firefox\//i.test(navigator.userAgent);
17804 }
17805 function isPortalEvent(event) {
17806 const { currentTarget, target } = event;
17807 if (!currentTarget) return false;
17808 if (!isNode2(target)) return true;
17809 return !contains2(currentTarget, target);
17810 }
17811 function isSelfTarget(event) {
17812 return event.target === event.currentTarget;
17813 }
17814 function isOpeningInNewTab(event) {
17815 const element = event.currentTarget;
17816 if (!element) return false;
17817 const isAppleDevice = isApple();
17818 if (isAppleDevice && !event.metaKey) return false;
17819 if (!isAppleDevice && !event.ctrlKey) return false;
17820 const tagName = element.tagName.toLowerCase();
17821 if (tagName === "a") return true;
17822 if (tagName === "button" && element.type === "submit") return true;
17823 if (tagName === "input" && element.type === "submit") return true;
17824 return false;
17825 }
17826 function isDownloading(event) {
17827 const element = event.currentTarget;
17828 if (!element) return false;
17829 const tagName = element.tagName.toLowerCase();
17830 if (!event.altKey) return false;
17831 if (tagName === "a") return true;
17832 if (tagName === "button" && element.type === "submit") return true;
17833 if (tagName === "input" && element.type === "submit") return true;
17834 return false;
17835 }
17836 function fireBlurEvent(element, eventInit) {
17837 const event = new FocusEvent("blur", eventInit);
17838 const defaultAllowed = element.dispatchEvent(event);
17839 const bubbleInit = {
17840 ...eventInit,
17841 bubbles: true
17842 };
17843 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
17844 return defaultAllowed;
17845 }
17846 function fireKeyboardEvent(element, type, eventInit) {
17847 const event = new KeyboardEvent(type, eventInit);
17848 return element.dispatchEvent(event);
17849 }
17850 function fireClickEvent(element, eventInit) {
17851 const event = new MouseEvent("click", eventInit);
17852 return element.dispatchEvent(event);
17853 }
17854 function isFocusEventOutside(event, container) {
17855 const containerElement = container || event.currentTarget;
17856 const relatedTarget = event.relatedTarget;
17857 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
17858 }
17859 function queueBeforeEvent(element, type, callback, timeout) {
17860 const createTimer = (callback2) => {
17861 if (timeout) {
17862 const timerId2 = setTimeout(callback2, timeout);
17863 return () => clearTimeout(timerId2);
17864 }
17865 const timerId = requestAnimationFrame(callback2);
17866 return () => cancelAnimationFrame(timerId);
17867 };
17868 const cancelTimer = createTimer(() => {
17869 element.removeEventListener(type, callSync, true);
17870 callback();
17871 });
17872 const callSync = () => {
17873 cancelTimer();
17874 callback();
17875 };
17876 element.addEventListener(type, callSync, {
17877 once: true,
17878 capture: true
17879 });
17880 return cancelTimer;
17881 }
17882 function addGlobalEventListener(type, listener, options, scope = window) {
17883 const children = [];
17884 try {
17885 scope.document.addEventListener(type, listener, options);
17886 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
17887 } catch {
17888 }
17889 const removeEventListener = () => {
17890 try {
17891 scope.document.removeEventListener(type, listener, options);
17892 } catch {
17893 }
17894 for (const remove of children) remove();
17895 };
17896 return removeEventListener;
17897 }
17898 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'])";
17899 function isFocusable(element) {
17900 if (!element.matches(selector)) return false;
17901 if (!isVisible(element)) return false;
17902 if (element.closest("[inert]")) return false;
17903 return true;
17904 }
17905 function hasFocus(element) {
17906 const activeElement2 = getActiveElement(element);
17907 if (!activeElement2) return false;
17908 if (activeElement2 === element) return true;
17909 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
17910 if (!activeDescendant) return false;
17911 return activeDescendant === element.id;
17912 }
17913 function hasFocusWithin(element) {
17914 const activeElement2 = getActiveElement(element);
17915 if (!activeElement2) return false;
17916 if (contains2(element, activeElement2)) return true;
17917 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
17918 if (!activeDescendant) return false;
17919 if (!("id" in element)) return false;
17920 if (activeDescendant === element.id) return true;
17921 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
17922 }
17923 function focusIntoView(element, options) {
17924 if (!("scrollIntoView" in element)) element.focus();
17925 else {
17926 element.focus({ preventScroll: true });
17927 element.scrollIntoView({
17928 block: "nearest",
17929 inline: "nearest",
17930 ...options
17931 });
17932 }
17933 }
17934 function noop4(..._) {
17935 }
17936 function hasOwnProperty(object, prop) {
17937 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
17938 return Object.prototype.hasOwnProperty.call(object, prop);
17939 }
17940 function chain(...fns) {
17941 return (...args) => {
17942 for (const fn of fns) if (typeof fn === "function") fn(...args);
17943 };
17944 }
17945 function normalizeString(str) {
17946 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
17947 }
17948 function omit(object, keys) {
17949 const result = { ...object };
17950 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
17951 return result;
17952 }
17953 function pick(object, paths) {
17954 const result = {};
17955 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
17956 return result;
17957 }
17958 function identity(value) {
17959 return value;
17960 }
17961 function invariant(condition, message2) {
17962 if (condition) return;
17963 if (typeof message2 !== "string") throw new Error("Invariant failed");
17964 throw new Error(message2);
17965 }
17966 function getKeys(obj) {
17967 return Object.keys(obj);
17968 }
17969 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
17970 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
17971 if (result == null) return false;
17972 return !result;
17973 }
17974 function disabledFromProps(props) {
17975 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
17976 }
17977 function removeUndefinedValues(obj) {
17978 const result = {};
17979 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
17980 return result;
17981 }
17982 function defaultValue(...values) {
17983 for (const value of values) if (value !== void 0) return value;
17984 }
17985 function createUndoCallback(callback) {
17986 return async () => {
17987 const redo = await callback?.();
17988 return createUndoCallback(async () => {
17989 await redo?.();
17990 return callback;
17991 });
17992 };
17993 }
17994 var UndoManager = createUndoManager();
17995 function createUndoManager({ limit = 100 } = {}) {
17996 const undoStack = [];
17997 let redoStack = [];
17998 let currentGroup = null;
17999 const canUndo = () => undoStack.length > 0;
18000 const canRedo = () => redoStack.length > 0;
18001 const undo = async () => {
18002 if (!canUndo()) return;
18003 currentGroup = null;
18004 redoStack.push(await undoStack.pop()?.());
18005 };
18006 const redo = async () => {
18007 if (!canRedo()) return;
18008 currentGroup = null;
18009 undoStack.push(await redoStack.pop()?.());
18010 };
18011 const execute = async (callback, group) => {
18012 if (!callback) return;
18013 while (undoStack.length > limit) undoStack.shift();
18014 const sameGroup = group === currentGroup;
18015 currentGroup = group ?? null;
18016 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
18017 const undoCallback = await callback();
18018 if (!undoCallback) return;
18019 redoStack = [];
18020 const currentUndo = undoStack[nextIndex];
18021 undoStack[nextIndex] = createUndoCallback(async () => {
18022 await undoCallback?.();
18023 const currentRedo = await currentUndo?.();
18024 return async () => {
18025 await currentRedo?.();
18026 await callback?.();
18027 };
18028 });
18029 };
18030 return {
18031 canUndo,
18032 canRedo,
18033 undo,
18034 redo,
18035 execute
18036 };
18037 }
18038
18039 // node_modules/@ariakit/react-utils/dist/index.js
18040 var React58 = __toESM(require_react(), 1);
18041 var import_react17 = __toESM(require_react(), 1);
18042 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
18043 function setRef(ref, value) {
18044 if (typeof ref === "function") ref(value);
18045 else if (ref) ref.current = value;
18046 }
18047 function isValidElementWithRef(element) {
18048 if (!element) return false;
18049 if (!(0, import_react17.isValidElement)(element)) return false;
18050 if ("ref" in element.props) return true;
18051 if ("ref" in element) return true;
18052 return false;
18053 }
18054 function getRefProperty(element) {
18055 if (!isValidElementWithRef(element)) return null;
18056 return { ...element.props }.ref || element.ref;
18057 }
18058 function mergeProps2(base, overrides) {
18059 const props = { ...base };
18060 for (const key in overrides) {
18061 if (!hasOwnProperty(overrides, key)) continue;
18062 if (key === "className") {
18063 const prop = "className";
18064 const baseClass = base[prop];
18065 const overrideClass = overrides[prop];
18066 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
18067 else props[prop] = overrideClass || baseClass;
18068 continue;
18069 }
18070 if (key === "style") {
18071 const prop = "style";
18072 props[prop] = base[prop] ? {
18073 ...base[prop],
18074 ...overrides[prop]
18075 } : overrides[prop];
18076 continue;
18077 }
18078 const overrideValue = overrides[key];
18079 if (key.startsWith("on")) {
18080 if (typeof overrideValue !== "function") continue;
18081 const baseValue = base[key];
18082 if (typeof baseValue === "function") {
18083 props[key] = (...args) => {
18084 overrideValue(...args);
18085 baseValue(...args);
18086 };
18087 continue;
18088 }
18089 }
18090 props[key] = overrideValue;
18091 }
18092 return props;
18093 }
18094 var _React = { ...React58 };
18095 var useReactId = _React.useId;
18096 var useReactDeferredValue = _React.useDeferredValue;
18097 var useReactInsertionEffect = _React.useInsertionEffect;
18098 var useSafeLayoutEffect = canUseDOM ? import_react17.useLayoutEffect : import_react17.useEffect;
18099 function useInitialValue(value) {
18100 const [initialValue] = (0, import_react17.useState)(value);
18101 return initialValue;
18102 }
18103 function useLiveRef(value) {
18104 const ref = (0, import_react17.useRef)(value);
18105 useSafeLayoutEffect(() => {
18106 ref.current = value;
18107 });
18108 return ref;
18109 }
18110 function useEvent(callback) {
18111 const ref = (0, import_react17.useRef)(() => {
18112 throw new Error("Cannot call an event handler while rendering.");
18113 });
18114 if (useReactInsertionEffect) useReactInsertionEffect(() => {
18115 ref.current = callback;
18116 });
18117 else ref.current = callback;
18118 return (0, import_react17.useCallback)((...args) => ref.current?.(...args), []);
18119 }
18120 function useTransactionState(callback) {
18121 const [state, setState] = (0, import_react17.useState)(null);
18122 useSafeLayoutEffect(() => {
18123 if (state == null) return;
18124 if (!callback) return;
18125 let prevState = null;
18126 callback((prev) => {
18127 prevState = prev;
18128 return state;
18129 });
18130 return () => {
18131 callback(prevState);
18132 };
18133 }, [state, callback]);
18134 return [state, setState];
18135 }
18136 function useMergeRefs(...refs) {
18137 return (0, import_react17.useMemo)(() => {
18138 if (!refs.some(Boolean)) return;
18139 return (value) => {
18140 for (const ref of refs) setRef(ref, value);
18141 };
18142 }, refs);
18143 }
18144 function useId5(defaultId) {
18145 if (useReactId) {
18146 const reactId = useReactId();
18147 if (defaultId) return defaultId;
18148 return reactId;
18149 }
18150 const [id, setId] = (0, import_react17.useState)(defaultId);
18151 useSafeLayoutEffect(() => {
18152 if (defaultId || id) return;
18153 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
18154 }, [defaultId, id]);
18155 return defaultId || id;
18156 }
18157 function useTagName(refOrElement, type) {
18158 const stringOrUndefined = (type2) => {
18159 if (typeof type2 !== "string") return;
18160 return type2;
18161 };
18162 const [tagName, setTagName] = (0, import_react17.useState)(() => stringOrUndefined(type));
18163 useSafeLayoutEffect(() => {
18164 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
18165 }, [refOrElement, type]);
18166 return tagName;
18167 }
18168 function useAttribute(refOrElement, attributeName, defaultValue2) {
18169 const initialValue = useInitialValue(defaultValue2);
18170 const [attribute, setAttribute] = (0, import_react17.useState)(initialValue);
18171 (0, import_react17.useEffect)(() => {
18172 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
18173 if (!element) return;
18174 const callback = () => {
18175 const value = element.getAttribute(attributeName);
18176 setAttribute(value == null ? initialValue : value);
18177 };
18178 const observer = new MutationObserver(callback);
18179 observer.observe(element, { attributeFilter: [attributeName] });
18180 callback();
18181 return () => observer.disconnect();
18182 }, [
18183 refOrElement,
18184 attributeName,
18185 initialValue
18186 ]);
18187 return attribute;
18188 }
18189 function useUpdateEffect(effect, deps) {
18190 const mounted = (0, import_react17.useRef)(false);
18191 (0, import_react17.useEffect)(() => {
18192 if (mounted.current) return effect();
18193 mounted.current = true;
18194 }, deps);
18195 (0, import_react17.useEffect)(() => () => {
18196 mounted.current = false;
18197 }, []);
18198 }
18199 function useUpdateLayoutEffect(effect, deps) {
18200 const mounted = (0, import_react17.useRef)(false);
18201 useSafeLayoutEffect(() => {
18202 if (mounted.current) return effect();
18203 mounted.current = true;
18204 }, deps);
18205 useSafeLayoutEffect(() => () => {
18206 mounted.current = false;
18207 }, []);
18208 }
18209 function useForceUpdate() {
18210 return (0, import_react17.useReducer)(() => [], []);
18211 }
18212 function useBooleanEvent(booleanOrCallback) {
18213 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
18214 }
18215 function useWrapElement(props, callback, deps = []) {
18216 const wrapElement = (0, import_react17.useCallback)((element) => {
18217 if (props.wrapElement) element = props.wrapElement(element);
18218 return callback(element);
18219 }, [...deps, props.wrapElement]);
18220 return {
18221 ...props,
18222 wrapElement
18223 };
18224 }
18225 function useMetadataProps(props, key, value) {
18226 const parent = props.onLoadedMetadataCapture;
18227 const onLoadedMetadataCapture = (0, import_react17.useMemo)(() => {
18228 return Object.assign(() => {
18229 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
18230 }, [
18231 parent,
18232 key,
18233 value
18234 ]);
18235 return [parent?.[key], { onLoadedMetadataCapture }];
18236 }
18237 var hasInstalledGlobalEventListeners = false;
18238 function useIsMouseMoving() {
18239 (0, import_react17.useEffect)(() => {
18240 if (hasInstalledGlobalEventListeners) return;
18241 addGlobalEventListener("mousemove", setMouseMoving, true);
18242 addGlobalEventListener("mousedown", resetMouseMoving, true);
18243 addGlobalEventListener("mouseup", resetMouseMoving, true);
18244 addGlobalEventListener("keydown", resetMouseMoving, true);
18245 addGlobalEventListener("scroll", resetMouseMoving, true);
18246 hasInstalledGlobalEventListeners = true;
18247 }, []);
18248 return useEvent(() => mouseMoving);
18249 }
18250 var mouseMoving = false;
18251 var previousScreenX = 0;
18252 var previousScreenY = 0;
18253 function hasMouseMovement(event) {
18254 const movementX = event.movementX || event.screenX - previousScreenX;
18255 const movementY = event.movementY || event.screenY - previousScreenY;
18256 previousScreenX = event.screenX;
18257 previousScreenY = event.screenY;
18258 return movementX || movementY || false;
18259 }
18260 function setMouseMoving(event) {
18261 if (!hasMouseMovement(event)) return;
18262 mouseMoving = true;
18263 }
18264 function resetMouseMoving() {
18265 mouseMoving = false;
18266 }
18267 function forwardRef49(render4) {
18268 const Role = React58.forwardRef((props, ref) => render4({
18269 ...props,
18270 ref
18271 }));
18272 Role.displayName = render4.displayName || render4.name;
18273 return Role;
18274 }
18275 function memo3(Component, propsAreEqual) {
18276 return React58.memo(Component, propsAreEqual);
18277 }
18278 function createElement3(Type, props) {
18279 const { wrapElement, render: render4, ...rest } = props;
18280 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
18281 let element;
18282 if (React58.isValidElement(render4)) {
18283 const renderProps = {
18284 ...render4.props,
18285 ref: mergedRef
18286 };
18287 element = React58.cloneElement(render4, mergeProps2(rest, renderProps));
18288 } else if (render4) element = render4(rest);
18289 else element = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Type, { ...rest });
18290 if (wrapElement) return wrapElement(element);
18291 return element;
18292 }
18293 function createHook(useProps) {
18294 const useRole = (props = {}) => {
18295 return useProps(props);
18296 };
18297 useRole.displayName = useProps.name;
18298 return useRole;
18299 }
18300 function createStoreContext(providers = [], scopedProviders = []) {
18301 const context = React58.createContext(void 0);
18302 const scopedContext = React58.createContext(void 0);
18303 const useContext47 = () => React58.useContext(context);
18304 const useScopedContext = (onlyScoped = false) => {
18305 const scoped = React58.useContext(scopedContext);
18306 const store = useContext47();
18307 if (onlyScoped) return scoped;
18308 return scoped || store;
18309 };
18310 const useProviderContext = () => {
18311 const scoped = React58.useContext(scopedContext);
18312 const store = useContext47();
18313 if (scoped && scoped === store) return;
18314 return store;
18315 };
18316 const ContextProvider = (props) => {
18317 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Provider2, {
18318 ...props,
18319 children
18320 }), /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(context.Provider, { ...props }));
18321 };
18322 const ScopedContextProvider = (props) => {
18323 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(ContextProvider, {
18324 ...props,
18325 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Provider2, {
18326 ...props,
18327 children
18328 }), /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(scopedContext.Provider, { ...props }))
18329 });
18330 };
18331 return {
18332 context,
18333 scopedContext,
18334 useContext: useContext47,
18335 useScopedContext,
18336 useProviderContext,
18337 ContextProvider,
18338 ScopedContextProvider
18339 };
18340 }
18341
18342 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
18343 var import_react18 = __toESM(require_react(), 1);
18344 var TagName = "div";
18345 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
18346 var isSafariBrowser = isSafari2();
18347 var alwaysFocusVisibleInputTypes = [
18348 "text",
18349 "search",
18350 "url",
18351 "tel",
18352 "email",
18353 "password",
18354 "number",
18355 "date",
18356 "month",
18357 "week",
18358 "time",
18359 "datetime",
18360 "datetime-local"
18361 ];
18362 function isAlwaysFocusVisible(element) {
18363 const { tagName, readOnly, type } = element;
18364 if (tagName === "TEXTAREA" && !readOnly) return true;
18365 if (tagName === "SELECT" && !readOnly) return true;
18366 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
18367 if (element.isContentEditable) return true;
18368 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
18369 return false;
18370 }
18371 function isNativeTabbable(tagName) {
18372 if (!tagName) return true;
18373 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
18374 }
18375 function supportsDisabledAttribute(tagName) {
18376 if (!tagName) return true;
18377 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
18378 }
18379 var buttonInputTypes2 = [
18380 "button",
18381 "color",
18382 "file",
18383 "image",
18384 "reset",
18385 "submit"
18386 ];
18387 function needsSafariTabIndex(tagName, inputType) {
18388 if (tagName === "button") return true;
18389 if (tagName === "input" && inputType) {
18390 if (inputType === "checkbox" || inputType === "radio") return true;
18391 return buttonInputTypes2.includes(inputType);
18392 }
18393 return false;
18394 }
18395 function isNativeSubmitControl(element) {
18396 if (element.tagName === "BUTTON") {
18397 const { type } = element;
18398 return type === "submit";
18399 }
18400 if (element.tagName === "INPUT") {
18401 const { type } = element;
18402 return type === "submit" || type === "image";
18403 }
18404 return false;
18405 }
18406 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
18407 if (!focusable2) return tabIndexProp;
18408 if (trulyDisabled) {
18409 if (nativeTabbable && !supportsDisabled) return -1;
18410 return;
18411 }
18412 if (nativeTabbable) {
18413 if (safariTabIndex && tabIndexProp == null) return 0;
18414 return tabIndexProp;
18415 }
18416 return tabIndexProp ?? 0;
18417 }
18418 function useDisableEvent(onEvent, disabled2) {
18419 return useEvent((event) => {
18420 onEvent?.(event);
18421 if (event.defaultPrevented) return;
18422 if (disabled2) {
18423 event.stopPropagation();
18424 event.preventDefault();
18425 }
18426 });
18427 }
18428 var hasInstalledGlobalEventListeners2 = false;
18429 var isKeyboardModality = true;
18430 function onGlobalMouseDown(event) {
18431 const target = event.target;
18432 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
18433 }
18434 function onGlobalKeyDown(event) {
18435 if (event.metaKey) return;
18436 if (event.ctrlKey) return;
18437 if (event.altKey) return;
18438 isKeyboardModality = true;
18439 }
18440 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
18441 const ref = (0, import_react18.useRef)(null);
18442 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
18443 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
18444 (0, import_react18.useEffect)(() => {
18445 if (!focusable2) return;
18446 if (hasInstalledGlobalEventListeners2) return;
18447 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
18448 addGlobalEventListener("keydown", onGlobalKeyDown, true);
18449 hasInstalledGlobalEventListeners2 = true;
18450 }, [focusable2]);
18451 const disabled2 = focusable2 && disabledFromProps(props);
18452 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
18453 const [focusVisible, setFocusVisible] = (0, import_react18.useState)(false);
18454 const focusVisibleRef = (0, import_react18.useRef)(false);
18455 const nativeSubmitObserverCleanupRef = (0, import_react18.useRef)(null);
18456 const cleanupFocusVisible = useEvent((element) => {
18457 nativeSubmitObserverCleanupRef.current?.();
18458 nativeSubmitObserverCleanupRef.current = null;
18459 focusVisibleRef.current = false;
18460 element?.removeAttribute("data-focus-visible");
18461 });
18462 (0, import_react18.useEffect)(() => {
18463 if (!focusable2) return;
18464 if (!trulyDisabled) return;
18465 cleanupFocusVisible(ref.current);
18466 if (focusVisible) setFocusVisible(false);
18467 }, [
18468 focusable2,
18469 trulyDisabled,
18470 focusVisible,
18471 cleanupFocusVisible
18472 ]);
18473 (0, import_react18.useEffect)(() => {
18474 if (!focusable2) return;
18475 if (!focusVisible) return;
18476 const element = ref.current;
18477 if (!element) return;
18478 if (typeof IntersectionObserver === "undefined") return;
18479 const observer = new IntersectionObserver(() => {
18480 if (!isFocusable(element)) {
18481 focusVisibleRef.current = false;
18482 setFocusVisible(false);
18483 }
18484 });
18485 observer.observe(element);
18486 return () => observer.disconnect();
18487 }, [focusable2, focusVisible]);
18488 (0, import_react18.useEffect)(() => {
18489 return () => nativeSubmitObserverCleanupRef.current?.();
18490 }, []);
18491 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
18492 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
18493 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
18494 const handleFocusVisible = (event, currentTarget) => {
18495 if (currentTarget) event.currentTarget = currentTarget;
18496 if (!focusable2) return;
18497 const element = event.currentTarget;
18498 if (!element) return;
18499 if (!hasFocus(element)) return;
18500 onFocusVisible?.(event);
18501 if (event.defaultPrevented) return;
18502 element.dataset.focusVisible = "true";
18503 focusVisibleRef.current = true;
18504 if (isNativeSubmitControl(element)) {
18505 nativeSubmitObserverCleanupRef.current?.();
18506 nativeSubmitObserverCleanupRef.current = null;
18507 if (typeof IntersectionObserver !== "undefined") {
18508 const observer = new IntersectionObserver(() => {
18509 if (isFocusable(element)) return;
18510 cleanupFocusVisible(element);
18511 });
18512 observer.observe(element);
18513 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
18514 }
18515 return;
18516 }
18517 setFocusVisible(true);
18518 };
18519 const onKeyDownCaptureProp = props.onKeyDownCapture;
18520 const onKeyDownCapture = useEvent((event) => {
18521 onKeyDownCaptureProp?.(event);
18522 if (event.defaultPrevented) return;
18523 if (!focusable2) return;
18524 if (focusVisible) return;
18525 if (focusVisibleRef.current) return;
18526 if (event.metaKey) return;
18527 if (event.altKey) return;
18528 if (event.ctrlKey) return;
18529 if (!isSelfTarget(event)) return;
18530 const element = event.currentTarget;
18531 const applyFocusVisible = () => handleFocusVisible(event, element);
18532 queueBeforeEvent(element, "focusout", applyFocusVisible);
18533 });
18534 const onFocusCaptureProp = props.onFocusCapture;
18535 const onFocusCapture = useEvent((event) => {
18536 onFocusCaptureProp?.(event);
18537 if (event.defaultPrevented) return;
18538 if (!focusable2) return;
18539 if (!isSelfTarget(event)) {
18540 setFocusVisible(false);
18541 return;
18542 }
18543 const element = event.currentTarget;
18544 const applyFocusVisible = () => handleFocusVisible(event, element);
18545 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
18546 else setFocusVisible(false);
18547 });
18548 const onBlurProp = props.onBlur;
18549 const onBlur = useEvent((event) => {
18550 onBlurProp?.(event);
18551 if (!focusable2) return;
18552 if (!isFocusEventOutside(event)) return;
18553 cleanupFocusVisible(event.currentTarget);
18554 setFocusVisible(false);
18555 });
18556 const autoFocusOnShow = (0, import_react18.useContext)(FocusableContext);
18557 const autoFocusRef = useEvent((element) => {
18558 if (!focusable2) return;
18559 if (!autoFocus) return;
18560 if (!element) return;
18561 if (!autoFocusOnShow) return;
18562 queueMicrotask(() => {
18563 if (hasFocus(element)) return;
18564 if (!isFocusable(element)) return;
18565 element.focus();
18566 });
18567 });
18568 const tagName = useTagName(ref);
18569 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
18570 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
18571 const [safariTabIndex, setSafariTabIndex] = (0, import_react18.useState)(false);
18572 if (isSafariBrowser) (0, import_react18.useEffect)(() => {
18573 if (!focusable2) return;
18574 const element = ref.current;
18575 if (!element) return;
18576 const tag = element.tagName.toLowerCase();
18577 const type = element.type;
18578 setSafariTabIndex(needsSafariTabIndex(tag, type));
18579 }, [focusable2]);
18580 const styleProp = props.style;
18581 const style = (0, import_react18.useMemo)(() => {
18582 if (trulyDisabled) return {
18583 pointerEvents: "none",
18584 ...styleProp
18585 };
18586 return styleProp;
18587 }, [trulyDisabled, styleProp]);
18588 props = {
18589 "data-focus-visible": focusable2 && focusVisible || void 0,
18590 "data-autofocus": autoFocus || void 0,
18591 "aria-disabled": disabled2 || void 0,
18592 ...props,
18593 ...metadataProps,
18594 ref: useMergeRefs(ref, autoFocusRef, props.ref),
18595 style,
18596 tabIndex: getTabIndex2({
18597 focusable: focusable2,
18598 trulyDisabled,
18599 nativeTabbable,
18600 supportsDisabled,
18601 safariTabIndex,
18602 tabIndexProp: props.tabIndex
18603 }),
18604 disabled: supportsDisabled && trulyDisabled ? true : void 0,
18605 contentEditable: disabled2 ? void 0 : props.contentEditable,
18606 onKeyPressCapture,
18607 onClickCapture,
18608 onMouseDownCapture,
18609 onKeyDownCapture,
18610 onFocusCapture,
18611 onBlur
18612 };
18613 return removeUndefinedValues(props);
18614 });
18615 var Focusable = forwardRef49(function Focusable2(props) {
18616 return createElement3(TagName, useFocusable(props));
18617 });
18618
18619 // node_modules/@ariakit/react-components/dist/command/command.js
18620 var import_react19 = __toESM(require_react(), 1);
18621 var TagName2 = "button";
18622 function isNativeClick(event) {
18623 if (!event.isTrusted) return false;
18624 const element = event.currentTarget;
18625 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
18626 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
18627 return false;
18628 }
18629 var symbol = /* @__PURE__ */ Symbol("command");
18630 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
18631 const ref = (0, import_react19.useRef)(null);
18632 const [isNativeButton, setIsNativeButton] = (0, import_react19.useState)(false);
18633 (0, import_react19.useEffect)(() => {
18634 if (!ref.current) return;
18635 setIsNativeButton(isButton(ref.current));
18636 }, []);
18637 const [active, setActive] = (0, import_react19.useState)(false);
18638 const activeRef = (0, import_react19.useRef)(false);
18639 const disabled2 = disabledFromProps(props);
18640 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
18641 const onKeyDownProp = props.onKeyDown;
18642 const onKeyDown = useEvent((event) => {
18643 onKeyDownProp?.(event);
18644 const element = event.currentTarget;
18645 if (event.defaultPrevented) return;
18646 if (isDuplicate) return;
18647 if (disabled2) return;
18648 if (!isSelfTarget(event)) return;
18649 if (isTextField(element)) return;
18650 if (element.isContentEditable) return;
18651 const isEnter = clickOnEnter && event.key === "Enter";
18652 const isSpace = clickOnSpace && event.key === " ";
18653 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
18654 const shouldPreventSpace = event.key === " " && !clickOnSpace;
18655 if (shouldPreventEnter || shouldPreventSpace) {
18656 event.preventDefault();
18657 return;
18658 }
18659 if (isEnter || isSpace) {
18660 const nativeClick = isNativeClick(event);
18661 if (isEnter) {
18662 if (!nativeClick) {
18663 event.preventDefault();
18664 const { view, ...eventInit } = event;
18665 const click = () => fireClickEvent(element, eventInit);
18666 if (isFirefox2()) queueBeforeEvent(element, "keyup", click);
18667 else queueMicrotask(click);
18668 }
18669 } else if (isSpace) {
18670 activeRef.current = true;
18671 if (!nativeClick) {
18672 event.preventDefault();
18673 setActive(true);
18674 }
18675 }
18676 }
18677 });
18678 const onKeyUpProp = props.onKeyUp;
18679 const onKeyUp = useEvent((event) => {
18680 onKeyUpProp?.(event);
18681 if (event.defaultPrevented) return;
18682 if (isDuplicate) return;
18683 if (disabled2) return;
18684 if (event.metaKey) return;
18685 const isSpace = clickOnSpace && event.key === " ";
18686 if (activeRef.current && isSpace) {
18687 activeRef.current = false;
18688 if (!isNativeClick(event)) {
18689 event.preventDefault();
18690 setActive(false);
18691 const element = event.currentTarget;
18692 const { view, ...eventInit } = event;
18693 queueMicrotask(() => fireClickEvent(element, eventInit));
18694 }
18695 }
18696 });
18697 props = {
18698 "data-active": active || void 0,
18699 type: isNativeButton ? "button" : void 0,
18700 ...metadataProps,
18701 ...props,
18702 ref: useMergeRefs(ref, props.ref),
18703 onKeyDown,
18704 onKeyUp
18705 };
18706 props = useFocusable(props);
18707 return props;
18708 });
18709 var Command = forwardRef49(function Command2(props) {
18710 return createElement3(TagName2, useCommand(props));
18711 });
18712
18713 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
18714 var ctx = createStoreContext();
18715 var useCollectionContext = ctx.useContext;
18716 var useCollectionScopedContext = ctx.useScopedContext;
18717 var useCollectionProviderContext = ctx.useProviderContext;
18718 var CollectionContextProvider = ctx.ContextProvider;
18719 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
18720
18721 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
18722 var import_react20 = __toESM(require_react(), 1);
18723 var TagName3 = "div";
18724 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
18725 const context = useCollectionContext();
18726 store = store || context;
18727 const id = useId5(props.id);
18728 const ref = (0, import_react20.useRef)(element);
18729 (0, import_react20.useEffect)(() => {
18730 const element2 = ref.current;
18731 if (!id) return;
18732 if (!element2) return;
18733 if (!shouldRegisterItem) return;
18734 const item = getItem({
18735 id,
18736 element: element2
18737 });
18738 return store?.renderItem(item);
18739 }, [
18740 id,
18741 shouldRegisterItem,
18742 getItem,
18743 store
18744 ]);
18745 props = {
18746 ...props,
18747 ref: useMergeRefs(ref, props.ref)
18748 };
18749 return removeUndefinedValues(props);
18750 });
18751 var CollectionItem = forwardRef49(function CollectionItem2(props) {
18752 return createElement3(TagName3, useCollectionItem(props));
18753 });
18754
18755 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
18756 var import_react21 = __toESM(require_react(), 1);
18757 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
18758 var useCompositeContext = ctx2.useContext;
18759 var useCompositeScopedContext = ctx2.useScopedContext;
18760 var useCompositeProviderContext = ctx2.useProviderContext;
18761 var CompositeContextProvider = ctx2.ContextProvider;
18762 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
18763 var CompositeItemContext = (0, import_react21.createContext)(void 0);
18764 var CompositeRowContext = (0, import_react21.createContext)(void 0);
18765
18766 // node_modules/@ariakit/react-components/dist/composite/utils.js
18767 function findFirstEnabledItem(items, excludeId) {
18768 return items.find((item) => {
18769 if (excludeId) return !item.disabled && item.id !== excludeId;
18770 return !item.disabled;
18771 });
18772 }
18773 function getEnabledItem(store, id) {
18774 if (!id) return null;
18775 return store.item(id) || null;
18776 }
18777 function groupItemsByRows(items) {
18778 const rows = [];
18779 for (const item of items) {
18780 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
18781 if (row) row.push(item);
18782 else rows.push([item]);
18783 }
18784 return rows;
18785 }
18786 function selectTextField(element, collapseToEnd = false) {
18787 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
18788 else if (element.isContentEditable) {
18789 const selection = getDocument(element).getSelection();
18790 selection?.selectAllChildren(element);
18791 if (collapseToEnd) selection?.collapseToEnd();
18792 }
18793 }
18794 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
18795 function focusSilently(element) {
18796 element[FOCUS_SILENTLY] = true;
18797 element.focus({ preventScroll: true });
18798 }
18799 function silentlyFocused(element) {
18800 const isSilentlyFocused = element[FOCUS_SILENTLY];
18801 delete element[FOCUS_SILENTLY];
18802 return isSilentlyFocused;
18803 }
18804 function isItem(store, element, exclude) {
18805 if (!element) return false;
18806 if (element === exclude) return false;
18807 const item = store.item(element.id);
18808 if (!item) return false;
18809 if (exclude && item.element === exclude) return false;
18810 return true;
18811 }
18812
18813 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
18814 var import_react22 = __toESM(require_react(), 1);
18815 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
18816
18817 // node_modules/@ariakit/store/dist/index.js
18818 function getInternal(store, key) {
18819 const internals = store.__unstableInternals;
18820 invariant(internals, "Invalid store");
18821 return internals[key];
18822 }
18823 function hasUpdatedKey(keys, updatedKey) {
18824 if (!keys) return true;
18825 for (const currentKey of keys) if (updatedKey instanceof Set) {
18826 if (updatedKey.has(currentKey)) return true;
18827 } else if (currentKey === updatedKey) return true;
18828 return false;
18829 }
18830 function addKeyedListener(map, keys, listener) {
18831 if (!keys) return;
18832 for (const key of keys) {
18833 let listeners = map.get(key);
18834 if (!listeners) {
18835 listeners = /* @__PURE__ */ new Set();
18836 map.set(key, listeners);
18837 }
18838 listeners.add(listener);
18839 }
18840 }
18841 function deleteKeyedListener(map, keys, listener) {
18842 if (!map) return;
18843 if (!keys) return;
18844 for (const key of keys) {
18845 const listeners = map.get(key);
18846 if (!listeners) continue;
18847 listeners.delete(listener);
18848 if (!listeners.size) map.delete(key);
18849 }
18850 }
18851 function createStore(initialState, ...stores) {
18852 let state = initialState;
18853 let prevStateBatch = state;
18854 let destroy = noop4;
18855 let batchPending = false;
18856 let inDispatch = false;
18857 let updatedKeys = /* @__PURE__ */ new Set();
18858 const instances = /* @__PURE__ */ new Set();
18859 const setups = /* @__PURE__ */ new Set();
18860 const syncListenerGroup = {
18861 listeners: /* @__PURE__ */ new Set(),
18862 disposables: /* @__PURE__ */ new Map(),
18863 listenerKeys: /* @__PURE__ */ new WeakMap()
18864 };
18865 const batchListenerGroup = {
18866 listeners: /* @__PURE__ */ new Set(),
18867 disposables: /* @__PURE__ */ new Map(),
18868 listenerKeys: /* @__PURE__ */ new WeakMap()
18869 };
18870 const storeSetup = (callback) => {
18871 setups.add(callback);
18872 return () => setups.delete(callback);
18873 };
18874 const storeInit = () => {
18875 const initializedInstances = instances.size;
18876 const instance = /* @__PURE__ */ Symbol();
18877 instances.add(instance);
18878 const maybeDestroy = () => {
18879 instances.delete(instance);
18880 if (instances.size) return;
18881 destroy();
18882 };
18883 if (initializedInstances) return maybeDestroy;
18884 const stateKeys = getKeys(state);
18885 const desyncs = [];
18886 for (const store of stores) {
18887 const storeState = store?.getState?.();
18888 if (!storeState) continue;
18889 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
18890 if (!keys.length) continue;
18891 if (stores.length === 1 || keys.length === stateKeys.length) {
18892 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
18893 setState(key, state2[key], true);
18894 }));
18895 continue;
18896 }
18897 let didSyncInitialState = false;
18898 desyncs.push(sync(store, keys, (state2, prevState) => {
18899 for (const key of keys) {
18900 if (didSyncInitialState && state2[key] === prevState[key]) continue;
18901 setState(key, state2[key], true);
18902 }
18903 didSyncInitialState = true;
18904 }));
18905 }
18906 const teardowns = [];
18907 for (const setup2 of setups) teardowns.push(setup2());
18908 const cleanups = stores.map(init);
18909 destroy = chain(...desyncs, ...teardowns, ...cleanups);
18910 return maybeDestroy;
18911 };
18912 const deleteListenerIndexes = (group, listener, keys) => {
18913 if (keys === void 0) return;
18914 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
18915 else group.allKeysListeners?.delete(listener);
18916 };
18917 const registerListener = (keys, listener, group = syncListenerGroup) => {
18918 const listenerKeysValue = keys ? [...keys] : null;
18919 if (group.listeners.has(listener)) deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
18920 group.listeners.add(listener);
18921 if (listenerKeysValue) {
18922 group.listenersByKey ??= /* @__PURE__ */ new Map();
18923 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
18924 } else {
18925 group.allKeysListeners ??= /* @__PURE__ */ new Set();
18926 group.allKeysListeners.add(listener);
18927 }
18928 group.listenerKeys.set(listener, listenerKeysValue);
18929 return () => {
18930 group.disposables.get(listener)?.();
18931 group.disposables.delete(listener);
18932 const currentKeys = group.listenerKeys.get(listener);
18933 deleteListenerIndexes(group, listener, listenerKeysValue);
18934 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
18935 group.listenerKeys.delete(listener);
18936 group.listeners.delete(listener);
18937 };
18938 };
18939 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
18940 const reconcileInitialCleanup = (group, listener, cleanup) => {
18941 if (cleanup) group.disposables.set(listener, cleanup);
18942 else group.disposables.delete(listener);
18943 };
18944 const storeSync = (keys, listener) => {
18945 reconcileInitialCleanup(syncListenerGroup, listener, listener(state, state));
18946 return registerListener(keys, listener);
18947 };
18948 const storeBatch = (keys, listener) => {
18949 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
18950 reconcileInitialCleanup(batchListenerGroup, listener, listener(state, prevStateBatch));
18951 return registerListener(keys, listener, batchListenerGroup);
18952 };
18953 const storePick = (keys) => createStore(pick(state, keys), finalStore);
18954 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
18955 const getState = () => state;
18956 const runListeners = (group, prevState, updatedKey) => {
18957 const { disposables } = group;
18958 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
18959 const keyedListeners = group.listenersByKey?.get(updatedKey);
18960 if (!keyedListeners) return;
18961 for (const listener of keyedListeners) {
18962 const cleanup = disposables.size ? disposables.get(listener) : void 0;
18963 if (cleanup) cleanup();
18964 const result = listener(state, prevState);
18965 if (result) disposables.set(listener, result);
18966 else if (cleanup) disposables.delete(listener);
18967 }
18968 return;
18969 }
18970 const allKeysListeners = group.allKeysListeners;
18971 for (const listener of group.listeners) {
18972 if (!allKeysListeners?.has(listener)) {
18973 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
18974 }
18975 const cleanup = disposables.size ? disposables.get(listener) : void 0;
18976 if (cleanup) cleanup();
18977 const result = listener(state, prevState);
18978 if (result) disposables.set(listener, result);
18979 else if (cleanup) disposables.delete(listener);
18980 }
18981 };
18982 const setState = (key, value, fromStores = false) => {
18983 if (!hasOwnProperty(state, key)) return;
18984 const currentValue = state[key];
18985 const nextValue = typeof value === "function" ? value(currentValue) : value;
18986 if (nextValue === currentValue) return;
18987 if (!fromStores && stores.length) for (const store of stores) store?.setState?.(key, nextValue);
18988 const prevState = state;
18989 state = {
18990 ...state,
18991 [key]: nextValue
18992 };
18993 const wasInDispatch = inDispatch;
18994 inDispatch = true;
18995 try {
18996 runListeners(syncListenerGroup, prevState, key);
18997 } finally {
18998 inDispatch = wasInDispatch;
18999 }
19000 if (!batchListenerGroup.listeners.size) {
19001 if (!inDispatch) prevStateBatch = state;
19002 return;
19003 }
19004 updatedKeys.add(key);
19005 if (batchPending) return;
19006 batchPending = true;
19007 queueMicrotask(() => {
19008 batchPending = false;
19009 const snapshot = state;
19010 const updatedKeysSnapshot = updatedKeys;
19011 updatedKeys = /* @__PURE__ */ new Set();
19012 const prevStateBatchBefore = prevStateBatch;
19013 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
19014 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
19015 });
19016 };
19017 const finalStore = {
19018 getState,
19019 setState,
19020 __unstableInternals: {
19021 setup: storeSetup,
19022 init: storeInit,
19023 subscribe: storeSubscribe,
19024 sync: storeSync,
19025 batch: storeBatch,
19026 pick: storePick,
19027 omit: storeOmit
19028 }
19029 };
19030 return finalStore;
19031 }
19032 function setup(store, ...args) {
19033 if (!store) return;
19034 return getInternal(store, "setup")(...args);
19035 }
19036 function init(store, ...args) {
19037 if (!store) return;
19038 return getInternal(store, "init")(...args);
19039 }
19040 function subscribe(store, ...args) {
19041 if (!store) return;
19042 return getInternal(store, "subscribe")(...args);
19043 }
19044 function sync(store, ...args) {
19045 if (!store) return;
19046 return getInternal(store, "sync")(...args);
19047 }
19048 function batch(store, ...args) {
19049 if (!store) return;
19050 return getInternal(store, "batch")(...args);
19051 }
19052 function omit2(store, ...args) {
19053 if (!store) return;
19054 return getInternal(store, "omit")(...args);
19055 }
19056 function pick2(store, ...args) {
19057 if (!store) return;
19058 return getInternal(store, "pick")(...args);
19059 }
19060 function mergeStore(...stores) {
19061 const initialState = {};
19062 for (const store2 of stores) {
19063 const nextState = store2?.getState?.();
19064 if (nextState) Object.assign(initialState, nextState);
19065 }
19066 const store = createStore(initialState, ...stores);
19067 return Object.assign({}, ...stores, store);
19068 }
19069 function throwOnConflictingProps(props, store) {
19070 if (false) return;
19071 if (!store) return;
19072 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
19073 const stateKey = key.replace("default", "");
19074 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
19075 });
19076 if (!defaultKeys.length) return;
19077 const storeState = store.getState();
19078 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
19079 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
19080
19081 const store = useSelectStore();
19082 <SelectProvider store={store} defaultValue="Apple" />
19083 ^ ^
19084
19085 Instead, pass the default state to the topmost store:
19086
19087 const store = useSelectStore({ defaultValue: "Apple" });
19088 <SelectProvider store={store} />
19089
19090 See https://github.com/ariakit/ariakit/pull/2745 for more details.
19091
19092 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
19093 `);
19094 }
19095
19096 // node_modules/@ariakit/react-store/dist/index.js
19097 var React59 = __toESM(require_react(), 1);
19098 var import_shim2 = __toESM(require_shim(), 1);
19099 var noopSubscribe = () => () => {
19100 };
19101 function useStoreState(store, keyOrSelector = identity) {
19102 const storeSubscribe = React59.useCallback((callback) => {
19103 if (!store) return noopSubscribe();
19104 return subscribe(store, null, callback);
19105 }, [store]);
19106 const getSnapshot = () => {
19107 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
19108 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
19109 const state = store?.getState();
19110 if (selector2) return selector2(state);
19111 if (!state) return;
19112 if (!key) return;
19113 if (!hasOwnProperty(state, key)) return;
19114 return state[key];
19115 };
19116 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
19117 }
19118 function useStoreStateObject(store, object) {
19119 const objRef = React59.useRef({});
19120 const storeSubscribe = React59.useCallback((callback) => {
19121 if (!store) return noopSubscribe();
19122 return subscribe(store, null, callback);
19123 }, [store]);
19124 const getSnapshot = () => {
19125 const state = store?.getState();
19126 let updated = false;
19127 const obj = objRef.current;
19128 for (const prop in object) {
19129 const keyOrSelector = object[prop];
19130 if (typeof keyOrSelector === "function") {
19131 const value = keyOrSelector(state);
19132 if (value !== obj[prop]) {
19133 obj[prop] = value;
19134 updated = true;
19135 }
19136 }
19137 if (typeof keyOrSelector === "string") {
19138 if (!state) continue;
19139 if (!hasOwnProperty(state, keyOrSelector)) continue;
19140 const value = state[keyOrSelector];
19141 if (value !== obj[prop]) {
19142 obj[prop] = value;
19143 updated = true;
19144 }
19145 }
19146 }
19147 if (updated) objRef.current = { ...obj };
19148 return objRef.current;
19149 };
19150 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
19151 }
19152 function useStoreProps(store, props, key, setKey) {
19153 const value = hasOwnProperty(props, key) ? props[key] : void 0;
19154 const propsRef = useLiveRef({
19155 value,
19156 setValue: setKey ? props[setKey] : void 0
19157 });
19158 useSafeLayoutEffect(() => {
19159 return sync(store, [key], (state, prev) => {
19160 const { value: value2, setValue } = propsRef.current;
19161 if (!setValue) return;
19162 if (state[key] === prev[key]) return;
19163 if (state[key] === value2) return;
19164 setValue(state[key]);
19165 });
19166 }, [store, key]);
19167 useSafeLayoutEffect(() => {
19168 if (value === void 0) return;
19169 store.setState(key, value);
19170 return batch(store, [key], () => {
19171 if (value === void 0) return;
19172 store.setState(key, value);
19173 });
19174 });
19175 }
19176 function useStore2(createStore2, props) {
19177 const [store, setStore] = React59.useState(() => createStore2(props));
19178 useSafeLayoutEffect(() => init(store), [store]);
19179 const useState47 = React59.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
19180 return [React59.useMemo(() => ({
19181 ...store,
19182 useState: useState47
19183 }), [store, useState47]), useEvent(() => {
19184 setStore((store2) => createStore2({
19185 ...props,
19186 ...store2.getState()
19187 }));
19188 })];
19189 }
19190
19191 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
19192 var TagName4 = "button";
19193 function isEditableElement(element) {
19194 if (isTextbox(element)) return true;
19195 return element.tagName === "INPUT" && !isButton(element);
19196 }
19197 function getNextPageOffset(scrollingElement, pageUp = false) {
19198 const height = scrollingElement.clientHeight;
19199 const { top } = scrollingElement.getBoundingClientRect();
19200 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
19201 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
19202 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
19203 return pageOffset;
19204 }
19205 function getItemOffset(itemElement, pageUp = false) {
19206 const { top } = itemElement.getBoundingClientRect();
19207 if (pageUp) return top + itemElement.clientHeight;
19208 return top;
19209 }
19210 function findNextPageItemId(element, store, next, pageUp = false) {
19211 if (!store) return;
19212 if (!next) return;
19213 const { renderedItems } = store.getState();
19214 const scrollingElement = getScrollingElement(element);
19215 if (!scrollingElement) return;
19216 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
19217 let id;
19218 let prevDifference;
19219 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
19220 const previousId = id;
19221 id = next(i2);
19222 if (!id) break;
19223 if (id === previousId) continue;
19224 const itemElement = getEnabledItem(store, id)?.element;
19225 if (!itemElement) continue;
19226 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
19227 const absDifference = Math.abs(difference);
19228 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
19229 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
19230 break;
19231 }
19232 prevDifference = absDifference;
19233 }
19234 return id;
19235 }
19236 function targetIsAnotherItem(event, store) {
19237 if (isSelfTarget(event)) return false;
19238 return isItem(store, event.target);
19239 }
19240 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
19241 const context = useCompositeScopedContext();
19242 store = store || context;
19243 const id = useId5(props.id);
19244 const ref = (0, import_react22.useRef)(null);
19245 const row = (0, import_react22.useContext)(CompositeRowContext);
19246 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
19247 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
19248 rowId(state) {
19249 if (rowIdProp) return rowIdProp;
19250 if (!state) return;
19251 if (!row?.baseElement) return;
19252 if (row.baseElement !== state.baseElement) return;
19253 return row.id;
19254 },
19255 baseElement(state) {
19256 return state?.baseElement || void 0;
19257 },
19258 isActiveItem(state) {
19259 return !!state && state.activeId === id;
19260 },
19261 ariaSetSize(state) {
19262 if (ariaSetSizeProp != null) return ariaSetSizeProp;
19263 if (!state) return;
19264 if (!row?.ariaSetSize) return;
19265 if (row.baseElement !== state.baseElement) return;
19266 return row.ariaSetSize;
19267 },
19268 ariaPosInSet(state) {
19269 if (ariaPosInSetProp != null) return ariaPosInSetProp;
19270 if (!state) return;
19271 if (!row?.ariaPosInSet) return;
19272 if (row.baseElement !== state.baseElement) return;
19273 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId);
19274 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
19275 },
19276 isTabbable(state) {
19277 if (!state?.renderedItems.length) return true;
19278 if (state.virtualFocus) return false;
19279 if (tabbable2) return true;
19280 if (state.activeId === null) return false;
19281 const item = store?.item(state.activeId);
19282 if (item?.disabled) return true;
19283 if (!item?.element) return true;
19284 return state.activeId === id;
19285 }
19286 });
19287 const getItem = (0, import_react22.useCallback)((item) => {
19288 const nextItem = {
19289 ...item,
19290 id: id || item.id,
19291 rowId,
19292 disabled: trulyDisabled,
19293 children: item.element?.textContent
19294 };
19295 if (getItemProp) return getItemProp(nextItem);
19296 return nextItem;
19297 }, [
19298 id,
19299 rowId,
19300 trulyDisabled,
19301 getItemProp
19302 ]);
19303 const onFocusProp = props.onFocus;
19304 const hasFocusedComposite = (0, import_react22.useRef)(false);
19305 const onFocus = useEvent((event) => {
19306 onFocusProp?.(event);
19307 if (event.defaultPrevented) return;
19308 if (isPortalEvent(event)) return;
19309 if (!id) return;
19310 if (!store) return;
19311 if (targetIsAnotherItem(event, store)) return;
19312 const { virtualFocus, baseElement: baseElement2 } = store.getState();
19313 store.setActiveId(id);
19314 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
19315 if (!virtualFocus) return;
19316 if (!isSelfTarget(event)) return;
19317 if (isEditableElement(event.currentTarget)) return;
19318 if (!baseElement2?.isConnected) return;
19319 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) event.currentTarget.scrollIntoView({
19320 block: "nearest",
19321 inline: "nearest"
19322 });
19323 hasFocusedComposite.current = true;
19324 if (event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget)) focusSilently(baseElement2);
19325 else baseElement2.focus();
19326 });
19327 const onBlurCaptureProp = props.onBlurCapture;
19328 const onBlurCapture = useEvent((event) => {
19329 onBlurCaptureProp?.(event);
19330 if (event.defaultPrevented) return;
19331 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
19332 hasFocusedComposite.current = false;
19333 event.preventDefault();
19334 event.stopPropagation();
19335 }
19336 });
19337 const onKeyDownProp = props.onKeyDown;
19338 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
19339 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
19340 const onKeyDown = useEvent((event) => {
19341 onKeyDownProp?.(event);
19342 if (event.defaultPrevented) return;
19343 if (!isSelfTarget(event)) return;
19344 if (!store) return;
19345 const { currentTarget } = event;
19346 const state = store.getState();
19347 const isGrid2 = !!store.item(id)?.rowId;
19348 const isVertical = state.orientation !== "horizontal";
19349 const isHorizontal = state.orientation !== "vertical";
19350 const canHomeEnd = () => {
19351 if (isGrid2) return true;
19352 if (isHorizontal) return true;
19353 if (!state.baseElement) return true;
19354 if (!isTextField(state.baseElement)) return true;
19355 return false;
19356 };
19357 const action = {
19358 ArrowUp: (isGrid2 || isVertical) && store.up,
19359 ArrowRight: (isGrid2 || isHorizontal) && store.next,
19360 ArrowDown: (isGrid2 || isVertical) && store.down,
19361 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
19362 Home: () => {
19363 if (!canHomeEnd()) return;
19364 if (!isGrid2 || event.ctrlKey) return store?.first();
19365 return store?.previous(-1);
19366 },
19367 End: () => {
19368 if (!canHomeEnd()) return;
19369 if (!isGrid2 || event.ctrlKey) return store?.last();
19370 return store?.next(-1);
19371 },
19372 PageUp: () => {
19373 return findNextPageItemId(currentTarget, store, store?.up, true);
19374 },
19375 PageDown: () => {
19376 return findNextPageItemId(currentTarget, store, store?.down);
19377 }
19378 }[event.key];
19379 if (action) {
19380 if (isTextbox(currentTarget)) {
19381 const selection = getTextboxSelection(currentTarget);
19382 const isLeft = isHorizontal && event.key === "ArrowLeft";
19383 const isRight = isHorizontal && event.key === "ArrowRight";
19384 const isUp = isVertical && event.key === "ArrowUp";
19385 const isDown = isVertical && event.key === "ArrowDown";
19386 if (isRight || isDown) {
19387 const { length: valueLength } = getTextboxValue(currentTarget);
19388 if (selection.end !== valueLength) return;
19389 } else if ((isLeft || isUp) && selection.start !== 0) return;
19390 }
19391 const nextId = action();
19392 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
19393 if (!moveOnKeyPressProp(event)) return;
19394 event.preventDefault();
19395 store.move(nextId);
19396 }
19397 }
19398 });
19399 const providerValue = (0, import_react22.useMemo)(() => ({
19400 id,
19401 baseElement
19402 }), [id, baseElement]);
19403 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(CompositeItemContext.Provider, {
19404 value: providerValue,
19405 children: element
19406 }), [providerValue]);
19407 props = {
19408 "data-active-item": isActiveItem || void 0,
19409 ...props,
19410 id,
19411 ref: useMergeRefs(ref, props.ref),
19412 tabIndex: isTabbable ? props.tabIndex : -1,
19413 onFocus,
19414 onBlurCapture,
19415 onKeyDown
19416 };
19417 props = useCommand(props);
19418 props = useCollectionItem({
19419 store,
19420 ...props,
19421 getItem,
19422 shouldRegisterItem: id ? props.shouldRegisterItem : false
19423 });
19424 return removeUndefinedValues({
19425 ...props,
19426 "aria-setsize": ariaSetSize,
19427 "aria-posinset": ariaPosInSet
19428 });
19429 });
19430 var CompositeItem = memo3(forwardRef49(function CompositeItem2(props) {
19431 return createElement3(TagName4, useCompositeItem(props));
19432 }));
19433
19434 // node_modules/@ariakit/react-components/dist/composite/composite.js
19435 var import_react23 = __toESM(require_react(), 1);
19436 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
19437 var TagName5 = "div";
19438 function isGrid(items) {
19439 return items.some((item) => !!item.rowId);
19440 }
19441 function isPrintableKey(event) {
19442 const target = event.target;
19443 if (target && !isTextField(target)) return false;
19444 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
19445 }
19446 function isModifierKey(event) {
19447 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
19448 }
19449 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
19450 return useEvent((event) => {
19451 onKeyboardEvent?.(event);
19452 if (event.defaultPrevented) return;
19453 if (event.isPropagationStopped()) return;
19454 if (!isSelfTarget(event)) return;
19455 if (isModifierKey(event)) return;
19456 if (isPrintableKey(event)) return;
19457 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
19458 if (!activeElement2) return;
19459 const { view, ...eventInit } = event;
19460 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
19461 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
19462 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
19463 });
19464 }
19465 function findFirstEnabledItemInTheLastRow(items) {
19466 return findFirstEnabledItem(flatten2DArray(reverseArray(groupItemsByRows(items))));
19467 }
19468 function withBaseScrollPreserved(store, callback) {
19469 const { virtualFocus, baseElement } = store.getState();
19470 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
19471 callback();
19472 return;
19473 }
19474 const savedScrollLeft = baseElement.scrollLeft;
19475 const savedScrollTop = baseElement.scrollTop;
19476 callback();
19477 baseElement.scrollLeft = savedScrollLeft;
19478 baseElement.scrollTop = savedScrollTop;
19479 }
19480 function useScheduleFocus(store) {
19481 const [scheduled, setScheduled] = (0, import_react23.useState)(false);
19482 const schedule = (0, import_react23.useCallback)(() => setScheduled(true), []);
19483 const activeItem = useStoreState(store, (state) => getEnabledItem(store, state.activeId));
19484 (0, import_react23.useEffect)(() => {
19485 const activeElement2 = activeItem?.element;
19486 if (!scheduled) return;
19487 if (!activeElement2) return;
19488 setScheduled(false);
19489 withBaseScrollPreserved(store, () => {
19490 activeElement2.focus({ preventScroll: true });
19491 });
19492 }, [
19493 store,
19494 activeItem,
19495 scheduled
19496 ]);
19497 return schedule;
19498 }
19499 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
19500 const context = useCompositeProviderContext();
19501 store = store || context;
19502 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
19503 const ref = (0, import_react23.useRef)(null);
19504 const previousElementRef = (0, import_react23.useRef)(null);
19505 const scheduleFocus = useScheduleFocus(store);
19506 const moves = useStoreState(store, "moves");
19507 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
19508 (0, import_react23.useEffect)(() => {
19509 if (!store) return;
19510 if (!moves) return;
19511 if (!composite) return;
19512 if (!focusOnMove) return;
19513 const { activeId: activeId2 } = store.getState();
19514 const itemElement = getEnabledItem(store, activeId2)?.element;
19515 if (!itemElement) return;
19516 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
19517 }, [
19518 store,
19519 moves,
19520 composite,
19521 focusOnMove
19522 ]);
19523 useSafeLayoutEffect(() => {
19524 if (!store) return;
19525 if (!moves) return;
19526 if (!composite) return;
19527 const { baseElement, activeId: activeId2 } = store.getState();
19528 if (!(activeId2 === null)) return;
19529 if (!baseElement) return;
19530 const previousElement = previousElementRef.current;
19531 previousElementRef.current = null;
19532 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
19533 if (!hasFocus(baseElement)) baseElement.focus();
19534 }, [
19535 store,
19536 moves,
19537 composite
19538 ]);
19539 const activeId = useStoreState(store, "activeId");
19540 const virtualFocus = useStoreState(store, "virtualFocus");
19541 useSafeLayoutEffect(() => {
19542 if (!store) return;
19543 if (!composite) return;
19544 if (!virtualFocus) return;
19545 const previousElement = previousElementRef.current;
19546 previousElementRef.current = null;
19547 if (!previousElement) return;
19548 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
19549 if (relatedTarget === previousElement) return;
19550 fireBlurEvent(previousElement, { relatedTarget });
19551 }, [
19552 store,
19553 activeId,
19554 virtualFocus,
19555 composite
19556 ]);
19557 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
19558 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
19559 const onFocusCaptureProp = props.onFocusCapture;
19560 const onFocusCapture = useEvent((event) => {
19561 onFocusCaptureProp?.(event);
19562 if (event.defaultPrevented) return;
19563 if (!store) return;
19564 const { virtualFocus: virtualFocus2 } = store.getState();
19565 if (!virtualFocus2) return;
19566 const previousActiveElement = event.relatedTarget;
19567 const isSilentlyFocused = silentlyFocused(event.currentTarget);
19568 if (isSelfTarget(event) && isSilentlyFocused) {
19569 event.stopPropagation();
19570 previousElementRef.current = previousActiveElement;
19571 }
19572 });
19573 const onFocusProp = props.onFocus;
19574 const onFocus = useEvent((event) => {
19575 onFocusProp?.(event);
19576 if (event.defaultPrevented) return;
19577 if (!composite) return;
19578 if (!store) return;
19579 const { relatedTarget } = event;
19580 const { virtualFocus: virtualFocus2 } = store.getState();
19581 if (virtualFocus2) {
19582 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
19583 } else if (isSelfTarget(event)) store.setActiveId(null);
19584 });
19585 const onBlurCaptureProp = props.onBlurCapture;
19586 const onBlurCapture = useEvent((event) => {
19587 onBlurCaptureProp?.(event);
19588 if (event.defaultPrevented) return;
19589 if (!store) return;
19590 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
19591 if (!virtualFocus2) return;
19592 const activeElement2 = getEnabledItem(store, activeId2)?.element;
19593 const nextActiveElement = event.relatedTarget;
19594 const nextActiveElementIsItem = isItem(store, nextActiveElement);
19595 const previousElement = previousElementRef.current;
19596 previousElementRef.current = null;
19597 if (isSelfTarget(event) && nextActiveElementIsItem) {
19598 if (nextActiveElement === activeElement2) {
19599 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
19600 } else if (activeElement2) fireBlurEvent(activeElement2, event);
19601 else if (previousElement) fireBlurEvent(previousElement, event);
19602 event.stopPropagation();
19603 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
19604 });
19605 const onKeyDownProp = props.onKeyDown;
19606 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
19607 const onKeyDown = useEvent((event) => {
19608 onKeyDownProp?.(event);
19609 if (event.nativeEvent.isComposing) return;
19610 if (event.defaultPrevented) return;
19611 if (!store) return;
19612 if (!isSelfTarget(event)) return;
19613 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
19614 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
19615 const isVertical = orientation !== "horizontal";
19616 const isHorizontal = orientation !== "vertical";
19617 const grid = isGrid(renderedItems);
19618 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
19619 const up = () => {
19620 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
19621 return store?.last();
19622 };
19623 const action = {
19624 ArrowUp: (grid || isVertical) && up,
19625 ArrowRight: (grid || isHorizontal) && store.first,
19626 ArrowDown: (grid || isVertical) && store.first,
19627 ArrowLeft: (grid || isHorizontal) && store.last,
19628 Home: store.first,
19629 End: store.last,
19630 PageUp: store.first,
19631 PageDown: store.last
19632 }[event.key];
19633 if (action) {
19634 const id = action();
19635 if (id !== void 0) {
19636 if (!moveOnKeyPressProp(event)) return;
19637 event.preventDefault();
19638 store.move(id);
19639 }
19640 }
19641 });
19642 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(CompositeScopedContextProvider, {
19643 value: store,
19644 children: element
19645 }), [store]);
19646 props = {
19647 "aria-activedescendant": useStoreState(store, (state) => {
19648 if (!store) return;
19649 if (!composite) return;
19650 if (!state.virtualFocus) return;
19651 return getEnabledItem(store, state.activeId)?.id;
19652 }),
19653 ...props,
19654 ref: useMergeRefs(ref, setBaseElement, props.ref),
19655 onKeyDownCapture,
19656 onKeyUpCapture,
19657 onFocusCapture,
19658 onFocus,
19659 onBlurCapture,
19660 onKeyDown
19661 };
19662 props = useFocusable({
19663 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
19664 ...props
19665 });
19666 return props;
19667 });
19668 var Composite6 = forwardRef49(function Composite7(props) {
19669 return createElement3(TagName5, useComposite(props));
19670 });
19671
19672 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
19673 var ctx3 = createStoreContext();
19674 var useDisclosureContext = ctx3.useContext;
19675 var useDisclosureScopedContext = ctx3.useScopedContext;
19676 var useDisclosureProviderContext = ctx3.useProviderContext;
19677 var DisclosureContextProvider = ctx3.ContextProvider;
19678 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
19679
19680 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
19681 var import_react24 = __toESM(require_react(), 1);
19682 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
19683 var useDialogContext = ctx4.useContext;
19684 var useDialogScopedContext = ctx4.useScopedContext;
19685 var useDialogProviderContext = ctx4.useProviderContext;
19686 var DialogContextProvider = ctx4.ContextProvider;
19687 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
19688 var DialogHeadingContext = (0, import_react24.createContext)(void 0);
19689 var DialogDescriptionContext = (0, import_react24.createContext)(void 0);
19690
19691 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
19692 var import_react25 = __toESM(require_react(), 1);
19693 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
19694 var import_react_dom4 = __toESM(require_react_dom(), 1);
19695 var TagName6 = "div";
19696 function afterTimeout(timeoutMs, cb) {
19697 const timeoutId = setTimeout(cb, timeoutMs);
19698 return () => clearTimeout(timeoutId);
19699 }
19700 function afterPaint(cb) {
19701 let raf = requestAnimationFrame(() => {
19702 raf = requestAnimationFrame(cb);
19703 });
19704 return () => cancelAnimationFrame(raf);
19705 }
19706 function parseCSSTime(...times) {
19707 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
19708 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
19709 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
19710 if (currentTime > longestTime) return currentTime;
19711 return longestTime;
19712 }, 0);
19713 }
19714 function isHidden(mounted, hidden, alwaysVisible) {
19715 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
19716 }
19717 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...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_react25.useRef)(null);
19722 const id = useId5(props.id);
19723 const [transition, setTransition] = (0, import_react25.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_react25.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 { transitionDuration, animationDuration, transitionDelay, animationDelay } = getComputedStyle(contentElement);
19780 const { transitionDuration: transitionDuration2 = "0", animationDuration: animationDuration2 = "0", transitionDelay: transitionDelay2 = "0", animationDelay: animationDelay2 = "0" } = otherElement ? getComputedStyle(otherElement) : {};
19781 const timeout = parseCSSTime(transitionDelay, animationDelay, transitionDelay2, animationDelay2) + parseCSSTime(transitionDuration, animationDuration, transitionDuration2, animationDuration2);
19782 if (!timeout) {
19783 if (transition === "enter") store.setState("animated", false);
19784 stopAnimation();
19785 return;
19786 }
19787 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
19788 }, [
19789 store,
19790 animated,
19791 contentElement,
19792 otherElement,
19793 open,
19794 transition
19795 ]);
19796 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DialogScopedContextProvider, {
19797 value: store,
19798 children: element
19799 }), [store]);
19800 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
19801 const styleProp = props.style;
19802 const style = (0, import_react25.useMemo)(() => {
19803 if (hidden) return {
19804 ...styleProp,
19805 display: "none"
19806 };
19807 return styleProp;
19808 }, [hidden, styleProp]);
19809 props = {
19810 "data-open": open || void 0,
19811 "data-enter": transition === "enter" || void 0,
19812 "data-leave": transition === "leave" || void 0,
19813 hidden,
19814 ...props,
19815 id,
19816 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
19817 style
19818 };
19819 return removeUndefinedValues(props);
19820 });
19821 var DisclosureContentImpl = forwardRef49(function DisclosureContentImpl2(props) {
19822 return createElement3(TagName6, useDisclosureContent(props));
19823 });
19824 var DisclosureContent = forwardRef49(function DisclosureContent2({ unmountOnHide, ...props }) {
19825 const context = useDisclosureProviderContext();
19826 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
19827 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DisclosureContentImpl, { ...props });
19828 });
19829
19830 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
19831 function createDisclosureStore(props = {}) {
19832 const store = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"]));
19833 throwOnConflictingProps(props, store);
19834 const syncState = store?.getState();
19835 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
19836 const animated = defaultValue(props.animated, syncState?.animated, false);
19837 const disclosure = createStore({
19838 open,
19839 animated,
19840 animating: !!animated && open,
19841 mounted: open,
19842 contentElement: defaultValue(syncState?.contentElement, null),
19843 disclosureElement: defaultValue(syncState?.disclosureElement, null)
19844 }, store);
19845 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
19846 if (state.animated) return;
19847 disclosure.setState("animating", false);
19848 }));
19849 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
19850 if (!disclosure.getState().animated) return;
19851 disclosure.setState("animating", true);
19852 }));
19853 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
19854 disclosure.setState("mounted", state.open || state.animating);
19855 }));
19856 return {
19857 ...disclosure,
19858 disclosure: props.disclosure,
19859 setOpen: (value) => disclosure.setState("open", value),
19860 show: () => disclosure.setState("open", true),
19861 hide: () => disclosure.setState("open", false),
19862 toggle: () => disclosure.setState("open", (open2) => !open2),
19863 stopAnimation: () => disclosure.setState("animating", false),
19864 setContentElement: (value) => disclosure.setState("contentElement", value),
19865 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
19866 };
19867 }
19868
19869 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
19870 function useDisclosureStoreProps(store, update2, props) {
19871 useUpdateEffect(update2, [props.store, props.disclosure]);
19872 useStoreProps(store, props, "open", "setOpen");
19873 useStoreProps(store, props, "mounted", "setMounted");
19874 useStoreProps(store, props, "animated");
19875 return Object.assign(store, { disclosure: props.disclosure });
19876 }
19877
19878 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
19879 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
19880 var usePopoverContext = ctx5.useContext;
19881 var usePopoverScopedContext = ctx5.useScopedContext;
19882 var usePopoverProviderContext = ctx5.useProviderContext;
19883 var PopoverContextProvider = ctx5.ContextProvider;
19884 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
19885
19886 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
19887 var import_react26 = __toESM(require_react(), 1);
19888 var ComboboxListRoleContext = (0, import_react26.createContext)(void 0);
19889 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
19890 var useComboboxContext = ctx6.useContext;
19891 var useComboboxScopedContext = ctx6.useScopedContext;
19892 var useComboboxProviderContext = ctx6.useProviderContext;
19893 var ComboboxContextProvider = ctx6.ContextProvider;
19894 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
19895 var ComboboxItemValueContext = (0, import_react26.createContext)(void 0);
19896 var ComboboxItemCheckedContext = (0, import_react26.createContext)(false);
19897
19898 // node_modules/@ariakit/components/dist/collection/collection-store.js
19899 function getCommonParent(items) {
19900 const firstItem = items.find((item) => !!item.element);
19901 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
19902 let parentElement = firstItem?.element?.parentElement;
19903 if (!lastElement) return getDocument(parentElement).body;
19904 while (parentElement) {
19905 if (parentElement.contains(lastElement)) return parentElement;
19906 parentElement = parentElement.parentElement;
19907 }
19908 return getDocument(parentElement).body;
19909 }
19910 function getPrivateStore(store) {
19911 return store?.__unstablePrivateStore;
19912 }
19913 function createCollectionStore(props = {}) {
19914 throwOnConflictingProps(props, props.store);
19915 const syncState = props.store?.getState();
19916 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
19917 const itemsMap = new Map(items.map((item) => [item.id, item]));
19918 const initialState = {
19919 items,
19920 renderedItems: defaultValue(syncState?.renderedItems, [])
19921 };
19922 const syncPrivateStore = getPrivateStore(props.store);
19923 const privateStore = createStore({
19924 items,
19925 renderedItems: initialState.renderedItems
19926 }, syncPrivateStore);
19927 const collection = createStore(initialState, props.store);
19928 const sortItems = (renderedItems) => {
19929 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
19930 privateStore.setState("renderedItems", sortedItems);
19931 collection.setState("renderedItems", sortedItems);
19932 };
19933 setup(collection, () => init(privateStore));
19934 setup(privateStore, () => {
19935 return batch(privateStore, ["items"], (state) => {
19936 collection.setState("items", state.items);
19937 });
19938 });
19939 setup(privateStore, () => {
19940 return batch(privateStore, ["renderedItems"], (state) => {
19941 let firstRun = true;
19942 let raf = requestAnimationFrame(() => {
19943 const { renderedItems } = collection.getState();
19944 if (state.renderedItems === renderedItems) return;
19945 sortItems(state.renderedItems);
19946 });
19947 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
19948 const ioCallback = () => {
19949 if (firstRun) {
19950 firstRun = false;
19951 return;
19952 }
19953 cancelAnimationFrame(raf);
19954 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
19955 };
19956 const root = getCommonParent(state.renderedItems);
19957 const observer = new IntersectionObserver(ioCallback, { root });
19958 for (const item of state.renderedItems) {
19959 if (!item.element) continue;
19960 observer.observe(item.element);
19961 }
19962 return () => {
19963 cancelAnimationFrame(raf);
19964 observer.disconnect();
19965 };
19966 });
19967 });
19968 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
19969 let prevItem;
19970 setItems((items2) => {
19971 const index2 = items2.findIndex(({ id }) => id === item.id);
19972 const nextItems = items2.slice();
19973 if (index2 !== -1) {
19974 prevItem = items2[index2];
19975 const nextItem = {
19976 ...prevItem,
19977 ...item
19978 };
19979 nextItems[index2] = nextItem;
19980 itemsMap.set(item.id, nextItem);
19981 } else {
19982 nextItems.push(item);
19983 itemsMap.set(item.id, item);
19984 }
19985 return nextItems;
19986 });
19987 const unmergeItem = () => {
19988 setItems((items2) => {
19989 if (!prevItem) {
19990 if (canDeleteFromMap) itemsMap.delete(item.id);
19991 return items2.filter(({ id }) => id !== item.id);
19992 }
19993 const index2 = items2.findIndex(({ id }) => id === item.id);
19994 if (index2 === -1) return items2;
19995 const nextItems = items2.slice();
19996 nextItems[index2] = prevItem;
19997 itemsMap.set(item.id, prevItem);
19998 return nextItems;
19999 });
20000 };
20001 return unmergeItem;
20002 };
20003 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
20004 return {
20005 ...collection,
20006 registerItem,
20007 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
20008 item: (id) => {
20009 if (!id) return null;
20010 let item = itemsMap.get(id);
20011 if (!item) {
20012 const { items: items2 } = privateStore.getState();
20013 item = items2.find((item2) => item2.id === id);
20014 if (item) itemsMap.set(id, item);
20015 }
20016 return item || null;
20017 },
20018 __unstablePrivateStore: privateStore
20019 };
20020 }
20021
20022 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
20023 function useCollectionStoreProps(store, update2, props) {
20024 useUpdateEffect(update2, [props.store]);
20025 useStoreProps(store, props, "items", "setItems");
20026 return store;
20027 }
20028
20029 // node_modules/@ariakit/components/dist/composite/composite-store.js
20030 var NULL_ITEM = { id: null };
20031 function findFirstEnabledItem2(items, excludeId) {
20032 return items.find((item) => {
20033 if (excludeId) return !item.disabled && item.id !== excludeId;
20034 return !item.disabled;
20035 });
20036 }
20037 function getEnabledItems(items, excludeId) {
20038 return items.filter((item) => {
20039 if (excludeId) return !item.disabled && item.id !== excludeId;
20040 return !item.disabled;
20041 });
20042 }
20043 function getItemsInRow(items, rowId) {
20044 return items.filter((item) => item.rowId === rowId);
20045 }
20046 function flipItems(items, activeId, shouldInsertNullItem = false) {
20047 const index2 = items.findIndex((item) => item.id === activeId);
20048 return [
20049 ...items.slice(index2 + 1),
20050 ...shouldInsertNullItem ? [NULL_ITEM] : [],
20051 ...items.slice(0, index2)
20052 ];
20053 }
20054 function groupItemsByRows2(items) {
20055 const rows = [];
20056 for (const item of items) {
20057 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
20058 if (row) row.push(item);
20059 else rows.push([item]);
20060 }
20061 return rows;
20062 }
20063 function getMaxRowLength(array) {
20064 let maxLength = 0;
20065 for (const { length } of array) if (length > maxLength) maxLength = length;
20066 return maxLength;
20067 }
20068 function createEmptyItem(rowId) {
20069 return {
20070 id: "__EMPTY_ITEM__",
20071 disabled: true,
20072 rowId
20073 };
20074 }
20075 function normalizeRows(rows, activeId, focusShift) {
20076 const maxLength = getMaxRowLength(rows);
20077 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
20078 const item = row[i2];
20079 if (!item || focusShift && item.disabled) {
20080 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
20081 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
20082 }
20083 }
20084 return rows;
20085 }
20086 function verticalizeItems(items) {
20087 const rows = groupItemsByRows2(items);
20088 const maxLength = getMaxRowLength(rows);
20089 const verticalized = [];
20090 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
20091 const item = row[i2];
20092 if (item) verticalized.push({
20093 ...item,
20094 rowId: item.rowId ? `${i2}` : void 0
20095 });
20096 }
20097 return verticalized;
20098 }
20099 function createCompositeStore(props = {}) {
20100 const syncState = props.store?.getState();
20101 const collection = createCollectionStore(props);
20102 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
20103 const composite = createStore({
20104 ...collection.getState(),
20105 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
20106 activeId,
20107 baseElement: defaultValue(syncState?.baseElement, null),
20108 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
20109 moves: defaultValue(syncState?.moves, 0),
20110 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
20111 rtl: defaultValue(props.rtl, syncState?.rtl, false),
20112 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
20113 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
20114 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
20115 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
20116 }, collection, props.store);
20117 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
20118 composite.setState("activeId", (activeId2) => {
20119 if (activeId2 !== void 0) return activeId2;
20120 return findFirstEnabledItem2(state.renderedItems)?.id;
20121 });
20122 }));
20123 const getNextId = (direction = "next", options = {}) => {
20124 const defaultState = composite.getState();
20125 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;
20126 const isVerticalDirection = direction === "up" || direction === "down";
20127 const isNextDirection = direction === "next" || direction === "down";
20128 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
20129 const canShift = focusShift && !skip;
20130 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift));
20131 items = canReverse ? reverseArray(items) : items;
20132 items = isVerticalDirection ? verticalizeItems(items) : items;
20133 if (activeId2 == null) return findFirstEnabledItem2(items)?.id;
20134 const activeItem = items.find((item) => item.id === activeId2);
20135 if (!activeItem) return findFirstEnabledItem2(items)?.id;
20136 const isGrid2 = items.some((item) => item.rowId);
20137 const activeIndex = items.indexOf(activeItem);
20138 const nextItems = items.slice(activeIndex + 1);
20139 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
20140 if (skip) {
20141 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
20142 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
20143 }
20144 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
20145 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
20146 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
20147 if (canLoop) return findFirstEnabledItem2(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
20148 if (canWrap) {
20149 const nextItem2 = findFirstEnabledItem2(hasNullItem ? nextItemsInRow : nextItems, activeId2);
20150 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
20151 }
20152 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
20153 if (!nextItem && hasNullItem) return null;
20154 return nextItem?.id;
20155 };
20156 return {
20157 ...collection,
20158 ...composite,
20159 setBaseElement: (element) => composite.setState("baseElement", element),
20160 setActiveId: (id) => composite.setState("activeId", id),
20161 move: (id) => {
20162 if (id === void 0) return;
20163 composite.setState("activeId", id);
20164 composite.setState("moves", (moves) => moves + 1);
20165 },
20166 first: () => findFirstEnabledItem2(composite.getState().renderedItems)?.id,
20167 last: () => findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))?.id,
20168 next: (options) => {
20169 if (options !== void 0 && typeof options === "number") options = { skip: options };
20170 return getNextId("next", options);
20171 },
20172 previous: (options) => {
20173 if (options !== void 0 && typeof options === "number") options = { skip: options };
20174 return getNextId("previous", options);
20175 },
20176 down: (options) => {
20177 if (options !== void 0 && typeof options === "number") options = { skip: options };
20178 return getNextId("down", options);
20179 },
20180 up: (options) => {
20181 if (options !== void 0 && typeof options === "number") options = { skip: options };
20182 return getNextId("up", options);
20183 }
20184 };
20185 }
20186
20187 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
20188 function useCompositeStoreOptions(props) {
20189 return {
20190 id: useId5(props.id),
20191 ...props
20192 };
20193 }
20194 function useCompositeStoreProps(store, update2, props) {
20195 store = useCollectionStoreProps(store, update2, props);
20196 useStoreProps(store, props, "activeId", "setActiveId");
20197 useStoreProps(store, props, "includesBaseElement");
20198 useStoreProps(store, props, "virtualFocus");
20199 useStoreProps(store, props, "orientation");
20200 useStoreProps(store, props, "rtl");
20201 useStoreProps(store, props, "focusLoop");
20202 useStoreProps(store, props, "focusWrap");
20203 useStoreProps(store, props, "focusShift");
20204 return store;
20205 }
20206
20207 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
20208 function createDialogStore(props = {}) {
20209 return createDisclosureStore(props);
20210 }
20211
20212 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
20213 function useDialogStoreProps(store, update2, props) {
20214 return useDisclosureStoreProps(store, update2, props);
20215 }
20216
20217 // node_modules/@ariakit/components/dist/popover/popover-store.js
20218 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
20219 const store = mergeStore(props.store, omit2(otherPopover, [
20220 "arrowElement",
20221 "anchorElement",
20222 "contentElement",
20223 "popoverElement",
20224 "disclosureElement"
20225 ]));
20226 throwOnConflictingProps(props, store);
20227 const syncState = store?.getState();
20228 const dialog = createDialogStore({
20229 ...props,
20230 store
20231 });
20232 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
20233 const popover = createStore({
20234 ...dialog.getState(),
20235 placement,
20236 currentPlacement: placement,
20237 anchorElement: defaultValue(syncState?.anchorElement, null),
20238 popoverElement: defaultValue(syncState?.popoverElement, null),
20239 arrowElement: defaultValue(syncState?.arrowElement, null),
20240 rendered: /* @__PURE__ */ Symbol("rendered")
20241 }, dialog, store);
20242 return {
20243 ...dialog,
20244 ...popover,
20245 setAnchorElement: (element) => popover.setState("anchorElement", element),
20246 setPopoverElement: (element) => popover.setState("popoverElement", element),
20247 setArrowElement: (element) => popover.setState("arrowElement", element),
20248 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
20249 };
20250 }
20251
20252 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
20253 function usePopoverStoreProps(store, update2, props) {
20254 useUpdateEffect(update2, [props.popover]);
20255 useStoreProps(store, props, "placement");
20256 return useDialogStoreProps(store, update2, props);
20257 }
20258
20259 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
20260 var TagName7 = "div";
20261 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
20262 const context = usePopoverProviderContext();
20263 store = store || context;
20264 props = {
20265 ...props,
20266 ref: useMergeRefs(store?.setAnchorElement, props.ref)
20267 };
20268 return props;
20269 });
20270 var PopoverAnchor = forwardRef49(function PopoverAnchor2(props) {
20271 return createElement3(TagName7, usePopoverAnchor(props));
20272 });
20273
20274 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
20275 var import_react27 = __toESM(require_react(), 1);
20276 var TagName8 = "div";
20277 function hoveringInside(event) {
20278 const nextElement = event.relatedTarget;
20279 if (!isElement2(nextElement)) return false;
20280 return contains2(event.currentTarget, nextElement);
20281 }
20282 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
20283 function movingToAnotherItem(event) {
20284 const { relatedTarget } = event;
20285 if (!isElement2(relatedTarget)) return false;
20286 let dest = relatedTarget;
20287 do {
20288 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
20289 dest = dest.parentElement;
20290 } while (dest);
20291 return false;
20292 }
20293 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
20294 const context = useCompositeScopedContext();
20295 store = store || context;
20296 invariant(store, "CompositeHover must be wrapped in a Composite component.");
20297 const isMouseMoving = useIsMouseMoving();
20298 const onMouseMoveProp = props.onMouseMove;
20299 const focusOnHoverProp = useBooleanEvent(focusOnHover);
20300 const onMouseMove = useEvent((event) => {
20301 onMouseMoveProp?.(event);
20302 if (event.defaultPrevented) return;
20303 if (!isMouseMoving()) return;
20304 if (!focusOnHoverProp(event)) return;
20305 if (!hasFocusWithin(event.currentTarget)) {
20306 const baseElement = store?.getState().baseElement;
20307 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
20308 }
20309 store?.setActiveId(event.currentTarget.id);
20310 });
20311 const onMouseLeaveProp = props.onMouseLeave;
20312 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
20313 const onMouseLeave = useEvent((event) => {
20314 onMouseLeaveProp?.(event);
20315 if (event.defaultPrevented) return;
20316 if (!isMouseMoving()) return;
20317 if (hoveringInside(event)) return;
20318 if (movingToAnotherItem(event)) return;
20319 if (!focusOnHoverProp(event)) return;
20320 if (!blurOnHoverEndProp(event)) return;
20321 store?.setActiveId(null);
20322 store?.getState().baseElement?.focus();
20323 });
20324 const ref = (0, import_react27.useCallback)((element) => {
20325 if (!element) return;
20326 element[symbol2] = true;
20327 }, []);
20328 props = {
20329 ...props,
20330 ref: useMergeRefs(ref, props.ref),
20331 onMouseMove,
20332 onMouseLeave
20333 };
20334 return removeUndefinedValues(props);
20335 });
20336 var CompositeHover = memo3(forwardRef49(function CompositeHover2(props) {
20337 return createElement3(TagName8, useCompositeHover(props));
20338 }));
20339
20340 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
20341 var import_react28 = __toESM(require_react(), 1);
20342 var TagName9 = "input";
20343 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
20344 if (!autoSelect) return false;
20345 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
20346 }
20347 function hasCompletionString(value, activeValue) {
20348 if (!activeValue) return false;
20349 if (value == null) return false;
20350 value = normalizeString(value);
20351 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
20352 }
20353 function isInputEvent(event) {
20354 return event.type === "input";
20355 }
20356 function isAriaAutoCompleteValue(value) {
20357 return value === "inline" || value === "list" || value === "both" || value === "none";
20358 }
20359 function getDefaultAutoSelectId(items) {
20360 return items.find((item) => {
20361 if (item.disabled) return false;
20362 return item.element?.getAttribute("role") !== "tab";
20363 })?.id;
20364 }
20365 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 }) {
20366 const context = useComboboxProviderContext();
20367 store = store || context;
20368 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
20369 const ref = (0, import_react28.useRef)(null);
20370 const [valueUpdated, forceValueUpdate] = useForceUpdate();
20371 const canAutoSelectRef = (0, import_react28.useRef)(false);
20372 const composingRef = (0, import_react28.useRef)(false);
20373 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
20374 const inline4 = autoComplete === "inline" || autoComplete === "both";
20375 const [canInline, setCanInline] = (0, import_react28.useState)(inline4);
20376 useUpdateLayoutEffect(() => {
20377 if (!inline4) return;
20378 setCanInline(true);
20379 }, [inline4]);
20380 const storeValue = useStoreState(store, "value");
20381 const prevSelectedValueRef = (0, import_react28.useRef)(void 0);
20382 (0, import_react28.useEffect)(() => {
20383 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
20384 prevSelectedValueRef.current = prev.selectedValue;
20385 });
20386 }, [store]);
20387 const inlineActiveValue = useStoreState(store, (state) => {
20388 if (!inline4) return;
20389 if (!canInline) return;
20390 if (state.activeValue && Array.isArray(state.selectedValue)) {
20391 if (state.selectedValue.includes(state.activeValue)) return;
20392 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
20393 }
20394 return state.activeValue;
20395 });
20396 const items = useStoreState(store, "renderedItems");
20397 const open = useStoreState(store, "open");
20398 const contentElement = useStoreState(store, "contentElement");
20399 const value = (0, import_react28.useMemo)(() => {
20400 if (!inline4) return storeValue;
20401 if (!canInline) return storeValue;
20402 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
20403 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
20404 return storeValue;
20405 }
20406 return inlineActiveValue || storeValue;
20407 }, [
20408 inline4,
20409 canInline,
20410 items,
20411 inlineActiveValue,
20412 autoSelect,
20413 storeValue
20414 ]);
20415 (0, import_react28.useEffect)(() => {
20416 const element = ref.current;
20417 if (!element) return;
20418 const onCompositeItemMove = () => setCanInline(true);
20419 element.addEventListener("combobox-item-move", onCompositeItemMove);
20420 return () => {
20421 element.removeEventListener("combobox-item-move", onCompositeItemMove);
20422 };
20423 }, []);
20424 (0, import_react28.useEffect)(() => {
20425 if (!inline4) return;
20426 if (!canInline) return;
20427 if (!inlineActiveValue) return;
20428 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
20429 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
20430 let cleanup = noop4;
20431 queueMicrotask(() => {
20432 const element = ref.current;
20433 if (!element) return;
20434 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
20435 const nextStart = storeValue.length;
20436 const nextEnd = inlineActiveValue.length;
20437 setSelectionRange(element, nextStart, nextEnd);
20438 cleanup = () => {
20439 if (!hasFocus(element)) return;
20440 const { start, end } = getTextboxSelection(element);
20441 if (start !== nextStart) return;
20442 if (end !== nextEnd) return;
20443 setSelectionRange(element, prevStart, prevEnd);
20444 };
20445 });
20446 return () => cleanup();
20447 }, [
20448 valueUpdated,
20449 inline4,
20450 canInline,
20451 inlineActiveValue,
20452 items,
20453 autoSelect,
20454 storeValue
20455 ]);
20456 const scrollingElementRef = (0, import_react28.useRef)(null);
20457 const getAutoSelectIdProp = useEvent(getAutoSelectId);
20458 const autoSelectIdRef = (0, import_react28.useRef)(null);
20459 const autoSelectMovedRef = (0, import_react28.useRef)(void 0);
20460 const userScrolledRef = (0, import_react28.useRef)(false);
20461 const isAutoScrollingRef = (0, import_react28.useRef)(false);
20462 (0, import_react28.useEffect)(() => {
20463 if (!open) return;
20464 if (!contentElement) return;
20465 const scrollingElement = getScrollingElement(contentElement);
20466 if (!scrollingElement) return;
20467 scrollingElementRef.current = scrollingElement;
20468 const onUserScroll = () => {
20469 canAutoSelectRef.current = false;
20470 userScrolledRef.current = true;
20471 };
20472 const onScroll = () => {
20473 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
20474 if (!store) return;
20475 if (!canAutoSelectRef.current) return;
20476 const { activeId } = store.getState();
20477 if (activeId === null) return;
20478 if (activeId === autoSelectIdRef.current) return;
20479 canAutoSelectRef.current = false;
20480 };
20481 const options = {
20482 passive: true,
20483 capture: true
20484 };
20485 scrollingElement.addEventListener("wheel", onUserScroll, options);
20486 scrollingElement.addEventListener("touchmove", onUserScroll, options);
20487 scrollingElement.addEventListener("scroll", onScroll, options);
20488 return () => {
20489 scrollingElement.removeEventListener("wheel", onUserScroll, true);
20490 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
20491 scrollingElement.removeEventListener("scroll", onScroll, true);
20492 };
20493 }, [
20494 open,
20495 contentElement,
20496 store
20497 ]);
20498 useSafeLayoutEffect(() => {
20499 userScrolledRef.current = false;
20500 if (!storeValue) return;
20501 if (composingRef.current) return;
20502 canAutoSelectRef.current = true;
20503 }, [storeValue]);
20504 useSafeLayoutEffect(() => {
20505 if (autoSelect !== "always" && open) return;
20506 canAutoSelectRef.current = open;
20507 }, [autoSelect, open]);
20508 useSafeLayoutEffect(() => {
20509 if (open) return;
20510 autoSelectMovedRef.current = void 0;
20511 }, [open]);
20512 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
20513 useUpdateEffect(() => {
20514 const canAutoSelect = canAutoSelectRef.current;
20515 if (!store) return;
20516 if (!open) return;
20517 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
20518 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
20519 if (baseElement && !hasFocus(baseElement)) return;
20520 if (contentElement2?.hasAttribute("data-placing")) {
20521 const observer = new MutationObserver(forceValueUpdate);
20522 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
20523 return () => observer.disconnect();
20524 }
20525 if (autoSelect && canAutoSelect) {
20526 const userAutoSelectId = getAutoSelectIdProp(items);
20527 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
20528 autoSelectIdRef.current = autoSelectId;
20529 const nextActiveId = autoSelectId ?? null;
20530 const nextActiveValue = store.item(nextActiveId)?.value;
20531 const moved = autoSelectMovedRef.current;
20532 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
20533 autoSelectMovedRef.current = {
20534 id: nextActiveId,
20535 value: nextActiveValue
20536 };
20537 store.move(nextActiveId);
20538 } else store.setState("activeValue", nextActiveValue);
20539 } else {
20540 const element = store.item(activeId || store.first())?.element;
20541 if (element && "scrollIntoView" in element) {
20542 isAutoScrollingRef.current = true;
20543 element.scrollIntoView({
20544 block: "nearest",
20545 inline: "nearest"
20546 });
20547 requestAnimationFrame(() => {
20548 isAutoScrollingRef.current = false;
20549 });
20550 }
20551 }
20552 }, [
20553 store,
20554 open,
20555 valueUpdated,
20556 storeValue,
20557 autoSelect,
20558 resetValueOnSelect,
20559 getAutoSelectIdProp,
20560 items
20561 ]);
20562 (0, import_react28.useEffect)(() => {
20563 if (!inline4) return;
20564 const combobox = ref.current;
20565 if (!combobox) return;
20566 const elements = [combobox, contentElement].filter((value2) => !!value2);
20567 const onBlur2 = (event) => {
20568 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
20569 };
20570 for (const element of elements) element.addEventListener("focusout", onBlur2);
20571 return () => {
20572 for (const element of elements) element.removeEventListener("focusout", onBlur2);
20573 };
20574 }, [
20575 inline4,
20576 contentElement,
20577 store,
20578 value
20579 ]);
20580 const canShow = (event) => {
20581 return event.currentTarget.value.length >= showMinLength;
20582 };
20583 const onChangeProp = props.onChange;
20584 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
20585 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
20586 const onChange = useEvent((event) => {
20587 onChangeProp?.(event);
20588 if (event.defaultPrevented) return;
20589 if (!store) return;
20590 const currentTarget = event.currentTarget;
20591 const { value: value2, selectionStart, selectionEnd } = currentTarget;
20592 const nativeEvent = event.nativeEvent;
20593 canAutoSelectRef.current = true;
20594 if (isInputEvent(nativeEvent)) {
20595 if (nativeEvent.isComposing) {
20596 canAutoSelectRef.current = false;
20597 composingRef.current = true;
20598 }
20599 if (inline4) {
20600 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
20601 const caretAtEnd = selectionStart === value2.length;
20602 setCanInline(textInserted && caretAtEnd);
20603 }
20604 }
20605 if (setValueOnChangeProp(event)) {
20606 const isSameValue = value2 === store.getState().value;
20607 store.setValue(value2);
20608 queueMicrotask(() => {
20609 setSelectionRange(currentTarget, selectionStart, selectionEnd);
20610 });
20611 if (inline4 && autoSelect && isSameValue) forceValueUpdate();
20612 }
20613 if (showOnChangeProp(event)) store.show();
20614 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
20615 });
20616 const onCompositionEndProp = props.onCompositionEnd;
20617 const onCompositionEnd = useEvent((event) => {
20618 canAutoSelectRef.current = true;
20619 composingRef.current = false;
20620 onCompositionEndProp?.(event);
20621 if (event.defaultPrevented) return;
20622 if (!autoSelect) return;
20623 forceValueUpdate();
20624 });
20625 const onMouseDownProp = props.onMouseDown;
20626 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
20627 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
20628 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
20629 const onMouseDown = useEvent((event) => {
20630 onMouseDownProp?.(event);
20631 if (event.defaultPrevented) return;
20632 if (event.button) return;
20633 if (event.ctrlKey) return;
20634 if (!store) return;
20635 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
20636 if (setValueOnClickProp(event)) store.setValue(value);
20637 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
20638 });
20639 const onKeyDownProp = props.onKeyDown;
20640 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
20641 const onKeyDown = useEvent((event) => {
20642 onKeyDownProp?.(event);
20643 if (!event.repeat) canAutoSelectRef.current = false;
20644 if (event.defaultPrevented) return;
20645 if (!store) return;
20646 const { open: open2 } = store.getState();
20647 if (open2 && event.key === "Enter") {
20648 event.preventDefault();
20649 return;
20650 }
20651 if (event.ctrlKey) return;
20652 if (event.altKey) return;
20653 if (event.shiftKey) return;
20654 if (event.metaKey) return;
20655 if (open2) return;
20656 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
20657 if (showOnKeyPressProp(event)) {
20658 event.preventDefault();
20659 store.show();
20660 }
20661 }
20662 });
20663 const onBlurProp = props.onBlur;
20664 const onBlur = useEvent((event) => {
20665 canAutoSelectRef.current = false;
20666 onBlurProp?.(event);
20667 if (event.defaultPrevented) return;
20668 });
20669 const id = useId5(props.id);
20670 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
20671 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
20672 props = {
20673 role: "combobox",
20674 "aria-autocomplete": ariaAutoComplete,
20675 "aria-haspopup": getPopupRole(contentElement, "listbox"),
20676 "aria-expanded": open,
20677 "aria-controls": contentElement?.id,
20678 "data-active-item": isActiveItem || void 0,
20679 value,
20680 ...props,
20681 id,
20682 ref: useMergeRefs(ref, props.ref),
20683 onChange,
20684 onCompositionEnd,
20685 onMouseDown,
20686 onKeyDown,
20687 onBlur
20688 };
20689 props = useComposite({
20690 store,
20691 focusable: focusable2,
20692 ...props,
20693 moveOnKeyPress: (event) => {
20694 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
20695 if (inline4) setCanInline(true);
20696 return true;
20697 }
20698 });
20699 props = usePopoverAnchor({
20700 store,
20701 ...props
20702 });
20703 return {
20704 autoComplete: "off",
20705 ...props
20706 };
20707 });
20708 var Combobox = forwardRef49(function Combobox2(props) {
20709 return createElement3(TagName9, useCombobox(props));
20710 });
20711
20712 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
20713 var import_react29 = __toESM(require_react(), 1);
20714 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
20715 var TagName10 = "div";
20716 function isSelected(storeValue, itemValue) {
20717 if (itemValue == null) return;
20718 if (storeValue == null) return false;
20719 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
20720 return storeValue === itemValue;
20721 }
20722 function getItemRole(popupRole) {
20723 return {
20724 menu: "menuitem",
20725 listbox: "option",
20726 tree: "treeitem"
20727 }[popupRole] ?? "option";
20728 }
20729 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
20730 const context = useComboboxScopedContext();
20731 store = store || context;
20732 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
20733 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
20734 resetValueOnSelectState: "resetValueOnSelect",
20735 multiSelectable(state) {
20736 return Array.isArray(state.selectedValue);
20737 },
20738 selected(state) {
20739 return isSelected(state.selectedValue, value);
20740 }
20741 });
20742 const getItem = (0, import_react29.useCallback)((item) => {
20743 const nextItem = {
20744 ...item,
20745 value
20746 };
20747 if (getItemProp) return getItemProp(nextItem);
20748 return nextItem;
20749 }, [value, getItemProp]);
20750 setValueOnClick = setValueOnClick ?? !multiSelectable;
20751 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
20752 const onClickProp = props.onClick;
20753 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
20754 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
20755 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
20756 const hideOnClickProp = useBooleanEvent(hideOnClick);
20757 const onClick = useEvent((event) => {
20758 onClickProp?.(event);
20759 if (event.defaultPrevented) return;
20760 if (isDownloading(event)) return;
20761 if (isOpeningInNewTab(event)) return;
20762 if (value != null) {
20763 if (selectValueOnClickProp(event)) {
20764 if (resetValueOnSelectProp(event)) store?.resetValue();
20765 store?.setSelectedValue((prevValue) => {
20766 if (!Array.isArray(prevValue)) return value;
20767 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
20768 return [...prevValue, value];
20769 });
20770 }
20771 if (setValueOnClickProp(event)) store?.setValue(value);
20772 }
20773 if (hideOnClickProp(event)) store?.hide();
20774 });
20775 const onKeyDownProp = props.onKeyDown;
20776 const onKeyDown = useEvent((event) => {
20777 onKeyDownProp?.(event);
20778 if (event.defaultPrevented) return;
20779 const baseElement = store?.getState().baseElement;
20780 if (!baseElement) return;
20781 if (hasFocus(baseElement)) return;
20782 if (event.key.length === 1 || event.key === "Backspace" || event.key === "Delete") {
20783 queueMicrotask(() => baseElement.focus());
20784 if (isTextField(baseElement)) store?.setValue(baseElement.value);
20785 }
20786 });
20787 if (multiSelectable && selected != null) props = {
20788 "aria-selected": selected,
20789 ...props
20790 };
20791 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ComboboxItemValueContext.Provider, {
20792 value,
20793 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ComboboxItemCheckedContext.Provider, {
20794 value: selected ?? false,
20795 children: element
20796 })
20797 }), [value, selected]);
20798 props = {
20799 role: getItemRole((0, import_react29.useContext)(ComboboxListRoleContext)),
20800 children: value,
20801 ...props,
20802 onClick,
20803 onKeyDown
20804 };
20805 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
20806 props = useCompositeItem({
20807 store,
20808 ...props,
20809 getItem,
20810 moveOnKeyPress: (event) => {
20811 if (!moveOnKeyPressProp(event)) return false;
20812 const moveEvent = new Event("combobox-item-move");
20813 store?.getState().baseElement?.dispatchEvent(moveEvent);
20814 return true;
20815 }
20816 });
20817 props = useCompositeHover({
20818 store,
20819 focusOnHover,
20820 ...props
20821 });
20822 return props;
20823 });
20824 var ComboboxItem = memo3(forwardRef49(function ComboboxItem2(props) {
20825 return createElement3(TagName10, useComboboxItem(props));
20826 }));
20827
20828 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
20829 var import_react30 = __toESM(require_react(), 1);
20830 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
20831 var TagName11 = "span";
20832 function normalizeValue(value) {
20833 return normalizeString(value).toLowerCase();
20834 }
20835 function getOffsets(string, values) {
20836 const offsets = [];
20837 for (const value of values) {
20838 let pos = 0;
20839 const length = value.length;
20840 while (string.indexOf(value, pos) !== -1) {
20841 const index2 = string.indexOf(value, pos);
20842 if (index2 !== -1) offsets.push([index2, length]);
20843 pos = index2 + 1;
20844 }
20845 }
20846 return offsets;
20847 }
20848 function filterOverlappingOffsets(offsets) {
20849 return offsets.filter(([offset4, length], i2, arr) => {
20850 return !arr.some(([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length);
20851 });
20852 }
20853 function sortOffsets(offsets) {
20854 return offsets.sort(([a2], [b2]) => a2 - b2);
20855 }
20856 function splitValue(itemValue, userValue) {
20857 if (!itemValue) return itemValue;
20858 if (!userValue) return itemValue;
20859 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
20860 const parts = [];
20861 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", {
20862 "data-autocomplete-value": autocomplete ? "" : void 0,
20863 "data-user-value": autocomplete ? void 0 : "",
20864 children: value
20865 }, parts.length);
20866 const offsets = sortOffsets(filterOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
20867 const firstEntry = offsets[0];
20868 if (!firstEntry) {
20869 parts.push(span(itemValue, true));
20870 return parts;
20871 }
20872 const [firstOffset] = firstEntry;
20873 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
20874 const value = itemValue.slice(offset4, offset4 + length);
20875 const nextOffset = offsets[i2 + 1]?.[0];
20876 return [value, itemValue.slice(offset4 + length, nextOffset)];
20877 })].forEach((value, i2) => {
20878 if (!value) return;
20879 parts.push(span(value, i2 % 2 === 0));
20880 });
20881 return parts;
20882 }
20883 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
20884 const context = useComboboxScopedContext();
20885 store = store || context;
20886 const itemContext = (0, import_react30.useContext)(ComboboxItemValueContext);
20887 const itemValue = value ?? itemContext;
20888 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
20889 props = {
20890 children: (0, import_react30.useMemo)(() => {
20891 if (!itemValue) return;
20892 if (!inputValue) return itemValue;
20893 return splitValue(itemValue, inputValue);
20894 }, [itemValue, inputValue]),
20895 ...props
20896 };
20897 return removeUndefinedValues(props);
20898 });
20899 var ComboboxItemValue = forwardRef49(function ComboboxItemValue2(props) {
20900 return createElement3(TagName11, useComboboxItemValue(props));
20901 });
20902
20903 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
20904 var TagName12 = "label";
20905 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
20906 const context = useComboboxProviderContext();
20907 store = store || context;
20908 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
20909 props = {
20910 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
20911 ...props
20912 };
20913 return removeUndefinedValues(props);
20914 });
20915 var ComboboxLabel = memo3(forwardRef49(function ComboboxLabel2(props) {
20916 return createElement3(TagName12, useComboboxLabel(props));
20917 }));
20918
20919 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
20920 var import_react31 = __toESM(require_react(), 1);
20921 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
20922 var TagName13 = "div";
20923 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
20924 const scopedContext = useComboboxScopedContext(true);
20925 const context = useComboboxContext();
20926 store = store || context;
20927 const scopedContextSameStore = !!store && store === scopedContext;
20928 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
20929 const ref = (0, import_react31.useRef)(null);
20930 const id = useId5(props.id);
20931 const mounted = useStoreState(store, "mounted");
20932 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
20933 const style = hidden ? {
20934 ...props.style,
20935 display: "none"
20936 } : props.style;
20937 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
20938 const role = useAttribute(ref, "role", props.role);
20939 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
20940 const [hasListboxInside, setHasListboxInside] = (0, import_react31.useState)(false);
20941 const contentElement = useStoreState(store, "contentElement");
20942 useSafeLayoutEffect(() => {
20943 if (!mounted) return;
20944 const element = ref.current;
20945 if (!element) return;
20946 if (contentElement !== element) return;
20947 const callback = () => {
20948 setHasListboxInside(!!element.querySelector("[role='listbox']"));
20949 };
20950 const observer = new MutationObserver(callback);
20951 observer.observe(element, {
20952 subtree: true,
20953 childList: true,
20954 attributeFilter: ["role"]
20955 });
20956 callback();
20957 return () => observer.disconnect();
20958 }, [mounted, contentElement]);
20959 if (!hasListboxInside) props = {
20960 role: "listbox",
20961 "aria-multiselectable": ariaMultiSelectable,
20962 ...props
20963 };
20964 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(ComboboxScopedContextProvider, {
20965 value: store,
20966 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(ComboboxListRoleContext.Provider, {
20967 value: role,
20968 children: element
20969 })
20970 }), [store, role]);
20971 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
20972 props = {
20973 hidden,
20974 ...props,
20975 id,
20976 ref: useMergeRefs(setContentElement, ref, props.ref),
20977 style
20978 };
20979 return removeUndefinedValues(props);
20980 });
20981 var ComboboxList = forwardRef49(function ComboboxList2(props) {
20982 return createElement3(TagName13, useComboboxList(props));
20983 });
20984
20985 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
20986 var import_react32 = __toESM(require_react(), 1);
20987 var TagValueContext = (0, import_react32.createContext)(null);
20988 var TagRemoveIdContext = (0, import_react32.createContext)(null);
20989 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
20990 var useTagContext = ctx7.useContext;
20991 var useTagScopedContext = ctx7.useScopedContext;
20992 var useTagProviderContext = ctx7.useProviderContext;
20993 var TagContextProvider = ctx7.ContextProvider;
20994 var TagScopedContextProvider = ctx7.ScopedContextProvider;
20995
20996 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
20997 var isTouchSafari = isSafari2() && isTouchDevice();
20998 function createComboboxStore({ tag, ...props } = {}) {
20999 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
21000 throwOnConflictingProps(props, store);
21001 const tagState = tag?.getState();
21002 const syncState = store?.getState();
21003 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
21004 const composite = createCompositeStore({
21005 ...props,
21006 activeId,
21007 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
21008 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
21009 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
21010 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
21011 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
21012 });
21013 const popover = createPopoverStore({
21014 ...props,
21015 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
21016 });
21017 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
21018 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
21019 const multiSelectable = Array.isArray(selectedValue);
21020 const initialState = {
21021 ...composite.getState(),
21022 ...popover.getState(),
21023 value,
21024 selectedValue,
21025 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
21026 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
21027 activeValue: syncState?.activeValue
21028 };
21029 const combobox = createStore(initialState, composite, popover, store);
21030 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
21031 combobox.setState("virtualFocus", false);
21032 }));
21033 setup(combobox, () => {
21034 if (!tag) return;
21035 return chain(sync(combobox, ["selectedValue"], (state) => {
21036 if (!Array.isArray(state.selectedValue)) return;
21037 tag.setValues(state.selectedValue);
21038 }), sync(tag, ["values"], (state) => {
21039 combobox.setState("selectedValue", state.values);
21040 }));
21041 });
21042 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
21043 if (!state.resetValueOnHide) return;
21044 if (state.mounted) return;
21045 combobox.setState("value", value);
21046 }));
21047 setup(combobox, () => sync(combobox, ["open"], (state) => {
21048 if (state.open) return;
21049 combobox.setState("activeId", activeId);
21050 combobox.setState("moves", 0);
21051 }));
21052 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
21053 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
21054 }));
21055 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
21056 if (state.moves === prev.moves) return;
21057 const { activeId: activeId2 } = combobox.getState();
21058 const activeItem = composite.item(activeId2);
21059 combobox.setState("activeValue", activeItem?.value);
21060 }));
21061 return {
21062 ...popover,
21063 ...composite,
21064 ...combobox,
21065 tag,
21066 setValue: (value2) => combobox.setState("value", value2),
21067 resetValue: () => combobox.setState("value", initialState.value),
21068 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
21069 };
21070 }
21071
21072 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
21073 function useComboboxStoreOptions(props) {
21074 const tag = useTagContext();
21075 props = {
21076 ...props,
21077 tag: props.tag !== void 0 ? props.tag : tag
21078 };
21079 return useCompositeStoreOptions(props);
21080 }
21081 function useComboboxStoreProps(store, update2, props) {
21082 useUpdateEffect(update2, [props.tag]);
21083 useStoreProps(store, props, "value", "setValue");
21084 useStoreProps(store, props, "selectedValue", "setSelectedValue");
21085 useStoreProps(store, props, "resetValueOnHide");
21086 useStoreProps(store, props, "resetValueOnSelect");
21087 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
21088 }
21089 function useComboboxStore(props = {}) {
21090 props = useComboboxStoreOptions(props);
21091 const [store, update2] = useStore2(createComboboxStore, props);
21092 return useComboboxStoreProps(store, update2, props);
21093 }
21094
21095 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
21096 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
21097 function ComboboxProvider(props = {}) {
21098 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(ComboboxContextProvider, {
21099 value: useComboboxStore(props),
21100 children: props.children
21101 });
21102 }
21103
21104 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
21105 var import_remove_accents = __toESM(require_remove_accents(), 1);
21106 var import_compose8 = __toESM(require_compose(), 1);
21107 var import_i18n25 = __toESM(require_i18n(), 1);
21108 var import_element67 = __toESM(require_element(), 1);
21109 var import_components19 = __toESM(require_components(), 1);
21110
21111 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
21112 var EMPTY_ARRAY3 = [];
21113 var getCurrentValue = (filterDefinition, currentFilter) => {
21114 if (filterDefinition.singleSelection) {
21115 return currentFilter?.value;
21116 }
21117 if (Array.isArray(currentFilter?.value)) {
21118 return currentFilter.value;
21119 }
21120 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
21121 return [currentFilter.value];
21122 }
21123 return EMPTY_ARRAY3;
21124 };
21125
21126 // packages/dataviews/build-module/hooks/use-elements.mjs
21127 var import_element66 = __toESM(require_element(), 1);
21128 var EMPTY_ARRAY4 = [];
21129 function useElements({
21130 elements,
21131 getElements
21132 }) {
21133 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
21134 const [records, setRecords] = (0, import_element66.useState)(staticElements);
21135 const [isLoading, setIsLoading] = (0, import_element66.useState)(false);
21136 (0, import_element66.useEffect)(() => {
21137 if (!getElements) {
21138 setRecords(staticElements);
21139 return;
21140 }
21141 let cancelled = false;
21142 setIsLoading(true);
21143 getElements().then((fetchedElements) => {
21144 if (!cancelled) {
21145 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
21146 setRecords(dynamicElements);
21147 }
21148 }).catch(() => {
21149 if (!cancelled) {
21150 setRecords(staticElements);
21151 }
21152 }).finally(() => {
21153 if (!cancelled) {
21154 setIsLoading(false);
21155 }
21156 });
21157 return () => {
21158 cancelled = true;
21159 };
21160 }, [getElements, staticElements]);
21161 return {
21162 elements: records,
21163 isLoading
21164 };
21165 }
21166
21167 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
21168 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
21169 function normalizeSearchInput(input = "") {
21170 return (0, import_remove_accents.default)(input.trim().toLowerCase());
21171 }
21172 var getNewValue = (filterDefinition, currentFilter, value) => {
21173 if (filterDefinition.singleSelection) {
21174 return value;
21175 }
21176 if (Array.isArray(currentFilter?.value)) {
21177 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
21178 }
21179 return [value];
21180 };
21181 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
21182 return `${prefix}-${filterElementValue}`;
21183 }
21184 var MultiSelectionOption = ({ selected }) => {
21185 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21186 "span",
21187 {
21188 className: clsx_default(
21189 "dataviews-filters__search-widget-listitem-multi-selection",
21190 { "is-selected": selected }
21191 ),
21192 children: selected && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components19.Icon, { icon: check_default })
21193 }
21194 );
21195 };
21196 var SingleSelectionOption = ({ selected }) => {
21197 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21198 "span",
21199 {
21200 className: clsx_default(
21201 "dataviews-filters__search-widget-listitem-single-selection",
21202 { "is-selected": selected }
21203 )
21204 }
21205 );
21206 };
21207 function ListBox({ view, filter, onChangeView }) {
21208 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
21209 const [activeCompositeId, setActiveCompositeId] = (0, import_element67.useState)(
21210 // When there are one or less operators, the first item is set as active
21211 // (by setting the initial `activeId` to `undefined`).
21212 // With 2 or more operators, the focus is moved on the operators control
21213 // (by setting the initial `activeId` to `null`), meaning that there won't
21214 // be an active item initially. Focus is then managed via the
21215 // `onFocusVisible` callback.
21216 filter.operators?.length === 1 ? void 0 : null
21217 );
21218 const currentFilter = view.filters?.find(
21219 (f2) => f2.field === filter.field
21220 );
21221 const currentValue = getCurrentValue(filter, currentFilter);
21222 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21223 import_components19.Composite,
21224 {
21225 virtualFocus: true,
21226 focusLoop: true,
21227 activeId: activeCompositeId,
21228 setActiveId: setActiveCompositeId,
21229 role: "listbox",
21230 className: "dataviews-filters__search-widget-listbox",
21231 "aria-label": (0, import_i18n25.sprintf)(
21232 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
21233 (0, import_i18n25.__)("List of: %1$s"),
21234 filter.name
21235 ),
21236 onFocusVisible: () => {
21237 if (!activeCompositeId && filter.elements.length) {
21238 setActiveCompositeId(
21239 generateFilterElementCompositeItemId(
21240 baseId,
21241 filter.elements[0].value
21242 )
21243 );
21244 }
21245 },
21246 render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components19.Composite.Typeahead, {}),
21247 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21248 import_components19.Composite.Hover,
21249 {
21250 render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21251 import_components19.Composite.Item,
21252 {
21253 id: generateFilterElementCompositeItemId(
21254 baseId,
21255 element.value
21256 ),
21257 render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21258 "div",
21259 {
21260 "aria-label": element.label,
21261 role: "option",
21262 className: "dataviews-filters__search-widget-listitem"
21263 }
21264 ),
21265 onClick: () => {
21266 const newFilters = currentFilter ? [
21267 ...(view.filters ?? []).map(
21268 (_filter) => {
21269 if (_filter.field === filter.field) {
21270 return {
21271 ..._filter,
21272 operator: currentFilter.operator || filter.operators[0],
21273 value: getNewValue(
21274 filter,
21275 currentFilter,
21276 element.value
21277 )
21278 };
21279 }
21280 return _filter;
21281 }
21282 )
21283 ] : [
21284 ...view.filters ?? [],
21285 {
21286 field: filter.field,
21287 operator: filter.operators[0],
21288 value: getNewValue(
21289 filter,
21290 currentFilter,
21291 element.value
21292 )
21293 }
21294 ];
21295 onChangeView({
21296 ...view,
21297 page: 1,
21298 filters: newFilters
21299 });
21300 }
21301 }
21302 ),
21303 children: [
21304 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21305 SingleSelectionOption,
21306 {
21307 selected: currentValue === element.value
21308 }
21309 ),
21310 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21311 MultiSelectionOption,
21312 {
21313 selected: currentValue.includes(element.value)
21314 }
21315 ),
21316 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21317 "span",
21318 {
21319 className: "dataviews-filters__search-widget-listitem-value",
21320 title: element.label,
21321 children: element.label
21322 }
21323 )
21324 ]
21325 },
21326 element.value
21327 ))
21328 }
21329 );
21330 }
21331 function ComboboxList22({ view, filter, onChangeView }) {
21332 const [searchValue, setSearchValue] = (0, import_element67.useState)("");
21333 const deferredSearchValue = (0, import_element67.useDeferredValue)(searchValue);
21334 const currentFilter = view.filters?.find(
21335 (_filter) => _filter.field === filter.field
21336 );
21337 const currentValue = getCurrentValue(filter, currentFilter);
21338 const matches = (0, import_element67.useMemo)(() => {
21339 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
21340 return filter.elements.filter(
21341 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
21342 );
21343 }, [filter.elements, deferredSearchValue]);
21344 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21345 ComboboxProvider,
21346 {
21347 selectedValue: currentValue,
21348 setSelectedValue: (value) => {
21349 const newFilters = currentFilter ? [
21350 ...(view.filters ?? []).map((_filter) => {
21351 if (_filter.field === filter.field) {
21352 return {
21353 ..._filter,
21354 operator: currentFilter.operator || filter.operators[0],
21355 value
21356 };
21357 }
21358 return _filter;
21359 })
21360 ] : [
21361 ...view.filters ?? [],
21362 {
21363 field: filter.field,
21364 operator: filter.operators[0],
21365 value
21366 }
21367 ];
21368 onChangeView({
21369 ...view,
21370 page: 1,
21371 filters: newFilters
21372 });
21373 },
21374 setValue: setSearchValue,
21375 children: [
21376 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
21377 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(ComboboxLabel, {}), children: (0, import_i18n25.__)("Search items") }),
21378 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21379 Combobox,
21380 {
21381 autoSelect: "always",
21382 placeholder: (0, import_i18n25.__)("Search"),
21383 className: "dataviews-filters__search-widget-filter-combobox__input"
21384 }
21385 ),
21386 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components19.Icon, { icon: search_default }) })
21387 ] }),
21388 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21389 ComboboxList,
21390 {
21391 className: "dataviews-filters__search-widget-filter-combobox-list",
21392 alwaysVisible: true,
21393 children: [
21394 matches.map((element) => {
21395 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21396 ComboboxItem,
21397 {
21398 resetValueOnSelect: false,
21399 value: element.value,
21400 className: "dataviews-filters__search-widget-listitem",
21401 hideOnClick: false,
21402 setValueOnClick: false,
21403 focusOnHover: true,
21404 children: [
21405 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21406 SingleSelectionOption,
21407 {
21408 selected: currentValue === element.value
21409 }
21410 ),
21411 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21412 MultiSelectionOption,
21413 {
21414 selected: currentValue.includes(
21415 element.value
21416 )
21417 }
21418 ),
21419 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21420 "span",
21421 {
21422 className: "dataviews-filters__search-widget-listitem-value",
21423 title: element.label,
21424 children: [
21425 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21426 ComboboxItemValue,
21427 {
21428 className: "dataviews-filters__search-widget-filter-combobox-item-value",
21429 value: element.label
21430 }
21431 ),
21432 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
21433 ]
21434 }
21435 )
21436 ]
21437 },
21438 element.value
21439 );
21440 }),
21441 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("p", { children: (0, import_i18n25.__)("No results found") })
21442 ]
21443 }
21444 )
21445 ]
21446 }
21447 );
21448 }
21449 function SearchWidget(props) {
21450 const { elements, isLoading } = useElements({
21451 elements: props.filter.elements,
21452 getElements: props.filter.getElements
21453 });
21454 if (isLoading) {
21455 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components19.Spinner, {}) });
21456 }
21457 if (elements.length === 0) {
21458 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n25.__)("No elements found") });
21459 }
21460 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
21461 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
21462 }
21463
21464 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
21465 var import_es6 = __toESM(require_es6(), 1);
21466 var import_compose9 = __toESM(require_compose(), 1);
21467 var import_element68 = __toESM(require_element(), 1);
21468 var import_components20 = __toESM(require_components(), 1);
21469 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
21470 function InputWidget({
21471 filter,
21472 view,
21473 onChangeView,
21474 fields
21475 }) {
21476 const currentFilter = view.filters?.find(
21477 (f2) => f2.field === filter.field
21478 );
21479 const currentValue = getCurrentValue(filter, currentFilter);
21480 const field = (0, import_element68.useMemo)(() => {
21481 const currentField = fields.find((f2) => f2.id === filter.field);
21482 if (currentField) {
21483 return {
21484 ...currentField,
21485 // Deactivate validation for filters.
21486 isValid: {},
21487 // Filter controls are always enabled.
21488 isDisabled: () => false,
21489 // Filter controls are always visible.
21490 isVisible: () => true,
21491 // Configure getValue/setValue as if Item was a plain object.
21492 getValue: ({ item }) => item[currentField.id],
21493 setValue: ({ value }) => ({
21494 [currentField.id]: value
21495 })
21496 };
21497 }
21498 return currentField;
21499 }, [fields, filter.field]);
21500 const data = (0, import_element68.useMemo)(() => {
21501 return (view.filters ?? []).reduce(
21502 (acc, activeFilter) => {
21503 acc[activeFilter.field] = activeFilter.value;
21504 return acc;
21505 },
21506 {}
21507 );
21508 }, [view.filters]);
21509 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
21510 if (!field || !currentFilter) {
21511 return;
21512 }
21513 const nextValue = field.getValue({ item: updatedData });
21514 if ((0, import_es6.default)(nextValue, currentValue)) {
21515 return;
21516 }
21517 onChangeView({
21518 ...view,
21519 filters: (view.filters ?? []).map(
21520 (_filter) => _filter.field === filter.field ? {
21521 ..._filter,
21522 operator: currentFilter.operator || filter.operators[0],
21523 // Consider empty strings as undefined:
21524 //
21525 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
21526 // - empty string as value means "search empty string": returns only the records that have an empty string as value
21527 //
21528 // In practice, this means the filter will not be able to find an empty string as the value.
21529 value: nextValue === "" ? void 0 : nextValue
21530 } : _filter
21531 )
21532 });
21533 });
21534 if (!field || !field.Edit || !currentFilter) {
21535 return null;
21536 }
21537 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
21538 import_components20.Flex,
21539 {
21540 className: "dataviews-filters__user-input-widget",
21541 gap: 2.5,
21542 direction: "column",
21543 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
21544 field.Edit,
21545 {
21546 hideLabelFromVision: true,
21547 data,
21548 field,
21549 operator: currentFilter.operator,
21550 onChange: handleChange
21551 }
21552 )
21553 }
21554 );
21555 }
21556
21557 // node_modules/date-fns/constants.js
21558 var daysInYear = 365.2425;
21559 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
21560 var minTime = -maxTime;
21561 var millisecondsInWeek = 6048e5;
21562 var millisecondsInDay = 864e5;
21563 var secondsInHour = 3600;
21564 var secondsInDay = secondsInHour * 24;
21565 var secondsInWeek = secondsInDay * 7;
21566 var secondsInYear = secondsInDay * daysInYear;
21567 var secondsInMonth = secondsInYear / 12;
21568 var secondsInQuarter = secondsInMonth * 3;
21569 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
21570
21571 // node_modules/date-fns/constructFrom.js
21572 function constructFrom(date, value) {
21573 if (typeof date === "function") return date(value);
21574 if (date && typeof date === "object" && constructFromSymbol in date)
21575 return date[constructFromSymbol](value);
21576 if (date instanceof Date) return new date.constructor(value);
21577 return new Date(value);
21578 }
21579
21580 // node_modules/date-fns/toDate.js
21581 function toDate(argument, context) {
21582 return constructFrom(context || argument, argument);
21583 }
21584
21585 // node_modules/date-fns/addDays.js
21586 function addDays(date, amount, options) {
21587 const _date = toDate(date, options?.in);
21588 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
21589 if (!amount) return _date;
21590 _date.setDate(_date.getDate() + amount);
21591 return _date;
21592 }
21593
21594 // node_modules/date-fns/addMonths.js
21595 function addMonths(date, amount, options) {
21596 const _date = toDate(date, options?.in);
21597 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
21598 if (!amount) {
21599 return _date;
21600 }
21601 const dayOfMonth = _date.getDate();
21602 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
21603 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
21604 const daysInMonth = endOfDesiredMonth.getDate();
21605 if (dayOfMonth >= daysInMonth) {
21606 return endOfDesiredMonth;
21607 } else {
21608 _date.setFullYear(
21609 endOfDesiredMonth.getFullYear(),
21610 endOfDesiredMonth.getMonth(),
21611 dayOfMonth
21612 );
21613 return _date;
21614 }
21615 }
21616
21617 // node_modules/date-fns/_lib/defaultOptions.js
21618 var defaultOptions = {};
21619 function getDefaultOptions() {
21620 return defaultOptions;
21621 }
21622
21623 // node_modules/date-fns/startOfWeek.js
21624 function startOfWeek(date, options) {
21625 const defaultOptions2 = getDefaultOptions();
21626 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
21627 const _date = toDate(date, options?.in);
21628 const day = _date.getDay();
21629 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
21630 _date.setDate(_date.getDate() - diff);
21631 _date.setHours(0, 0, 0, 0);
21632 return _date;
21633 }
21634
21635 // node_modules/date-fns/startOfISOWeek.js
21636 function startOfISOWeek(date, options) {
21637 return startOfWeek(date, { ...options, weekStartsOn: 1 });
21638 }
21639
21640 // node_modules/date-fns/getISOWeekYear.js
21641 function getISOWeekYear(date, options) {
21642 const _date = toDate(date, options?.in);
21643 const year = _date.getFullYear();
21644 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
21645 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
21646 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
21647 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
21648 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
21649 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
21650 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
21651 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
21652 if (_date.getTime() >= startOfNextYear.getTime()) {
21653 return year + 1;
21654 } else if (_date.getTime() >= startOfThisYear.getTime()) {
21655 return year;
21656 } else {
21657 return year - 1;
21658 }
21659 }
21660
21661 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
21662 function getTimezoneOffsetInMilliseconds(date) {
21663 const _date = toDate(date);
21664 const utcDate = new Date(
21665 Date.UTC(
21666 _date.getFullYear(),
21667 _date.getMonth(),
21668 _date.getDate(),
21669 _date.getHours(),
21670 _date.getMinutes(),
21671 _date.getSeconds(),
21672 _date.getMilliseconds()
21673 )
21674 );
21675 utcDate.setUTCFullYear(_date.getFullYear());
21676 return +date - +utcDate;
21677 }
21678
21679 // node_modules/date-fns/_lib/normalizeDates.js
21680 function normalizeDates(context, ...dates) {
21681 const normalize = constructFrom.bind(
21682 null,
21683 context || dates.find((date) => typeof date === "object")
21684 );
21685 return dates.map(normalize);
21686 }
21687
21688 // node_modules/date-fns/startOfDay.js
21689 function startOfDay(date, options) {
21690 const _date = toDate(date, options?.in);
21691 _date.setHours(0, 0, 0, 0);
21692 return _date;
21693 }
21694
21695 // node_modules/date-fns/differenceInCalendarDays.js
21696 function differenceInCalendarDays(laterDate, earlierDate, options) {
21697 const [laterDate_, earlierDate_] = normalizeDates(
21698 options?.in,
21699 laterDate,
21700 earlierDate
21701 );
21702 const laterStartOfDay = startOfDay(laterDate_);
21703 const earlierStartOfDay = startOfDay(earlierDate_);
21704 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
21705 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
21706 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
21707 }
21708
21709 // node_modules/date-fns/startOfISOWeekYear.js
21710 function startOfISOWeekYear(date, options) {
21711 const year = getISOWeekYear(date, options);
21712 const fourthOfJanuary = constructFrom(options?.in || date, 0);
21713 fourthOfJanuary.setFullYear(year, 0, 4);
21714 fourthOfJanuary.setHours(0, 0, 0, 0);
21715 return startOfISOWeek(fourthOfJanuary);
21716 }
21717
21718 // node_modules/date-fns/addWeeks.js
21719 function addWeeks(date, amount, options) {
21720 return addDays(date, amount * 7, options);
21721 }
21722
21723 // node_modules/date-fns/addYears.js
21724 function addYears(date, amount, options) {
21725 return addMonths(date, amount * 12, options);
21726 }
21727
21728 // node_modules/date-fns/isDate.js
21729 function isDate(value) {
21730 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
21731 }
21732
21733 // node_modules/date-fns/isValid.js
21734 function isValid(date) {
21735 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
21736 }
21737
21738 // node_modules/date-fns/startOfMonth.js
21739 function startOfMonth(date, options) {
21740 const _date = toDate(date, options?.in);
21741 _date.setDate(1);
21742 _date.setHours(0, 0, 0, 0);
21743 return _date;
21744 }
21745
21746 // node_modules/date-fns/startOfYear.js
21747 function startOfYear(date, options) {
21748 const date_ = toDate(date, options?.in);
21749 date_.setFullYear(date_.getFullYear(), 0, 1);
21750 date_.setHours(0, 0, 0, 0);
21751 return date_;
21752 }
21753
21754 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
21755 var formatDistanceLocale = {
21756 lessThanXSeconds: {
21757 one: "less than a second",
21758 other: "less than {{count}} seconds"
21759 },
21760 xSeconds: {
21761 one: "1 second",
21762 other: "{{count}} seconds"
21763 },
21764 halfAMinute: "half a minute",
21765 lessThanXMinutes: {
21766 one: "less than a minute",
21767 other: "less than {{count}} minutes"
21768 },
21769 xMinutes: {
21770 one: "1 minute",
21771 other: "{{count}} minutes"
21772 },
21773 aboutXHours: {
21774 one: "about 1 hour",
21775 other: "about {{count}} hours"
21776 },
21777 xHours: {
21778 one: "1 hour",
21779 other: "{{count}} hours"
21780 },
21781 xDays: {
21782 one: "1 day",
21783 other: "{{count}} days"
21784 },
21785 aboutXWeeks: {
21786 one: "about 1 week",
21787 other: "about {{count}} weeks"
21788 },
21789 xWeeks: {
21790 one: "1 week",
21791 other: "{{count}} weeks"
21792 },
21793 aboutXMonths: {
21794 one: "about 1 month",
21795 other: "about {{count}} months"
21796 },
21797 xMonths: {
21798 one: "1 month",
21799 other: "{{count}} months"
21800 },
21801 aboutXYears: {
21802 one: "about 1 year",
21803 other: "about {{count}} years"
21804 },
21805 xYears: {
21806 one: "1 year",
21807 other: "{{count}} years"
21808 },
21809 overXYears: {
21810 one: "over 1 year",
21811 other: "over {{count}} years"
21812 },
21813 almostXYears: {
21814 one: "almost 1 year",
21815 other: "almost {{count}} years"
21816 }
21817 };
21818 var formatDistance = (token, count, options) => {
21819 let result;
21820 const tokenValue = formatDistanceLocale[token];
21821 if (typeof tokenValue === "string") {
21822 result = tokenValue;
21823 } else if (count === 1) {
21824 result = tokenValue.one;
21825 } else {
21826 result = tokenValue.other.replace("{{count}}", count.toString());
21827 }
21828 if (options?.addSuffix) {
21829 if (options.comparison && options.comparison > 0) {
21830 return "in " + result;
21831 } else {
21832 return result + " ago";
21833 }
21834 }
21835 return result;
21836 };
21837
21838 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
21839 function buildFormatLongFn(args) {
21840 return (options = {}) => {
21841 const width = options.width ? String(options.width) : args.defaultWidth;
21842 const format6 = args.formats[width] || args.formats[args.defaultWidth];
21843 return format6;
21844 };
21845 }
21846
21847 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
21848 var dateFormats = {
21849 full: "EEEE, MMMM do, y",
21850 long: "MMMM do, y",
21851 medium: "MMM d, y",
21852 short: "MM/dd/yyyy"
21853 };
21854 var timeFormats = {
21855 full: "h:mm:ss a zzzz",
21856 long: "h:mm:ss a z",
21857 medium: "h:mm:ss a",
21858 short: "h:mm a"
21859 };
21860 var dateTimeFormats = {
21861 full: "{{date}} 'at' {{time}}",
21862 long: "{{date}} 'at' {{time}}",
21863 medium: "{{date}}, {{time}}",
21864 short: "{{date}}, {{time}}"
21865 };
21866 var formatLong = {
21867 date: buildFormatLongFn({
21868 formats: dateFormats,
21869 defaultWidth: "full"
21870 }),
21871 time: buildFormatLongFn({
21872 formats: timeFormats,
21873 defaultWidth: "full"
21874 }),
21875 dateTime: buildFormatLongFn({
21876 formats: dateTimeFormats,
21877 defaultWidth: "full"
21878 })
21879 };
21880
21881 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
21882 var formatRelativeLocale = {
21883 lastWeek: "'last' eeee 'at' p",
21884 yesterday: "'yesterday at' p",
21885 today: "'today at' p",
21886 tomorrow: "'tomorrow at' p",
21887 nextWeek: "eeee 'at' p",
21888 other: "P"
21889 };
21890 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
21891
21892 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
21893 function buildLocalizeFn(args) {
21894 return (value, options) => {
21895 const context = options?.context ? String(options.context) : "standalone";
21896 let valuesArray;
21897 if (context === "formatting" && args.formattingValues) {
21898 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
21899 const width = options?.width ? String(options.width) : defaultWidth;
21900 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
21901 } else {
21902 const defaultWidth = args.defaultWidth;
21903 const width = options?.width ? String(options.width) : args.defaultWidth;
21904 valuesArray = args.values[width] || args.values[defaultWidth];
21905 }
21906 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
21907 return valuesArray[index2];
21908 };
21909 }
21910
21911 // node_modules/date-fns/locale/en-US/_lib/localize.js
21912 var eraValues = {
21913 narrow: ["B", "A"],
21914 abbreviated: ["BC", "AD"],
21915 wide: ["Before Christ", "Anno Domini"]
21916 };
21917 var quarterValues = {
21918 narrow: ["1", "2", "3", "4"],
21919 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
21920 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
21921 };
21922 var monthValues = {
21923 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
21924 abbreviated: [
21925 "Jan",
21926 "Feb",
21927 "Mar",
21928 "Apr",
21929 "May",
21930 "Jun",
21931 "Jul",
21932 "Aug",
21933 "Sep",
21934 "Oct",
21935 "Nov",
21936 "Dec"
21937 ],
21938 wide: [
21939 "January",
21940 "February",
21941 "March",
21942 "April",
21943 "May",
21944 "June",
21945 "July",
21946 "August",
21947 "September",
21948 "October",
21949 "November",
21950 "December"
21951 ]
21952 };
21953 var dayValues = {
21954 narrow: ["S", "M", "T", "W", "T", "F", "S"],
21955 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
21956 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
21957 wide: [
21958 "Sunday",
21959 "Monday",
21960 "Tuesday",
21961 "Wednesday",
21962 "Thursday",
21963 "Friday",
21964 "Saturday"
21965 ]
21966 };
21967 var dayPeriodValues = {
21968 narrow: {
21969 am: "a",
21970 pm: "p",
21971 midnight: "mi",
21972 noon: "n",
21973 morning: "morning",
21974 afternoon: "afternoon",
21975 evening: "evening",
21976 night: "night"
21977 },
21978 abbreviated: {
21979 am: "AM",
21980 pm: "PM",
21981 midnight: "midnight",
21982 noon: "noon",
21983 morning: "morning",
21984 afternoon: "afternoon",
21985 evening: "evening",
21986 night: "night"
21987 },
21988 wide: {
21989 am: "a.m.",
21990 pm: "p.m.",
21991 midnight: "midnight",
21992 noon: "noon",
21993 morning: "morning",
21994 afternoon: "afternoon",
21995 evening: "evening",
21996 night: "night"
21997 }
21998 };
21999 var formattingDayPeriodValues = {
22000 narrow: {
22001 am: "a",
22002 pm: "p",
22003 midnight: "mi",
22004 noon: "n",
22005 morning: "in the morning",
22006 afternoon: "in the afternoon",
22007 evening: "in the evening",
22008 night: "at night"
22009 },
22010 abbreviated: {
22011 am: "AM",
22012 pm: "PM",
22013 midnight: "midnight",
22014 noon: "noon",
22015 morning: "in the morning",
22016 afternoon: "in the afternoon",
22017 evening: "in the evening",
22018 night: "at night"
22019 },
22020 wide: {
22021 am: "a.m.",
22022 pm: "p.m.",
22023 midnight: "midnight",
22024 noon: "noon",
22025 morning: "in the morning",
22026 afternoon: "in the afternoon",
22027 evening: "in the evening",
22028 night: "at night"
22029 }
22030 };
22031 var ordinalNumber = (dirtyNumber, _options) => {
22032 const number = Number(dirtyNumber);
22033 const rem100 = number % 100;
22034 if (rem100 > 20 || rem100 < 10) {
22035 switch (rem100 % 10) {
22036 case 1:
22037 return number + "st";
22038 case 2:
22039 return number + "nd";
22040 case 3:
22041 return number + "rd";
22042 }
22043 }
22044 return number + "th";
22045 };
22046 var localize = {
22047 ordinalNumber,
22048 era: buildLocalizeFn({
22049 values: eraValues,
22050 defaultWidth: "wide"
22051 }),
22052 quarter: buildLocalizeFn({
22053 values: quarterValues,
22054 defaultWidth: "wide",
22055 argumentCallback: (quarter) => quarter - 1
22056 }),
22057 month: buildLocalizeFn({
22058 values: monthValues,
22059 defaultWidth: "wide"
22060 }),
22061 day: buildLocalizeFn({
22062 values: dayValues,
22063 defaultWidth: "wide"
22064 }),
22065 dayPeriod: buildLocalizeFn({
22066 values: dayPeriodValues,
22067 defaultWidth: "wide",
22068 formattingValues: formattingDayPeriodValues,
22069 defaultFormattingWidth: "wide"
22070 })
22071 };
22072
22073 // node_modules/date-fns/locale/_lib/buildMatchFn.js
22074 function buildMatchFn(args) {
22075 return (string, options = {}) => {
22076 const width = options.width;
22077 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
22078 const matchResult = string.match(matchPattern);
22079 if (!matchResult) {
22080 return null;
22081 }
22082 const matchedString = matchResult[0];
22083 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
22084 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
22085 // [TODO] -- I challenge you to fix the type
22086 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
22087 );
22088 let value;
22089 value = args.valueCallback ? args.valueCallback(key) : key;
22090 value = options.valueCallback ? (
22091 // [TODO] -- I challenge you to fix the type
22092 options.valueCallback(value)
22093 ) : value;
22094 const rest = string.slice(matchedString.length);
22095 return { value, rest };
22096 };
22097 }
22098 function findKey(object, predicate) {
22099 for (const key in object) {
22100 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
22101 return key;
22102 }
22103 }
22104 return void 0;
22105 }
22106 function findIndex(array, predicate) {
22107 for (let key = 0; key < array.length; key++) {
22108 if (predicate(array[key])) {
22109 return key;
22110 }
22111 }
22112 return void 0;
22113 }
22114
22115 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
22116 function buildMatchPatternFn(args) {
22117 return (string, options = {}) => {
22118 const matchResult = string.match(args.matchPattern);
22119 if (!matchResult) return null;
22120 const matchedString = matchResult[0];
22121 const parseResult = string.match(args.parsePattern);
22122 if (!parseResult) return null;
22123 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
22124 value = options.valueCallback ? options.valueCallback(value) : value;
22125 const rest = string.slice(matchedString.length);
22126 return { value, rest };
22127 };
22128 }
22129
22130 // node_modules/date-fns/locale/en-US/_lib/match.js
22131 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
22132 var parseOrdinalNumberPattern = /\d+/i;
22133 var matchEraPatterns = {
22134 narrow: /^(b|a)/i,
22135 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
22136 wide: /^(before christ|before common era|anno domini|common era)/i
22137 };
22138 var parseEraPatterns = {
22139 any: [/^b/i, /^(a|c)/i]
22140 };
22141 var matchQuarterPatterns = {
22142 narrow: /^[1234]/i,
22143 abbreviated: /^q[1234]/i,
22144 wide: /^[1234](th|st|nd|rd)? quarter/i
22145 };
22146 var parseQuarterPatterns = {
22147 any: [/1/i, /2/i, /3/i, /4/i]
22148 };
22149 var matchMonthPatterns = {
22150 narrow: /^[jfmasond]/i,
22151 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
22152 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
22153 };
22154 var parseMonthPatterns = {
22155 narrow: [
22156 /^j/i,
22157 /^f/i,
22158 /^m/i,
22159 /^a/i,
22160 /^m/i,
22161 /^j/i,
22162 /^j/i,
22163 /^a/i,
22164 /^s/i,
22165 /^o/i,
22166 /^n/i,
22167 /^d/i
22168 ],
22169 any: [
22170 /^ja/i,
22171 /^f/i,
22172 /^mar/i,
22173 /^ap/i,
22174 /^may/i,
22175 /^jun/i,
22176 /^jul/i,
22177 /^au/i,
22178 /^s/i,
22179 /^o/i,
22180 /^n/i,
22181 /^d/i
22182 ]
22183 };
22184 var matchDayPatterns = {
22185 narrow: /^[smtwf]/i,
22186 short: /^(su|mo|tu|we|th|fr|sa)/i,
22187 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
22188 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
22189 };
22190 var parseDayPatterns = {
22191 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
22192 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
22193 };
22194 var matchDayPeriodPatterns = {
22195 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
22196 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
22197 };
22198 var parseDayPeriodPatterns = {
22199 any: {
22200 am: /^a/i,
22201 pm: /^p/i,
22202 midnight: /^mi/i,
22203 noon: /^no/i,
22204 morning: /morning/i,
22205 afternoon: /afternoon/i,
22206 evening: /evening/i,
22207 night: /night/i
22208 }
22209 };
22210 var match = {
22211 ordinalNumber: buildMatchPatternFn({
22212 matchPattern: matchOrdinalNumberPattern,
22213 parsePattern: parseOrdinalNumberPattern,
22214 valueCallback: (value) => parseInt(value, 10)
22215 }),
22216 era: buildMatchFn({
22217 matchPatterns: matchEraPatterns,
22218 defaultMatchWidth: "wide",
22219 parsePatterns: parseEraPatterns,
22220 defaultParseWidth: "any"
22221 }),
22222 quarter: buildMatchFn({
22223 matchPatterns: matchQuarterPatterns,
22224 defaultMatchWidth: "wide",
22225 parsePatterns: parseQuarterPatterns,
22226 defaultParseWidth: "any",
22227 valueCallback: (index2) => index2 + 1
22228 }),
22229 month: buildMatchFn({
22230 matchPatterns: matchMonthPatterns,
22231 defaultMatchWidth: "wide",
22232 parsePatterns: parseMonthPatterns,
22233 defaultParseWidth: "any"
22234 }),
22235 day: buildMatchFn({
22236 matchPatterns: matchDayPatterns,
22237 defaultMatchWidth: "wide",
22238 parsePatterns: parseDayPatterns,
22239 defaultParseWidth: "any"
22240 }),
22241 dayPeriod: buildMatchFn({
22242 matchPatterns: matchDayPeriodPatterns,
22243 defaultMatchWidth: "any",
22244 parsePatterns: parseDayPeriodPatterns,
22245 defaultParseWidth: "any"
22246 })
22247 };
22248
22249 // node_modules/date-fns/locale/en-US.js
22250 var enUS = {
22251 code: "en-US",
22252 formatDistance,
22253 formatLong,
22254 formatRelative,
22255 localize,
22256 match,
22257 options: {
22258 weekStartsOn: 0,
22259 firstWeekContainsDate: 1
22260 }
22261 };
22262
22263 // node_modules/date-fns/getDayOfYear.js
22264 function getDayOfYear(date, options) {
22265 const _date = toDate(date, options?.in);
22266 const diff = differenceInCalendarDays(_date, startOfYear(_date));
22267 const dayOfYear = diff + 1;
22268 return dayOfYear;
22269 }
22270
22271 // node_modules/date-fns/getISOWeek.js
22272 function getISOWeek(date, options) {
22273 const _date = toDate(date, options?.in);
22274 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
22275 return Math.round(diff / millisecondsInWeek) + 1;
22276 }
22277
22278 // node_modules/date-fns/getWeekYear.js
22279 function getWeekYear(date, options) {
22280 const _date = toDate(date, options?.in);
22281 const year = _date.getFullYear();
22282 const defaultOptions2 = getDefaultOptions();
22283 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
22284 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
22285 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
22286 firstWeekOfNextYear.setHours(0, 0, 0, 0);
22287 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
22288 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
22289 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
22290 firstWeekOfThisYear.setHours(0, 0, 0, 0);
22291 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
22292 if (+_date >= +startOfNextYear) {
22293 return year + 1;
22294 } else if (+_date >= +startOfThisYear) {
22295 return year;
22296 } else {
22297 return year - 1;
22298 }
22299 }
22300
22301 // node_modules/date-fns/startOfWeekYear.js
22302 function startOfWeekYear(date, options) {
22303 const defaultOptions2 = getDefaultOptions();
22304 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
22305 const year = getWeekYear(date, options);
22306 const firstWeek = constructFrom(options?.in || date, 0);
22307 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
22308 firstWeek.setHours(0, 0, 0, 0);
22309 const _date = startOfWeek(firstWeek, options);
22310 return _date;
22311 }
22312
22313 // node_modules/date-fns/getWeek.js
22314 function getWeek(date, options) {
22315 const _date = toDate(date, options?.in);
22316 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
22317 return Math.round(diff / millisecondsInWeek) + 1;
22318 }
22319
22320 // node_modules/date-fns/_lib/addLeadingZeros.js
22321 function addLeadingZeros(number, targetLength) {
22322 const sign = number < 0 ? "-" : "";
22323 const output = Math.abs(number).toString().padStart(targetLength, "0");
22324 return sign + output;
22325 }
22326
22327 // node_modules/date-fns/_lib/format/lightFormatters.js
22328 var lightFormatters = {
22329 // Year
22330 y(date, token) {
22331 const signedYear = date.getFullYear();
22332 const year = signedYear > 0 ? signedYear : 1 - signedYear;
22333 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
22334 },
22335 // Month
22336 M(date, token) {
22337 const month = date.getMonth();
22338 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
22339 },
22340 // Day of the month
22341 d(date, token) {
22342 return addLeadingZeros(date.getDate(), token.length);
22343 },
22344 // AM or PM
22345 a(date, token) {
22346 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
22347 switch (token) {
22348 case "a":
22349 case "aa":
22350 return dayPeriodEnumValue.toUpperCase();
22351 case "aaa":
22352 return dayPeriodEnumValue;
22353 case "aaaaa":
22354 return dayPeriodEnumValue[0];
22355 case "aaaa":
22356 default:
22357 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
22358 }
22359 },
22360 // Hour [1-12]
22361 h(date, token) {
22362 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
22363 },
22364 // Hour [0-23]
22365 H(date, token) {
22366 return addLeadingZeros(date.getHours(), token.length);
22367 },
22368 // Minute
22369 m(date, token) {
22370 return addLeadingZeros(date.getMinutes(), token.length);
22371 },
22372 // Second
22373 s(date, token) {
22374 return addLeadingZeros(date.getSeconds(), token.length);
22375 },
22376 // Fraction of second
22377 S(date, token) {
22378 const numberOfDigits = token.length;
22379 const milliseconds = date.getMilliseconds();
22380 const fractionalSeconds = Math.trunc(
22381 milliseconds * Math.pow(10, numberOfDigits - 3)
22382 );
22383 return addLeadingZeros(fractionalSeconds, token.length);
22384 }
22385 };
22386
22387 // node_modules/date-fns/_lib/format/formatters.js
22388 var dayPeriodEnum = {
22389 am: "am",
22390 pm: "pm",
22391 midnight: "midnight",
22392 noon: "noon",
22393 morning: "morning",
22394 afternoon: "afternoon",
22395 evening: "evening",
22396 night: "night"
22397 };
22398 var formatters = {
22399 // Era
22400 G: function(date, token, localize2) {
22401 const era = date.getFullYear() > 0 ? 1 : 0;
22402 switch (token) {
22403 // AD, BC
22404 case "G":
22405 case "GG":
22406 case "GGG":
22407 return localize2.era(era, { width: "abbreviated" });
22408 // A, B
22409 case "GGGGG":
22410 return localize2.era(era, { width: "narrow" });
22411 // Anno Domini, Before Christ
22412 case "GGGG":
22413 default:
22414 return localize2.era(era, { width: "wide" });
22415 }
22416 },
22417 // Year
22418 y: function(date, token, localize2) {
22419 if (token === "yo") {
22420 const signedYear = date.getFullYear();
22421 const year = signedYear > 0 ? signedYear : 1 - signedYear;
22422 return localize2.ordinalNumber(year, { unit: "year" });
22423 }
22424 return lightFormatters.y(date, token);
22425 },
22426 // Local week-numbering year
22427 Y: function(date, token, localize2, options) {
22428 const signedWeekYear = getWeekYear(date, options);
22429 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
22430 if (token === "YY") {
22431 const twoDigitYear = weekYear % 100;
22432 return addLeadingZeros(twoDigitYear, 2);
22433 }
22434 if (token === "Yo") {
22435 return localize2.ordinalNumber(weekYear, { unit: "year" });
22436 }
22437 return addLeadingZeros(weekYear, token.length);
22438 },
22439 // ISO week-numbering year
22440 R: function(date, token) {
22441 const isoWeekYear = getISOWeekYear(date);
22442 return addLeadingZeros(isoWeekYear, token.length);
22443 },
22444 // Extended year. This is a single number designating the year of this calendar system.
22445 // The main difference between `y` and `u` localizers are B.C. years:
22446 // | Year | `y` | `u` |
22447 // |------|-----|-----|
22448 // | AC 1 | 1 | 1 |
22449 // | BC 1 | 1 | 0 |
22450 // | BC 2 | 2 | -1 |
22451 // Also `yy` always returns the last two digits of a year,
22452 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
22453 u: function(date, token) {
22454 const year = date.getFullYear();
22455 return addLeadingZeros(year, token.length);
22456 },
22457 // Quarter
22458 Q: function(date, token, localize2) {
22459 const quarter = Math.ceil((date.getMonth() + 1) / 3);
22460 switch (token) {
22461 // 1, 2, 3, 4
22462 case "Q":
22463 return String(quarter);
22464 // 01, 02, 03, 04
22465 case "QQ":
22466 return addLeadingZeros(quarter, 2);
22467 // 1st, 2nd, 3rd, 4th
22468 case "Qo":
22469 return localize2.ordinalNumber(quarter, { unit: "quarter" });
22470 // Q1, Q2, Q3, Q4
22471 case "QQQ":
22472 return localize2.quarter(quarter, {
22473 width: "abbreviated",
22474 context: "formatting"
22475 });
22476 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
22477 case "QQQQQ":
22478 return localize2.quarter(quarter, {
22479 width: "narrow",
22480 context: "formatting"
22481 });
22482 // 1st quarter, 2nd quarter, ...
22483 case "QQQQ":
22484 default:
22485 return localize2.quarter(quarter, {
22486 width: "wide",
22487 context: "formatting"
22488 });
22489 }
22490 },
22491 // Stand-alone quarter
22492 q: function(date, token, localize2) {
22493 const quarter = Math.ceil((date.getMonth() + 1) / 3);
22494 switch (token) {
22495 // 1, 2, 3, 4
22496 case "q":
22497 return String(quarter);
22498 // 01, 02, 03, 04
22499 case "qq":
22500 return addLeadingZeros(quarter, 2);
22501 // 1st, 2nd, 3rd, 4th
22502 case "qo":
22503 return localize2.ordinalNumber(quarter, { unit: "quarter" });
22504 // Q1, Q2, Q3, Q4
22505 case "qqq":
22506 return localize2.quarter(quarter, {
22507 width: "abbreviated",
22508 context: "standalone"
22509 });
22510 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
22511 case "qqqqq":
22512 return localize2.quarter(quarter, {
22513 width: "narrow",
22514 context: "standalone"
22515 });
22516 // 1st quarter, 2nd quarter, ...
22517 case "qqqq":
22518 default:
22519 return localize2.quarter(quarter, {
22520 width: "wide",
22521 context: "standalone"
22522 });
22523 }
22524 },
22525 // Month
22526 M: function(date, token, localize2) {
22527 const month = date.getMonth();
22528 switch (token) {
22529 case "M":
22530 case "MM":
22531 return lightFormatters.M(date, token);
22532 // 1st, 2nd, ..., 12th
22533 case "Mo":
22534 return localize2.ordinalNumber(month + 1, { unit: "month" });
22535 // Jan, Feb, ..., Dec
22536 case "MMM":
22537 return localize2.month(month, {
22538 width: "abbreviated",
22539 context: "formatting"
22540 });
22541 // J, F, ..., D
22542 case "MMMMM":
22543 return localize2.month(month, {
22544 width: "narrow",
22545 context: "formatting"
22546 });
22547 // January, February, ..., December
22548 case "MMMM":
22549 default:
22550 return localize2.month(month, { width: "wide", context: "formatting" });
22551 }
22552 },
22553 // Stand-alone month
22554 L: function(date, token, localize2) {
22555 const month = date.getMonth();
22556 switch (token) {
22557 // 1, 2, ..., 12
22558 case "L":
22559 return String(month + 1);
22560 // 01, 02, ..., 12
22561 case "LL":
22562 return addLeadingZeros(month + 1, 2);
22563 // 1st, 2nd, ..., 12th
22564 case "Lo":
22565 return localize2.ordinalNumber(month + 1, { unit: "month" });
22566 // Jan, Feb, ..., Dec
22567 case "LLL":
22568 return localize2.month(month, {
22569 width: "abbreviated",
22570 context: "standalone"
22571 });
22572 // J, F, ..., D
22573 case "LLLLL":
22574 return localize2.month(month, {
22575 width: "narrow",
22576 context: "standalone"
22577 });
22578 // January, February, ..., December
22579 case "LLLL":
22580 default:
22581 return localize2.month(month, { width: "wide", context: "standalone" });
22582 }
22583 },
22584 // Local week of year
22585 w: function(date, token, localize2, options) {
22586 const week = getWeek(date, options);
22587 if (token === "wo") {
22588 return localize2.ordinalNumber(week, { unit: "week" });
22589 }
22590 return addLeadingZeros(week, token.length);
22591 },
22592 // ISO week of year
22593 I: function(date, token, localize2) {
22594 const isoWeek = getISOWeek(date);
22595 if (token === "Io") {
22596 return localize2.ordinalNumber(isoWeek, { unit: "week" });
22597 }
22598 return addLeadingZeros(isoWeek, token.length);
22599 },
22600 // Day of the month
22601 d: function(date, token, localize2) {
22602 if (token === "do") {
22603 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
22604 }
22605 return lightFormatters.d(date, token);
22606 },
22607 // Day of year
22608 D: function(date, token, localize2) {
22609 const dayOfYear = getDayOfYear(date);
22610 if (token === "Do") {
22611 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
22612 }
22613 return addLeadingZeros(dayOfYear, token.length);
22614 },
22615 // Day of week
22616 E: function(date, token, localize2) {
22617 const dayOfWeek = date.getDay();
22618 switch (token) {
22619 // Tue
22620 case "E":
22621 case "EE":
22622 case "EEE":
22623 return localize2.day(dayOfWeek, {
22624 width: "abbreviated",
22625 context: "formatting"
22626 });
22627 // T
22628 case "EEEEE":
22629 return localize2.day(dayOfWeek, {
22630 width: "narrow",
22631 context: "formatting"
22632 });
22633 // Tu
22634 case "EEEEEE":
22635 return localize2.day(dayOfWeek, {
22636 width: "short",
22637 context: "formatting"
22638 });
22639 // Tuesday
22640 case "EEEE":
22641 default:
22642 return localize2.day(dayOfWeek, {
22643 width: "wide",
22644 context: "formatting"
22645 });
22646 }
22647 },
22648 // Local day of week
22649 e: function(date, token, localize2, options) {
22650 const dayOfWeek = date.getDay();
22651 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
22652 switch (token) {
22653 // Numerical value (Nth day of week with current locale or weekStartsOn)
22654 case "e":
22655 return String(localDayOfWeek);
22656 // Padded numerical value
22657 case "ee":
22658 return addLeadingZeros(localDayOfWeek, 2);
22659 // 1st, 2nd, ..., 7th
22660 case "eo":
22661 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
22662 case "eee":
22663 return localize2.day(dayOfWeek, {
22664 width: "abbreviated",
22665 context: "formatting"
22666 });
22667 // T
22668 case "eeeee":
22669 return localize2.day(dayOfWeek, {
22670 width: "narrow",
22671 context: "formatting"
22672 });
22673 // Tu
22674 case "eeeeee":
22675 return localize2.day(dayOfWeek, {
22676 width: "short",
22677 context: "formatting"
22678 });
22679 // Tuesday
22680 case "eeee":
22681 default:
22682 return localize2.day(dayOfWeek, {
22683 width: "wide",
22684 context: "formatting"
22685 });
22686 }
22687 },
22688 // Stand-alone local day of week
22689 c: function(date, token, localize2, options) {
22690 const dayOfWeek = date.getDay();
22691 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
22692 switch (token) {
22693 // Numerical value (same as in `e`)
22694 case "c":
22695 return String(localDayOfWeek);
22696 // Padded numerical value
22697 case "cc":
22698 return addLeadingZeros(localDayOfWeek, token.length);
22699 // 1st, 2nd, ..., 7th
22700 case "co":
22701 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
22702 case "ccc":
22703 return localize2.day(dayOfWeek, {
22704 width: "abbreviated",
22705 context: "standalone"
22706 });
22707 // T
22708 case "ccccc":
22709 return localize2.day(dayOfWeek, {
22710 width: "narrow",
22711 context: "standalone"
22712 });
22713 // Tu
22714 case "cccccc":
22715 return localize2.day(dayOfWeek, {
22716 width: "short",
22717 context: "standalone"
22718 });
22719 // Tuesday
22720 case "cccc":
22721 default:
22722 return localize2.day(dayOfWeek, {
22723 width: "wide",
22724 context: "standalone"
22725 });
22726 }
22727 },
22728 // ISO day of week
22729 i: function(date, token, localize2) {
22730 const dayOfWeek = date.getDay();
22731 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
22732 switch (token) {
22733 // 2
22734 case "i":
22735 return String(isoDayOfWeek);
22736 // 02
22737 case "ii":
22738 return addLeadingZeros(isoDayOfWeek, token.length);
22739 // 2nd
22740 case "io":
22741 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
22742 // Tue
22743 case "iii":
22744 return localize2.day(dayOfWeek, {
22745 width: "abbreviated",
22746 context: "formatting"
22747 });
22748 // T
22749 case "iiiii":
22750 return localize2.day(dayOfWeek, {
22751 width: "narrow",
22752 context: "formatting"
22753 });
22754 // Tu
22755 case "iiiiii":
22756 return localize2.day(dayOfWeek, {
22757 width: "short",
22758 context: "formatting"
22759 });
22760 // Tuesday
22761 case "iiii":
22762 default:
22763 return localize2.day(dayOfWeek, {
22764 width: "wide",
22765 context: "formatting"
22766 });
22767 }
22768 },
22769 // AM or PM
22770 a: function(date, token, localize2) {
22771 const hours = date.getHours();
22772 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
22773 switch (token) {
22774 case "a":
22775 case "aa":
22776 return localize2.dayPeriod(dayPeriodEnumValue, {
22777 width: "abbreviated",
22778 context: "formatting"
22779 });
22780 case "aaa":
22781 return localize2.dayPeriod(dayPeriodEnumValue, {
22782 width: "abbreviated",
22783 context: "formatting"
22784 }).toLowerCase();
22785 case "aaaaa":
22786 return localize2.dayPeriod(dayPeriodEnumValue, {
22787 width: "narrow",
22788 context: "formatting"
22789 });
22790 case "aaaa":
22791 default:
22792 return localize2.dayPeriod(dayPeriodEnumValue, {
22793 width: "wide",
22794 context: "formatting"
22795 });
22796 }
22797 },
22798 // AM, PM, midnight, noon
22799 b: function(date, token, localize2) {
22800 const hours = date.getHours();
22801 let dayPeriodEnumValue;
22802 if (hours === 12) {
22803 dayPeriodEnumValue = dayPeriodEnum.noon;
22804 } else if (hours === 0) {
22805 dayPeriodEnumValue = dayPeriodEnum.midnight;
22806 } else {
22807 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
22808 }
22809 switch (token) {
22810 case "b":
22811 case "bb":
22812 return localize2.dayPeriod(dayPeriodEnumValue, {
22813 width: "abbreviated",
22814 context: "formatting"
22815 });
22816 case "bbb":
22817 return localize2.dayPeriod(dayPeriodEnumValue, {
22818 width: "abbreviated",
22819 context: "formatting"
22820 }).toLowerCase();
22821 case "bbbbb":
22822 return localize2.dayPeriod(dayPeriodEnumValue, {
22823 width: "narrow",
22824 context: "formatting"
22825 });
22826 case "bbbb":
22827 default:
22828 return localize2.dayPeriod(dayPeriodEnumValue, {
22829 width: "wide",
22830 context: "formatting"
22831 });
22832 }
22833 },
22834 // in the morning, in the afternoon, in the evening, at night
22835 B: function(date, token, localize2) {
22836 const hours = date.getHours();
22837 let dayPeriodEnumValue;
22838 if (hours >= 17) {
22839 dayPeriodEnumValue = dayPeriodEnum.evening;
22840 } else if (hours >= 12) {
22841 dayPeriodEnumValue = dayPeriodEnum.afternoon;
22842 } else if (hours >= 4) {
22843 dayPeriodEnumValue = dayPeriodEnum.morning;
22844 } else {
22845 dayPeriodEnumValue = dayPeriodEnum.night;
22846 }
22847 switch (token) {
22848 case "B":
22849 case "BB":
22850 case "BBB":
22851 return localize2.dayPeriod(dayPeriodEnumValue, {
22852 width: "abbreviated",
22853 context: "formatting"
22854 });
22855 case "BBBBB":
22856 return localize2.dayPeriod(dayPeriodEnumValue, {
22857 width: "narrow",
22858 context: "formatting"
22859 });
22860 case "BBBB":
22861 default:
22862 return localize2.dayPeriod(dayPeriodEnumValue, {
22863 width: "wide",
22864 context: "formatting"
22865 });
22866 }
22867 },
22868 // Hour [1-12]
22869 h: function(date, token, localize2) {
22870 if (token === "ho") {
22871 let hours = date.getHours() % 12;
22872 if (hours === 0) hours = 12;
22873 return localize2.ordinalNumber(hours, { unit: "hour" });
22874 }
22875 return lightFormatters.h(date, token);
22876 },
22877 // Hour [0-23]
22878 H: function(date, token, localize2) {
22879 if (token === "Ho") {
22880 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
22881 }
22882 return lightFormatters.H(date, token);
22883 },
22884 // Hour [0-11]
22885 K: function(date, token, localize2) {
22886 const hours = date.getHours() % 12;
22887 if (token === "Ko") {
22888 return localize2.ordinalNumber(hours, { unit: "hour" });
22889 }
22890 return addLeadingZeros(hours, token.length);
22891 },
22892 // Hour [1-24]
22893 k: function(date, token, localize2) {
22894 let hours = date.getHours();
22895 if (hours === 0) hours = 24;
22896 if (token === "ko") {
22897 return localize2.ordinalNumber(hours, { unit: "hour" });
22898 }
22899 return addLeadingZeros(hours, token.length);
22900 },
22901 // Minute
22902 m: function(date, token, localize2) {
22903 if (token === "mo") {
22904 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
22905 }
22906 return lightFormatters.m(date, token);
22907 },
22908 // Second
22909 s: function(date, token, localize2) {
22910 if (token === "so") {
22911 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
22912 }
22913 return lightFormatters.s(date, token);
22914 },
22915 // Fraction of second
22916 S: function(date, token) {
22917 return lightFormatters.S(date, token);
22918 },
22919 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
22920 X: function(date, token, _localize) {
22921 const timezoneOffset = date.getTimezoneOffset();
22922 if (timezoneOffset === 0) {
22923 return "Z";
22924 }
22925 switch (token) {
22926 // Hours and optional minutes
22927 case "X":
22928 return formatTimezoneWithOptionalMinutes(timezoneOffset);
22929 // Hours, minutes and optional seconds without `:` delimiter
22930 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
22931 // so this token always has the same output as `XX`
22932 case "XXXX":
22933 case "XX":
22934 return formatTimezone(timezoneOffset);
22935 // Hours, minutes and optional seconds with `:` delimiter
22936 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
22937 // so this token always has the same output as `XXX`
22938 case "XXXXX":
22939 case "XXX":
22940 // Hours and minutes with `:` delimiter
22941 default:
22942 return formatTimezone(timezoneOffset, ":");
22943 }
22944 },
22945 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
22946 x: function(date, token, _localize) {
22947 const timezoneOffset = date.getTimezoneOffset();
22948 switch (token) {
22949 // Hours and optional minutes
22950 case "x":
22951 return formatTimezoneWithOptionalMinutes(timezoneOffset);
22952 // Hours, minutes and optional seconds without `:` delimiter
22953 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
22954 // so this token always has the same output as `xx`
22955 case "xxxx":
22956 case "xx":
22957 return formatTimezone(timezoneOffset);
22958 // Hours, minutes and optional seconds with `:` delimiter
22959 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
22960 // so this token always has the same output as `xxx`
22961 case "xxxxx":
22962 case "xxx":
22963 // Hours and minutes with `:` delimiter
22964 default:
22965 return formatTimezone(timezoneOffset, ":");
22966 }
22967 },
22968 // Timezone (GMT)
22969 O: function(date, token, _localize) {
22970 const timezoneOffset = date.getTimezoneOffset();
22971 switch (token) {
22972 // Short
22973 case "O":
22974 case "OO":
22975 case "OOO":
22976 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
22977 // Long
22978 case "OOOO":
22979 default:
22980 return "GMT" + formatTimezone(timezoneOffset, ":");
22981 }
22982 },
22983 // Timezone (specific non-location)
22984 z: function(date, token, _localize) {
22985 const timezoneOffset = date.getTimezoneOffset();
22986 switch (token) {
22987 // Short
22988 case "z":
22989 case "zz":
22990 case "zzz":
22991 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
22992 // Long
22993 case "zzzz":
22994 default:
22995 return "GMT" + formatTimezone(timezoneOffset, ":");
22996 }
22997 },
22998 // Seconds timestamp
22999 t: function(date, token, _localize) {
23000 const timestamp = Math.trunc(+date / 1e3);
23001 return addLeadingZeros(timestamp, token.length);
23002 },
23003 // Milliseconds timestamp
23004 T: function(date, token, _localize) {
23005 return addLeadingZeros(+date, token.length);
23006 }
23007 };
23008 function formatTimezoneShort(offset4, delimiter = "") {
23009 const sign = offset4 > 0 ? "-" : "+";
23010 const absOffset = Math.abs(offset4);
23011 const hours = Math.trunc(absOffset / 60);
23012 const minutes = absOffset % 60;
23013 if (minutes === 0) {
23014 return sign + String(hours);
23015 }
23016 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
23017 }
23018 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
23019 if (offset4 % 60 === 0) {
23020 const sign = offset4 > 0 ? "-" : "+";
23021 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
23022 }
23023 return formatTimezone(offset4, delimiter);
23024 }
23025 function formatTimezone(offset4, delimiter = "") {
23026 const sign = offset4 > 0 ? "-" : "+";
23027 const absOffset = Math.abs(offset4);
23028 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
23029 const minutes = addLeadingZeros(absOffset % 60, 2);
23030 return sign + hours + delimiter + minutes;
23031 }
23032
23033 // node_modules/date-fns/_lib/format/longFormatters.js
23034 var dateLongFormatter = (pattern, formatLong2) => {
23035 switch (pattern) {
23036 case "P":
23037 return formatLong2.date({ width: "short" });
23038 case "PP":
23039 return formatLong2.date({ width: "medium" });
23040 case "PPP":
23041 return formatLong2.date({ width: "long" });
23042 case "PPPP":
23043 default:
23044 return formatLong2.date({ width: "full" });
23045 }
23046 };
23047 var timeLongFormatter = (pattern, formatLong2) => {
23048 switch (pattern) {
23049 case "p":
23050 return formatLong2.time({ width: "short" });
23051 case "pp":
23052 return formatLong2.time({ width: "medium" });
23053 case "ppp":
23054 return formatLong2.time({ width: "long" });
23055 case "pppp":
23056 default:
23057 return formatLong2.time({ width: "full" });
23058 }
23059 };
23060 var dateTimeLongFormatter = (pattern, formatLong2) => {
23061 const matchResult = pattern.match(/(P+)(p+)?/) || [];
23062 const datePattern = matchResult[1];
23063 const timePattern = matchResult[2];
23064 if (!timePattern) {
23065 return dateLongFormatter(pattern, formatLong2);
23066 }
23067 let dateTimeFormat;
23068 switch (datePattern) {
23069 case "P":
23070 dateTimeFormat = formatLong2.dateTime({ width: "short" });
23071 break;
23072 case "PP":
23073 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
23074 break;
23075 case "PPP":
23076 dateTimeFormat = formatLong2.dateTime({ width: "long" });
23077 break;
23078 case "PPPP":
23079 default:
23080 dateTimeFormat = formatLong2.dateTime({ width: "full" });
23081 break;
23082 }
23083 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
23084 };
23085 var longFormatters = {
23086 p: timeLongFormatter,
23087 P: dateTimeLongFormatter
23088 };
23089
23090 // node_modules/date-fns/_lib/protectedTokens.js
23091 var dayOfYearTokenRE = /^D+$/;
23092 var weekYearTokenRE = /^Y+$/;
23093 var throwTokens = ["D", "DD", "YY", "YYYY"];
23094 function isProtectedDayOfYearToken(token) {
23095 return dayOfYearTokenRE.test(token);
23096 }
23097 function isProtectedWeekYearToken(token) {
23098 return weekYearTokenRE.test(token);
23099 }
23100 function warnOrThrowProtectedError(token, format6, input) {
23101 const _message = message(token, format6, input);
23102 console.warn(_message);
23103 if (throwTokens.includes(token)) throw new RangeError(_message);
23104 }
23105 function message(token, format6, input) {
23106 const subject = token[0] === "Y" ? "years" : "days of the month";
23107 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`;
23108 }
23109
23110 // node_modules/date-fns/format.js
23111 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
23112 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
23113 var escapedStringRegExp = /^'([^]*?)'?$/;
23114 var doubleQuoteRegExp = /''/g;
23115 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
23116 function format(date, formatStr, options) {
23117 const defaultOptions2 = getDefaultOptions();
23118 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
23119 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
23120 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
23121 const originalDate = toDate(date, options?.in);
23122 if (!isValid(originalDate)) {
23123 throw new RangeError("Invalid time value");
23124 }
23125 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
23126 const firstCharacter = substring[0];
23127 if (firstCharacter === "p" || firstCharacter === "P") {
23128 const longFormatter = longFormatters[firstCharacter];
23129 return longFormatter(substring, locale.formatLong);
23130 }
23131 return substring;
23132 }).join("").match(formattingTokensRegExp).map((substring) => {
23133 if (substring === "''") {
23134 return { isToken: false, value: "'" };
23135 }
23136 const firstCharacter = substring[0];
23137 if (firstCharacter === "'") {
23138 return { isToken: false, value: cleanEscapedString(substring) };
23139 }
23140 if (formatters[firstCharacter]) {
23141 return { isToken: true, value: substring };
23142 }
23143 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
23144 throw new RangeError(
23145 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
23146 );
23147 }
23148 return { isToken: false, value: substring };
23149 });
23150 if (locale.localize.preprocessor) {
23151 parts = locale.localize.preprocessor(originalDate, parts);
23152 }
23153 const formatterOptions = {
23154 firstWeekContainsDate,
23155 weekStartsOn,
23156 locale
23157 };
23158 return parts.map((part) => {
23159 if (!part.isToken) return part.value;
23160 const token = part.value;
23161 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
23162 warnOrThrowProtectedError(token, formatStr, String(date));
23163 }
23164 const formatter = formatters[token[0]];
23165 return formatter(originalDate, token, locale.localize, formatterOptions);
23166 }).join("");
23167 }
23168 function cleanEscapedString(input) {
23169 const matched = input.match(escapedStringRegExp);
23170 if (!matched) {
23171 return input;
23172 }
23173 return matched[1].replace(doubleQuoteRegExp, "'");
23174 }
23175
23176 // node_modules/date-fns/subDays.js
23177 function subDays(date, amount, options) {
23178 return addDays(date, -amount, options);
23179 }
23180
23181 // node_modules/date-fns/subMonths.js
23182 function subMonths(date, amount, options) {
23183 return addMonths(date, -amount, options);
23184 }
23185
23186 // node_modules/date-fns/subWeeks.js
23187 function subWeeks(date, amount, options) {
23188 return addWeeks(date, -amount, options);
23189 }
23190
23191 // node_modules/date-fns/subYears.js
23192 function subYears(date, amount, options) {
23193 return addYears(date, -amount, options);
23194 }
23195
23196 // packages/dataviews/build-module/utils/operators.mjs
23197 var import_i18n26 = __toESM(require_i18n(), 1);
23198 var import_element69 = __toESM(require_element(), 1);
23199 var import_date = __toESM(require_date(), 1);
23200 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23201 var filterTextWrappers = {
23202 Name: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
23203 Value: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
23204 };
23205 function getRelativeDate(value, unit) {
23206 switch (unit) {
23207 case "days":
23208 return subDays(/* @__PURE__ */ new Date(), value);
23209 case "weeks":
23210 return subWeeks(/* @__PURE__ */ new Date(), value);
23211 case "months":
23212 return subMonths(/* @__PURE__ */ new Date(), value);
23213 case "years":
23214 return subYears(/* @__PURE__ */ new Date(), value);
23215 default:
23216 return /* @__PURE__ */ new Date();
23217 }
23218 }
23219 var isNoneOperatorDefinition = {
23220 /* translators: DataViews operator name */
23221 label: (0, import_i18n26.__)("Is none of"),
23222 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23223 (0, import_i18n26.sprintf)(
23224 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
23225 (0, import_i18n26.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
23226 filter.name,
23227 activeElements.map((element) => element.label).join(", ")
23228 ),
23229 filterTextWrappers
23230 ),
23231 filter: ((item, field, filterValue) => {
23232 if (!filterValue?.length) {
23233 return true;
23234 }
23235 const fieldValue = field.getValue({ item });
23236 if (Array.isArray(fieldValue)) {
23237 return !filterValue.some(
23238 (fv) => fieldValue.includes(fv)
23239 );
23240 } else if (typeof fieldValue === "string") {
23241 return !filterValue.includes(fieldValue);
23242 }
23243 return false;
23244 }),
23245 selection: "multi"
23246 };
23247 var OPERATORS = [
23248 {
23249 name: OPERATOR_IS_ANY,
23250 /* translators: DataViews operator name */
23251 label: (0, import_i18n26.__)("Includes"),
23252 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23253 (0, import_i18n26.sprintf)(
23254 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
23255 (0, import_i18n26.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
23256 filter.name,
23257 activeElements.map((element) => element.label).join(", ")
23258 ),
23259 filterTextWrappers
23260 ),
23261 filter(item, field, filterValue) {
23262 if (!filterValue?.length) {
23263 return true;
23264 }
23265 const fieldValue = field.getValue({ item });
23266 if (Array.isArray(fieldValue)) {
23267 return filterValue.some(
23268 (fv) => fieldValue.includes(fv)
23269 );
23270 } else if (typeof fieldValue === "string") {
23271 return filterValue.includes(fieldValue);
23272 }
23273 return false;
23274 },
23275 selection: "multi"
23276 },
23277 {
23278 name: OPERATOR_IS_NONE,
23279 ...isNoneOperatorDefinition
23280 },
23281 {
23282 name: OPERATOR_IS_ALL,
23283 /* translators: DataViews operator name */
23284 label: (0, import_i18n26.__)("Includes all"),
23285 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23286 (0, import_i18n26.sprintf)(
23287 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
23288 (0, import_i18n26.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
23289 filter.name,
23290 activeElements.map((element) => element.label).join(", ")
23291 ),
23292 filterTextWrappers
23293 ),
23294 filter(item, field, filterValue) {
23295 if (!filterValue?.length) {
23296 return true;
23297 }
23298 return filterValue.every((value) => {
23299 return field.getValue({ item })?.includes(value);
23300 });
23301 },
23302 selection: "multi"
23303 },
23304 {
23305 name: OPERATOR_IS_NOT_ALL,
23306 ...isNoneOperatorDefinition
23307 },
23308 {
23309 name: OPERATOR_BETWEEN,
23310 /* translators: DataViews operator name */
23311 label: (0, import_i18n26.__)("Between (inc)"),
23312 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23313 (0, import_i18n26.sprintf)(
23314 /* 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". */
23315 (0, import_i18n26.__)(
23316 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
23317 ),
23318 filter.name,
23319 activeElements[0].label[0],
23320 activeElements[0].label[1]
23321 ),
23322 filterTextWrappers
23323 ),
23324 filter(item, field, filterValue) {
23325 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
23326 return true;
23327 }
23328 const fieldValue = field.getValue({ item });
23329 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
23330 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
23331 }
23332 return false;
23333 },
23334 selection: "custom"
23335 },
23336 {
23337 name: OPERATOR_IN_THE_PAST,
23338 /* translators: DataViews operator name */
23339 label: (0, import_i18n26.__)("In the past"),
23340 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23341 (0, import_i18n26.sprintf)(
23342 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
23343 (0, import_i18n26.__)(
23344 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
23345 ),
23346 filter.name,
23347 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
23348 ),
23349 filterTextWrappers
23350 ),
23351 filter(item, field, filterValue) {
23352 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
23353 return true;
23354 }
23355 const targetDate = getRelativeDate(
23356 filterValue.value,
23357 filterValue.unit
23358 );
23359 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
23360 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
23361 },
23362 selection: "custom"
23363 },
23364 {
23365 name: OPERATOR_OVER,
23366 /* translators: DataViews operator name */
23367 label: (0, import_i18n26.__)("Over"),
23368 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23369 (0, import_i18n26.sprintf)(
23370 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
23371 (0, import_i18n26.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
23372 filter.name,
23373 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
23374 ),
23375 filterTextWrappers
23376 ),
23377 filter(item, field, filterValue) {
23378 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
23379 return true;
23380 }
23381 const targetDate = getRelativeDate(
23382 filterValue.value,
23383 filterValue.unit
23384 );
23385 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
23386 return fieldValue < targetDate;
23387 },
23388 selection: "custom"
23389 },
23390 {
23391 name: OPERATOR_IS,
23392 /* translators: DataViews operator name */
23393 label: (0, import_i18n26.__)("Is"),
23394 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23395 (0, import_i18n26.sprintf)(
23396 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
23397 (0, import_i18n26.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
23398 filter.name,
23399 activeElements[0].label
23400 ),
23401 filterTextWrappers
23402 ),
23403 filter(item, field, filterValue) {
23404 return filterValue === field.getValue({ item }) || filterValue === void 0;
23405 },
23406 selection: "single"
23407 },
23408 {
23409 name: OPERATOR_IS_NOT,
23410 /* translators: DataViews operator name */
23411 label: (0, import_i18n26.__)("Is not"),
23412 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23413 (0, import_i18n26.sprintf)(
23414 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
23415 (0, import_i18n26.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
23416 filter.name,
23417 activeElements[0].label
23418 ),
23419 filterTextWrappers
23420 ),
23421 filter(item, field, filterValue) {
23422 return filterValue !== field.getValue({ item });
23423 },
23424 selection: "single"
23425 },
23426 {
23427 name: OPERATOR_LESS_THAN,
23428 /* translators: DataViews operator name */
23429 label: (0, import_i18n26.__)("Less than"),
23430 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23431 (0, import_i18n26.sprintf)(
23432 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
23433 (0, import_i18n26.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
23434 filter.name,
23435 activeElements[0].label
23436 ),
23437 filterTextWrappers
23438 ),
23439 filter(item, field, filterValue) {
23440 if (filterValue === void 0) {
23441 return true;
23442 }
23443 const fieldValue = field.getValue({ item });
23444 return fieldValue < filterValue;
23445 },
23446 selection: "single"
23447 },
23448 {
23449 name: OPERATOR_GREATER_THAN,
23450 /* translators: DataViews operator name */
23451 label: (0, import_i18n26.__)("Greater than"),
23452 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23453 (0, import_i18n26.sprintf)(
23454 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
23455 (0, import_i18n26.__)(
23456 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
23457 ),
23458 filter.name,
23459 activeElements[0].label
23460 ),
23461 filterTextWrappers
23462 ),
23463 filter(item, field, filterValue) {
23464 if (filterValue === void 0) {
23465 return true;
23466 }
23467 const fieldValue = field.getValue({ item });
23468 return fieldValue > filterValue;
23469 },
23470 selection: "single"
23471 },
23472 {
23473 name: OPERATOR_LESS_THAN_OR_EQUAL,
23474 /* translators: DataViews operator name */
23475 label: (0, import_i18n26.__)("Less than or equal"),
23476 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23477 (0, import_i18n26.sprintf)(
23478 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
23479 (0, import_i18n26.__)(
23480 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
23481 ),
23482 filter.name,
23483 activeElements[0].label
23484 ),
23485 filterTextWrappers
23486 ),
23487 filter(item, field, filterValue) {
23488 if (filterValue === void 0) {
23489 return true;
23490 }
23491 const fieldValue = field.getValue({ item });
23492 return fieldValue <= filterValue;
23493 },
23494 selection: "single"
23495 },
23496 {
23497 name: OPERATOR_GREATER_THAN_OR_EQUAL,
23498 /* translators: DataViews operator name */
23499 label: (0, import_i18n26.__)("Greater than or equal"),
23500 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23501 (0, import_i18n26.sprintf)(
23502 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
23503 (0, import_i18n26.__)(
23504 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
23505 ),
23506 filter.name,
23507 activeElements[0].label
23508 ),
23509 filterTextWrappers
23510 ),
23511 filter(item, field, filterValue) {
23512 if (filterValue === void 0) {
23513 return true;
23514 }
23515 const fieldValue = field.getValue({ item });
23516 return fieldValue >= filterValue;
23517 },
23518 selection: "single"
23519 },
23520 {
23521 name: OPERATOR_BEFORE,
23522 /* translators: DataViews operator name */
23523 label: (0, import_i18n26.__)("Before"),
23524 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23525 (0, import_i18n26.sprintf)(
23526 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
23527 (0, import_i18n26.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
23528 filter.name,
23529 activeElements[0].label
23530 ),
23531 filterTextWrappers
23532 ),
23533 filter(item, field, filterValue) {
23534 if (filterValue === void 0) {
23535 return true;
23536 }
23537 const filterDate = (0, import_date.getDate)(filterValue);
23538 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23539 return fieldDate < filterDate;
23540 },
23541 selection: "single"
23542 },
23543 {
23544 name: OPERATOR_AFTER,
23545 /* translators: DataViews operator name */
23546 label: (0, import_i18n26.__)("After"),
23547 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23548 (0, import_i18n26.sprintf)(
23549 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
23550 (0, import_i18n26.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
23551 filter.name,
23552 activeElements[0].label
23553 ),
23554 filterTextWrappers
23555 ),
23556 filter(item, field, filterValue) {
23557 if (filterValue === void 0) {
23558 return true;
23559 }
23560 const filterDate = (0, import_date.getDate)(filterValue);
23561 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23562 return fieldDate > filterDate;
23563 },
23564 selection: "single"
23565 },
23566 {
23567 name: OPERATOR_BEFORE_INC,
23568 /* translators: DataViews operator name */
23569 label: (0, import_i18n26.__)("Before (inc)"),
23570 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23571 (0, import_i18n26.sprintf)(
23572 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
23573 (0, import_i18n26.__)(
23574 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
23575 ),
23576 filter.name,
23577 activeElements[0].label
23578 ),
23579 filterTextWrappers
23580 ),
23581 filter(item, field, filterValue) {
23582 if (filterValue === void 0) {
23583 return true;
23584 }
23585 const filterDate = (0, import_date.getDate)(filterValue);
23586 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23587 return fieldDate <= filterDate;
23588 },
23589 selection: "single"
23590 },
23591 {
23592 name: OPERATOR_AFTER_INC,
23593 /* translators: DataViews operator name */
23594 label: (0, import_i18n26.__)("After (inc)"),
23595 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23596 (0, import_i18n26.sprintf)(
23597 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
23598 (0, import_i18n26.__)(
23599 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
23600 ),
23601 filter.name,
23602 activeElements[0].label
23603 ),
23604 filterTextWrappers
23605 ),
23606 filter(item, field, filterValue) {
23607 if (filterValue === void 0) {
23608 return true;
23609 }
23610 const filterDate = (0, import_date.getDate)(filterValue);
23611 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23612 return fieldDate >= filterDate;
23613 },
23614 selection: "single"
23615 },
23616 {
23617 name: OPERATOR_CONTAINS,
23618 /* translators: DataViews operator name */
23619 label: (0, import_i18n26.__)("Contains"),
23620 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23621 (0, import_i18n26.sprintf)(
23622 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
23623 (0, import_i18n26.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
23624 filter.name,
23625 activeElements[0].label
23626 ),
23627 filterTextWrappers
23628 ),
23629 filter(item, field, filterValue) {
23630 if (filterValue === void 0) {
23631 return true;
23632 }
23633 const fieldValue = field.getValue({ item });
23634 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
23635 },
23636 selection: "single"
23637 },
23638 {
23639 name: OPERATOR_NOT_CONTAINS,
23640 /* translators: DataViews operator name */
23641 label: (0, import_i18n26.__)("Doesn't contain"),
23642 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23643 (0, import_i18n26.sprintf)(
23644 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
23645 (0, import_i18n26.__)(
23646 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
23647 ),
23648 filter.name,
23649 activeElements[0].label
23650 ),
23651 filterTextWrappers
23652 ),
23653 filter(item, field, filterValue) {
23654 if (filterValue === void 0) {
23655 return true;
23656 }
23657 const fieldValue = field.getValue({ item });
23658 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
23659 },
23660 selection: "single"
23661 },
23662 {
23663 name: OPERATOR_STARTS_WITH,
23664 /* translators: DataViews operator name */
23665 label: (0, import_i18n26.__)("Starts with"),
23666 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23667 (0, import_i18n26.sprintf)(
23668 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
23669 (0, import_i18n26.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
23670 filter.name,
23671 activeElements[0].label
23672 ),
23673 filterTextWrappers
23674 ),
23675 filter(item, field, filterValue) {
23676 if (filterValue === void 0) {
23677 return true;
23678 }
23679 const fieldValue = field.getValue({ item });
23680 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
23681 },
23682 selection: "single"
23683 },
23684 {
23685 name: OPERATOR_ON,
23686 /* translators: DataViews operator name */
23687 label: (0, import_i18n26.__)("On"),
23688 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23689 (0, import_i18n26.sprintf)(
23690 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
23691 (0, import_i18n26.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
23692 filter.name,
23693 activeElements[0].label
23694 ),
23695 filterTextWrappers
23696 ),
23697 filter(item, field, filterValue) {
23698 if (filterValue === void 0) {
23699 return true;
23700 }
23701 const filterDate = (0, import_date.getDate)(filterValue);
23702 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23703 return filterDate.getTime() === fieldDate.getTime();
23704 },
23705 selection: "single"
23706 },
23707 {
23708 name: OPERATOR_NOT_ON,
23709 /* translators: DataViews operator name */
23710 label: (0, import_i18n26.__)("Not on"),
23711 filterText: (filter, activeElements) => (0, import_element69.createInterpolateElement)(
23712 (0, import_i18n26.sprintf)(
23713 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
23714 (0, import_i18n26.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
23715 filter.name,
23716 activeElements[0].label
23717 ),
23718 filterTextWrappers
23719 ),
23720 filter(item, field, filterValue) {
23721 if (filterValue === void 0) {
23722 return true;
23723 }
23724 const filterDate = (0, import_date.getDate)(filterValue);
23725 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
23726 return filterDate.getTime() !== fieldDate.getTime();
23727 },
23728 selection: "single"
23729 }
23730 ];
23731 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
23732 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
23733 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
23734 (op) => op.name === name
23735 );
23736 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
23737
23738 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
23739 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23740 var ENTER = "Enter";
23741 var SPACE = " ";
23742 var FilterText = ({
23743 activeElements,
23744 filterInView,
23745 filter
23746 }) => {
23747 if (activeElements === void 0 || activeElements.length === 0) {
23748 return filter.name;
23749 }
23750 const operator = getOperatorByName(filterInView?.operator);
23751 if (operator !== void 0) {
23752 return operator.filterText(filter, activeElements);
23753 }
23754 return (0, import_i18n27.sprintf)(
23755 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
23756 (0, import_i18n27.__)("Unknown status for %1$s"),
23757 filter.name
23758 );
23759 };
23760 function OperatorSelector({
23761 filter,
23762 view,
23763 onChangeView
23764 }) {
23765 const operatorOptions = filter.operators?.map((operator) => ({
23766 value: operator,
23767 label: getOperatorByName(operator)?.label || operator
23768 }));
23769 const currentFilter = view.filters?.find(
23770 (_filter) => _filter.field === filter.field
23771 );
23772 const value = currentFilter?.operator || filter.operators[0];
23773 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(
23774 Stack,
23775 {
23776 direction: "row",
23777 gap: "sm",
23778 justify: "flex-start",
23779 className: "dataviews-filters__summary-operators-container",
23780 align: "center",
23781 children: [
23782 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
23783 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23784 import_components21.SelectControl,
23785 {
23786 className: "dataviews-filters__summary-operators-filter-select",
23787 label: (0, import_i18n27.__)("Conditions"),
23788 value,
23789 options: operatorOptions,
23790 onChange: (newValue) => {
23791 const newOperator = newValue;
23792 const currentOperator = currentFilter?.operator;
23793 const newFilters = currentFilter ? [
23794 ...(view.filters ?? []).map(
23795 (_filter) => {
23796 if (_filter.field === filter.field) {
23797 const currentOpSelectionModel = getOperatorByName(
23798 currentOperator
23799 )?.selection;
23800 const newOpSelectionModel = getOperatorByName(
23801 newOperator
23802 )?.selection;
23803 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
23804 currentOpSelectionModel,
23805 newOpSelectionModel
23806 ].includes("custom");
23807 return {
23808 ..._filter,
23809 value: shouldResetValue ? void 0 : _filter.value,
23810 operator: newOperator
23811 };
23812 }
23813 return _filter;
23814 }
23815 )
23816 ] : [
23817 ...view.filters ?? [],
23818 {
23819 field: filter.field,
23820 operator: newOperator,
23821 value: void 0
23822 }
23823 ];
23824 onChangeView({
23825 ...view,
23826 page: 1,
23827 filters: newFilters
23828 });
23829 },
23830 size: "small",
23831 variant: "minimal",
23832 hideLabelFromVision: true
23833 }
23834 )
23835 ]
23836 }
23837 );
23838 }
23839 function Filter({
23840 addFilterRef,
23841 openedFilter,
23842 fields,
23843 ...commonProps
23844 }) {
23845 const toggleRef = (0, import_element70.useRef)(null);
23846 const { filter, view, onChangeView } = commonProps;
23847 const filterInView = view.filters?.find(
23848 (f2) => f2.field === filter.field
23849 );
23850 let activeElements = [];
23851 const field = (0, import_element70.useMemo)(() => {
23852 const currentField = fields.find((f2) => f2.id === filter.field);
23853 if (currentField) {
23854 return {
23855 ...currentField,
23856 // Configure getValue as if Item was a plain object.
23857 // See related input-widget.tsx
23858 getValue: ({ item }) => item[currentField.id]
23859 };
23860 }
23861 return currentField;
23862 }, [fields, filter.field]);
23863 const { elements } = useElements({
23864 elements: filter.elements,
23865 getElements: filter.getElements
23866 });
23867 if (elements.length > 0) {
23868 activeElements = elements.filter((element) => {
23869 if (filter.singleSelection) {
23870 return element.value === filterInView?.value;
23871 }
23872 return filterInView?.value?.includes(element.value);
23873 });
23874 } else if (Array.isArray(filterInView?.value)) {
23875 const label = filterInView.value.map((v2) => {
23876 const formattedValue = field?.getValueFormatted({
23877 item: { [field.id]: v2 },
23878 field
23879 });
23880 return formattedValue || String(v2);
23881 });
23882 activeElements = [
23883 {
23884 value: filterInView.value,
23885 // @ts-ignore
23886 label
23887 }
23888 ];
23889 } else if (typeof filterInView?.value === "object") {
23890 activeElements = [
23891 { value: filterInView.value, label: filterInView.value }
23892 ];
23893 } else if (filterInView?.value !== void 0) {
23894 const label = field !== void 0 ? field.getValueFormatted({
23895 item: { [field.id]: filterInView.value },
23896 field
23897 }) : String(filterInView.value);
23898 activeElements = [
23899 {
23900 value: filterInView.value,
23901 label
23902 }
23903 ];
23904 }
23905 const isPrimary = filter.isPrimary;
23906 const isLocked = filterInView?.isLocked;
23907 const hasValues = !isLocked && filterInView?.value !== void 0;
23908 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
23909 const resetOrRemoveLabel = isPrimary ? (0, import_i18n27.__)("Reset") : (0, import_i18n27.__)("Remove");
23910 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23911 import_components21.Dropdown,
23912 {
23913 defaultOpen: openedFilter === filter.field,
23914 contentClassName: "dataviews-filters__summary-popover",
23915 popoverProps: { placement: "bottom-start", role: "dialog" },
23916 onClose: () => {
23917 toggleRef.current?.focus();
23918 },
23919 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
23920 /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(tooltip_exports.Root, { children: [
23921 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23922 tooltip_exports.Trigger,
23923 {
23924 render: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23925 "div",
23926 {
23927 className: clsx_default(
23928 "dataviews-filters__summary-chip",
23929 {
23930 "has-reset": canResetOrRemove,
23931 "has-values": hasValues,
23932 "is-not-clickable": isLocked
23933 }
23934 ),
23935 role: "button",
23936 tabIndex: isLocked ? -1 : 0,
23937 onClick: () => {
23938 if (!isLocked) {
23939 onToggle();
23940 }
23941 },
23942 onKeyDown: (event) => {
23943 if (!isLocked && [ENTER, SPACE].includes(
23944 event.key
23945 )) {
23946 onToggle();
23947 event.preventDefault();
23948 }
23949 },
23950 "aria-disabled": isLocked,
23951 "aria-pressed": isOpen,
23952 "aria-expanded": isOpen,
23953 ref: toggleRef,
23954 children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23955 FilterText,
23956 {
23957 activeElements,
23958 filterInView,
23959 filter
23960 }
23961 )
23962 }
23963 )
23964 }
23965 ),
23966 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(tooltip_exports.Popup, { children: (0, import_i18n27.sprintf)(
23967 /* translators: 1: Filter name. */
23968 (0, import_i18n27.__)("Filter by: %1$s"),
23969 filter.name.toLowerCase()
23970 ) })
23971 ] }),
23972 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(tooltip_exports.Root, { children: [
23973 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23974 tooltip_exports.Trigger,
23975 {
23976 render: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23977 "button",
23978 {
23979 className: clsx_default(
23980 "dataviews-filters__summary-chip-remove",
23981 { "has-values": hasValues }
23982 ),
23983 "aria-label": resetOrRemoveLabel,
23984 onClick: () => {
23985 onChangeView({
23986 ...view,
23987 page: 1,
23988 filters: view.filters?.filter(
23989 (_filter) => _filter.field !== filter.field
23990 )
23991 });
23992 if (!isPrimary) {
23993 addFilterRef.current?.focus();
23994 } else {
23995 toggleRef.current?.focus();
23996 }
23997 },
23998 children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components21.Icon, { icon: close_small_default })
23999 }
24000 )
24001 }
24002 ),
24003 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
24004 ] })
24005 ] }),
24006 renderContent: () => {
24007 return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
24008 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(OperatorSelector, { ...commonProps }),
24009 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24010 SearchWidget,
24011 {
24012 ...commonProps,
24013 filter: {
24014 ...commonProps.filter,
24015 elements
24016 }
24017 }
24018 ) : /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(InputWidget, { ...commonProps, fields })
24019 ] });
24020 }
24021 }
24022 );
24023 }
24024
24025 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
24026 var import_components22 = __toESM(require_components(), 1);
24027 var import_i18n28 = __toESM(require_i18n(), 1);
24028 var import_element71 = __toESM(require_element(), 1);
24029 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24030 var { Menu: Menu4 } = unlock2(import_components22.privateApis);
24031 function AddFilterMenu({
24032 filters,
24033 view,
24034 onChangeView,
24035 setOpenedFilter,
24036 triggerProps
24037 }) {
24038 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
24039 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(Menu4, { children: [
24040 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Menu4.TriggerButton, { ...triggerProps }),
24041 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
24042 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24043 Menu4.Item,
24044 {
24045 onClick: () => {
24046 setOpenedFilter(filter.field);
24047 onChangeView({
24048 ...view,
24049 page: 1,
24050 filters: [
24051 ...view.filters || [],
24052 {
24053 field: filter.field,
24054 value: void 0,
24055 operator: filter.operators[0]
24056 }
24057 ]
24058 });
24059 },
24060 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Menu4.ItemLabel, { children: filter.name })
24061 },
24062 filter.field
24063 );
24064 }) })
24065 ] });
24066 }
24067 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
24068 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
24069 return null;
24070 }
24071 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
24072 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24073 AddFilterMenu,
24074 {
24075 triggerProps: {
24076 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24077 import_components22.Button,
24078 {
24079 accessibleWhenDisabled: true,
24080 size: "compact",
24081 className: "dataviews-filters-button",
24082 variant: "tertiary",
24083 disabled: !inactiveFilters.length,
24084 ref
24085 }
24086 ),
24087 children: (0, import_i18n28.__)("Add filter")
24088 },
24089 ...{ filters, view, onChangeView, setOpenedFilter }
24090 }
24091 );
24092 }
24093 var add_filter_default = (0, import_element71.forwardRef)(AddFilter);
24094
24095 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
24096 var import_components23 = __toESM(require_components(), 1);
24097 var import_i18n29 = __toESM(require_i18n(), 1);
24098 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24099 function ResetFilter({
24100 filters,
24101 view,
24102 onChangeView
24103 }) {
24104 const isPrimary = (field) => filters.some(
24105 (_filter) => _filter.field === field && _filter.isPrimary
24106 );
24107 const isDisabled = !view.search && !view.filters?.some(
24108 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
24109 );
24110 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24111 import_components23.Button,
24112 {
24113 disabled: isDisabled,
24114 accessibleWhenDisabled: true,
24115 size: "compact",
24116 variant: "tertiary",
24117 className: "dataviews-filters__reset-button",
24118 onClick: () => {
24119 onChangeView({
24120 ...view,
24121 page: 1,
24122 search: "",
24123 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
24124 });
24125 },
24126 children: (0, import_i18n29.__)("Reset")
24127 }
24128 );
24129 }
24130
24131 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
24132 var import_element72 = __toESM(require_element(), 1);
24133 function useFilters(fields, view) {
24134 return (0, import_element72.useMemo)(() => {
24135 const filters = [];
24136 fields.forEach((field) => {
24137 if (field.filterBy === false || !field.hasElements && !field.Edit) {
24138 return;
24139 }
24140 const operators = field.filterBy.operators;
24141 const isPrimary = !!field.filterBy?.isPrimary;
24142 const isLocked = view.filters?.some(
24143 (f2) => f2.field === field.id && !!f2.isLocked
24144 ) ?? false;
24145 filters.push({
24146 field: field.id,
24147 name: field.label,
24148 elements: field.elements,
24149 getElements: field.getElements,
24150 hasElements: field.hasElements,
24151 singleSelection: operators.some(
24152 (op) => isSingleSelectionOperator(op)
24153 ),
24154 operators,
24155 isVisible: isLocked || isPrimary || !!view.filters?.some(
24156 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
24157 ),
24158 isPrimary,
24159 isLocked
24160 });
24161 });
24162 filters.sort((a2, b2) => {
24163 if (a2.isLocked && !b2.isLocked) {
24164 return -1;
24165 }
24166 if (!a2.isLocked && b2.isLocked) {
24167 return 1;
24168 }
24169 if (a2.isPrimary && !b2.isPrimary) {
24170 return -1;
24171 }
24172 if (!a2.isPrimary && b2.isPrimary) {
24173 return 1;
24174 }
24175 return a2.name.localeCompare(b2.name);
24176 });
24177 return filters;
24178 }, [fields, view]);
24179 }
24180 var use_filters_default = useFilters;
24181
24182 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
24183 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24184 function Filters({ className }) {
24185 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element73.useContext)(dataviews_context_default);
24186 const addFilterRef = (0, import_element73.useRef)(null);
24187 const filters = use_filters_default(fields, view);
24188 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24189 add_filter_default,
24190 {
24191 filters,
24192 view,
24193 onChangeView,
24194 ref: addFilterRef,
24195 setOpenedFilter
24196 },
24197 "add-filter"
24198 );
24199 const visibleFilters = filters.filter((filter) => filter.isVisible);
24200 if (visibleFilters.length === 0) {
24201 return null;
24202 }
24203 const filterComponents = [
24204 ...visibleFilters.map((filter) => {
24205 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24206 Filter,
24207 {
24208 filter,
24209 view,
24210 fields,
24211 onChangeView,
24212 addFilterRef,
24213 openedFilter
24214 },
24215 filter.field
24216 );
24217 }),
24218 addFilter
24219 ];
24220 filterComponents.push(
24221 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24222 ResetFilter,
24223 {
24224 filters,
24225 view,
24226 onChangeView
24227 },
24228 "reset-filters"
24229 )
24230 );
24231 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24232 Stack,
24233 {
24234 direction: "row",
24235 justify: "flex-start",
24236 gap: "sm",
24237 style: { width: "fit-content" },
24238 wrap: "wrap",
24239 className,
24240 children: filterComponents
24241 }
24242 );
24243 }
24244 var filters_default = (0, import_element73.memo)(Filters);
24245
24246 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
24247 var import_element74 = __toESM(require_element(), 1);
24248 var import_components24 = __toESM(require_components(), 1);
24249 var import_i18n30 = __toESM(require_i18n(), 1);
24250 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24251 function FiltersToggle() {
24252 const {
24253 filters,
24254 view,
24255 onChangeView,
24256 setOpenedFilter,
24257 isShowingFilter,
24258 setIsShowingFilter
24259 } = (0, import_element74.useContext)(dataviews_context_default);
24260 const buttonRef = (0, import_element74.useRef)(null);
24261 const onChangeViewWithFilterVisibility = (0, import_element74.useCallback)(
24262 (_view) => {
24263 onChangeView(_view);
24264 setIsShowingFilter(true);
24265 },
24266 [onChangeView, setIsShowingFilter]
24267 );
24268 if (filters.length === 0) {
24269 return null;
24270 }
24271 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
24272 const addFilterButtonProps = {
24273 label: (0, import_i18n30.__)("Add filter"),
24274 "aria-expanded": false,
24275 isPressed: false
24276 };
24277 const toggleFiltersButtonProps = {
24278 label: (0, import_i18n30._x)("Filter", "verb"),
24279 "aria-expanded": isShowingFilter,
24280 isPressed: isShowingFilter,
24281 onClick: () => {
24282 if (!isShowingFilter) {
24283 setOpenedFilter(null);
24284 }
24285 setIsShowingFilter(!isShowingFilter);
24286 }
24287 };
24288 const hasPrimaryOrLockedFilters = filters.some(
24289 (filter) => filter.isPrimary || filter.isLocked
24290 );
24291 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24292 import_components24.Button,
24293 {
24294 ref: buttonRef,
24295 className: "dataviews-filters__visibility-toggle",
24296 size: "compact",
24297 icon: funnel_default,
24298 disabled: hasPrimaryOrLockedFilters,
24299 accessibleWhenDisabled: true,
24300 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
24301 }
24302 );
24303 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24304 AddFilterMenu,
24305 {
24306 filters,
24307 view,
24308 onChangeView: onChangeViewWithFilterVisibility,
24309 setOpenedFilter,
24310 triggerProps: { render: buttonComponent }
24311 }
24312 ) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24313 FilterVisibilityToggle,
24314 {
24315 buttonRef,
24316 filtersCount: view.filters?.length,
24317 children: buttonComponent
24318 }
24319 ) });
24320 }
24321 function FilterVisibilityToggle({
24322 buttonRef,
24323 filtersCount,
24324 children
24325 }) {
24326 (0, import_element74.useEffect)(
24327 () => () => {
24328 buttonRef.current?.focus();
24329 },
24330 [buttonRef]
24331 );
24332 return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_jsx_runtime104.Fragment, { children: [
24333 children,
24334 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
24335 ] });
24336 }
24337 var toggle_default = FiltersToggle;
24338
24339 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
24340 var import_element75 = __toESM(require_element(), 1);
24341 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24342 function FiltersToggled(props) {
24343 const { isShowingFilter } = (0, import_element75.useContext)(dataviews_context_default);
24344 if (!isShowingFilter) {
24345 return null;
24346 }
24347 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(filters_default, { ...props });
24348 }
24349 var filters_toggled_default = FiltersToggled;
24350
24351 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
24352 var import_element76 = __toESM(require_element(), 1);
24353 var import_components25 = __toESM(require_components(), 1);
24354 var import_i18n31 = __toESM(require_i18n(), 1);
24355 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24356 function DataViewsLayout({ className }) {
24357 const {
24358 actions = [],
24359 data,
24360 fields,
24361 getItemId,
24362 getItemLevel,
24363 hasInitiallyLoaded,
24364 isLoading,
24365 view,
24366 onChangeView,
24367 selection,
24368 onChangeSelection,
24369 setOpenedFilter,
24370 onClickItem,
24371 isItemClickable,
24372 renderItemLink,
24373 defaultLayouts,
24374 containerRef,
24375 empty = /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("p", { children: (0, import_i18n31.__)("No results") })
24376 } = (0, import_element76.useContext)(dataviews_context_default);
24377 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
24378 delay: 200
24379 });
24380 if (!hasInitiallyLoaded) {
24381 if (!isDelayedInitialLoading) {
24382 return null;
24383 }
24384 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components25.Spinner, {}) }) });
24385 }
24386 const ViewComponent = VIEW_LAYOUTS.find(
24387 (v2) => v2.type === view.type && defaultLayouts[v2.type]
24388 )?.component;
24389 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24390 ViewComponent,
24391 {
24392 className,
24393 actions,
24394 data,
24395 fields,
24396 getItemId,
24397 getItemLevel,
24398 isLoading,
24399 onChangeView,
24400 onChangeSelection,
24401 selection,
24402 setOpenedFilter,
24403 onClickItem,
24404 renderItemLink,
24405 isItemClickable,
24406 view,
24407 empty
24408 }
24409 ) });
24410 }
24411
24412 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
24413 var import_element77 = __toESM(require_element(), 1);
24414 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24415 var EMPTY_ARRAY5 = [];
24416 function DataViewsFooter() {
24417 const {
24418 view,
24419 paginationInfo: { totalItems = 0, totalPages },
24420 data,
24421 actions = EMPTY_ARRAY5,
24422 isLoading,
24423 hasInitiallyLoaded
24424 } = (0, import_element77.useContext)(dataviews_context_default);
24425 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
24426 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
24427 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
24428 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
24429 return null;
24430 }
24431 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24432 "div",
24433 {
24434 className: "dataviews-footer",
24435 inert: isRefreshing ? "true" : void 0,
24436 children: /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(
24437 Stack,
24438 {
24439 direction: "row",
24440 justify: "end",
24441 align: "center",
24442 className: clsx_default("dataviews-footer__content", {
24443 "is-refreshing": isDelayedRefreshing
24444 }),
24445 gap: "sm",
24446 children: [
24447 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(BulkActionsFooter, {}),
24448 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(dataviews_pagination_default, {})
24449 ]
24450 }
24451 )
24452 }
24453 );
24454 }
24455
24456 // packages/dataviews/build-module/components/dataviews-search/index.mjs
24457 var import_i18n32 = __toESM(require_i18n(), 1);
24458 var import_element78 = __toESM(require_element(), 1);
24459 var import_components26 = __toESM(require_components(), 1);
24460 var import_compose10 = __toESM(require_compose(), 1);
24461 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24462 var DataViewsSearch = (0, import_element78.memo)(function Search({ label }) {
24463 const { view, onChangeView } = (0, import_element78.useContext)(dataviews_context_default);
24464 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
24465 view.search
24466 );
24467 (0, import_element78.useEffect)(() => {
24468 if (view.search !== debouncedSearch) {
24469 setSearch(view.search ?? "");
24470 }
24471 }, [view.search, setSearch]);
24472 const onChangeViewRef = (0, import_element78.useRef)(onChangeView);
24473 const viewRef = (0, import_element78.useRef)(view);
24474 (0, import_element78.useEffect)(() => {
24475 onChangeViewRef.current = onChangeView;
24476 viewRef.current = view;
24477 }, [onChangeView, view]);
24478 (0, import_element78.useEffect)(() => {
24479 if (debouncedSearch !== viewRef.current?.search) {
24480 onChangeViewRef.current({
24481 ...viewRef.current,
24482 page: view.page ? 1 : void 0,
24483 startPosition: view.startPosition ? 1 : void 0,
24484 search: debouncedSearch
24485 });
24486 }
24487 }, [debouncedSearch]);
24488 const searchLabel = label || (0, import_i18n32.__)("Search");
24489 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24490 import_components26.SearchControl,
24491 {
24492 className: "dataviews-search",
24493 onChange: setSearch,
24494 value: search,
24495 label: searchLabel,
24496 placeholder: searchLabel,
24497 size: "compact"
24498 }
24499 );
24500 });
24501 var dataviews_search_default = DataViewsSearch;
24502
24503 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
24504 var import_components27 = __toESM(require_components(), 1);
24505 var import_i18n33 = __toESM(require_i18n(), 1);
24506 var import_element79 = __toESM(require_element(), 1);
24507 var import_warning = __toESM(require_warning(), 1);
24508 var import_compose11 = __toESM(require_compose(), 1);
24509 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24510 var { Menu: Menu5 } = unlock2(import_components27.privateApis);
24511 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
24512 className: "dataviews-config__popover",
24513 placement: "bottom-end",
24514 offset: 9
24515 };
24516 function ViewTypeMenu() {
24517 const { view, onChangeView, defaultLayouts } = (0, import_element79.useContext)(dataviews_context_default);
24518 const availableLayouts = Object.keys(defaultLayouts);
24519 if (availableLayouts.length <= 1) {
24520 return null;
24521 }
24522 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
24523 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(Menu5, { children: [
24524 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24525 Menu5.TriggerButton,
24526 {
24527 render: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24528 import_components27.Button,
24529 {
24530 size: "compact",
24531 icon: activeView?.icon,
24532 label: (0, import_i18n33.__)("Layout")
24533 }
24534 )
24535 }
24536 ),
24537 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
24538 const config = VIEW_LAYOUTS.find(
24539 (v2) => v2.type === layout
24540 );
24541 if (!config) {
24542 return null;
24543 }
24544 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24545 Menu5.RadioItem,
24546 {
24547 value: layout,
24548 name: "view-actions-available-view",
24549 checked: layout === view.type,
24550 hideOnClick: true,
24551 onChange: (e2) => {
24552 switch (e2.target.value) {
24553 case "list":
24554 case "grid":
24555 case "table":
24556 case "pickerGrid":
24557 case "pickerTable":
24558 case "pickerActivity":
24559 case "activity":
24560 const viewWithoutLayout = { ...view };
24561 if ("layout" in viewWithoutLayout) {
24562 delete viewWithoutLayout.layout;
24563 }
24564 return onChangeView({
24565 ...viewWithoutLayout,
24566 type: e2.target.value,
24567 ...defaultLayouts[e2.target.value]
24568 });
24569 }
24570 (0, import_warning.default)("Invalid dataview");
24571 },
24572 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Menu5.ItemLabel, { children: config.label })
24573 },
24574 layout
24575 );
24576 }) })
24577 ] });
24578 }
24579 function SortFieldControl() {
24580 const { view, fields, onChangeView } = (0, import_element79.useContext)(dataviews_context_default);
24581 const orderOptions = (0, import_element79.useMemo)(() => {
24582 const sortableFields = fields.filter(
24583 (field) => field.enableSorting !== false
24584 );
24585 return sortableFields.map((field) => {
24586 return {
24587 label: field.label,
24588 value: field.id
24589 };
24590 });
24591 }, [fields]);
24592 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24593 import_components27.SelectControl,
24594 {
24595 __next40pxDefaultSize: true,
24596 label: (0, import_i18n33.__)("Sort by"),
24597 value: view.sort?.field,
24598 options: orderOptions,
24599 onChange: (value) => {
24600 onChangeView({
24601 ...view,
24602 sort: {
24603 direction: view?.sort?.direction || "desc",
24604 field: value
24605 },
24606 showLevels: false
24607 });
24608 }
24609 }
24610 );
24611 }
24612 function SortDirectionControl() {
24613 const { view, fields, onChangeView } = (0, import_element79.useContext)(dataviews_context_default);
24614 const sortableFields = fields.filter(
24615 (field) => field.enableSorting !== false
24616 );
24617 if (sortableFields.length === 0) {
24618 return null;
24619 }
24620 let value = view.sort?.direction;
24621 if (!value && view.sort?.field) {
24622 value = "desc";
24623 }
24624 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24625 import_components27.__experimentalToggleGroupControl,
24626 {
24627 className: "dataviews-view-config__sort-direction",
24628 __next40pxDefaultSize: true,
24629 isBlock: true,
24630 label: (0, import_i18n33.__)("Order"),
24631 value,
24632 onChange: (newDirection) => {
24633 if (newDirection === "asc" || newDirection === "desc") {
24634 onChangeView({
24635 ...view,
24636 sort: {
24637 direction: newDirection,
24638 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
24639 fields.find(
24640 (field) => field.enableSorting !== false
24641 )?.id || ""
24642 },
24643 showLevels: false
24644 });
24645 return;
24646 }
24647 (0, import_warning.default)("Invalid direction");
24648 },
24649 children: SORTING_DIRECTIONS.map((direction) => {
24650 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24651 import_components27.__experimentalToggleGroupControlOptionIcon,
24652 {
24653 value: direction,
24654 icon: sortIcons[direction],
24655 label: sortLabels[direction]
24656 },
24657 direction
24658 );
24659 })
24660 }
24661 );
24662 }
24663 function ItemsPerPageControl() {
24664 const { view, config, onChangeView } = (0, import_element79.useContext)(dataviews_context_default);
24665 const { infiniteScrollEnabled } = view;
24666 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
24667 return null;
24668 }
24669 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24670 import_components27.__experimentalToggleGroupControl,
24671 {
24672 __next40pxDefaultSize: true,
24673 isBlock: true,
24674 label: (0, import_i18n33.__)("Items per page"),
24675 value: view.perPage || 10,
24676 disabled: !view?.sort?.field,
24677 onChange: (newItemsPerPage) => {
24678 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
24679 onChangeView({
24680 ...view,
24681 perPage: newItemsPerPageNumber,
24682 page: 1
24683 });
24684 },
24685 children: config.perPageSizes.map((value) => {
24686 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24687 import_components27.__experimentalToggleGroupControlOption,
24688 {
24689 value,
24690 label: value.toString()
24691 },
24692 value
24693 );
24694 })
24695 }
24696 );
24697 }
24698 function ResetViewButton() {
24699 const { onReset } = (0, import_element79.useContext)(dataviews_context_default);
24700 if (onReset === void 0) {
24701 return null;
24702 }
24703 const isDisabled = onReset === false;
24704 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24705 import_components27.Button,
24706 {
24707 variant: "tertiary",
24708 size: "compact",
24709 disabled: isDisabled,
24710 accessibleWhenDisabled: true,
24711 className: "dataviews-view-config__reset-button",
24712 onClick: () => {
24713 if (typeof onReset === "function") {
24714 onReset();
24715 }
24716 },
24717 children: (0, import_i18n33.__)("Reset view")
24718 }
24719 );
24720 }
24721 function DataviewsViewConfigDropdown() {
24722 const { view, onReset } = (0, import_element79.useContext)(dataviews_context_default);
24723 const popoverId = (0, import_compose11.useInstanceId)(
24724 _DataViewsViewConfig,
24725 "dataviews-view-config-dropdown"
24726 );
24727 const activeLayout = VIEW_LAYOUTS.find(
24728 (layout) => layout.type === view.type
24729 );
24730 const isModified = typeof onReset === "function";
24731 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24732 import_components27.Dropdown,
24733 {
24734 expandOnMobile: true,
24735 popoverProps: {
24736 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
24737 id: popoverId
24738 },
24739 renderToggle: ({ onToggle, isOpen }) => {
24740 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
24741 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24742 import_components27.Button,
24743 {
24744 size: "compact",
24745 icon: cog_default,
24746 label: (0, import_i18n33._x)(
24747 "View options",
24748 "View is used as a noun"
24749 ),
24750 onClick: onToggle,
24751 "aria-expanded": isOpen ? "true" : "false",
24752 "aria-controls": popoverId
24753 }
24754 ),
24755 isModified && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
24756 ] });
24757 },
24758 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24759 import_components27.__experimentalDropdownContentWrapper,
24760 {
24761 paddingSize: "medium",
24762 className: "dataviews-config__popover-content-wrapper",
24763 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
24764 Stack,
24765 {
24766 direction: "column",
24767 className: "dataviews-view-config",
24768 gap: "xl",
24769 children: [
24770 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
24771 Stack,
24772 {
24773 direction: "row",
24774 justify: "space-between",
24775 align: "center",
24776 className: "dataviews-view-config__header",
24777 children: [
24778 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24779 import_components27.__experimentalHeading,
24780 {
24781 level: 2,
24782 className: "dataviews-settings-section__title",
24783 children: (0, import_i18n33.__)("Appearance")
24784 }
24785 ),
24786 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ResetViewButton, {})
24787 ]
24788 }
24789 ),
24790 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(Stack, { direction: "column", gap: "lg", children: [
24791 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
24792 Stack,
24793 {
24794 direction: "row",
24795 gap: "sm",
24796 className: "dataviews-view-config__sort-controls",
24797 children: [
24798 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(SortFieldControl, {}),
24799 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(SortDirectionControl, {})
24800 ]
24801 }
24802 ),
24803 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(activeLayout.viewConfigOptions, {}),
24804 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ItemsPerPageControl, {}),
24805 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(PropertiesSection, {})
24806 ] })
24807 ]
24808 }
24809 )
24810 }
24811 )
24812 }
24813 );
24814 }
24815 function _DataViewsViewConfig() {
24816 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
24817 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ViewTypeMenu, {}),
24818 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(DataviewsViewConfigDropdown, {})
24819 ] });
24820 }
24821 var DataViewsViewConfig = (0, import_element79.memo)(_DataViewsViewConfig);
24822 var dataviews_view_config_default = DataViewsViewConfig;
24823
24824 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
24825 var import_components28 = __toESM(require_components(), 1);
24826 var import_element80 = __toESM(require_element(), 1);
24827
24828 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
24829 function getCustomValidity(isValid2, validity) {
24830 let customValidity;
24831 if (isValid2?.required && validity?.required) {
24832 customValidity = validity?.required?.message ? validity.required : void 0;
24833 } else if (isValid2?.pattern && validity?.pattern) {
24834 customValidity = validity.pattern;
24835 } else if (isValid2?.min && validity?.min) {
24836 customValidity = validity.min;
24837 } else if (isValid2?.max && validity?.max) {
24838 customValidity = validity.max;
24839 } else if (isValid2?.minLength && validity?.minLength) {
24840 customValidity = validity.minLength;
24841 } else if (isValid2?.maxLength && validity?.maxLength) {
24842 customValidity = validity.maxLength;
24843 } else if (isValid2?.elements && validity?.elements) {
24844 customValidity = validity.elements;
24845 } else if (validity?.custom) {
24846 customValidity = validity.custom;
24847 }
24848 return customValidity;
24849 }
24850
24851 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
24852 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24853 var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis);
24854 function Checkbox({
24855 field,
24856 onChange,
24857 data,
24858 hideLabelFromVision,
24859 markWhenOptional,
24860 validity
24861 }) {
24862 const { getValue, setValue, label, description, isValid: isValid2 } = field;
24863 const disabled2 = field.isDisabled({ item: data, field });
24864 const onChangeControl = (0, import_element80.useCallback)(() => {
24865 onChange(
24866 setValue({ item: data, value: !getValue({ item: data }) })
24867 );
24868 }, [data, getValue, onChange, setValue]);
24869 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24870 ValidatedCheckboxControl,
24871 {
24872 required: !!field.isValid?.required,
24873 markWhenOptional,
24874 customValidity: getCustomValidity(isValid2, validity),
24875 hidden: hideLabelFromVision,
24876 label,
24877 help: description,
24878 checked: getValue({ item: data }),
24879 onChange: onChangeControl,
24880 disabled: disabled2
24881 }
24882 );
24883 }
24884
24885 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
24886 var import_components29 = __toESM(require_components(), 1);
24887 var import_element81 = __toESM(require_element(), 1);
24888 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24889 var { ValidatedComboboxControl } = unlock2(import_components29.privateApis);
24890 function Combobox3({
24891 data,
24892 field,
24893 onChange,
24894 hideLabelFromVision,
24895 validity
24896 }) {
24897 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
24898 const value = getValue({ item: data }) ?? "";
24899 const onChangeControl = (0, import_element81.useCallback)(
24900 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
24901 [data, onChange, setValue]
24902 );
24903 const { elements, isLoading } = useElements({
24904 elements: field.elements,
24905 getElements: field.getElements
24906 });
24907 if (isLoading) {
24908 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components29.Spinner, {});
24909 }
24910 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24911 ValidatedComboboxControl,
24912 {
24913 required: !!field.isValid?.required,
24914 customValidity: getCustomValidity(isValid2, validity),
24915 label,
24916 value,
24917 help: description,
24918 placeholder,
24919 options: elements,
24920 onChange: onChangeControl,
24921 hideLabelFromVision,
24922 allowReset: true,
24923 expandOnFocus: true
24924 }
24925 );
24926 }
24927
24928 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
24929 var import_components31 = __toESM(require_components(), 1);
24930 var import_element84 = __toESM(require_element(), 1);
24931 var import_i18n35 = __toESM(require_i18n(), 1);
24932 var import_date3 = __toESM(require_date(), 1);
24933
24934 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
24935 var import_components30 = __toESM(require_components(), 1);
24936 var import_element82 = __toESM(require_element(), 1);
24937 var import_i18n34 = __toESM(require_i18n(), 1);
24938 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24939 var TIME_UNITS_OPTIONS = {
24940 [OPERATOR_IN_THE_PAST]: [
24941 { value: "days", label: (0, import_i18n34.__)("Days") },
24942 { value: "weeks", label: (0, import_i18n34.__)("Weeks") },
24943 { value: "months", label: (0, import_i18n34.__)("Months") },
24944 { value: "years", label: (0, import_i18n34.__)("Years") }
24945 ],
24946 [OPERATOR_OVER]: [
24947 { value: "days", label: (0, import_i18n34.__)("Days ago") },
24948 { value: "weeks", label: (0, import_i18n34.__)("Weeks ago") },
24949 { value: "months", label: (0, import_i18n34.__)("Months ago") },
24950 { value: "years", label: (0, import_i18n34.__)("Years ago") }
24951 ]
24952 };
24953 function RelativeDateControl({
24954 className,
24955 data,
24956 field,
24957 onChange,
24958 hideLabelFromVision,
24959 operator
24960 }) {
24961 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
24962 const { id, label, description, getValue, setValue } = field;
24963 const disabled2 = field.isDisabled({ item: data, field });
24964 const fieldValue = getValue({ item: data });
24965 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
24966 const onChangeValue = (0, import_element82.useCallback)(
24967 (newValue) => onChange(
24968 setValue({
24969 item: data,
24970 value: { value: Number(newValue), unit }
24971 })
24972 ),
24973 [onChange, setValue, data, unit]
24974 );
24975 const onChangeUnit = (0, import_element82.useCallback)(
24976 (newUnit) => onChange(
24977 setValue({
24978 item: data,
24979 value: { value: relValue, unit: newUnit }
24980 })
24981 ),
24982 [onChange, setValue, data, relValue]
24983 );
24984 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24985 import_components30.BaseControl,
24986 {
24987 id,
24988 className: clsx_default(className, "dataviews-controls__relative-date"),
24989 label,
24990 hideLabelFromVision,
24991 help: description,
24992 children: /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(Stack, { direction: "row", gap: "sm", children: [
24993 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24994 import_components30.__experimentalNumberControl,
24995 {
24996 __next40pxDefaultSize: true,
24997 className: "dataviews-controls__relative-date-number",
24998 spinControls: "none",
24999 min: 1,
25000 step: 1,
25001 value: relValue,
25002 onChange: onChangeValue,
25003 disabled: disabled2
25004 }
25005 ),
25006 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25007 import_components30.SelectControl,
25008 {
25009 className: "dataviews-controls__relative-date-unit",
25010 __next40pxDefaultSize: true,
25011 label: (0, import_i18n34.__)("Unit"),
25012 value: unit,
25013 options,
25014 onChange: onChangeUnit,
25015 hideLabelFromVision: true,
25016 disabled: disabled2
25017 }
25018 )
25019 ] })
25020 }
25021 );
25022 }
25023
25024 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
25025 var import_element83 = __toESM(require_element(), 1);
25026 function useDisabledDateMatchers(isValid2, parseDateFn) {
25027 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
25028 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
25029 const disabledMatchers = (0, import_element83.useMemo)(() => {
25030 const matchers = [];
25031 if (minConstraint) {
25032 const minDate = parseDateFn(minConstraint);
25033 if (minDate) {
25034 matchers.push({ before: minDate });
25035 }
25036 }
25037 if (maxConstraint) {
25038 const maxDate = parseDateFn(maxConstraint);
25039 if (maxDate) {
25040 matchers.push({ after: maxDate });
25041 }
25042 }
25043 return matchers.length > 0 ? matchers : void 0;
25044 }, [minConstraint, maxConstraint, parseDateFn]);
25045 return { minConstraint, maxConstraint, disabledMatchers };
25046 }
25047
25048 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
25049 var import_date2 = __toESM(require_date(), 1);
25050 function parseDateTime(dateTimeString) {
25051 if (!dateTimeString) {
25052 return null;
25053 }
25054 const parsed = (0, import_date2.getDate)(dateTimeString);
25055 return parsed && isValid(parsed) ? parsed : null;
25056 }
25057
25058 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
25059 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
25060 var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis);
25061 var formatDateTime = (value) => {
25062 if (!value) {
25063 return "";
25064 }
25065 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
25066 };
25067 function CalendarDateTimeControl({
25068 data,
25069 field,
25070 onChange,
25071 hideLabelFromVision,
25072 markWhenOptional,
25073 validity,
25074 config
25075 }) {
25076 const { compact } = config || {};
25077 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
25078 const disabled2 = field.isDisabled({ item: data, field });
25079 const fieldValue = getValue({ item: data });
25080 const value = typeof fieldValue === "string" ? fieldValue : void 0;
25081 const [calendarMonth, setCalendarMonth] = (0, import_element84.useState)(() => {
25082 const parsedDate = parseDateTime(value);
25083 return parsedDate || /* @__PURE__ */ new Date();
25084 });
25085 const inputControlRef = (0, import_element84.useRef)(null);
25086 const validationTimeoutRef = (0, import_element84.useRef)(void 0);
25087 const previousFocusRef = (0, import_element84.useRef)(null);
25088 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
25089 const onChangeCallback = (0, import_element84.useCallback)(
25090 (newValue) => onChange(setValue({ item: data, value: newValue })),
25091 [data, onChange, setValue]
25092 );
25093 (0, import_element84.useEffect)(() => {
25094 return () => {
25095 if (validationTimeoutRef.current) {
25096 clearTimeout(validationTimeoutRef.current);
25097 }
25098 };
25099 }, []);
25100 const onSelectDate = (0, import_element84.useCallback)(
25101 (newDate) => {
25102 let dateTimeValue;
25103 if (newDate) {
25104 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
25105 let wpTime;
25106 if (value) {
25107 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
25108 } else {
25109 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
25110 }
25111 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
25112 dateTimeValue = finalDateTime.toISOString();
25113 onChangeCallback(dateTimeValue);
25114 if (validationTimeoutRef.current) {
25115 clearTimeout(validationTimeoutRef.current);
25116 }
25117 } else {
25118 onChangeCallback(void 0);
25119 }
25120 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
25121 validationTimeoutRef.current = setTimeout(() => {
25122 if (inputControlRef.current) {
25123 inputControlRef.current.focus();
25124 inputControlRef.current.blur();
25125 onChangeCallback(dateTimeValue);
25126 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
25127 previousFocusRef.current.focus();
25128 }
25129 }
25130 }, 0);
25131 },
25132 [onChangeCallback, value]
25133 );
25134 const handleManualDateTimeChange = (0, import_element84.useCallback)(
25135 (newValue) => {
25136 if (newValue) {
25137 const dateTime = (0, import_date3.getDate)(newValue);
25138 onChangeCallback(dateTime.toISOString());
25139 const parsedDate = parseDateTime(dateTime.toISOString());
25140 if (parsedDate) {
25141 setCalendarMonth(parsedDate);
25142 }
25143 } else {
25144 onChangeCallback(void 0);
25145 }
25146 },
25147 [onChangeCallback]
25148 );
25149 const { format: fieldFormat } = field;
25150 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
25151 const {
25152 timezone: { string: timezoneString }
25153 } = (0, import_date3.getSettings)();
25154 let displayLabel = label;
25155 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
25156 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
25157 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
25158 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
25159 }
25160 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25161 import_components31.BaseControl,
25162 {
25163 id,
25164 label: displayLabel,
25165 help: description,
25166 hideLabelFromVision,
25167 children: /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(Stack, { direction: "column", gap: "lg", children: [
25168 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25169 ValidatedInputControl,
25170 {
25171 ref: inputControlRef,
25172 __next40pxDefaultSize: true,
25173 required: !!isValid2?.required,
25174 customValidity: getCustomValidity(isValid2, validity),
25175 type: "datetime-local",
25176 label: (0, import_i18n35.__)("Date time"),
25177 hideLabelFromVision: true,
25178 value: formatDateTime(value),
25179 onChange: handleManualDateTimeChange,
25180 disabled: disabled2,
25181 min: minConstraint ? formatDateTime(minConstraint) : void 0,
25182 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
25183 }
25184 ),
25185 !compact && /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25186 DateCalendar,
25187 {
25188 style: { width: "100%" },
25189 selected: value ? parseDateTime(value) || void 0 : void 0,
25190 onSelect: onSelectDate,
25191 month: calendarMonth,
25192 onMonthChange: setCalendarMonth,
25193 timeZone: timezoneString || void 0,
25194 weekStartsOn,
25195 disabled: disabled2 || disabledMatchers
25196 }
25197 )
25198 ] })
25199 }
25200 );
25201 }
25202 function DateTime({
25203 data,
25204 field,
25205 onChange,
25206 hideLabelFromVision,
25207 markWhenOptional,
25208 operator,
25209 validity,
25210 config
25211 }) {
25212 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
25213 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25214 RelativeDateControl,
25215 {
25216 className: "dataviews-controls__datetime",
25217 data,
25218 field,
25219 onChange,
25220 hideLabelFromVision,
25221 operator
25222 }
25223 );
25224 }
25225 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25226 CalendarDateTimeControl,
25227 {
25228 data,
25229 field,
25230 onChange,
25231 hideLabelFromVision,
25232 markWhenOptional,
25233 validity,
25234 config
25235 }
25236 );
25237 }
25238
25239 // packages/dataviews/build-module/components/dataform-controls/date.mjs
25240 var import_components32 = __toESM(require_components(), 1);
25241 var import_element85 = __toESM(require_element(), 1);
25242 var import_i18n36 = __toESM(require_i18n(), 1);
25243 var import_date4 = __toESM(require_date(), 1);
25244 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
25245 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis);
25246 var DATE_PRESETS = [
25247 {
25248 id: "today",
25249 label: (0, import_i18n36.__)("Today"),
25250 getValue: () => (0, import_date4.getDate)(null)
25251 },
25252 {
25253 id: "yesterday",
25254 label: (0, import_i18n36.__)("Yesterday"),
25255 getValue: () => {
25256 const today = (0, import_date4.getDate)(null);
25257 return subDays(today, 1);
25258 }
25259 },
25260 {
25261 id: "past-week",
25262 label: (0, import_i18n36.__)("Past week"),
25263 getValue: () => {
25264 const today = (0, import_date4.getDate)(null);
25265 return subDays(today, 7);
25266 }
25267 },
25268 {
25269 id: "past-month",
25270 label: (0, import_i18n36.__)("Past month"),
25271 getValue: () => {
25272 const today = (0, import_date4.getDate)(null);
25273 return subMonths(today, 1);
25274 }
25275 }
25276 ];
25277 var DATE_RANGE_PRESETS = [
25278 {
25279 id: "last-7-days",
25280 label: (0, import_i18n36.__)("Last 7 days"),
25281 getValue: () => {
25282 const today = (0, import_date4.getDate)(null);
25283 return [subDays(today, 7), today];
25284 }
25285 },
25286 {
25287 id: "last-30-days",
25288 label: (0, import_i18n36.__)("Last 30 days"),
25289 getValue: () => {
25290 const today = (0, import_date4.getDate)(null);
25291 return [subDays(today, 30), today];
25292 }
25293 },
25294 {
25295 id: "month-to-date",
25296 label: (0, import_i18n36.__)("Month to date"),
25297 getValue: () => {
25298 const today = (0, import_date4.getDate)(null);
25299 return [startOfMonth(today), today];
25300 }
25301 },
25302 {
25303 id: "last-year",
25304 label: (0, import_i18n36.__)("Last year"),
25305 getValue: () => {
25306 const today = (0, import_date4.getDate)(null);
25307 return [subYears(today, 1), today];
25308 }
25309 },
25310 {
25311 id: "year-to-date",
25312 label: (0, import_i18n36.__)("Year to date"),
25313 getValue: () => {
25314 const today = (0, import_date4.getDate)(null);
25315 return [startOfYear(today), today];
25316 }
25317 }
25318 ];
25319 var parseDate = (dateString) => {
25320 if (!dateString) {
25321 return null;
25322 }
25323 const parsed = (0, import_date4.getDate)(dateString);
25324 return parsed && isValid(parsed) ? parsed : null;
25325 };
25326 var formatDate = (date) => {
25327 if (!date) {
25328 return "";
25329 }
25330 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
25331 };
25332 function ValidatedDateControl({
25333 field,
25334 validity,
25335 inputRefs,
25336 isTouched,
25337 setIsTouched,
25338 children
25339 }) {
25340 const { isValid: isValid2 } = field;
25341 const [customValidity, setCustomValidity] = (0, import_element85.useState)(void 0);
25342 const validateRefs = (0, import_element85.useCallback)(() => {
25343 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25344 for (const ref of refs) {
25345 const input = ref.current;
25346 if (input && !input.validity.valid) {
25347 setCustomValidity({
25348 type: "invalid",
25349 message: input.validationMessage
25350 });
25351 return;
25352 }
25353 }
25354 setCustomValidity(void 0);
25355 }, [inputRefs]);
25356 (0, import_element85.useEffect)(() => {
25357 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25358 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
25359 for (const ref of refs) {
25360 const input = ref.current;
25361 if (input) {
25362 input.setCustomValidity(
25363 result?.type === "invalid" && result.message ? result.message : ""
25364 );
25365 }
25366 }
25367 }, [inputRefs, isValid2, validity]);
25368 (0, import_element85.useEffect)(() => {
25369 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25370 const handleInvalid = (event) => {
25371 event.preventDefault();
25372 setIsTouched(true);
25373 };
25374 for (const ref of refs) {
25375 ref.current?.addEventListener("invalid", handleInvalid);
25376 }
25377 return () => {
25378 for (const ref of refs) {
25379 ref.current?.removeEventListener("invalid", handleInvalid);
25380 }
25381 };
25382 }, [inputRefs, setIsTouched]);
25383 (0, import_element85.useEffect)(() => {
25384 if (!isTouched) {
25385 return;
25386 }
25387 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
25388 if (result) {
25389 setCustomValidity(result);
25390 } else {
25391 validateRefs();
25392 }
25393 }, [isTouched, isValid2, validity, validateRefs]);
25394 const onBlur = (event) => {
25395 if (isTouched) {
25396 return;
25397 }
25398 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
25399 setIsTouched(true);
25400 }
25401 };
25402 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)("div", { onBlur, children: [
25403 children,
25404 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
25405 "p",
25406 {
25407 className: clsx_default(
25408 "components-validated-control__indicator",
25409 customValidity.type === "invalid" ? "is-invalid" : void 0
25410 ),
25411 children: [
25412 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25413 import_components32.Icon,
25414 {
25415 className: "components-validated-control__indicator-icon",
25416 icon: error_default,
25417 size: 16,
25418 fill: "currentColor"
25419 }
25420 ),
25421 customValidity.message
25422 ]
25423 }
25424 ) })
25425 ] });
25426 }
25427 function CalendarDateControl({
25428 data,
25429 field,
25430 onChange,
25431 hideLabelFromVision,
25432 markWhenOptional,
25433 validity
25434 }) {
25435 const {
25436 id,
25437 label,
25438 description,
25439 setValue,
25440 getValue,
25441 isValid: isValid2,
25442 format: fieldFormat
25443 } = field;
25444 const disabled2 = field.isDisabled({ item: data, field });
25445 const [selectedPresetId, setSelectedPresetId] = (0, import_element85.useState)(
25446 null
25447 );
25448 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
25449 const fieldValue = getValue({ item: data });
25450 const value = typeof fieldValue === "string" ? fieldValue : void 0;
25451 const [calendarMonth, setCalendarMonth] = (0, import_element85.useState)(() => {
25452 const parsedDate = parseDate(value);
25453 return parsedDate || /* @__PURE__ */ new Date();
25454 });
25455 const [isTouched, setIsTouched] = (0, import_element85.useState)(false);
25456 const validityTargetRef = (0, import_element85.useRef)(null);
25457 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
25458 const onChangeCallback = (0, import_element85.useCallback)(
25459 (newValue) => onChange(setValue({ item: data, value: newValue })),
25460 [data, onChange, setValue]
25461 );
25462 const onSelectDate = (0, import_element85.useCallback)(
25463 (newDate) => {
25464 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
25465 onChangeCallback(dateValue);
25466 setSelectedPresetId(null);
25467 setIsTouched(true);
25468 },
25469 [onChangeCallback]
25470 );
25471 const handlePresetClick = (0, import_element85.useCallback)(
25472 (preset) => {
25473 const presetDate = preset.getValue();
25474 const dateValue = formatDate(presetDate);
25475 setCalendarMonth(presetDate);
25476 onChangeCallback(dateValue);
25477 setSelectedPresetId(preset.id);
25478 setIsTouched(true);
25479 },
25480 [onChangeCallback]
25481 );
25482 const handleManualDateChange = (0, import_element85.useCallback)(
25483 (newValue) => {
25484 onChangeCallback(newValue);
25485 if (newValue) {
25486 const parsedDate = parseDate(newValue);
25487 if (parsedDate) {
25488 setCalendarMonth(parsedDate);
25489 }
25490 }
25491 setSelectedPresetId(null);
25492 setIsTouched(true);
25493 },
25494 [onChangeCallback]
25495 );
25496 const {
25497 timezone: { string: timezoneString }
25498 } = (0, import_date4.getSettings)();
25499 let displayLabel = label;
25500 if (isValid2?.required && !markWhenOptional) {
25501 displayLabel = `${label} (${(0, import_i18n36.__)("Required")})`;
25502 } else if (!isValid2?.required && markWhenOptional) {
25503 displayLabel = `${label} (${(0, import_i18n36.__)("Optional")})`;
25504 }
25505 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25506 ValidatedDateControl,
25507 {
25508 field,
25509 validity,
25510 inputRefs: validityTargetRef,
25511 isTouched,
25512 setIsTouched,
25513 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25514 import_components32.BaseControl,
25515 {
25516 id,
25517 className: "dataviews-controls__date",
25518 label: displayLabel,
25519 help: description,
25520 hideLabelFromVision,
25521 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(Stack, { direction: "column", gap: "lg", children: [
25522 /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
25523 Stack,
25524 {
25525 direction: "row",
25526 gap: "sm",
25527 wrap: "wrap",
25528 justify: "flex-start",
25529 children: [
25530 DATE_PRESETS.map((preset) => {
25531 const isSelected2 = selectedPresetId === preset.id;
25532 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25533 import_components32.Button,
25534 {
25535 className: "dataviews-controls__date-preset",
25536 variant: "tertiary",
25537 isPressed: isSelected2,
25538 size: "small",
25539 disabled: disabled2,
25540 accessibleWhenDisabled: true,
25541 onClick: () => handlePresetClick(preset),
25542 children: preset.label
25543 },
25544 preset.id
25545 );
25546 }),
25547 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25548 import_components32.Button,
25549 {
25550 className: "dataviews-controls__date-preset",
25551 variant: "tertiary",
25552 isPressed: !selectedPresetId,
25553 size: "small",
25554 disabled: !!selectedPresetId || disabled2,
25555 accessibleWhenDisabled: true,
25556 children: (0, import_i18n36.__)("Custom")
25557 }
25558 )
25559 ]
25560 }
25561 ),
25562 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25563 import_components32.__experimentalInputControl,
25564 {
25565 __next40pxDefaultSize: true,
25566 ref: validityTargetRef,
25567 type: "date",
25568 label: (0, import_i18n36.__)("Date"),
25569 hideLabelFromVision: true,
25570 value,
25571 onChange: handleManualDateChange,
25572 required: !!field.isValid?.required,
25573 disabled: disabled2,
25574 min: minConstraint,
25575 max: maxConstraint
25576 }
25577 ),
25578 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25579 DateCalendar2,
25580 {
25581 style: { width: "100%" },
25582 selected: value ? parseDate(value) || void 0 : void 0,
25583 onSelect: onSelectDate,
25584 month: calendarMonth,
25585 onMonthChange: setCalendarMonth,
25586 timeZone: timezoneString || void 0,
25587 weekStartsOn,
25588 disabled: disabled2 || disabledMatchers,
25589 disableNavigation: disabled2
25590 }
25591 )
25592 ] })
25593 }
25594 )
25595 }
25596 );
25597 }
25598 function CalendarDateRangeControl({
25599 data,
25600 field,
25601 onChange,
25602 hideLabelFromVision,
25603 markWhenOptional,
25604 validity
25605 }) {
25606 const {
25607 id,
25608 label,
25609 description,
25610 getValue,
25611 setValue,
25612 isValid: isValid2,
25613 format: fieldFormat
25614 } = field;
25615 const disabled2 = field.isDisabled({ item: data, field });
25616 let value;
25617 const fieldValue = getValue({ item: data });
25618 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
25619 value = fieldValue;
25620 }
25621 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
25622 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
25623 const onChangeCallback = (0, import_element85.useCallback)(
25624 (newValue) => {
25625 onChange(
25626 setValue({
25627 item: data,
25628 value: newValue
25629 })
25630 );
25631 },
25632 [data, onChange, setValue]
25633 );
25634 const [selectedPresetId, setSelectedPresetId] = (0, import_element85.useState)(
25635 null
25636 );
25637 const selectedRange = (0, import_element85.useMemo)(() => {
25638 if (!value) {
25639 return { from: void 0, to: void 0 };
25640 }
25641 const [from, to] = value;
25642 return {
25643 from: parseDate(from) || void 0,
25644 to: parseDate(to) || void 0
25645 };
25646 }, [value]);
25647 const [calendarMonth, setCalendarMonth] = (0, import_element85.useState)(() => {
25648 return selectedRange.from || /* @__PURE__ */ new Date();
25649 });
25650 const [isTouched, setIsTouched] = (0, import_element85.useState)(false);
25651 const fromInputRef = (0, import_element85.useRef)(null);
25652 const toInputRef = (0, import_element85.useRef)(null);
25653 const updateDateRange = (0, import_element85.useCallback)(
25654 (fromDate, toDate2) => {
25655 if (fromDate && toDate2) {
25656 onChangeCallback([
25657 formatDate(fromDate),
25658 formatDate(toDate2)
25659 ]);
25660 } else if (!fromDate && !toDate2) {
25661 onChangeCallback(void 0);
25662 }
25663 },
25664 [onChangeCallback]
25665 );
25666 const onSelectCalendarRange = (0, import_element85.useCallback)(
25667 (newRange) => {
25668 updateDateRange(newRange?.from, newRange?.to);
25669 setSelectedPresetId(null);
25670 setIsTouched(true);
25671 },
25672 [updateDateRange]
25673 );
25674 const handlePresetClick = (0, import_element85.useCallback)(
25675 (preset) => {
25676 const [startDate, endDate] = preset.getValue();
25677 setCalendarMonth(startDate);
25678 updateDateRange(startDate, endDate);
25679 setSelectedPresetId(preset.id);
25680 setIsTouched(true);
25681 },
25682 [updateDateRange]
25683 );
25684 const handleManualDateChange = (0, import_element85.useCallback)(
25685 (fromOrTo, newValue) => {
25686 const [currentFrom, currentTo] = value || [
25687 void 0,
25688 void 0
25689 ];
25690 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
25691 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
25692 updateDateRange(updatedFrom, updatedTo);
25693 if (newValue) {
25694 const parsedDate = parseDate(newValue);
25695 if (parsedDate) {
25696 setCalendarMonth(parsedDate);
25697 }
25698 }
25699 setSelectedPresetId(null);
25700 setIsTouched(true);
25701 },
25702 [value, updateDateRange]
25703 );
25704 const { timezone } = (0, import_date4.getSettings)();
25705 let displayLabel = label;
25706 if (field.isValid?.required && !markWhenOptional) {
25707 displayLabel = `${label} (${(0, import_i18n36.__)("Required")})`;
25708 } else if (!field.isValid?.required && markWhenOptional) {
25709 displayLabel = `${label} (${(0, import_i18n36.__)("Optional")})`;
25710 }
25711 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25712 ValidatedDateControl,
25713 {
25714 field,
25715 validity,
25716 inputRefs: [fromInputRef, toInputRef],
25717 isTouched,
25718 setIsTouched,
25719 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25720 import_components32.BaseControl,
25721 {
25722 id,
25723 className: "dataviews-controls__date",
25724 label: displayLabel,
25725 help: description,
25726 hideLabelFromVision,
25727 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(Stack, { direction: "column", gap: "lg", children: [
25728 /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
25729 Stack,
25730 {
25731 direction: "row",
25732 gap: "sm",
25733 wrap: "wrap",
25734 justify: "flex-start",
25735 children: [
25736 DATE_RANGE_PRESETS.map((preset) => {
25737 const isSelected2 = selectedPresetId === preset.id;
25738 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25739 import_components32.Button,
25740 {
25741 className: "dataviews-controls__date-preset",
25742 variant: "tertiary",
25743 isPressed: isSelected2,
25744 size: "small",
25745 disabled: disabled2,
25746 accessibleWhenDisabled: true,
25747 onClick: () => handlePresetClick(preset),
25748 children: preset.label
25749 },
25750 preset.id
25751 );
25752 }),
25753 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25754 import_components32.Button,
25755 {
25756 className: "dataviews-controls__date-preset",
25757 variant: "tertiary",
25758 isPressed: !selectedPresetId,
25759 size: "small",
25760 accessibleWhenDisabled: true,
25761 disabled: !!selectedPresetId || disabled2,
25762 children: (0, import_i18n36.__)("Custom")
25763 }
25764 )
25765 ]
25766 }
25767 ),
25768 /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
25769 Stack,
25770 {
25771 direction: "row",
25772 gap: "sm",
25773 justify: "space-between",
25774 className: "dataviews-controls__date-range-inputs",
25775 children: [
25776 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25777 import_components32.__experimentalInputControl,
25778 {
25779 __next40pxDefaultSize: true,
25780 ref: fromInputRef,
25781 type: "date",
25782 label: (0, import_i18n36.__)("From"),
25783 hideLabelFromVision: true,
25784 value: value?.[0],
25785 onChange: (newValue) => handleManualDateChange("from", newValue),
25786 required: !!field.isValid?.required,
25787 disabled: disabled2,
25788 min: minConstraint,
25789 max: maxConstraint
25790 }
25791 ),
25792 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25793 import_components32.__experimentalInputControl,
25794 {
25795 __next40pxDefaultSize: true,
25796 ref: toInputRef,
25797 type: "date",
25798 label: (0, import_i18n36.__)("To"),
25799 hideLabelFromVision: true,
25800 value: value?.[1],
25801 onChange: (newValue) => handleManualDateChange("to", newValue),
25802 required: !!field.isValid?.required,
25803 disabled: disabled2,
25804 min: minConstraint,
25805 max: maxConstraint
25806 }
25807 )
25808 ]
25809 }
25810 ),
25811 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25812 DateRangeCalendar,
25813 {
25814 style: { width: "100%" },
25815 selected: selectedRange,
25816 onSelect: onSelectCalendarRange,
25817 month: calendarMonth,
25818 onMonthChange: setCalendarMonth,
25819 timeZone: timezone.string || void 0,
25820 weekStartsOn,
25821 disabled: disabled2 || disabledMatchers
25822 }
25823 )
25824 ] })
25825 }
25826 )
25827 }
25828 );
25829 }
25830 function DateControl({
25831 data,
25832 field,
25833 onChange,
25834 hideLabelFromVision,
25835 markWhenOptional,
25836 operator,
25837 validity
25838 }) {
25839 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
25840 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25841 RelativeDateControl,
25842 {
25843 className: "dataviews-controls__date",
25844 data,
25845 field,
25846 onChange,
25847 hideLabelFromVision,
25848 operator
25849 }
25850 );
25851 }
25852 if (operator === OPERATOR_BETWEEN) {
25853 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25854 CalendarDateRangeControl,
25855 {
25856 data,
25857 field,
25858 onChange,
25859 hideLabelFromVision,
25860 markWhenOptional,
25861 validity
25862 }
25863 );
25864 }
25865 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
25866 CalendarDateControl,
25867 {
25868 data,
25869 field,
25870 onChange,
25871 hideLabelFromVision,
25872 markWhenOptional,
25873 validity
25874 }
25875 );
25876 }
25877
25878 // packages/dataviews/build-module/components/dataform-controls/select.mjs
25879 var import_components33 = __toESM(require_components(), 1);
25880 var import_element86 = __toESM(require_element(), 1);
25881 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
25882 var { ValidatedSelectControl } = unlock2(import_components33.privateApis);
25883 function Select({
25884 data,
25885 field,
25886 onChange,
25887 hideLabelFromVision,
25888 markWhenOptional,
25889 validity
25890 }) {
25891 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
25892 const disabled2 = field.isDisabled({ item: data, field });
25893 const isMultiple = type === "array";
25894 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
25895 const onChangeControl = (0, import_element86.useCallback)(
25896 (newValue) => onChange(setValue({ item: data, value: newValue })),
25897 [data, onChange, setValue]
25898 );
25899 const { elements, isLoading } = useElements({
25900 elements: field.elements,
25901 getElements: field.getElements
25902 });
25903 if (isLoading) {
25904 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components33.Spinner, {});
25905 }
25906 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25907 ValidatedSelectControl,
25908 {
25909 required: !!field.isValid?.required,
25910 markWhenOptional,
25911 customValidity: getCustomValidity(isValid2, validity),
25912 label,
25913 value,
25914 help: description,
25915 options: elements,
25916 onChange: onChangeControl,
25917 __next40pxDefaultSize: true,
25918 hideLabelFromVision,
25919 multiple: isMultiple,
25920 disabled: disabled2
25921 }
25922 );
25923 }
25924
25925 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
25926 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
25927 var ELEMENTS_THRESHOLD = 10;
25928 function AdaptiveSelect(props) {
25929 const { field } = props;
25930 const { elements } = useElements({
25931 elements: field.elements,
25932 getElements: field.getElements
25933 });
25934 if (elements.length >= ELEMENTS_THRESHOLD) {
25935 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(Combobox3, { ...props });
25936 }
25937 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(Select, { ...props });
25938 }
25939
25940 // packages/dataviews/build-module/components/dataform-controls/email.mjs
25941 var import_components35 = __toESM(require_components(), 1);
25942
25943 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
25944 var import_components34 = __toESM(require_components(), 1);
25945 var import_element87 = __toESM(require_element(), 1);
25946 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
25947 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis);
25948 function ValidatedText({
25949 data,
25950 field,
25951 onChange,
25952 hideLabelFromVision,
25953 markWhenOptional,
25954 type,
25955 prefix,
25956 suffix,
25957 validity
25958 }) {
25959 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
25960 const value = getValue({ item: data });
25961 const disabled2 = field.isDisabled({ item: data, field });
25962 const onChangeControl = (0, import_element87.useCallback)(
25963 (newValue) => onChange(
25964 setValue({
25965 item: data,
25966 value: newValue
25967 })
25968 ),
25969 [data, setValue, onChange]
25970 );
25971 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
25972 ValidatedInputControl2,
25973 {
25974 required: !!isValid2.required,
25975 markWhenOptional,
25976 customValidity: getCustomValidity(isValid2, validity),
25977 label,
25978 placeholder,
25979 value: value ?? "",
25980 help: description,
25981 onChange: onChangeControl,
25982 hideLabelFromVision,
25983 type,
25984 prefix,
25985 suffix,
25986 disabled: disabled2,
25987 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
25988 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
25989 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
25990 __next40pxDefaultSize: true
25991 }
25992 );
25993 }
25994
25995 // packages/dataviews/build-module/components/dataform-controls/email.mjs
25996 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
25997 function Email({
25998 data,
25999 field,
26000 onChange,
26001 hideLabelFromVision,
26002 markWhenOptional,
26003 validity
26004 }) {
26005 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26006 ValidatedText,
26007 {
26008 ...{
26009 data,
26010 field,
26011 onChange,
26012 hideLabelFromVision,
26013 markWhenOptional,
26014 validity,
26015 type: "email",
26016 prefix: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components35.Icon, { icon: envelope_default }) })
26017 }
26018 }
26019 );
26020 }
26021
26022 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
26023 var import_components36 = __toESM(require_components(), 1);
26024 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
26025 function Telephone({
26026 data,
26027 field,
26028 onChange,
26029 hideLabelFromVision,
26030 markWhenOptional,
26031 validity
26032 }) {
26033 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26034 ValidatedText,
26035 {
26036 ...{
26037 data,
26038 field,
26039 onChange,
26040 hideLabelFromVision,
26041 markWhenOptional,
26042 validity,
26043 type: "tel",
26044 prefix: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(import_components36.Icon, { icon: mobile_default }) })
26045 }
26046 }
26047 );
26048 }
26049
26050 // packages/dataviews/build-module/components/dataform-controls/url.mjs
26051 var import_components37 = __toESM(require_components(), 1);
26052 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
26053 function Url({
26054 data,
26055 field,
26056 onChange,
26057 hideLabelFromVision,
26058 markWhenOptional,
26059 validity
26060 }) {
26061 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
26062 ValidatedText,
26063 {
26064 ...{
26065 data,
26066 field,
26067 onChange,
26068 hideLabelFromVision,
26069 markWhenOptional,
26070 validity,
26071 type: "url",
26072 prefix: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(import_components37.Icon, { icon: link_default }) })
26073 }
26074 }
26075 );
26076 }
26077
26078 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
26079 var import_components38 = __toESM(require_components(), 1);
26080 var import_element88 = __toESM(require_element(), 1);
26081 var import_i18n37 = __toESM(require_i18n(), 1);
26082 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
26083 var { ValidatedNumberControl } = unlock2(import_components38.privateApis);
26084 function toNumberOrEmpty(value) {
26085 if (value === "" || value === void 0) {
26086 return "";
26087 }
26088 const number = Number(value);
26089 return Number.isFinite(number) ? number : "";
26090 }
26091 function BetweenControls({
26092 value,
26093 onChange,
26094 hideLabelFromVision,
26095 step
26096 }) {
26097 const [min2 = "", max2 = ""] = value;
26098 const onChangeMin = (0, import_element88.useCallback)(
26099 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
26100 [onChange, max2]
26101 );
26102 const onChangeMax = (0, import_element88.useCallback)(
26103 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
26104 [onChange, min2]
26105 );
26106 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26107 import_components38.BaseControl,
26108 {
26109 help: (0, import_i18n37.__)("The max. value must be greater than the min. value."),
26110 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
26111 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26112 import_components38.__experimentalNumberControl,
26113 {
26114 label: (0, import_i18n37.__)("Min."),
26115 value: min2,
26116 max: max2 ? Number(max2) - step : void 0,
26117 onChange: onChangeMin,
26118 __next40pxDefaultSize: true,
26119 hideLabelFromVision,
26120 step
26121 }
26122 ),
26123 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26124 import_components38.__experimentalNumberControl,
26125 {
26126 label: (0, import_i18n37.__)("Max."),
26127 value: max2,
26128 min: min2 ? Number(min2) + step : void 0,
26129 onChange: onChangeMax,
26130 __next40pxDefaultSize: true,
26131 hideLabelFromVision,
26132 step
26133 }
26134 )
26135 ] })
26136 }
26137 );
26138 }
26139 function ValidatedNumber({
26140 data,
26141 field,
26142 onChange,
26143 hideLabelFromVision,
26144 markWhenOptional,
26145 operator,
26146 validity
26147 }) {
26148 const decimals = field.format?.decimals ?? 0;
26149 const step = Math.pow(10, Math.abs(decimals) * -1);
26150 const { label, description, getValue, setValue, isValid: isValid2 } = field;
26151 const value = getValue({ item: data }) ?? "";
26152 const disabled2 = field.isDisabled({ item: data, field });
26153 const onChangeControl = (0, import_element88.useCallback)(
26154 (newValue) => {
26155 onChange(
26156 setValue({
26157 item: data,
26158 // Do not convert an empty string or undefined to a number,
26159 // otherwise there's a mismatch between the UI control (empty)
26160 // and the data relied by onChange (0).
26161 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
26162 })
26163 );
26164 },
26165 [data, onChange, setValue]
26166 );
26167 const onChangeBetweenControls = (0, import_element88.useCallback)(
26168 (newValue) => {
26169 onChange(
26170 setValue({
26171 item: data,
26172 value: newValue
26173 })
26174 );
26175 },
26176 [data, onChange, setValue]
26177 );
26178 if (operator === OPERATOR_BETWEEN) {
26179 let valueBetween = ["", ""];
26180 if (Array.isArray(value) && value.length === 2 && value.every(
26181 (element) => typeof element === "number" || element === ""
26182 )) {
26183 valueBetween = value;
26184 }
26185 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26186 BetweenControls,
26187 {
26188 value: valueBetween,
26189 onChange: onChangeBetweenControls,
26190 hideLabelFromVision,
26191 step
26192 }
26193 );
26194 }
26195 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26196 ValidatedNumberControl,
26197 {
26198 required: !!isValid2.required,
26199 markWhenOptional,
26200 customValidity: getCustomValidity(isValid2, validity),
26201 label,
26202 help: description,
26203 value,
26204 onChange: onChangeControl,
26205 __next40pxDefaultSize: true,
26206 hideLabelFromVision,
26207 step,
26208 min: isValid2.min ? isValid2.min.constraint : void 0,
26209 max: isValid2.max ? isValid2.max.constraint : void 0,
26210 disabled: disabled2
26211 }
26212 );
26213 }
26214
26215 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
26216 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
26217 function Integer(props) {
26218 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(ValidatedNumber, { ...props });
26219 }
26220
26221 // packages/dataviews/build-module/components/dataform-controls/number.mjs
26222 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
26223 function Number2(props) {
26224 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ValidatedNumber, { ...props });
26225 }
26226
26227 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
26228 var import_components39 = __toESM(require_components(), 1);
26229 var import_element89 = __toESM(require_element(), 1);
26230 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
26231 var { ValidatedRadioControl } = unlock2(import_components39.privateApis);
26232 function Radio({
26233 data,
26234 field,
26235 onChange,
26236 hideLabelFromVision,
26237 markWhenOptional,
26238 validity
26239 }) {
26240 const { label, description, getValue, setValue, isValid: isValid2 } = field;
26241 const disabled2 = field.isDisabled({ item: data, field });
26242 const { elements, isLoading } = useElements({
26243 elements: field.elements,
26244 getElements: field.getElements
26245 });
26246 const value = getValue({ item: data });
26247 const onChangeControl = (0, import_element89.useCallback)(
26248 (newValue) => onChange(setValue({ item: data, value: newValue })),
26249 [data, onChange, setValue]
26250 );
26251 if (isLoading) {
26252 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components39.Spinner, {});
26253 }
26254 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
26255 ValidatedRadioControl,
26256 {
26257 required: !!field.isValid?.required,
26258 markWhenOptional,
26259 customValidity: getCustomValidity(isValid2, validity),
26260 label,
26261 help: description,
26262 onChange: onChangeControl,
26263 options: elements,
26264 selected: value,
26265 hideLabelFromVision,
26266 disabled: disabled2
26267 }
26268 );
26269 }
26270
26271 // packages/dataviews/build-module/components/dataform-controls/text.mjs
26272 var import_element90 = __toESM(require_element(), 1);
26273 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
26274 function Text3({
26275 data,
26276 field,
26277 onChange,
26278 hideLabelFromVision,
26279 markWhenOptional,
26280 config,
26281 validity
26282 }) {
26283 const { prefix, suffix } = config || {};
26284 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
26285 ValidatedText,
26286 {
26287 ...{
26288 data,
26289 field,
26290 onChange,
26291 hideLabelFromVision,
26292 markWhenOptional,
26293 validity,
26294 prefix: prefix ? (0, import_element90.createElement)(prefix) : void 0,
26295 suffix: suffix ? (0, import_element90.createElement)(suffix) : void 0
26296 }
26297 }
26298 );
26299 }
26300
26301 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
26302 var import_components40 = __toESM(require_components(), 1);
26303 var import_element91 = __toESM(require_element(), 1);
26304 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
26305 var { ValidatedToggleControl } = unlock2(import_components40.privateApis);
26306 function Toggle({
26307 field,
26308 onChange,
26309 data,
26310 hideLabelFromVision,
26311 markWhenOptional,
26312 validity
26313 }) {
26314 const { label, description, getValue, setValue, isValid: isValid2 } = field;
26315 const disabled2 = field.isDisabled({ item: data, field });
26316 const onChangeControl = (0, import_element91.useCallback)(() => {
26317 onChange(
26318 setValue({ item: data, value: !getValue({ item: data }) })
26319 );
26320 }, [onChange, setValue, data, getValue]);
26321 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
26322 ValidatedToggleControl,
26323 {
26324 required: !!isValid2.required,
26325 markWhenOptional,
26326 customValidity: getCustomValidity(isValid2, validity),
26327 hidden: hideLabelFromVision,
26328 label,
26329 help: description,
26330 checked: getValue({ item: data }),
26331 onChange: onChangeControl,
26332 disabled: disabled2
26333 }
26334 );
26335 }
26336
26337 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
26338 var import_components41 = __toESM(require_components(), 1);
26339 var import_element92 = __toESM(require_element(), 1);
26340 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
26341 var { ValidatedTextareaControl } = unlock2(import_components41.privateApis);
26342 function Textarea({
26343 data,
26344 field,
26345 onChange,
26346 hideLabelFromVision,
26347 markWhenOptional,
26348 config,
26349 validity
26350 }) {
26351 const { rows = 4 } = config || {};
26352 const disabled2 = field.isDisabled({ item: data, field });
26353 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
26354 const value = field.getValue({ item: data });
26355 const onChangeControl = (0, import_element92.useCallback)(
26356 (newValue) => onChange(setValue({ item: data, value: newValue })),
26357 [data, onChange, setValue]
26358 );
26359 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
26360 ValidatedTextareaControl,
26361 {
26362 required: !!isValid2.required,
26363 markWhenOptional,
26364 customValidity: getCustomValidity(isValid2, validity),
26365 label,
26366 placeholder,
26367 value: value ?? "",
26368 help: description,
26369 onChange: onChangeControl,
26370 rows,
26371 disabled: disabled2,
26372 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
26373 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
26374 __next40pxDefaultSize: true,
26375 hideLabelFromVision
26376 }
26377 );
26378 }
26379
26380 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
26381 var import_components42 = __toESM(require_components(), 1);
26382 var import_element93 = __toESM(require_element(), 1);
26383 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
26384 var { ValidatedToggleGroupControl } = unlock2(import_components42.privateApis);
26385 function ToggleGroup({
26386 data,
26387 field,
26388 onChange,
26389 hideLabelFromVision,
26390 markWhenOptional,
26391 validity
26392 }) {
26393 const { getValue, setValue, isValid: isValid2 } = field;
26394 const disabled2 = field.isDisabled({ item: data, field });
26395 const value = getValue({ item: data });
26396 const onChangeControl = (0, import_element93.useCallback)(
26397 (newValue) => onChange(setValue({ item: data, value: newValue })),
26398 [data, onChange, setValue]
26399 );
26400 const { elements, isLoading } = useElements({
26401 elements: field.elements,
26402 getElements: field.getElements
26403 });
26404 if (isLoading) {
26405 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(import_components42.Spinner, {});
26406 }
26407 if (elements.length === 0) {
26408 return null;
26409 }
26410 const selectedOption = elements.find((el) => el.value === value);
26411 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
26412 ValidatedToggleGroupControl,
26413 {
26414 required: !!field.isValid?.required,
26415 markWhenOptional,
26416 customValidity: getCustomValidity(isValid2, validity),
26417 __next40pxDefaultSize: true,
26418 isBlock: true,
26419 label: field.label,
26420 help: selectedOption?.description || field.description,
26421 onChange: onChangeControl,
26422 value,
26423 hideLabelFromVision,
26424 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
26425 import_components42.__experimentalToggleGroupControlOption,
26426 {
26427 label: el.label,
26428 value: el.value,
26429 disabled: disabled2
26430 },
26431 el.value
26432 ))
26433 }
26434 );
26435 }
26436
26437 // packages/dataviews/build-module/components/dataform-controls/array.mjs
26438 var import_components43 = __toESM(require_components(), 1);
26439 var import_element94 = __toESM(require_element(), 1);
26440 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
26441 var { ValidatedFormTokenField } = unlock2(import_components43.privateApis);
26442 function ArrayControl({
26443 data,
26444 field,
26445 onChange,
26446 hideLabelFromVision,
26447 markWhenOptional,
26448 validity
26449 }) {
26450 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
26451 const value = getValue({ item: data });
26452 const disabled2 = field.isDisabled({ item: data, field });
26453 const { elements, isLoading } = useElements({
26454 elements: field.elements,
26455 getElements: field.getElements
26456 });
26457 const arrayValueAsElements = (0, import_element94.useMemo)(
26458 () => Array.isArray(value) ? value.map((token) => {
26459 const element = elements?.find(
26460 (suggestion) => suggestion.value === token
26461 );
26462 return element || { value: token, label: token };
26463 }) : [],
26464 [value, elements]
26465 );
26466 const onChangeControl = (0, import_element94.useCallback)(
26467 (tokens) => {
26468 const valueTokens = tokens.map((token) => {
26469 if (typeof token === "object" && "value" in token) {
26470 return token.value;
26471 }
26472 return token;
26473 });
26474 onChange(setValue({ item: data, value: valueTokens }));
26475 },
26476 [onChange, setValue, data]
26477 );
26478 if (isLoading) {
26479 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components43.Spinner, {});
26480 }
26481 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
26482 ValidatedFormTokenField,
26483 {
26484 required: !!isValid2?.required,
26485 markWhenOptional,
26486 customValidity: getCustomValidity(isValid2, validity),
26487 label: hideLabelFromVision ? void 0 : label,
26488 value: arrayValueAsElements,
26489 onChange: onChangeControl,
26490 placeholder,
26491 suggestions: elements?.map((element) => element.value),
26492 disabled: disabled2,
26493 __experimentalValidateInput: (token) => {
26494 if (field.isValid?.elements && elements) {
26495 return elements.some(
26496 (element) => element.value === token || element.label === token
26497 );
26498 }
26499 return true;
26500 },
26501 __experimentalExpandOnFocus: elements && elements.length > 0,
26502 help: description ?? (field.isValid?.elements ? "" : void 0),
26503 displayTransform: (token) => {
26504 if (typeof token === "object" && "label" in token) {
26505 return token.label;
26506 }
26507 if (typeof token === "string" && elements) {
26508 const element = elements.find(
26509 (el) => el.value === token
26510 );
26511 return element?.label || token;
26512 }
26513 return token;
26514 },
26515 __experimentalRenderItem: ({ item }) => {
26516 if (typeof item === "string" && elements) {
26517 const element = elements.find(
26518 (el) => el.value === item
26519 );
26520 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("span", { children: element?.label || item });
26521 }
26522 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("span", { children: item });
26523 }
26524 }
26525 );
26526 }
26527
26528 // node_modules/colord/index.mjs
26529 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
26530 var t = function(r3) {
26531 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
26532 };
26533 var n = function(r3, t2, n2) {
26534 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
26535 };
26536 var e = function(r3, t2, n2) {
26537 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
26538 };
26539 var u = function(r3) {
26540 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
26541 };
26542 var a = function(r3) {
26543 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
26544 };
26545 var o = function(r3) {
26546 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
26547 };
26548 var i = /^#([0-9a-f]{3,8})$/i;
26549 var s = function(r3) {
26550 var t2 = r3.toString(16);
26551 return t2.length < 2 ? "0" + t2 : t2;
26552 };
26553 var h = function(r3) {
26554 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;
26555 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
26556 };
26557 var b = function(r3) {
26558 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
26559 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
26560 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;
26561 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 };
26562 };
26563 var g = function(r3) {
26564 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
26565 };
26566 var d = function(r3) {
26567 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
26568 };
26569 var f = function(r3) {
26570 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 }));
26571 var t2, n2, e2;
26572 };
26573 var c = function(r3) {
26574 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 };
26575 var t2, n2, e2, u2;
26576 };
26577 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
26578 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
26579 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
26580 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
26581 var y = { string: [[function(r3) {
26582 var t2 = i.exec(r3);
26583 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;
26584 }, "hex"], [function(r3) {
26585 var t2 = v.exec(r3) || m.exec(r3);
26586 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;
26587 }, "rgb"], [function(t2) {
26588 var n2 = l.exec(t2) || p.exec(t2);
26589 if (!n2) return null;
26590 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) });
26591 return f(a2);
26592 }, "hsl"]], object: [[function(r3) {
26593 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
26594 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
26595 }, "rgb"], [function(r3) {
26596 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
26597 if (!t(n2) || !t(e2) || !t(u2)) return null;
26598 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
26599 return f(i2);
26600 }, "hsl"], [function(r3) {
26601 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
26602 if (!t(n2) || !t(a2) || !t(o2)) return null;
26603 var h2 = (function(r4) {
26604 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
26605 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
26606 return b(h2);
26607 }, "hsv"]] };
26608 var N = function(r3, t2) {
26609 for (var n2 = 0; n2 < t2.length; n2++) {
26610 var e2 = t2[n2][0](r3);
26611 if (e2) return [e2, t2[n2][1]];
26612 }
26613 return [null, void 0];
26614 };
26615 var x = function(r3) {
26616 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
26617 };
26618 var M = function(r3, t2) {
26619 var n2 = c(r3);
26620 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
26621 };
26622 var H = function(r3) {
26623 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
26624 };
26625 var $ = function(r3, t2) {
26626 var n2 = c(r3);
26627 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
26628 };
26629 var j = (function() {
26630 function r3(r4) {
26631 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
26632 }
26633 return r3.prototype.isValid = function() {
26634 return null !== this.parsed;
26635 }, r3.prototype.brightness = function() {
26636 return n(H(this.rgba), 2);
26637 }, r3.prototype.isDark = function() {
26638 return H(this.rgba) < 0.5;
26639 }, r3.prototype.isLight = function() {
26640 return H(this.rgba) >= 0.5;
26641 }, r3.prototype.toHex = function() {
26642 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;
26643 var r4, t2, e2, u2, a2, i2;
26644 }, r3.prototype.toRgb = function() {
26645 return o(this.rgba);
26646 }, r3.prototype.toRgbString = function() {
26647 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 + ")";
26648 var r4, t2, n2, e2, u2;
26649 }, r3.prototype.toHsl = function() {
26650 return d(c(this.rgba));
26651 }, r3.prototype.toHslString = function() {
26652 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 + "%)";
26653 var r4, t2, n2, e2, u2;
26654 }, r3.prototype.toHsv = function() {
26655 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
26656 var r4;
26657 }, r3.prototype.invert = function() {
26658 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
26659 var r4;
26660 }, r3.prototype.saturate = function(r4) {
26661 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
26662 }, r3.prototype.desaturate = function(r4) {
26663 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
26664 }, r3.prototype.grayscale = function() {
26665 return w(M(this.rgba, -1));
26666 }, r3.prototype.lighten = function(r4) {
26667 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
26668 }, r3.prototype.darken = function(r4) {
26669 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
26670 }, r3.prototype.rotate = function(r4) {
26671 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
26672 }, r3.prototype.alpha = function(r4) {
26673 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
26674 var t2;
26675 }, r3.prototype.hue = function(r4) {
26676 var t2 = c(this.rgba);
26677 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
26678 }, r3.prototype.isEqual = function(r4) {
26679 return this.toHex() === w(r4).toHex();
26680 }, r3;
26681 })();
26682 var w = function(r3) {
26683 return r3 instanceof j ? r3 : new j(r3);
26684 };
26685
26686 // packages/dataviews/build-module/components/dataform-controls/color.mjs
26687 var import_components44 = __toESM(require_components(), 1);
26688 var import_element95 = __toESM(require_element(), 1);
26689 var import_i18n38 = __toESM(require_i18n(), 1);
26690 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
26691 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components44.privateApis);
26692 var ColorPickerDropdown = ({
26693 color,
26694 onColorChange,
26695 disabled: disabled2
26696 }) => {
26697 const validColor = color && w(color).isValid() ? color : "#ffffff";
26698 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
26699 import_components44.Dropdown,
26700 {
26701 className: "dataviews-controls__color-picker-dropdown",
26702 popoverProps: { resize: false },
26703 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
26704 import_components44.Button,
26705 {
26706 onClick: onToggle,
26707 "aria-label": (0, import_i18n38.__)("Open color picker"),
26708 size: "small",
26709 disabled: disabled2,
26710 accessibleWhenDisabled: true,
26711 icon: () => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components44.ColorIndicator, { colorValue: validColor })
26712 }
26713 ),
26714 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components44.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
26715 import_components44.ColorPicker,
26716 {
26717 color: validColor,
26718 onChange: onColorChange,
26719 enableAlpha: true
26720 }
26721 ) })
26722 }
26723 );
26724 };
26725 function Color({
26726 data,
26727 field,
26728 onChange,
26729 hideLabelFromVision,
26730 markWhenOptional,
26731 validity
26732 }) {
26733 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
26734 const disabled2 = field.isDisabled({ item: data, field });
26735 const value = field.getValue({ item: data }) || "";
26736 const handleColorChange = (0, import_element95.useCallback)(
26737 (newColor) => {
26738 onChange(setValue({ item: data, value: newColor }));
26739 },
26740 [data, onChange, setValue]
26741 );
26742 const handleInputChange = (0, import_element95.useCallback)(
26743 (newValue) => {
26744 onChange(setValue({ item: data, value: newValue || "" }));
26745 },
26746 [data, onChange, setValue]
26747 );
26748 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
26749 ValidatedInputControl3,
26750 {
26751 required: !!field.isValid?.required,
26752 markWhenOptional,
26753 customValidity: getCustomValidity(isValid2, validity),
26754 label,
26755 placeholder,
26756 value,
26757 help: description,
26758 onChange: handleInputChange,
26759 hideLabelFromVision,
26760 type: "text",
26761 disabled: disabled2,
26762 prefix: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components44.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
26763 ColorPickerDropdown,
26764 {
26765 color: value,
26766 onColorChange: handleColorChange,
26767 disabled: disabled2
26768 }
26769 ) })
26770 }
26771 );
26772 }
26773
26774 // packages/dataviews/build-module/components/dataform-controls/password.mjs
26775 var import_components45 = __toESM(require_components(), 1);
26776 var import_element96 = __toESM(require_element(), 1);
26777 var import_i18n39 = __toESM(require_i18n(), 1);
26778 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1);
26779 function Password({
26780 data,
26781 field,
26782 onChange,
26783 hideLabelFromVision,
26784 markWhenOptional,
26785 validity
26786 }) {
26787 const [isVisible2, setIsVisible] = (0, import_element96.useState)(false);
26788 const disabled2 = field.isDisabled({ item: data, field });
26789 const toggleVisibility = (0, import_element96.useCallback)(() => {
26790 setIsVisible((prev) => !prev);
26791 }, []);
26792 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
26793 ValidatedText,
26794 {
26795 ...{
26796 data,
26797 field,
26798 onChange,
26799 hideLabelFromVision,
26800 markWhenOptional,
26801 validity,
26802 type: isVisible2 ? "text" : "password",
26803 suffix: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(import_components45.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
26804 import_components45.Button,
26805 {
26806 icon: isVisible2 ? unseen_default : seen_default,
26807 onClick: toggleVisibility,
26808 size: "small",
26809 label: isVisible2 ? (0, import_i18n39.__)("Hide password") : (0, import_i18n39.__)("Show password"),
26810 disabled: disabled2,
26811 accessibleWhenDisabled: true
26812 }
26813 ) })
26814 }
26815 }
26816 );
26817 }
26818
26819 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
26820 function hasElements(field) {
26821 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
26822 }
26823
26824 // packages/dataviews/build-module/components/dataform-controls/index.mjs
26825 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1);
26826 var FORM_CONTROLS = {
26827 adaptiveSelect: AdaptiveSelect,
26828 array: ArrayControl,
26829 checkbox: Checkbox,
26830 color: Color,
26831 combobox: Combobox3,
26832 datetime: DateTime,
26833 date: DateControl,
26834 email: Email,
26835 telephone: Telephone,
26836 url: Url,
26837 integer: Integer,
26838 number: Number2,
26839 password: Password,
26840 radio: Radio,
26841 select: Select,
26842 text: Text3,
26843 toggle: Toggle,
26844 textarea: Textarea,
26845 toggleGroup: ToggleGroup
26846 };
26847 function isEditConfig(value) {
26848 return value && typeof value === "object" && typeof value.control === "string";
26849 }
26850 function createConfiguredControl(config) {
26851 const { control, ...controlConfig } = config;
26852 const BaseControlType = getControlByType(control);
26853 if (BaseControlType === null) {
26854 return null;
26855 }
26856 return function ConfiguredControl(props) {
26857 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(BaseControlType, { ...props, config: controlConfig });
26858 };
26859 }
26860 function getControl(field, fallback) {
26861 if (typeof field.Edit === "function") {
26862 return field.Edit;
26863 }
26864 if (typeof field.Edit === "string") {
26865 return getControlByType(field.Edit);
26866 }
26867 if (isEditConfig(field.Edit)) {
26868 return createConfiguredControl(field.Edit);
26869 }
26870 if (hasElements(field) && field.type !== "array") {
26871 return getControlByType("adaptiveSelect");
26872 }
26873 if (fallback === null) {
26874 return null;
26875 }
26876 return getControlByType(fallback);
26877 }
26878 function getControlByType(type) {
26879 if (Object.keys(FORM_CONTROLS).includes(type)) {
26880 return FORM_CONTROLS[type];
26881 }
26882 return null;
26883 }
26884
26885 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
26886 function getFilterBy(field, defaultOperators, validOperators) {
26887 if (field.filterBy === false) {
26888 return false;
26889 }
26890 const operators = field.filterBy?.operators?.filter(
26891 (op) => validOperators.includes(op)
26892 ) ?? defaultOperators;
26893 if (operators.length === 0) {
26894 return false;
26895 }
26896 return {
26897 isPrimary: !!field.filterBy?.isPrimary,
26898 operators
26899 };
26900 }
26901 var get_filter_by_default = getFilterBy;
26902
26903 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
26904 var getValueFromId = (id) => ({ item }) => {
26905 const path = id.split(".");
26906 let value = item;
26907 for (const segment of path) {
26908 if (value.hasOwnProperty(segment)) {
26909 value = value[segment];
26910 } else {
26911 value = void 0;
26912 }
26913 }
26914 return value;
26915 };
26916 var get_value_from_id_default = getValueFromId;
26917
26918 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
26919 var setValueFromId = (id) => ({ value }) => {
26920 const path = id.split(".");
26921 const result = {};
26922 let current = result;
26923 for (const segment of path.slice(0, -1)) {
26924 current[segment] = {};
26925 current = current[segment];
26926 }
26927 current[path.at(-1)] = value;
26928 return result;
26929 };
26930 var set_value_from_id_default = setValueFromId;
26931
26932 // packages/dataviews/build-module/field-types/email.mjs
26933 var import_i18n40 = __toESM(require_i18n(), 1);
26934
26935 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
26936 function RenderFromElements({
26937 item,
26938 field
26939 }) {
26940 const { elements, isLoading } = useElements({
26941 elements: field.elements,
26942 getElements: field.getElements
26943 });
26944 const value = field.getValue({ item });
26945 if (isLoading) {
26946 return value;
26947 }
26948 if (elements.length === 0) {
26949 return value;
26950 }
26951 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
26952 }
26953
26954 // packages/dataviews/build-module/field-types/utils/render-default.mjs
26955 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1);
26956 function render({
26957 item,
26958 field
26959 }) {
26960 if (field.hasElements) {
26961 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(RenderFromElements, { item, field });
26962 }
26963 return field.getValueFormatted({ item, field });
26964 }
26965
26966 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
26967 var sort_text_default = (a2, b2, direction) => {
26968 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
26969 };
26970
26971 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
26972 function isValidRequired(item, field) {
26973 const value = field.getValue({ item });
26974 return ![void 0, "", null].includes(value);
26975 }
26976
26977 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
26978 function isValidMinLength(item, field) {
26979 if (typeof field.isValid.minLength?.constraint !== "number") {
26980 return false;
26981 }
26982 const value = field.getValue({ item });
26983 if ([void 0, "", null].includes(value)) {
26984 return true;
26985 }
26986 return String(value).length >= field.isValid.minLength.constraint;
26987 }
26988
26989 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
26990 function isValidMaxLength(item, field) {
26991 if (typeof field.isValid.maxLength?.constraint !== "number") {
26992 return false;
26993 }
26994 const value = field.getValue({ item });
26995 if ([void 0, "", null].includes(value)) {
26996 return true;
26997 }
26998 return String(value).length <= field.isValid.maxLength.constraint;
26999 }
27000
27001 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
27002 function isValidPattern(item, field) {
27003 if (field.isValid.pattern?.constraint === void 0) {
27004 return true;
27005 }
27006 try {
27007 const regexp = new RegExp(field.isValid.pattern.constraint);
27008 const value = field.getValue({ item });
27009 if ([void 0, "", null].includes(value)) {
27010 return true;
27011 }
27012 return regexp.test(String(value));
27013 } catch {
27014 return false;
27015 }
27016 }
27017
27018 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
27019 function isValidElements(item, field) {
27020 const elements = field.elements ?? [];
27021 const validValues = elements.map((el) => el.value);
27022 if (validValues.length === 0) {
27023 return true;
27024 }
27025 const value = field.getValue({ item });
27026 return [].concat(value).every((v2) => validValues.includes(v2));
27027 }
27028
27029 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
27030 function getValueFormatted({
27031 item,
27032 field
27033 }) {
27034 return field.getValue({ item });
27035 }
27036 var get_value_formatted_default_default = getValueFormatted;
27037
27038 // packages/dataviews/build-module/field-types/email.mjs
27039 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])?)*$/;
27040 function isValidCustom(item, field) {
27041 const value = field.getValue({ item });
27042 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
27043 return (0, import_i18n40.__)("Value must be a valid email address.");
27044 }
27045 return null;
27046 }
27047 var email_default = {
27048 type: "email",
27049 render,
27050 Edit: "email",
27051 sort: sort_text_default,
27052 enableSorting: true,
27053 enableGlobalSearch: false,
27054 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27055 validOperators: [
27056 OPERATOR_IS,
27057 OPERATOR_IS_NOT,
27058 OPERATOR_CONTAINS,
27059 OPERATOR_NOT_CONTAINS,
27060 OPERATOR_STARTS_WITH,
27061 // Multiple selection
27062 OPERATOR_IS_ANY,
27063 OPERATOR_IS_NONE,
27064 OPERATOR_IS_ALL,
27065 OPERATOR_IS_NOT_ALL
27066 ],
27067 format: {},
27068 getValueFormatted: get_value_formatted_default_default,
27069 validate: {
27070 required: isValidRequired,
27071 pattern: isValidPattern,
27072 minLength: isValidMinLength,
27073 maxLength: isValidMaxLength,
27074 elements: isValidElements,
27075 custom: isValidCustom
27076 }
27077 };
27078
27079 // packages/dataviews/build-module/field-types/integer.mjs
27080 var import_i18n41 = __toESM(require_i18n(), 1);
27081
27082 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
27083 var sort_number_default = (a2, b2, direction) => {
27084 return direction === "asc" ? a2 - b2 : b2 - a2;
27085 };
27086
27087 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
27088 function isValidMin(item, field) {
27089 if (typeof field.isValid.min?.constraint !== "number") {
27090 return false;
27091 }
27092 const value = field.getValue({ item });
27093 if ([void 0, "", null].includes(value)) {
27094 return true;
27095 }
27096 return Number(value) >= field.isValid.min.constraint;
27097 }
27098
27099 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
27100 function isValidMax(item, field) {
27101 if (typeof field.isValid.max?.constraint !== "number") {
27102 return false;
27103 }
27104 const value = field.getValue({ item });
27105 if ([void 0, "", null].includes(value)) {
27106 return true;
27107 }
27108 return Number(value) <= field.isValid.max.constraint;
27109 }
27110
27111 // packages/dataviews/build-module/field-types/integer.mjs
27112 var format2 = {
27113 separatorThousand: ","
27114 };
27115 function getValueFormatted2({
27116 item,
27117 field
27118 }) {
27119 let value = field.getValue({ item });
27120 if (value === null || value === void 0) {
27121 return "";
27122 }
27123 value = Number(value);
27124 if (!Number.isFinite(value)) {
27125 return String(value);
27126 }
27127 let formatInteger;
27128 if (field.type !== "integer") {
27129 formatInteger = format2;
27130 } else {
27131 formatInteger = field.format;
27132 }
27133 const { separatorThousand } = formatInteger;
27134 const integerValue = Math.trunc(value);
27135 if (!separatorThousand) {
27136 return String(integerValue);
27137 }
27138 return String(integerValue).replace(
27139 /\B(?=(\d{3})+(?!\d))/g,
27140 separatorThousand
27141 );
27142 }
27143 function isValidCustom2(item, field) {
27144 const value = field.getValue({ item });
27145 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
27146 return (0, import_i18n41.__)("Value must be an integer.");
27147 }
27148 return null;
27149 }
27150 var integer_default = {
27151 type: "integer",
27152 render,
27153 Edit: "integer",
27154 sort: sort_number_default,
27155 enableSorting: true,
27156 enableGlobalSearch: false,
27157 defaultOperators: [
27158 OPERATOR_IS,
27159 OPERATOR_IS_NOT,
27160 OPERATOR_LESS_THAN,
27161 OPERATOR_GREATER_THAN,
27162 OPERATOR_LESS_THAN_OR_EQUAL,
27163 OPERATOR_GREATER_THAN_OR_EQUAL,
27164 OPERATOR_BETWEEN
27165 ],
27166 validOperators: [
27167 // Single-selection
27168 OPERATOR_IS,
27169 OPERATOR_IS_NOT,
27170 OPERATOR_LESS_THAN,
27171 OPERATOR_GREATER_THAN,
27172 OPERATOR_LESS_THAN_OR_EQUAL,
27173 OPERATOR_GREATER_THAN_OR_EQUAL,
27174 OPERATOR_BETWEEN,
27175 // Multiple-selection
27176 OPERATOR_IS_ANY,
27177 OPERATOR_IS_NONE,
27178 OPERATOR_IS_ALL,
27179 OPERATOR_IS_NOT_ALL
27180 ],
27181 format: format2,
27182 getValueFormatted: getValueFormatted2,
27183 validate: {
27184 required: isValidRequired,
27185 min: isValidMin,
27186 max: isValidMax,
27187 elements: isValidElements,
27188 custom: isValidCustom2
27189 }
27190 };
27191
27192 // packages/dataviews/build-module/field-types/number.mjs
27193 var import_i18n42 = __toESM(require_i18n(), 1);
27194 var format3 = {
27195 separatorThousand: ",",
27196 separatorDecimal: ".",
27197 decimals: 2
27198 };
27199 function getValueFormatted3({
27200 item,
27201 field
27202 }) {
27203 let value = field.getValue({ item });
27204 if (value === null || value === void 0) {
27205 return "";
27206 }
27207 value = Number(value);
27208 if (!Number.isFinite(value)) {
27209 return String(value);
27210 }
27211 let formatNumber;
27212 if (field.type !== "number") {
27213 formatNumber = format3;
27214 } else {
27215 formatNumber = field.format;
27216 }
27217 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
27218 const fixedValue = value.toFixed(decimals);
27219 const [integerPart, decimalPart] = fixedValue.split(".");
27220 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
27221 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
27222 }
27223 function isEmpty(value) {
27224 return value === "" || value === void 0 || value === null;
27225 }
27226 function isValidCustom3(item, field) {
27227 const value = field.getValue({ item });
27228 if (!isEmpty(value) && !Number.isFinite(value)) {
27229 return (0, import_i18n42.__)("Value must be a number.");
27230 }
27231 return null;
27232 }
27233 var number_default = {
27234 type: "number",
27235 render,
27236 Edit: "number",
27237 sort: sort_number_default,
27238 enableSorting: true,
27239 enableGlobalSearch: false,
27240 defaultOperators: [
27241 OPERATOR_IS,
27242 OPERATOR_IS_NOT,
27243 OPERATOR_LESS_THAN,
27244 OPERATOR_GREATER_THAN,
27245 OPERATOR_LESS_THAN_OR_EQUAL,
27246 OPERATOR_GREATER_THAN_OR_EQUAL,
27247 OPERATOR_BETWEEN
27248 ],
27249 validOperators: [
27250 // Single-selection
27251 OPERATOR_IS,
27252 OPERATOR_IS_NOT,
27253 OPERATOR_LESS_THAN,
27254 OPERATOR_GREATER_THAN,
27255 OPERATOR_LESS_THAN_OR_EQUAL,
27256 OPERATOR_GREATER_THAN_OR_EQUAL,
27257 OPERATOR_BETWEEN,
27258 // Multiple-selection
27259 OPERATOR_IS_ANY,
27260 OPERATOR_IS_NONE,
27261 OPERATOR_IS_ALL,
27262 OPERATOR_IS_NOT_ALL
27263 ],
27264 format: format3,
27265 getValueFormatted: getValueFormatted3,
27266 validate: {
27267 required: isValidRequired,
27268 min: isValidMin,
27269 max: isValidMax,
27270 elements: isValidElements,
27271 custom: isValidCustom3
27272 }
27273 };
27274
27275 // packages/dataviews/build-module/field-types/text.mjs
27276 var text_default = {
27277 type: "text",
27278 render,
27279 Edit: "text",
27280 sort: sort_text_default,
27281 enableSorting: true,
27282 enableGlobalSearch: false,
27283 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27284 validOperators: [
27285 // Single selection
27286 OPERATOR_IS,
27287 OPERATOR_IS_NOT,
27288 OPERATOR_CONTAINS,
27289 OPERATOR_NOT_CONTAINS,
27290 OPERATOR_STARTS_WITH,
27291 // Multiple selection
27292 OPERATOR_IS_ANY,
27293 OPERATOR_IS_NONE,
27294 OPERATOR_IS_ALL,
27295 OPERATOR_IS_NOT_ALL
27296 ],
27297 format: {},
27298 getValueFormatted: get_value_formatted_default_default,
27299 validate: {
27300 required: isValidRequired,
27301 pattern: isValidPattern,
27302 minLength: isValidMinLength,
27303 maxLength: isValidMaxLength,
27304 elements: isValidElements
27305 }
27306 };
27307
27308 // packages/dataviews/build-module/field-types/datetime.mjs
27309 var import_date7 = __toESM(require_date(), 1);
27310
27311 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
27312 var import_date6 = __toESM(require_date(), 1);
27313 function parseDateLike(value) {
27314 if (!value) {
27315 return null;
27316 }
27317 if (!isValid(new Date(value))) {
27318 return null;
27319 }
27320 const parsed = (0, import_date6.getDate)(value);
27321 return parsed && isValid(parsed) ? parsed : null;
27322 }
27323 function validateDateLikeBoundary(item, field, boundary) {
27324 const constraint = field.isValid[boundary]?.constraint;
27325 if (typeof constraint !== "string") {
27326 return false;
27327 }
27328 const value = field.getValue({ item });
27329 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
27330 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
27331 return true;
27332 }
27333 const parsedConstraint = parseDateLike(constraint);
27334 const parsedValue = parseDateLike(String(boundaryValue));
27335 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
27336 }
27337 function isValidMinDate(item, field) {
27338 return validateDateLikeBoundary(item, field, "min");
27339 }
27340 function isValidMaxDate(item, field) {
27341 return validateDateLikeBoundary(item, field, "max");
27342 }
27343
27344 // packages/dataviews/build-module/field-types/datetime.mjs
27345 var format4 = {
27346 datetime: (0, import_date7.getSettings)().formats.datetime,
27347 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
27348 };
27349 function getValueFormatted4({
27350 item,
27351 field
27352 }) {
27353 const value = field.getValue({ item });
27354 if (["", void 0, null].includes(value)) {
27355 return "";
27356 }
27357 let formatDatetime;
27358 if (field.type !== "datetime") {
27359 formatDatetime = format4;
27360 } else {
27361 formatDatetime = field.format;
27362 }
27363 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
27364 }
27365 var sort = (a2, b2, direction) => {
27366 const timeA = new Date(a2).getTime();
27367 const timeB = new Date(b2).getTime();
27368 return direction === "asc" ? timeA - timeB : timeB - timeA;
27369 };
27370 var datetime_default = {
27371 type: "datetime",
27372 render,
27373 Edit: "datetime",
27374 sort,
27375 enableSorting: true,
27376 enableGlobalSearch: false,
27377 defaultOperators: [
27378 OPERATOR_ON,
27379 OPERATOR_NOT_ON,
27380 OPERATOR_BEFORE,
27381 OPERATOR_AFTER,
27382 OPERATOR_BEFORE_INC,
27383 OPERATOR_AFTER_INC,
27384 OPERATOR_IN_THE_PAST,
27385 OPERATOR_OVER
27386 ],
27387 validOperators: [
27388 OPERATOR_ON,
27389 OPERATOR_NOT_ON,
27390 OPERATOR_BEFORE,
27391 OPERATOR_AFTER,
27392 OPERATOR_BEFORE_INC,
27393 OPERATOR_AFTER_INC,
27394 OPERATOR_IN_THE_PAST,
27395 OPERATOR_OVER
27396 ],
27397 format: format4,
27398 getValueFormatted: getValueFormatted4,
27399 validate: {
27400 required: isValidRequired,
27401 elements: isValidElements,
27402 min: isValidMinDate,
27403 max: isValidMaxDate
27404 }
27405 };
27406
27407 // packages/dataviews/build-module/field-types/date.mjs
27408 var import_date8 = __toESM(require_date(), 1);
27409 var format5 = {
27410 date: (0, import_date8.getSettings)().formats.date,
27411 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
27412 };
27413 function getValueFormatted5({
27414 item,
27415 field
27416 }) {
27417 const value = field.getValue({ item });
27418 if (["", void 0, null].includes(value)) {
27419 return "";
27420 }
27421 let formatDate2;
27422 if (field.type !== "date") {
27423 formatDate2 = format5;
27424 } else {
27425 formatDate2 = field.format;
27426 }
27427 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
27428 }
27429 var sort2 = (a2, b2, direction) => {
27430 const timeA = new Date(a2).getTime();
27431 const timeB = new Date(b2).getTime();
27432 return direction === "asc" ? timeA - timeB : timeB - timeA;
27433 };
27434 var date_default = {
27435 type: "date",
27436 render,
27437 Edit: "date",
27438 sort: sort2,
27439 enableSorting: true,
27440 enableGlobalSearch: false,
27441 defaultOperators: [
27442 OPERATOR_ON,
27443 OPERATOR_NOT_ON,
27444 OPERATOR_BEFORE,
27445 OPERATOR_AFTER,
27446 OPERATOR_BEFORE_INC,
27447 OPERATOR_AFTER_INC,
27448 OPERATOR_IN_THE_PAST,
27449 OPERATOR_OVER,
27450 OPERATOR_BETWEEN
27451 ],
27452 validOperators: [
27453 OPERATOR_ON,
27454 OPERATOR_NOT_ON,
27455 OPERATOR_BEFORE,
27456 OPERATOR_AFTER,
27457 OPERATOR_BEFORE_INC,
27458 OPERATOR_AFTER_INC,
27459 OPERATOR_IN_THE_PAST,
27460 OPERATOR_OVER,
27461 OPERATOR_BETWEEN
27462 ],
27463 format: format5,
27464 getValueFormatted: getValueFormatted5,
27465 validate: {
27466 required: isValidRequired,
27467 elements: isValidElements,
27468 min: isValidMinDate,
27469 max: isValidMaxDate
27470 }
27471 };
27472
27473 // packages/dataviews/build-module/field-types/boolean.mjs
27474 var import_i18n43 = __toESM(require_i18n(), 1);
27475
27476 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
27477 function isValidRequiredForBool(item, field) {
27478 const value = field.getValue({ item });
27479 return value === true;
27480 }
27481
27482 // packages/dataviews/build-module/field-types/boolean.mjs
27483 function getValueFormatted6({
27484 item,
27485 field
27486 }) {
27487 const value = field.getValue({ item });
27488 if (value === true) {
27489 return (0, import_i18n43.__)("True");
27490 }
27491 if (value === false) {
27492 return (0, import_i18n43.__)("False");
27493 }
27494 return "";
27495 }
27496 function isValidCustom4(item, field) {
27497 const value = field.getValue({ item });
27498 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
27499 return (0, import_i18n43.__)("Value must be true, false, or undefined");
27500 }
27501 return null;
27502 }
27503 var sort3 = (a2, b2, direction) => {
27504 const boolA = Boolean(a2);
27505 const boolB = Boolean(b2);
27506 if (boolA === boolB) {
27507 return 0;
27508 }
27509 if (direction === "asc") {
27510 return boolA ? 1 : -1;
27511 }
27512 return boolA ? -1 : 1;
27513 };
27514 var boolean_default = {
27515 type: "boolean",
27516 render,
27517 Edit: "checkbox",
27518 sort: sort3,
27519 validate: {
27520 required: isValidRequiredForBool,
27521 elements: isValidElements,
27522 custom: isValidCustom4
27523 },
27524 enableSorting: true,
27525 enableGlobalSearch: false,
27526 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
27527 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
27528 format: {},
27529 getValueFormatted: getValueFormatted6
27530 };
27531
27532 // packages/dataviews/build-module/field-types/media.mjs
27533 var media_default = {
27534 type: "media",
27535 render: () => null,
27536 Edit: null,
27537 sort: () => 0,
27538 enableSorting: false,
27539 enableGlobalSearch: false,
27540 defaultOperators: [],
27541 validOperators: [],
27542 format: {},
27543 getValueFormatted: get_value_formatted_default_default,
27544 // cannot validate any constraint, so
27545 // the only available validation for the field author
27546 // would be providing a custom validator.
27547 validate: {}
27548 };
27549
27550 // packages/dataviews/build-module/field-types/array.mjs
27551 var import_i18n44 = __toESM(require_i18n(), 1);
27552
27553 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
27554 function isValidRequiredForArray(item, field) {
27555 const value = field.getValue({ item });
27556 return Array.isArray(value) && value.length > 0 && value.every(
27557 (element) => ![void 0, "", null].includes(element)
27558 );
27559 }
27560
27561 // packages/dataviews/build-module/field-types/array.mjs
27562 function getValueFormatted7({
27563 item,
27564 field
27565 }) {
27566 const value = field.getValue({ item });
27567 const arr = Array.isArray(value) ? value : [];
27568 return arr.join(", ");
27569 }
27570 function render2({ item, field }) {
27571 return getValueFormatted7({ item, field });
27572 }
27573 function isValidCustom5(item, field) {
27574 const value = field.getValue({ item });
27575 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
27576 return (0, import_i18n44.__)("Value must be an array.");
27577 }
27578 if (!value.every((v2) => typeof v2 === "string")) {
27579 return (0, import_i18n44.__)("Every value must be a string.");
27580 }
27581 return null;
27582 }
27583 var sort4 = (a2, b2, direction) => {
27584 const arrA = Array.isArray(a2) ? a2 : [];
27585 const arrB = Array.isArray(b2) ? b2 : [];
27586 if (arrA.length !== arrB.length) {
27587 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
27588 }
27589 const joinedA = arrA.join(",");
27590 const joinedB = arrB.join(",");
27591 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
27592 };
27593 var array_default = {
27594 type: "array",
27595 render: render2,
27596 Edit: "array",
27597 sort: sort4,
27598 enableSorting: true,
27599 enableGlobalSearch: false,
27600 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27601 validOperators: [
27602 OPERATOR_IS_ANY,
27603 OPERATOR_IS_NONE,
27604 OPERATOR_IS_ALL,
27605 OPERATOR_IS_NOT_ALL
27606 ],
27607 format: {},
27608 getValueFormatted: getValueFormatted7,
27609 validate: {
27610 required: isValidRequiredForArray,
27611 elements: isValidElements,
27612 custom: isValidCustom5
27613 }
27614 };
27615
27616 // packages/dataviews/build-module/field-types/password.mjs
27617 function getValueFormatted8({
27618 item,
27619 field
27620 }) {
27621 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
27622 }
27623 var password_default = {
27624 type: "password",
27625 render,
27626 Edit: "password",
27627 sort: () => 0,
27628 // Passwords should not be sortable for security reasons
27629 enableSorting: false,
27630 enableGlobalSearch: false,
27631 defaultOperators: [],
27632 validOperators: [],
27633 format: {},
27634 getValueFormatted: getValueFormatted8,
27635 validate: {
27636 required: isValidRequired,
27637 pattern: isValidPattern,
27638 minLength: isValidMinLength,
27639 maxLength: isValidMaxLength,
27640 elements: isValidElements
27641 }
27642 };
27643
27644 // packages/dataviews/build-module/field-types/telephone.mjs
27645 var telephone_default = {
27646 type: "telephone",
27647 render,
27648 Edit: "telephone",
27649 sort: sort_text_default,
27650 enableSorting: true,
27651 enableGlobalSearch: false,
27652 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27653 validOperators: [
27654 OPERATOR_IS,
27655 OPERATOR_IS_NOT,
27656 OPERATOR_CONTAINS,
27657 OPERATOR_NOT_CONTAINS,
27658 OPERATOR_STARTS_WITH,
27659 // Multiple selection
27660 OPERATOR_IS_ANY,
27661 OPERATOR_IS_NONE,
27662 OPERATOR_IS_ALL,
27663 OPERATOR_IS_NOT_ALL
27664 ],
27665 format: {},
27666 getValueFormatted: get_value_formatted_default_default,
27667 validate: {
27668 required: isValidRequired,
27669 pattern: isValidPattern,
27670 minLength: isValidMinLength,
27671 maxLength: isValidMaxLength,
27672 elements: isValidElements
27673 }
27674 };
27675
27676 // packages/dataviews/build-module/field-types/color.mjs
27677 var import_i18n45 = __toESM(require_i18n(), 1);
27678 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1);
27679 function render3({ item, field }) {
27680 if (field.hasElements) {
27681 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(RenderFromElements, { item, field });
27682 }
27683 const value = get_value_formatted_default_default({ item, field });
27684 if (!value || !w(value).isValid()) {
27685 return value;
27686 }
27687 return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
27688 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
27689 "div",
27690 {
27691 style: {
27692 width: "16px",
27693 height: "16px",
27694 borderRadius: "50%",
27695 backgroundColor: value,
27696 border: "1px solid #ddd",
27697 flexShrink: 0
27698 }
27699 }
27700 ),
27701 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("span", { children: value })
27702 ] });
27703 }
27704 function isValidCustom6(item, field) {
27705 const value = field.getValue({ item });
27706 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
27707 return (0, import_i18n45.__)("Value must be a valid color.");
27708 }
27709 return null;
27710 }
27711 var sort5 = (a2, b2, direction) => {
27712 const colorA = w(a2);
27713 const colorB = w(b2);
27714 if (!colorA.isValid() && !colorB.isValid()) {
27715 return 0;
27716 }
27717 if (!colorA.isValid()) {
27718 return direction === "asc" ? 1 : -1;
27719 }
27720 if (!colorB.isValid()) {
27721 return direction === "asc" ? -1 : 1;
27722 }
27723 const hslA = colorA.toHsl();
27724 const hslB = colorB.toHsl();
27725 if (hslA.h !== hslB.h) {
27726 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
27727 }
27728 if (hslA.s !== hslB.s) {
27729 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
27730 }
27731 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
27732 };
27733 var color_default = {
27734 type: "color",
27735 render: render3,
27736 Edit: "color",
27737 sort: sort5,
27738 enableSorting: true,
27739 enableGlobalSearch: false,
27740 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27741 validOperators: [
27742 OPERATOR_IS,
27743 OPERATOR_IS_NOT,
27744 OPERATOR_IS_ANY,
27745 OPERATOR_IS_NONE
27746 ],
27747 format: {},
27748 getValueFormatted: get_value_formatted_default_default,
27749 validate: {
27750 required: isValidRequired,
27751 elements: isValidElements,
27752 custom: isValidCustom6
27753 }
27754 };
27755
27756 // packages/dataviews/build-module/field-types/url.mjs
27757 var url_default = {
27758 type: "url",
27759 render,
27760 Edit: "url",
27761 sort: sort_text_default,
27762 enableSorting: true,
27763 enableGlobalSearch: false,
27764 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
27765 validOperators: [
27766 OPERATOR_IS,
27767 OPERATOR_IS_NOT,
27768 OPERATOR_CONTAINS,
27769 OPERATOR_NOT_CONTAINS,
27770 OPERATOR_STARTS_WITH,
27771 // Multiple selection
27772 OPERATOR_IS_ANY,
27773 OPERATOR_IS_NONE,
27774 OPERATOR_IS_ALL,
27775 OPERATOR_IS_NOT_ALL
27776 ],
27777 format: {},
27778 getValueFormatted: get_value_formatted_default_default,
27779 validate: {
27780 required: isValidRequired,
27781 pattern: isValidPattern,
27782 minLength: isValidMinLength,
27783 maxLength: isValidMaxLength,
27784 elements: isValidElements
27785 }
27786 };
27787
27788 // packages/dataviews/build-module/field-types/no-type.mjs
27789 var sort6 = (a2, b2, direction) => {
27790 if (typeof a2 === "number" && typeof b2 === "number") {
27791 return sort_number_default(a2, b2, direction);
27792 }
27793 return sort_text_default(a2, b2, direction);
27794 };
27795 var no_type_default = {
27796 // type: no type for this one
27797 render,
27798 Edit: null,
27799 sort: sort6,
27800 enableSorting: true,
27801 enableGlobalSearch: false,
27802 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
27803 validOperators: getAllOperatorNames(),
27804 format: {},
27805 getValueFormatted: get_value_formatted_default_default,
27806 validate: {
27807 required: isValidRequired,
27808 elements: isValidElements
27809 }
27810 };
27811
27812 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
27813 function supportsNumericRangeConstraint(type) {
27814 return type === "integer" || type === "number";
27815 }
27816 function supportsDateRangeConstraint(type) {
27817 return type === "date" || type === "datetime";
27818 }
27819 function normalizeRangeRule(value, fieldType, key) {
27820 const validator = fieldType.validate[key];
27821 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
27822 return { constraint: value, validate: validator };
27823 }
27824 return void 0;
27825 }
27826 function getIsValid(field, fieldType) {
27827 const rules = field.isValid;
27828 let required;
27829 if (rules?.required === true && fieldType.validate.required !== void 0) {
27830 required = {
27831 constraint: true,
27832 validate: fieldType.validate.required
27833 };
27834 }
27835 let elements;
27836 if ((rules?.elements === true || // elements is enabled unless the field opts-out
27837 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
27838 elements = {
27839 constraint: true,
27840 validate: fieldType.validate.elements
27841 };
27842 }
27843 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
27844 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
27845 const minLengthValue = rules?.minLength;
27846 let minLength;
27847 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
27848 minLength = {
27849 constraint: minLengthValue,
27850 validate: fieldType.validate.minLength
27851 };
27852 }
27853 const maxLengthValue = rules?.maxLength;
27854 let maxLength;
27855 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
27856 maxLength = {
27857 constraint: maxLengthValue,
27858 validate: fieldType.validate.maxLength
27859 };
27860 }
27861 const patternValue = rules?.pattern;
27862 let pattern;
27863 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
27864 pattern = {
27865 constraint: patternValue,
27866 validate: fieldType.validate.pattern
27867 };
27868 }
27869 const custom = rules?.custom ?? fieldType.validate.custom;
27870 return {
27871 required,
27872 elements,
27873 min: min2,
27874 max: max2,
27875 minLength,
27876 maxLength,
27877 pattern,
27878 custom
27879 };
27880 }
27881
27882 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
27883 function getFilter(fieldType) {
27884 return fieldType.validOperators.reduce((accumulator, operator) => {
27885 const operatorObj = getOperatorByName(operator);
27886 if (operatorObj?.filter) {
27887 accumulator[operator] = operatorObj.filter;
27888 }
27889 return accumulator;
27890 }, {});
27891 }
27892
27893 // packages/dataviews/build-module/field-types/utils/get-format.mjs
27894 function getFormat(field, fieldType) {
27895 return {
27896 ...fieldType.format,
27897 ...field.format
27898 };
27899 }
27900 var get_format_default = getFormat;
27901
27902 // packages/dataviews/build-module/field-types/index.mjs
27903 function getFieldTypeByName(type) {
27904 const found = [
27905 email_default,
27906 integer_default,
27907 number_default,
27908 text_default,
27909 datetime_default,
27910 date_default,
27911 boolean_default,
27912 media_default,
27913 array_default,
27914 password_default,
27915 telephone_default,
27916 color_default,
27917 url_default
27918 ].find((fieldType) => fieldType?.type === type);
27919 if (!!found) {
27920 return found;
27921 }
27922 return no_type_default;
27923 }
27924 function normalizeFields(fields) {
27925 return fields.map((field) => {
27926 const fieldType = getFieldTypeByName(field.type);
27927 const getValue = field.getValue || get_value_from_id_default(field.id);
27928 const sort7 = function(a2, b2, direction) {
27929 const aValue = getValue({ item: a2 });
27930 const bValue = getValue({ item: b2 });
27931 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
27932 };
27933 return {
27934 id: field.id,
27935 label: field.label || field.id,
27936 header: field.header || field.label || field.id,
27937 description: field.description,
27938 placeholder: field.placeholder,
27939 getValue,
27940 setValue: field.setValue || set_value_from_id_default(field.id),
27941 elements: field.elements,
27942 getElements: field.getElements,
27943 hasElements: hasElements(field),
27944 isVisible: field.isVisible,
27945 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
27946 enableHiding: field.enableHiding ?? true,
27947 readOnly: field.readOnly ?? false,
27948 // The type provides defaults for the following props
27949 type: fieldType.type,
27950 render: field.render ?? fieldType.render,
27951 Edit: getControl(field, fieldType.Edit),
27952 sort: sort7,
27953 enableSorting: field.enableSorting ?? fieldType.enableSorting,
27954 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
27955 isValid: getIsValid(field, fieldType),
27956 filterBy: get_filter_by_default(
27957 field,
27958 fieldType.defaultOperators,
27959 fieldType.validOperators
27960 ),
27961 filter: getFilter(fieldType),
27962 format: get_format_default(field, fieldType),
27963 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
27964 };
27965 });
27966 }
27967
27968 // packages/dataviews/build-module/hooks/use-data.mjs
27969 var import_element97 = __toESM(require_element(), 1);
27970 function useData({
27971 view,
27972 data: shownData,
27973 getItemId,
27974 isLoading,
27975 paginationInfo,
27976 selection
27977 }) {
27978 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
27979 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element97.useState)(
27980 !isLoading
27981 );
27982 (0, import_element97.useEffect)(() => {
27983 if (!isLoading) {
27984 setHasInitiallyLoaded(true);
27985 }
27986 }, [isLoading]);
27987 const previousDataRef = (0, import_element97.useRef)(shownData);
27988 const previousPaginationInfoRef = (0, import_element97.useRef)(paginationInfo);
27989 (0, import_element97.useEffect)(() => {
27990 if (!isLoading) {
27991 previousDataRef.current = shownData;
27992 previousPaginationInfoRef.current = paginationInfo;
27993 }
27994 }, [shownData, isLoading, paginationInfo]);
27995 const [visibleEntries, setVisibleEntries] = (0, import_element97.useState)([]);
27996 const positionMapRef = (0, import_element97.useRef)(/* @__PURE__ */ new Map());
27997 const allLoadedRecordsRef = (0, import_element97.useRef)([]);
27998 const prevViewParamsRef = (0, import_element97.useRef)({
27999 search: void 0,
28000 filters: void 0,
28001 perPage: void 0
28002 });
28003 const scrollDirectionRef = (0, import_element97.useRef)(void 0);
28004 const prevStartPositionRef = (0, import_element97.useRef)(void 0);
28005 const hasInitializedRef = (0, import_element97.useRef)(false);
28006 const allLoadedRecords = (0, import_element97.useMemo)(() => {
28007 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
28008 if (view.startPosition < prevStartPositionRef.current) {
28009 scrollDirectionRef.current = "up";
28010 } else if (view.startPosition > prevStartPositionRef.current) {
28011 scrollDirectionRef.current = "down";
28012 }
28013 }
28014 prevStartPositionRef.current = view.startPosition;
28015 const currentFiltersKey = JSON.stringify(view.filters ?? []);
28016 const prevFiltersKey = prevViewParamsRef.current.filters;
28017 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
28018 hasInitializedRef.current = true;
28019 prevViewParamsRef.current = {
28020 search: view.search,
28021 filters: currentFiltersKey,
28022 perPage: view.perPage
28023 };
28024 if (shouldReset) {
28025 positionMapRef.current.clear();
28026 scrollDirectionRef.current = void 0;
28027 const startPosition = view.search ? 1 : view.startPosition ?? 1;
28028 const records = shownData.map((record, index2) => {
28029 const position = startPosition + index2;
28030 positionMapRef.current.set(getItemId(record), position);
28031 return {
28032 ...record,
28033 position
28034 };
28035 });
28036 allLoadedRecordsRef.current = records;
28037 return records;
28038 }
28039 const prev = allLoadedRecordsRef.current;
28040 const shownDataIds = new Set(shownData.map(getItemId));
28041 const scrollDirection = scrollDirectionRef.current;
28042 const basePosition = view.search ? 1 : view.startPosition ?? 1;
28043 const newRecords = shownData.map((record, index2) => {
28044 const itemId = getItemId(record);
28045 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
28046 if (position !== void 0) {
28047 positionMapRef.current.set(itemId, position);
28048 }
28049 return {
28050 ...record,
28051 position
28052 };
28053 });
28054 if (newRecords.length === 0) {
28055 return prev;
28056 }
28057 const prevWithoutDuplicates = prev.filter(
28058 (record) => !shownDataIds.has(getItemId(record))
28059 );
28060 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
28061 allRecords.sort((a2, b2) => {
28062 const posA = a2.position;
28063 const posB = b2.position;
28064 return posA - posB;
28065 });
28066 let result = allRecords;
28067 if (visibleEntries.length > 0) {
28068 const visibleMin = Math.min(...visibleEntries);
28069 const visibleMax = Math.max(...visibleEntries);
28070 const buffer = 20;
28071 const recordPositions = allRecords.map(
28072 (r3) => r3.position
28073 );
28074 const minRecordPos = Math.min(...recordPositions);
28075 const maxRecordPos = Math.max(...recordPositions);
28076 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
28077 if (hasOverlap) {
28078 result = allRecords.filter((record) => {
28079 const itemId = getItemId(record);
28080 const isSelected2 = selection?.includes(itemId);
28081 if (isSelected2) {
28082 return true;
28083 }
28084 const itemPosition = record.position;
28085 if (scrollDirection === "up") {
28086 return itemPosition <= visibleMax + buffer;
28087 } else if (scrollDirection === "down") {
28088 return itemPosition >= visibleMin - buffer;
28089 }
28090 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
28091 });
28092 }
28093 }
28094 allLoadedRecordsRef.current = result;
28095 return result;
28096 }, [
28097 shownData,
28098 view.search,
28099 view.filters,
28100 view.perPage,
28101 view.startPosition,
28102 view.infiniteScrollEnabled,
28103 visibleEntries,
28104 selection,
28105 getItemId
28106 ]);
28107 if (!isInfiniteScrollEnabled) {
28108 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
28109 return {
28110 data: dataToReturn.map((item) => ({
28111 ...item,
28112 position: void 0
28113 })),
28114 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
28115 hasInitiallyLoaded,
28116 setVisibleEntries: void 0
28117 };
28118 }
28119 return {
28120 data: allLoadedRecords,
28121 paginationInfo,
28122 hasInitiallyLoaded,
28123 setVisibleEntries
28124 };
28125 }
28126
28127 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
28128 var import_element98 = __toESM(require_element(), 1);
28129 var import_compose12 = __toESM(require_compose(), 1);
28130 function captureAnchorElement(container, anchorElementRef, direction) {
28131 const containerRect = container.getBoundingClientRect();
28132 const centerY = containerRect.top + containerRect.height / 2;
28133 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
28134 if (items.length === 0) {
28135 return false;
28136 }
28137 const bestAnchor = items.reduce((best, item) => {
28138 const itemRect = item.getBoundingClientRect();
28139 const itemCenterY = itemRect.top + itemRect.height / 2;
28140 const distance = Math.abs(itemCenterY - centerY);
28141 const bestRect = best.getBoundingClientRect();
28142 const bestCenterY = bestRect.top + bestRect.height / 2;
28143 const bestDistance = Math.abs(bestCenterY - centerY);
28144 return distance < bestDistance ? item : best;
28145 });
28146 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
28147 const anchorRect = bestAnchor.getBoundingClientRect();
28148 anchorElementRef.current = {
28149 posinset,
28150 viewportOffset: anchorRect.top - containerRect.top,
28151 direction
28152 };
28153 return true;
28154 }
28155 function useInfiniteScroll({
28156 view,
28157 onChangeView,
28158 isLoading,
28159 paginationInfo,
28160 containerRef,
28161 setVisibleEntries
28162 }) {
28163 const anchorElementRef = (0, import_element98.useRef)(null);
28164 const viewRef = (0, import_element98.useRef)(view);
28165 const isLoadingRef = (0, import_element98.useRef)(isLoading);
28166 const onChangeViewRef = (0, import_element98.useRef)(onChangeView);
28167 const totalItemsRef = (0, import_element98.useRef)(paginationInfo.totalItems);
28168 (0, import_element98.useLayoutEffect)(() => {
28169 viewRef.current = view;
28170 isLoadingRef.current = isLoading;
28171 onChangeViewRef.current = onChangeView;
28172 totalItemsRef.current = paginationInfo.totalItems;
28173 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
28174 const intersectionObserverCallback = (0, import_element98.useCallback)(
28175 (entries) => {
28176 if (!setVisibleEntries) {
28177 return;
28178 }
28179 setVisibleEntries((prev) => {
28180 const newVisibleEntries = new Set(prev);
28181 let hasChanged = false;
28182 entries.forEach((entry) => {
28183 const posInSet = Number(
28184 entry.target?.attributes?.getNamedItem(
28185 "aria-posinset"
28186 )?.value
28187 );
28188 if (isNaN(posInSet)) {
28189 return;
28190 }
28191 if (entry.isIntersecting) {
28192 if (!newVisibleEntries.has(posInSet)) {
28193 newVisibleEntries.add(posInSet);
28194 hasChanged = true;
28195 }
28196 } else if (newVisibleEntries.has(posInSet)) {
28197 newVisibleEntries.delete(posInSet);
28198 hasChanged = true;
28199 }
28200 });
28201 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
28202 });
28203 },
28204 [setVisibleEntries]
28205 );
28206 (0, import_element98.useLayoutEffect)(() => {
28207 const container = containerRef.current;
28208 const anchor = anchorElementRef.current;
28209 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
28210 return;
28211 }
28212 const anchorElement = container.querySelector(
28213 `[aria-posinset="${anchor.posinset}"]`
28214 );
28215 if (anchorElement) {
28216 const containerRect = container.getBoundingClientRect();
28217 const anchorRect = anchorElement.getBoundingClientRect();
28218 const currentOffset = anchorRect.top - containerRect.top;
28219 const scrollAdjustment = currentOffset - anchor.viewportOffset;
28220 if (Math.abs(scrollAdjustment) > 1) {
28221 container.scrollTop += scrollAdjustment;
28222 }
28223 }
28224 anchorElementRef.current = null;
28225 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
28226 const intersectionObserverRef = (0, import_element98.useRef)(
28227 null
28228 );
28229 (0, import_element98.useEffect)(() => {
28230 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
28231 if (intersectionObserverRef.current) {
28232 intersectionObserverRef.current.disconnect();
28233 intersectionObserverRef.current = null;
28234 }
28235 return;
28236 }
28237 intersectionObserverRef.current = new IntersectionObserver(
28238 intersectionObserverCallback,
28239 { root: null, rootMargin: "0px", threshold: 0.1 }
28240 );
28241 return () => {
28242 if (intersectionObserverRef.current) {
28243 intersectionObserverRef.current.disconnect();
28244 intersectionObserverRef.current = null;
28245 }
28246 };
28247 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
28248 (0, import_element98.useEffect)(() => {
28249 if (!view.infiniteScrollEnabled || !containerRef.current) {
28250 return;
28251 }
28252 let lastScrollTop = 0;
28253 const BOTTOM_THRESHOLD = 600;
28254 const TOP_THRESHOLD = 800;
28255 const handleScroll = (0, import_compose12.throttle)((event) => {
28256 const currentView = viewRef.current;
28257 const totalItems = totalItemsRef.current;
28258 const target = event.target;
28259 const scrollTop = target.scrollTop;
28260 const scrollHeight = target.scrollHeight;
28261 const clientHeight = target.clientHeight;
28262 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
28263 lastScrollTop = scrollTop;
28264 if (isLoadingRef.current) {
28265 return;
28266 }
28267 const currentStartPosition = currentView.startPosition || 1;
28268 const batchSize = currentView.perPage || 10;
28269 const currentEndPosition = Math.min(
28270 currentStartPosition + batchSize,
28271 totalItems
28272 );
28273 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
28274 if (currentEndPosition < totalItems) {
28275 const newStartPosition = currentEndPosition;
28276 captureAnchorElement(target, anchorElementRef, "down");
28277 onChangeViewRef.current({
28278 ...currentView,
28279 startPosition: newStartPosition
28280 });
28281 }
28282 }
28283 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
28284 if (currentStartPosition > 1) {
28285 const calculatedStartPosition = currentStartPosition - batchSize;
28286 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
28287 captureAnchorElement(target, anchorElementRef, "up");
28288 onChangeViewRef.current({
28289 ...currentView,
28290 startPosition: newStartPosition
28291 });
28292 }
28293 }
28294 }, 50);
28295 const container = containerRef.current;
28296 container.addEventListener("scroll", handleScroll);
28297 return () => {
28298 container.removeEventListener("scroll", handleScroll);
28299 handleScroll.cancel();
28300 };
28301 }, [containerRef, view.infiniteScrollEnabled]);
28302 return {
28303 intersectionObserver: intersectionObserverRef.current
28304 };
28305 }
28306
28307 // packages/dataviews/build-module/dataviews/index.mjs
28308 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1);
28309 var defaultGetItemId = (item) => item.id;
28310 var defaultIsItemClickable = () => true;
28311 var EMPTY_ARRAY6 = [];
28312 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
28313 var dataViewsLayouts = VIEW_LAYOUTS.filter(
28314 (viewLayout) => !viewLayout.isPicker
28315 );
28316 function DefaultUI({
28317 header,
28318 search = true,
28319 searchLabel = void 0
28320 }) {
28321 const { view } = (0, import_element99.useContext)(dataviews_context_default);
28322 const isInfiniteScroll = view.infiniteScrollEnabled;
28323 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_jsx_runtime135.Fragment, { children: [
28324 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
28325 Stack,
28326 {
28327 direction: "row",
28328 align: "top",
28329 justify: "space-between",
28330 className: clsx_default("dataviews__view-actions", {
28331 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
28332 }),
28333 gap: "xs",
28334 children: [
28335 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
28336 Stack,
28337 {
28338 direction: "row",
28339 justify: "start",
28340 gap: "sm",
28341 className: "dataviews__search",
28342 children: [
28343 search && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(dataviews_search_default, { label: searchLabel }),
28344 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(toggle_default, {})
28345 ]
28346 }
28347 ),
28348 /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
28349 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(dataviews_view_config_default, {}),
28350 header
28351 ] })
28352 ]
28353 }
28354 ),
28355 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
28356 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(DataViewsLayout, {}),
28357 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(DataViewsFooter, {})
28358 ] });
28359 }
28360 function DataViews({
28361 view,
28362 onChangeView,
28363 fields,
28364 search = true,
28365 searchLabel = void 0,
28366 actions = EMPTY_ARRAY6,
28367 data,
28368 getItemId = defaultGetItemId,
28369 getItemLevel,
28370 isLoading = false,
28371 paginationInfo,
28372 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
28373 selection: selectionProperty,
28374 onChangeSelection,
28375 onClickItem,
28376 renderItemLink,
28377 isItemClickable = defaultIsItemClickable,
28378 header,
28379 children,
28380 config = { perPageSizes: [10, 20, 50, 100] },
28381 empty,
28382 onReset
28383 }) {
28384 const [selectionState, setSelectionState] = (0, import_element99.useState)([]);
28385 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
28386 const selection = isUncontrolled ? selectionState : selectionProperty;
28387 const {
28388 data: displayData,
28389 paginationInfo: displayPaginationInfo,
28390 hasInitiallyLoaded,
28391 setVisibleEntries
28392 } = useData({
28393 view,
28394 data,
28395 getItemId,
28396 isLoading,
28397 selection,
28398 paginationInfo
28399 });
28400 const containerRef = (0, import_element99.useRef)(null);
28401 const [containerWidth, setContainerWidth] = (0, import_element99.useState)(0);
28402 const resizeObserverRef = (0, import_compose13.useResizeObserver)(
28403 (resizeObserverEntries) => {
28404 setContainerWidth(
28405 resizeObserverEntries[0].borderBoxSize[0].inlineSize
28406 );
28407 },
28408 { box: "border-box" }
28409 );
28410 const [openedFilter, setOpenedFilter] = (0, import_element99.useState)(null);
28411 function setSelectionWithChange(value) {
28412 const newValue = typeof value === "function" ? value(selection) : value;
28413 if (isUncontrolled) {
28414 setSelectionState(newValue);
28415 }
28416 if (onChangeSelection) {
28417 onChangeSelection(newValue);
28418 }
28419 }
28420 const _fields = (0, import_element99.useMemo)(() => normalizeFields(fields), [fields]);
28421 const _selection = (0, import_element99.useMemo)(() => {
28422 if (view.infiniteScrollEnabled) {
28423 return selection;
28424 }
28425 return selection.filter(
28426 (id) => data.some((item) => getItemId(item) === id)
28427 );
28428 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
28429 const filters = use_filters_default(_fields, view);
28430 const hasPrimaryOrLockedFilters = (0, import_element99.useMemo)(
28431 () => (filters || []).some(
28432 (filter) => filter.isPrimary || filter.isLocked
28433 ),
28434 [filters]
28435 );
28436 const [isShowingFilter, setIsShowingFilter] = (0, import_element99.useState)(
28437 hasPrimaryOrLockedFilters
28438 );
28439 const { intersectionObserver } = useInfiniteScroll({
28440 view,
28441 onChangeView,
28442 isLoading,
28443 paginationInfo,
28444 containerRef,
28445 setVisibleEntries
28446 });
28447 (0, import_element99.useEffect)(() => {
28448 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
28449 setIsShowingFilter(true);
28450 }
28451 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
28452 const defaultLayouts = (0, import_element99.useMemo)(
28453 () => Object.fromEntries(
28454 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
28455 return dataViewsLayouts.some(
28456 (viewLayout) => viewLayout.type === layoutType
28457 );
28458 }).map(([key, value]) => [
28459 key,
28460 value === true ? {} : value
28461 ])
28462 ),
28463 [defaultLayoutsProperty]
28464 );
28465 if (!defaultLayouts[view.type]) {
28466 return null;
28467 }
28468 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28469 dataviews_context_default.Provider,
28470 {
28471 value: {
28472 view,
28473 onChangeView,
28474 fields: _fields,
28475 actions,
28476 data: displayData,
28477 isLoading,
28478 paginationInfo: displayPaginationInfo,
28479 selection: _selection,
28480 onChangeSelection: setSelectionWithChange,
28481 openedFilter,
28482 setOpenedFilter,
28483 getItemId,
28484 getItemLevel,
28485 isItemClickable,
28486 onClickItem,
28487 renderItemLink,
28488 containerWidth,
28489 containerRef,
28490 resizeObserverRef,
28491 defaultLayouts,
28492 filters,
28493 isShowingFilter,
28494 setIsShowingFilter,
28495 config,
28496 empty,
28497 hasInitiallyLoaded,
28498 onReset,
28499 intersectionObserver
28500 },
28501 children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28502 DefaultUI,
28503 {
28504 header,
28505 search,
28506 searchLabel
28507 }
28508 ) })
28509 }
28510 );
28511 }
28512 var DataViewsSubComponents = DataViews;
28513 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
28514 DataViewsSubComponents.Filters = filters_default;
28515 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
28516 DataViewsSubComponents.FiltersToggle = toggle_default;
28517 DataViewsSubComponents.Layout = DataViewsLayout;
28518 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
28519 DataViewsSubComponents.Pagination = DataViewsPagination;
28520 DataViewsSubComponents.Search = dataviews_search_default;
28521 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
28522 DataViewsSubComponents.Footer = DataViewsFooter;
28523 var dataviews_default = DataViewsSubComponents;
28524
28525 // packages/dataviews/build-module/dataform/index.mjs
28526 var import_element111 = __toESM(require_element(), 1);
28527
28528 // packages/dataviews/build-module/components/dataform-context/index.mjs
28529 var import_element100 = __toESM(require_element(), 1);
28530 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1);
28531 var DataFormContext = (0, import_element100.createContext)({
28532 fields: []
28533 });
28534 DataFormContext.displayName = "DataFormContext";
28535 function DataFormProvider({
28536 fields,
28537 children
28538 }) {
28539 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(DataFormContext.Provider, { value: { fields }, children });
28540 }
28541 var dataform_context_default = DataFormContext;
28542
28543 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
28544 var import_element110 = __toESM(require_element(), 1);
28545
28546 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
28547 var import_element101 = __toESM(require_element(), 1);
28548 var import_components46 = __toESM(require_components(), 1);
28549
28550 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
28551 var import_i18n46 = __toESM(require_i18n(), 1);
28552 var DEFAULT_LAYOUT = {
28553 type: "regular",
28554 labelPosition: "top"
28555 };
28556 var normalizeCardSummaryField = (sum) => {
28557 if (typeof sum === "string") {
28558 return [{ id: sum, visibility: "when-collapsed" }];
28559 }
28560 return sum.map((item) => {
28561 if (typeof item === "string") {
28562 return { id: item, visibility: "when-collapsed" };
28563 }
28564 return { id: item.id, visibility: item.visibility };
28565 });
28566 };
28567 function normalizeLayout(layout) {
28568 let normalizedLayout = DEFAULT_LAYOUT;
28569 if (layout?.type === "regular") {
28570 normalizedLayout = {
28571 type: "regular",
28572 labelPosition: layout?.labelPosition ?? "top"
28573 };
28574 } else if (layout?.type === "panel") {
28575 const summary = layout.summary ?? [];
28576 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
28577 const openAs = layout?.openAs;
28578 let normalizedOpenAs;
28579 if (typeof openAs === "object" && openAs.type === "modal") {
28580 normalizedOpenAs = {
28581 type: "modal",
28582 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n46.__)("Apply"),
28583 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n46.__)("Cancel")
28584 };
28585 } else if (openAs === "modal") {
28586 normalizedOpenAs = {
28587 type: "modal",
28588 applyLabel: (0, import_i18n46.__)("Apply"),
28589 cancelLabel: (0, import_i18n46.__)("Cancel")
28590 };
28591 } else {
28592 normalizedOpenAs = { type: "dropdown" };
28593 }
28594 normalizedLayout = {
28595 type: "panel",
28596 labelPosition: layout?.labelPosition ?? "side",
28597 openAs: normalizedOpenAs,
28598 summary: normalizedSummary,
28599 editVisibility: layout?.editVisibility ?? "on-hover"
28600 };
28601 } else if (layout?.type === "card") {
28602 if (layout.withHeader === false) {
28603 normalizedLayout = {
28604 type: "card",
28605 withHeader: false,
28606 isOpened: true,
28607 summary: [],
28608 isCollapsible: false
28609 };
28610 } else {
28611 const summary = layout.summary ?? [];
28612 normalizedLayout = {
28613 type: "card",
28614 withHeader: true,
28615 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
28616 summary: normalizeCardSummaryField(summary),
28617 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
28618 };
28619 }
28620 } else if (layout?.type === "row") {
28621 normalizedLayout = {
28622 type: "row",
28623 alignment: layout?.alignment ?? "center",
28624 styles: layout?.styles ?? {}
28625 };
28626 } else if (layout?.type === "details") {
28627 normalizedLayout = {
28628 type: "details",
28629 summary: layout?.summary ?? ""
28630 };
28631 }
28632 return normalizedLayout;
28633 }
28634 function normalizeForm(form) {
28635 const normalizedFormLayout = normalizeLayout(form?.layout);
28636 const normalizedFields = (form.fields ?? []).map(
28637 (field) => {
28638 if (typeof field === "string") {
28639 return {
28640 id: field,
28641 layout: normalizedFormLayout
28642 };
28643 }
28644 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
28645 return {
28646 id: field.id,
28647 layout: fieldLayout,
28648 ...!!field.label && { label: field.label },
28649 ...!!field.description && {
28650 description: field.description
28651 },
28652 ..."children" in field && Array.isArray(field.children) && {
28653 children: normalizeForm({
28654 fields: field.children,
28655 layout: DEFAULT_LAYOUT
28656 }).fields
28657 }
28658 };
28659 }
28660 );
28661 return {
28662 layout: normalizedFormLayout,
28663 fields: normalizedFields
28664 };
28665 }
28666 var normalize_form_default = normalizeForm;
28667
28668 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
28669 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
28670 function Header3({ title }) {
28671 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
28672 Stack,
28673 {
28674 direction: "column",
28675 className: "dataforms-layouts-regular__header",
28676 gap: "lg",
28677 children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components46.__experimentalHeading, { level: 2, size: 13, children: title }) })
28678 }
28679 );
28680 }
28681 function FormRegularField({
28682 data,
28683 field,
28684 onChange,
28685 hideLabelFromVision,
28686 markWhenOptional,
28687 validity
28688 }) {
28689 const { fields } = (0, import_element101.useContext)(dataform_context_default);
28690 const layout = field.layout;
28691 const form = (0, import_element101.useMemo)(
28692 () => ({
28693 layout: DEFAULT_LAYOUT,
28694 fields: !!field.children ? field.children : []
28695 }),
28696 [field]
28697 );
28698 if (!!field.children) {
28699 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(import_jsx_runtime137.Fragment, { children: [
28700 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(Header3, { title: field.label }),
28701 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
28702 DataFormLayout,
28703 {
28704 data,
28705 form,
28706 onChange,
28707 validity: validity?.children
28708 }
28709 )
28710 ] });
28711 }
28712 const labelPosition = layout.labelPosition;
28713 const fieldDefinition = fields.find(
28714 (fieldDef) => fieldDef.id === field.id
28715 );
28716 if (!fieldDefinition || !fieldDefinition.Edit) {
28717 return null;
28718 }
28719 if (labelPosition === "side") {
28720 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(
28721 Stack,
28722 {
28723 direction: "row",
28724 className: "dataforms-layouts-regular__field",
28725 gap: "sm",
28726 children: [
28727 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
28728 "div",
28729 {
28730 className: clsx_default(
28731 "dataforms-layouts-regular__field-label",
28732 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
28733 ),
28734 children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components46.BaseControl.VisualLabel, { children: fieldDefinition.label })
28735 }
28736 ),
28737 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
28738 fieldDefinition.render,
28739 {
28740 item: data,
28741 field: fieldDefinition
28742 }
28743 ) : /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
28744 fieldDefinition.Edit,
28745 {
28746 data,
28747 field: fieldDefinition,
28748 onChange,
28749 hideLabelFromVision: true,
28750 markWhenOptional,
28751 validity
28752 },
28753 fieldDefinition.id
28754 ) })
28755 ]
28756 }
28757 );
28758 }
28759 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_jsx_runtime137.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(import_jsx_runtime137.Fragment, { children: [
28760 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components46.BaseControl.VisualLabel, { children: fieldDefinition.label }),
28761 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
28762 fieldDefinition.render,
28763 {
28764 item: data,
28765 field: fieldDefinition
28766 }
28767 )
28768 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
28769 fieldDefinition.Edit,
28770 {
28771 data,
28772 field: fieldDefinition,
28773 onChange,
28774 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
28775 markWhenOptional,
28776 validity
28777 }
28778 ) });
28779 }
28780
28781 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
28782 var import_deepmerge2 = __toESM(require_cjs(), 1);
28783 var import_components49 = __toESM(require_components(), 1);
28784 var import_element106 = __toESM(require_element(), 1);
28785 var import_compose15 = __toESM(require_compose(), 1);
28786
28787 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
28788 var import_components48 = __toESM(require_components(), 1);
28789 var import_i18n47 = __toESM(require_i18n(), 1);
28790 var import_compose14 = __toESM(require_compose(), 1);
28791 var import_element102 = __toESM(require_element(), 1);
28792
28793 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
28794 function getLabelClassName(labelPosition, showError) {
28795 return clsx_default(
28796 "dataforms-layouts-panel__field-label",
28797 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
28798 { "has-error": showError }
28799 );
28800 }
28801 var get_label_classname_default = getLabelClassName;
28802
28803 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
28804 var import_components47 = __toESM(require_components(), 1);
28805 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1);
28806 function getLabelContent(showError, errorMessage, fieldLabel) {
28807 return showError ? /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(tooltip_exports.Root, { children: [
28808 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
28809 tooltip_exports.Trigger,
28810 {
28811 render: /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
28812 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_components47.Icon, { icon: error_default, size: 16 }),
28813 /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(VisuallyHidden, { children: [
28814 errorMessage,
28815 ": "
28816 ] }),
28817 fieldLabel
28818 ] })
28819 }
28820 ),
28821 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(tooltip_exports.Popup, { children: errorMessage })
28822 ] }) : fieldLabel;
28823 }
28824 var get_label_content_default = getLabelContent;
28825
28826 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
28827 function getFirstValidationError(validity) {
28828 if (!validity) {
28829 return void 0;
28830 }
28831 const validityRules = Object.keys(validity).filter(
28832 (key) => key !== "children"
28833 );
28834 for (const key of validityRules) {
28835 const rule = validity[key];
28836 if (rule === void 0) {
28837 continue;
28838 }
28839 if (rule.type === "invalid") {
28840 if (rule.message) {
28841 return rule.message;
28842 }
28843 if (key === "required") {
28844 return "A required field is empty";
28845 }
28846 return "Unidentified validation error";
28847 }
28848 }
28849 if (validity.children) {
28850 for (const childValidity of Object.values(validity.children)) {
28851 const childError = getFirstValidationError(childValidity);
28852 if (childError) {
28853 return childError;
28854 }
28855 }
28856 }
28857 return void 0;
28858 }
28859 var get_first_validation_error_default = getFirstValidationError;
28860
28861 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
28862 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1);
28863 function SummaryButton({
28864 data,
28865 field,
28866 fieldLabel,
28867 summaryFields,
28868 validity,
28869 touched,
28870 disabled: disabled2,
28871 isOpen,
28872 onClick
28873 }) {
28874 const { labelPosition, editVisibility } = field.layout;
28875 const errorMessage = get_first_validation_error_default(validity);
28876 const showError = touched && !!errorMessage;
28877 const labelClassName = get_label_classname_default(labelPosition, showError);
28878 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
28879 const className = clsx_default(
28880 "dataforms-layouts-panel__field-trigger",
28881 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
28882 {
28883 "is-disabled": disabled2,
28884 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
28885 }
28886 );
28887 const controlId = (0, import_compose14.useInstanceId)(
28888 SummaryButton,
28889 "dataforms-layouts-panel__field-control"
28890 );
28891 const ariaLabel = showError ? (0, import_i18n47.sprintf)(
28892 // translators: %s: Field name.
28893 (0, import_i18n47._x)("Edit %s (has errors)", "field"),
28894 fieldLabel || ""
28895 ) : (0, import_i18n47.sprintf)(
28896 // translators: %s: Field name.
28897 (0, import_i18n47._x)("Edit %s", "field"),
28898 fieldLabel || ""
28899 );
28900 const rowRef = (0, import_element102.useRef)(null);
28901 const editButtonRef = (0, import_element102.useRef)(null);
28902 const handleRowClick = (event) => {
28903 if (!isOpen && event.detail < 2 && !editButtonRef.current?.contains(event.target) && rowRef.current?.ownerDocument.defaultView?.getSelection()?.toString()) {
28904 return;
28905 }
28906 onClick();
28907 };
28908 const handleKeyDown = (event) => {
28909 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
28910 event.preventDefault();
28911 onClick();
28912 }
28913 };
28914 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(
28915 "div",
28916 {
28917 ref: rowRef,
28918 className,
28919 onClick: !disabled2 ? handleRowClick : void 0,
28920 onKeyDown: !disabled2 ? handleKeyDown : void 0,
28921 children: [
28922 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("span", { className: labelClassName, children: labelContent }),
28923 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(tooltip_exports.Root, { children: [
28924 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
28925 tooltip_exports.Trigger,
28926 {
28927 render: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
28928 "span",
28929 {
28930 className: "dataforms-layouts-panel__field-label-error-content",
28931 role: "img",
28932 "aria-label": errorMessage,
28933 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components48.Icon, { icon: error_default, size: 16 })
28934 }
28935 )
28936 }
28937 ),
28938 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(tooltip_exports.Popup, { children: errorMessage })
28939 ] }),
28940 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
28941 "span",
28942 {
28943 id: `${controlId}`,
28944 className: "dataforms-layouts-panel__field-control",
28945 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
28946 "span",
28947 {
28948 style: {
28949 display: "flex",
28950 flexDirection: "column",
28951 alignItems: "flex-start",
28952 width: "100%",
28953 gap: "2px"
28954 },
28955 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
28956 "span",
28957 {
28958 style: { width: "100%" },
28959 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
28960 summaryField.render,
28961 {
28962 item: data,
28963 field: summaryField
28964 }
28965 )
28966 },
28967 summaryField.id
28968 ))
28969 }
28970 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
28971 summaryField.render,
28972 {
28973 item: data,
28974 field: summaryField
28975 },
28976 summaryField.id
28977 ))
28978 }
28979 ),
28980 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
28981 import_components48.Button,
28982 {
28983 ref: editButtonRef,
28984 className: "dataforms-layouts-panel__field-trigger-icon",
28985 label: ariaLabel,
28986 icon: pencil_default,
28987 size: "small",
28988 "aria-expanded": isOpen,
28989 "aria-haspopup": "dialog",
28990 "aria-describedby": `${controlId}`
28991 }
28992 )
28993 ]
28994 }
28995 );
28996 }
28997
28998 // packages/dataviews/build-module/hooks/use-form-validity.mjs
28999 var import_deepmerge = __toESM(require_cjs(), 1);
29000 var import_es62 = __toESM(require_es6(), 1);
29001 var import_element103 = __toESM(require_element(), 1);
29002 var import_i18n48 = __toESM(require_i18n(), 1);
29003 function isFormValid(formValidity) {
29004 if (!formValidity) {
29005 return true;
29006 }
29007 return Object.values(formValidity).every((fieldValidation) => {
29008 return Object.entries(fieldValidation).every(
29009 ([key, validation]) => {
29010 if (key === "children" && validation && typeof validation === "object") {
29011 return isFormValid(validation);
29012 }
29013 return validation.type !== "invalid" && validation.type !== "validating";
29014 }
29015 );
29016 });
29017 }
29018 function getFormFieldsToValidate(form, fields) {
29019 const normalizedForm = normalize_form_default(form);
29020 if (normalizedForm.fields.length === 0) {
29021 return [];
29022 }
29023 const fieldsMap = /* @__PURE__ */ new Map();
29024 fields.forEach((field) => {
29025 fieldsMap.set(field.id, field);
29026 });
29027 function processFormField(formField) {
29028 if ("children" in formField && Array.isArray(formField.children)) {
29029 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
29030 if (processedChildren.length === 0) {
29031 return null;
29032 }
29033 const fieldDef2 = fieldsMap.get(formField.id);
29034 if (fieldDef2) {
29035 const [normalizedField2] = normalizeFields([
29036 fieldDef2
29037 ]);
29038 return {
29039 id: formField.id,
29040 children: processedChildren,
29041 field: normalizedField2
29042 };
29043 }
29044 return {
29045 id: formField.id,
29046 children: processedChildren
29047 };
29048 }
29049 const fieldDef = fieldsMap.get(formField.id);
29050 if (!fieldDef) {
29051 return null;
29052 }
29053 const [normalizedField] = normalizeFields([fieldDef]);
29054 return {
29055 id: formField.id,
29056 children: [],
29057 field: normalizedField
29058 };
29059 }
29060 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
29061 return toValidate;
29062 }
29063 function setValidityAtPath(formValidity, fieldValidity, path) {
29064 if (!formValidity) {
29065 formValidity = {};
29066 }
29067 if (path.length === 0) {
29068 return formValidity;
29069 }
29070 const result = { ...formValidity };
29071 let current = result;
29072 for (let i2 = 0; i2 < path.length - 1; i2++) {
29073 const segment = path[i2];
29074 if (!current[segment]) {
29075 current[segment] = {};
29076 }
29077 current[segment] = { ...current[segment] };
29078 current = current[segment];
29079 }
29080 const finalKey = path[path.length - 1];
29081 current[finalKey] = {
29082 ...current[finalKey] || {},
29083 ...fieldValidity
29084 };
29085 return result;
29086 }
29087 function removeValidationProperty(formValidity, path, property) {
29088 if (!formValidity || path.length === 0) {
29089 return formValidity;
29090 }
29091 const result = { ...formValidity };
29092 let current = result;
29093 for (let i2 = 0; i2 < path.length - 1; i2++) {
29094 const segment = path[i2];
29095 if (!current[segment]) {
29096 return formValidity;
29097 }
29098 current[segment] = { ...current[segment] };
29099 current = current[segment];
29100 }
29101 const finalKey = path[path.length - 1];
29102 if (!current[finalKey]) {
29103 return formValidity;
29104 }
29105 const fieldValidity = { ...current[finalKey] };
29106 delete fieldValidity[property];
29107 if (Object.keys(fieldValidity).length === 0) {
29108 delete current[finalKey];
29109 } else {
29110 current[finalKey] = fieldValidity;
29111 }
29112 if (Object.keys(result).length === 0) {
29113 return void 0;
29114 }
29115 return result;
29116 }
29117 function handleElementsValidationAsync(promise, formField, promiseHandler) {
29118 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
29119 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
29120 elementsCounterRef.current[formField.id] = currentToken;
29121 promise.then((result) => {
29122 if (currentToken !== elementsCounterRef.current[formField.id]) {
29123 return;
29124 }
29125 if (!Array.isArray(result)) {
29126 setFormValidity((prev) => {
29127 const newFormValidity = setValidityAtPath(
29128 prev,
29129 {
29130 elements: {
29131 type: "invalid",
29132 message: (0, import_i18n48.__)("Could not validate elements.")
29133 }
29134 },
29135 [...path, formField.id]
29136 );
29137 return newFormValidity;
29138 });
29139 return;
29140 }
29141 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
29142 ...formField.field,
29143 elements: result
29144 })) {
29145 setFormValidity((prev) => {
29146 const newFormValidity = setValidityAtPath(
29147 prev,
29148 {
29149 elements: {
29150 type: "invalid",
29151 message: (0, import_i18n48.__)(
29152 "Value must be one of the elements."
29153 )
29154 }
29155 },
29156 [...path, formField.id]
29157 );
29158 return newFormValidity;
29159 });
29160 } else {
29161 setFormValidity((prev) => {
29162 return removeValidationProperty(
29163 prev,
29164 [...path, formField.id],
29165 "elements"
29166 );
29167 });
29168 }
29169 }).catch((error2) => {
29170 if (currentToken !== elementsCounterRef.current[formField.id]) {
29171 return;
29172 }
29173 let errorMessage;
29174 if (error2 instanceof Error) {
29175 errorMessage = error2.message;
29176 } else {
29177 errorMessage = String(error2) || (0, import_i18n48.__)(
29178 "Unknown error when running elements validation asynchronously."
29179 );
29180 }
29181 setFormValidity((prev) => {
29182 const newFormValidity = setValidityAtPath(
29183 prev,
29184 {
29185 elements: {
29186 type: "invalid",
29187 message: errorMessage
29188 }
29189 },
29190 [...path, formField.id]
29191 );
29192 return newFormValidity;
29193 });
29194 });
29195 }
29196 function handleCustomValidationAsync(promise, formField, promiseHandler) {
29197 const { customCounterRef, setFormValidity, path } = promiseHandler;
29198 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
29199 customCounterRef.current[formField.id] = currentToken;
29200 promise.then((result) => {
29201 if (currentToken !== customCounterRef.current[formField.id]) {
29202 return;
29203 }
29204 if (result === null) {
29205 setFormValidity((prev) => {
29206 return removeValidationProperty(
29207 prev,
29208 [...path, formField.id],
29209 "custom"
29210 );
29211 });
29212 return;
29213 }
29214 if (typeof result === "string") {
29215 setFormValidity((prev) => {
29216 const newFormValidity = setValidityAtPath(
29217 prev,
29218 {
29219 custom: {
29220 type: "invalid",
29221 message: result
29222 }
29223 },
29224 [...path, formField.id]
29225 );
29226 return newFormValidity;
29227 });
29228 return;
29229 }
29230 setFormValidity((prev) => {
29231 const newFormValidity = setValidityAtPath(
29232 prev,
29233 {
29234 custom: {
29235 type: "invalid",
29236 message: (0, import_i18n48.__)("Validation could not be processed.")
29237 }
29238 },
29239 [...path, formField.id]
29240 );
29241 return newFormValidity;
29242 });
29243 }).catch((error2) => {
29244 if (currentToken !== customCounterRef.current[formField.id]) {
29245 return;
29246 }
29247 let errorMessage;
29248 if (error2 instanceof Error) {
29249 errorMessage = error2.message;
29250 } else {
29251 errorMessage = String(error2) || (0, import_i18n48.__)(
29252 "Unknown error when running custom validation asynchronously."
29253 );
29254 }
29255 setFormValidity((prev) => {
29256 const newFormValidity = setValidityAtPath(
29257 prev,
29258 {
29259 custom: {
29260 type: "invalid",
29261 message: errorMessage
29262 }
29263 },
29264 [...path, formField.id]
29265 );
29266 return newFormValidity;
29267 });
29268 });
29269 }
29270 function validateFormField(item, formField, promiseHandler) {
29271 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
29272 return {
29273 required: { type: "invalid" }
29274 };
29275 }
29276 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
29277 return {
29278 pattern: {
29279 type: "invalid",
29280 message: (0, import_i18n48.__)("Value does not match the required pattern.")
29281 }
29282 };
29283 }
29284 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
29285 return {
29286 min: {
29287 type: "invalid",
29288 message: (0, import_i18n48.__)("Value is below the minimum.")
29289 }
29290 };
29291 }
29292 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
29293 return {
29294 max: {
29295 type: "invalid",
29296 message: (0, import_i18n48.__)("Value is above the maximum.")
29297 }
29298 };
29299 }
29300 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
29301 return {
29302 minLength: {
29303 type: "invalid",
29304 message: (0, import_i18n48.__)("Value is too short.")
29305 }
29306 };
29307 }
29308 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
29309 return {
29310 maxLength: {
29311 type: "invalid",
29312 message: (0, import_i18n48.__)("Value is too long.")
29313 }
29314 };
29315 }
29316 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
29317 return {
29318 elements: {
29319 type: "invalid",
29320 message: (0, import_i18n48.__)("Value must be one of the elements.")
29321 }
29322 };
29323 }
29324 let customError;
29325 if (!!formField.field && formField.field.isValid.custom) {
29326 try {
29327 const value = formField.field.getValue({ item });
29328 customError = formField.field.isValid.custom(
29329 (0, import_deepmerge.default)(
29330 item,
29331 formField.field.setValue({
29332 item,
29333 value
29334 })
29335 ),
29336 formField.field
29337 );
29338 } catch (error2) {
29339 let errorMessage;
29340 if (error2 instanceof Error) {
29341 errorMessage = error2.message;
29342 } else {
29343 errorMessage = String(error2) || (0, import_i18n48.__)("Unknown error when running custom validation.");
29344 }
29345 return {
29346 custom: {
29347 type: "invalid",
29348 message: errorMessage
29349 }
29350 };
29351 }
29352 }
29353 if (typeof customError === "string") {
29354 return {
29355 custom: {
29356 type: "invalid",
29357 message: customError
29358 }
29359 };
29360 }
29361 const fieldValidity = {};
29362 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
29363 handleElementsValidationAsync(
29364 formField.field.getElements(),
29365 formField,
29366 promiseHandler
29367 );
29368 fieldValidity.elements = {
29369 type: "validating",
29370 message: (0, import_i18n48.__)("Validating\u2026")
29371 };
29372 }
29373 if (customError instanceof Promise) {
29374 handleCustomValidationAsync(customError, formField, promiseHandler);
29375 fieldValidity.custom = {
29376 type: "validating",
29377 message: (0, import_i18n48.__)("Validating\u2026")
29378 };
29379 }
29380 if (Object.keys(fieldValidity).length > 0) {
29381 return fieldValidity;
29382 }
29383 if (formField.children.length > 0) {
29384 const result = {};
29385 formField.children.forEach((child) => {
29386 result[child.id] = validateFormField(item, child, {
29387 ...promiseHandler,
29388 path: [...promiseHandler.path, formField.id, "children"]
29389 });
29390 });
29391 const filteredResult = {};
29392 Object.entries(result).forEach(([key, value]) => {
29393 if (value !== void 0) {
29394 filteredResult[key] = value;
29395 }
29396 });
29397 if (Object.keys(filteredResult).length === 0) {
29398 return void 0;
29399 }
29400 return {
29401 children: filteredResult
29402 };
29403 }
29404 return void 0;
29405 }
29406 function getFormFieldValue(formField, item) {
29407 const fieldValue = formField?.field?.getValue({ item });
29408 if (formField.children.length === 0) {
29409 return fieldValue;
29410 }
29411 const childrenValues = formField.children.map(
29412 (child) => getFormFieldValue(child, item)
29413 );
29414 if (!childrenValues) {
29415 return fieldValue;
29416 }
29417 return {
29418 value: fieldValue,
29419 children: childrenValues
29420 };
29421 }
29422 function useFormValidity(item, fields, form) {
29423 const [formValidity, setFormValidity] = (0, import_element103.useState)();
29424 const customCounterRef = (0, import_element103.useRef)({});
29425 const elementsCounterRef = (0, import_element103.useRef)({});
29426 const previousValuesRef = (0, import_element103.useRef)({});
29427 const validate = (0, import_element103.useCallback)(() => {
29428 const promiseHandler = {
29429 customCounterRef,
29430 elementsCounterRef,
29431 setFormValidity,
29432 path: [],
29433 item
29434 };
29435 const formFieldsToValidate = getFormFieldsToValidate(form, fields);
29436 if (formFieldsToValidate.length === 0) {
29437 setFormValidity(void 0);
29438 return;
29439 }
29440 const newFormValidity = {};
29441 const untouchedFields = [];
29442 formFieldsToValidate.forEach((formField) => {
29443 const value = getFormFieldValue(formField, item);
29444 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)(
29445 previousValuesRef.current[formField.id],
29446 value
29447 )) {
29448 untouchedFields.push(formField.id);
29449 return;
29450 }
29451 previousValuesRef.current[formField.id] = value;
29452 const fieldValidity = validateFormField(
29453 item,
29454 formField,
29455 promiseHandler
29456 );
29457 if (fieldValidity !== void 0) {
29458 newFormValidity[formField.id] = fieldValidity;
29459 }
29460 });
29461 setFormValidity((existingFormValidity) => {
29462 let validity = {
29463 ...existingFormValidity,
29464 ...newFormValidity
29465 };
29466 const fieldsToKeep = [
29467 ...untouchedFields,
29468 ...Object.keys(newFormValidity)
29469 ];
29470 Object.keys(validity).forEach((key) => {
29471 if (validity && !fieldsToKeep.includes(key)) {
29472 delete validity[key];
29473 }
29474 });
29475 if (Object.keys(validity).length === 0) {
29476 validity = void 0;
29477 }
29478 const areEqual = (0, import_es62.default)(existingFormValidity, validity);
29479 if (areEqual) {
29480 return existingFormValidity;
29481 }
29482 return validity;
29483 });
29484 }, [item, fields, form]);
29485 (0, import_element103.useEffect)(() => {
29486 validate();
29487 }, [validate]);
29488 return {
29489 validity: formValidity,
29490 isValid: isFormValid(formValidity)
29491 };
29492 }
29493 var use_form_validity_default = useFormValidity;
29494
29495 // packages/dataviews/build-module/hooks/use-report-validity.mjs
29496 var import_element104 = __toESM(require_element(), 1);
29497 function useReportValidity(ref, shouldReport) {
29498 (0, import_element104.useEffect)(() => {
29499 if (shouldReport && ref.current) {
29500 const inputs = ref.current.querySelectorAll(
29501 "input, textarea, select"
29502 );
29503 inputs.forEach((input) => {
29504 input.reportValidity();
29505 });
29506 }
29507 }, [shouldReport, ref]);
29508 }
29509
29510 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
29511 var import_element105 = __toESM(require_element(), 1);
29512
29513 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
29514 function extractSummaryIds(summary) {
29515 if (Array.isArray(summary)) {
29516 return summary.map(
29517 (item) => typeof item === "string" ? item : item.id
29518 );
29519 }
29520 return [];
29521 }
29522 var getSummaryFields = (summaryField, fields) => {
29523 if (Array.isArray(summaryField) && summaryField.length > 0) {
29524 const summaryIds = extractSummaryIds(summaryField);
29525 return summaryIds.map(
29526 (summaryId) => fields.find((_field) => _field.id === summaryId)
29527 ).filter((_field) => _field !== void 0);
29528 }
29529 return [];
29530 };
29531
29532 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
29533 var getFieldDefinition = (field, fields) => {
29534 const fieldDefinition = fields.find((_field) => _field.id === field.id);
29535 if (!fieldDefinition) {
29536 return fields.find((_field) => {
29537 if (!!field.children) {
29538 const simpleChildren = field.children.filter(
29539 (child) => !child.children
29540 );
29541 if (simpleChildren.length === 0) {
29542 return false;
29543 }
29544 return _field.id === simpleChildren[0].id;
29545 }
29546 return _field.id === field.id;
29547 });
29548 }
29549 return fieldDefinition;
29550 };
29551 function useFieldFromFormField(field) {
29552 const { fields } = (0, import_element105.useContext)(dataform_context_default);
29553 const layout = field.layout;
29554 const summaryFields = getSummaryFields(layout.summary, fields);
29555 const fieldDefinition = getFieldDefinition(field, fields);
29556 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
29557 if (summaryFields.length === 0) {
29558 return {
29559 summaryFields: fieldDefinition ? [fieldDefinition] : [],
29560 fieldDefinition,
29561 fieldLabel
29562 };
29563 }
29564 return {
29565 summaryFields,
29566 fieldDefinition,
29567 fieldLabel
29568 };
29569 }
29570 var use_field_from_form_field_default = useFieldFromFormField;
29571
29572 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
29573 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1);
29574 function ModalContent({
29575 data,
29576 field,
29577 onChange,
29578 fieldLabel,
29579 onClose,
29580 touched
29581 }) {
29582 const { openAs } = field.layout;
29583 const { applyLabel, cancelLabel } = openAs;
29584 const { fields } = (0, import_element106.useContext)(dataform_context_default);
29585 const [changes, setChanges] = (0, import_element106.useState)({});
29586 const modalData = (0, import_element106.useMemo)(() => {
29587 return (0, import_deepmerge2.default)(data, changes, {
29588 arrayMerge: (target, source) => source
29589 });
29590 }, [data, changes]);
29591 const form = (0, import_element106.useMemo)(
29592 () => ({
29593 layout: DEFAULT_LAYOUT,
29594 fields: !!field.children ? field.children : (
29595 // If not explicit children return the field id itself.
29596 [{ id: field.id, layout: DEFAULT_LAYOUT }]
29597 )
29598 }),
29599 [field]
29600 );
29601 const fieldsAsFieldType = fields.map((f2) => ({
29602 ...f2,
29603 Edit: f2.Edit === null ? void 0 : f2.Edit,
29604 isValid: {
29605 required: f2.isValid.required?.constraint,
29606 elements: f2.isValid.elements?.constraint,
29607 min: f2.isValid.min?.constraint,
29608 max: f2.isValid.max?.constraint,
29609 pattern: f2.isValid.pattern?.constraint,
29610 minLength: f2.isValid.minLength?.constraint,
29611 maxLength: f2.isValid.maxLength?.constraint
29612 }
29613 }));
29614 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
29615 const onApply = () => {
29616 onChange(changes);
29617 onClose();
29618 };
29619 const handleOnChange = (newValue) => {
29620 setChanges(
29621 (prev) => (0, import_deepmerge2.default)(prev, newValue, {
29622 arrayMerge: (target, source) => source
29623 })
29624 );
29625 };
29626 const focusOnMountRef = (0, import_compose15.useFocusOnMount)("firstInputElement");
29627 const contentRef = (0, import_element106.useRef)(null);
29628 const mergedRef = (0, import_compose15.useMergeRefs)([focusOnMountRef, contentRef]);
29629 useReportValidity(contentRef, touched);
29630 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
29631 import_components49.Modal,
29632 {
29633 className: "dataforms-layouts-panel__modal",
29634 onRequestClose: onClose,
29635 isFullScreen: false,
29636 title: fieldLabel,
29637 size: "medium",
29638 children: [
29639 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29640 DataFormLayout,
29641 {
29642 data: modalData,
29643 form,
29644 onChange: handleOnChange,
29645 validity,
29646 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29647 FieldLayout,
29648 {
29649 data: modalData,
29650 field: childField,
29651 onChange: handleOnChange,
29652 hideLabelFromVision: form.fields.length < 2,
29653 markWhenOptional,
29654 validity: childFieldValidity
29655 },
29656 childField.id
29657 )
29658 }
29659 ) }),
29660 /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
29661 Stack,
29662 {
29663 direction: "row",
29664 className: "dataforms-layouts-panel__modal-footer",
29665 gap: "md",
29666 children: [
29667 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components49.__experimentalSpacer, { style: { flex: 1 } }),
29668 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29669 import_components49.Button,
29670 {
29671 variant: "tertiary",
29672 onClick: onClose,
29673 __next40pxDefaultSize: true,
29674 children: cancelLabel
29675 }
29676 ),
29677 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29678 import_components49.Button,
29679 {
29680 variant: "primary",
29681 onClick: onApply,
29682 __next40pxDefaultSize: true,
29683 children: applyLabel
29684 }
29685 )
29686 ]
29687 }
29688 )
29689 ]
29690 }
29691 );
29692 }
29693 function PanelModal({
29694 data,
29695 field,
29696 onChange,
29697 validity
29698 }) {
29699 const [touched, setTouched] = (0, import_element106.useState)(false);
29700 const [isOpen, setIsOpen] = (0, import_element106.useState)(false);
29701 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
29702 if (!fieldDefinition) {
29703 return null;
29704 }
29705 const handleClose = () => {
29706 setIsOpen(false);
29707 setTouched(true);
29708 };
29709 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(import_jsx_runtime140.Fragment, { children: [
29710 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29711 SummaryButton,
29712 {
29713 data,
29714 field,
29715 fieldLabel,
29716 summaryFields,
29717 validity,
29718 touched,
29719 disabled: fieldDefinition.readOnly === true,
29720 onClick: () => setIsOpen(true),
29721 isOpen
29722 }
29723 ),
29724 isOpen && /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29725 ModalContent,
29726 {
29727 data,
29728 field,
29729 onChange,
29730 fieldLabel: fieldLabel ?? "",
29731 onClose: handleClose,
29732 touched
29733 }
29734 )
29735 ] });
29736 }
29737 var modal_default = PanelModal;
29738
29739 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
29740 var import_components50 = __toESM(require_components(), 1);
29741 var import_i18n49 = __toESM(require_i18n(), 1);
29742 var import_element107 = __toESM(require_element(), 1);
29743 var import_compose16 = __toESM(require_compose(), 1);
29744 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1);
29745 function DropdownHeader({
29746 title,
29747 onClose
29748 }) {
29749 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29750 Stack,
29751 {
29752 direction: "column",
29753 className: "dataforms-layouts-panel__dropdown-header",
29754 gap: "lg",
29755 children: /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
29756 title && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components50.__experimentalHeading, { level: 2, size: 13, children: title }),
29757 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components50.__experimentalSpacer, { style: { flex: 1 } }),
29758 onClose && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29759 import_components50.Button,
29760 {
29761 label: (0, import_i18n49.__)("Close"),
29762 icon: close_small_default,
29763 onClick: onClose,
29764 size: "small"
29765 }
29766 )
29767 ] })
29768 }
29769 );
29770 }
29771 function DropdownContentWithValidation({
29772 touched,
29773 children
29774 }) {
29775 const ref = (0, import_element107.useRef)(null);
29776 useReportValidity(ref, touched);
29777 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("div", { ref, children });
29778 }
29779 function PanelDropdown({
29780 data,
29781 field,
29782 onChange,
29783 validity
29784 }) {
29785 const [touched, setTouched] = (0, import_element107.useState)(false);
29786 const [popoverAnchor, setPopoverAnchor] = (0, import_element107.useState)(
29787 null
29788 );
29789 const popoverProps = (0, import_element107.useMemo)(
29790 () => ({
29791 // Anchor the popover to the middle of the entire row so that it doesn't
29792 // move around when the label changes.
29793 anchor: popoverAnchor,
29794 placement: "left-start",
29795 offset: 36,
29796 shift: true
29797 }),
29798 [popoverAnchor]
29799 );
29800 const [dialogRef, dialogProps] = (0, import_compose16.__experimentalUseDialog)({
29801 focusOnMount: "firstInputElement"
29802 });
29803 const form = (0, import_element107.useMemo)(
29804 () => ({
29805 layout: DEFAULT_LAYOUT,
29806 fields: !!field.children ? field.children : (
29807 // If not explicit children return the field id itself.
29808 [{ id: field.id, layout: DEFAULT_LAYOUT }]
29809 )
29810 }),
29811 [field]
29812 );
29813 const formValidity = (0, import_element107.useMemo)(() => {
29814 if (validity === void 0) {
29815 return void 0;
29816 }
29817 if (!!field.children) {
29818 return validity?.children;
29819 }
29820 return { [field.id]: validity };
29821 }, [validity, field]);
29822 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
29823 if (!fieldDefinition) {
29824 return null;
29825 }
29826 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29827 "div",
29828 {
29829 ref: setPopoverAnchor,
29830 className: "dataforms-layouts-panel__field-dropdown-anchor",
29831 children: /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29832 import_components50.Dropdown,
29833 {
29834 contentClassName: "dataforms-layouts-panel__field-dropdown",
29835 popoverProps,
29836 focusOnMount: false,
29837 onToggle: (willOpen) => {
29838 if (!willOpen) {
29839 setTouched(true);
29840 }
29841 },
29842 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29843 SummaryButton,
29844 {
29845 data,
29846 field,
29847 fieldLabel,
29848 summaryFields,
29849 validity,
29850 touched,
29851 disabled: fieldDefinition.readOnly === true,
29852 isOpen,
29853 onClick: onToggle
29854 }
29855 ),
29856 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
29857 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29858 DropdownHeader,
29859 {
29860 title: fieldLabel,
29861 onClose
29862 }
29863 ),
29864 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29865 DataFormLayout,
29866 {
29867 data,
29868 form,
29869 onChange,
29870 validity: formValidity,
29871 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29872 FieldLayout,
29873 {
29874 data,
29875 field: childField,
29876 onChange,
29877 hideLabelFromVision: (form?.fields ?? []).length < 2,
29878 markWhenOptional,
29879 validity: childFieldValidity
29880 },
29881 childField.id
29882 )
29883 }
29884 )
29885 ] }) })
29886 }
29887 )
29888 }
29889 );
29890 }
29891 var dropdown_default = PanelDropdown;
29892
29893 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
29894 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1);
29895 function FormPanelField({
29896 data,
29897 field,
29898 onChange,
29899 validity
29900 }) {
29901 const layout = field.layout;
29902 if (layout.openAs.type === "modal") {
29903 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
29904 modal_default,
29905 {
29906 data,
29907 field,
29908 onChange,
29909 validity
29910 }
29911 );
29912 }
29913 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
29914 dropdown_default,
29915 {
29916 data,
29917 field,
29918 onChange,
29919 validity
29920 }
29921 );
29922 }
29923
29924 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
29925 var import_element108 = __toESM(require_element(), 1);
29926
29927 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
29928 var import_i18n50 = __toESM(require_i18n(), 1);
29929 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1);
29930 function countInvalidFields(validity) {
29931 if (!validity) {
29932 return 0;
29933 }
29934 let count = 0;
29935 const validityRules = Object.keys(validity).filter(
29936 (key) => key !== "children"
29937 );
29938 for (const key of validityRules) {
29939 const rule = validity[key];
29940 if (rule?.type === "invalid") {
29941 count++;
29942 }
29943 }
29944 if (validity.children) {
29945 for (const childValidity of Object.values(validity.children)) {
29946 count += countInvalidFields(childValidity);
29947 }
29948 }
29949 return count;
29950 }
29951 function ValidationBadge({
29952 validity
29953 }) {
29954 const invalidCount = countInvalidFields(validity);
29955 if (invalidCount === 0) {
29956 return null;
29957 }
29958 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(Badge, { intent: "high", children: (0, import_i18n50.sprintf)(
29959 /* translators: %d: Number of fields that need attention */
29960 (0, import_i18n50._n)(
29961 "%d field needs attention",
29962 "%d fields need attention",
29963 invalidCount
29964 ),
29965 invalidCount
29966 ) });
29967 }
29968
29969 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
29970 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1);
29971 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
29972 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
29973 return false;
29974 }
29975 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
29976 const fieldConfig = summaryConfigArray.find((config) => {
29977 if (typeof config === "string") {
29978 return config === summaryField.id;
29979 }
29980 if (typeof config === "object" && "id" in config) {
29981 return config.id === summaryField.id;
29982 }
29983 return false;
29984 });
29985 if (!fieldConfig) {
29986 return false;
29987 }
29988 if (typeof fieldConfig === "string") {
29989 return true;
29990 }
29991 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
29992 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
29993 }
29994 return true;
29995 }
29996 function HeaderContent({
29997 data,
29998 fields,
29999 label,
30000 layout,
30001 isOpen,
30002 touched,
30003 validity
30004 }) {
30005 const summaryFields = getSummaryFields(layout.summary, fields);
30006 const visibleSummaryFields = summaryFields.filter(
30007 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
30008 );
30009 const hasBadge = touched && layout.isCollapsible;
30010 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader;
30011 return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(
30012 Stack,
30013 {
30014 align: "center",
30015 justify: "space-between",
30016 className: "dataforms-layouts-card__field-header-content",
30017 children: [
30018 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(card_exports.Title, { children: label }),
30019 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [
30020 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(ValidationBadge, { validity }),
30021 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30022 summaryField.render,
30023 {
30024 item: data,
30025 field: summaryField
30026 },
30027 summaryField.id
30028 )) })
30029 ] })
30030 ]
30031 }
30032 );
30033 }
30034 function BodyContent({
30035 data,
30036 field,
30037 form,
30038 onChange,
30039 hideLabelFromVision,
30040 markWhenOptional,
30041 validity,
30042 withHeader
30043 }) {
30044 if (field.children) {
30045 return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(import_jsx_runtime144.Fragment, { children: [
30046 field.description && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
30047 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30048 DataFormLayout,
30049 {
30050 data,
30051 form,
30052 onChange,
30053 validity: validity?.children
30054 }
30055 )
30056 ] });
30057 }
30058 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
30059 if (!SingleFieldLayout) {
30060 return null;
30061 }
30062 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30063 SingleFieldLayout,
30064 {
30065 data,
30066 field,
30067 onChange,
30068 hideLabelFromVision: hideLabelFromVision || withHeader,
30069 markWhenOptional,
30070 validity
30071 }
30072 );
30073 }
30074 function FormCardField({
30075 data,
30076 field,
30077 onChange,
30078 hideLabelFromVision,
30079 markWhenOptional,
30080 validity
30081 }) {
30082 const { fields } = (0, import_element108.useContext)(dataform_context_default);
30083 const layout = field.layout;
30084 const contentRef = (0, import_element108.useRef)(null);
30085 const form = (0, import_element108.useMemo)(
30086 () => ({
30087 layout: DEFAULT_LAYOUT,
30088 fields: field.children ?? []
30089 }),
30090 [field]
30091 );
30092 const { isOpened, isCollapsible } = layout;
30093 const [isOpen, setIsOpen] = (0, import_element108.useState)(isOpened);
30094 const [touched, setTouched] = (0, import_element108.useState)(false);
30095 (0, import_element108.useEffect)(() => {
30096 setIsOpen(isOpened);
30097 }, [isOpened]);
30098 const handleOpenChange = (0, import_element108.useCallback)((open) => {
30099 if (!open) {
30100 setTouched(true);
30101 }
30102 setIsOpen(open);
30103 }, []);
30104 const handleBlur = (0, import_element108.useCallback)(() => {
30105 setTouched(true);
30106 }, []);
30107 useReportValidity(
30108 contentRef,
30109 (isCollapsible ? isOpen : true) && touched
30110 );
30111 let label = field.label;
30112 let withHeader;
30113 if (field.children) {
30114 withHeader = !!label && layout.withHeader;
30115 } else {
30116 const fieldDefinition = fields.find(
30117 (fieldDef) => fieldDef.id === field.id
30118 );
30119 if (!fieldDefinition || !fieldDefinition.Edit) {
30120 return null;
30121 }
30122 label = fieldDefinition.label;
30123 withHeader = !!label && layout.withHeader;
30124 }
30125 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30126 BodyContent,
30127 {
30128 data,
30129 field,
30130 form,
30131 onChange,
30132 hideLabelFromVision,
30133 markWhenOptional,
30134 validity,
30135 withHeader
30136 }
30137 );
30138 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30139 HeaderContent,
30140 {
30141 data,
30142 fields,
30143 label,
30144 layout,
30145 isOpen: isCollapsible ? !!isOpen : true,
30146 touched,
30147 validity
30148 }
30149 );
30150 if (withHeader && isCollapsible) {
30151 return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(
30152 collapsible_card_exports.Root,
30153 {
30154 className: "dataforms-layouts-card__field",
30155 open: isOpen,
30156 onOpenChange: handleOpenChange,
30157 children: [
30158 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(collapsible_card_exports.Header, { children: headerContent }),
30159 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30160 collapsible_card_exports.Content,
30161 {
30162 ref: contentRef,
30163 onBlur: handleBlur,
30164 children: bodyContent
30165 }
30166 )
30167 ]
30168 }
30169 );
30170 }
30171 return /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [
30172 withHeader && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(card_exports.Header, { children: headerContent }),
30173 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent })
30174 ] });
30175 }
30176
30177 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
30178 var import_components51 = __toESM(require_components(), 1);
30179 var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1);
30180 function Header4({ title }) {
30181 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30182 Stack,
30183 {
30184 direction: "column",
30185 className: "dataforms-layouts-row__header",
30186 gap: "lg",
30187 children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components51.__experimentalHeading, { level: 2, size: 13, children: title }) })
30188 }
30189 );
30190 }
30191 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_jsx_runtime145.Fragment, { children });
30192 function FormRowField({
30193 data,
30194 field,
30195 onChange,
30196 hideLabelFromVision,
30197 markWhenOptional,
30198 validity
30199 }) {
30200 const layout = field.layout;
30201 if (!!field.children) {
30202 const form = {
30203 layout: DEFAULT_LAYOUT,
30204 fields: field.children
30205 };
30206 return /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
30207 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Header4, { title: field.label }),
30208 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30209 DataFormLayout,
30210 {
30211 data,
30212 form,
30213 onChange,
30214 validity: validity?.children,
30215 as: EMPTY_WRAPPER,
30216 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30217 "div",
30218 {
30219 className: "dataforms-layouts-row__field-control",
30220 style: layout.styles[childField.id],
30221 children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30222 FieldLayout,
30223 {
30224 data,
30225 field: childField,
30226 onChange,
30227 hideLabelFromVision,
30228 markWhenOptional,
30229 validity: childFieldValidity
30230 }
30231 )
30232 },
30233 childField.id
30234 )
30235 }
30236 ) })
30237 ] });
30238 }
30239 const RegularLayout = getFormFieldLayout("regular")?.component;
30240 if (!RegularLayout) {
30241 return null;
30242 }
30243 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_jsx_runtime145.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30244 RegularLayout,
30245 {
30246 data,
30247 field,
30248 onChange,
30249 markWhenOptional,
30250 validity
30251 }
30252 ) }) });
30253 }
30254
30255 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
30256 var import_element109 = __toESM(require_element(), 1);
30257 var import_i18n51 = __toESM(require_i18n(), 1);
30258 var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1);
30259 function FormDetailsField({
30260 data,
30261 field,
30262 onChange,
30263 validity
30264 }) {
30265 const { fields } = (0, import_element109.useContext)(dataform_context_default);
30266 const detailsRef = (0, import_element109.useRef)(null);
30267 const contentRef = (0, import_element109.useRef)(null);
30268 const [touched, setTouched] = (0, import_element109.useState)(false);
30269 const [isOpen, setIsOpen] = (0, import_element109.useState)(false);
30270 const form = (0, import_element109.useMemo)(
30271 () => ({
30272 layout: DEFAULT_LAYOUT,
30273 fields: field.children ?? []
30274 }),
30275 [field]
30276 );
30277 (0, import_element109.useEffect)(() => {
30278 const details = detailsRef.current;
30279 if (!details) {
30280 return;
30281 }
30282 const handleToggle = () => {
30283 const nowOpen = details.open;
30284 if (!nowOpen) {
30285 setTouched(true);
30286 }
30287 setIsOpen(nowOpen);
30288 };
30289 details.addEventListener("toggle", handleToggle);
30290 return () => {
30291 details.removeEventListener("toggle", handleToggle);
30292 };
30293 }, []);
30294 useReportValidity(contentRef, isOpen && touched);
30295 const handleBlur = (0, import_element109.useCallback)(() => {
30296 setTouched(true);
30297 }, []);
30298 if (!field.children) {
30299 return null;
30300 }
30301 const summaryFieldId = field.layout.summary ?? "";
30302 const summaryField = summaryFieldId ? fields.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
30303 let summaryContent;
30304 if (summaryField && summaryField.render) {
30305 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(summaryField.render, { item: data, field: summaryField });
30306 } else {
30307 summaryContent = field.label || (0, import_i18n51.__)("More details");
30308 }
30309 return /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(
30310 "details",
30311 {
30312 ref: detailsRef,
30313 className: "dataforms-layouts-details__details",
30314 children: [
30315 /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(
30316 Stack,
30317 {
30318 direction: "row",
30319 align: "center",
30320 gap: "md",
30321 className: "dataforms-layouts-details__summary-content",
30322 children: [
30323 summaryContent,
30324 touched && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(ValidationBadge, { validity })
30325 ]
30326 }
30327 ) }),
30328 /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
30329 "div",
30330 {
30331 ref: contentRef,
30332 className: "dataforms-layouts-details__content",
30333 onBlur: handleBlur,
30334 children: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
30335 DataFormLayout,
30336 {
30337 data,
30338 form,
30339 onChange,
30340 validity: validity?.children
30341 }
30342 )
30343 }
30344 )
30345 ]
30346 }
30347 );
30348 }
30349
30350 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
30351 var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1);
30352 var FORM_FIELD_LAYOUTS = [
30353 {
30354 type: "regular",
30355 component: FormRegularField,
30356 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30357 Stack,
30358 {
30359 direction: "column",
30360 className: "dataforms-layouts__wrapper",
30361 gap: "lg",
30362 children
30363 }
30364 )
30365 },
30366 {
30367 type: "panel",
30368 component: FormPanelField,
30369 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30370 Stack,
30371 {
30372 direction: "column",
30373 className: "dataforms-layouts__wrapper",
30374 gap: "md",
30375 children
30376 }
30377 )
30378 },
30379 {
30380 type: "card",
30381 component: FormCardField,
30382 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30383 Stack,
30384 {
30385 direction: "column",
30386 className: "dataforms-layouts__wrapper",
30387 gap: "xl",
30388 children
30389 }
30390 )
30391 },
30392 {
30393 type: "row",
30394 component: FormRowField,
30395 wrapper: ({
30396 children,
30397 layout
30398 }) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30399 Stack,
30400 {
30401 direction: "column",
30402 className: "dataforms-layouts__wrapper",
30403 gap: "lg",
30404 children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
30405 Stack,
30406 {
30407 direction: "row",
30408 gap: "lg",
30409 align: layout.alignment,
30410 children
30411 }
30412 ) })
30413 }
30414 )
30415 },
30416 {
30417 type: "details",
30418 component: FormDetailsField
30419 }
30420 ];
30421 function getFormFieldLayout(type) {
30422 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
30423 }
30424
30425 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
30426 var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1);
30427 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
30428 function DataFormLayout({
30429 data,
30430 form,
30431 onChange,
30432 validity,
30433 children,
30434 as
30435 }) {
30436 const { fields: fieldDefinitions } = (0, import_element110.useContext)(dataform_context_default);
30437 const markWhenOptional = (0, import_element110.useMemo)(() => {
30438 const requiredCount = fieldDefinitions.filter(
30439 (f2) => !!f2.isValid?.required
30440 ).length;
30441 const optionalCount = fieldDefinitions.length - requiredCount;
30442 return requiredCount > optionalCount;
30443 }, [fieldDefinitions]);
30444 function getFieldDefinition2(field) {
30445 return fieldDefinitions.find(
30446 (fieldDefinition) => fieldDefinition.id === field.id
30447 );
30448 }
30449 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
30450 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
30451 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
30452 if (!FieldLayout) {
30453 return null;
30454 }
30455 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
30456 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
30457 return null;
30458 }
30459 if (children) {
30460 return children(
30461 FieldLayout,
30462 formField,
30463 validity?.[formField.id],
30464 markWhenOptional
30465 );
30466 }
30467 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
30468 FieldLayout,
30469 {
30470 data,
30471 field: formField,
30472 onChange,
30473 markWhenOptional,
30474 validity: validity?.[formField.id]
30475 },
30476 formField.id
30477 );
30478 }) });
30479 }
30480
30481 // packages/dataviews/build-module/dataform/index.mjs
30482 var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1);
30483 function DataForm({
30484 data,
30485 form,
30486 fields,
30487 onChange,
30488 validity
30489 }) {
30490 const normalizedForm = (0, import_element111.useMemo)(() => normalize_form_default(form), [form]);
30491 const normalizedFields = (0, import_element111.useMemo)(
30492 () => normalizeFields(fields),
30493 [fields]
30494 );
30495 if (!form.fields) {
30496 return null;
30497 }
30498 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
30499 DataFormLayout,
30500 {
30501 data,
30502 form: normalizedForm,
30503 onChange,
30504 validity
30505 }
30506 ) });
30507 }
30508
30509 // widgets/quick-draft/render.tsx
30510 var import_element116 = __toESM(require_element());
30511 var import_escape_html = __toESM(require_escape_html());
30512 var import_i18n54 = __toESM(require_i18n());
30513
30514 // widgets/quick-draft/components/drafts-list/drafts-list.tsx
30515 var import_core_data = __toESM(require_core_data());
30516 var import_data6 = __toESM(require_data());
30517 var import_date10 = __toESM(require_date());
30518 var import_element112 = __toESM(require_element());
30519 var import_html_entities = __toESM(require_html_entities());
30520 var import_i18n52 = __toESM(require_i18n());
30521 var import_url3 = __toESM(require_url());
30522
30523 // packages/style-runtime/src/index.ts
30524 var STYLE_HASH_ATTRIBUTE24 = "data-wp-hash";
30525 function getRuntime24() {
30526 const globalScope = globalThis;
30527 if (globalScope.__wpStyleRuntime) {
30528 return globalScope.__wpStyleRuntime;
30529 }
30530 globalScope.__wpStyleRuntime = {
30531 documents: /* @__PURE__ */ new Map(),
30532 styles: /* @__PURE__ */ new Map(),
30533 injectedStyles: /* @__PURE__ */ new WeakMap()
30534 };
30535 if (typeof document !== "undefined") {
30536 registerDocument24(document);
30537 }
30538 return globalScope.__wpStyleRuntime;
30539 }
30540 function documentContainsStyleHash24(targetDocument, hash) {
30541 if (!targetDocument.head) {
30542 return false;
30543 }
30544 for (const style of targetDocument.head.querySelectorAll(
30545 `style[${STYLE_HASH_ATTRIBUTE24}]`
30546 )) {
30547 if (style.getAttribute(STYLE_HASH_ATTRIBUTE24) === hash) {
30548 return true;
30549 }
30550 }
30551 return false;
30552 }
30553 function injectStyle24(targetDocument, hash, css) {
30554 if (!targetDocument.head) {
30555 return;
30556 }
30557 const runtime = getRuntime24();
30558 let injectedStyles = runtime.injectedStyles.get(targetDocument);
30559 if (!injectedStyles) {
30560 injectedStyles = /* @__PURE__ */ new Set();
30561 runtime.injectedStyles.set(targetDocument, injectedStyles);
30562 }
30563 if (injectedStyles.has(hash)) {
30564 return;
30565 }
30566 if (documentContainsStyleHash24(targetDocument, hash)) {
30567 injectedStyles.add(hash);
30568 return;
30569 }
30570 const style = targetDocument.createElement("style");
30571 style.setAttribute(STYLE_HASH_ATTRIBUTE24, hash);
30572 style.appendChild(targetDocument.createTextNode(css));
30573 targetDocument.head.appendChild(style);
30574 injectedStyles.add(hash);
30575 }
30576 function registerDocument24(targetDocument) {
30577 const runtime = getRuntime24();
30578 runtime.documents.set(
30579 targetDocument,
30580 (runtime.documents.get(targetDocument) ?? 0) + 1
30581 );
30582 for (const [hash, css] of runtime.styles) {
30583 injectStyle24(targetDocument, hash, css);
30584 }
30585 return () => {
30586 const count = runtime.documents.get(targetDocument);
30587 if (count === void 0) {
30588 return;
30589 }
30590 if (count <= 1) {
30591 runtime.documents.delete(targetDocument);
30592 return;
30593 }
30594 runtime.documents.set(targetDocument, count - 1);
30595 };
30596 }
30597 function registerStyle24(hash, css) {
30598 const runtime = getRuntime24();
30599 runtime.styles.set(hash, css);
30600 for (const targetDocument of runtime.documents.keys()) {
30601 injectStyle24(targetDocument, hash, css);
30602 }
30603 }
30604
30605 // widgets/quick-draft/components/drafts-list/drafts-list.module.css
30606 if (typeof process === "undefined" || true) {
30607 registerStyle24("e1237767e8", "._27c1e13d297c9c75__root{flex:1;min-height:0;min-width:0;overflow:auto}._54b9ae86534218ea__titleHeader{border-top:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);padding-block-end:var(--wpds-dimension-padding-md,12px);padding-block-start:var(--wpds-dimension-padding-md,12px);padding-inline-start:var(--wpds-dimension-padding-md,12px)}._2e31af77792038af__thumbImage{object-fit:cover}._2e31af77792038af__thumbImage,.c4458e85b75cb2ca__thumbPlaceholder{border-radius:var(--wpds-border-radius-md,4px);height:100%;width:100%}.c4458e85b75cb2ca__thumbPlaceholder{align-items:center;background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:flex;justify-content:center}._30dc10ae55a67d24__titleRow{min-width:0;width:100%}.eb5556cdba7ae763__titleLink{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._41963413d9183e83__date{color:var(--wpds-color-foreground-content-neutral-weak,#707070)}");
30608 }
30609 var drafts_list_default = { "root": "_27c1e13d297c9c75__root", "titleHeader": "_54b9ae86534218ea__titleHeader", "thumbImage": "_2e31af77792038af__thumbImage", "thumbPlaceholder": "c4458e85b75cb2ca__thumbPlaceholder", "titleRow": "_30dc10ae55a67d24__titleRow", "titleLink": "eb5556cdba7ae763__titleLink", "date": "_41963413d9183e83__date" };
30610
30611 // widgets/quick-draft/components/drafts-list/drafts-list.tsx
30612 var import_jsx_runtime150 = __toESM(require_jsx_runtime());
30613 var DRAFTS_QUERY = {
30614 status: "draft",
30615 orderby: "date",
30616 order: "desc",
30617 per_page: 20,
30618 _embed: "wp:featuredmedia"
30619 };
30620 var DEFAULT_LAYOUTS2 = { list: {} };
30621 var INITIAL_VIEW = {
30622 type: "list",
30623 page: 1,
30624 perPage: DRAFTS_QUERY.per_page,
30625 search: "",
30626 filters: [],
30627 fields: [],
30628 titleField: "title",
30629 descriptionField: "date",
30630 mediaField: "featured",
30631 showMedia: true,
30632 layout: { density: "compact" }
30633 };
30634 function getEditUrl(postId) {
30635 return (0, import_url3.addQueryArgs)("post.php", { post: postId, action: "edit" });
30636 }
30637 function getThumbnailUrl(post) {
30638 const media = post._embedded?.["wp:featuredmedia"]?.[0];
30639 const sizes = media?.media_details?.sizes;
30640 return sizes?.thumbnail?.source_url ?? sizes?.medium?.source_url ?? media?.source_url;
30641 }
30642 function DraftThumbnail({ post }) {
30643 const url = getThumbnailUrl(post);
30644 if (url) {
30645 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30646 "img",
30647 {
30648 className: drafts_list_default.thumbImage,
30649 src: url,
30650 alt: "",
30651 loading: "lazy"
30652 }
30653 );
30654 }
30655 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("div", { className: drafts_list_default.thumbPlaceholder, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Icon, { icon: post_featured_image_default }) });
30656 }
30657 function DraftTitle({
30658 post,
30659 onDelete
30660 }) {
30661 const title = (0, import_html_entities.decodeEntities)(post.title?.rendered ?? "") || (0, import_i18n52.__)("(no title)");
30662 return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
30663 Stack,
30664 {
30665 direction: "row",
30666 align: "center",
30667 justify: "space-between",
30668 gap: "sm",
30669 className: drafts_list_default.titleRow,
30670 children: [
30671 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30672 Link,
30673 {
30674 href: getEditUrl(post.id),
30675 openInNewTab: true,
30676 className: drafts_list_default.titleLink,
30677 children: title
30678 }
30679 ),
30680 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30681 IconButton,
30682 {
30683 icon: trash_default,
30684 label: (0, import_i18n52.__)("Delete draft"),
30685 variant: "minimal",
30686 size: "small",
30687 onClick: () => onDelete(post.id)
30688 }
30689 )
30690 ]
30691 }
30692 );
30693 }
30694 function DraftDate({ post }) {
30695 const fullDate = (0, import_date10.dateI18n)((0, import_date10.getSettings)().formats.datetime, post.date);
30696 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30697 Text,
30698 {
30699 variant: "body-sm",
30700 className: drafts_list_default.date,
30701 render: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { title: fullDate }),
30702 children: (0, import_date10.humanTimeDiff)(post.date)
30703 }
30704 );
30705 }
30706 function DraftsList() {
30707 const [view, setView] = (0, import_element112.useState)(INITIAL_VIEW);
30708 const { drafts, isLoading } = (0, import_data6.useSelect)((select) => {
30709 const { getEntityRecords, hasFinishedResolution } = select(import_core_data.store);
30710 const records = getEntityRecords("postType", "post", DRAFTS_QUERY);
30711 return {
30712 drafts: records ?? [],
30713 isLoading: !hasFinishedResolution("getEntityRecords", [
30714 "postType",
30715 "post",
30716 DRAFTS_QUERY
30717 ])
30718 };
30719 }, []);
30720 const { deleteEntityRecord } = (0, import_data6.useDispatch)(import_core_data.store);
30721 const deleteDraft = (0, import_element112.useCallback)(
30722 (id) => {
30723 void deleteEntityRecord("postType", "post", id, void 0);
30724 },
30725 [deleteEntityRecord]
30726 );
30727 const fields = (0, import_element112.useMemo)(
30728 () => [
30729 {
30730 id: "title",
30731 label: (0, import_i18n52.__)("Title"),
30732 enableSorting: false,
30733 enableHiding: false,
30734 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(DraftTitle, { post: item, onDelete: deleteDraft })
30735 },
30736 {
30737 id: "date",
30738 label: (0, import_i18n52.__)("Date"),
30739 enableSorting: false,
30740 enableHiding: false,
30741 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(DraftDate, { post: item })
30742 },
30743 {
30744 id: "featured",
30745 label: (0, import_i18n52.__)("Featured image"),
30746 enableSorting: false,
30747 enableHiding: false,
30748 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(DraftThumbnail, { post: item })
30749 }
30750 ],
30751 [deleteDraft]
30752 );
30753 return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(Stack, { direction: "column", className: drafts_list_default.root, children: [
30754 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Text, { variant: "heading-md", className: drafts_list_default.titleHeader, children: (0, import_i18n52.__)("Your recent drafts") }),
30755 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30756 dataviews_default,
30757 {
30758 data: drafts,
30759 fields,
30760 view,
30761 onChangeView: setView,
30762 getItemId: (item) => String(item.id),
30763 isLoading,
30764 paginationInfo: { totalItems: drafts.length, totalPages: 1 },
30765 defaultLayouts: DEFAULT_LAYOUTS2,
30766 empty: /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(empty_state_exports.Root, { children: [
30767 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(empty_state_exports.Icon, { icon: drafts_default }),
30768 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(empty_state_exports.Description, { children: (0, import_i18n52.__)("No drafts yet.") })
30769 ] }),
30770 children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(dataviews_default.Layout, {})
30771 }
30772 )
30773 ] });
30774 }
30775
30776 // widgets/quick-draft/components/saved-post/saved-post.tsx
30777 var import_element113 = __toESM(require_element());
30778 var import_i18n53 = __toESM(require_i18n());
30779 var import_url4 = __toESM(require_url());
30780
30781 // widgets/quick-draft/components/saved-post/saved-post.module.css
30782 if (typeof process === "undefined" || true) {
30783 registerStyle24("985119c4a3", "._88880a636bc02513__body{height:100%}._20963e427e9696da__icon{background-color:var(--wpds-color-background-surface-success-weak,#ebffed);border-color:var(--wpds-color-stroke-surface-success,#94d29e);color:var(--wpds-color-foreground-content-success,#002900)}.ff3d1c6f8ba60167__continueLink{color:var(--wpds-color-foreground-interactive-brand-strong,#fff)}");
30784 }
30785 var saved_post_default = { "body": "_88880a636bc02513__body", "icon": "_20963e427e9696da__icon", "continueLink": "ff3d1c6f8ba60167__continueLink" };
30786
30787 // widgets/quick-draft/components/saved-post/saved-post.tsx
30788 var import_jsx_runtime151 = __toESM(require_jsx_runtime());
30789 function SavedPost({
30790 postId,
30791 postTitle,
30792 onWriteAnother
30793 }) {
30794 const editUrl = (0, import_url4.addQueryArgs)("post.php", {
30795 post: postId,
30796 action: "edit"
30797 });
30798 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
30799 Stack,
30800 {
30801 direction: "column",
30802 align: "center",
30803 justify: "center",
30804 className: saved_post_default.body,
30805 children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(empty_state_exports.Root, { children: [
30806 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(empty_state_exports.Icon, { icon: check_default, className: saved_post_default.icon }),
30807 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(empty_state_exports.Title, { children: (0, import_i18n53.__)("Draft saved") }),
30808 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(empty_state_exports.Description, { children: (0, import_element113.createInterpolateElement)(
30809 (0, import_i18n53.sprintf)(
30810 /* translators: %s: post title */
30811 (0, import_i18n53.__)(
30812 '<strong>"%s"</strong> is ready to keep editing.'
30813 ),
30814 postTitle
30815 ),
30816 {
30817 strong: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("strong", {})
30818 }
30819 ) }),
30820 /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(empty_state_exports.Actions, { children: [
30821 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
30822 Button4,
30823 {
30824 variant: "solid",
30825 size: "compact",
30826 nativeButton: false,
30827 render: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
30828 Link,
30829 {
30830 href: editUrl,
30831 openInNewTab: true,
30832 className: saved_post_default.continueLink
30833 }
30834 ),
30835 children: (0, import_i18n53.__)("Continue editing")
30836 }
30837 ),
30838 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
30839 Button4,
30840 {
30841 variant: "minimal",
30842 size: "compact",
30843 onClick: onWriteAnother,
30844 children: (0, import_i18n53.__)("Write another")
30845 }
30846 )
30847 ] })
30848 ] })
30849 }
30850 );
30851 }
30852
30853 // widgets/quick-draft/fields/quick-draft-content-field/quick-draft-content-field.tsx
30854 var import_components52 = __toESM(require_components());
30855 var import_element114 = __toESM(require_element());
30856
30857 // widgets/quick-draft/fields/quick-draft-content-field/quick-draft-content-field.module.css
30858 if (typeof process === "undefined" || true) {
30859 registerStyle24("ca3754f0d9", ".d6b34c2200336d18__root{height:100%;min-height:0}.d6b34c2200336d18__root .components-base-control,.d6b34c2200336d18__root .components-base-control__field{display:flex;flex:1;flex-direction:column;min-height:0}.d6b34c2200336d18__root .components-textarea-control__input{flex:1;min-height:0;resize:none}.dataforms-layouts-regular__field:has(.d6b34c2200336d18__root){flex:1;min-height:0}");
30860 }
30861 var quick_draft_content_field_default = { "root": "d6b34c2200336d18__root" };
30862
30863 // widgets/quick-draft/fields/quick-draft-content-field/quick-draft-content-field.tsx
30864 var import_jsx_runtime152 = __toESM(require_jsx_runtime());
30865 function getErrorMessage(validity) {
30866 if (!validity) {
30867 return void 0;
30868 }
30869 const entries = [
30870 validity.required,
30871 validity.minLength,
30872 validity.maxLength,
30873 validity.pattern,
30874 validity.custom
30875 ];
30876 const invalid = entries.find((entry) => entry?.type === "invalid");
30877 return invalid?.message;
30878 }
30879 function QuickDraftContentField({
30880 data,
30881 field,
30882 onChange,
30883 hideLabelFromVision,
30884 validity
30885 }) {
30886 const value = field.getValue({ item: data });
30887 const disabled2 = field.isDisabled({ item: data, field });
30888 const onChangeValue = (0, import_element114.useCallback)(
30889 (newValue) => onChange(field.setValue({ item: data, value: newValue })),
30890 [data, field, onChange]
30891 );
30892 const errorMessage = getErrorMessage(validity);
30893 const help = errorMessage ?? field.description;
30894 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(Stack, { direction: "column", className: quick_draft_content_field_default.root, children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
30895 import_components52.TextareaControl,
30896 {
30897 label: field.label,
30898 hideLabelFromVision,
30899 value: value ?? "",
30900 placeholder: field.placeholder,
30901 help,
30902 onChange: onChangeValue,
30903 disabled: disabled2,
30904 rows: 4
30905 }
30906 ) });
30907 }
30908
30909 // widgets/quick-draft/hooks/use-widget-size/use-widget-size.ts
30910 var import_compose17 = __toESM(require_compose());
30911 var import_element115 = __toESM(require_element());
30912 var WIDE_MIN_WIDTH = 560;
30913 var TALL_MIN_HEIGHT = 420;
30914 var INITIAL_SIZE = { width: 0, height: 0 };
30915 function useWidgetSize() {
30916 const [size4, setSize] = (0, import_element115.useState)(INITIAL_SIZE);
30917 const ref = (0, import_compose17.useResizeObserver)(
30918 (entries) => {
30919 const entry = entries[0];
30920 if (!entry) {
30921 return;
30922 }
30923 const box = entry.borderBoxSize?.[0];
30924 const width = box ? box.inlineSize : entry.contentRect.width;
30925 const height = box ? box.blockSize : entry.contentRect.height;
30926 setSize(
30927 (prev) => prev.width === width && prev.height === height ? prev : { width, height }
30928 );
30929 },
30930 { box: "border-box" }
30931 );
30932 return (0, import_element115.useMemo)(
30933 () => ({
30934 ref,
30935 width: size4.width,
30936 height: size4.height,
30937 isWide: size4.width >= WIDE_MIN_WIDTH,
30938 isTall: size4.height >= TALL_MIN_HEIGHT
30939 }),
30940 [ref, size4.width, size4.height]
30941 );
30942 }
30943
30944 // widgets/quick-draft/style.module.css
30945 if (typeof process === "undefined" || true) {
30946 registerStyle24("eb62be714d", "._1ceea6985c028257__body,.e95823d50a99f185__fill{height:100%}._0325357a2c3b57a4__primaryPane{border-top:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);flex:1;min-height:0;min-width:0;padding:var(--wpds-dimension-padding-lg,16px)}._20004de4c12366b1__listPane{flex:1;min-height:0;min-width:0}._809476aa1889889d__backRow{border-top:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);padding:var(--wpds-dimension-padding-sm,8px)}._264d0da8d26b736f__row ._0325357a2c3b57a4__primaryPane{border-inline-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);margin:0 auto;max-width:var(--wpds-dimension-surface-width-md,400px)}._6b9679a01ecee959__formContainer,._6b9679a01ecee959__formContainer>.dataforms-layouts__wrapper{flex:1;min-height:0}");
30947 }
30948 var style_default23 = { "body": "_1ceea6985c028257__body", "fill": "e95823d50a99f185__fill", "primaryPane": "_0325357a2c3b57a4__primaryPane", "listPane": "_20004de4c12366b1__listPane", "backRow": "_809476aa1889889d__backRow", "row": "_264d0da8d26b736f__row", "formContainer": "_6b9679a01ecee959__formContainer" };
30949
30950 // widgets/quick-draft/render.tsx
30951 var import_jsx_runtime153 = __toESM(require_jsx_runtime());
30952 function textToParagraphBlocks(text) {
30953 if (!text.trim()) {
30954 return "";
30955 }
30956 return (0, import_autop.autop)((0, import_escape_html.escapeHTML)(text)).replace(
30957 /<p>([\s\S]*?)<\/p>/g,
30958 "<!-- wp:paragraph -->\n<p>$1</p>\n<!-- /wp:paragraph -->"
30959 );
30960 }
30961 var FORM = {
30962 layout: { type: "regular" },
30963 fields: ["title", "content"]
30964 };
30965 var INITIAL_DATA = {
30966 title: "",
30967 content: ""
30968 };
30969 function QuickDraft() {
30970 const [data, setData] = (0, import_element116.useState)(INITIAL_DATA);
30971 const [isSaving, setIsSaving] = (0, import_element116.useState)(false);
30972 const [createdPost, setCreatedPost] = (0, import_element116.useState)(null);
30973 const [isListOpenInCompact, setIsListOpenInCompact] = (0, import_element116.useState)(false);
30974 const { ref, isWide, isTall } = useWidgetSize();
30975 const showDraftsList = isWide || isTall;
30976 const listBeside = isWide;
30977 const { saveEntityRecord } = (0, import_data7.useDispatch)(import_core_data2.store);
30978 const { hasDrafts } = (0, import_data7.useSelect)(
30979 (select) => {
30980 if (showDraftsList) {
30981 return { hasDrafts: false };
30982 }
30983 const { getEntityRecords } = select(import_core_data2.store);
30984 const anyDrafts = getEntityRecords("postType", "post", {
30985 status: "draft",
30986 per_page: 1
30987 });
30988 return { hasDrafts: (anyDrafts?.length ?? 0) > 0 };
30989 },
30990 [showDraftsList]
30991 );
30992 const fields = (0, import_element116.useMemo)(
30993 () => [
30994 {
30995 id: "title",
30996 type: "text",
30997 label: (0, import_i18n54.__)("Title"),
30998 isValid: { required: true, minLength: 3 },
30999 hideLabelFromVision: true,
31000 help: (0, import_i18n54.__)("Enter a title for your post.")
31001 },
31002 {
31003 id: "content",
31004 type: "text",
31005 label: (0, import_i18n54.__)("Content"),
31006 isValid: { required: true, minLength: 10 },
31007 Edit: QuickDraftContentField,
31008 help: (0, import_i18n54.__)("Enter the content for your post.")
31009 }
31010 ],
31011 []
31012 );
31013 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, FORM);
31014 const canSave = isValid2 && !isSaving;
31015 const saveDraftPost = async () => {
31016 if (!canSave) {
31017 return;
31018 }
31019 setIsSaving(true);
31020 try {
31021 const saved = await saveEntityRecord("postType", "post", {
31022 title: data.title,
31023 content: textToParagraphBlocks(data.content),
31024 status: "draft"
31025 });
31026 const newId = saved?.id;
31027 if (typeof newId === "number") {
31028 setCreatedPost({ id: newId, title: data.title });
31029 }
31030 setData(INITIAL_DATA);
31031 } finally {
31032 setIsSaving(false);
31033 }
31034 };
31035 const writeAnother = () => {
31036 setCreatedPost(null);
31037 };
31038 let primary;
31039 if (createdPost !== null) {
31040 primary = /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31041 SavedPost,
31042 {
31043 postId: createdPost.id,
31044 postTitle: createdPost.title,
31045 onWriteAnother: writeAnother
31046 }
31047 );
31048 } else {
31049 primary = /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
31050 Stack,
31051 {
31052 direction: "column",
31053 gap: "md",
31054 justify: "space-between",
31055 className: style_default23.fill,
31056 children: [
31057 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { direction: "column", className: style_default23.formContainer, children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31058 DataForm,
31059 {
31060 data,
31061 fields,
31062 form: FORM,
31063 validity,
31064 onChange: (edits) => setData((prev) => ({ ...prev, ...edits }))
31065 }
31066 ) }),
31067 /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(Stack, { direction: "row", gap: "md", justify: "flex-start", children: [
31068 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31069 Button4,
31070 {
31071 variant: "solid",
31072 onClick: saveDraftPost,
31073 loading: isSaving,
31074 disabled: !canSave,
31075 children: (0, import_i18n54.__)("Save as draft")
31076 }
31077 ),
31078 !showDraftsList && hasDrafts && /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
31079 Button4,
31080 {
31081 variant: "minimal",
31082 onClick: () => setIsListOpenInCompact(true),
31083 children: [
31084 (0, import_i18n54.__)("Draft posts"),
31085 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Button4.Icon, { icon: chevron_right_default })
31086 ]
31087 }
31088 )
31089 ] })
31090 ]
31091 }
31092 );
31093 }
31094 if (!showDraftsList && isListOpenInCompact) {
31095 return /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(Stack, { ref, direction: "column", className: style_default23.body, children: [
31096 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { direction: "column", className: style_default23.listPane, children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(DraftsList, {}) }),
31097 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31098 Stack,
31099 {
31100 direction: "row",
31101 justify: "flex-start",
31102 className: style_default23.backRow,
31103 children: /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
31104 Button4,
31105 {
31106 variant: "minimal",
31107 tone: "neutral",
31108 size: "compact",
31109 onClick: () => setIsListOpenInCompact(false),
31110 children: [
31111 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Button4.Icon, { icon: chevron_left_default }),
31112 (0, import_i18n54.__)("Back")
31113 ]
31114 }
31115 )
31116 }
31117 )
31118 ] });
31119 }
31120 if (!showDraftsList) {
31121 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { ref, direction: "column", className: style_default23.body, children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { direction: "column", className: style_default23.primaryPane, children: primary }) });
31122 }
31123 return /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
31124 Stack,
31125 {
31126 ref,
31127 direction: listBeside ? "row" : "column",
31128 className: clsx_default(
31129 style_default23.body,
31130 listBeside ? style_default23.row : style_default23.column
31131 ),
31132 children: [
31133 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { direction: "column", className: style_default23.primaryPane, children: primary }),
31134 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Stack, { direction: "column", className: style_default23.listPane, children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(DraftsList, {}) })
31135 ]
31136 }
31137 );
31138 }
31139 export {
31140 QuickDraft as default
31141 };
31142 /*! Bundled license information:
31143
31144 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
31145 (**
31146 * @license React
31147 * use-sync-external-store-shim.development.js
31148 *
31149 * Copyright (c) Meta Platforms, Inc. and affiliates.
31150 *
31151 * This source code is licensed under the MIT license found in the
31152 * LICENSE file in the root directory of this source tree.
31153 *)
31154
31155 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
31156 (**
31157 * @license React
31158 * use-sync-external-store-shim/with-selector.development.js
31159 *
31160 * Copyright (c) Meta Platforms, Inc. and affiliates.
31161 *
31162 * This source code is licensed under the MIT license found in the
31163 * LICENSE file in the root directory of this source tree.
31164 *)
31165 */
31166