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

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

32,162 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 = useState48({
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 useEffect41(
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, useState48 = React60.useState, useEffect41 = 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, useRef57 = React60.useRef, useEffect41 = React60.useEffect, useMemo54 = React60.useMemo, useDebugValue2 = React60.useDebugValue;
173 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
174 var instRef = useRef57(null);
175 if (null === instRef.current) {
176 var inst = { hasValue: false, value: null };
177 instRef.current = inst;
178 } else inst = instRef.current;
179 instRef = useMemo54(
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 useEffect41(
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 // package-external:@wordpress/rich-text
837 var require_rich_text = __commonJS({
838 "package-external:@wordpress/rich-text"(exports, module) {
839 module.exports = window.wp.richText;
840 }
841 });
842
843 // node_modules/deepmerge/dist/cjs.js
844 var require_cjs = __commonJS({
845 "node_modules/deepmerge/dist/cjs.js"(exports, module) {
846 "use strict";
847 var isMergeableObject = function isMergeableObject2(value) {
848 return isNonNullObject(value) && !isSpecial(value);
849 };
850 function isNonNullObject(value) {
851 return !!value && typeof value === "object";
852 }
853 function isSpecial(value) {
854 var stringValue = Object.prototype.toString.call(value);
855 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
856 }
857 var canUseSymbol = typeof Symbol === "function" && Symbol.for;
858 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
859 function isReactElement(value) {
860 return value.$$typeof === REACT_ELEMENT_TYPE;
861 }
862 function emptyTarget(val) {
863 return Array.isArray(val) ? [] : {};
864 }
865 function cloneUnlessOtherwiseSpecified(value, options) {
866 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
867 }
868 function defaultArrayMerge(target, source, options) {
869 return target.concat(source).map(function(element) {
870 return cloneUnlessOtherwiseSpecified(element, options);
871 });
872 }
873 function getMergeFunction(key, options) {
874 if (!options.customMerge) {
875 return deepmerge;
876 }
877 var customMerge = options.customMerge(key);
878 return typeof customMerge === "function" ? customMerge : deepmerge;
879 }
880 function getEnumerableOwnPropertySymbols(target) {
881 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) {
882 return Object.propertyIsEnumerable.call(target, symbol3);
883 }) : [];
884 }
885 function getKeys2(target) {
886 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
887 }
888 function propertyIsOnObject(object, property) {
889 try {
890 return property in object;
891 } catch (_) {
892 return false;
893 }
894 }
895 function propertyIsUnsafe(target, key) {
896 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
897 }
898 function mergeObject(target, source, options) {
899 var destination = {};
900 if (options.isMergeableObject(target)) {
901 getKeys2(target).forEach(function(key) {
902 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
903 });
904 }
905 getKeys2(source).forEach(function(key) {
906 if (propertyIsUnsafe(target, key)) {
907 return;
908 }
909 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
910 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
911 } else {
912 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
913 }
914 });
915 return destination;
916 }
917 function deepmerge(target, source, options) {
918 options = options || {};
919 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
920 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
921 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
922 var sourceIsArray = Array.isArray(source);
923 var targetIsArray = Array.isArray(target);
924 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
925 if (!sourceAndTargetTypesMatch) {
926 return cloneUnlessOtherwiseSpecified(source, options);
927 } else if (sourceIsArray) {
928 return options.arrayMerge(target, source, options);
929 } else {
930 return mergeObject(target, source, options);
931 }
932 }
933 deepmerge.all = function deepmergeAll(array, options) {
934 if (!Array.isArray(array)) {
935 throw new Error("first argument should be an array");
936 }
937 return array.reduce(function(prev, next) {
938 return deepmerge(prev, next, options);
939 }, {});
940 };
941 var deepmerge_1 = deepmerge;
942 module.exports = deepmerge_1;
943 }
944 });
945
946 // package-external:@wordpress/escape-html
947 var require_escape_html = __commonJS({
948 "package-external:@wordpress/escape-html"(exports, module) {
949 module.exports = window.wp.escapeHtml;
950 }
951 });
952
953 // package-external:@wordpress/html-entities
954 var require_html_entities = __commonJS({
955 "package-external:@wordpress/html-entities"(exports, module) {
956 module.exports = window.wp.htmlEntities;
957 }
958 });
959
960 // package-external:@wordpress/url
961 var require_url = __commonJS({
962 "package-external:@wordpress/url"(exports, module) {
963 module.exports = window.wp.url;
964 }
965 });
966
967 // node_modules/clsx/dist/clsx.mjs
968 function r(e2) {
969 var t2, f2, n2 = "";
970 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
971 else if ("object" == typeof e2) if (Array.isArray(e2)) {
972 var o2 = e2.length;
973 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
974 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
975 return n2;
976 }
977 function clsx() {
978 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
979 return n2;
980 }
981 var clsx_default = clsx;
982
983 // widgets/quick-draft/render.tsx
984 var import_autop = __toESM(require_autop());
985 var import_core_data2 = __toESM(require_core_data());
986 var import_data7 = __toESM(require_data());
987
988 // packages/dataviews/build-module/dataviews/index.mjs
989 var import_element102 = __toESM(require_element(), 1);
990 var import_compose14 = __toESM(require_compose(), 1);
991
992 // packages/ui/build-module/badge/badge.mjs
993 var import_element11 = __toESM(require_element(), 1);
994
995 // node_modules/@base-ui/utils/useControlled.mjs
996 var React = __toESM(require_react(), 1);
997
998 // node_modules/@base-ui/utils/error.mjs
999 var set;
1000 if (true) {
1001 set = /* @__PURE__ */ new Set();
1002 }
1003 function error(...messages) {
1004 if (true) {
1005 const messageKey = messages.join(" ");
1006 if (!set.has(messageKey)) {
1007 set.add(messageKey);
1008 console.error(`Base UI: ${messageKey}`);
1009 }
1010 }
1011 }
1012
1013 // node_modules/@base-ui/utils/useControlled.mjs
1014 function useControlled({
1015 controlled,
1016 default: defaultProp,
1017 name,
1018 state = "value"
1019 }) {
1020 const {
1021 current: isControlled
1022 } = React.useRef(controlled !== void 0);
1023 const [valueState, setValue] = React.useState(defaultProp);
1024 const value = isControlled ? controlled : valueState;
1025 if (true) {
1026 React.useEffect(() => {
1027 if (isControlled !== (controlled !== void 0)) {
1028 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"));
1029 }
1030 }, [state, name, controlled]);
1031 const {
1032 current: defaultValue2
1033 } = React.useRef(defaultProp);
1034 React.useEffect(() => {
1035 if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) {
1036 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"));
1037 }
1038 }, [defaultProp]);
1039 }
1040 const setValueIfUncontrolled = React.useCallback((newValue) => {
1041 if (!isControlled) {
1042 setValue(newValue);
1043 }
1044 }, []);
1045 return [value, setValueIfUncontrolled];
1046 }
1047 function serializeToDevModeString(input) {
1048 let nextId = 0;
1049 const seen = /* @__PURE__ */ new WeakMap();
1050 try {
1051 const result = JSON.stringify(input, function replacer(key, value) {
1052 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) {
1053 return void 0;
1054 }
1055 if (typeof value === "bigint") {
1056 return `__bigint__:${value}`;
1057 }
1058 if (value !== null && typeof value === "object") {
1059 const id = seen.get(value);
1060 if (id !== void 0) {
1061 return `__object__:${id}`;
1062 }
1063 seen.set(value, nextId);
1064 nextId += 1;
1065 }
1066 return value;
1067 });
1068 return result ?? `__top__:${typeof input}`;
1069 } catch {
1070 return "__unserializable__";
1071 }
1072 }
1073
1074 // node_modules/@base-ui/utils/safeReact.mjs
1075 var React2 = __toESM(require_react(), 1);
1076 var SafeReact = {
1077 ...React2
1078 };
1079
1080 // node_modules/@base-ui/utils/useRefWithInit.mjs
1081 var React3 = __toESM(require_react(), 1);
1082 var UNINITIALIZED = {};
1083 function useRefWithInit(init2, initArg) {
1084 const ref = React3.useRef(UNINITIALIZED);
1085 if (ref.current === UNINITIALIZED) {
1086 ref.current = init2(initArg);
1087 }
1088 return ref;
1089 }
1090
1091 // node_modules/@base-ui/utils/useStableCallback.mjs
1092 var useInsertionEffect = SafeReact.useInsertionEffect;
1093 var useSafeInsertionEffect = (
1094 // React 17 doesn't have useInsertionEffect.
1095 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1096 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1097 );
1098 function useStableCallback(callback) {
1099 const stable = useRefWithInit(createStableCallback).current;
1100 stable.next = callback;
1101 useSafeInsertionEffect(stable.effect);
1102 return stable.trampoline;
1103 }
1104 function createStableCallback() {
1105 const stable = {
1106 next: void 0,
1107 callback: assertNotCalled,
1108 trampoline: (...args) => stable.callback?.(...args),
1109 effect: () => {
1110 stable.callback = stable.next;
1111 }
1112 };
1113 return stable;
1114 }
1115 function assertNotCalled() {
1116 if (true) {
1117 throw (
1118 /* minify-error-disabled */
1119 new Error("Base UI: Cannot call an event handler while rendering.")
1120 );
1121 }
1122 }
1123
1124 // node_modules/@base-ui/utils/useIsoLayoutEffect.mjs
1125 var React4 = __toESM(require_react(), 1);
1126 var noop = () => {
1127 };
1128 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
1129
1130 // node_modules/@base-ui/utils/warn.mjs
1131 var set2;
1132 if (true) {
1133 set2 = /* @__PURE__ */ new Set();
1134 }
1135 function warn(...messages) {
1136 if (true) {
1137 const messageKey = messages.join(" ");
1138 if (!set2.has(messageKey)) {
1139 set2.add(messageKey);
1140 console.warn(`Base UI: ${messageKey}`);
1141 }
1142 }
1143 }
1144
1145 // node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs
1146 var React5 = __toESM(require_react(), 1);
1147 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
1148 if (true) DirectionContext.displayName = "DirectionContext";
1149 function useDirection() {
1150 const context = React5.useContext(DirectionContext);
1151 return context?.direction ?? "ltr";
1152 }
1153
1154 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1155 var React8 = __toESM(require_react(), 1);
1156
1157 // node_modules/@base-ui/utils/useMergedRefs.mjs
1158 function useMergedRefs(a2, b2, c2, d2) {
1159 const forkRef = useRefWithInit(createForkRef).current;
1160 if (didChange(forkRef, a2, b2, c2, d2)) {
1161 update(forkRef, [a2, b2, c2, d2]);
1162 }
1163 return forkRef.callback;
1164 }
1165 function useMergedRefsN(refs) {
1166 const forkRef = useRefWithInit(createForkRef).current;
1167 if (didChangeN(forkRef, refs)) {
1168 update(forkRef, refs);
1169 }
1170 return forkRef.callback;
1171 }
1172 function createForkRef() {
1173 return {
1174 callback: null,
1175 cleanup: null,
1176 refs: []
1177 };
1178 }
1179 function didChange(forkRef, a2, b2, c2, d2) {
1180 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1181 }
1182 function didChangeN(forkRef, newRefs) {
1183 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1184 }
1185 function update(forkRef, refs) {
1186 forkRef.refs = refs;
1187 if (refs.every((ref) => ref == null)) {
1188 forkRef.callback = null;
1189 return;
1190 }
1191 forkRef.callback = (instance) => {
1192 if (forkRef.cleanup) {
1193 forkRef.cleanup();
1194 forkRef.cleanup = null;
1195 }
1196 if (instance != null) {
1197 const cleanupCallbacks = Array(refs.length).fill(null);
1198 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1199 const ref = refs[i2];
1200 if (ref == null) {
1201 continue;
1202 }
1203 switch (typeof ref) {
1204 case "function": {
1205 const refCleanup = ref(instance);
1206 if (typeof refCleanup === "function") {
1207 cleanupCallbacks[i2] = refCleanup;
1208 }
1209 break;
1210 }
1211 case "object": {
1212 ref.current = instance;
1213 break;
1214 }
1215 default:
1216 }
1217 }
1218 forkRef.cleanup = () => {
1219 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1220 const ref = refs[i2];
1221 if (ref == null) {
1222 continue;
1223 }
1224 switch (typeof ref) {
1225 case "function": {
1226 const cleanupCallback = cleanupCallbacks[i2];
1227 if (typeof cleanupCallback === "function") {
1228 cleanupCallback();
1229 } else {
1230 ref(null);
1231 }
1232 break;
1233 }
1234 case "object": {
1235 ref.current = null;
1236 break;
1237 }
1238 default:
1239 }
1240 }
1241 };
1242 }
1243 };
1244 }
1245
1246 // node_modules/@base-ui/utils/getReactElementRef.mjs
1247 var React7 = __toESM(require_react(), 1);
1248
1249 // node_modules/@base-ui/utils/reactVersion.mjs
1250 var React6 = __toESM(require_react(), 1);
1251 var majorVersion = parseInt(React6.version, 10);
1252 function isReactVersionAtLeast(reactVersionToCheck) {
1253 return majorVersion >= reactVersionToCheck;
1254 }
1255
1256 // node_modules/@base-ui/utils/getReactElementRef.mjs
1257 function getReactElementRef(element) {
1258 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1259 return null;
1260 }
1261 const reactElement = element;
1262 const propsWithRef = reactElement.props;
1263 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1264 }
1265
1266 // node_modules/@base-ui/utils/mergeObjects.mjs
1267 function mergeObjects(a2, b2) {
1268 if (a2 && !b2) {
1269 return a2;
1270 }
1271 if (!a2 && b2) {
1272 return b2;
1273 }
1274 if (a2 || b2) {
1275 return {
1276 ...a2,
1277 ...b2
1278 };
1279 }
1280 return void 0;
1281 }
1282
1283 // node_modules/@base-ui/utils/empty.mjs
1284 function NOOP() {
1285 }
1286 var EMPTY_ARRAY = Object.freeze([]);
1287 var EMPTY_OBJECT = Object.freeze({});
1288
1289 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
1290 function getStateAttributesProps(state, customMapping) {
1291 const props = {};
1292 for (const key in state) {
1293 const value = state[key];
1294 if (customMapping?.hasOwnProperty(key)) {
1295 const customProps = customMapping[key](value);
1296 if (customProps != null) {
1297 Object.assign(props, customProps);
1298 }
1299 continue;
1300 }
1301 if (value === true) {
1302 props[`data-${key.toLowerCase()}`] = "";
1303 } else if (value) {
1304 props[`data-${key.toLowerCase()}`] = value.toString();
1305 }
1306 }
1307 return props;
1308 }
1309
1310 // node_modules/@base-ui/react/utils/resolveClassName.mjs
1311 function resolveClassName(className, state) {
1312 return typeof className === "function" ? className(state) : className;
1313 }
1314
1315 // node_modules/@base-ui/react/utils/resolveStyle.mjs
1316 function resolveStyle(style, state) {
1317 return typeof style === "function" ? style(state) : style;
1318 }
1319
1320 // node_modules/@base-ui/react/merge-props/mergeProps.mjs
1321 var EMPTY_PROPS = {};
1322 function mergeProps(a2, b2, c2, d2, e2) {
1323 if (!c2 && !d2 && !e2 && !a2) {
1324 return createInitialMergedProps(b2);
1325 }
1326 let merged = createInitialMergedProps(a2);
1327 if (b2) {
1328 merged = mergeInto(merged, b2);
1329 }
1330 if (c2) {
1331 merged = mergeInto(merged, c2);
1332 }
1333 if (d2) {
1334 merged = mergeInto(merged, d2);
1335 }
1336 if (e2) {
1337 merged = mergeInto(merged, e2);
1338 }
1339 return merged;
1340 }
1341 function mergePropsN(props) {
1342 if (props.length === 0) {
1343 return EMPTY_PROPS;
1344 }
1345 if (props.length === 1) {
1346 return createInitialMergedProps(props[0]);
1347 }
1348 let merged = createInitialMergedProps(props[0]);
1349 for (let i2 = 1; i2 < props.length; i2 += 1) {
1350 merged = mergeInto(merged, props[i2]);
1351 }
1352 return merged;
1353 }
1354 function createInitialMergedProps(inputProps) {
1355 if (isPropsGetter(inputProps)) {
1356 return {
1357 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1358 };
1359 }
1360 return copyInitialProps(inputProps);
1361 }
1362 function mergeInto(merged, inputProps) {
1363 if (isPropsGetter(inputProps)) {
1364 return resolvePropsGetter(inputProps, merged);
1365 }
1366 return mutablyMergeInto(merged, inputProps);
1367 }
1368 function copyInitialProps(inputProps) {
1369 const copiedProps = {
1370 ...inputProps
1371 };
1372 for (const propName in copiedProps) {
1373 const propValue = copiedProps[propName];
1374 if (isEventHandler(propName, propValue)) {
1375 copiedProps[propName] = wrapEventHandler(propValue);
1376 }
1377 }
1378 return copiedProps;
1379 }
1380 function mutablyMergeInto(mergedProps, externalProps) {
1381 if (!externalProps) {
1382 return mergedProps;
1383 }
1384 for (const propName in externalProps) {
1385 const externalPropValue = externalProps[propName];
1386 switch (propName) {
1387 case "style": {
1388 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1389 break;
1390 }
1391 case "className": {
1392 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1393 break;
1394 }
1395 default: {
1396 if (isEventHandler(propName, externalPropValue)) {
1397 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1398 } else {
1399 mergedProps[propName] = externalPropValue;
1400 }
1401 }
1402 }
1403 }
1404 return mergedProps;
1405 }
1406 function isEventHandler(key, value) {
1407 const code0 = key.charCodeAt(0);
1408 const code1 = key.charCodeAt(1);
1409 const code2 = key.charCodeAt(2);
1410 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1411 }
1412 function isPropsGetter(inputProps) {
1413 return typeof inputProps === "function";
1414 }
1415 function resolvePropsGetter(inputProps, previousProps) {
1416 if (isPropsGetter(inputProps)) {
1417 return inputProps(previousProps);
1418 }
1419 return inputProps ?? EMPTY_PROPS;
1420 }
1421 function mergeEventHandlers(ourHandler, theirHandler) {
1422 if (!theirHandler) {
1423 return ourHandler;
1424 }
1425 if (!ourHandler) {
1426 return wrapEventHandler(theirHandler);
1427 }
1428 return (...args) => {
1429 const event = args[0];
1430 if (isSyntheticEvent(event)) {
1431 const baseUIEvent = event;
1432 makeEventPreventable(baseUIEvent);
1433 const result2 = theirHandler(...args);
1434 if (!baseUIEvent.baseUIHandlerPrevented) {
1435 ourHandler?.(...args);
1436 }
1437 return result2;
1438 }
1439 const result = theirHandler(...args);
1440 ourHandler?.(...args);
1441 return result;
1442 };
1443 }
1444 function wrapEventHandler(handler) {
1445 if (!handler) {
1446 return handler;
1447 }
1448 return (...args) => {
1449 const event = args[0];
1450 if (isSyntheticEvent(event)) {
1451 makeEventPreventable(event);
1452 }
1453 return handler(...args);
1454 };
1455 }
1456 function makeEventPreventable(event) {
1457 event.preventBaseUIHandler = () => {
1458 event.baseUIHandlerPrevented = true;
1459 };
1460 return event;
1461 }
1462 function mergeClassNames(ourClassName, theirClassName) {
1463 if (theirClassName) {
1464 if (ourClassName) {
1465 return theirClassName + " " + ourClassName;
1466 }
1467 return theirClassName;
1468 }
1469 return ourClassName;
1470 }
1471 function isSyntheticEvent(event) {
1472 return event != null && typeof event === "object" && "nativeEvent" in event;
1473 }
1474
1475 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1476 var import_react = __toESM(require_react(), 1);
1477 function useRenderElement(element, componentProps, params = {}) {
1478 const renderProp = componentProps.render;
1479 const outProps = useRenderElementProps(componentProps, params);
1480 if (params.enabled === false) {
1481 return null;
1482 }
1483 const state = params.state ?? EMPTY_OBJECT;
1484 return evaluateRenderProp(element, renderProp, outProps, state);
1485 }
1486 function useRenderElementProps(componentProps, params = {}) {
1487 const {
1488 className: classNameProp,
1489 style: styleProp,
1490 render: renderProp
1491 } = componentProps;
1492 const {
1493 state = EMPTY_OBJECT,
1494 ref,
1495 props,
1496 stateAttributesMapping: stateAttributesMapping4,
1497 enabled = true
1498 } = params;
1499 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1500 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1501 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping4) : EMPTY_OBJECT;
1502 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1503 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1504 if (typeof document !== "undefined") {
1505 if (!enabled) {
1506 useMergedRefs(null, null);
1507 } else if (Array.isArray(ref)) {
1508 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1509 } else {
1510 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1511 }
1512 }
1513 if (!enabled) {
1514 return EMPTY_OBJECT;
1515 }
1516 if (className !== void 0) {
1517 outProps.className = mergeClassNames(outProps.className, className);
1518 }
1519 if (style !== void 0) {
1520 outProps.style = mergeObjects(outProps.style, style);
1521 }
1522 return outProps;
1523 }
1524 function resolveRenderFunctionProps(props) {
1525 if (Array.isArray(props)) {
1526 return mergePropsN(props);
1527 }
1528 return mergeProps(void 0, props);
1529 }
1530 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1531 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1532 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1533 function evaluateRenderProp(element, render4, props, state) {
1534 if (render4) {
1535 if (typeof render4 === "function") {
1536 if (true) {
1537 warnIfRenderPropLooksLikeComponent(render4);
1538 }
1539 return render4(props, state);
1540 }
1541 const mergedProps = mergeProps(props, render4.props);
1542 mergedProps.ref = props.ref;
1543 let newElement = render4;
1544 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1545 const children = React8.Children.toArray(render4);
1546 newElement = children[0];
1547 }
1548 if (true) {
1549 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1550 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"));
1551 }
1552 }
1553 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1554 }
1555 if (element) {
1556 if (typeof element === "string") {
1557 return renderTag(element, props);
1558 }
1559 }
1560 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1561 }
1562 function warnIfRenderPropLooksLikeComponent(renderFn) {
1563 const functionName = renderFn.name;
1564 if (functionName.length === 0) {
1565 return;
1566 }
1567 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1568 return;
1569 }
1570 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1571 return;
1572 }
1573 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");
1574 }
1575 function renderTag(Tag, props) {
1576 if (Tag === "button") {
1577 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1578 type: "button",
1579 ...props,
1580 key: props.key
1581 });
1582 }
1583 if (Tag === "img") {
1584 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1585 alt: "",
1586 ...props,
1587 key: props.key
1588 });
1589 }
1590 return /* @__PURE__ */ React8.createElement(Tag, props);
1591 }
1592
1593 // node_modules/@base-ui/utils/useId.mjs
1594 var React9 = __toESM(require_react(), 1);
1595 var globalId = 0;
1596 function useGlobalId(idOverride, prefix = "mui") {
1597 const [defaultId, setDefaultId] = React9.useState(idOverride);
1598 const id = idOverride || defaultId;
1599 React9.useEffect(() => {
1600 if (defaultId == null) {
1601 globalId += 1;
1602 setDefaultId(`${prefix}-${globalId}`);
1603 }
1604 }, [defaultId, prefix]);
1605 return id;
1606 }
1607 var maybeReactUseId = SafeReact.useId;
1608 function useId(idOverride, prefix) {
1609 if (maybeReactUseId !== void 0) {
1610 const reactId = maybeReactUseId();
1611 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1612 }
1613 return useGlobalId(idOverride, prefix);
1614 }
1615
1616 // node_modules/@base-ui/react/internals/useBaseUiId.mjs
1617 function useBaseUiId(idOverride) {
1618 return useId(idOverride, "base-ui");
1619 }
1620
1621 // node_modules/@base-ui/react/collapsible/root/useCollapsibleRoot.mjs
1622 var React12 = __toESM(require_react(), 1);
1623
1624 // node_modules/@base-ui/react/internals/reason-parts.mjs
1625 var reason_parts_exports = {};
1626 __export(reason_parts_exports, {
1627 cancelOpen: () => cancelOpen,
1628 chipRemovePress: () => chipRemovePress,
1629 clearPress: () => clearPress,
1630 closePress: () => closePress,
1631 closeWatcher: () => closeWatcher,
1632 decrementPress: () => decrementPress,
1633 disabled: () => disabled,
1634 drag: () => drag,
1635 escapeKey: () => escapeKey,
1636 focusOut: () => focusOut,
1637 imperativeAction: () => imperativeAction,
1638 incrementPress: () => incrementPress,
1639 initial: () => initial,
1640 inputBlur: () => inputBlur,
1641 inputChange: () => inputChange,
1642 inputClear: () => inputClear,
1643 inputPaste: () => inputPaste,
1644 inputPress: () => inputPress,
1645 itemPress: () => itemPress,
1646 keyboard: () => keyboard,
1647 linkPress: () => linkPress,
1648 listNavigation: () => listNavigation,
1649 missing: () => missing,
1650 none: () => none,
1651 outsidePress: () => outsidePress,
1652 pointer: () => pointer,
1653 scrub: () => scrub,
1654 siblingOpen: () => siblingOpen,
1655 swipe: () => swipe,
1656 trackPress: () => trackPress,
1657 triggerFocus: () => triggerFocus,
1658 triggerHover: () => triggerHover,
1659 triggerPress: () => triggerPress,
1660 wheel: () => wheel,
1661 windowResize: () => windowResize
1662 });
1663 var none = "none";
1664 var triggerPress = "trigger-press";
1665 var triggerHover = "trigger-hover";
1666 var triggerFocus = "trigger-focus";
1667 var outsidePress = "outside-press";
1668 var itemPress = "item-press";
1669 var closePress = "close-press";
1670 var linkPress = "link-press";
1671 var clearPress = "clear-press";
1672 var chipRemovePress = "chip-remove-press";
1673 var trackPress = "track-press";
1674 var incrementPress = "increment-press";
1675 var decrementPress = "decrement-press";
1676 var inputChange = "input-change";
1677 var inputClear = "input-clear";
1678 var inputBlur = "input-blur";
1679 var inputPaste = "input-paste";
1680 var inputPress = "input-press";
1681 var focusOut = "focus-out";
1682 var escapeKey = "escape-key";
1683 var closeWatcher = "close-watcher";
1684 var listNavigation = "list-navigation";
1685 var keyboard = "keyboard";
1686 var pointer = "pointer";
1687 var drag = "drag";
1688 var wheel = "wheel";
1689 var scrub = "scrub";
1690 var cancelOpen = "cancel-open";
1691 var siblingOpen = "sibling-open";
1692 var disabled = "disabled";
1693 var missing = "missing";
1694 var initial = "initial";
1695 var imperativeAction = "imperative-action";
1696 var swipe = "swipe";
1697 var windowResize = "window-resize";
1698
1699 // node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs
1700 function createChangeEventDetails(reason, event, trigger, customProperties) {
1701 let canceled = false;
1702 let allowPropagation = false;
1703 const custom = customProperties ?? EMPTY_OBJECT;
1704 const details = {
1705 reason,
1706 event: event ?? new Event("base-ui"),
1707 cancel() {
1708 canceled = true;
1709 },
1710 allowPropagation() {
1711 allowPropagation = true;
1712 },
1713 get isCanceled() {
1714 return canceled;
1715 },
1716 get isPropagationAllowed() {
1717 return allowPropagation;
1718 },
1719 trigger,
1720 ...custom
1721 };
1722 return details;
1723 }
1724
1725 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1726 var React11 = __toESM(require_react(), 1);
1727
1728 // node_modules/@base-ui/utils/useOnMount.mjs
1729 var React10 = __toESM(require_react(), 1);
1730 var EMPTY = [];
1731 function useOnMount(fn) {
1732 React10.useEffect(fn, EMPTY);
1733 }
1734
1735 // node_modules/@base-ui/utils/useAnimationFrame.mjs
1736 var EMPTY2 = null;
1737 var LAST_RAF = globalThis.requestAnimationFrame;
1738 var Scheduler = class {
1739 /* This implementation uses an array as a backing data-structure for frame callbacks.
1740 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1741 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1742 * be much more efficient if there is a call pattern that alterns as
1743 * "request-cancel-request-cancel-…".
1744 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1745 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1746 callbacks = [];
1747 callbacksCount = 0;
1748 nextId = 1;
1749 startId = 1;
1750 isScheduled = false;
1751 tick = (timestamp) => {
1752 this.isScheduled = false;
1753 const currentCallbacks = this.callbacks;
1754 const currentCallbacksCount = this.callbacksCount;
1755 this.callbacks = [];
1756 this.callbacksCount = 0;
1757 this.startId = this.nextId;
1758 if (currentCallbacksCount > 0) {
1759 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1760 currentCallbacks[i2]?.(timestamp);
1761 }
1762 }
1763 };
1764 request(fn) {
1765 const id = this.nextId;
1766 this.nextId += 1;
1767 this.callbacks.push(fn);
1768 this.callbacksCount += 1;
1769 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1770 if (!this.isScheduled || didRAFChange) {
1771 requestAnimationFrame(this.tick);
1772 this.isScheduled = true;
1773 }
1774 return id;
1775 }
1776 cancel(id) {
1777 const index2 = id - this.startId;
1778 if (index2 < 0 || index2 >= this.callbacks.length) {
1779 return;
1780 }
1781 this.callbacks[index2] = null;
1782 this.callbacksCount -= 1;
1783 }
1784 };
1785 var scheduler = new Scheduler();
1786 var AnimationFrame = class _AnimationFrame {
1787 static create() {
1788 return new _AnimationFrame();
1789 }
1790 static request(fn) {
1791 return scheduler.request(fn);
1792 }
1793 static cancel(id) {
1794 return scheduler.cancel(id);
1795 }
1796 currentId = EMPTY2;
1797 /**
1798 * Executes `fn` after `delay`, clearing any previously scheduled call.
1799 */
1800 request(fn) {
1801 this.cancel();
1802 this.currentId = scheduler.request(() => {
1803 this.currentId = EMPTY2;
1804 fn();
1805 });
1806 }
1807 cancel = () => {
1808 if (this.currentId !== EMPTY2) {
1809 scheduler.cancel(this.currentId);
1810 this.currentId = EMPTY2;
1811 }
1812 };
1813 disposeEffect = () => {
1814 return this.cancel;
1815 };
1816 };
1817 function useAnimationFrame() {
1818 const timeout = useRefWithInit(AnimationFrame.create).current;
1819 useOnMount(timeout.disposeEffect);
1820 return timeout;
1821 }
1822
1823 // node_modules/@base-ui/react/internals/useTransitionStatus.mjs
1824 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1825 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1826 const [mounted, setMounted] = React11.useState(open);
1827 if (open && !mounted) {
1828 setMounted(true);
1829 setTransitionStatus("starting");
1830 }
1831 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1832 setTransitionStatus("ending");
1833 }
1834 if (!open && !mounted && transitionStatus === "ending") {
1835 setTransitionStatus(void 0);
1836 }
1837 useIsoLayoutEffect(() => {
1838 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1839 const frame = AnimationFrame.request(() => {
1840 setTransitionStatus("ending");
1841 });
1842 return () => {
1843 AnimationFrame.cancel(frame);
1844 };
1845 }
1846 return void 0;
1847 }, [open, mounted, transitionStatus, deferEndingState]);
1848 useIsoLayoutEffect(() => {
1849 if (!open || enableIdleState) {
1850 return void 0;
1851 }
1852 const frame = AnimationFrame.request(() => {
1853 setTransitionStatus(void 0);
1854 });
1855 return () => {
1856 AnimationFrame.cancel(frame);
1857 };
1858 }, [enableIdleState, open]);
1859 useIsoLayoutEffect(() => {
1860 if (!open || !enableIdleState) {
1861 return void 0;
1862 }
1863 if (open && mounted && transitionStatus !== "idle") {
1864 setTransitionStatus("starting");
1865 }
1866 const frame = AnimationFrame.request(() => {
1867 setTransitionStatus("idle");
1868 });
1869 return () => {
1870 AnimationFrame.cancel(frame);
1871 };
1872 }, [enableIdleState, open, mounted, transitionStatus]);
1873 return {
1874 mounted,
1875 setMounted,
1876 transitionStatus
1877 };
1878 }
1879
1880 // node_modules/@base-ui/react/collapsible/root/useCollapsibleRoot.mjs
1881 function useCollapsibleRoot(parameters) {
1882 const {
1883 open: openParam,
1884 defaultOpen,
1885 onOpenChange,
1886 disabled: disabled2
1887 } = parameters;
1888 const [open, setOpen] = useControlled({
1889 controlled: openParam,
1890 default: defaultOpen,
1891 name: "Collapsible",
1892 state: "open"
1893 });
1894 const {
1895 mounted,
1896 setMounted,
1897 transitionStatus
1898 } = useTransitionStatus(open, true, true);
1899 const defaultPanelId = useBaseUiId();
1900 const [panelIdState, setPanelIdState] = React12.useState();
1901 const panelId = panelIdState ?? defaultPanelId;
1902 const handleTrigger = useStableCallback((event) => {
1903 const nextOpen = !open;
1904 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent);
1905 onOpenChange(nextOpen, eventDetails);
1906 if (eventDetails.isCanceled) {
1907 return;
1908 }
1909 setOpen(nextOpen);
1910 });
1911 return React12.useMemo(() => ({
1912 disabled: disabled2,
1913 handleTrigger,
1914 mounted,
1915 open,
1916 panelId,
1917 setMounted,
1918 setOpen,
1919 setPanelIdState,
1920 transitionStatus
1921 }), [disabled2, handleTrigger, mounted, open, panelId, setMounted, setOpen, setPanelIdState, transitionStatus]);
1922 }
1923
1924 // node_modules/@base-ui/react/collapsible/root/CollapsibleRootContext.mjs
1925 var React13 = __toESM(require_react(), 1);
1926 var CollapsibleRootContext = /* @__PURE__ */ React13.createContext(void 0);
1927 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext";
1928 function useCollapsibleRootContext() {
1929 const context = React13.useContext(CollapsibleRootContext);
1930 if (context === void 0) {
1931 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15));
1932 }
1933 return context;
1934 }
1935
1936 // node_modules/@base-ui/react/internals/stateAttributesMapping.mjs
1937 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1938 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1939 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1940 return TransitionStatusDataAttributes2;
1941 })({});
1942 var STARTING_HOOK = {
1943 [TransitionStatusDataAttributes.startingStyle]: ""
1944 };
1945 var ENDING_HOOK = {
1946 [TransitionStatusDataAttributes.endingStyle]: ""
1947 };
1948 var transitionStatusMapping = {
1949 transitionStatus(value) {
1950 if (value === "starting") {
1951 return STARTING_HOOK;
1952 }
1953 if (value === "ending") {
1954 return ENDING_HOOK;
1955 }
1956 return null;
1957 }
1958 };
1959
1960 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanelDataAttributes.mjs
1961 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) {
1962 CollapsiblePanelDataAttributes2["open"] = "data-open";
1963 CollapsiblePanelDataAttributes2["closed"] = "data-closed";
1964 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
1965 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
1966 return CollapsiblePanelDataAttributes2;
1967 })({});
1968
1969 // node_modules/@base-ui/react/collapsible/trigger/CollapsibleTriggerDataAttributes.mjs
1970 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) {
1971 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open";
1972 return CollapsibleTriggerDataAttributes2;
1973 })({});
1974
1975 // node_modules/@base-ui/react/utils/collapsibleOpenStateMapping.mjs
1976 var PANEL_OPEN_HOOK = {
1977 [CollapsiblePanelDataAttributes.open]: ""
1978 };
1979 var PANEL_CLOSED_HOOK = {
1980 [CollapsiblePanelDataAttributes.closed]: ""
1981 };
1982 var triggerOpenStateMapping = {
1983 open(value) {
1984 if (value) {
1985 return {
1986 [CollapsibleTriggerDataAttributes.panelOpen]: ""
1987 };
1988 }
1989 return null;
1990 }
1991 };
1992 var collapsibleOpenStateMapping = {
1993 open(value) {
1994 if (value) {
1995 return PANEL_OPEN_HOOK;
1996 }
1997 return PANEL_CLOSED_HOOK;
1998 }
1999 };
2000
2001 // node_modules/@base-ui/react/internals/use-button/useButton.mjs
2002 var React16 = __toESM(require_react(), 1);
2003
2004 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2005 function hasWindow() {
2006 return typeof window !== "undefined";
2007 }
2008 function getNodeName(node) {
2009 if (isNode(node)) {
2010 return (node.nodeName || "").toLowerCase();
2011 }
2012 return "#document";
2013 }
2014 function getWindow(node) {
2015 var _node$ownerDocument;
2016 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2017 }
2018 function getDocumentElement(node) {
2019 var _ref;
2020 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2021 }
2022 function isNode(value) {
2023 if (!hasWindow()) {
2024 return false;
2025 }
2026 return value instanceof Node || value instanceof getWindow(value).Node;
2027 }
2028 function isElement(value) {
2029 if (!hasWindow()) {
2030 return false;
2031 }
2032 return value instanceof Element || value instanceof getWindow(value).Element;
2033 }
2034 function isHTMLElement(value) {
2035 if (!hasWindow()) {
2036 return false;
2037 }
2038 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2039 }
2040 function isShadowRoot(value) {
2041 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2042 return false;
2043 }
2044 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2045 }
2046 function isOverflowElement(element) {
2047 const {
2048 overflow,
2049 overflowX,
2050 overflowY,
2051 display
2052 } = getComputedStyle2(element);
2053 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2054 }
2055 function isTableElement(element) {
2056 return /^(table|td|th)$/.test(getNodeName(element));
2057 }
2058 function isTopLayer(element) {
2059 try {
2060 if (element.matches(":popover-open")) {
2061 return true;
2062 }
2063 } catch (_e) {
2064 }
2065 try {
2066 return element.matches(":modal");
2067 } catch (_e) {
2068 return false;
2069 }
2070 }
2071 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2072 var containRe = /paint|layout|strict|content/;
2073 var isNotNone = (value) => !!value && value !== "none";
2074 var isWebKitValue;
2075 function isContainingBlock(elementOrCss) {
2076 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2077 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 || "");
2078 }
2079 function getContainingBlock(element) {
2080 let currentNode = getParentNode(element);
2081 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2082 if (isContainingBlock(currentNode)) {
2083 return currentNode;
2084 } else if (isTopLayer(currentNode)) {
2085 return null;
2086 }
2087 currentNode = getParentNode(currentNode);
2088 }
2089 return null;
2090 }
2091 function isWebKit() {
2092 if (isWebKitValue == null) {
2093 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2094 }
2095 return isWebKitValue;
2096 }
2097 function isLastTraversableNode(node) {
2098 return /^(html|body|#document)$/.test(getNodeName(node));
2099 }
2100 function getComputedStyle2(element) {
2101 return getWindow(element).getComputedStyle(element);
2102 }
2103 function getNodeScroll(element) {
2104 if (isElement(element)) {
2105 return {
2106 scrollLeft: element.scrollLeft,
2107 scrollTop: element.scrollTop
2108 };
2109 }
2110 return {
2111 scrollLeft: element.scrollX,
2112 scrollTop: element.scrollY
2113 };
2114 }
2115 function getParentNode(node) {
2116 if (getNodeName(node) === "html") {
2117 return node;
2118 }
2119 const result = (
2120 // Step into the shadow DOM of the parent of a slotted node.
2121 node.assignedSlot || // DOM Element detected.
2122 node.parentNode || // ShadowRoot detected.
2123 isShadowRoot(node) && node.host || // Fallback.
2124 getDocumentElement(node)
2125 );
2126 return isShadowRoot(result) ? result.host : result;
2127 }
2128 function getNearestOverflowAncestor(node) {
2129 const parentNode = getParentNode(node);
2130 if (isLastTraversableNode(parentNode)) {
2131 return node.ownerDocument ? node.ownerDocument.body : node.body;
2132 }
2133 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2134 return parentNode;
2135 }
2136 return getNearestOverflowAncestor(parentNode);
2137 }
2138 function getOverflowAncestors(node, list, traverseIframes) {
2139 var _node$ownerDocument2;
2140 if (list === void 0) {
2141 list = [];
2142 }
2143 if (traverseIframes === void 0) {
2144 traverseIframes = true;
2145 }
2146 const scrollableAncestor = getNearestOverflowAncestor(node);
2147 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2148 const win = getWindow(scrollableAncestor);
2149 if (isBody) {
2150 const frameElement = getFrameElement(win);
2151 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2152 } else {
2153 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2154 }
2155 }
2156 function getFrameElement(win) {
2157 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2158 }
2159
2160 // node_modules/@base-ui/react/internals/composite/root/CompositeRootContext.mjs
2161 var React14 = __toESM(require_react(), 1);
2162 var CompositeRootContext = /* @__PURE__ */ React14.createContext(void 0);
2163 if (true) CompositeRootContext.displayName = "CompositeRootContext";
2164 function useCompositeRootContext(optional = false) {
2165 const context = React14.useContext(CompositeRootContext);
2166 if (context === void 0 && !optional) {
2167 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16));
2168 }
2169 return context;
2170 }
2171
2172 // node_modules/@base-ui/react/utils/useFocusableWhenDisabled.mjs
2173 var React15 = __toESM(require_react(), 1);
2174 function useFocusableWhenDisabled(parameters) {
2175 const {
2176 focusableWhenDisabled,
2177 disabled: disabled2,
2178 composite = false,
2179 tabIndex: tabIndexProp = 0,
2180 isNativeButton
2181 } = parameters;
2182 const isFocusableComposite = composite && focusableWhenDisabled !== false;
2183 const isNonFocusableComposite = composite && focusableWhenDisabled === false;
2184 const props = React15.useMemo(() => {
2185 const additionalProps = {
2186 // allow Tabbing away from focusableWhenDisabled elements
2187 onKeyDown(event) {
2188 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") {
2189 event.preventDefault();
2190 }
2191 }
2192 };
2193 if (!composite) {
2194 additionalProps.tabIndex = tabIndexProp;
2195 if (!isNativeButton && disabled2) {
2196 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
2197 }
2198 }
2199 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) {
2200 additionalProps["aria-disabled"] = disabled2;
2201 }
2202 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
2203 additionalProps.disabled = disabled2;
2204 }
2205 return additionalProps;
2206 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);
2207 return {
2208 props
2209 };
2210 }
2211
2212 // node_modules/@base-ui/react/internals/use-button/useButton.mjs
2213 function useButton(parameters = {}) {
2214 const {
2215 disabled: disabled2 = false,
2216 focusableWhenDisabled,
2217 tabIndex = 0,
2218 native: isNativeButton = true,
2219 composite: compositeProp
2220 } = parameters;
2221 const elementRef = React16.useRef(null);
2222 const compositeRootContext = useCompositeRootContext(true);
2223 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
2224 const {
2225 props: focusableWhenDisabledProps
2226 } = useFocusableWhenDisabled({
2227 focusableWhenDisabled,
2228 disabled: disabled2,
2229 composite: isCompositeItem,
2230 tabIndex,
2231 isNativeButton
2232 });
2233 if (true) {
2234 React16.useEffect(() => {
2235 if (!elementRef.current) {
2236 return;
2237 }
2238 const isButtonTag = isButtonElement(elementRef.current);
2239 if (isNativeButton) {
2240 if (!isButtonTag) {
2241 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2242 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`.";
2243 error(`${message2}${ownerStackMessage}`);
2244 }
2245 } else if (isButtonTag) {
2246 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2247 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`.";
2248 error(`${message2}${ownerStackMessage}`);
2249 }
2250 }, [isNativeButton]);
2251 }
2252 const updateDisabled = React16.useCallback(() => {
2253 const element = elementRef.current;
2254 if (!isButtonElement(element)) {
2255 return;
2256 }
2257 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
2258 element.disabled = false;
2259 }
2260 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]);
2261 useIsoLayoutEffect(updateDisabled, [updateDisabled]);
2262 const getButtonProps = React16.useCallback((externalProps = {}) => {
2263 const {
2264 onClick: externalOnClick,
2265 onMouseDown: externalOnMouseDown,
2266 onKeyUp: externalOnKeyUp,
2267 onKeyDown: externalOnKeyDown,
2268 onPointerDown: externalOnPointerDown,
2269 ...otherExternalProps
2270 } = externalProps;
2271 return mergeProps({
2272 onClick(event) {
2273 if (disabled2) {
2274 event.preventDefault();
2275 return;
2276 }
2277 externalOnClick?.(event);
2278 },
2279 onMouseDown(event) {
2280 if (!disabled2) {
2281 externalOnMouseDown?.(event);
2282 }
2283 },
2284 onKeyDown(event) {
2285 if (disabled2) {
2286 return;
2287 }
2288 makeEventPreventable(event);
2289 externalOnKeyDown?.(event);
2290 if (event.baseUIHandlerPrevented) {
2291 return;
2292 }
2293 const isCurrentTarget = event.target === event.currentTarget;
2294 const currentTarget = event.currentTarget;
2295 const isButton2 = isButtonElement(currentTarget);
2296 const isLink = !isNativeButton && isValidLinkElement(currentTarget);
2297 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink);
2298 const isEnterKey = event.key === "Enter";
2299 const isSpaceKey = event.key === " ";
2300 const role = currentTarget.getAttribute("role");
2301 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
2302 if (isCurrentTarget && isCompositeItem && isSpaceKey) {
2303 if (event.defaultPrevented && isTextNavigationRole) {
2304 return;
2305 }
2306 event.preventDefault();
2307 if (isLink || isNativeButton && isButton2) {
2308 currentTarget.click();
2309 event.preventBaseUIHandler();
2310 } else if (shouldClick) {
2311 externalOnClick?.(event);
2312 event.preventBaseUIHandler();
2313 }
2314 return;
2315 }
2316 if (shouldClick) {
2317 if (!isNativeButton && (isSpaceKey || isEnterKey)) {
2318 event.preventDefault();
2319 }
2320 if (!isNativeButton && isEnterKey) {
2321 externalOnClick?.(event);
2322 }
2323 }
2324 },
2325 onKeyUp(event) {
2326 if (disabled2) {
2327 return;
2328 }
2329 makeEventPreventable(event);
2330 externalOnKeyUp?.(event);
2331 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
2332 event.preventDefault();
2333 return;
2334 }
2335 if (event.baseUIHandlerPrevented) {
2336 return;
2337 }
2338 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") {
2339 externalOnClick?.(event);
2340 }
2341 },
2342 onPointerDown(event) {
2343 if (disabled2) {
2344 event.preventDefault();
2345 return;
2346 }
2347 externalOnPointerDown?.(event);
2348 }
2349 }, isNativeButton ? {
2350 type: "button"
2351 } : {
2352 role: "button"
2353 }, focusableWhenDisabledProps, otherExternalProps);
2354 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
2355 const buttonRef = useStableCallback((element) => {
2356 elementRef.current = element;
2357 updateDisabled();
2358 });
2359 return {
2360 getButtonProps,
2361 buttonRef
2362 };
2363 }
2364 function isButtonElement(elem) {
2365 return isHTMLElement(elem) && elem.tagName === "BUTTON";
2366 }
2367 function isValidLinkElement(elem) {
2368 return Boolean(elem?.tagName === "A" && elem?.href);
2369 }
2370
2371 // node_modules/@base-ui/react/collapsible/panel/useCollapsiblePanel.mjs
2372 var React18 = __toESM(require_react(), 1);
2373
2374 // node_modules/@base-ui/utils/addEventListener.mjs
2375 function addEventListener(target, type, listener, options) {
2376 target.addEventListener(type, listener, options);
2377 return () => {
2378 target.removeEventListener(type, listener, options);
2379 };
2380 }
2381
2382 // node_modules/@base-ui/utils/useValueAsRef.mjs
2383 function useValueAsRef(value) {
2384 const latest = useRefWithInit(createLatestRef, value).current;
2385 latest.next = value;
2386 useIsoLayoutEffect(latest.effect);
2387 return latest;
2388 }
2389 function createLatestRef(value) {
2390 const latest = {
2391 current: value,
2392 next: value,
2393 effect: () => {
2394 latest.current = latest.next;
2395 }
2396 };
2397 return latest;
2398 }
2399
2400 // node_modules/@base-ui/utils/owner.mjs
2401 function ownerDocument(node) {
2402 return node?.ownerDocument || document;
2403 }
2404
2405 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2406 var React17 = __toESM(require_react(), 1);
2407
2408 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2409 var ReactDOM = __toESM(require_react_dom(), 1);
2410
2411 // node_modules/@base-ui/react/utils/resolveRef.mjs
2412 function resolveRef(maybeRef) {
2413 if (maybeRef == null) {
2414 return maybeRef;
2415 }
2416 return "current" in maybeRef ? maybeRef.current : maybeRef;
2417 }
2418
2419 // node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
2420 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2421 const frame = useAnimationFrame();
2422 return useStableCallback((fnToExecute, signal = null) => {
2423 frame.cancel();
2424 const element = resolveRef(elementOrRef);
2425 if (element == null) {
2426 return;
2427 }
2428 const resolvedElement = element;
2429 const done = () => {
2430 ReactDOM.flushSync(fnToExecute);
2431 };
2432 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2433 fnToExecute();
2434 return;
2435 }
2436 function exec() {
2437 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2438 if (!signal?.aborted) {
2439 done();
2440 }
2441 }).catch(() => {
2442 if (treatAbortedAsFinished) {
2443 if (!signal?.aborted) {
2444 done();
2445 }
2446 return;
2447 }
2448 const currentAnimations = resolvedElement.getAnimations();
2449 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2450 exec();
2451 }
2452 });
2453 }
2454 if (waitForStartingStyleRemoved) {
2455 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2456 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2457 frame.request(exec);
2458 return;
2459 }
2460 const attributeObserver = new MutationObserver(() => {
2461 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2462 attributeObserver.disconnect();
2463 exec();
2464 }
2465 });
2466 attributeObserver.observe(resolvedElement, {
2467 attributes: true,
2468 attributeFilter: [startingStyleAttribute]
2469 });
2470 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2471 once: true
2472 });
2473 return;
2474 }
2475 frame.request(exec);
2476 });
2477 }
2478
2479 // node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
2480 function useOpenChangeComplete(parameters) {
2481 const {
2482 enabled = true,
2483 open,
2484 ref,
2485 onComplete: onCompleteParam
2486 } = parameters;
2487 const onComplete = useStableCallback(onCompleteParam);
2488 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2489 React17.useEffect(() => {
2490 if (!enabled) {
2491 return void 0;
2492 }
2493 const abortController = new AbortController();
2494 runOnceAnimationsFinish(onComplete, abortController.signal);
2495 return () => {
2496 abortController.abort();
2497 };
2498 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2499 }
2500
2501 // node_modules/@base-ui/react/collapsible/panel/useCollapsiblePanel.mjs
2502 var EMPTY_DIMENSIONS = {
2503 height: void 0,
2504 width: void 0
2505 };
2506 function useCollapsiblePanel(parameters) {
2507 const {
2508 externalRef,
2509 hiddenUntilFound,
2510 id: idParam,
2511 keepMounted,
2512 mounted,
2513 onOpenChange,
2514 open,
2515 setMounted,
2516 setOpen,
2517 transitionStatus
2518 } = parameters;
2519 const panelRef = React18.useRef(null);
2520 const animationTypeRef = React18.useRef(null);
2521 const [dimensions, setDimensionsUnwrapped] = React18.useState(EMPTY_DIMENSIONS);
2522 const lastMeasuredDimensionsRef = React18.useRef(EMPTY_DIMENSIONS);
2523 const shouldSkipNextOpenRef = React18.useRef(false);
2524 const shouldPreventMountAnimationRef = React18.useRef(open);
2525 const shouldPreventActivityResumeAnimationRef = React18.useRef(false);
2526 const [forcePanelIdle, setForcePanelIdle] = React18.useState(false);
2527 const pendingTemporaryStyleRestoreRef = React18.useRef(null);
2528 const mergedPanelRef = useMergedRefs(externalRef, panelRef);
2529 const latestStateRef = useValueAsRef({
2530 mounted,
2531 open
2532 });
2533 const runOnceCloseAnimationsFinish = useAnimationsFinished(panelRef, false, false);
2534 const hidden = !open && !mounted;
2535 const panelTransitionStatus = forcePanelIdle ? "idle" : transitionStatus;
2536 const shouldPreventOpenAnimation = open && // These 2 refs are safe to read in render, they are only written from committed
2537 // layout/effect paths and gate one-shot motion suppression for the next open
2538 // lifecycle. They intentionally expose the last committed motion snapshot.
2539 (shouldPreventMountAnimationRef.current || shouldPreventActivityResumeAnimationRef.current);
2540 const renderedDimensions = !open && mounted && // These 2 refs are also safe to read in render, both hold the last committed
2541 // animation mode and measurement. This fallback only restores a previously
2542 // measured pixel size after the live dimensions state has been reset back to `auto`.
2543 animationTypeRef.current === "css-animation" && dimensions.height === void 0 && dimensions.width === void 0 ? lastMeasuredDimensionsRef.current : dimensions;
2544 const shouldPersistHiddenTransitionStyles = hiddenUntilFound && hidden && animationTypeRef.current !== "css-animation";
2545 const setDimensions = useStableCallback((nextDimensions, shouldCacheMeasurement = true) => {
2546 if (shouldCacheMeasurement) {
2547 lastMeasuredDimensionsRef.current = nextDimensions;
2548 }
2549 setDimensionsUnwrapped(nextDimensions);
2550 });
2551 const restorePendingTemporaryStyle = useStableCallback(() => {
2552 pendingTemporaryStyleRestoreRef.current?.();
2553 pendingTemporaryStyleRestoreRef.current = null;
2554 });
2555 const setPendingTemporaryStyleRestore = useStableCallback((restore) => {
2556 restorePendingTemporaryStyle();
2557 pendingTemporaryStyleRestoreRef.current = () => {
2558 pendingTemporaryStyleRestoreRef.current = null;
2559 restore();
2560 };
2561 });
2562 const markActivityResumeAnimationSuppressed = useStableCallback(() => {
2563 if (open && mounted && animationTypeRef.current === "css-animation") {
2564 shouldPreventActivityResumeAnimationRef.current = true;
2565 }
2566 });
2567 useIsoLayoutEffect(() => {
2568 if (!forcePanelIdle || transitionStatus === "starting") {
2569 return;
2570 }
2571 setForcePanelIdle(false);
2572 }, [forcePanelIdle, transitionStatus]);
2573 React18.useEffect(() => {
2574 return () => {
2575 markActivityResumeAnimationSuppressed();
2576 restorePendingTemporaryStyle();
2577 };
2578 }, [markActivityResumeAnimationSuppressed, restorePendingTemporaryStyle]);
2579 useIsoLayoutEffect(() => {
2580 const panel = panelRef.current;
2581 if (!panel) {
2582 return void 0;
2583 }
2584 if (!open && pendingTemporaryStyleRestoreRef.current) {
2585 restorePendingTemporaryStyle();
2586 }
2587 const animationType = getAnimationType(panel, shouldPreventOpenAnimation);
2588 animationTypeRef.current = animationType;
2589 if (open && transitionStatus === "idle" && shouldPreventMountAnimationRef.current && animationType === "css-animation") {
2590 lastMeasuredDimensionsRef.current = getDimensions(panel);
2591 return void 0;
2592 }
2593 if (open && transitionStatus === "starting") {
2594 const skipNextOpen = shouldSkipNextOpenRef.current;
2595 shouldSkipNextOpenRef.current = false;
2596 if (animationType === "none") {
2597 setDimensions(getDimensions(panel));
2598 setForcePanelIdle(true);
2599 return void 0;
2600 }
2601 if (animationType === "css-transition") {
2602 const restoreLayoutStyles = resetLayoutStyles(panel);
2603 setDimensions(getDimensions(panel));
2604 if (!skipNextOpen) {
2605 return restoreLayoutStyles;
2606 }
2607 const restoreTransitionDuration = setTemporaryStyle(panel, "transition-duration", "0s");
2608 setPendingTemporaryStyleRestore(restoreTransitionDuration);
2609 setForcePanelIdle(true);
2610 return restoreLayoutStyles;
2611 }
2612 if (animationType === "css-animation") {
2613 setDimensions(getDimensions(panel));
2614 if (!skipNextOpen) {
2615 const restoreAnimationName2 = setTemporaryStyle(panel, "animation-name", "none");
2616 restoreAnimationName2();
2617 return void 0;
2618 }
2619 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
2620 const restoreAnimationDuration = setTemporaryStyle(panel, "animation-duration", "0s");
2621 restoreAnimationName();
2622 setPendingTemporaryStyleRestore(restoreAnimationDuration);
2623 setForcePanelIdle(true);
2624 return void 0;
2625 }
2626 }
2627 if (!open && mounted && (transitionStatus === "idle" || transitionStatus === "starting")) {
2628 shouldPreventMountAnimationRef.current = false;
2629 shouldPreventActivityResumeAnimationRef.current = false;
2630 if (animationType === "none") {
2631 setDimensions(EMPTY_DIMENSIONS, false);
2632 setMounted(false);
2633 return void 0;
2634 }
2635 setDimensions(getDimensions(panel));
2636 return void 0;
2637 }
2638 if (transitionStatus !== "ending") {
2639 return void 0;
2640 }
2641 if (animationType === "none") {
2642 setMounted(false);
2643 return void 0;
2644 }
2645 const nextDimensions = getDimensions(panel);
2646 const hasMeasuredSize = (nextDimensions.height ?? 0) > 0 || (nextDimensions.width ?? 0) > 0;
2647 if (!hasMeasuredSize) {
2648 setMounted(false);
2649 return void 0;
2650 }
2651 setDimensions(nextDimensions);
2652 if (animationType === "css-animation") {
2653 const restoreAnimationName = setTemporaryStyle(panel, "animation-name", "none");
2654 restoreAnimationName();
2655 }
2656 return void 0;
2657 }, [mounted, open, restorePendingTemporaryStyle, setDimensions, setMounted, setPendingTemporaryStyleRestore, shouldPreventOpenAnimation, transitionStatus]);
2658 useOpenChangeComplete({
2659 enabled: open && mounted && panelTransitionStatus === "idle",
2660 open: true,
2661 ref: panelRef,
2662 onComplete() {
2663 if (!open) {
2664 return;
2665 }
2666 setDimensions(EMPTY_DIMENSIONS, false);
2667 }
2668 });
2669 React18.useEffect(() => {
2670 if (open || !mounted || panelTransitionStatus !== "ending") {
2671 return void 0;
2672 }
2673 const panel = panelRef.current;
2674 if (!panel) {
2675 return void 0;
2676 }
2677 const abortController = new AbortController();
2678 let endingStyleFrame = -1;
2679 function handleComplete() {
2680 if (latestStateRef.current.open) {
2681 return;
2682 }
2683 setMounted(false);
2684 setDimensions(EMPTY_DIMENSIONS, false);
2685 }
2686 endingStyleFrame = AnimationFrame.request(() => {
2687 if (!abortController.signal.aborted) {
2688 runOnceCloseAnimationsFinish(handleComplete, abortController.signal);
2689 }
2690 });
2691 return () => {
2692 AnimationFrame.cancel(endingStyleFrame);
2693 abortController.abort();
2694 };
2695 }, [latestStateRef, mounted, open, panelTransitionStatus, runOnceCloseAnimationsFinish, setDimensions, setMounted]);
2696 useIsoLayoutEffect(() => {
2697 const panel = panelRef.current;
2698 if (!panel || !hiddenUntilFound || !hidden) {
2699 return;
2700 }
2701 panel.setAttribute("hidden", "until-found");
2702 }, [hidden, hiddenUntilFound]);
2703 React18.useEffect(function registerBeforeMatchListener() {
2704 const panel = panelRef.current;
2705 if (!panel) {
2706 return void 0;
2707 }
2708 function handleBeforeMatch(event) {
2709 const eventDetails = createChangeEventDetails(reason_parts_exports.none, event);
2710 onOpenChange(true, eventDetails);
2711 if (eventDetails.isCanceled) {
2712 return;
2713 }
2714 shouldSkipNextOpenRef.current = true;
2715 setOpen(true);
2716 }
2717 return addEventListener(panel, "beforematch", handleBeforeMatch);
2718 }, [onOpenChange, setOpen]);
2719 const shouldRender = keepMounted || hiddenUntilFound || mounted || open;
2720 return {
2721 height: renderedDimensions.height,
2722 props: {
2723 ...shouldPersistHiddenTransitionStyles ? {
2724 [CollapsiblePanelDataAttributes.startingStyle]: ""
2725 } : void 0,
2726 hidden,
2727 id: idParam
2728 },
2729 ref: mergedPanelRef,
2730 shouldPreventOpenAnimation,
2731 shouldRender,
2732 transitionStatus: panelTransitionStatus,
2733 width: renderedDimensions.width
2734 };
2735 }
2736 function getDimensions(element) {
2737 return {
2738 height: element.scrollHeight,
2739 width: element.scrollWidth
2740 };
2741 }
2742 function getAnimationType(element, hasSuppressedMountAnimation = false) {
2743 const panelStyles = getWindow(element).getComputedStyle(element);
2744 const hasAnimation = (panelStyles.animationName.split(",").map((name) => name.trim()).some((name) => name !== "" && name !== "none") || hasSuppressedMountAnimation) && hasNonZeroDuration(panelStyles.animationDuration);
2745 const hasTransition = hasNonZeroDuration(panelStyles.transitionDuration);
2746 if (hasAnimation && hasTransition) {
2747 if (true) {
2748 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used.");
2749 }
2750 return "css-transition";
2751 }
2752 if (hasTransition) {
2753 return "css-transition";
2754 }
2755 if (hasAnimation) {
2756 return "css-animation";
2757 }
2758 return "none";
2759 }
2760 function hasNonZeroDuration(value) {
2761 return value.split(",").map((part) => part.trim()).some((part) => part !== "" && Number.parseFloat(part) > 0);
2762 }
2763 function setTemporaryStyle(element, property, value) {
2764 const previousValue = element.style.getPropertyValue(property);
2765 const previousPriority = element.style.getPropertyPriority(property);
2766 element.style.setProperty(property, value);
2767 return () => {
2768 if (previousValue === "") {
2769 element.style.removeProperty(property);
2770 return;
2771 }
2772 element.style.setProperty(property, previousValue, previousPriority);
2773 };
2774 }
2775 function resetLayoutStyles(element) {
2776 const originalLayoutStyles = {
2777 "justify-content": element.style.justifyContent,
2778 "align-items": element.style.alignItems,
2779 "align-content": element.style.alignContent,
2780 "justify-items": element.style.justifyItems
2781 };
2782 Object.keys(originalLayoutStyles).forEach((key) => {
2783 element.style.setProperty(key, "initial", "important");
2784 });
2785 function restoreLayoutStyles() {
2786 Object.entries(originalLayoutStyles).forEach(([key, value]) => {
2787 if (value === "") {
2788 element.style.removeProperty(key);
2789 return;
2790 }
2791 element.style.setProperty(key, value);
2792 });
2793 }
2794 const frame = AnimationFrame.request(restoreLayoutStyles);
2795 return () => {
2796 AnimationFrame.cancel(frame);
2797 restoreLayoutStyles();
2798 };
2799 }
2800
2801 // node_modules/@base-ui/utils/useOnFirstRender.mjs
2802 var React19 = __toESM(require_react(), 1);
2803 function useOnFirstRender(fn) {
2804 const ref = React19.useRef(true);
2805 if (ref.current) {
2806 ref.current = false;
2807 fn();
2808 }
2809 }
2810
2811 // node_modules/@base-ui/utils/platform/parts.mjs
2812 var parts_exports = {};
2813 __export(parts_exports, {
2814 engine: () => engine_exports,
2815 env: () => env_exports,
2816 os: () => os_exports,
2817 screenReader: () => screen_reader_exports
2818 });
2819
2820 // node_modules/@base-ui/utils/platform/os.mjs
2821 var os_exports = {};
2822 __export(os_exports, {
2823 android: () => android,
2824 apple: () => apple,
2825 ios: () => ios,
2826 linux: () => linux,
2827 mac: () => mac,
2828 windows: () => windows
2829 });
2830
2831 // node_modules/@base-ui/utils/platform/shared.mjs
2832 function readRawData() {
2833 if (typeof navigator === "undefined") {
2834 return {
2835 userAgent: "",
2836 platform: "",
2837 maxTouchPoints: 0
2838 };
2839 }
2840 if (true) {
2841 const uaData = navigator.userAgentData;
2842 if (uaData && Array.isArray(uaData.brands)) {
2843 return {
2844 userAgent: uaData.brands.map(({
2845 brand,
2846 version: version2
2847 }) => `${brand}/${version2}`).join(" "),
2848 platform: uaData.platform ?? navigator.platform ?? "",
2849 maxTouchPoints: navigator.maxTouchPoints ?? 0
2850 };
2851 }
2852 }
2853 return {
2854 userAgent: navigator.userAgent,
2855 platform: navigator.platform ?? "",
2856 maxTouchPoints: navigator.maxTouchPoints ?? 0
2857 };
2858 }
2859 var {
2860 userAgent,
2861 platform,
2862 maxTouchPoints
2863 } = readRawData();
2864 var lowerUserAgent = userAgent.toLowerCase();
2865 var lowerPlatform = platform.toLowerCase();
2866
2867 // node_modules/@base-ui/utils/platform/os.mjs
2868 var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1;
2869 var ANDROID_STRING = "android";
2870 var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING);
2871 var mac = !ios && lowerPlatform.startsWith("mac");
2872 var windows = lowerPlatform.startsWith("win");
2873 var linux = !android && /^(linux|chrome os)/.test(lowerPlatform);
2874 var apple = mac || ios;
2875
2876 // node_modules/@base-ui/utils/platform/engine.mjs
2877 var engine_exports = {};
2878 __export(engine_exports, {
2879 blink: () => blink,
2880 gecko: () => gecko,
2881 webkit: () => webkit
2882 });
2883 var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none");
2884 var gecko = !webkit && lowerUserAgent.includes("firefox");
2885 var blink = !webkit && lowerUserAgent.includes("chrom");
2886
2887 // node_modules/@base-ui/utils/platform/screen-reader.mjs
2888 var screen_reader_exports = {};
2889 __export(screen_reader_exports, {
2890 voiceOver: () => voiceOver
2891 });
2892 var voiceOver = apple;
2893
2894 // node_modules/@base-ui/utils/platform/env.mjs
2895 var env_exports = {};
2896 __export(env_exports, {
2897 jsdom: () => jsdom
2898 });
2899 var jsdom = /jsdom|happydom/.test(lowerUserAgent);
2900
2901 // node_modules/@base-ui/utils/useTimeout.mjs
2902 var EMPTY3 = 0;
2903 var Timeout = class _Timeout {
2904 static create() {
2905 return new _Timeout();
2906 }
2907 currentId = EMPTY3;
2908 /**
2909 * Executes `fn` after `delay`, clearing any previously scheduled call.
2910 */
2911 start(delay, fn) {
2912 this.clear();
2913 this.currentId = setTimeout(() => {
2914 this.currentId = EMPTY3;
2915 fn();
2916 }, delay);
2917 }
2918 isStarted() {
2919 return this.currentId !== EMPTY3;
2920 }
2921 clear = () => {
2922 if (this.currentId !== EMPTY3) {
2923 clearTimeout(this.currentId);
2924 this.currentId = EMPTY3;
2925 }
2926 };
2927 disposeEffect = () => {
2928 return this.clear;
2929 };
2930 };
2931 function useTimeout() {
2932 const timeout = useRefWithInit(Timeout.create).current;
2933 useOnMount(timeout.disposeEffect);
2934 return timeout;
2935 }
2936
2937 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
2938 var React20 = __toESM(require_react(), 1);
2939
2940 // node_modules/@base-ui/react/floating-ui-react/utils/event.mjs
2941 function isReactEvent(event) {
2942 return "nativeEvent" in event;
2943 }
2944 function isMouseLikePointerType(pointerType, strict) {
2945 const values = ["mouse", "pen"];
2946 if (!strict) {
2947 values.push("", void 0);
2948 }
2949 return values.includes(pointerType);
2950 }
2951 function isClickLikeEvent(event) {
2952 const type = event.type;
2953 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2954 }
2955
2956 // node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs
2957 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2958 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2959
2960 // node_modules/@base-ui/react/internals/shadowDom.mjs
2961 function activeElement(doc) {
2962 let element = doc.activeElement;
2963 while (element?.shadowRoot?.activeElement != null) {
2964 element = element.shadowRoot.activeElement;
2965 }
2966 return element;
2967 }
2968 function contains(parent, child) {
2969 if (!parent || !child) {
2970 return false;
2971 }
2972 const rootNode = child.getRootNode?.();
2973 if (parent.contains(child)) {
2974 return true;
2975 }
2976 if (rootNode && isShadowRoot(rootNode)) {
2977 let next = child;
2978 while (next) {
2979 if (parent === next) {
2980 return true;
2981 }
2982 next = next.parentNode || next.host;
2983 }
2984 }
2985 return false;
2986 }
2987 function getTarget(event) {
2988 if ("composedPath" in event) {
2989 return event.composedPath()[0];
2990 }
2991 return event.target;
2992 }
2993
2994 // node_modules/@base-ui/react/floating-ui-react/utils/element.mjs
2995 function isTargetInsideEnabledTrigger(target, triggerElements) {
2996 if (!isElement(target)) {
2997 return false;
2998 }
2999 const targetElement = target;
3000 if (triggerElements.hasElement(targetElement)) {
3001 return !targetElement.hasAttribute("data-trigger-disabled");
3002 }
3003 for (const [, trigger] of triggerElements.entries()) {
3004 if (contains(trigger, targetElement)) {
3005 return !trigger.hasAttribute("data-trigger-disabled");
3006 }
3007 }
3008 return false;
3009 }
3010 function isEventTargetWithin(event, node) {
3011 if (node == null) {
3012 return false;
3013 }
3014 if ("composedPath" in event) {
3015 return event.composedPath().includes(node);
3016 }
3017 const eventAgain = event;
3018 return eventAgain.target != null && node.contains(eventAgain.target);
3019 }
3020 function isRootElement(element) {
3021 return element.matches("html,body");
3022 }
3023 function isTypeableElement(element) {
3024 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
3025 }
3026 function isInteractiveElement(element) {
3027 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
3028 }
3029 function matchesFocusVisible(element) {
3030 if (!element || parts_exports.env.jsdom) {
3031 return true;
3032 }
3033 try {
3034 return element.matches(":focus-visible");
3035 } catch (_e) {
3036 return true;
3037 }
3038 }
3039
3040 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs
3041 function resolveValue(value, pointerType) {
3042 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
3043 return 0;
3044 }
3045 if (typeof value === "function") {
3046 return value();
3047 }
3048 return value;
3049 }
3050 function getDelay(value, prop, pointerType) {
3051 const result = resolveValue(value, pointerType);
3052 if (typeof result === "number") {
3053 return result;
3054 }
3055 return result?.[prop];
3056 }
3057 function getRestMs(value) {
3058 if (typeof value === "function") {
3059 return value();
3060 }
3061 return value;
3062 }
3063 function isClickLikeOpenEvent(openEventType, interactedInside) {
3064 return interactedInside || openEventType === "click" || openEventType === "mousedown";
3065 }
3066 function isHoverOpenEvent(openEventType) {
3067 return openEventType?.includes("mouse") && openEventType !== "mousedown";
3068 }
3069
3070 // node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
3071 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
3072 var FloatingDelayGroupContext = /* @__PURE__ */ React20.createContext({
3073 hasProvider: false,
3074 timeoutMs: 0,
3075 delayRef: {
3076 current: 0
3077 },
3078 initialDelayRef: {
3079 current: 0
3080 },
3081 timeout: new Timeout(),
3082 currentIdRef: {
3083 current: null
3084 },
3085 currentContextRef: {
3086 current: null
3087 }
3088 });
3089 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
3090 function resetDelayRef(delayRef, initialDelayRef) {
3091 delayRef.current = initialDelayRef.current;
3092 }
3093 function FloatingDelayGroup(props) {
3094 const {
3095 children,
3096 delay,
3097 timeoutMs = 0
3098 } = props;
3099 const delayRef = React20.useRef(delay);
3100 const initialDelayRef = React20.useRef(delay);
3101 const currentIdRef = React20.useRef(null);
3102 const currentContextRef = React20.useRef(null);
3103 const timeout = useTimeout();
3104 useIsoLayoutEffect(() => {
3105 initialDelayRef.current = delay;
3106 if (!currentIdRef.current) {
3107 delayRef.current = delay;
3108 return;
3109 }
3110 delayRef.current = {
3111 open: getDelay(delayRef.current, "open"),
3112 close: getDelay(delay, "close")
3113 };
3114 }, [delay, currentIdRef, delayRef, initialDelayRef]);
3115 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
3116 value: React20.useMemo(() => ({
3117 hasProvider: true,
3118 delayRef,
3119 initialDelayRef,
3120 currentIdRef,
3121 timeoutMs,
3122 currentContextRef,
3123 timeout
3124 }), [timeoutMs, timeout]),
3125 children
3126 });
3127 }
3128 function useDelayGroup(context, options = {
3129 open: false
3130 }) {
3131 const {
3132 open
3133 } = options;
3134 const store = "rootStore" in context ? context.rootStore : context;
3135 const floatingId = store.useState("floatingId");
3136 const groupContext = React20.useContext(FloatingDelayGroupContext);
3137 const {
3138 currentIdRef,
3139 delayRef,
3140 timeoutMs,
3141 initialDelayRef,
3142 currentContextRef,
3143 hasProvider,
3144 timeout
3145 } = groupContext;
3146 const [isInstantPhase, setIsInstantPhase] = React20.useState(false);
3147 const openRef = React20.useRef(open);
3148 const isUnmountedRef = React20.useRef(false);
3149 useIsoLayoutEffect(() => {
3150 openRef.current = open;
3151 }, [open]);
3152 useIsoLayoutEffect(() => {
3153 return () => {
3154 isUnmountedRef.current = true;
3155 };
3156 }, []);
3157 useIsoLayoutEffect(() => {
3158 function unset() {
3159 if (!isUnmountedRef.current) {
3160 setIsInstantPhase(false);
3161 }
3162 currentContextRef.current?.setIsInstantPhase(false);
3163 currentIdRef.current = null;
3164 currentContextRef.current = null;
3165 delayRef.current = initialDelayRef.current;
3166 timeout.clear();
3167 }
3168 if (!currentIdRef.current) {
3169 return void 0;
3170 }
3171 if (!open && currentIdRef.current === floatingId) {
3172 setIsInstantPhase(false);
3173 if (timeoutMs) {
3174 const closingId = floatingId;
3175 timeout.start(timeoutMs, () => {
3176 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3177 return;
3178 }
3179 unset();
3180 });
3181 return () => {
3182 if (openRef.current || currentIdRef.current !== closingId) {
3183 timeout.clear();
3184 }
3185 };
3186 }
3187 unset();
3188 }
3189 return void 0;
3190 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
3191 useIsoLayoutEffect(() => {
3192 if (!open) {
3193 return;
3194 }
3195 const prevContext = currentContextRef.current;
3196 const prevId = currentIdRef.current;
3197 timeout.clear();
3198 currentContextRef.current = {
3199 onOpenChange: store.setOpen,
3200 setIsInstantPhase
3201 };
3202 currentIdRef.current = floatingId;
3203 delayRef.current = {
3204 open: 0,
3205 close: getDelay(initialDelayRef.current, "close")
3206 };
3207 if (prevId !== null && prevId !== floatingId) {
3208 setIsInstantPhase(true);
3209 prevContext?.setIsInstantPhase(true);
3210 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3211 } else {
3212 setIsInstantPhase(false);
3213 prevContext?.setIsInstantPhase(false);
3214 }
3215 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
3216 useIsoLayoutEffect(() => {
3217 return () => {
3218 if (currentIdRef.current === floatingId) {
3219 currentContextRef.current = null;
3220 if (!openRef.current) {
3221 return;
3222 }
3223 currentIdRef.current = null;
3224 resetDelayRef(delayRef, initialDelayRef);
3225 timeout.clear();
3226 }
3227 };
3228 }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]);
3229 return React20.useMemo(() => ({
3230 hasProvider,
3231 delayRef,
3232 isInstantPhase
3233 }), [hasProvider, delayRef, isInstantPhase]);
3234 }
3235
3236 // node_modules/@base-ui/utils/mergeCleanups.mjs
3237 function mergeCleanups(...cleanups) {
3238 return () => {
3239 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3240 const cleanup = cleanups[i2];
3241 if (cleanup) {
3242 cleanup();
3243 }
3244 }
3245 };
3246 }
3247
3248 // node_modules/@base-ui/react/utils/FocusGuard.mjs
3249 var React21 = __toESM(require_react(), 1);
3250
3251 // node_modules/@base-ui/utils/visuallyHidden.mjs
3252 var visuallyHiddenBase = {
3253 clipPath: "inset(50%)",
3254 overflow: "hidden",
3255 whiteSpace: "nowrap",
3256 border: 0,
3257 padding: 0,
3258 width: 1,
3259 height: 1,
3260 margin: -1
3261 };
3262 var visuallyHidden = {
3263 ...visuallyHiddenBase,
3264 position: "fixed",
3265 top: 0,
3266 left: 0
3267 };
3268 var visuallyHiddenInput = {
3269 ...visuallyHiddenBase,
3270 position: "absolute"
3271 };
3272
3273 // node_modules/@base-ui/react/utils/FocusGuard.mjs
3274 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3275 var FocusGuard = /* @__PURE__ */ React21.forwardRef(function FocusGuard2(props, ref) {
3276 const [role, setRole] = React21.useState();
3277 useIsoLayoutEffect(() => {
3278 if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) {
3279 setRole("button");
3280 }
3281 }, []);
3282 const restProps = {
3283 tabIndex: 0,
3284 // Role is only for VoiceOver
3285 role
3286 };
3287 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
3288 ...props,
3289 ref,
3290 style: visuallyHidden,
3291 "aria-hidden": role ? void 0 : true,
3292 ...restProps,
3293 "data-base-ui-focus-guard": ""
3294 });
3295 });
3296 if (true) FocusGuard.displayName = "FocusGuard";
3297
3298 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
3299 var sides = ["top", "right", "bottom", "left"];
3300 var min = Math.min;
3301 var max = Math.max;
3302 var round = Math.round;
3303 var floor = Math.floor;
3304 var createCoords = (v2) => ({
3305 x: v2,
3306 y: v2
3307 });
3308 var oppositeSideMap = {
3309 left: "right",
3310 right: "left",
3311 bottom: "top",
3312 top: "bottom"
3313 };
3314 function clamp(start, value, end) {
3315 return max(start, min(value, end));
3316 }
3317 function evaluate(value, param) {
3318 return typeof value === "function" ? value(param) : value;
3319 }
3320 function getSide(placement) {
3321 return placement.split("-")[0];
3322 }
3323 function getAlignment(placement) {
3324 return placement.split("-")[1];
3325 }
3326 function getOppositeAxis(axis) {
3327 return axis === "x" ? "y" : "x";
3328 }
3329 function getAxisLength(axis) {
3330 return axis === "y" ? "height" : "width";
3331 }
3332 function getSideAxis(placement) {
3333 const firstChar = placement[0];
3334 return firstChar === "t" || firstChar === "b" ? "y" : "x";
3335 }
3336 function getAlignmentAxis(placement) {
3337 return getOppositeAxis(getSideAxis(placement));
3338 }
3339 function getAlignmentSides(placement, rects, rtl) {
3340 if (rtl === void 0) {
3341 rtl = false;
3342 }
3343 const alignment = getAlignment(placement);
3344 const alignmentAxis = getAlignmentAxis(placement);
3345 const length = getAxisLength(alignmentAxis);
3346 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
3347 if (rects.reference[length] > rects.floating[length]) {
3348 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
3349 }
3350 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
3351 }
3352 function getExpandedPlacements(placement) {
3353 const oppositePlacement = getOppositePlacement(placement);
3354 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
3355 }
3356 function getOppositeAlignmentPlacement(placement) {
3357 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
3358 }
3359 var lrPlacement = ["left", "right"];
3360 var rlPlacement = ["right", "left"];
3361 var tbPlacement = ["top", "bottom"];
3362 var btPlacement = ["bottom", "top"];
3363 function getSideList(side, isStart, rtl) {
3364 switch (side) {
3365 case "top":
3366 case "bottom":
3367 if (rtl) return isStart ? rlPlacement : lrPlacement;
3368 return isStart ? lrPlacement : rlPlacement;
3369 case "left":
3370 case "right":
3371 return isStart ? tbPlacement : btPlacement;
3372 default:
3373 return [];
3374 }
3375 }
3376 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
3377 const alignment = getAlignment(placement);
3378 let list = getSideList(getSide(placement), direction === "start", rtl);
3379 if (alignment) {
3380 list = list.map((side) => side + "-" + alignment);
3381 if (flipAlignment) {
3382 list = list.concat(list.map(getOppositeAlignmentPlacement));
3383 }
3384 }
3385 return list;
3386 }
3387 function getOppositePlacement(placement) {
3388 const side = getSide(placement);
3389 return oppositeSideMap[side] + placement.slice(side.length);
3390 }
3391 function expandPaddingObject(padding) {
3392 return {
3393 top: 0,
3394 right: 0,
3395 bottom: 0,
3396 left: 0,
3397 ...padding
3398 };
3399 }
3400 function getPaddingObject(padding) {
3401 return typeof padding !== "number" ? expandPaddingObject(padding) : {
3402 top: padding,
3403 right: padding,
3404 bottom: padding,
3405 left: padding
3406 };
3407 }
3408 function rectToClientRect(rect) {
3409 const {
3410 x: x2,
3411 y: y2,
3412 width,
3413 height
3414 } = rect;
3415 return {
3416 width,
3417 height,
3418 top: y2,
3419 left: x2,
3420 right: x2 + width,
3421 bottom: y2 + height,
3422 x: x2,
3423 y: y2
3424 };
3425 }
3426
3427 // node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs
3428 function isHiddenByStyles(styles) {
3429 return styles.visibility === "hidden" || styles.visibility === "collapse";
3430 }
3431 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
3432 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
3433 return false;
3434 }
3435 if (typeof element.checkVisibility === "function") {
3436 return element.checkVisibility();
3437 }
3438 return styles.display !== "none" && styles.display !== "contents";
3439 }
3440
3441 // node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs
3442 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
3443 function getParentElement(element) {
3444 const assignedSlot = element.assignedSlot;
3445 if (assignedSlot) {
3446 return assignedSlot;
3447 }
3448 if (element.parentElement) {
3449 return element.parentElement;
3450 }
3451 const rootNode = element.getRootNode();
3452 return isShadowRoot(rootNode) ? rootNode.host : null;
3453 }
3454 function getDetailsSummary(details) {
3455 for (const child of Array.from(details.children)) {
3456 if (getNodeName(child) === "summary") {
3457 return child;
3458 }
3459 }
3460 return null;
3461 }
3462 function isWithinOpenDetailsSummary(element, details) {
3463 const summary = getDetailsSummary(details);
3464 return !!summary && (element === summary || contains(summary, element));
3465 }
3466 function isFocusableCandidate(element) {
3467 const nodeName = element ? getNodeName(element) : "";
3468 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");
3469 }
3470 function isFocusableElement(element) {
3471 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
3472 return false;
3473 }
3474 for (let current = element; current; current = getParentElement(current)) {
3475 const isAncestor = current !== element;
3476 const isSlot = getNodeName(current) === "slot";
3477 if (current.hasAttribute("inert")) {
3478 return false;
3479 }
3480 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
3481 return false;
3482 }
3483 }
3484 return true;
3485 }
3486 function isVisibleInTabbableTree(element, isAncestor) {
3487 const styles = getComputedStyle2(element);
3488 if (!isAncestor) {
3489 return isElementVisible(element, styles);
3490 }
3491 return styles.display !== "none";
3492 }
3493 function getTabIndex(element) {
3494 const tabIndex = element.tabIndex;
3495 if (tabIndex < 0) {
3496 const nodeName = getNodeName(element);
3497 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
3498 return 0;
3499 }
3500 }
3501 return tabIndex;
3502 }
3503 function getNamedRadioInput(element) {
3504 if (getNodeName(element) !== "input") {
3505 return null;
3506 }
3507 const input = element;
3508 return input.type === "radio" && input.name !== "" ? input : null;
3509 }
3510 function isTabbableRadio(element, candidates) {
3511 const input = getNamedRadioInput(element);
3512 if (!input) {
3513 return true;
3514 }
3515 const checkedRadio = candidates.find((candidate) => {
3516 const radio = getNamedRadioInput(candidate);
3517 return radio?.name === input.name && radio.form === input.form && radio.checked;
3518 });
3519 if (checkedRadio) {
3520 return checkedRadio === input;
3521 }
3522 return candidates.find((candidate) => {
3523 const radio = getNamedRadioInput(candidate);
3524 return radio?.name === input.name && radio.form === input.form;
3525 }) === input;
3526 }
3527 function getComposedChildren(container) {
3528 if (isHTMLElement(container) && getNodeName(container) === "slot") {
3529 const assignedElements = container.assignedElements({
3530 flatten: true
3531 });
3532 if (assignedElements.length > 0) {
3533 return assignedElements;
3534 }
3535 }
3536 if (isHTMLElement(container) && container.shadowRoot) {
3537 return Array.from(container.shadowRoot.children);
3538 }
3539 return Array.from(container.children);
3540 }
3541 function appendCandidates(container, list) {
3542 getComposedChildren(container).forEach((child) => {
3543 if (isFocusableCandidate(child)) {
3544 list.push(child);
3545 }
3546 appendCandidates(child, list);
3547 });
3548 }
3549 function appendMatchingElements(container, selector2, list) {
3550 getComposedChildren(container).forEach((child) => {
3551 if (isHTMLElement(child) && child.matches(selector2)) {
3552 list.push(child);
3553 }
3554 appendMatchingElements(child, selector2, list);
3555 });
3556 }
3557 function focusable(container) {
3558 const candidates = [];
3559 appendCandidates(container, candidates);
3560 return candidates.filter(isFocusableElement);
3561 }
3562 function tabbable(container) {
3563 const candidates = focusable(container);
3564 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
3565 }
3566 function getTabbableIn(container, dir) {
3567 const list = tabbable(container);
3568 const len = list.length;
3569 if (len === 0) {
3570 return void 0;
3571 }
3572 const active = activeElement(ownerDocument(container));
3573 const index2 = list.indexOf(active);
3574 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
3575 return list[nextIndex];
3576 }
3577 function getNextTabbable(referenceElement) {
3578 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
3579 }
3580 function getPreviousTabbable(referenceElement) {
3581 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
3582 }
3583 function isOutsideEvent(event, container) {
3584 const containerElement = container || event.currentTarget;
3585 const relatedTarget = event.relatedTarget;
3586 return !relatedTarget || !contains(containerElement, relatedTarget);
3587 }
3588 function disableFocusInside(container) {
3589 const tabbableElements = tabbable(container);
3590 tabbableElements.forEach((element) => {
3591 element.dataset.tabindex = element.getAttribute("tabindex") || "";
3592 element.setAttribute("tabindex", "-1");
3593 });
3594 }
3595 function enableFocusInside(container) {
3596 const elements = [];
3597 appendMatchingElements(container, "[data-tabindex]", elements);
3598 elements.forEach((element) => {
3599 const tabindex = element.dataset.tabindex;
3600 delete element.dataset.tabindex;
3601 if (tabindex) {
3602 element.setAttribute("tabindex", tabindex);
3603 } else {
3604 element.removeAttribute("tabindex");
3605 }
3606 });
3607 }
3608
3609 // node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs
3610 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
3611 const directChildren = nodes.filter((node) => node.parentId === id);
3612 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
3613 }
3614
3615 // node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs
3616 function createAttribute(name) {
3617 return `data-base-ui-${name}`;
3618 }
3619
3620 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3621 var React22 = __toESM(require_react(), 1);
3622 var ReactDOM2 = __toESM(require_react_dom(), 1);
3623
3624 // node_modules/@base-ui/react/internals/constants.mjs
3625 var DISABLED_TRANSITIONS_STYLE = {
3626 style: {
3627 transition: "none"
3628 }
3629 };
3630 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3631 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3632 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3633 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3634 var POPUP_COLLISION_AVOIDANCE = {
3635 fallbackAxisSide: "end"
3636 };
3637 var ownerVisuallyHidden = {
3638 clipPath: "inset(50%)",
3639 position: "fixed",
3640 top: 0,
3641 left: 0
3642 };
3643
3644 // node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
3645 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3646 var PortalContext = /* @__PURE__ */ React22.createContext(null);
3647 if (true) PortalContext.displayName = "PortalContext";
3648 var usePortalContext = () => React22.useContext(PortalContext);
3649 var attr = createAttribute("portal");
3650 function useFloatingPortalNode(props = {}) {
3651 const {
3652 ref,
3653 container: containerProp,
3654 componentProps = EMPTY_OBJECT,
3655 elementProps
3656 } = props;
3657 const uniqueId = useId();
3658 const portalContext = usePortalContext();
3659 const parentPortalNode = portalContext?.portalNode;
3660 const [containerElement, setContainerElement] = React22.useState(null);
3661 const [portalNode, setPortalNode] = React22.useState(null);
3662 const setPortalNodeRef = useStableCallback((node) => {
3663 if (node !== null) {
3664 setPortalNode(node);
3665 }
3666 });
3667 const containerRef = React22.useRef(null);
3668 useIsoLayoutEffect(() => {
3669 if (containerProp === null) {
3670 if (containerRef.current) {
3671 containerRef.current = null;
3672 setPortalNode(null);
3673 setContainerElement(null);
3674 }
3675 return;
3676 }
3677 if (uniqueId == null) {
3678 return;
3679 }
3680 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3681 if (resolvedContainer == null) {
3682 if (containerRef.current) {
3683 containerRef.current = null;
3684 setPortalNode(null);
3685 setContainerElement(null);
3686 }
3687 return;
3688 }
3689 if (containerRef.current !== resolvedContainer) {
3690 containerRef.current = resolvedContainer;
3691 setPortalNode(null);
3692 setContainerElement(resolvedContainer);
3693 }
3694 }, [containerProp, parentPortalNode, uniqueId]);
3695 const portalElement = useRenderElement("div", componentProps, {
3696 ref: [ref, setPortalNodeRef],
3697 props: [{
3698 id: uniqueId,
3699 [attr]: ""
3700 }, elementProps]
3701 });
3702 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3703 return {
3704 portalNode,
3705 portalSubtree
3706 };
3707 }
3708 var FloatingPortal = /* @__PURE__ */ React22.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3709 const {
3710 render: render4,
3711 className,
3712 style,
3713 children,
3714 container,
3715 renderGuards,
3716 ...elementProps
3717 } = componentProps;
3718 const {
3719 portalNode,
3720 portalSubtree
3721 } = useFloatingPortalNode({
3722 container,
3723 ref: forwardedRef,
3724 componentProps,
3725 elementProps
3726 });
3727 const beforeOutsideRef = React22.useRef(null);
3728 const afterOutsideRef = React22.useRef(null);
3729 const beforeInsideRef = React22.useRef(null);
3730 const afterInsideRef = React22.useRef(null);
3731 const [focusManagerState, setFocusManagerState] = React22.useState(null);
3732 const focusInsideDisabledRef = React22.useRef(false);
3733 const modal = focusManagerState?.modal;
3734 const open = focusManagerState?.open;
3735 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3736 React22.useEffect(() => {
3737 if (!portalNode || modal) {
3738 return void 0;
3739 }
3740 function onFocus(event) {
3741 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3742 if (event.type === "focusin") {
3743 if (focusInsideDisabledRef.current) {
3744 enableFocusInside(portalNode);
3745 focusInsideDisabledRef.current = false;
3746 }
3747 } else {
3748 disableFocusInside(portalNode);
3749 focusInsideDisabledRef.current = true;
3750 }
3751 }
3752 }
3753 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3754 }, [portalNode, modal]);
3755 useIsoLayoutEffect(() => {
3756 if (!portalNode || open !== true || !focusInsideDisabledRef.current) {
3757 return;
3758 }
3759 enableFocusInside(portalNode);
3760 focusInsideDisabledRef.current = false;
3761 }, [open, portalNode]);
3762 const portalContextValue = React22.useMemo(() => ({
3763 beforeOutsideRef,
3764 afterOutsideRef,
3765 beforeInsideRef,
3766 afterInsideRef,
3767 portalNode,
3768 setFocusManagerState
3769 }), [portalNode]);
3770 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React22.Fragment, {
3771 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
3772 value: portalContextValue,
3773 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3774 "data-type": "outside",
3775 ref: beforeOutsideRef,
3776 onFocus: (event) => {
3777 if (isOutsideEvent(event, portalNode)) {
3778 beforeInsideRef.current?.focus();
3779 } else {
3780 const domReference = focusManagerState ? focusManagerState.domReference : null;
3781 const prevTabbable = getPreviousTabbable(domReference);
3782 prevTabbable?.focus();
3783 }
3784 }
3785 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3786 "aria-owns": portalNode.id,
3787 style: ownerVisuallyHidden
3788 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3789 "data-type": "outside",
3790 ref: afterOutsideRef,
3791 onFocus: (event) => {
3792 if (isOutsideEvent(event, portalNode)) {
3793 afterInsideRef.current?.focus();
3794 } else {
3795 const domReference = focusManagerState ? focusManagerState.domReference : null;
3796 const nextTabbable = getNextTabbable(domReference);
3797 nextTabbable?.focus();
3798 if (focusManagerState?.closeOnFocusOut) {
3799 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3800 }
3801 }
3802 }
3803 })]
3804 })]
3805 });
3806 });
3807 if (true) FloatingPortal.displayName = "FloatingPortal";
3808
3809 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3810 var React23 = __toESM(require_react(), 1);
3811
3812 // node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs
3813 function createEventEmitter() {
3814 const map = /* @__PURE__ */ new Map();
3815 return {
3816 emit(event, data) {
3817 map.get(event)?.forEach((listener) => listener(data));
3818 },
3819 on(event, listener) {
3820 if (!map.has(event)) {
3821 map.set(event, /* @__PURE__ */ new Set());
3822 }
3823 map.get(event).add(listener);
3824 },
3825 off(event, listener) {
3826 map.get(event)?.delete(listener);
3827 }
3828 };
3829 }
3830
3831 // node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
3832 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3833 var FloatingNodeContext = /* @__PURE__ */ React23.createContext(null);
3834 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3835 var FloatingTreeContext = /* @__PURE__ */ React23.createContext(null);
3836 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3837 var useFloatingParentNodeId = () => React23.useContext(FloatingNodeContext)?.id || null;
3838 var useFloatingTree = (externalTree) => {
3839 const contextTree = React23.useContext(FloatingTreeContext);
3840 return externalTree ?? contextTree;
3841 };
3842
3843 // node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs
3844 var React24 = __toESM(require_react(), 1);
3845 function createVirtualElement(domElement, data) {
3846 let offsetX = null;
3847 let offsetY = null;
3848 let isAutoUpdateEvent = false;
3849 return {
3850 contextElement: domElement || void 0,
3851 getBoundingClientRect() {
3852 const domRect = domElement?.getBoundingClientRect() || {
3853 width: 0,
3854 height: 0,
3855 x: 0,
3856 y: 0
3857 };
3858 const isXAxis = data.axis === "x" || data.axis === "both";
3859 const isYAxis = data.axis === "y" || data.axis === "both";
3860 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3861 let width = domRect.width;
3862 let height = domRect.height;
3863 let x2 = domRect.x;
3864 let y2 = domRect.y;
3865 if (offsetX == null && data.x && isXAxis) {
3866 offsetX = domRect.x - data.x;
3867 }
3868 if (offsetY == null && data.y && isYAxis) {
3869 offsetY = domRect.y - data.y;
3870 }
3871 x2 -= offsetX || 0;
3872 y2 -= offsetY || 0;
3873 width = 0;
3874 height = 0;
3875 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3876 width = data.axis === "y" ? domRect.width : 0;
3877 height = data.axis === "x" ? domRect.height : 0;
3878 x2 = isXAxis && data.x != null ? data.x : x2;
3879 y2 = isYAxis && data.y != null ? data.y : y2;
3880 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3881 height = data.axis === "x" ? domRect.height : height;
3882 width = data.axis === "y" ? domRect.width : width;
3883 }
3884 isAutoUpdateEvent = true;
3885 return {
3886 width,
3887 height,
3888 x: x2,
3889 y: y2,
3890 top: y2,
3891 right: x2 + width,
3892 bottom: y2 + height,
3893 left: x2
3894 };
3895 }
3896 };
3897 }
3898 function isMouseBasedEvent(event) {
3899 return event != null && event.clientX != null;
3900 }
3901 function useClientPoint(context, props = {}) {
3902 const {
3903 enabled = true,
3904 axis = "both"
3905 } = props;
3906 const store = "rootStore" in context ? context.rootStore : context;
3907 const open = store.useState("open");
3908 const floating = store.useState("floatingElement");
3909 const domReference = store.useState("domReferenceElement");
3910 const dataRef = store.context.dataRef;
3911 const initialRef = React24.useRef(false);
3912 const cleanupListenerRef = React24.useRef(null);
3913 const [pointerType, setPointerType] = React24.useState();
3914 const [reactive, setReactive] = React24.useState([]);
3915 const resetReference = useStableCallback((reference2) => {
3916 store.set("positionReference", reference2);
3917 });
3918 const setReference = useStableCallback((newX, newY, referenceElement) => {
3919 if (initialRef.current) {
3920 return;
3921 }
3922 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3923 return;
3924 }
3925 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3926 x: newX,
3927 y: newY,
3928 axis,
3929 dataRef,
3930 pointerType
3931 }));
3932 });
3933 const handleReferenceEnterOrMove = useStableCallback((event) => {
3934 if (!open) {
3935 setReference(event.clientX, event.clientY, event.currentTarget);
3936 } else if (!cleanupListenerRef.current) {
3937 setReference(event.clientX, event.clientY, event.currentTarget);
3938 setReactive([]);
3939 }
3940 });
3941 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3942 React24.useEffect(() => {
3943 if (!enabled) {
3944 resetReference(domReference);
3945 return void 0;
3946 }
3947 if (!openCheck) {
3948 return void 0;
3949 }
3950 function cleanupListener() {
3951 cleanupListenerRef.current?.();
3952 cleanupListenerRef.current = null;
3953 }
3954 const win = getWindow(floating);
3955 function handleMouseMove(event) {
3956 const target = getTarget(event);
3957 if (!contains(floating, target)) {
3958 setReference(event.clientX, event.clientY);
3959 } else {
3960 cleanupListener();
3961 }
3962 }
3963 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3964 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3965 } else {
3966 resetReference(domReference);
3967 }
3968 return cleanupListener;
3969 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3970 React24.useEffect(() => () => {
3971 store.set("positionReference", null);
3972 }, [store]);
3973 React24.useEffect(() => {
3974 if (enabled && !floating) {
3975 initialRef.current = false;
3976 }
3977 }, [enabled, floating]);
3978 React24.useEffect(() => {
3979 if (!enabled && open) {
3980 initialRef.current = true;
3981 }
3982 }, [enabled, open]);
3983 const reference = React24.useMemo(() => {
3984 function setPointerTypeRef(event) {
3985 setPointerType(event.pointerType);
3986 }
3987 return {
3988 onPointerDown: setPointerTypeRef,
3989 onPointerEnter: setPointerTypeRef,
3990 onMouseMove: handleReferenceEnterOrMove,
3991 onMouseEnter: handleReferenceEnterOrMove
3992 };
3993 }, [handleReferenceEnterOrMove]);
3994 return React24.useMemo(() => enabled ? {
3995 reference,
3996 trigger: reference
3997 } : {}, [enabled, reference]);
3998 }
3999
4000 // node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs
4001 var React25 = __toESM(require_react(), 1);
4002 function alwaysFalse() {
4003 return false;
4004 }
4005 function normalizeProp(normalizable) {
4006 return {
4007 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
4008 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
4009 };
4010 }
4011 function useDismiss(context, props = {}) {
4012 const {
4013 enabled = true,
4014 escapeKey: escapeKey2 = true,
4015 outsidePress: outsidePressProp = true,
4016 outsidePressEvent = "sloppy",
4017 referencePress = alwaysFalse,
4018 bubbles,
4019 externalTree
4020 } = props;
4021 const store = "rootStore" in context ? context.rootStore : context;
4022 const open = store.useState("open");
4023 const floatingElement = store.useState("floatingElement");
4024 const {
4025 dataRef
4026 } = store.context;
4027 const tree = useFloatingTree(externalTree);
4028 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
4029 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
4030 const outsidePressEnabled = outsidePress2 !== false;
4031 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
4032 const {
4033 escapeKey: escapeKeyBubbles,
4034 outsidePress: outsidePressBubbles
4035 } = normalizeProp(bubbles);
4036 const pressStartedInsideRef = React25.useRef(false);
4037 const pressStartPreventedRef = React25.useRef(false);
4038 const suppressNextOutsideClickRef = React25.useRef(false);
4039 const isComposingRef = React25.useRef(false);
4040 const currentPointerTypeRef = React25.useRef("");
4041 const touchStateRef = React25.useRef(null);
4042 const cancelDismissOnEndTimeout = useTimeout();
4043 const clearInsideReactTreeTimeout = useTimeout();
4044 const clearInsideReactTree = useStableCallback(() => {
4045 clearInsideReactTreeTimeout.clear();
4046 dataRef.current.insideReactTree = false;
4047 });
4048 const hasBlockingChild = useStableCallback((bubbleKey) => {
4049 const nodeId = dataRef.current.floatingContext?.nodeId;
4050 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
4051 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
4052 });
4053 const isEventWithinOwnElements = useStableCallback((event) => {
4054 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
4055 });
4056 const closeOnReferencePress = useStableCallback((event) => {
4057 if (!referencePress()) {
4058 return;
4059 }
4060 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
4061 });
4062 const closeOnEscapeKeyDown = useStableCallback((event) => {
4063 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
4064 return;
4065 }
4066 if (isComposingRef.current) {
4067 return;
4068 }
4069 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
4070 return;
4071 }
4072 const native = isReactEvent(event) ? event.nativeEvent : event;
4073 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
4074 store.setOpen(false, eventDetails);
4075 if (!eventDetails.isCanceled) {
4076 event.preventDefault();
4077 }
4078 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
4079 event.stopPropagation();
4080 }
4081 });
4082 const markInsideReactTree = useStableCallback(() => {
4083 dataRef.current.insideReactTree = true;
4084 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
4085 });
4086 const markPressStartedInsideReactTree = useStableCallback((event) => {
4087 if (!open || !enabled || event.button !== 0) {
4088 return;
4089 }
4090 const target = getTarget(event.nativeEvent);
4091 if (!contains(store.select("floatingElement"), target)) {
4092 return;
4093 }
4094 if (!pressStartedInsideRef.current) {
4095 pressStartedInsideRef.current = true;
4096 pressStartPreventedRef.current = false;
4097 }
4098 });
4099 const markInsidePressStartPrevented = useStableCallback((event) => {
4100 if (!open || !enabled) {
4101 return;
4102 }
4103 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
4104 return;
4105 }
4106 if (pressStartedInsideRef.current) {
4107 pressStartPreventedRef.current = true;
4108 }
4109 });
4110 React25.useEffect(() => {
4111 if (!open || !enabled) {
4112 return void 0;
4113 }
4114 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
4115 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
4116 const compositionTimeout = new Timeout();
4117 const preventedPressSuppressionTimeout = new Timeout();
4118 function handleCompositionStart() {
4119 compositionTimeout.clear();
4120 isComposingRef.current = true;
4121 }
4122 function handleCompositionEnd() {
4123 compositionTimeout.start(
4124 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
4125 // Only apply to WebKit for the test to remain 0ms.
4126 parts_exports.engine.webkit ? 5 : 0,
4127 () => {
4128 isComposingRef.current = false;
4129 }
4130 );
4131 }
4132 function suppressImmediateOutsideClickAfterPreventedStart() {
4133 suppressNextOutsideClickRef.current = true;
4134 preventedPressSuppressionTimeout.start(0, () => {
4135 suppressNextOutsideClickRef.current = false;
4136 });
4137 }
4138 function resetPressStartState() {
4139 pressStartedInsideRef.current = false;
4140 pressStartPreventedRef.current = false;
4141 }
4142 function getOutsidePressEvent() {
4143 const type = currentPointerTypeRef.current;
4144 const computedType = type === "pen" || !type ? "mouse" : type;
4145 const outsidePressEventValue = getOutsidePressEventProp();
4146 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
4147 if (typeof resolved === "string") {
4148 return resolved;
4149 }
4150 return resolved[computedType];
4151 }
4152 function shouldIgnoreEvent(event) {
4153 const computedOutsidePressEvent = getOutsidePressEvent();
4154 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
4155 }
4156 function isEventWithinFloatingTree(event) {
4157 const nodeId = dataRef.current.floatingContext?.nodeId;
4158 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
4159 return isEventWithinOwnElements(event) || targetIsInsideChildren;
4160 }
4161 function closeOnPressOutside(event) {
4162 if (shouldIgnoreEvent(event)) {
4163 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
4164 preventedPressSuppressionTimeout.clear();
4165 suppressNextOutsideClickRef.current = false;
4166 }
4167 clearInsideReactTree();
4168 return;
4169 }
4170 if (dataRef.current.insideReactTree) {
4171 clearInsideReactTree();
4172 return;
4173 }
4174 const target = getTarget(event);
4175 const inertSelector = `[${createAttribute("inert")}]`;
4176 const targetRoot = isElement(target) ? target.getRootNode() : null;
4177 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
4178 const triggers = store.context.triggerElements;
4179 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
4180 return;
4181 }
4182 let targetRootAncestor = isElement(target) ? target : null;
4183 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
4184 const nextParent = getParentNode(targetRootAncestor);
4185 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
4186 break;
4187 }
4188 targetRootAncestor = nextParent;
4189 }
4190 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
4191 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
4192 // element was injected after the floating element rendered.
4193 markers.every((marker) => !contains(targetRootAncestor, marker))) {
4194 return;
4195 }
4196 if (isHTMLElement(target) && !("touches" in event)) {
4197 const lastTraversableNode = isLastTraversableNode(target);
4198 const style = getComputedStyle2(target);
4199 const scrollRe = /auto|scroll/;
4200 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
4201 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
4202 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
4203 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
4204 const isRTL7 = style.direction === "rtl";
4205 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
4206 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
4207 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
4208 return;
4209 }
4210 }
4211 if (isEventWithinFloatingTree(event)) {
4212 return;
4213 }
4214 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
4215 preventedPressSuppressionTimeout.clear();
4216 suppressNextOutsideClickRef.current = false;
4217 return;
4218 }
4219 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4220 return;
4221 }
4222 if (hasBlockingChild("__outsidePressBubbles")) {
4223 return;
4224 }
4225 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
4226 clearInsideReactTree();
4227 }
4228 function handlePointerDown(event) {
4229 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4230 return;
4231 }
4232 closeOnPressOutside(event);
4233 }
4234 function handleTouchStart(event) {
4235 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
4236 return;
4237 }
4238 const touch = event.touches[0];
4239 if (touch) {
4240 touchStateRef.current = {
4241 startTime: Date.now(),
4242 startX: touch.clientX,
4243 startY: touch.clientY,
4244 dismissOnTouchEnd: false,
4245 dismissOnMouseDown: true
4246 };
4247 cancelDismissOnEndTimeout.start(1e3, () => {
4248 if (touchStateRef.current) {
4249 touchStateRef.current.dismissOnTouchEnd = false;
4250 touchStateRef.current.dismissOnMouseDown = false;
4251 }
4252 });
4253 }
4254 }
4255 function addTargetEventListenerOnce(event, listener) {
4256 const target = getTarget(event);
4257 if (!target) {
4258 return;
4259 }
4260 const unsubscribe2 = addEventListener(target, event.type, () => {
4261 listener(event);
4262 unsubscribe2();
4263 });
4264 }
4265 function handleTouchStartCapture(event) {
4266 currentPointerTypeRef.current = "touch";
4267 addTargetEventListenerOnce(event, handleTouchStart);
4268 }
4269 function closeOnPressOutsideCapture(event) {
4270 cancelDismissOnEndTimeout.clear();
4271 if (event.type === "pointerdown") {
4272 currentPointerTypeRef.current = event.pointerType;
4273 }
4274 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
4275 return;
4276 }
4277 addTargetEventListenerOnce(event, (targetEvent) => {
4278 if (targetEvent.type === "pointerdown") {
4279 handlePointerDown(targetEvent);
4280 } else {
4281 closeOnPressOutside(targetEvent);
4282 }
4283 });
4284 }
4285 function handlePressEndCapture(event) {
4286 if (!pressStartedInsideRef.current) {
4287 return;
4288 }
4289 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
4290 resetPressStartState();
4291 if (getOutsidePressEvent() !== "intentional") {
4292 return;
4293 }
4294 if (event.type === "pointercancel") {
4295 if (pressStartedInsideDefaultPrevented) {
4296 suppressImmediateOutsideClickAfterPreventedStart();
4297 }
4298 return;
4299 }
4300 if (isEventWithinFloatingTree(event)) {
4301 return;
4302 }
4303 if (pressStartedInsideDefaultPrevented) {
4304 suppressImmediateOutsideClickAfterPreventedStart();
4305 return;
4306 }
4307 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
4308 return;
4309 }
4310 preventedPressSuppressionTimeout.clear();
4311 suppressNextOutsideClickRef.current = true;
4312 clearInsideReactTree();
4313 }
4314 function handleTouchMove(event) {
4315 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4316 return;
4317 }
4318 const touch = event.touches[0];
4319 if (!touch) {
4320 return;
4321 }
4322 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
4323 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
4324 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
4325 if (distance > 5) {
4326 touchStateRef.current.dismissOnTouchEnd = true;
4327 }
4328 if (distance > 10) {
4329 closeOnPressOutside(event);
4330 cancelDismissOnEndTimeout.clear();
4331 touchStateRef.current = null;
4332 }
4333 }
4334 function handleTouchMoveCapture(event) {
4335 addTargetEventListenerOnce(event, handleTouchMove);
4336 }
4337 function handleTouchEnd(event) {
4338 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
4339 return;
4340 }
4341 if (touchStateRef.current.dismissOnTouchEnd) {
4342 closeOnPressOutside(event);
4343 }
4344 cancelDismissOnEndTimeout.clear();
4345 touchStateRef.current = null;
4346 }
4347 function handleTouchEndCapture(event) {
4348 addTargetEventListenerOnce(event, handleTouchEnd);
4349 }
4350 const doc = ownerDocument(floatingElement);
4351 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)));
4352 return () => {
4353 unsubscribe();
4354 compositionTimeout.clear();
4355 preventedPressSuppressionTimeout.clear();
4356 resetPressStartState();
4357 suppressNextOutsideClickRef.current = false;
4358 };
4359 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
4360 React25.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
4361 const reference = React25.useMemo(() => ({
4362 onKeyDown: closeOnEscapeKeyDown,
4363 onPointerDown: closeOnReferencePress,
4364 onClick: closeOnReferencePress
4365 }), [closeOnEscapeKeyDown, closeOnReferencePress]);
4366 const floating = React25.useMemo(() => ({
4367 onKeyDown: closeOnEscapeKeyDown,
4368 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
4369 // `onPointerDown`, such as with <NumberField.ScrubArea>.
4370 // See https://github.com/mui/base-ui/pull/3379
4371 onPointerDown: markInsidePressStartPrevented,
4372 onMouseDown: markInsidePressStartPrevented,
4373 onClickCapture: markInsideReactTree,
4374 onMouseDownCapture(event) {
4375 markInsideReactTree();
4376 markPressStartedInsideReactTree(event);
4377 },
4378 onPointerDownCapture(event) {
4379 markInsideReactTree();
4380 markPressStartedInsideReactTree(event);
4381 },
4382 onMouseUpCapture: markInsideReactTree,
4383 onTouchEndCapture: markInsideReactTree,
4384 onTouchMoveCapture: markInsideReactTree
4385 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
4386 return React25.useMemo(() => enabled ? {
4387 reference,
4388 floating,
4389 trigger: reference
4390 } : {}, [enabled, reference, floating]);
4391 }
4392
4393 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
4394 var React32 = __toESM(require_react(), 1);
4395
4396 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
4397 function computeCoordsFromPlacement(_ref, placement, rtl) {
4398 let {
4399 reference,
4400 floating
4401 } = _ref;
4402 const sideAxis = getSideAxis(placement);
4403 const alignmentAxis = getAlignmentAxis(placement);
4404 const alignLength = getAxisLength(alignmentAxis);
4405 const side = getSide(placement);
4406 const isVertical = sideAxis === "y";
4407 const commonX = reference.x + reference.width / 2 - floating.width / 2;
4408 const commonY = reference.y + reference.height / 2 - floating.height / 2;
4409 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
4410 let coords;
4411 switch (side) {
4412 case "top":
4413 coords = {
4414 x: commonX,
4415 y: reference.y - floating.height
4416 };
4417 break;
4418 case "bottom":
4419 coords = {
4420 x: commonX,
4421 y: reference.y + reference.height
4422 };
4423 break;
4424 case "right":
4425 coords = {
4426 x: reference.x + reference.width,
4427 y: commonY
4428 };
4429 break;
4430 case "left":
4431 coords = {
4432 x: reference.x - floating.width,
4433 y: commonY
4434 };
4435 break;
4436 default:
4437 coords = {
4438 x: reference.x,
4439 y: reference.y
4440 };
4441 }
4442 switch (getAlignment(placement)) {
4443 case "start":
4444 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
4445 break;
4446 case "end":
4447 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
4448 break;
4449 }
4450 return coords;
4451 }
4452 async function detectOverflow(state, options) {
4453 var _await$platform$isEle;
4454 if (options === void 0) {
4455 options = {};
4456 }
4457 const {
4458 x: x2,
4459 y: y2,
4460 platform: platform3,
4461 rects,
4462 elements,
4463 strategy
4464 } = state;
4465 const {
4466 boundary = "clippingAncestors",
4467 rootBoundary = "viewport",
4468 elementContext = "floating",
4469 altBoundary = false,
4470 padding = 0
4471 } = evaluate(options, state);
4472 const paddingObject = getPaddingObject(padding);
4473 const altContext = elementContext === "floating" ? "reference" : "floating";
4474 const element = elements[altBoundary ? altContext : elementContext];
4475 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
4476 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)),
4477 boundary,
4478 rootBoundary,
4479 strategy
4480 }));
4481 const rect = elementContext === "floating" ? {
4482 x: x2,
4483 y: y2,
4484 width: rects.floating.width,
4485 height: rects.floating.height
4486 } : rects.reference;
4487 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
4488 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
4489 x: 1,
4490 y: 1
4491 } : {
4492 x: 1,
4493 y: 1
4494 };
4495 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
4496 elements,
4497 rect,
4498 offsetParent,
4499 strategy
4500 }) : rect);
4501 return {
4502 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
4503 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
4504 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
4505 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
4506 };
4507 }
4508 var MAX_RESET_COUNT = 50;
4509 var computePosition = async (reference, floating, config) => {
4510 const {
4511 placement = "bottom",
4512 strategy = "absolute",
4513 middleware = [],
4514 platform: platform3
4515 } = config;
4516 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
4517 ...platform3,
4518 detectOverflow
4519 };
4520 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
4521 let rects = await platform3.getElementRects({
4522 reference,
4523 floating,
4524 strategy
4525 });
4526 let {
4527 x: x2,
4528 y: y2
4529 } = computeCoordsFromPlacement(rects, placement, rtl);
4530 let statefulPlacement = placement;
4531 let resetCount = 0;
4532 const middlewareData = {};
4533 for (let i2 = 0; i2 < middleware.length; i2++) {
4534 const currentMiddleware = middleware[i2];
4535 if (!currentMiddleware) {
4536 continue;
4537 }
4538 const {
4539 name,
4540 fn
4541 } = currentMiddleware;
4542 const {
4543 x: nextX,
4544 y: nextY,
4545 data,
4546 reset
4547 } = await fn({
4548 x: x2,
4549 y: y2,
4550 initialPlacement: placement,
4551 placement: statefulPlacement,
4552 strategy,
4553 middlewareData,
4554 rects,
4555 platform: platformWithDetectOverflow,
4556 elements: {
4557 reference,
4558 floating
4559 }
4560 });
4561 x2 = nextX != null ? nextX : x2;
4562 y2 = nextY != null ? nextY : y2;
4563 middlewareData[name] = {
4564 ...middlewareData[name],
4565 ...data
4566 };
4567 if (reset && resetCount < MAX_RESET_COUNT) {
4568 resetCount++;
4569 if (typeof reset === "object") {
4570 if (reset.placement) {
4571 statefulPlacement = reset.placement;
4572 }
4573 if (reset.rects) {
4574 rects = reset.rects === true ? await platform3.getElementRects({
4575 reference,
4576 floating,
4577 strategy
4578 }) : reset.rects;
4579 }
4580 ({
4581 x: x2,
4582 y: y2
4583 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4584 }
4585 i2 = -1;
4586 }
4587 }
4588 return {
4589 x: x2,
4590 y: y2,
4591 placement: statefulPlacement,
4592 strategy,
4593 middlewareData
4594 };
4595 };
4596 var flip = function(options) {
4597 if (options === void 0) {
4598 options = {};
4599 }
4600 return {
4601 name: "flip",
4602 options,
4603 async fn(state) {
4604 var _middlewareData$arrow, _middlewareData$flip;
4605 const {
4606 placement,
4607 middlewareData,
4608 rects,
4609 initialPlacement,
4610 platform: platform3,
4611 elements
4612 } = state;
4613 const {
4614 mainAxis: checkMainAxis = true,
4615 crossAxis: checkCrossAxis = true,
4616 fallbackPlacements: specifiedFallbackPlacements,
4617 fallbackStrategy = "bestFit",
4618 fallbackAxisSideDirection = "none",
4619 flipAlignment = true,
4620 ...detectOverflowOptions
4621 } = evaluate(options, state);
4622 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4623 return {};
4624 }
4625 const side = getSide(placement);
4626 const initialSideAxis = getSideAxis(initialPlacement);
4627 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4628 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4629 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4630 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4631 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4632 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4633 }
4634 const placements2 = [initialPlacement, ...fallbackPlacements];
4635 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4636 const overflows = [];
4637 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4638 if (checkMainAxis) {
4639 overflows.push(overflow[side]);
4640 }
4641 if (checkCrossAxis) {
4642 const sides2 = getAlignmentSides(placement, rects, rtl);
4643 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4644 }
4645 overflowsData = [...overflowsData, {
4646 placement,
4647 overflows
4648 }];
4649 if (!overflows.every((side2) => side2 <= 0)) {
4650 var _middlewareData$flip2, _overflowsData$filter;
4651 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4652 const nextPlacement = placements2[nextIndex];
4653 if (nextPlacement) {
4654 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4655 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4656 // overflows the main axis.
4657 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4658 return {
4659 data: {
4660 index: nextIndex,
4661 overflows: overflowsData
4662 },
4663 reset: {
4664 placement: nextPlacement
4665 }
4666 };
4667 }
4668 }
4669 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;
4670 if (!resetPlacement) {
4671 switch (fallbackStrategy) {
4672 case "bestFit": {
4673 var _overflowsData$filter2;
4674 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4675 if (hasFallbackAxisSideDirection) {
4676 const currentSideAxis = getSideAxis(d2.placement);
4677 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4678 // reading directions favoring greater width.
4679 currentSideAxis === "y";
4680 }
4681 return true;
4682 }).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];
4683 if (placement2) {
4684 resetPlacement = placement2;
4685 }
4686 break;
4687 }
4688 case "initialPlacement":
4689 resetPlacement = initialPlacement;
4690 break;
4691 }
4692 }
4693 if (placement !== resetPlacement) {
4694 return {
4695 reset: {
4696 placement: resetPlacement
4697 }
4698 };
4699 }
4700 }
4701 return {};
4702 }
4703 };
4704 };
4705 function getSideOffsets(overflow, rect) {
4706 return {
4707 top: overflow.top - rect.height,
4708 right: overflow.right - rect.width,
4709 bottom: overflow.bottom - rect.height,
4710 left: overflow.left - rect.width
4711 };
4712 }
4713 function isAnySideFullyClipped(overflow) {
4714 return sides.some((side) => overflow[side] >= 0);
4715 }
4716 var hide = function(options) {
4717 if (options === void 0) {
4718 options = {};
4719 }
4720 return {
4721 name: "hide",
4722 options,
4723 async fn(state) {
4724 const {
4725 rects,
4726 platform: platform3
4727 } = state;
4728 const {
4729 strategy = "referenceHidden",
4730 ...detectOverflowOptions
4731 } = evaluate(options, state);
4732 switch (strategy) {
4733 case "referenceHidden": {
4734 const overflow = await platform3.detectOverflow(state, {
4735 ...detectOverflowOptions,
4736 elementContext: "reference"
4737 });
4738 const offsets = getSideOffsets(overflow, rects.reference);
4739 return {
4740 data: {
4741 referenceHiddenOffsets: offsets,
4742 referenceHidden: isAnySideFullyClipped(offsets)
4743 }
4744 };
4745 }
4746 case "escaped": {
4747 const overflow = await platform3.detectOverflow(state, {
4748 ...detectOverflowOptions,
4749 altBoundary: true
4750 });
4751 const offsets = getSideOffsets(overflow, rects.floating);
4752 return {
4753 data: {
4754 escapedOffsets: offsets,
4755 escaped: isAnySideFullyClipped(offsets)
4756 }
4757 };
4758 }
4759 default: {
4760 return {};
4761 }
4762 }
4763 }
4764 };
4765 };
4766 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4767 async function convertValueToCoords(state, options) {
4768 const {
4769 placement,
4770 platform: platform3,
4771 elements
4772 } = state;
4773 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4774 const side = getSide(placement);
4775 const alignment = getAlignment(placement);
4776 const isVertical = getSideAxis(placement) === "y";
4777 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4778 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4779 const rawValue = evaluate(options, state);
4780 let {
4781 mainAxis,
4782 crossAxis,
4783 alignmentAxis
4784 } = typeof rawValue === "number" ? {
4785 mainAxis: rawValue,
4786 crossAxis: 0,
4787 alignmentAxis: null
4788 } : {
4789 mainAxis: rawValue.mainAxis || 0,
4790 crossAxis: rawValue.crossAxis || 0,
4791 alignmentAxis: rawValue.alignmentAxis
4792 };
4793 if (alignment && typeof alignmentAxis === "number") {
4794 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4795 }
4796 return isVertical ? {
4797 x: crossAxis * crossAxisMulti,
4798 y: mainAxis * mainAxisMulti
4799 } : {
4800 x: mainAxis * mainAxisMulti,
4801 y: crossAxis * crossAxisMulti
4802 };
4803 }
4804 var offset = function(options) {
4805 if (options === void 0) {
4806 options = 0;
4807 }
4808 return {
4809 name: "offset",
4810 options,
4811 async fn(state) {
4812 var _middlewareData$offse, _middlewareData$arrow;
4813 const {
4814 x: x2,
4815 y: y2,
4816 placement,
4817 middlewareData
4818 } = state;
4819 const diffCoords = await convertValueToCoords(state, options);
4820 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4821 return {};
4822 }
4823 return {
4824 x: x2 + diffCoords.x,
4825 y: y2 + diffCoords.y,
4826 data: {
4827 ...diffCoords,
4828 placement
4829 }
4830 };
4831 }
4832 };
4833 };
4834 var shift = function(options) {
4835 if (options === void 0) {
4836 options = {};
4837 }
4838 return {
4839 name: "shift",
4840 options,
4841 async fn(state) {
4842 const {
4843 x: x2,
4844 y: y2,
4845 placement,
4846 platform: platform3
4847 } = state;
4848 const {
4849 mainAxis: checkMainAxis = true,
4850 crossAxis: checkCrossAxis = false,
4851 limiter = {
4852 fn: (_ref) => {
4853 let {
4854 x: x3,
4855 y: y3
4856 } = _ref;
4857 return {
4858 x: x3,
4859 y: y3
4860 };
4861 }
4862 },
4863 ...detectOverflowOptions
4864 } = evaluate(options, state);
4865 const coords = {
4866 x: x2,
4867 y: y2
4868 };
4869 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4870 const crossAxis = getSideAxis(getSide(placement));
4871 const mainAxis = getOppositeAxis(crossAxis);
4872 let mainAxisCoord = coords[mainAxis];
4873 let crossAxisCoord = coords[crossAxis];
4874 if (checkMainAxis) {
4875 const minSide = mainAxis === "y" ? "top" : "left";
4876 const maxSide = mainAxis === "y" ? "bottom" : "right";
4877 const min2 = mainAxisCoord + overflow[minSide];
4878 const max2 = mainAxisCoord - overflow[maxSide];
4879 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4880 }
4881 if (checkCrossAxis) {
4882 const minSide = crossAxis === "y" ? "top" : "left";
4883 const maxSide = crossAxis === "y" ? "bottom" : "right";
4884 const min2 = crossAxisCoord + overflow[minSide];
4885 const max2 = crossAxisCoord - overflow[maxSide];
4886 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4887 }
4888 const limitedCoords = limiter.fn({
4889 ...state,
4890 [mainAxis]: mainAxisCoord,
4891 [crossAxis]: crossAxisCoord
4892 });
4893 return {
4894 ...limitedCoords,
4895 data: {
4896 x: limitedCoords.x - x2,
4897 y: limitedCoords.y - y2,
4898 enabled: {
4899 [mainAxis]: checkMainAxis,
4900 [crossAxis]: checkCrossAxis
4901 }
4902 }
4903 };
4904 }
4905 };
4906 };
4907 var limitShift = function(options) {
4908 if (options === void 0) {
4909 options = {};
4910 }
4911 return {
4912 options,
4913 fn(state) {
4914 const {
4915 x: x2,
4916 y: y2,
4917 placement,
4918 rects,
4919 middlewareData
4920 } = state;
4921 const {
4922 offset: offset4 = 0,
4923 mainAxis: checkMainAxis = true,
4924 crossAxis: checkCrossAxis = true
4925 } = evaluate(options, state);
4926 const coords = {
4927 x: x2,
4928 y: y2
4929 };
4930 const crossAxis = getSideAxis(placement);
4931 const mainAxis = getOppositeAxis(crossAxis);
4932 let mainAxisCoord = coords[mainAxis];
4933 let crossAxisCoord = coords[crossAxis];
4934 const rawOffset = evaluate(offset4, state);
4935 const computedOffset = typeof rawOffset === "number" ? {
4936 mainAxis: rawOffset,
4937 crossAxis: 0
4938 } : {
4939 mainAxis: 0,
4940 crossAxis: 0,
4941 ...rawOffset
4942 };
4943 if (checkMainAxis) {
4944 const len = mainAxis === "y" ? "height" : "width";
4945 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4946 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4947 if (mainAxisCoord < limitMin) {
4948 mainAxisCoord = limitMin;
4949 } else if (mainAxisCoord > limitMax) {
4950 mainAxisCoord = limitMax;
4951 }
4952 }
4953 if (checkCrossAxis) {
4954 var _middlewareData$offse, _middlewareData$offse2;
4955 const len = mainAxis === "y" ? "width" : "height";
4956 const isOriginSide = originSides.has(getSide(placement));
4957 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);
4958 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);
4959 if (crossAxisCoord < limitMin) {
4960 crossAxisCoord = limitMin;
4961 } else if (crossAxisCoord > limitMax) {
4962 crossAxisCoord = limitMax;
4963 }
4964 }
4965 return {
4966 [mainAxis]: mainAxisCoord,
4967 [crossAxis]: crossAxisCoord
4968 };
4969 }
4970 };
4971 };
4972 var size = function(options) {
4973 if (options === void 0) {
4974 options = {};
4975 }
4976 return {
4977 name: "size",
4978 options,
4979 async fn(state) {
4980 var _state$middlewareData, _state$middlewareData2;
4981 const {
4982 placement,
4983 rects,
4984 platform: platform3,
4985 elements
4986 } = state;
4987 const {
4988 apply = () => {
4989 },
4990 ...detectOverflowOptions
4991 } = evaluate(options, state);
4992 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4993 const side = getSide(placement);
4994 const alignment = getAlignment(placement);
4995 const isYAxis = getSideAxis(placement) === "y";
4996 const {
4997 width,
4998 height
4999 } = rects.floating;
5000 let heightSide;
5001 let widthSide;
5002 if (side === "top" || side === "bottom") {
5003 heightSide = side;
5004 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
5005 } else {
5006 widthSide = side;
5007 heightSide = alignment === "end" ? "top" : "bottom";
5008 }
5009 const maximumClippingHeight = height - overflow.top - overflow.bottom;
5010 const maximumClippingWidth = width - overflow.left - overflow.right;
5011 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
5012 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
5013 const noShift = !state.middlewareData.shift;
5014 let availableHeight = overflowAvailableHeight;
5015 let availableWidth = overflowAvailableWidth;
5016 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
5017 availableWidth = maximumClippingWidth;
5018 }
5019 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
5020 availableHeight = maximumClippingHeight;
5021 }
5022 if (noShift && !alignment) {
5023 const xMin = max(overflow.left, 0);
5024 const xMax = max(overflow.right, 0);
5025 const yMin = max(overflow.top, 0);
5026 const yMax = max(overflow.bottom, 0);
5027 if (isYAxis) {
5028 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
5029 } else {
5030 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
5031 }
5032 }
5033 await apply({
5034 ...state,
5035 availableWidth,
5036 availableHeight
5037 });
5038 const nextDimensions = await platform3.getDimensions(elements.floating);
5039 if (width !== nextDimensions.width || height !== nextDimensions.height) {
5040 return {
5041 reset: {
5042 rects: true
5043 }
5044 };
5045 }
5046 return {};
5047 }
5048 };
5049 };
5050
5051 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
5052 function getCssDimensions(element) {
5053 const css = getComputedStyle2(element);
5054 let width = parseFloat(css.width) || 0;
5055 let height = parseFloat(css.height) || 0;
5056 const hasOffset = isHTMLElement(element);
5057 const offsetWidth = hasOffset ? element.offsetWidth : width;
5058 const offsetHeight = hasOffset ? element.offsetHeight : height;
5059 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
5060 if (shouldFallback) {
5061 width = offsetWidth;
5062 height = offsetHeight;
5063 }
5064 return {
5065 width,
5066 height,
5067 $: shouldFallback
5068 };
5069 }
5070 function unwrapElement(element) {
5071 return !isElement(element) ? element.contextElement : element;
5072 }
5073 function getScale(element) {
5074 const domElement = unwrapElement(element);
5075 if (!isHTMLElement(domElement)) {
5076 return createCoords(1);
5077 }
5078 const rect = domElement.getBoundingClientRect();
5079 const {
5080 width,
5081 height,
5082 $: $2
5083 } = getCssDimensions(domElement);
5084 let x2 = ($2 ? round(rect.width) : rect.width) / width;
5085 let y2 = ($2 ? round(rect.height) : rect.height) / height;
5086 if (!x2 || !Number.isFinite(x2)) {
5087 x2 = 1;
5088 }
5089 if (!y2 || !Number.isFinite(y2)) {
5090 y2 = 1;
5091 }
5092 return {
5093 x: x2,
5094 y: y2
5095 };
5096 }
5097 var noOffsets = /* @__PURE__ */ createCoords(0);
5098 function getVisualOffsets(element) {
5099 const win = getWindow(element);
5100 if (!isWebKit() || !win.visualViewport) {
5101 return noOffsets;
5102 }
5103 return {
5104 x: win.visualViewport.offsetLeft,
5105 y: win.visualViewport.offsetTop
5106 };
5107 }
5108 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
5109 if (isFixed === void 0) {
5110 isFixed = false;
5111 }
5112 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
5113 return false;
5114 }
5115 return isFixed;
5116 }
5117 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
5118 if (includeScale === void 0) {
5119 includeScale = false;
5120 }
5121 if (isFixedStrategy === void 0) {
5122 isFixedStrategy = false;
5123 }
5124 const clientRect = element.getBoundingClientRect();
5125 const domElement = unwrapElement(element);
5126 let scale = createCoords(1);
5127 if (includeScale) {
5128 if (offsetParent) {
5129 if (isElement(offsetParent)) {
5130 scale = getScale(offsetParent);
5131 }
5132 } else {
5133 scale = getScale(element);
5134 }
5135 }
5136 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
5137 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
5138 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
5139 let width = clientRect.width / scale.x;
5140 let height = clientRect.height / scale.y;
5141 if (domElement) {
5142 const win = getWindow(domElement);
5143 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
5144 let currentWin = win;
5145 let currentIFrame = getFrameElement(currentWin);
5146 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
5147 const iframeScale = getScale(currentIFrame);
5148 const iframeRect = currentIFrame.getBoundingClientRect();
5149 const css = getComputedStyle2(currentIFrame);
5150 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
5151 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
5152 x2 *= iframeScale.x;
5153 y2 *= iframeScale.y;
5154 width *= iframeScale.x;
5155 height *= iframeScale.y;
5156 x2 += left;
5157 y2 += top;
5158 currentWin = getWindow(currentIFrame);
5159 currentIFrame = getFrameElement(currentWin);
5160 }
5161 }
5162 return rectToClientRect({
5163 width,
5164 height,
5165 x: x2,
5166 y: y2
5167 });
5168 }
5169 function getWindowScrollBarX(element, rect) {
5170 const leftScroll = getNodeScroll(element).scrollLeft;
5171 if (!rect) {
5172 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
5173 }
5174 return rect.left + leftScroll;
5175 }
5176 function getHTMLOffset(documentElement, scroll) {
5177 const htmlRect = documentElement.getBoundingClientRect();
5178 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
5179 const y2 = htmlRect.top + scroll.scrollTop;
5180 return {
5181 x: x2,
5182 y: y2
5183 };
5184 }
5185 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
5186 let {
5187 elements,
5188 rect,
5189 offsetParent,
5190 strategy
5191 } = _ref;
5192 const isFixed = strategy === "fixed";
5193 const documentElement = getDocumentElement(offsetParent);
5194 const topLayer = elements ? isTopLayer(elements.floating) : false;
5195 if (offsetParent === documentElement || topLayer && isFixed) {
5196 return rect;
5197 }
5198 let scroll = {
5199 scrollLeft: 0,
5200 scrollTop: 0
5201 };
5202 let scale = createCoords(1);
5203 const offsets = createCoords(0);
5204 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5205 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5206 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5207 scroll = getNodeScroll(offsetParent);
5208 }
5209 if (isOffsetParentAnElement) {
5210 const offsetRect = getBoundingClientRect(offsetParent);
5211 scale = getScale(offsetParent);
5212 offsets.x = offsetRect.x + offsetParent.clientLeft;
5213 offsets.y = offsetRect.y + offsetParent.clientTop;
5214 }
5215 }
5216 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5217 return {
5218 width: rect.width * scale.x,
5219 height: rect.height * scale.y,
5220 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
5221 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
5222 };
5223 }
5224 function getClientRects(element) {
5225 return Array.from(element.getClientRects());
5226 }
5227 function getDocumentRect(element) {
5228 const html = getDocumentElement(element);
5229 const scroll = getNodeScroll(element);
5230 const body = element.ownerDocument.body;
5231 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
5232 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
5233 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
5234 const y2 = -scroll.scrollTop;
5235 if (getComputedStyle2(body).direction === "rtl") {
5236 x2 += max(html.clientWidth, body.clientWidth) - width;
5237 }
5238 return {
5239 width,
5240 height,
5241 x: x2,
5242 y: y2
5243 };
5244 }
5245 var SCROLLBAR_MAX = 25;
5246 function getViewportRect(element, strategy) {
5247 const win = getWindow(element);
5248 const html = getDocumentElement(element);
5249 const visualViewport = win.visualViewport;
5250 let width = html.clientWidth;
5251 let height = html.clientHeight;
5252 let x2 = 0;
5253 let y2 = 0;
5254 if (visualViewport) {
5255 width = visualViewport.width;
5256 height = visualViewport.height;
5257 const visualViewportBased = isWebKit();
5258 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
5259 x2 = visualViewport.offsetLeft;
5260 y2 = visualViewport.offsetTop;
5261 }
5262 }
5263 const windowScrollbarX = getWindowScrollBarX(html);
5264 if (windowScrollbarX <= 0) {
5265 const doc = html.ownerDocument;
5266 const body = doc.body;
5267 const bodyStyles = getComputedStyle(body);
5268 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
5269 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
5270 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
5271 width -= clippingStableScrollbarWidth;
5272 }
5273 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
5274 width += windowScrollbarX;
5275 }
5276 return {
5277 width,
5278 height,
5279 x: x2,
5280 y: y2
5281 };
5282 }
5283 function getInnerBoundingClientRect(element, strategy) {
5284 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
5285 const top = clientRect.top + element.clientTop;
5286 const left = clientRect.left + element.clientLeft;
5287 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
5288 const width = element.clientWidth * scale.x;
5289 const height = element.clientHeight * scale.y;
5290 const x2 = left * scale.x;
5291 const y2 = top * scale.y;
5292 return {
5293 width,
5294 height,
5295 x: x2,
5296 y: y2
5297 };
5298 }
5299 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
5300 let rect;
5301 if (clippingAncestor === "viewport") {
5302 rect = getViewportRect(element, strategy);
5303 } else if (clippingAncestor === "document") {
5304 rect = getDocumentRect(getDocumentElement(element));
5305 } else if (isElement(clippingAncestor)) {
5306 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
5307 } else {
5308 const visualOffsets = getVisualOffsets(element);
5309 rect = {
5310 x: clippingAncestor.x - visualOffsets.x,
5311 y: clippingAncestor.y - visualOffsets.y,
5312 width: clippingAncestor.width,
5313 height: clippingAncestor.height
5314 };
5315 }
5316 return rectToClientRect(rect);
5317 }
5318 function hasFixedPositionAncestor(element, stopNode) {
5319 const parentNode = getParentNode(element);
5320 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
5321 return false;
5322 }
5323 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
5324 }
5325 function getClippingElementAncestors(element, cache) {
5326 const cachedResult = cache.get(element);
5327 if (cachedResult) {
5328 return cachedResult;
5329 }
5330 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
5331 let currentContainingBlockComputedStyle = null;
5332 const elementIsFixed = getComputedStyle2(element).position === "fixed";
5333 let currentNode = elementIsFixed ? getParentNode(element) : element;
5334 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
5335 const computedStyle = getComputedStyle2(currentNode);
5336 const currentNodeIsContaining = isContainingBlock(currentNode);
5337 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
5338 currentContainingBlockComputedStyle = null;
5339 }
5340 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
5341 if (shouldDropCurrentNode) {
5342 result = result.filter((ancestor) => ancestor !== currentNode);
5343 } else {
5344 currentContainingBlockComputedStyle = computedStyle;
5345 }
5346 currentNode = getParentNode(currentNode);
5347 }
5348 cache.set(element, result);
5349 return result;
5350 }
5351 function getClippingRect(_ref) {
5352 let {
5353 element,
5354 boundary,
5355 rootBoundary,
5356 strategy
5357 } = _ref;
5358 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
5359 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
5360 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
5361 let top = firstRect.top;
5362 let right = firstRect.right;
5363 let bottom = firstRect.bottom;
5364 let left = firstRect.left;
5365 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
5366 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
5367 top = max(rect.top, top);
5368 right = min(rect.right, right);
5369 bottom = min(rect.bottom, bottom);
5370 left = max(rect.left, left);
5371 }
5372 return {
5373 width: right - left,
5374 height: bottom - top,
5375 x: left,
5376 y: top
5377 };
5378 }
5379 function getDimensions2(element) {
5380 const {
5381 width,
5382 height
5383 } = getCssDimensions(element);
5384 return {
5385 width,
5386 height
5387 };
5388 }
5389 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
5390 const isOffsetParentAnElement = isHTMLElement(offsetParent);
5391 const documentElement = getDocumentElement(offsetParent);
5392 const isFixed = strategy === "fixed";
5393 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
5394 let scroll = {
5395 scrollLeft: 0,
5396 scrollTop: 0
5397 };
5398 const offsets = createCoords(0);
5399 function setLeftRTLScrollbarOffset() {
5400 offsets.x = getWindowScrollBarX(documentElement);
5401 }
5402 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5403 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
5404 scroll = getNodeScroll(offsetParent);
5405 }
5406 if (isOffsetParentAnElement) {
5407 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
5408 offsets.x = offsetRect.x + offsetParent.clientLeft;
5409 offsets.y = offsetRect.y + offsetParent.clientTop;
5410 } else if (documentElement) {
5411 setLeftRTLScrollbarOffset();
5412 }
5413 }
5414 if (isFixed && !isOffsetParentAnElement && documentElement) {
5415 setLeftRTLScrollbarOffset();
5416 }
5417 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
5418 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
5419 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
5420 return {
5421 x: x2,
5422 y: y2,
5423 width: rect.width,
5424 height: rect.height
5425 };
5426 }
5427 function isStaticPositioned(element) {
5428 return getComputedStyle2(element).position === "static";
5429 }
5430 function getTrueOffsetParent(element, polyfill) {
5431 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
5432 return null;
5433 }
5434 if (polyfill) {
5435 return polyfill(element);
5436 }
5437 let rawOffsetParent = element.offsetParent;
5438 if (getDocumentElement(element) === rawOffsetParent) {
5439 rawOffsetParent = rawOffsetParent.ownerDocument.body;
5440 }
5441 return rawOffsetParent;
5442 }
5443 function getOffsetParent(element, polyfill) {
5444 const win = getWindow(element);
5445 if (isTopLayer(element)) {
5446 return win;
5447 }
5448 if (!isHTMLElement(element)) {
5449 let svgOffsetParent = getParentNode(element);
5450 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
5451 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
5452 return svgOffsetParent;
5453 }
5454 svgOffsetParent = getParentNode(svgOffsetParent);
5455 }
5456 return win;
5457 }
5458 let offsetParent = getTrueOffsetParent(element, polyfill);
5459 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
5460 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
5461 }
5462 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
5463 return win;
5464 }
5465 return offsetParent || getContainingBlock(element) || win;
5466 }
5467 var getElementRects = async function(data) {
5468 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
5469 const getDimensionsFn = this.getDimensions;
5470 const floatingDimensions = await getDimensionsFn(data.floating);
5471 return {
5472 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
5473 floating: {
5474 x: 0,
5475 y: 0,
5476 width: floatingDimensions.width,
5477 height: floatingDimensions.height
5478 }
5479 };
5480 };
5481 function isRTL(element) {
5482 return getComputedStyle2(element).direction === "rtl";
5483 }
5484 var platform2 = {
5485 convertOffsetParentRelativeRectToViewportRelativeRect,
5486 getDocumentElement,
5487 getClippingRect,
5488 getOffsetParent,
5489 getElementRects,
5490 getClientRects,
5491 getDimensions: getDimensions2,
5492 getScale,
5493 isElement,
5494 isRTL
5495 };
5496 function rectsAreEqual(a2, b2) {
5497 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
5498 }
5499 function observeMove(element, onMove) {
5500 let io = null;
5501 let timeoutId;
5502 const root = getDocumentElement(element);
5503 function cleanup() {
5504 var _io;
5505 clearTimeout(timeoutId);
5506 (_io = io) == null || _io.disconnect();
5507 io = null;
5508 }
5509 function refresh(skip, threshold) {
5510 if (skip === void 0) {
5511 skip = false;
5512 }
5513 if (threshold === void 0) {
5514 threshold = 1;
5515 }
5516 cleanup();
5517 const elementRectForRootMargin = element.getBoundingClientRect();
5518 const {
5519 left,
5520 top,
5521 width,
5522 height
5523 } = elementRectForRootMargin;
5524 if (!skip) {
5525 onMove();
5526 }
5527 if (!width || !height) {
5528 return;
5529 }
5530 const insetTop = floor(top);
5531 const insetRight = floor(root.clientWidth - (left + width));
5532 const insetBottom = floor(root.clientHeight - (top + height));
5533 const insetLeft = floor(left);
5534 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
5535 const options = {
5536 rootMargin,
5537 threshold: max(0, min(1, threshold)) || 1
5538 };
5539 let isFirstUpdate = true;
5540 function handleObserve(entries) {
5541 const ratio = entries[0].intersectionRatio;
5542 if (ratio !== threshold) {
5543 if (!isFirstUpdate) {
5544 return refresh();
5545 }
5546 if (!ratio) {
5547 timeoutId = setTimeout(() => {
5548 refresh(false, 1e-7);
5549 }, 1e3);
5550 } else {
5551 refresh(false, ratio);
5552 }
5553 }
5554 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5555 refresh();
5556 }
5557 isFirstUpdate = false;
5558 }
5559 try {
5560 io = new IntersectionObserver(handleObserve, {
5561 ...options,
5562 // Handle <iframe>s
5563 root: root.ownerDocument
5564 });
5565 } catch (_e) {
5566 io = new IntersectionObserver(handleObserve, options);
5567 }
5568 io.observe(element);
5569 }
5570 refresh(true);
5571 return cleanup;
5572 }
5573 function autoUpdate(reference, floating, update2, options) {
5574 if (options === void 0) {
5575 options = {};
5576 }
5577 const {
5578 ancestorScroll = true,
5579 ancestorResize = true,
5580 elementResize = typeof ResizeObserver === "function",
5581 layoutShift = typeof IntersectionObserver === "function",
5582 animationFrame = false
5583 } = options;
5584 const referenceEl = unwrapElement(reference);
5585 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5586 ancestors.forEach((ancestor) => {
5587 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5588 passive: true
5589 });
5590 ancestorResize && ancestor.addEventListener("resize", update2);
5591 });
5592 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5593 let reobserveFrame = -1;
5594 let resizeObserver = null;
5595 if (elementResize) {
5596 resizeObserver = new ResizeObserver((_ref) => {
5597 let [firstEntry] = _ref;
5598 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5599 resizeObserver.unobserve(floating);
5600 cancelAnimationFrame(reobserveFrame);
5601 reobserveFrame = requestAnimationFrame(() => {
5602 var _resizeObserver;
5603 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5604 });
5605 }
5606 update2();
5607 });
5608 if (referenceEl && !animationFrame) {
5609 resizeObserver.observe(referenceEl);
5610 }
5611 if (floating) {
5612 resizeObserver.observe(floating);
5613 }
5614 }
5615 let frameId;
5616 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5617 if (animationFrame) {
5618 frameLoop();
5619 }
5620 function frameLoop() {
5621 const nextRefRect = getBoundingClientRect(reference);
5622 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5623 update2();
5624 }
5625 prevRefRect = nextRefRect;
5626 frameId = requestAnimationFrame(frameLoop);
5627 }
5628 update2();
5629 return () => {
5630 var _resizeObserver2;
5631 ancestors.forEach((ancestor) => {
5632 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5633 ancestorResize && ancestor.removeEventListener("resize", update2);
5634 });
5635 cleanupIo == null || cleanupIo();
5636 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5637 resizeObserver = null;
5638 if (animationFrame) {
5639 cancelAnimationFrame(frameId);
5640 }
5641 };
5642 }
5643 var offset2 = offset;
5644 var shift2 = shift;
5645 var flip2 = flip;
5646 var size2 = size;
5647 var hide2 = hide;
5648 var limitShift2 = limitShift;
5649 var computePosition2 = (reference, floating, options) => {
5650 const cache = /* @__PURE__ */ new Map();
5651 const mergedOptions = {
5652 platform: platform2,
5653 ...options
5654 };
5655 const platformWithCache = {
5656 ...mergedOptions.platform,
5657 _c: cache
5658 };
5659 return computePosition(reference, floating, {
5660 ...mergedOptions,
5661 platform: platformWithCache
5662 });
5663 };
5664
5665 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5666 var React26 = __toESM(require_react(), 1);
5667 var import_react2 = __toESM(require_react(), 1);
5668 var ReactDOM3 = __toESM(require_react_dom(), 1);
5669 var isClient = typeof document !== "undefined";
5670 var noop2 = function noop3() {
5671 };
5672 var index = isClient ? import_react2.useLayoutEffect : noop2;
5673 function deepEqual(a2, b2) {
5674 if (a2 === b2) {
5675 return true;
5676 }
5677 if (typeof a2 !== typeof b2) {
5678 return false;
5679 }
5680 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5681 return true;
5682 }
5683 let length;
5684 let i2;
5685 let keys;
5686 if (a2 && b2 && typeof a2 === "object") {
5687 if (Array.isArray(a2)) {
5688 length = a2.length;
5689 if (length !== b2.length) return false;
5690 for (i2 = length; i2-- !== 0; ) {
5691 if (!deepEqual(a2[i2], b2[i2])) {
5692 return false;
5693 }
5694 }
5695 return true;
5696 }
5697 keys = Object.keys(a2);
5698 length = keys.length;
5699 if (length !== Object.keys(b2).length) {
5700 return false;
5701 }
5702 for (i2 = length; i2-- !== 0; ) {
5703 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5704 return false;
5705 }
5706 }
5707 for (i2 = length; i2-- !== 0; ) {
5708 const key = keys[i2];
5709 if (key === "_owner" && a2.$$typeof) {
5710 continue;
5711 }
5712 if (!deepEqual(a2[key], b2[key])) {
5713 return false;
5714 }
5715 }
5716 return true;
5717 }
5718 return a2 !== a2 && b2 !== b2;
5719 }
5720 function getDPR(element) {
5721 if (typeof window === "undefined") {
5722 return 1;
5723 }
5724 const win = element.ownerDocument.defaultView || window;
5725 return win.devicePixelRatio || 1;
5726 }
5727 function roundByDPR(element, value) {
5728 const dpr = getDPR(element);
5729 return Math.round(value * dpr) / dpr;
5730 }
5731 function useLatestRef(value) {
5732 const ref = React26.useRef(value);
5733 index(() => {
5734 ref.current = value;
5735 });
5736 return ref;
5737 }
5738 function useFloating(options) {
5739 if (options === void 0) {
5740 options = {};
5741 }
5742 const {
5743 placement = "bottom",
5744 strategy = "absolute",
5745 middleware = [],
5746 platform: platform3,
5747 elements: {
5748 reference: externalReference,
5749 floating: externalFloating
5750 } = {},
5751 transform = true,
5752 whileElementsMounted,
5753 open
5754 } = options;
5755 const [data, setData] = React26.useState({
5756 x: 0,
5757 y: 0,
5758 strategy,
5759 placement,
5760 middlewareData: {},
5761 isPositioned: false
5762 });
5763 const [latestMiddleware, setLatestMiddleware] = React26.useState(middleware);
5764 if (!deepEqual(latestMiddleware, middleware)) {
5765 setLatestMiddleware(middleware);
5766 }
5767 const [_reference, _setReference] = React26.useState(null);
5768 const [_floating, _setFloating] = React26.useState(null);
5769 const setReference = React26.useCallback((node) => {
5770 if (node !== referenceRef.current) {
5771 referenceRef.current = node;
5772 _setReference(node);
5773 }
5774 }, []);
5775 const setFloating = React26.useCallback((node) => {
5776 if (node !== floatingRef.current) {
5777 floatingRef.current = node;
5778 _setFloating(node);
5779 }
5780 }, []);
5781 const referenceEl = externalReference || _reference;
5782 const floatingEl = externalFloating || _floating;
5783 const referenceRef = React26.useRef(null);
5784 const floatingRef = React26.useRef(null);
5785 const dataRef = React26.useRef(data);
5786 const hasWhileElementsMounted = whileElementsMounted != null;
5787 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5788 const platformRef = useLatestRef(platform3);
5789 const openRef = useLatestRef(open);
5790 const update2 = React26.useCallback(() => {
5791 if (!referenceRef.current || !floatingRef.current) {
5792 return;
5793 }
5794 const config = {
5795 placement,
5796 strategy,
5797 middleware: latestMiddleware
5798 };
5799 if (platformRef.current) {
5800 config.platform = platformRef.current;
5801 }
5802 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5803 const fullData = {
5804 ...data2,
5805 // The floating element's position may be recomputed while it's closed
5806 // but still mounted (such as when transitioning out). To ensure
5807 // `isPositioned` will be `false` initially on the next open, avoid
5808 // setting it to `true` when `open === false` (must be specified).
5809 isPositioned: openRef.current !== false
5810 };
5811 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5812 dataRef.current = fullData;
5813 ReactDOM3.flushSync(() => {
5814 setData(fullData);
5815 });
5816 }
5817 });
5818 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5819 index(() => {
5820 if (open === false && dataRef.current.isPositioned) {
5821 dataRef.current.isPositioned = false;
5822 setData((data2) => ({
5823 ...data2,
5824 isPositioned: false
5825 }));
5826 }
5827 }, [open]);
5828 const isMountedRef = React26.useRef(false);
5829 index(() => {
5830 isMountedRef.current = true;
5831 return () => {
5832 isMountedRef.current = false;
5833 };
5834 }, []);
5835 index(() => {
5836 if (referenceEl) referenceRef.current = referenceEl;
5837 if (floatingEl) floatingRef.current = floatingEl;
5838 if (referenceEl && floatingEl) {
5839 if (whileElementsMountedRef.current) {
5840 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5841 }
5842 update2();
5843 }
5844 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5845 const refs = React26.useMemo(() => ({
5846 reference: referenceRef,
5847 floating: floatingRef,
5848 setReference,
5849 setFloating
5850 }), [setReference, setFloating]);
5851 const elements = React26.useMemo(() => ({
5852 reference: referenceEl,
5853 floating: floatingEl
5854 }), [referenceEl, floatingEl]);
5855 const floatingStyles = React26.useMemo(() => {
5856 const initialStyles = {
5857 position: strategy,
5858 left: 0,
5859 top: 0
5860 };
5861 if (!elements.floating) {
5862 return initialStyles;
5863 }
5864 const x2 = roundByDPR(elements.floating, data.x);
5865 const y2 = roundByDPR(elements.floating, data.y);
5866 if (transform) {
5867 return {
5868 ...initialStyles,
5869 transform: "translate(" + x2 + "px, " + y2 + "px)",
5870 ...getDPR(elements.floating) >= 1.5 && {
5871 willChange: "transform"
5872 }
5873 };
5874 }
5875 return {
5876 position: strategy,
5877 left: x2,
5878 top: y2
5879 };
5880 }, [strategy, transform, elements.floating, data.x, data.y]);
5881 return React26.useMemo(() => ({
5882 ...data,
5883 update: update2,
5884 refs,
5885 elements,
5886 floatingStyles
5887 }), [data, update2, refs, elements, floatingStyles]);
5888 }
5889 var offset3 = (options, deps) => {
5890 const result = offset2(options);
5891 return {
5892 name: result.name,
5893 fn: result.fn,
5894 options: [options, deps]
5895 };
5896 };
5897 var shift3 = (options, deps) => {
5898 const result = shift2(options);
5899 return {
5900 name: result.name,
5901 fn: result.fn,
5902 options: [options, deps]
5903 };
5904 };
5905 var limitShift3 = (options, deps) => {
5906 const result = limitShift2(options);
5907 return {
5908 fn: result.fn,
5909 options: [options, deps]
5910 };
5911 };
5912 var flip3 = (options, deps) => {
5913 const result = flip2(options);
5914 return {
5915 name: result.name,
5916 fn: result.fn,
5917 options: [options, deps]
5918 };
5919 };
5920 var size3 = (options, deps) => {
5921 const result = size2(options);
5922 return {
5923 name: result.name,
5924 fn: result.fn,
5925 options: [options, deps]
5926 };
5927 };
5928 var hide3 = (options, deps) => {
5929 const result = hide2(options);
5930 return {
5931 name: result.name,
5932 fn: result.fn,
5933 options: [options, deps]
5934 };
5935 };
5936
5937 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
5938 var React31 = __toESM(require_react(), 1);
5939 var ReactDOM4 = __toESM(require_react_dom(), 1);
5940
5941 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
5942 var React30 = __toESM(require_react(), 1);
5943
5944 // node_modules/@base-ui/utils/store/createSelector.mjs
5945 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5946 if (other.length > 0) {
5947 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5948 }
5949 let selector2;
5950 if (a2 && b2 && c2 && d2 && e2 && f2) {
5951 selector2 = (state, a1, a22, a3) => {
5952 const va = a2(state, a1, a22, a3);
5953 const vb = b2(state, a1, a22, a3);
5954 const vc = c2(state, a1, a22, a3);
5955 const vd = d2(state, a1, a22, a3);
5956 const ve = e2(state, a1, a22, a3);
5957 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5958 };
5959 } else if (a2 && b2 && c2 && d2 && e2) {
5960 selector2 = (state, a1, a22, a3) => {
5961 const va = a2(state, a1, a22, a3);
5962 const vb = b2(state, a1, a22, a3);
5963 const vc = c2(state, a1, a22, a3);
5964 const vd = d2(state, a1, a22, a3);
5965 return e2(va, vb, vc, vd, a1, a22, a3);
5966 };
5967 } else if (a2 && b2 && c2 && d2) {
5968 selector2 = (state, a1, a22, a3) => {
5969 const va = a2(state, a1, a22, a3);
5970 const vb = b2(state, a1, a22, a3);
5971 const vc = c2(state, a1, a22, a3);
5972 return d2(va, vb, vc, a1, a22, a3);
5973 };
5974 } else if (a2 && b2 && c2) {
5975 selector2 = (state, a1, a22, a3) => {
5976 const va = a2(state, a1, a22, a3);
5977 const vb = b2(state, a1, a22, a3);
5978 return c2(va, vb, a1, a22, a3);
5979 };
5980 } else if (a2 && b2) {
5981 selector2 = (state, a1, a22, a3) => {
5982 const va = a2(state, a1, a22, a3);
5983 return b2(va, a1, a22, a3);
5984 };
5985 } else if (a2) {
5986 selector2 = a2;
5987 } else {
5988 throw (
5989 /* minify-error-disabled */
5990 new Error("Missing arguments")
5991 );
5992 }
5993 return selector2;
5994 };
5995
5996 // node_modules/@base-ui/utils/store/useStore.mjs
5997 var React28 = __toESM(require_react(), 1);
5998 var import_shim = __toESM(require_shim(), 1);
5999 var import_with_selector = __toESM(require_with_selector(), 1);
6000
6001 // node_modules/@base-ui/utils/fastHooks.mjs
6002 var React27 = __toESM(require_react(), 1);
6003 var hooks = [];
6004 var currentInstance = void 0;
6005 function getInstance() {
6006 return currentInstance;
6007 }
6008 function register(hook) {
6009 hooks.push(hook);
6010 }
6011 function fastComponent(fn) {
6012 const FastComponent = (props, forwardedRef) => {
6013 const instance = useRefWithInit(createInstance).current;
6014 let result;
6015 try {
6016 currentInstance = instance;
6017 for (const hook of hooks) {
6018 hook.before(instance);
6019 }
6020 result = fn(props, forwardedRef);
6021 for (const hook of hooks) {
6022 hook.after(instance);
6023 }
6024 instance.didInitialize = true;
6025 } finally {
6026 currentInstance = void 0;
6027 }
6028 return result;
6029 };
6030 FastComponent.displayName = fn.displayName || fn.name;
6031 return FastComponent;
6032 }
6033 function fastComponentRef(fn) {
6034 return /* @__PURE__ */ React27.forwardRef(fastComponent(fn));
6035 }
6036 function createInstance() {
6037 return {
6038 didInitialize: false
6039 };
6040 }
6041
6042 // node_modules/@base-ui/utils/store/useStore.mjs
6043 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
6044 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
6045 function useStore(store, selector2, a1, a2, a3) {
6046 return useStoreImplementation(store, selector2, a1, a2, a3);
6047 }
6048 function useStoreR19(store, selector2, a1, a2, a3) {
6049 const getSelection = React28.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
6050 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
6051 }
6052 register({
6053 before(instance) {
6054 instance.syncIndex = 0;
6055 if (!instance.didInitialize) {
6056 instance.syncTick = 1;
6057 instance.syncHooks = [];
6058 instance.didChangeStore = true;
6059 instance.getSnapshot = () => {
6060 let didChange2 = false;
6061 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
6062 const hook = instance.syncHooks[i2];
6063 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
6064 if (!Object.is(hook.value, value)) {
6065 didChange2 = true;
6066 hook.value = value;
6067 }
6068 }
6069 if (didChange2) {
6070 instance.syncTick += 1;
6071 }
6072 return instance.syncTick;
6073 };
6074 }
6075 },
6076 after(instance) {
6077 if (instance.syncHooks.length > 0) {
6078 if (instance.didChangeStore) {
6079 instance.didChangeStore = false;
6080 instance.subscribe = (onStoreChange) => {
6081 const stores = /* @__PURE__ */ new Set();
6082 for (const hook of instance.syncHooks) {
6083 stores.add(hook.store);
6084 }
6085 const unsubscribes = [];
6086 for (const store of stores) {
6087 unsubscribes.push(store.subscribe(onStoreChange));
6088 }
6089 return () => {
6090 for (const unsubscribe of unsubscribes) {
6091 unsubscribe();
6092 }
6093 };
6094 };
6095 }
6096 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
6097 }
6098 }
6099 });
6100 function useStoreFast(store, selector2, a1, a2, a3) {
6101 const instance = getInstance();
6102 if (!instance) {
6103 return useStoreR19(store, selector2, a1, a2, a3);
6104 }
6105 const index2 = instance.syncIndex;
6106 instance.syncIndex += 1;
6107 let hook;
6108 if (!instance.didInitialize) {
6109 hook = {
6110 store,
6111 selector: selector2,
6112 a1,
6113 a2,
6114 a3,
6115 value: selector2(store.getSnapshot(), a1, a2, a3)
6116 };
6117 instance.syncHooks.push(hook);
6118 } else {
6119 hook = instance.syncHooks[index2];
6120 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
6121 if (hook.store !== store) {
6122 instance.didChangeStore = true;
6123 }
6124 hook.store = store;
6125 hook.selector = selector2;
6126 hook.a1 = a1;
6127 hook.a2 = a2;
6128 hook.a3 = a3;
6129 hook.value = selector2(store.getSnapshot(), a1, a2, a3);
6130 }
6131 }
6132 return hook.value;
6133 }
6134 function useStoreLegacy(store, selector2, a1, a2, a3) {
6135 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
6136 }
6137
6138 // node_modules/@base-ui/utils/store/Store.mjs
6139 var Store = class {
6140 /**
6141 * The current state of the store.
6142 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
6143 * 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).
6144 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
6145 *
6146 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
6147 */
6148 // Internal state to handle recursive `setState()` calls
6149 constructor(state) {
6150 this.state = state;
6151 this.listeners = /* @__PURE__ */ new Set();
6152 this.updateTick = 0;
6153 }
6154 /**
6155 * Registers a listener that will be called whenever the store's state changes.
6156 *
6157 * @param fn The listener function to be called on state changes.
6158 * @returns A function to unsubscribe the listener.
6159 */
6160 subscribe = (fn) => {
6161 this.listeners.add(fn);
6162 return () => {
6163 this.listeners.delete(fn);
6164 };
6165 };
6166 /**
6167 * Returns the current state of the store.
6168 */
6169 getSnapshot = () => {
6170 return this.state;
6171 };
6172 /**
6173 * Updates the entire store's state and notifies all registered listeners.
6174 *
6175 * @param newState The new state to set for the store.
6176 */
6177 setState(newState) {
6178 if (this.state === newState) {
6179 return;
6180 }
6181 this.state = newState;
6182 this.updateTick += 1;
6183 const currentTick = this.updateTick;
6184 for (const listener of this.listeners) {
6185 if (currentTick !== this.updateTick) {
6186 return;
6187 }
6188 listener(newState);
6189 }
6190 }
6191 /**
6192 * Merges the provided changes into the current state and notifies listeners if there are changes.
6193 *
6194 * @param changes An object containing the changes to apply to the current state.
6195 */
6196 update(changes) {
6197 for (const key in changes) {
6198 if (!Object.is(this.state[key], changes[key])) {
6199 this.setState({
6200 ...this.state,
6201 ...changes
6202 });
6203 return;
6204 }
6205 }
6206 }
6207 /**
6208 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
6209 *
6210 * @param key The key in the store's state to update.
6211 * @param value The new value to set for the specified key.
6212 */
6213 set(key, value) {
6214 if (!Object.is(this.state[key], value)) {
6215 this.setState({
6216 ...this.state,
6217 [key]: value
6218 });
6219 }
6220 }
6221 /**
6222 * Gives the state a new reference and updates all registered listeners.
6223 */
6224 notifyAll() {
6225 const newState = {
6226 ...this.state
6227 };
6228 this.setState(newState);
6229 }
6230 use(selector2, a1, a2, a3) {
6231 return useStore(this, selector2, a1, a2, a3);
6232 }
6233 };
6234
6235 // node_modules/@base-ui/utils/store/ReactStore.mjs
6236 var React29 = __toESM(require_react(), 1);
6237 var ReactStore = class extends Store {
6238 /**
6239 * Creates a new ReactStore instance.
6240 *
6241 * @param state Initial state of the store.
6242 * @param context Non-reactive context values.
6243 * @param selectors Optional selectors for use with `useState`.
6244 */
6245 constructor(state, context = {}, selectors3) {
6246 super(state);
6247 this.context = context;
6248 this.selectors = selectors3;
6249 }
6250 /**
6251 * Non-reactive values such as refs, callbacks, etc.
6252 */
6253 /**
6254 * Synchronizes a single external value into the store.
6255 *
6256 * Note that the while the value in `state` is updated immediately, the value returned
6257 * by `useState` is updated before the next render (similarly to React's `useState`).
6258 */
6259 useSyncedValue(key, value) {
6260 React29.useDebugValue(key);
6261 const store = this;
6262 useIsoLayoutEffect(() => {
6263 if (store.state[key] !== value) {
6264 store.set(key, value);
6265 }
6266 }, [store, key, value]);
6267 }
6268 /**
6269 * Synchronizes a single external value into the store and
6270 * cleans it up (sets to `undefined`) on unmount.
6271 *
6272 * Note that the while the value in `state` is updated immediately, the value returned
6273 * by `useState` is updated before the next render (similarly to React's `useState`).
6274 */
6275 useSyncedValueWithCleanup(key, value) {
6276 const store = this;
6277 useIsoLayoutEffect(() => {
6278 if (store.state[key] !== value) {
6279 store.set(key, value);
6280 }
6281 return () => {
6282 store.set(key, void 0);
6283 };
6284 }, [store, key, value]);
6285 }
6286 /**
6287 * Synchronizes multiple external values into the store.
6288 *
6289 * Note that the while the values in `state` are updated immediately, the values returned
6290 * by `useState` are updated before the next render (similarly to React's `useState`).
6291 */
6292 useSyncedValues(statePart) {
6293 const store = this;
6294 if (true) {
6295 React29.useDebugValue(statePart, (p2) => Object.keys(p2));
6296 const keys = React29.useRef(Object.keys(statePart)).current;
6297 const nextKeys = Object.keys(statePart);
6298 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
6299 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
6300 }
6301 }
6302 const dependencies = Object.values(statePart);
6303 useIsoLayoutEffect(() => {
6304 store.update(statePart);
6305 }, [store, ...dependencies]);
6306 }
6307 /**
6308 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
6309 * is non-undefined, the store's state at `key` is updated to match `controlled`.
6310 */
6311 useControlledProp(key, controlled) {
6312 React29.useDebugValue(key);
6313 const store = this;
6314 const isControlled = controlled !== void 0;
6315 useIsoLayoutEffect(() => {
6316 if (isControlled && !Object.is(store.state[key], controlled)) {
6317 store.setState({
6318 ...store.state,
6319 [key]: controlled
6320 });
6321 }
6322 }, [store, key, controlled, isControlled]);
6323 if (true) {
6324 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
6325 if (!cache.has(key)) {
6326 cache.set(key, isControlled);
6327 }
6328 const previouslyControlled = cache.get(key);
6329 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
6330 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).`);
6331 }
6332 }
6333 }
6334 /** Gets the current value from the store using a selector with the provided key.
6335 *
6336 * @param key Key of the selector to use.
6337 */
6338 select(key, a1, a2, a3) {
6339 const selector2 = this.selectors[key];
6340 return selector2(this.state, a1, a2, a3);
6341 }
6342 /**
6343 * Returns a value from the store's state using a selector function.
6344 * Used to subscribe to specific parts of the state.
6345 * This methods causes a rerender whenever the selected state changes.
6346 *
6347 * @param key Key of the selector to use.
6348 */
6349 useState(key, a1, a2, a3) {
6350 React29.useDebugValue(key);
6351 return useStore(this, this.selectors[key], a1, a2, a3);
6352 }
6353 /**
6354 * Wraps a function with `useStableCallback` to ensure it has a stable reference
6355 * and assigns it to the context.
6356 *
6357 * @param key Key of the event callback. Must be a function in the context.
6358 * @param fn Function to assign.
6359 */
6360 useContextCallback(key, fn) {
6361 React29.useDebugValue(key);
6362 const stableFunction = useStableCallback(fn ?? NOOP);
6363 this.context[key] = stableFunction;
6364 }
6365 /**
6366 * Returns a stable setter function for a specific key in the store's state.
6367 * It's commonly used to pass as a ref callback to React elements.
6368 *
6369 * @param key Key of the state to set.
6370 */
6371 useStateSetter(key) {
6372 const ref = React29.useRef(void 0);
6373 if (ref.current === void 0) {
6374 ref.current = (value) => {
6375 this.set(key, value);
6376 };
6377 }
6378 return ref.current;
6379 }
6380 /**
6381 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
6382 *
6383 * @param key Key of the selector to observe.
6384 * @param listener Listener function called when the selector result changes.
6385 */
6386 observe(selector2, listener) {
6387 let selectFn;
6388 if (typeof selector2 === "function") {
6389 selectFn = selector2;
6390 } else {
6391 selectFn = this.selectors[selector2];
6392 }
6393 let prevValue = selectFn(this.state);
6394 listener(prevValue, prevValue, this);
6395 return this.subscribe((nextState) => {
6396 const nextValue = selectFn(nextState);
6397 if (!Object.is(prevValue, nextValue)) {
6398 const oldValue = prevValue;
6399 prevValue = nextValue;
6400 listener(nextValue, oldValue, this);
6401 }
6402 });
6403 }
6404 };
6405
6406 // node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs
6407 var selectors = {
6408 open: createSelector((state) => state.open),
6409 transitionStatus: createSelector((state) => state.transitionStatus),
6410 domReferenceElement: createSelector((state) => state.domReferenceElement),
6411 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
6412 floatingElement: createSelector((state) => state.floatingElement),
6413 floatingId: createSelector((state) => state.floatingId)
6414 };
6415 var FloatingRootStore = class extends ReactStore {
6416 constructor(options) {
6417 const {
6418 syncOnly,
6419 nested,
6420 onOpenChange,
6421 triggerElements,
6422 ...initialState
6423 } = options;
6424 super({
6425 ...initialState,
6426 positionReference: initialState.referenceElement,
6427 domReferenceElement: initialState.referenceElement
6428 }, {
6429 onOpenChange,
6430 dataRef: {
6431 current: {}
6432 },
6433 events: createEventEmitter(),
6434 nested,
6435 triggerElements
6436 }, selectors);
6437 this.syncOnly = syncOnly;
6438 }
6439 /**
6440 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
6441 */
6442 syncOpenEvent = (newOpen, event) => {
6443 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
6444 // click events to upgrade a hover-open.
6445 event != null && isClickLikeEvent(event)) {
6446 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
6447 }
6448 };
6449 /**
6450 * Runs the root-owned side effects for an open state change.
6451 */
6452 dispatchOpenChange = (newOpen, eventDetails) => {
6453 this.syncOpenEvent(newOpen, eventDetails.event);
6454 const details = {
6455 open: newOpen,
6456 reason: eventDetails.reason,
6457 nativeEvent: eventDetails.event,
6458 nested: this.context.nested,
6459 triggerElement: eventDetails.trigger
6460 };
6461 this.context.events.emit("openchange", details);
6462 };
6463 /**
6464 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
6465 *
6466 * @param newOpen The new open state.
6467 * @param eventDetails Details about the event that triggered the open state change.
6468 */
6469 setOpen = (newOpen, eventDetails) => {
6470 if (this.syncOnly) {
6471 this.context.onOpenChange?.(newOpen, eventDetails);
6472 return;
6473 }
6474 this.dispatchOpenChange(newOpen, eventDetails);
6475 this.context.onOpenChange?.(newOpen, eventDetails);
6476 };
6477 };
6478
6479 // node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
6480 function useSyncedFloatingRootContext(options) {
6481 const {
6482 popupStore,
6483 treatPopupAsFloatingElement = false,
6484 floatingRootContext: floatingRootContextProp,
6485 floatingId,
6486 nested,
6487 onOpenChange
6488 } = options;
6489 const open = popupStore.useState("open");
6490 const referenceElement = popupStore.useState("activeTriggerElement");
6491 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6492 const triggerElements = popupStore.context.triggerElements;
6493 const handleOpenChange = onOpenChange;
6494 const internalStoreRef = React30.useRef(null);
6495 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
6496 internalStoreRef.current = new FloatingRootStore({
6497 open,
6498 transitionStatus: void 0,
6499 referenceElement,
6500 floatingElement,
6501 triggerElements,
6502 onOpenChange: handleOpenChange,
6503 floatingId,
6504 syncOnly: true,
6505 nested
6506 });
6507 }
6508 const store = floatingRootContextProp ?? internalStoreRef.current;
6509 popupStore.useSyncedValue("floatingId", floatingId);
6510 useIsoLayoutEffect(() => {
6511 const valuesToSync = {
6512 open,
6513 floatingId,
6514 referenceElement,
6515 floatingElement
6516 };
6517 if (isElement(referenceElement)) {
6518 valuesToSync.domReferenceElement = referenceElement;
6519 }
6520 if (store.state.positionReference === store.state.referenceElement) {
6521 valuesToSync.positionReference = referenceElement;
6522 }
6523 store.update(valuesToSync);
6524 }, [open, floatingId, referenceElement, floatingElement, store]);
6525 store.context.onOpenChange = handleOpenChange;
6526 store.context.nested = nested;
6527 return store;
6528 }
6529
6530 // node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
6531 var FOCUSABLE_POPUP_PROPS = {
6532 tabIndex: -1,
6533 [FOCUSABLE_ATTRIBUTE]: ""
6534 };
6535 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
6536 const floatingId = useId();
6537 const nested = useFloatingParentNodeId() != null;
6538 const internalStoreRef = React31.useRef(null);
6539 if (externalStore === void 0 && internalStoreRef.current === null) {
6540 internalStoreRef.current = createStore2(floatingId, nested);
6541 }
6542 const store = externalStore ?? internalStoreRef.current;
6543 useSyncedFloatingRootContext({
6544 popupStore: store,
6545 treatPopupAsFloatingElement,
6546 floatingRootContext: store.state.floatingRootContext,
6547 floatingId,
6548 nested,
6549 onOpenChange: store.setOpen
6550 });
6551 return {
6552 store,
6553 internalStore: internalStoreRef.current
6554 };
6555 }
6556 function useTriggerRegistration(id, store) {
6557 const registeredElementIdRef = React31.useRef(null);
6558 const registeredElementRef = React31.useRef(null);
6559 return React31.useCallback((element) => {
6560 if (id === void 0) {
6561 return;
6562 }
6563 let shouldSyncTriggerCount = false;
6564 if (registeredElementIdRef.current !== null) {
6565 const registeredId = registeredElementIdRef.current;
6566 const registeredElement = registeredElementRef.current;
6567 const currentElement = store.context.triggerElements.getById(registeredId);
6568 if (registeredElement && currentElement === registeredElement) {
6569 store.context.triggerElements.delete(registeredId);
6570 shouldSyncTriggerCount = true;
6571 }
6572 registeredElementIdRef.current = null;
6573 registeredElementRef.current = null;
6574 }
6575 if (element !== null) {
6576 registeredElementIdRef.current = id;
6577 registeredElementRef.current = element;
6578 store.context.triggerElements.add(id, element);
6579 shouldSyncTriggerCount = true;
6580 }
6581 if (shouldSyncTriggerCount) {
6582 const triggerCount = store.context.triggerElements.size;
6583 if (store.select("open") && store.state.triggerCount !== triggerCount) {
6584 store.set("triggerCount", triggerCount);
6585 }
6586 }
6587 }, [store, id]);
6588 }
6589 function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) {
6590 if (open) {
6591 state.preventUnmountingOnClose = false;
6592 } else if (preventUnmountOnClose) {
6593 state.preventUnmountingOnClose = true;
6594 }
6595 const triggerId = trigger?.id ?? null;
6596 if (triggerId || open) {
6597 state.activeTriggerId = triggerId;
6598 state.activeTriggerElement = trigger ?? null;
6599 }
6600 }
6601 function attachPreventUnmountOnClose(eventDetails) {
6602 let preventUnmountOnClose = false;
6603 eventDetails.preventUnmountOnClose = () => {
6604 preventUnmountOnClose = true;
6605 };
6606 return () => preventUnmountOnClose;
6607 }
6608 function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) {
6609 const reason = eventDetails.reason;
6610 const isHover = reason === reason_parts_exports.triggerHover;
6611 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
6612 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
6613 const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
6614 store.context.onOpenChange?.(nextOpen, eventDetails);
6615 if (eventDetails.isCanceled) {
6616 return;
6617 }
6618 options.onBeforeDispatch?.();
6619 store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
6620 const changeState = () => {
6621 const updatedState = {
6622 ...options.extraState,
6623 open: nextOpen
6624 };
6625 if (isFocusOpen) {
6626 updatedState.instantType = "focus";
6627 } else if (isDismissClose) {
6628 updatedState.instantType = "dismiss";
6629 } else if (isHover) {
6630 updatedState.instantType = void 0;
6631 }
6632 setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
6633 store.update(updatedState);
6634 };
6635 if (isHover) {
6636 ReactDOM4.flushSync(changeState);
6637 } else {
6638 changeState();
6639 }
6640 }
6641 function useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerId) {
6642 useOnFirstRender(() => {
6643 if (openProp === void 0 && store.state.open === false && defaultOpen) {
6644 store.state = {
6645 ...store.state,
6646 open: true,
6647 activeTriggerId: defaultTriggerId,
6648 preventUnmountingOnClose: false
6649 };
6650 }
6651 });
6652 }
6653 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6654 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6655 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6656 const registerTrigger = useStableCallback((element) => {
6657 baseRegisterTrigger(element);
6658 if (!element) {
6659 return;
6660 }
6661 const open = store.select("open");
6662 const activeTriggerId = store.select("activeTriggerId");
6663 if (activeTriggerId === triggerId) {
6664 store.update({
6665 activeTriggerElement: element,
6666 ...open ? stateUpdates : null
6667 });
6668 return;
6669 }
6670 if (activeTriggerId == null && open) {
6671 store.update({
6672 activeTriggerId: triggerId,
6673 activeTriggerElement: element,
6674 ...stateUpdates
6675 });
6676 }
6677 });
6678 useIsoLayoutEffect(() => {
6679 if (isMountedByThisTrigger) {
6680 store.update({
6681 activeTriggerElement: triggerElementRef.current,
6682 ...stateUpdates
6683 });
6684 }
6685 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6686 return {
6687 registerTrigger,
6688 isMountedByThisTrigger
6689 };
6690 }
6691 function useImplicitActiveTrigger(store, options = {}) {
6692 const {
6693 closeOnActiveTriggerUnmount = false
6694 } = options;
6695 const open = store.useState("open");
6696 const reactiveTriggerCount = store.useState("triggerCount");
6697 useIsoLayoutEffect(() => {
6698 if (!open) {
6699 if (store.state.triggerCount !== 0) {
6700 store.set("triggerCount", 0);
6701 }
6702 return;
6703 }
6704 const triggerCount = store.context.triggerElements.size;
6705 const stateUpdates = {};
6706 if (store.state.triggerCount !== triggerCount) {
6707 stateUpdates.triggerCount = triggerCount;
6708 }
6709 const activeTriggerId = store.select("activeTriggerId");
6710 let lostActiveTriggerId = null;
6711 if (activeTriggerId) {
6712 const activeTriggerElement = store.context.triggerElements.getById(activeTriggerId);
6713 if (!activeTriggerElement) {
6714 lostActiveTriggerId = activeTriggerId;
6715 } else if (activeTriggerElement !== store.state.activeTriggerElement) {
6716 stateUpdates.activeTriggerElement = activeTriggerElement;
6717 }
6718 }
6719 if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) {
6720 const iteratorResult = store.context.triggerElements.entries().next();
6721 if (!iteratorResult.done) {
6722 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6723 stateUpdates.activeTriggerId = implicitTriggerId;
6724 stateUpdates.activeTriggerElement = implicitTriggerElement;
6725 }
6726 }
6727 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) {
6728 store.update(stateUpdates);
6729 }
6730 if (lostActiveTriggerId) {
6731 if (closeOnActiveTriggerUnmount) {
6732 queueMicrotask(() => {
6733 if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
6734 const eventDetails = createChangeEventDetails(reason_parts_exports.none);
6735 store.setOpen(false, eventDetails);
6736 if (!eventDetails.isCanceled) {
6737 store.update({
6738 activeTriggerId: null,
6739 activeTriggerElement: null
6740 });
6741 }
6742 }
6743 });
6744 }
6745 }
6746 }, [open, store, reactiveTriggerCount, closeOnActiveTriggerUnmount]);
6747 }
6748 function useOpenStateTransitions(open, store, onUnmount) {
6749 const {
6750 mounted,
6751 setMounted,
6752 transitionStatus
6753 } = useTransitionStatus(open);
6754 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6755 const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose;
6756 store.useSyncedValues({
6757 mounted,
6758 transitionStatus,
6759 preventUnmountingOnClose: syncedPreventUnmountingOnClose
6760 });
6761 const forceUnmount = useStableCallback(() => {
6762 setMounted(false);
6763 store.update({
6764 activeTriggerId: null,
6765 activeTriggerElement: null,
6766 mounted: false,
6767 preventUnmountingOnClose: false
6768 });
6769 onUnmount?.();
6770 store.context.onOpenChangeComplete?.(false);
6771 });
6772 useOpenChangeComplete({
6773 enabled: mounted && !open && !syncedPreventUnmountingOnClose,
6774 open,
6775 ref: store.context.popupRef,
6776 onComplete() {
6777 if (!open) {
6778 forceUnmount();
6779 }
6780 }
6781 });
6782 return {
6783 forceUnmount,
6784 transitionStatus
6785 };
6786 }
6787 function usePopupInteractionProps(store, statePart) {
6788 store.useSyncedValues(statePart);
6789 useIsoLayoutEffect(() => () => {
6790 store.update({
6791 activeTriggerProps: EMPTY_OBJECT,
6792 inactiveTriggerProps: EMPTY_OBJECT,
6793 popupProps: EMPTY_OBJECT
6794 });
6795 }, [store]);
6796 }
6797
6798 // node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs
6799 var PopupTriggerMap = class {
6800 constructor() {
6801 this.elementsSet = /* @__PURE__ */ new Set();
6802 this.idMap = /* @__PURE__ */ new Map();
6803 }
6804 /**
6805 * Adds a trigger element with the given ID.
6806 *
6807 * Note: The provided element is assumed to not be registered under multiple IDs.
6808 */
6809 add(id, element) {
6810 const existingElement = this.idMap.get(id);
6811 if (existingElement === element) {
6812 return;
6813 }
6814 if (existingElement !== void 0) {
6815 this.elementsSet.delete(existingElement);
6816 }
6817 this.elementsSet.add(element);
6818 this.idMap.set(id, element);
6819 if (true) {
6820 if (this.elementsSet.size !== this.idMap.size) {
6821 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6822 }
6823 }
6824 }
6825 /**
6826 * Removes the trigger element with the given ID.
6827 */
6828 delete(id) {
6829 const element = this.idMap.get(id);
6830 if (element) {
6831 this.elementsSet.delete(element);
6832 this.idMap.delete(id);
6833 }
6834 }
6835 /**
6836 * Whether the given element is registered as a trigger.
6837 */
6838 hasElement(element) {
6839 return this.elementsSet.has(element);
6840 }
6841 /**
6842 * Whether there is a registered trigger element matching the given predicate.
6843 */
6844 hasMatchingElement(predicate) {
6845 for (const element of this.elementsSet) {
6846 if (predicate(element)) {
6847 return true;
6848 }
6849 }
6850 return false;
6851 }
6852 /**
6853 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6854 */
6855 getById(id) {
6856 return this.idMap.get(id);
6857 }
6858 /**
6859 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6860 */
6861 entries() {
6862 return this.idMap.entries();
6863 }
6864 /**
6865 * Returns an iterable of all registered trigger elements.
6866 */
6867 elements() {
6868 return this.elementsSet.values();
6869 }
6870 /**
6871 * Returns the number of registered trigger elements.
6872 */
6873 get size() {
6874 return this.idMap.size;
6875 }
6876 };
6877
6878 // node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs
6879 function getEmptyRootContext() {
6880 return new FloatingRootStore({
6881 open: false,
6882 transitionStatus: void 0,
6883 floatingElement: null,
6884 referenceElement: null,
6885 triggerElements: new PopupTriggerMap(),
6886 floatingId: void 0,
6887 syncOnly: false,
6888 nested: false,
6889 onOpenChange: void 0
6890 });
6891 }
6892
6893 // node_modules/@base-ui/react/utils/popups/store.mjs
6894 function createInitialPopupStoreState() {
6895 return {
6896 open: false,
6897 openProp: void 0,
6898 mounted: false,
6899 transitionStatus: void 0,
6900 floatingRootContext: getEmptyRootContext(),
6901 floatingId: void 0,
6902 triggerCount: 0,
6903 preventUnmountingOnClose: false,
6904 payload: void 0,
6905 activeTriggerId: null,
6906 activeTriggerElement: null,
6907 triggerIdProp: void 0,
6908 popupElement: null,
6909 positionerElement: null,
6910 activeTriggerProps: EMPTY_OBJECT,
6911 inactiveTriggerProps: EMPTY_OBJECT,
6912 popupProps: EMPTY_OBJECT
6913 };
6914 }
6915 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6916 return new FloatingRootStore({
6917 open: false,
6918 transitionStatus: void 0,
6919 floatingElement: null,
6920 referenceElement: null,
6921 triggerElements,
6922 floatingId,
6923 syncOnly: true,
6924 nested,
6925 onOpenChange: void 0
6926 });
6927 }
6928 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6929 var openSelector = createSelector((state) => state.openProp ?? state.open);
6930 var popupIdSelector = createSelector((state) => {
6931 const popupId = state.popupElement?.id ?? state.floatingId;
6932 return popupId || void 0;
6933 });
6934 function triggerOwnsOpenPopup(state, triggerId) {
6935 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6936 }
6937 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6938 if (triggerOwnsOpenPopup(state, triggerId)) {
6939 return true;
6940 }
6941 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6942 }
6943 var popupStoreSelectors = {
6944 open: openSelector,
6945 mounted: createSelector((state) => state.mounted),
6946 transitionStatus: createSelector((state) => state.transitionStatus),
6947 floatingRootContext: createSelector((state) => state.floatingRootContext),
6948 triggerCount: createSelector((state) => state.triggerCount),
6949 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6950 payload: createSelector((state) => state.payload),
6951 activeTriggerId: activeTriggerIdSelector,
6952 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6953 popupId: popupIdSelector,
6954 /**
6955 * Whether the trigger with the given ID was used to open the popup.
6956 */
6957 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6958 /**
6959 * Whether the popup is open and was activated by a trigger with the given ID.
6960 */
6961 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6962 /**
6963 * Whether the popup is mounted and was activated by a trigger with the given ID.
6964 */
6965 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6966 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6967 /**
6968 * Popup id for the trigger that currently owns the open popup.
6969 */
6970 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6971 popupProps: createSelector((state) => state.popupProps),
6972 popupElement: createSelector((state) => state.popupElement),
6973 positionerElement: createSelector((state) => state.positionerElement)
6974 };
6975
6976 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs
6977 function useFloatingRootContext(options) {
6978 const {
6979 open = false,
6980 onOpenChange,
6981 elements = {}
6982 } = options;
6983 const floatingId = useId();
6984 const nested = useFloatingParentNodeId() != null;
6985 if (true) {
6986 const optionDomReference = elements.reference;
6987 if (optionDomReference && !isElement(optionDomReference)) {
6988 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6989 }
6990 }
6991 const store = useRefWithInit(() => new FloatingRootStore({
6992 open,
6993 transitionStatus: void 0,
6994 onOpenChange,
6995 referenceElement: elements.reference ?? null,
6996 floatingElement: elements.floating ?? null,
6997 triggerElements: new PopupTriggerMap(),
6998 floatingId,
6999 syncOnly: false,
7000 nested
7001 })).current;
7002 useIsoLayoutEffect(() => {
7003 const valuesToSync = {
7004 open,
7005 floatingId
7006 };
7007 if (elements.reference !== void 0) {
7008 valuesToSync.referenceElement = elements.reference;
7009 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
7010 }
7011 if (elements.floating !== void 0) {
7012 valuesToSync.floatingElement = elements.floating;
7013 }
7014 store.update(valuesToSync);
7015 }, [open, floatingId, elements.reference, elements.floating, store]);
7016 store.context.onOpenChange = onOpenChange;
7017 store.context.nested = nested;
7018 return store;
7019 }
7020
7021 // node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
7022 function useFloating2(options = {}) {
7023 const {
7024 nodeId,
7025 externalTree
7026 } = options;
7027 const internalStore = useFloatingRootContext(options);
7028 const store = options.rootContext || internalStore;
7029 const referenceElement = store.useState("referenceElement");
7030 const floatingElement = store.useState("floatingElement");
7031 const domReferenceElement = store.useState("domReferenceElement");
7032 const open = store.useState("open");
7033 const floatingId = store.useState("floatingId");
7034 const [positionReference, setPositionReferenceRaw] = React32.useState(null);
7035 const [localDomReference, setLocalDomReference] = React32.useState(void 0);
7036 const [localFloatingElement, setLocalFloatingElement] = React32.useState(void 0);
7037 const domReferenceRef = React32.useRef(null);
7038 const tree = useFloatingTree(externalTree);
7039 const storeElements = React32.useMemo(() => ({
7040 reference: referenceElement,
7041 floating: floatingElement,
7042 domReference: domReferenceElement
7043 }), [referenceElement, floatingElement, domReferenceElement]);
7044 const position = useFloating({
7045 ...options,
7046 elements: {
7047 ...storeElements,
7048 ...positionReference && {
7049 reference: positionReference
7050 }
7051 }
7052 });
7053 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
7054 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
7055 store.useSyncedValue("referenceElement", localDomReference ?? null);
7056 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
7057 store.useSyncedValue("floatingElement", syncedFloatingElement);
7058 const setPositionReference = React32.useCallback((node) => {
7059 const computedPositionReference = isElement(node) ? {
7060 getBoundingClientRect: () => node.getBoundingClientRect(),
7061 getClientRects: () => node.getClientRects(),
7062 contextElement: node
7063 } : node;
7064 setPositionReferenceRaw(computedPositionReference);
7065 position.refs.setReference(computedPositionReference);
7066 }, [position.refs]);
7067 const setReference = React32.useCallback((node) => {
7068 if (isElement(node) || node === null) {
7069 domReferenceRef.current = node;
7070 setLocalDomReference(node);
7071 }
7072 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
7073 // `null` to support `positionReference` + an unstable `reference`
7074 // callback ref.
7075 node !== null && !isElement(node)) {
7076 position.refs.setReference(node);
7077 }
7078 }, [position.refs, setLocalDomReference]);
7079 const setFloating = React32.useCallback((node) => {
7080 setLocalFloatingElement(node);
7081 position.refs.setFloating(node);
7082 }, [position.refs]);
7083 const refs = React32.useMemo(() => ({
7084 ...position.refs,
7085 setReference,
7086 setFloating,
7087 setPositionReference,
7088 domReference: domReferenceRef
7089 }), [position.refs, setReference, setFloating, setPositionReference]);
7090 const elements = React32.useMemo(() => ({
7091 ...position.elements,
7092 domReference: domReferenceElement
7093 }), [position.elements, domReferenceElement]);
7094 const context = React32.useMemo(() => ({
7095 ...position,
7096 dataRef: store.context.dataRef,
7097 open,
7098 onOpenChange: store.setOpen,
7099 events: store.context.events,
7100 floatingId,
7101 refs,
7102 elements,
7103 nodeId,
7104 rootStore: store
7105 }), [position, refs, elements, nodeId, store, open, floatingId]);
7106 useIsoLayoutEffect(() => {
7107 if (domReferenceElement) {
7108 domReferenceRef.current = domReferenceElement;
7109 }
7110 }, [domReferenceElement]);
7111 useIsoLayoutEffect(() => {
7112 store.context.dataRef.current.floatingContext = context;
7113 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
7114 if (node) {
7115 node.context = context;
7116 }
7117 });
7118 return React32.useMemo(() => ({
7119 ...position,
7120 context,
7121 refs,
7122 elements,
7123 rootStore: store
7124 }), [position, refs, elements, context, store]);
7125 }
7126
7127 // node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
7128 var React33 = __toESM(require_react(), 1);
7129 var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit;
7130 function useFocus(context, props = {}) {
7131 const {
7132 enabled = true,
7133 delay
7134 } = props;
7135 const store = "rootStore" in context ? context.rootStore : context;
7136 const {
7137 events,
7138 dataRef
7139 } = store.context;
7140 const blockFocusRef = React33.useRef(false);
7141 const blockedReferenceRef = React33.useRef(null);
7142 const keyboardModalityRef = React33.useRef(true);
7143 const timeout = useTimeout();
7144 React33.useEffect(() => {
7145 const domReference = store.select("domReferenceElement");
7146 if (!enabled) {
7147 return void 0;
7148 }
7149 const win = getWindow(domReference);
7150 function onBlur() {
7151 const currentDomReference = store.select("domReferenceElement");
7152 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
7153 blockFocusRef.current = true;
7154 }
7155 }
7156 function onKeyDown() {
7157 keyboardModalityRef.current = true;
7158 }
7159 function onPointerDown() {
7160 keyboardModalityRef.current = false;
7161 }
7162 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
7163 }, [store, enabled]);
7164 React33.useEffect(() => {
7165 if (!enabled) {
7166 return void 0;
7167 }
7168 function onOpenChangeLocal(details) {
7169 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
7170 const referenceElement = store.select("domReferenceElement");
7171 if (isElement(referenceElement)) {
7172 blockedReferenceRef.current = referenceElement;
7173 blockFocusRef.current = true;
7174 }
7175 }
7176 }
7177 events.on("openchange", onOpenChangeLocal);
7178 return () => {
7179 events.off("openchange", onOpenChangeLocal);
7180 };
7181 }, [events, enabled, store]);
7182 const reference = React33.useMemo(() => {
7183 function resetBlockedFocus() {
7184 blockFocusRef.current = false;
7185 blockedReferenceRef.current = null;
7186 }
7187 return {
7188 onMouseLeave() {
7189 resetBlockedFocus();
7190 },
7191 onFocus(event) {
7192 const focusTarget = event.currentTarget;
7193 if (blockFocusRef.current) {
7194 if (blockedReferenceRef.current === focusTarget) {
7195 return;
7196 }
7197 resetBlockedFocus();
7198 }
7199 const target = getTarget(event.nativeEvent);
7200 if (isElement(target)) {
7201 if (isMacSafari && !event.relatedTarget) {
7202 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
7203 return;
7204 }
7205 } else if (!matchesFocusVisible(target)) {
7206 return;
7207 }
7208 }
7209 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
7210 const {
7211 nativeEvent,
7212 currentTarget
7213 } = event;
7214 const delayValue = typeof delay === "function" ? delay() : delay;
7215 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
7216 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7217 return;
7218 }
7219 timeout.start(delayValue, () => {
7220 if (blockFocusRef.current) {
7221 return;
7222 }
7223 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
7224 });
7225 },
7226 onBlur(event) {
7227 resetBlockedFocus();
7228 const relatedTarget = event.relatedTarget;
7229 const nativeEvent = event.nativeEvent;
7230 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
7231 timeout.start(0, () => {
7232 const domReference = store.select("domReferenceElement");
7233 const activeEl = activeElement(ownerDocument(domReference));
7234 if (!relatedTarget && activeEl === domReference) {
7235 return;
7236 }
7237 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
7238 return;
7239 }
7240 const nextFocusedElement = relatedTarget ?? activeEl;
7241 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
7242 return;
7243 }
7244 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
7245 });
7246 }
7247 };
7248 }, [dataRef, delay, store, timeout]);
7249 return React33.useMemo(() => enabled ? {
7250 reference,
7251 trigger: reference
7252 } : {}, [enabled, reference]);
7253 }
7254
7255 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7256 var React34 = __toESM(require_react(), 1);
7257
7258 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs
7259 var HoverInteraction = class _HoverInteraction {
7260 constructor() {
7261 this.pointerType = void 0;
7262 this.interactedInside = false;
7263 this.handler = void 0;
7264 this.blockMouseMove = true;
7265 this.performedPointerEventsMutation = false;
7266 this.pointerEventsScopeElement = null;
7267 this.pointerEventsReferenceElement = null;
7268 this.pointerEventsFloatingElement = null;
7269 this.restTimeoutPending = false;
7270 this.openChangeTimeout = new Timeout();
7271 this.restTimeout = new Timeout();
7272 this.handleCloseOptions = void 0;
7273 }
7274 static create() {
7275 return new _HoverInteraction();
7276 }
7277 dispose = () => {
7278 this.openChangeTimeout.clear();
7279 this.restTimeout.clear();
7280 };
7281 disposeEffect = () => {
7282 return this.dispose;
7283 };
7284 };
7285 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
7286 function clearSafePolygonPointerEventsMutation(instance) {
7287 if (!instance.performedPointerEventsMutation) {
7288 return;
7289 }
7290 const scopeElement = instance.pointerEventsScopeElement;
7291 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
7292 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
7293 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
7294 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
7295 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
7296 }
7297 instance.performedPointerEventsMutation = false;
7298 instance.pointerEventsScopeElement = null;
7299 instance.pointerEventsReferenceElement = null;
7300 instance.pointerEventsFloatingElement = null;
7301 }
7302 function applySafePolygonPointerEventsMutation(instance, options) {
7303 const {
7304 scopeElement,
7305 referenceElement,
7306 floatingElement
7307 } = options;
7308 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
7309 if (existingOwner && existingOwner !== instance) {
7310 clearSafePolygonPointerEventsMutation(existingOwner);
7311 }
7312 clearSafePolygonPointerEventsMutation(instance);
7313 instance.performedPointerEventsMutation = true;
7314 instance.pointerEventsScopeElement = scopeElement;
7315 instance.pointerEventsReferenceElement = referenceElement;
7316 instance.pointerEventsFloatingElement = floatingElement;
7317 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
7318 scopeElement.style.pointerEvents = "none";
7319 referenceElement.style.pointerEvents = "auto";
7320 floatingElement.style.pointerEvents = "auto";
7321 }
7322 function useHoverInteractionSharedState(store) {
7323 const data = store.context.dataRef.current;
7324 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
7325 if (!data.hoverInteractionState) {
7326 data.hoverInteractionState = instance;
7327 }
7328 useOnMount(data.hoverInteractionState.disposeEffect);
7329 return data.hoverInteractionState;
7330 }
7331
7332 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
7333 function useHoverFloatingInteraction(context, parameters = {}) {
7334 const {
7335 enabled = true,
7336 closeDelay: closeDelayProp = 0,
7337 nodeId: nodeIdProp
7338 } = parameters;
7339 const store = "rootStore" in context ? context.rootStore : context;
7340 const open = store.useState("open");
7341 const floatingElement = store.useState("floatingElement");
7342 const domReferenceElement = store.useState("domReferenceElement");
7343 const {
7344 dataRef
7345 } = store.context;
7346 const tree = useFloatingTree();
7347 const parentId = useFloatingParentNodeId();
7348 const instance = useHoverInteractionSharedState(store);
7349 const childClosedTimeout = useTimeout();
7350 const isClickLikeOpenEvent2 = useStableCallback(() => {
7351 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7352 });
7353 const isHoverOpen = useStableCallback(() => {
7354 return isHoverOpenEvent(dataRef.current.openEvent?.type);
7355 });
7356 const clearPointerEvents = useStableCallback(() => {
7357 clearSafePolygonPointerEventsMutation(instance);
7358 });
7359 useIsoLayoutEffect(() => {
7360 if (!open) {
7361 instance.pointerType = void 0;
7362 instance.restTimeoutPending = false;
7363 instance.interactedInside = false;
7364 clearPointerEvents();
7365 }
7366 }, [open, instance, clearPointerEvents]);
7367 React34.useEffect(() => {
7368 return clearPointerEvents;
7369 }, [clearPointerEvents]);
7370 useIsoLayoutEffect(() => {
7371 if (!enabled) {
7372 return void 0;
7373 }
7374 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
7375 const ref = domReferenceElement;
7376 const floatingEl = floatingElement;
7377 const doc = ownerDocument(floatingElement);
7378 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
7379 if (parentFloating) {
7380 parentFloating.style.pointerEvents = "";
7381 }
7382 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
7383 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
7384 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
7385 applySafePolygonPointerEventsMutation(instance, {
7386 scopeElement,
7387 referenceElement: ref,
7388 floatingElement: floatingEl
7389 });
7390 return () => {
7391 clearPointerEvents();
7392 };
7393 }
7394 return void 0;
7395 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
7396 React34.useEffect(() => {
7397 if (!enabled) {
7398 return void 0;
7399 }
7400 function hasParentChildren() {
7401 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
7402 }
7403 function closeWithDelay(event) {
7404 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
7405 const close = () => {
7406 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7407 tree?.events.emit("floating.closed", event);
7408 };
7409 if (closeDelay) {
7410 instance.openChangeTimeout.start(closeDelay, close);
7411 } else {
7412 instance.openChangeTimeout.clear();
7413 close();
7414 }
7415 }
7416 function handleInteractInside(event) {
7417 const target = getTarget(event);
7418 if (!isInteractiveElement(target)) {
7419 instance.interactedInside = false;
7420 return;
7421 }
7422 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
7423 }
7424 function onFloatingMouseEnter() {
7425 instance.openChangeTimeout.clear();
7426 childClosedTimeout.clear();
7427 tree?.events.off("floating.closed", onNodeClosed);
7428 clearPointerEvents();
7429 }
7430 function onFloatingMouseLeave(event) {
7431 if (hasParentChildren() && tree) {
7432 tree.events.on("floating.closed", onNodeClosed);
7433 return;
7434 }
7435 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7436 return;
7437 }
7438 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
7439 const relatedTarget = event.relatedTarget;
7440 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
7441 if (isMovingIntoDescendantFloating) {
7442 return;
7443 }
7444 if (instance.handler) {
7445 instance.handler(event);
7446 return;
7447 }
7448 clearPointerEvents();
7449 if (isHoverOpen() && !isClickLikeOpenEvent2()) {
7450 closeWithDelay(event);
7451 }
7452 }
7453 function onNodeClosed(event) {
7454 if (!tree || !parentId || hasParentChildren()) {
7455 return;
7456 }
7457 childClosedTimeout.start(0, () => {
7458 tree.events.off("floating.closed", onNodeClosed);
7459 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7460 tree.events.emit("floating.closed", event);
7461 });
7462 }
7463 const floating = floatingElement;
7464 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
7465 tree?.events.off("floating.closed", onNodeClosed);
7466 });
7467 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
7468 }
7469
7470 // node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
7471 var React35 = __toESM(require_react(), 1);
7472 var ReactDOM5 = __toESM(require_react_dom(), 1);
7473 var EMPTY_REF = {
7474 current: null
7475 };
7476 function useHoverReferenceInteraction(context, props = {}) {
7477 const {
7478 enabled = true,
7479 delay = 0,
7480 handleClose = null,
7481 mouseOnly = false,
7482 restMs = 0,
7483 move = true,
7484 triggerElementRef = EMPTY_REF,
7485 externalTree,
7486 isActiveTrigger = true,
7487 getHandleCloseContext,
7488 isClosing,
7489 shouldOpen: shouldOpenProp
7490 } = props;
7491 const store = "rootStore" in context ? context.rootStore : context;
7492 const {
7493 dataRef,
7494 events
7495 } = store.context;
7496 const tree = useFloatingTree(externalTree);
7497 const instance = useHoverInteractionSharedState(store);
7498 const isHoverCloseActiveRef = React35.useRef(false);
7499 const handleCloseRef = useValueAsRef(handleClose);
7500 const delayRef = useValueAsRef(delay);
7501 const restMsRef = useValueAsRef(restMs);
7502 const enabledRef = useValueAsRef(enabled);
7503 const shouldOpenRef = useValueAsRef(shouldOpenProp);
7504 const isClosingRef = useValueAsRef(isClosing);
7505 const isClickLikeOpenEvent2 = useStableCallback(() => {
7506 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
7507 });
7508 const checkShouldOpen = useStableCallback(() => {
7509 return shouldOpenRef.current?.() !== false;
7510 });
7511 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
7512 const allTriggers = store.context.triggerElements;
7513 if (allTriggers.hasElement(currentTarget)) {
7514 return !currentDomReference || !contains(currentDomReference, currentTarget);
7515 }
7516 if (!isElement(target)) {
7517 return false;
7518 }
7519 const targetElement = target;
7520 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
7521 });
7522 const cleanupMouseMoveHandler = useStableCallback(() => {
7523 if (!instance.handler) {
7524 return;
7525 }
7526 const doc = ownerDocument(store.select("domReferenceElement"));
7527 doc.removeEventListener("mousemove", instance.handler);
7528 instance.handler = void 0;
7529 });
7530 const clearPointerEvents = useStableCallback(() => {
7531 clearSafePolygonPointerEventsMutation(instance);
7532 });
7533 if (isActiveTrigger) {
7534 instance.handleCloseOptions = handleCloseRef.current?.__options;
7535 }
7536 React35.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
7537 React35.useEffect(() => {
7538 if (!enabled) {
7539 return void 0;
7540 }
7541 function onOpenChangeLocal(details) {
7542 if (!details.open) {
7543 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
7544 cleanupMouseMoveHandler();
7545 instance.openChangeTimeout.clear();
7546 instance.restTimeout.clear();
7547 instance.blockMouseMove = true;
7548 instance.restTimeoutPending = false;
7549 } else {
7550 isHoverCloseActiveRef.current = false;
7551 }
7552 }
7553 events.on("openchange", onOpenChangeLocal);
7554 return () => {
7555 events.off("openchange", onOpenChangeLocal);
7556 };
7557 }, [enabled, events, instance, cleanupMouseMoveHandler]);
7558 React35.useEffect(() => {
7559 if (!enabled) {
7560 return void 0;
7561 }
7562 function closeWithDelay(event, runElseBranch = true) {
7563 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
7564 if (closeDelay) {
7565 instance.openChangeTimeout.start(closeDelay, () => {
7566 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7567 tree?.events.emit("floating.closed", event);
7568 });
7569 } else if (runElseBranch) {
7570 instance.openChangeTimeout.clear();
7571 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
7572 tree?.events.emit("floating.closed", event);
7573 }
7574 }
7575 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
7576 if (!isElement(trigger)) {
7577 return void 0;
7578 }
7579 function onMouseEnter(event) {
7580 instance.openChangeTimeout.clear();
7581 instance.blockMouseMove = false;
7582 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7583 return;
7584 }
7585 const restMsValue = getRestMs(restMsRef.current);
7586 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
7587 const eventTarget = getTarget(event);
7588 const currentTarget = event.currentTarget ?? null;
7589 const currentDomReference = store.select("domReferenceElement");
7590 let triggerNode = currentTarget;
7591 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
7592 for (const triggerElement of store.context.triggerElements.elements()) {
7593 if (contains(triggerElement, eventTarget)) {
7594 triggerNode = triggerElement;
7595 break;
7596 }
7597 }
7598 }
7599 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
7600 triggerNode = currentDomReference;
7601 }
7602 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
7603 const isOpen = store.select("open");
7604 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
7605 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
7606 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
7607 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
7608 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
7609 const shouldOpen = !isOpen || isOverInactive;
7610 if (shouldOpenImmediately) {
7611 if (checkShouldOpen()) {
7612 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7613 }
7614 return;
7615 }
7616 if (isRestOnlyDelay) {
7617 return;
7618 }
7619 if (openDelay) {
7620 instance.openChangeTimeout.start(openDelay, () => {
7621 if (shouldOpen && checkShouldOpen()) {
7622 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7623 }
7624 });
7625 } else if (shouldOpen) {
7626 if (checkShouldOpen()) {
7627 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
7628 }
7629 }
7630 }
7631 function onMouseLeave(event) {
7632 if (isClickLikeOpenEvent2()) {
7633 clearPointerEvents();
7634 return;
7635 }
7636 cleanupMouseMoveHandler();
7637 const domReferenceElement = store.select("domReferenceElement");
7638 const doc = ownerDocument(domReferenceElement);
7639 instance.restTimeout.clear();
7640 instance.restTimeoutPending = false;
7641 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7642 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7643 return;
7644 }
7645 if (handleCloseRef.current && handleCloseContextBase) {
7646 if (!store.select("open")) {
7647 instance.openChangeTimeout.clear();
7648 }
7649 const currentTrigger = triggerElementRef.current;
7650 instance.handler = handleCloseRef.current({
7651 ...handleCloseContextBase,
7652 tree,
7653 x: event.clientX,
7654 y: event.clientY,
7655 onClose() {
7656 clearPointerEvents();
7657 cleanupMouseMoveHandler();
7658 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7659 closeWithDelay(event, true);
7660 }
7661 }
7662 });
7663 doc.addEventListener("mousemove", instance.handler);
7664 instance.handler(event);
7665 return;
7666 }
7667 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7668 if (shouldClose) {
7669 closeWithDelay(event);
7670 }
7671 }
7672 if (move) {
7673 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7674 once: true
7675 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7676 }
7677 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7678 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
7679 return React35.useMemo(() => {
7680 if (!enabled) {
7681 return void 0;
7682 }
7683 function setPointerRef(event) {
7684 instance.pointerType = event.pointerType;
7685 }
7686 return {
7687 onPointerDown: setPointerRef,
7688 onPointerEnter: setPointerRef,
7689 onMouseMove(event) {
7690 const {
7691 nativeEvent
7692 } = event;
7693 const trigger = event.currentTarget;
7694 const currentDomReference = store.select("domReferenceElement");
7695 const currentOpen = store.select("open");
7696 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7697 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7698 return;
7699 }
7700 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7701 const floatingElement = store.select("floatingElement");
7702 if (floatingElement) {
7703 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7704 applySafePolygonPointerEventsMutation(instance, {
7705 scopeElement,
7706 referenceElement: trigger,
7707 floatingElement
7708 });
7709 }
7710 }
7711 const restMsValue = getRestMs(restMsRef.current);
7712 if (currentOpen && !isOverInactive || restMsValue === 0) {
7713 return;
7714 }
7715 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7716 return;
7717 }
7718 instance.restTimeout.clear();
7719 function handleMouseMove() {
7720 instance.restTimeoutPending = false;
7721 if (isClickLikeOpenEvent2()) {
7722 return;
7723 }
7724 const latestOpen = store.select("open");
7725 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7726 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7727 }
7728 }
7729 if (instance.pointerType === "touch") {
7730 ReactDOM5.flushSync(() => {
7731 handleMouseMove();
7732 });
7733 } else if (isOverInactive && currentOpen) {
7734 handleMouseMove();
7735 } else {
7736 instance.restTimeoutPending = true;
7737 instance.restTimeout.start(restMsValue, handleMouseMove);
7738 }
7739 }
7740 };
7741 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
7742 }
7743
7744 // node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs
7745 var CURSOR_SPEED_THRESHOLD = 0.1;
7746 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7747 var POLYGON_BUFFER = 0.5;
7748 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7749 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7750 }
7751 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7752 let isInsideValue = false;
7753 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7754 isInsideValue = !isInsideValue;
7755 }
7756 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7757 isInsideValue = !isInsideValue;
7758 }
7759 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7760 isInsideValue = !isInsideValue;
7761 }
7762 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7763 isInsideValue = !isInsideValue;
7764 }
7765 return isInsideValue;
7766 }
7767 function isInsideRect(pointX, pointY, rect) {
7768 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7769 }
7770 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7771 const minX = Math.min(x1, x2);
7772 const maxX = Math.max(x1, x2);
7773 const minY = Math.min(y1, y2);
7774 const maxY = Math.max(y1, y2);
7775 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7776 }
7777 function safePolygon(options = {}) {
7778 const {
7779 blockPointerEvents = false
7780 } = options;
7781 const timeout = new Timeout();
7782 const fn = ({
7783 x: x2,
7784 y: y2,
7785 placement,
7786 elements,
7787 onClose,
7788 nodeId,
7789 tree
7790 }) => {
7791 const side = placement?.split("-")[0];
7792 let hasLanded = false;
7793 let lastX = null;
7794 let lastY = null;
7795 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7796 function isCursorMovingSlowly(nextX, nextY) {
7797 const currentTime = performance.now();
7798 const elapsedTime = currentTime - lastCursorTime;
7799 if (lastX === null || lastY === null || elapsedTime === 0) {
7800 lastX = nextX;
7801 lastY = nextY;
7802 lastCursorTime = currentTime;
7803 return false;
7804 }
7805 const deltaX = nextX - lastX;
7806 const deltaY = nextY - lastY;
7807 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7808 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7809 lastX = nextX;
7810 lastY = nextY;
7811 lastCursorTime = currentTime;
7812 return distanceSquared < thresholdSquared;
7813 }
7814 function close() {
7815 timeout.clear();
7816 onClose();
7817 }
7818 return function onMouseMove(event) {
7819 timeout.clear();
7820 const domReference = elements.domReference;
7821 const floating = elements.floating;
7822 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7823 return void 0;
7824 }
7825 const {
7826 clientX,
7827 clientY
7828 } = event;
7829 const target = getTarget(event);
7830 const isLeave = event.type === "mouseleave";
7831 const isOverFloatingEl = contains(floating, target);
7832 const isOverReferenceEl = contains(domReference, target);
7833 if (isOverFloatingEl) {
7834 hasLanded = true;
7835 if (!isLeave) {
7836 return void 0;
7837 }
7838 }
7839 if (isOverReferenceEl) {
7840 hasLanded = false;
7841 if (!isLeave) {
7842 hasLanded = true;
7843 return void 0;
7844 }
7845 }
7846 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7847 return void 0;
7848 }
7849 function hasOpenChildNode() {
7850 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7851 }
7852 function closeIfNoOpenChild() {
7853 if (!hasOpenChildNode()) {
7854 close();
7855 }
7856 }
7857 if (hasOpenChildNode()) {
7858 return void 0;
7859 }
7860 const refRect = domReference.getBoundingClientRect();
7861 const rect = floating.getBoundingClientRect();
7862 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7863 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7864 const isFloatingWider = rect.width > refRect.width;
7865 const isFloatingTaller = rect.height > refRect.height;
7866 const left = (isFloatingWider ? refRect : rect).left;
7867 const right = (isFloatingWider ? refRect : rect).right;
7868 const top = (isFloatingTaller ? refRect : rect).top;
7869 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7870 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) {
7871 closeIfNoOpenChild();
7872 return void 0;
7873 }
7874 let isInsideTroughRect = false;
7875 switch (side) {
7876 case "top":
7877 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7878 break;
7879 case "bottom":
7880 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7881 break;
7882 case "left":
7883 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7884 break;
7885 case "right":
7886 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7887 break;
7888 default:
7889 }
7890 if (isInsideTroughRect) {
7891 return void 0;
7892 }
7893 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7894 closeIfNoOpenChild();
7895 return void 0;
7896 }
7897 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7898 closeIfNoOpenChild();
7899 return void 0;
7900 }
7901 let isInsidePolygon = false;
7902 switch (side) {
7903 case "top": {
7904 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7905 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7906 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7907 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7908 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7909 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7910 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7911 break;
7912 }
7913 case "bottom": {
7914 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7915 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7916 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7917 const cursorPointY = y2 - POLYGON_BUFFER;
7918 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7919 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7920 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7921 break;
7922 }
7923 case "left": {
7924 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7925 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7926 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7927 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7928 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7929 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7930 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7931 break;
7932 }
7933 case "right": {
7934 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7935 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7936 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7937 const cursorPointX = x2 - POLYGON_BUFFER;
7938 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7939 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7940 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7941 break;
7942 }
7943 default:
7944 }
7945 if (!isInsidePolygon) {
7946 closeIfNoOpenChild();
7947 } else if (!hasLanded) {
7948 timeout.start(40, closeIfNoOpenChild);
7949 }
7950 return void 0;
7951 };
7952 };
7953 fn.__options = {
7954 ...options,
7955 blockPointerEvents
7956 };
7957 return fn;
7958 }
7959
7960 // node_modules/@base-ui/react/utils/popupStateMapping.mjs
7961 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7962 CommonPopupDataAttributes2["open"] = "data-open";
7963 CommonPopupDataAttributes2["closed"] = "data-closed";
7964 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7965 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7966 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7967 CommonPopupDataAttributes2["side"] = "data-side";
7968 CommonPopupDataAttributes2["align"] = "data-align";
7969 return CommonPopupDataAttributes2;
7970 })({});
7971 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7972 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7973 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7974 return CommonTriggerDataAttributes2;
7975 })({});
7976 var TRIGGER_HOOK = {
7977 [CommonTriggerDataAttributes.popupOpen]: ""
7978 };
7979 var PRESSABLE_TRIGGER_HOOK = {
7980 [CommonTriggerDataAttributes.popupOpen]: "",
7981 [CommonTriggerDataAttributes.pressed]: ""
7982 };
7983 var POPUP_OPEN_HOOK = {
7984 [CommonPopupDataAttributes.open]: ""
7985 };
7986 var POPUP_CLOSED_HOOK = {
7987 [CommonPopupDataAttributes.closed]: ""
7988 };
7989 var ANCHOR_HIDDEN_HOOK = {
7990 [CommonPopupDataAttributes.anchorHidden]: ""
7991 };
7992 var triggerOpenStateMapping2 = {
7993 open(value) {
7994 if (value) {
7995 return TRIGGER_HOOK;
7996 }
7997 return null;
7998 }
7999 };
8000 var popupStateMapping = {
8001 open(value) {
8002 if (value) {
8003 return POPUP_OPEN_HOOK;
8004 }
8005 return POPUP_CLOSED_HOOK;
8006 },
8007 anchorHidden(value) {
8008 if (value) {
8009 return ANCHOR_HIDDEN_HOOK;
8010 }
8011 return null;
8012 }
8013 };
8014
8015 // node_modules/@base-ui/utils/inertValue.mjs
8016 function inertValue(value) {
8017 if (isReactVersionAtLeast(19)) {
8018 return value;
8019 }
8020 return value ? "true" : void 0;
8021 }
8022
8023 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
8024 var React36 = __toESM(require_react(), 1);
8025
8026 // node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs
8027 var baseArrow = (options) => ({
8028 name: "arrow",
8029 options,
8030 async fn(state) {
8031 const {
8032 x: x2,
8033 y: y2,
8034 placement,
8035 rects,
8036 platform: platform3,
8037 elements,
8038 middlewareData
8039 } = state;
8040 const {
8041 element,
8042 padding = 0,
8043 offsetParent = "real"
8044 } = evaluate(options, state) || {};
8045 if (element == null) {
8046 return {};
8047 }
8048 const paddingObject = getPaddingObject(padding);
8049 const coords = {
8050 x: x2,
8051 y: y2
8052 };
8053 const axis = getAlignmentAxis(placement);
8054 const length = getAxisLength(axis);
8055 const arrowDimensions = await platform3.getDimensions(element);
8056 const isYAxis = axis === "y";
8057 const minProp = isYAxis ? "top" : "left";
8058 const maxProp = isYAxis ? "bottom" : "right";
8059 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
8060 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
8061 const startDiff = coords[axis] - rects.reference[axis];
8062 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
8063 let clientSize = elements.floating[clientProp] || rects.floating[length];
8064 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
8065 clientSize = elements.floating[clientProp] || rects.floating[length];
8066 }
8067 const centerToReference = endDiff / 2 - startDiff / 2;
8068 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
8069 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
8070 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
8071 const min2 = minPadding;
8072 const max2 = clientSize - arrowDimensions[length] - maxPadding;
8073 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
8074 const offset4 = clamp(min2, center, max2);
8075 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
8076 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
8077 return {
8078 [axis]: coords[axis] + alignmentOffset,
8079 data: {
8080 [axis]: offset4,
8081 centerOffset: center - offset4 - alignmentOffset,
8082 ...shouldAddOffset && {
8083 alignmentOffset
8084 }
8085 },
8086 reset: shouldAddOffset
8087 };
8088 }
8089 });
8090 var arrow4 = (options, deps) => ({
8091 ...baseArrow(options),
8092 options: [options, deps]
8093 });
8094
8095 // node_modules/@base-ui/react/utils/hideMiddleware.mjs
8096 var nativeHideFn = hide3().fn;
8097 var hide4 = {
8098 name: "hide",
8099 async fn(state) {
8100 const {
8101 width,
8102 height,
8103 x: x2,
8104 y: y2
8105 } = state.rects.reference;
8106 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
8107 const nativeHideResult = await nativeHideFn(state);
8108 return {
8109 data: {
8110 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
8111 }
8112 };
8113 }
8114 };
8115
8116 // node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs
8117 var DEFAULT_SIDES = {
8118 sideX: "left",
8119 sideY: "top"
8120 };
8121 var adaptiveOrigin = {
8122 name: "adaptiveOrigin",
8123 async fn(state) {
8124 const {
8125 x: rawX,
8126 y: rawY,
8127 rects: {
8128 floating: floatRect
8129 },
8130 elements: {
8131 floating
8132 },
8133 platform: platform3,
8134 strategy,
8135 placement
8136 } = state;
8137 const win = getWindow(floating);
8138 const styles = win.getComputedStyle(floating);
8139 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
8140 if (!hasTransition) {
8141 return {
8142 x: rawX,
8143 y: rawY,
8144 data: DEFAULT_SIDES
8145 };
8146 }
8147 const offsetParent = await platform3.getOffsetParent?.(floating);
8148 let offsetDimensions = {
8149 width: 0,
8150 height: 0
8151 };
8152 if (strategy === "fixed" && win?.visualViewport) {
8153 offsetDimensions = {
8154 width: win.visualViewport.width,
8155 height: win.visualViewport.height
8156 };
8157 } else if (offsetParent === win) {
8158 const doc = ownerDocument(floating);
8159 offsetDimensions = {
8160 width: doc.documentElement.clientWidth,
8161 height: doc.documentElement.clientHeight
8162 };
8163 } else if (await platform3.isElement?.(offsetParent)) {
8164 offsetDimensions = await platform3.getDimensions(offsetParent);
8165 }
8166 const currentSide = getSide(placement);
8167 let x2 = rawX;
8168 let y2 = rawY;
8169 if (currentSide === "left") {
8170 x2 = offsetDimensions.width - (rawX + floatRect.width);
8171 }
8172 if (currentSide === "top") {
8173 y2 = offsetDimensions.height - (rawY + floatRect.height);
8174 }
8175 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
8176 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
8177 return {
8178 x: x2,
8179 y: y2,
8180 data: {
8181 sideX,
8182 sideY
8183 }
8184 };
8185 }
8186 };
8187
8188 // node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
8189 function getLogicalSide(sideParam, renderedSide, isRtl) {
8190 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
8191 const logicalRight = isRtl ? "inline-start" : "inline-end";
8192 const logicalLeft = isRtl ? "inline-end" : "inline-start";
8193 return {
8194 top: "top",
8195 right: isLogicalSideParam ? logicalRight : "right",
8196 bottom: "bottom",
8197 left: isLogicalSideParam ? logicalLeft : "left"
8198 }[renderedSide];
8199 }
8200 function getOffsetData(state, sideParam, isRtl) {
8201 const {
8202 rects,
8203 placement
8204 } = state;
8205 const data = {
8206 side: getLogicalSide(sideParam, getSide(placement), isRtl),
8207 align: getAlignment(placement) || "center",
8208 anchor: {
8209 width: rects.reference.width,
8210 height: rects.reference.height
8211 },
8212 positioner: {
8213 width: rects.floating.width,
8214 height: rects.floating.height
8215 }
8216 };
8217 return data;
8218 }
8219 function useAnchorPositioning(params) {
8220 const {
8221 // Public parameters
8222 anchor,
8223 positionMethod = "absolute",
8224 side: sideParam = "bottom",
8225 sideOffset = 0,
8226 align = "center",
8227 alignOffset = 0,
8228 collisionBoundary,
8229 collisionPadding: collisionPaddingParam = 5,
8230 sticky = false,
8231 arrowPadding = 5,
8232 disableAnchorTracking = false,
8233 inline: inlineMiddleware,
8234 // Private parameters
8235 keepMounted = false,
8236 floatingRootContext,
8237 mounted,
8238 collisionAvoidance,
8239 shiftCrossAxis = false,
8240 nodeId,
8241 adaptiveOrigin: adaptiveOrigin2,
8242 lazyFlip = false,
8243 externalTree
8244 } = params;
8245 const [mountSide, setMountSide] = React36.useState(null);
8246 if (!mounted && mountSide !== null) {
8247 setMountSide(null);
8248 }
8249 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
8250 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
8251 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
8252 const anchorFn = typeof anchor === "function" ? anchor : void 0;
8253 const anchorFnCallback = useStableCallback(anchorFn);
8254 const anchorDep = anchorFn ? anchorFnCallback : anchor;
8255 const anchorValueRef = useValueAsRef(anchor);
8256 const mountedRef = useValueAsRef(mounted);
8257 const direction = useDirection();
8258 const isRtl = direction === "rtl";
8259 const side = mountSide || {
8260 top: "top",
8261 right: "right",
8262 bottom: "bottom",
8263 left: "left",
8264 "inline-end": isRtl ? "left" : "right",
8265 "inline-start": isRtl ? "right" : "left"
8266 }[sideParam];
8267 const placement = align === "center" ? side : `${side}-${align}`;
8268 let collisionPadding = collisionPaddingParam;
8269 const bias = 1;
8270 const biasTop = sideParam === "bottom" ? bias : 0;
8271 const biasBottom = sideParam === "top" ? bias : 0;
8272 const biasLeft = sideParam === "right" ? bias : 0;
8273 const biasRight = sideParam === "left" ? bias : 0;
8274 if (typeof collisionPadding === "number") {
8275 collisionPadding = {
8276 top: collisionPadding + biasTop,
8277 right: collisionPadding + biasRight,
8278 bottom: collisionPadding + biasBottom,
8279 left: collisionPadding + biasLeft
8280 };
8281 } else if (collisionPadding) {
8282 collisionPadding = {
8283 top: (collisionPadding.top || 0) + biasTop,
8284 right: (collisionPadding.right || 0) + biasRight,
8285 bottom: (collisionPadding.bottom || 0) + biasBottom,
8286 left: (collisionPadding.left || 0) + biasLeft
8287 };
8288 }
8289 const commonCollisionProps = {
8290 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
8291 padding: collisionPadding
8292 };
8293 const arrowRef = React36.useRef(null);
8294 const sideOffsetRef = useValueAsRef(sideOffset);
8295 const alignOffsetRef = useValueAsRef(alignOffset);
8296 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
8297 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
8298 const middleware = [];
8299 if (inlineMiddleware) {
8300 middleware.push(inlineMiddleware);
8301 }
8302 middleware.push(offset3((state) => {
8303 const data = getOffsetData(state, sideParam, isRtl);
8304 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
8305 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
8306 return {
8307 mainAxis: sideAxis,
8308 crossAxis: alignAxis,
8309 alignmentAxis: alignAxis
8310 };
8311 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
8312 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
8313 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
8314 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
8315 ...commonCollisionProps,
8316 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
8317 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
8318 padding: {
8319 top: collisionPadding.top + bias,
8320 right: collisionPadding.right + bias,
8321 bottom: collisionPadding.bottom + bias,
8322 left: collisionPadding.left + bias
8323 },
8324 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
8325 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
8326 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
8327 });
8328 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
8329 const html = ownerDocument(data.elements.floating).documentElement;
8330 return {
8331 ...commonCollisionProps,
8332 // Use the Layout Viewport to avoid shifting around when pinch-zooming
8333 // for context menus.
8334 rootBoundary: shiftCrossAxis ? {
8335 x: 0,
8336 y: 0,
8337 width: html.clientWidth,
8338 height: html.clientHeight
8339 } : void 0,
8340 mainAxis: collisionAvoidanceAlign !== "none",
8341 crossAxis: crossAxisShiftEnabled,
8342 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
8343 if (!arrowRef.current) {
8344 return {};
8345 }
8346 const {
8347 width,
8348 height
8349 } = arrowRef.current.getBoundingClientRect();
8350 const sideAxis = getSideAxis(getSide(limitData.placement));
8351 const arrowSize = sideAxis === "y" ? width : height;
8352 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
8353 return {
8354 offset: arrowSize / 2 + offsetAmount / 2
8355 };
8356 })
8357 };
8358 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
8359 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
8360 middleware.push(shiftMiddleware, flipMiddleware);
8361 } else {
8362 middleware.push(flipMiddleware, shiftMiddleware);
8363 }
8364 middleware.push(size3({
8365 ...commonCollisionProps,
8366 apply({
8367 elements: {
8368 floating
8369 },
8370 availableWidth,
8371 availableHeight,
8372 rects
8373 }) {
8374 if (!mountedRef.current) {
8375 return;
8376 }
8377 const floatingStyle = floating.style;
8378 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
8379 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
8380 const dpr = getWindow(floating).devicePixelRatio || 1;
8381 const {
8382 x: x3,
8383 y: y3,
8384 width,
8385 height
8386 } = rects.reference;
8387 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
8388 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
8389 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
8390 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
8391 }
8392 }), arrow4((state) => ({
8393 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
8394 // we'll create a fake element.
8395 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
8396 padding: arrowPadding,
8397 offsetParent: "floating"
8398 }), [arrowPadding]), {
8399 name: "transformOrigin",
8400 fn(state) {
8401 const {
8402 elements: elements2,
8403 middlewareData: middlewareData2,
8404 placement: renderedPlacement2,
8405 rects,
8406 y: y3
8407 } = state;
8408 const currentRenderedSide = getSide(renderedPlacement2);
8409 const currentRenderedAxis = getSideAxis(currentRenderedSide);
8410 const arrowEl = arrowRef.current;
8411 const arrowX = middlewareData2.arrow?.x || 0;
8412 const arrowY = middlewareData2.arrow?.y || 0;
8413 const arrowWidth = arrowEl?.clientWidth || 0;
8414 const arrowHeight = arrowEl?.clientHeight || 0;
8415 const transformX = arrowX + arrowWidth / 2;
8416 const transformY = arrowY + arrowHeight / 2;
8417 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
8418 const halfAnchorHeight = rects.reference.height / 2;
8419 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
8420 const isOverlappingAnchor = shiftY > sideOffsetValue;
8421 const adjacentTransformOrigin = {
8422 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
8423 bottom: `${transformX}px ${-sideOffsetValue}px`,
8424 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
8425 right: `${-sideOffsetValue}px ${transformY}px`
8426 }[currentRenderedSide];
8427 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
8428 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
8429 return {};
8430 }
8431 }, hide4, adaptiveOrigin2);
8432 useIsoLayoutEffect(() => {
8433 if (!mounted && floatingRootContext) {
8434 floatingRootContext.update({
8435 referenceElement: null,
8436 floatingElement: null,
8437 domReferenceElement: null,
8438 positionReference: null
8439 });
8440 }
8441 }, [mounted, floatingRootContext]);
8442 const autoUpdateOptions = React36.useMemo(() => ({
8443 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
8444 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
8445 }), [disableAnchorTracking]);
8446 const {
8447 refs,
8448 elements,
8449 x: x2,
8450 y: y2,
8451 middlewareData,
8452 update: update2,
8453 placement: renderedPlacement,
8454 context,
8455 isPositioned,
8456 floatingStyles: originalFloatingStyles
8457 } = useFloating2({
8458 rootContext: floatingRootContext,
8459 open: keepMounted ? mounted : void 0,
8460 placement,
8461 middleware,
8462 strategy: positionMethod,
8463 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
8464 nodeId,
8465 externalTree
8466 });
8467 const {
8468 sideX,
8469 sideY
8470 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
8471 const resolvedPosition = isPositioned ? positionMethod : "fixed";
8472 const floatingStyles = React36.useMemo(() => {
8473 const base = adaptiveOrigin2 ? {
8474 position: resolvedPosition,
8475 [sideX]: x2,
8476 [sideY]: y2
8477 } : {
8478 position: resolvedPosition,
8479 ...originalFloatingStyles
8480 };
8481 if (!isPositioned) {
8482 base.opacity = 0;
8483 }
8484 return base;
8485 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
8486 const registeredPositionReferenceRef = React36.useRef(null);
8487 useIsoLayoutEffect(() => {
8488 if (!mounted) {
8489 return;
8490 }
8491 const anchorValue = anchorValueRef.current;
8492 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
8493 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
8494 const finalAnchor = unwrappedElement || null;
8495 if (finalAnchor !== registeredPositionReferenceRef.current) {
8496 refs.setPositionReference(finalAnchor);
8497 registeredPositionReferenceRef.current = finalAnchor;
8498 }
8499 }, [mounted, refs, anchorDep, anchorValueRef]);
8500 React36.useEffect(() => {
8501 if (!mounted) {
8502 return;
8503 }
8504 const anchorValue = anchorValueRef.current;
8505 if (typeof anchorValue === "function") {
8506 return;
8507 }
8508 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
8509 refs.setPositionReference(anchorValue.current);
8510 registeredPositionReferenceRef.current = anchorValue.current;
8511 }
8512 }, [mounted, refs, anchorDep, anchorValueRef]);
8513 React36.useEffect(() => {
8514 if (keepMounted && mounted && elements.reference && elements.floating) {
8515 return autoUpdate(elements.reference, elements.floating, update2, autoUpdateOptions);
8516 }
8517 return void 0;
8518 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
8519 const renderedSide = getSide(renderedPlacement);
8520 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
8521 const renderedAlign = getAlignment(renderedPlacement) || "center";
8522 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
8523 useIsoLayoutEffect(() => {
8524 if (lazyFlip && mounted && isPositioned) {
8525 setMountSide(renderedSide);
8526 }
8527 }, [lazyFlip, mounted, isPositioned, renderedSide]);
8528 const arrowStyles = React36.useMemo(() => ({
8529 position: "absolute",
8530 top: middlewareData.arrow?.y,
8531 left: middlewareData.arrow?.x
8532 }), [middlewareData.arrow]);
8533 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
8534 return React36.useMemo(() => ({
8535 positionerStyles: floatingStyles,
8536 arrowStyles,
8537 arrowRef,
8538 arrowUncentered,
8539 side: logicalRenderedSide,
8540 align: renderedAlign,
8541 physicalSide: renderedSide,
8542 anchorHidden,
8543 refs,
8544 context,
8545 isPositioned,
8546 update: update2
8547 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
8548 }
8549 function isRef(param) {
8550 return param != null && "current" in param;
8551 }
8552
8553 // node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs
8554 function getDisabledMountTransitionStyles(transitionStatus) {
8555 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
8556 }
8557
8558 // node_modules/@base-ui/react/utils/usePositioner.mjs
8559 function usePositioner(componentProps, state, {
8560 styles,
8561 transitionStatus,
8562 props,
8563 refs,
8564 hidden,
8565 inert = false
8566 }) {
8567 const style = {
8568 ...styles
8569 };
8570 if (inert) {
8571 style.pointerEvents = "none";
8572 }
8573 return useRenderElement("div", componentProps, {
8574 state,
8575 ref: refs,
8576 props: [{
8577 role: "presentation",
8578 hidden,
8579 style
8580 }, getDisabledMountTransitionStyles(transitionStatus), props],
8581 stateAttributesMapping: popupStateMapping
8582 });
8583 }
8584
8585 // node_modules/@base-ui/react/button/Button.mjs
8586 var React37 = __toESM(require_react(), 1);
8587 var Button = /* @__PURE__ */ React37.forwardRef(function Button2(componentProps, forwardedRef) {
8588 const {
8589 render: render4,
8590 className,
8591 disabled: disabled2 = false,
8592 focusableWhenDisabled = false,
8593 nativeButton = true,
8594 style,
8595 ...elementProps
8596 } = componentProps;
8597 const {
8598 getButtonProps,
8599 buttonRef
8600 } = useButton({
8601 disabled: disabled2,
8602 focusableWhenDisabled,
8603 native: nativeButton
8604 });
8605 const state = {
8606 disabled: disabled2
8607 };
8608 return useRenderElement("button", componentProps, {
8609 state,
8610 ref: [forwardedRef, buttonRef],
8611 props: [elementProps, getButtonProps]
8612 });
8613 });
8614 if (true) Button.displayName = "Button";
8615
8616 // node_modules/@base-ui/react/collapsible/index.parts.mjs
8617 var index_parts_exports = {};
8618 __export(index_parts_exports, {
8619 Panel: () => CollapsiblePanel,
8620 Root: () => CollapsibleRoot,
8621 Trigger: () => CollapsibleTrigger
8622 });
8623
8624 // node_modules/@base-ui/react/collapsible/root/CollapsibleRoot.mjs
8625 var React38 = __toESM(require_react(), 1);
8626
8627 // node_modules/@base-ui/react/collapsible/root/stateAttributesMapping.mjs
8628 var collapsibleStateAttributesMapping = {
8629 ...collapsibleOpenStateMapping,
8630 ...transitionStatusMapping
8631 };
8632
8633 // node_modules/@base-ui/react/collapsible/root/CollapsibleRoot.mjs
8634 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8635 var CollapsibleRoot = /* @__PURE__ */ React38.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) {
8636 const {
8637 render: render4,
8638 className,
8639 defaultOpen = false,
8640 disabled: disabled2 = false,
8641 onOpenChange: onOpenChangeProp,
8642 open,
8643 style,
8644 ...elementProps
8645 } = componentProps;
8646 const onOpenChange = useStableCallback(onOpenChangeProp);
8647 const collapsible = useCollapsibleRoot({
8648 open,
8649 defaultOpen,
8650 onOpenChange,
8651 disabled: disabled2
8652 });
8653 const state = React38.useMemo(() => ({
8654 open: collapsible.open,
8655 disabled: collapsible.disabled,
8656 transitionStatus: collapsible.transitionStatus
8657 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]);
8658 const contextValue = React38.useMemo(() => ({
8659 ...collapsible,
8660 onOpenChange,
8661 state
8662 }), [collapsible, onOpenChange, state]);
8663 const element = useRenderElement("div", componentProps, {
8664 state,
8665 ref: forwardedRef,
8666 props: elementProps,
8667 stateAttributesMapping: collapsibleStateAttributesMapping
8668 });
8669 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollapsibleRootContext.Provider, {
8670 value: contextValue,
8671 children: element
8672 });
8673 });
8674 if (true) CollapsibleRoot.displayName = "CollapsibleRoot";
8675
8676 // node_modules/@base-ui/react/collapsible/trigger/CollapsibleTrigger.mjs
8677 var React39 = __toESM(require_react(), 1);
8678 var stateAttributesMapping = {
8679 ...triggerOpenStateMapping,
8680 ...transitionStatusMapping
8681 };
8682 var CollapsibleTrigger = /* @__PURE__ */ React39.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) {
8683 const {
8684 panelId,
8685 open,
8686 handleTrigger,
8687 state,
8688 disabled: contextDisabled
8689 } = useCollapsibleRootContext();
8690 const {
8691 className,
8692 disabled: disabled2 = contextDisabled,
8693 render: render4,
8694 nativeButton = true,
8695 style,
8696 ...elementProps
8697 } = componentProps;
8698 const {
8699 getButtonProps,
8700 buttonRef
8701 } = useButton({
8702 disabled: disabled2,
8703 focusableWhenDisabled: true,
8704 native: nativeButton
8705 });
8706 const element = useRenderElement("button", componentProps, {
8707 state,
8708 ref: [forwardedRef, buttonRef],
8709 props: [{
8710 "aria-controls": open ? panelId : void 0,
8711 "aria-expanded": open,
8712 onClick: handleTrigger
8713 }, elementProps, getButtonProps],
8714 stateAttributesMapping
8715 });
8716 return element;
8717 });
8718 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger";
8719
8720 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanel.mjs
8721 var React40 = __toESM(require_react(), 1);
8722
8723 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanelCssVars.mjs
8724 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) {
8725 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height";
8726 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width";
8727 return CollapsiblePanelCssVars2;
8728 })({});
8729
8730 // node_modules/@base-ui/react/collapsible/panel/CollapsiblePanel.mjs
8731 var CollapsiblePanel = /* @__PURE__ */ React40.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) {
8732 const {
8733 className,
8734 hiddenUntilFound: hiddenUntilFoundProp,
8735 keepMounted: keepMountedProp,
8736 render: render4,
8737 id: idProp,
8738 style,
8739 ...elementProps
8740 } = componentProps;
8741 if (true) {
8742 useIsoLayoutEffect(() => {
8743 if (hiddenUntilFoundProp && keepMountedProp === false) {
8744 warn("The `keepMounted={false}` prop on `Collapsible.Panel` is ignored when `hiddenUntilFound` is enabled, since the panel must remain mounted while closed.");
8745 }
8746 }, [hiddenUntilFoundProp, keepMountedProp]);
8747 }
8748 const {
8749 mounted,
8750 onOpenChange,
8751 open,
8752 panelId,
8753 setMounted,
8754 setPanelIdState,
8755 setOpen,
8756 state,
8757 transitionStatus
8758 } = useCollapsibleRootContext();
8759 const hiddenUntilFound = hiddenUntilFoundProp ?? false;
8760 const keepMounted = keepMountedProp ?? false;
8761 useIsoLayoutEffect(() => {
8762 if (idProp) {
8763 setPanelIdState(idProp);
8764 return () => {
8765 setPanelIdState(void 0);
8766 };
8767 }
8768 return void 0;
8769 }, [idProp, setPanelIdState]);
8770 const {
8771 height,
8772 props,
8773 ref,
8774 shouldPreventOpenAnimation,
8775 shouldRender,
8776 transitionStatus: panelTransitionStatus,
8777 width
8778 } = useCollapsiblePanel({
8779 externalRef: forwardedRef,
8780 hiddenUntilFound,
8781 id: panelId,
8782 keepMounted,
8783 mounted,
8784 onOpenChange,
8785 open,
8786 setMounted,
8787 setOpen,
8788 transitionStatus
8789 });
8790 const panelState = {
8791 ...state,
8792 transitionStatus: panelTransitionStatus
8793 };
8794 const resolvedStyle = resolveStyle(style, panelState);
8795 const element = useRenderElement("div", {
8796 ...componentProps,
8797 style: void 0
8798 }, {
8799 state: panelState,
8800 ref,
8801 props: [
8802 props,
8803 {
8804 style: {
8805 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `${height}px`,
8806 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `${width}px`
8807 }
8808 },
8809 elementProps,
8810 resolvedStyle ? {
8811 style: resolvedStyle
8812 } : void 0,
8813 // Resolve the public `style` prop so temporary `animationName: 'none'`
8814 // can still win after user's inline styles have been merged.
8815 shouldPreventOpenAnimation ? {
8816 style: {
8817 animationName: "none"
8818 }
8819 } : void 0
8820 ],
8821 stateAttributesMapping: collapsibleStateAttributesMapping
8822 });
8823 if (!shouldRender) {
8824 return null;
8825 }
8826 return element;
8827 });
8828 if (true) CollapsiblePanel.displayName = "CollapsiblePanel";
8829
8830 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
8831 var React43 = __toESM(require_react(), 1);
8832 var ReactDOM6 = __toESM(require_react_dom(), 1);
8833
8834 // node_modules/@base-ui/utils/usePreviousValue.mjs
8835 var React41 = __toESM(require_react(), 1);
8836 function usePreviousValue(value) {
8837 const [state, setState] = React41.useState({
8838 current: value,
8839 previous: null
8840 });
8841 if (value !== state.current) {
8842 setState({
8843 current: value,
8844 previous: state.current
8845 });
8846 }
8847 return state.previous;
8848 }
8849
8850 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8851 var React42 = __toESM(require_react(), 1);
8852
8853 // node_modules/@base-ui/react/utils/getCssDimensions.mjs
8854 function getCssDimensions2(element) {
8855 const css = getComputedStyle2(element);
8856 let width = parseFloat(css.width) || 0;
8857 let height = parseFloat(css.height) || 0;
8858 const hasOffset = isHTMLElement(element);
8859 const offsetWidth = hasOffset ? element.offsetWidth : width;
8860 const offsetHeight = hasOffset ? element.offsetHeight : height;
8861 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
8862 if (shouldFallback) {
8863 width = offsetWidth;
8864 height = offsetHeight;
8865 }
8866 return {
8867 width,
8868 height
8869 };
8870 }
8871
8872 // node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
8873 function usePopupAutoResize(parameters) {
8874 const {
8875 popupElement,
8876 positionerElement,
8877 content,
8878 mounted,
8879 onMeasureLayout: onMeasureLayoutParam,
8880 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8881 side,
8882 direction
8883 } = parameters;
8884 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8885 const animationFrame = useAnimationFrame();
8886 const committedDimensionsRef = React42.useRef(null);
8887 const isInitialRenderRef = React42.useRef(true);
8888 const restoreAnchoringStylesRef = React42.useRef(NOOP);
8889 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8890 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8891 const anchoringStyles = React42.useMemo(() => {
8892 let isOriginSide = side === "top";
8893 let isPhysicalLeft = side === "left";
8894 if (direction === "rtl") {
8895 isOriginSide = isOriginSide || side === "inline-end";
8896 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8897 } else {
8898 isOriginSide = isOriginSide || side === "inline-start";
8899 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8900 }
8901 return isOriginSide ? {
8902 position: "absolute",
8903 [side === "top" ? "bottom" : "top"]: "0",
8904 [isPhysicalLeft ? "right" : "left"]: "0"
8905 } : EMPTY_OBJECT;
8906 }, [side, direction]);
8907 useIsoLayoutEffect(() => {
8908 if (!mounted) {
8909 restoreAnchoringStylesRef.current = NOOP;
8910 isInitialRenderRef.current = true;
8911 committedDimensionsRef.current = null;
8912 return void 0;
8913 }
8914 if (!popupElement || !positionerElement) {
8915 return void 0;
8916 }
8917 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8918 setPopupCssSize(popupElement, "auto");
8919 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8920 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8921 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8922 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8923 "--available-width": "max-content",
8924 "--available-height": "max-content"
8925 });
8926 function restoreMeasurementOverrides() {
8927 restorePopupPosition();
8928 restorePopupTransform();
8929 restorePositionerAvailableSize();
8930 }
8931 function restoreMeasurementOverridesIncludingScale() {
8932 restoreMeasurementOverrides();
8933 restorePopupScale();
8934 }
8935 onMeasureLayout?.();
8936 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8937 setPositionerCssSize(positionerElement, "max-content");
8938 const dimensions = getCssDimensions2(popupElement);
8939 committedDimensionsRef.current = dimensions;
8940 setPositionerCssSize(positionerElement, dimensions);
8941 restoreMeasurementOverridesIncludingScale();
8942 onMeasureLayoutComplete?.(null, dimensions);
8943 isInitialRenderRef.current = false;
8944 return () => {
8945 restoreAnchoringStylesRef.current();
8946 restoreAnchoringStylesRef.current = NOOP;
8947 };
8948 }
8949 setPositionerCssSize(positionerElement, "max-content");
8950 const previousDimensions = committedDimensionsRef.current;
8951 const newDimensions = getCssDimensions2(popupElement);
8952 committedDimensionsRef.current = newDimensions;
8953 setPopupCssSize(popupElement, previousDimensions);
8954 restoreMeasurementOverridesIncludingScale();
8955 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8956 setPositionerCssSize(positionerElement, newDimensions);
8957 const abortController = new AbortController();
8958 animationFrame.request(() => {
8959 setPopupCssSize(popupElement, newDimensions);
8960 runOnceAnimationsFinish(() => {
8961 popupElement.style.setProperty("--popup-width", "auto");
8962 popupElement.style.setProperty("--popup-height", "auto");
8963 }, abortController.signal);
8964 });
8965 return () => {
8966 abortController.abort();
8967 animationFrame.cancel();
8968 restoreAnchoringStylesRef.current();
8969 restoreAnchoringStylesRef.current = NOOP;
8970 };
8971 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8972 }
8973 function overrideElementStyle(element, property, value) {
8974 const originalValue = element.style.getPropertyValue(property);
8975 element.style.setProperty(property, value);
8976 return () => {
8977 element.style.setProperty(property, originalValue);
8978 };
8979 }
8980 function applyElementStyles(element, styles) {
8981 const restorers = [];
8982 for (const [key, value] of Object.entries(styles)) {
8983 restorers.push(overrideElementStyle(element, key, value));
8984 }
8985 return restorers.length ? () => {
8986 restorers.forEach((restore) => restore());
8987 } : NOOP;
8988 }
8989 function setPopupCssSize(popupElement, size4) {
8990 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8991 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8992 popupElement.style.setProperty("--popup-width", width);
8993 popupElement.style.setProperty("--popup-height", height);
8994 }
8995 function setPositionerCssSize(positionerElement, size4) {
8996 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8997 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8998 positionerElement.style.setProperty("--positioner-width", width);
8999 positionerElement.style.setProperty("--positioner-height", height);
9000 }
9001
9002 // node_modules/@base-ui/react/utils/usePopupViewport.mjs
9003 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
9004 function usePopupViewport(parameters) {
9005 const {
9006 store,
9007 side,
9008 cssVars,
9009 children
9010 } = parameters;
9011 const direction = useDirection();
9012 const activeTrigger = store.useState("activeTriggerElement");
9013 const activeTriggerId = store.useState("activeTriggerId");
9014 const open = store.useState("open");
9015 const payload = store.useState("payload");
9016 const mounted = store.useState("mounted");
9017 const popupElement = store.useState("popupElement");
9018 const positionerElement = store.useState("positionerElement");
9019 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
9020 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
9021 const capturedNodeRef = React43.useRef(null);
9022 const [previousContentNode, setPreviousContentNode] = React43.useState(null);
9023 const [newTriggerOffset, setNewTriggerOffset] = React43.useState(null);
9024 const currentContainerRef = React43.useRef(null);
9025 const previousContainerRef = React43.useRef(null);
9026 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
9027 const cleanupFrame = useAnimationFrame();
9028 const [previousContentDimensions, setPreviousContentDimensions] = React43.useState(null);
9029 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React43.useState(false);
9030 useIsoLayoutEffect(() => {
9031 store.set("hasViewport", true);
9032 return () => {
9033 store.set("hasViewport", false);
9034 };
9035 }, [store]);
9036 const handleMeasureLayout = useStableCallback(() => {
9037 currentContainerRef.current?.style.setProperty("animation", "none");
9038 currentContainerRef.current?.style.setProperty("transition", "none");
9039 previousContainerRef.current?.style.setProperty("display", "none");
9040 });
9041 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
9042 currentContainerRef.current?.style.removeProperty("animation");
9043 currentContainerRef.current?.style.removeProperty("transition");
9044 previousContainerRef.current?.style.removeProperty("display");
9045 if (previousDimensions) {
9046 setPreviousContentDimensions(previousDimensions);
9047 }
9048 });
9049 const lastHandledTriggerRef = React43.useRef(null);
9050 useIsoLayoutEffect(() => {
9051 if (!open || !mounted) {
9052 lastHandledTriggerRef.current = null;
9053 }
9054 }, [open, mounted]);
9055 useIsoLayoutEffect(() => {
9056 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
9057 setPreviousContentNode(capturedNodeRef.current);
9058 setShowStartingStyleAttribute(true);
9059 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
9060 setNewTriggerOffset(offset4);
9061 cleanupFrame.request(() => {
9062 ReactDOM6.flushSync(() => {
9063 setShowStartingStyleAttribute(false);
9064 });
9065 onAnimationsFinished(() => {
9066 setPreviousContentNode(null);
9067 setPreviousContentDimensions(null);
9068 capturedNodeRef.current = null;
9069 });
9070 });
9071 lastHandledTriggerRef.current = activeTrigger;
9072 }
9073 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
9074 useIsoLayoutEffect(() => {
9075 const source = currentContainerRef.current;
9076 if (!source) {
9077 return;
9078 }
9079 const wrapper = ownerDocument(source).createElement("div");
9080 for (const child of Array.from(source.childNodes)) {
9081 wrapper.appendChild(child.cloneNode(true));
9082 }
9083 capturedNodeRef.current = wrapper;
9084 });
9085 const isTransitioning = previousContentNode != null;
9086 let childrenToRender;
9087 if (!isTransitioning) {
9088 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
9089 "data-current": true,
9090 ref: currentContainerRef,
9091 children
9092 }, currentContentKey);
9093 } else {
9094 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React43.Fragment, {
9095 children: [/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
9096 "data-previous": true,
9097 inert: inertValue(true),
9098 ref: previousContainerRef,
9099 style: {
9100 ...previousContentDimensions ? {
9101 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
9102 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
9103 } : null,
9104 position: "absolute"
9105 },
9106 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
9107 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
9108 "data-current": true,
9109 ref: currentContainerRef,
9110 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
9111 children
9112 }, currentContentKey)]
9113 });
9114 }
9115 useIsoLayoutEffect(() => {
9116 const container = previousContainerRef.current;
9117 if (!container || !previousContentNode) {
9118 return;
9119 }
9120 container.replaceChildren(...Array.from(previousContentNode.childNodes));
9121 }, [previousContentNode]);
9122 usePopupAutoResize({
9123 popupElement,
9124 positionerElement,
9125 mounted,
9126 content: payload,
9127 onMeasureLayout: handleMeasureLayout,
9128 onMeasureLayoutComplete: handleMeasureLayoutComplete,
9129 side,
9130 direction
9131 });
9132 const state = {
9133 activationDirection: getActivationDirection(newTriggerOffset),
9134 transitioning: isTransitioning
9135 };
9136 return {
9137 children: childrenToRender,
9138 state
9139 };
9140 }
9141 function getActivationDirection(offset4) {
9142 if (!offset4) {
9143 return void 0;
9144 }
9145 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
9146 }
9147 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
9148 if (value > tolerance) {
9149 return positiveLabel;
9150 }
9151 if (value < -tolerance) {
9152 return negativeLabel;
9153 }
9154 return "";
9155 }
9156 function calculateRelativePosition(from, to) {
9157 const fromRect = from.getBoundingClientRect();
9158 const toRect = to.getBoundingClientRect();
9159 const fromCenter = {
9160 x: fromRect.left + fromRect.width / 2,
9161 y: fromRect.top + fromRect.height / 2
9162 };
9163 const toCenter = {
9164 x: toRect.left + toRect.width / 2,
9165 y: toRect.top + toRect.height / 2
9166 };
9167 return {
9168 horizontal: toCenter.x - fromCenter.x,
9169 vertical: toCenter.y - fromCenter.y
9170 };
9171 }
9172 function usePopupContentKey(activeTriggerId, payload) {
9173 const [contentKey, setContentKey] = React43.useState(0);
9174 const previousActiveTriggerIdRef = React43.useRef(activeTriggerId);
9175 const previousPayloadRef = React43.useRef(payload);
9176 const pendingPayloadUpdateRef = React43.useRef(false);
9177 useIsoLayoutEffect(() => {
9178 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
9179 const previousPayload = previousPayloadRef.current;
9180 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
9181 const payloadChanged = payload !== previousPayload;
9182 if (triggerIdChanged) {
9183 setContentKey((value) => value + 1);
9184 pendingPayloadUpdateRef.current = !payloadChanged;
9185 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
9186 setContentKey((value) => value + 1);
9187 pendingPayloadUpdateRef.current = false;
9188 }
9189 previousActiveTriggerIdRef.current = activeTriggerId;
9190 previousPayloadRef.current = payload;
9191 }, [activeTriggerId, payload]);
9192 return `${activeTriggerId ?? "current"}-${contentKey}`;
9193 }
9194
9195 // node_modules/@base-ui/react/utils/FloatingPortalLite.mjs
9196 var React44 = __toESM(require_react(), 1);
9197 var ReactDOM7 = __toESM(require_react_dom(), 1);
9198 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
9199 var FloatingPortalLite = /* @__PURE__ */ React44.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
9200 const {
9201 children,
9202 container,
9203 className,
9204 render: render4,
9205 style,
9206 ...elementProps
9207 } = componentProps;
9208 const {
9209 portalNode,
9210 portalSubtree
9211 } = useFloatingPortalNode({
9212 container,
9213 ref: forwardedRef,
9214 componentProps,
9215 elementProps
9216 });
9217 if (!portalSubtree && !portalNode) {
9218 return null;
9219 }
9220 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(React44.Fragment, {
9221 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)]
9222 });
9223 });
9224 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
9225
9226 // node_modules/@base-ui/react/tooltip/index.parts.mjs
9227 var index_parts_exports2 = {};
9228 __export(index_parts_exports2, {
9229 Arrow: () => TooltipArrow,
9230 Handle: () => TooltipHandle,
9231 Popup: () => TooltipPopup,
9232 Portal: () => TooltipPortal,
9233 Positioner: () => TooltipPositioner,
9234 Provider: () => TooltipProvider,
9235 Root: () => TooltipRoot,
9236 Trigger: () => TooltipTrigger,
9237 Viewport: () => TooltipViewport,
9238 createHandle: () => createTooltipHandle
9239 });
9240
9241 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
9242 var React47 = __toESM(require_react(), 1);
9243
9244 // node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs
9245 var React45 = __toESM(require_react(), 1);
9246 var TooltipRootContext = /* @__PURE__ */ React45.createContext(void 0);
9247 if (true) TooltipRootContext.displayName = "TooltipRootContext";
9248 function useTooltipRootContext(optional) {
9249 const context = React45.useContext(TooltipRootContext);
9250 if (context === void 0 && !optional) {
9251 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
9252 }
9253 return context;
9254 }
9255
9256 // node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs
9257 var React46 = __toESM(require_react(), 1);
9258 var selectors2 = {
9259 ...popupStoreSelectors,
9260 disabled: createSelector((state) => state.disabled),
9261 instantType: createSelector((state) => state.instantType),
9262 isInstantPhase: createSelector((state) => state.isInstantPhase),
9263 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
9264 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
9265 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
9266 closeOnClick: createSelector((state) => state.closeOnClick),
9267 closeDelay: createSelector((state) => state.closeDelay),
9268 hasViewport: createSelector((state) => state.hasViewport)
9269 };
9270 var TooltipStore = class _TooltipStore extends ReactStore {
9271 constructor(initialState, floatingId, nested = false) {
9272 const triggerElements = new PopupTriggerMap();
9273 const state = {
9274 ...createInitialState(),
9275 ...initialState
9276 };
9277 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
9278 super(state, {
9279 popupRef: /* @__PURE__ */ React46.createRef(),
9280 onOpenChange: void 0,
9281 onOpenChangeComplete: void 0,
9282 triggerElements
9283 }, selectors2);
9284 }
9285 setOpen = (nextOpen, eventDetails) => {
9286 applyPopupOpenChange(this, nextOpen, eventDetails, {
9287 extraState: {
9288 openChangeReason: eventDetails.reason
9289 }
9290 });
9291 };
9292 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
9293 cancelPendingOpen(event) {
9294 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
9295 }
9296 static useStore(externalStore, initialState) {
9297 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
9298 return store;
9299 }
9300 };
9301 function createInitialState() {
9302 return {
9303 ...createInitialPopupStoreState(),
9304 disabled: false,
9305 instantType: void 0,
9306 isInstantPhase: false,
9307 trackCursorAxis: "none",
9308 disableHoverablePopup: false,
9309 openChangeReason: null,
9310 closeOnClick: true,
9311 closeDelay: 0,
9312 hasViewport: false
9313 };
9314 }
9315
9316 // node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
9317 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
9318 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
9319 const {
9320 disabled: disabled2 = false,
9321 defaultOpen = false,
9322 open: openProp,
9323 disableHoverablePopup = false,
9324 trackCursorAxis = "none",
9325 actionsRef,
9326 onOpenChange,
9327 onOpenChangeComplete,
9328 handle,
9329 triggerId: triggerIdProp,
9330 defaultTriggerId: defaultTriggerIdProp = null,
9331 children
9332 } = props;
9333 const store = TooltipStore.useStore(handle?.store, {
9334 open: defaultOpen,
9335 openProp,
9336 activeTriggerId: defaultTriggerIdProp,
9337 triggerIdProp
9338 });
9339 useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerIdProp);
9340 store.useControlledProp("openProp", openProp);
9341 store.useControlledProp("triggerIdProp", triggerIdProp);
9342 store.useContextCallback("onOpenChange", onOpenChange);
9343 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
9344 const openState = store.useState("open");
9345 const open = !disabled2 && openState;
9346 const activeTriggerId = store.useState("activeTriggerId");
9347 const mounted = store.useState("mounted");
9348 const payload = store.useState("payload");
9349 store.useSyncedValues({
9350 trackCursorAxis,
9351 disableHoverablePopup
9352 });
9353 store.useSyncedValue("disabled", disabled2);
9354 useImplicitActiveTrigger(store, {
9355 closeOnActiveTriggerUnmount: true
9356 });
9357 const {
9358 forceUnmount,
9359 transitionStatus
9360 } = useOpenStateTransitions(open, store);
9361 const isInstantPhase = store.useState("isInstantPhase");
9362 const instantType = store.useState("instantType");
9363 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
9364 const previousInstantTypeRef = React47.useRef(null);
9365 useIsoLayoutEffect(() => {
9366 if (openState && disabled2) {
9367 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
9368 }
9369 }, [openState, disabled2, store]);
9370 useIsoLayoutEffect(() => {
9371 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
9372 if (instantType !== "delay") {
9373 previousInstantTypeRef.current = instantType;
9374 }
9375 store.set("instantType", "delay");
9376 } else if (previousInstantTypeRef.current !== null) {
9377 store.set("instantType", previousInstantTypeRef.current);
9378 previousInstantTypeRef.current = null;
9379 }
9380 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
9381 useIsoLayoutEffect(() => {
9382 if (open) {
9383 if (activeTriggerId == null) {
9384 store.set("payload", void 0);
9385 }
9386 }
9387 }, [store, activeTriggerId, open]);
9388 const handleImperativeClose = React47.useCallback(() => {
9389 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
9390 }, [store]);
9391 React47.useImperativeHandle(actionsRef, () => ({
9392 unmount: forceUnmount,
9393 close: handleImperativeClose
9394 }), [forceUnmount, handleImperativeClose]);
9395 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
9396 return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(TooltipRootContext.Provider, {
9397 value: store,
9398 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipInteractions, {
9399 store,
9400 disabled: disabled2,
9401 trackCursorAxis
9402 }), typeof children === "function" ? children({
9403 payload
9404 }) : children]
9405 });
9406 });
9407 if (true) TooltipRoot.displayName = "TooltipRoot";
9408 function TooltipInteractions({
9409 store,
9410 disabled: disabled2,
9411 trackCursorAxis
9412 }) {
9413 const floatingRootContext = store.useState("floatingRootContext");
9414 const dismiss = useDismiss(floatingRootContext, {
9415 enabled: !disabled2,
9416 referencePress: () => store.select("closeOnClick")
9417 });
9418 const clientPoint = useClientPoint(floatingRootContext, {
9419 enabled: !disabled2 && trackCursorAxis !== "none",
9420 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
9421 });
9422 const activeTriggerProps = React47.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
9423 const inactiveTriggerProps = React47.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
9424 const popupProps = React47.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
9425 usePopupInteractionProps(store, {
9426 activeTriggerProps,
9427 inactiveTriggerProps,
9428 popupProps
9429 });
9430 return null;
9431 }
9432
9433 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
9434 var React49 = __toESM(require_react(), 1);
9435
9436 // node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs
9437 var React48 = __toESM(require_react(), 1);
9438 var TooltipProviderContext = /* @__PURE__ */ React48.createContext(void 0);
9439 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
9440 function useTooltipProviderContext() {
9441 return React48.useContext(TooltipProviderContext);
9442 }
9443
9444 // node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs
9445 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
9446 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
9447 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
9448 return TooltipTriggerDataAttributes2;
9449 })({});
9450
9451 // node_modules/@base-ui/react/tooltip/utils/constants.mjs
9452 var OPEN_DELAY = 600;
9453
9454 // node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
9455 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
9456 function getTargetElement(event) {
9457 if ("composedPath" in event) {
9458 const path = event.composedPath();
9459 for (let i2 = 0; i2 < path.length; i2 += 1) {
9460 const element = path[i2];
9461 if (isElement(element)) {
9462 return element;
9463 }
9464 }
9465 }
9466 const target = event.target;
9467 if (isElement(target)) {
9468 return target;
9469 }
9470 return null;
9471 }
9472 function closestEnabledTooltipTrigger(element) {
9473 let current = element;
9474 while (current) {
9475 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
9476 return current;
9477 }
9478 const parentElement = current.parentElement;
9479 if (parentElement) {
9480 current = parentElement;
9481 continue;
9482 }
9483 const root = current.getRootNode();
9484 current = "host" in root && isElement(root.host) ? root.host : null;
9485 }
9486 return null;
9487 }
9488 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
9489 const {
9490 render: render4,
9491 className,
9492 style,
9493 handle,
9494 payload,
9495 disabled: disabledProp,
9496 delay,
9497 closeOnClick = true,
9498 closeDelay,
9499 id: idProp,
9500 ...elementProps
9501 } = componentProps;
9502 const rootContext = useTooltipRootContext(true);
9503 const store = handle?.store ?? rootContext;
9504 if (!store) {
9505 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));
9506 }
9507 const thisTriggerId = useBaseUiId(idProp);
9508 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
9509 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
9510 const floatingRootContext = store.useState("floatingRootContext");
9511 const triggerElementRef = React49.useRef(null);
9512 const delayWithDefault = delay ?? OPEN_DELAY;
9513 const closeDelayWithDefault = closeDelay ?? 0;
9514 const {
9515 registerTrigger,
9516 isMountedByThisTrigger
9517 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
9518 payload,
9519 closeOnClick,
9520 closeDelay: closeDelayWithDefault
9521 });
9522 const providerContext = useTooltipProviderContext();
9523 const {
9524 delayRef,
9525 isInstantPhase,
9526 hasProvider
9527 } = useDelayGroup(floatingRootContext, {
9528 open: isOpenedByThisTrigger
9529 });
9530 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
9531 store.useSyncedValue("isInstantPhase", isInstantPhase);
9532 const rootDisabled = store.useState("disabled");
9533 const disabled2 = disabledProp ?? rootDisabled;
9534 const disabledRef = useValueAsRef(disabled2);
9535 const trackCursorAxis = store.useState("trackCursorAxis");
9536 const disableHoverablePopup = store.useState("disableHoverablePopup");
9537 const isNestedTriggerHoveredRef = React49.useRef(false);
9538 const nestedTriggerOpenTimeout = useTimeout();
9539 const pointerTypeRef = React49.useRef(void 0);
9540 function getOpenDelay() {
9541 const providerDelay = providerContext?.delay;
9542 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
9543 let computedOpenDelay = delayWithDefault;
9544 if (hasProvider) {
9545 if (groupOpenValue !== 0) {
9546 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
9547 } else {
9548 computedOpenDelay = 0;
9549 }
9550 }
9551 return computedOpenDelay;
9552 }
9553 function isEnabledNestedTriggerTarget(target) {
9554 const triggerEl = triggerElementRef.current;
9555 if (!triggerEl || !target) {
9556 return false;
9557 }
9558 const nearestTrigger = closestEnabledTooltipTrigger(target);
9559 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
9560 }
9561 function detectNestedTriggerHover(target) {
9562 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
9563 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
9564 if (nestedTriggerHovered) {
9565 hoverInteraction.openChangeTimeout.clear();
9566 hoverInteraction.restTimeout.clear();
9567 hoverInteraction.restTimeoutPending = false;
9568 nestedTriggerOpenTimeout.clear();
9569 }
9570 return nestedTriggerHovered;
9571 }
9572 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
9573 enabled: !disabled2,
9574 mouseOnly: true,
9575 move: false,
9576 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
9577 restMs: getOpenDelay,
9578 delay() {
9579 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
9580 let computedCloseDelay = closeDelayWithDefault;
9581 if (closeDelay == null && hasProvider) {
9582 computedCloseDelay = closeValue;
9583 }
9584 return {
9585 close: computedCloseDelay
9586 };
9587 },
9588 triggerElementRef,
9589 isActiveTrigger: isTriggerActive,
9590 isClosing: () => store.select("transitionStatus") === "ending",
9591 shouldOpen() {
9592 return !isNestedTriggerHoveredRef.current;
9593 }
9594 });
9595 const focusProps = useFocus(floatingRootContext, {
9596 enabled: !disabled2
9597 }).reference;
9598 const handleNestedTriggerHover = (event) => {
9599 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
9600 const target = getTargetElement(event);
9601 const nestedTriggerHovered = detectNestedTriggerHover(target);
9602 const triggerEl = triggerElementRef.current;
9603 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
9604 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
9605 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
9606 return;
9607 }
9608 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
9609 isMouseLikePointerType(pointerTypeRef.current)) {
9610 const open = () => {
9611 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
9612 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
9613 }
9614 };
9615 const openDelay = getOpenDelay();
9616 if (openDelay === 0) {
9617 nestedTriggerOpenTimeout.clear();
9618 open();
9619 } else {
9620 nestedTriggerOpenTimeout.start(openDelay, open);
9621 }
9622 }
9623 };
9624 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
9625 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
9626 const state = {
9627 open: isOpenedByThisTrigger
9628 };
9629 const element = useRenderElement("button", componentProps, {
9630 state,
9631 ref: [forwardedRef, registerTrigger, triggerElementRef],
9632 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
9633 onMouseOver(event) {
9634 handleNestedTriggerHover(event.nativeEvent);
9635 },
9636 onFocus(event) {
9637 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
9638 event.preventBaseUIHandler();
9639 }
9640 },
9641 onMouseLeave() {
9642 isNestedTriggerHoveredRef.current = false;
9643 nestedTriggerOpenTimeout.clear();
9644 pointerTypeRef.current = void 0;
9645 },
9646 onPointerEnter(event) {
9647 pointerTypeRef.current = event.pointerType;
9648 },
9649 onPointerDown(event) {
9650 pointerTypeRef.current = event.pointerType;
9651 store.set("closeOnClick", closeOnClick);
9652 if (closeOnClick && !store.select("open")) {
9653 store.cancelPendingOpen(event.nativeEvent);
9654 }
9655 },
9656 onClick(event) {
9657 if (closeOnClick && !store.select("open")) {
9658 store.cancelPendingOpen(event.nativeEvent);
9659 }
9660 },
9661 id: thisTriggerId,
9662 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
9663 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
9664 }, elementProps],
9665 stateAttributesMapping: triggerOpenStateMapping2
9666 });
9667 return element;
9668 });
9669 if (true) TooltipTrigger.displayName = "TooltipTrigger";
9670
9671 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
9672 var React51 = __toESM(require_react(), 1);
9673
9674 // node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs
9675 var React50 = __toESM(require_react(), 1);
9676 var TooltipPortalContext = /* @__PURE__ */ React50.createContext(void 0);
9677 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
9678 function useTooltipPortalContext() {
9679 const value = React50.useContext(TooltipPortalContext);
9680 if (value === void 0) {
9681 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
9682 }
9683 return value;
9684 }
9685
9686 // node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
9687 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
9688 var TooltipPortal = /* @__PURE__ */ React51.forwardRef(function TooltipPortal2(props, forwardedRef) {
9689 const {
9690 keepMounted = false,
9691 ...portalProps
9692 } = props;
9693 const store = useTooltipRootContext();
9694 const mounted = store.useState("mounted");
9695 const shouldRender = mounted || keepMounted;
9696 if (!shouldRender) {
9697 return null;
9698 }
9699 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPortalContext.Provider, {
9700 value: keepMounted,
9701 children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloatingPortalLite, {
9702 ref: forwardedRef,
9703 ...portalProps
9704 })
9705 });
9706 });
9707 if (true) TooltipPortal.displayName = "TooltipPortal";
9708
9709 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9710 var React53 = __toESM(require_react(), 1);
9711
9712 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs
9713 var React52 = __toESM(require_react(), 1);
9714 var TooltipPositionerContext = /* @__PURE__ */ React52.createContext(void 0);
9715 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
9716 function useTooltipPositionerContext() {
9717 const context = React52.useContext(TooltipPositionerContext);
9718 if (context === void 0) {
9719 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
9720 }
9721 return context;
9722 }
9723
9724 // node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
9725 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
9726 var TooltipPositioner = /* @__PURE__ */ React53.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
9727 const {
9728 render: render4,
9729 className,
9730 anchor,
9731 positionMethod = "absolute",
9732 side = "top",
9733 align = "center",
9734 sideOffset = 0,
9735 alignOffset = 0,
9736 collisionBoundary = "clipping-ancestors",
9737 collisionPadding = 5,
9738 arrowPadding = 5,
9739 sticky = false,
9740 disableAnchorTracking = false,
9741 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
9742 style,
9743 ...elementProps
9744 } = componentProps;
9745 const store = useTooltipRootContext();
9746 const keepMounted = useTooltipPortalContext();
9747 const open = store.useState("open");
9748 const mounted = store.useState("mounted");
9749 const trackCursorAxis = store.useState("trackCursorAxis");
9750 const disableHoverablePopup = store.useState("disableHoverablePopup");
9751 const floatingRootContext = store.useState("floatingRootContext");
9752 const instantType = store.useState("instantType");
9753 const transitionStatus = store.useState("transitionStatus");
9754 const hasViewport = store.useState("hasViewport");
9755 const positioning = useAnchorPositioning({
9756 anchor,
9757 positionMethod,
9758 floatingRootContext,
9759 mounted,
9760 side,
9761 sideOffset,
9762 align,
9763 alignOffset,
9764 collisionBoundary,
9765 collisionPadding,
9766 sticky,
9767 arrowPadding,
9768 disableAnchorTracking,
9769 keepMounted,
9770 collisionAvoidance,
9771 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
9772 });
9773 const state = React53.useMemo(() => ({
9774 open,
9775 side: positioning.side,
9776 align: positioning.align,
9777 anchorHidden: positioning.anchorHidden,
9778 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
9779 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
9780 const element = usePositioner(componentProps, state, {
9781 styles: positioning.positionerStyles,
9782 transitionStatus,
9783 props: elementProps,
9784 refs: [forwardedRef, store.useStateSetter("positionerElement")],
9785 hidden: !mounted,
9786 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
9787 });
9788 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipPositionerContext.Provider, {
9789 value: positioning,
9790 children: element
9791 });
9792 });
9793 if (true) TooltipPositioner.displayName = "TooltipPositioner";
9794
9795 // node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs
9796 var React54 = __toESM(require_react(), 1);
9797 var stateAttributesMapping2 = {
9798 ...popupStateMapping,
9799 ...transitionStatusMapping
9800 };
9801 var TooltipPopup = /* @__PURE__ */ React54.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
9802 const {
9803 render: render4,
9804 className,
9805 style,
9806 ...elementProps
9807 } = componentProps;
9808 const store = useTooltipRootContext();
9809 const {
9810 side,
9811 align
9812 } = useTooltipPositionerContext();
9813 const open = store.useState("open");
9814 const instantType = store.useState("instantType");
9815 const transitionStatus = store.useState("transitionStatus");
9816 const popupProps = store.useState("popupProps");
9817 const floatingContext = store.useState("floatingRootContext");
9818 const disabled2 = store.useState("disabled");
9819 const closeDelay = store.useState("closeDelay");
9820 useOpenChangeComplete({
9821 open,
9822 ref: store.context.popupRef,
9823 onComplete() {
9824 if (open) {
9825 store.context.onOpenChangeComplete?.(true);
9826 }
9827 }
9828 });
9829 useHoverFloatingInteraction(floatingContext, {
9830 enabled: !disabled2,
9831 closeDelay
9832 });
9833 const setPopupElement = store.useStateSetter("popupElement");
9834 const state = {
9835 open,
9836 side,
9837 align,
9838 instant: instantType,
9839 transitionStatus
9840 };
9841 const element = useRenderElement("div", componentProps, {
9842 state,
9843 ref: [forwardedRef, store.context.popupRef, setPopupElement],
9844 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9845 stateAttributesMapping: stateAttributesMapping2
9846 });
9847 return element;
9848 });
9849 if (true) TooltipPopup.displayName = "TooltipPopup";
9850
9851 // node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs
9852 var React55 = __toESM(require_react(), 1);
9853 var TooltipArrow = /* @__PURE__ */ React55.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9854 const {
9855 render: render4,
9856 className,
9857 style,
9858 ...elementProps
9859 } = componentProps;
9860 const store = useTooltipRootContext();
9861 const {
9862 arrowRef,
9863 side,
9864 align,
9865 arrowUncentered,
9866 arrowStyles
9867 } = useTooltipPositionerContext();
9868 const open = store.useState("open");
9869 const instantType = store.useState("instantType");
9870 const state = {
9871 open,
9872 side,
9873 align,
9874 uncentered: arrowUncentered,
9875 instant: instantType
9876 };
9877 const element = useRenderElement("div", componentProps, {
9878 state,
9879 ref: [forwardedRef, arrowRef],
9880 props: [{
9881 style: arrowStyles,
9882 "aria-hidden": true
9883 }, elementProps],
9884 stateAttributesMapping: popupStateMapping
9885 });
9886 return element;
9887 });
9888 if (true) TooltipArrow.displayName = "TooltipArrow";
9889
9890 // node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs
9891 var React56 = __toESM(require_react(), 1);
9892 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
9893 var TooltipProvider = function TooltipProvider2(props) {
9894 const {
9895 delay,
9896 closeDelay,
9897 timeout = 400
9898 } = props;
9899 const contextValue = React56.useMemo(() => ({
9900 delay,
9901 closeDelay
9902 }), [delay, closeDelay]);
9903 const delayValue = React56.useMemo(() => ({
9904 open: delay,
9905 close: closeDelay
9906 }), [delay, closeDelay]);
9907 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipProviderContext.Provider, {
9908 value: contextValue,
9909 children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatingDelayGroup, {
9910 delay: delayValue,
9911 timeoutMs: timeout,
9912 children: props.children
9913 })
9914 });
9915 };
9916 if (true) TooltipProvider.displayName = "TooltipProvider";
9917
9918 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9919 var React57 = __toESM(require_react(), 1);
9920
9921 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs
9922 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9923 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9924 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9925 return TooltipViewportCssVars2;
9926 })({});
9927
9928 // node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
9929 var stateAttributesMapping3 = {
9930 activationDirection: (value) => value ? {
9931 "data-activation-direction": value
9932 } : null
9933 };
9934 var TooltipViewport = /* @__PURE__ */ React57.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9935 const {
9936 render: render4,
9937 className,
9938 style,
9939 children,
9940 ...elementProps
9941 } = componentProps;
9942 const store = useTooltipRootContext();
9943 const positioner = useTooltipPositionerContext();
9944 const instantType = store.useState("instantType");
9945 const {
9946 children: childrenToRender,
9947 state: viewportState
9948 } = usePopupViewport({
9949 store,
9950 side: positioner.side,
9951 cssVars: TooltipViewportCssVars,
9952 children
9953 });
9954 const state = {
9955 activationDirection: viewportState.activationDirection,
9956 transitioning: viewportState.transitioning,
9957 instant: instantType
9958 };
9959 return useRenderElement("div", componentProps, {
9960 state,
9961 ref: forwardedRef,
9962 props: [elementProps, {
9963 children: childrenToRender
9964 }],
9965 stateAttributesMapping: stateAttributesMapping3
9966 });
9967 });
9968 if (true) TooltipViewport.displayName = "TooltipViewport";
9969
9970 // node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs
9971 var TooltipHandle = class {
9972 /**
9973 * Internal store holding the tooltip state.
9974 * @internal
9975 */
9976 constructor() {
9977 this.store = new TooltipStore();
9978 }
9979 /**
9980 * Opens the tooltip and associates it with the trigger with the given ID.
9981 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9982 *
9983 * This method should only be called in an event handler or an effect (not during rendering).
9984 *
9985 * @param triggerId ID of the trigger to associate with the tooltip.
9986 */
9987 open(triggerId) {
9988 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9989 if (triggerId && !triggerElement) {
9990 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9991 }
9992 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9993 }
9994 /**
9995 * Closes the tooltip.
9996 */
9997 close() {
9998 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9999 }
10000 /**
10001 * Indicates whether the tooltip is currently open.
10002 */
10003 get isOpen() {
10004 return this.store.select("open");
10005 }
10006 };
10007 function createTooltipHandle() {
10008 return new TooltipHandle();
10009 }
10010
10011 // node_modules/@base-ui/react/use-render/useRender.mjs
10012 function useRender(params) {
10013 return useRenderElement(params.defaultTagName ?? "div", params, params);
10014 }
10015
10016 // packages/ui/build-module/text/text.mjs
10017 var import_element10 = __toESM(require_element(), 1);
10018 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
10019 function getRuntime() {
10020 const globalScope = globalThis;
10021 if (globalScope.__wpStyleRuntime) {
10022 return globalScope.__wpStyleRuntime;
10023 }
10024 globalScope.__wpStyleRuntime = {
10025 documents: /* @__PURE__ */ new Map(),
10026 styles: /* @__PURE__ */ new Map(),
10027 injectedStyles: /* @__PURE__ */ new WeakMap()
10028 };
10029 if (typeof document !== "undefined") {
10030 registerDocument(document);
10031 }
10032 return globalScope.__wpStyleRuntime;
10033 }
10034 function documentContainsStyleHash(targetDocument, hash) {
10035 if (!targetDocument.head) {
10036 return false;
10037 }
10038 for (const style of targetDocument.head.querySelectorAll(
10039 `style[${STYLE_HASH_ATTRIBUTE}]`
10040 )) {
10041 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
10042 return true;
10043 }
10044 }
10045 return false;
10046 }
10047 function injectStyle(targetDocument, hash, css) {
10048 if (!targetDocument.head) {
10049 return;
10050 }
10051 const runtime = getRuntime();
10052 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10053 if (!injectedStyles) {
10054 injectedStyles = /* @__PURE__ */ new Set();
10055 runtime.injectedStyles.set(targetDocument, injectedStyles);
10056 }
10057 if (injectedStyles.has(hash)) {
10058 return;
10059 }
10060 if (documentContainsStyleHash(targetDocument, hash)) {
10061 injectedStyles.add(hash);
10062 return;
10063 }
10064 const style = targetDocument.createElement("style");
10065 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
10066 style.appendChild(targetDocument.createTextNode(css));
10067 targetDocument.head.appendChild(style);
10068 injectedStyles.add(hash);
10069 }
10070 function registerDocument(targetDocument) {
10071 const runtime = getRuntime();
10072 runtime.documents.set(
10073 targetDocument,
10074 (runtime.documents.get(targetDocument) ?? 0) + 1
10075 );
10076 for (const [hash, css] of runtime.styles) {
10077 injectStyle(targetDocument, hash, css);
10078 }
10079 return () => {
10080 const count = runtime.documents.get(targetDocument);
10081 if (count === void 0) {
10082 return;
10083 }
10084 if (count <= 1) {
10085 runtime.documents.delete(targetDocument);
10086 return;
10087 }
10088 runtime.documents.set(targetDocument, count - 1);
10089 };
10090 }
10091 function registerStyle(hash, css) {
10092 const runtime = getRuntime();
10093 runtime.styles.set(hash, css);
10094 for (const targetDocument of runtime.documents.keys()) {
10095 injectStyle(targetDocument, hash, css);
10096 }
10097 }
10098 if (typeof process === "undefined" || true) {
10099 registerStyle("a495f9d138", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}');
10100 }
10101 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" };
10102 if (typeof process === "undefined" || true) {
10103 registerStyle("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
10104 }
10105 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" };
10106 var Text = (0, import_element10.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
10107 const element = useRender({
10108 render: render4,
10109 defaultTagName: "span",
10110 ref,
10111 props: mergeProps(props, {
10112 className: clsx_default(
10113 style_default.text,
10114 global_css_defense_default.heading,
10115 global_css_defense_default.p,
10116 style_default[variant],
10117 className
10118 )
10119 })
10120 });
10121 return element;
10122 });
10123
10124 // packages/ui/build-module/badge/badge.mjs
10125 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
10126 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
10127 function getRuntime2() {
10128 const globalScope = globalThis;
10129 if (globalScope.__wpStyleRuntime) {
10130 return globalScope.__wpStyleRuntime;
10131 }
10132 globalScope.__wpStyleRuntime = {
10133 documents: /* @__PURE__ */ new Map(),
10134 styles: /* @__PURE__ */ new Map(),
10135 injectedStyles: /* @__PURE__ */ new WeakMap()
10136 };
10137 if (typeof document !== "undefined") {
10138 registerDocument2(document);
10139 }
10140 return globalScope.__wpStyleRuntime;
10141 }
10142 function documentContainsStyleHash2(targetDocument, hash) {
10143 if (!targetDocument.head) {
10144 return false;
10145 }
10146 for (const style of targetDocument.head.querySelectorAll(
10147 `style[${STYLE_HASH_ATTRIBUTE2}]`
10148 )) {
10149 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
10150 return true;
10151 }
10152 }
10153 return false;
10154 }
10155 function injectStyle2(targetDocument, hash, css) {
10156 if (!targetDocument.head) {
10157 return;
10158 }
10159 const runtime = getRuntime2();
10160 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10161 if (!injectedStyles) {
10162 injectedStyles = /* @__PURE__ */ new Set();
10163 runtime.injectedStyles.set(targetDocument, injectedStyles);
10164 }
10165 if (injectedStyles.has(hash)) {
10166 return;
10167 }
10168 if (documentContainsStyleHash2(targetDocument, hash)) {
10169 injectedStyles.add(hash);
10170 return;
10171 }
10172 const style = targetDocument.createElement("style");
10173 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
10174 style.appendChild(targetDocument.createTextNode(css));
10175 targetDocument.head.appendChild(style);
10176 injectedStyles.add(hash);
10177 }
10178 function registerDocument2(targetDocument) {
10179 const runtime = getRuntime2();
10180 runtime.documents.set(
10181 targetDocument,
10182 (runtime.documents.get(targetDocument) ?? 0) + 1
10183 );
10184 for (const [hash, css] of runtime.styles) {
10185 injectStyle2(targetDocument, hash, css);
10186 }
10187 return () => {
10188 const count = runtime.documents.get(targetDocument);
10189 if (count === void 0) {
10190 return;
10191 }
10192 if (count <= 1) {
10193 runtime.documents.delete(targetDocument);
10194 return;
10195 }
10196 runtime.documents.set(targetDocument, count - 1);
10197 };
10198 }
10199 function registerStyle2(hash, css) {
10200 const runtime = getRuntime2();
10201 runtime.styles.set(hash, css);
10202 for (const targetDocument of runtime.documents.keys()) {
10203 injectStyle2(targetDocument, hash, css);
10204 }
10205 }
10206 if (typeof process === "undefined" || true) {
10207 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))}}}");
10208 }
10209 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" };
10210 var Badge = (0, import_element11.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) {
10211 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
10212 Text,
10213 {
10214 ref,
10215 className: clsx_default(
10216 style_default2.badge,
10217 style_default2[`is-${intent}-intent`],
10218 className
10219 ),
10220 ...props,
10221 variant: "body-sm"
10222 }
10223 );
10224 });
10225
10226 // packages/ui/build-module/button/button.mjs
10227 var import_element12 = __toESM(require_element(), 1);
10228 var import_i18n = __toESM(require_i18n(), 1);
10229 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
10230 import { speak } from "@wordpress/a11y";
10231 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
10232 function getRuntime3() {
10233 const globalScope = globalThis;
10234 if (globalScope.__wpStyleRuntime) {
10235 return globalScope.__wpStyleRuntime;
10236 }
10237 globalScope.__wpStyleRuntime = {
10238 documents: /* @__PURE__ */ new Map(),
10239 styles: /* @__PURE__ */ new Map(),
10240 injectedStyles: /* @__PURE__ */ new WeakMap()
10241 };
10242 if (typeof document !== "undefined") {
10243 registerDocument3(document);
10244 }
10245 return globalScope.__wpStyleRuntime;
10246 }
10247 function documentContainsStyleHash3(targetDocument, hash) {
10248 if (!targetDocument.head) {
10249 return false;
10250 }
10251 for (const style of targetDocument.head.querySelectorAll(
10252 `style[${STYLE_HASH_ATTRIBUTE3}]`
10253 )) {
10254 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
10255 return true;
10256 }
10257 }
10258 return false;
10259 }
10260 function injectStyle3(targetDocument, hash, css) {
10261 if (!targetDocument.head) {
10262 return;
10263 }
10264 const runtime = getRuntime3();
10265 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10266 if (!injectedStyles) {
10267 injectedStyles = /* @__PURE__ */ new Set();
10268 runtime.injectedStyles.set(targetDocument, injectedStyles);
10269 }
10270 if (injectedStyles.has(hash)) {
10271 return;
10272 }
10273 if (documentContainsStyleHash3(targetDocument, hash)) {
10274 injectedStyles.add(hash);
10275 return;
10276 }
10277 const style = targetDocument.createElement("style");
10278 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
10279 style.appendChild(targetDocument.createTextNode(css));
10280 targetDocument.head.appendChild(style);
10281 injectedStyles.add(hash);
10282 }
10283 function registerDocument3(targetDocument) {
10284 const runtime = getRuntime3();
10285 runtime.documents.set(
10286 targetDocument,
10287 (runtime.documents.get(targetDocument) ?? 0) + 1
10288 );
10289 for (const [hash, css] of runtime.styles) {
10290 injectStyle3(targetDocument, hash, css);
10291 }
10292 return () => {
10293 const count = runtime.documents.get(targetDocument);
10294 if (count === void 0) {
10295 return;
10296 }
10297 if (count <= 1) {
10298 runtime.documents.delete(targetDocument);
10299 return;
10300 }
10301 runtime.documents.set(targetDocument, count - 1);
10302 };
10303 }
10304 function registerStyle3(hash, css) {
10305 const runtime = getRuntime3();
10306 runtime.styles.set(hash, css);
10307 for (const targetDocument of runtime.documents.keys()) {
10308 injectStyle3(targetDocument, hash, css);
10309 }
10310 }
10311 if (typeof process === "undefined" || true) {
10312 registerStyle3("b74f1ac304", '@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-emphasis,600);--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:border-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:0px;--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)}}}');
10313 }
10314 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" };
10315 if (typeof process === "undefined" || true) {
10316 registerStyle3("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10317 }
10318 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10319 if (typeof process === "undefined" || true) {
10320 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))}}}");
10321 }
10322 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" };
10323 if (typeof process === "undefined" || true) {
10324 registerStyle3("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
10325 }
10326 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" };
10327 var Button3 = (0, import_element12.forwardRef)(
10328 function Button22({
10329 tone = "brand",
10330 variant = "solid",
10331 size: size4 = "default",
10332 className,
10333 focusableWhenDisabled = true,
10334 disabled: disabled2,
10335 loading,
10336 loadingAnnouncement = (0, import_i18n.__)("Loading"),
10337 children,
10338 ...props
10339 }, ref) {
10340 const mergedClassName = clsx_default(
10341 global_css_defense_default2.button,
10342 resets_default["box-sizing"],
10343 focus_default["outset-ring--focus-except-active"],
10344 variant !== "unstyled" && style_default3.button,
10345 style_default3[`is-${tone}`],
10346 style_default3[`is-${variant}`],
10347 style_default3[`is-${size4}`],
10348 loading && style_default3["is-loading"],
10349 className
10350 );
10351 (0, import_element12.useEffect)(() => {
10352 if (loading && loadingAnnouncement) {
10353 speak(loadingAnnouncement);
10354 }
10355 }, [loading, loadingAnnouncement]);
10356 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
10357 Button,
10358 {
10359 ref,
10360 className: mergedClassName,
10361 focusableWhenDisabled,
10362 disabled: disabled2 ?? loading,
10363 ...props,
10364 children
10365 }
10366 );
10367 }
10368 );
10369
10370 // packages/ui/build-module/button/icon.mjs
10371 var import_element14 = __toESM(require_element(), 1);
10372
10373 // packages/ui/build-module/icon/icon.mjs
10374 var import_element13 = __toESM(require_element(), 1);
10375 var import_primitives = __toESM(require_primitives(), 1);
10376 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
10377 var Icon = (0, import_element13.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
10378 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
10379 import_primitives.SVG,
10380 {
10381 ref,
10382 ...icon.props,
10383 ...restProps,
10384 width: size4,
10385 height: size4
10386 }
10387 );
10388 });
10389
10390 // packages/ui/build-module/button/icon.mjs
10391 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
10392 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
10393 function getRuntime4() {
10394 const globalScope = globalThis;
10395 if (globalScope.__wpStyleRuntime) {
10396 return globalScope.__wpStyleRuntime;
10397 }
10398 globalScope.__wpStyleRuntime = {
10399 documents: /* @__PURE__ */ new Map(),
10400 styles: /* @__PURE__ */ new Map(),
10401 injectedStyles: /* @__PURE__ */ new WeakMap()
10402 };
10403 if (typeof document !== "undefined") {
10404 registerDocument4(document);
10405 }
10406 return globalScope.__wpStyleRuntime;
10407 }
10408 function documentContainsStyleHash4(targetDocument, hash) {
10409 if (!targetDocument.head) {
10410 return false;
10411 }
10412 for (const style of targetDocument.head.querySelectorAll(
10413 `style[${STYLE_HASH_ATTRIBUTE4}]`
10414 )) {
10415 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
10416 return true;
10417 }
10418 }
10419 return false;
10420 }
10421 function injectStyle4(targetDocument, hash, css) {
10422 if (!targetDocument.head) {
10423 return;
10424 }
10425 const runtime = getRuntime4();
10426 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10427 if (!injectedStyles) {
10428 injectedStyles = /* @__PURE__ */ new Set();
10429 runtime.injectedStyles.set(targetDocument, injectedStyles);
10430 }
10431 if (injectedStyles.has(hash)) {
10432 return;
10433 }
10434 if (documentContainsStyleHash4(targetDocument, hash)) {
10435 injectedStyles.add(hash);
10436 return;
10437 }
10438 const style = targetDocument.createElement("style");
10439 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
10440 style.appendChild(targetDocument.createTextNode(css));
10441 targetDocument.head.appendChild(style);
10442 injectedStyles.add(hash);
10443 }
10444 function registerDocument4(targetDocument) {
10445 const runtime = getRuntime4();
10446 runtime.documents.set(
10447 targetDocument,
10448 (runtime.documents.get(targetDocument) ?? 0) + 1
10449 );
10450 for (const [hash, css] of runtime.styles) {
10451 injectStyle4(targetDocument, hash, css);
10452 }
10453 return () => {
10454 const count = runtime.documents.get(targetDocument);
10455 if (count === void 0) {
10456 return;
10457 }
10458 if (count <= 1) {
10459 runtime.documents.delete(targetDocument);
10460 return;
10461 }
10462 runtime.documents.set(targetDocument, count - 1);
10463 };
10464 }
10465 function registerStyle4(hash, css) {
10466 const runtime = getRuntime4();
10467 runtime.styles.set(hash, css);
10468 for (const targetDocument of runtime.documents.keys()) {
10469 injectStyle4(targetDocument, hash, css);
10470 }
10471 }
10472 if (typeof process === "undefined" || true) {
10473 registerStyle4("b74f1ac304", '@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-emphasis,600);--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:border-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:0px;--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)}}}');
10474 }
10475 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" };
10476 var ButtonIcon = (0, import_element14.forwardRef)(
10477 function ButtonIcon2({ className, icon, ...props }, ref) {
10478 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
10479 Icon,
10480 {
10481 ref,
10482 icon,
10483 className: clsx_default(style_default4.icon, className),
10484 size: 24,
10485 ...props
10486 }
10487 );
10488 }
10489 );
10490
10491 // packages/ui/build-module/button/index.mjs
10492 ButtonIcon.displayName = "Button.Icon";
10493 var Button4 = Object.assign(Button3, {
10494 /**
10495 * An icon component specifically designed to work well when rendered inside
10496 * a `Button` component.
10497 */
10498 Icon: ButtonIcon
10499 });
10500
10501 // packages/ui/build-module/card/index.mjs
10502 var card_exports = {};
10503 __export(card_exports, {
10504 Content: () => Content,
10505 FullBleed: () => FullBleed,
10506 Header: () => Header,
10507 Root: () => Root,
10508 Title: () => Title
10509 });
10510
10511 // packages/ui/build-module/card/root.mjs
10512 var import_element15 = __toESM(require_element(), 1);
10513 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
10514 function getRuntime5() {
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 registerDocument5(document);
10526 }
10527 return globalScope.__wpStyleRuntime;
10528 }
10529 function documentContainsStyleHash5(targetDocument, hash) {
10530 if (!targetDocument.head) {
10531 return false;
10532 }
10533 for (const style of targetDocument.head.querySelectorAll(
10534 `style[${STYLE_HASH_ATTRIBUTE5}]`
10535 )) {
10536 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
10537 return true;
10538 }
10539 }
10540 return false;
10541 }
10542 function injectStyle5(targetDocument, hash, css) {
10543 if (!targetDocument.head) {
10544 return;
10545 }
10546 const runtime = getRuntime5();
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 (documentContainsStyleHash5(targetDocument, hash)) {
10556 injectedStyles.add(hash);
10557 return;
10558 }
10559 const style = targetDocument.createElement("style");
10560 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
10561 style.appendChild(targetDocument.createTextNode(css));
10562 targetDocument.head.appendChild(style);
10563 injectedStyles.add(hash);
10564 }
10565 function registerDocument5(targetDocument) {
10566 const runtime = getRuntime5();
10567 runtime.documents.set(
10568 targetDocument,
10569 (runtime.documents.get(targetDocument) ?? 0) + 1
10570 );
10571 for (const [hash, css] of runtime.styles) {
10572 injectStyle5(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 registerStyle5(hash, css) {
10587 const runtime = getRuntime5();
10588 runtime.styles.set(hash, css);
10589 for (const targetDocument of runtime.documents.keys()) {
10590 injectStyle5(targetDocument, hash, css);
10591 }
10592 }
10593 if (typeof process === "undefined" || true) {
10594 registerStyle5("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10595 }
10596 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10597 if (typeof process === "undefined" || true) {
10598 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)}}}");
10599 }
10600 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10601 var Root = (0, import_element15.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
10602 const mergedClassName = clsx_default(style_default5.root, resets_default2["box-sizing"]);
10603 const element = useRender({
10604 defaultTagName: "div",
10605 render: render4,
10606 ref,
10607 props: mergeProps({ className: mergedClassName }, restProps)
10608 });
10609 return element;
10610 });
10611
10612 // packages/ui/build-module/card/header.mjs
10613 var import_element16 = __toESM(require_element(), 1);
10614 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
10615 function getRuntime6() {
10616 const globalScope = globalThis;
10617 if (globalScope.__wpStyleRuntime) {
10618 return globalScope.__wpStyleRuntime;
10619 }
10620 globalScope.__wpStyleRuntime = {
10621 documents: /* @__PURE__ */ new Map(),
10622 styles: /* @__PURE__ */ new Map(),
10623 injectedStyles: /* @__PURE__ */ new WeakMap()
10624 };
10625 if (typeof document !== "undefined") {
10626 registerDocument6(document);
10627 }
10628 return globalScope.__wpStyleRuntime;
10629 }
10630 function documentContainsStyleHash6(targetDocument, hash) {
10631 if (!targetDocument.head) {
10632 return false;
10633 }
10634 for (const style of targetDocument.head.querySelectorAll(
10635 `style[${STYLE_HASH_ATTRIBUTE6}]`
10636 )) {
10637 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
10638 return true;
10639 }
10640 }
10641 return false;
10642 }
10643 function injectStyle6(targetDocument, hash, css) {
10644 if (!targetDocument.head) {
10645 return;
10646 }
10647 const runtime = getRuntime6();
10648 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10649 if (!injectedStyles) {
10650 injectedStyles = /* @__PURE__ */ new Set();
10651 runtime.injectedStyles.set(targetDocument, injectedStyles);
10652 }
10653 if (injectedStyles.has(hash)) {
10654 return;
10655 }
10656 if (documentContainsStyleHash6(targetDocument, hash)) {
10657 injectedStyles.add(hash);
10658 return;
10659 }
10660 const style = targetDocument.createElement("style");
10661 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
10662 style.appendChild(targetDocument.createTextNode(css));
10663 targetDocument.head.appendChild(style);
10664 injectedStyles.add(hash);
10665 }
10666 function registerDocument6(targetDocument) {
10667 const runtime = getRuntime6();
10668 runtime.documents.set(
10669 targetDocument,
10670 (runtime.documents.get(targetDocument) ?? 0) + 1
10671 );
10672 for (const [hash, css] of runtime.styles) {
10673 injectStyle6(targetDocument, hash, css);
10674 }
10675 return () => {
10676 const count = runtime.documents.get(targetDocument);
10677 if (count === void 0) {
10678 return;
10679 }
10680 if (count <= 1) {
10681 runtime.documents.delete(targetDocument);
10682 return;
10683 }
10684 runtime.documents.set(targetDocument, count - 1);
10685 };
10686 }
10687 function registerStyle6(hash, css) {
10688 const runtime = getRuntime6();
10689 runtime.styles.set(hash, css);
10690 for (const targetDocument of runtime.documents.keys()) {
10691 injectStyle6(targetDocument, hash, css);
10692 }
10693 }
10694 if (typeof process === "undefined" || true) {
10695 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)}}}");
10696 }
10697 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10698 var Header = (0, import_element16.forwardRef)(
10699 function CardHeader({ render: render4, ...props }, ref) {
10700 const element = useRender({
10701 defaultTagName: "div",
10702 render: render4,
10703 ref,
10704 props: mergeProps({ className: style_default6.header }, props)
10705 });
10706 return element;
10707 }
10708 );
10709
10710 // packages/ui/build-module/card/content.mjs
10711 var import_element17 = __toESM(require_element(), 1);
10712 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
10713 function getRuntime7() {
10714 const globalScope = globalThis;
10715 if (globalScope.__wpStyleRuntime) {
10716 return globalScope.__wpStyleRuntime;
10717 }
10718 globalScope.__wpStyleRuntime = {
10719 documents: /* @__PURE__ */ new Map(),
10720 styles: /* @__PURE__ */ new Map(),
10721 injectedStyles: /* @__PURE__ */ new WeakMap()
10722 };
10723 if (typeof document !== "undefined") {
10724 registerDocument7(document);
10725 }
10726 return globalScope.__wpStyleRuntime;
10727 }
10728 function documentContainsStyleHash7(targetDocument, hash) {
10729 if (!targetDocument.head) {
10730 return false;
10731 }
10732 for (const style of targetDocument.head.querySelectorAll(
10733 `style[${STYLE_HASH_ATTRIBUTE7}]`
10734 )) {
10735 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
10736 return true;
10737 }
10738 }
10739 return false;
10740 }
10741 function injectStyle7(targetDocument, hash, css) {
10742 if (!targetDocument.head) {
10743 return;
10744 }
10745 const runtime = getRuntime7();
10746 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10747 if (!injectedStyles) {
10748 injectedStyles = /* @__PURE__ */ new Set();
10749 runtime.injectedStyles.set(targetDocument, injectedStyles);
10750 }
10751 if (injectedStyles.has(hash)) {
10752 return;
10753 }
10754 if (documentContainsStyleHash7(targetDocument, hash)) {
10755 injectedStyles.add(hash);
10756 return;
10757 }
10758 const style = targetDocument.createElement("style");
10759 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
10760 style.appendChild(targetDocument.createTextNode(css));
10761 targetDocument.head.appendChild(style);
10762 injectedStyles.add(hash);
10763 }
10764 function registerDocument7(targetDocument) {
10765 const runtime = getRuntime7();
10766 runtime.documents.set(
10767 targetDocument,
10768 (runtime.documents.get(targetDocument) ?? 0) + 1
10769 );
10770 for (const [hash, css] of runtime.styles) {
10771 injectStyle7(targetDocument, hash, css);
10772 }
10773 return () => {
10774 const count = runtime.documents.get(targetDocument);
10775 if (count === void 0) {
10776 return;
10777 }
10778 if (count <= 1) {
10779 runtime.documents.delete(targetDocument);
10780 return;
10781 }
10782 runtime.documents.set(targetDocument, count - 1);
10783 };
10784 }
10785 function registerStyle7(hash, css) {
10786 const runtime = getRuntime7();
10787 runtime.styles.set(hash, css);
10788 for (const targetDocument of runtime.documents.keys()) {
10789 injectStyle7(targetDocument, hash, css);
10790 }
10791 }
10792 if (typeof process === "undefined" || true) {
10793 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)}}}");
10794 }
10795 var style_default7 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10796 var Content = (0, import_element17.forwardRef)(
10797 function CardContent({ render: render4, ...props }, ref) {
10798 const element = useRender({
10799 defaultTagName: "div",
10800 render: render4,
10801 ref,
10802 props: mergeProps({ className: style_default7.content }, props)
10803 });
10804 return element;
10805 }
10806 );
10807
10808 // packages/ui/build-module/card/full-bleed.mjs
10809 var import_element18 = __toESM(require_element(), 1);
10810 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
10811 function getRuntime8() {
10812 const globalScope = globalThis;
10813 if (globalScope.__wpStyleRuntime) {
10814 return globalScope.__wpStyleRuntime;
10815 }
10816 globalScope.__wpStyleRuntime = {
10817 documents: /* @__PURE__ */ new Map(),
10818 styles: /* @__PURE__ */ new Map(),
10819 injectedStyles: /* @__PURE__ */ new WeakMap()
10820 };
10821 if (typeof document !== "undefined") {
10822 registerDocument8(document);
10823 }
10824 return globalScope.__wpStyleRuntime;
10825 }
10826 function documentContainsStyleHash8(targetDocument, hash) {
10827 if (!targetDocument.head) {
10828 return false;
10829 }
10830 for (const style of targetDocument.head.querySelectorAll(
10831 `style[${STYLE_HASH_ATTRIBUTE8}]`
10832 )) {
10833 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
10834 return true;
10835 }
10836 }
10837 return false;
10838 }
10839 function injectStyle8(targetDocument, hash, css) {
10840 if (!targetDocument.head) {
10841 return;
10842 }
10843 const runtime = getRuntime8();
10844 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10845 if (!injectedStyles) {
10846 injectedStyles = /* @__PURE__ */ new Set();
10847 runtime.injectedStyles.set(targetDocument, injectedStyles);
10848 }
10849 if (injectedStyles.has(hash)) {
10850 return;
10851 }
10852 if (documentContainsStyleHash8(targetDocument, hash)) {
10853 injectedStyles.add(hash);
10854 return;
10855 }
10856 const style = targetDocument.createElement("style");
10857 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
10858 style.appendChild(targetDocument.createTextNode(css));
10859 targetDocument.head.appendChild(style);
10860 injectedStyles.add(hash);
10861 }
10862 function registerDocument8(targetDocument) {
10863 const runtime = getRuntime8();
10864 runtime.documents.set(
10865 targetDocument,
10866 (runtime.documents.get(targetDocument) ?? 0) + 1
10867 );
10868 for (const [hash, css] of runtime.styles) {
10869 injectStyle8(targetDocument, hash, css);
10870 }
10871 return () => {
10872 const count = runtime.documents.get(targetDocument);
10873 if (count === void 0) {
10874 return;
10875 }
10876 if (count <= 1) {
10877 runtime.documents.delete(targetDocument);
10878 return;
10879 }
10880 runtime.documents.set(targetDocument, count - 1);
10881 };
10882 }
10883 function registerStyle8(hash, css) {
10884 const runtime = getRuntime8();
10885 runtime.styles.set(hash, css);
10886 for (const targetDocument of runtime.documents.keys()) {
10887 injectStyle8(targetDocument, hash, css);
10888 }
10889 }
10890 if (typeof process === "undefined" || true) {
10891 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)}}}");
10892 }
10893 var style_default8 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
10894 var FullBleed = (0, import_element18.forwardRef)(
10895 function CardFullBleed({ render: render4, ...props }, ref) {
10896 const element = useRender({
10897 defaultTagName: "div",
10898 render: render4,
10899 ref,
10900 props: mergeProps(
10901 { className: style_default8.fullbleed },
10902 props
10903 )
10904 });
10905 return element;
10906 }
10907 );
10908
10909 // packages/ui/build-module/card/title.mjs
10910 var import_element19 = __toESM(require_element(), 1);
10911 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
10912 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", {});
10913 var Title = (0, import_element19.forwardRef)(
10914 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
10915 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
10916 Text,
10917 {
10918 ref,
10919 variant: "heading-lg",
10920 render: render4,
10921 ...props,
10922 children
10923 }
10924 );
10925 }
10926 );
10927
10928 // packages/ui/build-module/collapsible/panel.mjs
10929 var import_element20 = __toESM(require_element(), 1);
10930 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
10931 var Panel = (0, import_element20.forwardRef)(
10932 function CollapsiblePanel3(props, forwardedRef) {
10933 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props });
10934 }
10935 );
10936
10937 // packages/ui/build-module/collapsible/root.mjs
10938 var import_element21 = __toESM(require_element(), 1);
10939 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
10940 var Root2 = (0, import_element21.forwardRef)(
10941 function CollapsibleRoot3(props, forwardedRef) {
10942 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props });
10943 }
10944 );
10945
10946 // packages/ui/build-module/collapsible/trigger.mjs
10947 var import_element22 = __toESM(require_element(), 1);
10948 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
10949 var Trigger = (0, import_element22.forwardRef)(
10950 function CollapsibleTrigger3(props, forwardedRef) {
10951 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props });
10952 }
10953 );
10954
10955 // packages/ui/build-module/collapsible-card/index.mjs
10956 var collapsible_card_exports = {};
10957 __export(collapsible_card_exports, {
10958 Content: () => Content2,
10959 Header: () => Header2,
10960 HeaderDescription: () => HeaderDescription,
10961 Root: () => Root3
10962 });
10963
10964 // packages/ui/build-module/collapsible-card/root.mjs
10965 var import_element23 = __toESM(require_element(), 1);
10966 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
10967 var Root3 = (0, import_element23.forwardRef)(
10968 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) {
10969 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
10970 Root2,
10971 {
10972 ref,
10973 render: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Root, { render: render4 }),
10974 ...restProps
10975 }
10976 );
10977 }
10978 );
10979
10980 // packages/ui/build-module/collapsible-card/header.mjs
10981 var import_element25 = __toESM(require_element(), 1);
10982
10983 // packages/icons/build-module/library/arrow-down.mjs
10984 var import_primitives2 = __toESM(require_primitives(), 1);
10985 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
10986 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" }) });
10987
10988 // packages/icons/build-module/library/arrow-left.mjs
10989 var import_primitives3 = __toESM(require_primitives(), 1);
10990 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
10991 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" }) });
10992
10993 // packages/icons/build-module/library/arrow-right.mjs
10994 var import_primitives4 = __toESM(require_primitives(), 1);
10995 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
10996 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" }) });
10997
10998 // packages/icons/build-module/library/arrow-up.mjs
10999 var import_primitives5 = __toESM(require_primitives(), 1);
11000 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
11001 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" }) });
11002
11003 // packages/icons/build-module/library/block-table.mjs
11004 var import_primitives6 = __toESM(require_primitives(), 1);
11005 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
11006 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" }) });
11007
11008 // packages/icons/build-module/library/category.mjs
11009 var import_primitives7 = __toESM(require_primitives(), 1);
11010 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
11011 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" }) });
11012
11013 // packages/icons/build-module/library/check.mjs
11014 var import_primitives8 = __toESM(require_primitives(), 1);
11015 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
11016 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" }) });
11017
11018 // packages/icons/build-module/library/chevron-down.mjs
11019 var import_primitives9 = __toESM(require_primitives(), 1);
11020 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
11021 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" }) });
11022
11023 // packages/icons/build-module/library/chevron-left.mjs
11024 var import_primitives10 = __toESM(require_primitives(), 1);
11025 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
11026 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" }) });
11027
11028 // packages/icons/build-module/library/chevron-right.mjs
11029 var import_primitives11 = __toESM(require_primitives(), 1);
11030 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
11031 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" }) });
11032
11033 // packages/icons/build-module/library/close-small.mjs
11034 var import_primitives12 = __toESM(require_primitives(), 1);
11035 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
11036 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" }) });
11037
11038 // packages/icons/build-module/library/cog.mjs
11039 var import_primitives13 = __toESM(require_primitives(), 1);
11040 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
11041 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" }) });
11042
11043 // packages/icons/build-module/library/drafts.mjs
11044 var import_primitives14 = __toESM(require_primitives(), 1);
11045 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
11046 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" }) });
11047
11048 // packages/icons/build-module/library/envelope.mjs
11049 var import_primitives15 = __toESM(require_primitives(), 1);
11050 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
11051 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" }) });
11052
11053 // packages/icons/build-module/library/error.mjs
11054 var import_primitives16 = __toESM(require_primitives(), 1);
11055 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
11056 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" }) });
11057
11058 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
11059 var import_primitives17 = __toESM(require_primitives(), 1);
11060 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
11061 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" }) });
11062
11063 // packages/icons/build-module/library/format-list-bullets.mjs
11064 var import_primitives18 = __toESM(require_primitives(), 1);
11065 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
11066 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" }) });
11067
11068 // packages/icons/build-module/library/funnel.mjs
11069 var import_primitives19 = __toESM(require_primitives(), 1);
11070 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
11071 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" }) });
11072
11073 // packages/icons/build-module/library/link.mjs
11074 var import_primitives20 = __toESM(require_primitives(), 1);
11075 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
11076 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" }) });
11077
11078 // packages/icons/build-module/library/mobile.mjs
11079 var import_primitives21 = __toESM(require_primitives(), 1);
11080 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
11081 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" }) });
11082
11083 // packages/icons/build-module/library/more-vertical.mjs
11084 var import_primitives22 = __toESM(require_primitives(), 1);
11085 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
11086 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" }) });
11087
11088 // packages/icons/build-module/library/next.mjs
11089 var import_primitives23 = __toESM(require_primitives(), 1);
11090 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
11091 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" }) });
11092
11093 // packages/icons/build-module/library/pencil.mjs
11094 var import_primitives24 = __toESM(require_primitives(), 1);
11095 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
11096 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" }) });
11097
11098 // packages/icons/build-module/library/post-featured-image.mjs
11099 var import_primitives25 = __toESM(require_primitives(), 1);
11100 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
11101 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" }) });
11102
11103 // packages/icons/build-module/library/previous.mjs
11104 var import_primitives26 = __toESM(require_primitives(), 1);
11105 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
11106 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" }) });
11107
11108 // packages/icons/build-module/library/scheduled.mjs
11109 var import_primitives27 = __toESM(require_primitives(), 1);
11110 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
11111 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" }) });
11112
11113 // packages/icons/build-module/library/search.mjs
11114 var import_primitives28 = __toESM(require_primitives(), 1);
11115 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
11116 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" }) });
11117
11118 // packages/icons/build-module/library/seen.mjs
11119 var import_primitives29 = __toESM(require_primitives(), 1);
11120 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
11121 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" }) });
11122
11123 // packages/icons/build-module/library/trash.mjs
11124 var import_primitives30 = __toESM(require_primitives(), 1);
11125 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
11126 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" }) });
11127
11128 // packages/icons/build-module/library/unseen.mjs
11129 var import_primitives31 = __toESM(require_primitives(), 1);
11130 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11131 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" }) });
11132
11133 // packages/ui/build-module/collapsible-card/context.mjs
11134 var import_element24 = __toESM(require_element(), 1);
11135 var HeaderDescriptionIdContext = (0, import_element24.createContext)({
11136 setDescriptionId: () => {
11137 }
11138 });
11139
11140 // packages/ui/build-module/collapsible-card/header.mjs
11141 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11142 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
11143 function getRuntime9() {
11144 const globalScope = globalThis;
11145 if (globalScope.__wpStyleRuntime) {
11146 return globalScope.__wpStyleRuntime;
11147 }
11148 globalScope.__wpStyleRuntime = {
11149 documents: /* @__PURE__ */ new Map(),
11150 styles: /* @__PURE__ */ new Map(),
11151 injectedStyles: /* @__PURE__ */ new WeakMap()
11152 };
11153 if (typeof document !== "undefined") {
11154 registerDocument9(document);
11155 }
11156 return globalScope.__wpStyleRuntime;
11157 }
11158 function documentContainsStyleHash9(targetDocument, hash) {
11159 if (!targetDocument.head) {
11160 return false;
11161 }
11162 for (const style of targetDocument.head.querySelectorAll(
11163 `style[${STYLE_HASH_ATTRIBUTE9}]`
11164 )) {
11165 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
11166 return true;
11167 }
11168 }
11169 return false;
11170 }
11171 function injectStyle9(targetDocument, hash, css) {
11172 if (!targetDocument.head) {
11173 return;
11174 }
11175 const runtime = getRuntime9();
11176 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11177 if (!injectedStyles) {
11178 injectedStyles = /* @__PURE__ */ new Set();
11179 runtime.injectedStyles.set(targetDocument, injectedStyles);
11180 }
11181 if (injectedStyles.has(hash)) {
11182 return;
11183 }
11184 if (documentContainsStyleHash9(targetDocument, hash)) {
11185 injectedStyles.add(hash);
11186 return;
11187 }
11188 const style = targetDocument.createElement("style");
11189 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
11190 style.appendChild(targetDocument.createTextNode(css));
11191 targetDocument.head.appendChild(style);
11192 injectedStyles.add(hash);
11193 }
11194 function registerDocument9(targetDocument) {
11195 const runtime = getRuntime9();
11196 runtime.documents.set(
11197 targetDocument,
11198 (runtime.documents.get(targetDocument) ?? 0) + 1
11199 );
11200 for (const [hash, css] of runtime.styles) {
11201 injectStyle9(targetDocument, hash, css);
11202 }
11203 return () => {
11204 const count = runtime.documents.get(targetDocument);
11205 if (count === void 0) {
11206 return;
11207 }
11208 if (count <= 1) {
11209 runtime.documents.delete(targetDocument);
11210 return;
11211 }
11212 runtime.documents.set(targetDocument, count - 1);
11213 };
11214 }
11215 function registerStyle9(hash, css) {
11216 const runtime = getRuntime9();
11217 runtime.styles.set(hash, css);
11218 for (const targetDocument of runtime.documents.keys()) {
11219 injectStyle9(targetDocument, hash, css);
11220 }
11221 }
11222 if (typeof process === "undefined" || true) {
11223 registerStyle9("78199613cf", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._03cfdbcd710393c9__overflow-visible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}");
11224 }
11225 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", "overflow-visible": "_03cfdbcd710393c9__overflow-visible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
11226 if (typeof process === "undefined" || true) {
11227 registerStyle9("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
11228 }
11229 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" };
11230 if (typeof process === "undefined" || true) {
11231 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))}}}");
11232 }
11233 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" };
11234 var Header2 = (0, import_element25.forwardRef)(
11235 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) {
11236 const [descriptionId, setDescriptionId] = (0, import_element25.useState)();
11237 const contextValue = (0, import_element25.useMemo)(
11238 () => ({ setDescriptionId }),
11239 [setDescriptionId]
11240 );
11241 return useRender({
11242 defaultTagName: "div",
11243 render: render4,
11244 ref,
11245 props: mergeProps(restProps, {
11246 className: clsx_default(
11247 global_css_defense_default3.heading,
11248 style_default9["heading-wrapper"],
11249 className
11250 ),
11251 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
11252 Trigger,
11253 {
11254 className: style_default9.header,
11255 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Header, {}),
11256 nativeButton: false,
11257 "aria-describedby": descriptionId,
11258 children: [
11259 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: style_default9["header-content"], children }),
11260 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11261 "div",
11262 {
11263 className: clsx_default(
11264 style_default9["header-trigger-positioner"]
11265 ),
11266 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11267 "div",
11268 {
11269 className: clsx_default(
11270 style_default9["header-trigger-wrapper"],
11271 global_css_defense_default3.div,
11272 // While the interactive trigger element is the whole header,
11273 // the focus ring will be displayed only on the icon to visually
11274 // emulate it being the button.
11275 focus_default2["outset-ring--focus-parent-visible"]
11276 ),
11277 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11278 Icon,
11279 {
11280 icon: chevron_down_default,
11281 className: style_default9["header-trigger"]
11282 }
11283 )
11284 }
11285 )
11286 }
11287 )
11288 ]
11289 }
11290 ) })
11291 })
11292 });
11293 }
11294 );
11295
11296 // packages/ui/build-module/collapsible-card/header-description.mjs
11297 var import_element26 = __toESM(require_element(), 1);
11298 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11299 var HeaderDescription = (0, import_element26.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) {
11300 const descriptionId = (0, import_element26.useId)();
11301 const { setDescriptionId } = (0, import_element26.useContext)(HeaderDescriptionIdContext);
11302 (0, import_element26.useEffect)(() => {
11303 setDescriptionId(descriptionId);
11304 return () => setDescriptionId(void 0);
11305 }, [descriptionId, setDescriptionId]);
11306 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11307 "div",
11308 {
11309 ref,
11310 id: descriptionId,
11311 "aria-hidden": "true",
11312 className,
11313 ...restProps,
11314 children
11315 }
11316 );
11317 });
11318
11319 // packages/ui/build-module/collapsible-card/content.mjs
11320 var import_element27 = __toESM(require_element(), 1);
11321 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11322 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
11323 function getRuntime10() {
11324 const globalScope = globalThis;
11325 if (globalScope.__wpStyleRuntime) {
11326 return globalScope.__wpStyleRuntime;
11327 }
11328 globalScope.__wpStyleRuntime = {
11329 documents: /* @__PURE__ */ new Map(),
11330 styles: /* @__PURE__ */ new Map(),
11331 injectedStyles: /* @__PURE__ */ new WeakMap()
11332 };
11333 if (typeof document !== "undefined") {
11334 registerDocument10(document);
11335 }
11336 return globalScope.__wpStyleRuntime;
11337 }
11338 function documentContainsStyleHash10(targetDocument, hash) {
11339 if (!targetDocument.head) {
11340 return false;
11341 }
11342 for (const style of targetDocument.head.querySelectorAll(
11343 `style[${STYLE_HASH_ATTRIBUTE10}]`
11344 )) {
11345 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
11346 return true;
11347 }
11348 }
11349 return false;
11350 }
11351 function injectStyle10(targetDocument, hash, css) {
11352 if (!targetDocument.head) {
11353 return;
11354 }
11355 const runtime = getRuntime10();
11356 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11357 if (!injectedStyles) {
11358 injectedStyles = /* @__PURE__ */ new Set();
11359 runtime.injectedStyles.set(targetDocument, injectedStyles);
11360 }
11361 if (injectedStyles.has(hash)) {
11362 return;
11363 }
11364 if (documentContainsStyleHash10(targetDocument, hash)) {
11365 injectedStyles.add(hash);
11366 return;
11367 }
11368 const style = targetDocument.createElement("style");
11369 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
11370 style.appendChild(targetDocument.createTextNode(css));
11371 targetDocument.head.appendChild(style);
11372 injectedStyles.add(hash);
11373 }
11374 function registerDocument10(targetDocument) {
11375 const runtime = getRuntime10();
11376 runtime.documents.set(
11377 targetDocument,
11378 (runtime.documents.get(targetDocument) ?? 0) + 1
11379 );
11380 for (const [hash, css] of runtime.styles) {
11381 injectStyle10(targetDocument, hash, css);
11382 }
11383 return () => {
11384 const count = runtime.documents.get(targetDocument);
11385 if (count === void 0) {
11386 return;
11387 }
11388 if (count <= 1) {
11389 runtime.documents.delete(targetDocument);
11390 return;
11391 }
11392 runtime.documents.set(targetDocument, count - 1);
11393 };
11394 }
11395 function registerStyle10(hash, css) {
11396 const runtime = getRuntime10();
11397 runtime.styles.set(hash, css);
11398 for (const targetDocument of runtime.documents.keys()) {
11399 injectStyle10(targetDocument, hash, css);
11400 }
11401 }
11402 if (typeof process === "undefined" || true) {
11403 registerStyle10("78199613cf", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._03cfdbcd710393c9__overflow-visible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}}");
11404 }
11405 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", "overflow-visible": "_03cfdbcd710393c9__overflow-visible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
11406 var Content2 = (0, import_element27.forwardRef)(
11407 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) {
11408 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11409 Panel,
11410 {
11411 ref,
11412 className: (state) => clsx_default(
11413 style_default10.content,
11414 state.open && state.transitionStatus === "idle" && style_default10["overflow-visible"],
11415 className
11416 ),
11417 hiddenUntilFound,
11418 ...restProps,
11419 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11420 Content,
11421 {
11422 className: style_default10["content-inner"],
11423 render: render4,
11424 children
11425 }
11426 )
11427 }
11428 );
11429 }
11430 );
11431
11432 // packages/ui/build-module/utils/render-slot-with-children.mjs
11433 var import_element28 = __toESM(require_element(), 1);
11434 function renderSlotWithChildren(slot, defaultSlot, children) {
11435 return (0, import_element28.cloneElement)(slot ?? defaultSlot, { children });
11436 }
11437
11438 // packages/ui/build-module/utils/theme-provider.mjs
11439 var theme = __toESM(require_theme(), 1);
11440
11441 // packages/ui/build-module/lock-unlock.mjs
11442 var import_private_apis = __toESM(require_private_apis(), 1);
11443 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
11444 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
11445 "@wordpress/ui"
11446 );
11447
11448 // packages/ui/build-module/utils/theme-provider.mjs
11449 function getThemeProvider() {
11450 const themePackage = theme;
11451 if (themePackage.ThemeProvider) {
11452 return themePackage.ThemeProvider;
11453 }
11454 if (!themePackage.privateApis) {
11455 throw new Error(
11456 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
11457 );
11458 }
11459 return unlock(
11460 themePackage.privateApis
11461 ).ThemeProvider;
11462 }
11463 var ThemeProvider = getThemeProvider();
11464
11465 // packages/ui/build-module/stack/stack.mjs
11466 var import_element29 = __toESM(require_element(), 1);
11467 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
11468 function getRuntime11() {
11469 const globalScope = globalThis;
11470 if (globalScope.__wpStyleRuntime) {
11471 return globalScope.__wpStyleRuntime;
11472 }
11473 globalScope.__wpStyleRuntime = {
11474 documents: /* @__PURE__ */ new Map(),
11475 styles: /* @__PURE__ */ new Map(),
11476 injectedStyles: /* @__PURE__ */ new WeakMap()
11477 };
11478 if (typeof document !== "undefined") {
11479 registerDocument11(document);
11480 }
11481 return globalScope.__wpStyleRuntime;
11482 }
11483 function documentContainsStyleHash11(targetDocument, hash) {
11484 if (!targetDocument.head) {
11485 return false;
11486 }
11487 for (const style of targetDocument.head.querySelectorAll(
11488 `style[${STYLE_HASH_ATTRIBUTE11}]`
11489 )) {
11490 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
11491 return true;
11492 }
11493 }
11494 return false;
11495 }
11496 function injectStyle11(targetDocument, hash, css) {
11497 if (!targetDocument.head) {
11498 return;
11499 }
11500 const runtime = getRuntime11();
11501 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11502 if (!injectedStyles) {
11503 injectedStyles = /* @__PURE__ */ new Set();
11504 runtime.injectedStyles.set(targetDocument, injectedStyles);
11505 }
11506 if (injectedStyles.has(hash)) {
11507 return;
11508 }
11509 if (documentContainsStyleHash11(targetDocument, hash)) {
11510 injectedStyles.add(hash);
11511 return;
11512 }
11513 const style = targetDocument.createElement("style");
11514 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
11515 style.appendChild(targetDocument.createTextNode(css));
11516 targetDocument.head.appendChild(style);
11517 injectedStyles.add(hash);
11518 }
11519 function registerDocument11(targetDocument) {
11520 const runtime = getRuntime11();
11521 runtime.documents.set(
11522 targetDocument,
11523 (runtime.documents.get(targetDocument) ?? 0) + 1
11524 );
11525 for (const [hash, css] of runtime.styles) {
11526 injectStyle11(targetDocument, hash, css);
11527 }
11528 return () => {
11529 const count = runtime.documents.get(targetDocument);
11530 if (count === void 0) {
11531 return;
11532 }
11533 if (count <= 1) {
11534 runtime.documents.delete(targetDocument);
11535 return;
11536 }
11537 runtime.documents.set(targetDocument, count - 1);
11538 };
11539 }
11540 function registerStyle11(hash, css) {
11541 const runtime = getRuntime11();
11542 runtime.styles.set(hash, css);
11543 for (const targetDocument of runtime.documents.keys()) {
11544 injectStyle11(targetDocument, hash, css);
11545 }
11546 }
11547 if (typeof process === "undefined" || true) {
11548 registerStyle11("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
11549 }
11550 var style_default11 = { "stack": "_19ce0419607e1896__stack" };
11551 var gapTokens = {
11552 xs: "var(--wpds-dimension-gap-xs, 4px)",
11553 sm: "var(--wpds-dimension-gap-sm, 8px)",
11554 md: "var(--wpds-dimension-gap-md, 12px)",
11555 lg: "var(--wpds-dimension-gap-lg, 16px)",
11556 xl: "var(--wpds-dimension-gap-xl, 24px)",
11557 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
11558 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
11559 };
11560 var Stack = (0, import_element29.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
11561 const style = {
11562 gap: gap && gapTokens[gap],
11563 alignItems: align,
11564 justifyContent: justify,
11565 flexDirection: direction,
11566 flexWrap: wrap
11567 };
11568 const element = useRender({
11569 render: render4,
11570 ref,
11571 props: mergeProps(props, { style, className: style_default11.stack })
11572 });
11573 return element;
11574 });
11575
11576 // packages/ui/build-module/icon-button/icon-button.mjs
11577 var import_element34 = __toESM(require_element(), 1);
11578
11579 // packages/ui/build-module/tooltip/index.mjs
11580 var tooltip_exports = {};
11581 __export(tooltip_exports, {
11582 Popup: () => Popup,
11583 Portal: () => Portal,
11584 Positioner: () => Positioner,
11585 Provider: () => Provider,
11586 Root: () => Root4,
11587 Trigger: () => Trigger2
11588 });
11589
11590 // packages/ui/build-module/tooltip/popup.mjs
11591 var import_element32 = __toESM(require_element(), 1);
11592
11593 // packages/ui/build-module/tooltip/portal.mjs
11594 var import_element30 = __toESM(require_element(), 1);
11595
11596 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
11597 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
11598 function getRuntime12() {
11599 const globalScope = globalThis;
11600 if (globalScope.__wpStyleRuntime) {
11601 return globalScope.__wpStyleRuntime;
11602 }
11603 globalScope.__wpStyleRuntime = {
11604 documents: /* @__PURE__ */ new Map(),
11605 styles: /* @__PURE__ */ new Map(),
11606 injectedStyles: /* @__PURE__ */ new WeakMap()
11607 };
11608 if (typeof document !== "undefined") {
11609 registerDocument12(document);
11610 }
11611 return globalScope.__wpStyleRuntime;
11612 }
11613 function documentContainsStyleHash12(targetDocument, hash) {
11614 if (!targetDocument.head) {
11615 return false;
11616 }
11617 for (const style of targetDocument.head.querySelectorAll(
11618 `style[${STYLE_HASH_ATTRIBUTE12}]`
11619 )) {
11620 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
11621 return true;
11622 }
11623 }
11624 return false;
11625 }
11626 function injectStyle12(targetDocument, hash, css) {
11627 if (!targetDocument.head) {
11628 return;
11629 }
11630 const runtime = getRuntime12();
11631 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11632 if (!injectedStyles) {
11633 injectedStyles = /* @__PURE__ */ new Set();
11634 runtime.injectedStyles.set(targetDocument, injectedStyles);
11635 }
11636 if (injectedStyles.has(hash)) {
11637 return;
11638 }
11639 if (documentContainsStyleHash12(targetDocument, hash)) {
11640 injectedStyles.add(hash);
11641 return;
11642 }
11643 const style = targetDocument.createElement("style");
11644 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
11645 style.appendChild(targetDocument.createTextNode(css));
11646 targetDocument.head.appendChild(style);
11647 injectedStyles.add(hash);
11648 }
11649 function registerDocument12(targetDocument) {
11650 const runtime = getRuntime12();
11651 runtime.documents.set(
11652 targetDocument,
11653 (runtime.documents.get(targetDocument) ?? 0) + 1
11654 );
11655 for (const [hash, css] of runtime.styles) {
11656 injectStyle12(targetDocument, hash, css);
11657 }
11658 return () => {
11659 const count = runtime.documents.get(targetDocument);
11660 if (count === void 0) {
11661 return;
11662 }
11663 if (count <= 1) {
11664 runtime.documents.delete(targetDocument);
11665 return;
11666 }
11667 runtime.documents.set(targetDocument, count - 1);
11668 };
11669 }
11670 function registerStyle12(hash, css) {
11671 const runtime = getRuntime12();
11672 runtime.styles.set(hash, css);
11673 for (const targetDocument of runtime.documents.keys()) {
11674 injectStyle12(targetDocument, hash, css);
11675 }
11676 }
11677 if (typeof process === "undefined" || true) {
11678 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}}}");
11679 }
11680 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
11681 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
11682 function resolveOwnerDocument() {
11683 return typeof document === "undefined" ? null : document;
11684 }
11685 function isInWordPressEnvironment() {
11686 let topWp;
11687 try {
11688 topWp = window.top?.wp;
11689 } catch {
11690 }
11691 const wp = topWp ?? window.wp;
11692 return typeof wp?.components === "object" && wp.components !== null;
11693 }
11694 var cachedSlot = null;
11695 function ensureSlotIsAccessible(element) {
11696 element.setAttribute("aria-hidden", "false");
11697 return element;
11698 }
11699 function createSlot(ownerDocument2) {
11700 const element = ownerDocument2.createElement("div");
11701 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
11702 if (wp_compat_overlay_slot_default.slot) {
11703 element.classList.add(wp_compat_overlay_slot_default.slot);
11704 }
11705 ownerDocument2.body.appendChild(element);
11706 return element;
11707 }
11708 function getWpCompatOverlaySlot() {
11709 if (typeof window === "undefined") {
11710 return void 0;
11711 }
11712 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
11713 return void 0;
11714 }
11715 const ownerDocument2 = resolveOwnerDocument();
11716 if (!ownerDocument2 || !ownerDocument2.body) {
11717 return void 0;
11718 }
11719 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
11720 return ensureSlotIsAccessible(cachedSlot);
11721 }
11722 const existing = ownerDocument2.querySelector(
11723 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
11724 );
11725 if (existing instanceof HTMLDivElement) {
11726 cachedSlot = ensureSlotIsAccessible(existing);
11727 return cachedSlot;
11728 }
11729 if (cachedSlot?.isConnected) {
11730 cachedSlot.remove();
11731 }
11732 cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2));
11733 return cachedSlot;
11734 }
11735
11736 // packages/ui/build-module/tooltip/portal.mjs
11737 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11738 var Portal = (0, import_element30.forwardRef)(
11739 function TooltipPortal3({ container, ...restProps }, ref) {
11740 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11741 index_parts_exports2.Portal,
11742 {
11743 container: container ?? getWpCompatOverlaySlot(),
11744 ...restProps,
11745 ref
11746 }
11747 );
11748 }
11749 );
11750
11751 // packages/ui/build-module/tooltip/positioner.mjs
11752 var import_element31 = __toESM(require_element(), 1);
11753 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11754 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
11755 function getRuntime13() {
11756 const globalScope = globalThis;
11757 if (globalScope.__wpStyleRuntime) {
11758 return globalScope.__wpStyleRuntime;
11759 }
11760 globalScope.__wpStyleRuntime = {
11761 documents: /* @__PURE__ */ new Map(),
11762 styles: /* @__PURE__ */ new Map(),
11763 injectedStyles: /* @__PURE__ */ new WeakMap()
11764 };
11765 if (typeof document !== "undefined") {
11766 registerDocument13(document);
11767 }
11768 return globalScope.__wpStyleRuntime;
11769 }
11770 function documentContainsStyleHash13(targetDocument, hash) {
11771 if (!targetDocument.head) {
11772 return false;
11773 }
11774 for (const style of targetDocument.head.querySelectorAll(
11775 `style[${STYLE_HASH_ATTRIBUTE13}]`
11776 )) {
11777 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
11778 return true;
11779 }
11780 }
11781 return false;
11782 }
11783 function injectStyle13(targetDocument, hash, css) {
11784 if (!targetDocument.head) {
11785 return;
11786 }
11787 const runtime = getRuntime13();
11788 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11789 if (!injectedStyles) {
11790 injectedStyles = /* @__PURE__ */ new Set();
11791 runtime.injectedStyles.set(targetDocument, injectedStyles);
11792 }
11793 if (injectedStyles.has(hash)) {
11794 return;
11795 }
11796 if (documentContainsStyleHash13(targetDocument, hash)) {
11797 injectedStyles.add(hash);
11798 return;
11799 }
11800 const style = targetDocument.createElement("style");
11801 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
11802 style.appendChild(targetDocument.createTextNode(css));
11803 targetDocument.head.appendChild(style);
11804 injectedStyles.add(hash);
11805 }
11806 function registerDocument13(targetDocument) {
11807 const runtime = getRuntime13();
11808 runtime.documents.set(
11809 targetDocument,
11810 (runtime.documents.get(targetDocument) ?? 0) + 1
11811 );
11812 for (const [hash, css] of runtime.styles) {
11813 injectStyle13(targetDocument, hash, css);
11814 }
11815 return () => {
11816 const count = runtime.documents.get(targetDocument);
11817 if (count === void 0) {
11818 return;
11819 }
11820 if (count <= 1) {
11821 runtime.documents.delete(targetDocument);
11822 return;
11823 }
11824 runtime.documents.set(targetDocument, count - 1);
11825 };
11826 }
11827 function registerStyle13(hash, css) {
11828 const runtime = getRuntime13();
11829 runtime.styles.set(hash, css);
11830 for (const targetDocument of runtime.documents.keys()) {
11831 injectStyle13(targetDocument, hash, css);
11832 }
11833 }
11834 if (typeof process === "undefined" || true) {
11835 registerStyle13("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
11836 }
11837 var resets_default3 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
11838 if (typeof process === "undefined" || true) {
11839 registerStyle13("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
11840 }
11841 var style_default12 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
11842 var Positioner = (0, import_element31.forwardRef)(
11843 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
11844 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11845 index_parts_exports2.Positioner,
11846 {
11847 ref,
11848 align,
11849 side,
11850 sideOffset,
11851 ...props,
11852 className: clsx_default(
11853 resets_default3["box-sizing"],
11854 style_default12.positioner,
11855 className
11856 )
11857 }
11858 );
11859 }
11860 );
11861
11862 // packages/ui/build-module/tooltip/popup.mjs
11863 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
11864 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
11865 function getRuntime14() {
11866 const globalScope = globalThis;
11867 if (globalScope.__wpStyleRuntime) {
11868 return globalScope.__wpStyleRuntime;
11869 }
11870 globalScope.__wpStyleRuntime = {
11871 documents: /* @__PURE__ */ new Map(),
11872 styles: /* @__PURE__ */ new Map(),
11873 injectedStyles: /* @__PURE__ */ new WeakMap()
11874 };
11875 if (typeof document !== "undefined") {
11876 registerDocument14(document);
11877 }
11878 return globalScope.__wpStyleRuntime;
11879 }
11880 function documentContainsStyleHash14(targetDocument, hash) {
11881 if (!targetDocument.head) {
11882 return false;
11883 }
11884 for (const style of targetDocument.head.querySelectorAll(
11885 `style[${STYLE_HASH_ATTRIBUTE14}]`
11886 )) {
11887 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
11888 return true;
11889 }
11890 }
11891 return false;
11892 }
11893 function injectStyle14(targetDocument, hash, css) {
11894 if (!targetDocument.head) {
11895 return;
11896 }
11897 const runtime = getRuntime14();
11898 let injectedStyles = runtime.injectedStyles.get(targetDocument);
11899 if (!injectedStyles) {
11900 injectedStyles = /* @__PURE__ */ new Set();
11901 runtime.injectedStyles.set(targetDocument, injectedStyles);
11902 }
11903 if (injectedStyles.has(hash)) {
11904 return;
11905 }
11906 if (documentContainsStyleHash14(targetDocument, hash)) {
11907 injectedStyles.add(hash);
11908 return;
11909 }
11910 const style = targetDocument.createElement("style");
11911 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
11912 style.appendChild(targetDocument.createTextNode(css));
11913 targetDocument.head.appendChild(style);
11914 injectedStyles.add(hash);
11915 }
11916 function registerDocument14(targetDocument) {
11917 const runtime = getRuntime14();
11918 runtime.documents.set(
11919 targetDocument,
11920 (runtime.documents.get(targetDocument) ?? 0) + 1
11921 );
11922 for (const [hash, css] of runtime.styles) {
11923 injectStyle14(targetDocument, hash, css);
11924 }
11925 return () => {
11926 const count = runtime.documents.get(targetDocument);
11927 if (count === void 0) {
11928 return;
11929 }
11930 if (count <= 1) {
11931 runtime.documents.delete(targetDocument);
11932 return;
11933 }
11934 runtime.documents.set(targetDocument, count - 1);
11935 };
11936 }
11937 function registerStyle14(hash, css) {
11938 const runtime = getRuntime14();
11939 runtime.styles.set(hash, css);
11940 for (const targetDocument of runtime.documents.keys()) {
11941 injectStyle14(targetDocument, hash, css);
11942 }
11943 }
11944 if (typeof process === "undefined" || true) {
11945 registerStyle14("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
11946 }
11947 var style_default13 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
11948 var POPUP_COLOR = { background: "#1e1e1e" };
11949 var Popup = (0, import_element32.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
11950 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
11951 index_parts_exports2.Popup,
11952 {
11953 ref,
11954 className: clsx_default(style_default13.popup, className),
11955 ...props,
11956 children
11957 }
11958 ) });
11959 const positionedPopup = renderSlotWithChildren(
11960 positioner,
11961 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Positioner, {}),
11962 popupContent
11963 );
11964 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Portal, {}), positionedPopup);
11965 });
11966
11967 // packages/ui/build-module/tooltip/trigger.mjs
11968 var import_element33 = __toESM(require_element(), 1);
11969 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
11970 var Trigger2 = (0, import_element33.forwardRef)(
11971 function TooltipTrigger3(props, ref) {
11972 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(index_parts_exports2.Trigger, { ref, ...props });
11973 }
11974 );
11975
11976 // packages/ui/build-module/tooltip/root.mjs
11977 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
11978 function Root4(props) {
11979 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(index_parts_exports2.Root, { ...props });
11980 }
11981
11982 // packages/ui/build-module/tooltip/provider.mjs
11983 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
11984 function Provider({ ...props }) {
11985 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(index_parts_exports2.Provider, { ...props });
11986 }
11987
11988 // packages/ui/build-module/icon-button/icon-button.mjs
11989 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
11990 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash";
11991 function getRuntime15() {
11992 const globalScope = globalThis;
11993 if (globalScope.__wpStyleRuntime) {
11994 return globalScope.__wpStyleRuntime;
11995 }
11996 globalScope.__wpStyleRuntime = {
11997 documents: /* @__PURE__ */ new Map(),
11998 styles: /* @__PURE__ */ new Map(),
11999 injectedStyles: /* @__PURE__ */ new WeakMap()
12000 };
12001 if (typeof document !== "undefined") {
12002 registerDocument15(document);
12003 }
12004 return globalScope.__wpStyleRuntime;
12005 }
12006 function documentContainsStyleHash15(targetDocument, hash) {
12007 if (!targetDocument.head) {
12008 return false;
12009 }
12010 for (const style of targetDocument.head.querySelectorAll(
12011 `style[${STYLE_HASH_ATTRIBUTE15}]`
12012 )) {
12013 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) {
12014 return true;
12015 }
12016 }
12017 return false;
12018 }
12019 function injectStyle15(targetDocument, hash, css) {
12020 if (!targetDocument.head) {
12021 return;
12022 }
12023 const runtime = getRuntime15();
12024 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12025 if (!injectedStyles) {
12026 injectedStyles = /* @__PURE__ */ new Set();
12027 runtime.injectedStyles.set(targetDocument, injectedStyles);
12028 }
12029 if (injectedStyles.has(hash)) {
12030 return;
12031 }
12032 if (documentContainsStyleHash15(targetDocument, hash)) {
12033 injectedStyles.add(hash);
12034 return;
12035 }
12036 const style = targetDocument.createElement("style");
12037 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash);
12038 style.appendChild(targetDocument.createTextNode(css));
12039 targetDocument.head.appendChild(style);
12040 injectedStyles.add(hash);
12041 }
12042 function registerDocument15(targetDocument) {
12043 const runtime = getRuntime15();
12044 runtime.documents.set(
12045 targetDocument,
12046 (runtime.documents.get(targetDocument) ?? 0) + 1
12047 );
12048 for (const [hash, css] of runtime.styles) {
12049 injectStyle15(targetDocument, hash, css);
12050 }
12051 return () => {
12052 const count = runtime.documents.get(targetDocument);
12053 if (count === void 0) {
12054 return;
12055 }
12056 if (count <= 1) {
12057 runtime.documents.delete(targetDocument);
12058 return;
12059 }
12060 runtime.documents.set(targetDocument, count - 1);
12061 };
12062 }
12063 function registerStyle15(hash, css) {
12064 const runtime = getRuntime15();
12065 runtime.styles.set(hash, css);
12066 for (const targetDocument of runtime.documents.keys()) {
12067 injectStyle15(targetDocument, hash, css);
12068 }
12069 }
12070 if (typeof process === "undefined" || true) {
12071 registerStyle15("c5cdafb1bc", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer compositions{._28cfdc260e755391__icon-button{--wp-ui-button-aspect-ratio:1;--wp-ui-button-padding-inline:0px;--wp-ui-button-min-width:unset}.f1c70d719989a85a__icon{margin:-1px}}}");
12072 }
12073 var style_default14 = { "icon-button": "_28cfdc260e755391__icon-button", "icon": "f1c70d719989a85a__icon" };
12074 var IconButton = (0, import_element34.forwardRef)(
12075 function IconButton2({
12076 label,
12077 className,
12078 // Prevent accidental forwarding of `children`
12079 children: _children,
12080 disabled: disabled2,
12081 focusableWhenDisabled = true,
12082 icon,
12083 size: size4,
12084 shortcut,
12085 positioner,
12086 ...restProps
12087 }, ref) {
12088 const classes = clsx_default(style_default14["icon-button"], className);
12089 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Root4, { children: [
12090 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12091 Trigger2,
12092 {
12093 ref,
12094 disabled: disabled2 && !focusableWhenDisabled,
12095 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12096 Button4,
12097 {
12098 ...restProps,
12099 size: size4,
12100 "aria-label": label,
12101 "aria-keyshortcuts": shortcut?.ariaKeyShortcut,
12102 disabled: disabled2,
12103 focusableWhenDisabled
12104 }
12105 ),
12106 className: classes,
12107 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Icon, { icon, size: 24, className: style_default14.icon })
12108 }
12109 ),
12110 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Popup, { positioner, children: [
12111 label,
12112 shortcut && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
12113 " ",
12114 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { "aria-hidden": "true", children: shortcut.displayShortcut })
12115 ] })
12116 ] })
12117 ] });
12118 }
12119 );
12120
12121 // packages/ui/build-module/empty-state/index.mjs
12122 var empty_state_exports = {};
12123 __export(empty_state_exports, {
12124 Actions: () => Actions,
12125 Description: () => Description,
12126 Icon: () => Icon3,
12127 Root: () => Root5,
12128 Title: () => Title2,
12129 Visual: () => Visual
12130 });
12131
12132 // packages/ui/build-module/empty-state/root.mjs
12133 var import_element35 = __toESM(require_element(), 1);
12134 var STYLE_HASH_ATTRIBUTE16 = "data-wp-hash";
12135 function getRuntime16() {
12136 const globalScope = globalThis;
12137 if (globalScope.__wpStyleRuntime) {
12138 return globalScope.__wpStyleRuntime;
12139 }
12140 globalScope.__wpStyleRuntime = {
12141 documents: /* @__PURE__ */ new Map(),
12142 styles: /* @__PURE__ */ new Map(),
12143 injectedStyles: /* @__PURE__ */ new WeakMap()
12144 };
12145 if (typeof document !== "undefined") {
12146 registerDocument16(document);
12147 }
12148 return globalScope.__wpStyleRuntime;
12149 }
12150 function documentContainsStyleHash16(targetDocument, hash) {
12151 if (!targetDocument.head) {
12152 return false;
12153 }
12154 for (const style of targetDocument.head.querySelectorAll(
12155 `style[${STYLE_HASH_ATTRIBUTE16}]`
12156 )) {
12157 if (style.getAttribute(STYLE_HASH_ATTRIBUTE16) === hash) {
12158 return true;
12159 }
12160 }
12161 return false;
12162 }
12163 function injectStyle16(targetDocument, hash, css) {
12164 if (!targetDocument.head) {
12165 return;
12166 }
12167 const runtime = getRuntime16();
12168 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12169 if (!injectedStyles) {
12170 injectedStyles = /* @__PURE__ */ new Set();
12171 runtime.injectedStyles.set(targetDocument, injectedStyles);
12172 }
12173 if (injectedStyles.has(hash)) {
12174 return;
12175 }
12176 if (documentContainsStyleHash16(targetDocument, hash)) {
12177 injectedStyles.add(hash);
12178 return;
12179 }
12180 const style = targetDocument.createElement("style");
12181 style.setAttribute(STYLE_HASH_ATTRIBUTE16, hash);
12182 style.appendChild(targetDocument.createTextNode(css));
12183 targetDocument.head.appendChild(style);
12184 injectedStyles.add(hash);
12185 }
12186 function registerDocument16(targetDocument) {
12187 const runtime = getRuntime16();
12188 runtime.documents.set(
12189 targetDocument,
12190 (runtime.documents.get(targetDocument) ?? 0) + 1
12191 );
12192 for (const [hash, css] of runtime.styles) {
12193 injectStyle16(targetDocument, hash, css);
12194 }
12195 return () => {
12196 const count = runtime.documents.get(targetDocument);
12197 if (count === void 0) {
12198 return;
12199 }
12200 if (count <= 1) {
12201 runtime.documents.delete(targetDocument);
12202 return;
12203 }
12204 runtime.documents.set(targetDocument, count - 1);
12205 };
12206 }
12207 function registerStyle16(hash, css) {
12208 const runtime = getRuntime16();
12209 runtime.styles.set(hash, css);
12210 for (const targetDocument of runtime.documents.keys()) {
12211 injectStyle16(targetDocument, hash, css);
12212 }
12213 }
12214 if (typeof process === "undefined" || true) {
12215 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}}}}');
12216 }
12217 var style_default15 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12218 var Root5 = (0, import_element35.forwardRef)(
12219 function EmptyStateRoot({ render: render4, ...props }, ref) {
12220 const className = clsx_default(style_default15.root);
12221 const element = useRender({
12222 defaultTagName: "div",
12223 render: render4,
12224 ref,
12225 props: mergeProps({ className }, props)
12226 });
12227 return element;
12228 }
12229 );
12230
12231 // packages/ui/build-module/empty-state/visual.mjs
12232 var import_element36 = __toESM(require_element(), 1);
12233 var STYLE_HASH_ATTRIBUTE17 = "data-wp-hash";
12234 function getRuntime17() {
12235 const globalScope = globalThis;
12236 if (globalScope.__wpStyleRuntime) {
12237 return globalScope.__wpStyleRuntime;
12238 }
12239 globalScope.__wpStyleRuntime = {
12240 documents: /* @__PURE__ */ new Map(),
12241 styles: /* @__PURE__ */ new Map(),
12242 injectedStyles: /* @__PURE__ */ new WeakMap()
12243 };
12244 if (typeof document !== "undefined") {
12245 registerDocument17(document);
12246 }
12247 return globalScope.__wpStyleRuntime;
12248 }
12249 function documentContainsStyleHash17(targetDocument, hash) {
12250 if (!targetDocument.head) {
12251 return false;
12252 }
12253 for (const style of targetDocument.head.querySelectorAll(
12254 `style[${STYLE_HASH_ATTRIBUTE17}]`
12255 )) {
12256 if (style.getAttribute(STYLE_HASH_ATTRIBUTE17) === hash) {
12257 return true;
12258 }
12259 }
12260 return false;
12261 }
12262 function injectStyle17(targetDocument, hash, css) {
12263 if (!targetDocument.head) {
12264 return;
12265 }
12266 const runtime = getRuntime17();
12267 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12268 if (!injectedStyles) {
12269 injectedStyles = /* @__PURE__ */ new Set();
12270 runtime.injectedStyles.set(targetDocument, injectedStyles);
12271 }
12272 if (injectedStyles.has(hash)) {
12273 return;
12274 }
12275 if (documentContainsStyleHash17(targetDocument, hash)) {
12276 injectedStyles.add(hash);
12277 return;
12278 }
12279 const style = targetDocument.createElement("style");
12280 style.setAttribute(STYLE_HASH_ATTRIBUTE17, hash);
12281 style.appendChild(targetDocument.createTextNode(css));
12282 targetDocument.head.appendChild(style);
12283 injectedStyles.add(hash);
12284 }
12285 function registerDocument17(targetDocument) {
12286 const runtime = getRuntime17();
12287 runtime.documents.set(
12288 targetDocument,
12289 (runtime.documents.get(targetDocument) ?? 0) + 1
12290 );
12291 for (const [hash, css] of runtime.styles) {
12292 injectStyle17(targetDocument, hash, css);
12293 }
12294 return () => {
12295 const count = runtime.documents.get(targetDocument);
12296 if (count === void 0) {
12297 return;
12298 }
12299 if (count <= 1) {
12300 runtime.documents.delete(targetDocument);
12301 return;
12302 }
12303 runtime.documents.set(targetDocument, count - 1);
12304 };
12305 }
12306 function registerStyle17(hash, css) {
12307 const runtime = getRuntime17();
12308 runtime.styles.set(hash, css);
12309 for (const targetDocument of runtime.documents.keys()) {
12310 injectStyle17(targetDocument, hash, css);
12311 }
12312 }
12313 if (typeof process === "undefined" || true) {
12314 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}}}}');
12315 }
12316 var style_default16 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12317 var Visual = (0, import_element36.forwardRef)(
12318 function EmptyStateVisual({ render: render4, ...props }, ref) {
12319 const className = clsx_default(style_default16.visual);
12320 const element = useRender({
12321 defaultTagName: "div",
12322 render: render4,
12323 ref,
12324 props: mergeProps({ className }, props)
12325 });
12326 return element;
12327 }
12328 );
12329
12330 // packages/ui/build-module/empty-state/icon.mjs
12331 var import_element37 = __toESM(require_element(), 1);
12332 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
12333 var STYLE_HASH_ATTRIBUTE18 = "data-wp-hash";
12334 function getRuntime18() {
12335 const globalScope = globalThis;
12336 if (globalScope.__wpStyleRuntime) {
12337 return globalScope.__wpStyleRuntime;
12338 }
12339 globalScope.__wpStyleRuntime = {
12340 documents: /* @__PURE__ */ new Map(),
12341 styles: /* @__PURE__ */ new Map(),
12342 injectedStyles: /* @__PURE__ */ new WeakMap()
12343 };
12344 if (typeof document !== "undefined") {
12345 registerDocument18(document);
12346 }
12347 return globalScope.__wpStyleRuntime;
12348 }
12349 function documentContainsStyleHash18(targetDocument, hash) {
12350 if (!targetDocument.head) {
12351 return false;
12352 }
12353 for (const style of targetDocument.head.querySelectorAll(
12354 `style[${STYLE_HASH_ATTRIBUTE18}]`
12355 )) {
12356 if (style.getAttribute(STYLE_HASH_ATTRIBUTE18) === hash) {
12357 return true;
12358 }
12359 }
12360 return false;
12361 }
12362 function injectStyle18(targetDocument, hash, css) {
12363 if (!targetDocument.head) {
12364 return;
12365 }
12366 const runtime = getRuntime18();
12367 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12368 if (!injectedStyles) {
12369 injectedStyles = /* @__PURE__ */ new Set();
12370 runtime.injectedStyles.set(targetDocument, injectedStyles);
12371 }
12372 if (injectedStyles.has(hash)) {
12373 return;
12374 }
12375 if (documentContainsStyleHash18(targetDocument, hash)) {
12376 injectedStyles.add(hash);
12377 return;
12378 }
12379 const style = targetDocument.createElement("style");
12380 style.setAttribute(STYLE_HASH_ATTRIBUTE18, hash);
12381 style.appendChild(targetDocument.createTextNode(css));
12382 targetDocument.head.appendChild(style);
12383 injectedStyles.add(hash);
12384 }
12385 function registerDocument18(targetDocument) {
12386 const runtime = getRuntime18();
12387 runtime.documents.set(
12388 targetDocument,
12389 (runtime.documents.get(targetDocument) ?? 0) + 1
12390 );
12391 for (const [hash, css] of runtime.styles) {
12392 injectStyle18(targetDocument, hash, css);
12393 }
12394 return () => {
12395 const count = runtime.documents.get(targetDocument);
12396 if (count === void 0) {
12397 return;
12398 }
12399 if (count <= 1) {
12400 runtime.documents.delete(targetDocument);
12401 return;
12402 }
12403 runtime.documents.set(targetDocument, count - 1);
12404 };
12405 }
12406 function registerStyle18(hash, css) {
12407 const runtime = getRuntime18();
12408 runtime.styles.set(hash, css);
12409 for (const targetDocument of runtime.documents.keys()) {
12410 injectStyle18(targetDocument, hash, css);
12411 }
12412 }
12413 if (typeof process === "undefined" || true) {
12414 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}}}}');
12415 }
12416 var style_default17 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12417 var Icon3 = (0, import_element37.forwardRef)(
12418 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
12419 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
12420 Visual,
12421 {
12422 ref,
12423 className: clsx_default(style_default17.icon, className),
12424 ...restProps,
12425 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Icon, { icon })
12426 }
12427 );
12428 }
12429 );
12430
12431 // packages/ui/build-module/empty-state/title.mjs
12432 var import_element38 = __toESM(require_element(), 1);
12433 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
12434 var STYLE_HASH_ATTRIBUTE19 = "data-wp-hash";
12435 function getRuntime19() {
12436 const globalScope = globalThis;
12437 if (globalScope.__wpStyleRuntime) {
12438 return globalScope.__wpStyleRuntime;
12439 }
12440 globalScope.__wpStyleRuntime = {
12441 documents: /* @__PURE__ */ new Map(),
12442 styles: /* @__PURE__ */ new Map(),
12443 injectedStyles: /* @__PURE__ */ new WeakMap()
12444 };
12445 if (typeof document !== "undefined") {
12446 registerDocument19(document);
12447 }
12448 return globalScope.__wpStyleRuntime;
12449 }
12450 function documentContainsStyleHash19(targetDocument, hash) {
12451 if (!targetDocument.head) {
12452 return false;
12453 }
12454 for (const style of targetDocument.head.querySelectorAll(
12455 `style[${STYLE_HASH_ATTRIBUTE19}]`
12456 )) {
12457 if (style.getAttribute(STYLE_HASH_ATTRIBUTE19) === hash) {
12458 return true;
12459 }
12460 }
12461 return false;
12462 }
12463 function injectStyle19(targetDocument, hash, css) {
12464 if (!targetDocument.head) {
12465 return;
12466 }
12467 const runtime = getRuntime19();
12468 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12469 if (!injectedStyles) {
12470 injectedStyles = /* @__PURE__ */ new Set();
12471 runtime.injectedStyles.set(targetDocument, injectedStyles);
12472 }
12473 if (injectedStyles.has(hash)) {
12474 return;
12475 }
12476 if (documentContainsStyleHash19(targetDocument, hash)) {
12477 injectedStyles.add(hash);
12478 return;
12479 }
12480 const style = targetDocument.createElement("style");
12481 style.setAttribute(STYLE_HASH_ATTRIBUTE19, hash);
12482 style.appendChild(targetDocument.createTextNode(css));
12483 targetDocument.head.appendChild(style);
12484 injectedStyles.add(hash);
12485 }
12486 function registerDocument19(targetDocument) {
12487 const runtime = getRuntime19();
12488 runtime.documents.set(
12489 targetDocument,
12490 (runtime.documents.get(targetDocument) ?? 0) + 1
12491 );
12492 for (const [hash, css] of runtime.styles) {
12493 injectStyle19(targetDocument, hash, css);
12494 }
12495 return () => {
12496 const count = runtime.documents.get(targetDocument);
12497 if (count === void 0) {
12498 return;
12499 }
12500 if (count <= 1) {
12501 runtime.documents.delete(targetDocument);
12502 return;
12503 }
12504 runtime.documents.set(targetDocument, count - 1);
12505 };
12506 }
12507 function registerStyle19(hash, css) {
12508 const runtime = getRuntime19();
12509 runtime.styles.set(hash, css);
12510 for (const targetDocument of runtime.documents.keys()) {
12511 injectStyle19(targetDocument, hash, css);
12512 }
12513 }
12514 if (typeof process === "undefined" || true) {
12515 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}}}}');
12516 }
12517 var style_default18 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12518 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("h2", {});
12519 var Title2 = (0, import_element38.forwardRef)(
12520 function EmptyStateTitle({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
12521 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
12522 Text,
12523 {
12524 ref,
12525 variant: "heading-lg",
12526 render: render4,
12527 className: clsx_default(style_default18.title, className),
12528 ...props,
12529 children
12530 }
12531 );
12532 }
12533 );
12534
12535 // packages/ui/build-module/empty-state/description.mjs
12536 var import_element39 = __toESM(require_element(), 1);
12537 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
12538 var STYLE_HASH_ATTRIBUTE20 = "data-wp-hash";
12539 function getRuntime20() {
12540 const globalScope = globalThis;
12541 if (globalScope.__wpStyleRuntime) {
12542 return globalScope.__wpStyleRuntime;
12543 }
12544 globalScope.__wpStyleRuntime = {
12545 documents: /* @__PURE__ */ new Map(),
12546 styles: /* @__PURE__ */ new Map(),
12547 injectedStyles: /* @__PURE__ */ new WeakMap()
12548 };
12549 if (typeof document !== "undefined") {
12550 registerDocument20(document);
12551 }
12552 return globalScope.__wpStyleRuntime;
12553 }
12554 function documentContainsStyleHash20(targetDocument, hash) {
12555 if (!targetDocument.head) {
12556 return false;
12557 }
12558 for (const style of targetDocument.head.querySelectorAll(
12559 `style[${STYLE_HASH_ATTRIBUTE20}]`
12560 )) {
12561 if (style.getAttribute(STYLE_HASH_ATTRIBUTE20) === hash) {
12562 return true;
12563 }
12564 }
12565 return false;
12566 }
12567 function injectStyle20(targetDocument, hash, css) {
12568 if (!targetDocument.head) {
12569 return;
12570 }
12571 const runtime = getRuntime20();
12572 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12573 if (!injectedStyles) {
12574 injectedStyles = /* @__PURE__ */ new Set();
12575 runtime.injectedStyles.set(targetDocument, injectedStyles);
12576 }
12577 if (injectedStyles.has(hash)) {
12578 return;
12579 }
12580 if (documentContainsStyleHash20(targetDocument, hash)) {
12581 injectedStyles.add(hash);
12582 return;
12583 }
12584 const style = targetDocument.createElement("style");
12585 style.setAttribute(STYLE_HASH_ATTRIBUTE20, hash);
12586 style.appendChild(targetDocument.createTextNode(css));
12587 targetDocument.head.appendChild(style);
12588 injectedStyles.add(hash);
12589 }
12590 function registerDocument20(targetDocument) {
12591 const runtime = getRuntime20();
12592 runtime.documents.set(
12593 targetDocument,
12594 (runtime.documents.get(targetDocument) ?? 0) + 1
12595 );
12596 for (const [hash, css] of runtime.styles) {
12597 injectStyle20(targetDocument, hash, css);
12598 }
12599 return () => {
12600 const count = runtime.documents.get(targetDocument);
12601 if (count === void 0) {
12602 return;
12603 }
12604 if (count <= 1) {
12605 runtime.documents.delete(targetDocument);
12606 return;
12607 }
12608 runtime.documents.set(targetDocument, count - 1);
12609 };
12610 }
12611 function registerStyle20(hash, css) {
12612 const runtime = getRuntime20();
12613 runtime.styles.set(hash, css);
12614 for (const targetDocument of runtime.documents.keys()) {
12615 injectStyle20(targetDocument, hash, css);
12616 }
12617 }
12618 if (typeof process === "undefined" || true) {
12619 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}}}}');
12620 }
12621 var style_default19 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12622 var DEFAULT_TAG3 = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", {});
12623 var Description = (0, import_element39.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG3, className, children, ...props }, ref) {
12624 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
12625 Text,
12626 {
12627 ref,
12628 variant: "body-md",
12629 render: render4,
12630 className: clsx_default(style_default19.description, className),
12631 ...props,
12632 children
12633 }
12634 );
12635 });
12636
12637 // packages/ui/build-module/empty-state/actions.mjs
12638 var import_element40 = __toESM(require_element(), 1);
12639 var STYLE_HASH_ATTRIBUTE21 = "data-wp-hash";
12640 function getRuntime21() {
12641 const globalScope = globalThis;
12642 if (globalScope.__wpStyleRuntime) {
12643 return globalScope.__wpStyleRuntime;
12644 }
12645 globalScope.__wpStyleRuntime = {
12646 documents: /* @__PURE__ */ new Map(),
12647 styles: /* @__PURE__ */ new Map(),
12648 injectedStyles: /* @__PURE__ */ new WeakMap()
12649 };
12650 if (typeof document !== "undefined") {
12651 registerDocument21(document);
12652 }
12653 return globalScope.__wpStyleRuntime;
12654 }
12655 function documentContainsStyleHash21(targetDocument, hash) {
12656 if (!targetDocument.head) {
12657 return false;
12658 }
12659 for (const style of targetDocument.head.querySelectorAll(
12660 `style[${STYLE_HASH_ATTRIBUTE21}]`
12661 )) {
12662 if (style.getAttribute(STYLE_HASH_ATTRIBUTE21) === hash) {
12663 return true;
12664 }
12665 }
12666 return false;
12667 }
12668 function injectStyle21(targetDocument, hash, css) {
12669 if (!targetDocument.head) {
12670 return;
12671 }
12672 const runtime = getRuntime21();
12673 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12674 if (!injectedStyles) {
12675 injectedStyles = /* @__PURE__ */ new Set();
12676 runtime.injectedStyles.set(targetDocument, injectedStyles);
12677 }
12678 if (injectedStyles.has(hash)) {
12679 return;
12680 }
12681 if (documentContainsStyleHash21(targetDocument, hash)) {
12682 injectedStyles.add(hash);
12683 return;
12684 }
12685 const style = targetDocument.createElement("style");
12686 style.setAttribute(STYLE_HASH_ATTRIBUTE21, hash);
12687 style.appendChild(targetDocument.createTextNode(css));
12688 targetDocument.head.appendChild(style);
12689 injectedStyles.add(hash);
12690 }
12691 function registerDocument21(targetDocument) {
12692 const runtime = getRuntime21();
12693 runtime.documents.set(
12694 targetDocument,
12695 (runtime.documents.get(targetDocument) ?? 0) + 1
12696 );
12697 for (const [hash, css] of runtime.styles) {
12698 injectStyle21(targetDocument, hash, css);
12699 }
12700 return () => {
12701 const count = runtime.documents.get(targetDocument);
12702 if (count === void 0) {
12703 return;
12704 }
12705 if (count <= 1) {
12706 runtime.documents.delete(targetDocument);
12707 return;
12708 }
12709 runtime.documents.set(targetDocument, count - 1);
12710 };
12711 }
12712 function registerStyle21(hash, css) {
12713 const runtime = getRuntime21();
12714 runtime.styles.set(hash, css);
12715 for (const targetDocument of runtime.documents.keys()) {
12716 injectStyle21(targetDocument, hash, css);
12717 }
12718 }
12719 if (typeof process === "undefined" || true) {
12720 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}}}}');
12721 }
12722 var style_default20 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
12723 var Actions = (0, import_element40.forwardRef)(
12724 function EmptyStateActions({ render: render4, ...props }, ref) {
12725 const className = clsx_default(style_default20.actions);
12726 const element = useRender({
12727 defaultTagName: "div",
12728 render: render4,
12729 ref,
12730 props: mergeProps({ className }, props)
12731 });
12732 return element;
12733 }
12734 );
12735
12736 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
12737 var import_element41 = __toESM(require_element(), 1);
12738 var STYLE_HASH_ATTRIBUTE22 = "data-wp-hash";
12739 function getRuntime22() {
12740 const globalScope = globalThis;
12741 if (globalScope.__wpStyleRuntime) {
12742 return globalScope.__wpStyleRuntime;
12743 }
12744 globalScope.__wpStyleRuntime = {
12745 documents: /* @__PURE__ */ new Map(),
12746 styles: /* @__PURE__ */ new Map(),
12747 injectedStyles: /* @__PURE__ */ new WeakMap()
12748 };
12749 if (typeof document !== "undefined") {
12750 registerDocument22(document);
12751 }
12752 return globalScope.__wpStyleRuntime;
12753 }
12754 function documentContainsStyleHash22(targetDocument, hash) {
12755 if (!targetDocument.head) {
12756 return false;
12757 }
12758 for (const style of targetDocument.head.querySelectorAll(
12759 `style[${STYLE_HASH_ATTRIBUTE22}]`
12760 )) {
12761 if (style.getAttribute(STYLE_HASH_ATTRIBUTE22) === hash) {
12762 return true;
12763 }
12764 }
12765 return false;
12766 }
12767 function injectStyle22(targetDocument, hash, css) {
12768 if (!targetDocument.head) {
12769 return;
12770 }
12771 const runtime = getRuntime22();
12772 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12773 if (!injectedStyles) {
12774 injectedStyles = /* @__PURE__ */ new Set();
12775 runtime.injectedStyles.set(targetDocument, injectedStyles);
12776 }
12777 if (injectedStyles.has(hash)) {
12778 return;
12779 }
12780 if (documentContainsStyleHash22(targetDocument, hash)) {
12781 injectedStyles.add(hash);
12782 return;
12783 }
12784 const style = targetDocument.createElement("style");
12785 style.setAttribute(STYLE_HASH_ATTRIBUTE22, hash);
12786 style.appendChild(targetDocument.createTextNode(css));
12787 targetDocument.head.appendChild(style);
12788 injectedStyles.add(hash);
12789 }
12790 function registerDocument22(targetDocument) {
12791 const runtime = getRuntime22();
12792 runtime.documents.set(
12793 targetDocument,
12794 (runtime.documents.get(targetDocument) ?? 0) + 1
12795 );
12796 for (const [hash, css] of runtime.styles) {
12797 injectStyle22(targetDocument, hash, css);
12798 }
12799 return () => {
12800 const count = runtime.documents.get(targetDocument);
12801 if (count === void 0) {
12802 return;
12803 }
12804 if (count <= 1) {
12805 runtime.documents.delete(targetDocument);
12806 return;
12807 }
12808 runtime.documents.set(targetDocument, count - 1);
12809 };
12810 }
12811 function registerStyle22(hash, css) {
12812 const runtime = getRuntime22();
12813 runtime.styles.set(hash, css);
12814 for (const targetDocument of runtime.documents.keys()) {
12815 injectStyle22(targetDocument, hash, css);
12816 }
12817 }
12818 if (typeof process === "undefined" || true) {
12819 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}}}");
12820 }
12821 var style_default21 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
12822 var VisuallyHidden = (0, import_element41.forwardRef)(
12823 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
12824 const element = useRender({
12825 render: render4,
12826 ref,
12827 props: mergeProps(
12828 { className: style_default21["visually-hidden"] },
12829 restProps,
12830 {
12831 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
12832 "data-visually-hidden": ""
12833 }
12834 )
12835 });
12836 return element;
12837 }
12838 );
12839
12840 // packages/ui/build-module/link/link.mjs
12841 var import_element42 = __toESM(require_element(), 1);
12842 var import_i18n2 = __toESM(require_i18n(), 1);
12843 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
12844 var STYLE_HASH_ATTRIBUTE23 = "data-wp-hash";
12845 function getRuntime23() {
12846 const globalScope = globalThis;
12847 if (globalScope.__wpStyleRuntime) {
12848 return globalScope.__wpStyleRuntime;
12849 }
12850 globalScope.__wpStyleRuntime = {
12851 documents: /* @__PURE__ */ new Map(),
12852 styles: /* @__PURE__ */ new Map(),
12853 injectedStyles: /* @__PURE__ */ new WeakMap()
12854 };
12855 if (typeof document !== "undefined") {
12856 registerDocument23(document);
12857 }
12858 return globalScope.__wpStyleRuntime;
12859 }
12860 function documentContainsStyleHash23(targetDocument, hash) {
12861 if (!targetDocument.head) {
12862 return false;
12863 }
12864 for (const style of targetDocument.head.querySelectorAll(
12865 `style[${STYLE_HASH_ATTRIBUTE23}]`
12866 )) {
12867 if (style.getAttribute(STYLE_HASH_ATTRIBUTE23) === hash) {
12868 return true;
12869 }
12870 }
12871 return false;
12872 }
12873 function injectStyle23(targetDocument, hash, css) {
12874 if (!targetDocument.head) {
12875 return;
12876 }
12877 const runtime = getRuntime23();
12878 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12879 if (!injectedStyles) {
12880 injectedStyles = /* @__PURE__ */ new Set();
12881 runtime.injectedStyles.set(targetDocument, injectedStyles);
12882 }
12883 if (injectedStyles.has(hash)) {
12884 return;
12885 }
12886 if (documentContainsStyleHash23(targetDocument, hash)) {
12887 injectedStyles.add(hash);
12888 return;
12889 }
12890 const style = targetDocument.createElement("style");
12891 style.setAttribute(STYLE_HASH_ATTRIBUTE23, hash);
12892 style.appendChild(targetDocument.createTextNode(css));
12893 targetDocument.head.appendChild(style);
12894 injectedStyles.add(hash);
12895 }
12896 function registerDocument23(targetDocument) {
12897 const runtime = getRuntime23();
12898 runtime.documents.set(
12899 targetDocument,
12900 (runtime.documents.get(targetDocument) ?? 0) + 1
12901 );
12902 for (const [hash, css] of runtime.styles) {
12903 injectStyle23(targetDocument, hash, css);
12904 }
12905 return () => {
12906 const count = runtime.documents.get(targetDocument);
12907 if (count === void 0) {
12908 return;
12909 }
12910 if (count <= 1) {
12911 runtime.documents.delete(targetDocument);
12912 return;
12913 }
12914 runtime.documents.set(targetDocument, count - 1);
12915 };
12916 }
12917 function registerStyle23(hash, css) {
12918 const runtime = getRuntime23();
12919 runtime.styles.set(hash, css);
12920 for (const targetDocument of runtime.documents.keys()) {
12921 injectStyle23(targetDocument, hash, css);
12922 }
12923 }
12924 if (typeof process === "undefined" || true) {
12925 registerStyle23("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
12926 }
12927 var resets_default4 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
12928 if (typeof process === "undefined" || true) {
12929 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))}}}");
12930 }
12931 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" };
12932 if (typeof process === "undefined" || true) {
12933 registerStyle23("e8e6a9be37", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-foreground-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-default,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}}');
12934 }
12935 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" };
12936 if (typeof process === "undefined" || true) {
12937 registerStyle23("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
12938 }
12939 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" };
12940 var Link = (0, import_element42.forwardRef)(function Link2({
12941 children,
12942 variant = "default",
12943 tone = "brand",
12944 openInNewTab = false,
12945 render: render4,
12946 className,
12947 ...props
12948 }, ref) {
12949 const element = useRender({
12950 render: render4,
12951 defaultTagName: "a",
12952 ref,
12953 props: mergeProps(props, {
12954 className: clsx_default(
12955 global_css_defense_default4.a,
12956 resets_default4["box-sizing"],
12957 focus_default3["outset-ring--focus-except-active"],
12958 variant !== "unstyled" && style_default22.link,
12959 variant !== "unstyled" && style_default22[`is-${tone}`],
12960 variant === "unstyled" && style_default22["is-unstyled"],
12961 className
12962 ),
12963 target: openInNewTab ? "_blank" : void 0,
12964 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
12965 children,
12966 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
12967 "span",
12968 {
12969 className: style_default22["link-icon"],
12970 role: "img",
12971 "aria-label": (
12972 /* translators: accessibility text appended to link text */
12973 (0, import_i18n2.__)("(opens in a new tab)")
12974 )
12975 }
12976 )
12977 ] })
12978 })
12979 });
12980 return element;
12981 });
12982
12983 // packages/dataviews/build-module/components/dataviews-context/index.mjs
12984 var import_element43 = __toESM(require_element(), 1);
12985
12986 // packages/dataviews/build-module/constants.mjs
12987 var import_i18n3 = __toESM(require_i18n(), 1);
12988 var OPERATOR_IS_ANY = "isAny";
12989 var OPERATOR_IS_NONE = "isNone";
12990 var OPERATOR_IS_ALL = "isAll";
12991 var OPERATOR_IS_NOT_ALL = "isNotAll";
12992 var OPERATOR_BETWEEN = "between";
12993 var OPERATOR_IN_THE_PAST = "inThePast";
12994 var OPERATOR_OVER = "over";
12995 var OPERATOR_IS = "is";
12996 var OPERATOR_IS_NOT = "isNot";
12997 var OPERATOR_LESS_THAN = "lessThan";
12998 var OPERATOR_GREATER_THAN = "greaterThan";
12999 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
13000 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
13001 var OPERATOR_BEFORE = "before";
13002 var OPERATOR_AFTER = "after";
13003 var OPERATOR_BEFORE_INC = "beforeInc";
13004 var OPERATOR_AFTER_INC = "afterInc";
13005 var OPERATOR_CONTAINS = "contains";
13006 var OPERATOR_NOT_CONTAINS = "notContains";
13007 var OPERATOR_STARTS_WITH = "startsWith";
13008 var OPERATOR_ON = "on";
13009 var OPERATOR_NOT_ON = "notOn";
13010 var SORTING_DIRECTIONS = ["asc", "desc"];
13011 var sortArrows = { asc: "\u2191", desc: "\u2193" };
13012 var sortValues = { asc: "ascending", desc: "descending" };
13013 var sortLabels = {
13014 asc: (0, import_i18n3.__)("Sort ascending"),
13015 desc: (0, import_i18n3.__)("Sort descending")
13016 };
13017 var sortIcons = {
13018 asc: arrow_up_default,
13019 desc: arrow_down_default
13020 };
13021 var LAYOUT_TABLE = "table";
13022 var LAYOUT_GRID = "grid";
13023 var LAYOUT_LIST = "list";
13024 var LAYOUT_ACTIVITY = "activity";
13025 var LAYOUT_PICKER_GRID = "pickerGrid";
13026 var LAYOUT_PICKER_TABLE = "pickerTable";
13027 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
13028
13029 // packages/dataviews/build-module/components/dataviews-context/index.mjs
13030 var DataViewsContext = (0, import_element43.createContext)({
13031 view: { type: LAYOUT_TABLE },
13032 onChangeView: () => {
13033 },
13034 fields: [],
13035 data: [],
13036 paginationInfo: {
13037 totalItems: 0,
13038 totalPages: 0
13039 },
13040 selection: [],
13041 onChangeSelection: () => {
13042 },
13043 setOpenedFilter: () => {
13044 },
13045 openedFilter: null,
13046 getItemId: (item) => item.id,
13047 isItemClickable: () => true,
13048 renderItemLink: void 0,
13049 containerWidth: 0,
13050 containerRef: (0, import_element43.createRef)(),
13051 resizeObserverRef: () => {
13052 },
13053 defaultLayouts: { list: {}, grid: {}, table: {} },
13054 filters: [],
13055 isShowingFilter: false,
13056 setIsShowingFilter: () => {
13057 },
13058 hasInitiallyLoaded: false,
13059 config: {
13060 perPageSizes: []
13061 },
13062 intersectionObserver: null
13063 });
13064 DataViewsContext.displayName = "DataViewsContext";
13065 var dataviews_context_default = DataViewsContext;
13066
13067 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
13068 var import_i18n24 = __toESM(require_i18n(), 1);
13069
13070 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
13071 var import_i18n11 = __toESM(require_i18n(), 1);
13072 var import_components6 = __toESM(require_components(), 1);
13073 var import_element52 = __toESM(require_element(), 1);
13074 var import_keycodes2 = __toESM(require_keycodes(), 1);
13075
13076 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
13077 var import_components = __toESM(require_components(), 1);
13078 var import_i18n4 = __toESM(require_i18n(), 1);
13079 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13080 var SELECTION_CHECKBOX_CLASS = "dataviews-selection-checkbox";
13081 function DataViewsSelectionCheckbox({
13082 selection,
13083 onChangeSelection,
13084 item,
13085 getItemId,
13086 titleField,
13087 disabled: disabled2,
13088 ...extraProps
13089 }) {
13090 const id = getItemId(item);
13091 const isInSelectionArray = selection.includes(id);
13092 const checked = !disabled2 && isInSelectionArray;
13093 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n4.__)("(no title)");
13094 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13095 import_components.CheckboxControl,
13096 {
13097 className: SELECTION_CHECKBOX_CLASS,
13098 "aria-label": selectionLabel,
13099 "aria-disabled": disabled2,
13100 checked,
13101 onChange: () => {
13102 if (disabled2) {
13103 return;
13104 }
13105 onChangeSelection(
13106 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
13107 );
13108 },
13109 ...extraProps
13110 }
13111 );
13112 }
13113
13114 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
13115 var import_components2 = __toESM(require_components(), 1);
13116 var import_i18n5 = __toESM(require_i18n(), 1);
13117 var import_element44 = __toESM(require_element(), 1);
13118 var import_data = __toESM(require_data(), 1);
13119 var import_compose = __toESM(require_compose(), 1);
13120
13121 // packages/dataviews/build-module/lock-unlock.mjs
13122 var import_private_apis2 = __toESM(require_private_apis(), 1);
13123 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
13124 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
13125 "@wordpress/dataviews"
13126 );
13127
13128 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
13129 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13130 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
13131 function ButtonTrigger({
13132 action,
13133 onClick,
13134 items,
13135 variant
13136 }) {
13137 const label = typeof action.label === "string" ? action.label : action.label(items);
13138 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13139 import_components2.Button,
13140 {
13141 disabled: !!action.disabled,
13142 accessibleWhenDisabled: true,
13143 size: "compact",
13144 variant,
13145 onClick,
13146 children: label
13147 }
13148 );
13149 }
13150 function MenuItemTrigger({
13151 action,
13152 onClick,
13153 items
13154 }) {
13155 const label = typeof action.label === "string" ? action.label : action.label(items);
13156 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Menu.ItemLabel, { children: label }) });
13157 }
13158 function ActionModal({
13159 action,
13160 items,
13161 closeModal
13162 }) {
13163 const label = typeof action.label === "string" ? action.label : action.label(items);
13164 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
13165 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13166 import_components2.Modal,
13167 {
13168 title: modalHeader || label,
13169 __experimentalHideHeader: !!action.hideModalHeader,
13170 onRequestClose: closeModal,
13171 focusOnMount: action.modalFocusOnMount ?? true,
13172 size: action.modalSize || "medium",
13173 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
13174 action.id
13175 )}`,
13176 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(action.RenderModal, { items, closeModal })
13177 }
13178 );
13179 }
13180 function ActionsMenuGroup({
13181 actions,
13182 item,
13183 registry,
13184 setActiveModalAction
13185 }) {
13186 const { primaryActions, regularActions } = (0, import_element44.useMemo)(() => {
13187 return actions.reduce(
13188 (acc, action) => {
13189 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
13190 return acc;
13191 },
13192 {
13193 primaryActions: [],
13194 regularActions: []
13195 }
13196 );
13197 }, [actions]);
13198 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13199 MenuItemTrigger,
13200 {
13201 action,
13202 onClick: () => {
13203 if ("RenderModal" in action) {
13204 setActiveModalAction(action);
13205 return;
13206 }
13207 action.callback([item], { registry });
13208 },
13209 items: [item]
13210 },
13211 action.id
13212 ));
13213 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Menu.Group, { children: [
13214 renderActionGroup(primaryActions),
13215 renderActionGroup(regularActions)
13216 ] });
13217 }
13218 function ItemActions({
13219 item,
13220 actions,
13221 isCompact
13222 }) {
13223 const registry = (0, import_data.useRegistry)();
13224 const { primaryActions, eligibleActions } = (0, import_element44.useMemo)(() => {
13225 const _eligibleActions = actions.filter(
13226 (action) => !action.isEligible || action.isEligible(item)
13227 );
13228 const _primaryActions = _eligibleActions.filter(
13229 (action) => action.isPrimary
13230 );
13231 return {
13232 primaryActions: _primaryActions,
13233 eligibleActions: _eligibleActions
13234 };
13235 }, [actions, item]);
13236 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
13237 if (isCompact) {
13238 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13239 CompactItemActions,
13240 {
13241 item,
13242 actions: eligibleActions,
13243 isSmall: true,
13244 registry
13245 }
13246 );
13247 }
13248 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
13249 Stack,
13250 {
13251 direction: "row",
13252 justify: "flex-end",
13253 className: "dataviews-item-actions",
13254 style: {
13255 flexShrink: 0,
13256 width: "auto"
13257 },
13258 children: [
13259 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13260 PrimaryActions,
13261 {
13262 item,
13263 actions: primaryActions,
13264 registry
13265 }
13266 ),
13267 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13268 // there if there are any actions at all.
13269 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13270 CompactItemActions,
13271 {
13272 item,
13273 actions: eligibleActions,
13274 registry
13275 }
13276 )
13277 ]
13278 }
13279 );
13280 }
13281 function CompactItemActions({
13282 item,
13283 actions,
13284 isSmall,
13285 registry
13286 }) {
13287 const [activeModalAction, setActiveModalAction] = (0, import_element44.useState)(
13288 null
13289 );
13290 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
13291 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Menu, { placement: "bottom-end", children: [
13292 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13293 Menu.TriggerButton,
13294 {
13295 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13296 import_components2.Button,
13297 {
13298 size: isSmall ? "small" : "compact",
13299 icon: more_vertical_default,
13300 label: (0, import_i18n5.__)("Actions"),
13301 accessibleWhenDisabled: true,
13302 disabled: !actions.length,
13303 className: "dataviews-all-actions-button"
13304 }
13305 )
13306 }
13307 ),
13308 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13309 ActionsMenuGroup,
13310 {
13311 actions,
13312 item,
13313 registry,
13314 setActiveModalAction
13315 }
13316 ) })
13317 ] }),
13318 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13319 ActionModal,
13320 {
13321 action: activeModalAction,
13322 items: [item],
13323 closeModal: () => setActiveModalAction(null)
13324 }
13325 )
13326 ] });
13327 }
13328 function PrimaryActions({
13329 item,
13330 actions,
13331 registry,
13332 buttonVariant
13333 }) {
13334 const [activeModalAction, setActiveModalAction] = (0, import_element44.useState)(null);
13335 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
13336 if (isMobileViewport) {
13337 return null;
13338 }
13339 if (!Array.isArray(actions) || actions.length === 0) {
13340 return null;
13341 }
13342 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
13343 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13344 ButtonTrigger,
13345 {
13346 action,
13347 onClick: () => {
13348 if ("RenderModal" in action) {
13349 setActiveModalAction(action);
13350 return;
13351 }
13352 action.callback([item], { registry });
13353 },
13354 items: [item],
13355 variant: buttonVariant
13356 },
13357 action.id
13358 )),
13359 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13360 ActionModal,
13361 {
13362 action: activeModalAction,
13363 items: [item],
13364 closeModal: () => setActiveModalAction(null)
13365 }
13366 )
13367 ] });
13368 }
13369
13370 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
13371 var import_components3 = __toESM(require_components(), 1);
13372 var import_i18n7 = __toESM(require_i18n(), 1);
13373 var import_element45 = __toESM(require_element(), 1);
13374 var import_data2 = __toESM(require_data(), 1);
13375 var import_compose2 = __toESM(require_compose(), 1);
13376
13377 // packages/dataviews/build-module/utils/get-footer-message.mjs
13378 var import_i18n6 = __toESM(require_i18n(), 1);
13379 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
13380 if (selectionCount > 0) {
13381 return (0, import_i18n6.sprintf)(
13382 /* translators: %d: number of items. */
13383 (0, import_i18n6._n)("%d Item selected", "%d Items selected", selectionCount),
13384 selectionCount
13385 );
13386 }
13387 if (onlyTotalCount || totalItems <= itemsCount) {
13388 return (0, import_i18n6.sprintf)(
13389 /* translators: %d: number of items. */
13390 (0, import_i18n6._n)("%d Item", "%d Items", totalItems),
13391 totalItems
13392 );
13393 }
13394 return (0, import_i18n6.sprintf)(
13395 /* translators: %1$d: number of items. %2$d: total number of items. */
13396 (0, import_i18n6._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
13397 itemsCount,
13398 totalItems
13399 );
13400 }
13401
13402 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
13403 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
13404 function ActionWithModal({
13405 action,
13406 items,
13407 ActionTriggerComponent
13408 }) {
13409 const [isModalOpen, setIsModalOpen] = (0, import_element45.useState)(false);
13410 const actionTriggerProps = {
13411 action,
13412 onClick: () => {
13413 setIsModalOpen(true);
13414 },
13415 items
13416 };
13417 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
13418 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
13419 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13420 ActionModal,
13421 {
13422 action,
13423 items,
13424 closeModal: () => setIsModalOpen(false)
13425 }
13426 )
13427 ] });
13428 }
13429 function hasAPossibleBulkAction(actions, item) {
13430 return actions.some(
13431 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
13432 );
13433 }
13434 function useHasAPossibleBulkAction(actions, item) {
13435 return (0, import_element45.useMemo)(
13436 () => hasAPossibleBulkAction(actions, item),
13437 [actions, item]
13438 );
13439 }
13440 function useSomeItemHasAPossibleBulkAction(actions, data) {
13441 return (0, import_element45.useMemo)(
13442 () => data.some((item) => hasAPossibleBulkAction(actions, item)),
13443 [actions, data]
13444 );
13445 }
13446 function BulkSelectionCheckbox({
13447 selection,
13448 onChangeSelection,
13449 data,
13450 actions,
13451 getItemId,
13452 disableSelectAll = false
13453 }) {
13454 const selectableItems = (0, import_element45.useMemo)(() => {
13455 return data.filter((item) => {
13456 return actions.some(
13457 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
13458 );
13459 });
13460 }, [data, actions]);
13461 const selectedItems = data.filter(
13462 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
13463 );
13464 const hasSelection = selection.length > 0;
13465 const areAllSelected = selectedItems.length === selectableItems.length;
13466 if (disableSelectAll) {
13467 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13468 import_components3.CheckboxControl,
13469 {
13470 className: "dataviews-view-table-selection-checkbox",
13471 checked: hasSelection,
13472 disabled: !hasSelection,
13473 onChange: () => {
13474 onChangeSelection([]);
13475 },
13476 "aria-label": (0, import_i18n7.__)("Deselect all")
13477 }
13478 );
13479 }
13480 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13481 import_components3.CheckboxControl,
13482 {
13483 className: "dataviews-view-table-selection-checkbox",
13484 checked: areAllSelected,
13485 indeterminate: !areAllSelected && !!selectedItems.length,
13486 onChange: () => {
13487 if (areAllSelected) {
13488 onChangeSelection([]);
13489 } else {
13490 onChangeSelection(
13491 selectableItems.map((item) => getItemId(item))
13492 );
13493 }
13494 },
13495 "aria-label": areAllSelected ? (0, import_i18n7.__)("Deselect all") : (0, import_i18n7.__)("Select all")
13496 }
13497 );
13498 }
13499 function ActionTrigger({
13500 action,
13501 onClick,
13502 isBusy,
13503 items
13504 }) {
13505 const label = typeof action.label === "string" ? action.label : action.label(items);
13506 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
13507 if (isMobile) {
13508 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13509 import_components3.Button,
13510 {
13511 disabled: isBusy,
13512 accessibleWhenDisabled: true,
13513 label,
13514 icon: action.icon,
13515 size: "compact",
13516 onClick,
13517 isBusy
13518 }
13519 );
13520 }
13521 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13522 import_components3.Button,
13523 {
13524 disabled: isBusy,
13525 accessibleWhenDisabled: true,
13526 size: "compact",
13527 onClick,
13528 isBusy,
13529 children: label
13530 }
13531 );
13532 }
13533 var EMPTY_ARRAY2 = [];
13534 function ActionButton({
13535 action,
13536 selectedItems,
13537 actionInProgress,
13538 setActionInProgress
13539 }) {
13540 const registry = (0, import_data2.useRegistry)();
13541 const selectedEligibleItems = (0, import_element45.useMemo)(() => {
13542 return selectedItems.filter((item) => {
13543 return !action.isEligible || action.isEligible(item);
13544 });
13545 }, [action, selectedItems]);
13546 if ("RenderModal" in action) {
13547 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13548 ActionWithModal,
13549 {
13550 action,
13551 items: selectedEligibleItems,
13552 ActionTriggerComponent: ActionTrigger
13553 },
13554 action.id
13555 );
13556 }
13557 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13558 ActionTrigger,
13559 {
13560 action,
13561 onClick: async () => {
13562 setActionInProgress(action.id);
13563 await action.callback(selectedItems, {
13564 registry
13565 });
13566 setActionInProgress(null);
13567 },
13568 items: selectedEligibleItems,
13569 isBusy: actionInProgress === action.id
13570 },
13571 action.id
13572 );
13573 }
13574 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
13575 const message2 = getFooterMessage(
13576 selection.length,
13577 data.length,
13578 paginationInfo.totalItems,
13579 isInfiniteScroll
13580 );
13581 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
13582 Stack,
13583 {
13584 direction: "row",
13585 className: "dataviews-bulk-actions-footer__container",
13586 gap: "md",
13587 align: "center",
13588 children: [
13589 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13590 BulkSelectionCheckbox,
13591 {
13592 selection,
13593 onChangeSelection,
13594 data,
13595 actions,
13596 getItemId,
13597 disableSelectAll: isInfiniteScroll
13598 }
13599 ),
13600 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
13601 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
13602 Stack,
13603 {
13604 direction: "row",
13605 className: "dataviews-bulk-actions-footer__action-buttons",
13606 gap: "xs",
13607 children: [
13608 actionsToShow.map((action) => {
13609 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13610 ActionButton,
13611 {
13612 action,
13613 selectedItems,
13614 actionInProgress,
13615 setActionInProgress
13616 },
13617 action.id
13618 );
13619 }),
13620 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13621 import_components3.Button,
13622 {
13623 icon: close_small_default,
13624 showTooltip: true,
13625 tooltipPosition: "top",
13626 size: "compact",
13627 label: (0, import_i18n7.__)("Cancel"),
13628 disabled: !!actionInProgress,
13629 accessibleWhenDisabled: false,
13630 onClick: () => {
13631 onChangeSelection(EMPTY_ARRAY2);
13632 }
13633 }
13634 )
13635 ]
13636 }
13637 )
13638 ]
13639 }
13640 );
13641 }
13642 function FooterContent({
13643 selection,
13644 actions,
13645 onChangeSelection,
13646 data,
13647 getItemId,
13648 isInfiniteScroll,
13649 paginationInfo
13650 }) {
13651 const [actionInProgress, setActionInProgress] = (0, import_element45.useState)(
13652 null
13653 );
13654 const footerContentRef = (0, import_element45.useRef)(void 0);
13655 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
13656 const bulkActions = (0, import_element45.useMemo)(
13657 () => actions.filter((action) => action.supportsBulk),
13658 [actions]
13659 );
13660 const selectableItems = (0, import_element45.useMemo)(() => {
13661 return data.filter((item) => {
13662 return bulkActions.some(
13663 (action) => !action.isEligible || action.isEligible(item)
13664 );
13665 });
13666 }, [data, bulkActions]);
13667 const selectedItems = (0, import_element45.useMemo)(() => {
13668 return data.filter(
13669 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
13670 );
13671 }, [selection, data, getItemId, selectableItems]);
13672 const actionsToShow = (0, import_element45.useMemo)(
13673 () => actions.filter((action) => {
13674 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
13675 (item) => !action.isEligible || action.isEligible(item)
13676 );
13677 }),
13678 [actions, selectedItems, isMobile]
13679 );
13680 if (!actionInProgress) {
13681 if (footerContentRef.current) {
13682 footerContentRef.current = void 0;
13683 }
13684 return renderFooterContent(
13685 data,
13686 actions,
13687 getItemId,
13688 isInfiniteScroll,
13689 selection,
13690 actionsToShow,
13691 selectedItems,
13692 actionInProgress,
13693 setActionInProgress,
13694 onChangeSelection,
13695 paginationInfo
13696 );
13697 } else if (!footerContentRef.current) {
13698 footerContentRef.current = renderFooterContent(
13699 data,
13700 actions,
13701 getItemId,
13702 isInfiniteScroll,
13703 selection,
13704 actionsToShow,
13705 selectedItems,
13706 actionInProgress,
13707 setActionInProgress,
13708 onChangeSelection,
13709 paginationInfo
13710 );
13711 }
13712 return footerContentRef.current;
13713 }
13714 function BulkActionsFooter() {
13715 const {
13716 data,
13717 selection,
13718 actions = EMPTY_ARRAY2,
13719 onChangeSelection,
13720 getItemId,
13721 paginationInfo,
13722 view
13723 } = (0, import_element45.useContext)(dataviews_context_default);
13724 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13725 FooterContent,
13726 {
13727 selection,
13728 onChangeSelection,
13729 data,
13730 actions,
13731 getItemId,
13732 isInfiniteScroll: !!view.infiniteScrollEnabled,
13733 paginationInfo
13734 }
13735 );
13736 }
13737
13738 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
13739 var import_i18n8 = __toESM(require_i18n(), 1);
13740 var import_components4 = __toESM(require_components(), 1);
13741 var import_element46 = __toESM(require_element(), 1);
13742
13743 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
13744 function getHideableFields(view, fields) {
13745 const togglableFields = [
13746 view?.titleField,
13747 view?.mediaField,
13748 view?.descriptionField
13749 ].filter(Boolean);
13750 return fields.filter(
13751 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
13752 );
13753 }
13754
13755 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
13756 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
13757 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
13758 function WithMenuSeparators({ children }) {
13759 return import_element46.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_element46.Fragment, { children: [
13760 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Separator, {}),
13761 child
13762 ] }, i2));
13763 }
13764 var _HeaderMenu = (0, import_element46.forwardRef)(function HeaderMenu({
13765 fieldId,
13766 view,
13767 fields,
13768 onChangeView,
13769 onHide,
13770 setOpenedFilter,
13771 canMove = true,
13772 canInsertLeft = true,
13773 canInsertRight = true
13774 }, ref) {
13775 const visibleFieldIds = view.fields ?? [];
13776 const index2 = visibleFieldIds?.indexOf(fieldId);
13777 const isSorted = view.sort?.field === fieldId;
13778 let isHidable = false;
13779 let isSortable = false;
13780 let canAddFilter = false;
13781 let operators = [];
13782 const field = fields.find((f2) => f2.id === fieldId);
13783 const { setIsShowingFilter } = (0, import_element46.useContext)(dataviews_context_default);
13784 if (!field) {
13785 return null;
13786 }
13787 isHidable = field.enableHiding !== false;
13788 isSortable = field.enableSorting !== false;
13789 const header = field.header;
13790 operators = !!field.filterBy && field.filterBy?.operators || [];
13791 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
13792 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
13793 return header;
13794 }
13795 const hiddenFields = getHideableFields(view, fields).filter(
13796 (f2) => !visibleFieldIds.includes(f2.id)
13797 );
13798 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
13799 const isRtl = (0, import_i18n8.isRTL)();
13800 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2, { children: [
13801 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
13802 Menu2.TriggerButton,
13803 {
13804 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13805 import_components4.Button,
13806 {
13807 size: "compact",
13808 className: "dataviews-view-table-header-button",
13809 ref,
13810 variant: "tertiary"
13811 }
13812 ),
13813 children: [
13814 header,
13815 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
13816 ]
13817 }
13818 ),
13819 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(WithMenuSeparators, { children: [
13820 isSortable && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
13821 (direction) => {
13822 const isChecked = view.sort && isSorted && view.sort.direction === direction;
13823 const value = `${fieldId}-${direction}`;
13824 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13825 Menu2.RadioItem,
13826 {
13827 name: "view-table-sorting",
13828 value,
13829 checked: isChecked,
13830 onChange: () => {
13831 onChangeView({
13832 ...view,
13833 sort: {
13834 field: fieldId,
13835 direction
13836 },
13837 showLevels: false
13838 });
13839 },
13840 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
13841 },
13842 value
13843 );
13844 }
13845 ) }),
13846 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13847 Menu2.Item,
13848 {
13849 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: funnel_default }),
13850 onClick: () => {
13851 setOpenedFilter(fieldId);
13852 setIsShowingFilter(true);
13853 onChangeView({
13854 ...view,
13855 page: 1,
13856 filters: [
13857 ...view.filters || [],
13858 {
13859 field: fieldId,
13860 value: void 0,
13861 operator: operators[0]
13862 }
13863 ]
13864 });
13865 },
13866 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Add filter") })
13867 }
13868 ) }),
13869 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2.Group, { children: [
13870 canMove && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13871 Menu2.Item,
13872 {
13873 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: arrow_left_default }),
13874 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
13875 onClick: () => {
13876 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
13877 const newFields = [
13878 ...visibleFieldIds
13879 ];
13880 newFields.splice(index2, 1);
13881 newFields.splice(
13882 targetIndex,
13883 0,
13884 fieldId
13885 );
13886 onChangeView({
13887 ...view,
13888 fields: newFields
13889 });
13890 },
13891 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Move left") })
13892 }
13893 ),
13894 canMove && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13895 Menu2.Item,
13896 {
13897 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: arrow_right_default }),
13898 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
13899 onClick: () => {
13900 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
13901 const newFields = [
13902 ...visibleFieldIds
13903 ];
13904 newFields.splice(index2, 1);
13905 newFields.splice(
13906 targetIndex,
13907 0,
13908 fieldId
13909 );
13910 onChangeView({
13911 ...view,
13912 fields: newFields
13913 });
13914 },
13915 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Move right") })
13916 }
13917 ),
13918 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2, { children: [
13919 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Insert left") }) }),
13920 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
13921 const insertIndex = isRtl ? index2 + 1 : index2;
13922 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13923 Menu2.Item,
13924 {
13925 onClick: () => {
13926 onChangeView({
13927 ...view,
13928 fields: [
13929 ...visibleFieldIds.slice(
13930 0,
13931 insertIndex
13932 ),
13933 hiddenField.id,
13934 ...visibleFieldIds.slice(
13935 insertIndex
13936 )
13937 ]
13938 });
13939 },
13940 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
13941 },
13942 hiddenField.id
13943 );
13944 }) })
13945 ] }),
13946 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Menu2, { children: [
13947 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Insert right") }) }),
13948 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
13949 const insertIndex = isRtl ? index2 : index2 + 1;
13950 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13951 Menu2.Item,
13952 {
13953 onClick: () => {
13954 onChangeView({
13955 ...view,
13956 fields: [
13957 ...visibleFieldIds.slice(
13958 0,
13959 insertIndex
13960 ),
13961 hiddenField.id,
13962 ...visibleFieldIds.slice(
13963 insertIndex
13964 )
13965 ]
13966 });
13967 },
13968 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
13969 },
13970 hiddenField.id
13971 );
13972 }) })
13973 ] }),
13974 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13975 Menu2.Item,
13976 {
13977 prefix: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components4.Icon, { icon: unseen_default }),
13978 onClick: () => {
13979 onHide(field);
13980 onChangeView({
13981 ...view,
13982 fields: visibleFieldIds.filter(
13983 (id) => id !== fieldId
13984 )
13985 });
13986 },
13987 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Menu2.ItemLabel, { children: (0, import_i18n8.__)("Hide column") })
13988 }
13989 )
13990 ] })
13991 ] }) })
13992 ] });
13993 });
13994 var ColumnHeaderMenu = _HeaderMenu;
13995 var column_header_menu_default = ColumnHeaderMenu;
13996
13997 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
13998 var import_element47 = __toESM(require_element(), 1);
13999 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
14000 function getClickableItemProps({
14001 item,
14002 isItemClickable,
14003 onClickItem,
14004 className
14005 }) {
14006 if (!isItemClickable(item) || !onClickItem) {
14007 return { className };
14008 }
14009 return {
14010 className: className ? `${className} ${className}--clickable` : void 0,
14011 role: "button",
14012 tabIndex: 0,
14013 onClick: (event) => {
14014 event.stopPropagation();
14015 onClickItem(item);
14016 },
14017 onKeyDown: (event) => {
14018 if (event.key === "Enter" || event.key === "" || event.key === " ") {
14019 event.stopPropagation();
14020 onClickItem(item);
14021 }
14022 }
14023 };
14024 }
14025 function ItemClickWrapper({
14026 item,
14027 isItemClickable,
14028 onClickItem,
14029 renderItemLink,
14030 className,
14031 children,
14032 ...extraProps
14033 }) {
14034 if (!isItemClickable(item)) {
14035 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className, ...extraProps, children });
14036 }
14037 if (renderItemLink) {
14038 const renderedElement = renderItemLink({
14039 item,
14040 className: `${className} ${className}--clickable`,
14041 ...extraProps,
14042 children
14043 });
14044 return (0, import_element47.cloneElement)(renderedElement, {
14045 onClick: (event) => {
14046 event.stopPropagation();
14047 if (renderedElement.props.onClick) {
14048 renderedElement.props.onClick(event);
14049 }
14050 },
14051 onKeyDown: (event) => {
14052 if (event.key === "Enter" || event.key === "" || event.key === " ") {
14053 event.stopPropagation();
14054 if (renderedElement.props.onKeyDown) {
14055 renderedElement.props.onKeyDown(event);
14056 }
14057 }
14058 }
14059 });
14060 }
14061 const clickProps = getClickableItemProps({
14062 item,
14063 isItemClickable,
14064 onClickItem,
14065 className
14066 });
14067 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { ...clickProps, ...extraProps, children });
14068 }
14069
14070 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
14071 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
14072 function ColumnPrimary({
14073 item,
14074 level,
14075 titleField,
14076 mediaField,
14077 descriptionField,
14078 onClickItem,
14079 renderItemLink,
14080 isItemClickable
14081 }) {
14082 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
14083 mediaField && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14084 ItemClickWrapper,
14085 {
14086 item,
14087 isItemClickable,
14088 onClickItem,
14089 renderItemLink,
14090 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
14091 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
14092 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14093 mediaField.render,
14094 {
14095 item,
14096 field: mediaField,
14097 config: { sizes: "32px" }
14098 }
14099 )
14100 }
14101 ),
14102 /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
14103 Stack,
14104 {
14105 direction: "column",
14106 align: "flex-start",
14107 className: "dataviews-view-table__primary-column-content",
14108 children: [
14109 titleField && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
14110 ItemClickWrapper,
14111 {
14112 item,
14113 isItemClickable,
14114 onClickItem,
14115 renderItemLink,
14116 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
14117 children: [
14118 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "dataviews-view-table__level", children: [
14119 Array(level).fill("\u2014").join(" "),
14120 "\xA0"
14121 ] }),
14122 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(titleField.render, { item, field: titleField })
14123 ]
14124 }
14125 ),
14126 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14127 descriptionField.render,
14128 {
14129 item,
14130 field: descriptionField
14131 }
14132 )
14133 ]
14134 }
14135 )
14136 ] });
14137 }
14138 var column_primary_default = ColumnPrimary;
14139
14140 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
14141 var import_element48 = __toESM(require_element(), 1);
14142 var import_i18n9 = __toESM(require_i18n(), 1);
14143 var isScrolledToEnd = (element) => {
14144 if ((0, import_i18n9.isRTL)()) {
14145 const scrollLeft = Math.abs(element.scrollLeft);
14146 return scrollLeft <= 1;
14147 }
14148 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
14149 };
14150 function useScrollState({
14151 scrollContainerRef,
14152 enabledHorizontal = false
14153 }) {
14154 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element48.useState)(false);
14155 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element48.useState)(false);
14156 const handleScroll = (0, import_element48.useCallback)(() => {
14157 const scrollContainer = scrollContainerRef.current;
14158 if (!scrollContainer) {
14159 return;
14160 }
14161 if (enabledHorizontal) {
14162 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
14163 }
14164 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
14165 }, [scrollContainerRef, enabledHorizontal]);
14166 (0, import_element48.useEffect)(() => {
14167 if (typeof window === "undefined" || !scrollContainerRef.current) {
14168 return () => {
14169 };
14170 }
14171 const scrollContainer = scrollContainerRef.current;
14172 handleScroll();
14173 scrollContainer.addEventListener("scroll", handleScroll);
14174 window.addEventListener("resize", handleScroll);
14175 return () => {
14176 scrollContainer.removeEventListener("scroll", handleScroll);
14177 window.removeEventListener("resize", handleScroll);
14178 };
14179 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
14180 return { isHorizontalScrollEnd, isVerticallyScrolled };
14181 }
14182
14183 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
14184 function getDataByGroup(data, groupByField) {
14185 return data.reduce((groups, item) => {
14186 const groupName = groupByField.getValue({ item });
14187 if (!groups.has(groupName)) {
14188 groups.set(groupName, []);
14189 }
14190 groups.get(groupName)?.push(item);
14191 return groups;
14192 }, /* @__PURE__ */ new Map());
14193 }
14194
14195 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-selection-props.mjs
14196 var import_element49 = __toESM(require_element(), 1);
14197 var import_keycodes = __toESM(require_keycodes(), 1);
14198 function getRange(orderedIds, fromIndex, toIndex) {
14199 return orderedIds.slice(
14200 Math.min(fromIndex, toIndex),
14201 Math.max(fromIndex, toIndex) + 1
14202 );
14203 }
14204 function getRangeSelection({
14205 anchorId,
14206 targetId,
14207 lastTargetId,
14208 orderedIds,
14209 selection
14210 }) {
14211 const targetIndex = orderedIds.indexOf(targetId);
14212 if (targetIndex === -1) {
14213 return selection;
14214 }
14215 const anchorIndex = anchorId === null ? -1 : orderedIds.indexOf(anchorId);
14216 const hasAnchor = anchorIndex !== -1;
14217 const rangeStart = hasAnchor ? anchorIndex : targetIndex;
14218 const lastTargetIndex = hasAnchor && lastTargetId !== null ? orderedIds.indexOf(lastTargetId) : -1;
14219 const lastRange = lastTargetIndex === -1 ? [] : getRange(orderedIds, rangeStart, lastTargetIndex);
14220 const base = selection.filter((id) => !lastRange.includes(id));
14221 return [
14222 .../* @__PURE__ */ new Set([
14223 ...base,
14224 ...getRange(orderedIds, rangeStart, targetIndex)
14225 ])
14226 ];
14227 }
14228 function getClosestSelectedId({
14229 targetId,
14230 orderedIds,
14231 selection
14232 }) {
14233 const targetIndex = orderedIds.indexOf(targetId);
14234 if (targetIndex === -1) {
14235 return null;
14236 }
14237 const selectedIds = new Set(selection);
14238 let closestId = null;
14239 let closestDistance = Infinity;
14240 orderedIds.forEach((id, index2) => {
14241 if (!selectedIds.has(id)) {
14242 return;
14243 }
14244 const distance = Math.abs(index2 - targetIndex);
14245 if (distance < closestDistance) {
14246 closestDistance = distance;
14247 closestId = id;
14248 }
14249 });
14250 return closestId;
14251 }
14252 function useSelectionProps({
14253 data,
14254 actions,
14255 getItemId,
14256 selection,
14257 onChangeSelection
14258 }) {
14259 const gestureRef = (0, import_element49.useRef)(null);
14260 const isTouchDeviceRef = (0, import_element49.useRef)(false);
14261 (0, import_element49.useEffect)(() => {
14262 const markTouchDevice = () => {
14263 isTouchDeviceRef.current = true;
14264 };
14265 document.addEventListener("touchstart", markTouchDevice, {
14266 once: true
14267 });
14268 return () => document.removeEventListener("touchstart", markTouchDevice);
14269 }, []);
14270 const selectableIds = data.filter((item) => hasAPossibleBulkAction(actions, item)).map(getItemId);
14271 const selectableIdSet = new Set(selectableIds);
14272 const hasSelectableItems = selectableIds.length > 0;
14273 const getSelectionProps = (id) => {
14274 const isSelectable = selectableIdSet.has(id);
14275 return {
14276 onMouseDown: (event) => {
14277 if (event.button === 0 && event.shiftKey && hasSelectableItems) {
14278 event.preventDefault();
14279 }
14280 },
14281 onClickCapture: (event) => {
14282 if (!hasSelectableItems) {
14283 return;
14284 }
14285 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
14286 const isSelectionCheckboxClick = event.target instanceof Element && !!event.target.closest(`.${SELECTION_CHECKBOX_CLASS}`);
14287 if (!isModifierKeyPressed && !event.shiftKey) {
14288 if (isSelectable && isSelectionCheckboxClick) {
14289 gestureRef.current = {
14290 anchorId: id,
14291 lastTargetId: null
14292 };
14293 }
14294 return;
14295 }
14296 if (isTouchDeviceRef.current || document.getSelection()?.type === "Range") {
14297 return;
14298 }
14299 event.stopPropagation();
14300 if (!isSelectionCheckboxClick) {
14301 event.preventDefault();
14302 }
14303 if (!isSelectable) {
14304 return;
14305 }
14306 if (event.shiftKey) {
14307 let gesture = gestureRef.current;
14308 if (!gesture || !selectableIdSet.has(gesture.anchorId)) {
14309 gesture = {
14310 anchorId: getClosestSelectedId({
14311 targetId: id,
14312 orderedIds: selectableIds,
14313 selection
14314 }) ?? id,
14315 lastTargetId: null
14316 };
14317 }
14318 onChangeSelection(
14319 getRangeSelection({
14320 anchorId: gesture.anchorId,
14321 targetId: id,
14322 lastTargetId: gesture.lastTargetId,
14323 orderedIds: selectableIds,
14324 selection
14325 })
14326 );
14327 gestureRef.current = {
14328 anchorId: gesture.anchorId,
14329 lastTargetId: id
14330 };
14331 } else {
14332 onChangeSelection(
14333 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
14334 );
14335 gestureRef.current = { anchorId: id, lastTargetId: null };
14336 }
14337 }
14338 };
14339 };
14340 return { getSelectionProps };
14341 }
14342
14343 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
14344 var import_components5 = __toESM(require_components(), 1);
14345 var import_i18n10 = __toESM(require_i18n(), 1);
14346 var import_element50 = __toESM(require_element(), 1);
14347 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
14348 function FieldItem({
14349 field,
14350 isVisible: isVisible2,
14351 onToggleVisibility
14352 }) {
14353 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: [
14354 /* @__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 }) }),
14355 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
14356 ] }) });
14357 }
14358 function isDefined(item) {
14359 return !!item;
14360 }
14361 function PropertiesSection({
14362 showLabel = true
14363 }) {
14364 const { view, fields, onChangeView } = (0, import_element50.useContext)(dataviews_context_default);
14365 const regularFields = getHideableFields(view, fields);
14366 if (!regularFields?.length) {
14367 return null;
14368 }
14369 const titleField = fields.find((f2) => f2.id === view.titleField);
14370 const previewField = fields.find((f2) => f2.id === view.mediaField);
14371 const descriptionField = fields.find(
14372 (f2) => f2.id === view.descriptionField
14373 );
14374 const lockedFields = [
14375 {
14376 field: titleField,
14377 isVisibleFlag: "showTitle"
14378 },
14379 {
14380 field: previewField,
14381 isVisibleFlag: "showMedia"
14382 },
14383 {
14384 field: descriptionField,
14385 isVisibleFlag: "showDescription"
14386 }
14387 ].filter(({ field }) => isDefined(field));
14388 const visibleFieldIds = view.fields ?? [];
14389 const visibleRegularFieldsCount = regularFields.filter(
14390 (f2) => visibleFieldIds.includes(f2.id)
14391 ).length;
14392 const visibleLockedFields = lockedFields.filter(
14393 ({ isVisibleFlag }) => (
14394 // @ts-expect-error
14395 view[isVisibleFlag] ?? true
14396 )
14397 );
14398 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
14399 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
14400 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
14401 showLabel && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n10.__)("Properties") }),
14402 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14403 Stack,
14404 {
14405 direction: "column",
14406 className: "dataviews-view-config__properties",
14407 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
14408 lockedFields.map(({ field, isVisibleFlag }) => {
14409 const isVisible2 = view[isVisibleFlag] ?? true;
14410 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
14411 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14412 FieldItem,
14413 {
14414 field: fieldToRender,
14415 isVisible: isVisible2,
14416 onToggleVisibility: () => {
14417 onChangeView({
14418 ...view,
14419 [isVisibleFlag]: !isVisible2
14420 });
14421 }
14422 },
14423 field.id
14424 );
14425 }),
14426 regularFields.map((field) => {
14427 const isVisible2 = visibleFieldIds.includes(field.id);
14428 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
14429 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14430 FieldItem,
14431 {
14432 field: fieldToRender,
14433 isVisible: isVisible2,
14434 onToggleVisibility: () => {
14435 onChangeView({
14436 ...view,
14437 fields: isVisible2 ? visibleFieldIds.filter(
14438 (fieldId) => fieldId !== field.id
14439 ) : [...visibleFieldIds, field.id]
14440 });
14441 }
14442 },
14443 field.id
14444 );
14445 })
14446 ] })
14447 }
14448 )
14449 ] });
14450 }
14451
14452 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
14453 var import_element51 = __toESM(require_element(), 1);
14454 function useDelayedLoading(isLoading, options = { delay: 400 }) {
14455 const [showLoader, setShowLoader] = (0, import_element51.useState)(false);
14456 (0, import_element51.useEffect)(() => {
14457 if (!isLoading) {
14458 return;
14459 }
14460 const timeout = setTimeout(() => {
14461 setShowLoader(true);
14462 }, options.delay);
14463 return () => {
14464 clearTimeout(timeout);
14465 setShowLoader(false);
14466 };
14467 }, [isLoading, options.delay]);
14468 return showLoader;
14469 }
14470
14471 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
14472 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
14473 function getEffectiveAlign(explicitAlign, fieldType) {
14474 if (explicitAlign) {
14475 return explicitAlign;
14476 }
14477 if (fieldType === "integer" || fieldType === "number") {
14478 return "end";
14479 }
14480 return void 0;
14481 }
14482 function TableColumnField({
14483 item,
14484 fields,
14485 column,
14486 align
14487 }) {
14488 const field = fields.find((f2) => f2.id === column);
14489 if (!field) {
14490 return null;
14491 }
14492 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14493 "dataviews-view-table__cell-align-end": align === "end",
14494 "dataviews-view-table__cell-align-center": align === "center"
14495 });
14496 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(field.render, { item, field }) });
14497 }
14498 function TableRow({
14499 hasBulkActions,
14500 item,
14501 level,
14502 actions,
14503 fields,
14504 id,
14505 view,
14506 titleField,
14507 mediaField,
14508 descriptionField,
14509 selection,
14510 getItemId,
14511 isItemClickable,
14512 onClickItem,
14513 renderItemLink,
14514 onChangeSelection,
14515 onMouseDown,
14516 onClickCapture,
14517 isActionsColumnSticky,
14518 posinset
14519 }) {
14520 const { paginationInfo } = (0, import_element52.useContext)(dataviews_context_default);
14521 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
14522 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
14523 const {
14524 showTitle = true,
14525 showMedia = true,
14526 showDescription = true,
14527 infiniteScrollEnabled
14528 } = view;
14529 const columns = view.fields ?? [];
14530 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14531 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14532 "tr",
14533 {
14534 className: clsx_default("dataviews-view-table__row", {
14535 "is-selected": hasPossibleBulkAction && isSelected2,
14536 "has-bulk-actions": hasPossibleBulkAction
14537 }),
14538 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
14539 "aria-posinset": posinset,
14540 role: infiniteScrollEnabled ? "article" : void 0,
14541 onClickCapture,
14542 onMouseDown: (event) => {
14543 const isMetaClick = (0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey;
14544 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
14545 event.preventDefault();
14546 }
14547 onMouseDown(event);
14548 },
14549 children: [
14550 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)(
14551 DataViewsSelectionCheckbox,
14552 {
14553 item,
14554 selection,
14555 onChangeSelection,
14556 getItemId,
14557 titleField,
14558 disabled: !hasPossibleBulkAction
14559 }
14560 ) }) }),
14561 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14562 column_primary_default,
14563 {
14564 item,
14565 level,
14566 titleField: showTitle ? titleField : void 0,
14567 mediaField: showMedia ? mediaField : void 0,
14568 descriptionField: showDescription ? descriptionField : void 0,
14569 isItemClickable,
14570 onClickItem,
14571 renderItemLink
14572 }
14573 ) }),
14574 columns.map((column) => {
14575 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14576 const field = fields.find((f2) => f2.id === column);
14577 const effectiveAlign = getEffectiveAlign(align, field?.type);
14578 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14579 "td",
14580 {
14581 style: {
14582 width,
14583 maxWidth,
14584 minWidth
14585 },
14586 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14587 TableColumnField,
14588 {
14589 fields,
14590 item,
14591 column,
14592 align: effectiveAlign
14593 }
14594 )
14595 },
14596 column
14597 );
14598 }),
14599 !!actions?.length && // Disable reason: we are not making the element interactive,
14600 // but preventing any click events from bubbling up to the
14601 // table row. This allows us to add a click handler to the row
14602 // itself (to toggle row selection) without erroneously
14603 // intercepting click events from ItemActions.
14604 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14605 "td",
14606 {
14607 className: clsx_default("dataviews-view-table__actions-column", {
14608 "dataviews-view-table__actions-column--sticky": true,
14609 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
14610 }),
14611 onClick: (e2) => e2.stopPropagation(),
14612 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ItemActions, { item, actions })
14613 }
14614 )
14615 ]
14616 }
14617 );
14618 }
14619 function ViewTable({
14620 actions,
14621 data,
14622 fields,
14623 getItemId,
14624 getItemLevel,
14625 isLoading = false,
14626 onChangeView,
14627 onChangeSelection,
14628 selection,
14629 setOpenedFilter,
14630 onClickItem,
14631 isItemClickable,
14632 renderItemLink,
14633 view,
14634 className,
14635 empty
14636 }) {
14637 const { containerRef } = (0, import_element52.useContext)(dataviews_context_default);
14638 const isDelayedLoading = useDelayedLoading(isLoading);
14639 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14640 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14641 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
14642 const { getSelectionProps } = useSelectionProps({
14643 data: orderedData,
14644 actions,
14645 getItemId,
14646 selection,
14647 onChangeSelection
14648 });
14649 const headerMenuRefs = (0, import_element52.useRef)(/* @__PURE__ */ new Map());
14650 const headerMenuToFocusRef = (0, import_element52.useRef)(void 0);
14651 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element52.useState)();
14652 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element52.useState)(null);
14653 (0, import_element52.useEffect)(() => {
14654 if (headerMenuToFocusRef.current) {
14655 headerMenuToFocusRef.current.focus();
14656 headerMenuToFocusRef.current = void 0;
14657 }
14658 });
14659 const tableNoticeId = (0, import_element52.useId)();
14660 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
14661 scrollContainerRef: containerRef,
14662 enabledHorizontal: !!actions?.length
14663 });
14664 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
14665 if (nextHeaderMenuToFocus) {
14666 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14667 setNextHeaderMenuToFocus(void 0);
14668 return;
14669 }
14670 const onHide = (field) => {
14671 const hidden = headerMenuRefs.current.get(field.id);
14672 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14673 setNextHeaderMenuToFocus(fallback?.node);
14674 };
14675 const handleHeaderContextMenu = (event) => {
14676 event.preventDefault();
14677 event.stopPropagation();
14678 const virtualAnchor = {
14679 getBoundingClientRect: () => ({
14680 x: event.clientX,
14681 y: event.clientY,
14682 top: event.clientY,
14683 left: event.clientX,
14684 right: event.clientX,
14685 bottom: event.clientY,
14686 width: 0,
14687 height: 0,
14688 toJSON: () => ({})
14689 })
14690 };
14691 window.requestAnimationFrame(() => {
14692 setContextMenuAnchor(virtualAnchor);
14693 });
14694 };
14695 const hasData = !!data?.length;
14696 const titleField = fields.find((field) => field.id === view.titleField);
14697 const mediaField = fields.find((field) => field.id === view.mediaField);
14698 const descriptionField = fields.find(
14699 (field) => field.id === view.descriptionField
14700 );
14701 const { showTitle = true, showMedia = true, showDescription = true } = view;
14702 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14703 const columns = view.fields ?? [];
14704 const headerMenuRef = (column, index2) => (node) => {
14705 if (node) {
14706 headerMenuRefs.current.set(column, {
14707 node,
14708 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14709 });
14710 } else {
14711 headerMenuRefs.current.delete(column);
14712 }
14713 };
14714 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14715 const isRtl = (0, import_i18n11.isRTL)();
14716 if (!hasData) {
14717 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14718 "div",
14719 {
14720 className: clsx_default("dataviews-no-results", {
14721 "is-refreshing": isDelayedLoading
14722 }),
14723 id: tableNoticeId,
14724 children: empty
14725 }
14726 );
14727 }
14728 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
14729 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14730 "table",
14731 {
14732 className: clsx_default("dataviews-view-table", className, {
14733 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14734 view.layout.density
14735 ),
14736 "has-bulk-actions": hasBulkActions,
14737 "is-refreshing": !isInfiniteScroll && isDelayedLoading
14738 }),
14739 "aria-busy": isLoading,
14740 "aria-describedby": tableNoticeId,
14741 role: isInfiniteScroll ? "feed" : void 0,
14742 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
14743 children: [
14744 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("colgroup", { children: [
14745 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
14746 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
14747 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14748 "col",
14749 {
14750 className: clsx_default(
14751 `dataviews-view-table__col-${column}`,
14752 {
14753 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
14754 }
14755 )
14756 },
14757 `col-${column}`
14758 )),
14759 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("col", { className: "dataviews-view-table__col-actions" })
14760 ] }),
14761 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14762 import_components6.Popover,
14763 {
14764 anchor: contextMenuAnchor,
14765 onClose: () => setContextMenuAnchor(null),
14766 placement: "bottom-start",
14767 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(PropertiesSection, { showLabel: false })
14768 }
14769 ),
14770 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14771 "thead",
14772 {
14773 className: clsx_default({
14774 "dataviews-view-table__thead--stuck": isVerticallyScrolled
14775 }),
14776 onContextMenu: handleHeaderContextMenu,
14777 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("tr", { className: "dataviews-view-table__row", children: [
14778 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14779 "th",
14780 {
14781 className: "dataviews-view-table__checkbox-column",
14782 scope: "col",
14783 onContextMenu: handleHeaderContextMenu,
14784 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14785 BulkSelectionCheckbox,
14786 {
14787 selection,
14788 onChangeSelection,
14789 data,
14790 actions,
14791 getItemId
14792 }
14793 )
14794 }
14795 ),
14796 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14797 column_header_menu_default,
14798 {
14799 ref: headerMenuRef(
14800 titleField.id,
14801 0
14802 ),
14803 fieldId: titleField.id,
14804 view,
14805 fields,
14806 onChangeView,
14807 onHide,
14808 setOpenedFilter,
14809 canMove: false,
14810 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
14811 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
14812 }
14813 ) }),
14814 columns.map((column, index2) => {
14815 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14816 const field = fields.find(
14817 (f2) => f2.id === column
14818 );
14819 const effectiveAlign = getEffectiveAlign(
14820 align,
14821 field?.type
14822 );
14823 const canInsertOrMove = view.layout?.enableMoving ?? true;
14824 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14825 "th",
14826 {
14827 style: {
14828 width,
14829 maxWidth,
14830 minWidth,
14831 textAlign: effectiveAlign
14832 },
14833 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14834 scope: "col",
14835 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14836 column_header_menu_default,
14837 {
14838 ref: headerMenuRef(column, index2),
14839 fieldId: column,
14840 view,
14841 fields,
14842 onChangeView,
14843 onHide,
14844 setOpenedFilter,
14845 canMove: canInsertOrMove,
14846 canInsertLeft: canInsertOrMove,
14847 canInsertRight: canInsertOrMove
14848 }
14849 )
14850 },
14851 column
14852 );
14853 }),
14854 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14855 "th",
14856 {
14857 className: clsx_default(
14858 "dataviews-view-table__actions-column",
14859 {
14860 "dataviews-view-table__actions-column--sticky": true,
14861 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
14862 }
14863 ),
14864 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n11.__)("Actions") })
14865 }
14866 )
14867 ] })
14868 }
14869 ),
14870 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14871 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("tbody", { children: [
14872 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14873 "td",
14874 {
14875 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
14876 className: "dataviews-view-table__group-header-cell",
14877 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n11.sprintf)(
14878 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14879 (0, import_i18n11.__)("%1$s: %2$s"),
14880 groupField.label,
14881 groupName
14882 )
14883 }
14884 ) }),
14885 groupItems.map((item, index2) => {
14886 const id = getItemId(item) || index2.toString();
14887 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14888 TableRow,
14889 {
14890 item,
14891 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
14892 hasBulkActions,
14893 actions,
14894 fields,
14895 id,
14896 view,
14897 titleField,
14898 mediaField,
14899 descriptionField,
14900 selection,
14901 getItemId,
14902 onChangeSelection,
14903 ...getSelectionProps(id),
14904 onClickItem,
14905 renderItemLink,
14906 isItemClickable,
14907 isActionsColumnSticky: !isHorizontalScrollEnd
14908 },
14909 getItemId(item)
14910 );
14911 })
14912 ] }, `group-${groupName}`)
14913 ) : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("tbody", { children: hasData && data.map((item, index2) => {
14914 const id = getItemId(item) || index2.toString();
14915 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14916 TableRow,
14917 {
14918 item,
14919 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
14920 hasBulkActions,
14921 actions,
14922 fields,
14923 id,
14924 view,
14925 titleField,
14926 mediaField,
14927 descriptionField,
14928 selection,
14929 getItemId,
14930 onChangeSelection,
14931 ...getSelectionProps(id),
14932 onClickItem,
14933 renderItemLink,
14934 isItemClickable,
14935 isActionsColumnSticky: !isHorizontalScrollEnd,
14936 posinset: isInfiniteScroll ? index2 + 1 : void 0
14937 },
14938 getItemId(item)
14939 );
14940 }) })
14941 ]
14942 }
14943 ),
14944 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, {}) }) })
14945 ] });
14946 }
14947 var table_default = ViewTable;
14948
14949 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
14950 var import_components9 = __toESM(require_components(), 1);
14951 var import_i18n14 = __toESM(require_i18n(), 1);
14952
14953 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
14954 var import_components8 = __toESM(require_components(), 1);
14955 var import_i18n13 = __toESM(require_i18n(), 1);
14956 var import_compose3 = __toESM(require_compose(), 1);
14957 var import_element56 = __toESM(require_element(), 1);
14958
14959 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
14960 var import_components7 = __toESM(require_components(), 1);
14961 var import_i18n12 = __toESM(require_i18n(), 1);
14962 var import_element53 = __toESM(require_element(), 1);
14963 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
14964 var imageSizes = [
14965 {
14966 value: 120,
14967 breakpoint: 1
14968 },
14969 {
14970 value: 170,
14971 breakpoint: 1
14972 },
14973 {
14974 value: 230,
14975 breakpoint: 1
14976 },
14977 {
14978 value: 290,
14979 breakpoint: 1112
14980 // at minimum image width, 4 images display at this container size
14981 },
14982 {
14983 value: 350,
14984 breakpoint: 1636
14985 // at minimum image width, 6 images display at this container size
14986 },
14987 {
14988 value: 430,
14989 breakpoint: 588
14990 // at minimum image width, 2 images display at this container size
14991 }
14992 ];
14993 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
14994 function useGridColumns() {
14995 const context = (0, import_element53.useContext)(dataviews_context_default);
14996 const view = context.view;
14997 return (0, import_element53.useMemo)(() => {
14998 const containerWidth = context.containerWidth;
14999 const gap = 32;
15000 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
15001 const columns = Math.floor(
15002 (containerWidth + gap) / (previewSize + gap)
15003 );
15004 return Math.max(1, columns);
15005 }, [context.containerWidth, view.layout?.previewSize]);
15006 }
15007
15008 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
15009 var import_element54 = __toESM(require_element(), 1);
15010 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
15011 var GridItems = (0, import_element54.forwardRef)(({ className, previewSize, ...props }, ref) => {
15012 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
15013 "div",
15014 {
15015 ref,
15016 className: clsx_default("dataviews-view-grid-items", className),
15017 style: {
15018 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
15019 },
15020 ...props
15021 }
15022 );
15023 });
15024
15025 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
15026 var import_element55 = __toESM(require_element(), 1);
15027 function useIntersectionObserver(elementRef, posinset) {
15028 const { intersectionObserver } = (0, import_element55.useContext)(dataviews_context_default);
15029 (0, import_element55.useEffect)(() => {
15030 const element = elementRef.current;
15031 if (!element || posinset === void 0 || !intersectionObserver) {
15032 return;
15033 }
15034 intersectionObserver.observe(element);
15035 return () => {
15036 intersectionObserver.unobserve(element);
15037 };
15038 }, [elementRef, intersectionObserver, posinset]);
15039 }
15040 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
15041 const hasData = !!data?.length;
15042 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
15043 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
15044 }
15045
15046 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
15047 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
15048 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
15049 function chunk(array, size4) {
15050 const chunks = [];
15051 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
15052 chunks.push(array.slice(i2, i2 + size4));
15053 }
15054 return chunks;
15055 }
15056 var GridItem = (0, import_element56.forwardRef)(
15057 function GridItem2({
15058 view,
15059 selection,
15060 onChangeSelection,
15061 onClickItem,
15062 isItemClickable,
15063 renderItemLink,
15064 getItemId,
15065 item,
15066 actions,
15067 mediaField,
15068 titleField,
15069 descriptionField,
15070 regularFields,
15071 badgeFields,
15072 hasBulkActions,
15073 config,
15074 posinset,
15075 setsize,
15076 ...props
15077 }, forwardedRef) {
15078 const {
15079 showTitle = true,
15080 showMedia = true,
15081 showDescription = true
15082 } = view;
15083 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
15084 const id = getItemId(item);
15085 const elementRef = (0, import_element56.useRef)(null);
15086 const setRefs = (0, import_element56.useCallback)(
15087 (node) => {
15088 elementRef.current = node;
15089 if (typeof forwardedRef === "function") {
15090 forwardedRef(node);
15091 } else if (forwardedRef) {
15092 forwardedRef.current = node;
15093 }
15094 },
15095 [forwardedRef]
15096 );
15097 useIntersectionObserver(elementRef, posinset);
15098 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
15099 const isSelected2 = selection.includes(id);
15100 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
15101 const rendersMediaField = showMedia && mediaField?.render;
15102 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15103 mediaField.render,
15104 {
15105 item,
15106 field: mediaField,
15107 config
15108 }
15109 ) : mediaPlaceholder;
15110 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(titleField.render, { item, field: titleField }) : null;
15111 let mediaA11yProps;
15112 let titleA11yProps;
15113 if (isItemClickable(item) && onClickItem) {
15114 if (renderedTitleField) {
15115 mediaA11yProps = {
15116 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
15117 };
15118 titleA11yProps = {
15119 id: `dataviews-view-grid__title-field-${instanceId}`
15120 };
15121 } else {
15122 mediaA11yProps = {
15123 "aria-label": (0, import_i18n13.__)("Navigate to item")
15124 };
15125 }
15126 }
15127 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
15128 Stack,
15129 {
15130 direction: "column",
15131 ...props,
15132 ref: setRefs,
15133 "aria-setsize": setsize,
15134 "aria-posinset": posinset,
15135 className: clsx_default(
15136 props.className,
15137 "dataviews-view-grid__row__gridcell",
15138 "dataviews-view-grid__card",
15139 {
15140 "is-selected": hasBulkAction && isSelected2
15141 }
15142 ),
15143 children: [
15144 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15145 ItemClickWrapper,
15146 {
15147 item,
15148 isItemClickable,
15149 onClickItem,
15150 renderItemLink,
15151 className: clsx_default("dataviews-view-grid__media", {
15152 "dataviews-view-grid__media--placeholder": !rendersMediaField
15153 }),
15154 ...mediaA11yProps,
15155 children: renderedMediaField
15156 }
15157 ),
15158 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15159 DataViewsSelectionCheckbox,
15160 {
15161 item,
15162 selection,
15163 onChangeSelection,
15164 getItemId,
15165 titleField,
15166 disabled: !hasBulkAction
15167 }
15168 ),
15169 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15170 ItemActions,
15171 {
15172 item,
15173 actions,
15174 isCompact: true
15175 }
15176 ) }),
15177 showTitle && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15178 ItemClickWrapper,
15179 {
15180 item,
15181 isItemClickable,
15182 onClickItem,
15183 renderItemLink,
15184 className: "dataviews-view-grid__title-field dataviews-title-field",
15185 ...titleA11yProps,
15186 title: titleField?.getValueFormatted({
15187 item,
15188 field: titleField
15189 }) || void 0,
15190 children: renderedTitleField
15191 }
15192 ) }),
15193 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Stack, { direction: "column", gap: "xs", children: [
15194 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15195 descriptionField.render,
15196 {
15197 item,
15198 field: descriptionField
15199 }
15200 ),
15201 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15202 Stack,
15203 {
15204 direction: "row",
15205 className: "dataviews-view-grid__badge-fields",
15206 gap: "sm",
15207 wrap: "wrap",
15208 align: "top",
15209 justify: "flex-start",
15210 children: badgeFields.map((field) => {
15211 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15212 WCBadge,
15213 {
15214 className: "dataviews-view-grid__field-value",
15215 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15216 field.render,
15217 {
15218 item,
15219 field
15220 }
15221 )
15222 },
15223 field.id
15224 );
15225 })
15226 }
15227 ),
15228 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15229 Stack,
15230 {
15231 direction: "column",
15232 className: "dataviews-view-grid__fields",
15233 gap: "xs",
15234 children: regularFields.map((field) => {
15235 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15236 import_components8.Flex,
15237 {
15238 className: "dataviews-view-grid__field",
15239 gap: 1,
15240 justify: "flex-start",
15241 expanded: true,
15242 style: { height: "auto" },
15243 direction: "row",
15244 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
15245 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(tooltip_exports.Root, { children: [
15246 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15247 tooltip_exports.Trigger,
15248 {
15249 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
15250 }
15251 ),
15252 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(tooltip_exports.Popup, { children: field.label })
15253 ] }),
15254 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15255 import_components8.FlexItem,
15256 {
15257 className: "dataviews-view-grid__field-value",
15258 style: { maxHeight: "none" },
15259 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15260 field.render,
15261 {
15262 item,
15263 field
15264 }
15265 )
15266 }
15267 )
15268 ] })
15269 },
15270 field.id
15271 );
15272 })
15273 }
15274 )
15275 ] })
15276 ]
15277 }
15278 );
15279 }
15280 );
15281 function CompositeGrid({
15282 data,
15283 isInfiniteScroll,
15284 className,
15285 inert,
15286 isLoading,
15287 view,
15288 fields,
15289 selection,
15290 onChangeSelection,
15291 onClickItem,
15292 isItemClickable,
15293 renderItemLink,
15294 getItemId,
15295 actions,
15296 getSelectionProps
15297 }) {
15298 const { paginationInfo, resizeObserverRef } = (0, import_element56.useContext)(dataviews_context_default);
15299 const gridColumns = useGridColumns();
15300 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
15301 const titleField = fields.find(
15302 (field) => field.id === view?.titleField
15303 );
15304 const mediaField = fields.find(
15305 (field) => field.id === view?.mediaField
15306 );
15307 const descriptionField = fields.find(
15308 (field) => field.id === view?.descriptionField
15309 );
15310 const otherFields = view.fields ?? [];
15311 const { regularFields, badgeFields } = otherFields.reduce(
15312 (accumulator, fieldId) => {
15313 const field = fields.find((f2) => f2.id === fieldId);
15314 if (!field) {
15315 return accumulator;
15316 }
15317 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
15318 accumulator[key].push(field);
15319 return accumulator;
15320 },
15321 { regularFields: [], badgeFields: [] }
15322 );
15323 const size4 = "900px";
15324 const totalRows = Math.ceil(data.length / gridColumns);
15325 const placeholdersNeeded = usePlaceholdersNeeded(
15326 data,
15327 isInfiniteScroll,
15328 gridColumns
15329 );
15330 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, {
15331 // Render infinite scroll layout (no rows, feed semantics)
15332 children: [
15333 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
15334 import_components8.Composite,
15335 {
15336 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15337 GridItems,
15338 {
15339 className: clsx_default(
15340 "dataviews-view-grid-infinite-scroll",
15341 className,
15342 {
15343 [`has-${view.layout?.density}-density`]: view.layout?.density && [
15344 "compact",
15345 "comfortable"
15346 ].includes(view.layout.density)
15347 }
15348 ),
15349 previewSize: view.layout?.previewSize,
15350 "aria-busy": isLoading,
15351 ref: resizeObserverRef
15352 }
15353 ),
15354 role: "feed",
15355 focusWrap: true,
15356 inert,
15357 children: [
15358 Array.from({ length: placeholdersNeeded }).map(
15359 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15360 import_components8.Composite.Item,
15361 {
15362 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15363 Stack,
15364 {
15365 ...props,
15366 direction: "column",
15367 role: "article",
15368 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
15369 }
15370 ),
15371 "aria-hidden": true,
15372 tabIndex: -1
15373 },
15374 `placeholder-${index2}`
15375 )
15376 ),
15377 data.map((item) => {
15378 const itemId = getItemId(item);
15379 const selectionProps = getSelectionProps(itemId);
15380 const stablePosition = item.position;
15381 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15382 import_components8.Composite.Item,
15383 {
15384 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15385 GridItem,
15386 {
15387 ...props,
15388 id: itemId,
15389 role: "article",
15390 view,
15391 selection,
15392 onChangeSelection,
15393 onClickItem,
15394 isItemClickable,
15395 renderItemLink,
15396 getItemId,
15397 item,
15398 actions,
15399 onMouseDown: (event) => {
15400 props.onMouseDown?.(event);
15401 selectionProps.onMouseDown(
15402 event
15403 );
15404 },
15405 onClickCapture: (event) => {
15406 props.onClickCapture?.(event);
15407 selectionProps.onClickCapture(
15408 event
15409 );
15410 },
15411 mediaField,
15412 titleField,
15413 descriptionField,
15414 regularFields,
15415 badgeFields,
15416 hasBulkActions,
15417 posinset: stablePosition,
15418 setsize: paginationInfo.totalItems,
15419 config: {
15420 sizes: size4
15421 }
15422 }
15423 )
15424 },
15425 itemId
15426 );
15427 })
15428 ]
15429 }
15430 ),
15431 // Render standard grid layout (with rows, grid semantics)
15432 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15433 import_components8.Composite,
15434 {
15435 role: "grid",
15436 className: clsx_default("dataviews-view-grid", className, {
15437 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
15438 view.layout.density
15439 )
15440 }),
15441 focusWrap: true,
15442 "aria-busy": isLoading,
15443 "aria-rowcount": totalRows,
15444 ref: resizeObserverRef,
15445 inert,
15446 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15447 import_components8.Composite.Row,
15448 {
15449 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15450 "div",
15451 {
15452 role: "row",
15453 "aria-rowindex": i2 + 1,
15454 "aria-label": (0, import_i18n13.sprintf)(
15455 /* translators: %d: The row number in the grid */
15456 (0, import_i18n13.__)("Row %d"),
15457 i2 + 1
15458 ),
15459 className: "dataviews-view-grid__row",
15460 style: {
15461 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
15462 }
15463 }
15464 ),
15465 children: row.map((item) => {
15466 const itemId = getItemId(item);
15467 const selectionProps = getSelectionProps(itemId);
15468 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15469 import_components8.Composite.Item,
15470 {
15471 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15472 GridItem,
15473 {
15474 ...props,
15475 id: itemId,
15476 role: "gridcell",
15477 view,
15478 selection,
15479 onChangeSelection,
15480 onClickItem,
15481 isItemClickable,
15482 renderItemLink,
15483 getItemId,
15484 item,
15485 actions,
15486 onMouseDown: (event) => {
15487 props.onMouseDown?.(
15488 event
15489 );
15490 selectionProps.onMouseDown(
15491 event
15492 );
15493 },
15494 onClickCapture: (event) => {
15495 props.onClickCapture?.(
15496 event
15497 );
15498 selectionProps.onClickCapture(
15499 event
15500 );
15501 },
15502 mediaField,
15503 titleField,
15504 descriptionField,
15505 regularFields,
15506 badgeFields,
15507 hasBulkActions,
15508 config: {
15509 sizes: size4
15510 }
15511 }
15512 )
15513 },
15514 itemId
15515 );
15516 })
15517 },
15518 i2
15519 ))
15520 }
15521 )
15522 ]
15523 });
15524 }
15525
15526 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
15527 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
15528 function ViewGrid({
15529 actions,
15530 data,
15531 fields,
15532 getItemId,
15533 isLoading,
15534 onChangeSelection,
15535 onClickItem,
15536 isItemClickable,
15537 renderItemLink,
15538 selection,
15539 view,
15540 className,
15541 empty
15542 }) {
15543 const isDelayedLoading = useDelayedLoading(!!isLoading);
15544 const hasData = !!data?.length;
15545 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
15546 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
15547 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
15548 const orderedData = dataByGroup ? Array.from(dataByGroup.values()).flat() : data;
15549 const { getSelectionProps } = useSelectionProps({
15550 data: orderedData,
15551 actions,
15552 getItemId,
15553 selection,
15554 onChangeSelection
15555 });
15556 if (!hasData) {
15557 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15558 "div",
15559 {
15560 className: clsx_default("dataviews-no-results", {
15561 "is-refreshing": isDelayedLoading
15562 }),
15563 children: empty
15564 }
15565 );
15566 }
15567 const gridProps = {
15568 className: clsx_default(className, {
15569 "is-refreshing": !isInfiniteScroll && isDelayedLoading
15570 }),
15571 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
15572 isLoading,
15573 view,
15574 fields,
15575 selection,
15576 onChangeSelection,
15577 onClickItem,
15578 isItemClickable,
15579 renderItemLink,
15580 getItemId,
15581 actions,
15582 getSelectionProps
15583 };
15584 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, {
15585 // Render multiple groups.
15586 children: [
15587 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
15588 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
15589 Stack,
15590 {
15591 direction: "column",
15592 gap: "sm",
15593 children: [
15594 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
15595 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
15596 (0, import_i18n14.__)("%1$s: %2$s"),
15597 groupField.label,
15598 groupName
15599 ) }),
15600 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15601 CompositeGrid,
15602 {
15603 ...gridProps,
15604 data: groupItems,
15605 isInfiniteScroll: false
15606 }
15607 )
15608 ]
15609 },
15610 groupName
15611 )
15612 ) }),
15613 // Render a single grid with all data.
15614 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15615 CompositeGrid,
15616 {
15617 ...gridProps,
15618 data,
15619 isInfiniteScroll: !!isInfiniteScroll
15620 }
15621 ),
15622 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components9.Spinner, {}) })
15623 ]
15624 });
15625 }
15626 var grid_default = ViewGrid;
15627
15628 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
15629 var import_compose4 = __toESM(require_compose(), 1);
15630 var import_components10 = __toESM(require_components(), 1);
15631 var import_element57 = __toESM(require_element(), 1);
15632 var import_i18n15 = __toESM(require_i18n(), 1);
15633 var import_data3 = __toESM(require_data(), 1);
15634 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
15635 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
15636 function generateItemWrapperCompositeId(idPrefix) {
15637 return `${idPrefix}-item-wrapper`;
15638 }
15639 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
15640 return `${idPrefix}-primary-action-${primaryActionId}`;
15641 }
15642 function generateDropdownTriggerCompositeId(idPrefix) {
15643 return `${idPrefix}-dropdown`;
15644 }
15645 function PrimaryActionGridCell({
15646 idPrefix,
15647 primaryAction,
15648 item
15649 }) {
15650 const registry = (0, import_data3.useRegistry)();
15651 const [isModalOpen, setIsModalOpen] = (0, import_element57.useState)(false);
15652 const compositeItemId = generatePrimaryActionCompositeId(
15653 idPrefix,
15654 primaryAction.id
15655 );
15656 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
15657 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15658 import_components10.Composite.Item,
15659 {
15660 id: compositeItemId,
15661 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15662 import_components10.Button,
15663 {
15664 disabled: !!primaryAction.disabled,
15665 accessibleWhenDisabled: true,
15666 text: label,
15667 size: "small",
15668 onClick: () => setIsModalOpen(true)
15669 }
15670 ),
15671 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15672 ActionModal,
15673 {
15674 action: primaryAction,
15675 items: [item],
15676 closeModal: () => setIsModalOpen(false)
15677 }
15678 )
15679 }
15680 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15681 import_components10.Composite.Item,
15682 {
15683 id: compositeItemId,
15684 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15685 import_components10.Button,
15686 {
15687 disabled: !!primaryAction.disabled,
15688 accessibleWhenDisabled: true,
15689 size: "small",
15690 onClick: () => {
15691 primaryAction.callback([item], { registry });
15692 },
15693 children: label
15694 }
15695 )
15696 }
15697 ) }, primaryAction.id);
15698 }
15699 function ListItem({
15700 view,
15701 actions,
15702 idPrefix,
15703 isSelected: isSelected2,
15704 item,
15705 titleField,
15706 mediaField,
15707 descriptionField,
15708 onSelect,
15709 otherFields,
15710 onDropdownTriggerKeyDown,
15711 posinset
15712 }) {
15713 const {
15714 showTitle = true,
15715 showMedia = true,
15716 showDescription = true,
15717 infiniteScrollEnabled
15718 } = view;
15719 const itemRef = (0, import_element57.useRef)(null);
15720 const labelId = `${idPrefix}-label`;
15721 const descriptionId = `${idPrefix}-description`;
15722 const registry = (0, import_data3.useRegistry)();
15723 const [isHovered, setIsHovered] = (0, import_element57.useState)(false);
15724 const [activeModalAction, setActiveModalAction] = (0, import_element57.useState)(
15725 null
15726 );
15727 const handleHover = ({ type }) => {
15728 const isHover = type === "mouseenter";
15729 setIsHovered(isHover);
15730 };
15731 const { paginationInfo } = (0, import_element57.useContext)(dataviews_context_default);
15732 (0, import_element57.useEffect)(() => {
15733 if (isSelected2) {
15734 itemRef.current?.scrollIntoView({
15735 behavior: "auto",
15736 block: "nearest",
15737 inline: "nearest"
15738 });
15739 }
15740 }, [isSelected2]);
15741 const { primaryAction, eligibleActions } = (0, import_element57.useMemo)(() => {
15742 const _eligibleActions = actions.filter(
15743 (action) => !action.isEligible || action.isEligible(item)
15744 );
15745 const _primaryActions = _eligibleActions.filter(
15746 (action) => action.isPrimary
15747 );
15748 return {
15749 primaryAction: _primaryActions[0],
15750 eligibleActions: _eligibleActions
15751 };
15752 }, [actions, item]);
15753 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
15754 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)(
15755 mediaField.render,
15756 {
15757 item,
15758 field: mediaField,
15759 config: { sizes: "52px" }
15760 }
15761 ) }) : null;
15762 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(titleField.render, { item, field: titleField }) : null;
15763 const renderDescription = showDescription && descriptionField?.render;
15764 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
15765 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15766 Stack,
15767 {
15768 direction: "row",
15769 gap: "md",
15770 className: "dataviews-view-list__item-actions",
15771 children: [
15772 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15773 PrimaryActionGridCell,
15774 {
15775 idPrefix,
15776 primaryAction,
15777 item
15778 }
15779 ),
15780 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { role: "gridcell", children: [
15781 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Menu3, { placement: "bottom-end", children: [
15782 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15783 Menu3.TriggerButton,
15784 {
15785 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15786 import_components10.Composite.Item,
15787 {
15788 id: generateDropdownTriggerCompositeId(
15789 idPrefix
15790 ),
15791 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15792 import_components10.Button,
15793 {
15794 size: "small",
15795 icon: more_vertical_default,
15796 label: (0, import_i18n15.__)("Actions"),
15797 accessibleWhenDisabled: true,
15798 disabled: !actions.length,
15799 onKeyDown: onDropdownTriggerKeyDown
15800 }
15801 )
15802 }
15803 )
15804 }
15805 ),
15806 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15807 ActionsMenuGroup,
15808 {
15809 actions: eligibleActions,
15810 item,
15811 registry,
15812 setActiveModalAction
15813 }
15814 ) })
15815 ] }),
15816 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15817 ActionModal,
15818 {
15819 action: activeModalAction,
15820 items: [item],
15821 closeModal: () => setActiveModalAction(null)
15822 }
15823 )
15824 ] })
15825 ]
15826 }
15827 );
15828 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15829 import_components10.Composite.Row,
15830 {
15831 ref: itemRef,
15832 render: (
15833 /* aria-posinset breaks Composite.Row if passed to it directly. */
15834 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15835 "div",
15836 {
15837 "aria-posinset": posinset,
15838 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
15839 }
15840 )
15841 ),
15842 role: infiniteScrollEnabled ? "article" : "row",
15843 className: clsx_default({
15844 "is-selected": isSelected2,
15845 "is-hovered": isHovered
15846 }),
15847 onMouseEnter: handleHover,
15848 onMouseLeave: handleHover,
15849 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15850 Stack,
15851 {
15852 direction: "row",
15853 className: "dataviews-view-list__item-wrapper",
15854 children: [
15855 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15856 import_components10.Composite.Item,
15857 {
15858 id: generateItemWrapperCompositeId(idPrefix),
15859 "aria-pressed": isSelected2,
15860 "aria-labelledby": labelId,
15861 "aria-describedby": descriptionId,
15862 className: "dataviews-view-list__item",
15863 onClick: () => onSelect(item)
15864 }
15865 ) }),
15866 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15867 Stack,
15868 {
15869 direction: "row",
15870 gap: "md",
15871 justify: "start",
15872 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
15873 style: { flex: 1, minWidth: 0 },
15874 children: [
15875 renderedMediaField,
15876 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15877 Stack,
15878 {
15879 direction: "column",
15880 gap: "xs",
15881 className: "dataviews-view-list__field-wrapper",
15882 children: [
15883 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "row", align: "center", children: [
15884 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15885 "div",
15886 {
15887 className: "dataviews-title-field dataviews-view-list__title-field",
15888 id: labelId,
15889 children: renderedTitleField
15890 }
15891 ),
15892 usedActions
15893 ] }),
15894 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15895 descriptionField.render,
15896 {
15897 item,
15898 field: descriptionField
15899 }
15900 ) }),
15901 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15902 "div",
15903 {
15904 className: "dataviews-view-list__fields",
15905 id: descriptionId,
15906 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15907 "div",
15908 {
15909 className: "dataviews-view-list__field",
15910 children: [
15911 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15912 VisuallyHidden,
15913 {
15914 className: "dataviews-view-list__field-label",
15915 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", {}),
15916 children: field.label
15917 }
15918 ),
15919 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15920 field.render,
15921 {
15922 item,
15923 field
15924 }
15925 ) })
15926 ]
15927 },
15928 field.id
15929 ))
15930 }
15931 )
15932 ]
15933 }
15934 )
15935 ]
15936 }
15937 )
15938 ]
15939 }
15940 )
15941 }
15942 );
15943 }
15944 function isDefined2(item) {
15945 return !!item;
15946 }
15947 function ViewList(props) {
15948 const {
15949 actions,
15950 data,
15951 fields,
15952 getItemId,
15953 isLoading,
15954 onChangeSelection,
15955 selection,
15956 view,
15957 className,
15958 empty
15959 } = props;
15960 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
15961 const isDelayedLoading = useDelayedLoading(!!isLoading);
15962 const { paginationInfo } = (0, import_element57.useContext)(dataviews_context_default);
15963 const selectedItem = data?.findLast(
15964 (item) => selection.includes(getItemId(item))
15965 );
15966 const titleField = fields.find((field) => field.id === view.titleField);
15967 const mediaField = fields.find((field) => field.id === view.mediaField);
15968 const descriptionField = fields.find(
15969 (field) => field.id === view.descriptionField
15970 );
15971 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
15972 const onSelect = (item) => onChangeSelection([getItemId(item)]);
15973 const generateCompositeItemIdPrefix = (0, import_element57.useCallback)(
15974 (item) => `${baseId}-${getItemId(item)}`,
15975 [baseId, getItemId]
15976 );
15977 const isActiveCompositeItem = (0, import_element57.useCallback)(
15978 (item, idToCheck) => {
15979 return idToCheck.startsWith(
15980 generateCompositeItemIdPrefix(item)
15981 );
15982 },
15983 [generateCompositeItemIdPrefix]
15984 );
15985 const [activeCompositeId, setActiveCompositeId] = (0, import_element57.useState)(void 0);
15986 const compositeRef = (0, import_element57.useRef)(null);
15987 (0, import_element57.useEffect)(() => {
15988 if (selectedItem) {
15989 setActiveCompositeId(
15990 generateItemWrapperCompositeId(
15991 generateCompositeItemIdPrefix(selectedItem)
15992 )
15993 );
15994 }
15995 }, [selectedItem, generateCompositeItemIdPrefix]);
15996 const activeItemIndex = data.findIndex(
15997 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
15998 );
15999 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
16000 const isActiveIdInList = activeItemIndex !== -1;
16001 const selectCompositeItem = (0, import_element57.useCallback)(
16002 (targetIndex, generateCompositeId) => {
16003 const clampedIndex = Math.min(
16004 data.length - 1,
16005 Math.max(0, targetIndex)
16006 );
16007 if (!data[clampedIndex]) {
16008 return;
16009 }
16010 const itemIdPrefix = generateCompositeItemIdPrefix(
16011 data[clampedIndex]
16012 );
16013 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
16014 setActiveCompositeId(targetCompositeItemId);
16015 if (compositeRef.current?.contains(
16016 compositeRef.current.ownerDocument.activeElement
16017 )) {
16018 document.getElementById(targetCompositeItemId)?.focus();
16019 }
16020 },
16021 [data, generateCompositeItemIdPrefix]
16022 );
16023 (0, import_element57.useEffect)(() => {
16024 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
16025 if (!isActiveIdInList && wasActiveIdInList) {
16026 selectCompositeItem(
16027 previousActiveItemIndex,
16028 generateItemWrapperCompositeId
16029 );
16030 }
16031 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
16032 const onDropdownTriggerKeyDown = (0, import_element57.useCallback)(
16033 (event) => {
16034 if (event.key === "ArrowDown") {
16035 event.preventDefault();
16036 selectCompositeItem(
16037 activeItemIndex + 1,
16038 generateDropdownTriggerCompositeId
16039 );
16040 }
16041 if (event.key === "ArrowUp") {
16042 event.preventDefault();
16043 selectCompositeItem(
16044 activeItemIndex - 1,
16045 generateDropdownTriggerCompositeId
16046 );
16047 }
16048 },
16049 [selectCompositeItem, activeItemIndex]
16050 );
16051 const hasData = !!data?.length;
16052 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
16053 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
16054 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
16055 const hasMoreItems = isInfiniteScroll && (view.startPosition ?? 1) + (view.perPage ?? 0) < paginationInfo.totalItems;
16056 const listClassName = clsx_default("dataviews-view-list", className, {
16057 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(view.layout.density),
16058 "is-refreshing": !isInfiniteScroll && isDelayedLoading
16059 });
16060 const compositeProps = {
16061 ref: compositeRef,
16062 id: baseId,
16063 render: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", {}),
16064 activeId: activeCompositeId,
16065 setActiveId: setActiveCompositeId,
16066 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0
16067 };
16068 if (!hasData) {
16069 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16070 "div",
16071 {
16072 className: clsx_default("dataviews-no-results", {
16073 "is-refreshing": isDelayedLoading
16074 }),
16075 children: empty
16076 }
16077 );
16078 }
16079 if (hasData && groupField && dataByGroup) {
16080 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16081 import_components10.Composite,
16082 {
16083 ...compositeProps,
16084 className: "dataviews-view-list__group",
16085 role: "grid",
16086 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Stack, { direction: "column", gap: "lg", className: listClassName, children: Array.from(dataByGroup.entries()).map(
16087 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "column", children: [
16088 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n15.sprintf)(
16089 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
16090 (0, import_i18n15.__)("%1$s: %2$s"),
16091 groupField.label,
16092 groupName
16093 ) }),
16094 groupItems.map((item) => {
16095 const id = generateCompositeItemIdPrefix(item);
16096 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16097 ListItem,
16098 {
16099 view,
16100 idPrefix: id,
16101 actions,
16102 item,
16103 isSelected: item === selectedItem,
16104 onSelect,
16105 mediaField,
16106 titleField,
16107 descriptionField,
16108 otherFields,
16109 onDropdownTriggerKeyDown
16110 },
16111 id
16112 );
16113 })
16114 ] }, groupName)
16115 ) })
16116 }
16117 );
16118 }
16119 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { children: [
16120 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16121 import_components10.Composite,
16122 {
16123 ...compositeProps,
16124 className: listClassName,
16125 role: view.infiniteScrollEnabled ? "feed" : "grid",
16126 children: data.map((item, index2) => {
16127 const id = generateCompositeItemIdPrefix(item);
16128 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16129 ListItem,
16130 {
16131 view,
16132 idPrefix: id,
16133 actions,
16134 item,
16135 isSelected: item === selectedItem,
16136 onSelect,
16137 mediaField,
16138 titleField,
16139 descriptionField,
16140 otherFields,
16141 onDropdownTriggerKeyDown,
16142 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
16143 },
16144 id
16145 );
16146 })
16147 }
16148 ),
16149 (hasMoreItems || isInfiniteScroll && isLoading) && // Keep the spinner's height reserved while loading more so the
16150 // scroll position doesn't bounce. Hidden, and silent to a11y,
16151 // while idle.
16152 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
16153 "p",
16154 {
16155 className: "dataviews-loading-more",
16156 "aria-hidden": !isLoading,
16157 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components10.Spinner, {})
16158 }
16159 )
16160 ] });
16161 }
16162
16163 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
16164 var import_components11 = __toESM(require_components(), 1);
16165
16166 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
16167 var import_i18n16 = __toESM(require_i18n(), 1);
16168 var import_element58 = __toESM(require_element(), 1);
16169 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
16170 function ActivityGroup({
16171 groupName,
16172 groupData,
16173 groupField,
16174 showLabel = true,
16175 children
16176 }) {
16177 const groupHeader = showLabel ? (0, import_element58.createInterpolateElement)(
16178 // translators: %s: The label of the field e.g. "Status".
16179 (0, import_i18n16.sprintf)((0, import_i18n16.__)("%s: <groupName />"), groupField.label).trim(),
16180 {
16181 groupName: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
16182 groupField.render,
16183 {
16184 item: groupData[0],
16185 field: groupField
16186 }
16187 )
16188 }
16189 ) : /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(groupField.render, { item: groupData[0], field: groupField });
16190 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
16191 Stack,
16192 {
16193 direction: "column",
16194 className: "dataviews-view-activity__group",
16195 children: [
16196 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
16197 children
16198 ]
16199 },
16200 groupName
16201 );
16202 }
16203
16204 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
16205 var import_element59 = __toESM(require_element(), 1);
16206 var import_data4 = __toESM(require_data(), 1);
16207 var import_compose5 = __toESM(require_compose(), 1);
16208 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
16209 function ActivityItem(props) {
16210 const {
16211 view,
16212 actions,
16213 item,
16214 titleField,
16215 mediaField,
16216 descriptionField,
16217 otherFields,
16218 posinset,
16219 onClickItem,
16220 renderItemLink,
16221 isItemClickable
16222 } = props;
16223 const {
16224 showTitle = true,
16225 showMedia = true,
16226 showDescription = true,
16227 infiniteScrollEnabled
16228 } = view;
16229 const itemRef = (0, import_element59.useRef)(null);
16230 const registry = (0, import_data4.useRegistry)();
16231 const { paginationInfo } = (0, import_element59.useContext)(dataviews_context_default);
16232 const { primaryActions, eligibleActions } = (0, import_element59.useMemo)(() => {
16233 const _eligibleActions = actions.filter(
16234 (action) => !action.isEligible || action.isEligible(item)
16235 );
16236 const _primaryActions = _eligibleActions.filter(
16237 (action) => action.isPrimary
16238 );
16239 return {
16240 primaryActions: _primaryActions,
16241 eligibleActions: _eligibleActions
16242 };
16243 }, [actions, item]);
16244 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
16245 const density = view.layout?.density ?? "balanced";
16246 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16247 mediaField.render,
16248 {
16249 item,
16250 field: mediaField,
16251 config: {
16252 sizes: density === "comfortable" ? "32px" : "24px"
16253 }
16254 }
16255 ) : null;
16256 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16257 "span",
16258 {
16259 className: "dataviews-view-activity__item-bullet",
16260 "aria-hidden": "true"
16261 }
16262 ) });
16263 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(titleField.render, { item, field: titleField }) : null;
16264 const verticalGap = (0, import_element59.useMemo)(() => {
16265 switch (density) {
16266 case "comfortable":
16267 return "md";
16268 default:
16269 return "sm";
16270 }
16271 }, [density]);
16272 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16273 "div",
16274 {
16275 ref: itemRef,
16276 role: infiniteScrollEnabled ? "article" : void 0,
16277 "aria-posinset": posinset,
16278 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
16279 className: clsx_default(
16280 "dataviews-view-activity__item",
16281 density === "compact" && "is-compact",
16282 density === "balanced" && "is-balanced",
16283 density === "comfortable" && "is-comfortable"
16284 ),
16285 children: /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
16286 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16287 Stack,
16288 {
16289 direction: "column",
16290 gap: "xs",
16291 align: "center",
16292 className: "dataviews-view-activity__item-type",
16293 children: renderedMediaField
16294 }
16295 ),
16296 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
16297 Stack,
16298 {
16299 direction: "column",
16300 gap: verticalGap,
16301 align: "flex-start",
16302 className: "dataviews-view-activity__item-content",
16303 children: [
16304 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16305 ItemClickWrapper,
16306 {
16307 item,
16308 isItemClickable,
16309 onClickItem,
16310 renderItemLink,
16311 className: "dataviews-view-activity__item-title",
16312 children: renderedTitleField
16313 }
16314 ),
16315 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16316 descriptionField.render,
16317 {
16318 item,
16319 field: descriptionField
16320 }
16321 ) }),
16322 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
16323 "div",
16324 {
16325 className: "dataviews-view-activity__item-field",
16326 children: [
16327 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16328 VisuallyHidden,
16329 {
16330 className: "dataviews-view-activity__item-field-label",
16331 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", {}),
16332 children: field.label
16333 }
16334 ),
16335 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16336 field.render,
16337 {
16338 item,
16339 field
16340 }
16341 ) })
16342 ]
16343 },
16344 field.id
16345 )) }),
16346 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16347 PrimaryActions,
16348 {
16349 item,
16350 actions: primaryActions,
16351 registry,
16352 buttonVariant: "secondary"
16353 }
16354 )
16355 ]
16356 }
16357 ),
16358 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
16359 // there if there are any actions at all.
16360 isMobileViewport && // At the same time, only show the menu if there are actions to show.
16361 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16362 ItemActions,
16363 {
16364 item,
16365 actions: eligibleActions,
16366 isCompact: true
16367 }
16368 ) })
16369 ] })
16370 }
16371 );
16372 }
16373 var activity_item_default = ActivityItem;
16374
16375 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
16376 var import_react15 = __toESM(require_react(), 1);
16377 function isDefined3(item) {
16378 return !!item;
16379 }
16380 function ActivityItems(props) {
16381 const { data, fields, getItemId, view } = props;
16382 const titleField = fields.find((field) => field.id === view.titleField);
16383 const mediaField = fields.find((field) => field.id === view.mediaField);
16384 const descriptionField = fields.find(
16385 (field) => field.id === view.descriptionField
16386 );
16387 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
16388 return data.map((item, index2) => {
16389 return /* @__PURE__ */ (0, import_react15.createElement)(
16390 activity_item_default,
16391 {
16392 ...props,
16393 key: getItemId(item),
16394 item,
16395 mediaField,
16396 titleField,
16397 descriptionField,
16398 otherFields,
16399 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
16400 }
16401 );
16402 });
16403 }
16404
16405 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
16406 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
16407 function ViewActivity(props) {
16408 const { empty, data, fields, isLoading, view, className } = props;
16409 const isDelayedLoading = useDelayedLoading(!!isLoading);
16410 const hasData = !!data?.length;
16411 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
16412 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
16413 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
16414 if (!hasData) {
16415 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16416 "div",
16417 {
16418 className: clsx_default("dataviews-no-results", {
16419 "is-refreshing": isDelayedLoading
16420 }),
16421 children: empty
16422 }
16423 );
16424 }
16425 const isInert = !isInfiniteScroll && !!isLoading;
16426 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
16427 "is-refreshing": !isInfiniteScroll && isDelayedLoading
16428 });
16429 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
16430 if (hasData && groupField && dataByGroup) {
16431 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16432 Stack,
16433 {
16434 direction: "column",
16435 gap: "sm",
16436 className: wrapperClassName,
16437 inert: isInert ? "true" : void 0,
16438 children: groupedEntries.map(
16439 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16440 ActivityGroup,
16441 {
16442 groupName,
16443 groupData,
16444 groupField,
16445 showLabel: view.groupBy?.showLabel !== false,
16446 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16447 ActivityItems,
16448 {
16449 ...props,
16450 data: groupData
16451 }
16452 )
16453 },
16454 groupName
16455 )
16456 )
16457 }
16458 );
16459 }
16460 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(import_jsx_runtime80.Fragment, { children: [
16461 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16462 "div",
16463 {
16464 className: wrapperClassName,
16465 role: view.infiniteScrollEnabled ? "feed" : void 0,
16466 inert: isInert ? "true" : void 0,
16467 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ActivityItems, { ...props })
16468 }
16469 ),
16470 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components11.Spinner, {}) })
16471 ] });
16472 }
16473
16474 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
16475 var import_components14 = __toESM(require_components(), 1);
16476 var import_i18n19 = __toESM(require_i18n(), 1);
16477 var import_compose6 = __toESM(require_compose(), 1);
16478 var import_element62 = __toESM(require_element(), 1);
16479
16480 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
16481 var import_components13 = __toESM(require_components(), 1);
16482 var import_data5 = __toESM(require_data(), 1);
16483 var import_element61 = __toESM(require_element(), 1);
16484 var import_i18n18 = __toESM(require_i18n(), 1);
16485
16486 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
16487 var import_components12 = __toESM(require_components(), 1);
16488 var import_element60 = __toESM(require_element(), 1);
16489 var import_i18n17 = __toESM(require_i18n(), 1);
16490 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
16491 function hasPaginationControls(view, paginationInfo) {
16492 return !view.infiniteScrollEnabled && paginationInfo.totalItems > 0 && paginationInfo.totalPages > 1;
16493 }
16494 function DataViewsPagination() {
16495 const { view, onChangeView, paginationInfo } = (0, import_element60.useContext)(dataviews_context_default);
16496 if (!hasPaginationControls(view, paginationInfo)) {
16497 return null;
16498 }
16499 const { totalPages } = paginationInfo;
16500 const currentPage = view.page ?? 1;
16501 const pageSelectOptions = Array.from(Array(totalPages)).map(
16502 (_, i2) => {
16503 const page = i2 + 1;
16504 return {
16505 value: page.toString(),
16506 label: page.toString(),
16507 "aria-label": currentPage === page ? (0, import_i18n17.sprintf)(
16508 // translators: 1: current page number. 2: total number of pages.
16509 (0, import_i18n17.__)("Page %1$d of %2$d"),
16510 currentPage,
16511 totalPages
16512 ) : page.toString()
16513 };
16514 }
16515 );
16516 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
16517 Stack,
16518 {
16519 direction: "row",
16520 className: "dataviews-pagination",
16521 justify: "end",
16522 align: "center",
16523 gap: "xl",
16524 children: [
16525 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16526 Stack,
16527 {
16528 direction: "row",
16529 justify: "flex-start",
16530 align: "center",
16531 gap: "xs",
16532 className: "dataviews-pagination__page-select",
16533 children: (0, import_element60.createInterpolateElement)(
16534 (0, import_i18n17.sprintf)(
16535 // translators: 1: Current page number, 2: Total number of pages.
16536 (0, import_i18n17._x)("<div>Page</div>%1$s<div>of %2$d</div>", "paging"),
16537 "<CurrentPage />",
16538 totalPages
16539 ),
16540 {
16541 div: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { "aria-hidden": true }),
16542 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
16543 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16544 import_components12.SelectControl,
16545 {
16546 "aria-label": (0, import_i18n17.__)("Current page"),
16547 value: currentPage.toString(),
16548 options: pageSelectOptions,
16549 onChange: (newValue) => {
16550 onChangeView({
16551 ...view,
16552 page: +newValue
16553 });
16554 },
16555 size: "small",
16556 variant: "minimal"
16557 }
16558 )
16559 }
16560 )
16561 }
16562 ),
16563 /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
16564 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16565 import_components12.Button,
16566 {
16567 onClick: () => onChangeView({
16568 ...view,
16569 page: currentPage - 1
16570 }),
16571 disabled: currentPage === 1,
16572 accessibleWhenDisabled: true,
16573 label: (0, import_i18n17.__)("Previous page"),
16574 icon: (0, import_i18n17.isRTL)() ? next_default : previous_default,
16575 showTooltip: true,
16576 size: "compact",
16577 tooltipPosition: "top"
16578 }
16579 ),
16580 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16581 import_components12.Button,
16582 {
16583 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
16584 disabled: currentPage >= totalPages,
16585 accessibleWhenDisabled: true,
16586 label: (0, import_i18n17.__)("Next page"),
16587 icon: (0, import_i18n17.isRTL)() ? previous_default : next_default,
16588 showTooltip: true,
16589 size: "compact",
16590 tooltipPosition: "top"
16591 }
16592 )
16593 ] })
16594 ]
16595 }
16596 );
16597 }
16598 var dataviews_pagination_default = (0, import_element60.memo)(DataViewsPagination);
16599
16600 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
16601 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
16602 function useIsMultiselectPicker(actions) {
16603 return (0, import_element61.useMemo)(() => {
16604 return !!actions?.length && actions?.every((action) => action.supportsBulk);
16605 }, [actions]);
16606 }
16607
16608 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
16609 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
16610 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
16611 function GridItem3({
16612 view,
16613 multiselect,
16614 selection,
16615 onChangeSelection,
16616 getItemId,
16617 item,
16618 mediaField,
16619 titleField,
16620 descriptionField,
16621 regularFields,
16622 badgeFields,
16623 config,
16624 posinset,
16625 setsize
16626 }) {
16627 const { showTitle = true, showMedia = true, showDescription = true } = view;
16628 const id = getItemId(item);
16629 const elementRef = (0, import_element62.useRef)(null);
16630 const isSelected2 = selection.includes(id);
16631 useIntersectionObserver(elementRef, posinset);
16632 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16633 mediaField.render,
16634 {
16635 item,
16636 field: mediaField,
16637 config
16638 }
16639 ) : null;
16640 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(titleField.render, { item, field: titleField }) : null;
16641 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
16642 import_components14.Composite.Item,
16643 {
16644 ref: elementRef,
16645 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n19.__)("(no title)") : void 0,
16646 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Stack, { direction: "column", children, ...props }),
16647 role: "option",
16648 "aria-posinset": posinset,
16649 "aria-setsize": setsize,
16650 className: clsx_default("dataviews-view-picker-grid__card", {
16651 "is-selected": isSelected2
16652 }),
16653 "aria-selected": isSelected2,
16654 onClick: () => {
16655 if (isSelected2) {
16656 onChangeSelection(
16657 selection.filter((itemId) => id !== itemId)
16658 );
16659 } else {
16660 const newSelection = multiselect ? [...selection, id] : [id];
16661 onChangeSelection(newSelection);
16662 }
16663 },
16664 children: [
16665 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
16666 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16667 DataViewsSelectionCheckbox,
16668 {
16669 item,
16670 selection,
16671 onChangeSelection,
16672 getItemId,
16673 titleField,
16674 disabled: false,
16675 "aria-hidden": true,
16676 tabIndex: -1
16677 }
16678 ),
16679 showTitle && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16680 Stack,
16681 {
16682 direction: "row",
16683 justify: "space-between",
16684 className: "dataviews-view-picker-grid__title-actions",
16685 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
16686 }
16687 ),
16688 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Stack, { direction: "column", gap: "xs", children: [
16689 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16690 descriptionField.render,
16691 {
16692 item,
16693 field: descriptionField
16694 }
16695 ),
16696 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16697 Stack,
16698 {
16699 direction: "row",
16700 className: "dataviews-view-picker-grid__badge-fields",
16701 gap: "sm",
16702 wrap: "wrap",
16703 align: "top",
16704 justify: "flex-start",
16705 children: badgeFields.map((field) => {
16706 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16707 WCBadge2,
16708 {
16709 className: "dataviews-view-picker-grid__field-value",
16710 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16711 field.render,
16712 {
16713 item,
16714 field
16715 }
16716 )
16717 },
16718 field.id
16719 );
16720 })
16721 }
16722 ),
16723 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16724 Stack,
16725 {
16726 direction: "column",
16727 className: "dataviews-view-picker-grid__fields",
16728 gap: "xs",
16729 children: regularFields.map((field) => {
16730 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16731 import_components14.Flex,
16732 {
16733 className: "dataviews-view-picker-grid__field",
16734 gap: 1,
16735 justify: "flex-start",
16736 expanded: true,
16737 style: { height: "auto" },
16738 direction: "row",
16739 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, { children: [
16740 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
16741 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16742 import_components14.FlexItem,
16743 {
16744 className: "dataviews-view-picker-grid__field-value",
16745 style: { maxHeight: "none" },
16746 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16747 field.render,
16748 {
16749 item,
16750 field
16751 }
16752 )
16753 }
16754 )
16755 ] })
16756 },
16757 field.id
16758 );
16759 })
16760 }
16761 )
16762 ] })
16763 ]
16764 },
16765 id
16766 );
16767 }
16768 function GridGroup({
16769 groupName,
16770 groupField,
16771 showLabel = true,
16772 children
16773 }) {
16774 const headerId = (0, import_compose6.useInstanceId)(
16775 GridGroup,
16776 "dataviews-view-picker-grid-group__header"
16777 );
16778 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
16779 Stack,
16780 {
16781 direction: "column",
16782 gap: "sm",
16783 role: "group",
16784 "aria-labelledby": headerId,
16785 children: [
16786 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16787 "h3",
16788 {
16789 className: "dataviews-view-picker-grid-group__header",
16790 id: headerId,
16791 children: showLabel ? (0, import_i18n19.sprintf)(
16792 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
16793 (0, import_i18n19.__)("%1$s: %2$s"),
16794 groupField.label,
16795 groupName
16796 ) : groupName
16797 }
16798 ),
16799 children
16800 ]
16801 },
16802 groupName
16803 );
16804 }
16805 function ViewPickerGrid({
16806 actions,
16807 data,
16808 fields,
16809 getItemId,
16810 isLoading,
16811 onChangeSelection,
16812 selection,
16813 view,
16814 className,
16815 empty
16816 }) {
16817 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element62.useContext)(dataviews_context_default);
16818 const titleField = fields.find(
16819 (field) => field.id === view?.titleField
16820 );
16821 const mediaField = fields.find(
16822 (field) => field.id === view?.mediaField
16823 );
16824 const descriptionField = fields.find(
16825 (field) => field.id === view?.descriptionField
16826 );
16827 const otherFields = view.fields ?? [];
16828 const { regularFields, badgeFields } = otherFields.reduce(
16829 (accumulator, fieldId) => {
16830 const field = fields.find((f2) => f2.id === fieldId);
16831 if (!field) {
16832 return accumulator;
16833 }
16834 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
16835 accumulator[key].push(field);
16836 return accumulator;
16837 },
16838 { regularFields: [], badgeFields: [] }
16839 );
16840 const hasData = !!data?.length;
16841 const usedPreviewSize = view.layout?.previewSize;
16842 const isMultiselect = useIsMultiselectPicker(actions);
16843 const size4 = "900px";
16844 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
16845 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
16846 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
16847 const currentPage = view?.page ?? 1;
16848 const perPage = view?.perPage ?? 0;
16849 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
16850 const gridColumns = useGridColumns();
16851 const placeholdersNeeded = usePlaceholdersNeeded(
16852 data,
16853 isInfiniteScroll,
16854 gridColumns
16855 );
16856 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, {
16857 // Render multiple groups.
16858 children: [
16859 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16860 import_components14.Composite,
16861 {
16862 virtualFocus: true,
16863 orientation: "horizontal",
16864 role: "listbox",
16865 "aria-multiselectable": isMultiselect,
16866 className: clsx_default(
16867 "dataviews-view-picker-grid",
16868 className,
16869 {
16870 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
16871 view.layout.density
16872 )
16873 }
16874 ),
16875 "aria-label": itemListLabel,
16876 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16877 Stack,
16878 {
16879 direction: "column",
16880 gap: "lg",
16881 children,
16882 ...props
16883 }
16884 ),
16885 children: Array.from(dataByGroup.entries()).map(
16886 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16887 GridGroup,
16888 {
16889 groupName,
16890 groupField,
16891 showLabel: view.groupBy?.showLabel !== false,
16892 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16893 GridItems,
16894 {
16895 previewSize: usedPreviewSize,
16896 style: {
16897 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
16898 },
16899 "aria-busy": isLoading,
16900 ref: resizeObserverRef,
16901 children: groupItems.map((item) => {
16902 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
16903 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16904 GridItem3,
16905 {
16906 view,
16907 multiselect: isMultiselect,
16908 selection,
16909 onChangeSelection,
16910 getItemId,
16911 item,
16912 mediaField,
16913 titleField,
16914 descriptionField,
16915 regularFields,
16916 badgeFields,
16917 config: {
16918 sizes: size4
16919 },
16920 posinset: posInSet,
16921 setsize: setSize
16922 },
16923 getItemId(item)
16924 );
16925 })
16926 }
16927 )
16928 },
16929 groupName
16930 )
16931 )
16932 }
16933 ),
16934 // Render a single grid with all data.
16935 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
16936 import_components14.Composite,
16937 {
16938 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16939 GridItems,
16940 {
16941 className: clsx_default(
16942 "dataviews-view-picker-grid",
16943 className,
16944 {
16945 [`has-${view.layout?.density}-density`]: view.layout?.density && [
16946 "compact",
16947 "comfortable"
16948 ].includes(view.layout.density)
16949 }
16950 ),
16951 previewSize: usedPreviewSize,
16952 "aria-busy": isLoading,
16953 ref: resizeObserverRef
16954 }
16955 ),
16956 virtualFocus: true,
16957 orientation: "horizontal",
16958 role: "listbox",
16959 "aria-multiselectable": isMultiselect,
16960 "aria-label": itemListLabel,
16961 children: [
16962 Array.from({ length: placeholdersNeeded }).map(
16963 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16964 import_components14.Composite.Item,
16965 {
16966 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16967 Stack,
16968 {
16969 direction: "column",
16970 children,
16971 ...props
16972 }
16973 ),
16974 role: "option",
16975 "aria-hidden": true,
16976 tabIndex: -1,
16977 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
16978 },
16979 `placeholder-${index2}`
16980 )
16981 ),
16982 data.map((item) => {
16983 const posinset = item.position;
16984 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16985 GridItem3,
16986 {
16987 view,
16988 multiselect: isMultiselect,
16989 selection,
16990 onChangeSelection,
16991 getItemId,
16992 item,
16993 mediaField,
16994 titleField,
16995 descriptionField,
16996 regularFields,
16997 badgeFields,
16998 config: {
16999 sizes: size4
17000 },
17001 posinset,
17002 setsize: setSize
17003 },
17004 getItemId(item)
17005 );
17006 })
17007 ]
17008 }
17009 ),
17010 // Render empty state.
17011 !hasData && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
17012 "div",
17013 {
17014 className: clsx_default({
17015 "dataviews-loading": isLoading,
17016 "dataviews-no-results": !isLoading
17017 }),
17018 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components14.Spinner, {}) }) : empty
17019 }
17020 ),
17021 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components14.Spinner, {}) })
17022 ]
17023 });
17024 }
17025 var picker_grid_default = ViewPickerGrid;
17026
17027 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
17028 var import_i18n20 = __toESM(require_i18n(), 1);
17029 var import_components15 = __toESM(require_components(), 1);
17030 var import_element63 = __toESM(require_element(), 1);
17031 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
17032 function TableColumnField2({
17033 item,
17034 fields,
17035 column,
17036 align
17037 }) {
17038 const field = fields.find((f2) => f2.id === column);
17039 if (!field) {
17040 return null;
17041 }
17042 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
17043 "dataviews-view-table__cell-align-end": align === "end",
17044 "dataviews-view-table__cell-align-center": align === "center"
17045 });
17046 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(field.render, { item, field }) });
17047 }
17048 function TableRow2({
17049 item,
17050 fields,
17051 id,
17052 view,
17053 titleField,
17054 mediaField,
17055 descriptionField,
17056 selection,
17057 getItemId,
17058 onChangeSelection,
17059 multiselect,
17060 posinset
17061 }) {
17062 const { paginationInfo } = (0, import_element63.useContext)(dataviews_context_default);
17063 const isSelected2 = selection.includes(id);
17064 const [isHovered, setIsHovered] = (0, import_element63.useState)(false);
17065 const elementRef = (0, import_element63.useRef)(null);
17066 useIntersectionObserver(elementRef, posinset);
17067 const {
17068 showTitle = true,
17069 showMedia = true,
17070 showDescription = true,
17071 infiniteScrollEnabled
17072 } = view;
17073 const handleMouseEnter = () => {
17074 setIsHovered(true);
17075 };
17076 const handleMouseLeave = () => {
17077 setIsHovered(false);
17078 };
17079 const columns = view.fields ?? [];
17080 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
17081 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
17082 import_components15.Composite.Item,
17083 {
17084 ref: elementRef,
17085 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17086 "tr",
17087 {
17088 className: clsx_default("dataviews-view-table__row", {
17089 "is-selected": isSelected2,
17090 "is-hovered": isHovered
17091 }),
17092 onMouseEnter: handleMouseEnter,
17093 onMouseLeave: handleMouseLeave,
17094 children,
17095 ...props
17096 }
17097 ),
17098 "aria-selected": isSelected2,
17099 "aria-setsize": paginationInfo.totalItems || void 0,
17100 "aria-posinset": posinset,
17101 role: infiniteScrollEnabled ? "article" : "option",
17102 onMouseDown: (event) => {
17103 if (event.button !== 0) {
17104 return;
17105 }
17106 event.currentTarget.parentElement?.focus({
17107 preventScroll: true
17108 });
17109 },
17110 onClick: () => {
17111 if (isSelected2) {
17112 onChangeSelection(
17113 selection.filter((itemId) => id !== itemId)
17114 );
17115 } else {
17116 const newSelection = multiselect ? [...selection, id] : [id];
17117 onChangeSelection(newSelection);
17118 }
17119 },
17120 children: [
17121 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17122 "td",
17123 {
17124 className: "dataviews-view-table__checkbox-column",
17125 role: "presentation",
17126 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17127 DataViewsSelectionCheckbox,
17128 {
17129 item,
17130 selection,
17131 onChangeSelection,
17132 getItemId,
17133 titleField,
17134 disabled: false,
17135 "aria-hidden": true,
17136 tabIndex: -1
17137 }
17138 ) })
17139 }
17140 ),
17141 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17142 "td",
17143 {
17144 role: "presentation",
17145 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17146 column_primary_default,
17147 {
17148 item,
17149 titleField: showTitle ? titleField : void 0,
17150 mediaField: showMedia ? mediaField : void 0,
17151 descriptionField: showDescription ? descriptionField : void 0,
17152 isItemClickable: () => false
17153 }
17154 )
17155 }
17156 ),
17157 columns.map((column) => {
17158 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
17159 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17160 "td",
17161 {
17162 style: {
17163 width,
17164 maxWidth,
17165 minWidth
17166 },
17167 role: "presentation",
17168 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17169 TableColumnField2,
17170 {
17171 fields,
17172 item,
17173 column,
17174 align
17175 }
17176 )
17177 },
17178 column
17179 );
17180 })
17181 ]
17182 },
17183 id
17184 );
17185 }
17186 function ViewPickerTable({
17187 actions,
17188 data,
17189 fields,
17190 getItemId,
17191 isLoading = false,
17192 onChangeView,
17193 onChangeSelection,
17194 selection,
17195 setOpenedFilter,
17196 view,
17197 className,
17198 empty
17199 }) {
17200 const headerMenuRefs = (0, import_element63.useRef)(/* @__PURE__ */ new Map());
17201 const headerMenuToFocusRef = (0, import_element63.useRef)(void 0);
17202 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element63.useState)();
17203 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
17204 (0, import_element63.useEffect)(() => {
17205 if (headerMenuToFocusRef.current) {
17206 headerMenuToFocusRef.current.focus();
17207 headerMenuToFocusRef.current = void 0;
17208 }
17209 });
17210 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
17211 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
17212 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
17213 const tableNoticeId = (0, import_element63.useId)();
17214 if (nextHeaderMenuToFocus) {
17215 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
17216 setNextHeaderMenuToFocus(void 0);
17217 return;
17218 }
17219 const onHide = (field) => {
17220 const hidden = headerMenuRefs.current.get(field.id);
17221 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
17222 setNextHeaderMenuToFocus(fallback?.node);
17223 };
17224 const hasData = !!data?.length;
17225 const titleField = fields.find((field) => field.id === view.titleField);
17226 const mediaField = fields.find((field) => field.id === view.mediaField);
17227 const descriptionField = fields.find(
17228 (field) => field.id === view.descriptionField
17229 );
17230 const { showTitle = true, showMedia = true, showDescription = true } = view;
17231 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
17232 const columns = view.fields ?? [];
17233 const headerMenuRef = (column, index2) => (node) => {
17234 if (node) {
17235 headerMenuRefs.current.set(column, {
17236 node,
17237 fallback: columns[index2 > 0 ? index2 - 1 : 1]
17238 });
17239 } else {
17240 headerMenuRefs.current.delete(column);
17241 }
17242 };
17243 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_jsx_runtime84.Fragment, { children: [
17244 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
17245 "table",
17246 {
17247 className: clsx_default(
17248 "dataviews-view-table",
17249 "dataviews-view-picker-table",
17250 className,
17251 {
17252 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
17253 view.layout.density
17254 )
17255 }
17256 ),
17257 "aria-busy": isLoading,
17258 "aria-describedby": tableNoticeId,
17259 role: isInfiniteScroll ? "feed" : "listbox",
17260 children: [
17261 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
17262 "tr",
17263 {
17264 className: "dataviews-view-table__row",
17265 role: "presentation",
17266 children: [
17267 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17268 BulkSelectionCheckbox,
17269 {
17270 selection,
17271 onChangeSelection,
17272 data,
17273 actions,
17274 getItemId,
17275 disableSelectAll: isInfiniteScroll
17276 }
17277 ) }),
17278 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17279 column_header_menu_default,
17280 {
17281 ref: headerMenuRef(
17282 titleField.id,
17283 0
17284 ),
17285 fieldId: titleField.id,
17286 view,
17287 fields,
17288 onChangeView,
17289 onHide,
17290 setOpenedFilter,
17291 canMove: false
17292 }
17293 ) }),
17294 columns.map((column, index2) => {
17295 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
17296 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17297 "th",
17298 {
17299 style: {
17300 width,
17301 maxWidth,
17302 minWidth,
17303 textAlign: align
17304 },
17305 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
17306 scope: "col",
17307 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17308 column_header_menu_default,
17309 {
17310 ref: headerMenuRef(column, index2),
17311 fieldId: column,
17312 view,
17313 fields,
17314 onChangeView,
17315 onHide,
17316 setOpenedFilter,
17317 canMove: view.layout?.enableMoving ?? true
17318 }
17319 )
17320 },
17321 column
17322 );
17323 })
17324 ]
17325 }
17326 ) }),
17327 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
17328 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
17329 import_components15.Composite,
17330 {
17331 virtualFocus: true,
17332 orientation: "vertical",
17333 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("tbody", { role: "group" }),
17334 children: [
17335 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17336 "tr",
17337 {
17338 className: "dataviews-view-table__group-header-row",
17339 role: "presentation",
17340 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17341 "td",
17342 {
17343 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
17344 className: "dataviews-view-table__group-header-cell",
17345 role: "presentation",
17346 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n20.sprintf)(
17347 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
17348 (0, import_i18n20.__)("%1$s: %2$s"),
17349 groupField.label,
17350 groupName
17351 )
17352 }
17353 )
17354 }
17355 ),
17356 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17357 TableRow2,
17358 {
17359 item,
17360 fields,
17361 id: getItemId(item) || index2.toString(),
17362 view,
17363 titleField,
17364 mediaField,
17365 descriptionField,
17366 selection,
17367 getItemId,
17368 onChangeSelection,
17369 multiselect: isMultiselect
17370 },
17371 getItemId(item)
17372 ))
17373 ]
17374 },
17375 `group-${groupName}`
17376 )
17377 ) : /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17378 import_components15.Composite,
17379 {
17380 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("tbody", { role: "presentation" }),
17381 virtualFocus: true,
17382 orientation: "vertical",
17383 children: hasData && data.map((item, index2) => {
17384 const itemId = getItemId(item);
17385 const posinset = item.position;
17386 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
17387 TableRow2,
17388 {
17389 item,
17390 fields,
17391 id: itemId || index2.toString(),
17392 view,
17393 titleField,
17394 mediaField,
17395 descriptionField,
17396 selection,
17397 getItemId,
17398 onChangeSelection,
17399 multiselect: isMultiselect,
17400 posinset
17401 },
17402 itemId
17403 );
17404 })
17405 }
17406 )
17407 ]
17408 }
17409 ),
17410 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
17411 "div",
17412 {
17413 className: clsx_default({
17414 "dataviews-loading": isLoading,
17415 "dataviews-no-results": !hasData && !isLoading
17416 }),
17417 id: tableNoticeId,
17418 children: [
17419 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_components15.Spinner, {}) }) : empty),
17420 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_components15.Spinner, {}) })
17421 ]
17422 }
17423 )
17424 ] });
17425 }
17426 var picker_table_default = ViewPickerTable;
17427
17428 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
17429 var import_components16 = __toESM(require_components(), 1);
17430 var import_element64 = __toESM(require_element(), 1);
17431 var import_compose7 = __toESM(require_compose(), 1);
17432 var import_i18n21 = __toESM(require_i18n(), 1);
17433 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
17434 function isDefined4(item) {
17435 return !!item;
17436 }
17437 function PickerActivityItem({
17438 view,
17439 multiselect,
17440 selection,
17441 onChangeSelection,
17442 getItemId,
17443 item,
17444 titleField,
17445 mediaField,
17446 descriptionField,
17447 otherFields,
17448 posinset,
17449 setsize
17450 }) {
17451 const elementRef = (0, import_element64.useRef)(null);
17452 useIntersectionObserver(elementRef, posinset);
17453 const { showTitle = true, showMedia = true, showDescription = true } = view;
17454 const id = getItemId(item);
17455 const isSelected2 = selection.includes(id);
17456 const density = view.layout?.density ?? "balanced";
17457 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17458 mediaField.render,
17459 {
17460 item,
17461 field: mediaField,
17462 config: {
17463 sizes: density === "comfortable" ? "32px" : "24px"
17464 }
17465 }
17466 ) : null;
17467 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)(
17468 "span",
17469 {
17470 className: "dataviews-view-picker-activity__item-bullet",
17471 "aria-hidden": "true"
17472 }
17473 ) });
17474 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(titleField.render, { item, field: titleField }) : null;
17475 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
17476 const verticalGap = (0, import_element64.useMemo)(() => {
17477 switch (density) {
17478 case "comfortable":
17479 return "md";
17480 default:
17481 return "sm";
17482 }
17483 }, [density]);
17484 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17485 import_components16.Composite.Item,
17486 {
17487 ref: elementRef,
17488 role: "option",
17489 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
17490 "aria-posinset": posinset,
17491 "aria-setsize": setsize,
17492 "aria-selected": isSelected2,
17493 className: clsx_default(
17494 "dataviews-view-picker-activity__item",
17495 density === "compact" && "is-compact",
17496 density === "balanced" && "is-balanced",
17497 density === "comfortable" && "is-comfortable",
17498 isSelected2 && "is-selected"
17499 ),
17500 onClick: () => {
17501 if (isSelected2) {
17502 onChangeSelection(
17503 selection.filter((itemId) => id !== itemId)
17504 );
17505 } else {
17506 const newSelection = multiselect ? [...selection, id] : [id];
17507 onChangeSelection(newSelection);
17508 }
17509 },
17510 render: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", {}),
17511 children: /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
17512 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17513 Stack,
17514 {
17515 direction: "column",
17516 gap: "xs",
17517 align: "center",
17518 className: "dataviews-view-picker-activity__item-type",
17519 children: renderedMediaField
17520 }
17521 ),
17522 /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
17523 Stack,
17524 {
17525 direction: "column",
17526 gap: verticalGap,
17527 align: "flex-start",
17528 className: "dataviews-view-picker-activity__item-content",
17529 children: [
17530 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
17531 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
17532 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
17533 "div",
17534 {
17535 className: "dataviews-view-picker-activity__item-field",
17536 children: [
17537 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17538 VisuallyHidden,
17539 {
17540 render: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", {}),
17541 className: "dataviews-view-picker-activity__item-field-label",
17542 children: field.label
17543 }
17544 ),
17545 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17546 field.render,
17547 {
17548 item,
17549 field
17550 }
17551 ) })
17552 ]
17553 },
17554 field.id
17555 )) })
17556 ]
17557 }
17558 )
17559 ] })
17560 }
17561 );
17562 }
17563 function PickerActivityGroup({
17564 groupName,
17565 groupField,
17566 showLabel = true,
17567 children
17568 }) {
17569 const headerId = (0, import_compose7.useInstanceId)(
17570 PickerActivityGroup,
17571 "dataviews-view-picker-activity-group__header"
17572 );
17573 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
17574 Stack,
17575 {
17576 direction: "column",
17577 role: "group",
17578 "aria-labelledby": headerId,
17579 className: "dataviews-view-picker-activity-group",
17580 children: [
17581 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17582 "h3",
17583 {
17584 className: "dataviews-view-picker-activity-group__header",
17585 id: headerId,
17586 children: showLabel ? (0, import_i18n21.sprintf)(
17587 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
17588 (0, import_i18n21.__)("%1$s: %2$s"),
17589 groupField.label,
17590 groupName
17591 ) : groupName
17592 }
17593 ),
17594 children
17595 ]
17596 }
17597 );
17598 }
17599 function ViewPickerActivity({
17600 data,
17601 fields,
17602 getItemId,
17603 isLoading,
17604 onChangeSelection,
17605 selection,
17606 view,
17607 actions,
17608 className,
17609 empty
17610 }) {
17611 const { itemListLabel, paginationInfo } = (0, import_element64.useContext)(dataviews_context_default);
17612 const isMultiselect = useIsMultiselectPicker(actions);
17613 const titleField = fields.find(
17614 (field) => field.id === view?.titleField
17615 );
17616 const mediaField = fields.find(
17617 (field) => field.id === view?.mediaField
17618 );
17619 const descriptionField = fields.find(
17620 (field) => field.id === view?.descriptionField
17621 );
17622 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
17623 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
17624 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
17625 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
17626 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
17627 const hasData = !!data?.length;
17628 const isGrouped = !!(groupField && dataByGroup);
17629 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17630 PickerActivityItem,
17631 {
17632 view,
17633 multiselect: isMultiselect,
17634 selection,
17635 onChangeSelection,
17636 getItemId,
17637 item,
17638 titleField,
17639 mediaField,
17640 descriptionField,
17641 otherFields,
17642 posinset: item.position,
17643 setsize
17644 },
17645 getItemId(item)
17646 );
17647 if (!hasData) {
17648 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17649 "div",
17650 {
17651 className: clsx_default({
17652 "dataviews-loading": isLoading,
17653 "dataviews-no-results": !isLoading
17654 }),
17655 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_components16.Spinner, {}) }) : empty
17656 }
17657 );
17658 }
17659 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_jsx_runtime85.Fragment, { children: [
17660 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17661 import_components16.Composite,
17662 {
17663 virtualFocus: true,
17664 orientation: "vertical",
17665 role: "listbox",
17666 "aria-multiselectable": isMultiselect,
17667 "aria-label": itemListLabel,
17668 "aria-busy": isLoading,
17669 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
17670 className: clsx_default(
17671 "dataviews-view-picker-activity",
17672 className
17673 ),
17674 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
17675 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
17676 PickerActivityGroup,
17677 {
17678 groupName,
17679 groupField,
17680 showLabel: view.groupBy?.showLabel !== false,
17681 children: groupItems.map(renderItem)
17682 },
17683 groupName
17684 )
17685 ) : data.map(renderItem)
17686 }
17687 ),
17688 isLoading && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_components16.Spinner, {}) })
17689 ] });
17690 }
17691
17692 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
17693 var import_components17 = __toESM(require_components(), 1);
17694 var import_i18n22 = __toESM(require_i18n(), 1);
17695 var import_element65 = __toESM(require_element(), 1);
17696 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
17697 function DensityPicker() {
17698 const context = (0, import_element65.useContext)(dataviews_context_default);
17699 const view = context.view;
17700 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
17701 import_components17.__experimentalToggleGroupControl,
17702 {
17703 label: (0, import_i18n22.__)("Density"),
17704 value: view.layout?.density || "balanced",
17705 onChange: (value) => {
17706 context.onChangeView({
17707 ...view,
17708 layout: {
17709 ...view.layout,
17710 density: value
17711 }
17712 });
17713 },
17714 isBlock: true,
17715 children: [
17716 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
17717 import_components17.__experimentalToggleGroupControlOption,
17718 {
17719 value: "comfortable",
17720 label: (0, import_i18n22._x)(
17721 "Comfortable",
17722 "Density option for DataView layout"
17723 )
17724 },
17725 "comfortable"
17726 ),
17727 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
17728 import_components17.__experimentalToggleGroupControlOption,
17729 {
17730 value: "balanced",
17731 label: (0, import_i18n22._x)("Balanced", "Density option for DataView layout")
17732 },
17733 "balanced"
17734 ),
17735 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
17736 import_components17.__experimentalToggleGroupControlOption,
17737 {
17738 value: "compact",
17739 label: (0, import_i18n22._x)("Compact", "Density option for DataView layout")
17740 },
17741 "compact"
17742 )
17743 ]
17744 }
17745 );
17746 }
17747
17748 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
17749 var import_components18 = __toESM(require_components(), 1);
17750 var import_i18n23 = __toESM(require_i18n(), 1);
17751 var import_element66 = __toESM(require_element(), 1);
17752 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
17753 var imageSizes2 = [
17754 {
17755 value: 120,
17756 breakpoint: 1
17757 },
17758 {
17759 value: 170,
17760 breakpoint: 1
17761 },
17762 {
17763 value: 230,
17764 breakpoint: 1
17765 },
17766 {
17767 value: 290,
17768 breakpoint: 1112
17769 // at minimum image width, 4 images display at this container size
17770 },
17771 {
17772 value: 350,
17773 breakpoint: 1636
17774 // at minimum image width, 6 images display at this container size
17775 },
17776 {
17777 value: 430,
17778 breakpoint: 588
17779 // at minimum image width, 2 images display at this container size
17780 }
17781 ];
17782 function PreviewSizePicker() {
17783 const context = (0, import_element66.useContext)(dataviews_context_default);
17784 const view = context.view;
17785 const breakValues = imageSizes2.filter((size4) => {
17786 return context.containerWidth >= size4.breakpoint;
17787 });
17788 const layoutPreviewSize = view.layout?.previewSize ?? 230;
17789 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
17790 const marks = breakValues.map((size4, index2) => {
17791 return {
17792 value: index2
17793 };
17794 });
17795 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
17796 import_components18.RangeControl,
17797 {
17798 showTooltip: false,
17799 label: (0, import_i18n23.__)("Preview size"),
17800 value: previewSizeToUse,
17801 min: 0,
17802 max: breakValues.length - 1,
17803 withInputField: false,
17804 onChange: (value = 0) => {
17805 context.onChangeView({
17806 ...view,
17807 layout: {
17808 ...view.layout,
17809 previewSize: breakValues[value].value
17810 }
17811 });
17812 },
17813 step: 1,
17814 marks
17815 }
17816 );
17817 }
17818
17819 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
17820 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
17821 function GridConfigOptions() {
17822 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [
17823 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(DensityPicker, {}),
17824 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(PreviewSizePicker, {})
17825 ] });
17826 }
17827
17828 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
17829 var VIEW_LAYOUTS = [
17830 {
17831 type: LAYOUT_TABLE,
17832 label: (0, import_i18n24.__)("Table"),
17833 component: table_default,
17834 icon: block_table_default,
17835 viewConfigOptions: DensityPicker
17836 },
17837 {
17838 type: LAYOUT_GRID,
17839 label: (0, import_i18n24.__)("Grid"),
17840 component: grid_default,
17841 icon: category_default,
17842 viewConfigOptions: GridConfigOptions
17843 },
17844 {
17845 type: LAYOUT_LIST,
17846 label: (0, import_i18n24.__)("List"),
17847 component: ViewList,
17848 icon: (0, import_i18n24.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
17849 viewConfigOptions: DensityPicker
17850 },
17851 {
17852 type: LAYOUT_ACTIVITY,
17853 label: (0, import_i18n24.__)("Activity"),
17854 component: ViewActivity,
17855 icon: scheduled_default,
17856 viewConfigOptions: DensityPicker
17857 },
17858 {
17859 type: LAYOUT_PICKER_GRID,
17860 label: (0, import_i18n24.__)("Grid"),
17861 component: picker_grid_default,
17862 icon: category_default,
17863 viewConfigOptions: GridConfigOptions,
17864 isPicker: true
17865 },
17866 {
17867 type: LAYOUT_PICKER_TABLE,
17868 label: (0, import_i18n24.__)("Table"),
17869 component: picker_table_default,
17870 icon: block_table_default,
17871 viewConfigOptions: DensityPicker,
17872 isPicker: true
17873 },
17874 {
17875 type: LAYOUT_PICKER_ACTIVITY,
17876 label: (0, import_i18n24.__)("Activity"),
17877 component: ViewPickerActivity,
17878 icon: scheduled_default,
17879 viewConfigOptions: DensityPicker,
17880 isPicker: true
17881 }
17882 ];
17883
17884 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
17885 var import_element74 = __toESM(require_element(), 1);
17886
17887 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
17888 var import_components21 = __toESM(require_components(), 1);
17889 var import_i18n27 = __toESM(require_i18n(), 1);
17890 var import_element71 = __toESM(require_element(), 1);
17891
17892 // node_modules/@ariakit/react-components/dist/focusable/focusable-context.js
17893 var import_react16 = __toESM(require_react(), 1);
17894 var FocusableContext = (0, import_react16.createContext)(true);
17895
17896 // node_modules/@ariakit/utils/dist/index.js
17897 function toArray(arg) {
17898 if (Array.isArray(arg)) return arg;
17899 return typeof arg !== "undefined" ? [arg] : [];
17900 }
17901 function flatten2DArray(array) {
17902 const flattened = [];
17903 for (const row of array) flattened.push(...row);
17904 return flattened;
17905 }
17906 function reverseArray(array) {
17907 return array.slice().reverse();
17908 }
17909 function noop4(..._) {
17910 }
17911 function hasOwnProperty(object, prop) {
17912 if (typeof Object.hasOwn === "function") return Object.hasOwn(object, prop);
17913 return Object.prototype.hasOwnProperty.call(object, prop);
17914 }
17915 function chain(...fns) {
17916 return (...args) => {
17917 for (const fn of fns) if (typeof fn === "function") fn(...args);
17918 };
17919 }
17920 function normalizeString(str) {
17921 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
17922 }
17923 function omit(object, keys) {
17924 const result = { ...object };
17925 for (const key of keys) if (hasOwnProperty(result, key)) delete result[key];
17926 return result;
17927 }
17928 function pick(object, paths) {
17929 const result = {};
17930 for (const key of paths) if (hasOwnProperty(object, key)) result[key] = object[key];
17931 return result;
17932 }
17933 function identity(value) {
17934 return value;
17935 }
17936 function afterPaint(cb = noop4) {
17937 let raf = requestAnimationFrame(() => {
17938 raf = requestAnimationFrame(cb);
17939 });
17940 return () => cancelAnimationFrame(raf);
17941 }
17942 function invariant(condition, message2) {
17943 if (condition) return;
17944 if (typeof message2 !== "string") throw new Error("Invariant failed");
17945 throw new Error(message2);
17946 }
17947 function getKeys(obj) {
17948 return Object.keys(obj);
17949 }
17950 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
17951 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
17952 if (result == null) return false;
17953 return !result;
17954 }
17955 function disabledFromProps(props) {
17956 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
17957 }
17958 function removeUndefinedValues(obj) {
17959 const result = {};
17960 for (const key in obj) if (obj[key] !== void 0) result[key] = obj[key];
17961 return result;
17962 }
17963 function defaultValue(...values) {
17964 for (const value of values) if (value !== void 0) return value;
17965 }
17966 var canUseDOM = checkIsBrowser();
17967 function checkIsBrowser() {
17968 return typeof window !== "undefined" && !!window.document?.createElement;
17969 }
17970 function getDocument(node) {
17971 if (!node) return document;
17972 if ("self" in node) return node.document;
17973 return node.ownerDocument || document;
17974 }
17975 function getActiveElement(node, activeDescendant = false) {
17976 const { activeElement: activeElement2 } = getDocument(node);
17977 if (!activeElement2?.nodeName) return null;
17978 if (isFrame(activeElement2) && activeElement2.contentDocument?.body) return getActiveElement(activeElement2.contentDocument.body, activeDescendant);
17979 if (activeDescendant) {
17980 const id = activeElement2.getAttribute("aria-activedescendant");
17981 if (id) {
17982 const element = getDocument(activeElement2).getElementById(id);
17983 if (element) return element;
17984 }
17985 }
17986 return activeElement2;
17987 }
17988 function contains2(parent, child) {
17989 return parent === child || parent.contains(child);
17990 }
17991 function isElement2(target) {
17992 return target?.nodeType === 1;
17993 }
17994 function isNode2(target) {
17995 return typeof target?.nodeType === "number";
17996 }
17997 function isFrame(element) {
17998 return element.tagName === "IFRAME";
17999 }
18000 function isButton(element) {
18001 const tagName = element.tagName.toLowerCase();
18002 if (tagName === "button") return true;
18003 if (tagName === "input" && element.type) return buttonInputTypes.indexOf(element.type) !== -1;
18004 return false;
18005 }
18006 var buttonInputTypes = [
18007 "button",
18008 "color",
18009 "file",
18010 "image",
18011 "reset",
18012 "submit"
18013 ];
18014 function isVisible(element) {
18015 if (typeof element.checkVisibility === "function") return element.checkVisibility();
18016 const htmlElement = element;
18017 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
18018 }
18019 function isTextField(element) {
18020 try {
18021 if (element.tagName === "TEXTAREA") return true;
18022 if (element.tagName !== "INPUT") return false;
18023 return element.selectionStart !== null;
18024 } catch (_error) {
18025 return false;
18026 }
18027 }
18028 function isTextbox(element) {
18029 return element.isContentEditable || isTextField(element);
18030 }
18031 function getTextboxValue(element) {
18032 if (isTextField(element)) return element.value;
18033 if (element.isContentEditable) {
18034 const range = getDocument(element).createRange();
18035 range.selectNodeContents(element);
18036 return range.toString();
18037 }
18038 return "";
18039 }
18040 function getTextboxSelection(element) {
18041 let start = 0;
18042 let end = 0;
18043 if (isTextField(element)) {
18044 start = element.selectionStart || 0;
18045 end = element.selectionEnd || 0;
18046 } else if (element.isContentEditable) {
18047 const selection = getDocument(element).getSelection();
18048 if (selection?.rangeCount && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
18049 const range = selection.getRangeAt(0);
18050 const nextRange = range.cloneRange();
18051 nextRange.selectNodeContents(element);
18052 nextRange.setEnd(range.startContainer, range.startOffset);
18053 start = nextRange.toString().length;
18054 nextRange.setEnd(range.endContainer, range.endOffset);
18055 end = nextRange.toString().length;
18056 }
18057 }
18058 return {
18059 start,
18060 end
18061 };
18062 }
18063 var allowedPopupRoles = [
18064 "dialog",
18065 "menu",
18066 "listbox",
18067 "tree",
18068 "grid"
18069 ];
18070 var itemRoleByPopupRole = {
18071 menu: "menuitem",
18072 listbox: "option",
18073 tree: "treeitem"
18074 };
18075 function getPopupRole(element, fallback) {
18076 const role = element?.getAttribute("role");
18077 if (role && allowedPopupRoles.indexOf(role) !== -1) return role;
18078 return fallback;
18079 }
18080 function getItemRoleByPopupRole(popupRole) {
18081 if (popupRole == null) return;
18082 if (!hasOwnProperty(itemRoleByPopupRole, popupRole)) return;
18083 return itemRoleByPopupRole[popupRole];
18084 }
18085 function getScrollingElement(element) {
18086 if (!element) return null;
18087 const isScrollableOverflow = (overflow) => {
18088 if (overflow === "auto") return true;
18089 if (overflow === "scroll") return true;
18090 return false;
18091 };
18092 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
18093 const { overflowY } = getComputedStyle(element);
18094 if (isScrollableOverflow(overflowY)) return element;
18095 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
18096 const { overflowX } = getComputedStyle(element);
18097 if (isScrollableOverflow(overflowX)) return element;
18098 }
18099 const doc = getDocument(element);
18100 return getScrollingElement(element.parentElement) || doc.scrollingElement || doc.body;
18101 }
18102 function setSelectionRange(element, ...args) {
18103 if (/text|search|password|tel|url/i.test(element.type)) element.setSelectionRange(...args);
18104 }
18105 function sortBasedOnDOMPosition(items, getElement) {
18106 const pairs = items.map((item, index2) => [index2, item]);
18107 let isOrderDifferent = false;
18108 pairs.sort(([indexA, a2], [indexB, b2]) => {
18109 const elementA = getElement(a2);
18110 const elementB = getElement(b2);
18111 if (elementA === elementB) return 0;
18112 if (!elementA || !elementB) return 0;
18113 if (isElementPreceding(elementA, elementB)) {
18114 if (indexA > indexB) isOrderDifferent = true;
18115 return -1;
18116 }
18117 if (indexA < indexB) isOrderDifferent = true;
18118 return 1;
18119 });
18120 if (isOrderDifferent) return pairs.map(([_, item]) => item);
18121 return items;
18122 }
18123 function isElementPreceding(a2, b2) {
18124 return Boolean(b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING);
18125 }
18126 function isTouchDevice() {
18127 return canUseDOM && !!navigator.maxTouchPoints;
18128 }
18129 function isApple() {
18130 if (!canUseDOM) return false;
18131 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
18132 }
18133 function isSafari() {
18134 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
18135 }
18136 function isFirefox() {
18137 return canUseDOM && /firefox\//i.test(navigator.userAgent);
18138 }
18139 function isPortalEvent(event) {
18140 const { currentTarget, target } = event;
18141 if (!currentTarget) return false;
18142 if (!isNode2(target)) return true;
18143 return !contains2(currentTarget, target);
18144 }
18145 function isSelfTarget(event) {
18146 return event.target === event.currentTarget;
18147 }
18148 function isActivatableNavigationTarget(element) {
18149 if (!isElement2(element)) return false;
18150 const target = element;
18151 const tagName = target.tagName.toLowerCase();
18152 if (tagName === "a") return true;
18153 if (tagName === "button" && target.type === "submit") return true;
18154 if (tagName === "input" && target.type === "submit") return true;
18155 return false;
18156 }
18157 function isOpeningInNewTab(event) {
18158 const isAppleDevice = isApple();
18159 if (isAppleDevice && !event.metaKey) return false;
18160 if (!isAppleDevice && !event.ctrlKey) return false;
18161 return isActivatableNavigationTarget(event.currentTarget);
18162 }
18163 function isDownloading(event) {
18164 if (!event.altKey) return false;
18165 return isActivatableNavigationTarget(event.currentTarget);
18166 }
18167 function fireBlurEvent(element, eventInit) {
18168 const event = new FocusEvent("blur", eventInit);
18169 const defaultAllowed = element.dispatchEvent(event);
18170 const bubbleInit = {
18171 ...eventInit,
18172 bubbles: true
18173 };
18174 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
18175 return defaultAllowed;
18176 }
18177 function fireKeyboardEvent(element, type, eventInit) {
18178 const event = new KeyboardEvent(type, eventInit);
18179 return element.dispatchEvent(event);
18180 }
18181 function fireClickEvent(element, eventInit) {
18182 const event = new MouseEvent("click", eventInit);
18183 return element.dispatchEvent(event);
18184 }
18185 function isFocusEventOutside(event, container) {
18186 const containerElement = container || event.currentTarget;
18187 const relatedTarget = event.relatedTarget;
18188 return !isNode2(relatedTarget) || !contains2(containerElement, relatedTarget);
18189 }
18190 function isInputEvent(event) {
18191 return event.type === "input";
18192 }
18193 function queueBeforeEvent(element, type, callback, timeout) {
18194 const createTimer = (callback2) => {
18195 if (timeout) {
18196 const timerId2 = setTimeout(callback2, timeout);
18197 return () => clearTimeout(timerId2);
18198 }
18199 const timerId = requestAnimationFrame(callback2);
18200 return () => cancelAnimationFrame(timerId);
18201 };
18202 const cancelTimer = createTimer(() => {
18203 element.removeEventListener(type, callSync, true);
18204 callback();
18205 });
18206 const callSync = () => {
18207 cancelTimer();
18208 callback();
18209 };
18210 element.addEventListener(type, callSync, {
18211 once: true,
18212 capture: true
18213 });
18214 return () => {
18215 cancelTimer();
18216 element.removeEventListener(type, callSync, true);
18217 };
18218 }
18219 function addGlobalEventListener(type, listener, options, scope = window) {
18220 const children = [];
18221 try {
18222 scope.document.addEventListener(type, listener, options);
18223 for (const frame of Array.from(scope.frames)) children.push(addGlobalEventListener(type, listener, options, frame));
18224 } catch {
18225 }
18226 const removeEventListener = () => {
18227 try {
18228 scope.document.removeEventListener(type, listener, options);
18229 } catch {
18230 }
18231 for (const remove of children) remove();
18232 };
18233 return removeEventListener;
18234 }
18235 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'])";
18236 function isFocusable(element) {
18237 if (!element.matches(selector)) return false;
18238 if (!isVisible(element)) return false;
18239 if (element.closest("[inert]")) return false;
18240 return true;
18241 }
18242 function hasFocus(element) {
18243 const activeElement2 = getActiveElement(element);
18244 if (!activeElement2) return false;
18245 if (activeElement2 === element) return true;
18246 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
18247 if (!activeDescendant) return false;
18248 return activeDescendant === element.id;
18249 }
18250 function hasFocusWithin(element) {
18251 const activeElement2 = getActiveElement(element);
18252 if (!activeElement2) return false;
18253 if (contains2(element, activeElement2)) return true;
18254 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
18255 if (!activeDescendant) return false;
18256 if (!("id" in element)) return false;
18257 if (activeDescendant === element.id) return true;
18258 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
18259 }
18260 function focusIntoView(element, options) {
18261 if (!("scrollIntoView" in element)) element.focus();
18262 else {
18263 element.focus({ preventScroll: true });
18264 element.scrollIntoView({
18265 block: "nearest",
18266 inline: "nearest",
18267 ...options
18268 });
18269 }
18270 }
18271 function createUndoCallback(callback) {
18272 return async () => {
18273 const redo = await callback?.();
18274 return createUndoCallback(async () => {
18275 await redo?.();
18276 return callback;
18277 });
18278 };
18279 }
18280 var UndoManager = createUndoManager();
18281 function createUndoManager({ limit = 100 } = {}) {
18282 const undoStack = [];
18283 let redoStack = [];
18284 let currentGroup = null;
18285 const canUndo = () => undoStack.length > 0;
18286 const canRedo = () => redoStack.length > 0;
18287 const undo = async () => {
18288 if (!canUndo()) return;
18289 currentGroup = null;
18290 redoStack.push(await undoStack.pop()?.());
18291 };
18292 const redo = async () => {
18293 if (!canRedo()) return;
18294 currentGroup = null;
18295 undoStack.push(await redoStack.pop()?.());
18296 };
18297 const execute = async (callback, group) => {
18298 if (!callback) return;
18299 const sameGroup = group === currentGroup;
18300 currentGroup = group ?? null;
18301 const nextIndex = sameGroup ? Math.max(0, undoStack.length - 1) : undoStack.length;
18302 const undoCallback = await callback();
18303 if (!undoCallback) return;
18304 redoStack = [];
18305 const currentUndo = undoStack[nextIndex];
18306 undoStack[nextIndex] = createUndoCallback(async () => {
18307 await undoCallback?.();
18308 const currentRedo = await currentUndo?.();
18309 return async () => {
18310 await currentRedo?.();
18311 await callback?.();
18312 };
18313 });
18314 while (undoStack.length > limit) undoStack.shift();
18315 };
18316 return {
18317 canUndo,
18318 canRedo,
18319 undo,
18320 redo,
18321 execute
18322 };
18323 }
18324
18325 // node_modules/@ariakit/react-utils/dist/index.js
18326 var React58 = __toESM(require_react(), 1);
18327 var import_react17 = __toESM(require_react(), 1);
18328 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
18329 function setRef(ref, value) {
18330 if (typeof ref === "function") {
18331 const cleanup = ref(value);
18332 if (typeof cleanup === "function") return cleanup;
18333 } else if (ref) ref.current = value;
18334 }
18335 function isValidElementWithRef(element) {
18336 if (!element) return false;
18337 if (!(0, import_react17.isValidElement)(element)) return false;
18338 if ("ref" in element.props) return true;
18339 if ("ref" in element) return true;
18340 return false;
18341 }
18342 function getRefProperty(element) {
18343 if (!isValidElementWithRef(element)) return null;
18344 return { ...element.props }.ref || element.ref;
18345 }
18346 function mergeProps2(base, overrides) {
18347 const props = { ...base };
18348 for (const key in overrides) {
18349 if (!hasOwnProperty(overrides, key)) continue;
18350 if (key === "className") {
18351 const prop = "className";
18352 const baseClass = base[prop];
18353 const overrideClass = overrides[prop];
18354 if (baseClass && overrideClass) props[prop] = `${baseClass} ${overrideClass}`;
18355 else props[prop] = overrideClass || baseClass;
18356 continue;
18357 }
18358 if (key === "style") {
18359 const prop = "style";
18360 props[prop] = base[prop] ? {
18361 ...base[prop],
18362 ...overrides[prop]
18363 } : overrides[prop];
18364 continue;
18365 }
18366 const overrideValue = overrides[key];
18367 if (key.startsWith("on")) {
18368 if (typeof overrideValue !== "function") continue;
18369 const baseValue = base[key];
18370 if (typeof baseValue === "function") {
18371 props[key] = (...args) => {
18372 overrideValue(...args);
18373 baseValue(...args);
18374 };
18375 continue;
18376 }
18377 }
18378 props[key] = overrideValue;
18379 }
18380 return props;
18381 }
18382 var _React = { ...React58 };
18383 var useReactId = _React.useId;
18384 var useReactDeferredValue = _React.useDeferredValue;
18385 var useReactInsertionEffect = _React.useInsertionEffect;
18386 var useSafeLayoutEffect = canUseDOM ? import_react17.useLayoutEffect : import_react17.useEffect;
18387 function useInitialValue(value) {
18388 const [initialValue] = (0, import_react17.useState)(value);
18389 return initialValue;
18390 }
18391 function useLiveRef(value) {
18392 const ref = (0, import_react17.useRef)(value);
18393 useSafeLayoutEffect(() => {
18394 ref.current = value;
18395 });
18396 return ref;
18397 }
18398 function useEvent(callback) {
18399 const ref = (0, import_react17.useRef)(() => {
18400 throw new Error("Cannot call an event handler while rendering.");
18401 });
18402 if (useReactInsertionEffect) useReactInsertionEffect(() => {
18403 ref.current = callback;
18404 });
18405 else ref.current = callback;
18406 return (0, import_react17.useCallback)((...args) => ref.current?.(...args), []);
18407 }
18408 function useTransactionState(callback) {
18409 const [state, setState] = (0, import_react17.useState)(null);
18410 useSafeLayoutEffect(() => {
18411 if (state == null) return;
18412 if (!callback) return;
18413 let prevState = null;
18414 callback((prev) => {
18415 prevState = prev;
18416 return state;
18417 });
18418 return () => {
18419 callback(prevState);
18420 };
18421 }, [state, callback]);
18422 return [state, setState];
18423 }
18424 function useMergeRefs(...refs) {
18425 return (0, import_react17.useMemo)(() => {
18426 if (!refs.some(Boolean)) return;
18427 return (value) => {
18428 const refEffects = [];
18429 for (const ref of refs) {
18430 if (!ref) continue;
18431 const cleanup = setRef(ref, value);
18432 refEffects.push({
18433 ref,
18434 cleanup: typeof cleanup === "function" ? cleanup : void 0
18435 });
18436 }
18437 if (!refEffects.some((effect) => effect.cleanup)) return;
18438 return () => {
18439 for (const { ref, cleanup } of refEffects) if (cleanup) cleanup();
18440 else setRef(ref, null);
18441 };
18442 };
18443 }, refs);
18444 }
18445 function useId5(defaultId) {
18446 if (useReactId) {
18447 const reactId = useReactId();
18448 if (defaultId) return defaultId;
18449 return reactId;
18450 }
18451 const [id, setId] = (0, import_react17.useState)(defaultId);
18452 useSafeLayoutEffect(() => {
18453 if (defaultId || id) return;
18454 setId(`id-${Math.random().toString(36).slice(2, 8)}`);
18455 }, [defaultId, id]);
18456 return defaultId || id;
18457 }
18458 function useTagName(refOrElement, type) {
18459 const stringOrUndefined = (type2) => {
18460 if (typeof type2 !== "string") return;
18461 return type2;
18462 };
18463 const [tagName, setTagName] = (0, import_react17.useState)(() => stringOrUndefined(type));
18464 useSafeLayoutEffect(() => {
18465 setTagName((refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement)?.tagName.toLowerCase() || stringOrUndefined(type));
18466 }, [refOrElement, type]);
18467 return tagName;
18468 }
18469 function useAttribute(refOrElement, attributeName, defaultValue2) {
18470 const initialValue = useInitialValue(defaultValue2);
18471 const [attribute, setAttribute] = (0, import_react17.useState)(initialValue);
18472 (0, import_react17.useEffect)(() => {
18473 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
18474 if (!element) return;
18475 const callback = () => {
18476 const value = element.getAttribute(attributeName);
18477 setAttribute(value == null ? initialValue : value);
18478 };
18479 const observer = new MutationObserver(callback);
18480 observer.observe(element, { attributeFilter: [attributeName] });
18481 callback();
18482 return () => observer.disconnect();
18483 }, [
18484 refOrElement,
18485 attributeName,
18486 initialValue
18487 ]);
18488 return attribute;
18489 }
18490 function useUpdateEffect(effect, deps) {
18491 const mounted = (0, import_react17.useRef)(false);
18492 (0, import_react17.useEffect)(() => {
18493 if (mounted.current) return effect();
18494 mounted.current = true;
18495 }, deps);
18496 (0, import_react17.useEffect)(() => () => {
18497 mounted.current = false;
18498 }, []);
18499 }
18500 function useUpdateLayoutEffect(effect, deps) {
18501 const mounted = (0, import_react17.useRef)(false);
18502 useSafeLayoutEffect(() => {
18503 if (mounted.current) return effect();
18504 mounted.current = true;
18505 }, deps);
18506 useSafeLayoutEffect(() => () => {
18507 mounted.current = false;
18508 }, []);
18509 }
18510 function useForceUpdate() {
18511 return (0, import_react17.useReducer)(() => [], []);
18512 }
18513 function useBooleanEvent(booleanOrCallback) {
18514 return useEvent(typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback);
18515 }
18516 function useWrapElement(props, callback, deps = []) {
18517 const wrapElement = (0, import_react17.useCallback)((element) => {
18518 if (props.wrapElement) element = props.wrapElement(element);
18519 return callback(element);
18520 }, [...deps, props.wrapElement]);
18521 return {
18522 ...props,
18523 wrapElement
18524 };
18525 }
18526 function useMetadataProps(props, key, value) {
18527 const parent = props.onLoadedMetadataCapture;
18528 const onLoadedMetadataCapture = (0, import_react17.useMemo)(() => {
18529 return Object.assign(() => {
18530 }, parent, ...value !== void 0 ? [{ [key]: value }] : []);
18531 }, [
18532 parent,
18533 key,
18534 value
18535 ]);
18536 return [parent?.[key], { onLoadedMetadataCapture }];
18537 }
18538 var hasInstalledGlobalEventListeners = false;
18539 function useIsMouseMoving() {
18540 (0, import_react17.useEffect)(() => {
18541 if (hasInstalledGlobalEventListeners) return;
18542 addGlobalEventListener("mousemove", setMouseMoving, true);
18543 addGlobalEventListener("mousedown", resetMouseMoving, true);
18544 addGlobalEventListener("mouseup", resetMouseMoving, true);
18545 addGlobalEventListener("keydown", resetMouseMoving, true);
18546 addGlobalEventListener("scroll", resetMouseMoving, true);
18547 hasInstalledGlobalEventListeners = true;
18548 }, []);
18549 return useEvent(() => mouseMoving);
18550 }
18551 var mouseMoving = false;
18552 var previousScreenX = 0;
18553 var previousScreenY = 0;
18554 function hasMouseMovement(event) {
18555 const movementX = event.movementX || event.screenX - previousScreenX;
18556 const movementY = event.movementY || event.screenY - previousScreenY;
18557 previousScreenX = event.screenX;
18558 previousScreenY = event.screenY;
18559 return movementX || movementY || false;
18560 }
18561 function setMouseMoving(event) {
18562 if (!hasMouseMovement(event)) return;
18563 mouseMoving = true;
18564 }
18565 function resetMouseMoving() {
18566 mouseMoving = false;
18567 }
18568 function forwardRef49(render4) {
18569 const Role = React58.forwardRef((props, ref) => render4({
18570 ...props,
18571 ref
18572 }));
18573 Role.displayName = render4.displayName || render4.name;
18574 return Role;
18575 }
18576 function memo3(Component, propsAreEqual) {
18577 return React58.memo(Component, propsAreEqual);
18578 }
18579 function createElement3(Type, props) {
18580 const { wrapElement, render: render4, ...rest } = props;
18581 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
18582 let element;
18583 if (React58.isValidElement(render4)) {
18584 const renderProps = {
18585 ...render4.props,
18586 ref: mergedRef
18587 };
18588 element = React58.cloneElement(render4, mergeProps2(rest, renderProps));
18589 } else if (render4) element = render4(rest);
18590 else element = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Type, { ...rest });
18591 if (wrapElement) return wrapElement(element);
18592 return element;
18593 }
18594 function createHook(useProps) {
18595 const useRole = (props = {}) => {
18596 return useProps(props);
18597 };
18598 useRole.displayName = useProps.name;
18599 return useRole;
18600 }
18601 function createStoreContext(providers = [], scopedProviders = []) {
18602 const context = React58.createContext(void 0);
18603 const scopedContext = React58.createContext(void 0);
18604 const useContext47 = () => React58.useContext(context);
18605 const useScopedContext = (onlyScoped = false) => {
18606 const scoped = React58.useContext(scopedContext);
18607 const store = useContext47();
18608 if (onlyScoped) return scoped;
18609 return scoped || store;
18610 };
18611 const useProviderContext = () => {
18612 const scoped = React58.useContext(scopedContext);
18613 const store = useContext47();
18614 if (scoped && scoped === store) return;
18615 return store;
18616 };
18617 const ContextProvider = (props) => {
18618 return providers.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Provider2, {
18619 ...props,
18620 children
18621 }), /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(context.Provider, { ...props }));
18622 };
18623 const ScopedContextProvider = (props) => {
18624 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(ContextProvider, {
18625 ...props,
18626 children: scopedProviders.reduceRight((children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Provider2, {
18627 ...props,
18628 children
18629 }), /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(scopedContext.Provider, { ...props }))
18630 });
18631 };
18632 return {
18633 context,
18634 scopedContext,
18635 useContext: useContext47,
18636 useScopedContext,
18637 useProviderContext,
18638 ContextProvider,
18639 ScopedContextProvider
18640 };
18641 }
18642
18643 // node_modules/@ariakit/react-components/dist/focusable/focusable.js
18644 var import_react18 = __toESM(require_react(), 1);
18645 var TagName = "div";
18646 var accessibleWhenDisabledSymbol = /* @__PURE__ */ Symbol("accessibleWhenDisabled");
18647 var isSafariBrowser = isSafari();
18648 var alwaysFocusVisibleInputTypes = [
18649 "text",
18650 "search",
18651 "url",
18652 "tel",
18653 "email",
18654 "password",
18655 "number",
18656 "date",
18657 "month",
18658 "week",
18659 "time",
18660 "datetime",
18661 "datetime-local"
18662 ];
18663 function isAlwaysFocusVisible(element) {
18664 const { tagName, readOnly, type } = element;
18665 if (tagName === "TEXTAREA" && !readOnly) return true;
18666 if (tagName === "SELECT" && !readOnly) return true;
18667 if (tagName === "INPUT" && !readOnly) return alwaysFocusVisibleInputTypes.includes(type);
18668 if (element.isContentEditable) return true;
18669 if (element.getAttribute("role") === "combobox" && element.dataset.name) return true;
18670 return false;
18671 }
18672 function isNativeTabbable(tagName) {
18673 if (!tagName) return true;
18674 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
18675 }
18676 function supportsDisabledAttribute(tagName) {
18677 if (!tagName) return true;
18678 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
18679 }
18680 function isNativeSubmitControl(element) {
18681 if (element.tagName === "BUTTON") {
18682 const { type } = element;
18683 return type === "submit";
18684 }
18685 if (element.tagName === "INPUT") {
18686 const { type } = element;
18687 return type === "submit" || type === "image";
18688 }
18689 return false;
18690 }
18691 function getTabIndex2({ focusable: focusable2, trulyDisabled, nativeTabbable, supportsDisabled, safariTabIndex, tabIndexProp }) {
18692 if (!focusable2) return tabIndexProp;
18693 if (trulyDisabled) {
18694 if (nativeTabbable && !supportsDisabled) return -1;
18695 return;
18696 }
18697 if (nativeTabbable) {
18698 if (safariTabIndex && tabIndexProp == null) return 0;
18699 return tabIndexProp;
18700 }
18701 return tabIndexProp ?? 0;
18702 }
18703 function useDisableEvent(onEvent, disabled2) {
18704 return useEvent((event) => {
18705 onEvent?.(event);
18706 if (event.defaultPrevented) return;
18707 if (disabled2) {
18708 event.stopPropagation();
18709 event.preventDefault();
18710 }
18711 });
18712 }
18713 var hasInstalledGlobalEventListeners2 = false;
18714 var isKeyboardModality = true;
18715 function onGlobalMouseDown(event) {
18716 const target = event.target;
18717 if (isElement2(target) && !target.hasAttribute("data-focus-visible")) isKeyboardModality = false;
18718 }
18719 function onGlobalKeyDown(event) {
18720 if (event.metaKey) return;
18721 if (event.ctrlKey) return;
18722 if (event.altKey) return;
18723 isKeyboardModality = true;
18724 }
18725 var useFocusable = createHook(function useFocusable2({ focusable: focusable2 = true, accessibleWhenDisabled, autoFocus, onFocusVisible, ...props }) {
18726 const ref = (0, import_react18.useRef)(null);
18727 const [parentAccessibleWhenDisabled, metadataProps] = useMetadataProps(props, accessibleWhenDisabledSymbol, accessibleWhenDisabled);
18728 accessibleWhenDisabled ??= parentAccessibleWhenDisabled;
18729 (0, import_react18.useEffect)(() => {
18730 if (!focusable2) return;
18731 if (hasInstalledGlobalEventListeners2) return;
18732 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
18733 addGlobalEventListener("keydown", onGlobalKeyDown, true);
18734 hasInstalledGlobalEventListeners2 = true;
18735 }, [focusable2]);
18736 const disabled2 = focusable2 && disabledFromProps(props);
18737 const trulyDisabled = disabled2 && !accessibleWhenDisabled;
18738 const [focusVisible, setFocusVisible] = (0, import_react18.useState)(false);
18739 const focusVisibleRef = (0, import_react18.useRef)(false);
18740 const nativeSubmitObserverCleanupRef = (0, import_react18.useRef)(null);
18741 const cleanupFocusVisible = useEvent((element) => {
18742 nativeSubmitObserverCleanupRef.current?.();
18743 nativeSubmitObserverCleanupRef.current = null;
18744 focusVisibleRef.current = false;
18745 element?.removeAttribute("data-focus-visible");
18746 });
18747 (0, import_react18.useEffect)(() => {
18748 if (!focusable2) return;
18749 if (!trulyDisabled) return;
18750 cleanupFocusVisible(ref.current);
18751 if (focusVisible) setFocusVisible(false);
18752 }, [
18753 focusable2,
18754 trulyDisabled,
18755 focusVisible,
18756 cleanupFocusVisible
18757 ]);
18758 (0, import_react18.useEffect)(() => {
18759 if (!focusable2) return;
18760 if (!focusVisible) return;
18761 const element = ref.current;
18762 if (!element) return;
18763 if (typeof IntersectionObserver === "undefined") return;
18764 const observer = new IntersectionObserver(() => {
18765 if (!isFocusable(element)) {
18766 focusVisibleRef.current = false;
18767 setFocusVisible(false);
18768 }
18769 });
18770 observer.observe(element);
18771 return () => observer.disconnect();
18772 }, [focusable2, focusVisible]);
18773 (0, import_react18.useEffect)(() => {
18774 return () => nativeSubmitObserverCleanupRef.current?.();
18775 }, []);
18776 const onKeyPressCapture = useDisableEvent(props.onKeyPressCapture, disabled2);
18777 const onMouseDownCapture = useDisableEvent(props.onMouseDownCapture, disabled2);
18778 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
18779 const handleFocusVisible = (event, currentTarget) => {
18780 if (currentTarget) event.currentTarget = currentTarget;
18781 if (!focusable2) return;
18782 const element = event.currentTarget;
18783 if (!element) return;
18784 if (!hasFocus(element)) return;
18785 onFocusVisible?.(event);
18786 if (event.defaultPrevented) return;
18787 element.dataset.focusVisible = "true";
18788 focusVisibleRef.current = true;
18789 if (isNativeSubmitControl(element)) {
18790 nativeSubmitObserverCleanupRef.current?.();
18791 nativeSubmitObserverCleanupRef.current = null;
18792 if (typeof IntersectionObserver !== "undefined") {
18793 const observer = new IntersectionObserver(() => {
18794 if (isFocusable(element)) return;
18795 cleanupFocusVisible(element);
18796 });
18797 observer.observe(element);
18798 nativeSubmitObserverCleanupRef.current = () => observer.disconnect();
18799 }
18800 return;
18801 }
18802 setFocusVisible(true);
18803 };
18804 const onKeyDownCaptureProp = props.onKeyDownCapture;
18805 const onKeyDownCapture = useEvent((event) => {
18806 onKeyDownCaptureProp?.(event);
18807 if (event.defaultPrevented) return;
18808 if (!focusable2) return;
18809 if (focusVisible) return;
18810 if (focusVisibleRef.current) return;
18811 if (event.metaKey) return;
18812 if (event.altKey) return;
18813 if (event.ctrlKey) return;
18814 if (!isSelfTarget(event)) return;
18815 const element = event.currentTarget;
18816 const applyFocusVisible = () => handleFocusVisible(event, element);
18817 queueBeforeEvent(element, "focusout", applyFocusVisible);
18818 });
18819 const onFocusCaptureProp = props.onFocusCapture;
18820 const onFocusCapture = useEvent((event) => {
18821 onFocusCaptureProp?.(event);
18822 if (event.defaultPrevented) return;
18823 if (!focusable2) return;
18824 if (!isSelfTarget(event)) {
18825 setFocusVisible(false);
18826 return;
18827 }
18828 const element = event.currentTarget;
18829 const applyFocusVisible = () => handleFocusVisible(event, element);
18830 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) queueBeforeEvent(event.target, "focusout", applyFocusVisible);
18831 else setFocusVisible(false);
18832 });
18833 const onBlurProp = props.onBlur;
18834 const onBlur = useEvent((event) => {
18835 onBlurProp?.(event);
18836 if (!focusable2) return;
18837 if (!isFocusEventOutside(event)) return;
18838 cleanupFocusVisible(event.currentTarget);
18839 setFocusVisible(false);
18840 });
18841 const autoFocusOnShow = (0, import_react18.useContext)(FocusableContext);
18842 const autoFocusRef = useEvent((element) => {
18843 if (!focusable2) return;
18844 if (!autoFocus) return;
18845 if (!element) return;
18846 if (!autoFocusOnShow) return;
18847 queueMicrotask(() => {
18848 if (hasFocus(element)) return;
18849 if (!isFocusable(element)) return;
18850 element.focus();
18851 });
18852 });
18853 const tagName = useTagName(ref);
18854 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
18855 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
18856 const [safariTabIndex, setSafariTabIndex] = (0, import_react18.useState)(false);
18857 if (isSafariBrowser) (0, import_react18.useEffect)(() => {
18858 if (!focusable2) return;
18859 const element = ref.current;
18860 if (!element) return;
18861 const { type } = element;
18862 const isNativeCheckboxOrRadio = element.tagName === "INPUT" && (type === "checkbox" || type === "radio");
18863 setSafariTabIndex(isButton(element) || isNativeCheckboxOrRadio);
18864 }, [focusable2]);
18865 const styleProp = props.style;
18866 const style = (0, import_react18.useMemo)(() => {
18867 if (trulyDisabled) return {
18868 pointerEvents: "none",
18869 ...styleProp
18870 };
18871 return styleProp;
18872 }, [trulyDisabled, styleProp]);
18873 props = {
18874 "data-focus-visible": focusable2 && focusVisible || void 0,
18875 "data-autofocus": autoFocus || void 0,
18876 "aria-disabled": disabled2 || void 0,
18877 ...props,
18878 ...metadataProps,
18879 ref: useMergeRefs(ref, autoFocusRef, props.ref),
18880 style,
18881 tabIndex: getTabIndex2({
18882 focusable: focusable2,
18883 trulyDisabled,
18884 nativeTabbable,
18885 supportsDisabled,
18886 safariTabIndex,
18887 tabIndexProp: props.tabIndex
18888 }),
18889 disabled: supportsDisabled && trulyDisabled ? true : void 0,
18890 contentEditable: disabled2 ? void 0 : props.contentEditable,
18891 onKeyPressCapture,
18892 onClickCapture,
18893 onMouseDownCapture,
18894 onKeyDownCapture,
18895 onFocusCapture,
18896 onBlur
18897 };
18898 return removeUndefinedValues(props);
18899 });
18900 var Focusable = forwardRef49(function Focusable2(props) {
18901 return createElement3(TagName, useFocusable(props));
18902 });
18903
18904 // node_modules/@ariakit/react-components/dist/command/command.js
18905 var import_react19 = __toESM(require_react(), 1);
18906 var TagName2 = "button";
18907 function isNativeClick(event) {
18908 if (!event.isTrusted) return false;
18909 const element = event.currentTarget;
18910 if (event.key === "Enter") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
18911 if (event.key === " ") return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
18912 return false;
18913 }
18914 var symbol = /* @__PURE__ */ Symbol("command");
18915 var useCommand = createHook(function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
18916 const ref = (0, import_react19.useRef)(null);
18917 const [isNativeButton, setIsNativeButton] = (0, import_react19.useState)(false);
18918 (0, import_react19.useEffect)(() => {
18919 if (!ref.current) return;
18920 setIsNativeButton(isButton(ref.current));
18921 }, []);
18922 const [active, setActive] = (0, import_react19.useState)(false);
18923 const activeRef = (0, import_react19.useRef)(false);
18924 const disabled2 = disabledFromProps(props);
18925 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
18926 useSafeLayoutEffect(() => {
18927 if (!disabled2) return;
18928 activeRef.current = false;
18929 setActive(false);
18930 }, [disabled2]);
18931 const onKeyDownProp = props.onKeyDown;
18932 const onKeyDown = useEvent((event) => {
18933 onKeyDownProp?.(event);
18934 const element = event.currentTarget;
18935 if (event.defaultPrevented) return;
18936 if (isDuplicate) return;
18937 if (disabled2) return;
18938 if (!isSelfTarget(event)) return;
18939 if (isTextField(element)) return;
18940 if (element.isContentEditable) return;
18941 const isEnter = clickOnEnter && event.key === "Enter";
18942 const isSpace = clickOnSpace && event.key === " ";
18943 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
18944 const shouldPreventSpace = event.key === " " && !clickOnSpace;
18945 if (shouldPreventEnter || shouldPreventSpace) {
18946 event.preventDefault();
18947 return;
18948 }
18949 if (isEnter || isSpace) {
18950 const nativeClick = isNativeClick(event);
18951 if (isEnter) {
18952 if (!nativeClick) {
18953 event.preventDefault();
18954 const { view, ...eventInit } = event;
18955 const click = () => fireClickEvent(element, eventInit);
18956 if (isFirefox()) queueBeforeEvent(element, "keyup", click);
18957 else queueMicrotask(click);
18958 }
18959 } else if (isSpace) {
18960 activeRef.current = true;
18961 if (!nativeClick) {
18962 event.preventDefault();
18963 setActive(true);
18964 }
18965 }
18966 }
18967 });
18968 const onKeyUpProp = props.onKeyUp;
18969 const onKeyUp = useEvent((event) => {
18970 onKeyUpProp?.(event);
18971 if (isDuplicate) return;
18972 const isSpace = clickOnSpace && event.key === " ";
18973 if (!activeRef.current || !isSpace) return;
18974 const nativeClick = isNativeClick(event);
18975 activeRef.current = false;
18976 if (!nativeClick) setActive(false);
18977 if (event.defaultPrevented) return;
18978 if (!isSelfTarget(event)) return;
18979 if (disabled2) return;
18980 if (event.metaKey) return;
18981 if (nativeClick) return;
18982 event.preventDefault();
18983 const element = event.currentTarget;
18984 const { view, ...eventInit } = event;
18985 queueMicrotask(() => fireClickEvent(element, eventInit));
18986 });
18987 const onBlurProp = props.onBlur;
18988 const onBlur = useEvent((event) => {
18989 onBlurProp?.(event);
18990 if (!activeRef.current) return;
18991 activeRef.current = false;
18992 setActive(false);
18993 });
18994 props = {
18995 "data-active": active || void 0,
18996 type: isNativeButton ? "button" : void 0,
18997 ...metadataProps,
18998 ...props,
18999 ref: useMergeRefs(ref, props.ref),
19000 onKeyDown,
19001 onKeyUp,
19002 onBlur
19003 };
19004 props = useFocusable(props);
19005 return props;
19006 });
19007 var Command = forwardRef49(function Command2(props) {
19008 return createElement3(TagName2, useCommand(props));
19009 });
19010
19011 // node_modules/@ariakit/react-components/dist/collection/collection-context.js
19012 var ctx = createStoreContext();
19013 var useCollectionContext = ctx.useContext;
19014 var useCollectionScopedContext = ctx.useScopedContext;
19015 var useCollectionProviderContext = ctx.useProviderContext;
19016 var CollectionContextProvider = ctx.ContextProvider;
19017 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
19018
19019 // node_modules/@ariakit/react-components/dist/collection/collection-item.js
19020 var import_react20 = __toESM(require_react(), 1);
19021 var TagName3 = "div";
19022 var useCollectionItem = createHook(function useCollectionItem2({ store, shouldRegisterItem = true, getItem = identity, element, ...props }) {
19023 const context = useCollectionContext();
19024 store = store || context;
19025 const id = useId5(props.id);
19026 const ref = (0, import_react20.useRef)(element);
19027 (0, import_react20.useEffect)(() => {
19028 const element2 = ref.current;
19029 if (!id) return;
19030 if (!element2) return;
19031 if (!shouldRegisterItem) return;
19032 const item = getItem({
19033 id,
19034 element: element2
19035 });
19036 return store?.renderItem(item);
19037 }, [
19038 id,
19039 shouldRegisterItem,
19040 getItem,
19041 store
19042 ]);
19043 props = {
19044 ...props,
19045 ref: useMergeRefs(ref, props.ref)
19046 };
19047 return removeUndefinedValues(props);
19048 });
19049 var CollectionItem = forwardRef49(function CollectionItem2(props) {
19050 return createElement3(TagName3, useCollectionItem(props));
19051 });
19052
19053 // node_modules/@ariakit/react-components/dist/composite/composite-context.js
19054 var import_react21 = __toESM(require_react(), 1);
19055 var ctx2 = createStoreContext([CollectionContextProvider], [CollectionScopedContextProvider]);
19056 var useCompositeContext = ctx2.useContext;
19057 var useCompositeScopedContext = ctx2.useScopedContext;
19058 var useCompositeProviderContext = ctx2.useProviderContext;
19059 var CompositeContextProvider = ctx2.ContextProvider;
19060 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
19061 var CompositeItemContext = (0, import_react21.createContext)(void 0);
19062 var CompositeRowContext = (0, import_react21.createContext)(void 0);
19063
19064 // node_modules/@ariakit/store/dist/index.js
19065 function getInternal(store, key) {
19066 const internals = store.__unstableInternals;
19067 invariant(internals, "Invalid store");
19068 return internals[key];
19069 }
19070 function hasUpdatedKey(keys, updatedKey) {
19071 if (!keys) return true;
19072 for (const currentKey of keys) if (updatedKey instanceof Set) {
19073 if (updatedKey.has(currentKey)) return true;
19074 } else if (currentKey === updatedKey) return true;
19075 return false;
19076 }
19077 function isSameValue(value, other) {
19078 return value === other || value !== value && other !== other;
19079 }
19080 function getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) {
19081 let cleanupPrevState;
19082 for (const key of getKeys(state)) {
19083 if (isSameValue(state[key], stateBeforeCleanup[key])) continue;
19084 if (updatedKey !== void 0 && hasUpdatedKey([key], updatedKey)) continue;
19085 cleanupPrevState ??= { ...prevState };
19086 cleanupPrevState[key] = state[key];
19087 }
19088 return cleanupPrevState;
19089 }
19090 var MAX_REPAIR_PASSES = 100;
19091 function addKeyedListener(map, keys, listener) {
19092 if (!keys) return;
19093 for (const key of keys) {
19094 let listeners = map.get(key);
19095 if (!listeners) {
19096 listeners = /* @__PURE__ */ new Set();
19097 map.set(key, listeners);
19098 }
19099 listeners.add(listener);
19100 }
19101 }
19102 function deleteKeyedListener(map, keys, listener) {
19103 if (!map) return;
19104 if (!keys) return;
19105 for (const key of keys) {
19106 const listeners = map.get(key);
19107 if (!listeners) continue;
19108 listeners.delete(listener);
19109 if (!listeners.size) map.delete(key);
19110 }
19111 }
19112 function getFastPathNotifiedListeners(frame) {
19113 const notifiedListeners = /* @__PURE__ */ new Set();
19114 const currentListener = frame.currentListener;
19115 if (!currentListener) return notifiedListeners;
19116 for (const listener of frame.keyedListeners) {
19117 notifiedListeners.add(listener);
19118 if (listener === currentListener) return notifiedListeners;
19119 }
19120 notifiedListeners.clear();
19121 notifiedListeners.add(currentListener);
19122 return notifiedListeners;
19123 }
19124 function preserveFastPathNotifiedListeners(frame) {
19125 frame.notifiedListeners ??= getFastPathNotifiedListeners(frame);
19126 }
19127 function hasFastPathPassedListener(frame, listener) {
19128 if (!frame.currentListener) return false;
19129 let foundCurrentKeyedListener = false;
19130 for (const currentListener of frame.keyedListeners) {
19131 if (currentListener === frame.currentListener) {
19132 foundCurrentKeyedListener = true;
19133 continue;
19134 }
19135 if (!foundCurrentKeyedListener) continue;
19136 if (currentListener === listener) return false;
19137 }
19138 let foundListener = false;
19139 for (const currentListener of frame.group.listeners) {
19140 if (currentListener === frame.currentListener) return foundListener;
19141 if (currentListener === listener) foundListener = true;
19142 }
19143 return false;
19144 }
19145 function preserveFastPathFrames(fastPathFrames, group, listener) {
19146 for (const frame of fastPathFrames) {
19147 if (frame.group !== group) continue;
19148 if (frame.recovering) continue;
19149 if (listener && !frame.keyedListeners.has(listener)) continue;
19150 preserveFastPathNotifiedListeners(frame);
19151 for (const currentListener of frame.group.listeners) {
19152 if (currentListener === frame.currentListener) break;
19153 if (!hasFastPathPassedListener(frame, currentListener)) continue;
19154 frame.notifiedListeners?.add(currentListener);
19155 }
19156 }
19157 }
19158 function preserveFastPathPassedListeners(fastPathFrames, group, listener) {
19159 for (const frame of fastPathFrames) {
19160 if (frame.group !== group) continue;
19161 if (frame.recovering) continue;
19162 if (!hasFastPathPassedListener(frame, listener)) continue;
19163 preserveFastPathNotifiedListeners(frame);
19164 frame.notifiedListeners?.add(listener);
19165 }
19166 }
19167 function preserveFastPathPassedKeyedListeners({ fastPathFrames, group, keys, listener }) {
19168 const wasRegistered = group.listeners.has(listener);
19169 for (const frame of fastPathFrames) {
19170 if (frame.group !== group) continue;
19171 if (frame.recovering) continue;
19172 if (!keys.includes(frame.updatedKey)) continue;
19173 if (hasFastPathPassedListener(frame, listener)) {
19174 preserveFastPathNotifiedListeners(frame);
19175 frame.notifiedListeners?.add(listener);
19176 } else if (wasRegistered) {
19177 preserveFastPathNotifiedListeners(frame);
19178 frame.recoverToLive = true;
19179 }
19180 }
19181 }
19182 function clearFastPathNotifiedListener(fastPathFrames, group, listener) {
19183 for (const frame of fastPathFrames) {
19184 if (frame.group !== group) continue;
19185 frame.notifiedListeners?.delete(listener);
19186 }
19187 }
19188 function addFastPathKeyedListener({ fastPathFrames, group, keys, listener }) {
19189 for (const frame of fastPathFrames) {
19190 if (frame.group !== group) continue;
19191 if (frame.recovering) continue;
19192 if (!keys.includes(frame.updatedKey)) continue;
19193 frame.keyedListeners.add(listener);
19194 }
19195 }
19196 function runPendingCleanup(group, listener) {
19197 if (!group.disposables.size) return;
19198 const cleanup = group.disposables.get(listener);
19199 if (!cleanup) return;
19200 group.disposables.delete(listener);
19201 cleanup();
19202 }
19203 function setListenerCleanup(group, listener, cleanup) {
19204 const currentCleanup = group.disposables.get(listener);
19205 if (!currentCleanup) {
19206 group.disposables.set(listener, cleanup);
19207 return;
19208 }
19209 group.disposables.set(listener, () => {
19210 currentCleanup();
19211 cleanup();
19212 });
19213 }
19214 function notifyStoreListener(group, listener, state, prevState, getState, updatedKey) {
19215 if (group.suspendCounts?.has(listener)) return;
19216 const { disposables } = group;
19217 const cleanup = disposables.size ? disposables.get(listener) : void 0;
19218 if (cleanup) {
19219 disposables.delete(listener);
19220 const stateBeforeCleanup = state;
19221 cleanup();
19222 state = getState?.() ?? state;
19223 if (state !== stateBeforeCleanup) prevState = getCleanupPrevState(prevState, state, stateBeforeCleanup, updatedKey) ?? prevState;
19224 }
19225 const result = listener(state, prevState);
19226 if (result) setListenerCleanup(group, listener, result);
19227 }
19228 function runLiveListeners({ group, getState, prevState, updatedKey, notifiedListeners }) {
19229 const allKeysListeners = group.allKeysListeners;
19230 for (const listener of group.listeners) {
19231 if (notifiedListeners?.has(listener)) continue;
19232 if (!allKeysListeners?.has(listener)) {
19233 if (!hasUpdatedKey(group.listenerKeys.get(listener), updatedKey)) continue;
19234 }
19235 notifiedListeners?.add(listener);
19236 notifyStoreListener(group, listener, getState(), prevState, getState, updatedKey);
19237 }
19238 }
19239 function createStore(initialState, ...stores) {
19240 let state = initialState;
19241 let prevStateBatch = state;
19242 let destroy = noop4;
19243 let batchPending = false;
19244 let inDispatch = false;
19245 let updatedKeys = /* @__PURE__ */ new Set();
19246 const instances = /* @__PURE__ */ new Set();
19247 const setups = /* @__PURE__ */ new Set();
19248 const syncListenerGroup = {
19249 listeners: /* @__PURE__ */ new Set(),
19250 disposables: /* @__PURE__ */ new Map(),
19251 listenerKeys: /* @__PURE__ */ new WeakMap()
19252 };
19253 const batchListenerGroup = {
19254 listeners: /* @__PURE__ */ new Set(),
19255 disposables: /* @__PURE__ */ new Map(),
19256 listenerKeys: /* @__PURE__ */ new WeakMap()
19257 };
19258 const storeSetup = (callback) => {
19259 setups.add(callback);
19260 return () => setups.delete(callback);
19261 };
19262 const storeInit = () => {
19263 const initializedInstances = instances.size;
19264 const instance = /* @__PURE__ */ Symbol();
19265 instances.add(instance);
19266 const maybeDestroy = () => {
19267 if (!instances.delete(instance)) return;
19268 if (instances.size) return;
19269 destroy();
19270 };
19271 if (initializedInstances) return maybeDestroy;
19272 const stateKeys = getKeys(state);
19273 const desyncs = [];
19274 for (const store of stores) {
19275 const storeState = store?.getState?.();
19276 if (!storeState) continue;
19277 const keys = stateKeys.filter((key) => hasOwnProperty(storeState, key));
19278 if (!keys.length) continue;
19279 if (stores.length === 1 || keys.length === stateKeys.length) {
19280 for (const key of keys) desyncs.push(sync(store, [key], (state2) => {
19281 setState(key, state2[key], true);
19282 }));
19283 continue;
19284 }
19285 desyncs.push(subscribe(store, keys, (state2, prevState) => {
19286 for (const key of keys) {
19287 if (state2[key] === prevState[key]) continue;
19288 setState(key, state2[key], true);
19289 }
19290 }));
19291 for (const key of keys) {
19292 const liveState = store?.getState?.();
19293 if (!liveState) continue;
19294 setState(key, liveState[key], true);
19295 }
19296 }
19297 const teardowns = [];
19298 for (const setup2 of setups) teardowns.push(setup2());
19299 const cleanups = stores.map(init);
19300 destroy = chain(...desyncs, ...teardowns, ...cleanups);
19301 return maybeDestroy;
19302 };
19303 const deleteListenerIndexes = (group, listener, keys) => {
19304 if (keys === void 0) return;
19305 if (keys) deleteKeyedListener(group.listenersByKey, keys, listener);
19306 else group.allKeysListeners?.delete(listener);
19307 };
19308 const fastPathFrames = [];
19309 const registerListener = (keys, listener, group = syncListenerGroup) => {
19310 const listenerKeysValue = keys ? [...keys] : null;
19311 const wasRegistered = group.listeners.has(listener);
19312 if (!wasRegistered) clearFastPathNotifiedListener(fastPathFrames, group, listener);
19313 if (!listenerKeysValue) {
19314 if (wasRegistered) preserveFastPathFrames(fastPathFrames, group);
19315 preserveFastPathPassedListeners(fastPathFrames, group, listener);
19316 } else preserveFastPathPassedKeyedListeners({
19317 fastPathFrames,
19318 group,
19319 keys: listenerKeysValue,
19320 listener
19321 });
19322 if (wasRegistered) {
19323 preserveFastPathFrames(fastPathFrames, group, listener);
19324 deleteListenerIndexes(group, listener, group.listenerKeys.get(listener));
19325 }
19326 group.listeners.add(listener);
19327 if (listenerKeysValue) {
19328 group.listenersByKey ??= /* @__PURE__ */ new Map();
19329 addKeyedListener(group.listenersByKey, listenerKeysValue, listener);
19330 addFastPathKeyedListener({
19331 fastPathFrames,
19332 group,
19333 keys: listenerKeysValue,
19334 listener
19335 });
19336 } else {
19337 group.allKeysListeners ??= /* @__PURE__ */ new Set();
19338 group.allKeysListeners.add(listener);
19339 }
19340 group.listenerKeys.set(listener, listenerKeysValue);
19341 return () => {
19342 const cleanup = group.disposables.get(listener);
19343 group.disposables.delete(listener);
19344 preserveFastPathFrames(fastPathFrames, group, listener);
19345 const currentKeys = group.listenerKeys.get(listener);
19346 deleteListenerIndexes(group, listener, listenerKeysValue);
19347 if (currentKeys !== listenerKeysValue) deleteListenerIndexes(group, listener, currentKeys);
19348 group.listenerKeys.delete(listener);
19349 group.listeners.delete(listener);
19350 cleanup?.();
19351 };
19352 };
19353 const storeSubscribe = (keys, listener) => registerListener(keys, listener);
19354 const runInitialListener = (group, listener, prevState) => {
19355 const shouldSuspend = group.listeners.has(listener);
19356 if (shouldSuspend) {
19357 group.suspendCounts ??= /* @__PURE__ */ new Map();
19358 const count = group.suspendCounts.get(listener) ?? 0;
19359 group.suspendCounts.set(listener, count + 1);
19360 }
19361 let cleanupPrevState;
19362 try {
19363 const stateBeforeCleanups = state;
19364 runPendingCleanup(group, listener);
19365 if (state !== stateBeforeCleanups) cleanupPrevState = getCleanupPrevState(prevState, state, stateBeforeCleanups);
19366 const cleanup = listener(state, cleanupPrevState ?? prevState);
19367 if (cleanup) setListenerCleanup(group, listener, cleanup);
19368 } finally {
19369 if (shouldSuspend) {
19370 const suspendCounts = group.suspendCounts;
19371 const count = suspendCounts?.get(listener);
19372 if (count && count > 1) suspendCounts?.set(listener, count - 1);
19373 else suspendCounts?.delete(listener);
19374 if (!suspendCounts?.size) delete group.suspendCounts;
19375 }
19376 }
19377 };
19378 const storeSync = (keys, listener) => {
19379 runInitialListener(syncListenerGroup, listener, state);
19380 return registerListener(keys, listener);
19381 };
19382 const storeBatch = (keys, listener) => {
19383 if (!batchListenerGroup.listeners.size && !inDispatch) prevStateBatch = state;
19384 runInitialListener(batchListenerGroup, listener, prevStateBatch);
19385 return registerListener(keys, listener, batchListenerGroup);
19386 };
19387 const storePick = (keys) => createStore(pick(state, keys), finalStore);
19388 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
19389 const getState = () => state;
19390 const runListeners = (group, prevState, updatedKey) => {
19391 if (!(updatedKey instanceof Set) && !group.allKeysListeners?.size) {
19392 const keyedListeners = group.listenersByKey?.get(updatedKey);
19393 if (!keyedListeners) return;
19394 const frame = {
19395 group,
19396 keyedListeners,
19397 updatedKey,
19398 currentListener: null
19399 };
19400 fastPathFrames.push(frame);
19401 try {
19402 for (const listener of keyedListeners) {
19403 if (frame.notifiedListeners?.has(listener)) continue;
19404 frame.currentListener = listener;
19405 frame.notifiedListeners?.add(listener);
19406 notifyStoreListener(group, listener, state, prevState, getState, updatedKey);
19407 if (!group.allKeysListeners?.size && !frame.recoverToLive) continue;
19408 const notifiedListeners = frame.notifiedListeners ?? getFastPathNotifiedListeners(frame);
19409 frame.notifiedListeners = notifiedListeners;
19410 frame.recovering = true;
19411 runLiveListeners({
19412 group,
19413 getState,
19414 prevState,
19415 updatedKey,
19416 notifiedListeners
19417 });
19418 return;
19419 }
19420 } finally {
19421 fastPathFrames.pop();
19422 }
19423 return;
19424 }
19425 runLiveListeners({
19426 group,
19427 getState,
19428 prevState,
19429 updatedKey
19430 });
19431 };
19432 const setState = (key, value, fromStores = false) => {
19433 if (!hasOwnProperty(state, key)) return;
19434 const currentValue = state[key];
19435 const nextValue = typeof value === "function" ? value(currentValue) : value;
19436 if (isSameValue(nextValue, currentValue)) return;
19437 const wasInDispatch = inDispatch;
19438 inDispatch = true;
19439 const prevState = state;
19440 const nextState = {
19441 ...state,
19442 [key]: nextValue
19443 };
19444 state = nextState;
19445 let superseded = false;
19446 try {
19447 if (!fromStores && stores.length) {
19448 for (const store of stores) {
19449 store?.setState?.(key, nextValue);
19450 if (isSameValue(state[key], nextValue)) continue;
19451 superseded = true;
19452 break;
19453 }
19454 if (superseded) {
19455 let pass = 0;
19456 for (; pass < MAX_REPAIR_PASSES; pass += 1) {
19457 let changed = false;
19458 for (const store of stores) {
19459 const previousValue = state[key];
19460 store?.setState?.(key, previousValue);
19461 if (!isSameValue(state[key], previousValue)) changed = true;
19462 }
19463 if (!changed) break;
19464 }
19465 if (pass === MAX_REPAIR_PASSES) console.warn("Parent stores did not converge after a superseded fan-out; a parent listener may be rewriting this key in a cycle.");
19466 }
19467 }
19468 if (!superseded) runListeners(syncListenerGroup, state === nextState ? prevState : {
19469 ...state,
19470 [key]: prevState[key]
19471 }, key);
19472 } finally {
19473 inDispatch = wasInDispatch;
19474 }
19475 if (!batchListenerGroup.listeners.size) {
19476 if (!inDispatch) prevStateBatch = state;
19477 return;
19478 }
19479 updatedKeys.add(key);
19480 if (batchPending) return;
19481 batchPending = true;
19482 queueMicrotask(() => {
19483 batchPending = false;
19484 const snapshot = state;
19485 const updatedKeysSnapshot = updatedKeys;
19486 updatedKeys = /* @__PURE__ */ new Set();
19487 const prevStateBatchBefore = prevStateBatch;
19488 runListeners(batchListenerGroup, prevStateBatchBefore, updatedKeysSnapshot);
19489 if (prevStateBatch === prevStateBatchBefore) prevStateBatch = snapshot;
19490 });
19491 };
19492 const finalStore = {
19493 getState,
19494 setState,
19495 __unstableInternals: {
19496 setup: storeSetup,
19497 init: storeInit,
19498 subscribe: storeSubscribe,
19499 sync: storeSync,
19500 batch: storeBatch,
19501 pick: storePick,
19502 omit: storeOmit
19503 }
19504 };
19505 return finalStore;
19506 }
19507 function setup(store, ...args) {
19508 if (!store) return;
19509 return getInternal(store, "setup")(...args);
19510 }
19511 function init(store, ...args) {
19512 if (!store) return;
19513 return getInternal(store, "init")(...args);
19514 }
19515 function subscribe(store, ...args) {
19516 if (!store) return;
19517 return getInternal(store, "subscribe")(...args);
19518 }
19519 function sync(store, ...args) {
19520 if (!store) return;
19521 return getInternal(store, "sync")(...args);
19522 }
19523 function batch(store, ...args) {
19524 if (!store) return;
19525 return getInternal(store, "batch")(...args);
19526 }
19527 function omit2(store, ...args) {
19528 if (!store) return;
19529 return getInternal(store, "omit")(...args);
19530 }
19531 function pick2(store, ...args) {
19532 if (!store) return;
19533 return getInternal(store, "pick")(...args);
19534 }
19535 function mergeStore(...stores) {
19536 const initialState = {};
19537 for (const store2 of stores) {
19538 const nextState = store2?.getState?.();
19539 if (nextState) Object.assign(initialState, nextState);
19540 }
19541 const store = createStore(initialState, ...stores);
19542 return Object.assign({}, ...stores, store);
19543 }
19544 function throwOnConflictingProps(props, store) {
19545 if (false) return;
19546 if (!store) return;
19547 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
19548 const stateKey = key.replace("default", "");
19549 return `${stateKey[0]?.toLowerCase() || ""}${stateKey.slice(1)}`;
19550 });
19551 if (!defaultKeys.length) return;
19552 const storeState = store.getState();
19553 if (!defaultKeys.filter((key) => hasOwnProperty(storeState, key)).length) return;
19554 throw new Error(`Passing a store prop in conjunction with a default state is not supported.
19555
19556 const store = useSelectStore();
19557 <SelectProvider store={store} defaultValue="Apple" />
19558 ^ ^
19559
19560 Instead, pass the default state to the topmost store:
19561
19562 const store = useSelectStore({ defaultValue: "Apple" });
19563 <SelectProvider store={store} />
19564
19565 See https://github.com/ariakit/ariakit/pull/2745 for more details.
19566
19567 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
19568 `);
19569 }
19570
19571 // node_modules/@ariakit/components/dist/collection/collection-store.js
19572 function getCommonParent(items) {
19573 const firstItem = items.find((item) => !!item.element);
19574 const lastElement = [...items].reverse().find((item) => !!item.element)?.element;
19575 let parentElement = firstItem?.element?.parentElement;
19576 if (!lastElement) return getDocument(parentElement).body;
19577 while (parentElement) {
19578 if (parentElement.contains(lastElement)) return parentElement;
19579 parentElement = parentElement.parentElement;
19580 }
19581 return getDocument(parentElement).body;
19582 }
19583 function getPrivateStore(store) {
19584 return store?.__unstablePrivateStore;
19585 }
19586 function createCollectionStore(props = {}) {
19587 throwOnConflictingProps(props, props.store);
19588 const syncState = props.store?.getState();
19589 const items = defaultValue(props.items, syncState?.items, props.defaultItems, []);
19590 const itemsMap = new Map(items.map((item) => [item.id, item]));
19591 const initialState = {
19592 items,
19593 renderedItems: defaultValue(syncState?.renderedItems, [])
19594 };
19595 const syncPrivateStore = getPrivateStore(props.store);
19596 const privateStore = createStore({
19597 items,
19598 renderedItems: initialState.renderedItems
19599 }, syncPrivateStore);
19600 const collection = createStore(initialState, props.store);
19601 const sortItems = (renderedItems) => {
19602 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
19603 privateStore.setState("renderedItems", sortedItems);
19604 collection.setState("renderedItems", sortedItems);
19605 };
19606 setup(collection, () => init(privateStore));
19607 setup(privateStore, () => {
19608 return batch(privateStore, ["items"], (state) => {
19609 collection.setState("items", state.items);
19610 });
19611 });
19612 setup(privateStore, () => {
19613 return batch(privateStore, ["renderedItems"], (state) => {
19614 let firstRun = true;
19615 let raf = requestAnimationFrame(() => {
19616 const { renderedItems } = collection.getState();
19617 if (state.renderedItems === renderedItems) return;
19618 sortItems(state.renderedItems);
19619 });
19620 if (typeof IntersectionObserver !== "function") return () => cancelAnimationFrame(raf);
19621 const ioCallback = () => {
19622 if (firstRun) {
19623 firstRun = false;
19624 return;
19625 }
19626 cancelAnimationFrame(raf);
19627 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
19628 };
19629 const root = getCommonParent(state.renderedItems);
19630 const observer = new IntersectionObserver(ioCallback, { root });
19631 for (const item of state.renderedItems) {
19632 if (!item.element) continue;
19633 observer.observe(item.element);
19634 }
19635 return () => {
19636 cancelAnimationFrame(raf);
19637 observer.disconnect();
19638 };
19639 });
19640 });
19641 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
19642 let prevItem;
19643 setItems((items2) => {
19644 const index2 = items2.findIndex(({ id }) => id === item.id);
19645 const nextItems = items2.slice();
19646 if (index2 !== -1) {
19647 prevItem = items2[index2];
19648 const nextItem = {
19649 ...prevItem,
19650 ...item
19651 };
19652 nextItems[index2] = nextItem;
19653 itemsMap.set(item.id, nextItem);
19654 } else {
19655 nextItems.push(item);
19656 itemsMap.set(item.id, item);
19657 }
19658 return nextItems;
19659 });
19660 const unmergeItem = () => {
19661 setItems((items2) => {
19662 if (!prevItem) {
19663 if (canDeleteFromMap) itemsMap.delete(item.id);
19664 return items2.filter(({ id }) => id !== item.id);
19665 }
19666 const index2 = items2.findIndex(({ id }) => id === item.id);
19667 if (index2 === -1) return items2;
19668 const nextItems = items2.slice();
19669 nextItems[index2] = prevItem;
19670 itemsMap.set(item.id, prevItem);
19671 return nextItems;
19672 });
19673 };
19674 return unmergeItem;
19675 };
19676 const registerItem = (item) => mergeItem(item, (getItems) => privateStore.setState("items", getItems), true);
19677 return {
19678 ...collection,
19679 registerItem,
19680 renderItem: (item) => chain(registerItem(item), mergeItem(item, (getItems) => privateStore.setState("renderedItems", getItems))),
19681 item: (id) => {
19682 if (!id) return null;
19683 let item = itemsMap.get(id);
19684 if (!item) {
19685 const { items: items2 } = privateStore.getState();
19686 item = items2.find((item2) => item2.id === id);
19687 if (item) itemsMap.set(id, item);
19688 }
19689 return item || null;
19690 },
19691 __unstablePrivateStore: privateStore
19692 };
19693 }
19694
19695 // node_modules/@ariakit/components/dist/composite/composite-store.js
19696 var NULL_ITEM = { id: null };
19697 function findFirstEnabledItem(items, excludeId) {
19698 return items.find((item) => {
19699 if (excludeId) return !item.disabled && item.id !== excludeId;
19700 return !item.disabled;
19701 });
19702 }
19703 function getEnabledItems(items, excludeId) {
19704 return items.filter((item) => {
19705 if (excludeId) return !item.disabled && item.id !== excludeId;
19706 return !item.disabled;
19707 });
19708 }
19709 function getItemsInRow(items, rowId) {
19710 return items.filter((item) => item.rowId === rowId);
19711 }
19712 function findEnabledItemId({ items, fromIndex, step, rowId, excludeId }) {
19713 for (let i2 = fromIndex; i2 >= 0 && i2 < items.length; i2 += step) {
19714 const item = items[i2];
19715 if (!item) continue;
19716 if (item.rowId !== rowId) continue;
19717 if (item.disabled) continue;
19718 if (excludeId != null && item.id === excludeId) continue;
19719 return item.id;
19720 }
19721 }
19722 function flipItems(items, activeId, shouldInsertNullItem = false) {
19723 const index2 = items.findIndex((item) => item.id === activeId);
19724 return [
19725 ...items.slice(index2 + 1),
19726 ...shouldInsertNullItem ? [NULL_ITEM] : [],
19727 ...items.slice(0, index2)
19728 ];
19729 }
19730 function groupItemsByRows(items) {
19731 const rows = [];
19732 for (const item of items) {
19733 const row = rows.find((currentRow) => currentRow[0]?.rowId === item.rowId);
19734 if (row) row.push(item);
19735 else rows.push([item]);
19736 }
19737 return rows;
19738 }
19739 function getMaxRowLength(array) {
19740 let maxLength = 0;
19741 for (const { length } of array) if (length > maxLength) maxLength = length;
19742 return maxLength;
19743 }
19744 function createEmptyItem(rowId) {
19745 return {
19746 id: "__EMPTY_ITEM__",
19747 disabled: true,
19748 rowId
19749 };
19750 }
19751 function normalizeRows(rows, activeId, focusShift) {
19752 const maxLength = getMaxRowLength(rows);
19753 for (const row of rows) for (let i2 = 0; i2 < maxLength; i2 += 1) {
19754 const item = row[i2];
19755 if (!item || focusShift && item.disabled) {
19756 const previousItem = i2 === 0 && focusShift ? findFirstEnabledItem(row) : row[i2 - 1];
19757 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem?.rowId);
19758 }
19759 }
19760 return rows;
19761 }
19762 function verticalizeItems(items) {
19763 const rows = groupItemsByRows(items);
19764 const maxLength = getMaxRowLength(rows);
19765 const verticalized = [];
19766 for (let i2 = 0; i2 < maxLength; i2 += 1) for (const row of rows) {
19767 const item = row[i2];
19768 if (item) verticalized.push({
19769 ...item,
19770 rowId: item.rowId ? `${i2}` : void 0
19771 });
19772 }
19773 return verticalized;
19774 }
19775 function createCompositeStore(props = {}) {
19776 const syncState = props.store?.getState();
19777 const collection = createCollectionStore(props);
19778 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId);
19779 const composite = createStore({
19780 ...collection.getState(),
19781 id: defaultValue(props.id, syncState?.id) ?? `id-${Math.random().toString(36).slice(2, 8)}`,
19782 activeId,
19783 baseElement: defaultValue(syncState?.baseElement, null),
19784 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, activeId === null),
19785 moves: defaultValue(syncState?.moves, 0),
19786 orientation: defaultValue(props.orientation, syncState?.orientation, "both"),
19787 rtl: defaultValue(props.rtl, syncState?.rtl, false),
19788 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, false),
19789 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, false),
19790 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, false),
19791 focusShift: defaultValue(props.focusShift, syncState?.focusShift, false)
19792 }, collection, props.store);
19793 setup(composite, () => sync(composite, ["renderedItems", "activeId"], (state) => {
19794 composite.setState("activeId", (activeId2) => {
19795 if (activeId2 !== void 0) return activeId2;
19796 return findFirstEnabledItem(state.renderedItems)?.id;
19797 });
19798 }));
19799 const getNextId = (direction = "next", options = {}) => {
19800 const defaultState = composite.getState();
19801 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;
19802 const isVerticalDirection = direction === "up" || direction === "down";
19803 const isNextDirection = direction === "next" || direction === "down";
19804 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
19805 const canShift = focusShift && !skip;
19806 if (!skip && !focusWrap && !includesBaseElement && activeId2 != null) {
19807 if (!isVerticalDirection ? true : !canShift && !renderedItems.some((item) => item.rowId != null)) {
19808 const activeIndex2 = renderedItems.findIndex((item) => item.id === activeId2);
19809 const activeItem2 = renderedItems[activeIndex2];
19810 if (activeItem2) {
19811 const step = canReverse ? -1 : 1;
19812 const nextId = findEnabledItemId({
19813 items: renderedItems,
19814 fromIndex: activeIndex2 + step,
19815 step,
19816 rowId: activeItem2.rowId,
19817 excludeId: activeId2
19818 });
19819 if (nextId !== void 0) return nextId;
19820 if (!(focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"))) return void 0;
19821 return findEnabledItemId({
19822 items: renderedItems,
19823 fromIndex: step === 1 ? 0 : renderedItems.length - 1,
19824 step,
19825 rowId: activeItem2.rowId,
19826 excludeId: activeId2
19827 });
19828 }
19829 }
19830 }
19831 let items = !isVerticalDirection ? renderedItems : flatten2DArray(normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift));
19832 items = canReverse ? reverseArray(items) : items;
19833 items = isVerticalDirection ? verticalizeItems(items) : items;
19834 if (activeId2 == null) return findFirstEnabledItem(items)?.id;
19835 const activeItem = items.find((item) => item.id === activeId2);
19836 if (!activeItem) return findFirstEnabledItem(items)?.id;
19837 const isGrid2 = items.some((item) => item.rowId);
19838 const activeIndex = items.indexOf(activeItem);
19839 const nextItems = items.slice(activeIndex + 1);
19840 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
19841 if (skip) {
19842 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
19843 return (nextEnabledItemsInRow.slice(skip)[0] || nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1])?.id;
19844 }
19845 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
19846 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
19847 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
19848 if (canLoop) return findFirstEnabledItem(flipItems(canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId), activeId2, hasNullItem), activeId2)?.id;
19849 if (canWrap) {
19850 const nextItem2 = findFirstEnabledItem(hasNullItem ? nextItemsInRow : nextItems, activeId2);
19851 return hasNullItem ? nextItem2?.id || null : nextItem2?.id;
19852 }
19853 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2);
19854 if (!nextItem && hasNullItem) return null;
19855 return nextItem?.id;
19856 };
19857 const getNextIdFromOptions = (direction, options) => {
19858 if (typeof options === "number") return getNextId(direction, { skip: options });
19859 return getNextId(direction, options);
19860 };
19861 return {
19862 ...collection,
19863 ...composite,
19864 setBaseElement: (element) => composite.setState("baseElement", element),
19865 setActiveId: (id) => composite.setState("activeId", id),
19866 move: (id) => {
19867 if (id === void 0) return;
19868 composite.setState("activeId", id);
19869 composite.setState("moves", (moves) => moves + 1);
19870 },
19871 first: () => findFirstEnabledItem(composite.getState().renderedItems)?.id,
19872 last: () => findFirstEnabledItem(reverseArray(composite.getState().renderedItems))?.id,
19873 next: (options) => getNextIdFromOptions("next", options),
19874 previous: (options) => getNextIdFromOptions("previous", options),
19875 down: (options) => getNextIdFromOptions("down", options),
19876 up: (options) => getNextIdFromOptions("up", options)
19877 };
19878 }
19879
19880 // node_modules/@ariakit/react-components/dist/composite/utils.js
19881 var findFirstEnabledItem2 = findFirstEnabledItem;
19882 var groupItemsByRows2 = groupItemsByRows;
19883 function getEnabledItem(store, id) {
19884 if (!id) return null;
19885 return store.item(id) || null;
19886 }
19887 function selectTextField(element, collapseToEnd = false) {
19888 if (isTextField(element)) element.setSelectionRange(collapseToEnd ? element.value.length : 0, element.value.length);
19889 else if (element.isContentEditable) {
19890 const selection = getDocument(element).getSelection();
19891 selection?.selectAllChildren(element);
19892 if (collapseToEnd) selection?.collapseToEnd();
19893 }
19894 }
19895 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
19896 function focusSilently(element) {
19897 element[FOCUS_SILENTLY] = true;
19898 element.focus({ preventScroll: true });
19899 }
19900 function silentlyFocused(element) {
19901 const isSilentlyFocused = element[FOCUS_SILENTLY];
19902 delete element[FOCUS_SILENTLY];
19903 return isSilentlyFocused;
19904 }
19905 function isItem(store, element, exclude) {
19906 if (!element) return false;
19907 if (element === exclude) return false;
19908 const item = store.item(element.id);
19909 if (!item) return false;
19910 if (exclude && item.element === exclude) return false;
19911 return true;
19912 }
19913
19914 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
19915 var import_react22 = __toESM(require_react(), 1);
19916 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
19917
19918 // node_modules/@ariakit/react-store/dist/index.js
19919 var React59 = __toESM(require_react(), 1);
19920 var import_shim2 = __toESM(require_shim(), 1);
19921 var noopSubscribe = () => () => {
19922 };
19923 function useStoreState(store, keyOrSelector = identity) {
19924 const storeSubscribe = React59.useCallback((callback) => {
19925 if (!store) return noopSubscribe();
19926 return subscribe(store, null, callback);
19927 }, [store]);
19928 const getSnapshot = () => {
19929 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
19930 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
19931 const state = store?.getState();
19932 if (selector2) return selector2(state);
19933 if (!state) return;
19934 if (!key) return;
19935 if (!hasOwnProperty(state, key)) return;
19936 return state[key];
19937 };
19938 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
19939 }
19940 function useStoreStateObject(store, object) {
19941 const objRef = React59.useRef({});
19942 const storeSubscribe = React59.useCallback((callback) => {
19943 if (!store) return noopSubscribe();
19944 return subscribe(store, null, callback);
19945 }, [store]);
19946 const getSnapshot = () => {
19947 const state = store?.getState();
19948 let updated = false;
19949 const obj = objRef.current;
19950 for (const prop in object) {
19951 const keyOrSelector = object[prop];
19952 if (typeof keyOrSelector === "function") {
19953 const value = keyOrSelector(state);
19954 if (!Object.is(value, obj[prop])) {
19955 obj[prop] = value;
19956 updated = true;
19957 }
19958 }
19959 if (typeof keyOrSelector === "string") {
19960 if (!state) continue;
19961 if (!hasOwnProperty(state, keyOrSelector)) continue;
19962 const value = state[keyOrSelector];
19963 if (!Object.is(value, obj[prop])) {
19964 obj[prop] = value;
19965 updated = true;
19966 }
19967 }
19968 }
19969 if (updated) objRef.current = { ...obj };
19970 return objRef.current;
19971 };
19972 return (0, import_shim2.useSyncExternalStore)(storeSubscribe, getSnapshot, getSnapshot);
19973 }
19974 function useStoreProps(store, props, key, setKey) {
19975 const value = hasOwnProperty(props, key) ? props[key] : void 0;
19976 const propsRef = useLiveRef({
19977 value,
19978 setValue: setKey ? props[setKey] : void 0
19979 });
19980 useSafeLayoutEffect(() => {
19981 return sync(store, [key], (state, prev) => {
19982 const { value: value2, setValue } = propsRef.current;
19983 if (!setValue) return;
19984 if (state[key] === prev[key]) return;
19985 if (state[key] === value2) return;
19986 setValue(state[key]);
19987 });
19988 }, [store, key]);
19989 useSafeLayoutEffect(() => {
19990 if (value === void 0) return;
19991 store.setState(key, value);
19992 return batch(store, [key], () => {
19993 if (value === void 0) return;
19994 store.setState(key, value);
19995 });
19996 });
19997 }
19998 function useStore2(createStore2, props) {
19999 const [store, setStore] = React59.useState(() => createStore2(props));
20000 useSafeLayoutEffect(() => init(store), [store]);
20001 const useState48 = React59.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
20002 return [React59.useMemo(() => ({
20003 ...store,
20004 useState: useState48
20005 }), [store, useState48]), useEvent(() => {
20006 setStore((store2) => createStore2({
20007 ...props,
20008 ...store2.getState()
20009 }));
20010 })];
20011 }
20012
20013 // node_modules/@ariakit/react-components/dist/composite/composite-item.js
20014 var TagName4 = "button";
20015 function isEditableElement(element) {
20016 if (isTextbox(element)) return true;
20017 return element.tagName === "INPUT" && !isButton(element);
20018 }
20019 function getNextPageOffset(scrollingElement, pageUp = false) {
20020 const height = scrollingElement.clientHeight;
20021 const { top } = scrollingElement.getBoundingClientRect();
20022 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
20023 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
20024 if (scrollingElement.tagName === "HTML") return pageOffset + scrollingElement.scrollTop;
20025 return pageOffset;
20026 }
20027 function getItemOffset(itemElement, pageUp = false) {
20028 const { top } = itemElement.getBoundingClientRect();
20029 if (pageUp) return top + itemElement.clientHeight;
20030 return top;
20031 }
20032 function findNextPageItemId(element, store, next, pageUp = false) {
20033 if (!store) return;
20034 if (!next) return;
20035 const { renderedItems } = store.getState();
20036 const scrollingElement = getScrollingElement(element);
20037 if (!scrollingElement) return;
20038 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
20039 let id;
20040 let prevDifference;
20041 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
20042 const previousId = id;
20043 id = next(i2);
20044 if (!id) break;
20045 if (id === previousId) continue;
20046 const itemElement = getEnabledItem(store, id)?.element;
20047 if (!itemElement) continue;
20048 const difference = getItemOffset(itemElement, pageUp) - nextPageOffset;
20049 const absDifference = Math.abs(difference);
20050 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
20051 if (prevDifference !== void 0 && prevDifference < absDifference) id = previousId;
20052 break;
20053 }
20054 prevDifference = absDifference;
20055 }
20056 return id;
20057 }
20058 function targetIsAnotherItem(event, store) {
20059 if (isSelfTarget(event)) return false;
20060 return isItem(store, event.target);
20061 }
20062 var useCompositeItem = createHook(function useCompositeItem2({ store, rowId: rowIdProp, preventScrollOnKeyDown = false, moveOnKeyPress = true, tabbable: tabbable2 = false, getItem: getItemProp, "aria-setsize": ariaSetSizeProp, "aria-posinset": ariaPosInSetProp, ...props }) {
20063 const context = useCompositeScopedContext();
20064 store = store || context;
20065 const id = useId5(props.id);
20066 const ref = (0, import_react22.useRef)(null);
20067 const row = (0, import_react22.useContext)(CompositeRowContext);
20068 const trulyDisabled = disabledFromProps(props) && !props.accessibleWhenDisabled;
20069 const shouldRegisterItem = props.shouldRegisterItem;
20070 const getRowId = (state) => {
20071 if (rowIdProp) return rowIdProp;
20072 if (!state) return;
20073 if (!row?.baseElement) return;
20074 if (row.baseElement !== state.baseElement) return;
20075 return row.id;
20076 };
20077 const { rowId, baseElement, isActiveItem, ariaSetSize, ariaPosInSet, isTabbable } = useStoreStateObject(store, {
20078 rowId: getRowId,
20079 baseElement(state) {
20080 return state?.baseElement || void 0;
20081 },
20082 isActiveItem(state) {
20083 return !!state && state.activeId === id;
20084 },
20085 ariaSetSize(state) {
20086 if (ariaSetSizeProp != null) return ariaSetSizeProp;
20087 if (!state) return;
20088 if (!row?.ariaSetSize) return;
20089 if (row.baseElement !== state.baseElement) return;
20090 return row.ariaSetSize;
20091 },
20092 ariaPosInSet(state) {
20093 if (ariaPosInSetProp != null) return ariaPosInSetProp;
20094 if (!state) return;
20095 if (!row?.ariaPosInSet) return;
20096 if (row.baseElement !== state.baseElement) return;
20097 const rowId2 = getRowId(state);
20098 const itemsInRow = state.renderedItems.filter((item) => item.rowId === rowId2);
20099 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
20100 },
20101 isTabbable(state) {
20102 if (!state?.renderedItems.length) return true;
20103 if (state.virtualFocus) return false;
20104 if (tabbable2) return true;
20105 if (state.activeId === null) return false;
20106 const item = store?.item(state.activeId);
20107 if (item?.disabled) return true;
20108 if (!item?.element) return true;
20109 return state.activeId === id;
20110 }
20111 });
20112 const getItem = (0, import_react22.useCallback)((item) => {
20113 const nextItem = {
20114 ...item,
20115 id: id || item.id,
20116 rowId,
20117 disabled: trulyDisabled,
20118 children: item.element?.textContent
20119 };
20120 if (getItemProp) return getItemProp(nextItem);
20121 return nextItem;
20122 }, [
20123 id,
20124 rowId,
20125 trulyDisabled,
20126 getItemProp
20127 ]);
20128 const onFocusProp = props.onFocus;
20129 const hasFocusedComposite = (0, import_react22.useRef)(false);
20130 const cancelScheduledFocusRedirectRef = (0, import_react22.useRef)(null);
20131 const onFocus = useEvent((event) => {
20132 onFocusProp?.(event);
20133 if (event.defaultPrevented) return;
20134 if (isPortalEvent(event)) return;
20135 if (!id) return;
20136 if (!store) return;
20137 if (targetIsAnotherItem(event, store)) return;
20138 const { virtualFocus, baseElement: baseElement2 } = store.getState();
20139 store.setActiveId(id);
20140 if (isTextbox(event.currentTarget)) selectTextField(event.currentTarget);
20141 if (!virtualFocus) return;
20142 if (!isSelfTarget(event)) return;
20143 if (isEditableElement(event.currentTarget)) return;
20144 const redirectFocusToBaseElement = (currentTarget2, relatedTarget2, baseElement3) => {
20145 if (isSafari() && currentTarget2.hasAttribute("data-autofocus")) currentTarget2.scrollIntoView({
20146 block: "nearest",
20147 inline: "nearest"
20148 });
20149 hasFocusedComposite.current = true;
20150 if (relatedTarget2 === baseElement3 || isItem(store, relatedTarget2)) focusSilently(baseElement3);
20151 else baseElement3.focus();
20152 };
20153 if (baseElement2?.isConnected) {
20154 redirectFocusToBaseElement(event.currentTarget, event.relatedTarget, baseElement2);
20155 return;
20156 }
20157 if (shouldRegisterItem === false) return;
20158 const { currentTarget, relatedTarget } = event;
20159 const cancelScheduledFocusRedirect = () => {
20160 cancelScheduledFocusRedirectRef.current?.();
20161 cancelScheduledFocusRedirectRef.current = null;
20162 };
20163 cancelScheduledFocusRedirect();
20164 cancelScheduledFocusRedirectRef.current = subscribe(store, null, () => {
20165 if (getActiveElement(currentTarget) !== currentTarget) {
20166 cancelScheduledFocusRedirect();
20167 return;
20168 }
20169 const state = store.getState();
20170 const nextBaseElement = state.baseElement;
20171 if (!nextBaseElement?.isConnected) return;
20172 cancelScheduledFocusRedirect();
20173 if (!state.virtualFocus) return;
20174 redirectFocusToBaseElement(currentTarget, relatedTarget, nextBaseElement);
20175 });
20176 });
20177 const onBlurCaptureProp = props.onBlurCapture;
20178 const onBlurCapture = useEvent((event) => {
20179 onBlurCaptureProp?.(event);
20180 if (event.defaultPrevented) return;
20181 if (store?.getState()?.virtualFocus && hasFocusedComposite.current) {
20182 hasFocusedComposite.current = false;
20183 event.preventDefault();
20184 event.stopPropagation();
20185 }
20186 });
20187 const onKeyDownProp = props.onKeyDown;
20188 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
20189 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
20190 const onKeyDown = useEvent((event) => {
20191 onKeyDownProp?.(event);
20192 if (event.defaultPrevented) return;
20193 if (!isSelfTarget(event)) return;
20194 if (!store) return;
20195 const { currentTarget } = event;
20196 const state = store.getState();
20197 const isGrid2 = !!store.item(id)?.rowId;
20198 const isVertical = state.orientation !== "horizontal";
20199 const isHorizontal = state.orientation !== "vertical";
20200 const canHomeEnd = () => {
20201 if (isGrid2) return true;
20202 if (isHorizontal) return true;
20203 if (!state.baseElement) return true;
20204 if (!isTextField(state.baseElement)) return true;
20205 return false;
20206 };
20207 const action = {
20208 ArrowUp: (isGrid2 || isVertical) && store.up,
20209 ArrowRight: (isGrid2 || isHorizontal) && store.next,
20210 ArrowDown: (isGrid2 || isVertical) && store.down,
20211 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
20212 Home: () => {
20213 if (!canHomeEnd()) return;
20214 if (!isGrid2 || event.ctrlKey) return store?.first();
20215 return store?.previous(-1);
20216 },
20217 End: () => {
20218 if (!canHomeEnd()) return;
20219 if (!isGrid2 || event.ctrlKey) return store?.last();
20220 return store?.next(-1);
20221 },
20222 PageUp: () => {
20223 return findNextPageItemId(currentTarget, store, store?.up, true);
20224 },
20225 PageDown: () => {
20226 return findNextPageItemId(currentTarget, store, store?.down);
20227 }
20228 }[event.key];
20229 if (action) {
20230 if (isTextbox(currentTarget)) {
20231 const selection = getTextboxSelection(currentTarget);
20232 const isLeft = isHorizontal && event.key === "ArrowLeft";
20233 const isRight = isHorizontal && event.key === "ArrowRight";
20234 const isUp = isVertical && event.key === "ArrowUp";
20235 const isDown = isVertical && event.key === "ArrowDown";
20236 if (isRight || isDown) {
20237 const { length: valueLength } = getTextboxValue(currentTarget);
20238 if (selection.end !== valueLength) return;
20239 } else if ((isLeft || isUp) && selection.start !== 0) return;
20240 }
20241 const nextId = action();
20242 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
20243 if (!moveOnKeyPressProp(event)) return;
20244 event.preventDefault();
20245 store.move(nextId);
20246 }
20247 }
20248 });
20249 const providerValue = (0, import_react22.useMemo)(() => ({
20250 id,
20251 baseElement
20252 }), [id, baseElement]);
20253 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(CompositeItemContext.Provider, {
20254 value: providerValue,
20255 children: element
20256 }), [providerValue]);
20257 props = {
20258 "data-active-item": isActiveItem || void 0,
20259 ...props,
20260 id,
20261 ref: useMergeRefs(ref, props.ref),
20262 tabIndex: isTabbable ? props.tabIndex : -1,
20263 onFocus,
20264 onBlurCapture,
20265 onKeyDown
20266 };
20267 props = useCommand(props);
20268 props = useCollectionItem({
20269 store,
20270 ...props,
20271 getItem,
20272 shouldRegisterItem: id ? shouldRegisterItem : false
20273 });
20274 return removeUndefinedValues({
20275 ...props,
20276 "aria-setsize": ariaSetSize,
20277 "aria-posinset": ariaPosInSet
20278 });
20279 });
20280 var CompositeItem = memo3(forwardRef49(function CompositeItem2(props) {
20281 return createElement3(TagName4, useCompositeItem(props));
20282 }));
20283
20284 // node_modules/@ariakit/react-components/dist/composite/composite.js
20285 var import_react23 = __toESM(require_react(), 1);
20286 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
20287 var TagName5 = "div";
20288 function isGrid(items) {
20289 return items.some((item) => !!item.rowId);
20290 }
20291 function isPrintableKey(event) {
20292 const target = event.target;
20293 if (target && !isTextField(target)) return false;
20294 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
20295 }
20296 function isModifierKey(event) {
20297 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
20298 }
20299 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
20300 return useEvent((event) => {
20301 onKeyboardEvent?.(event);
20302 if (event.defaultPrevented) return;
20303 if (event.isPropagationStopped()) return;
20304 if (!isSelfTarget(event)) return;
20305 if (isModifierKey(event)) return;
20306 if (isPrintableKey(event)) return;
20307 const activeElement2 = getEnabledItem(store, store.getState().activeId)?.element;
20308 if (!activeElement2) return;
20309 const { view, ...eventInit } = event;
20310 if (activeElement2 !== previousElementRef?.current) activeElement2.focus();
20311 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) event.preventDefault();
20312 if (event.currentTarget.contains(activeElement2)) event.stopPropagation();
20313 });
20314 }
20315 function findFirstEnabledItemInTheLastRow(items) {
20316 return findFirstEnabledItem2(flatten2DArray(reverseArray(groupItemsByRows2(items))));
20317 }
20318 function withBaseScrollPreserved(store, callback) {
20319 const { virtualFocus, baseElement } = store.getState();
20320 if (!virtualFocus || !baseElement || !isTextField(baseElement)) {
20321 callback();
20322 return;
20323 }
20324 const savedScrollLeft = baseElement.scrollLeft;
20325 const savedScrollTop = baseElement.scrollTop;
20326 callback();
20327 baseElement.scrollLeft = savedScrollLeft;
20328 baseElement.scrollTop = savedScrollTop;
20329 }
20330 function useScheduleFocus(store) {
20331 const [scheduled, setScheduled] = (0, import_react23.useState)(false);
20332 const schedule = (0, import_react23.useCallback)(() => setScheduled(true), []);
20333 const activeItem = useStoreState(store, (state) => scheduled ? getEnabledItem(store, state.activeId) : null);
20334 (0, import_react23.useEffect)(() => {
20335 const activeElement2 = activeItem?.element;
20336 if (!scheduled) return;
20337 if (!activeElement2) return;
20338 setScheduled(false);
20339 withBaseScrollPreserved(store, () => {
20340 activeElement2.focus({ preventScroll: true });
20341 });
20342 }, [
20343 store,
20344 activeItem,
20345 scheduled
20346 ]);
20347 return schedule;
20348 }
20349 var CompositeFocusOnMove = memo3(function CompositeFocusOnMove2({ store, focusOnMove, previousElementRef }) {
20350 const moves = useStoreState(store, "moves");
20351 const baseElement = useStoreState(store, "baseElement");
20352 (0, import_react23.useEffect)(() => {
20353 if (!moves) return;
20354 if (!focusOnMove) return;
20355 const { activeId } = store.getState();
20356 const itemElement = getEnabledItem(store, activeId)?.element;
20357 if (!itemElement) return;
20358 withBaseScrollPreserved(store, () => focusIntoView(itemElement));
20359 }, [
20360 store,
20361 moves,
20362 focusOnMove
20363 ]);
20364 useSafeLayoutEffect(() => {
20365 if (!moves) return;
20366 if (!baseElement) return;
20367 const { activeId } = store.getState();
20368 if (!(activeId === null)) return;
20369 const previousElement = previousElementRef.current;
20370 previousElementRef.current = null;
20371 if (previousElement) fireBlurEvent(previousElement, { relatedTarget: baseElement });
20372 if (!hasFocus(baseElement)) baseElement.focus();
20373 }, [
20374 store,
20375 moves,
20376 baseElement
20377 ]);
20378 return null;
20379 });
20380 var useComposite = createHook(function useComposite2({ store, composite = true, focusOnMove = composite, moveOnKeyPress = true, ...props }) {
20381 const context = useCompositeProviderContext();
20382 store = store || context;
20383 invariant(store, "Composite must receive a `store` prop or be wrapped in a CompositeProvider component.");
20384 const ref = (0, import_react23.useRef)(null);
20385 const previousElementRef = (0, import_react23.useRef)(null);
20386 const scheduleFocus = useScheduleFocus(store);
20387 const [, setBaseElement] = useTransactionState(composite ? store.setBaseElement : null);
20388 const virtualFocus = useStoreState(store, "virtualFocus");
20389 const activeId = useStoreState(store, (state) => state.virtualFocus ? state.activeId : null);
20390 useSafeLayoutEffect(() => {
20391 if (!store) return;
20392 if (!composite) return;
20393 if (!virtualFocus) return;
20394 const previousElement = previousElementRef.current;
20395 previousElementRef.current = null;
20396 if (!previousElement) return;
20397 const relatedTarget = getEnabledItem(store, activeId)?.element || getActiveElement(previousElement);
20398 if (relatedTarget === previousElement) return;
20399 fireBlurEvent(previousElement, { relatedTarget });
20400 }, [
20401 store,
20402 activeId,
20403 virtualFocus,
20404 composite
20405 ]);
20406 const onKeyDownCapture = useKeyboardEventProxy(store, props.onKeyDownCapture, previousElementRef);
20407 const onKeyUpCapture = useKeyboardEventProxy(store, props.onKeyUpCapture, previousElementRef);
20408 const onFocusCaptureProp = props.onFocusCapture;
20409 const onFocusCapture = useEvent((event) => {
20410 onFocusCaptureProp?.(event);
20411 if (event.defaultPrevented) return;
20412 if (!store) return;
20413 const { virtualFocus: virtualFocus2 } = store.getState();
20414 if (!virtualFocus2) return;
20415 const previousActiveElement = event.relatedTarget;
20416 const isSilentlyFocused = silentlyFocused(event.currentTarget);
20417 if (isSelfTarget(event) && isSilentlyFocused) {
20418 event.stopPropagation();
20419 previousElementRef.current = previousActiveElement;
20420 }
20421 });
20422 const onFocusProp = props.onFocus;
20423 const onFocus = useEvent((event) => {
20424 onFocusProp?.(event);
20425 if (event.defaultPrevented) return;
20426 if (!composite) return;
20427 if (!store) return;
20428 const { relatedTarget } = event;
20429 const { virtualFocus: virtualFocus2 } = store.getState();
20430 if (virtualFocus2) {
20431 if (isSelfTarget(event) && !isItem(store, relatedTarget)) queueMicrotask(scheduleFocus);
20432 } else if (isSelfTarget(event)) store.setActiveId(null);
20433 });
20434 const onBlurCaptureProp = props.onBlurCapture;
20435 const onBlurCapture = useEvent((event) => {
20436 onBlurCaptureProp?.(event);
20437 if (event.defaultPrevented) return;
20438 if (!store) return;
20439 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
20440 if (!virtualFocus2) return;
20441 const activeElement2 = getEnabledItem(store, activeId2)?.element;
20442 const nextActiveElement = event.relatedTarget;
20443 const nextActiveElementIsItem = isItem(store, nextActiveElement);
20444 const previousElement = previousElementRef.current;
20445 previousElementRef.current = null;
20446 if (isSelfTarget(event) && nextActiveElementIsItem) {
20447 if (nextActiveElement === activeElement2) {
20448 if (previousElement && previousElement !== nextActiveElement) fireBlurEvent(previousElement, event);
20449 } else if (activeElement2) fireBlurEvent(activeElement2, event);
20450 else if (previousElement) fireBlurEvent(previousElement, event);
20451 event.stopPropagation();
20452 } else if (!isItem(store, event.target) && activeElement2) fireBlurEvent(activeElement2, event);
20453 });
20454 const onKeyDownProp = props.onKeyDown;
20455 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
20456 const onKeyDown = useEvent((event) => {
20457 onKeyDownProp?.(event);
20458 if (event.nativeEvent.isComposing) return;
20459 if (event.defaultPrevented) return;
20460 if (!store) return;
20461 if (!isSelfTarget(event)) return;
20462 const { orientation, renderedItems, activeId: activeId2, rtl } = store.getState();
20463 if (getEnabledItem(store, activeId2)?.element?.isConnected) return;
20464 const isVertical = orientation !== "horizontal";
20465 const isHorizontal = orientation !== "vertical";
20466 const grid = isGrid(renderedItems);
20467 if ((event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") && isTextField(event.currentTarget)) return;
20468 const up = () => {
20469 if (grid) return findFirstEnabledItemInTheLastRow(renderedItems)?.id;
20470 return store?.last();
20471 };
20472 const action = {
20473 ArrowUp: (grid || isVertical) && up,
20474 ArrowRight: (grid || isHorizontal) && (rtl ? store.last : store.first),
20475 ArrowDown: (grid || isVertical) && store.first,
20476 ArrowLeft: (grid || isHorizontal) && (rtl ? store.first : store.last),
20477 Home: store.first,
20478 End: store.last,
20479 PageUp: store.first,
20480 PageDown: store.last
20481 }[event.key];
20482 if (action) {
20483 const id = action();
20484 if (id !== void 0) {
20485 if (!moveOnKeyPressProp(event)) return;
20486 event.preventDefault();
20487 store.move(id);
20488 }
20489 }
20490 });
20491 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(CompositeScopedContextProvider, {
20492 value: store,
20493 children: [element, composite && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(CompositeFocusOnMove, {
20494 store,
20495 focusOnMove,
20496 previousElementRef
20497 })]
20498 }), [
20499 store,
20500 composite,
20501 focusOnMove
20502 ]);
20503 props = {
20504 "aria-activedescendant": useStoreState(store, (state) => {
20505 if (!store) return;
20506 if (!composite) return;
20507 if (!state.virtualFocus) return;
20508 return getEnabledItem(store, state.activeId)?.id;
20509 }),
20510 ...props,
20511 ref: useMergeRefs(ref, setBaseElement, props.ref),
20512 onKeyDownCapture,
20513 onKeyUpCapture,
20514 onFocusCapture,
20515 onFocus,
20516 onBlurCapture,
20517 onKeyDown
20518 };
20519 props = useFocusable({
20520 focusable: useStoreState(store, (state) => composite && (state.virtualFocus || state.activeId === null)),
20521 ...props
20522 });
20523 return props;
20524 });
20525 var Composite6 = forwardRef49(function Composite7(props) {
20526 return createElement3(TagName5, useComposite(props));
20527 });
20528
20529 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-context.js
20530 var ctx3 = createStoreContext();
20531 var useDisclosureContext = ctx3.useContext;
20532 var useDisclosureScopedContext = ctx3.useScopedContext;
20533 var useDisclosureProviderContext = ctx3.useProviderContext;
20534 var DisclosureContextProvider = ctx3.ContextProvider;
20535 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
20536
20537 // node_modules/@ariakit/react-components/dist/dialog/dialog-context.js
20538 var import_react24 = __toESM(require_react(), 1);
20539 var ctx4 = createStoreContext([DisclosureContextProvider], [DisclosureScopedContextProvider]);
20540 var useDialogContext = ctx4.useContext;
20541 var useDialogScopedContext = ctx4.useScopedContext;
20542 var useDialogProviderContext = ctx4.useProviderContext;
20543 var DialogContextProvider = ctx4.ContextProvider;
20544 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
20545 var DialogHeadingContext = (0, import_react24.createContext)(void 0);
20546 var DialogDescriptionContext = (0, import_react24.createContext)(void 0);
20547
20548 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-content.js
20549 var import_react25 = __toESM(require_react(), 1);
20550 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
20551 var import_react_dom4 = __toESM(require_react_dom(), 1);
20552 var TagName6 = "div";
20553 function afterTimeout(timeoutMs, cb) {
20554 const timeoutId = setTimeout(cb, timeoutMs);
20555 return () => clearTimeout(timeoutId);
20556 }
20557 function parseCSSTime(time) {
20558 const value = time?.trim() || "0s";
20559 const multiplier = value.endsWith("ms") ? 1 : 1e3;
20560 const parsed = Number.parseFloat(value) * multiplier;
20561 return Number.isNaN(parsed) ? 0 : parsed;
20562 }
20563 function getEndTime(names, delays, durations) {
20564 const nameList = names.split(",");
20565 const delayList = delays.split(",");
20566 const durationList = durations.split(",");
20567 let endTime = 0;
20568 for (const [index2, name] of nameList.entries()) {
20569 if (name.trim() === "none") continue;
20570 const delay = parseCSSTime(delayList[index2 % delayList.length]);
20571 const duration = parseCSSTime(durationList[index2 % durationList.length]);
20572 endTime = Math.max(endTime, delay + duration);
20573 }
20574 return endTime;
20575 }
20576 function getElementEndTime(element) {
20577 const { transitionProperty, transitionDuration, transitionDelay, animationName, animationDuration, animationDelay } = getComputedStyle(element);
20578 return Math.max(getEndTime(transitionProperty, transitionDelay, transitionDuration), getEndTime(animationName, animationDelay, animationDuration));
20579 }
20580 function isHidden(mounted, hidden, alwaysVisible) {
20581 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
20582 }
20583 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, unstable_otherElementRef: otherElementRef, ...props }) {
20584 const context = useDisclosureProviderContext();
20585 store = store || context;
20586 invariant(store, "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.");
20587 const ref = (0, import_react25.useRef)(null);
20588 const id = useId5(props.id);
20589 const [transition, setTransition] = (0, import_react25.useState)(null);
20590 const open = useStoreState(store, "open");
20591 const mounted = useStoreState(store, "mounted");
20592 const animated = useStoreState(store, "animated");
20593 const contentElement = useStoreState(store, "contentElement");
20594 const otherElement = useStoreState(store.disclosure, "contentElement");
20595 const hasClosedRef = (0, import_react25.useRef)(false);
20596 useSafeLayoutEffect(() => {
20597 if (!ref.current) return;
20598 store?.setContentElement(ref.current);
20599 }, [store]);
20600 useSafeLayoutEffect(() => {
20601 let previousAnimated;
20602 store?.setState("animated", (animated2) => {
20603 previousAnimated = animated2;
20604 return true;
20605 });
20606 return () => {
20607 if (previousAnimated === void 0) return;
20608 store?.setState("animated", previousAnimated);
20609 };
20610 }, [store]);
20611 useSafeLayoutEffect(() => {
20612 if (!animated) {
20613 if (!open) {
20614 hasClosedRef.current = true;
20615 setTransition(null);
20616 } else if (hasClosedRef.current) {
20617 hasClosedRef.current = false;
20618 setTransition("enter");
20619 }
20620 return;
20621 }
20622 if (!contentElement?.isConnected) {
20623 setTransition(null);
20624 return;
20625 }
20626 return afterPaint(() => {
20627 setTransition(open ? "enter" : mounted ? "leave" : null);
20628 });
20629 }, [
20630 animated,
20631 contentElement,
20632 open,
20633 mounted
20634 ]);
20635 useSafeLayoutEffect(() => {
20636 if (!store) return;
20637 if (!animated) return;
20638 if (!transition) return;
20639 if (!contentElement) return;
20640 const stopAnimation = () => store?.setState("animating", false);
20641 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
20642 if (transition === "leave" && open) return;
20643 if (transition === "enter" && !open) return;
20644 if (typeof animated === "number") return afterTimeout(animated, stopAnimationSync);
20645 const elements = [contentElement];
20646 if (otherElement) elements.push(otherElement);
20647 const relatedElement = otherElementRef?.current;
20648 if (relatedElement) elements.push(relatedElement);
20649 const timeout = Math.max(...elements.map(getElementEndTime));
20650 if (!timeout) {
20651 if (transition === "enter") store.setState("animated", false);
20652 stopAnimation();
20653 return;
20654 }
20655 return afterTimeout(Math.max(timeout - 1e3 / 60, 0), stopAnimationSync);
20656 }, [
20657 store,
20658 animated,
20659 contentElement,
20660 otherElement,
20661 otherElementRef,
20662 open,
20663 transition
20664 ]);
20665 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DialogScopedContextProvider, {
20666 value: store,
20667 children: element
20668 }), [store]);
20669 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
20670 const styleProp = props.style;
20671 const style = (0, import_react25.useMemo)(() => {
20672 if (hidden) return {
20673 ...styleProp,
20674 display: "none"
20675 };
20676 return styleProp;
20677 }, [hidden, styleProp]);
20678 props = {
20679 "data-open": open || void 0,
20680 "data-enter": transition === "enter" || void 0,
20681 "data-leave": transition === "leave" || void 0,
20682 hidden,
20683 ...props,
20684 id,
20685 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
20686 style
20687 };
20688 return removeUndefinedValues(props);
20689 });
20690 var DisclosureContentImpl = forwardRef49(function DisclosureContentImpl2(props) {
20691 return createElement3(TagName6, useDisclosureContent(props));
20692 });
20693 var DisclosureContent = forwardRef49(function DisclosureContent2({ unmountOnHide, ...props }) {
20694 const context = useDisclosureProviderContext();
20695 if (useStoreState(props.store || context, (state) => !unmountOnHide || state?.mounted) === false) return null;
20696 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DisclosureContentImpl, { ...props });
20697 });
20698
20699 // node_modules/@ariakit/components/dist/disclosure/disclosure-store.js
20700 function createDisclosureStore(props = {}) {
20701 const store = mergeStore(props.store, omit2(props.disclosure, ["contentElement", "disclosureElement"]));
20702 throwOnConflictingProps(props, store);
20703 const syncState = store?.getState();
20704 const open = defaultValue(props.open, syncState?.open, props.defaultOpen, false);
20705 const animated = defaultValue(props.animated, syncState?.animated, false);
20706 const disclosure = createStore({
20707 open,
20708 animated,
20709 animating: !!animated && open,
20710 mounted: open,
20711 contentElement: defaultValue(syncState?.contentElement, null),
20712 disclosureElement: defaultValue(syncState?.disclosureElement, null)
20713 }, store);
20714 setup(disclosure, () => sync(disclosure, ["animated", "animating"], (state) => {
20715 if (state.animated) return;
20716 disclosure.setState("animating", false);
20717 }));
20718 setup(disclosure, () => subscribe(disclosure, ["open"], () => {
20719 if (!disclosure.getState().animated) return;
20720 disclosure.setState("animating", true);
20721 }));
20722 setup(disclosure, () => sync(disclosure, ["open", "animating"], (state) => {
20723 disclosure.setState("mounted", state.open || state.animating);
20724 }));
20725 return {
20726 ...disclosure,
20727 disclosure: props.disclosure,
20728 setOpen: (value) => disclosure.setState("open", value),
20729 show: () => disclosure.setState("open", true),
20730 hide: () => disclosure.setState("open", false),
20731 toggle: () => disclosure.setState("open", (open2) => !open2),
20732 stopAnimation: () => disclosure.setState("animating", false),
20733 setContentElement: (value) => disclosure.setState("contentElement", value),
20734 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
20735 };
20736 }
20737
20738 // node_modules/@ariakit/react-components/dist/disclosure/disclosure-store.js
20739 function useDisclosureStoreProps(store, update2, props) {
20740 useUpdateEffect(update2, [props.store, props.disclosure]);
20741 useStoreProps(store, props, "open", "setOpen");
20742 useStoreProps(store, props, "mounted", "setMounted");
20743 useStoreProps(store, props, "animated");
20744 return Object.assign(store, { disclosure: props.disclosure });
20745 }
20746
20747 // node_modules/@ariakit/react-components/dist/popover/popover-context.js
20748 var ctx5 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
20749 var usePopoverContext = ctx5.useContext;
20750 var usePopoverScopedContext = ctx5.useScopedContext;
20751 var usePopoverProviderContext = ctx5.useProviderContext;
20752 var PopoverContextProvider = ctx5.ContextProvider;
20753 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
20754
20755 // node_modules/@ariakit/react-components/dist/combobox/combobox-context.js
20756 var import_react26 = __toESM(require_react(), 1);
20757 var ComboboxListRoleContext = (0, import_react26.createContext)(void 0);
20758 var ctx6 = createStoreContext([PopoverContextProvider, CompositeContextProvider], [PopoverScopedContextProvider, CompositeScopedContextProvider]);
20759 var useComboboxContext = ctx6.useContext;
20760 var useComboboxScopedContext = ctx6.useScopedContext;
20761 var useComboboxProviderContext = ctx6.useProviderContext;
20762 var ComboboxContextProvider = ctx6.ContextProvider;
20763 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
20764 var ComboboxItemValueContext = (0, import_react26.createContext)(void 0);
20765 var ComboboxItemCheckedContext = (0, import_react26.createContext)(false);
20766
20767 // node_modules/@ariakit/react-components/dist/collection/collection-store.js
20768 function useCollectionStoreProps(store, update2, props) {
20769 useUpdateEffect(update2, [props.store]);
20770 useStoreProps(store, props, "items", "setItems");
20771 return store;
20772 }
20773
20774 // node_modules/@ariakit/react-components/dist/composite/composite-store.js
20775 function useCompositeStoreOptions(props) {
20776 return {
20777 id: useId5(props.id),
20778 ...props
20779 };
20780 }
20781 function useCompositeStoreProps(store, update2, props) {
20782 store = useCollectionStoreProps(store, update2, props);
20783 useStoreProps(store, props, "activeId", "setActiveId");
20784 useStoreProps(store, props, "includesBaseElement");
20785 useStoreProps(store, props, "virtualFocus");
20786 useStoreProps(store, props, "orientation");
20787 useStoreProps(store, props, "rtl");
20788 useStoreProps(store, props, "focusLoop");
20789 useStoreProps(store, props, "focusWrap");
20790 useStoreProps(store, props, "focusShift");
20791 return store;
20792 }
20793
20794 // node_modules/@ariakit/components/dist/dialog/dialog-store.js
20795 function createDialogStore(props = {}) {
20796 return createDisclosureStore(props);
20797 }
20798
20799 // node_modules/@ariakit/react-components/dist/dialog/dialog-store.js
20800 function useDialogStoreProps(store, update2, props) {
20801 return useDisclosureStoreProps(store, update2, props);
20802 }
20803
20804 // node_modules/@ariakit/components/dist/popover/popover-store.js
20805 function createPopoverStore({ popover: otherPopover, ...props } = {}) {
20806 const store = mergeStore(props.store, omit2(otherPopover, [
20807 "arrowElement",
20808 "anchorElement",
20809 "contentElement",
20810 "popoverElement",
20811 "disclosureElement"
20812 ]));
20813 throwOnConflictingProps(props, store);
20814 const syncState = store?.getState();
20815 const dialog = createDialogStore({
20816 ...props,
20817 store
20818 });
20819 const placement = defaultValue(props.placement, syncState?.placement, "bottom");
20820 const popover = createStore({
20821 ...dialog.getState(),
20822 placement,
20823 currentPlacement: placement,
20824 anchorElement: defaultValue(syncState?.anchorElement, null),
20825 popoverElement: defaultValue(syncState?.popoverElement, null),
20826 arrowElement: defaultValue(syncState?.arrowElement, null),
20827 rendered: /* @__PURE__ */ Symbol("rendered")
20828 }, dialog, store);
20829 return {
20830 ...dialog,
20831 ...popover,
20832 setAnchorElement: (element) => popover.setState("anchorElement", element),
20833 setPopoverElement: (element) => popover.setState("popoverElement", element),
20834 setArrowElement: (element) => popover.setState("arrowElement", element),
20835 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
20836 };
20837 }
20838
20839 // node_modules/@ariakit/react-components/dist/popover/popover-store.js
20840 function usePopoverStoreProps(store, update2, props) {
20841 useUpdateEffect(update2, [props.popover]);
20842 useStoreProps(store, props, "placement");
20843 return useDialogStoreProps(store, update2, props);
20844 }
20845
20846 // node_modules/@ariakit/react-components/dist/popover/popover-anchor.js
20847 var TagName7 = "div";
20848 var usePopoverAnchor = createHook(function usePopoverAnchor2({ store, ...props }) {
20849 const context = usePopoverProviderContext();
20850 store = store || context;
20851 props = {
20852 ...props,
20853 ref: useMergeRefs(store?.setAnchorElement, props.ref)
20854 };
20855 return props;
20856 });
20857 var PopoverAnchor = forwardRef49(function PopoverAnchor2(props) {
20858 return createElement3(TagName7, usePopoverAnchor(props));
20859 });
20860
20861 // node_modules/@ariakit/react-components/dist/composite/composite-hover.js
20862 var import_react27 = __toESM(require_react(), 1);
20863 var TagName8 = "div";
20864 function hoveringInside(event) {
20865 const nextElement = event.relatedTarget;
20866 if (!isElement2(nextElement)) return false;
20867 return contains2(event.currentTarget, nextElement);
20868 }
20869 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
20870 function movingToAnotherItem(event) {
20871 const { relatedTarget } = event;
20872 if (!isElement2(relatedTarget)) return false;
20873 let dest = relatedTarget;
20874 do {
20875 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
20876 dest = dest.parentElement;
20877 } while (dest);
20878 return false;
20879 }
20880 var useCompositeHover = createHook(function useCompositeHover2({ store, focusOnHover = true, blurOnHoverEnd = !!focusOnHover, ...props }) {
20881 const context = useCompositeScopedContext();
20882 store = store || context;
20883 invariant(store, "CompositeHover must be wrapped in a Composite component.");
20884 const isMouseMoving = useIsMouseMoving();
20885 const onMouseMoveProp = props.onMouseMove;
20886 const focusOnHoverProp = useBooleanEvent(focusOnHover);
20887 const onMouseMove = useEvent((event) => {
20888 onMouseMoveProp?.(event);
20889 if (event.defaultPrevented) return;
20890 if (!isMouseMoving()) return;
20891 if (!focusOnHoverProp(event)) return;
20892 if (!hasFocusWithin(event.currentTarget)) {
20893 const baseElement = store?.getState().baseElement;
20894 if (baseElement && !hasFocus(baseElement)) baseElement.focus();
20895 }
20896 store?.setActiveId(event.currentTarget.id);
20897 });
20898 const onMouseLeaveProp = props.onMouseLeave;
20899 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
20900 const onMouseLeave = useEvent((event) => {
20901 onMouseLeaveProp?.(event);
20902 if (event.defaultPrevented) return;
20903 if (!isMouseMoving()) return;
20904 if (hoveringInside(event)) return;
20905 if (movingToAnotherItem(event)) return;
20906 if (!focusOnHoverProp(event)) return;
20907 if (!blurOnHoverEndProp(event)) return;
20908 store?.setActiveId(null);
20909 store?.getState().baseElement?.focus();
20910 });
20911 const ref = (0, import_react27.useCallback)((element) => {
20912 if (!element) return;
20913 element[symbol2] = true;
20914 }, []);
20915 props = {
20916 ...props,
20917 ref: useMergeRefs(ref, props.ref),
20918 onMouseMove,
20919 onMouseLeave
20920 };
20921 return removeUndefinedValues(props);
20922 });
20923 var CompositeHover = memo3(forwardRef49(function CompositeHover2(props) {
20924 return createElement3(TagName8, useCompositeHover(props));
20925 }));
20926
20927 // node_modules/@ariakit/react-components/dist/combobox/combobox.js
20928 var import_react28 = __toESM(require_react(), 1);
20929 var TagName9 = "input";
20930 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
20931 if (!autoSelect) return false;
20932 return items.find((item) => !item.disabled && item.value)?.value === activeValue;
20933 }
20934 function hasCompletionString(value, activeValue) {
20935 if (!activeValue) return false;
20936 if (value == null) return false;
20937 const normalizedValue = normalizeString(value);
20938 const normalizedActiveValue = normalizeString(activeValue);
20939 if (normalizedValue.length !== value.length) return false;
20940 if (normalizedActiveValue.length !== activeValue.length) return false;
20941 return normalizedActiveValue.length > normalizedValue.length && normalizedActiveValue.toLowerCase().startsWith(normalizedValue.toLowerCase());
20942 }
20943 function isAriaAutoCompleteValue(value) {
20944 return value === "inline" || value === "list" || value === "both" || value === "none";
20945 }
20946 function getDefaultAutoSelectId(items) {
20947 return items.find((item) => {
20948 if (item.disabled) return false;
20949 return item.element?.getAttribute("role") !== "tab";
20950 })?.id;
20951 }
20952 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 }) {
20953 const context = useComboboxProviderContext();
20954 store = store || context;
20955 invariant(store, "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.");
20956 const ref = (0, import_react28.useRef)(null);
20957 const [valueUpdated, forceValueUpdate] = useForceUpdate();
20958 const canAutoSelectRef = (0, import_react28.useRef)(false);
20959 const composingRef = (0, import_react28.useRef)(false);
20960 const autoSelect = useStoreState(store, (state) => state.virtualFocus && autoSelectProp);
20961 const inline4 = autoComplete === "inline" || autoComplete === "both";
20962 const [canInline, setCanInline] = (0, import_react28.useState)(inline4);
20963 useUpdateLayoutEffect(() => {
20964 if (!inline4) return;
20965 setCanInline(true);
20966 }, [inline4]);
20967 const storeValue = useStoreState(store, "value");
20968 const prevSelectedValueRef = (0, import_react28.useRef)(void 0);
20969 (0, import_react28.useEffect)(() => {
20970 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
20971 prevSelectedValueRef.current = prev.selectedValue;
20972 });
20973 }, [store]);
20974 const inlineActiveValue = useStoreState(store, (state) => {
20975 if (!inline4) return;
20976 if (!canInline) return;
20977 if (state.activeValue && Array.isArray(state.selectedValue)) {
20978 if (state.selectedValue.includes(state.activeValue)) return;
20979 if (prevSelectedValueRef.current?.includes(state.activeValue)) return;
20980 }
20981 return state.activeValue;
20982 });
20983 const items = useStoreState(store, "renderedItems");
20984 const open = useStoreState(store, "open");
20985 const contentElement = useStoreState(store, "contentElement");
20986 const value = (0, import_react28.useMemo)(() => {
20987 if (!inline4) return storeValue;
20988 if (!canInline) return storeValue;
20989 if (isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) {
20990 if (hasCompletionString(storeValue, inlineActiveValue)) return storeValue + (inlineActiveValue?.slice(storeValue.length) || "");
20991 return storeValue;
20992 }
20993 return inlineActiveValue || storeValue;
20994 }, [
20995 inline4,
20996 canInline,
20997 items,
20998 inlineActiveValue,
20999 autoSelect,
21000 storeValue
21001 ]);
21002 (0, import_react28.useEffect)(() => {
21003 const element = ref.current;
21004 if (!element) return;
21005 const onCompositeItemMove = () => setCanInline(true);
21006 element.addEventListener("combobox-item-move", onCompositeItemMove);
21007 return () => {
21008 element.removeEventListener("combobox-item-move", onCompositeItemMove);
21009 };
21010 }, []);
21011 (0, import_react28.useEffect)(() => {
21012 if (!inline4) return;
21013 if (!canInline) return;
21014 if (!inlineActiveValue) return;
21015 if (!isFirstItemAutoSelected(items, inlineActiveValue, autoSelect)) return;
21016 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
21017 let cleanup = noop4;
21018 queueMicrotask(() => {
21019 const element = ref.current;
21020 if (!element) return;
21021 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
21022 const nextStart = storeValue.length;
21023 const nextEnd = inlineActiveValue.length;
21024 setSelectionRange(element, nextStart, nextEnd);
21025 cleanup = () => {
21026 if (!hasFocus(element)) return;
21027 const { start, end } = getTextboxSelection(element);
21028 if (start !== nextStart) return;
21029 if (end !== nextEnd) return;
21030 setSelectionRange(element, prevStart, prevEnd);
21031 };
21032 });
21033 return () => cleanup();
21034 }, [
21035 valueUpdated,
21036 inline4,
21037 canInline,
21038 inlineActiveValue,
21039 items,
21040 autoSelect,
21041 storeValue
21042 ]);
21043 const getAutoSelectIdProp = useEvent(getAutoSelectId);
21044 const autoSelectIdRef = (0, import_react28.useRef)(null);
21045 const autoSelectMovedRef = (0, import_react28.useRef)(void 0);
21046 const userScrolledRef = (0, import_react28.useRef)(false);
21047 const isAutoScrollingRef = (0, import_react28.useRef)(false);
21048 (0, import_react28.useEffect)(() => {
21049 if (!open) return;
21050 if (!contentElement) return;
21051 const scrollingElement = getScrollingElement(contentElement);
21052 if (!scrollingElement) return;
21053 const onUserScroll = () => {
21054 canAutoSelectRef.current = false;
21055 userScrolledRef.current = true;
21056 };
21057 const onScroll = () => {
21058 if (!isAutoScrollingRef.current) userScrolledRef.current = true;
21059 if (!store) return;
21060 if (!canAutoSelectRef.current) return;
21061 const { activeId } = store.getState();
21062 if (activeId === null) return;
21063 if (activeId === autoSelectIdRef.current) return;
21064 canAutoSelectRef.current = false;
21065 };
21066 const options = {
21067 passive: true,
21068 capture: true
21069 };
21070 scrollingElement.addEventListener("wheel", onUserScroll, options);
21071 scrollingElement.addEventListener("touchmove", onUserScroll, options);
21072 scrollingElement.addEventListener("scroll", onScroll, options);
21073 return () => {
21074 scrollingElement.removeEventListener("wheel", onUserScroll, true);
21075 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
21076 scrollingElement.removeEventListener("scroll", onScroll, true);
21077 };
21078 }, [
21079 open,
21080 contentElement,
21081 store
21082 ]);
21083 useSafeLayoutEffect(() => {
21084 userScrolledRef.current = false;
21085 if (!storeValue) return;
21086 if (composingRef.current) return;
21087 canAutoSelectRef.current = true;
21088 }, [storeValue]);
21089 useSafeLayoutEffect(() => {
21090 if (autoSelect !== "always" && open) return;
21091 canAutoSelectRef.current = open;
21092 }, [autoSelect, open]);
21093 useSafeLayoutEffect(() => {
21094 if (open) return;
21095 autoSelectMovedRef.current = void 0;
21096 }, [open]);
21097 const resetValueOnSelect = useStoreState(store, "resetValueOnSelect");
21098 useUpdateEffect(() => {
21099 const canAutoSelect = canAutoSelectRef.current;
21100 if (!store) return;
21101 if (!open) return;
21102 if (!canAutoSelect && (!resetValueOnSelect || userScrolledRef.current)) return;
21103 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
21104 if (baseElement && !hasFocus(baseElement)) return;
21105 if (contentElement2?.hasAttribute("data-placing")) {
21106 const observer = new MutationObserver(forceValueUpdate);
21107 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
21108 return () => observer.disconnect();
21109 }
21110 if (autoSelect && canAutoSelect) {
21111 const userAutoSelectId = getAutoSelectIdProp(items);
21112 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : getDefaultAutoSelectId(items) ?? store.first();
21113 autoSelectIdRef.current = autoSelectId;
21114 const nextActiveId = autoSelectId ?? null;
21115 const nextActiveValue = store.item(nextActiveId)?.value;
21116 const moved = autoSelectMovedRef.current;
21117 if (nextActiveId !== activeId || moved?.id !== nextActiveId || moved?.value !== nextActiveValue) {
21118 autoSelectMovedRef.current = {
21119 id: nextActiveId,
21120 value: nextActiveValue
21121 };
21122 store.move(nextActiveId);
21123 } else store.setState("activeValue", nextActiveValue);
21124 } else {
21125 const element = store.item(activeId || store.first())?.element;
21126 if (element && "scrollIntoView" in element) {
21127 isAutoScrollingRef.current = true;
21128 element.scrollIntoView({
21129 block: "nearest",
21130 inline: "nearest"
21131 });
21132 requestAnimationFrame(() => {
21133 isAutoScrollingRef.current = false;
21134 });
21135 }
21136 }
21137 }, [
21138 store,
21139 open,
21140 valueUpdated,
21141 storeValue,
21142 autoSelect,
21143 resetValueOnSelect,
21144 getAutoSelectIdProp,
21145 items
21146 ]);
21147 (0, import_react28.useEffect)(() => {
21148 if (!inline4) return;
21149 const combobox = ref.current;
21150 if (!combobox) return;
21151 const elements = [combobox, contentElement].filter((value2) => !!value2);
21152 const onBlur2 = (event) => {
21153 if (elements.every((el) => isFocusEventOutside(event, el))) store?.setValue(value);
21154 };
21155 for (const element of elements) element.addEventListener("focusout", onBlur2);
21156 return () => {
21157 for (const element of elements) element.removeEventListener("focusout", onBlur2);
21158 };
21159 }, [
21160 inline4,
21161 contentElement,
21162 store,
21163 value
21164 ]);
21165 const canShow = (event) => {
21166 return event.currentTarget.value.length >= showMinLength;
21167 };
21168 const onChangeProp = props.onChange;
21169 const showOnChangeProp = useBooleanEvent(showOnChange ?? canShow);
21170 const setValueOnChangeProp = useBooleanEvent(setValueOnChange ?? !store.tag);
21171 const onChange = useEvent((event) => {
21172 onChangeProp?.(event);
21173 if (event.defaultPrevented) return;
21174 if (!store) return;
21175 const currentTarget = event.currentTarget;
21176 const { value: value2, selectionStart, selectionEnd } = currentTarget;
21177 const nativeEvent = event.nativeEvent;
21178 canAutoSelectRef.current = true;
21179 if (isInputEvent(nativeEvent)) {
21180 if (nativeEvent.isComposing) {
21181 canAutoSelectRef.current = false;
21182 composingRef.current = true;
21183 }
21184 if (inline4) {
21185 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
21186 const caretAtEnd = selectionStart === value2.length;
21187 setCanInline(textInserted && caretAtEnd);
21188 }
21189 }
21190 if (setValueOnChangeProp(event)) {
21191 const isSameValue2 = value2 === store.getState().value;
21192 store.setValue(value2);
21193 queueMicrotask(() => {
21194 setSelectionRange(currentTarget, selectionStart, selectionEnd);
21195 });
21196 if (inline4 && autoSelect && isSameValue2) forceValueUpdate();
21197 }
21198 if (showOnChangeProp(event)) store.show();
21199 if (!autoSelect || !canAutoSelectRef.current) store.setActiveId(null);
21200 });
21201 const onCompositionEndProp = props.onCompositionEnd;
21202 const onCompositionEnd = useEvent((event) => {
21203 canAutoSelectRef.current = true;
21204 composingRef.current = false;
21205 onCompositionEndProp?.(event);
21206 if (event.defaultPrevented) return;
21207 if (!autoSelect) return;
21208 forceValueUpdate();
21209 });
21210 const onMouseDownProp = props.onMouseDown;
21211 const blurActiveItemOnClickProp = useBooleanEvent(blurActiveItemOnClick ?? (() => store.getState().includesBaseElement));
21212 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
21213 const showOnClickProp = useBooleanEvent(showOnClick ?? canShow);
21214 const onMouseDown = useEvent((event) => {
21215 onMouseDownProp?.(event);
21216 if (event.defaultPrevented) return;
21217 if (event.button) return;
21218 if (event.ctrlKey) return;
21219 if (!store) return;
21220 if (blurActiveItemOnClickProp(event)) store.setActiveId(null);
21221 if (setValueOnClickProp(event)) store.setValue(value);
21222 if (showOnClickProp(event)) queueBeforeEvent(event.currentTarget, "mouseup", store.show);
21223 });
21224 const onKeyDownProp = props.onKeyDown;
21225 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress ?? canShow);
21226 const onKeyDown = useEvent((event) => {
21227 onKeyDownProp?.(event);
21228 if (!event.repeat) canAutoSelectRef.current = false;
21229 if (event.defaultPrevented) return;
21230 if (!store) return;
21231 const { open: open2 } = store.getState();
21232 if (open2 && event.key === "Enter") {
21233 event.preventDefault();
21234 return;
21235 }
21236 if (event.ctrlKey) return;
21237 if (event.altKey) return;
21238 if (event.shiftKey) return;
21239 if (event.metaKey) return;
21240 if (open2) return;
21241 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
21242 if (showOnKeyPressProp(event)) {
21243 event.preventDefault();
21244 store.show();
21245 }
21246 }
21247 });
21248 const onBlurProp = props.onBlur;
21249 const onBlur = useEvent((event) => {
21250 canAutoSelectRef.current = false;
21251 onBlurProp?.(event);
21252 });
21253 const id = useId5(props.id);
21254 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
21255 const isActiveItem = useStoreState(store, (state) => state.activeId === null);
21256 props = {
21257 role: "combobox",
21258 "aria-autocomplete": ariaAutoComplete,
21259 "aria-haspopup": getPopupRole(contentElement, "listbox"),
21260 "aria-expanded": open,
21261 "aria-controls": contentElement?.id,
21262 "data-active-item": isActiveItem || void 0,
21263 value,
21264 ...props,
21265 id,
21266 ref: useMergeRefs(ref, props.ref),
21267 onChange,
21268 onCompositionEnd,
21269 onMouseDown,
21270 onKeyDown,
21271 onBlur
21272 };
21273 props = useComposite({
21274 store,
21275 focusable: focusable2,
21276 ...props,
21277 moveOnKeyPress: (event) => {
21278 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
21279 if (inline4) setCanInline(true);
21280 return true;
21281 }
21282 });
21283 props = usePopoverAnchor({
21284 store,
21285 ...props
21286 });
21287 return {
21288 autoComplete: "off",
21289 ...props
21290 };
21291 });
21292 var Combobox = forwardRef49(function Combobox2(props) {
21293 return createElement3(TagName9, useCombobox(props));
21294 });
21295
21296 // node_modules/@ariakit/react-components/dist/combobox/combobox-item.js
21297 var import_react29 = __toESM(require_react(), 1);
21298 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
21299 var TagName10 = "div";
21300 function isSelected(storeValue, itemValue) {
21301 if (itemValue == null) return;
21302 if (storeValue == null) return false;
21303 if (Array.isArray(storeValue)) return storeValue.includes(itemValue);
21304 return storeValue === itemValue;
21305 }
21306 function getItemRole(popupRole) {
21307 return getItemRoleByPopupRole(popupRole) ?? "option";
21308 }
21309 var useComboboxItem = createHook(function useComboboxItem2({ store, value, hideOnClick, setValueOnClick, selectValueOnClick = true, resetValueOnSelect, focusOnHover = false, moveOnKeyPress = true, getItem: getItemProp, ...props }) {
21310 const context = useComboboxScopedContext();
21311 store = store || context;
21312 invariant(store, "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.");
21313 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
21314 resetValueOnSelectState: "resetValueOnSelect",
21315 multiSelectable(state) {
21316 return Array.isArray(state.selectedValue);
21317 },
21318 selected(state) {
21319 return isSelected(state.selectedValue, value);
21320 }
21321 });
21322 const getItem = (0, import_react29.useCallback)((item) => {
21323 const nextItem = {
21324 ...item,
21325 value
21326 };
21327 if (getItemProp) return getItemProp(nextItem);
21328 return nextItem;
21329 }, [value, getItemProp]);
21330 setValueOnClick = setValueOnClick ?? !multiSelectable;
21331 hideOnClick = hideOnClick ?? (value != null && !multiSelectable);
21332 const onClickProp = props.onClick;
21333 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
21334 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
21335 const resetValueOnSelectProp = useBooleanEvent(resetValueOnSelect ?? resetValueOnSelectState ?? multiSelectable);
21336 const hideOnClickProp = useBooleanEvent(hideOnClick);
21337 const onClick = useEvent((event) => {
21338 onClickProp?.(event);
21339 if (event.defaultPrevented) return;
21340 if (isDownloading(event)) return;
21341 if (isOpeningInNewTab(event)) return;
21342 if (value != null) {
21343 if (selectValueOnClickProp(event)) {
21344 if (resetValueOnSelectProp(event)) store?.resetValue();
21345 store?.setSelectedValue((prevValue) => {
21346 if (!Array.isArray(prevValue)) return value;
21347 if (prevValue.includes(value)) return prevValue.filter((v2) => v2 !== value);
21348 return [...prevValue, value];
21349 });
21350 }
21351 if (setValueOnClickProp(event)) store?.setValue(value);
21352 }
21353 if (hideOnClickProp(event)) store?.hide();
21354 });
21355 const onKeyDownProp = props.onKeyDown;
21356 const onKeyDown = useEvent((event) => {
21357 onKeyDownProp?.(event);
21358 if (event.defaultPrevented) return;
21359 const baseElement = store?.getState().baseElement;
21360 if (!baseElement) return;
21361 if (hasFocus(baseElement)) return;
21362 const printable = event.key.length === 1 && !event.ctrlKey && !event.metaKey;
21363 const paste = (!isApple() ? event.ctrlKey : event.metaKey) && event.key.toLowerCase() === "v";
21364 const deleteKey = event.key === "Backspace" || event.key === "Delete";
21365 if (printable || paste || deleteKey) {
21366 queueMicrotask(() => baseElement.focus());
21367 if (isTextField(baseElement)) store?.setValue(baseElement.value);
21368 }
21369 });
21370 if (multiSelectable && selected != null) props = {
21371 "aria-selected": selected,
21372 ...props
21373 };
21374 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ComboboxItemValueContext.Provider, {
21375 value,
21376 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ComboboxItemCheckedContext.Provider, {
21377 value: selected ?? false,
21378 children: element
21379 })
21380 }), [value, selected]);
21381 props = {
21382 role: getItemRole((0, import_react29.useContext)(ComboboxListRoleContext)),
21383 children: value,
21384 ...props,
21385 onClick,
21386 onKeyDown
21387 };
21388 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
21389 props = useCompositeItem({
21390 store,
21391 ...props,
21392 getItem,
21393 moveOnKeyPress: (event) => {
21394 if (!moveOnKeyPressProp(event)) return false;
21395 const moveEvent = new Event("combobox-item-move");
21396 store?.getState().baseElement?.dispatchEvent(moveEvent);
21397 return true;
21398 }
21399 });
21400 props = useCompositeHover({
21401 store,
21402 focusOnHover,
21403 ...props
21404 });
21405 return props;
21406 });
21407 var ComboboxItem = memo3(forwardRef49(function ComboboxItem2(props) {
21408 return createElement3(TagName10, useComboboxItem(props));
21409 }));
21410
21411 // node_modules/@ariakit/react-components/dist/combobox/combobox-item-value.js
21412 var import_react30 = __toESM(require_react(), 1);
21413 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
21414 var TagName11 = "span";
21415 function normalizeValue(value) {
21416 return normalizeString(value).toLowerCase();
21417 }
21418 function getOffsets(string, values) {
21419 const offsets = [];
21420 for (const value of values) {
21421 if (!value) continue;
21422 let pos = 0;
21423 const length = value.length;
21424 let index2 = string.indexOf(value, pos);
21425 while (index2 !== -1) {
21426 offsets.push([index2, length]);
21427 pos = index2 + 1;
21428 index2 = string.indexOf(value, pos);
21429 }
21430 }
21431 return offsets;
21432 }
21433 function mergeOverlappingOffsets(offsets) {
21434 offsets.sort(([a2], [b2]) => a2 - b2);
21435 const merged = [];
21436 for (const [offset4, length] of offsets) {
21437 const last = merged[merged.length - 1];
21438 if (last && offset4 < last[0] + last[1]) last[1] = Math.max(last[1], offset4 + length - last[0]);
21439 else merged.push([offset4, length]);
21440 }
21441 return merged;
21442 }
21443 function getNormalizedIndexes(itemValue) {
21444 const starts = [];
21445 const ends = [];
21446 let index2 = 0;
21447 for (const char of itemValue) {
21448 const normalizedLength = normalizeValue(char).length;
21449 for (let i2 = 0; i2 < normalizedLength; i2 += 1) {
21450 starts.push(i2 === 0 ? index2 : -1);
21451 ends.push(index2);
21452 }
21453 index2 += char.length;
21454 }
21455 starts.push(itemValue.length);
21456 ends.push(itemValue.length);
21457 let nextBoundary = itemValue.length;
21458 for (let i2 = starts.length - 1; i2 >= 0; i2 -= 1) {
21459 const start = starts[i2];
21460 if (start == null) continue;
21461 if (start === -1) starts[i2] = nextBoundary;
21462 else nextBoundary = start;
21463 }
21464 return {
21465 starts,
21466 ends
21467 };
21468 }
21469 function toOriginalOffsets(itemValue, normalizedOffsets) {
21470 if (!normalizedOffsets.length) return normalizedOffsets;
21471 const { starts, ends } = getNormalizedIndexes(itemValue);
21472 const offsets = [];
21473 for (const [normalizedOffset, normalizedLength] of normalizedOffsets) {
21474 const start = starts[normalizedOffset];
21475 const end = ends[normalizedOffset + normalizedLength];
21476 if (start == null || end == null) continue;
21477 if (end <= start) continue;
21478 offsets.push([start, end - start]);
21479 }
21480 return offsets;
21481 }
21482 function splitValue(itemValue, userValue) {
21483 if (!itemValue) return itemValue;
21484 if (!userValue) return itemValue;
21485 const userValues = toArray(userValue).map(normalizeValue);
21486 const parts = [];
21487 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", {
21488 "data-autocomplete-value": autocomplete ? "" : void 0,
21489 "data-user-value": autocomplete ? void 0 : "",
21490 children: value
21491 }, parts.length);
21492 const offsets = toOriginalOffsets(itemValue, mergeOverlappingOffsets(getOffsets(normalizeValue(itemValue), new Set(userValues))));
21493 const firstEntry = offsets[0];
21494 if (!firstEntry) {
21495 parts.push(span(itemValue, true));
21496 return parts;
21497 }
21498 const [firstOffset] = firstEntry;
21499 [itemValue.slice(0, firstOffset), ...offsets.flatMap(([offset4, length], i2) => {
21500 const value = itemValue.slice(offset4, offset4 + length);
21501 const nextOffset = offsets[i2 + 1]?.[0];
21502 return [value, itemValue.slice(offset4 + length, nextOffset)];
21503 })].forEach((value, i2) => {
21504 if (!value) return;
21505 parts.push(span(value, i2 % 2 === 0));
21506 });
21507 return parts;
21508 }
21509 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
21510 const context = useComboboxScopedContext();
21511 store = store || context;
21512 const itemContext = (0, import_react30.useContext)(ComboboxItemValueContext);
21513 const itemValue = value ?? itemContext;
21514 const inputValue = useStoreState(store, (state) => userValue ?? state?.value);
21515 props = {
21516 children: (0, import_react30.useMemo)(() => {
21517 if (!itemValue) return;
21518 if (!inputValue) return itemValue;
21519 return splitValue(itemValue, inputValue);
21520 }, [itemValue, inputValue]),
21521 ...props
21522 };
21523 return removeUndefinedValues(props);
21524 });
21525 var ComboboxItemValue = forwardRef49(function ComboboxItemValue2(props) {
21526 return createElement3(TagName11, useComboboxItemValue(props));
21527 });
21528
21529 // node_modules/@ariakit/react-components/dist/combobox/combobox-label.js
21530 var TagName12 = "label";
21531 var useComboboxLabel = createHook(function useComboboxLabel2({ store, ...props }) {
21532 const context = useComboboxProviderContext();
21533 store = store || context;
21534 invariant(store, "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.");
21535 props = {
21536 htmlFor: useStoreState(store, (state) => state.baseElement?.id),
21537 ...props
21538 };
21539 return removeUndefinedValues(props);
21540 });
21541 var ComboboxLabel = memo3(forwardRef49(function ComboboxLabel2(props) {
21542 return createElement3(TagName12, useComboboxLabel(props));
21543 }));
21544
21545 // node_modules/@ariakit/react-components/dist/combobox/combobox-list.js
21546 var import_react31 = __toESM(require_react(), 1);
21547 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
21548 var TagName13 = "div";
21549 var useComboboxList = createHook(function useComboboxList2({ store, alwaysVisible, ...props }) {
21550 const scopedContext = useComboboxScopedContext(true);
21551 const context = useComboboxContext();
21552 store = store || context;
21553 const scopedContextSameStore = !!store && store === scopedContext;
21554 invariant(store, "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.");
21555 const ref = (0, import_react31.useRef)(null);
21556 const id = useId5(props.id);
21557 const mounted = useStoreState(store, "mounted");
21558 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
21559 const style = hidden ? {
21560 ...props.style,
21561 display: "none"
21562 } : props.style;
21563 const multiSelectable = useStoreState(store, (state) => Array.isArray(state.selectedValue));
21564 const role = useAttribute(ref, "role", props.role);
21565 const ariaMultiSelectable = role === "listbox" || role === "tree" || role === "grid" ? multiSelectable || void 0 : void 0;
21566 const [hasListboxInside, setHasListboxInside] = (0, import_react31.useState)(false);
21567 const contentElement = useStoreState(store, "contentElement");
21568 useSafeLayoutEffect(() => {
21569 if (!mounted) return;
21570 const element = ref.current;
21571 if (!element) return;
21572 if (contentElement !== element) return;
21573 const callback = () => {
21574 setHasListboxInside(!!element.querySelector("[role='listbox']"));
21575 };
21576 const observer = new MutationObserver(callback);
21577 observer.observe(element, {
21578 subtree: true,
21579 childList: true,
21580 attributeFilter: ["role"]
21581 });
21582 callback();
21583 return () => observer.disconnect();
21584 }, [mounted, contentElement]);
21585 if (!hasListboxInside) props = {
21586 role: "listbox",
21587 "aria-multiselectable": ariaMultiSelectable,
21588 ...props
21589 };
21590 props = useWrapElement(props, (element) => /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(ComboboxScopedContextProvider, {
21591 value: store,
21592 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(ComboboxListRoleContext.Provider, {
21593 value: role,
21594 children: element
21595 })
21596 }), [store, role]);
21597 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
21598 props = {
21599 hidden,
21600 ...props,
21601 id,
21602 ref: useMergeRefs(setContentElement, ref, props.ref),
21603 style
21604 };
21605 return removeUndefinedValues(props);
21606 });
21607 var ComboboxList = forwardRef49(function ComboboxList2(props) {
21608 return createElement3(TagName13, useComboboxList(props));
21609 });
21610
21611 // node_modules/@ariakit/react-components/dist/tag/tag-context.js
21612 var import_react32 = __toESM(require_react(), 1);
21613 var TagValueContext = (0, import_react32.createContext)(null);
21614 var TagRemoveIdContext = (0, import_react32.createContext)(null);
21615 var ctx7 = createStoreContext([CompositeContextProvider], [CompositeScopedContextProvider]);
21616 var useTagContext = ctx7.useContext;
21617 var useTagScopedContext = ctx7.useScopedContext;
21618 var useTagProviderContext = ctx7.useProviderContext;
21619 var TagContextProvider = ctx7.ContextProvider;
21620 var TagScopedContextProvider = ctx7.ScopedContextProvider;
21621
21622 // node_modules/@ariakit/components/dist/combobox/combobox-store.js
21623 var isTouchSafari = isSafari() && isTouchDevice();
21624 function createComboboxStore({ tag, ...props } = {}) {
21625 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
21626 throwOnConflictingProps(props, store);
21627 const tagState = tag?.getState();
21628 const syncState = store?.getState();
21629 const activeId = defaultValue(props.activeId, syncState?.activeId, props.defaultActiveId, null);
21630 const composite = createCompositeStore({
21631 ...props,
21632 activeId,
21633 includesBaseElement: defaultValue(props.includesBaseElement, syncState?.includesBaseElement, true),
21634 orientation: defaultValue(props.orientation, syncState?.orientation, "vertical"),
21635 focusLoop: defaultValue(props.focusLoop, syncState?.focusLoop, true),
21636 focusWrap: defaultValue(props.focusWrap, syncState?.focusWrap, true),
21637 virtualFocus: defaultValue(props.virtualFocus, syncState?.virtualFocus, true)
21638 });
21639 const popover = createPopoverStore({
21640 ...props,
21641 placement: defaultValue(props.placement, syncState?.placement, "bottom-start")
21642 });
21643 const value = defaultValue(props.value, syncState?.value, props.defaultValue, "");
21644 const selectedValue = defaultValue(props.selectedValue, syncState?.selectedValue, tagState?.values, props.defaultSelectedValue, "");
21645 const multiSelectable = Array.isArray(selectedValue);
21646 const initialState = {
21647 ...composite.getState(),
21648 ...popover.getState(),
21649 value,
21650 selectedValue,
21651 resetValueOnSelect: defaultValue(props.resetValueOnSelect, syncState?.resetValueOnSelect, multiSelectable),
21652 resetValueOnHide: defaultValue(props.resetValueOnHide, syncState?.resetValueOnHide, multiSelectable && !tag),
21653 activeValue: syncState?.activeValue
21654 };
21655 const combobox = createStore(initialState, composite, popover, store);
21656 if (isTouchSafari) setup(combobox, () => sync(combobox, ["virtualFocus"], () => {
21657 combobox.setState("virtualFocus", false);
21658 }));
21659 setup(combobox, () => {
21660 if (!tag) return;
21661 return chain(sync(combobox, ["selectedValue"], (state) => {
21662 if (!Array.isArray(state.selectedValue)) return;
21663 tag.setValues(state.selectedValue);
21664 }), sync(tag, ["values"], (state) => {
21665 combobox.setState("selectedValue", state.values);
21666 }));
21667 });
21668 setup(combobox, () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
21669 if (!state.resetValueOnHide) return;
21670 if (state.mounted) return;
21671 combobox.setState("value", value);
21672 }));
21673 setup(combobox, () => sync(combobox, ["open"], (state) => {
21674 if (state.open) return;
21675 combobox.setState("activeId", activeId);
21676 combobox.setState("moves", 0);
21677 }));
21678 setup(combobox, () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
21679 if (state.moves === prevState.moves) combobox.setState("activeValue", void 0);
21680 }));
21681 setup(combobox, () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
21682 if (state.moves === prev.moves) return;
21683 const { activeId: activeId2 } = combobox.getState();
21684 const activeItem = composite.item(activeId2);
21685 combobox.setState("activeValue", activeItem?.value);
21686 }));
21687 return {
21688 ...popover,
21689 ...composite,
21690 ...combobox,
21691 tag,
21692 setValue: (value2) => combobox.setState("value", value2),
21693 resetValue: () => combobox.setState("value", initialState.value),
21694 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
21695 };
21696 }
21697
21698 // node_modules/@ariakit/react-components/dist/combobox/combobox-store.js
21699 function useComboboxStoreOptions(props) {
21700 const tag = useTagContext();
21701 props = {
21702 ...props,
21703 tag: props.tag !== void 0 ? props.tag : tag
21704 };
21705 return useCompositeStoreOptions(props);
21706 }
21707 function useComboboxStoreProps(store, update2, props) {
21708 useUpdateEffect(update2, [props.tag]);
21709 useStoreProps(store, props, "value", "setValue");
21710 useStoreProps(store, props, "selectedValue", "setSelectedValue");
21711 useStoreProps(store, props, "resetValueOnHide");
21712 useStoreProps(store, props, "resetValueOnSelect");
21713 return Object.assign(useCompositeStoreProps(usePopoverStoreProps(store, update2, props), update2, props), { tag: props.tag });
21714 }
21715 function useComboboxStore(props = {}) {
21716 props = useComboboxStoreOptions(props);
21717 const [store, update2] = useStore2(createComboboxStore, props);
21718 return useComboboxStoreProps(store, update2, props);
21719 }
21720
21721 // node_modules/@ariakit/react-components/dist/combobox/combobox-provider.js
21722 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
21723 function ComboboxProvider(props = {}) {
21724 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(ComboboxContextProvider, {
21725 value: useComboboxStore(props),
21726 children: props.children
21727 });
21728 }
21729
21730 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
21731 var import_remove_accents = __toESM(require_remove_accents(), 1);
21732 var import_compose8 = __toESM(require_compose(), 1);
21733 var import_i18n25 = __toESM(require_i18n(), 1);
21734 var import_element68 = __toESM(require_element(), 1);
21735 var import_components19 = __toESM(require_components(), 1);
21736
21737 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
21738 var EMPTY_ARRAY3 = [];
21739 var getCurrentValue = (filterDefinition, currentFilter) => {
21740 if (filterDefinition.singleSelection) {
21741 return currentFilter?.value;
21742 }
21743 if (Array.isArray(currentFilter?.value)) {
21744 return currentFilter.value;
21745 }
21746 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
21747 return [currentFilter.value];
21748 }
21749 return EMPTY_ARRAY3;
21750 };
21751
21752 // packages/dataviews/build-module/hooks/use-elements.mjs
21753 var import_element67 = __toESM(require_element(), 1);
21754 var EMPTY_ARRAY4 = [];
21755 function useElements({
21756 elements,
21757 getElements
21758 }) {
21759 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
21760 const [records, setRecords] = (0, import_element67.useState)(staticElements);
21761 const [isLoading, setIsLoading] = (0, import_element67.useState)(false);
21762 (0, import_element67.useEffect)(() => {
21763 if (!getElements) {
21764 setRecords(staticElements);
21765 return;
21766 }
21767 let cancelled = false;
21768 setIsLoading(true);
21769 getElements().then((fetchedElements) => {
21770 if (!cancelled) {
21771 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
21772 setRecords(dynamicElements);
21773 }
21774 }).catch(() => {
21775 if (!cancelled) {
21776 setRecords(staticElements);
21777 }
21778 }).finally(() => {
21779 if (!cancelled) {
21780 setIsLoading(false);
21781 }
21782 });
21783 return () => {
21784 cancelled = true;
21785 };
21786 }, [getElements, staticElements]);
21787 return {
21788 elements: records,
21789 isLoading
21790 };
21791 }
21792
21793 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
21794 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
21795 function normalizeSearchInput(input = "") {
21796 return (0, import_remove_accents.default)(input.trim().toLowerCase());
21797 }
21798 var getNewValue = (filterDefinition, currentFilter, value) => {
21799 if (filterDefinition.singleSelection) {
21800 return value;
21801 }
21802 if (Array.isArray(currentFilter?.value)) {
21803 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
21804 }
21805 return [value];
21806 };
21807 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
21808 return `${prefix}-${filterElementValue}`;
21809 }
21810 var MultiSelectionOption = ({ selected }) => {
21811 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21812 "span",
21813 {
21814 className: clsx_default(
21815 "dataviews-filters__search-widget-listitem-multi-selection",
21816 { "is-selected": selected }
21817 ),
21818 children: selected && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components19.Icon, { icon: check_default })
21819 }
21820 );
21821 };
21822 var SingleSelectionOption = ({ selected }) => {
21823 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21824 "span",
21825 {
21826 className: clsx_default(
21827 "dataviews-filters__search-widget-listitem-single-selection",
21828 { "is-selected": selected }
21829 )
21830 }
21831 );
21832 };
21833 function ListBox({ view, filter, onChangeView }) {
21834 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
21835 const [activeCompositeId, setActiveCompositeId] = (0, import_element68.useState)(
21836 // When there are one or less operators, the first item is set as active
21837 // (by setting the initial `activeId` to `undefined`).
21838 // With 2 or more operators, the focus is moved on the operators control
21839 // (by setting the initial `activeId` to `null`), meaning that there won't
21840 // be an active item initially. Focus is then managed via the
21841 // `onFocusVisible` callback.
21842 filter.operators?.length === 1 ? void 0 : null
21843 );
21844 const currentFilter = view.filters?.find(
21845 (f2) => f2.field === filter.field
21846 );
21847 const currentValue = getCurrentValue(filter, currentFilter);
21848 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21849 import_components19.Composite,
21850 {
21851 virtualFocus: true,
21852 focusLoop: true,
21853 activeId: activeCompositeId,
21854 setActiveId: setActiveCompositeId,
21855 role: "listbox",
21856 className: "dataviews-filters__search-widget-listbox",
21857 "aria-label": (0, import_i18n25.sprintf)(
21858 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
21859 (0, import_i18n25.__)("List of: %1$s"),
21860 filter.name
21861 ),
21862 onFocusVisible: () => {
21863 if (!activeCompositeId && filter.elements.length) {
21864 setActiveCompositeId(
21865 generateFilterElementCompositeItemId(
21866 baseId,
21867 filter.elements[0].value
21868 )
21869 );
21870 }
21871 },
21872 render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components19.Composite.Typeahead, {}),
21873 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21874 import_components19.Composite.Hover,
21875 {
21876 render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21877 import_components19.Composite.Item,
21878 {
21879 id: generateFilterElementCompositeItemId(
21880 baseId,
21881 element.value
21882 ),
21883 render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21884 "div",
21885 {
21886 "aria-label": element.label,
21887 role: "option",
21888 className: "dataviews-filters__search-widget-listitem"
21889 }
21890 ),
21891 onClick: () => {
21892 const newFilters = currentFilter ? [
21893 ...(view.filters ?? []).map(
21894 (_filter) => {
21895 if (_filter.field === filter.field) {
21896 return {
21897 ..._filter,
21898 operator: currentFilter.operator || filter.operators[0],
21899 value: getNewValue(
21900 filter,
21901 currentFilter,
21902 element.value
21903 )
21904 };
21905 }
21906 return _filter;
21907 }
21908 )
21909 ] : [
21910 ...view.filters ?? [],
21911 {
21912 field: filter.field,
21913 operator: filter.operators[0],
21914 value: getNewValue(
21915 filter,
21916 currentFilter,
21917 element.value
21918 )
21919 }
21920 ];
21921 onChangeView({
21922 ...view,
21923 page: 1,
21924 filters: newFilters
21925 });
21926 }
21927 }
21928 ),
21929 children: [
21930 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21931 SingleSelectionOption,
21932 {
21933 selected: currentValue === element.value
21934 }
21935 ),
21936 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21937 MultiSelectionOption,
21938 {
21939 selected: currentValue.includes(element.value)
21940 }
21941 ),
21942 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
21943 "span",
21944 {
21945 className: "dataviews-filters__search-widget-listitem-value",
21946 title: element.label,
21947 children: element.label
21948 }
21949 )
21950 ]
21951 },
21952 element.value
21953 ))
21954 }
21955 );
21956 }
21957 function ComboboxList22({ view, filter, onChangeView }) {
21958 const [searchValue, setSearchValue] = (0, import_element68.useState)("");
21959 const deferredSearchValue = (0, import_element68.useDeferredValue)(searchValue);
21960 const currentFilter = view.filters?.find(
21961 (_filter) => _filter.field === filter.field
21962 );
21963 const currentValue = getCurrentValue(filter, currentFilter);
21964 const matches = (0, import_element68.useMemo)(() => {
21965 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
21966 return filter.elements.filter(
21967 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
21968 );
21969 }, [filter.elements, deferredSearchValue]);
21970 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
21971 ComboboxProvider,
21972 {
21973 selectedValue: currentValue,
21974 setSelectedValue: (value) => {
21975 const newFilters = currentFilter ? [
21976 ...(view.filters ?? []).map((_filter) => {
21977 if (_filter.field === filter.field) {
21978 return {
21979 ..._filter,
21980 operator: currentFilter.operator || filter.operators[0],
21981 value
21982 };
21983 }
21984 return _filter;
21985 })
21986 ] : [
21987 ...view.filters ?? [],
21988 {
21989 field: filter.field,
21990 operator: filter.operators[0],
21991 value
21992 }
21993 ];
21994 onChangeView({
21995 ...view,
21996 page: 1,
21997 filters: newFilters
21998 });
21999 },
22000 setValue: setSearchValue,
22001 children: [
22002 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
22003 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(ComboboxLabel, {}), children: (0, import_i18n25.__)("Search items") }),
22004 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
22005 Combobox,
22006 {
22007 autoSelect: "always",
22008 placeholder: (0, import_i18n25.__)("Search"),
22009 className: "dataviews-filters__search-widget-filter-combobox__input"
22010 }
22011 ),
22012 /* @__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 }) })
22013 ] }),
22014 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
22015 ComboboxList,
22016 {
22017 className: "dataviews-filters__search-widget-filter-combobox-list",
22018 alwaysVisible: true,
22019 children: [
22020 matches.map((element) => {
22021 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
22022 ComboboxItem,
22023 {
22024 resetValueOnSelect: false,
22025 value: element.value,
22026 className: "dataviews-filters__search-widget-listitem",
22027 hideOnClick: false,
22028 setValueOnClick: false,
22029 focusOnHover: true,
22030 children: [
22031 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
22032 SingleSelectionOption,
22033 {
22034 selected: currentValue === element.value
22035 }
22036 ),
22037 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
22038 MultiSelectionOption,
22039 {
22040 selected: currentValue.includes(
22041 element.value
22042 )
22043 }
22044 ),
22045 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
22046 "span",
22047 {
22048 className: "dataviews-filters__search-widget-listitem-value",
22049 title: element.label,
22050 children: [
22051 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
22052 ComboboxItemValue,
22053 {
22054 className: "dataviews-filters__search-widget-filter-combobox-item-value",
22055 value: element.label
22056 }
22057 ),
22058 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
22059 ]
22060 }
22061 )
22062 ]
22063 },
22064 element.value
22065 );
22066 }),
22067 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("p", { children: (0, import_i18n25.__)("No results found") })
22068 ]
22069 }
22070 )
22071 ]
22072 }
22073 );
22074 }
22075 function SearchWidget(props) {
22076 const { elements, isLoading } = useElements({
22077 elements: props.filter.elements,
22078 getElements: props.filter.getElements
22079 });
22080 if (isLoading) {
22081 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, {}) });
22082 }
22083 if (elements.length === 0) {
22084 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n25.__)("No elements found") });
22085 }
22086 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
22087 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
22088 }
22089
22090 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
22091 var import_es6 = __toESM(require_es6(), 1);
22092 var import_compose9 = __toESM(require_compose(), 1);
22093 var import_element69 = __toESM(require_element(), 1);
22094 var import_components20 = __toESM(require_components(), 1);
22095 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
22096 function InputWidget({
22097 filter,
22098 view,
22099 onChangeView,
22100 fields
22101 }) {
22102 const currentFilter = view.filters?.find(
22103 (f2) => f2.field === filter.field
22104 );
22105 const currentValue = getCurrentValue(filter, currentFilter);
22106 const field = (0, import_element69.useMemo)(() => {
22107 const currentField = fields.find((f2) => f2.id === filter.field);
22108 if (currentField) {
22109 return {
22110 ...currentField,
22111 // Deactivate validation for filters.
22112 isValid: {},
22113 // Filter controls are always enabled.
22114 isDisabled: () => false,
22115 // Filter controls are always visible.
22116 isVisible: () => true,
22117 // Configure getValue/setValue as if Item was a plain object.
22118 getValue: ({ item }) => item[currentField.id],
22119 setValue: ({ value }) => ({
22120 [currentField.id]: value
22121 })
22122 };
22123 }
22124 return currentField;
22125 }, [fields, filter.field]);
22126 const data = (0, import_element69.useMemo)(() => {
22127 return (view.filters ?? []).reduce(
22128 (acc, activeFilter) => {
22129 acc[activeFilter.field] = activeFilter.value;
22130 return acc;
22131 },
22132 {}
22133 );
22134 }, [view.filters]);
22135 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
22136 if (!field || !currentFilter) {
22137 return;
22138 }
22139 const nextValue = field.getValue({ item: updatedData });
22140 if ((0, import_es6.default)(nextValue, currentValue)) {
22141 return;
22142 }
22143 onChangeView({
22144 ...view,
22145 filters: (view.filters ?? []).map(
22146 (_filter) => _filter.field === filter.field ? {
22147 ..._filter,
22148 operator: currentFilter.operator || filter.operators[0],
22149 // Consider empty strings as undefined:
22150 //
22151 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
22152 // - empty string as value means "search empty string": returns only the records that have an empty string as value
22153 //
22154 // In practice, this means the filter will not be able to find an empty string as the value.
22155 value: nextValue === "" ? void 0 : nextValue
22156 } : _filter
22157 )
22158 });
22159 });
22160 if (!field || !field.Edit || !currentFilter) {
22161 return null;
22162 }
22163 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
22164 import_components20.Flex,
22165 {
22166 className: "dataviews-filters__user-input-widget",
22167 gap: 2.5,
22168 direction: "column",
22169 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
22170 field.Edit,
22171 {
22172 hideLabelFromVision: true,
22173 data,
22174 field,
22175 operator: currentFilter.operator,
22176 onChange: handleChange
22177 }
22178 )
22179 }
22180 );
22181 }
22182
22183 // node_modules/date-fns/constants.js
22184 var daysInYear = 365.2425;
22185 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
22186 var minTime = -maxTime;
22187 var millisecondsInWeek = 6048e5;
22188 var millisecondsInDay = 864e5;
22189 var secondsInHour = 3600;
22190 var secondsInDay = secondsInHour * 24;
22191 var secondsInWeek = secondsInDay * 7;
22192 var secondsInYear = secondsInDay * daysInYear;
22193 var secondsInMonth = secondsInYear / 12;
22194 var secondsInQuarter = secondsInMonth * 3;
22195 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
22196
22197 // node_modules/date-fns/constructFrom.js
22198 function constructFrom(date, value) {
22199 if (typeof date === "function") return date(value);
22200 if (date && typeof date === "object" && constructFromSymbol in date)
22201 return date[constructFromSymbol](value);
22202 if (date instanceof Date) return new date.constructor(value);
22203 return new Date(value);
22204 }
22205
22206 // node_modules/date-fns/toDate.js
22207 function toDate(argument, context) {
22208 return constructFrom(context || argument, argument);
22209 }
22210
22211 // node_modules/date-fns/addDays.js
22212 function addDays(date, amount, options) {
22213 const _date = toDate(date, options?.in);
22214 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
22215 if (!amount) return _date;
22216 _date.setDate(_date.getDate() + amount);
22217 return _date;
22218 }
22219
22220 // node_modules/date-fns/addMonths.js
22221 function addMonths(date, amount, options) {
22222 const _date = toDate(date, options?.in);
22223 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
22224 if (!amount) {
22225 return _date;
22226 }
22227 const dayOfMonth = _date.getDate();
22228 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
22229 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
22230 const daysInMonth = endOfDesiredMonth.getDate();
22231 if (dayOfMonth >= daysInMonth) {
22232 return endOfDesiredMonth;
22233 } else {
22234 _date.setFullYear(
22235 endOfDesiredMonth.getFullYear(),
22236 endOfDesiredMonth.getMonth(),
22237 dayOfMonth
22238 );
22239 return _date;
22240 }
22241 }
22242
22243 // node_modules/date-fns/_lib/defaultOptions.js
22244 var defaultOptions = {};
22245 function getDefaultOptions() {
22246 return defaultOptions;
22247 }
22248
22249 // node_modules/date-fns/startOfWeek.js
22250 function startOfWeek(date, options) {
22251 const defaultOptions2 = getDefaultOptions();
22252 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
22253 const _date = toDate(date, options?.in);
22254 const day = _date.getDay();
22255 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
22256 _date.setDate(_date.getDate() - diff);
22257 _date.setHours(0, 0, 0, 0);
22258 return _date;
22259 }
22260
22261 // node_modules/date-fns/startOfISOWeek.js
22262 function startOfISOWeek(date, options) {
22263 return startOfWeek(date, { ...options, weekStartsOn: 1 });
22264 }
22265
22266 // node_modules/date-fns/getISOWeekYear.js
22267 function getISOWeekYear(date, options) {
22268 const _date = toDate(date, options?.in);
22269 const year = _date.getFullYear();
22270 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
22271 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
22272 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
22273 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
22274 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
22275 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
22276 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
22277 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
22278 if (_date.getTime() >= startOfNextYear.getTime()) {
22279 return year + 1;
22280 } else if (_date.getTime() >= startOfThisYear.getTime()) {
22281 return year;
22282 } else {
22283 return year - 1;
22284 }
22285 }
22286
22287 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
22288 function getTimezoneOffsetInMilliseconds(date) {
22289 const _date = toDate(date);
22290 const utcDate = new Date(
22291 Date.UTC(
22292 _date.getFullYear(),
22293 _date.getMonth(),
22294 _date.getDate(),
22295 _date.getHours(),
22296 _date.getMinutes(),
22297 _date.getSeconds(),
22298 _date.getMilliseconds()
22299 )
22300 );
22301 utcDate.setUTCFullYear(_date.getFullYear());
22302 return +date - +utcDate;
22303 }
22304
22305 // node_modules/date-fns/_lib/normalizeDates.js
22306 function normalizeDates(context, ...dates) {
22307 const normalize = constructFrom.bind(
22308 null,
22309 context || dates.find((date) => typeof date === "object")
22310 );
22311 return dates.map(normalize);
22312 }
22313
22314 // node_modules/date-fns/startOfDay.js
22315 function startOfDay(date, options) {
22316 const _date = toDate(date, options?.in);
22317 _date.setHours(0, 0, 0, 0);
22318 return _date;
22319 }
22320
22321 // node_modules/date-fns/differenceInCalendarDays.js
22322 function differenceInCalendarDays(laterDate, earlierDate, options) {
22323 const [laterDate_, earlierDate_] = normalizeDates(
22324 options?.in,
22325 laterDate,
22326 earlierDate
22327 );
22328 const laterStartOfDay = startOfDay(laterDate_);
22329 const earlierStartOfDay = startOfDay(earlierDate_);
22330 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
22331 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
22332 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
22333 }
22334
22335 // node_modules/date-fns/startOfISOWeekYear.js
22336 function startOfISOWeekYear(date, options) {
22337 const year = getISOWeekYear(date, options);
22338 const fourthOfJanuary = constructFrom(options?.in || date, 0);
22339 fourthOfJanuary.setFullYear(year, 0, 4);
22340 fourthOfJanuary.setHours(0, 0, 0, 0);
22341 return startOfISOWeek(fourthOfJanuary);
22342 }
22343
22344 // node_modules/date-fns/addWeeks.js
22345 function addWeeks(date, amount, options) {
22346 return addDays(date, amount * 7, options);
22347 }
22348
22349 // node_modules/date-fns/addYears.js
22350 function addYears(date, amount, options) {
22351 return addMonths(date, amount * 12, options);
22352 }
22353
22354 // node_modules/date-fns/isDate.js
22355 function isDate(value) {
22356 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
22357 }
22358
22359 // node_modules/date-fns/isValid.js
22360 function isValid(date) {
22361 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
22362 }
22363
22364 // node_modules/date-fns/startOfMonth.js
22365 function startOfMonth(date, options) {
22366 const _date = toDate(date, options?.in);
22367 _date.setDate(1);
22368 _date.setHours(0, 0, 0, 0);
22369 return _date;
22370 }
22371
22372 // node_modules/date-fns/startOfYear.js
22373 function startOfYear(date, options) {
22374 const date_ = toDate(date, options?.in);
22375 date_.setFullYear(date_.getFullYear(), 0, 1);
22376 date_.setHours(0, 0, 0, 0);
22377 return date_;
22378 }
22379
22380 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
22381 var formatDistanceLocale = {
22382 lessThanXSeconds: {
22383 one: "less than a second",
22384 other: "less than {{count}} seconds"
22385 },
22386 xSeconds: {
22387 one: "1 second",
22388 other: "{{count}} seconds"
22389 },
22390 halfAMinute: "half a minute",
22391 lessThanXMinutes: {
22392 one: "less than a minute",
22393 other: "less than {{count}} minutes"
22394 },
22395 xMinutes: {
22396 one: "1 minute",
22397 other: "{{count}} minutes"
22398 },
22399 aboutXHours: {
22400 one: "about 1 hour",
22401 other: "about {{count}} hours"
22402 },
22403 xHours: {
22404 one: "1 hour",
22405 other: "{{count}} hours"
22406 },
22407 xDays: {
22408 one: "1 day",
22409 other: "{{count}} days"
22410 },
22411 aboutXWeeks: {
22412 one: "about 1 week",
22413 other: "about {{count}} weeks"
22414 },
22415 xWeeks: {
22416 one: "1 week",
22417 other: "{{count}} weeks"
22418 },
22419 aboutXMonths: {
22420 one: "about 1 month",
22421 other: "about {{count}} months"
22422 },
22423 xMonths: {
22424 one: "1 month",
22425 other: "{{count}} months"
22426 },
22427 aboutXYears: {
22428 one: "about 1 year",
22429 other: "about {{count}} years"
22430 },
22431 xYears: {
22432 one: "1 year",
22433 other: "{{count}} years"
22434 },
22435 overXYears: {
22436 one: "over 1 year",
22437 other: "over {{count}} years"
22438 },
22439 almostXYears: {
22440 one: "almost 1 year",
22441 other: "almost {{count}} years"
22442 }
22443 };
22444 var formatDistance = (token, count, options) => {
22445 let result;
22446 const tokenValue = formatDistanceLocale[token];
22447 if (typeof tokenValue === "string") {
22448 result = tokenValue;
22449 } else if (count === 1) {
22450 result = tokenValue.one;
22451 } else {
22452 result = tokenValue.other.replace("{{count}}", count.toString());
22453 }
22454 if (options?.addSuffix) {
22455 if (options.comparison && options.comparison > 0) {
22456 return "in " + result;
22457 } else {
22458 return result + " ago";
22459 }
22460 }
22461 return result;
22462 };
22463
22464 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
22465 function buildFormatLongFn(args) {
22466 return (options = {}) => {
22467 const width = options.width ? String(options.width) : args.defaultWidth;
22468 const format6 = args.formats[width] || args.formats[args.defaultWidth];
22469 return format6;
22470 };
22471 }
22472
22473 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
22474 var dateFormats = {
22475 full: "EEEE, MMMM do, y",
22476 long: "MMMM do, y",
22477 medium: "MMM d, y",
22478 short: "MM/dd/yyyy"
22479 };
22480 var timeFormats = {
22481 full: "h:mm:ss a zzzz",
22482 long: "h:mm:ss a z",
22483 medium: "h:mm:ss a",
22484 short: "h:mm a"
22485 };
22486 var dateTimeFormats = {
22487 full: "{{date}} 'at' {{time}}",
22488 long: "{{date}} 'at' {{time}}",
22489 medium: "{{date}}, {{time}}",
22490 short: "{{date}}, {{time}}"
22491 };
22492 var formatLong = {
22493 date: buildFormatLongFn({
22494 formats: dateFormats,
22495 defaultWidth: "full"
22496 }),
22497 time: buildFormatLongFn({
22498 formats: timeFormats,
22499 defaultWidth: "full"
22500 }),
22501 dateTime: buildFormatLongFn({
22502 formats: dateTimeFormats,
22503 defaultWidth: "full"
22504 })
22505 };
22506
22507 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
22508 var formatRelativeLocale = {
22509 lastWeek: "'last' eeee 'at' p",
22510 yesterday: "'yesterday at' p",
22511 today: "'today at' p",
22512 tomorrow: "'tomorrow at' p",
22513 nextWeek: "eeee 'at' p",
22514 other: "P"
22515 };
22516 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
22517
22518 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
22519 function buildLocalizeFn(args) {
22520 return (value, options) => {
22521 const context = options?.context ? String(options.context) : "standalone";
22522 let valuesArray;
22523 if (context === "formatting" && args.formattingValues) {
22524 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
22525 const width = options?.width ? String(options.width) : defaultWidth;
22526 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
22527 } else {
22528 const defaultWidth = args.defaultWidth;
22529 const width = options?.width ? String(options.width) : args.defaultWidth;
22530 valuesArray = args.values[width] || args.values[defaultWidth];
22531 }
22532 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
22533 return valuesArray[index2];
22534 };
22535 }
22536
22537 // node_modules/date-fns/locale/en-US/_lib/localize.js
22538 var eraValues = {
22539 narrow: ["B", "A"],
22540 abbreviated: ["BC", "AD"],
22541 wide: ["Before Christ", "Anno Domini"]
22542 };
22543 var quarterValues = {
22544 narrow: ["1", "2", "3", "4"],
22545 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
22546 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
22547 };
22548 var monthValues = {
22549 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
22550 abbreviated: [
22551 "Jan",
22552 "Feb",
22553 "Mar",
22554 "Apr",
22555 "May",
22556 "Jun",
22557 "Jul",
22558 "Aug",
22559 "Sep",
22560 "Oct",
22561 "Nov",
22562 "Dec"
22563 ],
22564 wide: [
22565 "January",
22566 "February",
22567 "March",
22568 "April",
22569 "May",
22570 "June",
22571 "July",
22572 "August",
22573 "September",
22574 "October",
22575 "November",
22576 "December"
22577 ]
22578 };
22579 var dayValues = {
22580 narrow: ["S", "M", "T", "W", "T", "F", "S"],
22581 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
22582 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
22583 wide: [
22584 "Sunday",
22585 "Monday",
22586 "Tuesday",
22587 "Wednesday",
22588 "Thursday",
22589 "Friday",
22590 "Saturday"
22591 ]
22592 };
22593 var dayPeriodValues = {
22594 narrow: {
22595 am: "a",
22596 pm: "p",
22597 midnight: "mi",
22598 noon: "n",
22599 morning: "morning",
22600 afternoon: "afternoon",
22601 evening: "evening",
22602 night: "night"
22603 },
22604 abbreviated: {
22605 am: "AM",
22606 pm: "PM",
22607 midnight: "midnight",
22608 noon: "noon",
22609 morning: "morning",
22610 afternoon: "afternoon",
22611 evening: "evening",
22612 night: "night"
22613 },
22614 wide: {
22615 am: "a.m.",
22616 pm: "p.m.",
22617 midnight: "midnight",
22618 noon: "noon",
22619 morning: "morning",
22620 afternoon: "afternoon",
22621 evening: "evening",
22622 night: "night"
22623 }
22624 };
22625 var formattingDayPeriodValues = {
22626 narrow: {
22627 am: "a",
22628 pm: "p",
22629 midnight: "mi",
22630 noon: "n",
22631 morning: "in the morning",
22632 afternoon: "in the afternoon",
22633 evening: "in the evening",
22634 night: "at night"
22635 },
22636 abbreviated: {
22637 am: "AM",
22638 pm: "PM",
22639 midnight: "midnight",
22640 noon: "noon",
22641 morning: "in the morning",
22642 afternoon: "in the afternoon",
22643 evening: "in the evening",
22644 night: "at night"
22645 },
22646 wide: {
22647 am: "a.m.",
22648 pm: "p.m.",
22649 midnight: "midnight",
22650 noon: "noon",
22651 morning: "in the morning",
22652 afternoon: "in the afternoon",
22653 evening: "in the evening",
22654 night: "at night"
22655 }
22656 };
22657 var ordinalNumber = (dirtyNumber, _options) => {
22658 const number = Number(dirtyNumber);
22659 const rem100 = number % 100;
22660 if (rem100 > 20 || rem100 < 10) {
22661 switch (rem100 % 10) {
22662 case 1:
22663 return number + "st";
22664 case 2:
22665 return number + "nd";
22666 case 3:
22667 return number + "rd";
22668 }
22669 }
22670 return number + "th";
22671 };
22672 var localize = {
22673 ordinalNumber,
22674 era: buildLocalizeFn({
22675 values: eraValues,
22676 defaultWidth: "wide"
22677 }),
22678 quarter: buildLocalizeFn({
22679 values: quarterValues,
22680 defaultWidth: "wide",
22681 argumentCallback: (quarter) => quarter - 1
22682 }),
22683 month: buildLocalizeFn({
22684 values: monthValues,
22685 defaultWidth: "wide"
22686 }),
22687 day: buildLocalizeFn({
22688 values: dayValues,
22689 defaultWidth: "wide"
22690 }),
22691 dayPeriod: buildLocalizeFn({
22692 values: dayPeriodValues,
22693 defaultWidth: "wide",
22694 formattingValues: formattingDayPeriodValues,
22695 defaultFormattingWidth: "wide"
22696 })
22697 };
22698
22699 // node_modules/date-fns/locale/_lib/buildMatchFn.js
22700 function buildMatchFn(args) {
22701 return (string, options = {}) => {
22702 const width = options.width;
22703 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
22704 const matchResult = string.match(matchPattern);
22705 if (!matchResult) {
22706 return null;
22707 }
22708 const matchedString = matchResult[0];
22709 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
22710 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
22711 // [TODO] -- I challenge you to fix the type
22712 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
22713 );
22714 let value;
22715 value = args.valueCallback ? args.valueCallback(key) : key;
22716 value = options.valueCallback ? (
22717 // [TODO] -- I challenge you to fix the type
22718 options.valueCallback(value)
22719 ) : value;
22720 const rest = string.slice(matchedString.length);
22721 return { value, rest };
22722 };
22723 }
22724 function findKey(object, predicate) {
22725 for (const key in object) {
22726 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
22727 return key;
22728 }
22729 }
22730 return void 0;
22731 }
22732 function findIndex(array, predicate) {
22733 for (let key = 0; key < array.length; key++) {
22734 if (predicate(array[key])) {
22735 return key;
22736 }
22737 }
22738 return void 0;
22739 }
22740
22741 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
22742 function buildMatchPatternFn(args) {
22743 return (string, options = {}) => {
22744 const matchResult = string.match(args.matchPattern);
22745 if (!matchResult) return null;
22746 const matchedString = matchResult[0];
22747 const parseResult = string.match(args.parsePattern);
22748 if (!parseResult) return null;
22749 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
22750 value = options.valueCallback ? options.valueCallback(value) : value;
22751 const rest = string.slice(matchedString.length);
22752 return { value, rest };
22753 };
22754 }
22755
22756 // node_modules/date-fns/locale/en-US/_lib/match.js
22757 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
22758 var parseOrdinalNumberPattern = /\d+/i;
22759 var matchEraPatterns = {
22760 narrow: /^(b|a)/i,
22761 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
22762 wide: /^(before christ|before common era|anno domini|common era)/i
22763 };
22764 var parseEraPatterns = {
22765 any: [/^b/i, /^(a|c)/i]
22766 };
22767 var matchQuarterPatterns = {
22768 narrow: /^[1234]/i,
22769 abbreviated: /^q[1234]/i,
22770 wide: /^[1234](th|st|nd|rd)? quarter/i
22771 };
22772 var parseQuarterPatterns = {
22773 any: [/1/i, /2/i, /3/i, /4/i]
22774 };
22775 var matchMonthPatterns = {
22776 narrow: /^[jfmasond]/i,
22777 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
22778 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
22779 };
22780 var parseMonthPatterns = {
22781 narrow: [
22782 /^j/i,
22783 /^f/i,
22784 /^m/i,
22785 /^a/i,
22786 /^m/i,
22787 /^j/i,
22788 /^j/i,
22789 /^a/i,
22790 /^s/i,
22791 /^o/i,
22792 /^n/i,
22793 /^d/i
22794 ],
22795 any: [
22796 /^ja/i,
22797 /^f/i,
22798 /^mar/i,
22799 /^ap/i,
22800 /^may/i,
22801 /^jun/i,
22802 /^jul/i,
22803 /^au/i,
22804 /^s/i,
22805 /^o/i,
22806 /^n/i,
22807 /^d/i
22808 ]
22809 };
22810 var matchDayPatterns = {
22811 narrow: /^[smtwf]/i,
22812 short: /^(su|mo|tu|we|th|fr|sa)/i,
22813 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
22814 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
22815 };
22816 var parseDayPatterns = {
22817 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
22818 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
22819 };
22820 var matchDayPeriodPatterns = {
22821 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
22822 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
22823 };
22824 var parseDayPeriodPatterns = {
22825 any: {
22826 am: /^a/i,
22827 pm: /^p/i,
22828 midnight: /^mi/i,
22829 noon: /^no/i,
22830 morning: /morning/i,
22831 afternoon: /afternoon/i,
22832 evening: /evening/i,
22833 night: /night/i
22834 }
22835 };
22836 var match = {
22837 ordinalNumber: buildMatchPatternFn({
22838 matchPattern: matchOrdinalNumberPattern,
22839 parsePattern: parseOrdinalNumberPattern,
22840 valueCallback: (value) => parseInt(value, 10)
22841 }),
22842 era: buildMatchFn({
22843 matchPatterns: matchEraPatterns,
22844 defaultMatchWidth: "wide",
22845 parsePatterns: parseEraPatterns,
22846 defaultParseWidth: "any"
22847 }),
22848 quarter: buildMatchFn({
22849 matchPatterns: matchQuarterPatterns,
22850 defaultMatchWidth: "wide",
22851 parsePatterns: parseQuarterPatterns,
22852 defaultParseWidth: "any",
22853 valueCallback: (index2) => index2 + 1
22854 }),
22855 month: buildMatchFn({
22856 matchPatterns: matchMonthPatterns,
22857 defaultMatchWidth: "wide",
22858 parsePatterns: parseMonthPatterns,
22859 defaultParseWidth: "any"
22860 }),
22861 day: buildMatchFn({
22862 matchPatterns: matchDayPatterns,
22863 defaultMatchWidth: "wide",
22864 parsePatterns: parseDayPatterns,
22865 defaultParseWidth: "any"
22866 }),
22867 dayPeriod: buildMatchFn({
22868 matchPatterns: matchDayPeriodPatterns,
22869 defaultMatchWidth: "any",
22870 parsePatterns: parseDayPeriodPatterns,
22871 defaultParseWidth: "any"
22872 })
22873 };
22874
22875 // node_modules/date-fns/locale/en-US.js
22876 var enUS = {
22877 code: "en-US",
22878 formatDistance,
22879 formatLong,
22880 formatRelative,
22881 localize,
22882 match,
22883 options: {
22884 weekStartsOn: 0,
22885 firstWeekContainsDate: 1
22886 }
22887 };
22888
22889 // node_modules/date-fns/getDayOfYear.js
22890 function getDayOfYear(date, options) {
22891 const _date = toDate(date, options?.in);
22892 const diff = differenceInCalendarDays(_date, startOfYear(_date));
22893 const dayOfYear = diff + 1;
22894 return dayOfYear;
22895 }
22896
22897 // node_modules/date-fns/getISOWeek.js
22898 function getISOWeek(date, options) {
22899 const _date = toDate(date, options?.in);
22900 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
22901 return Math.round(diff / millisecondsInWeek) + 1;
22902 }
22903
22904 // node_modules/date-fns/getWeekYear.js
22905 function getWeekYear(date, options) {
22906 const _date = toDate(date, options?.in);
22907 const year = _date.getFullYear();
22908 const defaultOptions2 = getDefaultOptions();
22909 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
22910 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
22911 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
22912 firstWeekOfNextYear.setHours(0, 0, 0, 0);
22913 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
22914 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
22915 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
22916 firstWeekOfThisYear.setHours(0, 0, 0, 0);
22917 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
22918 if (+_date >= +startOfNextYear) {
22919 return year + 1;
22920 } else if (+_date >= +startOfThisYear) {
22921 return year;
22922 } else {
22923 return year - 1;
22924 }
22925 }
22926
22927 // node_modules/date-fns/startOfWeekYear.js
22928 function startOfWeekYear(date, options) {
22929 const defaultOptions2 = getDefaultOptions();
22930 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
22931 const year = getWeekYear(date, options);
22932 const firstWeek = constructFrom(options?.in || date, 0);
22933 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
22934 firstWeek.setHours(0, 0, 0, 0);
22935 const _date = startOfWeek(firstWeek, options);
22936 return _date;
22937 }
22938
22939 // node_modules/date-fns/getWeek.js
22940 function getWeek(date, options) {
22941 const _date = toDate(date, options?.in);
22942 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
22943 return Math.round(diff / millisecondsInWeek) + 1;
22944 }
22945
22946 // node_modules/date-fns/_lib/addLeadingZeros.js
22947 function addLeadingZeros(number, targetLength) {
22948 const sign = number < 0 ? "-" : "";
22949 const output = Math.abs(number).toString().padStart(targetLength, "0");
22950 return sign + output;
22951 }
22952
22953 // node_modules/date-fns/_lib/format/lightFormatters.js
22954 var lightFormatters = {
22955 // Year
22956 y(date, token) {
22957 const signedYear = date.getFullYear();
22958 const year = signedYear > 0 ? signedYear : 1 - signedYear;
22959 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
22960 },
22961 // Month
22962 M(date, token) {
22963 const month = date.getMonth();
22964 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
22965 },
22966 // Day of the month
22967 d(date, token) {
22968 return addLeadingZeros(date.getDate(), token.length);
22969 },
22970 // AM or PM
22971 a(date, token) {
22972 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
22973 switch (token) {
22974 case "a":
22975 case "aa":
22976 return dayPeriodEnumValue.toUpperCase();
22977 case "aaa":
22978 return dayPeriodEnumValue;
22979 case "aaaaa":
22980 return dayPeriodEnumValue[0];
22981 case "aaaa":
22982 default:
22983 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
22984 }
22985 },
22986 // Hour [1-12]
22987 h(date, token) {
22988 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
22989 },
22990 // Hour [0-23]
22991 H(date, token) {
22992 return addLeadingZeros(date.getHours(), token.length);
22993 },
22994 // Minute
22995 m(date, token) {
22996 return addLeadingZeros(date.getMinutes(), token.length);
22997 },
22998 // Second
22999 s(date, token) {
23000 return addLeadingZeros(date.getSeconds(), token.length);
23001 },
23002 // Fraction of second
23003 S(date, token) {
23004 const numberOfDigits = token.length;
23005 const milliseconds = date.getMilliseconds();
23006 const fractionalSeconds = Math.trunc(
23007 milliseconds * Math.pow(10, numberOfDigits - 3)
23008 );
23009 return addLeadingZeros(fractionalSeconds, token.length);
23010 }
23011 };
23012
23013 // node_modules/date-fns/_lib/format/formatters.js
23014 var dayPeriodEnum = {
23015 am: "am",
23016 pm: "pm",
23017 midnight: "midnight",
23018 noon: "noon",
23019 morning: "morning",
23020 afternoon: "afternoon",
23021 evening: "evening",
23022 night: "night"
23023 };
23024 var formatters = {
23025 // Era
23026 G: function(date, token, localize2) {
23027 const era = date.getFullYear() > 0 ? 1 : 0;
23028 switch (token) {
23029 // AD, BC
23030 case "G":
23031 case "GG":
23032 case "GGG":
23033 return localize2.era(era, { width: "abbreviated" });
23034 // A, B
23035 case "GGGGG":
23036 return localize2.era(era, { width: "narrow" });
23037 // Anno Domini, Before Christ
23038 case "GGGG":
23039 default:
23040 return localize2.era(era, { width: "wide" });
23041 }
23042 },
23043 // Year
23044 y: function(date, token, localize2) {
23045 if (token === "yo") {
23046 const signedYear = date.getFullYear();
23047 const year = signedYear > 0 ? signedYear : 1 - signedYear;
23048 return localize2.ordinalNumber(year, { unit: "year" });
23049 }
23050 return lightFormatters.y(date, token);
23051 },
23052 // Local week-numbering year
23053 Y: function(date, token, localize2, options) {
23054 const signedWeekYear = getWeekYear(date, options);
23055 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
23056 if (token === "YY") {
23057 const twoDigitYear = weekYear % 100;
23058 return addLeadingZeros(twoDigitYear, 2);
23059 }
23060 if (token === "Yo") {
23061 return localize2.ordinalNumber(weekYear, { unit: "year" });
23062 }
23063 return addLeadingZeros(weekYear, token.length);
23064 },
23065 // ISO week-numbering year
23066 R: function(date, token) {
23067 const isoWeekYear = getISOWeekYear(date);
23068 return addLeadingZeros(isoWeekYear, token.length);
23069 },
23070 // Extended year. This is a single number designating the year of this calendar system.
23071 // The main difference between `y` and `u` localizers are B.C. years:
23072 // | Year | `y` | `u` |
23073 // |------|-----|-----|
23074 // | AC 1 | 1 | 1 |
23075 // | BC 1 | 1 | 0 |
23076 // | BC 2 | 2 | -1 |
23077 // Also `yy` always returns the last two digits of a year,
23078 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
23079 u: function(date, token) {
23080 const year = date.getFullYear();
23081 return addLeadingZeros(year, token.length);
23082 },
23083 // Quarter
23084 Q: function(date, token, localize2) {
23085 const quarter = Math.ceil((date.getMonth() + 1) / 3);
23086 switch (token) {
23087 // 1, 2, 3, 4
23088 case "Q":
23089 return String(quarter);
23090 // 01, 02, 03, 04
23091 case "QQ":
23092 return addLeadingZeros(quarter, 2);
23093 // 1st, 2nd, 3rd, 4th
23094 case "Qo":
23095 return localize2.ordinalNumber(quarter, { unit: "quarter" });
23096 // Q1, Q2, Q3, Q4
23097 case "QQQ":
23098 return localize2.quarter(quarter, {
23099 width: "abbreviated",
23100 context: "formatting"
23101 });
23102 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
23103 case "QQQQQ":
23104 return localize2.quarter(quarter, {
23105 width: "narrow",
23106 context: "formatting"
23107 });
23108 // 1st quarter, 2nd quarter, ...
23109 case "QQQQ":
23110 default:
23111 return localize2.quarter(quarter, {
23112 width: "wide",
23113 context: "formatting"
23114 });
23115 }
23116 },
23117 // Stand-alone quarter
23118 q: function(date, token, localize2) {
23119 const quarter = Math.ceil((date.getMonth() + 1) / 3);
23120 switch (token) {
23121 // 1, 2, 3, 4
23122 case "q":
23123 return String(quarter);
23124 // 01, 02, 03, 04
23125 case "qq":
23126 return addLeadingZeros(quarter, 2);
23127 // 1st, 2nd, 3rd, 4th
23128 case "qo":
23129 return localize2.ordinalNumber(quarter, { unit: "quarter" });
23130 // Q1, Q2, Q3, Q4
23131 case "qqq":
23132 return localize2.quarter(quarter, {
23133 width: "abbreviated",
23134 context: "standalone"
23135 });
23136 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
23137 case "qqqqq":
23138 return localize2.quarter(quarter, {
23139 width: "narrow",
23140 context: "standalone"
23141 });
23142 // 1st quarter, 2nd quarter, ...
23143 case "qqqq":
23144 default:
23145 return localize2.quarter(quarter, {
23146 width: "wide",
23147 context: "standalone"
23148 });
23149 }
23150 },
23151 // Month
23152 M: function(date, token, localize2) {
23153 const month = date.getMonth();
23154 switch (token) {
23155 case "M":
23156 case "MM":
23157 return lightFormatters.M(date, token);
23158 // 1st, 2nd, ..., 12th
23159 case "Mo":
23160 return localize2.ordinalNumber(month + 1, { unit: "month" });
23161 // Jan, Feb, ..., Dec
23162 case "MMM":
23163 return localize2.month(month, {
23164 width: "abbreviated",
23165 context: "formatting"
23166 });
23167 // J, F, ..., D
23168 case "MMMMM":
23169 return localize2.month(month, {
23170 width: "narrow",
23171 context: "formatting"
23172 });
23173 // January, February, ..., December
23174 case "MMMM":
23175 default:
23176 return localize2.month(month, { width: "wide", context: "formatting" });
23177 }
23178 },
23179 // Stand-alone month
23180 L: function(date, token, localize2) {
23181 const month = date.getMonth();
23182 switch (token) {
23183 // 1, 2, ..., 12
23184 case "L":
23185 return String(month + 1);
23186 // 01, 02, ..., 12
23187 case "LL":
23188 return addLeadingZeros(month + 1, 2);
23189 // 1st, 2nd, ..., 12th
23190 case "Lo":
23191 return localize2.ordinalNumber(month + 1, { unit: "month" });
23192 // Jan, Feb, ..., Dec
23193 case "LLL":
23194 return localize2.month(month, {
23195 width: "abbreviated",
23196 context: "standalone"
23197 });
23198 // J, F, ..., D
23199 case "LLLLL":
23200 return localize2.month(month, {
23201 width: "narrow",
23202 context: "standalone"
23203 });
23204 // January, February, ..., December
23205 case "LLLL":
23206 default:
23207 return localize2.month(month, { width: "wide", context: "standalone" });
23208 }
23209 },
23210 // Local week of year
23211 w: function(date, token, localize2, options) {
23212 const week = getWeek(date, options);
23213 if (token === "wo") {
23214 return localize2.ordinalNumber(week, { unit: "week" });
23215 }
23216 return addLeadingZeros(week, token.length);
23217 },
23218 // ISO week of year
23219 I: function(date, token, localize2) {
23220 const isoWeek = getISOWeek(date);
23221 if (token === "Io") {
23222 return localize2.ordinalNumber(isoWeek, { unit: "week" });
23223 }
23224 return addLeadingZeros(isoWeek, token.length);
23225 },
23226 // Day of the month
23227 d: function(date, token, localize2) {
23228 if (token === "do") {
23229 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
23230 }
23231 return lightFormatters.d(date, token);
23232 },
23233 // Day of year
23234 D: function(date, token, localize2) {
23235 const dayOfYear = getDayOfYear(date);
23236 if (token === "Do") {
23237 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
23238 }
23239 return addLeadingZeros(dayOfYear, token.length);
23240 },
23241 // Day of week
23242 E: function(date, token, localize2) {
23243 const dayOfWeek = date.getDay();
23244 switch (token) {
23245 // Tue
23246 case "E":
23247 case "EE":
23248 case "EEE":
23249 return localize2.day(dayOfWeek, {
23250 width: "abbreviated",
23251 context: "formatting"
23252 });
23253 // T
23254 case "EEEEE":
23255 return localize2.day(dayOfWeek, {
23256 width: "narrow",
23257 context: "formatting"
23258 });
23259 // Tu
23260 case "EEEEEE":
23261 return localize2.day(dayOfWeek, {
23262 width: "short",
23263 context: "formatting"
23264 });
23265 // Tuesday
23266 case "EEEE":
23267 default:
23268 return localize2.day(dayOfWeek, {
23269 width: "wide",
23270 context: "formatting"
23271 });
23272 }
23273 },
23274 // Local day of week
23275 e: function(date, token, localize2, options) {
23276 const dayOfWeek = date.getDay();
23277 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
23278 switch (token) {
23279 // Numerical value (Nth day of week with current locale or weekStartsOn)
23280 case "e":
23281 return String(localDayOfWeek);
23282 // Padded numerical value
23283 case "ee":
23284 return addLeadingZeros(localDayOfWeek, 2);
23285 // 1st, 2nd, ..., 7th
23286 case "eo":
23287 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
23288 case "eee":
23289 return localize2.day(dayOfWeek, {
23290 width: "abbreviated",
23291 context: "formatting"
23292 });
23293 // T
23294 case "eeeee":
23295 return localize2.day(dayOfWeek, {
23296 width: "narrow",
23297 context: "formatting"
23298 });
23299 // Tu
23300 case "eeeeee":
23301 return localize2.day(dayOfWeek, {
23302 width: "short",
23303 context: "formatting"
23304 });
23305 // Tuesday
23306 case "eeee":
23307 default:
23308 return localize2.day(dayOfWeek, {
23309 width: "wide",
23310 context: "formatting"
23311 });
23312 }
23313 },
23314 // Stand-alone local day of week
23315 c: function(date, token, localize2, options) {
23316 const dayOfWeek = date.getDay();
23317 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
23318 switch (token) {
23319 // Numerical value (same as in `e`)
23320 case "c":
23321 return String(localDayOfWeek);
23322 // Padded numerical value
23323 case "cc":
23324 return addLeadingZeros(localDayOfWeek, token.length);
23325 // 1st, 2nd, ..., 7th
23326 case "co":
23327 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
23328 case "ccc":
23329 return localize2.day(dayOfWeek, {
23330 width: "abbreviated",
23331 context: "standalone"
23332 });
23333 // T
23334 case "ccccc":
23335 return localize2.day(dayOfWeek, {
23336 width: "narrow",
23337 context: "standalone"
23338 });
23339 // Tu
23340 case "cccccc":
23341 return localize2.day(dayOfWeek, {
23342 width: "short",
23343 context: "standalone"
23344 });
23345 // Tuesday
23346 case "cccc":
23347 default:
23348 return localize2.day(dayOfWeek, {
23349 width: "wide",
23350 context: "standalone"
23351 });
23352 }
23353 },
23354 // ISO day of week
23355 i: function(date, token, localize2) {
23356 const dayOfWeek = date.getDay();
23357 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
23358 switch (token) {
23359 // 2
23360 case "i":
23361 return String(isoDayOfWeek);
23362 // 02
23363 case "ii":
23364 return addLeadingZeros(isoDayOfWeek, token.length);
23365 // 2nd
23366 case "io":
23367 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
23368 // Tue
23369 case "iii":
23370 return localize2.day(dayOfWeek, {
23371 width: "abbreviated",
23372 context: "formatting"
23373 });
23374 // T
23375 case "iiiii":
23376 return localize2.day(dayOfWeek, {
23377 width: "narrow",
23378 context: "formatting"
23379 });
23380 // Tu
23381 case "iiiiii":
23382 return localize2.day(dayOfWeek, {
23383 width: "short",
23384 context: "formatting"
23385 });
23386 // Tuesday
23387 case "iiii":
23388 default:
23389 return localize2.day(dayOfWeek, {
23390 width: "wide",
23391 context: "formatting"
23392 });
23393 }
23394 },
23395 // AM or PM
23396 a: function(date, token, localize2) {
23397 const hours = date.getHours();
23398 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
23399 switch (token) {
23400 case "a":
23401 case "aa":
23402 return localize2.dayPeriod(dayPeriodEnumValue, {
23403 width: "abbreviated",
23404 context: "formatting"
23405 });
23406 case "aaa":
23407 return localize2.dayPeriod(dayPeriodEnumValue, {
23408 width: "abbreviated",
23409 context: "formatting"
23410 }).toLowerCase();
23411 case "aaaaa":
23412 return localize2.dayPeriod(dayPeriodEnumValue, {
23413 width: "narrow",
23414 context: "formatting"
23415 });
23416 case "aaaa":
23417 default:
23418 return localize2.dayPeriod(dayPeriodEnumValue, {
23419 width: "wide",
23420 context: "formatting"
23421 });
23422 }
23423 },
23424 // AM, PM, midnight, noon
23425 b: function(date, token, localize2) {
23426 const hours = date.getHours();
23427 let dayPeriodEnumValue;
23428 if (hours === 12) {
23429 dayPeriodEnumValue = dayPeriodEnum.noon;
23430 } else if (hours === 0) {
23431 dayPeriodEnumValue = dayPeriodEnum.midnight;
23432 } else {
23433 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
23434 }
23435 switch (token) {
23436 case "b":
23437 case "bb":
23438 return localize2.dayPeriod(dayPeriodEnumValue, {
23439 width: "abbreviated",
23440 context: "formatting"
23441 });
23442 case "bbb":
23443 return localize2.dayPeriod(dayPeriodEnumValue, {
23444 width: "abbreviated",
23445 context: "formatting"
23446 }).toLowerCase();
23447 case "bbbbb":
23448 return localize2.dayPeriod(dayPeriodEnumValue, {
23449 width: "narrow",
23450 context: "formatting"
23451 });
23452 case "bbbb":
23453 default:
23454 return localize2.dayPeriod(dayPeriodEnumValue, {
23455 width: "wide",
23456 context: "formatting"
23457 });
23458 }
23459 },
23460 // in the morning, in the afternoon, in the evening, at night
23461 B: function(date, token, localize2) {
23462 const hours = date.getHours();
23463 let dayPeriodEnumValue;
23464 if (hours >= 17) {
23465 dayPeriodEnumValue = dayPeriodEnum.evening;
23466 } else if (hours >= 12) {
23467 dayPeriodEnumValue = dayPeriodEnum.afternoon;
23468 } else if (hours >= 4) {
23469 dayPeriodEnumValue = dayPeriodEnum.morning;
23470 } else {
23471 dayPeriodEnumValue = dayPeriodEnum.night;
23472 }
23473 switch (token) {
23474 case "B":
23475 case "BB":
23476 case "BBB":
23477 return localize2.dayPeriod(dayPeriodEnumValue, {
23478 width: "abbreviated",
23479 context: "formatting"
23480 });
23481 case "BBBBB":
23482 return localize2.dayPeriod(dayPeriodEnumValue, {
23483 width: "narrow",
23484 context: "formatting"
23485 });
23486 case "BBBB":
23487 default:
23488 return localize2.dayPeriod(dayPeriodEnumValue, {
23489 width: "wide",
23490 context: "formatting"
23491 });
23492 }
23493 },
23494 // Hour [1-12]
23495 h: function(date, token, localize2) {
23496 if (token === "ho") {
23497 let hours = date.getHours() % 12;
23498 if (hours === 0) hours = 12;
23499 return localize2.ordinalNumber(hours, { unit: "hour" });
23500 }
23501 return lightFormatters.h(date, token);
23502 },
23503 // Hour [0-23]
23504 H: function(date, token, localize2) {
23505 if (token === "Ho") {
23506 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
23507 }
23508 return lightFormatters.H(date, token);
23509 },
23510 // Hour [0-11]
23511 K: function(date, token, localize2) {
23512 const hours = date.getHours() % 12;
23513 if (token === "Ko") {
23514 return localize2.ordinalNumber(hours, { unit: "hour" });
23515 }
23516 return addLeadingZeros(hours, token.length);
23517 },
23518 // Hour [1-24]
23519 k: function(date, token, localize2) {
23520 let hours = date.getHours();
23521 if (hours === 0) hours = 24;
23522 if (token === "ko") {
23523 return localize2.ordinalNumber(hours, { unit: "hour" });
23524 }
23525 return addLeadingZeros(hours, token.length);
23526 },
23527 // Minute
23528 m: function(date, token, localize2) {
23529 if (token === "mo") {
23530 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
23531 }
23532 return lightFormatters.m(date, token);
23533 },
23534 // Second
23535 s: function(date, token, localize2) {
23536 if (token === "so") {
23537 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
23538 }
23539 return lightFormatters.s(date, token);
23540 },
23541 // Fraction of second
23542 S: function(date, token) {
23543 return lightFormatters.S(date, token);
23544 },
23545 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
23546 X: function(date, token, _localize) {
23547 const timezoneOffset = date.getTimezoneOffset();
23548 if (timezoneOffset === 0) {
23549 return "Z";
23550 }
23551 switch (token) {
23552 // Hours and optional minutes
23553 case "X":
23554 return formatTimezoneWithOptionalMinutes(timezoneOffset);
23555 // Hours, minutes and optional seconds without `:` delimiter
23556 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
23557 // so this token always has the same output as `XX`
23558 case "XXXX":
23559 case "XX":
23560 return formatTimezone(timezoneOffset);
23561 // Hours, minutes and optional seconds with `:` delimiter
23562 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
23563 // so this token always has the same output as `XXX`
23564 case "XXXXX":
23565 case "XXX":
23566 // Hours and minutes with `:` delimiter
23567 default:
23568 return formatTimezone(timezoneOffset, ":");
23569 }
23570 },
23571 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
23572 x: function(date, token, _localize) {
23573 const timezoneOffset = date.getTimezoneOffset();
23574 switch (token) {
23575 // Hours and optional minutes
23576 case "x":
23577 return formatTimezoneWithOptionalMinutes(timezoneOffset);
23578 // Hours, minutes and optional seconds without `:` delimiter
23579 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
23580 // so this token always has the same output as `xx`
23581 case "xxxx":
23582 case "xx":
23583 return formatTimezone(timezoneOffset);
23584 // Hours, minutes and optional seconds with `:` delimiter
23585 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
23586 // so this token always has the same output as `xxx`
23587 case "xxxxx":
23588 case "xxx":
23589 // Hours and minutes with `:` delimiter
23590 default:
23591 return formatTimezone(timezoneOffset, ":");
23592 }
23593 },
23594 // Timezone (GMT)
23595 O: function(date, token, _localize) {
23596 const timezoneOffset = date.getTimezoneOffset();
23597 switch (token) {
23598 // Short
23599 case "O":
23600 case "OO":
23601 case "OOO":
23602 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
23603 // Long
23604 case "OOOO":
23605 default:
23606 return "GMT" + formatTimezone(timezoneOffset, ":");
23607 }
23608 },
23609 // Timezone (specific non-location)
23610 z: function(date, token, _localize) {
23611 const timezoneOffset = date.getTimezoneOffset();
23612 switch (token) {
23613 // Short
23614 case "z":
23615 case "zz":
23616 case "zzz":
23617 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
23618 // Long
23619 case "zzzz":
23620 default:
23621 return "GMT" + formatTimezone(timezoneOffset, ":");
23622 }
23623 },
23624 // Seconds timestamp
23625 t: function(date, token, _localize) {
23626 const timestamp = Math.trunc(+date / 1e3);
23627 return addLeadingZeros(timestamp, token.length);
23628 },
23629 // Milliseconds timestamp
23630 T: function(date, token, _localize) {
23631 return addLeadingZeros(+date, token.length);
23632 }
23633 };
23634 function formatTimezoneShort(offset4, delimiter = "") {
23635 const sign = offset4 > 0 ? "-" : "+";
23636 const absOffset = Math.abs(offset4);
23637 const hours = Math.trunc(absOffset / 60);
23638 const minutes = absOffset % 60;
23639 if (minutes === 0) {
23640 return sign + String(hours);
23641 }
23642 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
23643 }
23644 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
23645 if (offset4 % 60 === 0) {
23646 const sign = offset4 > 0 ? "-" : "+";
23647 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
23648 }
23649 return formatTimezone(offset4, delimiter);
23650 }
23651 function formatTimezone(offset4, delimiter = "") {
23652 const sign = offset4 > 0 ? "-" : "+";
23653 const absOffset = Math.abs(offset4);
23654 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
23655 const minutes = addLeadingZeros(absOffset % 60, 2);
23656 return sign + hours + delimiter + minutes;
23657 }
23658
23659 // node_modules/date-fns/_lib/format/longFormatters.js
23660 var dateLongFormatter = (pattern, formatLong2) => {
23661 switch (pattern) {
23662 case "P":
23663 return formatLong2.date({ width: "short" });
23664 case "PP":
23665 return formatLong2.date({ width: "medium" });
23666 case "PPP":
23667 return formatLong2.date({ width: "long" });
23668 case "PPPP":
23669 default:
23670 return formatLong2.date({ width: "full" });
23671 }
23672 };
23673 var timeLongFormatter = (pattern, formatLong2) => {
23674 switch (pattern) {
23675 case "p":
23676 return formatLong2.time({ width: "short" });
23677 case "pp":
23678 return formatLong2.time({ width: "medium" });
23679 case "ppp":
23680 return formatLong2.time({ width: "long" });
23681 case "pppp":
23682 default:
23683 return formatLong2.time({ width: "full" });
23684 }
23685 };
23686 var dateTimeLongFormatter = (pattern, formatLong2) => {
23687 const matchResult = pattern.match(/(P+)(p+)?/) || [];
23688 const datePattern = matchResult[1];
23689 const timePattern = matchResult[2];
23690 if (!timePattern) {
23691 return dateLongFormatter(pattern, formatLong2);
23692 }
23693 let dateTimeFormat;
23694 switch (datePattern) {
23695 case "P":
23696 dateTimeFormat = formatLong2.dateTime({ width: "short" });
23697 break;
23698 case "PP":
23699 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
23700 break;
23701 case "PPP":
23702 dateTimeFormat = formatLong2.dateTime({ width: "long" });
23703 break;
23704 case "PPPP":
23705 default:
23706 dateTimeFormat = formatLong2.dateTime({ width: "full" });
23707 break;
23708 }
23709 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
23710 };
23711 var longFormatters = {
23712 p: timeLongFormatter,
23713 P: dateTimeLongFormatter
23714 };
23715
23716 // node_modules/date-fns/_lib/protectedTokens.js
23717 var dayOfYearTokenRE = /^D+$/;
23718 var weekYearTokenRE = /^Y+$/;
23719 var throwTokens = ["D", "DD", "YY", "YYYY"];
23720 function isProtectedDayOfYearToken(token) {
23721 return dayOfYearTokenRE.test(token);
23722 }
23723 function isProtectedWeekYearToken(token) {
23724 return weekYearTokenRE.test(token);
23725 }
23726 function warnOrThrowProtectedError(token, format6, input) {
23727 const _message = message(token, format6, input);
23728 console.warn(_message);
23729 if (throwTokens.includes(token)) throw new RangeError(_message);
23730 }
23731 function message(token, format6, input) {
23732 const subject = token[0] === "Y" ? "years" : "days of the month";
23733 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`;
23734 }
23735
23736 // node_modules/date-fns/format.js
23737 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
23738 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
23739 var escapedStringRegExp = /^'([^]*?)'?$/;
23740 var doubleQuoteRegExp = /''/g;
23741 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
23742 function format(date, formatStr, options) {
23743 const defaultOptions2 = getDefaultOptions();
23744 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
23745 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
23746 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
23747 const originalDate = toDate(date, options?.in);
23748 if (!isValid(originalDate)) {
23749 throw new RangeError("Invalid time value");
23750 }
23751 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
23752 const firstCharacter = substring[0];
23753 if (firstCharacter === "p" || firstCharacter === "P") {
23754 const longFormatter = longFormatters[firstCharacter];
23755 return longFormatter(substring, locale.formatLong);
23756 }
23757 return substring;
23758 }).join("").match(formattingTokensRegExp).map((substring) => {
23759 if (substring === "''") {
23760 return { isToken: false, value: "'" };
23761 }
23762 const firstCharacter = substring[0];
23763 if (firstCharacter === "'") {
23764 return { isToken: false, value: cleanEscapedString(substring) };
23765 }
23766 if (formatters[firstCharacter]) {
23767 return { isToken: true, value: substring };
23768 }
23769 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
23770 throw new RangeError(
23771 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
23772 );
23773 }
23774 return { isToken: false, value: substring };
23775 });
23776 if (locale.localize.preprocessor) {
23777 parts = locale.localize.preprocessor(originalDate, parts);
23778 }
23779 const formatterOptions = {
23780 firstWeekContainsDate,
23781 weekStartsOn,
23782 locale
23783 };
23784 return parts.map((part) => {
23785 if (!part.isToken) return part.value;
23786 const token = part.value;
23787 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
23788 warnOrThrowProtectedError(token, formatStr, String(date));
23789 }
23790 const formatter = formatters[token[0]];
23791 return formatter(originalDate, token, locale.localize, formatterOptions);
23792 }).join("");
23793 }
23794 function cleanEscapedString(input) {
23795 const matched = input.match(escapedStringRegExp);
23796 if (!matched) {
23797 return input;
23798 }
23799 return matched[1].replace(doubleQuoteRegExp, "'");
23800 }
23801
23802 // node_modules/date-fns/subDays.js
23803 function subDays(date, amount, options) {
23804 return addDays(date, -amount, options);
23805 }
23806
23807 // node_modules/date-fns/subMonths.js
23808 function subMonths(date, amount, options) {
23809 return addMonths(date, -amount, options);
23810 }
23811
23812 // node_modules/date-fns/subWeeks.js
23813 function subWeeks(date, amount, options) {
23814 return addWeeks(date, -amount, options);
23815 }
23816
23817 // node_modules/date-fns/subYears.js
23818 function subYears(date, amount, options) {
23819 return addYears(date, -amount, options);
23820 }
23821
23822 // packages/dataviews/build-module/utils/operators.mjs
23823 var import_i18n26 = __toESM(require_i18n(), 1);
23824 var import_element70 = __toESM(require_element(), 1);
23825 var import_date = __toESM(require_date(), 1);
23826 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23827 var filterTextWrappers = {
23828 Name: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
23829 Value: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
23830 };
23831 function getRelativeDate(value, unit) {
23832 switch (unit) {
23833 case "days":
23834 return subDays(/* @__PURE__ */ new Date(), value);
23835 case "weeks":
23836 return subWeeks(/* @__PURE__ */ new Date(), value);
23837 case "months":
23838 return subMonths(/* @__PURE__ */ new Date(), value);
23839 case "years":
23840 return subYears(/* @__PURE__ */ new Date(), value);
23841 default:
23842 return /* @__PURE__ */ new Date();
23843 }
23844 }
23845 var isNoneOperatorDefinition = {
23846 /* translators: DataViews operator name */
23847 label: (0, import_i18n26.__)("Is none of"),
23848 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
23849 (0, import_i18n26.sprintf)(
23850 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
23851 (0, import_i18n26.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
23852 filter.name,
23853 activeElements.map((element) => element.label).join(", ")
23854 ),
23855 filterTextWrappers
23856 ),
23857 filter: ((item, field, filterValue) => {
23858 if (!filterValue?.length) {
23859 return true;
23860 }
23861 const fieldValue = field.getValue({ item });
23862 if (Array.isArray(fieldValue)) {
23863 return !filterValue.some(
23864 (fv) => fieldValue.includes(fv)
23865 );
23866 } else if (typeof fieldValue === "string") {
23867 return !filterValue.includes(fieldValue);
23868 }
23869 return false;
23870 }),
23871 selection: "multi"
23872 };
23873 var OPERATORS = [
23874 {
23875 name: OPERATOR_IS_ANY,
23876 /* translators: DataViews operator name */
23877 label: (0, import_i18n26.__)("Includes"),
23878 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
23879 (0, import_i18n26.sprintf)(
23880 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
23881 (0, import_i18n26.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
23882 filter.name,
23883 activeElements.map((element) => element.label).join(", ")
23884 ),
23885 filterTextWrappers
23886 ),
23887 filter(item, field, filterValue) {
23888 if (!filterValue?.length) {
23889 return true;
23890 }
23891 const fieldValue = field.getValue({ item });
23892 if (Array.isArray(fieldValue)) {
23893 return filterValue.some(
23894 (fv) => fieldValue.includes(fv)
23895 );
23896 } else if (typeof fieldValue === "string") {
23897 return filterValue.includes(fieldValue);
23898 }
23899 return false;
23900 },
23901 selection: "multi"
23902 },
23903 {
23904 name: OPERATOR_IS_NONE,
23905 ...isNoneOperatorDefinition
23906 },
23907 {
23908 name: OPERATOR_IS_ALL,
23909 /* translators: DataViews operator name */
23910 label: (0, import_i18n26.__)("Includes all"),
23911 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
23912 (0, import_i18n26.sprintf)(
23913 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
23914 (0, import_i18n26.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
23915 filter.name,
23916 activeElements.map((element) => element.label).join(", ")
23917 ),
23918 filterTextWrappers
23919 ),
23920 filter(item, field, filterValue) {
23921 if (!filterValue?.length) {
23922 return true;
23923 }
23924 return filterValue.every((value) => {
23925 return field.getValue({ item })?.includes(value);
23926 });
23927 },
23928 selection: "multi"
23929 },
23930 {
23931 name: OPERATOR_IS_NOT_ALL,
23932 ...isNoneOperatorDefinition
23933 },
23934 {
23935 name: OPERATOR_BETWEEN,
23936 /* translators: DataViews operator name */
23937 label: (0, import_i18n26.__)("Between (inc)"),
23938 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
23939 (0, import_i18n26.sprintf)(
23940 /* 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". */
23941 (0, import_i18n26.__)(
23942 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
23943 ),
23944 filter.name,
23945 activeElements[0].label[0],
23946 activeElements[0].label[1]
23947 ),
23948 filterTextWrappers
23949 ),
23950 filter(item, field, filterValue) {
23951 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
23952 return true;
23953 }
23954 const fieldValue = field.getValue({ item });
23955 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
23956 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
23957 }
23958 return false;
23959 },
23960 selection: "custom"
23961 },
23962 {
23963 name: OPERATOR_IN_THE_PAST,
23964 /* translators: DataViews operator name */
23965 label: (0, import_i18n26.__)("In the past"),
23966 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
23967 (0, import_i18n26.sprintf)(
23968 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
23969 (0, import_i18n26.__)(
23970 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
23971 ),
23972 filter.name,
23973 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
23974 ),
23975 filterTextWrappers
23976 ),
23977 filter(item, field, filterValue) {
23978 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
23979 return true;
23980 }
23981 const targetDate = getRelativeDate(
23982 filterValue.value,
23983 filterValue.unit
23984 );
23985 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
23986 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
23987 },
23988 selection: "custom"
23989 },
23990 {
23991 name: OPERATOR_OVER,
23992 /* translators: DataViews operator name */
23993 label: (0, import_i18n26.__)("Over"),
23994 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
23995 (0, import_i18n26.sprintf)(
23996 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
23997 (0, import_i18n26.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
23998 filter.name,
23999 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
24000 ),
24001 filterTextWrappers
24002 ),
24003 filter(item, field, filterValue) {
24004 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
24005 return true;
24006 }
24007 const targetDate = getRelativeDate(
24008 filterValue.value,
24009 filterValue.unit
24010 );
24011 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
24012 return fieldValue < targetDate;
24013 },
24014 selection: "custom"
24015 },
24016 {
24017 name: OPERATOR_IS,
24018 /* translators: DataViews operator name */
24019 label: (0, import_i18n26.__)("Is"),
24020 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24021 (0, import_i18n26.sprintf)(
24022 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
24023 (0, import_i18n26.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
24024 filter.name,
24025 activeElements[0].label
24026 ),
24027 filterTextWrappers
24028 ),
24029 filter(item, field, filterValue) {
24030 return filterValue === field.getValue({ item }) || filterValue === void 0;
24031 },
24032 selection: "single"
24033 },
24034 {
24035 name: OPERATOR_IS_NOT,
24036 /* translators: DataViews operator name */
24037 label: (0, import_i18n26.__)("Is not"),
24038 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24039 (0, import_i18n26.sprintf)(
24040 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
24041 (0, import_i18n26.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
24042 filter.name,
24043 activeElements[0].label
24044 ),
24045 filterTextWrappers
24046 ),
24047 filter(item, field, filterValue) {
24048 return filterValue !== field.getValue({ item });
24049 },
24050 selection: "single"
24051 },
24052 {
24053 name: OPERATOR_LESS_THAN,
24054 /* translators: DataViews operator name */
24055 label: (0, import_i18n26.__)("Less than"),
24056 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24057 (0, import_i18n26.sprintf)(
24058 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
24059 (0, import_i18n26.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
24060 filter.name,
24061 activeElements[0].label
24062 ),
24063 filterTextWrappers
24064 ),
24065 filter(item, field, filterValue) {
24066 if (filterValue === void 0) {
24067 return true;
24068 }
24069 const fieldValue = field.getValue({ item });
24070 return fieldValue < filterValue;
24071 },
24072 selection: "single"
24073 },
24074 {
24075 name: OPERATOR_GREATER_THAN,
24076 /* translators: DataViews operator name */
24077 label: (0, import_i18n26.__)("Greater than"),
24078 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24079 (0, import_i18n26.sprintf)(
24080 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
24081 (0, import_i18n26.__)(
24082 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
24083 ),
24084 filter.name,
24085 activeElements[0].label
24086 ),
24087 filterTextWrappers
24088 ),
24089 filter(item, field, filterValue) {
24090 if (filterValue === void 0) {
24091 return true;
24092 }
24093 const fieldValue = field.getValue({ item });
24094 return fieldValue > filterValue;
24095 },
24096 selection: "single"
24097 },
24098 {
24099 name: OPERATOR_LESS_THAN_OR_EQUAL,
24100 /* translators: DataViews operator name */
24101 label: (0, import_i18n26.__)("Less than or equal"),
24102 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24103 (0, import_i18n26.sprintf)(
24104 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
24105 (0, import_i18n26.__)(
24106 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
24107 ),
24108 filter.name,
24109 activeElements[0].label
24110 ),
24111 filterTextWrappers
24112 ),
24113 filter(item, field, filterValue) {
24114 if (filterValue === void 0) {
24115 return true;
24116 }
24117 const fieldValue = field.getValue({ item });
24118 return fieldValue <= filterValue;
24119 },
24120 selection: "single"
24121 },
24122 {
24123 name: OPERATOR_GREATER_THAN_OR_EQUAL,
24124 /* translators: DataViews operator name */
24125 label: (0, import_i18n26.__)("Greater than or equal"),
24126 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24127 (0, import_i18n26.sprintf)(
24128 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
24129 (0, import_i18n26.__)(
24130 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
24131 ),
24132 filter.name,
24133 activeElements[0].label
24134 ),
24135 filterTextWrappers
24136 ),
24137 filter(item, field, filterValue) {
24138 if (filterValue === void 0) {
24139 return true;
24140 }
24141 const fieldValue = field.getValue({ item });
24142 return fieldValue >= filterValue;
24143 },
24144 selection: "single"
24145 },
24146 {
24147 name: OPERATOR_BEFORE,
24148 /* translators: DataViews operator name */
24149 label: (0, import_i18n26.__)("Before"),
24150 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24151 (0, import_i18n26.sprintf)(
24152 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
24153 (0, import_i18n26.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
24154 filter.name,
24155 activeElements[0].label
24156 ),
24157 filterTextWrappers
24158 ),
24159 filter(item, field, filterValue) {
24160 if (filterValue === void 0) {
24161 return true;
24162 }
24163 const filterDate = (0, import_date.getDate)(filterValue);
24164 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24165 return fieldDate < filterDate;
24166 },
24167 selection: "single"
24168 },
24169 {
24170 name: OPERATOR_AFTER,
24171 /* translators: DataViews operator name */
24172 label: (0, import_i18n26.__)("After"),
24173 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24174 (0, import_i18n26.sprintf)(
24175 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
24176 (0, import_i18n26.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
24177 filter.name,
24178 activeElements[0].label
24179 ),
24180 filterTextWrappers
24181 ),
24182 filter(item, field, filterValue) {
24183 if (filterValue === void 0) {
24184 return true;
24185 }
24186 const filterDate = (0, import_date.getDate)(filterValue);
24187 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24188 return fieldDate > filterDate;
24189 },
24190 selection: "single"
24191 },
24192 {
24193 name: OPERATOR_BEFORE_INC,
24194 /* translators: DataViews operator name */
24195 label: (0, import_i18n26.__)("Before (inc)"),
24196 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24197 (0, import_i18n26.sprintf)(
24198 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
24199 (0, import_i18n26.__)(
24200 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
24201 ),
24202 filter.name,
24203 activeElements[0].label
24204 ),
24205 filterTextWrappers
24206 ),
24207 filter(item, field, filterValue) {
24208 if (filterValue === void 0) {
24209 return true;
24210 }
24211 const filterDate = (0, import_date.getDate)(filterValue);
24212 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24213 return fieldDate <= filterDate;
24214 },
24215 selection: "single"
24216 },
24217 {
24218 name: OPERATOR_AFTER_INC,
24219 /* translators: DataViews operator name */
24220 label: (0, import_i18n26.__)("After (inc)"),
24221 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24222 (0, import_i18n26.sprintf)(
24223 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
24224 (0, import_i18n26.__)(
24225 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
24226 ),
24227 filter.name,
24228 activeElements[0].label
24229 ),
24230 filterTextWrappers
24231 ),
24232 filter(item, field, filterValue) {
24233 if (filterValue === void 0) {
24234 return true;
24235 }
24236 const filterDate = (0, import_date.getDate)(filterValue);
24237 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24238 return fieldDate >= filterDate;
24239 },
24240 selection: "single"
24241 },
24242 {
24243 name: OPERATOR_CONTAINS,
24244 /* translators: DataViews operator name */
24245 label: (0, import_i18n26.__)("Contains"),
24246 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24247 (0, import_i18n26.sprintf)(
24248 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
24249 (0, import_i18n26.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
24250 filter.name,
24251 activeElements[0].label
24252 ),
24253 filterTextWrappers
24254 ),
24255 filter(item, field, filterValue) {
24256 if (filterValue === void 0) {
24257 return true;
24258 }
24259 const fieldValue = field.getValue({ item });
24260 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
24261 },
24262 selection: "single"
24263 },
24264 {
24265 name: OPERATOR_NOT_CONTAINS,
24266 /* translators: DataViews operator name */
24267 label: (0, import_i18n26.__)("Doesn't contain"),
24268 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24269 (0, import_i18n26.sprintf)(
24270 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
24271 (0, import_i18n26.__)(
24272 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
24273 ),
24274 filter.name,
24275 activeElements[0].label
24276 ),
24277 filterTextWrappers
24278 ),
24279 filter(item, field, filterValue) {
24280 if (filterValue === void 0) {
24281 return true;
24282 }
24283 const fieldValue = field.getValue({ item });
24284 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
24285 },
24286 selection: "single"
24287 },
24288 {
24289 name: OPERATOR_STARTS_WITH,
24290 /* translators: DataViews operator name */
24291 label: (0, import_i18n26.__)("Starts with"),
24292 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24293 (0, import_i18n26.sprintf)(
24294 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
24295 (0, import_i18n26.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
24296 filter.name,
24297 activeElements[0].label
24298 ),
24299 filterTextWrappers
24300 ),
24301 filter(item, field, filterValue) {
24302 if (filterValue === void 0) {
24303 return true;
24304 }
24305 const fieldValue = field.getValue({ item });
24306 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
24307 },
24308 selection: "single"
24309 },
24310 {
24311 name: OPERATOR_ON,
24312 /* translators: DataViews operator name */
24313 label: (0, import_i18n26.__)("On"),
24314 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24315 (0, import_i18n26.sprintf)(
24316 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
24317 (0, import_i18n26.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
24318 filter.name,
24319 activeElements[0].label
24320 ),
24321 filterTextWrappers
24322 ),
24323 filter(item, field, filterValue) {
24324 if (filterValue === void 0) {
24325 return true;
24326 }
24327 const filterDate = (0, import_date.getDate)(filterValue);
24328 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24329 return filterDate.getTime() === fieldDate.getTime();
24330 },
24331 selection: "single"
24332 },
24333 {
24334 name: OPERATOR_NOT_ON,
24335 /* translators: DataViews operator name */
24336 label: (0, import_i18n26.__)("Not on"),
24337 filterText: (filter, activeElements) => (0, import_element70.createInterpolateElement)(
24338 (0, import_i18n26.sprintf)(
24339 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
24340 (0, import_i18n26.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
24341 filter.name,
24342 activeElements[0].label
24343 ),
24344 filterTextWrappers
24345 ),
24346 filter(item, field, filterValue) {
24347 if (filterValue === void 0) {
24348 return true;
24349 }
24350 const filterDate = (0, import_date.getDate)(filterValue);
24351 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
24352 return filterDate.getTime() !== fieldDate.getTime();
24353 },
24354 selection: "single"
24355 }
24356 ];
24357 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
24358 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
24359 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
24360 (op) => op.name === name
24361 );
24362 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
24363
24364 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
24365 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
24366 var ENTER = "Enter";
24367 var SPACE = " ";
24368 var FilterText = ({
24369 activeElements,
24370 filterInView,
24371 filter
24372 }) => {
24373 if (activeElements === void 0 || activeElements.length === 0) {
24374 return filter.name;
24375 }
24376 const operator = getOperatorByName(filterInView?.operator);
24377 if (operator !== void 0) {
24378 return operator.filterText(filter, activeElements);
24379 }
24380 return (0, import_i18n27.sprintf)(
24381 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
24382 (0, import_i18n27.__)("Unknown status for %1$s"),
24383 filter.name
24384 );
24385 };
24386 function OperatorSelector({
24387 filter,
24388 view,
24389 onChangeView
24390 }) {
24391 const operatorOptions = filter.operators?.map((operator) => ({
24392 value: operator,
24393 label: getOperatorByName(operator)?.label || operator
24394 }));
24395 const currentFilter = view.filters?.find(
24396 (_filter) => _filter.field === filter.field
24397 );
24398 const value = currentFilter?.operator || filter.operators[0];
24399 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(
24400 Stack,
24401 {
24402 direction: "row",
24403 gap: "sm",
24404 justify: "flex-start",
24405 className: "dataviews-filters__summary-operators-container",
24406 align: "center",
24407 children: [
24408 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
24409 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24410 import_components21.SelectControl,
24411 {
24412 className: "dataviews-filters__summary-operators-filter-select",
24413 label: (0, import_i18n27.__)("Conditions"),
24414 value,
24415 options: operatorOptions,
24416 onChange: (newValue) => {
24417 const newOperator = newValue;
24418 const currentOperator = currentFilter?.operator;
24419 const newFilters = currentFilter ? [
24420 ...(view.filters ?? []).map(
24421 (_filter) => {
24422 if (_filter.field === filter.field) {
24423 const currentOpSelectionModel = getOperatorByName(
24424 currentOperator
24425 )?.selection;
24426 const newOpSelectionModel = getOperatorByName(
24427 newOperator
24428 )?.selection;
24429 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
24430 currentOpSelectionModel,
24431 newOpSelectionModel
24432 ].includes("custom");
24433 return {
24434 ..._filter,
24435 value: shouldResetValue ? void 0 : _filter.value,
24436 operator: newOperator
24437 };
24438 }
24439 return _filter;
24440 }
24441 )
24442 ] : [
24443 ...view.filters ?? [],
24444 {
24445 field: filter.field,
24446 operator: newOperator,
24447 value: void 0
24448 }
24449 ];
24450 onChangeView({
24451 ...view,
24452 page: 1,
24453 filters: newFilters
24454 });
24455 },
24456 size: "small",
24457 variant: "minimal",
24458 hideLabelFromVision: true
24459 }
24460 )
24461 ]
24462 }
24463 );
24464 }
24465 function Filter({
24466 addFilterRef,
24467 openedFilter,
24468 fields,
24469 ...commonProps
24470 }) {
24471 const toggleRef = (0, import_element71.useRef)(null);
24472 const { filter, view, onChangeView } = commonProps;
24473 const filterInView = view.filters?.find(
24474 (f2) => f2.field === filter.field
24475 );
24476 let activeElements = [];
24477 const field = (0, import_element71.useMemo)(() => {
24478 const currentField = fields.find((f2) => f2.id === filter.field);
24479 if (currentField) {
24480 return {
24481 ...currentField,
24482 // Configure getValue as if Item was a plain object.
24483 // See related input-widget.tsx
24484 getValue: ({ item }) => item[currentField.id]
24485 };
24486 }
24487 return currentField;
24488 }, [fields, filter.field]);
24489 const { elements } = useElements({
24490 elements: filter.elements,
24491 getElements: filter.getElements
24492 });
24493 if (elements.length > 0) {
24494 activeElements = elements.filter((element) => {
24495 if (filter.singleSelection) {
24496 return element.value === filterInView?.value;
24497 }
24498 return filterInView?.value?.includes(element.value);
24499 });
24500 } else if (Array.isArray(filterInView?.value)) {
24501 const label = filterInView.value.map((v2) => {
24502 const formattedValue = field?.getValueFormatted({
24503 item: { [field.id]: v2 },
24504 field
24505 });
24506 return formattedValue || String(v2);
24507 });
24508 activeElements = [
24509 {
24510 value: filterInView.value,
24511 // @ts-ignore
24512 label
24513 }
24514 ];
24515 } else if (typeof filterInView?.value === "object") {
24516 activeElements = [
24517 { value: filterInView.value, label: filterInView.value }
24518 ];
24519 } else if (filterInView?.value !== void 0) {
24520 const label = field !== void 0 ? field.getValueFormatted({
24521 item: { [field.id]: filterInView.value },
24522 field
24523 }) : String(filterInView.value);
24524 activeElements = [
24525 {
24526 value: filterInView.value,
24527 label
24528 }
24529 ];
24530 }
24531 const isPrimary = filter.isPrimary;
24532 const isLocked = filterInView?.isLocked;
24533 const hasValues = !isLocked && filterInView?.value !== void 0;
24534 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
24535 const resetOrRemoveLabel = isPrimary ? (0, import_i18n27.__)("Reset") : (0, import_i18n27.__)("Remove");
24536 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24537 import_components21.Dropdown,
24538 {
24539 defaultOpen: openedFilter === filter.field,
24540 contentClassName: "dataviews-filters__summary-popover",
24541 popoverProps: { placement: "bottom-start", role: "dialog" },
24542 onClose: () => {
24543 toggleRef.current?.focus();
24544 },
24545 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
24546 /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(tooltip_exports.Root, { children: [
24547 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24548 tooltip_exports.Trigger,
24549 {
24550 render: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24551 "div",
24552 {
24553 className: clsx_default(
24554 "dataviews-filters__summary-chip",
24555 {
24556 "has-reset": canResetOrRemove,
24557 "has-values": hasValues,
24558 "is-not-clickable": isLocked
24559 }
24560 ),
24561 role: "button",
24562 tabIndex: isLocked ? -1 : 0,
24563 onClick: () => {
24564 if (!isLocked) {
24565 onToggle();
24566 }
24567 },
24568 onKeyDown: (event) => {
24569 if (!isLocked && [ENTER, SPACE].includes(
24570 event.key
24571 )) {
24572 onToggle();
24573 event.preventDefault();
24574 }
24575 },
24576 "aria-disabled": isLocked,
24577 "aria-pressed": isOpen,
24578 "aria-expanded": isOpen,
24579 ref: toggleRef,
24580 children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24581 FilterText,
24582 {
24583 activeElements,
24584 filterInView,
24585 filter
24586 }
24587 )
24588 }
24589 )
24590 }
24591 ),
24592 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(tooltip_exports.Popup, { children: (0, import_i18n27.sprintf)(
24593 /* translators: 1: Filter name. */
24594 (0, import_i18n27.__)("Filter by: %1$s"),
24595 filter.name.toLowerCase()
24596 ) })
24597 ] }),
24598 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(tooltip_exports.Root, { children: [
24599 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24600 tooltip_exports.Trigger,
24601 {
24602 render: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24603 "button",
24604 {
24605 className: clsx_default(
24606 "dataviews-filters__summary-chip-remove",
24607 { "has-values": hasValues }
24608 ),
24609 "aria-label": resetOrRemoveLabel,
24610 onClick: () => {
24611 onChangeView({
24612 ...view,
24613 page: 1,
24614 filters: view.filters?.filter(
24615 (_filter) => _filter.field !== filter.field
24616 )
24617 });
24618 if (!isPrimary) {
24619 addFilterRef.current?.focus();
24620 } else {
24621 toggleRef.current?.focus();
24622 }
24623 },
24624 children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components21.Icon, { icon: close_small_default })
24625 }
24626 )
24627 }
24628 ),
24629 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
24630 ] })
24631 ] }),
24632 renderContent: () => {
24633 return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
24634 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(OperatorSelector, { ...commonProps }),
24635 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24636 SearchWidget,
24637 {
24638 ...commonProps,
24639 filter: {
24640 ...commonProps.filter,
24641 elements
24642 }
24643 }
24644 ) : /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(InputWidget, { ...commonProps, fields })
24645 ] });
24646 }
24647 }
24648 );
24649 }
24650
24651 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
24652 var import_components22 = __toESM(require_components(), 1);
24653 var import_i18n28 = __toESM(require_i18n(), 1);
24654 var import_element72 = __toESM(require_element(), 1);
24655 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24656 var { Menu: Menu4 } = unlock2(import_components22.privateApis);
24657 function AddFilterMenu({
24658 filters,
24659 view,
24660 onChangeView,
24661 setOpenedFilter,
24662 triggerProps
24663 }) {
24664 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
24665 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(Menu4, { children: [
24666 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Menu4.TriggerButton, { ...triggerProps }),
24667 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
24668 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24669 Menu4.Item,
24670 {
24671 onClick: () => {
24672 setOpenedFilter(filter.field);
24673 onChangeView({
24674 ...view,
24675 page: 1,
24676 filters: [
24677 ...view.filters || [],
24678 {
24679 field: filter.field,
24680 value: void 0,
24681 operator: filter.operators[0]
24682 }
24683 ]
24684 });
24685 },
24686 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Menu4.ItemLabel, { children: filter.name })
24687 },
24688 filter.field
24689 );
24690 }) })
24691 ] });
24692 }
24693 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
24694 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
24695 return null;
24696 }
24697 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
24698 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24699 AddFilterMenu,
24700 {
24701 triggerProps: {
24702 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24703 import_components22.Button,
24704 {
24705 accessibleWhenDisabled: true,
24706 size: "compact",
24707 className: "dataviews-filters-button",
24708 variant: "tertiary",
24709 disabled: !inactiveFilters.length,
24710 ref
24711 }
24712 ),
24713 children: (0, import_i18n28.__)("Add filter")
24714 },
24715 ...{ filters, view, onChangeView, setOpenedFilter }
24716 }
24717 );
24718 }
24719 var add_filter_default = (0, import_element72.forwardRef)(AddFilter);
24720
24721 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
24722 var import_components23 = __toESM(require_components(), 1);
24723 var import_i18n29 = __toESM(require_i18n(), 1);
24724 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24725 function ResetFilter({
24726 filters,
24727 view,
24728 onChangeView
24729 }) {
24730 const isPrimary = (field) => filters.some(
24731 (_filter) => _filter.field === field && _filter.isPrimary
24732 );
24733 const isDisabled = !view.search && !view.filters?.some(
24734 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
24735 );
24736 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24737 import_components23.Button,
24738 {
24739 disabled: isDisabled,
24740 accessibleWhenDisabled: true,
24741 size: "compact",
24742 variant: "tertiary",
24743 className: "dataviews-filters__reset-button",
24744 onClick: () => {
24745 onChangeView({
24746 ...view,
24747 page: 1,
24748 search: "",
24749 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
24750 });
24751 },
24752 children: (0, import_i18n29.__)("Reset")
24753 }
24754 );
24755 }
24756
24757 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
24758 var import_element73 = __toESM(require_element(), 1);
24759 function useFilters(fields, view) {
24760 return (0, import_element73.useMemo)(() => {
24761 const filters = [];
24762 fields.forEach((field) => {
24763 if (field.filterBy === false || !field.hasElements && !field.Edit) {
24764 return;
24765 }
24766 const operators = field.filterBy.operators;
24767 const isPrimary = !!field.filterBy?.isPrimary;
24768 const isLocked = view.filters?.some(
24769 (f2) => f2.field === field.id && !!f2.isLocked
24770 ) ?? false;
24771 filters.push({
24772 field: field.id,
24773 name: field.label,
24774 elements: field.elements,
24775 getElements: field.getElements,
24776 hasElements: field.hasElements,
24777 singleSelection: operators.some(
24778 (op) => isSingleSelectionOperator(op)
24779 ),
24780 operators,
24781 isVisible: isLocked || isPrimary || !!view.filters?.some(
24782 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
24783 ),
24784 isPrimary,
24785 isLocked
24786 });
24787 });
24788 filters.sort((a2, b2) => {
24789 if (a2.isLocked && !b2.isLocked) {
24790 return -1;
24791 }
24792 if (!a2.isLocked && b2.isLocked) {
24793 return 1;
24794 }
24795 if (a2.isPrimary && !b2.isPrimary) {
24796 return -1;
24797 }
24798 if (!a2.isPrimary && b2.isPrimary) {
24799 return 1;
24800 }
24801 return a2.name.localeCompare(b2.name);
24802 });
24803 return filters;
24804 }, [fields, view]);
24805 }
24806 var use_filters_default = useFilters;
24807
24808 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
24809 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24810 function Filters({ className }) {
24811 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element74.useContext)(dataviews_context_default);
24812 const addFilterRef = (0, import_element74.useRef)(null);
24813 const filters = use_filters_default(fields, view);
24814 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24815 add_filter_default,
24816 {
24817 filters,
24818 view,
24819 onChangeView,
24820 ref: addFilterRef,
24821 setOpenedFilter
24822 },
24823 "add-filter"
24824 );
24825 const visibleFilters = filters.filter((filter) => filter.isVisible);
24826 if (visibleFilters.length === 0) {
24827 return null;
24828 }
24829 const filterComponents = [
24830 ...visibleFilters.map((filter) => {
24831 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24832 Filter,
24833 {
24834 filter,
24835 view,
24836 fields,
24837 onChangeView,
24838 addFilterRef,
24839 openedFilter
24840 },
24841 filter.field
24842 );
24843 }),
24844 addFilter
24845 ];
24846 filterComponents.push(
24847 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24848 ResetFilter,
24849 {
24850 filters,
24851 view,
24852 onChangeView
24853 },
24854 "reset-filters"
24855 )
24856 );
24857 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24858 Stack,
24859 {
24860 direction: "row",
24861 justify: "flex-start",
24862 gap: "sm",
24863 style: { width: "fit-content" },
24864 wrap: "wrap",
24865 className,
24866 children: filterComponents
24867 }
24868 );
24869 }
24870 var filters_default = (0, import_element74.memo)(Filters);
24871
24872 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
24873 var import_element75 = __toESM(require_element(), 1);
24874 var import_components24 = __toESM(require_components(), 1);
24875 var import_i18n30 = __toESM(require_i18n(), 1);
24876 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24877 function FiltersToggle() {
24878 const {
24879 filters,
24880 view,
24881 onChangeView,
24882 setOpenedFilter,
24883 isShowingFilter,
24884 setIsShowingFilter
24885 } = (0, import_element75.useContext)(dataviews_context_default);
24886 const buttonRef = (0, import_element75.useRef)(null);
24887 const onChangeViewWithFilterVisibility = (0, import_element75.useCallback)(
24888 (_view) => {
24889 onChangeView(_view);
24890 setIsShowingFilter(true);
24891 },
24892 [onChangeView, setIsShowingFilter]
24893 );
24894 if (filters.length === 0) {
24895 return null;
24896 }
24897 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
24898 const addFilterButtonProps = {
24899 label: (0, import_i18n30.__)("Add filter"),
24900 "aria-expanded": false,
24901 isPressed: false
24902 };
24903 const toggleFiltersButtonProps = {
24904 label: (0, import_i18n30._x)("Filter", "verb"),
24905 "aria-expanded": isShowingFilter,
24906 isPressed: isShowingFilter,
24907 onClick: () => {
24908 if (!isShowingFilter) {
24909 setOpenedFilter(null);
24910 }
24911 setIsShowingFilter(!isShowingFilter);
24912 }
24913 };
24914 const hasPrimaryOrLockedFilters = filters.some(
24915 (filter) => filter.isPrimary || filter.isLocked
24916 );
24917 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24918 import_components24.Button,
24919 {
24920 ref: buttonRef,
24921 className: "dataviews-filters__visibility-toggle",
24922 size: "compact",
24923 icon: funnel_default,
24924 disabled: hasPrimaryOrLockedFilters,
24925 accessibleWhenDisabled: true,
24926 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
24927 }
24928 );
24929 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24930 AddFilterMenu,
24931 {
24932 filters,
24933 view,
24934 onChangeView: onChangeViewWithFilterVisibility,
24935 setOpenedFilter,
24936 triggerProps: { render: buttonComponent }
24937 }
24938 ) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24939 FilterVisibilityToggle,
24940 {
24941 buttonRef,
24942 filtersCount: view.filters?.length,
24943 children: buttonComponent
24944 }
24945 ) });
24946 }
24947 function FilterVisibilityToggle({
24948 buttonRef,
24949 filtersCount,
24950 children
24951 }) {
24952 (0, import_element75.useEffect)(
24953 () => () => {
24954 buttonRef.current?.focus();
24955 },
24956 [buttonRef]
24957 );
24958 return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_jsx_runtime104.Fragment, { children: [
24959 children,
24960 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
24961 ] });
24962 }
24963 var toggle_default = FiltersToggle;
24964
24965 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
24966 var import_element76 = __toESM(require_element(), 1);
24967 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24968 function FiltersToggled(props) {
24969 const { isShowingFilter } = (0, import_element76.useContext)(dataviews_context_default);
24970 if (!isShowingFilter) {
24971 return null;
24972 }
24973 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(filters_default, { ...props });
24974 }
24975 var filters_toggled_default = FiltersToggled;
24976
24977 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
24978 var import_element77 = __toESM(require_element(), 1);
24979 var import_components25 = __toESM(require_components(), 1);
24980 var import_i18n31 = __toESM(require_i18n(), 1);
24981 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24982 function DataViewsLayout({ className }) {
24983 const {
24984 actions = [],
24985 data,
24986 fields,
24987 getItemId,
24988 getItemLevel,
24989 hasInitiallyLoaded,
24990 isLoading,
24991 view,
24992 onChangeView,
24993 selection,
24994 onChangeSelection,
24995 setOpenedFilter,
24996 onClickItem,
24997 isItemClickable,
24998 renderItemLink,
24999 defaultLayouts,
25000 containerRef,
25001 empty = /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("p", { children: (0, import_i18n31.__)("No results") })
25002 } = (0, import_element77.useContext)(dataviews_context_default);
25003 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
25004 delay: 200
25005 });
25006 if (!hasInitiallyLoaded) {
25007 if (!isDelayedInitialLoading) {
25008 return null;
25009 }
25010 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, {}) }) });
25011 }
25012 const ViewComponent = VIEW_LAYOUTS.find(
25013 (v2) => v2.type === view.type && defaultLayouts[v2.type]
25014 )?.component;
25015 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
25016 ViewComponent,
25017 {
25018 className,
25019 actions,
25020 data,
25021 fields,
25022 getItemId,
25023 getItemLevel,
25024 isLoading,
25025 onChangeView,
25026 onChangeSelection,
25027 selection,
25028 setOpenedFilter,
25029 onClickItem,
25030 renderItemLink,
25031 isItemClickable,
25032 view,
25033 empty
25034 }
25035 ) });
25036 }
25037
25038 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
25039 var import_element78 = __toESM(require_element(), 1);
25040 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
25041 var EMPTY_ARRAY5 = [];
25042 function DataViewsFooter() {
25043 const {
25044 view,
25045 paginationInfo: { totalItems = 0, totalPages },
25046 data,
25047 actions = EMPTY_ARRAY5,
25048 isLoading,
25049 hasInitiallyLoaded
25050 } = (0, import_element78.useContext)(dataviews_context_default);
25051 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
25052 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
25053 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
25054 const hasPagination = hasPaginationControls(view, {
25055 totalItems,
25056 totalPages
25057 });
25058 if (!totalItems || !hasBulkActions && !hasPagination) {
25059 return null;
25060 }
25061 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
25062 "div",
25063 {
25064 className: "dataviews-footer",
25065 inert: isRefreshing ? "true" : void 0,
25066 children: /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(
25067 Stack,
25068 {
25069 direction: "row",
25070 justify: "end",
25071 align: "center",
25072 className: clsx_default("dataviews-footer__content", {
25073 "is-refreshing": isDelayedRefreshing
25074 }),
25075 gap: "sm",
25076 children: [
25077 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(BulkActionsFooter, {}),
25078 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(dataviews_pagination_default, {})
25079 ]
25080 }
25081 )
25082 }
25083 );
25084 }
25085
25086 // packages/dataviews/build-module/components/dataviews-search/index.mjs
25087 var import_i18n32 = __toESM(require_i18n(), 1);
25088 var import_element79 = __toESM(require_element(), 1);
25089 var import_components26 = __toESM(require_components(), 1);
25090 var import_compose10 = __toESM(require_compose(), 1);
25091 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
25092 var DataViewsSearch = (0, import_element79.memo)(function Search({ label }) {
25093 const { view, onChangeView } = (0, import_element79.useContext)(dataviews_context_default);
25094 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
25095 view.search
25096 );
25097 (0, import_element79.useEffect)(() => {
25098 if (view.search !== debouncedSearch) {
25099 setSearch(view.search ?? "");
25100 }
25101 }, [view.search, setSearch]);
25102 const onChangeViewRef = (0, import_element79.useRef)(onChangeView);
25103 const viewRef = (0, import_element79.useRef)(view);
25104 (0, import_element79.useEffect)(() => {
25105 onChangeViewRef.current = onChangeView;
25106 viewRef.current = view;
25107 }, [onChangeView, view]);
25108 (0, import_element79.useEffect)(() => {
25109 if (debouncedSearch !== viewRef.current?.search) {
25110 onChangeViewRef.current({
25111 ...viewRef.current,
25112 page: view.page ? 1 : void 0,
25113 startPosition: view.startPosition ? 1 : void 0,
25114 search: debouncedSearch
25115 });
25116 }
25117 }, [debouncedSearch]);
25118 const searchLabel = label || (0, import_i18n32.__)("Search");
25119 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
25120 import_components26.SearchControl,
25121 {
25122 className: "dataviews-search",
25123 onChange: setSearch,
25124 value: search,
25125 label: searchLabel,
25126 placeholder: searchLabel,
25127 size: "compact"
25128 }
25129 );
25130 });
25131 var dataviews_search_default = DataViewsSearch;
25132
25133 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
25134 var import_components27 = __toESM(require_components(), 1);
25135 var import_i18n33 = __toESM(require_i18n(), 1);
25136 var import_element80 = __toESM(require_element(), 1);
25137 var import_warning = __toESM(require_warning(), 1);
25138 var import_compose11 = __toESM(require_compose(), 1);
25139 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
25140 var { Menu: Menu5 } = unlock2(import_components27.privateApis);
25141 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
25142 className: "dataviews-config__popover",
25143 placement: "bottom-end",
25144 offset: 9
25145 };
25146 function ViewTypeMenu() {
25147 const { view, onChangeView, defaultLayouts } = (0, import_element80.useContext)(dataviews_context_default);
25148 const availableLayouts = Object.keys(defaultLayouts);
25149 if (availableLayouts.length <= 1) {
25150 return null;
25151 }
25152 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
25153 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(Menu5, { children: [
25154 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25155 Menu5.TriggerButton,
25156 {
25157 render: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25158 import_components27.Button,
25159 {
25160 size: "compact",
25161 icon: activeView?.icon,
25162 label: (0, import_i18n33.__)("Layout")
25163 }
25164 )
25165 }
25166 ),
25167 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
25168 const config = VIEW_LAYOUTS.find(
25169 (v2) => v2.type === layout
25170 );
25171 if (!config) {
25172 return null;
25173 }
25174 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25175 Menu5.RadioItem,
25176 {
25177 value: layout,
25178 name: "view-actions-available-view",
25179 checked: layout === view.type,
25180 hideOnClick: true,
25181 onChange: (e2) => {
25182 switch (e2.target.value) {
25183 case "list":
25184 case "grid":
25185 case "table":
25186 case "pickerGrid":
25187 case "pickerTable":
25188 case "pickerActivity":
25189 case "activity":
25190 const viewWithoutLayout = { ...view };
25191 if ("layout" in viewWithoutLayout) {
25192 delete viewWithoutLayout.layout;
25193 }
25194 return onChangeView({
25195 ...viewWithoutLayout,
25196 type: e2.target.value,
25197 ...defaultLayouts[e2.target.value]
25198 });
25199 }
25200 (0, import_warning.default)("Invalid dataview");
25201 },
25202 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Menu5.ItemLabel, { children: config.label })
25203 },
25204 layout
25205 );
25206 }) })
25207 ] });
25208 }
25209 function SortFieldControl() {
25210 const { view, fields, onChangeView } = (0, import_element80.useContext)(dataviews_context_default);
25211 const orderOptions = (0, import_element80.useMemo)(() => {
25212 const sortableFields = fields.filter(
25213 (field) => field.enableSorting !== false
25214 );
25215 return sortableFields.map((field) => {
25216 return {
25217 label: field.label,
25218 value: field.id
25219 };
25220 });
25221 }, [fields]);
25222 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25223 import_components27.SelectControl,
25224 {
25225 label: (0, import_i18n33.__)("Sort by"),
25226 value: view.sort?.field,
25227 options: orderOptions,
25228 onChange: (value) => {
25229 onChangeView({
25230 ...view,
25231 sort: {
25232 direction: view?.sort?.direction || "desc",
25233 field: value
25234 },
25235 showLevels: false
25236 });
25237 }
25238 }
25239 );
25240 }
25241 function SortDirectionControl() {
25242 const { view, fields, onChangeView } = (0, import_element80.useContext)(dataviews_context_default);
25243 const sortableFields = fields.filter(
25244 (field) => field.enableSorting !== false
25245 );
25246 if (sortableFields.length === 0) {
25247 return null;
25248 }
25249 let value = view.sort?.direction;
25250 if (!value && view.sort?.field) {
25251 value = "desc";
25252 }
25253 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25254 import_components27.__experimentalToggleGroupControl,
25255 {
25256 className: "dataviews-view-config__sort-direction",
25257 isBlock: true,
25258 label: (0, import_i18n33.__)("Order"),
25259 value,
25260 onChange: (newDirection) => {
25261 if (newDirection === "asc" || newDirection === "desc") {
25262 onChangeView({
25263 ...view,
25264 sort: {
25265 direction: newDirection,
25266 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
25267 fields.find(
25268 (field) => field.enableSorting !== false
25269 )?.id || ""
25270 },
25271 showLevels: false
25272 });
25273 return;
25274 }
25275 (0, import_warning.default)("Invalid direction");
25276 },
25277 children: SORTING_DIRECTIONS.map((direction) => {
25278 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25279 import_components27.__experimentalToggleGroupControlOptionIcon,
25280 {
25281 value: direction,
25282 icon: sortIcons[direction],
25283 label: sortLabels[direction]
25284 },
25285 direction
25286 );
25287 })
25288 }
25289 );
25290 }
25291 function ItemsPerPageControl() {
25292 const { view, config, onChangeView } = (0, import_element80.useContext)(dataviews_context_default);
25293 const { infiniteScrollEnabled } = view;
25294 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
25295 return null;
25296 }
25297 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25298 import_components27.__experimentalToggleGroupControl,
25299 {
25300 isBlock: true,
25301 label: (0, import_i18n33.__)("Items per page"),
25302 value: view.perPage || 10,
25303 disabled: !view?.sort?.field,
25304 onChange: (newItemsPerPage) => {
25305 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
25306 onChangeView({
25307 ...view,
25308 perPage: newItemsPerPageNumber,
25309 page: 1
25310 });
25311 },
25312 children: config.perPageSizes.map((value) => {
25313 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25314 import_components27.__experimentalToggleGroupControlOption,
25315 {
25316 value,
25317 label: value.toString()
25318 },
25319 value
25320 );
25321 })
25322 }
25323 );
25324 }
25325 function ResetViewButton() {
25326 const { onReset } = (0, import_element80.useContext)(dataviews_context_default);
25327 if (onReset === void 0) {
25328 return null;
25329 }
25330 const isDisabled = onReset === false;
25331 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25332 import_components27.Button,
25333 {
25334 variant: "tertiary",
25335 size: "compact",
25336 disabled: isDisabled,
25337 accessibleWhenDisabled: true,
25338 className: "dataviews-view-config__reset-button",
25339 onClick: () => {
25340 if (typeof onReset === "function") {
25341 onReset();
25342 }
25343 },
25344 children: (0, import_i18n33.__)("Reset view")
25345 }
25346 );
25347 }
25348 function DataviewsViewConfigDropdown() {
25349 const { view, onReset } = (0, import_element80.useContext)(dataviews_context_default);
25350 const popoverId = (0, import_compose11.useInstanceId)(
25351 _DataViewsViewConfig,
25352 "dataviews-view-config-dropdown"
25353 );
25354 const activeLayout = VIEW_LAYOUTS.find(
25355 (layout) => layout.type === view.type
25356 );
25357 const isModified = typeof onReset === "function";
25358 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25359 import_components27.Dropdown,
25360 {
25361 expandOnMobile: true,
25362 popoverProps: {
25363 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
25364 id: popoverId
25365 },
25366 renderToggle: ({ onToggle, isOpen }) => {
25367 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
25368 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25369 import_components27.Button,
25370 {
25371 size: "compact",
25372 icon: cog_default,
25373 label: (0, import_i18n33._x)(
25374 "View options",
25375 "View is used as a noun"
25376 ),
25377 onClick: onToggle,
25378 "aria-expanded": isOpen ? "true" : "false",
25379 "aria-controls": popoverId
25380 }
25381 ),
25382 isModified && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
25383 ] });
25384 },
25385 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25386 import_components27.__experimentalDropdownContentWrapper,
25387 {
25388 paddingSize: "medium",
25389 className: "dataviews-config__popover-content-wrapper",
25390 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
25391 Stack,
25392 {
25393 direction: "column",
25394 className: "dataviews-view-config",
25395 gap: "xl",
25396 children: [
25397 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
25398 Stack,
25399 {
25400 direction: "row",
25401 justify: "space-between",
25402 align: "center",
25403 className: "dataviews-view-config__header",
25404 children: [
25405 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25406 import_components27.__experimentalHeading,
25407 {
25408 level: 2,
25409 className: "dataviews-settings-section__title",
25410 children: (0, import_i18n33.__)("Appearance")
25411 }
25412 ),
25413 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ResetViewButton, {})
25414 ]
25415 }
25416 ),
25417 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(Stack, { direction: "column", gap: "lg", children: [
25418 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
25419 Stack,
25420 {
25421 direction: "row",
25422 gap: "sm",
25423 className: "dataviews-view-config__sort-controls",
25424 children: [
25425 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(SortFieldControl, {}),
25426 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(SortDirectionControl, {})
25427 ]
25428 }
25429 ),
25430 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(activeLayout.viewConfigOptions, {}),
25431 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ItemsPerPageControl, {}),
25432 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(PropertiesSection, {})
25433 ] })
25434 ]
25435 }
25436 )
25437 }
25438 )
25439 }
25440 );
25441 }
25442 function _DataViewsViewConfig() {
25443 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
25444 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(ViewTypeMenu, {}),
25445 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(DataviewsViewConfigDropdown, {})
25446 ] });
25447 }
25448 var DataViewsViewConfig = (0, import_element80.memo)(_DataViewsViewConfig);
25449 var dataviews_view_config_default = DataViewsViewConfig;
25450
25451 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
25452 var import_components28 = __toESM(require_components(), 1);
25453 var import_element81 = __toESM(require_element(), 1);
25454
25455 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
25456 function getCustomValidity(isValid2, validity) {
25457 let customValidity;
25458 if (isValid2?.required && validity?.required) {
25459 customValidity = validity?.required?.message ? validity.required : void 0;
25460 } else if (isValid2?.pattern && validity?.pattern) {
25461 customValidity = validity.pattern;
25462 } else if (isValid2?.min && validity?.min) {
25463 customValidity = validity.min;
25464 } else if (isValid2?.max && validity?.max) {
25465 customValidity = validity.max;
25466 } else if (isValid2?.minLength && validity?.minLength) {
25467 customValidity = validity.minLength;
25468 } else if (isValid2?.maxLength && validity?.maxLength) {
25469 customValidity = validity.maxLength;
25470 } else if (isValid2?.elements && validity?.elements) {
25471 customValidity = validity.elements;
25472 } else if (validity?.custom) {
25473 customValidity = validity.custom;
25474 }
25475 return customValidity;
25476 }
25477
25478 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
25479 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
25480 var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis);
25481 function Checkbox({
25482 field,
25483 onChange,
25484 data,
25485 hideLabelFromVision,
25486 markWhenOptional,
25487 validity
25488 }) {
25489 const { getValue, setValue, label, description, isValid: isValid2 } = field;
25490 const disabled2 = field.isDisabled({ item: data, field });
25491 const onChangeControl = (0, import_element81.useCallback)(() => {
25492 onChange(
25493 setValue({ item: data, value: !getValue({ item: data }) })
25494 );
25495 }, [data, getValue, onChange, setValue]);
25496 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
25497 ValidatedCheckboxControl,
25498 {
25499 required: !!field.isValid?.required,
25500 markWhenOptional,
25501 customValidity: getCustomValidity(isValid2, validity),
25502 hidden: hideLabelFromVision,
25503 label,
25504 help: description,
25505 checked: getValue({ item: data }),
25506 onChange: onChangeControl,
25507 disabled: disabled2
25508 }
25509 );
25510 }
25511
25512 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
25513 var import_components29 = __toESM(require_components(), 1);
25514 var import_element82 = __toESM(require_element(), 1);
25515 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
25516 var { ValidatedComboboxControl } = unlock2(import_components29.privateApis);
25517 function Combobox3({
25518 data,
25519 field,
25520 onChange,
25521 hideLabelFromVision,
25522 validity
25523 }) {
25524 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
25525 const value = getValue({ item: data }) ?? "";
25526 const onChangeControl = (0, import_element82.useCallback)(
25527 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
25528 [data, onChange, setValue]
25529 );
25530 const { elements, isLoading } = useElements({
25531 elements: field.elements,
25532 getElements: field.getElements
25533 });
25534 if (isLoading) {
25535 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components29.Spinner, {});
25536 }
25537 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
25538 ValidatedComboboxControl,
25539 {
25540 required: !!field.isValid?.required,
25541 customValidity: getCustomValidity(isValid2, validity),
25542 label,
25543 value,
25544 help: description,
25545 placeholder,
25546 options: elements,
25547 onChange: onChangeControl,
25548 hideLabelFromVision,
25549 allowReset: true,
25550 expandOnFocus: true
25551 }
25552 );
25553 }
25554
25555 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
25556 var import_components31 = __toESM(require_components(), 1);
25557 var import_element85 = __toESM(require_element(), 1);
25558 var import_i18n35 = __toESM(require_i18n(), 1);
25559 var import_date3 = __toESM(require_date(), 1);
25560
25561 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
25562 var import_components30 = __toESM(require_components(), 1);
25563 var import_element83 = __toESM(require_element(), 1);
25564 var import_i18n34 = __toESM(require_i18n(), 1);
25565 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
25566 var TIME_UNITS_OPTIONS = {
25567 [OPERATOR_IN_THE_PAST]: [
25568 { value: "days", label: (0, import_i18n34.__)("Days") },
25569 { value: "weeks", label: (0, import_i18n34.__)("Weeks") },
25570 { value: "months", label: (0, import_i18n34.__)("Months") },
25571 { value: "years", label: (0, import_i18n34.__)("Years") }
25572 ],
25573 [OPERATOR_OVER]: [
25574 { value: "days", label: (0, import_i18n34.__)("Days ago") },
25575 { value: "weeks", label: (0, import_i18n34.__)("Weeks ago") },
25576 { value: "months", label: (0, import_i18n34.__)("Months ago") },
25577 { value: "years", label: (0, import_i18n34.__)("Years ago") }
25578 ]
25579 };
25580 function RelativeDateControl({
25581 className,
25582 data,
25583 field,
25584 onChange,
25585 hideLabelFromVision,
25586 operator
25587 }) {
25588 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
25589 const { id, label, description, getValue, setValue } = field;
25590 const disabled2 = field.isDisabled({ item: data, field });
25591 const fieldValue = getValue({ item: data });
25592 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
25593 const onChangeValue = (0, import_element83.useCallback)(
25594 (newValue) => onChange(
25595 setValue({
25596 item: data,
25597 value: { value: Number(newValue), unit }
25598 })
25599 ),
25600 [onChange, setValue, data, unit]
25601 );
25602 const onChangeUnit = (0, import_element83.useCallback)(
25603 (newUnit) => onChange(
25604 setValue({
25605 item: data,
25606 value: { value: relValue, unit: newUnit }
25607 })
25608 ),
25609 [onChange, setValue, data, relValue]
25610 );
25611 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25612 import_components30.BaseControl,
25613 {
25614 id,
25615 className: clsx_default(className, "dataviews-controls__relative-date"),
25616 label,
25617 hideLabelFromVision,
25618 help: description,
25619 children: /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(Stack, { direction: "row", gap: "sm", children: [
25620 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25621 import_components30.__experimentalNumberControl,
25622 {
25623 className: "dataviews-controls__relative-date-number",
25624 spinControls: "none",
25625 min: 1,
25626 step: 1,
25627 value: relValue,
25628 onChange: onChangeValue,
25629 disabled: disabled2
25630 }
25631 ),
25632 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
25633 import_components30.SelectControl,
25634 {
25635 className: "dataviews-controls__relative-date-unit",
25636 label: (0, import_i18n34.__)("Unit"),
25637 value: unit,
25638 options,
25639 onChange: onChangeUnit,
25640 hideLabelFromVision: true,
25641 disabled: disabled2
25642 }
25643 )
25644 ] })
25645 }
25646 );
25647 }
25648
25649 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
25650 var import_element84 = __toESM(require_element(), 1);
25651 function useDisabledDateMatchers(isValid2, parseDateFn) {
25652 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
25653 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
25654 const disabledMatchers = (0, import_element84.useMemo)(() => {
25655 const matchers = [];
25656 if (minConstraint) {
25657 const minDate = parseDateFn(minConstraint);
25658 if (minDate) {
25659 matchers.push({ before: minDate });
25660 }
25661 }
25662 if (maxConstraint) {
25663 const maxDate = parseDateFn(maxConstraint);
25664 if (maxDate) {
25665 matchers.push({ after: maxDate });
25666 }
25667 }
25668 return matchers.length > 0 ? matchers : void 0;
25669 }, [minConstraint, maxConstraint, parseDateFn]);
25670 return { minConstraint, maxConstraint, disabledMatchers };
25671 }
25672
25673 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
25674 var import_date2 = __toESM(require_date(), 1);
25675 function parseDateTime(dateTimeString) {
25676 if (!dateTimeString) {
25677 return null;
25678 }
25679 const parsed = (0, import_date2.getDate)(dateTimeString);
25680 return parsed && isValid(parsed) ? parsed : null;
25681 }
25682
25683 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
25684 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
25685 var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis);
25686 var formatDateTime = (value) => {
25687 if (!value) {
25688 return "";
25689 }
25690 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
25691 };
25692 function CalendarDateTimeControl({
25693 data,
25694 field,
25695 onChange,
25696 hideLabelFromVision,
25697 markWhenOptional,
25698 validity,
25699 config
25700 }) {
25701 const { compact } = config || {};
25702 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
25703 const disabled2 = field.isDisabled({ item: data, field });
25704 const fieldValue = getValue({ item: data });
25705 const value = typeof fieldValue === "string" ? fieldValue : void 0;
25706 const [calendarMonth, setCalendarMonth] = (0, import_element85.useState)(() => {
25707 const parsedDate = parseDateTime(value);
25708 return parsedDate || /* @__PURE__ */ new Date();
25709 });
25710 const inputControlRef = (0, import_element85.useRef)(null);
25711 const validationTimeoutRef = (0, import_element85.useRef)(void 0);
25712 const previousFocusRef = (0, import_element85.useRef)(null);
25713 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
25714 const onChangeCallback = (0, import_element85.useCallback)(
25715 (newValue) => onChange(setValue({ item: data, value: newValue })),
25716 [data, onChange, setValue]
25717 );
25718 (0, import_element85.useEffect)(() => {
25719 return () => {
25720 if (validationTimeoutRef.current) {
25721 clearTimeout(validationTimeoutRef.current);
25722 }
25723 };
25724 }, []);
25725 const onSelectDate = (0, import_element85.useCallback)(
25726 (newDate) => {
25727 let dateTimeValue;
25728 if (newDate) {
25729 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
25730 let wpTime;
25731 if (value) {
25732 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
25733 } else {
25734 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
25735 }
25736 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
25737 dateTimeValue = finalDateTime.toISOString();
25738 onChangeCallback(dateTimeValue);
25739 if (validationTimeoutRef.current) {
25740 clearTimeout(validationTimeoutRef.current);
25741 }
25742 } else {
25743 onChangeCallback(void 0);
25744 }
25745 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
25746 validationTimeoutRef.current = setTimeout(() => {
25747 if (inputControlRef.current) {
25748 inputControlRef.current.focus();
25749 inputControlRef.current.blur();
25750 onChangeCallback(dateTimeValue);
25751 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
25752 previousFocusRef.current.focus();
25753 }
25754 }
25755 }, 0);
25756 },
25757 [onChangeCallback, value]
25758 );
25759 const handleManualDateTimeChange = (0, import_element85.useCallback)(
25760 (newValue) => {
25761 if (newValue) {
25762 const dateTime = (0, import_date3.getDate)(newValue);
25763 onChangeCallback(dateTime.toISOString());
25764 const parsedDate = parseDateTime(dateTime.toISOString());
25765 if (parsedDate) {
25766 setCalendarMonth(parsedDate);
25767 }
25768 } else {
25769 onChangeCallback(void 0);
25770 }
25771 },
25772 [onChangeCallback]
25773 );
25774 const { format: fieldFormat } = field;
25775 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
25776 const {
25777 timezone: { string: timezoneString }
25778 } = (0, import_date3.getSettings)();
25779 let displayLabel = label;
25780 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
25781 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
25782 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
25783 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
25784 }
25785 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25786 import_components31.BaseControl,
25787 {
25788 id,
25789 label: displayLabel,
25790 help: description,
25791 hideLabelFromVision,
25792 children: /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(Stack, { direction: "column", gap: "lg", children: [
25793 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25794 ValidatedInputControl,
25795 {
25796 ref: inputControlRef,
25797 required: !!isValid2?.required,
25798 customValidity: getCustomValidity(isValid2, validity),
25799 type: "datetime-local",
25800 label: (0, import_i18n35.__)("Date time"),
25801 hideLabelFromVision: true,
25802 value: formatDateTime(value),
25803 onChange: handleManualDateTimeChange,
25804 disabled: disabled2,
25805 min: minConstraint ? formatDateTime(minConstraint) : void 0,
25806 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
25807 }
25808 ),
25809 !compact && /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25810 DateCalendar,
25811 {
25812 style: { width: "100%" },
25813 selected: value ? parseDateTime(value) || void 0 : void 0,
25814 onSelect: onSelectDate,
25815 month: calendarMonth,
25816 onMonthChange: setCalendarMonth,
25817 timeZone: timezoneString || void 0,
25818 weekStartsOn,
25819 disabled: disabled2 || disabledMatchers
25820 }
25821 )
25822 ] })
25823 }
25824 );
25825 }
25826 function DateTime({
25827 data,
25828 field,
25829 onChange,
25830 hideLabelFromVision,
25831 markWhenOptional,
25832 operator,
25833 validity,
25834 config
25835 }) {
25836 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
25837 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25838 RelativeDateControl,
25839 {
25840 className: "dataviews-controls__datetime",
25841 data,
25842 field,
25843 onChange,
25844 hideLabelFromVision,
25845 operator
25846 }
25847 );
25848 }
25849 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
25850 CalendarDateTimeControl,
25851 {
25852 data,
25853 field,
25854 onChange,
25855 hideLabelFromVision,
25856 markWhenOptional,
25857 validity,
25858 config
25859 }
25860 );
25861 }
25862
25863 // packages/dataviews/build-module/components/dataform-controls/date.mjs
25864 var import_components32 = __toESM(require_components(), 1);
25865 var import_element86 = __toESM(require_element(), 1);
25866 var import_i18n36 = __toESM(require_i18n(), 1);
25867 var import_date4 = __toESM(require_date(), 1);
25868 import { speak as speak2 } from "@wordpress/a11y";
25869 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
25870 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis);
25871 var DATE_PRESETS = [
25872 {
25873 id: "today",
25874 label: (0, import_i18n36.__)("Today"),
25875 getValue: () => (0, import_date4.getDate)(null)
25876 },
25877 {
25878 id: "yesterday",
25879 label: (0, import_i18n36.__)("Yesterday"),
25880 getValue: () => {
25881 const today = (0, import_date4.getDate)(null);
25882 return subDays(today, 1);
25883 }
25884 },
25885 {
25886 id: "past-week",
25887 label: (0, import_i18n36.__)("Past week"),
25888 getValue: () => {
25889 const today = (0, import_date4.getDate)(null);
25890 return subDays(today, 7);
25891 }
25892 },
25893 {
25894 id: "past-month",
25895 label: (0, import_i18n36.__)("Past month"),
25896 getValue: () => {
25897 const today = (0, import_date4.getDate)(null);
25898 return subMonths(today, 1);
25899 }
25900 }
25901 ];
25902 var DATE_RANGE_PRESETS = [
25903 {
25904 id: "last-7-days",
25905 label: (0, import_i18n36.__)("Last 7 days"),
25906 getValue: () => {
25907 const today = (0, import_date4.getDate)(null);
25908 return [subDays(today, 7), today];
25909 }
25910 },
25911 {
25912 id: "last-30-days",
25913 label: (0, import_i18n36.__)("Last 30 days"),
25914 getValue: () => {
25915 const today = (0, import_date4.getDate)(null);
25916 return [subDays(today, 30), today];
25917 }
25918 },
25919 {
25920 id: "month-to-date",
25921 label: (0, import_i18n36.__)("Month to date"),
25922 getValue: () => {
25923 const today = (0, import_date4.getDate)(null);
25924 return [startOfMonth(today), today];
25925 }
25926 },
25927 {
25928 id: "last-year",
25929 label: (0, import_i18n36.__)("Last year"),
25930 getValue: () => {
25931 const today = (0, import_date4.getDate)(null);
25932 return [subYears(today, 1), today];
25933 }
25934 },
25935 {
25936 id: "year-to-date",
25937 label: (0, import_i18n36.__)("Year to date"),
25938 getValue: () => {
25939 const today = (0, import_date4.getDate)(null);
25940 return [startOfYear(today), today];
25941 }
25942 }
25943 ];
25944 var parseDate = (dateString) => {
25945 if (!dateString) {
25946 return null;
25947 }
25948 const parsed = (0, import_date4.getDate)(dateString);
25949 return parsed && isValid(parsed) ? parsed : null;
25950 };
25951 var formatDate = (date) => {
25952 if (!date) {
25953 return "";
25954 }
25955 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
25956 };
25957 function ValidatedDateControl({
25958 field,
25959 validity,
25960 inputRefs,
25961 isTouched,
25962 setIsTouched,
25963 children
25964 }) {
25965 const { isValid: isValid2 } = field;
25966 const [customValidity, setCustomValidity] = (0, import_element86.useState)(void 0);
25967 const validateRefs = (0, import_element86.useCallback)(() => {
25968 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25969 for (const ref of refs) {
25970 const input = ref.current;
25971 if (input && !input.validity.valid) {
25972 setCustomValidity({
25973 type: "invalid",
25974 message: input.validationMessage
25975 });
25976 return;
25977 }
25978 }
25979 setCustomValidity(void 0);
25980 }, [inputRefs]);
25981 (0, import_element86.useEffect)(() => {
25982 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25983 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
25984 for (const ref of refs) {
25985 const input = ref.current;
25986 if (input) {
25987 input.setCustomValidity(
25988 result?.type === "invalid" && result.message ? result.message : ""
25989 );
25990 }
25991 }
25992 }, [inputRefs, isValid2, validity]);
25993 (0, import_element86.useEffect)(() => {
25994 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
25995 const handleInvalid = (event) => {
25996 event.preventDefault();
25997 setIsTouched(true);
25998 };
25999 for (const ref of refs) {
26000 ref.current?.addEventListener("invalid", handleInvalid);
26001 }
26002 return () => {
26003 for (const ref of refs) {
26004 ref.current?.removeEventListener("invalid", handleInvalid);
26005 }
26006 };
26007 }, [inputRefs, setIsTouched]);
26008 (0, import_element86.useEffect)(() => {
26009 if (!isTouched) {
26010 return;
26011 }
26012 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
26013 if (result) {
26014 setCustomValidity(result);
26015 } else {
26016 validateRefs();
26017 }
26018 }, [isTouched, isValid2, validity, validateRefs]);
26019 (0, import_element86.useEffect)(() => {
26020 if (isTouched && customValidity?.message) {
26021 speak2(customValidity.message);
26022 }
26023 }, [isTouched, customValidity?.message]);
26024 const onBlur = (event) => {
26025 if (isTouched) {
26026 return;
26027 }
26028 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
26029 setIsTouched(true);
26030 }
26031 };
26032 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)("div", { onBlur, children: [
26033 children,
26034 customValidity && /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
26035 "p",
26036 {
26037 className: clsx_default(
26038 "components-validated-control__indicator",
26039 customValidity.type === "invalid" ? "is-invalid" : void 0
26040 ),
26041 children: [
26042 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26043 import_components32.Icon,
26044 {
26045 className: "components-validated-control__indicator-icon",
26046 icon: error_default,
26047 size: 16,
26048 fill: "currentColor"
26049 }
26050 ),
26051 customValidity.message
26052 ]
26053 }
26054 )
26055 ] });
26056 }
26057 function CalendarDateControl({
26058 data,
26059 field,
26060 onChange,
26061 hideLabelFromVision,
26062 markWhenOptional,
26063 validity
26064 }) {
26065 const {
26066 id,
26067 label,
26068 description,
26069 setValue,
26070 getValue,
26071 isValid: isValid2,
26072 format: fieldFormat
26073 } = field;
26074 const disabled2 = field.isDisabled({ item: data, field });
26075 const [selectedPresetId, setSelectedPresetId] = (0, import_element86.useState)(
26076 null
26077 );
26078 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
26079 const fieldValue = getValue({ item: data });
26080 const value = typeof fieldValue === "string" ? fieldValue : void 0;
26081 const [calendarMonth, setCalendarMonth] = (0, import_element86.useState)(() => {
26082 const parsedDate = parseDate(value);
26083 return parsedDate || /* @__PURE__ */ new Date();
26084 });
26085 const [isTouched, setIsTouched] = (0, import_element86.useState)(false);
26086 const validityTargetRef = (0, import_element86.useRef)(null);
26087 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
26088 const onChangeCallback = (0, import_element86.useCallback)(
26089 (newValue) => onChange(setValue({ item: data, value: newValue })),
26090 [data, onChange, setValue]
26091 );
26092 const onSelectDate = (0, import_element86.useCallback)(
26093 (newDate) => {
26094 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
26095 onChangeCallback(dateValue);
26096 setSelectedPresetId(null);
26097 setIsTouched(true);
26098 },
26099 [onChangeCallback]
26100 );
26101 const handlePresetClick = (0, import_element86.useCallback)(
26102 (preset) => {
26103 const presetDate = preset.getValue();
26104 const dateValue = formatDate(presetDate);
26105 setCalendarMonth(presetDate);
26106 onChangeCallback(dateValue);
26107 setSelectedPresetId(preset.id);
26108 setIsTouched(true);
26109 },
26110 [onChangeCallback]
26111 );
26112 const handleManualDateChange = (0, import_element86.useCallback)(
26113 (newValue) => {
26114 onChangeCallback(newValue);
26115 if (newValue) {
26116 const parsedDate = parseDate(newValue);
26117 if (parsedDate) {
26118 setCalendarMonth(parsedDate);
26119 }
26120 }
26121 setSelectedPresetId(null);
26122 setIsTouched(true);
26123 },
26124 [onChangeCallback]
26125 );
26126 const {
26127 timezone: { string: timezoneString }
26128 } = (0, import_date4.getSettings)();
26129 let displayLabel = label;
26130 if (isValid2?.required && !markWhenOptional) {
26131 displayLabel = `${label} (${(0, import_i18n36.__)("Required")})`;
26132 } else if (!isValid2?.required && markWhenOptional) {
26133 displayLabel = `${label} (${(0, import_i18n36.__)("Optional")})`;
26134 }
26135 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26136 ValidatedDateControl,
26137 {
26138 field,
26139 validity,
26140 inputRefs: validityTargetRef,
26141 isTouched,
26142 setIsTouched,
26143 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26144 import_components32.BaseControl,
26145 {
26146 id,
26147 className: "dataviews-controls__date",
26148 label: displayLabel,
26149 help: description,
26150 hideLabelFromVision,
26151 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(Stack, { direction: "column", gap: "lg", children: [
26152 /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
26153 Stack,
26154 {
26155 direction: "row",
26156 gap: "sm",
26157 wrap: "wrap",
26158 justify: "flex-start",
26159 children: [
26160 DATE_PRESETS.map((preset) => {
26161 const isSelected2 = selectedPresetId === preset.id;
26162 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26163 import_components32.Button,
26164 {
26165 className: "dataviews-controls__date-preset",
26166 variant: "tertiary",
26167 isPressed: isSelected2,
26168 size: "small",
26169 disabled: disabled2,
26170 accessibleWhenDisabled: true,
26171 onClick: () => handlePresetClick(preset),
26172 children: preset.label
26173 },
26174 preset.id
26175 );
26176 }),
26177 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26178 import_components32.Button,
26179 {
26180 className: "dataviews-controls__date-preset",
26181 variant: "tertiary",
26182 isPressed: !selectedPresetId,
26183 size: "small",
26184 disabled: !!selectedPresetId || disabled2,
26185 accessibleWhenDisabled: true,
26186 children: (0, import_i18n36.__)("Custom")
26187 }
26188 )
26189 ]
26190 }
26191 ),
26192 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26193 import_components32.__experimentalInputControl,
26194 {
26195 ref: validityTargetRef,
26196 type: "date",
26197 label: (0, import_i18n36.__)("Date"),
26198 hideLabelFromVision: true,
26199 value,
26200 onChange: handleManualDateChange,
26201 required: !!field.isValid?.required,
26202 disabled: disabled2,
26203 min: minConstraint,
26204 max: maxConstraint
26205 }
26206 ),
26207 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26208 DateCalendar2,
26209 {
26210 style: { width: "100%" },
26211 selected: value ? parseDate(value) || void 0 : void 0,
26212 onSelect: onSelectDate,
26213 month: calendarMonth,
26214 onMonthChange: setCalendarMonth,
26215 timeZone: timezoneString || void 0,
26216 weekStartsOn,
26217 disabled: disabled2 || disabledMatchers,
26218 disableNavigation: disabled2
26219 }
26220 )
26221 ] })
26222 }
26223 )
26224 }
26225 );
26226 }
26227 function CalendarDateRangeControl({
26228 data,
26229 field,
26230 onChange,
26231 hideLabelFromVision,
26232 markWhenOptional,
26233 validity
26234 }) {
26235 const {
26236 id,
26237 label,
26238 description,
26239 getValue,
26240 setValue,
26241 isValid: isValid2,
26242 format: fieldFormat
26243 } = field;
26244 const disabled2 = field.isDisabled({ item: data, field });
26245 let value;
26246 const fieldValue = getValue({ item: data });
26247 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
26248 value = fieldValue;
26249 }
26250 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
26251 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
26252 const onChangeCallback = (0, import_element86.useCallback)(
26253 (newValue) => {
26254 onChange(
26255 setValue({
26256 item: data,
26257 value: newValue
26258 })
26259 );
26260 },
26261 [data, onChange, setValue]
26262 );
26263 const [selectedPresetId, setSelectedPresetId] = (0, import_element86.useState)(
26264 null
26265 );
26266 const selectedRange = (0, import_element86.useMemo)(() => {
26267 if (!value) {
26268 return { from: void 0, to: void 0 };
26269 }
26270 const [from, to] = value;
26271 return {
26272 from: parseDate(from) || void 0,
26273 to: parseDate(to) || void 0
26274 };
26275 }, [value]);
26276 const [calendarMonth, setCalendarMonth] = (0, import_element86.useState)(() => {
26277 return selectedRange.from || /* @__PURE__ */ new Date();
26278 });
26279 const [isTouched, setIsTouched] = (0, import_element86.useState)(false);
26280 const fromInputRef = (0, import_element86.useRef)(null);
26281 const toInputRef = (0, import_element86.useRef)(null);
26282 const updateDateRange = (0, import_element86.useCallback)(
26283 (fromDate, toDate2) => {
26284 if (fromDate && toDate2) {
26285 onChangeCallback([
26286 formatDate(fromDate),
26287 formatDate(toDate2)
26288 ]);
26289 } else if (!fromDate && !toDate2) {
26290 onChangeCallback(void 0);
26291 }
26292 },
26293 [onChangeCallback]
26294 );
26295 const onSelectCalendarRange = (0, import_element86.useCallback)(
26296 (newRange) => {
26297 updateDateRange(newRange?.from, newRange?.to);
26298 setSelectedPresetId(null);
26299 setIsTouched(true);
26300 },
26301 [updateDateRange]
26302 );
26303 const handlePresetClick = (0, import_element86.useCallback)(
26304 (preset) => {
26305 const [startDate, endDate] = preset.getValue();
26306 setCalendarMonth(startDate);
26307 updateDateRange(startDate, endDate);
26308 setSelectedPresetId(preset.id);
26309 setIsTouched(true);
26310 },
26311 [updateDateRange]
26312 );
26313 const handleManualDateChange = (0, import_element86.useCallback)(
26314 (fromOrTo, newValue) => {
26315 const [currentFrom, currentTo] = value || [
26316 void 0,
26317 void 0
26318 ];
26319 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
26320 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
26321 updateDateRange(updatedFrom, updatedTo);
26322 if (newValue) {
26323 const parsedDate = parseDate(newValue);
26324 if (parsedDate) {
26325 setCalendarMonth(parsedDate);
26326 }
26327 }
26328 setSelectedPresetId(null);
26329 setIsTouched(true);
26330 },
26331 [value, updateDateRange]
26332 );
26333 const { timezone } = (0, import_date4.getSettings)();
26334 let displayLabel = label;
26335 if (field.isValid?.required && !markWhenOptional) {
26336 displayLabel = `${label} (${(0, import_i18n36.__)("Required")})`;
26337 } else if (!field.isValid?.required && markWhenOptional) {
26338 displayLabel = `${label} (${(0, import_i18n36.__)("Optional")})`;
26339 }
26340 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26341 ValidatedDateControl,
26342 {
26343 field,
26344 validity,
26345 inputRefs: [fromInputRef, toInputRef],
26346 isTouched,
26347 setIsTouched,
26348 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26349 import_components32.BaseControl,
26350 {
26351 id,
26352 className: "dataviews-controls__date",
26353 label: displayLabel,
26354 help: description,
26355 hideLabelFromVision,
26356 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(Stack, { direction: "column", gap: "lg", children: [
26357 /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
26358 Stack,
26359 {
26360 direction: "row",
26361 gap: "sm",
26362 wrap: "wrap",
26363 justify: "flex-start",
26364 children: [
26365 DATE_RANGE_PRESETS.map((preset) => {
26366 const isSelected2 = selectedPresetId === preset.id;
26367 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26368 import_components32.Button,
26369 {
26370 className: "dataviews-controls__date-preset",
26371 variant: "tertiary",
26372 isPressed: isSelected2,
26373 size: "small",
26374 disabled: disabled2,
26375 accessibleWhenDisabled: true,
26376 onClick: () => handlePresetClick(preset),
26377 children: preset.label
26378 },
26379 preset.id
26380 );
26381 }),
26382 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26383 import_components32.Button,
26384 {
26385 className: "dataviews-controls__date-preset",
26386 variant: "tertiary",
26387 isPressed: !selectedPresetId,
26388 size: "small",
26389 accessibleWhenDisabled: true,
26390 disabled: !!selectedPresetId || disabled2,
26391 children: (0, import_i18n36.__)("Custom")
26392 }
26393 )
26394 ]
26395 }
26396 ),
26397 /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
26398 Stack,
26399 {
26400 direction: "row",
26401 gap: "sm",
26402 justify: "space-between",
26403 className: "dataviews-controls__date-range-inputs",
26404 children: [
26405 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26406 import_components32.__experimentalInputControl,
26407 {
26408 ref: fromInputRef,
26409 type: "date",
26410 label: (0, import_i18n36.__)("From"),
26411 hideLabelFromVision: true,
26412 value: value?.[0],
26413 onChange: (newValue) => handleManualDateChange("from", newValue),
26414 required: !!field.isValid?.required,
26415 disabled: disabled2,
26416 min: minConstraint,
26417 max: maxConstraint
26418 }
26419 ),
26420 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26421 import_components32.__experimentalInputControl,
26422 {
26423 ref: toInputRef,
26424 type: "date",
26425 label: (0, import_i18n36.__)("To"),
26426 hideLabelFromVision: true,
26427 value: value?.[1],
26428 onChange: (newValue) => handleManualDateChange("to", newValue),
26429 required: !!field.isValid?.required,
26430 disabled: disabled2,
26431 min: minConstraint,
26432 max: maxConstraint
26433 }
26434 )
26435 ]
26436 }
26437 ),
26438 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26439 DateRangeCalendar,
26440 {
26441 style: { width: "100%" },
26442 selected: selectedRange,
26443 onSelect: onSelectCalendarRange,
26444 month: calendarMonth,
26445 onMonthChange: setCalendarMonth,
26446 timeZone: timezone.string || void 0,
26447 weekStartsOn,
26448 disabled: disabled2 || disabledMatchers
26449 }
26450 )
26451 ] })
26452 }
26453 )
26454 }
26455 );
26456 }
26457 function DateControl({
26458 data,
26459 field,
26460 onChange,
26461 hideLabelFromVision,
26462 markWhenOptional,
26463 operator,
26464 validity
26465 }) {
26466 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
26467 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26468 RelativeDateControl,
26469 {
26470 className: "dataviews-controls__date",
26471 data,
26472 field,
26473 onChange,
26474 hideLabelFromVision,
26475 operator
26476 }
26477 );
26478 }
26479 if (operator === OPERATOR_BETWEEN) {
26480 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26481 CalendarDateRangeControl,
26482 {
26483 data,
26484 field,
26485 onChange,
26486 hideLabelFromVision,
26487 markWhenOptional,
26488 validity
26489 }
26490 );
26491 }
26492 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
26493 CalendarDateControl,
26494 {
26495 data,
26496 field,
26497 onChange,
26498 hideLabelFromVision,
26499 markWhenOptional,
26500 validity
26501 }
26502 );
26503 }
26504
26505 // packages/dataviews/build-module/components/dataform-controls/select.mjs
26506 var import_components33 = __toESM(require_components(), 1);
26507 var import_element87 = __toESM(require_element(), 1);
26508 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
26509 var { ValidatedSelectControl } = unlock2(import_components33.privateApis);
26510 function Select({
26511 data,
26512 field,
26513 onChange,
26514 hideLabelFromVision,
26515 markWhenOptional,
26516 validity
26517 }) {
26518 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
26519 const disabled2 = field.isDisabled({ item: data, field });
26520 const isMultiple = type === "array";
26521 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
26522 const onChangeControl = (0, import_element87.useCallback)(
26523 (newValue) => onChange(setValue({ item: data, value: newValue })),
26524 [data, onChange, setValue]
26525 );
26526 const { elements, isLoading } = useElements({
26527 elements: field.elements,
26528 getElements: field.getElements
26529 });
26530 if (isLoading) {
26531 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components33.Spinner, {});
26532 }
26533 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
26534 ValidatedSelectControl,
26535 {
26536 required: !!field.isValid?.required,
26537 markWhenOptional,
26538 customValidity: getCustomValidity(isValid2, validity),
26539 label,
26540 value,
26541 help: description,
26542 options: elements,
26543 onChange: onChangeControl,
26544 hideLabelFromVision,
26545 multiple: isMultiple,
26546 disabled: disabled2
26547 }
26548 );
26549 }
26550
26551 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
26552 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
26553 var ELEMENTS_THRESHOLD = 10;
26554 function AdaptiveSelect(props) {
26555 const { field } = props;
26556 const { elements } = useElements({
26557 elements: field.elements,
26558 getElements: field.getElements
26559 });
26560 if (elements.length >= ELEMENTS_THRESHOLD) {
26561 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(Combobox3, { ...props });
26562 }
26563 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(Select, { ...props });
26564 }
26565
26566 // packages/dataviews/build-module/components/dataform-controls/email.mjs
26567 var import_components35 = __toESM(require_components(), 1);
26568
26569 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
26570 var import_components34 = __toESM(require_components(), 1);
26571 var import_element88 = __toESM(require_element(), 1);
26572 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
26573 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis);
26574 function ValidatedText({
26575 data,
26576 field,
26577 onChange,
26578 hideLabelFromVision,
26579 markWhenOptional,
26580 type,
26581 prefix,
26582 suffix,
26583 validity
26584 }) {
26585 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
26586 const value = getValue({ item: data });
26587 const disabled2 = field.isDisabled({ item: data, field });
26588 const onChangeControl = (0, import_element88.useCallback)(
26589 (newValue) => onChange(
26590 setValue({
26591 item: data,
26592 value: newValue
26593 })
26594 ),
26595 [data, setValue, onChange]
26596 );
26597 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26598 ValidatedInputControl2,
26599 {
26600 required: !!isValid2.required,
26601 markWhenOptional,
26602 customValidity: getCustomValidity(isValid2, validity),
26603 label,
26604 placeholder,
26605 value: value ?? "",
26606 help: description,
26607 onChange: onChangeControl,
26608 hideLabelFromVision,
26609 type,
26610 prefix,
26611 suffix,
26612 disabled: disabled2,
26613 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
26614 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
26615 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0
26616 }
26617 );
26618 }
26619
26620 // packages/dataviews/build-module/components/dataform-controls/email.mjs
26621 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
26622 function Email({
26623 data,
26624 field,
26625 onChange,
26626 hideLabelFromVision,
26627 markWhenOptional,
26628 validity
26629 }) {
26630 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26631 ValidatedText,
26632 {
26633 ...{
26634 data,
26635 field,
26636 onChange,
26637 hideLabelFromVision,
26638 markWhenOptional,
26639 validity,
26640 type: "email",
26641 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 }) })
26642 }
26643 }
26644 );
26645 }
26646
26647 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
26648 var import_components36 = __toESM(require_components(), 1);
26649 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
26650 function Telephone({
26651 data,
26652 field,
26653 onChange,
26654 hideLabelFromVision,
26655 markWhenOptional,
26656 validity
26657 }) {
26658 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26659 ValidatedText,
26660 {
26661 ...{
26662 data,
26663 field,
26664 onChange,
26665 hideLabelFromVision,
26666 markWhenOptional,
26667 validity,
26668 type: "tel",
26669 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 }) })
26670 }
26671 }
26672 );
26673 }
26674
26675 // packages/dataviews/build-module/components/dataform-controls/url.mjs
26676 var import_components37 = __toESM(require_components(), 1);
26677 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
26678 function Url({
26679 data,
26680 field,
26681 onChange,
26682 hideLabelFromVision,
26683 markWhenOptional,
26684 validity
26685 }) {
26686 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
26687 ValidatedText,
26688 {
26689 ...{
26690 data,
26691 field,
26692 onChange,
26693 hideLabelFromVision,
26694 markWhenOptional,
26695 validity,
26696 type: "url",
26697 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 }) })
26698 }
26699 }
26700 );
26701 }
26702
26703 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
26704 var import_components38 = __toESM(require_components(), 1);
26705 var import_element89 = __toESM(require_element(), 1);
26706 var import_i18n37 = __toESM(require_i18n(), 1);
26707 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
26708 var { ValidatedNumberControl } = unlock2(import_components38.privateApis);
26709 function toNumberOrEmpty(value) {
26710 if (value === "" || value === void 0) {
26711 return "";
26712 }
26713 const number = Number(value);
26714 return Number.isFinite(number) ? number : "";
26715 }
26716 function BetweenControls({
26717 value,
26718 onChange,
26719 hideLabelFromVision,
26720 step
26721 }) {
26722 const [min2 = "", max2 = ""] = value;
26723 const onChangeMin = (0, import_element89.useCallback)(
26724 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
26725 [onChange, max2]
26726 );
26727 const onChangeMax = (0, import_element89.useCallback)(
26728 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
26729 [onChange, min2]
26730 );
26731 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26732 import_components38.BaseControl,
26733 {
26734 help: (0, import_i18n37.__)("The max. value must be greater than the min. value."),
26735 children: /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
26736 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26737 import_components38.__experimentalNumberControl,
26738 {
26739 label: (0, import_i18n37.__)("Min."),
26740 value: min2,
26741 max: max2 ? Number(max2) - step : void 0,
26742 onChange: onChangeMin,
26743 hideLabelFromVision,
26744 step
26745 }
26746 ),
26747 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26748 import_components38.__experimentalNumberControl,
26749 {
26750 label: (0, import_i18n37.__)("Max."),
26751 value: max2,
26752 min: min2 ? Number(min2) + step : void 0,
26753 onChange: onChangeMax,
26754 hideLabelFromVision,
26755 step
26756 }
26757 )
26758 ] })
26759 }
26760 );
26761 }
26762 function ValidatedNumber({
26763 data,
26764 field,
26765 onChange,
26766 hideLabelFromVision,
26767 markWhenOptional,
26768 operator,
26769 validity
26770 }) {
26771 const decimals = field.format?.decimals ?? 0;
26772 const step = Math.pow(10, Math.abs(decimals) * -1);
26773 const { label, description, getValue, setValue, isValid: isValid2 } = field;
26774 const value = getValue({ item: data }) ?? "";
26775 const disabled2 = field.isDisabled({ item: data, field });
26776 const onChangeControl = (0, import_element89.useCallback)(
26777 (newValue) => {
26778 onChange(
26779 setValue({
26780 item: data,
26781 // Do not convert an empty string or undefined to a number,
26782 // otherwise there's a mismatch between the UI control (empty)
26783 // and the data relied by onChange (0).
26784 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
26785 })
26786 );
26787 },
26788 [data, onChange, setValue]
26789 );
26790 const onChangeBetweenControls = (0, import_element89.useCallback)(
26791 (newValue) => {
26792 onChange(
26793 setValue({
26794 item: data,
26795 value: newValue
26796 })
26797 );
26798 },
26799 [data, onChange, setValue]
26800 );
26801 if (operator === OPERATOR_BETWEEN) {
26802 let valueBetween = ["", ""];
26803 if (Array.isArray(value) && value.length === 2 && value.every(
26804 (element) => typeof element === "number" || element === ""
26805 )) {
26806 valueBetween = value;
26807 }
26808 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26809 BetweenControls,
26810 {
26811 value: valueBetween,
26812 onChange: onChangeBetweenControls,
26813 hideLabelFromVision,
26814 step
26815 }
26816 );
26817 }
26818 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
26819 ValidatedNumberControl,
26820 {
26821 required: !!isValid2.required,
26822 markWhenOptional,
26823 customValidity: getCustomValidity(isValid2, validity),
26824 label,
26825 help: description,
26826 value,
26827 onChange: onChangeControl,
26828 hideLabelFromVision,
26829 step,
26830 min: isValid2.min ? isValid2.min.constraint : void 0,
26831 max: isValid2.max ? isValid2.max.constraint : void 0,
26832 disabled: disabled2
26833 }
26834 );
26835 }
26836
26837 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
26838 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
26839 function Integer(props) {
26840 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(ValidatedNumber, { ...props });
26841 }
26842
26843 // packages/dataviews/build-module/components/dataform-controls/number.mjs
26844 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
26845 function Number2(props) {
26846 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ValidatedNumber, { ...props });
26847 }
26848
26849 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
26850 var import_components39 = __toESM(require_components(), 1);
26851 var import_element90 = __toESM(require_element(), 1);
26852 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
26853 var { ValidatedRadioControl } = unlock2(import_components39.privateApis);
26854 function Radio({
26855 data,
26856 field,
26857 onChange,
26858 hideLabelFromVision,
26859 markWhenOptional,
26860 validity
26861 }) {
26862 const { label, description, getValue, setValue, isValid: isValid2 } = field;
26863 const disabled2 = field.isDisabled({ item: data, field });
26864 const { elements, isLoading } = useElements({
26865 elements: field.elements,
26866 getElements: field.getElements
26867 });
26868 const value = getValue({ item: data });
26869 const onChangeControl = (0, import_element90.useCallback)(
26870 (newValue) => onChange(setValue({ item: data, value: newValue })),
26871 [data, onChange, setValue]
26872 );
26873 if (isLoading) {
26874 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components39.Spinner, {});
26875 }
26876 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
26877 ValidatedRadioControl,
26878 {
26879 required: !!field.isValid?.required,
26880 markWhenOptional,
26881 customValidity: getCustomValidity(isValid2, validity),
26882 label,
26883 help: description,
26884 onChange: onChangeControl,
26885 options: elements,
26886 selected: value,
26887 hideLabelFromVision,
26888 disabled: disabled2
26889 }
26890 );
26891 }
26892
26893 // packages/dataviews/build-module/components/dataform-controls/text.mjs
26894 var import_element91 = __toESM(require_element(), 1);
26895 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
26896 function Text3({
26897 data,
26898 field,
26899 onChange,
26900 hideLabelFromVision,
26901 markWhenOptional,
26902 config,
26903 validity
26904 }) {
26905 const { prefix, suffix } = config || {};
26906 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
26907 ValidatedText,
26908 {
26909 ...{
26910 data,
26911 field,
26912 onChange,
26913 hideLabelFromVision,
26914 markWhenOptional,
26915 validity,
26916 prefix: prefix ? (0, import_element91.createElement)(prefix) : void 0,
26917 suffix: suffix ? (0, import_element91.createElement)(suffix) : void 0
26918 }
26919 }
26920 );
26921 }
26922
26923 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
26924 var import_components40 = __toESM(require_components(), 1);
26925 var import_element92 = __toESM(require_element(), 1);
26926 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
26927 var { ValidatedToggleControl } = unlock2(import_components40.privateApis);
26928 function Toggle({
26929 field,
26930 onChange,
26931 data,
26932 hideLabelFromVision,
26933 markWhenOptional,
26934 validity
26935 }) {
26936 const { label, description, getValue, setValue, isValid: isValid2 } = field;
26937 const disabled2 = field.isDisabled({ item: data, field });
26938 const onChangeControl = (0, import_element92.useCallback)(() => {
26939 onChange(
26940 setValue({ item: data, value: !getValue({ item: data }) })
26941 );
26942 }, [onChange, setValue, data, getValue]);
26943 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
26944 ValidatedToggleControl,
26945 {
26946 required: !!isValid2.required,
26947 markWhenOptional,
26948 customValidity: getCustomValidity(isValid2, validity),
26949 hidden: hideLabelFromVision,
26950 label,
26951 help: description,
26952 checked: getValue({ item: data }),
26953 onChange: onChangeControl,
26954 disabled: disabled2
26955 }
26956 );
26957 }
26958
26959 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
26960 var import_components41 = __toESM(require_components(), 1);
26961 var import_element93 = __toESM(require_element(), 1);
26962 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
26963 var { ValidatedTextareaControl } = unlock2(import_components41.privateApis);
26964 function Textarea({
26965 data,
26966 field,
26967 onChange,
26968 hideLabelFromVision,
26969 markWhenOptional,
26970 config,
26971 validity
26972 }) {
26973 const { rows = 4 } = config || {};
26974 const disabled2 = field.isDisabled({ item: data, field });
26975 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
26976 const value = field.getValue({ item: data });
26977 const onChangeControl = (0, import_element93.useCallback)(
26978 (newValue) => onChange(setValue({ item: data, value: newValue })),
26979 [data, onChange, setValue]
26980 );
26981 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
26982 ValidatedTextareaControl,
26983 {
26984 required: !!isValid2.required,
26985 markWhenOptional,
26986 customValidity: getCustomValidity(isValid2, validity),
26987 label,
26988 placeholder,
26989 value: value ?? "",
26990 help: description,
26991 onChange: onChangeControl,
26992 rows,
26993 disabled: disabled2,
26994 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
26995 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
26996 __next40pxDefaultSize: true,
26997 hideLabelFromVision
26998 }
26999 );
27000 }
27001
27002 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
27003 var import_element95 = __toESM(require_element(), 1);
27004
27005 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
27006 var import_components42 = __toESM(require_components(), 1);
27007 var import_compose12 = __toESM(require_compose(), 1);
27008 var import_element94 = __toESM(require_element(), 1);
27009 var import_rich_text2 = __toESM(require_rich_text(), 1);
27010
27011 // packages/dataviews/build-module/components/dataform-controls/richtext/utils.mjs
27012 var EMPTY_ARRAY6 = [];
27013 function getAllowedFormats({
27014 allowedFormats,
27015 disableFormats
27016 }) {
27017 if (disableFormats) {
27018 return EMPTY_ARRAY6;
27019 }
27020 return allowedFormats;
27021 }
27022
27023 // packages/dataviews/build-module/components/dataform-controls/richtext/format-edit.mjs
27024 var import_rich_text = __toESM(require_rich_text(), 1);
27025 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
27026 var import_react33 = __toESM(require_react(), 1);
27027 var EMPTY_CONTEXT = {};
27028 function Edit({
27029 onChange,
27030 onFocus,
27031 value,
27032 forwardedRef,
27033 settings,
27034 isVisible: isVisible2
27035 }) {
27036 const { name, edit: EditFunction } = settings;
27037 if (!EditFunction) {
27038 return null;
27039 }
27040 const activeFormat = (0, import_rich_text.getActiveFormat)(value, name);
27041 const isActive = activeFormat !== void 0;
27042 const activeObject = (0, import_rich_text.getActiveObject)(value);
27043 const isObjectActive = activeObject !== void 0 && activeObject.type === name;
27044 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
27045 EditFunction,
27046 {
27047 isActive,
27048 isVisible: isVisible2,
27049 activeAttributes: isActive ? activeFormat.attributes || {} : {},
27050 isObjectActive,
27051 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
27052 value,
27053 onChange,
27054 onFocus,
27055 contentRef: forwardedRef,
27056 context: EMPTY_CONTEXT
27057 },
27058 name
27059 );
27060 }
27061 function FormatEdit({
27062 formatTypes,
27063 ...props
27064 }) {
27065 return formatTypes.map((settings) => /* @__PURE__ */ (0, import_react33.createElement)(Edit, { settings, ...props, key: settings.name }));
27066 }
27067
27068 // packages/dataviews/build-module/components/dataform-controls/richtext/control.mjs
27069 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
27070 var {
27071 ValidatedContentEditableControl: RichTextControlShell,
27072 withIgnoreIMEEvents
27073 } = unlock2(import_components42.privateApis);
27074 var {
27075 useRichText,
27076 KeyboardShortcutContext,
27077 InputEventContext,
27078 shortcutsListener,
27079 inputEventsListener
27080 } = unlock2(import_rich_text2.privateApis);
27081 var EMPTY_COMPLETERS = [];
27082 function RichTextControl({
27083 label,
27084 value: attrValue,
27085 onChange,
27086 placeholder,
27087 id,
27088 clientId,
27089 className,
27090 hideLabelFromVision,
27091 help,
27092 disabled: disabled2,
27093 required,
27094 markWhenOptional,
27095 customValidity,
27096 allowedFormats,
27097 disableFormats,
27098 withoutInteractiveFormatting,
27099 preserveWhiteSpace,
27100 disableLineBreaks,
27101 focusOnMount,
27102 completers = EMPTY_COMPLETERS
27103 }) {
27104 const [selection, setSelection] = (0, import_element94.useState)({
27105 start: void 0,
27106 end: void 0
27107 });
27108 const [isSelected2, setIsSelected] = (0, import_element94.useState)(false);
27109 const anchorRef = (0, import_element94.useRef)(void 0);
27110 const inputEvents = (0, import_element94.useRef)(/* @__PURE__ */ new Set());
27111 const keyboardShortcuts = (0, import_element94.useRef)(
27112 /* @__PURE__ */ new Set()
27113 );
27114 const focusOutside = (0, import_compose12.__experimentalUseFocusOutside)(() => setIsSelected(false));
27115 const adjustedAllowedFormats = getAllowedFormats({
27116 allowedFormats,
27117 disableFormats
27118 });
27119 const {
27120 value,
27121 onChange: onRichTextChange,
27122 ref: richTextRef,
27123 formatTypes,
27124 getValue
27125 } = useRichText({
27126 value: attrValue,
27127 onChange,
27128 selectionStart: selection.start,
27129 selectionEnd: selection.end,
27130 onSelectionChange: (start, end) => setSelection({ start, end }),
27131 __unstableIsSelected: isSelected2,
27132 preserveWhiteSpace: !!preserveWhiteSpace,
27133 placeholder,
27134 __unstableDisableFormats: disableFormats,
27135 allowedFormats: adjustedAllowedFormats,
27136 withoutInteractiveFormatting,
27137 __unstableFormatTypeHandlerContext: (0, import_element94.useMemo)(
27138 () => ({
27139 richTextIdentifier: id,
27140 blockClientId: clientId
27141 }),
27142 [id, clientId]
27143 )
27144 });
27145 function onFocus() {
27146 anchorRef.current?.focus();
27147 }
27148 const eventListenersPropsRef = (0, import_element94.useRef)({
27149 keyboardShortcuts,
27150 inputEvents
27151 });
27152 const inputRulePropsRef = (0, import_element94.useRef)({
27153 formatTypes,
27154 getValue,
27155 onChange: onRichTextChange
27156 });
27157 (0, import_element94.useInsertionEffect)(() => {
27158 inputRulePropsRef.current = {
27159 formatTypes,
27160 getValue,
27161 onChange: onRichTextChange
27162 };
27163 });
27164 const enterRef = (0, import_compose12.useRefEffect)(
27165 (element) => {
27166 if (disabled2) {
27167 return;
27168 }
27169 const onKeyDown = withIgnoreIMEEvents((event) => {
27170 if (event.key !== "Enter" || event.defaultPrevented || event.metaKey || event.ctrlKey) {
27171 return;
27172 }
27173 event.preventDefault();
27174 if (disableLineBreaks) {
27175 return;
27176 }
27177 const { getValue: getCurrentValue2, onChange: handleChange } = inputRulePropsRef.current;
27178 const current = getCurrentValue2();
27179 handleChange(
27180 (0, import_rich_text2.insert)(
27181 current,
27182 "\n",
27183 current.start ?? current.text.length,
27184 current.end ?? current.text.length
27185 )
27186 );
27187 });
27188 element.addEventListener("keydown", onKeyDown);
27189 return () => element.removeEventListener("keydown", onKeyDown);
27190 },
27191 [disableLineBreaks, disabled2]
27192 );
27193 const eventListenersRef = (0, import_compose12.useRefEffect)(
27194 (element) => {
27195 if (!isSelected2) {
27196 return;
27197 }
27198 const cleanupShortcuts = shortcutsListener(
27199 eventListenersPropsRef
27200 )(element);
27201 const cleanupInputEvents = inputEventsListener(
27202 eventListenersPropsRef
27203 )(element);
27204 function onFormatInput(event) {
27205 if (event.inputType !== "insertText" && event.type !== "compositionend") {
27206 return;
27207 }
27208 const {
27209 formatTypes: types,
27210 getValue: getCurrentValue2,
27211 onChange: handleChange
27212 } = inputRulePropsRef.current;
27213 const current = getCurrentValue2();
27214 const transformed = types.reduce(
27215 (accumulator, {
27216 __unstableInputRule
27217 }) => __unstableInputRule ? __unstableInputRule(accumulator) : accumulator,
27218 current
27219 );
27220 if (transformed !== current) {
27221 handleChange({
27222 ...transformed,
27223 activeFormats: current.activeFormats
27224 });
27225 }
27226 }
27227 element.addEventListener("input", onFormatInput);
27228 element.addEventListener("compositionend", onFormatInput);
27229 return () => {
27230 cleanupShortcuts();
27231 cleanupInputEvents();
27232 element.removeEventListener("input", onFormatInput);
27233 element.removeEventListener("compositionend", onFormatInput);
27234 };
27235 },
27236 [isSelected2]
27237 );
27238 const { ref: autocompleteRef, ...autocompleteProps } = (0, import_components42.__unstableUseAutocompleteProps)(
27239 {
27240 completers,
27241 record: value,
27242 onChange: onRichTextChange,
27243 // This control's completers insert their completion into the value;
27244 // none replace the whole value, so the required `onReplace` is a
27245 // no-op here.
27246 onReplace: () => {
27247 }
27248 }
27249 );
27250 const focusOnMountRef = (0, import_compose12.useRefEffect)(
27251 (element) => {
27252 if (focusOnMount && !disabled2) {
27253 element.focus();
27254 }
27255 },
27256 [focusOnMount, disabled2]
27257 );
27258 const editableRef = (0, import_compose12.useMergeRefs)([
27259 richTextRef,
27260 anchorRef,
27261 eventListenersRef,
27262 enterRef,
27263 focusOnMountRef,
27264 autocompleteRef
27265 ]);
27266 return (
27267 // Focus boundary for the field's selection: `onFocus` selects on entry;
27268 // the spread `useFocusOutside` handlers deselect once focus leaves.
27269 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
27270 "div",
27271 {
27272 ...focusOutside,
27273 onFocus: (event) => {
27274 setIsSelected(true);
27275 focusOutside.onFocus(event);
27276 },
27277 children: /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(import_components42.SlotFillProvider, { children: [
27278 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
27279 RichTextControlShell,
27280 {
27281 label,
27282 id,
27283 className: clsx_default(
27284 "dataviews-controls__richtext",
27285 className
27286 ),
27287 placeholder,
27288 hideLabelFromVision,
27289 help,
27290 disabled: disabled2,
27291 required,
27292 markWhenOptional,
27293 customValidity,
27294 value: value.text,
27295 "aria-multiline": !disableLineBreaks,
27296 ...autocompleteProps,
27297 ref: editableRef
27298 }
27299 ),
27300 isSelected2 && !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
27301 KeyboardShortcutContext.Provider,
27302 {
27303 value: keyboardShortcuts,
27304 children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(InputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
27305 FormatEdit,
27306 {
27307 value,
27308 onChange: onRichTextChange,
27309 onFocus,
27310 formatTypes,
27311 forwardedRef: anchorRef,
27312 isVisible: true
27313 }
27314 ) })
27315 }
27316 )
27317 ] })
27318 }
27319 )
27320 );
27321 }
27322
27323 // packages/dataviews/build-module/components/dataform-controls/richtext/index.mjs
27324 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
27325 function RichText({
27326 data,
27327 field,
27328 onChange,
27329 hideLabelFromVision,
27330 markWhenOptional,
27331 config,
27332 validity
27333 }) {
27334 const {
27335 className,
27336 clientId,
27337 allowedFormats,
27338 disableFormats,
27339 withoutInteractiveFormatting,
27340 preserveWhiteSpace,
27341 disableLineBreaks
27342 } = config || {};
27343 const disabled2 = field.isDisabled({ item: data, field });
27344 const { label, placeholder, description, id, setValue, isValid: isValid2 } = field;
27345 const value = field.getValue({ item: data }) ?? "";
27346 const onChangeControl = (0, import_element95.useCallback)(
27347 (newValue) => onChange(setValue({ item: data, value: newValue })),
27348 [data, onChange, setValue]
27349 );
27350 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
27351 RichTextControl,
27352 {
27353 label,
27354 value,
27355 onChange: onChangeControl,
27356 placeholder,
27357 id,
27358 hideLabelFromVision,
27359 help: description,
27360 disabled: disabled2,
27361 required: !!isValid2.required,
27362 markWhenOptional,
27363 customValidity: getCustomValidity(isValid2, validity),
27364 className,
27365 clientId,
27366 allowedFormats,
27367 disableFormats,
27368 withoutInteractiveFormatting,
27369 preserveWhiteSpace,
27370 disableLineBreaks
27371 }
27372 );
27373 }
27374
27375 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
27376 var import_components43 = __toESM(require_components(), 1);
27377 var import_element96 = __toESM(require_element(), 1);
27378 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1);
27379 var { ValidatedToggleGroupControl } = unlock2(import_components43.privateApis);
27380 function ToggleGroup({
27381 data,
27382 field,
27383 onChange,
27384 hideLabelFromVision,
27385 markWhenOptional,
27386 validity
27387 }) {
27388 const { getValue, setValue, isValid: isValid2 } = field;
27389 const disabled2 = field.isDisabled({ item: data, field });
27390 const value = getValue({ item: data });
27391 const onChangeControl = (0, import_element96.useCallback)(
27392 (newValue) => onChange(setValue({ item: data, value: newValue })),
27393 [data, onChange, setValue]
27394 );
27395 const { elements, isLoading } = useElements({
27396 elements: field.elements,
27397 getElements: field.getElements
27398 });
27399 if (isLoading) {
27400 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(import_components43.Spinner, {});
27401 }
27402 if (elements.length === 0) {
27403 return null;
27404 }
27405 const selectedOption = elements.find((el) => el.value === value);
27406 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
27407 ValidatedToggleGroupControl,
27408 {
27409 required: !!field.isValid?.required,
27410 markWhenOptional,
27411 customValidity: getCustomValidity(isValid2, validity),
27412 isBlock: true,
27413 label: field.label,
27414 help: selectedOption?.description || field.description,
27415 onChange: onChangeControl,
27416 value,
27417 hideLabelFromVision,
27418 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
27419 import_components43.__experimentalToggleGroupControlOption,
27420 {
27421 label: el.label,
27422 value: el.value,
27423 disabled: disabled2
27424 },
27425 el.value
27426 ))
27427 }
27428 );
27429 }
27430
27431 // packages/dataviews/build-module/components/dataform-controls/array.mjs
27432 var import_components44 = __toESM(require_components(), 1);
27433 var import_element97 = __toESM(require_element(), 1);
27434 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1);
27435 var { ValidatedFormTokenField } = unlock2(import_components44.privateApis);
27436 function ArrayControl({
27437 data,
27438 field,
27439 onChange,
27440 hideLabelFromVision,
27441 markWhenOptional,
27442 validity
27443 }) {
27444 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
27445 const value = getValue({ item: data });
27446 const disabled2 = field.isDisabled({ item: data, field });
27447 const { elements, isLoading } = useElements({
27448 elements: field.elements,
27449 getElements: field.getElements
27450 });
27451 const arrayValueAsElements = (0, import_element97.useMemo)(
27452 () => Array.isArray(value) ? value.map((token) => {
27453 const element = elements?.find(
27454 (suggestion) => suggestion.value === token
27455 );
27456 return element || { value: token, label: token };
27457 }) : [],
27458 [value, elements]
27459 );
27460 const onChangeControl = (0, import_element97.useCallback)(
27461 (tokens) => {
27462 const valueTokens = tokens.map((token) => {
27463 if (typeof token === "object" && "value" in token) {
27464 return token.value;
27465 }
27466 return token;
27467 });
27468 onChange(setValue({ item: data, value: valueTokens }));
27469 },
27470 [onChange, setValue, data]
27471 );
27472 if (isLoading) {
27473 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_components44.Spinner, {});
27474 }
27475 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
27476 ValidatedFormTokenField,
27477 {
27478 required: !!isValid2?.required,
27479 markWhenOptional,
27480 customValidity: getCustomValidity(isValid2, validity),
27481 label: hideLabelFromVision ? void 0 : label,
27482 value: arrayValueAsElements,
27483 onChange: onChangeControl,
27484 placeholder,
27485 suggestions: elements?.map((element) => element.value),
27486 disabled: disabled2,
27487 __experimentalValidateInput: (token) => {
27488 if (field.isValid?.elements && elements) {
27489 return elements.some(
27490 (element) => element.value === token || element.label === token
27491 );
27492 }
27493 return true;
27494 },
27495 __experimentalExpandOnFocus: elements && elements.length > 0,
27496 help: description ?? (field.isValid?.elements ? "" : void 0),
27497 displayTransform: (token) => {
27498 if (typeof token === "object" && "label" in token) {
27499 return token.label;
27500 }
27501 if (typeof token === "string" && elements) {
27502 const element = elements.find(
27503 (el) => el.value === token
27504 );
27505 return element?.label || token;
27506 }
27507 return token;
27508 },
27509 __experimentalRenderItem: ({ item }) => {
27510 if (typeof item === "string" && elements) {
27511 const element = elements.find(
27512 (el) => el.value === item
27513 );
27514 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { children: element?.label || item });
27515 }
27516 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { children: item });
27517 }
27518 }
27519 );
27520 }
27521
27522 // node_modules/colord/index.mjs
27523 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
27524 var t = function(r3) {
27525 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
27526 };
27527 var n = function(r3, t2, n2) {
27528 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
27529 };
27530 var e = function(r3, t2, n2) {
27531 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
27532 };
27533 var u = function(r3) {
27534 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
27535 };
27536 var a = function(r3) {
27537 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
27538 };
27539 var o = function(r3) {
27540 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
27541 };
27542 var i = /^#([0-9a-f]{3,8})$/i;
27543 var s = function(r3) {
27544 var t2 = r3.toString(16);
27545 return t2.length < 2 ? "0" + t2 : t2;
27546 };
27547 var h = function(r3) {
27548 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;
27549 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
27550 };
27551 var b = function(r3) {
27552 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
27553 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
27554 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;
27555 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 };
27556 };
27557 var g = function(r3) {
27558 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
27559 };
27560 var d = function(r3) {
27561 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
27562 };
27563 var f = function(r3) {
27564 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 }));
27565 var t2, n2, e2;
27566 };
27567 var c = function(r3) {
27568 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 };
27569 var t2, n2, e2, u2;
27570 };
27571 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
27572 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
27573 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
27574 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
27575 var y = { string: [[function(r3) {
27576 var t2 = i.exec(r3);
27577 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;
27578 }, "hex"], [function(r3) {
27579 var t2 = v.exec(r3) || m.exec(r3);
27580 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;
27581 }, "rgb"], [function(t2) {
27582 var n2 = l.exec(t2) || p.exec(t2);
27583 if (!n2) return null;
27584 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) });
27585 return f(a2);
27586 }, "hsl"]], object: [[function(r3) {
27587 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
27588 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
27589 }, "rgb"], [function(r3) {
27590 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
27591 if (!t(n2) || !t(e2) || !t(u2)) return null;
27592 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
27593 return f(i2);
27594 }, "hsl"], [function(r3) {
27595 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
27596 if (!t(n2) || !t(a2) || !t(o2)) return null;
27597 var h2 = (function(r4) {
27598 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
27599 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
27600 return b(h2);
27601 }, "hsv"]] };
27602 var N = function(r3, t2) {
27603 for (var n2 = 0; n2 < t2.length; n2++) {
27604 var e2 = t2[n2][0](r3);
27605 if (e2) return [e2, t2[n2][1]];
27606 }
27607 return [null, void 0];
27608 };
27609 var x = function(r3) {
27610 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
27611 };
27612 var M = function(r3, t2) {
27613 var n2 = c(r3);
27614 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
27615 };
27616 var H = function(r3) {
27617 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
27618 };
27619 var $ = function(r3, t2) {
27620 var n2 = c(r3);
27621 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
27622 };
27623 var j = (function() {
27624 function r3(r4) {
27625 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
27626 }
27627 return r3.prototype.isValid = function() {
27628 return null !== this.parsed;
27629 }, r3.prototype.brightness = function() {
27630 return n(H(this.rgba), 2);
27631 }, r3.prototype.isDark = function() {
27632 return H(this.rgba) < 0.5;
27633 }, r3.prototype.isLight = function() {
27634 return H(this.rgba) >= 0.5;
27635 }, r3.prototype.toHex = function() {
27636 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;
27637 var r4, t2, e2, u2, a2, i2;
27638 }, r3.prototype.toRgb = function() {
27639 return o(this.rgba);
27640 }, r3.prototype.toRgbString = function() {
27641 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 + ")";
27642 var r4, t2, n2, e2, u2;
27643 }, r3.prototype.toHsl = function() {
27644 return d(c(this.rgba));
27645 }, r3.prototype.toHslString = function() {
27646 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 + "%)";
27647 var r4, t2, n2, e2, u2;
27648 }, r3.prototype.toHsv = function() {
27649 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
27650 var r4;
27651 }, r3.prototype.invert = function() {
27652 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
27653 var r4;
27654 }, r3.prototype.saturate = function(r4) {
27655 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
27656 }, r3.prototype.desaturate = function(r4) {
27657 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
27658 }, r3.prototype.grayscale = function() {
27659 return w(M(this.rgba, -1));
27660 }, r3.prototype.lighten = function(r4) {
27661 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
27662 }, r3.prototype.darken = function(r4) {
27663 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
27664 }, r3.prototype.rotate = function(r4) {
27665 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
27666 }, r3.prototype.alpha = function(r4) {
27667 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
27668 var t2;
27669 }, r3.prototype.hue = function(r4) {
27670 var t2 = c(this.rgba);
27671 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
27672 }, r3.prototype.isEqual = function(r4) {
27673 return this.toHex() === w(r4).toHex();
27674 }, r3;
27675 })();
27676 var w = function(r3) {
27677 return r3 instanceof j ? r3 : new j(r3);
27678 };
27679
27680 // packages/dataviews/build-module/components/dataform-controls/color.mjs
27681 var import_components45 = __toESM(require_components(), 1);
27682 var import_element98 = __toESM(require_element(), 1);
27683 var import_i18n38 = __toESM(require_i18n(), 1);
27684 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1);
27685 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components45.privateApis);
27686 var ColorPickerDropdown = ({
27687 color,
27688 onColorChange,
27689 disabled: disabled2
27690 }) => {
27691 const validColor = color && w(color).isValid() ? color : "#ffffff";
27692 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
27693 import_components45.Dropdown,
27694 {
27695 className: "dataviews-controls__color-picker-dropdown",
27696 popoverProps: { resize: false },
27697 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
27698 import_components45.Button,
27699 {
27700 onClick: onToggle,
27701 "aria-label": (0, import_i18n38.__)("Open color picker"),
27702 size: "small",
27703 disabled: disabled2,
27704 accessibleWhenDisabled: true,
27705 icon: () => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
27706 }
27707 ),
27708 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
27709 import_components45.ColorPicker,
27710 {
27711 color: validColor,
27712 onChange: onColorChange,
27713 enableAlpha: true
27714 }
27715 ) })
27716 }
27717 );
27718 };
27719 function Color({
27720 data,
27721 field,
27722 onChange,
27723 hideLabelFromVision,
27724 markWhenOptional,
27725 validity
27726 }) {
27727 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
27728 const disabled2 = field.isDisabled({ item: data, field });
27729 const value = field.getValue({ item: data }) || "";
27730 const handleColorChange = (0, import_element98.useCallback)(
27731 (newColor) => {
27732 onChange(setValue({ item: data, value: newColor }));
27733 },
27734 [data, onChange, setValue]
27735 );
27736 const handleInputChange = (0, import_element98.useCallback)(
27737 (newValue) => {
27738 onChange(setValue({ item: data, value: newValue || "" }));
27739 },
27740 [data, onChange, setValue]
27741 );
27742 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
27743 ValidatedInputControl3,
27744 {
27745 required: !!field.isValid?.required,
27746 markWhenOptional,
27747 customValidity: getCustomValidity(isValid2, validity),
27748 label,
27749 placeholder,
27750 value,
27751 help: description,
27752 onChange: handleInputChange,
27753 hideLabelFromVision,
27754 type: "text",
27755 disabled: disabled2,
27756 prefix: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
27757 ColorPickerDropdown,
27758 {
27759 color: value,
27760 onColorChange: handleColorChange,
27761 disabled: disabled2
27762 }
27763 ) })
27764 }
27765 );
27766 }
27767
27768 // packages/dataviews/build-module/components/dataform-controls/password.mjs
27769 var import_components46 = __toESM(require_components(), 1);
27770 var import_element99 = __toESM(require_element(), 1);
27771 var import_i18n39 = __toESM(require_i18n(), 1);
27772 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1);
27773 function Password({
27774 data,
27775 field,
27776 onChange,
27777 hideLabelFromVision,
27778 markWhenOptional,
27779 validity
27780 }) {
27781 const [isVisible2, setIsVisible] = (0, import_element99.useState)(false);
27782 const disabled2 = field.isDisabled({ item: data, field });
27783 const toggleVisibility = (0, import_element99.useCallback)(() => {
27784 setIsVisible((prev) => !prev);
27785 }, []);
27786 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
27787 ValidatedText,
27788 {
27789 ...{
27790 data,
27791 field,
27792 onChange,
27793 hideLabelFromVision,
27794 markWhenOptional,
27795 validity,
27796 type: isVisible2 ? "text" : "password",
27797 suffix: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
27798 import_components46.Button,
27799 {
27800 icon: isVisible2 ? unseen_default : seen_default,
27801 onClick: toggleVisibility,
27802 size: "small",
27803 label: isVisible2 ? (0, import_i18n39.__)("Hide password") : (0, import_i18n39.__)("Show password"),
27804 disabled: disabled2,
27805 accessibleWhenDisabled: true
27806 }
27807 ) })
27808 }
27809 }
27810 );
27811 }
27812
27813 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
27814 function hasElements(field) {
27815 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
27816 }
27817
27818 // packages/dataviews/build-module/components/dataform-controls/index.mjs
27819 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1);
27820 var FORM_CONTROLS = {
27821 adaptiveSelect: AdaptiveSelect,
27822 array: ArrayControl,
27823 checkbox: Checkbox,
27824 color: Color,
27825 combobox: Combobox3,
27826 datetime: DateTime,
27827 date: DateControl,
27828 email: Email,
27829 telephone: Telephone,
27830 url: Url,
27831 integer: Integer,
27832 number: Number2,
27833 password: Password,
27834 radio: Radio,
27835 select: Select,
27836 text: Text3,
27837 toggle: Toggle,
27838 textarea: Textarea,
27839 richtext: RichText,
27840 toggleGroup: ToggleGroup
27841 };
27842 function isEditConfig(value) {
27843 return value && typeof value === "object" && typeof value.control === "string";
27844 }
27845 function createConfiguredControl(config) {
27846 const { control, ...controlConfig } = config;
27847 const BaseControlType = getControlByType(control);
27848 if (BaseControlType === null) {
27849 return null;
27850 }
27851 return function ConfiguredControl(props) {
27852 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(BaseControlType, { ...props, config: controlConfig });
27853 };
27854 }
27855 function getControl(field, fallback) {
27856 if (typeof field.Edit === "function") {
27857 return field.Edit;
27858 }
27859 if (typeof field.Edit === "string") {
27860 return getControlByType(field.Edit);
27861 }
27862 if (isEditConfig(field.Edit)) {
27863 return createConfiguredControl(field.Edit);
27864 }
27865 if (hasElements(field) && field.type !== "array") {
27866 return getControlByType("adaptiveSelect");
27867 }
27868 if (fallback === null) {
27869 return null;
27870 }
27871 return getControlByType(fallback);
27872 }
27873 function getControlByType(type) {
27874 if (Object.keys(FORM_CONTROLS).includes(type)) {
27875 return FORM_CONTROLS[type];
27876 }
27877 return null;
27878 }
27879
27880 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
27881 function getFilterBy(field, defaultOperators, validOperators) {
27882 if (field.filterBy === false) {
27883 return false;
27884 }
27885 const operators = field.filterBy?.operators?.filter(
27886 (op) => validOperators.includes(op)
27887 ) ?? defaultOperators;
27888 if (operators.length === 0) {
27889 return false;
27890 }
27891 return {
27892 isPrimary: !!field.filterBy?.isPrimary,
27893 operators
27894 };
27895 }
27896 var get_filter_by_default = getFilterBy;
27897
27898 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
27899 var getValueFromId = (id) => ({ item }) => {
27900 const path = id.split(".");
27901 let value = item;
27902 for (const segment of path) {
27903 if (value.hasOwnProperty(segment)) {
27904 value = value[segment];
27905 } else {
27906 value = void 0;
27907 }
27908 }
27909 return value;
27910 };
27911 var get_value_from_id_default = getValueFromId;
27912
27913 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
27914 var setValueFromId = (id) => ({ value }) => {
27915 const path = id.split(".");
27916 const result = {};
27917 let current = result;
27918 for (const segment of path.slice(0, -1)) {
27919 current[segment] = {};
27920 current = current[segment];
27921 }
27922 current[path.at(-1)] = value;
27923 return result;
27924 };
27925 var set_value_from_id_default = setValueFromId;
27926
27927 // packages/dataviews/build-module/field-types/email.mjs
27928 var import_i18n40 = __toESM(require_i18n(), 1);
27929
27930 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
27931 function RenderFromElements({
27932 item,
27933 field
27934 }) {
27935 const { elements, isLoading } = useElements({
27936 elements: field.elements,
27937 getElements: field.getElements
27938 });
27939 const value = field.getValue({ item });
27940 if (isLoading) {
27941 return value;
27942 }
27943 if (elements.length === 0) {
27944 return value;
27945 }
27946 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
27947 }
27948
27949 // packages/dataviews/build-module/field-types/utils/render-default.mjs
27950 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1);
27951 function render({
27952 item,
27953 field
27954 }) {
27955 if (field.hasElements) {
27956 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(RenderFromElements, { item, field });
27957 }
27958 return field.getValueFormatted({ item, field });
27959 }
27960
27961 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
27962 var sort_text_default = (a2, b2, direction) => {
27963 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
27964 };
27965
27966 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
27967 function isValidRequired(item, field) {
27968 const value = field.getValue({ item });
27969 return ![void 0, "", null].includes(value);
27970 }
27971
27972 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
27973 function isValidMinLength(item, field) {
27974 if (typeof field.isValid.minLength?.constraint !== "number") {
27975 return false;
27976 }
27977 const value = field.getValue({ item });
27978 if ([void 0, "", null].includes(value)) {
27979 return true;
27980 }
27981 return String(value).length >= field.isValid.minLength.constraint;
27982 }
27983
27984 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
27985 function isValidMaxLength(item, field) {
27986 if (typeof field.isValid.maxLength?.constraint !== "number") {
27987 return false;
27988 }
27989 const value = field.getValue({ item });
27990 if ([void 0, "", null].includes(value)) {
27991 return true;
27992 }
27993 return String(value).length <= field.isValid.maxLength.constraint;
27994 }
27995
27996 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
27997 function isValidPattern(item, field) {
27998 if (field.isValid.pattern?.constraint === void 0) {
27999 return true;
28000 }
28001 try {
28002 const regexp = new RegExp(field.isValid.pattern.constraint);
28003 const value = field.getValue({ item });
28004 if ([void 0, "", null].includes(value)) {
28005 return true;
28006 }
28007 return regexp.test(String(value));
28008 } catch {
28009 return false;
28010 }
28011 }
28012
28013 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
28014 function isValidElements(item, field) {
28015 const elements = field.elements ?? [];
28016 const validValues = elements.map((el) => el.value);
28017 if (validValues.length === 0) {
28018 return true;
28019 }
28020 const value = field.getValue({ item });
28021 return [].concat(value).every((v2) => validValues.includes(v2));
28022 }
28023
28024 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
28025 function getValueFormatted({
28026 item,
28027 field
28028 }) {
28029 return field.getValue({ item });
28030 }
28031 var get_value_formatted_default_default = getValueFormatted;
28032
28033 // packages/dataviews/build-module/field-types/email.mjs
28034 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])?)*$/;
28035 function isValidCustom(item, field) {
28036 const value = field.getValue({ item });
28037 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
28038 return (0, import_i18n40.__)("Value must be a valid email address.");
28039 }
28040 return null;
28041 }
28042 var email_default = {
28043 type: "email",
28044 render,
28045 Edit: "email",
28046 sort: sort_text_default,
28047 enableSorting: true,
28048 enableGlobalSearch: false,
28049 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
28050 validOperators: [
28051 OPERATOR_IS,
28052 OPERATOR_IS_NOT,
28053 OPERATOR_CONTAINS,
28054 OPERATOR_NOT_CONTAINS,
28055 OPERATOR_STARTS_WITH,
28056 // Multiple selection
28057 OPERATOR_IS_ANY,
28058 OPERATOR_IS_NONE,
28059 OPERATOR_IS_ALL,
28060 OPERATOR_IS_NOT_ALL
28061 ],
28062 format: {},
28063 getValueFormatted: get_value_formatted_default_default,
28064 validate: {
28065 required: isValidRequired,
28066 pattern: isValidPattern,
28067 minLength: isValidMinLength,
28068 maxLength: isValidMaxLength,
28069 elements: isValidElements,
28070 custom: isValidCustom
28071 }
28072 };
28073
28074 // packages/dataviews/build-module/field-types/integer.mjs
28075 var import_i18n41 = __toESM(require_i18n(), 1);
28076
28077 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
28078 var sort_number_default = (a2, b2, direction) => {
28079 return direction === "asc" ? a2 - b2 : b2 - a2;
28080 };
28081
28082 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
28083 function isValidMin(item, field) {
28084 if (typeof field.isValid.min?.constraint !== "number") {
28085 return false;
28086 }
28087 const value = field.getValue({ item });
28088 if ([void 0, "", null].includes(value)) {
28089 return true;
28090 }
28091 return Number(value) >= field.isValid.min.constraint;
28092 }
28093
28094 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
28095 function isValidMax(item, field) {
28096 if (typeof field.isValid.max?.constraint !== "number") {
28097 return false;
28098 }
28099 const value = field.getValue({ item });
28100 if ([void 0, "", null].includes(value)) {
28101 return true;
28102 }
28103 return Number(value) <= field.isValid.max.constraint;
28104 }
28105
28106 // packages/dataviews/build-module/field-types/integer.mjs
28107 var format2 = {
28108 separatorThousand: ","
28109 };
28110 function getValueFormatted2({
28111 item,
28112 field
28113 }) {
28114 let value = field.getValue({ item });
28115 if (value === null || value === void 0) {
28116 return "";
28117 }
28118 value = Number(value);
28119 if (!Number.isFinite(value)) {
28120 return String(value);
28121 }
28122 let formatInteger;
28123 if (field.type !== "integer") {
28124 formatInteger = format2;
28125 } else {
28126 formatInteger = field.format;
28127 }
28128 const { separatorThousand } = formatInteger;
28129 const integerValue = Math.trunc(value);
28130 if (!separatorThousand) {
28131 return String(integerValue);
28132 }
28133 return String(integerValue).replace(
28134 /\B(?=(\d{3})+(?!\d))/g,
28135 separatorThousand
28136 );
28137 }
28138 function isValidCustom2(item, field) {
28139 const value = field.getValue({ item });
28140 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
28141 return (0, import_i18n41.__)("Value must be an integer.");
28142 }
28143 return null;
28144 }
28145 var integer_default = {
28146 type: "integer",
28147 render,
28148 Edit: "integer",
28149 sort: sort_number_default,
28150 enableSorting: true,
28151 enableGlobalSearch: false,
28152 defaultOperators: [
28153 OPERATOR_IS,
28154 OPERATOR_IS_NOT,
28155 OPERATOR_LESS_THAN,
28156 OPERATOR_GREATER_THAN,
28157 OPERATOR_LESS_THAN_OR_EQUAL,
28158 OPERATOR_GREATER_THAN_OR_EQUAL,
28159 OPERATOR_BETWEEN
28160 ],
28161 validOperators: [
28162 // Single-selection
28163 OPERATOR_IS,
28164 OPERATOR_IS_NOT,
28165 OPERATOR_LESS_THAN,
28166 OPERATOR_GREATER_THAN,
28167 OPERATOR_LESS_THAN_OR_EQUAL,
28168 OPERATOR_GREATER_THAN_OR_EQUAL,
28169 OPERATOR_BETWEEN,
28170 // Multiple-selection
28171 OPERATOR_IS_ANY,
28172 OPERATOR_IS_NONE,
28173 OPERATOR_IS_ALL,
28174 OPERATOR_IS_NOT_ALL
28175 ],
28176 format: format2,
28177 getValueFormatted: getValueFormatted2,
28178 validate: {
28179 required: isValidRequired,
28180 min: isValidMin,
28181 max: isValidMax,
28182 elements: isValidElements,
28183 custom: isValidCustom2
28184 }
28185 };
28186
28187 // packages/dataviews/build-module/field-types/number.mjs
28188 var import_i18n42 = __toESM(require_i18n(), 1);
28189 var format3 = {
28190 separatorThousand: ",",
28191 separatorDecimal: ".",
28192 decimals: 2
28193 };
28194 function getValueFormatted3({
28195 item,
28196 field
28197 }) {
28198 let value = field.getValue({ item });
28199 if (value === null || value === void 0) {
28200 return "";
28201 }
28202 value = Number(value);
28203 if (!Number.isFinite(value)) {
28204 return String(value);
28205 }
28206 let formatNumber;
28207 if (field.type !== "number") {
28208 formatNumber = format3;
28209 } else {
28210 formatNumber = field.format;
28211 }
28212 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
28213 const fixedValue = value.toFixed(decimals);
28214 const [integerPart, decimalPart] = fixedValue.split(".");
28215 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
28216 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
28217 }
28218 function isEmpty(value) {
28219 return value === "" || value === void 0 || value === null;
28220 }
28221 function isValidCustom3(item, field) {
28222 const value = field.getValue({ item });
28223 if (!isEmpty(value) && !Number.isFinite(value)) {
28224 return (0, import_i18n42.__)("Value must be a number.");
28225 }
28226 return null;
28227 }
28228 var number_default = {
28229 type: "number",
28230 render,
28231 Edit: "number",
28232 sort: sort_number_default,
28233 enableSorting: true,
28234 enableGlobalSearch: false,
28235 defaultOperators: [
28236 OPERATOR_IS,
28237 OPERATOR_IS_NOT,
28238 OPERATOR_LESS_THAN,
28239 OPERATOR_GREATER_THAN,
28240 OPERATOR_LESS_THAN_OR_EQUAL,
28241 OPERATOR_GREATER_THAN_OR_EQUAL,
28242 OPERATOR_BETWEEN
28243 ],
28244 validOperators: [
28245 // Single-selection
28246 OPERATOR_IS,
28247 OPERATOR_IS_NOT,
28248 OPERATOR_LESS_THAN,
28249 OPERATOR_GREATER_THAN,
28250 OPERATOR_LESS_THAN_OR_EQUAL,
28251 OPERATOR_GREATER_THAN_OR_EQUAL,
28252 OPERATOR_BETWEEN,
28253 // Multiple-selection
28254 OPERATOR_IS_ANY,
28255 OPERATOR_IS_NONE,
28256 OPERATOR_IS_ALL,
28257 OPERATOR_IS_NOT_ALL
28258 ],
28259 format: format3,
28260 getValueFormatted: getValueFormatted3,
28261 validate: {
28262 required: isValidRequired,
28263 min: isValidMin,
28264 max: isValidMax,
28265 elements: isValidElements,
28266 custom: isValidCustom3
28267 }
28268 };
28269
28270 // packages/dataviews/build-module/field-types/text.mjs
28271 var text_default = {
28272 type: "text",
28273 render,
28274 Edit: "text",
28275 sort: sort_text_default,
28276 enableSorting: true,
28277 enableGlobalSearch: false,
28278 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
28279 validOperators: [
28280 // Single selection
28281 OPERATOR_IS,
28282 OPERATOR_IS_NOT,
28283 OPERATOR_CONTAINS,
28284 OPERATOR_NOT_CONTAINS,
28285 OPERATOR_STARTS_WITH,
28286 // Multiple selection
28287 OPERATOR_IS_ANY,
28288 OPERATOR_IS_NONE,
28289 OPERATOR_IS_ALL,
28290 OPERATOR_IS_NOT_ALL
28291 ],
28292 format: {},
28293 getValueFormatted: get_value_formatted_default_default,
28294 validate: {
28295 required: isValidRequired,
28296 pattern: isValidPattern,
28297 minLength: isValidMinLength,
28298 maxLength: isValidMaxLength,
28299 elements: isValidElements
28300 }
28301 };
28302
28303 // packages/dataviews/build-module/field-types/datetime.mjs
28304 var import_date7 = __toESM(require_date(), 1);
28305
28306 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
28307 var import_date6 = __toESM(require_date(), 1);
28308 function parseDateLike(value) {
28309 if (!value) {
28310 return null;
28311 }
28312 if (!isValid(new Date(value))) {
28313 return null;
28314 }
28315 const parsed = (0, import_date6.getDate)(value);
28316 return parsed && isValid(parsed) ? parsed : null;
28317 }
28318 function validateDateLikeBoundary(item, field, boundary) {
28319 const constraint = field.isValid[boundary]?.constraint;
28320 if (typeof constraint !== "string") {
28321 return false;
28322 }
28323 const value = field.getValue({ item });
28324 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
28325 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
28326 return true;
28327 }
28328 const parsedConstraint = parseDateLike(constraint);
28329 const parsedValue = parseDateLike(String(boundaryValue));
28330 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
28331 }
28332 function isValidMinDate(item, field) {
28333 return validateDateLikeBoundary(item, field, "min");
28334 }
28335 function isValidMaxDate(item, field) {
28336 return validateDateLikeBoundary(item, field, "max");
28337 }
28338
28339 // packages/dataviews/build-module/field-types/datetime.mjs
28340 var format4 = {
28341 datetime: (0, import_date7.getSettings)().formats.datetime,
28342 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
28343 };
28344 function getValueFormatted4({
28345 item,
28346 field
28347 }) {
28348 const value = field.getValue({ item });
28349 if (["", void 0, null].includes(value)) {
28350 return "";
28351 }
28352 let formatDatetime;
28353 if (field.type !== "datetime") {
28354 formatDatetime = format4;
28355 } else {
28356 formatDatetime = field.format;
28357 }
28358 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
28359 }
28360 var sort = (a2, b2, direction) => {
28361 const timeA = new Date(a2).getTime();
28362 const timeB = new Date(b2).getTime();
28363 return direction === "asc" ? timeA - timeB : timeB - timeA;
28364 };
28365 var datetime_default = {
28366 type: "datetime",
28367 render,
28368 Edit: "datetime",
28369 sort,
28370 enableSorting: true,
28371 enableGlobalSearch: false,
28372 defaultOperators: [
28373 OPERATOR_ON,
28374 OPERATOR_NOT_ON,
28375 OPERATOR_BEFORE,
28376 OPERATOR_AFTER,
28377 OPERATOR_BEFORE_INC,
28378 OPERATOR_AFTER_INC,
28379 OPERATOR_IN_THE_PAST,
28380 OPERATOR_OVER
28381 ],
28382 validOperators: [
28383 OPERATOR_ON,
28384 OPERATOR_NOT_ON,
28385 OPERATOR_BEFORE,
28386 OPERATOR_AFTER,
28387 OPERATOR_BEFORE_INC,
28388 OPERATOR_AFTER_INC,
28389 OPERATOR_IN_THE_PAST,
28390 OPERATOR_OVER
28391 ],
28392 format: format4,
28393 getValueFormatted: getValueFormatted4,
28394 validate: {
28395 required: isValidRequired,
28396 elements: isValidElements,
28397 min: isValidMinDate,
28398 max: isValidMaxDate
28399 }
28400 };
28401
28402 // packages/dataviews/build-module/field-types/date.mjs
28403 var import_date8 = __toESM(require_date(), 1);
28404 var format5 = {
28405 date: (0, import_date8.getSettings)().formats.date,
28406 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
28407 };
28408 function getValueFormatted5({
28409 item,
28410 field
28411 }) {
28412 const value = field.getValue({ item });
28413 if (["", void 0, null].includes(value)) {
28414 return "";
28415 }
28416 let formatDate2;
28417 if (field.type !== "date") {
28418 formatDate2 = format5;
28419 } else {
28420 formatDate2 = field.format;
28421 }
28422 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
28423 }
28424 var sort2 = (a2, b2, direction) => {
28425 const timeA = new Date(a2).getTime();
28426 const timeB = new Date(b2).getTime();
28427 return direction === "asc" ? timeA - timeB : timeB - timeA;
28428 };
28429 var date_default = {
28430 type: "date",
28431 render,
28432 Edit: "date",
28433 sort: sort2,
28434 enableSorting: true,
28435 enableGlobalSearch: false,
28436 defaultOperators: [
28437 OPERATOR_ON,
28438 OPERATOR_NOT_ON,
28439 OPERATOR_BEFORE,
28440 OPERATOR_AFTER,
28441 OPERATOR_BEFORE_INC,
28442 OPERATOR_AFTER_INC,
28443 OPERATOR_IN_THE_PAST,
28444 OPERATOR_OVER,
28445 OPERATOR_BETWEEN
28446 ],
28447 validOperators: [
28448 OPERATOR_ON,
28449 OPERATOR_NOT_ON,
28450 OPERATOR_BEFORE,
28451 OPERATOR_AFTER,
28452 OPERATOR_BEFORE_INC,
28453 OPERATOR_AFTER_INC,
28454 OPERATOR_IN_THE_PAST,
28455 OPERATOR_OVER,
28456 OPERATOR_BETWEEN
28457 ],
28458 format: format5,
28459 getValueFormatted: getValueFormatted5,
28460 validate: {
28461 required: isValidRequired,
28462 elements: isValidElements,
28463 min: isValidMinDate,
28464 max: isValidMaxDate
28465 }
28466 };
28467
28468 // packages/dataviews/build-module/field-types/boolean.mjs
28469 var import_i18n43 = __toESM(require_i18n(), 1);
28470
28471 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
28472 function isValidRequiredForBool(item, field) {
28473 const value = field.getValue({ item });
28474 return value === true;
28475 }
28476
28477 // packages/dataviews/build-module/field-types/boolean.mjs
28478 function getValueFormatted6({
28479 item,
28480 field
28481 }) {
28482 const value = field.getValue({ item });
28483 if (value === true) {
28484 return (0, import_i18n43.__)("True");
28485 }
28486 if (value === false) {
28487 return (0, import_i18n43.__)("False");
28488 }
28489 return "";
28490 }
28491 function isValidCustom4(item, field) {
28492 const value = field.getValue({ item });
28493 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
28494 return (0, import_i18n43.__)("Value must be true, false, or undefined");
28495 }
28496 return null;
28497 }
28498 var sort3 = (a2, b2, direction) => {
28499 const boolA = Boolean(a2);
28500 const boolB = Boolean(b2);
28501 if (boolA === boolB) {
28502 return 0;
28503 }
28504 if (direction === "asc") {
28505 return boolA ? 1 : -1;
28506 }
28507 return boolA ? -1 : 1;
28508 };
28509 var boolean_default = {
28510 type: "boolean",
28511 render,
28512 Edit: "checkbox",
28513 sort: sort3,
28514 validate: {
28515 required: isValidRequiredForBool,
28516 elements: isValidElements,
28517 custom: isValidCustom4
28518 },
28519 enableSorting: true,
28520 enableGlobalSearch: false,
28521 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
28522 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
28523 format: {},
28524 getValueFormatted: getValueFormatted6
28525 };
28526
28527 // packages/dataviews/build-module/field-types/media.mjs
28528 var media_default = {
28529 type: "media",
28530 render: () => null,
28531 Edit: null,
28532 sort: () => 0,
28533 enableSorting: false,
28534 enableGlobalSearch: false,
28535 defaultOperators: [],
28536 validOperators: [],
28537 format: {},
28538 getValueFormatted: get_value_formatted_default_default,
28539 // cannot validate any constraint, so
28540 // the only available validation for the field author
28541 // would be providing a custom validator.
28542 validate: {}
28543 };
28544
28545 // packages/dataviews/build-module/field-types/array.mjs
28546 var import_i18n44 = __toESM(require_i18n(), 1);
28547
28548 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
28549 function isValidRequiredForArray(item, field) {
28550 const value = field.getValue({ item });
28551 return Array.isArray(value) && value.length > 0 && value.every(
28552 (element) => ![void 0, "", null].includes(element)
28553 );
28554 }
28555
28556 // packages/dataviews/build-module/field-types/array.mjs
28557 function getValueFormatted7({
28558 item,
28559 field
28560 }) {
28561 const value = field.getValue({ item });
28562 const arr = Array.isArray(value) ? value : [];
28563 return arr.join(", ");
28564 }
28565 function render2({ item, field }) {
28566 return getValueFormatted7({ item, field });
28567 }
28568 function isValidCustom5(item, field) {
28569 const value = field.getValue({ item });
28570 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
28571 return (0, import_i18n44.__)("Value must be an array.");
28572 }
28573 if (!value.every((v2) => typeof v2 === "string")) {
28574 return (0, import_i18n44.__)("Every value must be a string.");
28575 }
28576 return null;
28577 }
28578 var sort4 = (a2, b2, direction) => {
28579 const arrA = Array.isArray(a2) ? a2 : [];
28580 const arrB = Array.isArray(b2) ? b2 : [];
28581 if (arrA.length !== arrB.length) {
28582 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
28583 }
28584 const joinedA = arrA.join(",");
28585 const joinedB = arrB.join(",");
28586 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
28587 };
28588 var array_default = {
28589 type: "array",
28590 render: render2,
28591 Edit: "array",
28592 sort: sort4,
28593 enableSorting: true,
28594 enableGlobalSearch: false,
28595 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
28596 validOperators: [
28597 OPERATOR_IS_ANY,
28598 OPERATOR_IS_NONE,
28599 OPERATOR_IS_ALL,
28600 OPERATOR_IS_NOT_ALL
28601 ],
28602 format: {},
28603 getValueFormatted: getValueFormatted7,
28604 validate: {
28605 required: isValidRequiredForArray,
28606 elements: isValidElements,
28607 custom: isValidCustom5
28608 }
28609 };
28610
28611 // packages/dataviews/build-module/field-types/password.mjs
28612 function getValueFormatted8({
28613 item,
28614 field
28615 }) {
28616 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
28617 }
28618 var password_default = {
28619 type: "password",
28620 render,
28621 Edit: "password",
28622 sort: () => 0,
28623 // Passwords should not be sortable for security reasons
28624 enableSorting: false,
28625 enableGlobalSearch: false,
28626 defaultOperators: [],
28627 validOperators: [],
28628 format: {},
28629 getValueFormatted: getValueFormatted8,
28630 validate: {
28631 required: isValidRequired,
28632 pattern: isValidPattern,
28633 minLength: isValidMinLength,
28634 maxLength: isValidMaxLength,
28635 elements: isValidElements
28636 }
28637 };
28638
28639 // packages/dataviews/build-module/field-types/telephone.mjs
28640 var telephone_default = {
28641 type: "telephone",
28642 render,
28643 Edit: "telephone",
28644 sort: sort_text_default,
28645 enableSorting: true,
28646 enableGlobalSearch: false,
28647 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
28648 validOperators: [
28649 OPERATOR_IS,
28650 OPERATOR_IS_NOT,
28651 OPERATOR_CONTAINS,
28652 OPERATOR_NOT_CONTAINS,
28653 OPERATOR_STARTS_WITH,
28654 // Multiple selection
28655 OPERATOR_IS_ANY,
28656 OPERATOR_IS_NONE,
28657 OPERATOR_IS_ALL,
28658 OPERATOR_IS_NOT_ALL
28659 ],
28660 format: {},
28661 getValueFormatted: get_value_formatted_default_default,
28662 validate: {
28663 required: isValidRequired,
28664 pattern: isValidPattern,
28665 minLength: isValidMinLength,
28666 maxLength: isValidMaxLength,
28667 elements: isValidElements
28668 }
28669 };
28670
28671 // packages/dataviews/build-module/field-types/color.mjs
28672 var import_i18n45 = __toESM(require_i18n(), 1);
28673 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
28674 function render3({ item, field }) {
28675 if (field.hasElements) {
28676 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(RenderFromElements, { item, field });
28677 }
28678 const value = get_value_formatted_default_default({ item, field });
28679 if (!value || !w(value).isValid()) {
28680 return value;
28681 }
28682 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
28683 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
28684 "div",
28685 {
28686 style: {
28687 width: "16px",
28688 height: "16px",
28689 borderRadius: "50%",
28690 backgroundColor: value,
28691 border: "1px solid #ddd",
28692 flexShrink: 0
28693 }
28694 }
28695 ),
28696 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("span", { children: value })
28697 ] });
28698 }
28699 function isValidCustom6(item, field) {
28700 const value = field.getValue({ item });
28701 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
28702 return (0, import_i18n45.__)("Value must be a valid color.");
28703 }
28704 return null;
28705 }
28706 var sort5 = (a2, b2, direction) => {
28707 const colorA = w(a2);
28708 const colorB = w(b2);
28709 if (!colorA.isValid() && !colorB.isValid()) {
28710 return 0;
28711 }
28712 if (!colorA.isValid()) {
28713 return direction === "asc" ? 1 : -1;
28714 }
28715 if (!colorB.isValid()) {
28716 return direction === "asc" ? -1 : 1;
28717 }
28718 const hslA = colorA.toHsl();
28719 const hslB = colorB.toHsl();
28720 if (hslA.h !== hslB.h) {
28721 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
28722 }
28723 if (hslA.s !== hslB.s) {
28724 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
28725 }
28726 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
28727 };
28728 var color_default = {
28729 type: "color",
28730 render: render3,
28731 Edit: "color",
28732 sort: sort5,
28733 enableSorting: true,
28734 enableGlobalSearch: false,
28735 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
28736 validOperators: [
28737 OPERATOR_IS,
28738 OPERATOR_IS_NOT,
28739 OPERATOR_IS_ANY,
28740 OPERATOR_IS_NONE
28741 ],
28742 format: {},
28743 getValueFormatted: get_value_formatted_default_default,
28744 validate: {
28745 required: isValidRequired,
28746 elements: isValidElements,
28747 custom: isValidCustom6
28748 }
28749 };
28750
28751 // packages/dataviews/build-module/field-types/url.mjs
28752 var url_default = {
28753 type: "url",
28754 render,
28755 Edit: "url",
28756 sort: sort_text_default,
28757 enableSorting: true,
28758 enableGlobalSearch: false,
28759 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
28760 validOperators: [
28761 OPERATOR_IS,
28762 OPERATOR_IS_NOT,
28763 OPERATOR_CONTAINS,
28764 OPERATOR_NOT_CONTAINS,
28765 OPERATOR_STARTS_WITH,
28766 // Multiple selection
28767 OPERATOR_IS_ANY,
28768 OPERATOR_IS_NONE,
28769 OPERATOR_IS_ALL,
28770 OPERATOR_IS_NOT_ALL
28771 ],
28772 format: {},
28773 getValueFormatted: get_value_formatted_default_default,
28774 validate: {
28775 required: isValidRequired,
28776 pattern: isValidPattern,
28777 minLength: isValidMinLength,
28778 maxLength: isValidMaxLength,
28779 elements: isValidElements
28780 }
28781 };
28782
28783 // packages/dataviews/build-module/field-types/no-type.mjs
28784 var sort6 = (a2, b2, direction) => {
28785 if (typeof a2 === "number" && typeof b2 === "number") {
28786 return sort_number_default(a2, b2, direction);
28787 }
28788 return sort_text_default(a2, b2, direction);
28789 };
28790 var no_type_default = {
28791 // type: no type for this one
28792 render,
28793 Edit: null,
28794 sort: sort6,
28795 enableSorting: true,
28796 enableGlobalSearch: false,
28797 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
28798 validOperators: getAllOperatorNames(),
28799 format: {},
28800 getValueFormatted: get_value_formatted_default_default,
28801 validate: {
28802 required: isValidRequired,
28803 elements: isValidElements
28804 }
28805 };
28806
28807 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
28808 function supportsNumericRangeConstraint(type) {
28809 return type === "integer" || type === "number";
28810 }
28811 function supportsDateRangeConstraint(type) {
28812 return type === "date" || type === "datetime";
28813 }
28814 function normalizeRangeRule(value, fieldType, key) {
28815 const validator = fieldType.validate[key];
28816 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
28817 return { constraint: value, validate: validator };
28818 }
28819 return void 0;
28820 }
28821 function getIsValid(field, fieldType) {
28822 const rules = field.isValid;
28823 let required;
28824 if (rules?.required === true && fieldType.validate.required !== void 0) {
28825 required = {
28826 constraint: true,
28827 validate: fieldType.validate.required
28828 };
28829 }
28830 let elements;
28831 if ((rules?.elements === true || // elements is enabled unless the field opts-out
28832 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
28833 elements = {
28834 constraint: true,
28835 validate: fieldType.validate.elements
28836 };
28837 }
28838 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
28839 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
28840 const minLengthValue = rules?.minLength;
28841 let minLength;
28842 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
28843 minLength = {
28844 constraint: minLengthValue,
28845 validate: fieldType.validate.minLength
28846 };
28847 }
28848 const maxLengthValue = rules?.maxLength;
28849 let maxLength;
28850 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
28851 maxLength = {
28852 constraint: maxLengthValue,
28853 validate: fieldType.validate.maxLength
28854 };
28855 }
28856 const patternValue = rules?.pattern;
28857 let pattern;
28858 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
28859 pattern = {
28860 constraint: patternValue,
28861 validate: fieldType.validate.pattern
28862 };
28863 }
28864 const custom = rules?.custom ?? fieldType.validate.custom;
28865 return {
28866 required,
28867 elements,
28868 min: min2,
28869 max: max2,
28870 minLength,
28871 maxLength,
28872 pattern,
28873 custom
28874 };
28875 }
28876
28877 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
28878 function getFilter(fieldType) {
28879 return fieldType.validOperators.reduce((accumulator, operator) => {
28880 const operatorObj = getOperatorByName(operator);
28881 if (operatorObj?.filter) {
28882 accumulator[operator] = operatorObj.filter;
28883 }
28884 return accumulator;
28885 }, {});
28886 }
28887
28888 // packages/dataviews/build-module/field-types/utils/get-format.mjs
28889 function getFormat(field, fieldType) {
28890 return {
28891 ...fieldType.format,
28892 ...field.format
28893 };
28894 }
28895 var get_format_default = getFormat;
28896
28897 // packages/dataviews/build-module/field-types/index.mjs
28898 function getFieldTypeByName(type) {
28899 const found = [
28900 email_default,
28901 integer_default,
28902 number_default,
28903 text_default,
28904 datetime_default,
28905 date_default,
28906 boolean_default,
28907 media_default,
28908 array_default,
28909 password_default,
28910 telephone_default,
28911 color_default,
28912 url_default
28913 ].find((fieldType) => fieldType?.type === type);
28914 if (!!found) {
28915 return found;
28916 }
28917 return no_type_default;
28918 }
28919 function normalizeFields(fields) {
28920 return fields.map((field) => {
28921 const fieldType = getFieldTypeByName(field.type);
28922 const getValue = field.getValue || get_value_from_id_default(field.id);
28923 const sort7 = function(a2, b2, direction) {
28924 const aValue = getValue({ item: a2 });
28925 const bValue = getValue({ item: b2 });
28926 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
28927 };
28928 return {
28929 id: field.id,
28930 label: field.label || field.id,
28931 header: field.header || field.label || field.id,
28932 description: field.description,
28933 placeholder: field.placeholder,
28934 getValue,
28935 setValue: field.setValue || set_value_from_id_default(field.id),
28936 elements: field.elements,
28937 getElements: field.getElements,
28938 hasElements: hasElements(field),
28939 isVisible: field.isVisible,
28940 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
28941 enableHiding: field.enableHiding ?? true,
28942 readOnly: field.readOnly ?? false,
28943 // The type provides defaults for the following props
28944 type: fieldType.type,
28945 render: field.render ?? fieldType.render,
28946 Edit: getControl(field, fieldType.Edit),
28947 sort: sort7,
28948 enableSorting: field.enableSorting ?? fieldType.enableSorting,
28949 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
28950 isValid: getIsValid(field, fieldType),
28951 filterBy: get_filter_by_default(
28952 field,
28953 fieldType.defaultOperators,
28954 fieldType.validOperators
28955 ),
28956 filter: getFilter(fieldType),
28957 format: get_format_default(field, fieldType),
28958 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
28959 };
28960 });
28961 }
28962
28963 // packages/dataviews/build-module/hooks/use-data.mjs
28964 var import_element100 = __toESM(require_element(), 1);
28965 function useData({
28966 view,
28967 data: shownData,
28968 getItemId,
28969 isLoading,
28970 paginationInfo,
28971 selection
28972 }) {
28973 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
28974 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element100.useState)(
28975 !isLoading
28976 );
28977 (0, import_element100.useEffect)(() => {
28978 if (!isLoading) {
28979 setHasInitiallyLoaded(true);
28980 }
28981 }, [isLoading]);
28982 const previousDataRef = (0, import_element100.useRef)(shownData);
28983 const previousPaginationInfoRef = (0, import_element100.useRef)(paginationInfo);
28984 (0, import_element100.useEffect)(() => {
28985 if (!isLoading) {
28986 previousDataRef.current = shownData;
28987 previousPaginationInfoRef.current = paginationInfo;
28988 }
28989 }, [shownData, isLoading, paginationInfo]);
28990 const [visibleEntries, setVisibleEntries] = (0, import_element100.useState)([]);
28991 const positionMapRef = (0, import_element100.useRef)(/* @__PURE__ */ new Map());
28992 const allLoadedRecordsRef = (0, import_element100.useRef)([]);
28993 const prevViewParamsRef = (0, import_element100.useRef)({
28994 search: void 0,
28995 filters: void 0,
28996 perPage: void 0
28997 });
28998 const scrollDirectionRef = (0, import_element100.useRef)(void 0);
28999 const prevStartPositionRef = (0, import_element100.useRef)(void 0);
29000 const hasInitializedRef = (0, import_element100.useRef)(false);
29001 const allLoadedRecords = (0, import_element100.useMemo)(() => {
29002 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
29003 if (view.startPosition < prevStartPositionRef.current) {
29004 scrollDirectionRef.current = "up";
29005 } else if (view.startPosition > prevStartPositionRef.current) {
29006 scrollDirectionRef.current = "down";
29007 }
29008 }
29009 prevStartPositionRef.current = view.startPosition;
29010 const currentFiltersKey = JSON.stringify(view.filters ?? []);
29011 const prevFiltersKey = prevViewParamsRef.current.filters;
29012 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
29013 hasInitializedRef.current = true;
29014 prevViewParamsRef.current = {
29015 search: view.search,
29016 filters: currentFiltersKey,
29017 perPage: view.perPage
29018 };
29019 if (shouldReset) {
29020 positionMapRef.current.clear();
29021 scrollDirectionRef.current = void 0;
29022 const startPosition = view.search ? 1 : view.startPosition ?? 1;
29023 const records = shownData.map((record, index2) => {
29024 const position = startPosition + index2;
29025 positionMapRef.current.set(getItemId(record), position);
29026 return {
29027 ...record,
29028 position
29029 };
29030 });
29031 allLoadedRecordsRef.current = records;
29032 return records;
29033 }
29034 const prev = allLoadedRecordsRef.current;
29035 const shownDataIds = new Set(shownData.map(getItemId));
29036 const scrollDirection = scrollDirectionRef.current;
29037 const basePosition = view.search ? 1 : view.startPosition ?? 1;
29038 const newRecords = shownData.map((record, index2) => {
29039 const itemId = getItemId(record);
29040 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
29041 if (position !== void 0) {
29042 positionMapRef.current.set(itemId, position);
29043 }
29044 return {
29045 ...record,
29046 position
29047 };
29048 });
29049 if (newRecords.length === 0) {
29050 return prev;
29051 }
29052 const prevWithoutDuplicates = prev.filter(
29053 (record) => !shownDataIds.has(getItemId(record))
29054 );
29055 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
29056 allRecords.sort((a2, b2) => {
29057 const posA = a2.position;
29058 const posB = b2.position;
29059 return posA - posB;
29060 });
29061 let result = allRecords;
29062 if (visibleEntries.length > 0) {
29063 const visibleMin = Math.min(...visibleEntries);
29064 const visibleMax = Math.max(...visibleEntries);
29065 const buffer = 20;
29066 const recordPositions = allRecords.map(
29067 (r3) => r3.position
29068 );
29069 const minRecordPos = Math.min(...recordPositions);
29070 const maxRecordPos = Math.max(...recordPositions);
29071 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
29072 if (hasOverlap) {
29073 result = allRecords.filter((record) => {
29074 const itemId = getItemId(record);
29075 const isSelected2 = selection?.includes(itemId);
29076 if (isSelected2) {
29077 return true;
29078 }
29079 const itemPosition = record.position;
29080 if (scrollDirection === "up") {
29081 return itemPosition <= visibleMax + buffer;
29082 } else if (scrollDirection === "down") {
29083 return itemPosition >= visibleMin - buffer;
29084 }
29085 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
29086 });
29087 }
29088 }
29089 allLoadedRecordsRef.current = result;
29090 return result;
29091 }, [
29092 shownData,
29093 view.search,
29094 view.filters,
29095 view.perPage,
29096 view.startPosition,
29097 view.infiniteScrollEnabled,
29098 visibleEntries,
29099 selection,
29100 getItemId
29101 ]);
29102 if (!isInfiniteScrollEnabled) {
29103 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
29104 return {
29105 data: dataToReturn.map((item) => ({
29106 ...item,
29107 position: void 0
29108 })),
29109 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
29110 hasInitiallyLoaded,
29111 setVisibleEntries: void 0
29112 };
29113 }
29114 return {
29115 data: allLoadedRecords,
29116 paginationInfo,
29117 hasInitiallyLoaded,
29118 setVisibleEntries
29119 };
29120 }
29121
29122 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
29123 var import_element101 = __toESM(require_element(), 1);
29124 var import_compose13 = __toESM(require_compose(), 1);
29125 function captureAnchorElement(container, anchorElementRef, direction) {
29126 const containerRect = container.getBoundingClientRect();
29127 const centerY = containerRect.top + containerRect.height / 2;
29128 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
29129 if (items.length === 0) {
29130 return false;
29131 }
29132 const bestAnchor = items.reduce((best, item) => {
29133 const itemRect = item.getBoundingClientRect();
29134 const itemCenterY = itemRect.top + itemRect.height / 2;
29135 const distance = Math.abs(itemCenterY - centerY);
29136 const bestRect = best.getBoundingClientRect();
29137 const bestCenterY = bestRect.top + bestRect.height / 2;
29138 const bestDistance = Math.abs(bestCenterY - centerY);
29139 return distance < bestDistance ? item : best;
29140 });
29141 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
29142 const anchorRect = bestAnchor.getBoundingClientRect();
29143 anchorElementRef.current = {
29144 posinset,
29145 viewportOffset: anchorRect.top - containerRect.top,
29146 scrollTop: container.scrollTop,
29147 direction
29148 };
29149 return true;
29150 }
29151 function useInfiniteScroll({
29152 view,
29153 onChangeView,
29154 isLoading,
29155 paginationInfo,
29156 containerRef,
29157 setVisibleEntries
29158 }) {
29159 const anchorElementRef = (0, import_element101.useRef)(null);
29160 const viewRef = (0, import_element101.useRef)(view);
29161 const isLoadingRef = (0, import_element101.useRef)(isLoading);
29162 const onChangeViewRef = (0, import_element101.useRef)(onChangeView);
29163 const totalItemsRef = (0, import_element101.useRef)(paginationInfo.totalItems);
29164 (0, import_element101.useLayoutEffect)(() => {
29165 viewRef.current = view;
29166 isLoadingRef.current = isLoading;
29167 onChangeViewRef.current = onChangeView;
29168 totalItemsRef.current = paginationInfo.totalItems;
29169 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
29170 const intersectionObserverCallback = (0, import_element101.useCallback)(
29171 (entries) => {
29172 if (!setVisibleEntries) {
29173 return;
29174 }
29175 setVisibleEntries((prev) => {
29176 const newVisibleEntries = new Set(prev);
29177 let hasChanged = false;
29178 entries.forEach((entry) => {
29179 const posInSet = Number(
29180 entry.target?.attributes?.getNamedItem(
29181 "aria-posinset"
29182 )?.value
29183 );
29184 if (isNaN(posInSet)) {
29185 return;
29186 }
29187 if (entry.isIntersecting) {
29188 if (!newVisibleEntries.has(posInSet)) {
29189 newVisibleEntries.add(posInSet);
29190 hasChanged = true;
29191 }
29192 } else if (newVisibleEntries.has(posInSet)) {
29193 newVisibleEntries.delete(posInSet);
29194 hasChanged = true;
29195 }
29196 });
29197 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
29198 });
29199 },
29200 [setVisibleEntries]
29201 );
29202 (0, import_element101.useLayoutEffect)(() => {
29203 const container = containerRef.current;
29204 const anchor = anchorElementRef.current;
29205 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
29206 return;
29207 }
29208 const anchorElement = container.querySelector(
29209 `[aria-posinset="${anchor.posinset}"]`
29210 );
29211 if (anchorElement) {
29212 const containerRect = container.getBoundingClientRect();
29213 const anchorRect = anchorElement.getBoundingClientRect();
29214 const currentOffset = anchorRect.top - containerRect.top;
29215 const scrollAdjustment = currentOffset - anchor.viewportOffset + (container.scrollTop - anchor.scrollTop);
29216 if (Math.abs(scrollAdjustment) > 1) {
29217 container.scrollTop += scrollAdjustment;
29218 }
29219 }
29220 anchorElementRef.current = null;
29221 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
29222 const intersectionObserverRef = (0, import_element101.useRef)(
29223 null
29224 );
29225 (0, import_element101.useEffect)(() => {
29226 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
29227 if (intersectionObserverRef.current) {
29228 intersectionObserverRef.current.disconnect();
29229 intersectionObserverRef.current = null;
29230 }
29231 return;
29232 }
29233 intersectionObserverRef.current = new IntersectionObserver(
29234 intersectionObserverCallback,
29235 { root: null, rootMargin: "0px", threshold: 0.1 }
29236 );
29237 return () => {
29238 if (intersectionObserverRef.current) {
29239 intersectionObserverRef.current.disconnect();
29240 intersectionObserverRef.current = null;
29241 }
29242 };
29243 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
29244 (0, import_element101.useEffect)(() => {
29245 if (!view.infiniteScrollEnabled || !containerRef.current) {
29246 return;
29247 }
29248 let lastScrollTop = 0;
29249 const BOTTOM_THRESHOLD = 600;
29250 const TOP_THRESHOLD = 800;
29251 const handleScroll = (0, import_compose13.throttle)((event) => {
29252 const currentView = viewRef.current;
29253 const totalItems = totalItemsRef.current;
29254 const target = event.target;
29255 const scrollTop = target.scrollTop;
29256 const scrollHeight = target.scrollHeight;
29257 const clientHeight = target.clientHeight;
29258 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
29259 lastScrollTop = scrollTop;
29260 if (isLoadingRef.current) {
29261 return;
29262 }
29263 const currentStartPosition = currentView.startPosition || 1;
29264 const batchSize = currentView.perPage || 10;
29265 const currentEndPosition = Math.min(
29266 currentStartPosition + batchSize,
29267 totalItems
29268 );
29269 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
29270 if (currentEndPosition < totalItems) {
29271 const newStartPosition = currentEndPosition;
29272 captureAnchorElement(target, anchorElementRef, "down");
29273 onChangeViewRef.current({
29274 ...currentView,
29275 startPosition: newStartPosition
29276 });
29277 }
29278 }
29279 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
29280 if (currentStartPosition > 1) {
29281 const calculatedStartPosition = currentStartPosition - batchSize;
29282 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
29283 captureAnchorElement(target, anchorElementRef, "up");
29284 onChangeViewRef.current({
29285 ...currentView,
29286 startPosition: newStartPosition
29287 });
29288 }
29289 }
29290 }, 50);
29291 const container = containerRef.current;
29292 container.addEventListener("scroll", handleScroll);
29293 return () => {
29294 container.removeEventListener("scroll", handleScroll);
29295 handleScroll.cancel();
29296 };
29297 }, [containerRef, view.infiniteScrollEnabled]);
29298 return {
29299 intersectionObserver: intersectionObserverRef.current
29300 };
29301 }
29302
29303 // packages/dataviews/build-module/dataviews/index.mjs
29304 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1);
29305 var defaultGetItemId = (item) => item.id;
29306 var defaultIsItemClickable = () => true;
29307 var EMPTY_ARRAY7 = [];
29308 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
29309 var dataViewsLayouts = VIEW_LAYOUTS.filter(
29310 (viewLayout) => !viewLayout.isPicker
29311 );
29312 function DefaultUI({
29313 header,
29314 search = true,
29315 searchLabel = void 0
29316 }) {
29317 const { view } = (0, import_element102.useContext)(dataviews_context_default);
29318 const isInfiniteScroll = view.infiniteScrollEnabled;
29319 return /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(import_jsx_runtime138.Fragment, { children: [
29320 /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(
29321 Stack,
29322 {
29323 direction: "row",
29324 align: "top",
29325 justify: "space-between",
29326 className: clsx_default("dataviews__view-actions", {
29327 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
29328 }),
29329 gap: "xs",
29330 children: [
29331 /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(
29332 Stack,
29333 {
29334 direction: "row",
29335 justify: "start",
29336 gap: "sm",
29337 className: "dataviews__search",
29338 children: [
29339 search && /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(dataviews_search_default, { label: searchLabel }),
29340 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(toggle_default, {})
29341 ]
29342 }
29343 ),
29344 /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
29345 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(dataviews_view_config_default, {}),
29346 header
29347 ] })
29348 ]
29349 }
29350 ),
29351 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
29352 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(DataViewsLayout, {}),
29353 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(DataViewsFooter, {})
29354 ] });
29355 }
29356 function DataViews({
29357 view,
29358 onChangeView,
29359 fields,
29360 search = true,
29361 searchLabel = void 0,
29362 actions = EMPTY_ARRAY7,
29363 data,
29364 getItemId = defaultGetItemId,
29365 getItemLevel,
29366 isLoading = false,
29367 paginationInfo,
29368 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
29369 selection: selectionProperty,
29370 onChangeSelection,
29371 onClickItem,
29372 renderItemLink,
29373 isItemClickable = defaultIsItemClickable,
29374 header,
29375 children,
29376 config = { perPageSizes: [10, 20, 50, 100] },
29377 empty,
29378 onReset
29379 }) {
29380 const [selectionState, setSelectionState] = (0, import_element102.useState)([]);
29381 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
29382 const selection = isUncontrolled ? selectionState : selectionProperty;
29383 const {
29384 data: displayData,
29385 paginationInfo: displayPaginationInfo,
29386 hasInitiallyLoaded,
29387 setVisibleEntries
29388 } = useData({
29389 view,
29390 data,
29391 getItemId,
29392 isLoading,
29393 selection,
29394 paginationInfo
29395 });
29396 const containerRef = (0, import_element102.useRef)(null);
29397 const [containerWidth, setContainerWidth] = (0, import_element102.useState)(0);
29398 const resizeObserverRef = (0, import_compose14.useResizeObserver)(
29399 (resizeObserverEntries) => {
29400 setContainerWidth(
29401 resizeObserverEntries[0].borderBoxSize[0].inlineSize
29402 );
29403 },
29404 { box: "border-box" }
29405 );
29406 const [openedFilter, setOpenedFilter] = (0, import_element102.useState)(null);
29407 function setSelectionWithChange(value) {
29408 const newValue = typeof value === "function" ? value(selection) : value;
29409 if (isUncontrolled) {
29410 setSelectionState(newValue);
29411 }
29412 if (onChangeSelection) {
29413 onChangeSelection(newValue);
29414 }
29415 }
29416 const _fields = (0, import_element102.useMemo)(() => normalizeFields(fields), [fields]);
29417 const _selection = (0, import_element102.useMemo)(() => {
29418 if (view.infiniteScrollEnabled) {
29419 return selection;
29420 }
29421 return selection.filter(
29422 (id) => data.some((item) => getItemId(item) === id)
29423 );
29424 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
29425 const filters = use_filters_default(_fields, view);
29426 const hasPrimaryOrLockedFilters = (0, import_element102.useMemo)(
29427 () => (filters || []).some(
29428 (filter) => filter.isPrimary || filter.isLocked
29429 ),
29430 [filters]
29431 );
29432 const [isShowingFilter, setIsShowingFilter] = (0, import_element102.useState)(
29433 hasPrimaryOrLockedFilters
29434 );
29435 const { intersectionObserver } = useInfiniteScroll({
29436 view,
29437 onChangeView,
29438 isLoading,
29439 paginationInfo,
29440 containerRef,
29441 setVisibleEntries
29442 });
29443 (0, import_element102.useEffect)(() => {
29444 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
29445 setIsShowingFilter(true);
29446 }
29447 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
29448 const defaultLayouts = (0, import_element102.useMemo)(
29449 () => Object.fromEntries(
29450 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
29451 return dataViewsLayouts.some(
29452 (viewLayout) => viewLayout.type === layoutType
29453 );
29454 }).map(([key, value]) => [
29455 key,
29456 value === true ? {} : value
29457 ])
29458 ),
29459 [defaultLayoutsProperty]
29460 );
29461 if (!defaultLayouts[view.type]) {
29462 return null;
29463 }
29464 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
29465 dataviews_context_default.Provider,
29466 {
29467 value: {
29468 view,
29469 onChangeView,
29470 fields: _fields,
29471 actions,
29472 data: displayData,
29473 isLoading,
29474 paginationInfo: displayPaginationInfo,
29475 selection: _selection,
29476 onChangeSelection: setSelectionWithChange,
29477 openedFilter,
29478 setOpenedFilter,
29479 getItemId,
29480 getItemLevel,
29481 isItemClickable,
29482 onClickItem,
29483 renderItemLink,
29484 containerWidth,
29485 containerRef,
29486 resizeObserverRef,
29487 defaultLayouts,
29488 filters,
29489 isShowingFilter,
29490 setIsShowingFilter,
29491 config,
29492 empty,
29493 hasInitiallyLoaded,
29494 onReset,
29495 intersectionObserver
29496 },
29497 children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
29498 DefaultUI,
29499 {
29500 header,
29501 search,
29502 searchLabel
29503 }
29504 ) })
29505 }
29506 );
29507 }
29508 var DataViewsSubComponents = DataViews;
29509 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
29510 DataViewsSubComponents.Filters = filters_default;
29511 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
29512 DataViewsSubComponents.FiltersToggle = toggle_default;
29513 DataViewsSubComponents.Layout = DataViewsLayout;
29514 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
29515 DataViewsSubComponents.Pagination = DataViewsPagination;
29516 DataViewsSubComponents.Search = dataviews_search_default;
29517 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
29518 DataViewsSubComponents.Footer = DataViewsFooter;
29519 var dataviews_default = DataViewsSubComponents;
29520
29521 // packages/dataviews/build-module/dataform/index.mjs
29522 var import_element114 = __toESM(require_element(), 1);
29523
29524 // packages/dataviews/build-module/components/dataform-context/index.mjs
29525 var import_element103 = __toESM(require_element(), 1);
29526 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1);
29527 var DataFormContext = (0, import_element103.createContext)({
29528 fields: []
29529 });
29530 DataFormContext.displayName = "DataFormContext";
29531 function DataFormProvider({
29532 fields,
29533 children
29534 }) {
29535 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(DataFormContext.Provider, { value: { fields }, children });
29536 }
29537 var dataform_context_default = DataFormContext;
29538
29539 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
29540 var import_element113 = __toESM(require_element(), 1);
29541
29542 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
29543 var import_element104 = __toESM(require_element(), 1);
29544 var import_components47 = __toESM(require_components(), 1);
29545
29546 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
29547 var import_i18n46 = __toESM(require_i18n(), 1);
29548 var DEFAULT_LAYOUT = {
29549 type: "regular",
29550 labelPosition: "top"
29551 };
29552 var normalizeCardSummaryField = (sum) => {
29553 if (typeof sum === "string") {
29554 return [{ id: sum, visibility: "when-collapsed" }];
29555 }
29556 return sum.map((item) => {
29557 if (typeof item === "string") {
29558 return { id: item, visibility: "when-collapsed" };
29559 }
29560 return { id: item.id, visibility: item.visibility };
29561 });
29562 };
29563 function normalizeLayout(layout) {
29564 let normalizedLayout = DEFAULT_LAYOUT;
29565 if (layout?.type === "regular") {
29566 normalizedLayout = {
29567 type: "regular",
29568 labelPosition: layout?.labelPosition ?? "top"
29569 };
29570 } else if (layout?.type === "panel") {
29571 const summary = layout.summary ?? [];
29572 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
29573 const openAs = layout?.openAs;
29574 let normalizedOpenAs;
29575 if (typeof openAs === "object" && openAs.type === "modal") {
29576 normalizedOpenAs = {
29577 type: "modal",
29578 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n46.__)("Apply"),
29579 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n46.__)("Cancel")
29580 };
29581 } else if (openAs === "modal") {
29582 normalizedOpenAs = {
29583 type: "modal",
29584 applyLabel: (0, import_i18n46.__)("Apply"),
29585 cancelLabel: (0, import_i18n46.__)("Cancel")
29586 };
29587 } else {
29588 normalizedOpenAs = { type: "dropdown" };
29589 }
29590 normalizedLayout = {
29591 type: "panel",
29592 labelPosition: layout?.labelPosition ?? "side",
29593 openAs: normalizedOpenAs,
29594 summary: normalizedSummary,
29595 editVisibility: layout?.editVisibility ?? "on-hover"
29596 };
29597 } else if (layout?.type === "card") {
29598 if (layout.withHeader === false) {
29599 normalizedLayout = {
29600 type: "card",
29601 withHeader: false,
29602 isOpened: true,
29603 summary: [],
29604 isCollapsible: false
29605 };
29606 } else {
29607 const summary = layout.summary ?? [];
29608 normalizedLayout = {
29609 type: "card",
29610 withHeader: true,
29611 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
29612 summary: normalizeCardSummaryField(summary),
29613 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
29614 };
29615 }
29616 } else if (layout?.type === "row") {
29617 normalizedLayout = {
29618 type: "row",
29619 alignment: layout?.alignment ?? "center",
29620 styles: layout?.styles ?? {}
29621 };
29622 } else if (layout?.type === "details") {
29623 normalizedLayout = {
29624 type: "details",
29625 summary: layout?.summary ?? ""
29626 };
29627 }
29628 return normalizedLayout;
29629 }
29630 function normalizeForm(form) {
29631 const normalizedFormLayout = normalizeLayout(form?.layout);
29632 const normalizedFields = (form.fields ?? []).map(
29633 (field) => {
29634 if (typeof field === "string") {
29635 return {
29636 id: field,
29637 layout: normalizedFormLayout
29638 };
29639 }
29640 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
29641 return {
29642 id: field.id,
29643 layout: fieldLayout,
29644 ...!!field.label && { label: field.label },
29645 ...!!field.description && {
29646 description: field.description
29647 },
29648 ..."children" in field && Array.isArray(field.children) && {
29649 children: normalizeForm({
29650 fields: field.children,
29651 layout: DEFAULT_LAYOUT
29652 }).fields
29653 }
29654 };
29655 }
29656 );
29657 return {
29658 layout: normalizedFormLayout,
29659 fields: normalizedFields
29660 };
29661 }
29662 var normalize_form_default = normalizeForm;
29663
29664 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
29665 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1);
29666 function Header3({ title }) {
29667 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29668 Stack,
29669 {
29670 direction: "column",
29671 className: "dataforms-layouts-regular__header",
29672 gap: "lg",
29673 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components47.__experimentalHeading, { level: 2, size: 13, children: title }) })
29674 }
29675 );
29676 }
29677 function FormRegularField({
29678 data,
29679 field,
29680 onChange,
29681 hideLabelFromVision,
29682 markWhenOptional,
29683 validity
29684 }) {
29685 const { fields } = (0, import_element104.useContext)(dataform_context_default);
29686 const layout = field.layout;
29687 const form = (0, import_element104.useMemo)(
29688 () => ({
29689 layout: DEFAULT_LAYOUT,
29690 fields: !!field.children ? field.children : []
29691 }),
29692 [field]
29693 );
29694 if (!!field.children) {
29695 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(import_jsx_runtime140.Fragment, { children: [
29696 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(Header3, { title: field.label }),
29697 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29698 DataFormLayout,
29699 {
29700 data,
29701 form,
29702 onChange,
29703 validity: validity?.children
29704 }
29705 )
29706 ] });
29707 }
29708 const labelPosition = layout.labelPosition;
29709 const fieldDefinition = fields.find(
29710 (fieldDef) => fieldDef.id === field.id
29711 );
29712 if (!fieldDefinition || !fieldDefinition.Edit) {
29713 return null;
29714 }
29715 if (labelPosition === "side") {
29716 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
29717 Stack,
29718 {
29719 direction: "row",
29720 className: "dataforms-layouts-regular__field",
29721 gap: "sm",
29722 children: [
29723 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29724 "div",
29725 {
29726 className: clsx_default(
29727 "dataforms-layouts-regular__field-label",
29728 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
29729 ),
29730 children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components47.BaseControl.VisualLabel, { children: fieldDefinition.label })
29731 }
29732 ),
29733 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29734 fieldDefinition.render,
29735 {
29736 item: data,
29737 field: fieldDefinition
29738 }
29739 ) : /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29740 fieldDefinition.Edit,
29741 {
29742 data,
29743 field: fieldDefinition,
29744 onChange,
29745 hideLabelFromVision: true,
29746 markWhenOptional,
29747 validity
29748 },
29749 fieldDefinition.id
29750 ) })
29751 ]
29752 }
29753 );
29754 }
29755 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_jsx_runtime140.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(import_jsx_runtime140.Fragment, { children: [
29756 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components47.BaseControl.VisualLabel, { children: fieldDefinition.label }),
29757 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29758 fieldDefinition.render,
29759 {
29760 item: data,
29761 field: fieldDefinition
29762 }
29763 )
29764 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29765 fieldDefinition.Edit,
29766 {
29767 data,
29768 field: fieldDefinition,
29769 onChange,
29770 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
29771 markWhenOptional,
29772 validity
29773 }
29774 ) });
29775 }
29776
29777 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
29778 var import_deepmerge2 = __toESM(require_cjs(), 1);
29779 var import_components50 = __toESM(require_components(), 1);
29780 var import_element109 = __toESM(require_element(), 1);
29781 var import_compose16 = __toESM(require_compose(), 1);
29782
29783 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
29784 var import_components49 = __toESM(require_components(), 1);
29785 var import_i18n47 = __toESM(require_i18n(), 1);
29786 var import_compose15 = __toESM(require_compose(), 1);
29787 var import_element105 = __toESM(require_element(), 1);
29788
29789 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
29790 function getLabelClassName(labelPosition, showError) {
29791 return clsx_default(
29792 "dataforms-layouts-panel__field-label",
29793 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
29794 { "has-error": showError }
29795 );
29796 }
29797 var get_label_classname_default = getLabelClassName;
29798
29799 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
29800 var import_components48 = __toESM(require_components(), 1);
29801 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1);
29802 function getLabelContent(showError, errorMessage, fieldLabel) {
29803 return showError ? /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(tooltip_exports.Root, { children: [
29804 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
29805 tooltip_exports.Trigger,
29806 {
29807 render: /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
29808 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components48.Icon, { icon: error_default, size: 16 }),
29809 /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(VisuallyHidden, { children: [
29810 errorMessage,
29811 ": "
29812 ] }),
29813 fieldLabel
29814 ] })
29815 }
29816 ),
29817 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(tooltip_exports.Popup, { children: errorMessage })
29818 ] }) : fieldLabel;
29819 }
29820 var get_label_content_default = getLabelContent;
29821
29822 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
29823 function getFirstValidationError(validity) {
29824 if (!validity) {
29825 return void 0;
29826 }
29827 const validityRules = Object.keys(validity).filter(
29828 (key) => key !== "children"
29829 );
29830 for (const key of validityRules) {
29831 const rule = validity[key];
29832 if (rule === void 0) {
29833 continue;
29834 }
29835 if (rule.type === "invalid") {
29836 if (rule.message) {
29837 return rule.message;
29838 }
29839 if (key === "required") {
29840 return "A required field is empty";
29841 }
29842 return "Unidentified validation error";
29843 }
29844 }
29845 if (validity.children) {
29846 for (const childValidity of Object.values(validity.children)) {
29847 const childError = getFirstValidationError(childValidity);
29848 if (childError) {
29849 return childError;
29850 }
29851 }
29852 }
29853 return void 0;
29854 }
29855 var get_first_validation_error_default = getFirstValidationError;
29856
29857 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
29858 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1);
29859 function SummaryButton({
29860 data,
29861 field,
29862 fieldLabel,
29863 summaryFields,
29864 validity,
29865 touched,
29866 disabled: disabled2,
29867 isOpen,
29868 onClick
29869 }) {
29870 const { labelPosition, editVisibility } = field.layout;
29871 const errorMessage = get_first_validation_error_default(validity);
29872 const showError = touched && !!errorMessage;
29873 const labelClassName = get_label_classname_default(labelPosition, showError);
29874 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
29875 const className = clsx_default(
29876 "dataforms-layouts-panel__field-trigger",
29877 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
29878 {
29879 "is-disabled": disabled2,
29880 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
29881 }
29882 );
29883 const controlId = (0, import_compose15.useInstanceId)(
29884 SummaryButton,
29885 "dataforms-layouts-panel__field-control"
29886 );
29887 const ariaLabel = showError ? (0, import_i18n47.sprintf)(
29888 // translators: %s: Field name.
29889 (0, import_i18n47._x)("Edit %s (has errors)", "field"),
29890 fieldLabel || ""
29891 ) : (0, import_i18n47.sprintf)(
29892 // translators: %s: Field name.
29893 (0, import_i18n47._x)("Edit %s", "field"),
29894 fieldLabel || ""
29895 );
29896 const rowRef = (0, import_element105.useRef)(null);
29897 const editButtonRef = (0, import_element105.useRef)(null);
29898 const handleRowClick = (event) => {
29899 if (!isOpen && event.detail < 2 && !editButtonRef.current?.contains(event.target) && rowRef.current?.ownerDocument.defaultView?.getSelection()?.toString()) {
29900 return;
29901 }
29902 onClick();
29903 };
29904 const handleKeyDown = (event) => {
29905 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
29906 event.preventDefault();
29907 onClick();
29908 }
29909 };
29910 return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(
29911 "div",
29912 {
29913 ref: rowRef,
29914 className,
29915 onClick: !disabled2 ? handleRowClick : void 0,
29916 onKeyDown: !disabled2 ? handleKeyDown : void 0,
29917 children: [
29918 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)("span", { className: labelClassName, children: labelContent }),
29919 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(tooltip_exports.Root, { children: [
29920 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
29921 tooltip_exports.Trigger,
29922 {
29923 render: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
29924 "span",
29925 {
29926 className: "dataforms-layouts-panel__field-label-error-content",
29927 role: "img",
29928 "aria-label": errorMessage,
29929 children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components49.Icon, { icon: error_default, size: 16 })
29930 }
29931 )
29932 }
29933 ),
29934 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(tooltip_exports.Popup, { children: errorMessage })
29935 ] }),
29936 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
29937 "span",
29938 {
29939 id: `${controlId}`,
29940 className: "dataforms-layouts-panel__field-control",
29941 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
29942 "span",
29943 {
29944 style: {
29945 display: "flex",
29946 flexDirection: "column",
29947 alignItems: "flex-start",
29948 width: "100%",
29949 gap: "2px"
29950 },
29951 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
29952 "span",
29953 {
29954 style: { width: "100%" },
29955 children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
29956 summaryField.render,
29957 {
29958 item: data,
29959 field: summaryField
29960 }
29961 )
29962 },
29963 summaryField.id
29964 ))
29965 }
29966 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
29967 summaryField.render,
29968 {
29969 item: data,
29970 field: summaryField
29971 },
29972 summaryField.id
29973 ))
29974 }
29975 ),
29976 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
29977 import_components49.Button,
29978 {
29979 ref: editButtonRef,
29980 className: "dataforms-layouts-panel__field-trigger-icon",
29981 label: ariaLabel,
29982 icon: pencil_default,
29983 size: "small",
29984 "aria-expanded": isOpen,
29985 "aria-haspopup": "dialog",
29986 "aria-describedby": `${controlId}`
29987 }
29988 )
29989 ]
29990 }
29991 );
29992 }
29993
29994 // packages/dataviews/build-module/hooks/use-form-validity.mjs
29995 var import_deepmerge = __toESM(require_cjs(), 1);
29996 var import_es62 = __toESM(require_es6(), 1);
29997 var import_element106 = __toESM(require_element(), 1);
29998 var import_i18n48 = __toESM(require_i18n(), 1);
29999 function isFormValid(formValidity) {
30000 if (!formValidity) {
30001 return true;
30002 }
30003 return Object.values(formValidity).every((fieldValidation) => {
30004 return Object.entries(fieldValidation).every(
30005 ([key, validation]) => {
30006 if (key === "children" && validation && typeof validation === "object") {
30007 return isFormValid(validation);
30008 }
30009 return validation.type !== "invalid" && validation.type !== "validating";
30010 }
30011 );
30012 });
30013 }
30014 function getFormFieldsToValidate(form, fields) {
30015 const normalizedForm = normalize_form_default(form);
30016 if (normalizedForm.fields.length === 0) {
30017 return [];
30018 }
30019 const fieldsMap = /* @__PURE__ */ new Map();
30020 fields.forEach((field) => {
30021 fieldsMap.set(field.id, field);
30022 });
30023 function processFormField(formField) {
30024 if ("children" in formField && Array.isArray(formField.children)) {
30025 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
30026 if (processedChildren.length === 0) {
30027 return null;
30028 }
30029 const fieldDef2 = fieldsMap.get(formField.id);
30030 if (fieldDef2) {
30031 const [normalizedField2] = normalizeFields([
30032 fieldDef2
30033 ]);
30034 return {
30035 id: formField.id,
30036 children: processedChildren,
30037 field: normalizedField2
30038 };
30039 }
30040 return {
30041 id: formField.id,
30042 children: processedChildren
30043 };
30044 }
30045 const fieldDef = fieldsMap.get(formField.id);
30046 if (!fieldDef) {
30047 return null;
30048 }
30049 const [normalizedField] = normalizeFields([fieldDef]);
30050 return {
30051 id: formField.id,
30052 children: [],
30053 field: normalizedField
30054 };
30055 }
30056 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
30057 return toValidate;
30058 }
30059 function setValidityAtPath(formValidity, fieldValidity, path) {
30060 if (!formValidity) {
30061 formValidity = {};
30062 }
30063 if (path.length === 0) {
30064 return formValidity;
30065 }
30066 const result = { ...formValidity };
30067 let current = result;
30068 for (let i2 = 0; i2 < path.length - 1; i2++) {
30069 const segment = path[i2];
30070 if (!current[segment]) {
30071 current[segment] = {};
30072 }
30073 current[segment] = { ...current[segment] };
30074 current = current[segment];
30075 }
30076 const finalKey = path[path.length - 1];
30077 current[finalKey] = {
30078 ...current[finalKey] || {},
30079 ...fieldValidity
30080 };
30081 return result;
30082 }
30083 function removeValidationProperty(formValidity, path, property) {
30084 if (!formValidity || path.length === 0) {
30085 return formValidity;
30086 }
30087 const result = { ...formValidity };
30088 let current = result;
30089 for (let i2 = 0; i2 < path.length - 1; i2++) {
30090 const segment = path[i2];
30091 if (!current[segment]) {
30092 return formValidity;
30093 }
30094 current[segment] = { ...current[segment] };
30095 current = current[segment];
30096 }
30097 const finalKey = path[path.length - 1];
30098 if (!current[finalKey]) {
30099 return formValidity;
30100 }
30101 const fieldValidity = { ...current[finalKey] };
30102 delete fieldValidity[property];
30103 if (Object.keys(fieldValidity).length === 0) {
30104 delete current[finalKey];
30105 } else {
30106 current[finalKey] = fieldValidity;
30107 }
30108 if (Object.keys(result).length === 0) {
30109 return void 0;
30110 }
30111 return result;
30112 }
30113 function handleElementsValidationAsync(promise, formField, promiseHandler) {
30114 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
30115 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
30116 elementsCounterRef.current[formField.id] = currentToken;
30117 promise.then((result) => {
30118 if (currentToken !== elementsCounterRef.current[formField.id]) {
30119 return;
30120 }
30121 if (!Array.isArray(result)) {
30122 setFormValidity((prev) => {
30123 const newFormValidity = setValidityAtPath(
30124 prev,
30125 {
30126 elements: {
30127 type: "invalid",
30128 message: (0, import_i18n48.__)("Could not validate elements.")
30129 }
30130 },
30131 [...path, formField.id]
30132 );
30133 return newFormValidity;
30134 });
30135 return;
30136 }
30137 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
30138 ...formField.field,
30139 elements: result
30140 })) {
30141 setFormValidity((prev) => {
30142 const newFormValidity = setValidityAtPath(
30143 prev,
30144 {
30145 elements: {
30146 type: "invalid",
30147 message: (0, import_i18n48.__)(
30148 "Value must be one of the elements."
30149 )
30150 }
30151 },
30152 [...path, formField.id]
30153 );
30154 return newFormValidity;
30155 });
30156 } else {
30157 setFormValidity((prev) => {
30158 return removeValidationProperty(
30159 prev,
30160 [...path, formField.id],
30161 "elements"
30162 );
30163 });
30164 }
30165 }).catch((error2) => {
30166 if (currentToken !== elementsCounterRef.current[formField.id]) {
30167 return;
30168 }
30169 let errorMessage;
30170 if (error2 instanceof Error) {
30171 errorMessage = error2.message;
30172 } else {
30173 errorMessage = String(error2) || (0, import_i18n48.__)(
30174 "Unknown error when running elements validation asynchronously."
30175 );
30176 }
30177 setFormValidity((prev) => {
30178 const newFormValidity = setValidityAtPath(
30179 prev,
30180 {
30181 elements: {
30182 type: "invalid",
30183 message: errorMessage
30184 }
30185 },
30186 [...path, formField.id]
30187 );
30188 return newFormValidity;
30189 });
30190 });
30191 }
30192 function handleCustomValidationAsync(promise, formField, promiseHandler) {
30193 const { customCounterRef, setFormValidity, path } = promiseHandler;
30194 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
30195 customCounterRef.current[formField.id] = currentToken;
30196 promise.then((result) => {
30197 if (currentToken !== customCounterRef.current[formField.id]) {
30198 return;
30199 }
30200 if (result === null) {
30201 setFormValidity((prev) => {
30202 return removeValidationProperty(
30203 prev,
30204 [...path, formField.id],
30205 "custom"
30206 );
30207 });
30208 return;
30209 }
30210 if (typeof result === "string") {
30211 setFormValidity((prev) => {
30212 const newFormValidity = setValidityAtPath(
30213 prev,
30214 {
30215 custom: {
30216 type: "invalid",
30217 message: result
30218 }
30219 },
30220 [...path, formField.id]
30221 );
30222 return newFormValidity;
30223 });
30224 return;
30225 }
30226 setFormValidity((prev) => {
30227 const newFormValidity = setValidityAtPath(
30228 prev,
30229 {
30230 custom: {
30231 type: "invalid",
30232 message: (0, import_i18n48.__)("Validation could not be processed.")
30233 }
30234 },
30235 [...path, formField.id]
30236 );
30237 return newFormValidity;
30238 });
30239 }).catch((error2) => {
30240 if (currentToken !== customCounterRef.current[formField.id]) {
30241 return;
30242 }
30243 let errorMessage;
30244 if (error2 instanceof Error) {
30245 errorMessage = error2.message;
30246 } else {
30247 errorMessage = String(error2) || (0, import_i18n48.__)(
30248 "Unknown error when running custom validation asynchronously."
30249 );
30250 }
30251 setFormValidity((prev) => {
30252 const newFormValidity = setValidityAtPath(
30253 prev,
30254 {
30255 custom: {
30256 type: "invalid",
30257 message: errorMessage
30258 }
30259 },
30260 [...path, formField.id]
30261 );
30262 return newFormValidity;
30263 });
30264 });
30265 }
30266 function validateFormField(item, formField, promiseHandler) {
30267 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
30268 return {
30269 required: { type: "invalid" }
30270 };
30271 }
30272 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
30273 return {
30274 pattern: {
30275 type: "invalid",
30276 message: (0, import_i18n48.__)("Value does not match the required pattern.")
30277 }
30278 };
30279 }
30280 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
30281 return {
30282 min: {
30283 type: "invalid",
30284 message: (0, import_i18n48.__)("Value is below the minimum.")
30285 }
30286 };
30287 }
30288 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
30289 return {
30290 max: {
30291 type: "invalid",
30292 message: (0, import_i18n48.__)("Value is above the maximum.")
30293 }
30294 };
30295 }
30296 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
30297 return {
30298 minLength: {
30299 type: "invalid",
30300 message: (0, import_i18n48.__)("Value is too short.")
30301 }
30302 };
30303 }
30304 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
30305 return {
30306 maxLength: {
30307 type: "invalid",
30308 message: (0, import_i18n48.__)("Value is too long.")
30309 }
30310 };
30311 }
30312 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
30313 return {
30314 elements: {
30315 type: "invalid",
30316 message: (0, import_i18n48.__)("Value must be one of the elements.")
30317 }
30318 };
30319 }
30320 let customError;
30321 if (!!formField.field && formField.field.isValid.custom) {
30322 try {
30323 const value = formField.field.getValue({ item });
30324 customError = formField.field.isValid.custom(
30325 (0, import_deepmerge.default)(
30326 item,
30327 formField.field.setValue({
30328 item,
30329 value
30330 })
30331 ),
30332 formField.field
30333 );
30334 } catch (error2) {
30335 let errorMessage;
30336 if (error2 instanceof Error) {
30337 errorMessage = error2.message;
30338 } else {
30339 errorMessage = String(error2) || (0, import_i18n48.__)("Unknown error when running custom validation.");
30340 }
30341 return {
30342 custom: {
30343 type: "invalid",
30344 message: errorMessage
30345 }
30346 };
30347 }
30348 }
30349 if (typeof customError === "string") {
30350 return {
30351 custom: {
30352 type: "invalid",
30353 message: customError
30354 }
30355 };
30356 }
30357 const fieldValidity = {};
30358 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
30359 handleElementsValidationAsync(
30360 formField.field.getElements(),
30361 formField,
30362 promiseHandler
30363 );
30364 fieldValidity.elements = {
30365 type: "validating",
30366 message: (0, import_i18n48.__)("Validating\u2026")
30367 };
30368 }
30369 if (customError instanceof Promise) {
30370 handleCustomValidationAsync(customError, formField, promiseHandler);
30371 fieldValidity.custom = {
30372 type: "validating",
30373 message: (0, import_i18n48.__)("Validating\u2026")
30374 };
30375 }
30376 if (Object.keys(fieldValidity).length > 0) {
30377 return fieldValidity;
30378 }
30379 if (formField.children.length > 0) {
30380 const result = {};
30381 formField.children.forEach((child) => {
30382 result[child.id] = validateFormField(item, child, {
30383 ...promiseHandler,
30384 path: [...promiseHandler.path, formField.id, "children"]
30385 });
30386 });
30387 const filteredResult = {};
30388 Object.entries(result).forEach(([key, value]) => {
30389 if (value !== void 0) {
30390 filteredResult[key] = value;
30391 }
30392 });
30393 if (Object.keys(filteredResult).length === 0) {
30394 return void 0;
30395 }
30396 return {
30397 children: filteredResult
30398 };
30399 }
30400 return void 0;
30401 }
30402 function getFormFieldValue(formField, item) {
30403 const fieldValue = formField?.field?.getValue({ item });
30404 if (formField.children.length === 0) {
30405 return fieldValue;
30406 }
30407 const childrenValues = formField.children.map(
30408 (child) => getFormFieldValue(child, item)
30409 );
30410 if (!childrenValues) {
30411 return fieldValue;
30412 }
30413 return {
30414 value: fieldValue,
30415 children: childrenValues
30416 };
30417 }
30418 function useFormValidity(item, fields, form) {
30419 const [formValidity, setFormValidity] = (0, import_element106.useState)();
30420 const customCounterRef = (0, import_element106.useRef)({});
30421 const elementsCounterRef = (0, import_element106.useRef)({});
30422 const previousValuesRef = (0, import_element106.useRef)({});
30423 const validate = (0, import_element106.useCallback)(() => {
30424 const promiseHandler = {
30425 customCounterRef,
30426 elementsCounterRef,
30427 setFormValidity,
30428 path: [],
30429 item
30430 };
30431 const formFieldsToValidate = getFormFieldsToValidate(form, fields);
30432 if (formFieldsToValidate.length === 0) {
30433 setFormValidity(void 0);
30434 return;
30435 }
30436 const newFormValidity = {};
30437 const untouchedFields = [];
30438 formFieldsToValidate.forEach((formField) => {
30439 const value = getFormFieldValue(formField, item);
30440 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)(
30441 previousValuesRef.current[formField.id],
30442 value
30443 )) {
30444 untouchedFields.push(formField.id);
30445 return;
30446 }
30447 previousValuesRef.current[formField.id] = value;
30448 const fieldValidity = validateFormField(
30449 item,
30450 formField,
30451 promiseHandler
30452 );
30453 if (fieldValidity !== void 0) {
30454 newFormValidity[formField.id] = fieldValidity;
30455 }
30456 });
30457 setFormValidity((existingFormValidity) => {
30458 let validity = {
30459 ...existingFormValidity,
30460 ...newFormValidity
30461 };
30462 const fieldsToKeep = [
30463 ...untouchedFields,
30464 ...Object.keys(newFormValidity)
30465 ];
30466 Object.keys(validity).forEach((key) => {
30467 if (validity && !fieldsToKeep.includes(key)) {
30468 delete validity[key];
30469 }
30470 });
30471 if (Object.keys(validity).length === 0) {
30472 validity = void 0;
30473 }
30474 const areEqual = (0, import_es62.default)(existingFormValidity, validity);
30475 if (areEqual) {
30476 return existingFormValidity;
30477 }
30478 return validity;
30479 });
30480 }, [item, fields, form]);
30481 (0, import_element106.useEffect)(() => {
30482 validate();
30483 }, [validate]);
30484 return {
30485 validity: formValidity,
30486 isValid: isFormValid(formValidity)
30487 };
30488 }
30489 var use_form_validity_default = useFormValidity;
30490
30491 // packages/dataviews/build-module/hooks/use-report-validity.mjs
30492 var import_element107 = __toESM(require_element(), 1);
30493 function useReportValidity(ref, shouldReport) {
30494 (0, import_element107.useEffect)(() => {
30495 if (shouldReport && ref.current) {
30496 const inputs = ref.current.querySelectorAll(
30497 "input, textarea, select"
30498 );
30499 inputs.forEach((input) => {
30500 input.reportValidity();
30501 });
30502 }
30503 }, [shouldReport, ref]);
30504 }
30505
30506 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
30507 var import_element108 = __toESM(require_element(), 1);
30508
30509 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
30510 function extractSummaryIds(summary) {
30511 if (Array.isArray(summary)) {
30512 return summary.map(
30513 (item) => typeof item === "string" ? item : item.id
30514 );
30515 }
30516 return [];
30517 }
30518 var getSummaryFields = (summaryField, fields) => {
30519 if (Array.isArray(summaryField) && summaryField.length > 0) {
30520 const summaryIds = extractSummaryIds(summaryField);
30521 return summaryIds.map(
30522 (summaryId) => fields.find((_field) => _field.id === summaryId)
30523 ).filter((_field) => _field !== void 0);
30524 }
30525 return [];
30526 };
30527
30528 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
30529 var getFieldDefinition = (field, fields) => {
30530 const fieldDefinition = fields.find((_field) => _field.id === field.id);
30531 if (!fieldDefinition) {
30532 return fields.find((_field) => {
30533 if (!!field.children) {
30534 const simpleChildren = field.children.filter(
30535 (child) => !child.children
30536 );
30537 if (simpleChildren.length === 0) {
30538 return false;
30539 }
30540 return _field.id === simpleChildren[0].id;
30541 }
30542 return _field.id === field.id;
30543 });
30544 }
30545 return fieldDefinition;
30546 };
30547 function useFieldFromFormField(field) {
30548 const { fields } = (0, import_element108.useContext)(dataform_context_default);
30549 const layout = field.layout;
30550 const summaryFields = getSummaryFields(layout.summary, fields);
30551 const fieldDefinition = getFieldDefinition(field, fields);
30552 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
30553 if (summaryFields.length === 0) {
30554 return {
30555 summaryFields: fieldDefinition ? [fieldDefinition] : [],
30556 fieldDefinition,
30557 fieldLabel
30558 };
30559 }
30560 return {
30561 summaryFields,
30562 fieldDefinition,
30563 fieldLabel
30564 };
30565 }
30566 var use_field_from_form_field_default = useFieldFromFormField;
30567
30568 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
30569 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1);
30570 function ModalContent({
30571 data,
30572 field,
30573 onChange,
30574 fieldLabel,
30575 onClose,
30576 touched
30577 }) {
30578 const { openAs } = field.layout;
30579 const { applyLabel, cancelLabel } = openAs;
30580 const { fields } = (0, import_element109.useContext)(dataform_context_default);
30581 const [changes, setChanges] = (0, import_element109.useState)({});
30582 const modalData = (0, import_element109.useMemo)(() => {
30583 return (0, import_deepmerge2.default)(data, changes, {
30584 arrayMerge: (target, source) => source
30585 });
30586 }, [data, changes]);
30587 const form = (0, import_element109.useMemo)(
30588 () => ({
30589 layout: DEFAULT_LAYOUT,
30590 fields: !!field.children ? field.children : (
30591 // If not explicit children return the field id itself.
30592 [{ id: field.id, layout: DEFAULT_LAYOUT }]
30593 )
30594 }),
30595 [field]
30596 );
30597 const fieldsAsFieldType = fields.map((f2) => ({
30598 ...f2,
30599 Edit: f2.Edit === null ? void 0 : f2.Edit,
30600 isValid: {
30601 required: f2.isValid.required?.constraint,
30602 elements: f2.isValid.elements?.constraint,
30603 min: f2.isValid.min?.constraint,
30604 max: f2.isValid.max?.constraint,
30605 pattern: f2.isValid.pattern?.constraint,
30606 minLength: f2.isValid.minLength?.constraint,
30607 maxLength: f2.isValid.maxLength?.constraint
30608 }
30609 }));
30610 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
30611 const onApply = () => {
30612 onChange(changes);
30613 onClose();
30614 };
30615 const handleOnChange = (newValue) => {
30616 setChanges(
30617 (prev) => (0, import_deepmerge2.default)(prev, newValue, {
30618 arrayMerge: (target, source) => source
30619 })
30620 );
30621 };
30622 const focusOnMountRef = (0, import_compose16.useFocusOnMount)("firstInputElement");
30623 const contentRef = (0, import_element109.useRef)(null);
30624 const mergedRef = (0, import_compose16.useMergeRefs)([focusOnMountRef, contentRef]);
30625 useReportValidity(contentRef, touched);
30626 return /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)(
30627 import_components50.Modal,
30628 {
30629 className: "dataforms-layouts-panel__modal",
30630 onRequestClose: onClose,
30631 isFullScreen: false,
30632 title: fieldLabel,
30633 size: "medium",
30634 children: [
30635 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
30636 DataFormLayout,
30637 {
30638 data: modalData,
30639 form,
30640 onChange: handleOnChange,
30641 validity,
30642 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
30643 FieldLayout,
30644 {
30645 data: modalData,
30646 field: childField,
30647 onChange: handleOnChange,
30648 hideLabelFromVision: form.fields.length < 2,
30649 markWhenOptional,
30650 validity: childFieldValidity
30651 },
30652 childField.id
30653 )
30654 }
30655 ) }),
30656 /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)(
30657 Stack,
30658 {
30659 direction: "row",
30660 className: "dataforms-layouts-panel__modal-footer",
30661 gap: "md",
30662 children: [
30663 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_components50.__experimentalSpacer, { style: { flex: 1 } }),
30664 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
30665 import_components50.Button,
30666 {
30667 variant: "tertiary",
30668 onClick: onClose,
30669 __next40pxDefaultSize: true,
30670 children: cancelLabel
30671 }
30672 ),
30673 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
30674 import_components50.Button,
30675 {
30676 variant: "primary",
30677 onClick: onApply,
30678 __next40pxDefaultSize: true,
30679 children: applyLabel
30680 }
30681 )
30682 ]
30683 }
30684 )
30685 ]
30686 }
30687 );
30688 }
30689 function PanelModal({
30690 data,
30691 field,
30692 onChange,
30693 validity
30694 }) {
30695 const [touched, setTouched] = (0, import_element109.useState)(false);
30696 const [isOpen, setIsOpen] = (0, import_element109.useState)(false);
30697 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
30698 if (!fieldDefinition) {
30699 return null;
30700 }
30701 const handleClose = () => {
30702 setIsOpen(false);
30703 setTouched(true);
30704 };
30705 return /* @__PURE__ */ (0, import_jsx_runtime143.jsxs)(import_jsx_runtime143.Fragment, { children: [
30706 /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
30707 SummaryButton,
30708 {
30709 data,
30710 field,
30711 fieldLabel,
30712 summaryFields,
30713 validity,
30714 touched,
30715 disabled: fieldDefinition.readOnly === true,
30716 onClick: () => setIsOpen(true),
30717 isOpen
30718 }
30719 ),
30720 isOpen && /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
30721 ModalContent,
30722 {
30723 data,
30724 field,
30725 onChange,
30726 fieldLabel: fieldLabel ?? "",
30727 onClose: handleClose,
30728 touched
30729 }
30730 )
30731 ] });
30732 }
30733 var modal_default = PanelModal;
30734
30735 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
30736 var import_components51 = __toESM(require_components(), 1);
30737 var import_i18n49 = __toESM(require_i18n(), 1);
30738 var import_element110 = __toESM(require_element(), 1);
30739 var import_compose17 = __toESM(require_compose(), 1);
30740 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1);
30741 function DropdownHeader({
30742 title,
30743 onClose
30744 }) {
30745 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30746 Stack,
30747 {
30748 direction: "column",
30749 className: "dataforms-layouts-panel__dropdown-header",
30750 gap: "lg",
30751 children: /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
30752 title && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components51.__experimentalHeading, { level: 2, size: 13, children: title }),
30753 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components51.__experimentalSpacer, { style: { flex: 1 } }),
30754 onClose && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30755 import_components51.Button,
30756 {
30757 label: (0, import_i18n49.__)("Close"),
30758 icon: close_small_default,
30759 onClick: onClose,
30760 size: "small"
30761 }
30762 )
30763 ] })
30764 }
30765 );
30766 }
30767 function DropdownContentWithValidation({
30768 touched,
30769 children
30770 }) {
30771 const ref = (0, import_element110.useRef)(null);
30772 useReportValidity(ref, touched);
30773 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("div", { ref, children });
30774 }
30775 function PanelDropdown({
30776 data,
30777 field,
30778 onChange,
30779 validity
30780 }) {
30781 const [touched, setTouched] = (0, import_element110.useState)(false);
30782 const [popoverAnchor, setPopoverAnchor] = (0, import_element110.useState)(
30783 null
30784 );
30785 const popoverProps = (0, import_element110.useMemo)(
30786 () => ({
30787 // Anchor the popover to the middle of the entire row so that it doesn't
30788 // move around when the label changes.
30789 anchor: popoverAnchor,
30790 placement: "left-start",
30791 offset: 36,
30792 shift: true
30793 }),
30794 [popoverAnchor]
30795 );
30796 const [dialogRef, dialogProps] = (0, import_compose17.__experimentalUseDialog)({
30797 focusOnMount: "firstInputElement"
30798 });
30799 const form = (0, import_element110.useMemo)(
30800 () => ({
30801 layout: DEFAULT_LAYOUT,
30802 fields: !!field.children ? field.children : (
30803 // If not explicit children return the field id itself.
30804 [{ id: field.id, layout: DEFAULT_LAYOUT }]
30805 )
30806 }),
30807 [field]
30808 );
30809 const formValidity = (0, import_element110.useMemo)(() => {
30810 if (validity === void 0) {
30811 return void 0;
30812 }
30813 if (!!field.children) {
30814 return validity?.children;
30815 }
30816 return { [field.id]: validity };
30817 }, [validity, field]);
30818 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
30819 if (!fieldDefinition) {
30820 return null;
30821 }
30822 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30823 "div",
30824 {
30825 ref: setPopoverAnchor,
30826 className: "dataforms-layouts-panel__field-dropdown-anchor",
30827 children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30828 import_components51.Dropdown,
30829 {
30830 contentClassName: "dataforms-layouts-panel__field-dropdown",
30831 popoverProps,
30832 focusOnMount: false,
30833 onToggle: (willOpen) => {
30834 if (!willOpen) {
30835 setTouched(true);
30836 }
30837 },
30838 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30839 SummaryButton,
30840 {
30841 data,
30842 field,
30843 fieldLabel,
30844 summaryFields,
30845 validity,
30846 touched,
30847 disabled: fieldDefinition.readOnly === true,
30848 isOpen,
30849 onClick: onToggle
30850 }
30851 ),
30852 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
30853 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30854 DropdownHeader,
30855 {
30856 title: fieldLabel,
30857 onClose
30858 }
30859 ),
30860 /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30861 DataFormLayout,
30862 {
30863 data,
30864 form,
30865 onChange,
30866 validity: formValidity,
30867 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30868 FieldLayout,
30869 {
30870 data,
30871 field: childField,
30872 onChange,
30873 hideLabelFromVision: (form?.fields ?? []).length < 2,
30874 markWhenOptional,
30875 validity: childFieldValidity
30876 },
30877 childField.id
30878 )
30879 }
30880 )
30881 ] }) })
30882 }
30883 )
30884 }
30885 );
30886 }
30887 var dropdown_default = PanelDropdown;
30888
30889 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
30890 var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1);
30891 function FormPanelField({
30892 data,
30893 field,
30894 onChange,
30895 validity
30896 }) {
30897 const layout = field.layout;
30898 if (layout.openAs.type === "modal") {
30899 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30900 modal_default,
30901 {
30902 data,
30903 field,
30904 onChange,
30905 validity
30906 }
30907 );
30908 }
30909 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30910 dropdown_default,
30911 {
30912 data,
30913 field,
30914 onChange,
30915 validity
30916 }
30917 );
30918 }
30919
30920 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
30921 var import_element111 = __toESM(require_element(), 1);
30922
30923 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
30924 var import_i18n50 = __toESM(require_i18n(), 1);
30925 var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1);
30926 function countInvalidFields(validity) {
30927 if (!validity) {
30928 return 0;
30929 }
30930 let count = 0;
30931 const validityRules = Object.keys(validity).filter(
30932 (key) => key !== "children"
30933 );
30934 for (const key of validityRules) {
30935 const rule = validity[key];
30936 if (rule?.type === "invalid") {
30937 count++;
30938 }
30939 }
30940 if (validity.children) {
30941 for (const childValidity of Object.values(validity.children)) {
30942 count += countInvalidFields(childValidity);
30943 }
30944 }
30945 return count;
30946 }
30947 function ValidationBadge({
30948 validity
30949 }) {
30950 const invalidCount = countInvalidFields(validity);
30951 if (invalidCount === 0) {
30952 return null;
30953 }
30954 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(Badge, { intent: "high", children: (0, import_i18n50.sprintf)(
30955 /* translators: %d: Number of fields that need attention */
30956 (0, import_i18n50._n)(
30957 "%d field needs attention",
30958 "%d fields need attention",
30959 invalidCount
30960 ),
30961 invalidCount
30962 ) });
30963 }
30964
30965 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
30966 var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1);
30967 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
30968 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
30969 return false;
30970 }
30971 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
30972 const fieldConfig = summaryConfigArray.find((config) => {
30973 if (typeof config === "string") {
30974 return config === summaryField.id;
30975 }
30976 if (typeof config === "object" && "id" in config) {
30977 return config.id === summaryField.id;
30978 }
30979 return false;
30980 });
30981 if (!fieldConfig) {
30982 return false;
30983 }
30984 if (typeof fieldConfig === "string") {
30985 return true;
30986 }
30987 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
30988 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
30989 }
30990 return true;
30991 }
30992 function HeaderContent({
30993 data,
30994 fields,
30995 label,
30996 layout,
30997 isOpen,
30998 touched,
30999 validity
31000 }) {
31001 const summaryFields = getSummaryFields(layout.summary, fields);
31002 const visibleSummaryFields = summaryFields.filter(
31003 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
31004 );
31005 const hasBadge = touched && layout.isCollapsible;
31006 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader;
31007 return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(
31008 Stack,
31009 {
31010 align: "center",
31011 justify: "space-between",
31012 className: "dataforms-layouts-card__field-header-content",
31013 children: [
31014 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(card_exports.Title, { children: label }),
31015 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [
31016 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(ValidationBadge, { validity }),
31017 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
31018 summaryField.render,
31019 {
31020 item: data,
31021 field: summaryField
31022 },
31023 summaryField.id
31024 )) })
31025 ] })
31026 ]
31027 }
31028 );
31029 }
31030 function BodyContent({
31031 data,
31032 field,
31033 form,
31034 onChange,
31035 hideLabelFromVision,
31036 markWhenOptional,
31037 validity,
31038 withHeader
31039 }) {
31040 if (field.children) {
31041 return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(import_jsx_runtime147.Fragment, { children: [
31042 field.description && /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
31043 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
31044 DataFormLayout,
31045 {
31046 data,
31047 form,
31048 onChange,
31049 validity: validity?.children
31050 }
31051 )
31052 ] });
31053 }
31054 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
31055 if (!SingleFieldLayout) {
31056 return null;
31057 }
31058 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
31059 SingleFieldLayout,
31060 {
31061 data,
31062 field,
31063 onChange,
31064 hideLabelFromVision: hideLabelFromVision || withHeader,
31065 markWhenOptional,
31066 validity
31067 }
31068 );
31069 }
31070 function FormCardField({
31071 data,
31072 field,
31073 onChange,
31074 hideLabelFromVision,
31075 markWhenOptional,
31076 validity
31077 }) {
31078 const { fields } = (0, import_element111.useContext)(dataform_context_default);
31079 const layout = field.layout;
31080 const contentRef = (0, import_element111.useRef)(null);
31081 const form = (0, import_element111.useMemo)(
31082 () => ({
31083 layout: DEFAULT_LAYOUT,
31084 fields: field.children ?? []
31085 }),
31086 [field]
31087 );
31088 const { isOpened, isCollapsible } = layout;
31089 const [isOpen, setIsOpen] = (0, import_element111.useState)(isOpened);
31090 const [touched, setTouched] = (0, import_element111.useState)(false);
31091 (0, import_element111.useEffect)(() => {
31092 setIsOpen(isOpened);
31093 }, [isOpened]);
31094 const handleOpenChange = (0, import_element111.useCallback)((open) => {
31095 if (!open) {
31096 setTouched(true);
31097 }
31098 setIsOpen(open);
31099 }, []);
31100 const handleBlur = (0, import_element111.useCallback)(() => {
31101 setTouched(true);
31102 }, []);
31103 useReportValidity(
31104 contentRef,
31105 (isCollapsible ? isOpen : true) && touched
31106 );
31107 let label = field.label;
31108 let withHeader;
31109 if (field.children) {
31110 withHeader = !!label && layout.withHeader;
31111 } else {
31112 const fieldDefinition = fields.find(
31113 (fieldDef) => fieldDef.id === field.id
31114 );
31115 if (!fieldDefinition || !fieldDefinition.Edit) {
31116 return null;
31117 }
31118 label = fieldDefinition.label;
31119 withHeader = !!label && layout.withHeader;
31120 }
31121 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
31122 BodyContent,
31123 {
31124 data,
31125 field,
31126 form,
31127 onChange,
31128 hideLabelFromVision,
31129 markWhenOptional,
31130 validity,
31131 withHeader
31132 }
31133 );
31134 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
31135 HeaderContent,
31136 {
31137 data,
31138 fields,
31139 label,
31140 layout,
31141 isOpen: isCollapsible ? !!isOpen : true,
31142 touched,
31143 validity
31144 }
31145 );
31146 if (withHeader && isCollapsible) {
31147 return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(
31148 collapsible_card_exports.Root,
31149 {
31150 className: "dataforms-layouts-card__field",
31151 open: isOpen,
31152 onOpenChange: handleOpenChange,
31153 children: [
31154 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(collapsible_card_exports.Header, { children: headerContent }),
31155 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
31156 collapsible_card_exports.Content,
31157 {
31158 ref: contentRef,
31159 onBlur: handleBlur,
31160 children: bodyContent
31161 }
31162 )
31163 ]
31164 }
31165 );
31166 }
31167 return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [
31168 withHeader && /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(card_exports.Header, { children: headerContent }),
31169 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent })
31170 ] });
31171 }
31172
31173 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
31174 var import_components52 = __toESM(require_components(), 1);
31175 var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1);
31176 function Header4({ title }) {
31177 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
31178 Stack,
31179 {
31180 direction: "column",
31181 className: "dataforms-layouts-row__header",
31182 gap: "lg",
31183 children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(import_components52.__experimentalHeading, { level: 2, size: 13, children: title }) })
31184 }
31185 );
31186 }
31187 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(import_jsx_runtime148.Fragment, { children });
31188 function FormRowField({
31189 data,
31190 field,
31191 onChange,
31192 hideLabelFromVision,
31193 markWhenOptional,
31194 validity
31195 }) {
31196 const layout = field.layout;
31197 if (!!field.children) {
31198 const form = {
31199 layout: DEFAULT_LAYOUT,
31200 fields: field.children
31201 };
31202 return /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
31203 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Header4, { title: field.label }),
31204 /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
31205 DataFormLayout,
31206 {
31207 data,
31208 form,
31209 onChange,
31210 validity: validity?.children,
31211 as: EMPTY_WRAPPER,
31212 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
31213 "div",
31214 {
31215 className: "dataforms-layouts-row__field-control",
31216 style: layout.styles[childField.id],
31217 children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
31218 FieldLayout,
31219 {
31220 data,
31221 field: childField,
31222 onChange,
31223 hideLabelFromVision,
31224 markWhenOptional,
31225 validity: childFieldValidity
31226 }
31227 )
31228 },
31229 childField.id
31230 )
31231 }
31232 ) })
31233 ] });
31234 }
31235 const RegularLayout = getFormFieldLayout("regular")?.component;
31236 if (!RegularLayout) {
31237 return null;
31238 }
31239 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(import_jsx_runtime148.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
31240 RegularLayout,
31241 {
31242 data,
31243 field,
31244 onChange,
31245 markWhenOptional,
31246 validity
31247 }
31248 ) }) });
31249 }
31250
31251 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
31252 var import_element112 = __toESM(require_element(), 1);
31253 var import_i18n51 = __toESM(require_i18n(), 1);
31254 var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1);
31255 function FormDetailsField({
31256 data,
31257 field,
31258 onChange,
31259 validity
31260 }) {
31261 const { fields } = (0, import_element112.useContext)(dataform_context_default);
31262 const detailsRef = (0, import_element112.useRef)(null);
31263 const contentRef = (0, import_element112.useRef)(null);
31264 const [touched, setTouched] = (0, import_element112.useState)(false);
31265 const [isOpen, setIsOpen] = (0, import_element112.useState)(false);
31266 const form = (0, import_element112.useMemo)(
31267 () => ({
31268 layout: DEFAULT_LAYOUT,
31269 fields: field.children ?? []
31270 }),
31271 [field]
31272 );
31273 (0, import_element112.useEffect)(() => {
31274 const details = detailsRef.current;
31275 if (!details) {
31276 return;
31277 }
31278 const handleToggle = () => {
31279 const nowOpen = details.open;
31280 if (!nowOpen) {
31281 setTouched(true);
31282 }
31283 setIsOpen(nowOpen);
31284 };
31285 details.addEventListener("toggle", handleToggle);
31286 return () => {
31287 details.removeEventListener("toggle", handleToggle);
31288 };
31289 }, []);
31290 useReportValidity(contentRef, isOpen && touched);
31291 const handleBlur = (0, import_element112.useCallback)(() => {
31292 setTouched(true);
31293 }, []);
31294 if (!field.children) {
31295 return null;
31296 }
31297 const summaryFieldId = field.layout.summary ?? "";
31298 const summaryField = summaryFieldId ? fields.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
31299 let summaryContent;
31300 if (summaryField && summaryField.render) {
31301 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(summaryField.render, { item: data, field: summaryField });
31302 } else {
31303 summaryContent = field.label || (0, import_i18n51.__)("More details");
31304 }
31305 return /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)(
31306 "details",
31307 {
31308 ref: detailsRef,
31309 className: "dataforms-layouts-details__details",
31310 children: [
31311 /* @__PURE__ */ (0, import_jsx_runtime149.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime149.jsxs)(
31312 Stack,
31313 {
31314 direction: "row",
31315 align: "center",
31316 gap: "md",
31317 className: "dataforms-layouts-details__summary-content",
31318 children: [
31319 summaryContent,
31320 touched && /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(ValidationBadge, { validity })
31321 ]
31322 }
31323 ) }),
31324 /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
31325 "div",
31326 {
31327 ref: contentRef,
31328 className: "dataforms-layouts-details__content",
31329 onBlur: handleBlur,
31330 children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
31331 DataFormLayout,
31332 {
31333 data,
31334 form,
31335 onChange,
31336 validity: validity?.children
31337 }
31338 )
31339 }
31340 )
31341 ]
31342 }
31343 );
31344 }
31345
31346 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
31347 var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1);
31348 var FORM_FIELD_LAYOUTS = [
31349 {
31350 type: "regular",
31351 component: FormRegularField,
31352 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
31353 Stack,
31354 {
31355 direction: "column",
31356 className: "dataforms-layouts__wrapper",
31357 gap: "lg",
31358 children
31359 }
31360 )
31361 },
31362 {
31363 type: "panel",
31364 component: FormPanelField,
31365 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
31366 Stack,
31367 {
31368 direction: "column",
31369 className: "dataforms-layouts__wrapper",
31370 gap: "md",
31371 children
31372 }
31373 )
31374 },
31375 {
31376 type: "card",
31377 component: FormCardField,
31378 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
31379 Stack,
31380 {
31381 direction: "column",
31382 className: "dataforms-layouts__wrapper",
31383 gap: "xl",
31384 children
31385 }
31386 )
31387 },
31388 {
31389 type: "row",
31390 component: FormRowField,
31391 wrapper: ({
31392 children,
31393 layout
31394 }) => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
31395 Stack,
31396 {
31397 direction: "column",
31398 className: "dataforms-layouts__wrapper",
31399 gap: "lg",
31400 children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
31401 Stack,
31402 {
31403 direction: "row",
31404 gap: "lg",
31405 align: layout.alignment,
31406 children
31407 }
31408 ) })
31409 }
31410 )
31411 },
31412 {
31413 type: "details",
31414 component: FormDetailsField
31415 }
31416 ];
31417 function getFormFieldLayout(type) {
31418 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
31419 }
31420
31421 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
31422 var import_jsx_runtime151 = __toESM(require_jsx_runtime(), 1);
31423 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
31424 function DataFormLayout({
31425 data,
31426 form,
31427 onChange,
31428 validity,
31429 children,
31430 as
31431 }) {
31432 const { fields: fieldDefinitions } = (0, import_element113.useContext)(dataform_context_default);
31433 const markWhenOptional = (0, import_element113.useMemo)(() => {
31434 const requiredCount = fieldDefinitions.filter(
31435 (f2) => !!f2.isValid?.required
31436 ).length;
31437 const optionalCount = fieldDefinitions.length - requiredCount;
31438 return requiredCount > optionalCount;
31439 }, [fieldDefinitions]);
31440 function getFieldDefinition2(field) {
31441 return fieldDefinitions.find(
31442 (fieldDefinition) => fieldDefinition.id === field.id
31443 );
31444 }
31445 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
31446 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
31447 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
31448 if (!FieldLayout) {
31449 return null;
31450 }
31451 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
31452 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
31453 return null;
31454 }
31455 if (children) {
31456 return children(
31457 FieldLayout,
31458 formField,
31459 validity?.[formField.id],
31460 markWhenOptional
31461 );
31462 }
31463 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
31464 FieldLayout,
31465 {
31466 data,
31467 field: formField,
31468 onChange,
31469 markWhenOptional,
31470 validity: validity?.[formField.id]
31471 },
31472 formField.id
31473 );
31474 }) });
31475 }
31476
31477 // packages/dataviews/build-module/dataform/index.mjs
31478 var import_jsx_runtime152 = __toESM(require_jsx_runtime(), 1);
31479 function DataForm({
31480 data,
31481 form,
31482 fields,
31483 onChange,
31484 validity
31485 }) {
31486 const normalizedForm = (0, import_element114.useMemo)(() => normalize_form_default(form), [form]);
31487 const normalizedFields = (0, import_element114.useMemo)(
31488 () => normalizeFields(fields),
31489 [fields]
31490 );
31491 if (!form.fields) {
31492 return null;
31493 }
31494 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
31495 DataFormLayout,
31496 {
31497 data,
31498 form: normalizedForm,
31499 onChange,
31500 validity
31501 }
31502 ) });
31503 }
31504
31505 // widgets/quick-draft/render.tsx
31506 var import_element119 = __toESM(require_element());
31507 var import_escape_html = __toESM(require_escape_html());
31508 var import_i18n54 = __toESM(require_i18n());
31509
31510 // widgets/quick-draft/components/drafts-list/drafts-list.tsx
31511 var import_core_data = __toESM(require_core_data());
31512 var import_data6 = __toESM(require_data());
31513 var import_date10 = __toESM(require_date());
31514 var import_element115 = __toESM(require_element());
31515 var import_html_entities = __toESM(require_html_entities());
31516 var import_i18n52 = __toESM(require_i18n());
31517 var import_url3 = __toESM(require_url());
31518
31519 // packages/style-runtime/src/index.ts
31520 var STYLE_HASH_ATTRIBUTE24 = "data-wp-hash";
31521 function getRuntime24() {
31522 const globalScope = globalThis;
31523 if (globalScope.__wpStyleRuntime) {
31524 return globalScope.__wpStyleRuntime;
31525 }
31526 globalScope.__wpStyleRuntime = {
31527 documents: /* @__PURE__ */ new Map(),
31528 styles: /* @__PURE__ */ new Map(),
31529 injectedStyles: /* @__PURE__ */ new WeakMap()
31530 };
31531 if (typeof document !== "undefined") {
31532 registerDocument24(document);
31533 }
31534 return globalScope.__wpStyleRuntime;
31535 }
31536 function documentContainsStyleHash24(targetDocument, hash) {
31537 if (!targetDocument.head) {
31538 return false;
31539 }
31540 for (const style of targetDocument.head.querySelectorAll(
31541 `style[${STYLE_HASH_ATTRIBUTE24}]`
31542 )) {
31543 if (style.getAttribute(STYLE_HASH_ATTRIBUTE24) === hash) {
31544 return true;
31545 }
31546 }
31547 return false;
31548 }
31549 function injectStyle24(targetDocument, hash, css) {
31550 if (!targetDocument.head) {
31551 return;
31552 }
31553 const runtime = getRuntime24();
31554 let injectedStyles = runtime.injectedStyles.get(targetDocument);
31555 if (!injectedStyles) {
31556 injectedStyles = /* @__PURE__ */ new Set();
31557 runtime.injectedStyles.set(targetDocument, injectedStyles);
31558 }
31559 if (injectedStyles.has(hash)) {
31560 return;
31561 }
31562 if (documentContainsStyleHash24(targetDocument, hash)) {
31563 injectedStyles.add(hash);
31564 return;
31565 }
31566 const style = targetDocument.createElement("style");
31567 style.setAttribute(STYLE_HASH_ATTRIBUTE24, hash);
31568 style.appendChild(targetDocument.createTextNode(css));
31569 targetDocument.head.appendChild(style);
31570 injectedStyles.add(hash);
31571 }
31572 function registerDocument24(targetDocument) {
31573 const runtime = getRuntime24();
31574 runtime.documents.set(
31575 targetDocument,
31576 (runtime.documents.get(targetDocument) ?? 0) + 1
31577 );
31578 for (const [hash, css] of runtime.styles) {
31579 injectStyle24(targetDocument, hash, css);
31580 }
31581 return () => {
31582 const count = runtime.documents.get(targetDocument);
31583 if (count === void 0) {
31584 return;
31585 }
31586 if (count <= 1) {
31587 runtime.documents.delete(targetDocument);
31588 return;
31589 }
31590 runtime.documents.set(targetDocument, count - 1);
31591 };
31592 }
31593 function registerStyle24(hash, css) {
31594 const runtime = getRuntime24();
31595 runtime.styles.set(hash, css);
31596 for (const targetDocument of runtime.documents.keys()) {
31597 injectStyle24(targetDocument, hash, css);
31598 }
31599 }
31600
31601 // widgets/quick-draft/components/drafts-list/drafts-list.module.css
31602 if (typeof process === "undefined" || true) {
31603 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)}");
31604 }
31605 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" };
31606
31607 // widgets/quick-draft/components/drafts-list/drafts-list.tsx
31608 var import_jsx_runtime153 = __toESM(require_jsx_runtime());
31609 var DRAFTS_QUERY = {
31610 status: "draft",
31611 orderby: "date",
31612 order: "desc",
31613 per_page: 20,
31614 _embed: "wp:featuredmedia"
31615 };
31616 var DEFAULT_LAYOUTS2 = { list: {} };
31617 var INITIAL_VIEW = {
31618 type: "list",
31619 page: 1,
31620 perPage: DRAFTS_QUERY.per_page,
31621 search: "",
31622 filters: [],
31623 fields: [],
31624 titleField: "title",
31625 descriptionField: "date",
31626 mediaField: "featured",
31627 showMedia: true,
31628 layout: { density: "compact" }
31629 };
31630 function getEditUrl(postId) {
31631 return (0, import_url3.addQueryArgs)("post.php", { post: postId, action: "edit" });
31632 }
31633 function getThumbnailUrl(post) {
31634 const media = post._embedded?.["wp:featuredmedia"]?.[0];
31635 const sizes = media?.media_details?.sizes;
31636 return sizes?.thumbnail?.source_url ?? sizes?.medium?.source_url ?? media?.source_url;
31637 }
31638 function DraftThumbnail({ post }) {
31639 const url = getThumbnailUrl(post);
31640 if (url) {
31641 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31642 "img",
31643 {
31644 className: drafts_list_default.thumbImage,
31645 src: url,
31646 alt: "",
31647 loading: "lazy"
31648 }
31649 );
31650 }
31651 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("div", { className: drafts_list_default.thumbPlaceholder, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Icon, { icon: post_featured_image_default }) });
31652 }
31653 function DraftTitle({
31654 post,
31655 onDelete
31656 }) {
31657 const title = (0, import_html_entities.decodeEntities)(post.title?.rendered ?? "") || (0, import_i18n52.__)("(no title)");
31658 return /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
31659 Stack,
31660 {
31661 direction: "row",
31662 align: "center",
31663 justify: "space-between",
31664 gap: "sm",
31665 className: drafts_list_default.titleRow,
31666 children: [
31667 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31668 Link,
31669 {
31670 href: getEditUrl(post.id),
31671 openInNewTab: true,
31672 className: drafts_list_default.titleLink,
31673 children: title
31674 }
31675 ),
31676 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31677 IconButton,
31678 {
31679 icon: trash_default,
31680 label: (0, import_i18n52.__)("Delete draft"),
31681 variant: "minimal",
31682 size: "small",
31683 onClick: () => onDelete(post.id)
31684 }
31685 )
31686 ]
31687 }
31688 );
31689 }
31690 function DraftDate({ post }) {
31691 const fullDate = (0, import_date10.dateI18n)((0, import_date10.getSettings)().formats.datetime, post.date);
31692 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31693 Text,
31694 {
31695 variant: "body-sm",
31696 className: drafts_list_default.date,
31697 render: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("span", { title: fullDate }),
31698 children: (0, import_date10.humanTimeDiff)(post.date)
31699 }
31700 );
31701 }
31702 function DraftsList() {
31703 const [view, setView] = (0, import_element115.useState)(INITIAL_VIEW);
31704 const { drafts, isLoading } = (0, import_data6.useSelect)((select) => {
31705 const { getEntityRecords, hasFinishedResolution } = select(import_core_data.store);
31706 const records = getEntityRecords("postType", "post", DRAFTS_QUERY);
31707 return {
31708 drafts: records ?? [],
31709 isLoading: !hasFinishedResolution("getEntityRecords", [
31710 "postType",
31711 "post",
31712 DRAFTS_QUERY
31713 ])
31714 };
31715 }, []);
31716 const { deleteEntityRecord } = (0, import_data6.useDispatch)(import_core_data.store);
31717 const deleteDraft = (0, import_element115.useCallback)(
31718 (id) => {
31719 void deleteEntityRecord("postType", "post", id, void 0);
31720 },
31721 [deleteEntityRecord]
31722 );
31723 const fields = (0, import_element115.useMemo)(
31724 () => [
31725 {
31726 id: "title",
31727 label: (0, import_i18n52.__)("Title"),
31728 enableSorting: false,
31729 enableHiding: false,
31730 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(DraftTitle, { post: item, onDelete: deleteDraft })
31731 },
31732 {
31733 id: "date",
31734 label: (0, import_i18n52.__)("Date"),
31735 enableSorting: false,
31736 enableHiding: false,
31737 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(DraftDate, { post: item })
31738 },
31739 {
31740 id: "featured",
31741 label: (0, import_i18n52.__)("Featured image"),
31742 enableSorting: false,
31743 enableHiding: false,
31744 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(DraftThumbnail, { post: item })
31745 }
31746 ],
31747 [deleteDraft]
31748 );
31749 return /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(Stack, { direction: "column", className: drafts_list_default.root, children: [
31750 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Text, { variant: "heading-md", className: drafts_list_default.titleHeader, children: (0, import_i18n52.__)("Your recent drafts") }),
31751 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
31752 dataviews_default,
31753 {
31754 data: drafts,
31755 fields,
31756 view,
31757 onChangeView: setView,
31758 getItemId: (item) => String(item.id),
31759 isLoading,
31760 paginationInfo: { totalItems: drafts.length, totalPages: 1 },
31761 defaultLayouts: DEFAULT_LAYOUTS2,
31762 empty: /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(empty_state_exports.Root, { children: [
31763 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(empty_state_exports.Icon, { icon: drafts_default }),
31764 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(empty_state_exports.Description, { children: (0, import_i18n52.__)("No drafts yet.") })
31765 ] }),
31766 children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(dataviews_default.Layout, {})
31767 }
31768 )
31769 ] });
31770 }
31771
31772 // widgets/quick-draft/components/saved-post/saved-post.tsx
31773 var import_element116 = __toESM(require_element());
31774 var import_i18n53 = __toESM(require_i18n());
31775 var import_url4 = __toESM(require_url());
31776
31777 // widgets/quick-draft/components/saved-post/saved-post.module.css
31778 if (typeof process === "undefined" || true) {
31779 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)}");
31780 }
31781 var saved_post_default = { "body": "_88880a636bc02513__body", "icon": "_20963e427e9696da__icon", "continueLink": "ff3d1c6f8ba60167__continueLink" };
31782
31783 // widgets/quick-draft/components/saved-post/saved-post.tsx
31784 var import_jsx_runtime154 = __toESM(require_jsx_runtime());
31785 function SavedPost({
31786 postId,
31787 postTitle,
31788 onWriteAnother
31789 }) {
31790 const editUrl = (0, import_url4.addQueryArgs)("post.php", {
31791 post: postId,
31792 action: "edit"
31793 });
31794 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
31795 Stack,
31796 {
31797 direction: "column",
31798 align: "center",
31799 justify: "center",
31800 className: saved_post_default.body,
31801 children: /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(empty_state_exports.Root, { children: [
31802 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(empty_state_exports.Icon, { icon: check_default, className: saved_post_default.icon }),
31803 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(empty_state_exports.Title, { children: (0, import_i18n53.__)("Draft saved") }),
31804 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(empty_state_exports.Description, { children: (0, import_element116.createInterpolateElement)(
31805 (0, import_i18n53.sprintf)(
31806 /* translators: %s: post title */
31807 (0, import_i18n53.__)(
31808 '<strong>"%s"</strong> is ready to keep editing.'
31809 ),
31810 postTitle
31811 ),
31812 {
31813 strong: /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("strong", {})
31814 }
31815 ) }),
31816 /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(empty_state_exports.Actions, { children: [
31817 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
31818 Button4,
31819 {
31820 variant: "solid",
31821 size: "compact",
31822 nativeButton: false,
31823 render: /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
31824 Link,
31825 {
31826 href: editUrl,
31827 openInNewTab: true,
31828 className: saved_post_default.continueLink
31829 }
31830 ),
31831 children: (0, import_i18n53.__)("Continue editing")
31832 }
31833 ),
31834 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
31835 Button4,
31836 {
31837 variant: "minimal",
31838 size: "compact",
31839 onClick: onWriteAnother,
31840 children: (0, import_i18n53.__)("Write another")
31841 }
31842 )
31843 ] })
31844 ] })
31845 }
31846 );
31847 }
31848
31849 // widgets/quick-draft/fields/quick-draft-content-field/quick-draft-content-field.tsx
31850 var import_components53 = __toESM(require_components());
31851 var import_element117 = __toESM(require_element());
31852
31853 // widgets/quick-draft/fields/quick-draft-content-field/quick-draft-content-field.module.css
31854 if (typeof process === "undefined" || true) {
31855 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}");
31856 }
31857 var quick_draft_content_field_default = { "root": "d6b34c2200336d18__root" };
31858
31859 // widgets/quick-draft/fields/quick-draft-content-field/quick-draft-content-field.tsx
31860 var import_jsx_runtime155 = __toESM(require_jsx_runtime());
31861 function getErrorMessage(validity) {
31862 if (!validity) {
31863 return void 0;
31864 }
31865 const entries = [
31866 validity.required,
31867 validity.minLength,
31868 validity.maxLength,
31869 validity.pattern,
31870 validity.custom
31871 ];
31872 const invalid = entries.find((entry) => entry?.type === "invalid");
31873 return invalid?.message;
31874 }
31875 function QuickDraftContentField({
31876 data,
31877 field,
31878 onChange,
31879 hideLabelFromVision,
31880 validity
31881 }) {
31882 const value = field.getValue({ item: data });
31883 const disabled2 = field.isDisabled({ item: data, field });
31884 const onChangeValue = (0, import_element117.useCallback)(
31885 (newValue) => onChange(field.setValue({ item: data, value: newValue })),
31886 [data, field, onChange]
31887 );
31888 const errorMessage = getErrorMessage(validity);
31889 const help = errorMessage ?? field.description;
31890 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(Stack, { direction: "column", className: quick_draft_content_field_default.root, children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
31891 import_components53.TextareaControl,
31892 {
31893 label: field.label,
31894 hideLabelFromVision,
31895 value: value ?? "",
31896 placeholder: field.placeholder,
31897 help,
31898 onChange: onChangeValue,
31899 disabled: disabled2,
31900 rows: 4
31901 }
31902 ) });
31903 }
31904
31905 // widgets/quick-draft/hooks/use-widget-size/use-widget-size.ts
31906 var import_compose18 = __toESM(require_compose());
31907 var import_element118 = __toESM(require_element());
31908 var WIDE_MIN_WIDTH = 560;
31909 var TALL_MIN_HEIGHT = 420;
31910 var INITIAL_SIZE = { width: 0, height: 0 };
31911 function useWidgetSize() {
31912 const [size4, setSize] = (0, import_element118.useState)(INITIAL_SIZE);
31913 const ref = (0, import_compose18.useResizeObserver)(
31914 (entries) => {
31915 const entry = entries[0];
31916 if (!entry) {
31917 return;
31918 }
31919 const box = entry.borderBoxSize?.[0];
31920 const width = box ? box.inlineSize : entry.contentRect.width;
31921 const height = box ? box.blockSize : entry.contentRect.height;
31922 setSize(
31923 (prev) => prev.width === width && prev.height === height ? prev : { width, height }
31924 );
31925 },
31926 { box: "border-box" }
31927 );
31928 return (0, import_element118.useMemo)(
31929 () => ({
31930 ref,
31931 width: size4.width,
31932 height: size4.height,
31933 isWide: size4.width >= WIDE_MIN_WIDTH,
31934 isTall: size4.height >= TALL_MIN_HEIGHT
31935 }),
31936 [ref, size4.width, size4.height]
31937 );
31938 }
31939
31940 // widgets/quick-draft/style.module.css
31941 if (typeof process === "undefined" || true) {
31942 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}");
31943 }
31944 var style_default23 = { "body": "_1ceea6985c028257__body", "fill": "e95823d50a99f185__fill", "primaryPane": "_0325357a2c3b57a4__primaryPane", "listPane": "_20004de4c12366b1__listPane", "backRow": "_809476aa1889889d__backRow", "row": "_264d0da8d26b736f__row", "formContainer": "_6b9679a01ecee959__formContainer" };
31945
31946 // widgets/quick-draft/render.tsx
31947 var import_jsx_runtime156 = __toESM(require_jsx_runtime());
31948 function textToParagraphBlocks(text) {
31949 if (!text.trim()) {
31950 return "";
31951 }
31952 return (0, import_autop.autop)((0, import_escape_html.escapeHTML)(text)).replace(
31953 /<p>([\s\S]*?)<\/p>/g,
31954 "<!-- wp:paragraph -->\n<p>$1</p>\n<!-- /wp:paragraph -->"
31955 );
31956 }
31957 var FORM = {
31958 layout: { type: "regular" },
31959 fields: ["title", "content"]
31960 };
31961 var INITIAL_DATA = {
31962 title: "",
31963 content: ""
31964 };
31965 function QuickDraft() {
31966 const [data, setData] = (0, import_element119.useState)(INITIAL_DATA);
31967 const [isSaving, setIsSaving] = (0, import_element119.useState)(false);
31968 const [createdPost, setCreatedPost] = (0, import_element119.useState)(null);
31969 const [isListOpenInCompact, setIsListOpenInCompact] = (0, import_element119.useState)(false);
31970 const { ref, isWide, isTall } = useWidgetSize();
31971 const showDraftsList = isWide || isTall;
31972 const listBeside = isWide;
31973 const { saveEntityRecord } = (0, import_data7.useDispatch)(import_core_data2.store);
31974 const { hasDrafts } = (0, import_data7.useSelect)(
31975 (select) => {
31976 if (showDraftsList) {
31977 return { hasDrafts: false };
31978 }
31979 const { getEntityRecords } = select(import_core_data2.store);
31980 const anyDrafts = getEntityRecords("postType", "post", {
31981 status: "draft",
31982 per_page: 1
31983 });
31984 return { hasDrafts: (anyDrafts?.length ?? 0) > 0 };
31985 },
31986 [showDraftsList]
31987 );
31988 const fields = (0, import_element119.useMemo)(
31989 () => [
31990 {
31991 id: "title",
31992 type: "text",
31993 label: (0, import_i18n54.__)("Title"),
31994 isValid: { required: true, minLength: 3 },
31995 hideLabelFromVision: true,
31996 help: (0, import_i18n54.__)("Enter a title for your post.")
31997 },
31998 {
31999 id: "content",
32000 type: "text",
32001 label: (0, import_i18n54.__)("Content"),
32002 isValid: { required: true, minLength: 10 },
32003 Edit: QuickDraftContentField,
32004 help: (0, import_i18n54.__)("Enter the content for your post.")
32005 }
32006 ],
32007 []
32008 );
32009 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, FORM);
32010 const canSave = isValid2 && !isSaving;
32011 const saveDraftPost = async () => {
32012 if (!canSave) {
32013 return;
32014 }
32015 setIsSaving(true);
32016 try {
32017 const saved = await saveEntityRecord("postType", "post", {
32018 title: data.title,
32019 content: textToParagraphBlocks(data.content),
32020 status: "draft"
32021 });
32022 const newId = saved?.id;
32023 if (typeof newId === "number") {
32024 setCreatedPost({ id: newId, title: data.title });
32025 }
32026 setData(INITIAL_DATA);
32027 } finally {
32028 setIsSaving(false);
32029 }
32030 };
32031 const writeAnother = () => {
32032 setCreatedPost(null);
32033 };
32034 let primary;
32035 if (createdPost !== null) {
32036 primary = /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
32037 SavedPost,
32038 {
32039 postId: createdPost.id,
32040 postTitle: createdPost.title,
32041 onWriteAnother: writeAnother
32042 }
32043 );
32044 } else {
32045 primary = /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(
32046 Stack,
32047 {
32048 direction: "column",
32049 gap: "md",
32050 justify: "space-between",
32051 className: style_default23.fill,
32052 children: [
32053 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(Stack, { direction: "column", className: style_default23.formContainer, children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
32054 DataForm,
32055 {
32056 data,
32057 fields,
32058 form: FORM,
32059 validity,
32060 onChange: (edits) => setData((prev) => ({ ...prev, ...edits }))
32061 }
32062 ) }),
32063 /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(Stack, { direction: "row", gap: "md", justify: "flex-start", children: [
32064 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
32065 Button4,
32066 {
32067 variant: "solid",
32068 onClick: saveDraftPost,
32069 loading: isSaving,
32070 disabled: !canSave,
32071 children: (0, import_i18n54.__)("Save as draft")
32072 }
32073 ),
32074 !showDraftsList && hasDrafts && /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(
32075 Button4,
32076 {
32077 variant: "minimal",
32078 onClick: () => setIsListOpenInCompact(true),
32079 children: [
32080 (0, import_i18n54.__)("Draft posts"),
32081 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(Button4.Icon, { icon: chevron_right_default })
32082 ]
32083 }
32084 )
32085 ] })
32086 ]
32087 }
32088 );
32089 }
32090 if (!showDraftsList && isListOpenInCompact) {
32091 return /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(Stack, { ref, direction: "column", className: style_default23.body, children: [
32092 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(Stack, { direction: "column", className: style_default23.listPane, children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(DraftsList, {}) }),
32093 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
32094 Stack,
32095 {
32096 direction: "row",
32097 justify: "flex-start",
32098 className: style_default23.backRow,
32099 children: /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(
32100 Button4,
32101 {
32102 variant: "minimal",
32103 tone: "neutral",
32104 size: "compact",
32105 onClick: () => setIsListOpenInCompact(false),
32106 children: [
32107 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(Button4.Icon, { icon: chevron_left_default }),
32108 (0, import_i18n54.__)("Back")
32109 ]
32110 }
32111 )
32112 }
32113 )
32114 ] });
32115 }
32116 if (!showDraftsList) {
32117 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(Stack, { ref, direction: "column", className: style_default23.body, children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(Stack, { direction: "column", className: style_default23.primaryPane, children: primary }) });
32118 }
32119 return /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(
32120 Stack,
32121 {
32122 ref,
32123 direction: listBeside ? "row" : "column",
32124 className: clsx_default(
32125 style_default23.body,
32126 listBeside ? style_default23.row : style_default23.column
32127 ),
32128 children: [
32129 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(Stack, { direction: "column", className: style_default23.primaryPane, children: primary }),
32130 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(Stack, { direction: "column", className: style_default23.listPane, children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(DraftsList, {}) })
32131 ]
32132 }
32133 );
32134 }
32135 export {
32136 QuickDraft as default
32137 };
32138 /*! Bundled license information:
32139
32140 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
32141 (**
32142 * @license React
32143 * use-sync-external-store-shim.development.js
32144 *
32145 * Copyright (c) Meta Platforms, Inc. and affiliates.
32146 *
32147 * This source code is licensed under the MIT license found in the
32148 * LICENSE file in the root directory of this source tree.
32149 *)
32150
32151 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
32152 (**
32153 * @license React
32154 * use-sync-external-store-shim/with-selector.development.js
32155 *
32156 * Copyright (c) Meta Platforms, Inc. and affiliates.
32157 *
32158 * This source code is licensed under the MIT license found in the
32159 * LICENSE file in the root directory of this source tree.
32160 *)
32161 */
32162