PluginProbe
Gutenberg / 23.3.2
Gutenberg v23.3.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 / modules / content-types / index.js

index.js in Gutenberg 23.3.2, at build/modules/content-types/index.js

38,652 lines 1.3 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/i18n
32 var require_i18n = __commonJS({
33 "package-external:@wordpress/i18n"(exports, module) {
34 module.exports = window.wp.i18n;
35 }
36 });
37
38 // package-external:@wordpress/element
39 var require_element = __commonJS({
40 "package-external:@wordpress/element"(exports, module) {
41 module.exports = window.wp.element;
42 }
43 });
44
45 // vendor-external:react
46 var require_react = __commonJS({
47 "vendor-external:react"(exports, module) {
48 module.exports = window.React;
49 }
50 });
51
52 // vendor-external:react/jsx-runtime
53 var require_jsx_runtime = __commonJS({
54 "vendor-external:react/jsx-runtime"(exports, module) {
55 module.exports = window.ReactJSXRuntime;
56 }
57 });
58
59 // vendor-external:react-dom
60 var require_react_dom = __commonJS({
61 "vendor-external:react-dom"(exports, module) {
62 module.exports = window.ReactDOM;
63 }
64 });
65
66 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
67 var require_use_sync_external_store_shim_development = __commonJS({
68 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
69 "use strict";
70 (function() {
71 function is(x2, y2) {
72 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
73 }
74 function useSyncExternalStore$2(subscribe2, getSnapshot) {
75 didWarnOld18Alpha || void 0 === React88.startTransition || (didWarnOld18Alpha = true, console.error(
76 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
77 ));
78 var value = getSnapshot();
79 if (!didWarnUncachedGetSnapshot) {
80 var cachedValue = getSnapshot();
81 objectIs(value, cachedValue) || (console.error(
82 "The result of getSnapshot should be cached to avoid an infinite loop"
83 ), didWarnUncachedGetSnapshot = true);
84 }
85 cachedValue = useState54({
86 inst: { value, getSnapshot }
87 });
88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
89 useLayoutEffect6(
90 function() {
91 inst.value = value;
92 inst.getSnapshot = getSnapshot;
93 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
94 },
95 [subscribe2, value, getSnapshot]
96 );
97 useEffect46(
98 function() {
99 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
100 return subscribe2(function() {
101 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
102 });
103 },
104 [subscribe2]
105 );
106 useDebugValue2(value);
107 return value;
108 }
109 function checkIfSnapshotChanged(inst) {
110 var latestGetSnapshot = inst.getSnapshot;
111 inst = inst.value;
112 try {
113 var nextValue = latestGetSnapshot();
114 return !objectIs(inst, nextValue);
115 } catch (error2) {
116 return true;
117 }
118 }
119 function useSyncExternalStore$1(subscribe2, getSnapshot) {
120 return getSnapshot();
121 }
122 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
123 var React88 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState54 = React88.useState, useEffect46 = React88.useEffect, useLayoutEffect6 = React88.useLayoutEffect, useDebugValue2 = React88.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
124 exports.useSyncExternalStore = void 0 !== React88.useSyncExternalStore ? React88.useSyncExternalStore : shim;
125 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
126 })();
127 }
128 });
129
130 // node_modules/use-sync-external-store/shim/index.js
131 var require_shim = __commonJS({
132 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
133 "use strict";
134 if (false) {
135 module.exports = null;
136 } else {
137 module.exports = require_use_sync_external_store_shim_development();
138 }
139 }
140 });
141
142 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
143 var require_with_selector_development = __commonJS({
144 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
145 "use strict";
146 (function() {
147 function is(x2, y2) {
148 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
149 }
150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
151 var React88 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef65 = React88.useRef, useEffect46 = React88.useEffect, useMemo75 = React88.useMemo, useDebugValue2 = React88.useDebugValue;
152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
153 var instRef = useRef65(null);
154 if (null === instRef.current) {
155 var inst = { hasValue: false, value: null };
156 instRef.current = inst;
157 } else inst = instRef.current;
158 instRef = useMemo75(
159 function() {
160 function memoizedSelector(nextSnapshot) {
161 if (!hasMemo) {
162 hasMemo = true;
163 memoizedSnapshot = nextSnapshot;
164 nextSnapshot = selector2(nextSnapshot);
165 if (void 0 !== isEqual && inst.hasValue) {
166 var currentSelection = inst.value;
167 if (isEqual(currentSelection, nextSnapshot))
168 return memoizedSelection = currentSelection;
169 }
170 return memoizedSelection = nextSnapshot;
171 }
172 currentSelection = memoizedSelection;
173 if (objectIs(memoizedSnapshot, nextSnapshot))
174 return currentSelection;
175 var nextSelection = selector2(nextSnapshot);
176 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
177 return memoizedSnapshot = nextSnapshot, currentSelection;
178 memoizedSnapshot = nextSnapshot;
179 return memoizedSelection = nextSelection;
180 }
181 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
182 return [
183 function() {
184 return memoizedSelector(getSnapshot());
185 },
186 null === maybeGetServerSnapshot ? void 0 : function() {
187 return memoizedSelector(maybeGetServerSnapshot());
188 }
189 ];
190 },
191 [getSnapshot, getServerSnapshot, selector2, isEqual]
192 );
193 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
194 useEffect46(
195 function() {
196 inst.hasValue = true;
197 inst.value = value;
198 },
199 [value]
200 );
201 useDebugValue2(value);
202 return value;
203 };
204 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
205 })();
206 }
207 });
208
209 // node_modules/use-sync-external-store/shim/with-selector.js
210 var require_with_selector = __commonJS({
211 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
212 "use strict";
213 if (false) {
214 module.exports = null;
215 } else {
216 module.exports = require_with_selector_development();
217 }
218 }
219 });
220
221 // package-external:@wordpress/primitives
222 var require_primitives = __commonJS({
223 "package-external:@wordpress/primitives"(exports, module) {
224 module.exports = window.wp.primitives;
225 }
226 });
227
228 // package-external:@wordpress/compose
229 var require_compose = __commonJS({
230 "package-external:@wordpress/compose"(exports, module) {
231 module.exports = window.wp.compose;
232 }
233 });
234
235 // package-external:@wordpress/theme
236 var require_theme = __commonJS({
237 "package-external:@wordpress/theme"(exports, module) {
238 module.exports = window.wp.theme;
239 }
240 });
241
242 // package-external:@wordpress/private-apis
243 var require_private_apis = __commonJS({
244 "package-external:@wordpress/private-apis"(exports, module) {
245 module.exports = window.wp.privateApis;
246 }
247 });
248
249 // package-external:@wordpress/components
250 var require_components = __commonJS({
251 "package-external:@wordpress/components"(exports, module) {
252 module.exports = window.wp.components;
253 }
254 });
255
256 // package-external:@wordpress/keycodes
257 var require_keycodes = __commonJS({
258 "package-external:@wordpress/keycodes"(exports, module) {
259 module.exports = window.wp.keycodes;
260 }
261 });
262
263 // package-external:@wordpress/data
264 var require_data = __commonJS({
265 "package-external:@wordpress/data"(exports, module) {
266 module.exports = window.wp.data;
267 }
268 });
269
270 // node_modules/remove-accents/index.js
271 var require_remove_accents = __commonJS({
272 "node_modules/remove-accents/index.js"(exports, module) {
273 var characterMap = {
274 "\xC0": "A",
275 "\xC1": "A",
276 "\xC2": "A",
277 "\xC3": "A",
278 "\xC4": "A",
279 "\xC5": "A",
280 "\u1EA4": "A",
281 "\u1EAE": "A",
282 "\u1EB2": "A",
283 "\u1EB4": "A",
284 "\u1EB6": "A",
285 "\xC6": "AE",
286 "\u1EA6": "A",
287 "\u1EB0": "A",
288 "\u0202": "A",
289 "\u1EA2": "A",
290 "\u1EA0": "A",
291 "\u1EA8": "A",
292 "\u1EAA": "A",
293 "\u1EAC": "A",
294 "\xC7": "C",
295 "\u1E08": "C",
296 "\xC8": "E",
297 "\xC9": "E",
298 "\xCA": "E",
299 "\xCB": "E",
300 "\u1EBE": "E",
301 "\u1E16": "E",
302 "\u1EC0": "E",
303 "\u1E14": "E",
304 "\u1E1C": "E",
305 "\u0206": "E",
306 "\u1EBA": "E",
307 "\u1EBC": "E",
308 "\u1EB8": "E",
309 "\u1EC2": "E",
310 "\u1EC4": "E",
311 "\u1EC6": "E",
312 "\xCC": "I",
313 "\xCD": "I",
314 "\xCE": "I",
315 "\xCF": "I",
316 "\u1E2E": "I",
317 "\u020A": "I",
318 "\u1EC8": "I",
319 "\u1ECA": "I",
320 "\xD0": "D",
321 "\xD1": "N",
322 "\xD2": "O",
323 "\xD3": "O",
324 "\xD4": "O",
325 "\xD5": "O",
326 "\xD6": "O",
327 "\xD8": "O",
328 "\u1ED0": "O",
329 "\u1E4C": "O",
330 "\u1E52": "O",
331 "\u020E": "O",
332 "\u1ECE": "O",
333 "\u1ECC": "O",
334 "\u1ED4": "O",
335 "\u1ED6": "O",
336 "\u1ED8": "O",
337 "\u1EDC": "O",
338 "\u1EDE": "O",
339 "\u1EE0": "O",
340 "\u1EDA": "O",
341 "\u1EE2": "O",
342 "\xD9": "U",
343 "\xDA": "U",
344 "\xDB": "U",
345 "\xDC": "U",
346 "\u1EE6": "U",
347 "\u1EE4": "U",
348 "\u1EEC": "U",
349 "\u1EEE": "U",
350 "\u1EF0": "U",
351 "\xDD": "Y",
352 "\xE0": "a",
353 "\xE1": "a",
354 "\xE2": "a",
355 "\xE3": "a",
356 "\xE4": "a",
357 "\xE5": "a",
358 "\u1EA5": "a",
359 "\u1EAF": "a",
360 "\u1EB3": "a",
361 "\u1EB5": "a",
362 "\u1EB7": "a",
363 "\xE6": "ae",
364 "\u1EA7": "a",
365 "\u1EB1": "a",
366 "\u0203": "a",
367 "\u1EA3": "a",
368 "\u1EA1": "a",
369 "\u1EA9": "a",
370 "\u1EAB": "a",
371 "\u1EAD": "a",
372 "\xE7": "c",
373 "\u1E09": "c",
374 "\xE8": "e",
375 "\xE9": "e",
376 "\xEA": "e",
377 "\xEB": "e",
378 "\u1EBF": "e",
379 "\u1E17": "e",
380 "\u1EC1": "e",
381 "\u1E15": "e",
382 "\u1E1D": "e",
383 "\u0207": "e",
384 "\u1EBB": "e",
385 "\u1EBD": "e",
386 "\u1EB9": "e",
387 "\u1EC3": "e",
388 "\u1EC5": "e",
389 "\u1EC7": "e",
390 "\xEC": "i",
391 "\xED": "i",
392 "\xEE": "i",
393 "\xEF": "i",
394 "\u1E2F": "i",
395 "\u020B": "i",
396 "\u1EC9": "i",
397 "\u1ECB": "i",
398 "\xF0": "d",
399 "\xF1": "n",
400 "\xF2": "o",
401 "\xF3": "o",
402 "\xF4": "o",
403 "\xF5": "o",
404 "\xF6": "o",
405 "\xF8": "o",
406 "\u1ED1": "o",
407 "\u1E4D": "o",
408 "\u1E53": "o",
409 "\u020F": "o",
410 "\u1ECF": "o",
411 "\u1ECD": "o",
412 "\u1ED5": "o",
413 "\u1ED7": "o",
414 "\u1ED9": "o",
415 "\u1EDD": "o",
416 "\u1EDF": "o",
417 "\u1EE1": "o",
418 "\u1EDB": "o",
419 "\u1EE3": "o",
420 "\xF9": "u",
421 "\xFA": "u",
422 "\xFB": "u",
423 "\xFC": "u",
424 "\u1EE7": "u",
425 "\u1EE5": "u",
426 "\u1EED": "u",
427 "\u1EEF": "u",
428 "\u1EF1": "u",
429 "\xFD": "y",
430 "\xFF": "y",
431 "\u0100": "A",
432 "\u0101": "a",
433 "\u0102": "A",
434 "\u0103": "a",
435 "\u0104": "A",
436 "\u0105": "a",
437 "\u0106": "C",
438 "\u0107": "c",
439 "\u0108": "C",
440 "\u0109": "c",
441 "\u010A": "C",
442 "\u010B": "c",
443 "\u010C": "C",
444 "\u010D": "c",
445 "C\u0306": "C",
446 "c\u0306": "c",
447 "\u010E": "D",
448 "\u010F": "d",
449 "\u0110": "D",
450 "\u0111": "d",
451 "\u0112": "E",
452 "\u0113": "e",
453 "\u0114": "E",
454 "\u0115": "e",
455 "\u0116": "E",
456 "\u0117": "e",
457 "\u0118": "E",
458 "\u0119": "e",
459 "\u011A": "E",
460 "\u011B": "e",
461 "\u011C": "G",
462 "\u01F4": "G",
463 "\u011D": "g",
464 "\u01F5": "g",
465 "\u011E": "G",
466 "\u011F": "g",
467 "\u0120": "G",
468 "\u0121": "g",
469 "\u0122": "G",
470 "\u0123": "g",
471 "\u0124": "H",
472 "\u0125": "h",
473 "\u0126": "H",
474 "\u0127": "h",
475 "\u1E2A": "H",
476 "\u1E2B": "h",
477 "\u0128": "I",
478 "\u0129": "i",
479 "\u012A": "I",
480 "\u012B": "i",
481 "\u012C": "I",
482 "\u012D": "i",
483 "\u012E": "I",
484 "\u012F": "i",
485 "\u0130": "I",
486 "\u0131": "i",
487 "\u0132": "IJ",
488 "\u0133": "ij",
489 "\u0134": "J",
490 "\u0135": "j",
491 "\u0136": "K",
492 "\u0137": "k",
493 "\u1E30": "K",
494 "\u1E31": "k",
495 "K\u0306": "K",
496 "k\u0306": "k",
497 "\u0139": "L",
498 "\u013A": "l",
499 "\u013B": "L",
500 "\u013C": "l",
501 "\u013D": "L",
502 "\u013E": "l",
503 "\u013F": "L",
504 "\u0140": "l",
505 "\u0141": "l",
506 "\u0142": "l",
507 "\u1E3E": "M",
508 "\u1E3F": "m",
509 "M\u0306": "M",
510 "m\u0306": "m",
511 "\u0143": "N",
512 "\u0144": "n",
513 "\u0145": "N",
514 "\u0146": "n",
515 "\u0147": "N",
516 "\u0148": "n",
517 "\u0149": "n",
518 "N\u0306": "N",
519 "n\u0306": "n",
520 "\u014C": "O",
521 "\u014D": "o",
522 "\u014E": "O",
523 "\u014F": "o",
524 "\u0150": "O",
525 "\u0151": "o",
526 "\u0152": "OE",
527 "\u0153": "oe",
528 "P\u0306": "P",
529 "p\u0306": "p",
530 "\u0154": "R",
531 "\u0155": "r",
532 "\u0156": "R",
533 "\u0157": "r",
534 "\u0158": "R",
535 "\u0159": "r",
536 "R\u0306": "R",
537 "r\u0306": "r",
538 "\u0212": "R",
539 "\u0213": "r",
540 "\u015A": "S",
541 "\u015B": "s",
542 "\u015C": "S",
543 "\u015D": "s",
544 "\u015E": "S",
545 "\u0218": "S",
546 "\u0219": "s",
547 "\u015F": "s",
548 "\u0160": "S",
549 "\u0161": "s",
550 "\u0162": "T",
551 "\u0163": "t",
552 "\u021B": "t",
553 "\u021A": "T",
554 "\u0164": "T",
555 "\u0165": "t",
556 "\u0166": "T",
557 "\u0167": "t",
558 "T\u0306": "T",
559 "t\u0306": "t",
560 "\u0168": "U",
561 "\u0169": "u",
562 "\u016A": "U",
563 "\u016B": "u",
564 "\u016C": "U",
565 "\u016D": "u",
566 "\u016E": "U",
567 "\u016F": "u",
568 "\u0170": "U",
569 "\u0171": "u",
570 "\u0172": "U",
571 "\u0173": "u",
572 "\u0216": "U",
573 "\u0217": "u",
574 "V\u0306": "V",
575 "v\u0306": "v",
576 "\u0174": "W",
577 "\u0175": "w",
578 "\u1E82": "W",
579 "\u1E83": "w",
580 "X\u0306": "X",
581 "x\u0306": "x",
582 "\u0176": "Y",
583 "\u0177": "y",
584 "\u0178": "Y",
585 "Y\u0306": "Y",
586 "y\u0306": "y",
587 "\u0179": "Z",
588 "\u017A": "z",
589 "\u017B": "Z",
590 "\u017C": "z",
591 "\u017D": "Z",
592 "\u017E": "z",
593 "\u017F": "s",
594 "\u0192": "f",
595 "\u01A0": "O",
596 "\u01A1": "o",
597 "\u01AF": "U",
598 "\u01B0": "u",
599 "\u01CD": "A",
600 "\u01CE": "a",
601 "\u01CF": "I",
602 "\u01D0": "i",
603 "\u01D1": "O",
604 "\u01D2": "o",
605 "\u01D3": "U",
606 "\u01D4": "u",
607 "\u01D5": "U",
608 "\u01D6": "u",
609 "\u01D7": "U",
610 "\u01D8": "u",
611 "\u01D9": "U",
612 "\u01DA": "u",
613 "\u01DB": "U",
614 "\u01DC": "u",
615 "\u1EE8": "U",
616 "\u1EE9": "u",
617 "\u1E78": "U",
618 "\u1E79": "u",
619 "\u01FA": "A",
620 "\u01FB": "a",
621 "\u01FC": "AE",
622 "\u01FD": "ae",
623 "\u01FE": "O",
624 "\u01FF": "o",
625 "\xDE": "TH",
626 "\xFE": "th",
627 "\u1E54": "P",
628 "\u1E55": "p",
629 "\u1E64": "S",
630 "\u1E65": "s",
631 "X\u0301": "X",
632 "x\u0301": "x",
633 "\u0403": "\u0413",
634 "\u0453": "\u0433",
635 "\u040C": "\u041A",
636 "\u045C": "\u043A",
637 "A\u030B": "A",
638 "a\u030B": "a",
639 "E\u030B": "E",
640 "e\u030B": "e",
641 "I\u030B": "I",
642 "i\u030B": "i",
643 "\u01F8": "N",
644 "\u01F9": "n",
645 "\u1ED2": "O",
646 "\u1ED3": "o",
647 "\u1E50": "O",
648 "\u1E51": "o",
649 "\u1EEA": "U",
650 "\u1EEB": "u",
651 "\u1E80": "W",
652 "\u1E81": "w",
653 "\u1EF2": "Y",
654 "\u1EF3": "y",
655 "\u0200": "A",
656 "\u0201": "a",
657 "\u0204": "E",
658 "\u0205": "e",
659 "\u0208": "I",
660 "\u0209": "i",
661 "\u020C": "O",
662 "\u020D": "o",
663 "\u0210": "R",
664 "\u0211": "r",
665 "\u0214": "U",
666 "\u0215": "u",
667 "B\u030C": "B",
668 "b\u030C": "b",
669 "\u010C\u0323": "C",
670 "\u010D\u0323": "c",
671 "\xCA\u030C": "E",
672 "\xEA\u030C": "e",
673 "F\u030C": "F",
674 "f\u030C": "f",
675 "\u01E6": "G",
676 "\u01E7": "g",
677 "\u021E": "H",
678 "\u021F": "h",
679 "J\u030C": "J",
680 "\u01F0": "j",
681 "\u01E8": "K",
682 "\u01E9": "k",
683 "M\u030C": "M",
684 "m\u030C": "m",
685 "P\u030C": "P",
686 "p\u030C": "p",
687 "Q\u030C": "Q",
688 "q\u030C": "q",
689 "\u0158\u0329": "R",
690 "\u0159\u0329": "r",
691 "\u1E66": "S",
692 "\u1E67": "s",
693 "V\u030C": "V",
694 "v\u030C": "v",
695 "W\u030C": "W",
696 "w\u030C": "w",
697 "X\u030C": "X",
698 "x\u030C": "x",
699 "Y\u030C": "Y",
700 "y\u030C": "y",
701 "A\u0327": "A",
702 "a\u0327": "a",
703 "B\u0327": "B",
704 "b\u0327": "b",
705 "\u1E10": "D",
706 "\u1E11": "d",
707 "\u0228": "E",
708 "\u0229": "e",
709 "\u0190\u0327": "E",
710 "\u025B\u0327": "e",
711 "\u1E28": "H",
712 "\u1E29": "h",
713 "I\u0327": "I",
714 "i\u0327": "i",
715 "\u0197\u0327": "I",
716 "\u0268\u0327": "i",
717 "M\u0327": "M",
718 "m\u0327": "m",
719 "O\u0327": "O",
720 "o\u0327": "o",
721 "Q\u0327": "Q",
722 "q\u0327": "q",
723 "U\u0327": "U",
724 "u\u0327": "u",
725 "X\u0327": "X",
726 "x\u0327": "x",
727 "Z\u0327": "Z",
728 "z\u0327": "z",
729 "\u0439": "\u0438",
730 "\u0419": "\u0418",
731 "\u0451": "\u0435",
732 "\u0401": "\u0415"
733 };
734 var chars = Object.keys(characterMap).join("|");
735 var allAccents = new RegExp(chars, "g");
736 var firstAccent = new RegExp(chars, "");
737 function matcher(match2) {
738 return characterMap[match2];
739 }
740 var removeAccents2 = function(string) {
741 return string.replace(allAccents, matcher);
742 };
743 var hasAccents = function(string) {
744 return !!string.match(firstAccent);
745 };
746 module.exports = removeAccents2;
747 module.exports.has = hasAccents;
748 module.exports.remove = removeAccents2;
749 }
750 });
751
752 // node_modules/fast-deep-equal/es6/index.js
753 var require_es6 = __commonJS({
754 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
755 "use strict";
756 module.exports = function equal(a2, b2) {
757 if (a2 === b2) return true;
758 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
759 if (a2.constructor !== b2.constructor) return false;
760 var length, i2, keys;
761 if (Array.isArray(a2)) {
762 length = a2.length;
763 if (length != b2.length) return false;
764 for (i2 = length; i2-- !== 0; )
765 if (!equal(a2[i2], b2[i2])) return false;
766 return true;
767 }
768 if (a2 instanceof Map && b2 instanceof Map) {
769 if (a2.size !== b2.size) return false;
770 for (i2 of a2.entries())
771 if (!b2.has(i2[0])) return false;
772 for (i2 of a2.entries())
773 if (!equal(i2[1], b2.get(i2[0]))) return false;
774 return true;
775 }
776 if (a2 instanceof Set && b2 instanceof Set) {
777 if (a2.size !== b2.size) return false;
778 for (i2 of a2.entries())
779 if (!b2.has(i2[0])) return false;
780 return true;
781 }
782 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
783 length = a2.length;
784 if (length != b2.length) return false;
785 for (i2 = length; i2-- !== 0; )
786 if (a2[i2] !== b2[i2]) return false;
787 return true;
788 }
789 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
790 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
791 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
792 keys = Object.keys(a2);
793 length = keys.length;
794 if (length !== Object.keys(b2).length) return false;
795 for (i2 = length; i2-- !== 0; )
796 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
797 for (i2 = length; i2-- !== 0; ) {
798 var key = keys[i2];
799 if (!equal(a2[key], b2[key])) return false;
800 }
801 return true;
802 }
803 return a2 !== a2 && b2 !== b2;
804 };
805 }
806 });
807
808 // package-external:@wordpress/date
809 var require_date = __commonJS({
810 "package-external:@wordpress/date"(exports, module) {
811 module.exports = window.wp.date;
812 }
813 });
814
815 // package-external:@wordpress/warning
816 var require_warning = __commonJS({
817 "package-external:@wordpress/warning"(exports, module) {
818 module.exports = window.wp.warning;
819 }
820 });
821
822 // node_modules/deepmerge/dist/cjs.js
823 var require_cjs = __commonJS({
824 "node_modules/deepmerge/dist/cjs.js"(exports, module) {
825 "use strict";
826 var isMergeableObject = function isMergeableObject2(value) {
827 return isNonNullObject(value) && !isSpecial(value);
828 };
829 function isNonNullObject(value) {
830 return !!value && typeof value === "object";
831 }
832 function isSpecial(value) {
833 var stringValue = Object.prototype.toString.call(value);
834 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
835 }
836 var canUseSymbol = typeof Symbol === "function" && Symbol.for;
837 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
838 function isReactElement(value) {
839 return value.$$typeof === REACT_ELEMENT_TYPE;
840 }
841 function emptyTarget(val) {
842 return Array.isArray(val) ? [] : {};
843 }
844 function cloneUnlessOtherwiseSpecified(value, options) {
845 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
846 }
847 function defaultArrayMerge(target, source, options) {
848 return target.concat(source).map(function(element) {
849 return cloneUnlessOtherwiseSpecified(element, options);
850 });
851 }
852 function getMergeFunction(key, options) {
853 if (!options.customMerge) {
854 return deepmerge;
855 }
856 var customMerge = options.customMerge(key);
857 return typeof customMerge === "function" ? customMerge : deepmerge;
858 }
859 function getEnumerableOwnPropertySymbols(target) {
860 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) {
861 return Object.propertyIsEnumerable.call(target, symbol3);
862 }) : [];
863 }
864 function getKeys2(target) {
865 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
866 }
867 function propertyIsOnObject(object, property) {
868 try {
869 return property in object;
870 } catch (_) {
871 return false;
872 }
873 }
874 function propertyIsUnsafe(target, key) {
875 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
876 }
877 function mergeObject(target, source, options) {
878 var destination = {};
879 if (options.isMergeableObject(target)) {
880 getKeys2(target).forEach(function(key) {
881 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
882 });
883 }
884 getKeys2(source).forEach(function(key) {
885 if (propertyIsUnsafe(target, key)) {
886 return;
887 }
888 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
889 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
890 } else {
891 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
892 }
893 });
894 return destination;
895 }
896 function deepmerge(target, source, options) {
897 options = options || {};
898 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
899 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
900 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
901 var sourceIsArray = Array.isArray(source);
902 var targetIsArray = Array.isArray(target);
903 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
904 if (!sourceAndTargetTypesMatch) {
905 return cloneUnlessOtherwiseSpecified(source, options);
906 } else if (sourceIsArray) {
907 return options.arrayMerge(target, source, options);
908 } else {
909 return mergeObject(target, source, options);
910 }
911 }
912 deepmerge.all = function deepmergeAll(array, options) {
913 if (!Array.isArray(array)) {
914 throw new Error("first argument should be an array");
915 }
916 return array.reduce(function(prev, next) {
917 return deepmerge(prev, next, options);
918 }, {});
919 };
920 var deepmerge_1 = deepmerge;
921 module.exports = deepmerge_1;
922 }
923 });
924
925 // package-external:@wordpress/core-data
926 var require_core_data = __commonJS({
927 "package-external:@wordpress/core-data"(exports, module) {
928 module.exports = window.wp.coreData;
929 }
930 });
931
932 // package-external:@wordpress/preferences
933 var require_preferences = __commonJS({
934 "package-external:@wordpress/preferences"(exports, module) {
935 module.exports = window.wp.preferences;
936 }
937 });
938
939 // package-external:@wordpress/notices
940 var require_notices = __commonJS({
941 "package-external:@wordpress/notices"(exports, module) {
942 module.exports = window.wp.notices;
943 }
944 });
945
946 // package-external:@wordpress/is-shallow-equal
947 var require_is_shallow_equal = __commonJS({
948 "package-external:@wordpress/is-shallow-equal"(exports, module) {
949 module.exports = window.wp.isShallowEqual;
950 }
951 });
952
953 // package-external:@wordpress/url
954 var require_url = __commonJS({
955 "package-external:@wordpress/url"(exports, module) {
956 module.exports = window.wp.url;
957 }
958 });
959
960 // packages/admin-ui/build-module/breadcrumbs/index.mjs
961 var import_i18n4 = __toESM(require_i18n(), 1);
962 import { Link as RouterLink } from "@wordpress/route";
963
964 // node_modules/clsx/dist/clsx.mjs
965 function r(e2) {
966 var t2, f2, n2 = "";
967 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
968 else if ("object" == typeof e2) if (Array.isArray(e2)) {
969 var o2 = e2.length;
970 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
971 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
972 return n2;
973 }
974 function clsx() {
975 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
976 return n2;
977 }
978 var clsx_default = clsx;
979
980 // packages/ui/build-module/badge/badge.mjs
981 var import_element12 = __toESM(require_element(), 1);
982
983 // node_modules/@base-ui/utils/esm/useControlled.js
984 var React = __toESM(require_react(), 1);
985
986 // node_modules/@base-ui/utils/esm/error.js
987 var set;
988 if (true) {
989 set = /* @__PURE__ */ new Set();
990 }
991 function error(...messages) {
992 if (true) {
993 const messageKey = messages.join(" ");
994 if (!set.has(messageKey)) {
995 set.add(messageKey);
996 console.error(`Base UI: ${messageKey}`);
997 }
998 }
999 }
1000
1001 // node_modules/@base-ui/utils/esm/useControlled.js
1002 function useControlled({
1003 controlled,
1004 default: defaultProp,
1005 name,
1006 state = "value"
1007 }) {
1008 const {
1009 current: isControlled
1010 } = React.useRef(controlled !== void 0);
1011 const [valueState, setValue] = React.useState(defaultProp);
1012 const value = isControlled ? controlled : valueState;
1013 if (true) {
1014 React.useEffect(() => {
1015 if (isControlled !== (controlled !== void 0)) {
1016 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"));
1017 }
1018 }, [state, name, controlled]);
1019 const {
1020 current: defaultValue2
1021 } = React.useRef(defaultProp);
1022 React.useEffect(() => {
1023 if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) {
1024 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"));
1025 }
1026 }, [defaultProp]);
1027 }
1028 const setValueIfUncontrolled = React.useCallback((newValue) => {
1029 if (!isControlled) {
1030 setValue(newValue);
1031 }
1032 }, []);
1033 return [value, setValueIfUncontrolled];
1034 }
1035 function serializeToDevModeString(input) {
1036 let nextId = 0;
1037 const seen = /* @__PURE__ */ new WeakMap();
1038 try {
1039 const result = JSON.stringify(input, function replacer(key, value) {
1040 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) {
1041 return void 0;
1042 }
1043 if (typeof value === "bigint") {
1044 return `__bigint__:${value}`;
1045 }
1046 if (value !== null && typeof value === "object") {
1047 const id = seen.get(value);
1048 if (id !== void 0) {
1049 return `__object__:${id}`;
1050 }
1051 seen.set(value, nextId);
1052 nextId += 1;
1053 }
1054 return value;
1055 });
1056 return result ?? `__top__:${typeof input}`;
1057 } catch {
1058 return "__unserializable__";
1059 }
1060 }
1061
1062 // node_modules/@base-ui/utils/esm/useStableCallback.js
1063 var React3 = __toESM(require_react(), 1);
1064
1065 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1066 var React2 = __toESM(require_react(), 1);
1067 var UNINITIALIZED = {};
1068 function useRefWithInit(init2, initArg) {
1069 const ref = React2.useRef(UNINITIALIZED);
1070 if (ref.current === UNINITIALIZED) {
1071 ref.current = init2(initArg);
1072 }
1073 return ref;
1074 }
1075
1076 // node_modules/@base-ui/utils/esm/useStableCallback.js
1077 var useInsertionEffect = React3[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
1078 var useSafeInsertionEffect = (
1079 // React 17 doesn't have useInsertionEffect.
1080 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1081 useInsertionEffect !== React3.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1082 );
1083 function useStableCallback(callback) {
1084 const stable = useRefWithInit(createStableCallback).current;
1085 stable.next = callback;
1086 useSafeInsertionEffect(stable.effect);
1087 return stable.trampoline;
1088 }
1089 function createStableCallback() {
1090 const stable = {
1091 next: void 0,
1092 callback: assertNotCalled,
1093 trampoline: (...args) => stable.callback?.(...args),
1094 effect: () => {
1095 stable.callback = stable.next;
1096 }
1097 };
1098 return stable;
1099 }
1100 function assertNotCalled() {
1101 if (true) {
1102 throw (
1103 /* minify-error-disabled */
1104 new Error("Base UI: Cannot call an event handler while rendering.")
1105 );
1106 }
1107 }
1108
1109 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1110 var React4 = __toESM(require_react(), 1);
1111 var noop = () => {
1112 };
1113 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
1114
1115 // node_modules/@base-ui/utils/esm/warn.js
1116 var set2;
1117 if (true) {
1118 set2 = /* @__PURE__ */ new Set();
1119 }
1120 function warn(...messages) {
1121 if (true) {
1122 const messageKey = messages.join(" ");
1123 if (!set2.has(messageKey)) {
1124 set2.add(messageKey);
1125 console.warn(`Base UI: ${messageKey}`);
1126 }
1127 }
1128 }
1129
1130 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1131 var React5 = __toESM(require_react(), 1);
1132 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
1133 if (true) DirectionContext.displayName = "DirectionContext";
1134 function useDirection() {
1135 const context = React5.useContext(DirectionContext);
1136 return context?.direction ?? "ltr";
1137 }
1138
1139 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1140 var React8 = __toESM(require_react(), 1);
1141
1142 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1143 function useMergedRefs(a2, b2, c2, d2) {
1144 const forkRef = useRefWithInit(createForkRef).current;
1145 if (didChange(forkRef, a2, b2, c2, d2)) {
1146 update(forkRef, [a2, b2, c2, d2]);
1147 }
1148 return forkRef.callback;
1149 }
1150 function useMergedRefsN(refs) {
1151 const forkRef = useRefWithInit(createForkRef).current;
1152 if (didChangeN(forkRef, refs)) {
1153 update(forkRef, refs);
1154 }
1155 return forkRef.callback;
1156 }
1157 function createForkRef() {
1158 return {
1159 callback: null,
1160 cleanup: null,
1161 refs: []
1162 };
1163 }
1164 function didChange(forkRef, a2, b2, c2, d2) {
1165 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1166 }
1167 function didChangeN(forkRef, newRefs) {
1168 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1169 }
1170 function update(forkRef, refs) {
1171 forkRef.refs = refs;
1172 if (refs.every((ref) => ref == null)) {
1173 forkRef.callback = null;
1174 return;
1175 }
1176 forkRef.callback = (instance) => {
1177 if (forkRef.cleanup) {
1178 forkRef.cleanup();
1179 forkRef.cleanup = null;
1180 }
1181 if (instance != null) {
1182 const cleanupCallbacks = Array(refs.length).fill(null);
1183 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1184 const ref = refs[i2];
1185 if (ref == null) {
1186 continue;
1187 }
1188 switch (typeof ref) {
1189 case "function": {
1190 const refCleanup = ref(instance);
1191 if (typeof refCleanup === "function") {
1192 cleanupCallbacks[i2] = refCleanup;
1193 }
1194 break;
1195 }
1196 case "object": {
1197 ref.current = instance;
1198 break;
1199 }
1200 default:
1201 }
1202 }
1203 forkRef.cleanup = () => {
1204 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1205 const ref = refs[i2];
1206 if (ref == null) {
1207 continue;
1208 }
1209 switch (typeof ref) {
1210 case "function": {
1211 const cleanupCallback = cleanupCallbacks[i2];
1212 if (typeof cleanupCallback === "function") {
1213 cleanupCallback();
1214 } else {
1215 ref(null);
1216 }
1217 break;
1218 }
1219 case "object": {
1220 ref.current = null;
1221 break;
1222 }
1223 default:
1224 }
1225 }
1226 };
1227 }
1228 };
1229 }
1230
1231 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1232 var React7 = __toESM(require_react(), 1);
1233
1234 // node_modules/@base-ui/utils/esm/reactVersion.js
1235 var React6 = __toESM(require_react(), 1);
1236 var majorVersion = parseInt(React6.version, 10);
1237 function isReactVersionAtLeast(reactVersionToCheck) {
1238 return majorVersion >= reactVersionToCheck;
1239 }
1240
1241 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1242 function getReactElementRef(element) {
1243 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1244 return null;
1245 }
1246 const reactElement = element;
1247 const propsWithRef = reactElement.props;
1248 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1249 }
1250
1251 // node_modules/@base-ui/utils/esm/mergeObjects.js
1252 function mergeObjects(a2, b2) {
1253 if (a2 && !b2) {
1254 return a2;
1255 }
1256 if (!a2 && b2) {
1257 return b2;
1258 }
1259 if (a2 || b2) {
1260 return {
1261 ...a2,
1262 ...b2
1263 };
1264 }
1265 return void 0;
1266 }
1267
1268 // node_modules/@base-ui/utils/esm/empty.js
1269 function NOOP() {
1270 }
1271 var EMPTY_ARRAY = Object.freeze([]);
1272 var EMPTY_OBJECT = Object.freeze({});
1273
1274 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1275 function getStateAttributesProps(state, customMapping) {
1276 const props = {};
1277 for (const key in state) {
1278 const value = state[key];
1279 if (customMapping?.hasOwnProperty(key)) {
1280 const customProps = customMapping[key](value);
1281 if (customProps != null) {
1282 Object.assign(props, customProps);
1283 }
1284 continue;
1285 }
1286 if (value === true) {
1287 props[`data-${key.toLowerCase()}`] = "";
1288 } else if (value) {
1289 props[`data-${key.toLowerCase()}`] = value.toString();
1290 }
1291 }
1292 return props;
1293 }
1294
1295 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1296 function resolveClassName(className, state) {
1297 return typeof className === "function" ? className(state) : className;
1298 }
1299
1300 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1301 function resolveStyle(style, state) {
1302 return typeof style === "function" ? style(state) : style;
1303 }
1304
1305 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1306 var EMPTY_PROPS = {};
1307 function mergeProps(a2, b2, c2, d2, e2) {
1308 if (!c2 && !d2 && !e2 && !a2) {
1309 return createInitialMergedProps(b2);
1310 }
1311 let merged = createInitialMergedProps(a2);
1312 if (b2) {
1313 merged = mergeInto(merged, b2);
1314 }
1315 if (c2) {
1316 merged = mergeInto(merged, c2);
1317 }
1318 if (d2) {
1319 merged = mergeInto(merged, d2);
1320 }
1321 if (e2) {
1322 merged = mergeInto(merged, e2);
1323 }
1324 return merged;
1325 }
1326 function mergePropsN(props) {
1327 if (props.length === 0) {
1328 return EMPTY_PROPS;
1329 }
1330 if (props.length === 1) {
1331 return createInitialMergedProps(props[0]);
1332 }
1333 let merged = createInitialMergedProps(props[0]);
1334 for (let i2 = 1; i2 < props.length; i2 += 1) {
1335 merged = mergeInto(merged, props[i2]);
1336 }
1337 return merged;
1338 }
1339 function createInitialMergedProps(inputProps) {
1340 if (isPropsGetter(inputProps)) {
1341 return {
1342 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1343 };
1344 }
1345 return copyInitialProps(inputProps);
1346 }
1347 function mergeInto(merged, inputProps) {
1348 if (isPropsGetter(inputProps)) {
1349 return resolvePropsGetter(inputProps, merged);
1350 }
1351 return mutablyMergeInto(merged, inputProps);
1352 }
1353 function copyInitialProps(inputProps) {
1354 const copiedProps = {
1355 ...inputProps
1356 };
1357 for (const propName in copiedProps) {
1358 const propValue = copiedProps[propName];
1359 if (isEventHandler(propName, propValue)) {
1360 copiedProps[propName] = wrapEventHandler(propValue);
1361 }
1362 }
1363 return copiedProps;
1364 }
1365 function mutablyMergeInto(mergedProps, externalProps) {
1366 if (!externalProps) {
1367 return mergedProps;
1368 }
1369 for (const propName in externalProps) {
1370 const externalPropValue = externalProps[propName];
1371 switch (propName) {
1372 case "style": {
1373 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1374 break;
1375 }
1376 case "className": {
1377 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1378 break;
1379 }
1380 default: {
1381 if (isEventHandler(propName, externalPropValue)) {
1382 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1383 } else {
1384 mergedProps[propName] = externalPropValue;
1385 }
1386 }
1387 }
1388 }
1389 return mergedProps;
1390 }
1391 function isEventHandler(key, value) {
1392 const code0 = key.charCodeAt(0);
1393 const code1 = key.charCodeAt(1);
1394 const code2 = key.charCodeAt(2);
1395 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1396 }
1397 function isPropsGetter(inputProps) {
1398 return typeof inputProps === "function";
1399 }
1400 function resolvePropsGetter(inputProps, previousProps) {
1401 if (isPropsGetter(inputProps)) {
1402 return inputProps(previousProps);
1403 }
1404 return inputProps ?? EMPTY_PROPS;
1405 }
1406 function mergeEventHandlers(ourHandler, theirHandler) {
1407 if (!theirHandler) {
1408 return ourHandler;
1409 }
1410 if (!ourHandler) {
1411 return wrapEventHandler(theirHandler);
1412 }
1413 return (...args) => {
1414 const event = args[0];
1415 if (isSyntheticEvent(event)) {
1416 const baseUIEvent = event;
1417 makeEventPreventable(baseUIEvent);
1418 const result2 = theirHandler(...args);
1419 if (!baseUIEvent.baseUIHandlerPrevented) {
1420 ourHandler?.(...args);
1421 }
1422 return result2;
1423 }
1424 const result = theirHandler(...args);
1425 ourHandler?.(...args);
1426 return result;
1427 };
1428 }
1429 function wrapEventHandler(handler) {
1430 if (!handler) {
1431 return handler;
1432 }
1433 return (...args) => {
1434 const event = args[0];
1435 if (isSyntheticEvent(event)) {
1436 makeEventPreventable(event);
1437 }
1438 return handler(...args);
1439 };
1440 }
1441 function makeEventPreventable(event) {
1442 event.preventBaseUIHandler = () => {
1443 event.baseUIHandlerPrevented = true;
1444 };
1445 return event;
1446 }
1447 function mergeClassNames(ourClassName, theirClassName) {
1448 if (theirClassName) {
1449 if (ourClassName) {
1450 return theirClassName + " " + ourClassName;
1451 }
1452 return theirClassName;
1453 }
1454 return ourClassName;
1455 }
1456 function isSyntheticEvent(event) {
1457 return event != null && typeof event === "object" && "nativeEvent" in event;
1458 }
1459
1460 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1461 var import_react = __toESM(require_react(), 1);
1462 function useRenderElement(element, componentProps, params = {}) {
1463 const renderProp = componentProps.render;
1464 const outProps = useRenderElementProps(componentProps, params);
1465 if (params.enabled === false) {
1466 return null;
1467 }
1468 const state = params.state ?? EMPTY_OBJECT;
1469 return evaluateRenderProp(element, renderProp, outProps, state);
1470 }
1471 function useRenderElementProps(componentProps, params = {}) {
1472 const {
1473 className: classNameProp,
1474 style: styleProp,
1475 render: renderProp
1476 } = componentProps;
1477 const {
1478 state = EMPTY_OBJECT,
1479 ref,
1480 props,
1481 stateAttributesMapping: stateAttributesMapping7,
1482 enabled = true
1483 } = params;
1484 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1485 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1486 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping7) : EMPTY_OBJECT;
1487 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1488 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1489 if (typeof document !== "undefined") {
1490 if (!enabled) {
1491 useMergedRefs(null, null);
1492 } else if (Array.isArray(ref)) {
1493 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1494 } else {
1495 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1496 }
1497 }
1498 if (!enabled) {
1499 return EMPTY_OBJECT;
1500 }
1501 if (className !== void 0) {
1502 outProps.className = mergeClassNames(outProps.className, className);
1503 }
1504 if (style !== void 0) {
1505 outProps.style = mergeObjects(outProps.style, style);
1506 }
1507 return outProps;
1508 }
1509 function resolveRenderFunctionProps(props) {
1510 if (Array.isArray(props)) {
1511 return mergePropsN(props);
1512 }
1513 return mergeProps(void 0, props);
1514 }
1515 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1516 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1517 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1518 function evaluateRenderProp(element, render4, props, state) {
1519 if (render4) {
1520 if (typeof render4 === "function") {
1521 if (true) {
1522 warnIfRenderPropLooksLikeComponent(render4);
1523 }
1524 return render4(props, state);
1525 }
1526 const mergedProps = mergeProps(props, render4.props);
1527 mergedProps.ref = props.ref;
1528 let newElement = render4;
1529 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1530 const children = React8.Children.toArray(render4);
1531 newElement = children[0];
1532 }
1533 if (true) {
1534 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1535 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"));
1536 }
1537 }
1538 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1539 }
1540 if (element) {
1541 if (typeof element === "string") {
1542 return renderTag(element, props);
1543 }
1544 }
1545 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1546 }
1547 function warnIfRenderPropLooksLikeComponent(renderFn) {
1548 const functionName = renderFn.name;
1549 if (functionName.length === 0) {
1550 return;
1551 }
1552 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1553 return;
1554 }
1555 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1556 return;
1557 }
1558 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");
1559 }
1560 function renderTag(Tag, props) {
1561 if (Tag === "button") {
1562 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1563 type: "button",
1564 ...props,
1565 key: props.key
1566 });
1567 }
1568 if (Tag === "img") {
1569 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1570 alt: "",
1571 ...props,
1572 key: props.key
1573 });
1574 }
1575 return /* @__PURE__ */ React8.createElement(Tag, props);
1576 }
1577
1578 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1579 var reason_parts_exports = {};
1580 __export(reason_parts_exports, {
1581 cancelOpen: () => cancelOpen,
1582 chipRemovePress: () => chipRemovePress,
1583 clearPress: () => clearPress,
1584 closePress: () => closePress,
1585 closeWatcher: () => closeWatcher,
1586 decrementPress: () => decrementPress,
1587 disabled: () => disabled,
1588 drag: () => drag,
1589 escapeKey: () => escapeKey,
1590 focusOut: () => focusOut,
1591 imperativeAction: () => imperativeAction,
1592 incrementPress: () => incrementPress,
1593 inputBlur: () => inputBlur,
1594 inputChange: () => inputChange,
1595 inputClear: () => inputClear,
1596 inputPaste: () => inputPaste,
1597 inputPress: () => inputPress,
1598 itemPress: () => itemPress,
1599 keyboard: () => keyboard,
1600 linkPress: () => linkPress,
1601 listNavigation: () => listNavigation,
1602 none: () => none,
1603 outsidePress: () => outsidePress,
1604 pointer: () => pointer,
1605 scrub: () => scrub,
1606 siblingOpen: () => siblingOpen,
1607 swipe: () => swipe,
1608 trackPress: () => trackPress,
1609 triggerFocus: () => triggerFocus,
1610 triggerHover: () => triggerHover,
1611 triggerPress: () => triggerPress,
1612 wheel: () => wheel,
1613 windowResize: () => windowResize
1614 });
1615 var none = "none";
1616 var triggerPress = "trigger-press";
1617 var triggerHover = "trigger-hover";
1618 var triggerFocus = "trigger-focus";
1619 var outsidePress = "outside-press";
1620 var itemPress = "item-press";
1621 var closePress = "close-press";
1622 var linkPress = "link-press";
1623 var clearPress = "clear-press";
1624 var chipRemovePress = "chip-remove-press";
1625 var trackPress = "track-press";
1626 var incrementPress = "increment-press";
1627 var decrementPress = "decrement-press";
1628 var inputChange = "input-change";
1629 var inputClear = "input-clear";
1630 var inputBlur = "input-blur";
1631 var inputPaste = "input-paste";
1632 var inputPress = "input-press";
1633 var focusOut = "focus-out";
1634 var escapeKey = "escape-key";
1635 var closeWatcher = "close-watcher";
1636 var listNavigation = "list-navigation";
1637 var keyboard = "keyboard";
1638 var pointer = "pointer";
1639 var drag = "drag";
1640 var wheel = "wheel";
1641 var scrub = "scrub";
1642 var cancelOpen = "cancel-open";
1643 var siblingOpen = "sibling-open";
1644 var disabled = "disabled";
1645 var imperativeAction = "imperative-action";
1646 var swipe = "swipe";
1647 var windowResize = "window-resize";
1648
1649 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1650 function createChangeEventDetails(reason, event, trigger, customProperties) {
1651 let canceled = false;
1652 let allowPropagation = false;
1653 const custom = customProperties ?? EMPTY_OBJECT;
1654 const details = {
1655 reason,
1656 event: event ?? new Event("base-ui"),
1657 cancel() {
1658 canceled = true;
1659 },
1660 allowPropagation() {
1661 allowPropagation = true;
1662 },
1663 get isCanceled() {
1664 return canceled;
1665 },
1666 get isPropagationAllowed() {
1667 return allowPropagation;
1668 },
1669 trigger,
1670 ...custom
1671 };
1672 return details;
1673 }
1674
1675 // node_modules/@base-ui/utils/esm/useId.js
1676 var React10 = __toESM(require_react(), 1);
1677
1678 // node_modules/@base-ui/utils/esm/safeReact.js
1679 var React9 = __toESM(require_react(), 1);
1680 var SafeReact = {
1681 ...React9
1682 };
1683
1684 // node_modules/@base-ui/utils/esm/useId.js
1685 var globalId = 0;
1686 function useGlobalId(idOverride, prefix = "mui") {
1687 const [defaultId, setDefaultId] = React10.useState(idOverride);
1688 const id = idOverride || defaultId;
1689 React10.useEffect(() => {
1690 if (defaultId == null) {
1691 globalId += 1;
1692 setDefaultId(`${prefix}-${globalId}`);
1693 }
1694 }, [defaultId, prefix]);
1695 return id;
1696 }
1697 var maybeReactUseId = SafeReact.useId;
1698 function useId(idOverride, prefix) {
1699 if (maybeReactUseId !== void 0) {
1700 const reactId = maybeReactUseId();
1701 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1702 }
1703 return useGlobalId(idOverride, prefix);
1704 }
1705
1706 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1707 function useBaseUiId(idOverride) {
1708 return useId(idOverride, "base-ui");
1709 }
1710
1711 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1712 var React13 = __toESM(require_react(), 1);
1713
1714 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1715 var ReactDOM = __toESM(require_react_dom(), 1);
1716
1717 // node_modules/@base-ui/utils/esm/useOnMount.js
1718 var React11 = __toESM(require_react(), 1);
1719 var EMPTY = [];
1720 function useOnMount(fn) {
1721 React11.useEffect(fn, EMPTY);
1722 }
1723
1724 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1725 var EMPTY2 = null;
1726 var LAST_RAF = globalThis.requestAnimationFrame;
1727 var Scheduler = class {
1728 /* This implementation uses an array as a backing data-structure for frame callbacks.
1729 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1730 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1731 * be much more efficient if there is a call pattern that alterns as
1732 * "request-cancel-request-cancel-…".
1733 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1734 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1735 callbacks = [];
1736 callbacksCount = 0;
1737 nextId = 1;
1738 startId = 1;
1739 isScheduled = false;
1740 tick = (timestamp) => {
1741 this.isScheduled = false;
1742 const currentCallbacks = this.callbacks;
1743 const currentCallbacksCount = this.callbacksCount;
1744 this.callbacks = [];
1745 this.callbacksCount = 0;
1746 this.startId = this.nextId;
1747 if (currentCallbacksCount > 0) {
1748 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1749 currentCallbacks[i2]?.(timestamp);
1750 }
1751 }
1752 };
1753 request(fn) {
1754 const id = this.nextId;
1755 this.nextId += 1;
1756 this.callbacks.push(fn);
1757 this.callbacksCount += 1;
1758 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1759 if (!this.isScheduled || didRAFChange) {
1760 requestAnimationFrame(this.tick);
1761 this.isScheduled = true;
1762 }
1763 return id;
1764 }
1765 cancel(id) {
1766 const index2 = id - this.startId;
1767 if (index2 < 0 || index2 >= this.callbacks.length) {
1768 return;
1769 }
1770 this.callbacks[index2] = null;
1771 this.callbacksCount -= 1;
1772 }
1773 };
1774 var scheduler = new Scheduler();
1775 var AnimationFrame = class _AnimationFrame {
1776 static create() {
1777 return new _AnimationFrame();
1778 }
1779 static request(fn) {
1780 return scheduler.request(fn);
1781 }
1782 static cancel(id) {
1783 return scheduler.cancel(id);
1784 }
1785 currentId = EMPTY2;
1786 /**
1787 * Executes `fn` after `delay`, clearing any previously scheduled call.
1788 */
1789 request(fn) {
1790 this.cancel();
1791 this.currentId = scheduler.request(() => {
1792 this.currentId = EMPTY2;
1793 fn();
1794 });
1795 }
1796 cancel = () => {
1797 if (this.currentId !== EMPTY2) {
1798 scheduler.cancel(this.currentId);
1799 this.currentId = EMPTY2;
1800 }
1801 };
1802 disposeEffect = () => {
1803 return this.cancel;
1804 };
1805 };
1806 function useAnimationFrame() {
1807 const timeout = useRefWithInit(AnimationFrame.create).current;
1808 useOnMount(timeout.disposeEffect);
1809 return timeout;
1810 }
1811
1812 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1813 function resolveRef(maybeRef) {
1814 if (maybeRef == null) {
1815 return maybeRef;
1816 }
1817 return "current" in maybeRef ? maybeRef.current : maybeRef;
1818 }
1819
1820 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1821 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1822 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1823 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1824 return TransitionStatusDataAttributes2;
1825 })({});
1826 var STARTING_HOOK = {
1827 [TransitionStatusDataAttributes.startingStyle]: ""
1828 };
1829 var ENDING_HOOK = {
1830 [TransitionStatusDataAttributes.endingStyle]: ""
1831 };
1832 var transitionStatusMapping = {
1833 transitionStatus(value) {
1834 if (value === "starting") {
1835 return STARTING_HOOK;
1836 }
1837 if (value === "ending") {
1838 return ENDING_HOOK;
1839 }
1840 return null;
1841 }
1842 };
1843
1844 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1845 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1846 const frame = useAnimationFrame();
1847 return useStableCallback((fnToExecute, signal = null) => {
1848 frame.cancel();
1849 const element = resolveRef(elementOrRef);
1850 if (element == null) {
1851 return;
1852 }
1853 const resolvedElement = element;
1854 const done = () => {
1855 ReactDOM.flushSync(fnToExecute);
1856 };
1857 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1858 fnToExecute();
1859 return;
1860 }
1861 function exec() {
1862 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
1863 if (!signal?.aborted) {
1864 done();
1865 }
1866 }).catch(() => {
1867 if (treatAbortedAsFinished) {
1868 if (!signal?.aborted) {
1869 done();
1870 }
1871 return;
1872 }
1873 const currentAnimations = resolvedElement.getAnimations();
1874 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
1875 exec();
1876 }
1877 });
1878 }
1879 if (waitForStartingStyleRemoved) {
1880 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
1881 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1882 frame.request(exec);
1883 return;
1884 }
1885 const attributeObserver = new MutationObserver(() => {
1886 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1887 attributeObserver.disconnect();
1888 exec();
1889 }
1890 });
1891 attributeObserver.observe(resolvedElement, {
1892 attributes: true,
1893 attributeFilter: [startingStyleAttribute]
1894 });
1895 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
1896 once: true
1897 });
1898 return;
1899 }
1900 frame.request(exec);
1901 });
1902 }
1903
1904 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1905 var React12 = __toESM(require_react(), 1);
1906 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1907 const [transitionStatus, setTransitionStatus] = React12.useState(open && enableIdleState ? "idle" : void 0);
1908 const [mounted, setMounted] = React12.useState(open);
1909 if (open && !mounted) {
1910 setMounted(true);
1911 setTransitionStatus("starting");
1912 }
1913 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1914 setTransitionStatus("ending");
1915 }
1916 if (!open && !mounted && transitionStatus === "ending") {
1917 setTransitionStatus(void 0);
1918 }
1919 useIsoLayoutEffect(() => {
1920 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1921 const frame = AnimationFrame.request(() => {
1922 setTransitionStatus("ending");
1923 });
1924 return () => {
1925 AnimationFrame.cancel(frame);
1926 };
1927 }
1928 return void 0;
1929 }, [open, mounted, transitionStatus, deferEndingState]);
1930 useIsoLayoutEffect(() => {
1931 if (!open || enableIdleState) {
1932 return void 0;
1933 }
1934 const frame = AnimationFrame.request(() => {
1935 setTransitionStatus(void 0);
1936 });
1937 return () => {
1938 AnimationFrame.cancel(frame);
1939 };
1940 }, [enableIdleState, open]);
1941 useIsoLayoutEffect(() => {
1942 if (!open || !enableIdleState) {
1943 return void 0;
1944 }
1945 if (open && mounted && transitionStatus !== "idle") {
1946 setTransitionStatus("starting");
1947 }
1948 const frame = AnimationFrame.request(() => {
1949 setTransitionStatus("idle");
1950 });
1951 return () => {
1952 AnimationFrame.cancel(frame);
1953 };
1954 }, [enableIdleState, open, mounted, transitionStatus]);
1955 return {
1956 mounted,
1957 setMounted,
1958 transitionStatus
1959 };
1960 }
1961
1962 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1963 function useCollapsibleRoot(parameters) {
1964 const {
1965 open: openParam,
1966 defaultOpen,
1967 onOpenChange,
1968 disabled: disabled2
1969 } = parameters;
1970 const isControlled = openParam !== void 0;
1971 const [open, setOpen] = useControlled({
1972 controlled: openParam,
1973 default: defaultOpen,
1974 name: "Collapsible",
1975 state: "open"
1976 });
1977 const {
1978 mounted,
1979 setMounted,
1980 transitionStatus
1981 } = useTransitionStatus(open, true, true);
1982 const [visible, setVisible] = React13.useState(open);
1983 const [{
1984 height,
1985 width
1986 }, setDimensions] = React13.useState({
1987 height: void 0,
1988 width: void 0
1989 });
1990 const defaultPanelId = useBaseUiId();
1991 const [panelIdState, setPanelIdState] = React13.useState();
1992 const panelId = panelIdState ?? defaultPanelId;
1993 const [hiddenUntilFound, setHiddenUntilFound] = React13.useState(false);
1994 const [keepMounted, setKeepMounted] = React13.useState(false);
1995 const abortControllerRef = React13.useRef(null);
1996 const animationTypeRef = React13.useRef(null);
1997 const transitionDimensionRef = React13.useRef(null);
1998 const panelRef = React13.useRef(null);
1999 const runOnceAnimationsFinish = useAnimationsFinished(panelRef, false);
2000 const handleTrigger = useStableCallback((event) => {
2001 const nextOpen = !open;
2002 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent);
2003 onOpenChange(nextOpen, eventDetails);
2004 if (eventDetails.isCanceled) {
2005 return;
2006 }
2007 const panel = panelRef.current;
2008 if (animationTypeRef.current === "css-animation" && panel != null) {
2009 panel.style.removeProperty("animation-name");
2010 }
2011 if (!hiddenUntilFound && !keepMounted) {
2012 if (animationTypeRef.current != null && animationTypeRef.current !== "css-animation") {
2013 if (!mounted && nextOpen) {
2014 setMounted(true);
2015 }
2016 }
2017 if (animationTypeRef.current === "css-animation") {
2018 if (!visible && nextOpen) {
2019 setVisible(true);
2020 }
2021 if (!mounted && nextOpen) {
2022 setMounted(true);
2023 }
2024 }
2025 }
2026 setOpen(nextOpen);
2027 if (animationTypeRef.current === "none" && mounted && !nextOpen) {
2028 setMounted(false);
2029 }
2030 });
2031 useIsoLayoutEffect(() => {
2032 if (isControlled && animationTypeRef.current === "none" && !open) {
2033 setMounted(false);
2034 }
2035 }, [isControlled, open, openParam, setMounted]);
2036 return React13.useMemo(() => ({
2037 abortControllerRef,
2038 animationTypeRef,
2039 disabled: disabled2,
2040 handleTrigger,
2041 height,
2042 mounted,
2043 open,
2044 panelId,
2045 panelRef,
2046 runOnceAnimationsFinish,
2047 setDimensions,
2048 setHiddenUntilFound,
2049 setKeepMounted,
2050 setMounted,
2051 setOpen,
2052 setPanelIdState,
2053 setVisible,
2054 transitionDimensionRef,
2055 transitionStatus,
2056 visible,
2057 width
2058 }), [abortControllerRef, animationTypeRef, disabled2, handleTrigger, height, mounted, open, panelId, panelRef, runOnceAnimationsFinish, setDimensions, setHiddenUntilFound, setKeepMounted, setMounted, setOpen, setVisible, transitionDimensionRef, transitionStatus, visible, width]);
2059 }
2060
2061 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRootContext.js
2062 var React14 = __toESM(require_react(), 1);
2063 var CollapsibleRootContext = /* @__PURE__ */ React14.createContext(void 0);
2064 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext";
2065 function useCollapsibleRootContext() {
2066 const context = React14.useContext(CollapsibleRootContext);
2067 if (context === void 0) {
2068 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15));
2069 }
2070 return context;
2071 }
2072
2073 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelDataAttributes.js
2074 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) {
2075 CollapsiblePanelDataAttributes2["open"] = "data-open";
2076 CollapsiblePanelDataAttributes2["closed"] = "data-closed";
2077 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
2078 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
2079 return CollapsiblePanelDataAttributes2;
2080 })({});
2081
2082 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTriggerDataAttributes.js
2083 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) {
2084 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open";
2085 return CollapsibleTriggerDataAttributes2;
2086 })({});
2087
2088 // node_modules/@base-ui/react/esm/utils/collapsibleOpenStateMapping.js
2089 var PANEL_OPEN_HOOK = {
2090 [CollapsiblePanelDataAttributes.open]: ""
2091 };
2092 var PANEL_CLOSED_HOOK = {
2093 [CollapsiblePanelDataAttributes.closed]: ""
2094 };
2095 var triggerOpenStateMapping = {
2096 open(value) {
2097 if (value) {
2098 return {
2099 [CollapsibleTriggerDataAttributes.panelOpen]: ""
2100 };
2101 }
2102 return null;
2103 }
2104 };
2105 var collapsibleOpenStateMapping = {
2106 open(value) {
2107 if (value) {
2108 return PANEL_OPEN_HOOK;
2109 }
2110 return PANEL_CLOSED_HOOK;
2111 }
2112 };
2113
2114 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
2115 var React17 = __toESM(require_react(), 1);
2116
2117 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2118 function hasWindow() {
2119 return typeof window !== "undefined";
2120 }
2121 function getNodeName(node) {
2122 if (isNode(node)) {
2123 return (node.nodeName || "").toLowerCase();
2124 }
2125 return "#document";
2126 }
2127 function getWindow(node) {
2128 var _node$ownerDocument;
2129 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2130 }
2131 function getDocumentElement(node) {
2132 var _ref;
2133 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2134 }
2135 function isNode(value) {
2136 if (!hasWindow()) {
2137 return false;
2138 }
2139 return value instanceof Node || value instanceof getWindow(value).Node;
2140 }
2141 function isElement(value) {
2142 if (!hasWindow()) {
2143 return false;
2144 }
2145 return value instanceof Element || value instanceof getWindow(value).Element;
2146 }
2147 function isHTMLElement(value) {
2148 if (!hasWindow()) {
2149 return false;
2150 }
2151 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2152 }
2153 function isShadowRoot(value) {
2154 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2155 return false;
2156 }
2157 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2158 }
2159 function isOverflowElement(element) {
2160 const {
2161 overflow,
2162 overflowX,
2163 overflowY,
2164 display
2165 } = getComputedStyle2(element);
2166 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2167 }
2168 function isTableElement(element) {
2169 return /^(table|td|th)$/.test(getNodeName(element));
2170 }
2171 function isTopLayer(element) {
2172 try {
2173 if (element.matches(":popover-open")) {
2174 return true;
2175 }
2176 } catch (_e) {
2177 }
2178 try {
2179 return element.matches(":modal");
2180 } catch (_e) {
2181 return false;
2182 }
2183 }
2184 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2185 var containRe = /paint|layout|strict|content/;
2186 var isNotNone = (value) => !!value && value !== "none";
2187 var isWebKitValue;
2188 function isContainingBlock(elementOrCss) {
2189 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2190 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 || "");
2191 }
2192 function getContainingBlock(element) {
2193 let currentNode = getParentNode(element);
2194 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2195 if (isContainingBlock(currentNode)) {
2196 return currentNode;
2197 } else if (isTopLayer(currentNode)) {
2198 return null;
2199 }
2200 currentNode = getParentNode(currentNode);
2201 }
2202 return null;
2203 }
2204 function isWebKit() {
2205 if (isWebKitValue == null) {
2206 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2207 }
2208 return isWebKitValue;
2209 }
2210 function isLastTraversableNode(node) {
2211 return /^(html|body|#document)$/.test(getNodeName(node));
2212 }
2213 function getComputedStyle2(element) {
2214 return getWindow(element).getComputedStyle(element);
2215 }
2216 function getNodeScroll(element) {
2217 if (isElement(element)) {
2218 return {
2219 scrollLeft: element.scrollLeft,
2220 scrollTop: element.scrollTop
2221 };
2222 }
2223 return {
2224 scrollLeft: element.scrollX,
2225 scrollTop: element.scrollY
2226 };
2227 }
2228 function getParentNode(node) {
2229 if (getNodeName(node) === "html") {
2230 return node;
2231 }
2232 const result = (
2233 // Step into the shadow DOM of the parent of a slotted node.
2234 node.assignedSlot || // DOM Element detected.
2235 node.parentNode || // ShadowRoot detected.
2236 isShadowRoot(node) && node.host || // Fallback.
2237 getDocumentElement(node)
2238 );
2239 return isShadowRoot(result) ? result.host : result;
2240 }
2241 function getNearestOverflowAncestor(node) {
2242 const parentNode = getParentNode(node);
2243 if (isLastTraversableNode(parentNode)) {
2244 return node.ownerDocument ? node.ownerDocument.body : node.body;
2245 }
2246 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2247 return parentNode;
2248 }
2249 return getNearestOverflowAncestor(parentNode);
2250 }
2251 function getOverflowAncestors(node, list, traverseIframes) {
2252 var _node$ownerDocument2;
2253 if (list === void 0) {
2254 list = [];
2255 }
2256 if (traverseIframes === void 0) {
2257 traverseIframes = true;
2258 }
2259 const scrollableAncestor = getNearestOverflowAncestor(node);
2260 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2261 const win = getWindow(scrollableAncestor);
2262 if (isBody) {
2263 const frameElement = getFrameElement(win);
2264 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2265 } else {
2266 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2267 }
2268 }
2269 function getFrameElement(win) {
2270 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2271 }
2272
2273 // node_modules/@base-ui/react/esm/internals/composite/root/CompositeRootContext.js
2274 var React15 = __toESM(require_react(), 1);
2275 var CompositeRootContext = /* @__PURE__ */ React15.createContext(void 0);
2276 if (true) CompositeRootContext.displayName = "CompositeRootContext";
2277 function useCompositeRootContext(optional = false) {
2278 const context = React15.useContext(CompositeRootContext);
2279 if (context === void 0 && !optional) {
2280 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16));
2281 }
2282 return context;
2283 }
2284
2285 // node_modules/@base-ui/react/esm/utils/useFocusableWhenDisabled.js
2286 var React16 = __toESM(require_react(), 1);
2287 function useFocusableWhenDisabled(parameters) {
2288 const {
2289 focusableWhenDisabled,
2290 disabled: disabled2,
2291 composite = false,
2292 tabIndex: tabIndexProp = 0,
2293 isNativeButton
2294 } = parameters;
2295 const isFocusableComposite = composite && focusableWhenDisabled !== false;
2296 const isNonFocusableComposite = composite && focusableWhenDisabled === false;
2297 const props = React16.useMemo(() => {
2298 const additionalProps = {
2299 // allow Tabbing away from focusableWhenDisabled elements
2300 onKeyDown(event) {
2301 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") {
2302 event.preventDefault();
2303 }
2304 }
2305 };
2306 if (!composite) {
2307 additionalProps.tabIndex = tabIndexProp;
2308 if (!isNativeButton && disabled2) {
2309 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
2310 }
2311 }
2312 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) {
2313 additionalProps["aria-disabled"] = disabled2;
2314 }
2315 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
2316 additionalProps.disabled = disabled2;
2317 }
2318 return additionalProps;
2319 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);
2320 return {
2321 props
2322 };
2323 }
2324
2325 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
2326 function useButton(parameters = {}) {
2327 const {
2328 disabled: disabled2 = false,
2329 focusableWhenDisabled,
2330 tabIndex = 0,
2331 native: isNativeButton = true,
2332 composite: compositeProp
2333 } = parameters;
2334 const elementRef = React17.useRef(null);
2335 const compositeRootContext = useCompositeRootContext(true);
2336 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
2337 const {
2338 props: focusableWhenDisabledProps
2339 } = useFocusableWhenDisabled({
2340 focusableWhenDisabled,
2341 disabled: disabled2,
2342 composite: isCompositeItem,
2343 tabIndex,
2344 isNativeButton
2345 });
2346 if (true) {
2347 React17.useEffect(() => {
2348 if (!elementRef.current) {
2349 return;
2350 }
2351 const isButtonTag = isButtonElement(elementRef.current);
2352 if (isNativeButton) {
2353 if (!isButtonTag) {
2354 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2355 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`.";
2356 error(`${message2}${ownerStackMessage}`);
2357 }
2358 } else if (isButtonTag) {
2359 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2360 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`.";
2361 error(`${message2}${ownerStackMessage}`);
2362 }
2363 }, [isNativeButton]);
2364 }
2365 const updateDisabled = React17.useCallback(() => {
2366 const element = elementRef.current;
2367 if (!isButtonElement(element)) {
2368 return;
2369 }
2370 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
2371 element.disabled = false;
2372 }
2373 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]);
2374 useIsoLayoutEffect(updateDisabled, [updateDisabled]);
2375 const getButtonProps = React17.useCallback((externalProps = {}) => {
2376 const {
2377 onClick: externalOnClick,
2378 onMouseDown: externalOnMouseDown,
2379 onKeyUp: externalOnKeyUp,
2380 onKeyDown: externalOnKeyDown,
2381 onPointerDown: externalOnPointerDown,
2382 ...otherExternalProps
2383 } = externalProps;
2384 const type = isNativeButton ? "button" : void 0;
2385 return mergeProps({
2386 type,
2387 onClick(event) {
2388 if (disabled2) {
2389 event.preventDefault();
2390 return;
2391 }
2392 externalOnClick?.(event);
2393 },
2394 onMouseDown(event) {
2395 if (!disabled2) {
2396 externalOnMouseDown?.(event);
2397 }
2398 },
2399 onKeyDown(event) {
2400 if (disabled2) {
2401 return;
2402 }
2403 makeEventPreventable(event);
2404 externalOnKeyDown?.(event);
2405 if (event.baseUIHandlerPrevented) {
2406 return;
2407 }
2408 const isCurrentTarget = event.target === event.currentTarget;
2409 const currentTarget = event.currentTarget;
2410 const isButton2 = isButtonElement(currentTarget);
2411 const isLink = !isNativeButton && isValidLinkElement(currentTarget);
2412 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink);
2413 const isEnterKey = event.key === "Enter";
2414 const isSpaceKey = event.key === " ";
2415 const role = currentTarget.getAttribute("role");
2416 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
2417 if (isCurrentTarget && isCompositeItem && isSpaceKey) {
2418 if (event.defaultPrevented && isTextNavigationRole) {
2419 return;
2420 }
2421 event.preventDefault();
2422 if (isLink || isNativeButton && isButton2) {
2423 currentTarget.click();
2424 event.preventBaseUIHandler();
2425 } else if (shouldClick) {
2426 externalOnClick?.(event);
2427 event.preventBaseUIHandler();
2428 }
2429 return;
2430 }
2431 if (shouldClick) {
2432 if (!isNativeButton && (isSpaceKey || isEnterKey)) {
2433 event.preventDefault();
2434 }
2435 if (!isNativeButton && isEnterKey) {
2436 externalOnClick?.(event);
2437 }
2438 }
2439 },
2440 onKeyUp(event) {
2441 if (disabled2) {
2442 return;
2443 }
2444 makeEventPreventable(event);
2445 externalOnKeyUp?.(event);
2446 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
2447 event.preventDefault();
2448 return;
2449 }
2450 if (event.baseUIHandlerPrevented) {
2451 return;
2452 }
2453 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") {
2454 externalOnClick?.(event);
2455 }
2456 },
2457 onPointerDown(event) {
2458 if (disabled2) {
2459 event.preventDefault();
2460 return;
2461 }
2462 externalOnPointerDown?.(event);
2463 }
2464 }, !isNativeButton ? {
2465 role: "button"
2466 } : void 0, focusableWhenDisabledProps, otherExternalProps);
2467 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
2468 const buttonRef = useStableCallback((element) => {
2469 elementRef.current = element;
2470 updateDisabled();
2471 });
2472 return {
2473 getButtonProps,
2474 buttonRef
2475 };
2476 }
2477 function isButtonElement(elem) {
2478 return isHTMLElement(elem) && elem.tagName === "BUTTON";
2479 }
2480 function isValidLinkElement(elem) {
2481 return Boolean(elem?.tagName === "A" && elem?.href);
2482 }
2483
2484 // node_modules/@base-ui/utils/esm/detectBrowser.js
2485 var hasNavigator = typeof navigator !== "undefined";
2486 var nav = getNavigatorData();
2487 var platform = getPlatform();
2488 var userAgent = getUserAgent();
2489 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2490 var isIOS = (
2491 // iPads can claim to be MacIntel
2492 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2493 );
2494 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2495 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2496 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2497 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2498 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2499 var isJSDOM = userAgent.includes("jsdom/");
2500 function getNavigatorData() {
2501 if (!hasNavigator) {
2502 return {
2503 platform: "",
2504 maxTouchPoints: -1
2505 };
2506 }
2507 const uaData = navigator.userAgentData;
2508 if (uaData?.platform) {
2509 return {
2510 platform: uaData.platform,
2511 maxTouchPoints: navigator.maxTouchPoints
2512 };
2513 }
2514 return {
2515 platform: navigator.platform ?? "",
2516 maxTouchPoints: navigator.maxTouchPoints ?? -1
2517 };
2518 }
2519 function getUserAgent() {
2520 if (!hasNavigator) {
2521 return "";
2522 }
2523 const uaData = navigator.userAgentData;
2524 if (uaData && Array.isArray(uaData.brands)) {
2525 return uaData.brands.map(({
2526 brand,
2527 version: version2
2528 }) => `${brand}/${version2}`).join(" ");
2529 }
2530 return navigator.userAgent;
2531 }
2532 function getPlatform() {
2533 if (!hasNavigator) {
2534 return "";
2535 }
2536 const uaData = navigator.userAgentData;
2537 if (uaData?.platform) {
2538 return uaData.platform;
2539 }
2540 return navigator.platform ?? "";
2541 }
2542
2543 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2544 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2545 var ACTIVE_KEY = "active";
2546 var SELECTED_KEY = "selected";
2547 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2548
2549 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2550 function activeElement(doc) {
2551 let element = doc.activeElement;
2552 while (element?.shadowRoot?.activeElement != null) {
2553 element = element.shadowRoot.activeElement;
2554 }
2555 return element;
2556 }
2557 function contains(parent, child) {
2558 if (!parent || !child) {
2559 return false;
2560 }
2561 const rootNode = child.getRootNode?.();
2562 if (parent.contains(child)) {
2563 return true;
2564 }
2565 if (rootNode && isShadowRoot(rootNode)) {
2566 let next = child;
2567 while (next) {
2568 if (parent === next) {
2569 return true;
2570 }
2571 next = next.parentNode || next.host;
2572 }
2573 }
2574 return false;
2575 }
2576 function getTarget(event) {
2577 if ("composedPath" in event) {
2578 return event.composedPath()[0];
2579 }
2580 return event.target;
2581 }
2582
2583 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2584 function isTargetInsideEnabledTrigger(target, triggerElements) {
2585 if (!isElement(target)) {
2586 return false;
2587 }
2588 const targetElement = target;
2589 if (triggerElements.hasElement(targetElement)) {
2590 return !targetElement.hasAttribute("data-trigger-disabled");
2591 }
2592 for (const [, trigger] of triggerElements.entries()) {
2593 if (contains(trigger, targetElement)) {
2594 return !trigger.hasAttribute("data-trigger-disabled");
2595 }
2596 }
2597 return false;
2598 }
2599 function isEventTargetWithin(event, node) {
2600 if (node == null) {
2601 return false;
2602 }
2603 if ("composedPath" in event) {
2604 return event.composedPath().includes(node);
2605 }
2606 const eventAgain = event;
2607 return eventAgain.target != null && node.contains(eventAgain.target);
2608 }
2609 function isRootElement(element) {
2610 return element.matches("html,body");
2611 }
2612 function isTypeableElement(element) {
2613 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2614 }
2615 function isInteractiveElement(element) {
2616 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2617 }
2618 function isTypeableCombobox(element) {
2619 if (!element) {
2620 return false;
2621 }
2622 return element.getAttribute("role") === "combobox" && isTypeableElement(element);
2623 }
2624 function matchesFocusVisible(element) {
2625 if (!element || isJSDOM) {
2626 return true;
2627 }
2628 try {
2629 return element.matches(":focus-visible");
2630 } catch (_e) {
2631 return true;
2632 }
2633 }
2634 function getFloatingFocusElement(floatingElement) {
2635 if (!floatingElement) {
2636 return null;
2637 }
2638 return floatingElement.hasAttribute(FOCUSABLE_ATTRIBUTE) ? floatingElement : floatingElement.querySelector(`[${FOCUSABLE_ATTRIBUTE}]`) || floatingElement;
2639 }
2640
2641 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2642 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2643 const directChildren = nodes.filter((node) => node.parentId === id);
2644 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2645 }
2646 function getNodeAncestors(nodes, id) {
2647 let allAncestors = [];
2648 let currentParentId = nodes.find((node) => node.id === id)?.parentId;
2649 while (currentParentId) {
2650 const currentNode = nodes.find((node) => node.id === currentParentId);
2651 currentParentId = currentNode?.parentId;
2652 if (currentNode) {
2653 allAncestors = allAncestors.concat(currentNode);
2654 }
2655 }
2656 return allAncestors;
2657 }
2658
2659 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2660 function stopEvent(event) {
2661 event.preventDefault();
2662 event.stopPropagation();
2663 }
2664 function isReactEvent(event) {
2665 return "nativeEvent" in event;
2666 }
2667 function isVirtualClick(event) {
2668 if (event.pointerType === "" && event.isTrusted) {
2669 return true;
2670 }
2671 if (isAndroid && event.pointerType) {
2672 return event.type === "click" && event.buttons === 1;
2673 }
2674 return event.detail === 0 && !event.pointerType;
2675 }
2676 function isVirtualPointerEvent(event) {
2677 if (isJSDOM) {
2678 return false;
2679 }
2680 return !isAndroid && event.width === 0 && event.height === 0 || isAndroid && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
2681 event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch";
2682 }
2683 function isMouseLikePointerType(pointerType, strict) {
2684 const values = ["mouse", "pen"];
2685 if (!strict) {
2686 values.push("", void 0);
2687 }
2688 return values.includes(pointerType);
2689 }
2690 function isClickLikeEvent(event) {
2691 const type = event.type;
2692 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2693 }
2694
2695 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2696 var sides = ["top", "right", "bottom", "left"];
2697 var min = Math.min;
2698 var max = Math.max;
2699 var round = Math.round;
2700 var floor = Math.floor;
2701 var createCoords = (v2) => ({
2702 x: v2,
2703 y: v2
2704 });
2705 var oppositeSideMap = {
2706 left: "right",
2707 right: "left",
2708 bottom: "top",
2709 top: "bottom"
2710 };
2711 function clamp(start, value, end) {
2712 return max(start, min(value, end));
2713 }
2714 function evaluate(value, param) {
2715 return typeof value === "function" ? value(param) : value;
2716 }
2717 function getSide(placement) {
2718 return placement.split("-")[0];
2719 }
2720 function getAlignment(placement) {
2721 return placement.split("-")[1];
2722 }
2723 function getOppositeAxis(axis) {
2724 return axis === "x" ? "y" : "x";
2725 }
2726 function getAxisLength(axis) {
2727 return axis === "y" ? "height" : "width";
2728 }
2729 function getSideAxis(placement) {
2730 const firstChar = placement[0];
2731 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2732 }
2733 function getAlignmentAxis(placement) {
2734 return getOppositeAxis(getSideAxis(placement));
2735 }
2736 function getAlignmentSides(placement, rects, rtl) {
2737 if (rtl === void 0) {
2738 rtl = false;
2739 }
2740 const alignment = getAlignment(placement);
2741 const alignmentAxis = getAlignmentAxis(placement);
2742 const length = getAxisLength(alignmentAxis);
2743 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2744 if (rects.reference[length] > rects.floating[length]) {
2745 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2746 }
2747 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2748 }
2749 function getExpandedPlacements(placement) {
2750 const oppositePlacement = getOppositePlacement(placement);
2751 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2752 }
2753 function getOppositeAlignmentPlacement(placement) {
2754 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2755 }
2756 var lrPlacement = ["left", "right"];
2757 var rlPlacement = ["right", "left"];
2758 var tbPlacement = ["top", "bottom"];
2759 var btPlacement = ["bottom", "top"];
2760 function getSideList(side, isStart, rtl) {
2761 switch (side) {
2762 case "top":
2763 case "bottom":
2764 if (rtl) return isStart ? rlPlacement : lrPlacement;
2765 return isStart ? lrPlacement : rlPlacement;
2766 case "left":
2767 case "right":
2768 return isStart ? tbPlacement : btPlacement;
2769 default:
2770 return [];
2771 }
2772 }
2773 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2774 const alignment = getAlignment(placement);
2775 let list = getSideList(getSide(placement), direction === "start", rtl);
2776 if (alignment) {
2777 list = list.map((side) => side + "-" + alignment);
2778 if (flipAlignment) {
2779 list = list.concat(list.map(getOppositeAlignmentPlacement));
2780 }
2781 }
2782 return list;
2783 }
2784 function getOppositePlacement(placement) {
2785 const side = getSide(placement);
2786 return oppositeSideMap[side] + placement.slice(side.length);
2787 }
2788 function expandPaddingObject(padding) {
2789 return {
2790 top: 0,
2791 right: 0,
2792 bottom: 0,
2793 left: 0,
2794 ...padding
2795 };
2796 }
2797 function getPaddingObject(padding) {
2798 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2799 top: padding,
2800 right: padding,
2801 bottom: padding,
2802 left: padding
2803 };
2804 }
2805 function rectToClientRect(rect) {
2806 const {
2807 x: x2,
2808 y: y2,
2809 width,
2810 height
2811 } = rect;
2812 return {
2813 width,
2814 height,
2815 top: y2,
2816 left: x2,
2817 right: x2 + width,
2818 bottom: y2 + height,
2819 x: x2,
2820 y: y2
2821 };
2822 }
2823
2824 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2825 function isHiddenByStyles(styles) {
2826 return styles.visibility === "hidden" || styles.visibility === "collapse";
2827 }
2828 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2829 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2830 return false;
2831 }
2832 if (typeof element.checkVisibility === "function") {
2833 return element.checkVisibility();
2834 }
2835 return styles.display !== "none" && styles.display !== "contents";
2836 }
2837
2838 // node_modules/@base-ui/utils/esm/owner.js
2839 function ownerDocument(node) {
2840 return node?.ownerDocument || document;
2841 }
2842
2843 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2844 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2845 function getParentElement(element) {
2846 const assignedSlot = element.assignedSlot;
2847 if (assignedSlot) {
2848 return assignedSlot;
2849 }
2850 if (element.parentElement) {
2851 return element.parentElement;
2852 }
2853 const rootNode = element.getRootNode();
2854 return isShadowRoot(rootNode) ? rootNode.host : null;
2855 }
2856 function getDetailsSummary(details) {
2857 for (const child of Array.from(details.children)) {
2858 if (getNodeName(child) === "summary") {
2859 return child;
2860 }
2861 }
2862 return null;
2863 }
2864 function isWithinOpenDetailsSummary(element, details) {
2865 const summary = getDetailsSummary(details);
2866 return !!summary && (element === summary || contains(summary, element));
2867 }
2868 function isFocusableCandidate(element) {
2869 const nodeName = element ? getNodeName(element) : "";
2870 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");
2871 }
2872 function isFocusableElement(element) {
2873 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2874 return false;
2875 }
2876 for (let current = element; current; current = getParentElement(current)) {
2877 const isAncestor = current !== element;
2878 const isSlot = getNodeName(current) === "slot";
2879 if (current.hasAttribute("inert")) {
2880 return false;
2881 }
2882 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2883 return false;
2884 }
2885 }
2886 return true;
2887 }
2888 function isVisibleInTabbableTree(element, isAncestor) {
2889 const styles = getComputedStyle2(element);
2890 if (!isAncestor) {
2891 return isElementVisible(element, styles);
2892 }
2893 return styles.display !== "none";
2894 }
2895 function getTabIndex(element) {
2896 const tabIndex = element.tabIndex;
2897 if (tabIndex < 0) {
2898 const nodeName = getNodeName(element);
2899 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2900 return 0;
2901 }
2902 }
2903 return tabIndex;
2904 }
2905 function getNamedRadioInput(element) {
2906 if (getNodeName(element) !== "input") {
2907 return null;
2908 }
2909 const input = element;
2910 return input.type === "radio" && input.name !== "" ? input : null;
2911 }
2912 function isTabbableRadio(element, candidates) {
2913 const input = getNamedRadioInput(element);
2914 if (!input) {
2915 return true;
2916 }
2917 const checkedRadio = candidates.find((candidate) => {
2918 const radio = getNamedRadioInput(candidate);
2919 return radio?.name === input.name && radio.form === input.form && radio.checked;
2920 });
2921 if (checkedRadio) {
2922 return checkedRadio === input;
2923 }
2924 return candidates.find((candidate) => {
2925 const radio = getNamedRadioInput(candidate);
2926 return radio?.name === input.name && radio.form === input.form;
2927 }) === input;
2928 }
2929 function getComposedChildren(container) {
2930 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2931 const assignedElements = container.assignedElements({
2932 flatten: true
2933 });
2934 if (assignedElements.length > 0) {
2935 return assignedElements;
2936 }
2937 }
2938 if (isHTMLElement(container) && container.shadowRoot) {
2939 return Array.from(container.shadowRoot.children);
2940 }
2941 return Array.from(container.children);
2942 }
2943 function appendCandidates(container, list) {
2944 getComposedChildren(container).forEach((child) => {
2945 if (isFocusableCandidate(child)) {
2946 list.push(child);
2947 }
2948 appendCandidates(child, list);
2949 });
2950 }
2951 function appendMatchingElements(container, selector2, list) {
2952 getComposedChildren(container).forEach((child) => {
2953 if (isHTMLElement(child) && child.matches(selector2)) {
2954 list.push(child);
2955 }
2956 appendMatchingElements(child, selector2, list);
2957 });
2958 }
2959 function isTabbable(element) {
2960 return isFocusableElement(element) && getTabIndex(element) >= 0;
2961 }
2962 function focusable(container) {
2963 const candidates = [];
2964 appendCandidates(container, candidates);
2965 return candidates.filter(isFocusableElement);
2966 }
2967 function tabbable(container) {
2968 const candidates = focusable(container);
2969 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2970 }
2971 function getTabbableIn(container, dir) {
2972 const list = tabbable(container);
2973 const len = list.length;
2974 if (len === 0) {
2975 return void 0;
2976 }
2977 const active = activeElement(ownerDocument(container));
2978 const index2 = list.indexOf(active);
2979 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2980 return list[nextIndex];
2981 }
2982 function getNextTabbable(referenceElement) {
2983 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2984 }
2985 function getPreviousTabbable(referenceElement) {
2986 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2987 }
2988 function getTabbableNearElement(referenceElement, dir) {
2989 if (!referenceElement) {
2990 return null;
2991 }
2992 const list = tabbable(ownerDocument(referenceElement).body);
2993 const elementCount = list.length;
2994 if (elementCount === 0) {
2995 return null;
2996 }
2997 const index2 = list.indexOf(referenceElement);
2998 if (index2 === -1) {
2999 return null;
3000 }
3001 const nextIndex = (index2 + dir + elementCount) % elementCount;
3002 return list[nextIndex];
3003 }
3004 function getTabbableAfterElement(referenceElement) {
3005 return getTabbableNearElement(referenceElement, 1);
3006 }
3007 function getTabbableBeforeElement(referenceElement) {
3008 return getTabbableNearElement(referenceElement, -1);
3009 }
3010 function isOutsideEvent(event, container) {
3011 const containerElement = container || event.currentTarget;
3012 const relatedTarget = event.relatedTarget;
3013 return !relatedTarget || !contains(containerElement, relatedTarget);
3014 }
3015 function disableFocusInside(container) {
3016 const tabbableElements = tabbable(container);
3017 tabbableElements.forEach((element) => {
3018 element.dataset.tabindex = element.getAttribute("tabindex") || "";
3019 element.setAttribute("tabindex", "-1");
3020 });
3021 }
3022 function enableFocusInside(container) {
3023 const elements = [];
3024 appendMatchingElements(container, "[data-tabindex]", elements);
3025 elements.forEach((element) => {
3026 const tabindex = element.dataset.tabindex;
3027 delete element.dataset.tabindex;
3028 if (tabindex) {
3029 element.setAttribute("tabindex", tabindex);
3030 } else {
3031 element.removeAttribute("tabindex");
3032 }
3033 });
3034 }
3035
3036 // node_modules/@base-ui/react/esm/internals/composite/composite.js
3037 var ARROW_UP = "ArrowUp";
3038 var ARROW_DOWN = "ArrowDown";
3039 var ARROW_LEFT = "ArrowLeft";
3040 var ARROW_RIGHT = "ArrowRight";
3041 var HOME = "Home";
3042 var END = "End";
3043 var HORIZONTAL_KEYS = /* @__PURE__ */ new Set([ARROW_LEFT, ARROW_RIGHT]);
3044 var VERTICAL_KEYS = /* @__PURE__ */ new Set([ARROW_UP, ARROW_DOWN]);
3045 var ARROW_KEYS = /* @__PURE__ */ new Set([...HORIZONTAL_KEYS, ...VERTICAL_KEYS]);
3046 var ALL_KEYS = /* @__PURE__ */ new Set([...ARROW_KEYS, HOME, END]);
3047 var COMPOSITE_KEYS = /* @__PURE__ */ new Set([ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, HOME, END]);
3048
3049 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
3050 var React18 = __toESM(require_react(), 1);
3051
3052 // node_modules/@base-ui/utils/esm/addEventListener.js
3053 function addEventListener(target, type, listener, options) {
3054 target.addEventListener(type, listener, options);
3055 return () => {
3056 target.removeEventListener(type, listener, options);
3057 };
3058 }
3059
3060 // node_modules/@base-ui/react/esm/accordion/root/AccordionRootDataAttributes.js
3061 var AccordionRootDataAttributes = /* @__PURE__ */ (function(AccordionRootDataAttributes2) {
3062 AccordionRootDataAttributes2["disabled"] = "data-disabled";
3063 AccordionRootDataAttributes2["orientation"] = "data-orientation";
3064 return AccordionRootDataAttributes2;
3065 })({});
3066
3067 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
3068 function useCollapsiblePanel(parameters) {
3069 const {
3070 abortControllerRef,
3071 animationTypeRef,
3072 externalRef,
3073 height,
3074 hiddenUntilFound,
3075 keepMounted,
3076 id: idParam,
3077 mounted,
3078 onOpenChange,
3079 open,
3080 panelRef,
3081 runOnceAnimationsFinish,
3082 setDimensions,
3083 setMounted,
3084 setOpen,
3085 setVisible,
3086 transitionDimensionRef,
3087 visible,
3088 width
3089 } = parameters;
3090 const isBeforeMatchRef = React18.useRef(false);
3091 const latestAnimationNameRef = React18.useRef(null);
3092 const shouldCancelInitialOpenAnimationRef = React18.useRef(open);
3093 const shouldCancelInitialOpenTransitionRef = React18.useRef(open);
3094 const endingStyleFrame = useAnimationFrame();
3095 const hidden = React18.useMemo(() => {
3096 if (animationTypeRef.current === "css-animation") {
3097 return !visible;
3098 }
3099 return !open && !mounted;
3100 }, [open, mounted, visible, animationTypeRef]);
3101 const handlePanelRef = useStableCallback((element) => {
3102 if (!element) {
3103 return void 0;
3104 }
3105 if (animationTypeRef.current == null || transitionDimensionRef.current == null) {
3106 const panelStyles = getComputedStyle(element);
3107 const hasAnimation = panelStyles.animationName !== "none" && panelStyles.animationName !== "";
3108 const hasTransition = panelStyles.transitionDuration !== "0s" && panelStyles.transitionDuration !== "";
3109 if (hasAnimation && hasTransition) {
3110 if (true) {
3111 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used.");
3112 }
3113 } else if (panelStyles.animationName === "none" && panelStyles.transitionDuration !== "0s") {
3114 animationTypeRef.current = "css-transition";
3115 } else if (panelStyles.animationName !== "none" && panelStyles.transitionDuration === "0s") {
3116 animationTypeRef.current = "css-animation";
3117 } else {
3118 animationTypeRef.current = "none";
3119 }
3120 if (element.getAttribute(AccordionRootDataAttributes.orientation) === "horizontal" || panelStyles.transitionProperty.indexOf("width") > -1) {
3121 transitionDimensionRef.current = "width";
3122 } else {
3123 transitionDimensionRef.current = "height";
3124 }
3125 }
3126 if (animationTypeRef.current !== "css-transition") {
3127 return void 0;
3128 }
3129 if (height === void 0 || width === void 0) {
3130 setDimensions({
3131 height: element.scrollHeight,
3132 width: element.scrollWidth
3133 });
3134 if (shouldCancelInitialOpenTransitionRef.current) {
3135 element.style.setProperty("transition-duration", "0s");
3136 }
3137 }
3138 let frame = -1;
3139 let nextFrame = -1;
3140 frame = AnimationFrame.request(() => {
3141 shouldCancelInitialOpenTransitionRef.current = false;
3142 nextFrame = AnimationFrame.request(() => {
3143 setTimeout(() => {
3144 element.style.removeProperty("transition-duration");
3145 });
3146 });
3147 });
3148 return () => {
3149 AnimationFrame.cancel(frame);
3150 AnimationFrame.cancel(nextFrame);
3151 };
3152 });
3153 const mergedPanelRef = useMergedRefs(externalRef, panelRef, handlePanelRef);
3154 useIsoLayoutEffect(() => {
3155 if (animationTypeRef.current !== "css-transition") {
3156 return void 0;
3157 }
3158 const panel = panelRef.current;
3159 if (!panel) {
3160 return void 0;
3161 }
3162 let resizeFrame = -1;
3163 if (abortControllerRef.current != null) {
3164 abortControllerRef.current.abort();
3165 abortControllerRef.current = null;
3166 }
3167 if (open) {
3168 const originalLayoutStyles = {
3169 "justify-content": panel.style.justifyContent,
3170 "align-items": panel.style.alignItems,
3171 "align-content": panel.style.alignContent,
3172 "justify-items": panel.style.justifyItems
3173 };
3174 Object.keys(originalLayoutStyles).forEach((key) => {
3175 panel.style.setProperty(key, "initial", "important");
3176 });
3177 if (!shouldCancelInitialOpenTransitionRef.current && !keepMounted) {
3178 panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, "");
3179 }
3180 setDimensions({
3181 height: panel.scrollHeight,
3182 width: panel.scrollWidth
3183 });
3184 resizeFrame = AnimationFrame.request(() => {
3185 Object.entries(originalLayoutStyles).forEach(([key, value]) => {
3186 if (value === "") {
3187 panel.style.removeProperty(key);
3188 } else {
3189 panel.style.setProperty(key, value);
3190 }
3191 });
3192 });
3193 } else {
3194 if (panel.scrollHeight === 0 && panel.scrollWidth === 0) {
3195 return void 0;
3196 }
3197 setDimensions({
3198 height: panel.scrollHeight,
3199 width: panel.scrollWidth
3200 });
3201 const abortController = new AbortController();
3202 abortControllerRef.current = abortController;
3203 const signal = abortController.signal;
3204 let attributeObserver = null;
3205 const endingStyleAttribute = CollapsiblePanelDataAttributes.endingStyle;
3206 attributeObserver = new MutationObserver((mutationList) => {
3207 const hasEndingStyle = mutationList.some((mutation) => mutation.type === "attributes" && mutation.attributeName === endingStyleAttribute);
3208 if (hasEndingStyle) {
3209 attributeObserver?.disconnect();
3210 attributeObserver = null;
3211 runOnceAnimationsFinish(() => {
3212 setDimensions({
3213 height: 0,
3214 width: 0
3215 });
3216 panel.style.removeProperty("content-visibility");
3217 setMounted(false);
3218 if (abortControllerRef.current === abortController) {
3219 abortControllerRef.current = null;
3220 }
3221 }, signal);
3222 }
3223 });
3224 attributeObserver.observe(panel, {
3225 attributes: true,
3226 attributeFilter: [endingStyleAttribute]
3227 });
3228 return () => {
3229 attributeObserver?.disconnect();
3230 endingStyleFrame.cancel();
3231 if (abortControllerRef.current === abortController) {
3232 abortController.abort();
3233 abortControllerRef.current = null;
3234 }
3235 };
3236 }
3237 return () => {
3238 AnimationFrame.cancel(resizeFrame);
3239 };
3240 }, [abortControllerRef, animationTypeRef, endingStyleFrame, hiddenUntilFound, keepMounted, mounted, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted]);
3241 useIsoLayoutEffect(() => {
3242 if (animationTypeRef.current !== "css-animation") {
3243 return;
3244 }
3245 const panel = panelRef.current;
3246 if (!panel) {
3247 return;
3248 }
3249 latestAnimationNameRef.current = panel.style.animationName || latestAnimationNameRef.current;
3250 panel.style.setProperty("animation-name", "none");
3251 setDimensions({
3252 height: panel.scrollHeight,
3253 width: panel.scrollWidth
3254 });
3255 if (!shouldCancelInitialOpenAnimationRef.current && !isBeforeMatchRef.current) {
3256 panel.style.removeProperty("animation-name");
3257 }
3258 if (open) {
3259 if (abortControllerRef.current != null) {
3260 abortControllerRef.current.abort();
3261 abortControllerRef.current = null;
3262 }
3263 setMounted(true);
3264 setVisible(true);
3265 } else {
3266 abortControllerRef.current = new AbortController();
3267 runOnceAnimationsFinish(() => {
3268 setMounted(false);
3269 setVisible(false);
3270 abortControllerRef.current = null;
3271 }, abortControllerRef.current.signal);
3272 }
3273 }, [abortControllerRef, animationTypeRef, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted, setVisible, visible]);
3274 useOnMount(() => {
3275 const frame = AnimationFrame.request(() => {
3276 shouldCancelInitialOpenAnimationRef.current = false;
3277 });
3278 return () => AnimationFrame.cancel(frame);
3279 });
3280 useIsoLayoutEffect(() => {
3281 if (!hiddenUntilFound) {
3282 return void 0;
3283 }
3284 const panel = panelRef.current;
3285 if (!panel) {
3286 return void 0;
3287 }
3288 let frame = -1;
3289 let nextFrame = -1;
3290 if (open && isBeforeMatchRef.current) {
3291 panel.style.transitionDuration = "0s";
3292 setDimensions({
3293 height: panel.scrollHeight,
3294 width: panel.scrollWidth
3295 });
3296 frame = AnimationFrame.request(() => {
3297 isBeforeMatchRef.current = false;
3298 nextFrame = AnimationFrame.request(() => {
3299 setTimeout(() => {
3300 panel.style.removeProperty("transition-duration");
3301 });
3302 });
3303 });
3304 }
3305 return () => {
3306 AnimationFrame.cancel(frame);
3307 AnimationFrame.cancel(nextFrame);
3308 };
3309 }, [hiddenUntilFound, open, panelRef, setDimensions]);
3310 useIsoLayoutEffect(() => {
3311 const panel = panelRef.current;
3312 if (panel && hiddenUntilFound && hidden) {
3313 panel.setAttribute("hidden", "until-found");
3314 if (animationTypeRef.current === "css-transition") {
3315 panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, "");
3316 }
3317 }
3318 }, [hiddenUntilFound, hidden, animationTypeRef, panelRef]);
3319 React18.useEffect(function registerBeforeMatchListener() {
3320 const panel = panelRef.current;
3321 if (!panel) {
3322 return void 0;
3323 }
3324 function handleBeforeMatch(event) {
3325 isBeforeMatchRef.current = true;
3326 setOpen(true);
3327 onOpenChange(true, createChangeEventDetails(reason_parts_exports.none, event));
3328 }
3329 return addEventListener(panel, "beforematch", handleBeforeMatch);
3330 }, [onOpenChange, panelRef, setOpen]);
3331 return React18.useMemo(() => ({
3332 props: {
3333 hidden,
3334 id: idParam,
3335 ref: mergedPanelRef
3336 }
3337 }), [hidden, idParam, mergedPanelRef]);
3338 }
3339
3340 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
3341 var React19 = __toESM(require_react(), 1);
3342 function useOpenChangeComplete(parameters) {
3343 const {
3344 enabled = true,
3345 open,
3346 ref,
3347 onComplete: onCompleteParam
3348 } = parameters;
3349 const onComplete = useStableCallback(onCompleteParam);
3350 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
3351 React19.useEffect(() => {
3352 if (!enabled) {
3353 return void 0;
3354 }
3355 const abortController = new AbortController();
3356 runOnceAnimationsFinish(onComplete, abortController.signal);
3357 return () => {
3358 abortController.abort();
3359 };
3360 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
3361 }
3362
3363 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
3364 var React20 = __toESM(require_react(), 1);
3365 function useOnFirstRender(fn) {
3366 const ref = React20.useRef(true);
3367 if (ref.current) {
3368 ref.current = false;
3369 fn();
3370 }
3371 }
3372
3373 // node_modules/@base-ui/utils/esm/useTimeout.js
3374 var EMPTY3 = 0;
3375 var Timeout = class _Timeout {
3376 static create() {
3377 return new _Timeout();
3378 }
3379 currentId = EMPTY3;
3380 /**
3381 * Executes `fn` after `delay`, clearing any previously scheduled call.
3382 */
3383 start(delay, fn) {
3384 this.clear();
3385 this.currentId = setTimeout(() => {
3386 this.currentId = EMPTY3;
3387 fn();
3388 }, delay);
3389 }
3390 isStarted() {
3391 return this.currentId !== EMPTY3;
3392 }
3393 clear = () => {
3394 if (this.currentId !== EMPTY3) {
3395 clearTimeout(this.currentId);
3396 this.currentId = EMPTY3;
3397 }
3398 };
3399 disposeEffect = () => {
3400 return this.clear;
3401 };
3402 };
3403 function useTimeout() {
3404 const timeout = useRefWithInit(Timeout.create).current;
3405 useOnMount(timeout.disposeEffect);
3406 return timeout;
3407 }
3408
3409 // node_modules/@base-ui/utils/esm/useScrollLock.js
3410 var originalHtmlStyles = {};
3411 var originalBodyStyles = {};
3412 var originalHtmlScrollBehavior = "";
3413 function hasInsetScrollbars(referenceElement) {
3414 if (typeof document === "undefined") {
3415 return false;
3416 }
3417 const doc = ownerDocument(referenceElement);
3418 const win = getWindow(doc);
3419 return win.innerWidth - doc.documentElement.clientWidth > 0;
3420 }
3421 function supportsStableScrollbarGutter(referenceElement) {
3422 const supported = typeof CSS !== "undefined" && CSS.supports && CSS.supports("scrollbar-gutter", "stable");
3423 if (!supported || typeof document === "undefined") {
3424 return false;
3425 }
3426 const doc = ownerDocument(referenceElement);
3427 const html = doc.documentElement;
3428 const body = doc.body;
3429 const scrollContainer = isOverflowElement(html) ? html : body;
3430 const originalScrollContainerOverflowY = scrollContainer.style.overflowY;
3431 const originalHtmlStyleGutter = html.style.scrollbarGutter;
3432 html.style.scrollbarGutter = "stable";
3433 scrollContainer.style.overflowY = "scroll";
3434 const before = scrollContainer.offsetWidth;
3435 scrollContainer.style.overflowY = "hidden";
3436 const after = scrollContainer.offsetWidth;
3437 scrollContainer.style.overflowY = originalScrollContainerOverflowY;
3438 html.style.scrollbarGutter = originalHtmlStyleGutter;
3439 return before === after;
3440 }
3441 function preventScrollOverlayScrollbars(referenceElement) {
3442 const doc = ownerDocument(referenceElement);
3443 const html = doc.documentElement;
3444 const body = doc.body;
3445 const elementToLock = isOverflowElement(html) ? html : body;
3446 const originalElementToLockStyles = {
3447 overflowY: elementToLock.style.overflowY,
3448 overflowX: elementToLock.style.overflowX
3449 };
3450 Object.assign(elementToLock.style, {
3451 overflowY: "hidden",
3452 overflowX: "hidden"
3453 });
3454 return () => {
3455 Object.assign(elementToLock.style, originalElementToLockStyles);
3456 };
3457 }
3458 function preventScrollInsetScrollbars(referenceElement) {
3459 const doc = ownerDocument(referenceElement);
3460 const html = doc.documentElement;
3461 const body = doc.body;
3462 const win = getWindow(html);
3463 let scrollTop = 0;
3464 let scrollLeft = 0;
3465 let updateGutterOnly = false;
3466 const resizeFrame = AnimationFrame.create();
3467 if (isWebKit2 && (win.visualViewport?.scale ?? 1) !== 1) {
3468 return () => {
3469 };
3470 }
3471 function lockScroll() {
3472 const htmlStyles = win.getComputedStyle(html);
3473 const bodyStyles = win.getComputedStyle(body);
3474 const htmlScrollbarGutterValue = htmlStyles.scrollbarGutter || "";
3475 const hasBothEdges = htmlScrollbarGutterValue.includes("both-edges");
3476 const scrollbarGutterValue = hasBothEdges ? "stable both-edges" : "stable";
3477 scrollTop = html.scrollTop;
3478 scrollLeft = html.scrollLeft;
3479 originalHtmlStyles = {
3480 scrollbarGutter: html.style.scrollbarGutter,
3481 overflowY: html.style.overflowY,
3482 overflowX: html.style.overflowX
3483 };
3484 originalHtmlScrollBehavior = html.style.scrollBehavior;
3485 originalBodyStyles = {
3486 position: body.style.position,
3487 height: body.style.height,
3488 width: body.style.width,
3489 boxSizing: body.style.boxSizing,
3490 overflowY: body.style.overflowY,
3491 overflowX: body.style.overflowX,
3492 scrollBehavior: body.style.scrollBehavior
3493 };
3494 const isScrollableY = html.scrollHeight > html.clientHeight;
3495 const isScrollableX = html.scrollWidth > html.clientWidth;
3496 const hasConstantOverflowY = htmlStyles.overflowY === "scroll" || bodyStyles.overflowY === "scroll";
3497 const hasConstantOverflowX = htmlStyles.overflowX === "scroll" || bodyStyles.overflowX === "scroll";
3498 const scrollbarWidth = Math.max(0, win.innerWidth - body.clientWidth);
3499 const scrollbarHeight = Math.max(0, win.innerHeight - body.clientHeight);
3500 const marginY = parseFloat(bodyStyles.marginTop) + parseFloat(bodyStyles.marginBottom);
3501 const marginX = parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight);
3502 const elementToLock = isOverflowElement(html) ? html : body;
3503 updateGutterOnly = supportsStableScrollbarGutter(referenceElement);
3504 if (updateGutterOnly) {
3505 html.style.scrollbarGutter = scrollbarGutterValue;
3506 elementToLock.style.overflowY = "hidden";
3507 elementToLock.style.overflowX = "hidden";
3508 return;
3509 }
3510 Object.assign(html.style, {
3511 scrollbarGutter: scrollbarGutterValue,
3512 overflowY: "hidden",
3513 overflowX: "hidden"
3514 });
3515 if (isScrollableY || hasConstantOverflowY) {
3516 html.style.overflowY = "scroll";
3517 }
3518 if (isScrollableX || hasConstantOverflowX) {
3519 html.style.overflowX = "scroll";
3520 }
3521 Object.assign(body.style, {
3522 position: "relative",
3523 height: marginY || scrollbarHeight ? `calc(100dvh - ${marginY + scrollbarHeight}px)` : "100dvh",
3524 width: marginX || scrollbarWidth ? `calc(100vw - ${marginX + scrollbarWidth}px)` : "100vw",
3525 boxSizing: "border-box",
3526 overflow: "hidden",
3527 scrollBehavior: "unset"
3528 });
3529 body.scrollTop = scrollTop;
3530 body.scrollLeft = scrollLeft;
3531 html.setAttribute("data-base-ui-scroll-locked", "");
3532 html.style.scrollBehavior = "unset";
3533 }
3534 function cleanup() {
3535 Object.assign(html.style, originalHtmlStyles);
3536 Object.assign(body.style, originalBodyStyles);
3537 if (!updateGutterOnly) {
3538 html.scrollTop = scrollTop;
3539 html.scrollLeft = scrollLeft;
3540 html.removeAttribute("data-base-ui-scroll-locked");
3541 html.style.scrollBehavior = originalHtmlScrollBehavior;
3542 }
3543 }
3544 function handleResize() {
3545 cleanup();
3546 resizeFrame.request(lockScroll);
3547 }
3548 lockScroll();
3549 const unsubscribeResize = addEventListener(win, "resize", handleResize);
3550 return () => {
3551 resizeFrame.cancel();
3552 cleanup();
3553 if (typeof win.removeEventListener === "function") {
3554 unsubscribeResize();
3555 }
3556 };
3557 }
3558 var ScrollLocker = class {
3559 lockCount = 0;
3560 restore = null;
3561 timeoutLock = Timeout.create();
3562 timeoutUnlock = Timeout.create();
3563 acquire(referenceElement) {
3564 this.lockCount += 1;
3565 if (this.lockCount === 1 && this.restore === null) {
3566 this.timeoutLock.start(0, () => this.lock(referenceElement));
3567 }
3568 return this.release;
3569 }
3570 release = () => {
3571 this.lockCount -= 1;
3572 if (this.lockCount === 0 && this.restore) {
3573 this.timeoutUnlock.start(0, this.unlock);
3574 }
3575 };
3576 unlock = () => {
3577 if (this.lockCount === 0 && this.restore) {
3578 this.restore?.();
3579 this.restore = null;
3580 }
3581 };
3582 lock(referenceElement) {
3583 if (this.lockCount === 0 || this.restore !== null) {
3584 return;
3585 }
3586 const doc = ownerDocument(referenceElement);
3587 const html = doc.documentElement;
3588 const htmlOverflowY = getWindow(html).getComputedStyle(html).overflowY;
3589 if (htmlOverflowY === "hidden" || htmlOverflowY === "clip") {
3590 this.restore = NOOP;
3591 return;
3592 }
3593 const hasOverlayScrollbars = isIOS || !hasInsetScrollbars(referenceElement);
3594 this.restore = hasOverlayScrollbars ? preventScrollOverlayScrollbars(referenceElement) : preventScrollInsetScrollbars(referenceElement);
3595 }
3596 };
3597 var SCROLL_LOCKER = new ScrollLocker();
3598 function useScrollLock(enabled = true, referenceElement = null) {
3599 useIsoLayoutEffect(() => {
3600 if (!enabled) {
3601 return void 0;
3602 }
3603 return SCROLL_LOCKER.acquire(referenceElement);
3604 }, [enabled, referenceElement]);
3605 }
3606
3607 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
3608 var React21 = __toESM(require_react(), 1);
3609
3610 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
3611 function resolveValue(value, pointerType) {
3612 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
3613 return 0;
3614 }
3615 if (typeof value === "function") {
3616 return value();
3617 }
3618 return value;
3619 }
3620 function getDelay(value, prop, pointerType) {
3621 const result = resolveValue(value, pointerType);
3622 if (typeof result === "number") {
3623 return result;
3624 }
3625 return result?.[prop];
3626 }
3627 function getRestMs(value) {
3628 if (typeof value === "function") {
3629 return value();
3630 }
3631 return value;
3632 }
3633 function isClickLikeOpenEvent(openEventType, interactedInside) {
3634 return interactedInside || openEventType === "click" || openEventType === "mousedown";
3635 }
3636
3637 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
3638 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
3639 var FloatingDelayGroupContext = /* @__PURE__ */ React21.createContext({
3640 hasProvider: false,
3641 timeoutMs: 0,
3642 delayRef: {
3643 current: 0
3644 },
3645 initialDelayRef: {
3646 current: 0
3647 },
3648 timeout: new Timeout(),
3649 currentIdRef: {
3650 current: null
3651 },
3652 currentContextRef: {
3653 current: null
3654 }
3655 });
3656 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
3657 function FloatingDelayGroup(props) {
3658 const {
3659 children,
3660 delay,
3661 timeoutMs = 0
3662 } = props;
3663 const delayRef = React21.useRef(delay);
3664 const initialDelayRef = React21.useRef(delay);
3665 const currentIdRef = React21.useRef(null);
3666 const currentContextRef = React21.useRef(null);
3667 const timeout = useTimeout();
3668 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
3669 value: React21.useMemo(() => ({
3670 hasProvider: true,
3671 delayRef,
3672 initialDelayRef,
3673 currentIdRef,
3674 timeoutMs,
3675 currentContextRef,
3676 timeout
3677 }), [timeoutMs, timeout]),
3678 children
3679 });
3680 }
3681 function useDelayGroup(context, options = {
3682 open: false
3683 }) {
3684 const store = "rootStore" in context ? context.rootStore : context;
3685 const floatingId = store.useState("floatingId");
3686 const {
3687 open
3688 } = options;
3689 const groupContext = React21.useContext(FloatingDelayGroupContext);
3690 const {
3691 currentIdRef,
3692 delayRef,
3693 timeoutMs,
3694 initialDelayRef,
3695 currentContextRef,
3696 hasProvider,
3697 timeout
3698 } = groupContext;
3699 const [isInstantPhase, setIsInstantPhase] = React21.useState(false);
3700 useIsoLayoutEffect(() => {
3701 function unset() {
3702 setIsInstantPhase(false);
3703 currentContextRef.current?.setIsInstantPhase(false);
3704 currentIdRef.current = null;
3705 currentContextRef.current = null;
3706 delayRef.current = initialDelayRef.current;
3707 }
3708 if (!currentIdRef.current) {
3709 return void 0;
3710 }
3711 if (!open && currentIdRef.current === floatingId) {
3712 setIsInstantPhase(false);
3713 if (timeoutMs) {
3714 const closingId = floatingId;
3715 timeout.start(timeoutMs, () => {
3716 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
3717 return;
3718 }
3719 unset();
3720 });
3721 return () => {
3722 timeout.clear();
3723 };
3724 }
3725 unset();
3726 }
3727 return void 0;
3728 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
3729 useIsoLayoutEffect(() => {
3730 if (!open) {
3731 return;
3732 }
3733 const prevContext = currentContextRef.current;
3734 const prevId = currentIdRef.current;
3735 timeout.clear();
3736 currentContextRef.current = {
3737 onOpenChange: store.setOpen,
3738 setIsInstantPhase
3739 };
3740 currentIdRef.current = floatingId;
3741 delayRef.current = {
3742 open: 0,
3743 close: getDelay(initialDelayRef.current, "close")
3744 };
3745 if (prevId !== null && prevId !== floatingId) {
3746 setIsInstantPhase(true);
3747 prevContext?.setIsInstantPhase(true);
3748 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
3749 } else {
3750 setIsInstantPhase(false);
3751 prevContext?.setIsInstantPhase(false);
3752 }
3753 }, [open, floatingId, store, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]);
3754 useIsoLayoutEffect(() => {
3755 return () => {
3756 currentContextRef.current = null;
3757 };
3758 }, [currentContextRef]);
3759 return React21.useMemo(() => ({
3760 hasProvider,
3761 delayRef,
3762 isInstantPhase
3763 }), [hasProvider, delayRef, isInstantPhase]);
3764 }
3765
3766 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingFocusManager.js
3767 var React25 = __toESM(require_react(), 1);
3768
3769 // node_modules/@base-ui/utils/esm/mergeCleanups.js
3770 function mergeCleanups(...cleanups) {
3771 return () => {
3772 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3773 const cleanup = cleanups[i2];
3774 if (cleanup) {
3775 cleanup();
3776 }
3777 }
3778 };
3779 }
3780
3781 // node_modules/@base-ui/utils/esm/useValueAsRef.js
3782 function useValueAsRef(value) {
3783 const latest = useRefWithInit(createLatestRef, value).current;
3784 latest.next = value;
3785 useIsoLayoutEffect(latest.effect);
3786 return latest;
3787 }
3788 function createLatestRef(value) {
3789 const latest = {
3790 current: value,
3791 next: value,
3792 effect: () => {
3793 latest.current = latest.next;
3794 }
3795 };
3796 return latest;
3797 }
3798
3799 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3800 var React22 = __toESM(require_react(), 1);
3801
3802 // node_modules/@base-ui/utils/esm/visuallyHidden.js
3803 var visuallyHiddenBase = {
3804 clipPath: "inset(50%)",
3805 overflow: "hidden",
3806 whiteSpace: "nowrap",
3807 border: 0,
3808 padding: 0,
3809 width: 1,
3810 height: 1,
3811 margin: -1
3812 };
3813 var visuallyHidden = {
3814 ...visuallyHiddenBase,
3815 position: "fixed",
3816 top: 0,
3817 left: 0
3818 };
3819 var visuallyHiddenInput = {
3820 ...visuallyHiddenBase,
3821 position: "absolute"
3822 };
3823
3824 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3825 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3826 var FocusGuard = /* @__PURE__ */ React22.forwardRef(function FocusGuard2(props, ref) {
3827 const [role, setRole] = React22.useState();
3828 useIsoLayoutEffect(() => {
3829 if (isSafari) {
3830 setRole("button");
3831 }
3832 }, []);
3833 const restProps = {
3834 tabIndex: 0,
3835 // Role is only for VoiceOver
3836 role
3837 };
3838 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
3839 ...props,
3840 ref,
3841 style: visuallyHidden,
3842 "aria-hidden": role ? void 0 : true,
3843 ...restProps,
3844 "data-base-ui-focus-guard": ""
3845 });
3846 });
3847 if (true) FocusGuard.displayName = "FocusGuard";
3848
3849 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
3850 function createAttribute(name) {
3851 return `data-base-ui-${name}`;
3852 }
3853
3854 // node_modules/@base-ui/react/esm/floating-ui-react/utils/enqueueFocus.js
3855 var rafId = 0;
3856 function enqueueFocus(el, options = {}) {
3857 const {
3858 preventScroll = false,
3859 cancelPrevious = true,
3860 sync: sync2 = false
3861 } = options;
3862 if (cancelPrevious) {
3863 cancelAnimationFrame(rafId);
3864 }
3865 const exec = () => el?.focus({
3866 preventScroll
3867 });
3868 if (sync2) {
3869 exec();
3870 return NOOP;
3871 }
3872 const currentRafId = requestAnimationFrame(exec);
3873 rafId = currentRafId;
3874 return () => {
3875 if (rafId === currentRafId) {
3876 cancelAnimationFrame(currentRafId);
3877 rafId = 0;
3878 }
3879 };
3880 }
3881
3882 // node_modules/@base-ui/react/esm/floating-ui-react/utils/markOthers.js
3883 var counters = {
3884 inert: /* @__PURE__ */ new WeakMap(),
3885 "aria-hidden": /* @__PURE__ */ new WeakMap()
3886 };
3887 var markerName = "data-base-ui-inert";
3888 var uncontrolledElementsSets = {
3889 inert: /* @__PURE__ */ new WeakSet(),
3890 "aria-hidden": /* @__PURE__ */ new WeakSet()
3891 };
3892 var markerCounterMap = /* @__PURE__ */ new WeakMap();
3893 var lockCount = 0;
3894 function getUncontrolledElementsSet(controlAttribute) {
3895 return uncontrolledElementsSets[controlAttribute];
3896 }
3897 function unwrapHost(node) {
3898 if (!node) {
3899 return null;
3900 }
3901 return isShadowRoot(node) ? node.host : unwrapHost(node.parentNode);
3902 }
3903 var correctElements = (parent, targets) => targets.map((target) => {
3904 if (parent.contains(target)) {
3905 return target;
3906 }
3907 const correctedTarget = unwrapHost(target);
3908 if (parent.contains(correctedTarget)) {
3909 return correctedTarget;
3910 }
3911 return null;
3912 }).filter((x2) => x2 != null);
3913 var buildKeepSet = (targets) => {
3914 const keep = /* @__PURE__ */ new Set();
3915 targets.forEach((target) => {
3916 let node = target;
3917 while (node && !keep.has(node)) {
3918 keep.add(node);
3919 node = node.parentNode;
3920 }
3921 });
3922 return keep;
3923 };
3924 var collectOutsideElements = (root, keepElements, stopElements) => {
3925 const outside = [];
3926 const walk = (parent) => {
3927 if (!parent || stopElements.has(parent)) {
3928 return;
3929 }
3930 Array.from(parent.children).forEach((node) => {
3931 if (getNodeName(node) === "script") {
3932 return;
3933 }
3934 if (keepElements.has(node)) {
3935 walk(node);
3936 } else {
3937 outside.push(node);
3938 }
3939 });
3940 };
3941 walk(root);
3942 return outside;
3943 };
3944 function applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert, {
3945 mark = true,
3946 markerIgnoreElements = []
3947 }) {
3948 const controlAttribute = inert ? "inert" : ariaHidden ? "aria-hidden" : null;
3949 let counterMap = null;
3950 let uncontrolledElementsSet = null;
3951 const avoidElements = correctElements(body, uncorrectedAvoidElements);
3952 const markerIgnoreTargets = mark ? correctElements(body, markerIgnoreElements) : [];
3953 const markerIgnoreSet = new Set(markerIgnoreTargets);
3954 const markerTargets = mark ? collectOutsideElements(body, buildKeepSet(avoidElements), new Set(avoidElements)).filter((target) => !markerIgnoreSet.has(target)) : [];
3955 const hiddenElements = [];
3956 const markedElements = [];
3957 if (controlAttribute) {
3958 const map = counters[controlAttribute];
3959 const currentUncontrolledElementsSet = getUncontrolledElementsSet(controlAttribute);
3960 uncontrolledElementsSet = currentUncontrolledElementsSet;
3961 counterMap = map;
3962 const ariaLiveElements = correctElements(body, Array.from(body.querySelectorAll("[aria-live]")));
3963 const controlElements = avoidElements.concat(ariaLiveElements);
3964 const controlTargets = collectOutsideElements(body, buildKeepSet(controlElements), new Set(controlElements));
3965 controlTargets.forEach((node) => {
3966 const attr2 = node.getAttribute(controlAttribute);
3967 const alreadyHidden = attr2 !== null && attr2 !== "false";
3968 const counterValue = (map.get(node) || 0) + 1;
3969 map.set(node, counterValue);
3970 hiddenElements.push(node);
3971 if (counterValue === 1 && alreadyHidden) {
3972 currentUncontrolledElementsSet.add(node);
3973 }
3974 if (!alreadyHidden) {
3975 node.setAttribute(controlAttribute, controlAttribute === "inert" ? "" : "true");
3976 }
3977 });
3978 }
3979 if (mark) {
3980 markerTargets.forEach((node) => {
3981 const markerValue = (markerCounterMap.get(node) || 0) + 1;
3982 markerCounterMap.set(node, markerValue);
3983 markedElements.push(node);
3984 if (markerValue === 1) {
3985 node.setAttribute(markerName, "");
3986 }
3987 });
3988 }
3989 lockCount += 1;
3990 return () => {
3991 if (counterMap) {
3992 hiddenElements.forEach((element) => {
3993 const currentCounterValue = counterMap.get(element) || 0;
3994 const counterValue = currentCounterValue - 1;
3995 counterMap.set(element, counterValue);
3996 if (!counterValue) {
3997 if (!uncontrolledElementsSet?.has(element) && controlAttribute) {
3998 element.removeAttribute(controlAttribute);
3999 }
4000 uncontrolledElementsSet?.delete(element);
4001 }
4002 });
4003 }
4004 if (mark) {
4005 markedElements.forEach((element) => {
4006 const markerValue = (markerCounterMap.get(element) || 0) - 1;
4007 markerCounterMap.set(element, markerValue);
4008 if (!markerValue) {
4009 element.removeAttribute(markerName);
4010 }
4011 });
4012 }
4013 lockCount -= 1;
4014 if (!lockCount) {
4015 counters.inert = /* @__PURE__ */ new WeakMap();
4016 counters["aria-hidden"] = /* @__PURE__ */ new WeakMap();
4017 uncontrolledElementsSets.inert = /* @__PURE__ */ new WeakSet();
4018 uncontrolledElementsSets["aria-hidden"] = /* @__PURE__ */ new WeakSet();
4019 markerCounterMap = /* @__PURE__ */ new WeakMap();
4020 }
4021 };
4022 }
4023 function markOthers(avoidElements, options = {}) {
4024 const {
4025 ariaHidden = false,
4026 inert = false,
4027 mark = true,
4028 markerIgnoreElements = []
4029 } = options;
4030 const body = ownerDocument(avoidElements[0]).body;
4031 return applyAttributeToOthers(avoidElements, body, ariaHidden, inert, {
4032 mark,
4033 markerIgnoreElements
4034 });
4035 }
4036
4037 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
4038 var React23 = __toESM(require_react(), 1);
4039 var ReactDOM2 = __toESM(require_react_dom(), 1);
4040
4041 // node_modules/@base-ui/react/esm/internals/constants.js
4042 var PATIENT_CLICK_THRESHOLD = 500;
4043 var DISABLED_TRANSITIONS_STYLE = {
4044 style: {
4045 transition: "none"
4046 }
4047 };
4048 var CLICK_TRIGGER_IDENTIFIER = "data-base-ui-click-trigger";
4049 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
4050 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
4051 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
4052 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
4053 var POPUP_COLLISION_AVOIDANCE = {
4054 fallbackAxisSide: "end"
4055 };
4056 var ownerVisuallyHidden = {
4057 clipPath: "inset(50%)",
4058 position: "fixed",
4059 top: 0,
4060 left: 0
4061 };
4062
4063 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
4064 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
4065 var PortalContext = /* @__PURE__ */ React23.createContext(null);
4066 if (true) PortalContext.displayName = "PortalContext";
4067 var usePortalContext = () => React23.useContext(PortalContext);
4068 var attr = createAttribute("portal");
4069 function useFloatingPortalNode(props = {}) {
4070 const {
4071 ref,
4072 container: containerProp,
4073 componentProps = EMPTY_OBJECT,
4074 elementProps
4075 } = props;
4076 const uniqueId = useId();
4077 const portalContext = usePortalContext();
4078 const parentPortalNode = portalContext?.portalNode;
4079 const [containerElement, setContainerElement] = React23.useState(null);
4080 const [portalNode, setPortalNode] = React23.useState(null);
4081 const setPortalNodeRef = useStableCallback((node) => {
4082 if (node !== null) {
4083 setPortalNode(node);
4084 }
4085 });
4086 const containerRef = React23.useRef(null);
4087 useIsoLayoutEffect(() => {
4088 if (containerProp === null) {
4089 if (containerRef.current) {
4090 containerRef.current = null;
4091 setPortalNode(null);
4092 setContainerElement(null);
4093 }
4094 return;
4095 }
4096 if (uniqueId == null) {
4097 return;
4098 }
4099 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
4100 if (resolvedContainer == null) {
4101 if (containerRef.current) {
4102 containerRef.current = null;
4103 setPortalNode(null);
4104 setContainerElement(null);
4105 }
4106 return;
4107 }
4108 if (containerRef.current !== resolvedContainer) {
4109 containerRef.current = resolvedContainer;
4110 setPortalNode(null);
4111 setContainerElement(resolvedContainer);
4112 }
4113 }, [containerProp, parentPortalNode, uniqueId]);
4114 const portalElement = useRenderElement("div", componentProps, {
4115 ref: [ref, setPortalNodeRef],
4116 props: [{
4117 id: uniqueId,
4118 [attr]: ""
4119 }, elementProps]
4120 });
4121 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
4122 return {
4123 portalNode,
4124 portalSubtree
4125 };
4126 }
4127 var FloatingPortal = /* @__PURE__ */ React23.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
4128 const {
4129 children,
4130 container,
4131 className,
4132 render: render4,
4133 renderGuards,
4134 style,
4135 ...elementProps
4136 } = componentProps;
4137 const {
4138 portalNode,
4139 portalSubtree
4140 } = useFloatingPortalNode({
4141 container,
4142 ref: forwardedRef,
4143 componentProps,
4144 elementProps
4145 });
4146 const beforeOutsideRef = React23.useRef(null);
4147 const afterOutsideRef = React23.useRef(null);
4148 const beforeInsideRef = React23.useRef(null);
4149 const afterInsideRef = React23.useRef(null);
4150 const [focusManagerState, setFocusManagerState] = React23.useState(null);
4151 const focusInsideDisabledRef = React23.useRef(false);
4152 const modal = focusManagerState?.modal;
4153 const open = focusManagerState?.open;
4154 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
4155 React23.useEffect(() => {
4156 if (!portalNode || modal) {
4157 return void 0;
4158 }
4159 function onFocus(event) {
4160 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
4161 if (event.type === "focusin") {
4162 if (focusInsideDisabledRef.current) {
4163 enableFocusInside(portalNode);
4164 focusInsideDisabledRef.current = false;
4165 }
4166 } else {
4167 disableFocusInside(portalNode);
4168 focusInsideDisabledRef.current = true;
4169 }
4170 }
4171 }
4172 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
4173 }, [portalNode, modal]);
4174 React23.useEffect(() => {
4175 if (!portalNode || open !== false) {
4176 return;
4177 }
4178 enableFocusInside(portalNode);
4179 focusInsideDisabledRef.current = false;
4180 }, [open, portalNode]);
4181 const portalContextValue = React23.useMemo(() => ({
4182 beforeOutsideRef,
4183 afterOutsideRef,
4184 beforeInsideRef,
4185 afterInsideRef,
4186 portalNode,
4187 setFocusManagerState
4188 }), [portalNode]);
4189 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React23.Fragment, {
4190 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
4191 value: portalContextValue,
4192 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
4193 "data-type": "outside",
4194 ref: beforeOutsideRef,
4195 onFocus: (event) => {
4196 if (isOutsideEvent(event, portalNode)) {
4197 beforeInsideRef.current?.focus();
4198 } else {
4199 const domReference = focusManagerState ? focusManagerState.domReference : null;
4200 const prevTabbable = getPreviousTabbable(domReference);
4201 prevTabbable?.focus();
4202 }
4203 }
4204 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
4205 "aria-owns": portalNode.id,
4206 style: ownerVisuallyHidden
4207 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
4208 "data-type": "outside",
4209 ref: afterOutsideRef,
4210 onFocus: (event) => {
4211 if (isOutsideEvent(event, portalNode)) {
4212 afterInsideRef.current?.focus();
4213 } else {
4214 const domReference = focusManagerState ? focusManagerState.domReference : null;
4215 const nextTabbable = getNextTabbable(domReference);
4216 nextTabbable?.focus();
4217 if (focusManagerState?.closeOnFocusOut) {
4218 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
4219 }
4220 }
4221 }
4222 })]
4223 })]
4224 });
4225 });
4226 if (true) FloatingPortal.displayName = "FloatingPortal";
4227
4228 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
4229 var React24 = __toESM(require_react(), 1);
4230
4231 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
4232 function createEventEmitter() {
4233 const map = /* @__PURE__ */ new Map();
4234 return {
4235 emit(event, data) {
4236 map.get(event)?.forEach((listener) => listener(data));
4237 },
4238 on(event, listener) {
4239 if (!map.has(event)) {
4240 map.set(event, /* @__PURE__ */ new Set());
4241 }
4242 map.get(event).add(listener);
4243 },
4244 off(event, listener) {
4245 map.get(event)?.delete(listener);
4246 }
4247 };
4248 }
4249
4250 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTreeStore.js
4251 var FloatingTreeStore = class {
4252 nodesRef = {
4253 current: []
4254 };
4255 events = createEventEmitter();
4256 addNode(node) {
4257 this.nodesRef.current.push(node);
4258 }
4259 removeNode(node) {
4260 const index2 = this.nodesRef.current.findIndex((n2) => n2 === node);
4261 if (index2 !== -1) {
4262 this.nodesRef.current.splice(index2, 1);
4263 }
4264 }
4265 };
4266
4267 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
4268 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
4269 var FloatingNodeContext = /* @__PURE__ */ React24.createContext(null);
4270 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
4271 var FloatingTreeContext = /* @__PURE__ */ React24.createContext(null);
4272 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
4273 var useFloatingParentNodeId = () => React24.useContext(FloatingNodeContext)?.id || null;
4274 var useFloatingTree = (externalTree) => {
4275 const contextTree = React24.useContext(FloatingTreeContext);
4276 return externalTree ?? contextTree;
4277 };
4278 function useFloatingNodeId(externalTree) {
4279 const id = useId();
4280 const tree = useFloatingTree(externalTree);
4281 const parentId = useFloatingParentNodeId();
4282 useIsoLayoutEffect(() => {
4283 if (!id) {
4284 return void 0;
4285 }
4286 const node = {
4287 id,
4288 parentId
4289 };
4290 tree?.addNode(node);
4291 return () => {
4292 tree?.removeNode(node);
4293 };
4294 }, [tree, id, parentId]);
4295 return id;
4296 }
4297 function FloatingNode(props) {
4298 const {
4299 children,
4300 id
4301 } = props;
4302 const parentId = useFloatingParentNodeId();
4303 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloatingNodeContext.Provider, {
4304 value: React24.useMemo(() => ({
4305 id,
4306 parentId
4307 }), [id, parentId]),
4308 children
4309 });
4310 }
4311 function FloatingTree(props) {
4312 const {
4313 children,
4314 externalTree
4315 } = props;
4316 const tree = useRefWithInit(() => externalTree ?? new FloatingTreeStore()).current;
4317 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloatingTreeContext.Provider, {
4318 value: tree,
4319 children
4320 });
4321 }
4322
4323 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingFocusManager.js
4324 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
4325 function getEventType(event, lastInteractionType) {
4326 const win = getWindow(getTarget(event));
4327 if (event instanceof win.KeyboardEvent) {
4328 return "keyboard";
4329 }
4330 if (event instanceof win.FocusEvent) {
4331 return lastInteractionType || "keyboard";
4332 }
4333 if ("pointerType" in event) {
4334 return event.pointerType || "keyboard";
4335 }
4336 if ("touches" in event) {
4337 return "touch";
4338 }
4339 if (event instanceof win.MouseEvent) {
4340 return lastInteractionType || (event.detail === 0 ? "keyboard" : "mouse");
4341 }
4342 return "";
4343 }
4344 var LIST_LIMIT = 20;
4345 var previouslyFocusedElements = [];
4346 function clearDisconnectedPreviouslyFocusedElements() {
4347 previouslyFocusedElements = previouslyFocusedElements.filter((entry) => {
4348 return entry.deref()?.isConnected;
4349 });
4350 }
4351 function addPreviouslyFocusedElement(element) {
4352 clearDisconnectedPreviouslyFocusedElements();
4353 if (element && getNodeName(element) !== "body") {
4354 previouslyFocusedElements.push(new WeakRef(element));
4355 if (previouslyFocusedElements.length > LIST_LIMIT) {
4356 previouslyFocusedElements = previouslyFocusedElements.slice(-LIST_LIMIT);
4357 }
4358 }
4359 }
4360 function getPreviouslyFocusedElement() {
4361 clearDisconnectedPreviouslyFocusedElements();
4362 return previouslyFocusedElements[previouslyFocusedElements.length - 1]?.deref();
4363 }
4364 function getFirstTabbableElement(container) {
4365 if (!container) {
4366 return null;
4367 }
4368 if (isTabbable(container)) {
4369 return container;
4370 }
4371 return tabbable(container)[0] || container;
4372 }
4373 function handleTabIndex(floatingFocusElement, orderRef) {
4374 if (floatingFocusElement.hasAttribute("tabindex") && !floatingFocusElement.hasAttribute("data-tabindex")) {
4375 return;
4376 }
4377 if (!orderRef.current.includes("floating") && !floatingFocusElement.getAttribute("role")?.includes("dialog")) {
4378 return;
4379 }
4380 const focusableElements = focusable(floatingFocusElement);
4381 const tabbableContent = focusableElements.filter((element) => {
4382 const dataTabIndex = element.getAttribute("data-tabindex") || "";
4383 return isTabbable(element) || element.hasAttribute("data-tabindex") && !dataTabIndex.startsWith("-");
4384 });
4385 const tabIndex = floatingFocusElement.getAttribute("tabindex");
4386 if (orderRef.current.includes("floating") || tabbableContent.length === 0) {
4387 if (tabIndex !== "0") {
4388 floatingFocusElement.setAttribute("tabindex", "0");
4389 }
4390 } else if (tabIndex !== "-1" || floatingFocusElement.hasAttribute("data-tabindex") && floatingFocusElement.getAttribute("data-tabindex") !== "-1") {
4391 floatingFocusElement.setAttribute("tabindex", "-1");
4392 floatingFocusElement.setAttribute("data-tabindex", "-1");
4393 }
4394 }
4395 function FloatingFocusManager(props) {
4396 const {
4397 context,
4398 children,
4399 disabled: disabled2 = false,
4400 initialFocus = true,
4401 returnFocus = true,
4402 restoreFocus = false,
4403 modal = true,
4404 closeOnFocusOut = true,
4405 openInteractionType = "",
4406 nextFocusableElement,
4407 previousFocusableElement,
4408 beforeContentFocusGuardRef,
4409 externalTree,
4410 getInsideElements
4411 } = props;
4412 const store = "rootStore" in context ? context.rootStore : context;
4413 const open = store.useState("open");
4414 const domReference = store.useState("domReferenceElement");
4415 const floating = store.useState("floatingElement");
4416 const {
4417 events,
4418 dataRef
4419 } = store.context;
4420 const getNodeId = useStableCallback(() => dataRef.current.floatingContext?.nodeId);
4421 const ignoreInitialFocus = initialFocus === false;
4422 const isUntrappedTypeableCombobox = isTypeableCombobox(domReference) && ignoreInitialFocus;
4423 const orderRef = React25.useRef(["content"]);
4424 const initialFocusRef = useValueAsRef(initialFocus);
4425 const returnFocusRef = useValueAsRef(returnFocus);
4426 const openInteractionTypeRef = useValueAsRef(openInteractionType);
4427 const tree = useFloatingTree(externalTree);
4428 const portalContext = usePortalContext();
4429 const preventReturnFocusRef = React25.useRef(false);
4430 const isPointerDownRef = React25.useRef(false);
4431 const pointerDownOutsideRef = React25.useRef(false);
4432 const lastFocusedTabbableRef = React25.useRef(null);
4433 const closeTypeRef = React25.useRef("");
4434 const lastInteractionTypeRef = React25.useRef("");
4435 const beforeGuardRef = React25.useRef(null);
4436 const afterGuardRef = React25.useRef(null);
4437 const mergedBeforeGuardRef = useMergedRefs(beforeGuardRef, beforeContentFocusGuardRef, portalContext?.beforeInsideRef);
4438 const mergedAfterGuardRef = useMergedRefs(afterGuardRef, portalContext?.afterInsideRef);
4439 const blurTimeout = useTimeout();
4440 const pointerDownTimeout = useTimeout();
4441 const restoreFocusFrame = useAnimationFrame();
4442 const isInsidePortal = portalContext != null;
4443 const floatingFocusElement = getFloatingFocusElement(floating);
4444 const getTabbableContent = useStableCallback((container = floatingFocusElement) => {
4445 return container ? tabbable(container) : [];
4446 });
4447 const getResolvedInsideElements = useStableCallback(() => getInsideElements?.().filter((element) => element != null) ?? []);
4448 React25.useEffect(() => {
4449 if (disabled2 || !modal) {
4450 return void 0;
4451 }
4452 function onKeyDown(event) {
4453 if (event.key === "Tab") {
4454 if (contains(floatingFocusElement, activeElement(ownerDocument(floatingFocusElement))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) {
4455 stopEvent(event);
4456 }
4457 }
4458 }
4459 const doc = ownerDocument(floatingFocusElement);
4460 return addEventListener(doc, "keydown", onKeyDown);
4461 }, [disabled2, domReference, floatingFocusElement, modal, orderRef, isUntrappedTypeableCombobox, getTabbableContent]);
4462 React25.useEffect(() => {
4463 if (disabled2 || !open) {
4464 return void 0;
4465 }
4466 const doc = ownerDocument(floatingFocusElement);
4467 function clearPointerDownOutside() {
4468 pointerDownOutsideRef.current = false;
4469 }
4470 function onPointerDown(event) {
4471 const target = getTarget(event);
4472 const insideElements = getResolvedInsideElements();
4473 const pointerTargetInside = contains(floating, target) || contains(domReference, target) || contains(portalContext?.portalNode, target) || insideElements.some((element) => element === target || contains(element, target));
4474 pointerDownOutsideRef.current = !pointerTargetInside;
4475 lastInteractionTypeRef.current = event.pointerType || "keyboard";
4476 if (target?.closest(`[${CLICK_TRIGGER_IDENTIFIER}]`)) {
4477 isPointerDownRef.current = true;
4478 }
4479 }
4480 function onKeyDown() {
4481 lastInteractionTypeRef.current = "keyboard";
4482 }
4483 return mergeCleanups(addEventListener(doc, "pointerdown", onPointerDown, true), addEventListener(doc, "pointerup", clearPointerDownOutside, true), addEventListener(doc, "pointercancel", clearPointerDownOutside, true), addEventListener(doc, "keydown", onKeyDown, true));
4484 }, [disabled2, floating, domReference, floatingFocusElement, open, portalContext, getResolvedInsideElements]);
4485 React25.useEffect(() => {
4486 if (disabled2 || !closeOnFocusOut) {
4487 return void 0;
4488 }
4489 const doc = ownerDocument(floatingFocusElement);
4490 function handlePointerDown() {
4491 isPointerDownRef.current = true;
4492 pointerDownTimeout.start(0, () => {
4493 isPointerDownRef.current = false;
4494 });
4495 }
4496 function handleFocusIn(event) {
4497 const target = getTarget(event);
4498 if (isTabbable(target)) {
4499 lastFocusedTabbableRef.current = target;
4500 }
4501 }
4502 function handleFocusOutside(event) {
4503 const relatedTarget = event.relatedTarget;
4504 const currentTarget = event.currentTarget;
4505 const target = getTarget(event);
4506 queueMicrotask(() => {
4507 const nodeId = getNodeId();
4508 const triggers = store.context.triggerElements;
4509 const insideElements = getResolvedInsideElements();
4510 const isRelatedFocusGuard = relatedTarget?.hasAttribute(createAttribute("focus-guard")) && [beforeGuardRef.current, afterGuardRef.current, portalContext?.beforeInsideRef.current, portalContext?.afterInsideRef.current, portalContext?.beforeOutsideRef.current, portalContext?.afterOutsideRef.current, resolveRef(previousFocusableElement), resolveRef(nextFocusableElement)].includes(relatedTarget);
4511 const movedToUnrelatedNode = !(contains(domReference, relatedTarget) || contains(floating, relatedTarget) || contains(relatedTarget, floating) || contains(portalContext?.portalNode, relatedTarget) || insideElements.some((element) => element === relatedTarget || contains(element, relatedTarget)) || relatedTarget != null && triggers.hasElement(relatedTarget) || triggers.hasMatchingElement((trigger) => contains(trigger, relatedTarget)) || isRelatedFocusGuard || tree && (getNodeChildren(tree.nodesRef.current, nodeId).find((node) => contains(node.context?.elements.floating, relatedTarget) || contains(node.context?.elements.domReference, relatedTarget)) || getNodeAncestors(tree.nodesRef.current, nodeId).find((node) => [node.context?.elements.floating, getFloatingFocusElement(node.context?.elements.floating)].includes(relatedTarget) || node.context?.elements.domReference === relatedTarget)));
4512 if (currentTarget === domReference && floatingFocusElement) {
4513 handleTabIndex(floatingFocusElement, orderRef);
4514 }
4515 if (restoreFocus && currentTarget !== domReference && !isElementVisible(target) && activeElement(doc) === doc.body) {
4516 if (isHTMLElement(floatingFocusElement)) {
4517 floatingFocusElement.focus();
4518 if (restoreFocus === "popup") {
4519 restoreFocusFrame.request(() => {
4520 floatingFocusElement.focus();
4521 });
4522 return;
4523 }
4524 }
4525 const tabbableContent = getTabbableContent();
4526 const prevTabbable = lastFocusedTabbableRef.current;
4527 const nodeToFocus = (prevTabbable && tabbableContent.includes(prevTabbable) ? prevTabbable : null) || tabbableContent[tabbableContent.length - 1] || floatingFocusElement;
4528 if (isHTMLElement(nodeToFocus)) {
4529 nodeToFocus.focus();
4530 }
4531 }
4532 if (dataRef.current.insideReactTree) {
4533 dataRef.current.insideReactTree = false;
4534 return;
4535 }
4536 if ((isUntrappedTypeableCombobox ? true : !modal) && relatedTarget && movedToUnrelatedNode && !isPointerDownRef.current && // Fix React 18 Strict Mode returnFocus due to double rendering.
4537 // For an "untrapped" typeable combobox (input role=combobox with
4538 // initialFocus=false), re-opening the popup and tabbing out should still close it even
4539 // when the previously focused element (e.g. the next tabbable outside the popup) is
4540 // focused again. Otherwise, the popup remains open on the second Tab sequence:
4541 // click input -> Tab (closes) -> click input -> Tab.
4542 // Allow closing when `isUntrappedTypeableCombobox` regardless of the previously focused element.
4543 (isUntrappedTypeableCombobox || relatedTarget !== getPreviouslyFocusedElement())) {
4544 preventReturnFocusRef.current = true;
4545 store.setOpen(false, createChangeEventDetails(reason_parts_exports.focusOut, event));
4546 }
4547 });
4548 }
4549 function markInsideReactTree() {
4550 if (pointerDownOutsideRef.current) {
4551 return;
4552 }
4553 dataRef.current.insideReactTree = true;
4554 blurTimeout.start(0, () => {
4555 dataRef.current.insideReactTree = false;
4556 });
4557 }
4558 const domReferenceElement = isHTMLElement(domReference) ? domReference : null;
4559 if (!floating && !domReferenceElement) {
4560 return void 0;
4561 }
4562 return mergeCleanups(domReferenceElement && addEventListener(domReferenceElement, "focusout", handleFocusOutside), domReferenceElement && addEventListener(domReferenceElement, "pointerdown", handlePointerDown), floating && addEventListener(floating, "focusin", handleFocusIn), floating && addEventListener(floating, "focusout", handleFocusOutside), floating && portalContext && addEventListener(floating, "focusout", markInsideReactTree, true));
4563 }, [disabled2, domReference, floating, floatingFocusElement, modal, tree, portalContext, store, closeOnFocusOut, restoreFocus, getTabbableContent, isUntrappedTypeableCombobox, getNodeId, orderRef, dataRef, blurTimeout, pointerDownTimeout, restoreFocusFrame, nextFocusableElement, previousFocusableElement, getResolvedInsideElements]);
4564 React25.useEffect(() => {
4565 if (disabled2 || !floating || !open) {
4566 return void 0;
4567 }
4568 const portalNodes = Array.from(portalContext?.portalNode?.querySelectorAll(`[${createAttribute("portal")}]`) || []);
4569 const ancestors = tree ? getNodeAncestors(tree.nodesRef.current, getNodeId()) : [];
4570 const rootAncestorComboboxDomReference = ancestors.find((node) => isTypeableCombobox(node.context?.elements.domReference || null))?.context?.elements.domReference;
4571 const controlInsideElements = [floating, ...portalNodes, beforeGuardRef.current, afterGuardRef.current, portalContext?.beforeOutsideRef.current, portalContext?.afterOutsideRef.current, ...getResolvedInsideElements()];
4572 const insideElements = [...controlInsideElements, rootAncestorComboboxDomReference, resolveRef(previousFocusableElement), resolveRef(nextFocusableElement), isUntrappedTypeableCombobox ? domReference : null].filter((x2) => x2 != null);
4573 const ariaHiddenCleanup = markOthers(insideElements, {
4574 ariaHidden: modal || isUntrappedTypeableCombobox,
4575 mark: false
4576 });
4577 const markerInsideElements = [floating, ...portalNodes].filter((x2) => x2 != null);
4578 const markerCleanup = markOthers(markerInsideElements);
4579 return () => {
4580 markerCleanup();
4581 ariaHiddenCleanup();
4582 };
4583 }, [open, disabled2, domReference, floating, modal, orderRef, portalContext, isUntrappedTypeableCombobox, tree, getNodeId, nextFocusableElement, previousFocusableElement, getResolvedInsideElements]);
4584 useIsoLayoutEffect(() => {
4585 if (!open || disabled2 || !isHTMLElement(floatingFocusElement)) {
4586 return;
4587 }
4588 const doc = ownerDocument(floatingFocusElement);
4589 const previouslyFocusedElement = activeElement(doc);
4590 queueMicrotask(() => {
4591 const initialFocusValueOrFn = initialFocusRef.current;
4592 const resolvedInitialFocus = typeof initialFocusValueOrFn === "function" ? initialFocusValueOrFn(openInteractionTypeRef.current || "") : initialFocusValueOrFn;
4593 if (resolvedInitialFocus === void 0 || resolvedInitialFocus === false) {
4594 return;
4595 }
4596 const focusAlreadyInsideFloatingEl = contains(floatingFocusElement, previouslyFocusedElement);
4597 if (focusAlreadyInsideFloatingEl) {
4598 return;
4599 }
4600 let focusableElements = null;
4601 const getDefaultFocusElement = () => {
4602 if (focusableElements == null) {
4603 focusableElements = getTabbableContent(floatingFocusElement);
4604 }
4605 return focusableElements[0] || floatingFocusElement;
4606 };
4607 let elToFocus;
4608 if (resolvedInitialFocus === true || resolvedInitialFocus === null) {
4609 elToFocus = getDefaultFocusElement();
4610 } else {
4611 elToFocus = resolveRef(resolvedInitialFocus);
4612 }
4613 elToFocus = elToFocus || getDefaultFocusElement();
4614 enqueueFocus(elToFocus, {
4615 preventScroll: elToFocus === floatingFocusElement
4616 });
4617 });
4618 }, [disabled2, open, floatingFocusElement, ignoreInitialFocus, getTabbableContent, initialFocusRef, openInteractionTypeRef]);
4619 useIsoLayoutEffect(() => {
4620 if (disabled2 || !floatingFocusElement) {
4621 return void 0;
4622 }
4623 const doc = ownerDocument(floatingFocusElement);
4624 const previouslyFocusedElement = activeElement(doc);
4625 addPreviouslyFocusedElement(previouslyFocusedElement);
4626 function onOpenChangeLocal(details) {
4627 if (!details.open) {
4628 closeTypeRef.current = getEventType(details.nativeEvent, lastInteractionTypeRef.current);
4629 }
4630 if (details.reason === reason_parts_exports.triggerHover && details.nativeEvent.type === "mouseleave") {
4631 preventReturnFocusRef.current = true;
4632 }
4633 if (details.reason !== reason_parts_exports.outsidePress) {
4634 return;
4635 }
4636 if (details.nested) {
4637 preventReturnFocusRef.current = false;
4638 } else if (isVirtualClick(details.nativeEvent) || isVirtualPointerEvent(details.nativeEvent)) {
4639 preventReturnFocusRef.current = false;
4640 } else {
4641 let isPreventScrollSupported = false;
4642 ownerDocument(floatingFocusElement).createElement("div").focus({
4643 get preventScroll() {
4644 isPreventScrollSupported = true;
4645 return false;
4646 }
4647 });
4648 if (isPreventScrollSupported) {
4649 preventReturnFocusRef.current = false;
4650 } else {
4651 preventReturnFocusRef.current = true;
4652 }
4653 }
4654 }
4655 events.on("openchange", onOpenChangeLocal);
4656 function getReturnElement() {
4657 const returnFocusValueOrFn = returnFocusRef.current;
4658 let resolvedReturnFocusValue = typeof returnFocusValueOrFn === "function" ? returnFocusValueOrFn(closeTypeRef.current) : returnFocusValueOrFn;
4659 if (resolvedReturnFocusValue === void 0 || resolvedReturnFocusValue === false) {
4660 return null;
4661 }
4662 if (resolvedReturnFocusValue === null) {
4663 resolvedReturnFocusValue = true;
4664 }
4665 if (typeof resolvedReturnFocusValue === "boolean") {
4666 const el = domReference || getPreviouslyFocusedElement();
4667 return el && el.isConnected ? el : null;
4668 }
4669 const fallback = domReference || getPreviouslyFocusedElement();
4670 return resolveRef(resolvedReturnFocusValue) || fallback || null;
4671 }
4672 return () => {
4673 events.off("openchange", onOpenChangeLocal);
4674 const activeEl = activeElement(doc);
4675 const insideElements = getResolvedInsideElements();
4676 const isFocusInsideFloatingTree = contains(floating, activeEl) || insideElements.some((element) => element === activeEl || contains(element, activeEl)) || tree && getNodeChildren(tree.nodesRef.current, getNodeId(), false).some((node) => contains(node.context?.elements.floating, activeEl));
4677 const returnFocusValueOrFn = returnFocusRef.current;
4678 const returnElement = getReturnElement();
4679 queueMicrotask(() => {
4680 const tabbableReturnElement = getFirstTabbableElement(returnElement);
4681 const hasExplicitReturnFocus = typeof returnFocusValueOrFn !== "boolean";
4682 if (returnFocusValueOrFn && !preventReturnFocusRef.current && isHTMLElement(tabbableReturnElement) && // If the focus moved somewhere else after mount, avoid returning focus
4683 // since it likely entered a different element which should be
4684 // respected: https://github.com/floating-ui/floating-ui/issues/2607
4685 (!hasExplicitReturnFocus && tabbableReturnElement !== activeEl && activeEl !== doc.body ? isFocusInsideFloatingTree : true)) {
4686 tabbableReturnElement.focus({
4687 preventScroll: true
4688 });
4689 }
4690 preventReturnFocusRef.current = false;
4691 });
4692 };
4693 }, [disabled2, floating, floatingFocusElement, returnFocusRef, dataRef, events, tree, domReference, getNodeId, getResolvedInsideElements]);
4694 useIsoLayoutEffect(() => {
4695 if (!isWebKit2 || open || !floating) {
4696 return;
4697 }
4698 const activeEl = activeElement(ownerDocument(floating));
4699 if (!isHTMLElement(activeEl) || !isTypeableElement(activeEl)) {
4700 return;
4701 }
4702 if (contains(floating, activeEl)) {
4703 activeEl.blur();
4704 }
4705 }, [open, floating]);
4706 useIsoLayoutEffect(() => {
4707 if (disabled2 || !portalContext) {
4708 return void 0;
4709 }
4710 portalContext.setFocusManagerState({
4711 modal,
4712 closeOnFocusOut,
4713 open,
4714 onOpenChange: store.setOpen,
4715 domReference
4716 });
4717 return () => {
4718 portalContext.setFocusManagerState(null);
4719 };
4720 }, [disabled2, portalContext, modal, open, store, closeOnFocusOut, domReference]);
4721 useIsoLayoutEffect(() => {
4722 if (disabled2 || !floatingFocusElement) {
4723 return void 0;
4724 }
4725 handleTabIndex(floatingFocusElement, orderRef);
4726 return () => {
4727 queueMicrotask(clearDisconnectedPreviouslyFocusedElements);
4728 };
4729 }, [disabled2, floatingFocusElement, orderRef]);
4730 const shouldRenderGuards = !disabled2 && (modal ? !isUntrappedTypeableCombobox : true) && (isInsidePortal || modal);
4731 return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React25.Fragment, {
4732 children: [shouldRenderGuards && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FocusGuard, {
4733 "data-type": "inside",
4734 ref: mergedBeforeGuardRef,
4735 onFocus: (event) => {
4736 if (modal) {
4737 const els = getTabbableContent();
4738 enqueueFocus(els[els.length - 1]);
4739 } else if (portalContext?.portalNode) {
4740 preventReturnFocusRef.current = false;
4741 if (isOutsideEvent(event, portalContext.portalNode)) {
4742 const nextTabbable = getNextTabbable(domReference);
4743 nextTabbable?.focus();
4744 } else {
4745 resolveRef(previousFocusableElement ?? portalContext.beforeOutsideRef)?.focus();
4746 }
4747 }
4748 }
4749 }), children, shouldRenderGuards && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FocusGuard, {
4750 "data-type": "inside",
4751 ref: mergedAfterGuardRef,
4752 onFocus: (event) => {
4753 if (modal) {
4754 enqueueFocus(getTabbableContent()[0]);
4755 } else if (portalContext?.portalNode) {
4756 if (closeOnFocusOut) {
4757 preventReturnFocusRef.current = true;
4758 }
4759 if (isOutsideEvent(event, portalContext.portalNode)) {
4760 const prevTabbable = getPreviousTabbable(domReference);
4761 prevTabbable?.focus();
4762 } else {
4763 resolveRef(nextFocusableElement ?? portalContext.afterOutsideRef)?.focus();
4764 }
4765 }
4766 }
4767 })]
4768 });
4769 }
4770
4771 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClick.js
4772 var React26 = __toESM(require_react(), 1);
4773 function useClick(context, props = {}) {
4774 const store = "rootStore" in context ? context.rootStore : context;
4775 const dataRef = store.context.dataRef;
4776 const {
4777 enabled = true,
4778 event: eventOption = "click",
4779 toggle = true,
4780 ignoreMouse = false,
4781 stickIfOpen = true,
4782 touchOpenDelay = 0,
4783 reason = reason_parts_exports.triggerPress
4784 } = props;
4785 const pointerTypeRef = React26.useRef(void 0);
4786 const frame = useAnimationFrame();
4787 const touchOpenTimeout = useTimeout();
4788 const reference = React26.useMemo(() => ({
4789 onPointerDown(event) {
4790 pointerTypeRef.current = event.pointerType;
4791 },
4792 onMouseDown(event) {
4793 const pointerType = pointerTypeRef.current;
4794 const nativeEvent = event.nativeEvent;
4795 const open = store.select("open");
4796 if (event.button !== 0 || eventOption === "click" || isMouseLikePointerType(pointerType, true) && ignoreMouse) {
4797 return;
4798 }
4799 const openEvent = dataRef.current.openEvent;
4800 const openEventType = openEvent?.type;
4801 const hasClickedOnInactiveTrigger = store.select("domReferenceElement") !== event.currentTarget;
4802 const nextOpen = open && hasClickedOnInactiveTrigger || !(open && toggle && (openEvent && stickIfOpen ? openEventType === "click" || openEventType === "mousedown" : true));
4803 const target = getTarget(nativeEvent);
4804 if (isTypeableElement(target)) {
4805 const details = createChangeEventDetails(reason, nativeEvent, target);
4806 if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) {
4807 touchOpenTimeout.start(touchOpenDelay, () => {
4808 store.setOpen(true, details);
4809 });
4810 } else {
4811 store.setOpen(nextOpen, details);
4812 }
4813 return;
4814 }
4815 const eventCurrentTarget = event.currentTarget;
4816 frame.request(() => {
4817 const details = createChangeEventDetails(reason, nativeEvent, eventCurrentTarget);
4818 if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) {
4819 touchOpenTimeout.start(touchOpenDelay, () => {
4820 store.setOpen(true, details);
4821 });
4822 } else {
4823 store.setOpen(nextOpen, details);
4824 }
4825 });
4826 },
4827 onClick(event) {
4828 if (eventOption === "mousedown-only") {
4829 return;
4830 }
4831 const pointerType = pointerTypeRef.current;
4832 if (eventOption === "mousedown" && pointerType) {
4833 pointerTypeRef.current = void 0;
4834 return;
4835 }
4836 if (isMouseLikePointerType(pointerType, true) && ignoreMouse) {
4837 return;
4838 }
4839 const open = store.select("open");
4840 const openEvent = dataRef.current.openEvent;
4841 const hasClickedOnInactiveTrigger = store.select("domReferenceElement") !== event.currentTarget;
4842 const nextOpen = open && hasClickedOnInactiveTrigger || !(open && toggle && (openEvent && stickIfOpen ? isClickLikeEvent(openEvent) : true));
4843 const details = createChangeEventDetails(reason, event.nativeEvent, event.currentTarget);
4844 if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) {
4845 touchOpenTimeout.start(touchOpenDelay, () => {
4846 store.setOpen(true, details);
4847 });
4848 } else {
4849 store.setOpen(nextOpen, details);
4850 }
4851 },
4852 onKeyDown() {
4853 pointerTypeRef.current = void 0;
4854 }
4855 }), [dataRef, eventOption, ignoreMouse, store, stickIfOpen, toggle, frame, touchOpenTimeout, touchOpenDelay, reason]);
4856 return React26.useMemo(() => enabled ? {
4857 reference
4858 } : EMPTY_OBJECT, [enabled, reference]);
4859 }
4860
4861 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
4862 var React27 = __toESM(require_react(), 1);
4863 function createVirtualElement(domElement, data) {
4864 let offsetX = null;
4865 let offsetY = null;
4866 let isAutoUpdateEvent = false;
4867 return {
4868 contextElement: domElement || void 0,
4869 getBoundingClientRect() {
4870 const domRect = domElement?.getBoundingClientRect() || {
4871 width: 0,
4872 height: 0,
4873 x: 0,
4874 y: 0
4875 };
4876 const isXAxis = data.axis === "x" || data.axis === "both";
4877 const isYAxis = data.axis === "y" || data.axis === "both";
4878 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
4879 let width = domRect.width;
4880 let height = domRect.height;
4881 let x2 = domRect.x;
4882 let y2 = domRect.y;
4883 if (offsetX == null && data.x && isXAxis) {
4884 offsetX = domRect.x - data.x;
4885 }
4886 if (offsetY == null && data.y && isYAxis) {
4887 offsetY = domRect.y - data.y;
4888 }
4889 x2 -= offsetX || 0;
4890 y2 -= offsetY || 0;
4891 width = 0;
4892 height = 0;
4893 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
4894 width = data.axis === "y" ? domRect.width : 0;
4895 height = data.axis === "x" ? domRect.height : 0;
4896 x2 = isXAxis && data.x != null ? data.x : x2;
4897 y2 = isYAxis && data.y != null ? data.y : y2;
4898 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
4899 height = data.axis === "x" ? domRect.height : height;
4900 width = data.axis === "y" ? domRect.width : width;
4901 }
4902 isAutoUpdateEvent = true;
4903 return {
4904 width,
4905 height,
4906 x: x2,
4907 y: y2,
4908 top: y2,
4909 right: x2 + width,
4910 bottom: y2 + height,
4911 left: x2
4912 };
4913 }
4914 };
4915 }
4916 function isMouseBasedEvent(event) {
4917 return event != null && event.clientX != null;
4918 }
4919 function useClientPoint(context, props = {}) {
4920 const store = "rootStore" in context ? context.rootStore : context;
4921 const open = store.useState("open");
4922 const floating = store.useState("floatingElement");
4923 const domReference = store.useState("domReferenceElement");
4924 const dataRef = store.context.dataRef;
4925 const {
4926 enabled = true,
4927 axis = "both"
4928 } = props;
4929 const initialRef = React27.useRef(false);
4930 const cleanupListenerRef = React27.useRef(null);
4931 const [pointerType, setPointerType] = React27.useState();
4932 const [reactive, setReactive] = React27.useState([]);
4933 const setReference = useStableCallback((newX, newY, referenceElement) => {
4934 if (initialRef.current) {
4935 return;
4936 }
4937 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
4938 return;
4939 }
4940 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
4941 x: newX,
4942 y: newY,
4943 axis,
4944 dataRef,
4945 pointerType
4946 }));
4947 });
4948 const handleReferenceEnterOrMove = useStableCallback((event) => {
4949 if (!open) {
4950 setReference(event.clientX, event.clientY, event.currentTarget);
4951 } else if (!cleanupListenerRef.current) {
4952 setReactive([]);
4953 }
4954 });
4955 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
4956 const addListener = React27.useCallback(() => {
4957 if (!openCheck || !enabled) {
4958 return void 0;
4959 }
4960 const win = getWindow(floating);
4961 function handleMouseMove(event) {
4962 const target = getTarget(event);
4963 if (!contains(floating, target)) {
4964 setReference(event.clientX, event.clientY);
4965 } else {
4966 cleanupListenerRef.current?.();
4967 cleanupListenerRef.current = null;
4968 }
4969 }
4970 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
4971 const cleanup = () => {
4972 cleanupListenerRef.current?.();
4973 cleanupListenerRef.current = null;
4974 };
4975 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
4976 return cleanup;
4977 }
4978 store.set("positionReference", domReference);
4979 return void 0;
4980 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference]);
4981 React27.useEffect(() => {
4982 return addListener();
4983 }, [addListener, reactive]);
4984 React27.useEffect(() => {
4985 if (enabled && !floating) {
4986 initialRef.current = false;
4987 }
4988 }, [enabled, floating]);
4989 React27.useEffect(() => {
4990 if (!enabled && open) {
4991 initialRef.current = true;
4992 }
4993 }, [enabled, open]);
4994 const reference = React27.useMemo(() => {
4995 function setPointerTypeRef(event) {
4996 setPointerType(event.pointerType);
4997 }
4998 return {
4999 onPointerDown: setPointerTypeRef,
5000 onPointerEnter: setPointerTypeRef,
5001 onMouseMove: handleReferenceEnterOrMove,
5002 onMouseEnter: handleReferenceEnterOrMove
5003 };
5004 }, [handleReferenceEnterOrMove]);
5005 return React27.useMemo(() => enabled ? {
5006 reference,
5007 trigger: reference
5008 } : {}, [enabled, reference]);
5009 }
5010
5011 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
5012 var React28 = __toESM(require_react(), 1);
5013 var bubbleHandlerKeys = {
5014 intentional: "onClick",
5015 sloppy: "onPointerDown"
5016 };
5017 function alwaysFalse() {
5018 return false;
5019 }
5020 function normalizeProp(normalizable) {
5021 return {
5022 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
5023 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
5024 };
5025 }
5026 function useDismiss(context, props = {}) {
5027 const store = "rootStore" in context ? context.rootStore : context;
5028 const open = store.useState("open");
5029 const floatingElement = store.useState("floatingElement");
5030 const {
5031 dataRef
5032 } = store.context;
5033 const {
5034 enabled = true,
5035 escapeKey: escapeKey2 = true,
5036 outsidePress: outsidePressProp = true,
5037 outsidePressEvent = "sloppy",
5038 referencePress = alwaysFalse,
5039 referencePressEvent = "sloppy",
5040 bubbles,
5041 externalTree
5042 } = props;
5043 const tree = useFloatingTree(externalTree);
5044 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
5045 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
5046 const outsidePressEnabled = outsidePress2 !== false;
5047 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
5048 const pressStartedInsideRef = React28.useRef(false);
5049 const pressStartPreventedRef = React28.useRef(false);
5050 const suppressNextOutsideClickRef = React28.useRef(false);
5051 const {
5052 escapeKey: escapeKeyBubbles,
5053 outsidePress: outsidePressBubbles
5054 } = normalizeProp(bubbles);
5055 const touchStateRef = React28.useRef(null);
5056 const cancelDismissOnEndTimeout = useTimeout();
5057 const clearInsideReactTreeTimeout = useTimeout();
5058 const clearInsideReactTree = useStableCallback(() => {
5059 clearInsideReactTreeTimeout.clear();
5060 dataRef.current.insideReactTree = false;
5061 });
5062 const isComposingRef = React28.useRef(false);
5063 const currentPointerTypeRef = React28.useRef("");
5064 const isReferencePressEnabled = useStableCallback(referencePress);
5065 const closeOnEscapeKeyDown = useStableCallback((event) => {
5066 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
5067 return;
5068 }
5069 if (isComposingRef.current) {
5070 return;
5071 }
5072 const nodeId = dataRef.current.floatingContext?.nodeId;
5073 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
5074 if (!escapeKeyBubbles) {
5075 if (children.length > 0) {
5076 let shouldDismiss = true;
5077 children.forEach((child) => {
5078 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) {
5079 shouldDismiss = false;
5080 }
5081 });
5082 if (!shouldDismiss) {
5083 return;
5084 }
5085 }
5086 }
5087 const native = isReactEvent(event) ? event.nativeEvent : event;
5088 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
5089 store.setOpen(false, eventDetails);
5090 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
5091 event.stopPropagation();
5092 }
5093 });
5094 const markInsideReactTree = useStableCallback(() => {
5095 dataRef.current.insideReactTree = true;
5096 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
5097 });
5098 React28.useEffect(() => {
5099 if (!open || !enabled) {
5100 return void 0;
5101 }
5102 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
5103 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
5104 const compositionTimeout = new Timeout();
5105 const preventedPressSuppressionTimeout = new Timeout();
5106 function handleCompositionStart() {
5107 compositionTimeout.clear();
5108 isComposingRef.current = true;
5109 }
5110 function handleCompositionEnd() {
5111 compositionTimeout.start(
5112 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
5113 // Only apply to WebKit for the test to remain 0ms.
5114 isWebKit() ? 5 : 0,
5115 () => {
5116 isComposingRef.current = false;
5117 }
5118 );
5119 }
5120 function suppressImmediateOutsideClickAfterPreventedStart() {
5121 suppressNextOutsideClickRef.current = true;
5122 preventedPressSuppressionTimeout.start(0, () => {
5123 suppressNextOutsideClickRef.current = false;
5124 });
5125 }
5126 function resetPressStartState() {
5127 pressStartedInsideRef.current = false;
5128 pressStartPreventedRef.current = false;
5129 }
5130 function getOutsidePressEvent() {
5131 const type = currentPointerTypeRef.current;
5132 const computedType = type === "pen" || !type ? "mouse" : type;
5133 const outsidePressEventValue = getOutsidePressEventProp();
5134 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
5135 if (typeof resolved === "string") {
5136 return resolved;
5137 }
5138 return resolved[computedType];
5139 }
5140 function shouldIgnoreEvent(event) {
5141 const computedOutsidePressEvent = getOutsidePressEvent();
5142 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
5143 }
5144 function isEventWithinFloatingTree(event) {
5145 const nodeId = dataRef.current.floatingContext?.nodeId;
5146 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
5147 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement")) || targetIsInsideChildren;
5148 }
5149 function closeOnPressOutside(event) {
5150 if (shouldIgnoreEvent(event)) {
5151 clearInsideReactTree();
5152 return;
5153 }
5154 if (dataRef.current.insideReactTree) {
5155 clearInsideReactTree();
5156 return;
5157 }
5158 const target = getTarget(event);
5159 const inertSelector = `[${createAttribute("inert")}]`;
5160 const targetRoot = isElement(target) ? target.getRootNode() : null;
5161 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
5162 const triggers = store.context.triggerElements;
5163 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
5164 return;
5165 }
5166 let targetRootAncestor = isElement(target) ? target : null;
5167 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
5168 const nextParent = getParentNode(targetRootAncestor);
5169 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
5170 break;
5171 }
5172 targetRootAncestor = nextParent;
5173 }
5174 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
5175 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
5176 // element was injected after the floating element rendered.
5177 markers.every((marker) => !contains(targetRootAncestor, marker))) {
5178 return;
5179 }
5180 if (isHTMLElement(target) && !("touches" in event)) {
5181 const lastTraversableNode = isLastTraversableNode(target);
5182 const style = getComputedStyle2(target);
5183 const scrollRe = /auto|scroll/;
5184 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
5185 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
5186 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
5187 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
5188 const isRTL7 = style.direction === "rtl";
5189 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
5190 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
5191 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
5192 return;
5193 }
5194 }
5195 if (isEventWithinFloatingTree(event)) {
5196 return;
5197 }
5198 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
5199 preventedPressSuppressionTimeout.clear();
5200 suppressNextOutsideClickRef.current = false;
5201 return;
5202 }
5203 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
5204 return;
5205 }
5206 const nodeId = dataRef.current.floatingContext?.nodeId;
5207 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
5208 if (children.length > 0) {
5209 let shouldDismiss = true;
5210 children.forEach((child) => {
5211 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) {
5212 shouldDismiss = false;
5213 }
5214 });
5215 if (!shouldDismiss) {
5216 return;
5217 }
5218 }
5219 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
5220 clearInsideReactTree();
5221 }
5222 function handlePointerDown(event) {
5223 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
5224 return;
5225 }
5226 closeOnPressOutside(event);
5227 }
5228 function handleTouchStart(event) {
5229 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
5230 return;
5231 }
5232 const touch = event.touches[0];
5233 if (touch) {
5234 touchStateRef.current = {
5235 startTime: Date.now(),
5236 startX: touch.clientX,
5237 startY: touch.clientY,
5238 dismissOnTouchEnd: false,
5239 dismissOnMouseDown: true
5240 };
5241 cancelDismissOnEndTimeout.start(1e3, () => {
5242 if (touchStateRef.current) {
5243 touchStateRef.current.dismissOnTouchEnd = false;
5244 touchStateRef.current.dismissOnMouseDown = false;
5245 }
5246 });
5247 }
5248 }
5249 function addTargetEventListenerOnce(event, listener) {
5250 const target = getTarget(event);
5251 if (!target) {
5252 return;
5253 }
5254 const unsubscribe2 = addEventListener(target, event.type, () => {
5255 listener(event);
5256 unsubscribe2();
5257 });
5258 }
5259 function handleTouchStartCapture(event) {
5260 currentPointerTypeRef.current = "touch";
5261 addTargetEventListenerOnce(event, handleTouchStart);
5262 }
5263 function closeOnPressOutsideCapture(event) {
5264 cancelDismissOnEndTimeout.clear();
5265 if (event.type === "pointerdown") {
5266 currentPointerTypeRef.current = event.pointerType;
5267 }
5268 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
5269 return;
5270 }
5271 addTargetEventListenerOnce(event, (targetEvent) => {
5272 if (targetEvent.type === "pointerdown") {
5273 handlePointerDown(targetEvent);
5274 } else {
5275 closeOnPressOutside(targetEvent);
5276 }
5277 });
5278 }
5279 function handlePressEndCapture(event) {
5280 if (!pressStartedInsideRef.current) {
5281 return;
5282 }
5283 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
5284 resetPressStartState();
5285 if (getOutsidePressEvent() !== "intentional") {
5286 return;
5287 }
5288 if (event.type === "pointercancel") {
5289 if (pressStartedInsideDefaultPrevented) {
5290 suppressImmediateOutsideClickAfterPreventedStart();
5291 }
5292 return;
5293 }
5294 if (isEventWithinFloatingTree(event)) {
5295 return;
5296 }
5297 if (pressStartedInsideDefaultPrevented) {
5298 suppressImmediateOutsideClickAfterPreventedStart();
5299 return;
5300 }
5301 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
5302 return;
5303 }
5304 preventedPressSuppressionTimeout.clear();
5305 suppressNextOutsideClickRef.current = true;
5306 clearInsideReactTree();
5307 }
5308 function handleTouchMove(event) {
5309 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
5310 return;
5311 }
5312 const touch = event.touches[0];
5313 if (!touch) {
5314 return;
5315 }
5316 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
5317 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
5318 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
5319 if (distance > 5) {
5320 touchStateRef.current.dismissOnTouchEnd = true;
5321 }
5322 if (distance > 10) {
5323 closeOnPressOutside(event);
5324 cancelDismissOnEndTimeout.clear();
5325 touchStateRef.current = null;
5326 }
5327 }
5328 function handleTouchMoveCapture(event) {
5329 addTargetEventListenerOnce(event, handleTouchMove);
5330 }
5331 function handleTouchEnd(event) {
5332 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
5333 return;
5334 }
5335 if (touchStateRef.current.dismissOnTouchEnd) {
5336 closeOnPressOutside(event);
5337 }
5338 cancelDismissOnEndTimeout.clear();
5339 touchStateRef.current = null;
5340 }
5341 function handleTouchEndCapture(event) {
5342 addTargetEventListenerOnce(event, handleTouchEnd);
5343 }
5344 const doc = ownerDocument(floatingElement);
5345 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)));
5346 return () => {
5347 unsubscribe();
5348 compositionTimeout.clear();
5349 preventedPressSuppressionTimeout.clear();
5350 resetPressStartState();
5351 suppressNextOutsideClickRef.current = false;
5352 };
5353 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store, cancelDismissOnEndTimeout]);
5354 React28.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
5355 const reference = React28.useMemo(() => ({
5356 onKeyDown: closeOnEscapeKeyDown,
5357 [bubbleHandlerKeys[referencePressEvent]]: (event) => {
5358 if (!isReferencePressEnabled()) {
5359 return;
5360 }
5361 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
5362 },
5363 ...referencePressEvent !== "intentional" && {
5364 onClick(event) {
5365 if (!isReferencePressEnabled()) {
5366 return;
5367 }
5368 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
5369 }
5370 }
5371 }), [closeOnEscapeKeyDown, store, referencePressEvent, isReferencePressEnabled]);
5372 const markPressStartedInsideReactTree = useStableCallback((event) => {
5373 if (!open || !enabled || event.button !== 0) {
5374 return;
5375 }
5376 const target = getTarget(event.nativeEvent);
5377 if (!contains(store.select("floatingElement"), target)) {
5378 return;
5379 }
5380 if (!pressStartedInsideRef.current) {
5381 pressStartedInsideRef.current = true;
5382 pressStartPreventedRef.current = false;
5383 }
5384 });
5385 const markInsidePressStartPrevented = useStableCallback((event) => {
5386 if (!open || !enabled) {
5387 return;
5388 }
5389 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
5390 return;
5391 }
5392 if (pressStartedInsideRef.current) {
5393 pressStartPreventedRef.current = true;
5394 }
5395 });
5396 const floating = React28.useMemo(() => ({
5397 onKeyDown: closeOnEscapeKeyDown,
5398 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
5399 // `onPointerDown`, such as with <NumberField.ScrubArea>.
5400 // See https://github.com/mui/base-ui/pull/3379
5401 onPointerDown: markInsidePressStartPrevented,
5402 onMouseDown: markInsidePressStartPrevented,
5403 onClickCapture: markInsideReactTree,
5404 onMouseDownCapture(event) {
5405 markInsideReactTree();
5406 markPressStartedInsideReactTree(event);
5407 },
5408 onPointerDownCapture(event) {
5409 markInsideReactTree();
5410 markPressStartedInsideReactTree(event);
5411 },
5412 onMouseUpCapture: markInsideReactTree,
5413 onTouchEndCapture: markInsideReactTree,
5414 onTouchMoveCapture: markInsideReactTree
5415 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
5416 return React28.useMemo(() => enabled ? {
5417 reference,
5418 floating,
5419 trigger: reference
5420 } : {}, [enabled, reference, floating]);
5421 }
5422
5423 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
5424 var React34 = __toESM(require_react(), 1);
5425
5426 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
5427 function computeCoordsFromPlacement(_ref, placement, rtl) {
5428 let {
5429 reference,
5430 floating
5431 } = _ref;
5432 const sideAxis = getSideAxis(placement);
5433 const alignmentAxis = getAlignmentAxis(placement);
5434 const alignLength = getAxisLength(alignmentAxis);
5435 const side = getSide(placement);
5436 const isVertical = sideAxis === "y";
5437 const commonX = reference.x + reference.width / 2 - floating.width / 2;
5438 const commonY = reference.y + reference.height / 2 - floating.height / 2;
5439 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
5440 let coords;
5441 switch (side) {
5442 case "top":
5443 coords = {
5444 x: commonX,
5445 y: reference.y - floating.height
5446 };
5447 break;
5448 case "bottom":
5449 coords = {
5450 x: commonX,
5451 y: reference.y + reference.height
5452 };
5453 break;
5454 case "right":
5455 coords = {
5456 x: reference.x + reference.width,
5457 y: commonY
5458 };
5459 break;
5460 case "left":
5461 coords = {
5462 x: reference.x - floating.width,
5463 y: commonY
5464 };
5465 break;
5466 default:
5467 coords = {
5468 x: reference.x,
5469 y: reference.y
5470 };
5471 }
5472 switch (getAlignment(placement)) {
5473 case "start":
5474 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
5475 break;
5476 case "end":
5477 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
5478 break;
5479 }
5480 return coords;
5481 }
5482 async function detectOverflow(state, options) {
5483 var _await$platform$isEle;
5484 if (options === void 0) {
5485 options = {};
5486 }
5487 const {
5488 x: x2,
5489 y: y2,
5490 platform: platform3,
5491 rects,
5492 elements,
5493 strategy
5494 } = state;
5495 const {
5496 boundary = "clippingAncestors",
5497 rootBoundary = "viewport",
5498 elementContext = "floating",
5499 altBoundary = false,
5500 padding = 0
5501 } = evaluate(options, state);
5502 const paddingObject = getPaddingObject(padding);
5503 const altContext = elementContext === "floating" ? "reference" : "floating";
5504 const element = elements[altBoundary ? altContext : elementContext];
5505 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
5506 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)),
5507 boundary,
5508 rootBoundary,
5509 strategy
5510 }));
5511 const rect = elementContext === "floating" ? {
5512 x: x2,
5513 y: y2,
5514 width: rects.floating.width,
5515 height: rects.floating.height
5516 } : rects.reference;
5517 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
5518 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
5519 x: 1,
5520 y: 1
5521 } : {
5522 x: 1,
5523 y: 1
5524 };
5525 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
5526 elements,
5527 rect,
5528 offsetParent,
5529 strategy
5530 }) : rect);
5531 return {
5532 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
5533 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
5534 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
5535 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
5536 };
5537 }
5538 var MAX_RESET_COUNT = 50;
5539 var computePosition = async (reference, floating, config) => {
5540 const {
5541 placement = "bottom",
5542 strategy = "absolute",
5543 middleware = [],
5544 platform: platform3
5545 } = config;
5546 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
5547 ...platform3,
5548 detectOverflow
5549 };
5550 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
5551 let rects = await platform3.getElementRects({
5552 reference,
5553 floating,
5554 strategy
5555 });
5556 let {
5557 x: x2,
5558 y: y2
5559 } = computeCoordsFromPlacement(rects, placement, rtl);
5560 let statefulPlacement = placement;
5561 let resetCount = 0;
5562 const middlewareData = {};
5563 for (let i2 = 0; i2 < middleware.length; i2++) {
5564 const currentMiddleware = middleware[i2];
5565 if (!currentMiddleware) {
5566 continue;
5567 }
5568 const {
5569 name,
5570 fn
5571 } = currentMiddleware;
5572 const {
5573 x: nextX,
5574 y: nextY,
5575 data,
5576 reset
5577 } = await fn({
5578 x: x2,
5579 y: y2,
5580 initialPlacement: placement,
5581 placement: statefulPlacement,
5582 strategy,
5583 middlewareData,
5584 rects,
5585 platform: platformWithDetectOverflow,
5586 elements: {
5587 reference,
5588 floating
5589 }
5590 });
5591 x2 = nextX != null ? nextX : x2;
5592 y2 = nextY != null ? nextY : y2;
5593 middlewareData[name] = {
5594 ...middlewareData[name],
5595 ...data
5596 };
5597 if (reset && resetCount < MAX_RESET_COUNT) {
5598 resetCount++;
5599 if (typeof reset === "object") {
5600 if (reset.placement) {
5601 statefulPlacement = reset.placement;
5602 }
5603 if (reset.rects) {
5604 rects = reset.rects === true ? await platform3.getElementRects({
5605 reference,
5606 floating,
5607 strategy
5608 }) : reset.rects;
5609 }
5610 ({
5611 x: x2,
5612 y: y2
5613 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
5614 }
5615 i2 = -1;
5616 }
5617 }
5618 return {
5619 x: x2,
5620 y: y2,
5621 placement: statefulPlacement,
5622 strategy,
5623 middlewareData
5624 };
5625 };
5626 var flip = function(options) {
5627 if (options === void 0) {
5628 options = {};
5629 }
5630 return {
5631 name: "flip",
5632 options,
5633 async fn(state) {
5634 var _middlewareData$arrow, _middlewareData$flip;
5635 const {
5636 placement,
5637 middlewareData,
5638 rects,
5639 initialPlacement,
5640 platform: platform3,
5641 elements
5642 } = state;
5643 const {
5644 mainAxis: checkMainAxis = true,
5645 crossAxis: checkCrossAxis = true,
5646 fallbackPlacements: specifiedFallbackPlacements,
5647 fallbackStrategy = "bestFit",
5648 fallbackAxisSideDirection = "none",
5649 flipAlignment = true,
5650 ...detectOverflowOptions
5651 } = evaluate(options, state);
5652 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
5653 return {};
5654 }
5655 const side = getSide(placement);
5656 const initialSideAxis = getSideAxis(initialPlacement);
5657 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
5658 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
5659 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
5660 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
5661 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
5662 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
5663 }
5664 const placements2 = [initialPlacement, ...fallbackPlacements];
5665 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
5666 const overflows = [];
5667 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
5668 if (checkMainAxis) {
5669 overflows.push(overflow[side]);
5670 }
5671 if (checkCrossAxis) {
5672 const sides2 = getAlignmentSides(placement, rects, rtl);
5673 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
5674 }
5675 overflowsData = [...overflowsData, {
5676 placement,
5677 overflows
5678 }];
5679 if (!overflows.every((side2) => side2 <= 0)) {
5680 var _middlewareData$flip2, _overflowsData$filter;
5681 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
5682 const nextPlacement = placements2[nextIndex];
5683 if (nextPlacement) {
5684 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
5685 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
5686 // overflows the main axis.
5687 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
5688 return {
5689 data: {
5690 index: nextIndex,
5691 overflows: overflowsData
5692 },
5693 reset: {
5694 placement: nextPlacement
5695 }
5696 };
5697 }
5698 }
5699 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;
5700 if (!resetPlacement) {
5701 switch (fallbackStrategy) {
5702 case "bestFit": {
5703 var _overflowsData$filter2;
5704 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
5705 if (hasFallbackAxisSideDirection) {
5706 const currentSideAxis = getSideAxis(d2.placement);
5707 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
5708 // reading directions favoring greater width.
5709 currentSideAxis === "y";
5710 }
5711 return true;
5712 }).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];
5713 if (placement2) {
5714 resetPlacement = placement2;
5715 }
5716 break;
5717 }
5718 case "initialPlacement":
5719 resetPlacement = initialPlacement;
5720 break;
5721 }
5722 }
5723 if (placement !== resetPlacement) {
5724 return {
5725 reset: {
5726 placement: resetPlacement
5727 }
5728 };
5729 }
5730 }
5731 return {};
5732 }
5733 };
5734 };
5735 function getSideOffsets(overflow, rect) {
5736 return {
5737 top: overflow.top - rect.height,
5738 right: overflow.right - rect.width,
5739 bottom: overflow.bottom - rect.height,
5740 left: overflow.left - rect.width
5741 };
5742 }
5743 function isAnySideFullyClipped(overflow) {
5744 return sides.some((side) => overflow[side] >= 0);
5745 }
5746 var hide = function(options) {
5747 if (options === void 0) {
5748 options = {};
5749 }
5750 return {
5751 name: "hide",
5752 options,
5753 async fn(state) {
5754 const {
5755 rects,
5756 platform: platform3
5757 } = state;
5758 const {
5759 strategy = "referenceHidden",
5760 ...detectOverflowOptions
5761 } = evaluate(options, state);
5762 switch (strategy) {
5763 case "referenceHidden": {
5764 const overflow = await platform3.detectOverflow(state, {
5765 ...detectOverflowOptions,
5766 elementContext: "reference"
5767 });
5768 const offsets = getSideOffsets(overflow, rects.reference);
5769 return {
5770 data: {
5771 referenceHiddenOffsets: offsets,
5772 referenceHidden: isAnySideFullyClipped(offsets)
5773 }
5774 };
5775 }
5776 case "escaped": {
5777 const overflow = await platform3.detectOverflow(state, {
5778 ...detectOverflowOptions,
5779 altBoundary: true
5780 });
5781 const offsets = getSideOffsets(overflow, rects.floating);
5782 return {
5783 data: {
5784 escapedOffsets: offsets,
5785 escaped: isAnySideFullyClipped(offsets)
5786 }
5787 };
5788 }
5789 default: {
5790 return {};
5791 }
5792 }
5793 }
5794 };
5795 };
5796 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
5797 async function convertValueToCoords(state, options) {
5798 const {
5799 placement,
5800 platform: platform3,
5801 elements
5802 } = state;
5803 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
5804 const side = getSide(placement);
5805 const alignment = getAlignment(placement);
5806 const isVertical = getSideAxis(placement) === "y";
5807 const mainAxisMulti = originSides.has(side) ? -1 : 1;
5808 const crossAxisMulti = rtl && isVertical ? -1 : 1;
5809 const rawValue = evaluate(options, state);
5810 let {
5811 mainAxis,
5812 crossAxis,
5813 alignmentAxis
5814 } = typeof rawValue === "number" ? {
5815 mainAxis: rawValue,
5816 crossAxis: 0,
5817 alignmentAxis: null
5818 } : {
5819 mainAxis: rawValue.mainAxis || 0,
5820 crossAxis: rawValue.crossAxis || 0,
5821 alignmentAxis: rawValue.alignmentAxis
5822 };
5823 if (alignment && typeof alignmentAxis === "number") {
5824 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
5825 }
5826 return isVertical ? {
5827 x: crossAxis * crossAxisMulti,
5828 y: mainAxis * mainAxisMulti
5829 } : {
5830 x: mainAxis * mainAxisMulti,
5831 y: crossAxis * crossAxisMulti
5832 };
5833 }
5834 var offset = function(options) {
5835 if (options === void 0) {
5836 options = 0;
5837 }
5838 return {
5839 name: "offset",
5840 options,
5841 async fn(state) {
5842 var _middlewareData$offse, _middlewareData$arrow;
5843 const {
5844 x: x2,
5845 y: y2,
5846 placement,
5847 middlewareData
5848 } = state;
5849 const diffCoords = await convertValueToCoords(state, options);
5850 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
5851 return {};
5852 }
5853 return {
5854 x: x2 + diffCoords.x,
5855 y: y2 + diffCoords.y,
5856 data: {
5857 ...diffCoords,
5858 placement
5859 }
5860 };
5861 }
5862 };
5863 };
5864 var shift = function(options) {
5865 if (options === void 0) {
5866 options = {};
5867 }
5868 return {
5869 name: "shift",
5870 options,
5871 async fn(state) {
5872 const {
5873 x: x2,
5874 y: y2,
5875 placement,
5876 platform: platform3
5877 } = state;
5878 const {
5879 mainAxis: checkMainAxis = true,
5880 crossAxis: checkCrossAxis = false,
5881 limiter = {
5882 fn: (_ref) => {
5883 let {
5884 x: x3,
5885 y: y3
5886 } = _ref;
5887 return {
5888 x: x3,
5889 y: y3
5890 };
5891 }
5892 },
5893 ...detectOverflowOptions
5894 } = evaluate(options, state);
5895 const coords = {
5896 x: x2,
5897 y: y2
5898 };
5899 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
5900 const crossAxis = getSideAxis(getSide(placement));
5901 const mainAxis = getOppositeAxis(crossAxis);
5902 let mainAxisCoord = coords[mainAxis];
5903 let crossAxisCoord = coords[crossAxis];
5904 if (checkMainAxis) {
5905 const minSide = mainAxis === "y" ? "top" : "left";
5906 const maxSide = mainAxis === "y" ? "bottom" : "right";
5907 const min2 = mainAxisCoord + overflow[minSide];
5908 const max2 = mainAxisCoord - overflow[maxSide];
5909 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
5910 }
5911 if (checkCrossAxis) {
5912 const minSide = crossAxis === "y" ? "top" : "left";
5913 const maxSide = crossAxis === "y" ? "bottom" : "right";
5914 const min2 = crossAxisCoord + overflow[minSide];
5915 const max2 = crossAxisCoord - overflow[maxSide];
5916 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
5917 }
5918 const limitedCoords = limiter.fn({
5919 ...state,
5920 [mainAxis]: mainAxisCoord,
5921 [crossAxis]: crossAxisCoord
5922 });
5923 return {
5924 ...limitedCoords,
5925 data: {
5926 x: limitedCoords.x - x2,
5927 y: limitedCoords.y - y2,
5928 enabled: {
5929 [mainAxis]: checkMainAxis,
5930 [crossAxis]: checkCrossAxis
5931 }
5932 }
5933 };
5934 }
5935 };
5936 };
5937 var limitShift = function(options) {
5938 if (options === void 0) {
5939 options = {};
5940 }
5941 return {
5942 options,
5943 fn(state) {
5944 const {
5945 x: x2,
5946 y: y2,
5947 placement,
5948 rects,
5949 middlewareData
5950 } = state;
5951 const {
5952 offset: offset4 = 0,
5953 mainAxis: checkMainAxis = true,
5954 crossAxis: checkCrossAxis = true
5955 } = evaluate(options, state);
5956 const coords = {
5957 x: x2,
5958 y: y2
5959 };
5960 const crossAxis = getSideAxis(placement);
5961 const mainAxis = getOppositeAxis(crossAxis);
5962 let mainAxisCoord = coords[mainAxis];
5963 let crossAxisCoord = coords[crossAxis];
5964 const rawOffset = evaluate(offset4, state);
5965 const computedOffset = typeof rawOffset === "number" ? {
5966 mainAxis: rawOffset,
5967 crossAxis: 0
5968 } : {
5969 mainAxis: 0,
5970 crossAxis: 0,
5971 ...rawOffset
5972 };
5973 if (checkMainAxis) {
5974 const len = mainAxis === "y" ? "height" : "width";
5975 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
5976 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
5977 if (mainAxisCoord < limitMin) {
5978 mainAxisCoord = limitMin;
5979 } else if (mainAxisCoord > limitMax) {
5980 mainAxisCoord = limitMax;
5981 }
5982 }
5983 if (checkCrossAxis) {
5984 var _middlewareData$offse, _middlewareData$offse2;
5985 const len = mainAxis === "y" ? "width" : "height";
5986 const isOriginSide = originSides.has(getSide(placement));
5987 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);
5988 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);
5989 if (crossAxisCoord < limitMin) {
5990 crossAxisCoord = limitMin;
5991 } else if (crossAxisCoord > limitMax) {
5992 crossAxisCoord = limitMax;
5993 }
5994 }
5995 return {
5996 [mainAxis]: mainAxisCoord,
5997 [crossAxis]: crossAxisCoord
5998 };
5999 }
6000 };
6001 };
6002 var size = function(options) {
6003 if (options === void 0) {
6004 options = {};
6005 }
6006 return {
6007 name: "size",
6008 options,
6009 async fn(state) {
6010 var _state$middlewareData, _state$middlewareData2;
6011 const {
6012 placement,
6013 rects,
6014 platform: platform3,
6015 elements
6016 } = state;
6017 const {
6018 apply = () => {
6019 },
6020 ...detectOverflowOptions
6021 } = evaluate(options, state);
6022 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
6023 const side = getSide(placement);
6024 const alignment = getAlignment(placement);
6025 const isYAxis = getSideAxis(placement) === "y";
6026 const {
6027 width,
6028 height
6029 } = rects.floating;
6030 let heightSide;
6031 let widthSide;
6032 if (side === "top" || side === "bottom") {
6033 heightSide = side;
6034 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
6035 } else {
6036 widthSide = side;
6037 heightSide = alignment === "end" ? "top" : "bottom";
6038 }
6039 const maximumClippingHeight = height - overflow.top - overflow.bottom;
6040 const maximumClippingWidth = width - overflow.left - overflow.right;
6041 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
6042 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
6043 const noShift = !state.middlewareData.shift;
6044 let availableHeight = overflowAvailableHeight;
6045 let availableWidth = overflowAvailableWidth;
6046 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
6047 availableWidth = maximumClippingWidth;
6048 }
6049 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
6050 availableHeight = maximumClippingHeight;
6051 }
6052 if (noShift && !alignment) {
6053 const xMin = max(overflow.left, 0);
6054 const xMax = max(overflow.right, 0);
6055 const yMin = max(overflow.top, 0);
6056 const yMax = max(overflow.bottom, 0);
6057 if (isYAxis) {
6058 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
6059 } else {
6060 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
6061 }
6062 }
6063 await apply({
6064 ...state,
6065 availableWidth,
6066 availableHeight
6067 });
6068 const nextDimensions = await platform3.getDimensions(elements.floating);
6069 if (width !== nextDimensions.width || height !== nextDimensions.height) {
6070 return {
6071 reset: {
6072 rects: true
6073 }
6074 };
6075 }
6076 return {};
6077 }
6078 };
6079 };
6080
6081 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
6082 function getCssDimensions(element) {
6083 const css = getComputedStyle2(element);
6084 let width = parseFloat(css.width) || 0;
6085 let height = parseFloat(css.height) || 0;
6086 const hasOffset = isHTMLElement(element);
6087 const offsetWidth = hasOffset ? element.offsetWidth : width;
6088 const offsetHeight = hasOffset ? element.offsetHeight : height;
6089 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
6090 if (shouldFallback) {
6091 width = offsetWidth;
6092 height = offsetHeight;
6093 }
6094 return {
6095 width,
6096 height,
6097 $: shouldFallback
6098 };
6099 }
6100 function unwrapElement(element) {
6101 return !isElement(element) ? element.contextElement : element;
6102 }
6103 function getScale(element) {
6104 const domElement = unwrapElement(element);
6105 if (!isHTMLElement(domElement)) {
6106 return createCoords(1);
6107 }
6108 const rect = domElement.getBoundingClientRect();
6109 const {
6110 width,
6111 height,
6112 $: $2
6113 } = getCssDimensions(domElement);
6114 let x2 = ($2 ? round(rect.width) : rect.width) / width;
6115 let y2 = ($2 ? round(rect.height) : rect.height) / height;
6116 if (!x2 || !Number.isFinite(x2)) {
6117 x2 = 1;
6118 }
6119 if (!y2 || !Number.isFinite(y2)) {
6120 y2 = 1;
6121 }
6122 return {
6123 x: x2,
6124 y: y2
6125 };
6126 }
6127 var noOffsets = /* @__PURE__ */ createCoords(0);
6128 function getVisualOffsets(element) {
6129 const win = getWindow(element);
6130 if (!isWebKit() || !win.visualViewport) {
6131 return noOffsets;
6132 }
6133 return {
6134 x: win.visualViewport.offsetLeft,
6135 y: win.visualViewport.offsetTop
6136 };
6137 }
6138 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
6139 if (isFixed === void 0) {
6140 isFixed = false;
6141 }
6142 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
6143 return false;
6144 }
6145 return isFixed;
6146 }
6147 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
6148 if (includeScale === void 0) {
6149 includeScale = false;
6150 }
6151 if (isFixedStrategy === void 0) {
6152 isFixedStrategy = false;
6153 }
6154 const clientRect = element.getBoundingClientRect();
6155 const domElement = unwrapElement(element);
6156 let scale = createCoords(1);
6157 if (includeScale) {
6158 if (offsetParent) {
6159 if (isElement(offsetParent)) {
6160 scale = getScale(offsetParent);
6161 }
6162 } else {
6163 scale = getScale(element);
6164 }
6165 }
6166 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
6167 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
6168 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
6169 let width = clientRect.width / scale.x;
6170 let height = clientRect.height / scale.y;
6171 if (domElement) {
6172 const win = getWindow(domElement);
6173 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
6174 let currentWin = win;
6175 let currentIFrame = getFrameElement(currentWin);
6176 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
6177 const iframeScale = getScale(currentIFrame);
6178 const iframeRect = currentIFrame.getBoundingClientRect();
6179 const css = getComputedStyle2(currentIFrame);
6180 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
6181 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
6182 x2 *= iframeScale.x;
6183 y2 *= iframeScale.y;
6184 width *= iframeScale.x;
6185 height *= iframeScale.y;
6186 x2 += left;
6187 y2 += top;
6188 currentWin = getWindow(currentIFrame);
6189 currentIFrame = getFrameElement(currentWin);
6190 }
6191 }
6192 return rectToClientRect({
6193 width,
6194 height,
6195 x: x2,
6196 y: y2
6197 });
6198 }
6199 function getWindowScrollBarX(element, rect) {
6200 const leftScroll = getNodeScroll(element).scrollLeft;
6201 if (!rect) {
6202 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
6203 }
6204 return rect.left + leftScroll;
6205 }
6206 function getHTMLOffset(documentElement, scroll) {
6207 const htmlRect = documentElement.getBoundingClientRect();
6208 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
6209 const y2 = htmlRect.top + scroll.scrollTop;
6210 return {
6211 x: x2,
6212 y: y2
6213 };
6214 }
6215 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
6216 let {
6217 elements,
6218 rect,
6219 offsetParent,
6220 strategy
6221 } = _ref;
6222 const isFixed = strategy === "fixed";
6223 const documentElement = getDocumentElement(offsetParent);
6224 const topLayer = elements ? isTopLayer(elements.floating) : false;
6225 if (offsetParent === documentElement || topLayer && isFixed) {
6226 return rect;
6227 }
6228 let scroll = {
6229 scrollLeft: 0,
6230 scrollTop: 0
6231 };
6232 let scale = createCoords(1);
6233 const offsets = createCoords(0);
6234 const isOffsetParentAnElement = isHTMLElement(offsetParent);
6235 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
6236 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
6237 scroll = getNodeScroll(offsetParent);
6238 }
6239 if (isOffsetParentAnElement) {
6240 const offsetRect = getBoundingClientRect(offsetParent);
6241 scale = getScale(offsetParent);
6242 offsets.x = offsetRect.x + offsetParent.clientLeft;
6243 offsets.y = offsetRect.y + offsetParent.clientTop;
6244 }
6245 }
6246 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
6247 return {
6248 width: rect.width * scale.x,
6249 height: rect.height * scale.y,
6250 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
6251 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
6252 };
6253 }
6254 function getClientRects(element) {
6255 return Array.from(element.getClientRects());
6256 }
6257 function getDocumentRect(element) {
6258 const html = getDocumentElement(element);
6259 const scroll = getNodeScroll(element);
6260 const body = element.ownerDocument.body;
6261 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
6262 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
6263 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
6264 const y2 = -scroll.scrollTop;
6265 if (getComputedStyle2(body).direction === "rtl") {
6266 x2 += max(html.clientWidth, body.clientWidth) - width;
6267 }
6268 return {
6269 width,
6270 height,
6271 x: x2,
6272 y: y2
6273 };
6274 }
6275 var SCROLLBAR_MAX = 25;
6276 function getViewportRect(element, strategy) {
6277 const win = getWindow(element);
6278 const html = getDocumentElement(element);
6279 const visualViewport = win.visualViewport;
6280 let width = html.clientWidth;
6281 let height = html.clientHeight;
6282 let x2 = 0;
6283 let y2 = 0;
6284 if (visualViewport) {
6285 width = visualViewport.width;
6286 height = visualViewport.height;
6287 const visualViewportBased = isWebKit();
6288 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
6289 x2 = visualViewport.offsetLeft;
6290 y2 = visualViewport.offsetTop;
6291 }
6292 }
6293 const windowScrollbarX = getWindowScrollBarX(html);
6294 if (windowScrollbarX <= 0) {
6295 const doc = html.ownerDocument;
6296 const body = doc.body;
6297 const bodyStyles = getComputedStyle(body);
6298 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
6299 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
6300 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
6301 width -= clippingStableScrollbarWidth;
6302 }
6303 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
6304 width += windowScrollbarX;
6305 }
6306 return {
6307 width,
6308 height,
6309 x: x2,
6310 y: y2
6311 };
6312 }
6313 function getInnerBoundingClientRect(element, strategy) {
6314 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
6315 const top = clientRect.top + element.clientTop;
6316 const left = clientRect.left + element.clientLeft;
6317 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
6318 const width = element.clientWidth * scale.x;
6319 const height = element.clientHeight * scale.y;
6320 const x2 = left * scale.x;
6321 const y2 = top * scale.y;
6322 return {
6323 width,
6324 height,
6325 x: x2,
6326 y: y2
6327 };
6328 }
6329 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
6330 let rect;
6331 if (clippingAncestor === "viewport") {
6332 rect = getViewportRect(element, strategy);
6333 } else if (clippingAncestor === "document") {
6334 rect = getDocumentRect(getDocumentElement(element));
6335 } else if (isElement(clippingAncestor)) {
6336 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
6337 } else {
6338 const visualOffsets = getVisualOffsets(element);
6339 rect = {
6340 x: clippingAncestor.x - visualOffsets.x,
6341 y: clippingAncestor.y - visualOffsets.y,
6342 width: clippingAncestor.width,
6343 height: clippingAncestor.height
6344 };
6345 }
6346 return rectToClientRect(rect);
6347 }
6348 function hasFixedPositionAncestor(element, stopNode) {
6349 const parentNode = getParentNode(element);
6350 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
6351 return false;
6352 }
6353 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
6354 }
6355 function getClippingElementAncestors(element, cache) {
6356 const cachedResult = cache.get(element);
6357 if (cachedResult) {
6358 return cachedResult;
6359 }
6360 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
6361 let currentContainingBlockComputedStyle = null;
6362 const elementIsFixed = getComputedStyle2(element).position === "fixed";
6363 let currentNode = elementIsFixed ? getParentNode(element) : element;
6364 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
6365 const computedStyle = getComputedStyle2(currentNode);
6366 const currentNodeIsContaining = isContainingBlock(currentNode);
6367 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
6368 currentContainingBlockComputedStyle = null;
6369 }
6370 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
6371 if (shouldDropCurrentNode) {
6372 result = result.filter((ancestor) => ancestor !== currentNode);
6373 } else {
6374 currentContainingBlockComputedStyle = computedStyle;
6375 }
6376 currentNode = getParentNode(currentNode);
6377 }
6378 cache.set(element, result);
6379 return result;
6380 }
6381 function getClippingRect(_ref) {
6382 let {
6383 element,
6384 boundary,
6385 rootBoundary,
6386 strategy
6387 } = _ref;
6388 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
6389 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
6390 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
6391 let top = firstRect.top;
6392 let right = firstRect.right;
6393 let bottom = firstRect.bottom;
6394 let left = firstRect.left;
6395 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
6396 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
6397 top = max(rect.top, top);
6398 right = min(rect.right, right);
6399 bottom = min(rect.bottom, bottom);
6400 left = max(rect.left, left);
6401 }
6402 return {
6403 width: right - left,
6404 height: bottom - top,
6405 x: left,
6406 y: top
6407 };
6408 }
6409 function getDimensions(element) {
6410 const {
6411 width,
6412 height
6413 } = getCssDimensions(element);
6414 return {
6415 width,
6416 height
6417 };
6418 }
6419 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
6420 const isOffsetParentAnElement = isHTMLElement(offsetParent);
6421 const documentElement = getDocumentElement(offsetParent);
6422 const isFixed = strategy === "fixed";
6423 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
6424 let scroll = {
6425 scrollLeft: 0,
6426 scrollTop: 0
6427 };
6428 const offsets = createCoords(0);
6429 function setLeftRTLScrollbarOffset() {
6430 offsets.x = getWindowScrollBarX(documentElement);
6431 }
6432 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
6433 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
6434 scroll = getNodeScroll(offsetParent);
6435 }
6436 if (isOffsetParentAnElement) {
6437 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
6438 offsets.x = offsetRect.x + offsetParent.clientLeft;
6439 offsets.y = offsetRect.y + offsetParent.clientTop;
6440 } else if (documentElement) {
6441 setLeftRTLScrollbarOffset();
6442 }
6443 }
6444 if (isFixed && !isOffsetParentAnElement && documentElement) {
6445 setLeftRTLScrollbarOffset();
6446 }
6447 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
6448 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
6449 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
6450 return {
6451 x: x2,
6452 y: y2,
6453 width: rect.width,
6454 height: rect.height
6455 };
6456 }
6457 function isStaticPositioned(element) {
6458 return getComputedStyle2(element).position === "static";
6459 }
6460 function getTrueOffsetParent(element, polyfill) {
6461 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
6462 return null;
6463 }
6464 if (polyfill) {
6465 return polyfill(element);
6466 }
6467 let rawOffsetParent = element.offsetParent;
6468 if (getDocumentElement(element) === rawOffsetParent) {
6469 rawOffsetParent = rawOffsetParent.ownerDocument.body;
6470 }
6471 return rawOffsetParent;
6472 }
6473 function getOffsetParent(element, polyfill) {
6474 const win = getWindow(element);
6475 if (isTopLayer(element)) {
6476 return win;
6477 }
6478 if (!isHTMLElement(element)) {
6479 let svgOffsetParent = getParentNode(element);
6480 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
6481 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
6482 return svgOffsetParent;
6483 }
6484 svgOffsetParent = getParentNode(svgOffsetParent);
6485 }
6486 return win;
6487 }
6488 let offsetParent = getTrueOffsetParent(element, polyfill);
6489 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
6490 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
6491 }
6492 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
6493 return win;
6494 }
6495 return offsetParent || getContainingBlock(element) || win;
6496 }
6497 var getElementRects = async function(data) {
6498 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
6499 const getDimensionsFn = this.getDimensions;
6500 const floatingDimensions = await getDimensionsFn(data.floating);
6501 return {
6502 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
6503 floating: {
6504 x: 0,
6505 y: 0,
6506 width: floatingDimensions.width,
6507 height: floatingDimensions.height
6508 }
6509 };
6510 };
6511 function isRTL(element) {
6512 return getComputedStyle2(element).direction === "rtl";
6513 }
6514 var platform2 = {
6515 convertOffsetParentRelativeRectToViewportRelativeRect,
6516 getDocumentElement,
6517 getClippingRect,
6518 getOffsetParent,
6519 getElementRects,
6520 getClientRects,
6521 getDimensions,
6522 getScale,
6523 isElement,
6524 isRTL
6525 };
6526 function rectsAreEqual(a2, b2) {
6527 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
6528 }
6529 function observeMove(element, onMove) {
6530 let io = null;
6531 let timeoutId;
6532 const root = getDocumentElement(element);
6533 function cleanup() {
6534 var _io;
6535 clearTimeout(timeoutId);
6536 (_io = io) == null || _io.disconnect();
6537 io = null;
6538 }
6539 function refresh(skip, threshold) {
6540 if (skip === void 0) {
6541 skip = false;
6542 }
6543 if (threshold === void 0) {
6544 threshold = 1;
6545 }
6546 cleanup();
6547 const elementRectForRootMargin = element.getBoundingClientRect();
6548 const {
6549 left,
6550 top,
6551 width,
6552 height
6553 } = elementRectForRootMargin;
6554 if (!skip) {
6555 onMove();
6556 }
6557 if (!width || !height) {
6558 return;
6559 }
6560 const insetTop = floor(top);
6561 const insetRight = floor(root.clientWidth - (left + width));
6562 const insetBottom = floor(root.clientHeight - (top + height));
6563 const insetLeft = floor(left);
6564 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
6565 const options = {
6566 rootMargin,
6567 threshold: max(0, min(1, threshold)) || 1
6568 };
6569 let isFirstUpdate = true;
6570 function handleObserve(entries) {
6571 const ratio = entries[0].intersectionRatio;
6572 if (ratio !== threshold) {
6573 if (!isFirstUpdate) {
6574 return refresh();
6575 }
6576 if (!ratio) {
6577 timeoutId = setTimeout(() => {
6578 refresh(false, 1e-7);
6579 }, 1e3);
6580 } else {
6581 refresh(false, ratio);
6582 }
6583 }
6584 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
6585 refresh();
6586 }
6587 isFirstUpdate = false;
6588 }
6589 try {
6590 io = new IntersectionObserver(handleObserve, {
6591 ...options,
6592 // Handle <iframe>s
6593 root: root.ownerDocument
6594 });
6595 } catch (_e) {
6596 io = new IntersectionObserver(handleObserve, options);
6597 }
6598 io.observe(element);
6599 }
6600 refresh(true);
6601 return cleanup;
6602 }
6603 function autoUpdate(reference, floating, update2, options) {
6604 if (options === void 0) {
6605 options = {};
6606 }
6607 const {
6608 ancestorScroll = true,
6609 ancestorResize = true,
6610 elementResize = typeof ResizeObserver === "function",
6611 layoutShift = typeof IntersectionObserver === "function",
6612 animationFrame = false
6613 } = options;
6614 const referenceEl = unwrapElement(reference);
6615 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
6616 ancestors.forEach((ancestor) => {
6617 ancestorScroll && ancestor.addEventListener("scroll", update2, {
6618 passive: true
6619 });
6620 ancestorResize && ancestor.addEventListener("resize", update2);
6621 });
6622 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
6623 let reobserveFrame = -1;
6624 let resizeObserver = null;
6625 if (elementResize) {
6626 resizeObserver = new ResizeObserver((_ref) => {
6627 let [firstEntry] = _ref;
6628 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
6629 resizeObserver.unobserve(floating);
6630 cancelAnimationFrame(reobserveFrame);
6631 reobserveFrame = requestAnimationFrame(() => {
6632 var _resizeObserver;
6633 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
6634 });
6635 }
6636 update2();
6637 });
6638 if (referenceEl && !animationFrame) {
6639 resizeObserver.observe(referenceEl);
6640 }
6641 if (floating) {
6642 resizeObserver.observe(floating);
6643 }
6644 }
6645 let frameId;
6646 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
6647 if (animationFrame) {
6648 frameLoop();
6649 }
6650 function frameLoop() {
6651 const nextRefRect = getBoundingClientRect(reference);
6652 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
6653 update2();
6654 }
6655 prevRefRect = nextRefRect;
6656 frameId = requestAnimationFrame(frameLoop);
6657 }
6658 update2();
6659 return () => {
6660 var _resizeObserver2;
6661 ancestors.forEach((ancestor) => {
6662 ancestorScroll && ancestor.removeEventListener("scroll", update2);
6663 ancestorResize && ancestor.removeEventListener("resize", update2);
6664 });
6665 cleanupIo == null || cleanupIo();
6666 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
6667 resizeObserver = null;
6668 if (animationFrame) {
6669 cancelAnimationFrame(frameId);
6670 }
6671 };
6672 }
6673 var offset2 = offset;
6674 var shift2 = shift;
6675 var flip2 = flip;
6676 var size2 = size;
6677 var hide2 = hide;
6678 var limitShift2 = limitShift;
6679 var computePosition2 = (reference, floating, options) => {
6680 const cache = /* @__PURE__ */ new Map();
6681 const mergedOptions = {
6682 platform: platform2,
6683 ...options
6684 };
6685 const platformWithCache = {
6686 ...mergedOptions.platform,
6687 _c: cache
6688 };
6689 return computePosition(reference, floating, {
6690 ...mergedOptions,
6691 platform: platformWithCache
6692 });
6693 };
6694
6695 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
6696 var React29 = __toESM(require_react(), 1);
6697 var import_react2 = __toESM(require_react(), 1);
6698 var ReactDOM3 = __toESM(require_react_dom(), 1);
6699 var isClient = typeof document !== "undefined";
6700 var noop2 = function noop3() {
6701 };
6702 var index = isClient ? import_react2.useLayoutEffect : noop2;
6703 function deepEqual(a2, b2) {
6704 if (a2 === b2) {
6705 return true;
6706 }
6707 if (typeof a2 !== typeof b2) {
6708 return false;
6709 }
6710 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
6711 return true;
6712 }
6713 let length;
6714 let i2;
6715 let keys;
6716 if (a2 && b2 && typeof a2 === "object") {
6717 if (Array.isArray(a2)) {
6718 length = a2.length;
6719 if (length !== b2.length) return false;
6720 for (i2 = length; i2-- !== 0; ) {
6721 if (!deepEqual(a2[i2], b2[i2])) {
6722 return false;
6723 }
6724 }
6725 return true;
6726 }
6727 keys = Object.keys(a2);
6728 length = keys.length;
6729 if (length !== Object.keys(b2).length) {
6730 return false;
6731 }
6732 for (i2 = length; i2-- !== 0; ) {
6733 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
6734 return false;
6735 }
6736 }
6737 for (i2 = length; i2-- !== 0; ) {
6738 const key = keys[i2];
6739 if (key === "_owner" && a2.$$typeof) {
6740 continue;
6741 }
6742 if (!deepEqual(a2[key], b2[key])) {
6743 return false;
6744 }
6745 }
6746 return true;
6747 }
6748 return a2 !== a2 && b2 !== b2;
6749 }
6750 function getDPR(element) {
6751 if (typeof window === "undefined") {
6752 return 1;
6753 }
6754 const win = element.ownerDocument.defaultView || window;
6755 return win.devicePixelRatio || 1;
6756 }
6757 function roundByDPR(element, value) {
6758 const dpr = getDPR(element);
6759 return Math.round(value * dpr) / dpr;
6760 }
6761 function useLatestRef(value) {
6762 const ref = React29.useRef(value);
6763 index(() => {
6764 ref.current = value;
6765 });
6766 return ref;
6767 }
6768 function useFloating(options) {
6769 if (options === void 0) {
6770 options = {};
6771 }
6772 const {
6773 placement = "bottom",
6774 strategy = "absolute",
6775 middleware = [],
6776 platform: platform3,
6777 elements: {
6778 reference: externalReference,
6779 floating: externalFloating
6780 } = {},
6781 transform = true,
6782 whileElementsMounted,
6783 open
6784 } = options;
6785 const [data, setData] = React29.useState({
6786 x: 0,
6787 y: 0,
6788 strategy,
6789 placement,
6790 middlewareData: {},
6791 isPositioned: false
6792 });
6793 const [latestMiddleware, setLatestMiddleware] = React29.useState(middleware);
6794 if (!deepEqual(latestMiddleware, middleware)) {
6795 setLatestMiddleware(middleware);
6796 }
6797 const [_reference, _setReference] = React29.useState(null);
6798 const [_floating, _setFloating] = React29.useState(null);
6799 const setReference = React29.useCallback((node) => {
6800 if (node !== referenceRef.current) {
6801 referenceRef.current = node;
6802 _setReference(node);
6803 }
6804 }, []);
6805 const setFloating = React29.useCallback((node) => {
6806 if (node !== floatingRef.current) {
6807 floatingRef.current = node;
6808 _setFloating(node);
6809 }
6810 }, []);
6811 const referenceEl = externalReference || _reference;
6812 const floatingEl = externalFloating || _floating;
6813 const referenceRef = React29.useRef(null);
6814 const floatingRef = React29.useRef(null);
6815 const dataRef = React29.useRef(data);
6816 const hasWhileElementsMounted = whileElementsMounted != null;
6817 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
6818 const platformRef = useLatestRef(platform3);
6819 const openRef = useLatestRef(open);
6820 const update2 = React29.useCallback(() => {
6821 if (!referenceRef.current || !floatingRef.current) {
6822 return;
6823 }
6824 const config = {
6825 placement,
6826 strategy,
6827 middleware: latestMiddleware
6828 };
6829 if (platformRef.current) {
6830 config.platform = platformRef.current;
6831 }
6832 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
6833 const fullData = {
6834 ...data2,
6835 // The floating element's position may be recomputed while it's closed
6836 // but still mounted (such as when transitioning out). To ensure
6837 // `isPositioned` will be `false` initially on the next open, avoid
6838 // setting it to `true` when `open === false` (must be specified).
6839 isPositioned: openRef.current !== false
6840 };
6841 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
6842 dataRef.current = fullData;
6843 ReactDOM3.flushSync(() => {
6844 setData(fullData);
6845 });
6846 }
6847 });
6848 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
6849 index(() => {
6850 if (open === false && dataRef.current.isPositioned) {
6851 dataRef.current.isPositioned = false;
6852 setData((data2) => ({
6853 ...data2,
6854 isPositioned: false
6855 }));
6856 }
6857 }, [open]);
6858 const isMountedRef = React29.useRef(false);
6859 index(() => {
6860 isMountedRef.current = true;
6861 return () => {
6862 isMountedRef.current = false;
6863 };
6864 }, []);
6865 index(() => {
6866 if (referenceEl) referenceRef.current = referenceEl;
6867 if (floatingEl) floatingRef.current = floatingEl;
6868 if (referenceEl && floatingEl) {
6869 if (whileElementsMountedRef.current) {
6870 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
6871 }
6872 update2();
6873 }
6874 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
6875 const refs = React29.useMemo(() => ({
6876 reference: referenceRef,
6877 floating: floatingRef,
6878 setReference,
6879 setFloating
6880 }), [setReference, setFloating]);
6881 const elements = React29.useMemo(() => ({
6882 reference: referenceEl,
6883 floating: floatingEl
6884 }), [referenceEl, floatingEl]);
6885 const floatingStyles = React29.useMemo(() => {
6886 const initialStyles = {
6887 position: strategy,
6888 left: 0,
6889 top: 0
6890 };
6891 if (!elements.floating) {
6892 return initialStyles;
6893 }
6894 const x2 = roundByDPR(elements.floating, data.x);
6895 const y2 = roundByDPR(elements.floating, data.y);
6896 if (transform) {
6897 return {
6898 ...initialStyles,
6899 transform: "translate(" + x2 + "px, " + y2 + "px)",
6900 ...getDPR(elements.floating) >= 1.5 && {
6901 willChange: "transform"
6902 }
6903 };
6904 }
6905 return {
6906 position: strategy,
6907 left: x2,
6908 top: y2
6909 };
6910 }, [strategy, transform, elements.floating, data.x, data.y]);
6911 return React29.useMemo(() => ({
6912 ...data,
6913 update: update2,
6914 refs,
6915 elements,
6916 floatingStyles
6917 }), [data, update2, refs, elements, floatingStyles]);
6918 }
6919 var offset3 = (options, deps) => {
6920 const result = offset2(options);
6921 return {
6922 name: result.name,
6923 fn: result.fn,
6924 options: [options, deps]
6925 };
6926 };
6927 var shift3 = (options, deps) => {
6928 const result = shift2(options);
6929 return {
6930 name: result.name,
6931 fn: result.fn,
6932 options: [options, deps]
6933 };
6934 };
6935 var limitShift3 = (options, deps) => {
6936 const result = limitShift2(options);
6937 return {
6938 fn: result.fn,
6939 options: [options, deps]
6940 };
6941 };
6942 var flip3 = (options, deps) => {
6943 const result = flip2(options);
6944 return {
6945 name: result.name,
6946 fn: result.fn,
6947 options: [options, deps]
6948 };
6949 };
6950 var size3 = (options, deps) => {
6951 const result = size2(options);
6952 return {
6953 name: result.name,
6954 fn: result.fn,
6955 options: [options, deps]
6956 };
6957 };
6958 var hide3 = (options, deps) => {
6959 const result = hide2(options);
6960 return {
6961 name: result.name,
6962 fn: result.fn,
6963 options: [options, deps]
6964 };
6965 };
6966
6967 // node_modules/@base-ui/utils/esm/store/createSelector.js
6968 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
6969 if (other.length > 0) {
6970 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
6971 }
6972 let selector2;
6973 if (a2 && b2 && c2 && d2 && e2 && f2) {
6974 selector2 = (state, a1, a22, a3) => {
6975 const va = a2(state, a1, a22, a3);
6976 const vb = b2(state, a1, a22, a3);
6977 const vc = c2(state, a1, a22, a3);
6978 const vd = d2(state, a1, a22, a3);
6979 const ve = e2(state, a1, a22, a3);
6980 return f2(va, vb, vc, vd, ve, a1, a22, a3);
6981 };
6982 } else if (a2 && b2 && c2 && d2 && e2) {
6983 selector2 = (state, a1, a22, a3) => {
6984 const va = a2(state, a1, a22, a3);
6985 const vb = b2(state, a1, a22, a3);
6986 const vc = c2(state, a1, a22, a3);
6987 const vd = d2(state, a1, a22, a3);
6988 return e2(va, vb, vc, vd, a1, a22, a3);
6989 };
6990 } else if (a2 && b2 && c2 && d2) {
6991 selector2 = (state, a1, a22, a3) => {
6992 const va = a2(state, a1, a22, a3);
6993 const vb = b2(state, a1, a22, a3);
6994 const vc = c2(state, a1, a22, a3);
6995 return d2(va, vb, vc, a1, a22, a3);
6996 };
6997 } else if (a2 && b2 && c2) {
6998 selector2 = (state, a1, a22, a3) => {
6999 const va = a2(state, a1, a22, a3);
7000 const vb = b2(state, a1, a22, a3);
7001 return c2(va, vb, a1, a22, a3);
7002 };
7003 } else if (a2 && b2) {
7004 selector2 = (state, a1, a22, a3) => {
7005 const va = a2(state, a1, a22, a3);
7006 return b2(va, a1, a22, a3);
7007 };
7008 } else if (a2) {
7009 selector2 = a2;
7010 } else {
7011 throw (
7012 /* minify-error-disabled */
7013 new Error("Missing arguments")
7014 );
7015 }
7016 return selector2;
7017 };
7018
7019 // node_modules/@base-ui/utils/esm/store/useStore.js
7020 var React31 = __toESM(require_react(), 1);
7021 var import_shim = __toESM(require_shim(), 1);
7022 var import_with_selector = __toESM(require_with_selector(), 1);
7023
7024 // node_modules/@base-ui/utils/esm/fastHooks.js
7025 var React30 = __toESM(require_react(), 1);
7026 var hooks = [];
7027 var currentInstance = void 0;
7028 function getInstance() {
7029 return currentInstance;
7030 }
7031 function register(hook) {
7032 hooks.push(hook);
7033 }
7034 function fastComponent(fn) {
7035 const FastComponent = (props, forwardedRef) => {
7036 const instance = useRefWithInit(createInstance).current;
7037 let result;
7038 try {
7039 currentInstance = instance;
7040 for (const hook of hooks) {
7041 hook.before(instance);
7042 }
7043 result = fn(props, forwardedRef);
7044 for (const hook of hooks) {
7045 hook.after(instance);
7046 }
7047 instance.didInitialize = true;
7048 } finally {
7049 currentInstance = void 0;
7050 }
7051 return result;
7052 };
7053 FastComponent.displayName = fn.displayName || fn.name;
7054 return FastComponent;
7055 }
7056 function fastComponentRef(fn) {
7057 return /* @__PURE__ */ React30.forwardRef(fastComponent(fn));
7058 }
7059 function createInstance() {
7060 return {
7061 didInitialize: false
7062 };
7063 }
7064
7065 // node_modules/@base-ui/utils/esm/store/useStore.js
7066 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
7067 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
7068 function useStore(store, selector2, a1, a2, a3) {
7069 return useStoreImplementation(store, selector2, a1, a2, a3);
7070 }
7071 function useStoreR19(store, selector2, a1, a2, a3) {
7072 const getSelection = React31.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
7073 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
7074 }
7075 register({
7076 before(instance) {
7077 instance.syncIndex = 0;
7078 if (!instance.didInitialize) {
7079 instance.syncTick = 1;
7080 instance.syncHooks = [];
7081 instance.didChangeStore = true;
7082 instance.getSnapshot = () => {
7083 let didChange2 = false;
7084 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
7085 const hook = instance.syncHooks[i2];
7086 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
7087 if (hook.didChange || !Object.is(hook.value, value)) {
7088 didChange2 = true;
7089 hook.value = value;
7090 hook.didChange = false;
7091 }
7092 }
7093 if (didChange2) {
7094 instance.syncTick += 1;
7095 }
7096 return instance.syncTick;
7097 };
7098 }
7099 },
7100 after(instance) {
7101 if (instance.syncHooks.length > 0) {
7102 if (instance.didChangeStore) {
7103 instance.didChangeStore = false;
7104 instance.subscribe = (onStoreChange) => {
7105 const stores = /* @__PURE__ */ new Set();
7106 for (const hook of instance.syncHooks) {
7107 stores.add(hook.store);
7108 }
7109 const unsubscribes = [];
7110 for (const store of stores) {
7111 unsubscribes.push(store.subscribe(onStoreChange));
7112 }
7113 return () => {
7114 for (const unsubscribe of unsubscribes) {
7115 unsubscribe();
7116 }
7117 };
7118 };
7119 }
7120 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
7121 }
7122 }
7123 });
7124 function useStoreFast(store, selector2, a1, a2, a3) {
7125 const instance = getInstance();
7126 if (!instance) {
7127 return useStoreR19(store, selector2, a1, a2, a3);
7128 }
7129 const index2 = instance.syncIndex;
7130 instance.syncIndex += 1;
7131 let hook;
7132 if (!instance.didInitialize) {
7133 hook = {
7134 store,
7135 selector: selector2,
7136 a1,
7137 a2,
7138 a3,
7139 value: selector2(store.getSnapshot(), a1, a2, a3),
7140 didChange: false
7141 };
7142 instance.syncHooks.push(hook);
7143 } else {
7144 hook = instance.syncHooks[index2];
7145 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
7146 if (hook.store !== store) {
7147 instance.didChangeStore = true;
7148 }
7149 hook.store = store;
7150 hook.selector = selector2;
7151 hook.a1 = a1;
7152 hook.a2 = a2;
7153 hook.a3 = a3;
7154 hook.didChange = true;
7155 }
7156 }
7157 return hook.value;
7158 }
7159 function useStoreLegacy(store, selector2, a1, a2, a3) {
7160 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
7161 }
7162
7163 // node_modules/@base-ui/utils/esm/store/Store.js
7164 var Store = class {
7165 /**
7166 * The current state of the store.
7167 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
7168 * 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).
7169 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
7170 *
7171 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
7172 */
7173 // Internal state to handle recursive `setState()` calls
7174 constructor(state) {
7175 this.state = state;
7176 this.listeners = /* @__PURE__ */ new Set();
7177 this.updateTick = 0;
7178 }
7179 /**
7180 * Registers a listener that will be called whenever the store's state changes.
7181 *
7182 * @param fn The listener function to be called on state changes.
7183 * @returns A function to unsubscribe the listener.
7184 */
7185 subscribe = (fn) => {
7186 this.listeners.add(fn);
7187 return () => {
7188 this.listeners.delete(fn);
7189 };
7190 };
7191 /**
7192 * Returns the current state of the store.
7193 */
7194 getSnapshot = () => {
7195 return this.state;
7196 };
7197 /**
7198 * Updates the entire store's state and notifies all registered listeners.
7199 *
7200 * @param newState The new state to set for the store.
7201 */
7202 setState(newState) {
7203 if (this.state === newState) {
7204 return;
7205 }
7206 this.state = newState;
7207 this.updateTick += 1;
7208 const currentTick = this.updateTick;
7209 for (const listener of this.listeners) {
7210 if (currentTick !== this.updateTick) {
7211 return;
7212 }
7213 listener(newState);
7214 }
7215 }
7216 /**
7217 * Merges the provided changes into the current state and notifies listeners if there are changes.
7218 *
7219 * @param changes An object containing the changes to apply to the current state.
7220 */
7221 update(changes) {
7222 for (const key in changes) {
7223 if (!Object.is(this.state[key], changes[key])) {
7224 this.setState({
7225 ...this.state,
7226 ...changes
7227 });
7228 return;
7229 }
7230 }
7231 }
7232 /**
7233 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
7234 *
7235 * @param key The key in the store's state to update.
7236 * @param value The new value to set for the specified key.
7237 */
7238 set(key, value) {
7239 if (!Object.is(this.state[key], value)) {
7240 this.setState({
7241 ...this.state,
7242 [key]: value
7243 });
7244 }
7245 }
7246 /**
7247 * Gives the state a new reference and updates all registered listeners.
7248 */
7249 notifyAll() {
7250 const newState = {
7251 ...this.state
7252 };
7253 this.setState(newState);
7254 }
7255 use(selector2, a1, a2, a3) {
7256 return useStore(this, selector2, a1, a2, a3);
7257 }
7258 };
7259
7260 // node_modules/@base-ui/utils/esm/store/ReactStore.js
7261 var React32 = __toESM(require_react(), 1);
7262 var ReactStore = class extends Store {
7263 /**
7264 * Creates a new ReactStore instance.
7265 *
7266 * @param state Initial state of the store.
7267 * @param context Non-reactive context values.
7268 * @param selectors Optional selectors for use with `useState`.
7269 */
7270 constructor(state, context = {}, selectors4) {
7271 super(state);
7272 this.context = context;
7273 this.selectors = selectors4;
7274 }
7275 /**
7276 * Non-reactive values such as refs, callbacks, etc.
7277 */
7278 /**
7279 * Synchronizes a single external value into the store.
7280 *
7281 * Note that the while the value in `state` is updated immediately, the value returned
7282 * by `useState` is updated before the next render (similarly to React's `useState`).
7283 */
7284 useSyncedValue(key, value) {
7285 React32.useDebugValue(key);
7286 useIsoLayoutEffect(() => {
7287 if (this.state[key] !== value) {
7288 this.set(key, value);
7289 }
7290 }, [key, value]);
7291 }
7292 /**
7293 * Synchronizes a single external value into the store and
7294 * cleans it up (sets to `undefined`) on unmount.
7295 *
7296 * Note that the while the value in `state` is updated immediately, the value returned
7297 * by `useState` is updated before the next render (similarly to React's `useState`).
7298 */
7299 useSyncedValueWithCleanup(key, value) {
7300 const store = this;
7301 useIsoLayoutEffect(() => {
7302 if (store.state[key] !== value) {
7303 store.set(key, value);
7304 }
7305 return () => {
7306 store.set(key, void 0);
7307 };
7308 }, [store, key, value]);
7309 }
7310 /**
7311 * Synchronizes multiple external values into the store.
7312 *
7313 * Note that the while the values in `state` are updated immediately, the values returned
7314 * by `useState` are updated before the next render (similarly to React's `useState`).
7315 */
7316 useSyncedValues(statePart) {
7317 const store = this;
7318 if (true) {
7319 React32.useDebugValue(statePart, (p2) => Object.keys(p2));
7320 const keys = React32.useRef(Object.keys(statePart)).current;
7321 const nextKeys = Object.keys(statePart);
7322 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
7323 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
7324 }
7325 }
7326 const dependencies = Object.values(statePart);
7327 useIsoLayoutEffect(() => {
7328 store.update(statePart);
7329 }, [store, ...dependencies]);
7330 }
7331 /**
7332 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
7333 * is non-undefined, the store's state at `key` is updated to match `controlled`.
7334 */
7335 useControlledProp(key, controlled) {
7336 React32.useDebugValue(key);
7337 const isControlled = controlled !== void 0;
7338 useIsoLayoutEffect(() => {
7339 if (isControlled && !Object.is(this.state[key], controlled)) {
7340 super.setState({
7341 ...this.state,
7342 [key]: controlled
7343 });
7344 }
7345 }, [key, controlled, isControlled]);
7346 if (true) {
7347 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
7348 if (!cache.has(key)) {
7349 cache.set(key, isControlled);
7350 }
7351 const previouslyControlled = cache.get(key);
7352 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
7353 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).`);
7354 }
7355 }
7356 }
7357 /** Gets the current value from the store using a selector with the provided key.
7358 *
7359 * @param key Key of the selector to use.
7360 */
7361 select(key, a1, a2, a3) {
7362 const selector2 = this.selectors[key];
7363 return selector2(this.state, a1, a2, a3);
7364 }
7365 /**
7366 * Returns a value from the store's state using a selector function.
7367 * Used to subscribe to specific parts of the state.
7368 * This methods causes a rerender whenever the selected state changes.
7369 *
7370 * @param key Key of the selector to use.
7371 */
7372 useState(key, a1, a2, a3) {
7373 React32.useDebugValue(key);
7374 return useStore(this, this.selectors[key], a1, a2, a3);
7375 }
7376 /**
7377 * Wraps a function with `useStableCallback` to ensure it has a stable reference
7378 * and assigns it to the context.
7379 *
7380 * @param key Key of the event callback. Must be a function in the context.
7381 * @param fn Function to assign.
7382 */
7383 useContextCallback(key, fn) {
7384 React32.useDebugValue(key);
7385 const stableFunction = useStableCallback(fn ?? NOOP);
7386 this.context[key] = stableFunction;
7387 }
7388 /**
7389 * Returns a stable setter function for a specific key in the store's state.
7390 * It's commonly used to pass as a ref callback to React elements.
7391 *
7392 * @param key Key of the state to set.
7393 */
7394 useStateSetter(key) {
7395 const ref = React32.useRef(void 0);
7396 if (ref.current === void 0) {
7397 ref.current = (value) => {
7398 this.set(key, value);
7399 };
7400 }
7401 return ref.current;
7402 }
7403 /**
7404 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
7405 *
7406 * @param key Key of the selector to observe.
7407 * @param listener Listener function called when the selector result changes.
7408 */
7409 observe(selector2, listener) {
7410 let selectFn;
7411 if (typeof selector2 === "function") {
7412 selectFn = selector2;
7413 } else {
7414 selectFn = this.selectors[selector2];
7415 }
7416 let prevValue = selectFn(this.state);
7417 listener(prevValue, prevValue, this);
7418 return this.subscribe((nextState) => {
7419 const nextValue = selectFn(nextState);
7420 if (!Object.is(prevValue, nextValue)) {
7421 const oldValue = prevValue;
7422 prevValue = nextValue;
7423 listener(nextValue, oldValue, this);
7424 }
7425 });
7426 }
7427 };
7428
7429 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
7430 var selectors = {
7431 open: createSelector((state) => state.open),
7432 transitionStatus: createSelector((state) => state.transitionStatus),
7433 domReferenceElement: createSelector((state) => state.domReferenceElement),
7434 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
7435 floatingElement: createSelector((state) => state.floatingElement),
7436 floatingId: createSelector((state) => state.floatingId)
7437 };
7438 var FloatingRootStore = class extends ReactStore {
7439 constructor(options) {
7440 const {
7441 syncOnly,
7442 nested,
7443 onOpenChange,
7444 triggerElements,
7445 ...initialState
7446 } = options;
7447 super({
7448 ...initialState,
7449 positionReference: initialState.referenceElement,
7450 domReferenceElement: initialState.referenceElement
7451 }, {
7452 onOpenChange,
7453 dataRef: {
7454 current: {}
7455 },
7456 events: createEventEmitter(),
7457 nested,
7458 triggerElements
7459 }, selectors);
7460 this.syncOnly = syncOnly;
7461 }
7462 /**
7463 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
7464 */
7465 syncOpenEvent = (newOpen, event) => {
7466 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
7467 // click events to upgrade a hover-open.
7468 event != null && isClickLikeEvent(event)) {
7469 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
7470 }
7471 };
7472 /**
7473 * Runs the root-owned side effects for an open state change.
7474 */
7475 dispatchOpenChange = (newOpen, eventDetails) => {
7476 this.syncOpenEvent(newOpen, eventDetails.event);
7477 const details = {
7478 open: newOpen,
7479 reason: eventDetails.reason,
7480 nativeEvent: eventDetails.event,
7481 nested: this.context.nested,
7482 triggerElement: eventDetails.trigger
7483 };
7484 this.context.events.emit("openchange", details);
7485 };
7486 /**
7487 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
7488 *
7489 * @param newOpen The new open state.
7490 * @param eventDetails Details about the event that triggered the open state change.
7491 */
7492 setOpen = (newOpen, eventDetails) => {
7493 if (this.syncOnly) {
7494 this.context.onOpenChange?.(newOpen, eventDetails);
7495 return;
7496 }
7497 this.dispatchOpenChange(newOpen, eventDetails);
7498 this.context.onOpenChange?.(newOpen, eventDetails);
7499 };
7500 };
7501
7502 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
7503 var React33 = __toESM(require_react(), 1);
7504 function useTriggerRegistration(id, store) {
7505 const registeredElementIdRef = React33.useRef(null);
7506 const registeredElementRef = React33.useRef(null);
7507 return React33.useCallback((element) => {
7508 if (id === void 0) {
7509 return;
7510 }
7511 if (registeredElementIdRef.current !== null) {
7512 const registeredId = registeredElementIdRef.current;
7513 const registeredElement = registeredElementRef.current;
7514 const currentElement = store.context.triggerElements.getById(registeredId);
7515 if (registeredElement && currentElement === registeredElement) {
7516 store.context.triggerElements.delete(registeredId);
7517 }
7518 registeredElementIdRef.current = null;
7519 registeredElementRef.current = null;
7520 }
7521 if (element !== null) {
7522 registeredElementIdRef.current = id;
7523 registeredElementRef.current = element;
7524 store.context.triggerElements.add(id, element);
7525 }
7526 }, [store, id]);
7527 }
7528 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
7529 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
7530 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
7531 const registerTrigger = useStableCallback((element) => {
7532 baseRegisterTrigger(element);
7533 if (!element || !store.select("open")) {
7534 return;
7535 }
7536 const activeTriggerId = store.select("activeTriggerId");
7537 if (activeTriggerId === triggerId) {
7538 store.update({
7539 activeTriggerElement: element,
7540 ...stateUpdates
7541 });
7542 return;
7543 }
7544 if (activeTriggerId == null) {
7545 store.update({
7546 activeTriggerId: triggerId,
7547 activeTriggerElement: element,
7548 ...stateUpdates
7549 });
7550 }
7551 });
7552 useIsoLayoutEffect(() => {
7553 if (isMountedByThisTrigger) {
7554 store.update({
7555 activeTriggerElement: triggerElementRef.current,
7556 ...stateUpdates
7557 });
7558 }
7559 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
7560 return {
7561 registerTrigger,
7562 isMountedByThisTrigger
7563 };
7564 }
7565 function useImplicitActiveTrigger(store) {
7566 const open = store.useState("open");
7567 useIsoLayoutEffect(() => {
7568 if (open && !store.select("activeTriggerId") && store.context.triggerElements.size === 1) {
7569 const iteratorResult = store.context.triggerElements.entries().next();
7570 if (!iteratorResult.done) {
7571 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
7572 store.update({
7573 activeTriggerId: implicitTriggerId,
7574 activeTriggerElement: implicitTriggerElement
7575 });
7576 }
7577 }
7578 }, [open, store]);
7579 }
7580 function useOpenStateTransitions(open, store, onUnmount) {
7581 const {
7582 mounted,
7583 setMounted,
7584 transitionStatus
7585 } = useTransitionStatus(open);
7586 store.useSyncedValues({
7587 mounted,
7588 transitionStatus
7589 });
7590 const forceUnmount = useStableCallback(() => {
7591 setMounted(false);
7592 store.update({
7593 activeTriggerId: null,
7594 activeTriggerElement: null,
7595 mounted: false
7596 });
7597 onUnmount?.();
7598 store.context.onOpenChangeComplete?.(false);
7599 });
7600 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
7601 useOpenChangeComplete({
7602 enabled: !preventUnmountingOnClose,
7603 open,
7604 ref: store.context.popupRef,
7605 onComplete() {
7606 if (!open) {
7607 forceUnmount();
7608 }
7609 }
7610 });
7611 return {
7612 forceUnmount,
7613 transitionStatus
7614 };
7615 }
7616
7617 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
7618 var PopupTriggerMap = class {
7619 constructor() {
7620 this.elementsSet = /* @__PURE__ */ new Set();
7621 this.idMap = /* @__PURE__ */ new Map();
7622 }
7623 /**
7624 * Adds a trigger element with the given ID.
7625 *
7626 * Note: The provided element is assumed to not be registered under multiple IDs.
7627 */
7628 add(id, element) {
7629 const existingElement = this.idMap.get(id);
7630 if (existingElement === element) {
7631 return;
7632 }
7633 if (existingElement !== void 0) {
7634 this.elementsSet.delete(existingElement);
7635 }
7636 this.elementsSet.add(element);
7637 this.idMap.set(id, element);
7638 if (true) {
7639 if (this.elementsSet.size !== this.idMap.size) {
7640 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
7641 }
7642 }
7643 }
7644 /**
7645 * Removes the trigger element with the given ID.
7646 */
7647 delete(id) {
7648 const element = this.idMap.get(id);
7649 if (element) {
7650 this.elementsSet.delete(element);
7651 this.idMap.delete(id);
7652 }
7653 }
7654 /**
7655 * Whether the given element is registered as a trigger.
7656 */
7657 hasElement(element) {
7658 return this.elementsSet.has(element);
7659 }
7660 /**
7661 * Whether there is a registered trigger element matching the given predicate.
7662 */
7663 hasMatchingElement(predicate) {
7664 for (const element of this.elementsSet) {
7665 if (predicate(element)) {
7666 return true;
7667 }
7668 }
7669 return false;
7670 }
7671 /**
7672 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
7673 */
7674 getById(id) {
7675 return this.idMap.get(id);
7676 }
7677 /**
7678 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
7679 */
7680 entries() {
7681 return this.idMap.entries();
7682 }
7683 /**
7684 * Returns an iterable of all registered trigger elements.
7685 */
7686 elements() {
7687 return this.elementsSet.values();
7688 }
7689 /**
7690 * Returns the number of registered trigger elements.
7691 */
7692 get size() {
7693 return this.idMap.size;
7694 }
7695 };
7696
7697 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
7698 function getEmptyRootContext() {
7699 return new FloatingRootStore({
7700 open: false,
7701 transitionStatus: void 0,
7702 floatingElement: null,
7703 referenceElement: null,
7704 triggerElements: new PopupTriggerMap(),
7705 floatingId: "",
7706 syncOnly: false,
7707 nested: false,
7708 onOpenChange: void 0
7709 });
7710 }
7711
7712 // node_modules/@base-ui/react/esm/utils/popups/store.js
7713 function createInitialPopupStoreState() {
7714 return {
7715 open: false,
7716 openProp: void 0,
7717 mounted: false,
7718 transitionStatus: void 0,
7719 floatingRootContext: getEmptyRootContext(),
7720 preventUnmountingOnClose: false,
7721 payload: void 0,
7722 activeTriggerId: null,
7723 activeTriggerElement: null,
7724 triggerIdProp: void 0,
7725 popupElement: null,
7726 positionerElement: null,
7727 activeTriggerProps: EMPTY_OBJECT,
7728 inactiveTriggerProps: EMPTY_OBJECT,
7729 popupProps: EMPTY_OBJECT
7730 };
7731 }
7732 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
7733 var popupStoreSelectors = {
7734 open: createSelector((state) => state.openProp ?? state.open),
7735 mounted: createSelector((state) => state.mounted),
7736 transitionStatus: createSelector((state) => state.transitionStatus),
7737 floatingRootContext: createSelector((state) => state.floatingRootContext),
7738 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
7739 payload: createSelector((state) => state.payload),
7740 activeTriggerId: activeTriggerIdSelector,
7741 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
7742 /**
7743 * Whether the trigger with the given ID was used to open the popup.
7744 */
7745 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
7746 /**
7747 * Whether the popup is open and was activated by a trigger with the given ID.
7748 */
7749 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open),
7750 /**
7751 * Whether the popup is mounted and was activated by a trigger with the given ID.
7752 */
7753 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
7754 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
7755 popupProps: createSelector((state) => state.popupProps),
7756 popupElement: createSelector((state) => state.popupElement),
7757 positionerElement: createSelector((state) => state.positionerElement)
7758 };
7759
7760 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
7761 function useFloatingRootContext(options) {
7762 const {
7763 open = false,
7764 onOpenChange,
7765 elements = {}
7766 } = options;
7767 const floatingId = useId();
7768 const nested = useFloatingParentNodeId() != null;
7769 if (true) {
7770 const optionDomReference = elements.reference;
7771 if (optionDomReference && !isElement(optionDomReference)) {
7772 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
7773 }
7774 }
7775 const store = useRefWithInit(() => new FloatingRootStore({
7776 open,
7777 transitionStatus: void 0,
7778 onOpenChange,
7779 referenceElement: elements.reference ?? null,
7780 floatingElement: elements.floating ?? null,
7781 triggerElements: new PopupTriggerMap(),
7782 floatingId,
7783 syncOnly: false,
7784 nested
7785 })).current;
7786 useIsoLayoutEffect(() => {
7787 const valuesToSync = {
7788 open,
7789 floatingId
7790 };
7791 if (elements.reference !== void 0) {
7792 valuesToSync.referenceElement = elements.reference;
7793 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
7794 }
7795 if (elements.floating !== void 0) {
7796 valuesToSync.floatingElement = elements.floating;
7797 }
7798 store.update(valuesToSync);
7799 }, [open, floatingId, elements.reference, elements.floating, store]);
7800 store.context.onOpenChange = onOpenChange;
7801 store.context.nested = nested;
7802 return store;
7803 }
7804
7805 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
7806 function useFloating2(options = {}) {
7807 const {
7808 nodeId,
7809 externalTree
7810 } = options;
7811 const internalRootStore = useFloatingRootContext(options);
7812 const rootContext = options.rootContext || internalRootStore;
7813 const rootContextElements = {
7814 reference: rootContext.useState("referenceElement"),
7815 floating: rootContext.useState("floatingElement"),
7816 domReference: rootContext.useState("domReferenceElement")
7817 };
7818 const [positionReference, setPositionReferenceRaw] = React34.useState(null);
7819 const domReferenceRef = React34.useRef(null);
7820 const tree = useFloatingTree(externalTree);
7821 useIsoLayoutEffect(() => {
7822 if (rootContextElements.domReference) {
7823 domReferenceRef.current = rootContextElements.domReference;
7824 }
7825 }, [rootContextElements.domReference]);
7826 const position = useFloating({
7827 ...options,
7828 elements: {
7829 ...rootContextElements,
7830 ...positionReference && {
7831 reference: positionReference
7832 }
7833 }
7834 });
7835 const setPositionReference = React34.useCallback((node) => {
7836 const computedPositionReference = isElement(node) ? {
7837 getBoundingClientRect: () => node.getBoundingClientRect(),
7838 getClientRects: () => node.getClientRects(),
7839 contextElement: node
7840 } : node;
7841 setPositionReferenceRaw(computedPositionReference);
7842 position.refs.setReference(computedPositionReference);
7843 }, [position.refs]);
7844 const [localDomReference, setLocalDomReference] = React34.useState(void 0);
7845 const [localFloatingElement, setLocalFloatingElement] = React34.useState(null);
7846 rootContext.useSyncedValue("referenceElement", localDomReference ?? null);
7847 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
7848 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement);
7849 rootContext.useSyncedValue("floatingElement", localFloatingElement);
7850 const setReference = React34.useCallback((node) => {
7851 if (isElement(node) || node === null) {
7852 domReferenceRef.current = node;
7853 setLocalDomReference(node);
7854 }
7855 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
7856 // `null` to support `positionReference` + an unstable `reference`
7857 // callback ref.
7858 node !== null && !isElement(node)) {
7859 position.refs.setReference(node);
7860 }
7861 }, [position.refs, setLocalDomReference]);
7862 const setFloating = React34.useCallback((node) => {
7863 setLocalFloatingElement(node);
7864 position.refs.setFloating(node);
7865 }, [position.refs]);
7866 const refs = React34.useMemo(() => ({
7867 ...position.refs,
7868 setReference,
7869 setFloating,
7870 setPositionReference,
7871 domReference: domReferenceRef
7872 }), [position.refs, setReference, setFloating, setPositionReference]);
7873 const elements = React34.useMemo(() => ({
7874 ...position.elements,
7875 domReference: rootContextElements.domReference
7876 }), [position.elements, rootContextElements.domReference]);
7877 const open = rootContext.useState("open");
7878 const floatingId = rootContext.useState("floatingId");
7879 const context = React34.useMemo(() => ({
7880 ...position,
7881 dataRef: rootContext.context.dataRef,
7882 open,
7883 onOpenChange: rootContext.setOpen,
7884 events: rootContext.context.events,
7885 floatingId,
7886 refs,
7887 elements,
7888 nodeId,
7889 rootStore: rootContext
7890 }), [position, refs, elements, nodeId, rootContext, open, floatingId]);
7891 useIsoLayoutEffect(() => {
7892 rootContext.context.dataRef.current.floatingContext = context;
7893 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
7894 if (node) {
7895 node.context = context;
7896 }
7897 });
7898 return React34.useMemo(() => ({
7899 ...position,
7900 context,
7901 refs,
7902 elements,
7903 rootStore: rootContext
7904 }), [position, refs, elements, context, rootContext]);
7905 }
7906
7907 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
7908 function useSyncedFloatingRootContext(options) {
7909 const {
7910 popupStore,
7911 treatPopupAsFloatingElement = false,
7912 onOpenChange
7913 } = options;
7914 const floatingId = useId();
7915 const nested = useFloatingParentNodeId() != null;
7916 const open = popupStore.useState("open");
7917 const referenceElement = popupStore.useState("activeTriggerElement");
7918 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
7919 const triggerElements = popupStore.context.triggerElements;
7920 const store = useRefWithInit(() => new FloatingRootStore({
7921 open,
7922 transitionStatus: void 0,
7923 referenceElement,
7924 floatingElement,
7925 triggerElements,
7926 onOpenChange,
7927 floatingId,
7928 syncOnly: true,
7929 nested
7930 })).current;
7931 useIsoLayoutEffect(() => {
7932 const valuesToSync = {
7933 open,
7934 floatingId,
7935 referenceElement,
7936 floatingElement
7937 };
7938 if (isElement(referenceElement)) {
7939 valuesToSync.domReferenceElement = referenceElement;
7940 }
7941 if (store.state.positionReference === store.state.referenceElement) {
7942 valuesToSync.positionReference = referenceElement;
7943 }
7944 store.update(valuesToSync);
7945 }, [open, floatingId, referenceElement, floatingElement, store]);
7946 store.context.onOpenChange = onOpenChange;
7947 store.context.nested = nested;
7948 return store;
7949 }
7950
7951 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
7952 var React35 = __toESM(require_react(), 1);
7953 var isMacSafari = isMac && isSafari;
7954 function useFocus(context, props = {}) {
7955 const store = "rootStore" in context ? context.rootStore : context;
7956 const {
7957 events,
7958 dataRef
7959 } = store.context;
7960 const {
7961 enabled = true,
7962 delay
7963 } = props;
7964 const blockFocusRef = React35.useRef(false);
7965 const blockedReferenceRef = React35.useRef(null);
7966 const timeout = useTimeout();
7967 const keyboardModalityRef = React35.useRef(true);
7968 React35.useEffect(() => {
7969 const domReference = store.select("domReferenceElement");
7970 if (!enabled) {
7971 return void 0;
7972 }
7973 const win = getWindow(domReference);
7974 function onBlur() {
7975 const currentDomReference = store.select("domReferenceElement");
7976 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
7977 blockFocusRef.current = true;
7978 }
7979 }
7980 function onKeyDown() {
7981 keyboardModalityRef.current = true;
7982 }
7983 function onPointerDown() {
7984 keyboardModalityRef.current = false;
7985 }
7986 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
7987 }, [store, enabled]);
7988 React35.useEffect(() => {
7989 if (!enabled) {
7990 return void 0;
7991 }
7992 function onOpenChangeLocal(details) {
7993 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
7994 const referenceElement = store.select("domReferenceElement");
7995 if (isElement(referenceElement)) {
7996 blockedReferenceRef.current = referenceElement;
7997 blockFocusRef.current = true;
7998 }
7999 }
8000 }
8001 events.on("openchange", onOpenChangeLocal);
8002 return () => {
8003 events.off("openchange", onOpenChangeLocal);
8004 };
8005 }, [events, enabled, store]);
8006 const reference = React35.useMemo(() => ({
8007 onMouseLeave() {
8008 blockFocusRef.current = false;
8009 blockedReferenceRef.current = null;
8010 },
8011 onFocus(event) {
8012 const focusTarget = event.currentTarget;
8013 if (blockFocusRef.current) {
8014 if (blockedReferenceRef.current === focusTarget) {
8015 return;
8016 }
8017 blockFocusRef.current = false;
8018 blockedReferenceRef.current = null;
8019 }
8020 const target = getTarget(event.nativeEvent);
8021 if (isElement(target)) {
8022 if (isMacSafari && !event.relatedTarget) {
8023 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
8024 return;
8025 }
8026 } else if (!matchesFocusVisible(target)) {
8027 return;
8028 }
8029 }
8030 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
8031 const {
8032 nativeEvent,
8033 currentTarget
8034 } = event;
8035 const delayValue = typeof delay === "function" ? delay() : delay;
8036 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
8037 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
8038 return;
8039 }
8040 timeout.start(delayValue, () => {
8041 if (blockFocusRef.current) {
8042 return;
8043 }
8044 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
8045 });
8046 },
8047 onBlur(event) {
8048 blockFocusRef.current = false;
8049 blockedReferenceRef.current = null;
8050 const relatedTarget = event.relatedTarget;
8051 const nativeEvent = event.nativeEvent;
8052 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
8053 timeout.start(0, () => {
8054 const domReference = store.select("domReferenceElement");
8055 const activeEl = activeElement(ownerDocument(domReference));
8056 if (!relatedTarget && activeEl === domReference) {
8057 return;
8058 }
8059 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
8060 return;
8061 }
8062 const nextFocusedElement = relatedTarget ?? activeEl;
8063 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
8064 return;
8065 }
8066 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
8067 });
8068 }
8069 }), [dataRef, store, timeout, delay]);
8070 return React35.useMemo(() => enabled ? {
8071 reference,
8072 trigger: reference
8073 } : {}, [enabled, reference]);
8074 }
8075
8076 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
8077 var React36 = __toESM(require_react(), 1);
8078
8079 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
8080 var HoverInteraction = class _HoverInteraction {
8081 constructor() {
8082 this.pointerType = void 0;
8083 this.interactedInside = false;
8084 this.handler = void 0;
8085 this.blockMouseMove = true;
8086 this.performedPointerEventsMutation = false;
8087 this.pointerEventsScopeElement = null;
8088 this.pointerEventsReferenceElement = null;
8089 this.pointerEventsFloatingElement = null;
8090 this.restTimeoutPending = false;
8091 this.openChangeTimeout = new Timeout();
8092 this.restTimeout = new Timeout();
8093 this.handleCloseOptions = void 0;
8094 }
8095 static create() {
8096 return new _HoverInteraction();
8097 }
8098 dispose = () => {
8099 this.openChangeTimeout.clear();
8100 this.restTimeout.clear();
8101 };
8102 disposeEffect = () => {
8103 return this.dispose;
8104 };
8105 };
8106 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
8107 function clearSafePolygonPointerEventsMutation(instance) {
8108 if (!instance.performedPointerEventsMutation) {
8109 return;
8110 }
8111 const scopeElement = instance.pointerEventsScopeElement;
8112 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
8113 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
8114 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
8115 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
8116 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
8117 }
8118 instance.performedPointerEventsMutation = false;
8119 instance.pointerEventsScopeElement = null;
8120 instance.pointerEventsReferenceElement = null;
8121 instance.pointerEventsFloatingElement = null;
8122 }
8123 function applySafePolygonPointerEventsMutation(instance, options) {
8124 const {
8125 scopeElement,
8126 referenceElement,
8127 floatingElement
8128 } = options;
8129 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
8130 if (existingOwner && existingOwner !== instance) {
8131 clearSafePolygonPointerEventsMutation(existingOwner);
8132 }
8133 clearSafePolygonPointerEventsMutation(instance);
8134 instance.performedPointerEventsMutation = true;
8135 instance.pointerEventsScopeElement = scopeElement;
8136 instance.pointerEventsReferenceElement = referenceElement;
8137 instance.pointerEventsFloatingElement = floatingElement;
8138 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
8139 scopeElement.style.pointerEvents = "none";
8140 referenceElement.style.pointerEvents = "auto";
8141 floatingElement.style.pointerEvents = "auto";
8142 }
8143 function useHoverInteractionSharedState(store) {
8144 const instance = useRefWithInit(HoverInteraction.create).current;
8145 const data = store.context.dataRef.current;
8146 if (!data.hoverInteractionState) {
8147 data.hoverInteractionState = instance;
8148 }
8149 useOnMount(data.hoverInteractionState.disposeEffect);
8150 return data.hoverInteractionState;
8151 }
8152
8153 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
8154 function useHoverFloatingInteraction(context, parameters = {}) {
8155 const store = "rootStore" in context ? context.rootStore : context;
8156 const open = store.useState("open");
8157 const floatingElement = store.useState("floatingElement");
8158 const domReferenceElement = store.useState("domReferenceElement");
8159 const {
8160 dataRef
8161 } = store.context;
8162 const {
8163 enabled = true,
8164 closeDelay: closeDelayProp = 0,
8165 nodeId: nodeIdProp
8166 } = parameters;
8167 const instance = useHoverInteractionSharedState(store);
8168 const tree = useFloatingTree();
8169 const parentId = useFloatingParentNodeId();
8170 const isClickLikeOpenEvent2 = useStableCallback(() => {
8171 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
8172 });
8173 const isHoverOpen = useStableCallback(() => {
8174 const type = dataRef.current.openEvent?.type;
8175 return type?.includes("mouse") && type !== "mousedown";
8176 });
8177 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
8178 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
8179 });
8180 const closeWithDelay = React36.useCallback((event) => {
8181 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
8182 const close = () => {
8183 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8184 tree?.events.emit("floating.closed", event);
8185 };
8186 if (closeDelay) {
8187 instance.openChangeTimeout.start(closeDelay, close);
8188 } else {
8189 instance.openChangeTimeout.clear();
8190 close();
8191 }
8192 }, [closeDelayProp, store, instance, tree]);
8193 const clearPointerEvents = useStableCallback(() => {
8194 clearSafePolygonPointerEventsMutation(instance);
8195 });
8196 const handleInteractInside = useStableCallback((event) => {
8197 const target = getTarget(event);
8198 if (!isInteractiveElement(target)) {
8199 instance.interactedInside = false;
8200 return;
8201 }
8202 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
8203 });
8204 useIsoLayoutEffect(() => {
8205 if (!open) {
8206 instance.pointerType = void 0;
8207 instance.restTimeoutPending = false;
8208 instance.interactedInside = false;
8209 clearPointerEvents();
8210 }
8211 }, [open, instance, clearPointerEvents]);
8212 React36.useEffect(() => {
8213 return clearPointerEvents;
8214 }, [clearPointerEvents]);
8215 useIsoLayoutEffect(() => {
8216 if (!enabled) {
8217 return void 0;
8218 }
8219 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
8220 const ref = domReferenceElement;
8221 const floatingEl = floatingElement;
8222 const doc = ownerDocument(floatingElement);
8223 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
8224 if (parentFloating) {
8225 parentFloating.style.pointerEvents = "";
8226 }
8227 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body;
8228 applySafePolygonPointerEventsMutation(instance, {
8229 scopeElement,
8230 referenceElement: ref,
8231 floatingElement: floatingEl
8232 });
8233 return () => {
8234 clearPointerEvents();
8235 };
8236 }
8237 return void 0;
8238 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
8239 const childClosedTimeout = useTimeout();
8240 React36.useEffect(() => {
8241 if (!enabled) {
8242 return void 0;
8243 }
8244 function onFloatingMouseEnter() {
8245 instance.openChangeTimeout.clear();
8246 childClosedTimeout.clear();
8247 tree?.events.off("floating.closed", onNodeClosed);
8248 clearPointerEvents();
8249 }
8250 function onFloatingMouseLeave(event) {
8251 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
8252 tree.events.on("floating.closed", onNodeClosed);
8253 return;
8254 }
8255 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) {
8256 return;
8257 }
8258 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
8259 const relatedTarget = event.relatedTarget;
8260 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
8261 if (isMovingIntoDescendantFloating) {
8262 return;
8263 }
8264 if (instance.handler) {
8265 instance.handler(event);
8266 return;
8267 }
8268 clearPointerEvents();
8269 if (!isClickLikeOpenEvent2()) {
8270 closeWithDelay(event);
8271 }
8272 }
8273 function onNodeClosed(event) {
8274 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
8275 return;
8276 }
8277 childClosedTimeout.start(0, () => {
8278 tree.events.off("floating.closed", onNodeClosed);
8279 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8280 tree.events.emit("floating.closed", event);
8281 });
8282 }
8283 const floating = floatingElement;
8284 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
8285 tree?.events.off("floating.closed", onNodeClosed);
8286 });
8287 }, [enabled, floatingElement, store, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]);
8288 }
8289
8290 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
8291 var React37 = __toESM(require_react(), 1);
8292 var ReactDOM4 = __toESM(require_react_dom(), 1);
8293 var EMPTY_REF = {
8294 current: null
8295 };
8296 function useHoverReferenceInteraction(context, props = {}) {
8297 const store = "rootStore" in context ? context.rootStore : context;
8298 const {
8299 dataRef,
8300 events
8301 } = store.context;
8302 const {
8303 enabled = true,
8304 delay = 0,
8305 handleClose = null,
8306 mouseOnly = false,
8307 restMs = 0,
8308 move = true,
8309 triggerElementRef = EMPTY_REF,
8310 externalTree,
8311 isActiveTrigger = true,
8312 getHandleCloseContext,
8313 isClosing
8314 } = props;
8315 const tree = useFloatingTree(externalTree);
8316 const instance = useHoverInteractionSharedState(store);
8317 const isHoverCloseActiveRef = React37.useRef(false);
8318 const handleCloseRef = useValueAsRef(handleClose);
8319 const delayRef = useValueAsRef(delay);
8320 const restMsRef = useValueAsRef(restMs);
8321 const enabledRef = useValueAsRef(enabled);
8322 const isClosingRef = useValueAsRef(isClosing);
8323 if (isActiveTrigger) {
8324 instance.handleCloseOptions = handleCloseRef.current?.__options;
8325 }
8326 const isClickLikeOpenEvent2 = useStableCallback(() => {
8327 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
8328 });
8329 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
8330 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
8331 });
8332 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
8333 const allTriggers = store.context.triggerElements;
8334 if (allTriggers.hasElement(currentTarget)) {
8335 return !currentDomReference || !contains(currentDomReference, currentTarget);
8336 }
8337 if (!isElement(target)) {
8338 return false;
8339 }
8340 const targetElement = target;
8341 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
8342 });
8343 const closeWithDelay = useStableCallback((event, runElseBranch = true) => {
8344 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
8345 if (closeDelay) {
8346 instance.openChangeTimeout.start(closeDelay, () => {
8347 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8348 tree?.events.emit("floating.closed", event);
8349 });
8350 } else if (runElseBranch) {
8351 instance.openChangeTimeout.clear();
8352 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8353 tree?.events.emit("floating.closed", event);
8354 }
8355 });
8356 const cleanupMouseMoveHandler = useStableCallback(() => {
8357 if (!instance.handler) {
8358 return;
8359 }
8360 const doc = ownerDocument(store.select("domReferenceElement"));
8361 doc.removeEventListener("mousemove", instance.handler);
8362 instance.handler = void 0;
8363 });
8364 const clearPointerEvents = useStableCallback(() => {
8365 clearSafePolygonPointerEventsMutation(instance);
8366 });
8367 React37.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
8368 React37.useEffect(() => {
8369 if (!enabled) {
8370 return void 0;
8371 }
8372 function onOpenChangeLocal(details) {
8373 if (!details.open) {
8374 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
8375 cleanupMouseMoveHandler();
8376 instance.openChangeTimeout.clear();
8377 instance.restTimeout.clear();
8378 instance.blockMouseMove = true;
8379 instance.restTimeoutPending = false;
8380 } else {
8381 isHoverCloseActiveRef.current = false;
8382 }
8383 }
8384 events.on("openchange", onOpenChangeLocal);
8385 return () => {
8386 events.off("openchange", onOpenChangeLocal);
8387 };
8388 }, [enabled, events, instance, cleanupMouseMoveHandler]);
8389 React37.useEffect(() => {
8390 if (!enabled) {
8391 return void 0;
8392 }
8393 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
8394 if (!isElement(trigger)) {
8395 return void 0;
8396 }
8397 function onMouseEnter(event) {
8398 instance.openChangeTimeout.clear();
8399 instance.blockMouseMove = false;
8400 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
8401 return;
8402 }
8403 const restMsValue = getRestMs(restMsRef.current);
8404 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
8405 const eventTarget = getTarget(event);
8406 const currentTarget = event.currentTarget ?? null;
8407 const currentDomReference = store.select("domReferenceElement");
8408 let triggerNode = currentTarget;
8409 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
8410 for (const triggerElement of store.context.triggerElements.elements()) {
8411 if (contains(triggerElement, eventTarget)) {
8412 triggerNode = triggerElement;
8413 break;
8414 }
8415 }
8416 }
8417 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
8418 triggerNode = currentDomReference;
8419 }
8420 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
8421 const isOpen = store.select("open");
8422 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
8423 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
8424 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
8425 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
8426 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
8427 const shouldOpen = !isOpen || isOverInactive;
8428 if (shouldOpenImmediately) {
8429 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
8430 return;
8431 }
8432 if (isRestOnlyDelay) {
8433 return;
8434 }
8435 if (openDelay) {
8436 instance.openChangeTimeout.start(openDelay, () => {
8437 if (shouldOpen) {
8438 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
8439 }
8440 });
8441 } else if (shouldOpen) {
8442 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
8443 }
8444 }
8445 function onMouseLeave(event) {
8446 if (isClickLikeOpenEvent2()) {
8447 clearPointerEvents();
8448 return;
8449 }
8450 cleanupMouseMoveHandler();
8451 const domReferenceElement = store.select("domReferenceElement");
8452 const doc = ownerDocument(domReferenceElement);
8453 instance.restTimeout.clear();
8454 instance.restTimeoutPending = false;
8455 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
8456 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget);
8457 if (ignoreRelatedTargetTrigger) {
8458 return;
8459 }
8460 if (handleCloseRef.current && handleCloseContextBase) {
8461 if (!store.select("open")) {
8462 instance.openChangeTimeout.clear();
8463 }
8464 const currentTrigger = triggerElementRef.current;
8465 instance.handler = handleCloseRef.current({
8466 ...handleCloseContextBase,
8467 tree,
8468 x: event.clientX,
8469 y: event.clientY,
8470 onClose() {
8471 clearPointerEvents();
8472 cleanupMouseMoveHandler();
8473 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
8474 closeWithDelay(event, true);
8475 }
8476 }
8477 });
8478 doc.addEventListener("mousemove", instance.handler);
8479 instance.handler(event);
8480 return;
8481 }
8482 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
8483 if (shouldClose) {
8484 closeWithDelay(event);
8485 }
8486 }
8487 if (move) {
8488 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
8489 once: true
8490 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
8491 }
8492 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
8493 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]);
8494 return React37.useMemo(() => {
8495 if (!enabled) {
8496 return void 0;
8497 }
8498 function setPointerRef(event) {
8499 instance.pointerType = event.pointerType;
8500 }
8501 return {
8502 onPointerDown: setPointerRef,
8503 onPointerEnter: setPointerRef,
8504 onMouseMove(event) {
8505 const {
8506 nativeEvent
8507 } = event;
8508 const trigger = event.currentTarget;
8509 const currentDomReference = store.select("domReferenceElement");
8510 const currentOpen = store.select("open");
8511 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
8512 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
8513 return;
8514 }
8515 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
8516 const floatingElement = store.select("floatingElement");
8517 if (floatingElement) {
8518 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
8519 applySafePolygonPointerEventsMutation(instance, {
8520 scopeElement,
8521 referenceElement: trigger,
8522 floatingElement
8523 });
8524 }
8525 }
8526 const restMsValue = getRestMs(restMsRef.current);
8527 if (currentOpen && !isOverInactive || restMsValue === 0) {
8528 return;
8529 }
8530 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
8531 return;
8532 }
8533 instance.restTimeout.clear();
8534 function handleMouseMove() {
8535 instance.restTimeoutPending = false;
8536 if (isClickLikeOpenEvent2()) {
8537 return;
8538 }
8539 const latestOpen = store.select("open");
8540 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) {
8541 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
8542 }
8543 }
8544 if (instance.pointerType === "touch") {
8545 ReactDOM4.flushSync(() => {
8546 handleMouseMove();
8547 });
8548 } else if (isOverInactive && currentOpen) {
8549 handleMouseMove();
8550 } else {
8551 instance.restTimeoutPending = true;
8552 instance.restTimeout.start(restMsValue, handleMouseMove);
8553 }
8554 }
8555 };
8556 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef]);
8557 }
8558
8559 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js
8560 var React38 = __toESM(require_react(), 1);
8561 function useInteractions(propsList = []) {
8562 const referenceDeps = propsList.map((key) => key?.reference);
8563 const floatingDeps = propsList.map((key) => key?.floating);
8564 const itemDeps = propsList.map((key) => key?.item);
8565 const triggerDeps = propsList.map((key) => key?.trigger);
8566 const getReferenceProps = React38.useCallback(
8567 (userProps) => mergeProps2(userProps, propsList, "reference"),
8568 // eslint-disable-next-line react-hooks/exhaustive-deps
8569 referenceDeps
8570 );
8571 const getFloatingProps = React38.useCallback(
8572 (userProps) => mergeProps2(userProps, propsList, "floating"),
8573 // eslint-disable-next-line react-hooks/exhaustive-deps
8574 floatingDeps
8575 );
8576 const getItemProps = React38.useCallback(
8577 (userProps) => mergeProps2(userProps, propsList, "item"),
8578 // eslint-disable-next-line react-hooks/exhaustive-deps
8579 itemDeps
8580 );
8581 const getTriggerProps = React38.useCallback(
8582 (userProps) => mergeProps2(userProps, propsList, "trigger"),
8583 // eslint-disable-next-line react-hooks/exhaustive-deps
8584 triggerDeps
8585 );
8586 return React38.useMemo(() => ({
8587 getReferenceProps,
8588 getFloatingProps,
8589 getItemProps,
8590 getTriggerProps
8591 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
8592 }
8593 function mergeProps2(userProps, propsList, elementKey) {
8594 const eventHandlers = /* @__PURE__ */ new Map();
8595 const isItem2 = elementKey === "item";
8596 const outputProps = {};
8597 if (elementKey === "floating") {
8598 outputProps.tabIndex = -1;
8599 outputProps[FOCUSABLE_ATTRIBUTE] = "";
8600 }
8601 for (const key in userProps) {
8602 if (isItem2 && userProps) {
8603 if (key === ACTIVE_KEY || key === SELECTED_KEY) {
8604 continue;
8605 }
8606 }
8607 outputProps[key] = userProps[key];
8608 }
8609 for (let i2 = 0; i2 < propsList.length; i2 += 1) {
8610 let props;
8611 const propsOrGetProps = propsList[i2]?.[elementKey];
8612 if (typeof propsOrGetProps === "function") {
8613 props = userProps ? propsOrGetProps(userProps) : null;
8614 } else {
8615 props = propsOrGetProps;
8616 }
8617 if (!props) {
8618 continue;
8619 }
8620 mutablyMergeProps(outputProps, props, isItem2, eventHandlers);
8621 }
8622 mutablyMergeProps(outputProps, userProps, isItem2, eventHandlers);
8623 return outputProps;
8624 }
8625 function mutablyMergeProps(outputProps, props, isItem2, eventHandlers) {
8626 for (const key in props) {
8627 const value = props[key];
8628 if (isItem2 && (key === ACTIVE_KEY || key === SELECTED_KEY)) {
8629 continue;
8630 }
8631 if (!key.startsWith("on")) {
8632 outputProps[key] = value;
8633 } else {
8634 if (!eventHandlers.has(key)) {
8635 eventHandlers.set(key, []);
8636 }
8637 if (typeof value === "function") {
8638 eventHandlers.get(key)?.push(value);
8639 outputProps[key] = (...args) => {
8640 return eventHandlers.get(key)?.map((fn) => fn(...args)).find((val) => val !== void 0);
8641 };
8642 }
8643 }
8644 }
8645 }
8646
8647 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useRole.js
8648 var React39 = __toESM(require_react(), 1);
8649 var componentRoleToAriaRoleMap = /* @__PURE__ */ new Map([["select", "listbox"], ["combobox", "listbox"], ["label", false]]);
8650 function useRole(context, props = {}) {
8651 const store = "rootStore" in context ? context.rootStore : context;
8652 const open = store.useState("open");
8653 const defaultFloatingId = store.useState("floatingId");
8654 const domReference = store.useState("domReferenceElement");
8655 const floatingElement = store.useState("floatingElement");
8656 const {
8657 role = "dialog"
8658 } = props;
8659 const defaultReferenceId = useId();
8660 const referenceId = domReference?.id || defaultReferenceId;
8661 const floatingId = React39.useMemo(() => getFloatingFocusElement(floatingElement)?.id || defaultFloatingId, [floatingElement, defaultFloatingId]);
8662 const ariaRole = componentRoleToAriaRoleMap.get(role) ?? role;
8663 const parentId = useFloatingParentNodeId();
8664 const isNested = parentId != null;
8665 const trigger = React39.useMemo(() => {
8666 if (ariaRole === "tooltip" || role === "label") {
8667 return EMPTY_OBJECT;
8668 }
8669 return {
8670 "aria-haspopup": ariaRole === "alertdialog" ? "dialog" : ariaRole,
8671 "aria-expanded": "false",
8672 ...ariaRole === "listbox" && {
8673 role: "combobox"
8674 },
8675 ...ariaRole === "menu" && isNested && {
8676 role: "menuitem"
8677 },
8678 ...role === "select" && {
8679 "aria-autocomplete": "none"
8680 },
8681 ...role === "combobox" && {
8682 "aria-autocomplete": "list"
8683 }
8684 };
8685 }, [ariaRole, isNested, role]);
8686 const reference = React39.useMemo(() => {
8687 if (ariaRole === "tooltip" || role === "label") {
8688 return {
8689 [`aria-${role === "label" ? "labelledby" : "describedby"}`]: open ? floatingId : void 0
8690 };
8691 }
8692 const triggerProps = trigger;
8693 return {
8694 ...triggerProps,
8695 "aria-expanded": open ? "true" : "false",
8696 "aria-controls": open ? floatingId : void 0,
8697 ...ariaRole === "menu" && {
8698 id: referenceId
8699 }
8700 };
8701 }, [ariaRole, floatingId, open, referenceId, role, trigger]);
8702 const floating = React39.useMemo(() => {
8703 const floatingProps = {
8704 id: floatingId,
8705 ...ariaRole && {
8706 role: ariaRole
8707 }
8708 };
8709 if (ariaRole === "tooltip" || role === "label") {
8710 return floatingProps;
8711 }
8712 return {
8713 ...floatingProps,
8714 ...ariaRole === "menu" && {
8715 "aria-labelledby": referenceId
8716 }
8717 };
8718 }, [ariaRole, floatingId, referenceId, role]);
8719 const item = React39.useCallback(({
8720 active,
8721 selected
8722 }) => {
8723 const commonProps = {
8724 role: "option",
8725 ...active && {
8726 id: `${floatingId}-fui-option`
8727 }
8728 };
8729 switch (role) {
8730 case "select":
8731 case "combobox":
8732 return {
8733 ...commonProps,
8734 "aria-selected": selected
8735 };
8736 default:
8737 }
8738 return {};
8739 }, [floatingId, role]);
8740 return React39.useMemo(() => ({
8741 reference,
8742 floating,
8743 item,
8744 trigger
8745 }), [reference, floating, trigger, item]);
8746 }
8747
8748 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
8749 var CURSOR_SPEED_THRESHOLD = 0.1;
8750 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
8751 var POLYGON_BUFFER = 0.5;
8752 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
8753 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
8754 }
8755 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
8756 let isInsideValue = false;
8757 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
8758 isInsideValue = !isInsideValue;
8759 }
8760 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
8761 isInsideValue = !isInsideValue;
8762 }
8763 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
8764 isInsideValue = !isInsideValue;
8765 }
8766 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
8767 isInsideValue = !isInsideValue;
8768 }
8769 return isInsideValue;
8770 }
8771 function isInsideRect(pointX, pointY, rect) {
8772 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
8773 }
8774 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
8775 const minX = Math.min(x1, x2);
8776 const maxX = Math.max(x1, x2);
8777 const minY = Math.min(y1, y2);
8778 const maxY = Math.max(y1, y2);
8779 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
8780 }
8781 function safePolygon(options = {}) {
8782 const {
8783 blockPointerEvents = false
8784 } = options;
8785 const timeout = new Timeout();
8786 const fn = ({
8787 x: x2,
8788 y: y2,
8789 placement,
8790 elements,
8791 onClose,
8792 nodeId,
8793 tree
8794 }) => {
8795 const side = placement?.split("-")[0];
8796 let hasLanded = false;
8797 let lastX = null;
8798 let lastY = null;
8799 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
8800 function isCursorMovingSlowly(nextX, nextY) {
8801 const currentTime = performance.now();
8802 const elapsedTime = currentTime - lastCursorTime;
8803 if (lastX === null || lastY === null || elapsedTime === 0) {
8804 lastX = nextX;
8805 lastY = nextY;
8806 lastCursorTime = currentTime;
8807 return false;
8808 }
8809 const deltaX = nextX - lastX;
8810 const deltaY = nextY - lastY;
8811 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
8812 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
8813 lastX = nextX;
8814 lastY = nextY;
8815 lastCursorTime = currentTime;
8816 return distanceSquared < thresholdSquared;
8817 }
8818 function close() {
8819 timeout.clear();
8820 onClose();
8821 }
8822 return function onMouseMove(event) {
8823 timeout.clear();
8824 const domReference = elements.domReference;
8825 const floating = elements.floating;
8826 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
8827 return void 0;
8828 }
8829 const {
8830 clientX,
8831 clientY
8832 } = event;
8833 const target = getTarget(event);
8834 const isLeave = event.type === "mouseleave";
8835 const isOverFloatingEl = contains(floating, target);
8836 const isOverReferenceEl = contains(domReference, target);
8837 if (isOverFloatingEl) {
8838 hasLanded = true;
8839 if (!isLeave) {
8840 return void 0;
8841 }
8842 }
8843 if (isOverReferenceEl) {
8844 hasLanded = false;
8845 if (!isLeave) {
8846 hasLanded = true;
8847 return void 0;
8848 }
8849 }
8850 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
8851 return void 0;
8852 }
8853 function hasOpenChildNode() {
8854 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
8855 }
8856 function closeIfNoOpenChild() {
8857 if (!hasOpenChildNode()) {
8858 close();
8859 }
8860 }
8861 if (hasOpenChildNode()) {
8862 return void 0;
8863 }
8864 const refRect = domReference.getBoundingClientRect();
8865 const rect = floating.getBoundingClientRect();
8866 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
8867 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
8868 const isFloatingWider = rect.width > refRect.width;
8869 const isFloatingTaller = rect.height > refRect.height;
8870 const left = (isFloatingWider ? refRect : rect).left;
8871 const right = (isFloatingWider ? refRect : rect).right;
8872 const top = (isFloatingTaller ? refRect : rect).top;
8873 const bottom = (isFloatingTaller ? refRect : rect).bottom;
8874 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) {
8875 closeIfNoOpenChild();
8876 return void 0;
8877 }
8878 let isInsideTroughRect = false;
8879 switch (side) {
8880 case "top":
8881 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
8882 break;
8883 case "bottom":
8884 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
8885 break;
8886 case "left":
8887 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
8888 break;
8889 case "right":
8890 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
8891 break;
8892 default:
8893 }
8894 if (isInsideTroughRect) {
8895 return void 0;
8896 }
8897 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
8898 closeIfNoOpenChild();
8899 return void 0;
8900 }
8901 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
8902 closeIfNoOpenChild();
8903 return void 0;
8904 }
8905 let isInsidePolygon = false;
8906 switch (side) {
8907 case "top": {
8908 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8909 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8910 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8911 const cursorPointY = y2 + POLYGON_BUFFER + 1;
8912 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
8913 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
8914 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8915 break;
8916 }
8917 case "bottom": {
8918 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8919 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8920 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
8921 const cursorPointY = y2 - POLYGON_BUFFER;
8922 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
8923 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
8924 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
8925 break;
8926 }
8927 case "left": {
8928 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8929 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8930 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8931 const cursorPointX = x2 + POLYGON_BUFFER + 1;
8932 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
8933 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
8934 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
8935 break;
8936 }
8937 case "right": {
8938 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
8939 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8940 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
8941 const cursorPointX = x2 - POLYGON_BUFFER;
8942 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
8943 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
8944 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
8945 break;
8946 }
8947 default:
8948 }
8949 if (!isInsidePolygon) {
8950 closeIfNoOpenChild();
8951 } else if (!hasLanded) {
8952 timeout.start(40, closeIfNoOpenChild);
8953 }
8954 return void 0;
8955 };
8956 };
8957 fn.__options = {
8958 ...options,
8959 blockPointerEvents
8960 };
8961 return fn;
8962 }
8963
8964 // node_modules/@base-ui/react/esm/utils/useOpenInteractionType.js
8965 var React42 = __toESM(require_react(), 1);
8966
8967 // node_modules/@base-ui/utils/esm/useEnhancedClickHandler.js
8968 var React40 = __toESM(require_react(), 1);
8969 function useEnhancedClickHandler(handler) {
8970 const lastClickInteractionTypeRef = React40.useRef("");
8971 const handlePointerDown = React40.useCallback((event) => {
8972 if (event.defaultPrevented) {
8973 return;
8974 }
8975 lastClickInteractionTypeRef.current = event.pointerType;
8976 handler(event, event.pointerType);
8977 }, [handler]);
8978 const handleClick = React40.useCallback((event) => {
8979 if (event.detail === 0) {
8980 handler(event, "keyboard");
8981 return;
8982 }
8983 if ("pointerType" in event) {
8984 handler(event, event.pointerType);
8985 } else {
8986 handler(event, lastClickInteractionTypeRef.current);
8987 }
8988 lastClickInteractionTypeRef.current = "";
8989 }, [handler]);
8990 return {
8991 onClick: handleClick,
8992 onPointerDown: handlePointerDown
8993 };
8994 }
8995
8996 // node_modules/@base-ui/react/esm/internals/useValueChanged.js
8997 var React41 = __toESM(require_react(), 1);
8998 function useValueChanged(value, onChange) {
8999 const valueRef = React41.useRef(value);
9000 const onChangeCallback = useStableCallback(onChange);
9001 useIsoLayoutEffect(() => {
9002 if (valueRef.current === value) {
9003 return;
9004 }
9005 onChangeCallback(valueRef.current);
9006 }, [value, onChangeCallback]);
9007 useIsoLayoutEffect(() => {
9008 valueRef.current = value;
9009 }, [value]);
9010 }
9011
9012 // node_modules/@base-ui/react/esm/utils/useOpenInteractionType.js
9013 function useOpenInteractionType(open) {
9014 const [openMethod, setOpenMethod] = React42.useState(null);
9015 const handleTriggerClick = useStableCallback((_, interactionType) => {
9016 if (!open) {
9017 setOpenMethod(interactionType || // On iOS Safari, the hitslop around touch targets means tapping outside an element's
9018 // bounds does not fire `pointerdown` but does fire `mousedown`. The `interactionType`
9019 // will be "" in that case.
9020 (isIOS ? "touch" : ""));
9021 }
9022 });
9023 useValueChanged(open, (previousOpen) => {
9024 if (previousOpen && !open) {
9025 setOpenMethod(null);
9026 }
9027 });
9028 const {
9029 onClick,
9030 onPointerDown
9031 } = useEnhancedClickHandler(handleTriggerClick);
9032 return React42.useMemo(() => ({
9033 openMethod,
9034 triggerProps: {
9035 onClick,
9036 onPointerDown
9037 }
9038 }), [openMethod, onClick, onPointerDown]);
9039 }
9040
9041 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
9042 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
9043 CommonPopupDataAttributes2["open"] = "data-open";
9044 CommonPopupDataAttributes2["closed"] = "data-closed";
9045 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
9046 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
9047 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
9048 CommonPopupDataAttributes2["side"] = "data-side";
9049 CommonPopupDataAttributes2["align"] = "data-align";
9050 return CommonPopupDataAttributes2;
9051 })({});
9052 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
9053 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
9054 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
9055 return CommonTriggerDataAttributes2;
9056 })({});
9057 var TRIGGER_HOOK = {
9058 [CommonTriggerDataAttributes.popupOpen]: ""
9059 };
9060 var PRESSABLE_TRIGGER_HOOK = {
9061 [CommonTriggerDataAttributes.popupOpen]: "",
9062 [CommonTriggerDataAttributes.pressed]: ""
9063 };
9064 var POPUP_OPEN_HOOK = {
9065 [CommonPopupDataAttributes.open]: ""
9066 };
9067 var POPUP_CLOSED_HOOK = {
9068 [CommonPopupDataAttributes.closed]: ""
9069 };
9070 var ANCHOR_HIDDEN_HOOK = {
9071 [CommonPopupDataAttributes.anchorHidden]: ""
9072 };
9073 var triggerOpenStateMapping2 = {
9074 open(value) {
9075 if (value) {
9076 return TRIGGER_HOOK;
9077 }
9078 return null;
9079 }
9080 };
9081 var pressableTriggerOpenStateMapping = {
9082 open(value) {
9083 if (value) {
9084 return PRESSABLE_TRIGGER_HOOK;
9085 }
9086 return null;
9087 }
9088 };
9089 var popupStateMapping = {
9090 open(value) {
9091 if (value) {
9092 return POPUP_OPEN_HOOK;
9093 }
9094 return POPUP_CLOSED_HOOK;
9095 },
9096 anchorHidden(value) {
9097 if (value) {
9098 return ANCHOR_HIDDEN_HOOK;
9099 }
9100 return null;
9101 }
9102 };
9103
9104 // node_modules/@base-ui/utils/esm/inertValue.js
9105 function inertValue(value) {
9106 if (isReactVersionAtLeast(19)) {
9107 return value;
9108 }
9109 return value ? "true" : void 0;
9110 }
9111
9112 // node_modules/@base-ui/react/esm/utils/InternalBackdrop.js
9113 var React43 = __toESM(require_react(), 1);
9114 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
9115 var InternalBackdrop = /* @__PURE__ */ React43.forwardRef(function InternalBackdrop2(props, ref) {
9116 const {
9117 cutout,
9118 ...otherProps
9119 } = props;
9120 let clipPath;
9121 if (cutout) {
9122 const rect = cutout.getBoundingClientRect();
9123 clipPath = `polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${rect.left}px ${rect.top}px,${rect.left}px ${rect.bottom}px,${rect.right}px ${rect.bottom}px,${rect.right}px ${rect.top}px,${rect.left}px ${rect.top}px)`;
9124 }
9125 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
9126 ref,
9127 role: "presentation",
9128 "data-base-ui-inert": "",
9129 ...otherProps,
9130 style: {
9131 position: "fixed",
9132 inset: 0,
9133 userSelect: "none",
9134 WebkitUserSelect: "none",
9135 clipPath
9136 }
9137 });
9138 });
9139 if (true) InternalBackdrop.displayName = "InternalBackdrop";
9140
9141 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
9142 var React44 = __toESM(require_react(), 1);
9143
9144 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
9145 var baseArrow = (options) => ({
9146 name: "arrow",
9147 options,
9148 async fn(state) {
9149 const {
9150 x: x2,
9151 y: y2,
9152 placement,
9153 rects,
9154 platform: platform3,
9155 elements,
9156 middlewareData
9157 } = state;
9158 const {
9159 element,
9160 padding = 0,
9161 offsetParent = "real"
9162 } = evaluate(options, state) || {};
9163 if (element == null) {
9164 return {};
9165 }
9166 const paddingObject = getPaddingObject(padding);
9167 const coords = {
9168 x: x2,
9169 y: y2
9170 };
9171 const axis = getAlignmentAxis(placement);
9172 const length = getAxisLength(axis);
9173 const arrowDimensions = await platform3.getDimensions(element);
9174 const isYAxis = axis === "y";
9175 const minProp = isYAxis ? "top" : "left";
9176 const maxProp = isYAxis ? "bottom" : "right";
9177 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
9178 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
9179 const startDiff = coords[axis] - rects.reference[axis];
9180 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
9181 let clientSize = elements.floating[clientProp] || rects.floating[length];
9182 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
9183 clientSize = elements.floating[clientProp] || rects.floating[length];
9184 }
9185 const centerToReference = endDiff / 2 - startDiff / 2;
9186 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
9187 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
9188 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
9189 const min2 = minPadding;
9190 const max2 = clientSize - arrowDimensions[length] - maxPadding;
9191 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
9192 const offset4 = clamp(min2, center, max2);
9193 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
9194 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
9195 return {
9196 [axis]: coords[axis] + alignmentOffset,
9197 data: {
9198 [axis]: offset4,
9199 centerOffset: center - offset4 - alignmentOffset,
9200 ...shouldAddOffset && {
9201 alignmentOffset
9202 }
9203 },
9204 reset: shouldAddOffset
9205 };
9206 }
9207 });
9208 var arrow4 = (options, deps) => ({
9209 ...baseArrow(options),
9210 options: [options, deps]
9211 });
9212
9213 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
9214 var hide4 = {
9215 name: "hide",
9216 async fn(state) {
9217 const {
9218 width,
9219 height,
9220 x: x2,
9221 y: y2
9222 } = state.rects.reference;
9223 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
9224 const nativeHideResult = await hide3().fn(state);
9225 return {
9226 data: {
9227 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
9228 }
9229 };
9230 }
9231 };
9232
9233 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
9234 var DEFAULT_SIDES = {
9235 sideX: "left",
9236 sideY: "top"
9237 };
9238 var adaptiveOrigin = {
9239 name: "adaptiveOrigin",
9240 async fn(state) {
9241 const {
9242 x: rawX,
9243 y: rawY,
9244 rects: {
9245 floating: floatRect
9246 },
9247 elements: {
9248 floating
9249 },
9250 platform: platform3,
9251 strategy,
9252 placement
9253 } = state;
9254 const win = getWindow(floating);
9255 const styles = win.getComputedStyle(floating);
9256 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
9257 if (!hasTransition) {
9258 return {
9259 x: rawX,
9260 y: rawY,
9261 data: DEFAULT_SIDES
9262 };
9263 }
9264 const offsetParent = await platform3.getOffsetParent?.(floating);
9265 let offsetDimensions = {
9266 width: 0,
9267 height: 0
9268 };
9269 if (strategy === "fixed" && win?.visualViewport) {
9270 offsetDimensions = {
9271 width: win.visualViewport.width,
9272 height: win.visualViewport.height
9273 };
9274 } else if (offsetParent === win) {
9275 const doc = ownerDocument(floating);
9276 offsetDimensions = {
9277 width: doc.documentElement.clientWidth,
9278 height: doc.documentElement.clientHeight
9279 };
9280 } else if (await platform3.isElement?.(offsetParent)) {
9281 offsetDimensions = await platform3.getDimensions(offsetParent);
9282 }
9283 const currentSide = getSide(placement);
9284 let x2 = rawX;
9285 let y2 = rawY;
9286 if (currentSide === "left") {
9287 x2 = offsetDimensions.width - (rawX + floatRect.width);
9288 }
9289 if (currentSide === "top") {
9290 y2 = offsetDimensions.height - (rawY + floatRect.height);
9291 }
9292 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
9293 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
9294 return {
9295 x: x2,
9296 y: y2,
9297 data: {
9298 sideX,
9299 sideY
9300 }
9301 };
9302 }
9303 };
9304
9305 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
9306 function getLogicalSide(sideParam, renderedSide, isRtl) {
9307 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
9308 const logicalRight = isRtl ? "inline-start" : "inline-end";
9309 const logicalLeft = isRtl ? "inline-end" : "inline-start";
9310 return {
9311 top: "top",
9312 right: isLogicalSideParam ? logicalRight : "right",
9313 bottom: "bottom",
9314 left: isLogicalSideParam ? logicalLeft : "left"
9315 }[renderedSide];
9316 }
9317 function getOffsetData(state, sideParam, isRtl) {
9318 const {
9319 rects,
9320 placement
9321 } = state;
9322 const data = {
9323 side: getLogicalSide(sideParam, getSide(placement), isRtl),
9324 align: getAlignment(placement) || "center",
9325 anchor: {
9326 width: rects.reference.width,
9327 height: rects.reference.height
9328 },
9329 positioner: {
9330 width: rects.floating.width,
9331 height: rects.floating.height
9332 }
9333 };
9334 return data;
9335 }
9336 function useAnchorPositioning(params) {
9337 const {
9338 // Public parameters
9339 anchor,
9340 positionMethod = "absolute",
9341 side: sideParam = "bottom",
9342 sideOffset = 0,
9343 align = "center",
9344 alignOffset = 0,
9345 collisionBoundary,
9346 collisionPadding: collisionPaddingParam = 5,
9347 sticky = false,
9348 arrowPadding = 5,
9349 disableAnchorTracking = false,
9350 // Private parameters
9351 keepMounted = false,
9352 floatingRootContext,
9353 mounted,
9354 collisionAvoidance,
9355 shiftCrossAxis = false,
9356 nodeId,
9357 adaptiveOrigin: adaptiveOrigin2,
9358 lazyFlip = false,
9359 externalTree
9360 } = params;
9361 const [mountSide, setMountSide] = React44.useState(null);
9362 if (!mounted && mountSide !== null) {
9363 setMountSide(null);
9364 }
9365 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
9366 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
9367 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
9368 const anchorFn = typeof anchor === "function" ? anchor : void 0;
9369 const anchorFnCallback = useStableCallback(anchorFn);
9370 const anchorDep = anchorFn ? anchorFnCallback : anchor;
9371 const anchorValueRef = useValueAsRef(anchor);
9372 const mountedRef = useValueAsRef(mounted);
9373 const direction = useDirection();
9374 const isRtl = direction === "rtl";
9375 const side = mountSide || {
9376 top: "top",
9377 right: "right",
9378 bottom: "bottom",
9379 left: "left",
9380 "inline-end": isRtl ? "left" : "right",
9381 "inline-start": isRtl ? "right" : "left"
9382 }[sideParam];
9383 const placement = align === "center" ? side : `${side}-${align}`;
9384 let collisionPadding = collisionPaddingParam;
9385 const bias = 1;
9386 const biasTop = sideParam === "bottom" ? bias : 0;
9387 const biasBottom = sideParam === "top" ? bias : 0;
9388 const biasLeft = sideParam === "right" ? bias : 0;
9389 const biasRight = sideParam === "left" ? bias : 0;
9390 if (typeof collisionPadding === "number") {
9391 collisionPadding = {
9392 top: collisionPadding + biasTop,
9393 right: collisionPadding + biasRight,
9394 bottom: collisionPadding + biasBottom,
9395 left: collisionPadding + biasLeft
9396 };
9397 } else if (collisionPadding) {
9398 collisionPadding = {
9399 top: (collisionPadding.top || 0) + biasTop,
9400 right: (collisionPadding.right || 0) + biasRight,
9401 bottom: (collisionPadding.bottom || 0) + biasBottom,
9402 left: (collisionPadding.left || 0) + biasLeft
9403 };
9404 }
9405 const commonCollisionProps = {
9406 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
9407 padding: collisionPadding
9408 };
9409 const arrowRef = React44.useRef(null);
9410 const sideOffsetRef = useValueAsRef(sideOffset);
9411 const alignOffsetRef = useValueAsRef(alignOffset);
9412 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
9413 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
9414 const middleware = [offset3((state) => {
9415 const data = getOffsetData(state, sideParam, isRtl);
9416 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
9417 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
9418 return {
9419 mainAxis: sideAxis,
9420 crossAxis: alignAxis,
9421 alignmentAxis: alignAxis
9422 };
9423 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])];
9424 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
9425 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
9426 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
9427 ...commonCollisionProps,
9428 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
9429 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
9430 padding: {
9431 top: collisionPadding.top + bias,
9432 right: collisionPadding.right + bias,
9433 bottom: collisionPadding.bottom + bias,
9434 left: collisionPadding.left + bias
9435 },
9436 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
9437 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
9438 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
9439 });
9440 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
9441 const html = ownerDocument(data.elements.floating).documentElement;
9442 return {
9443 ...commonCollisionProps,
9444 // Use the Layout Viewport to avoid shifting around when pinch-zooming
9445 // for context menus.
9446 rootBoundary: shiftCrossAxis ? {
9447 x: 0,
9448 y: 0,
9449 width: html.clientWidth,
9450 height: html.clientHeight
9451 } : void 0,
9452 mainAxis: collisionAvoidanceAlign !== "none",
9453 crossAxis: crossAxisShiftEnabled,
9454 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
9455 if (!arrowRef.current) {
9456 return {};
9457 }
9458 const {
9459 width,
9460 height
9461 } = arrowRef.current.getBoundingClientRect();
9462 const sideAxis = getSideAxis(getSide(limitData.placement));
9463 const arrowSize = sideAxis === "y" ? width : height;
9464 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
9465 return {
9466 offset: arrowSize / 2 + offsetAmount / 2
9467 };
9468 })
9469 };
9470 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
9471 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
9472 middleware.push(shiftMiddleware, flipMiddleware);
9473 } else {
9474 middleware.push(flipMiddleware, shiftMiddleware);
9475 }
9476 middleware.push(size3({
9477 ...commonCollisionProps,
9478 apply({
9479 elements: {
9480 floating
9481 },
9482 availableWidth,
9483 availableHeight,
9484 rects
9485 }) {
9486 if (!mountedRef.current) {
9487 return;
9488 }
9489 const floatingStyle = floating.style;
9490 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
9491 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
9492 const dpr = getWindow(floating).devicePixelRatio || 1;
9493 const {
9494 x: x3,
9495 y: y3,
9496 width,
9497 height
9498 } = rects.reference;
9499 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
9500 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
9501 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
9502 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
9503 }
9504 }), arrow4(() => ({
9505 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
9506 // we'll create a fake element.
9507 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"),
9508 padding: arrowPadding,
9509 offsetParent: "floating"
9510 }), [arrowPadding]), {
9511 name: "transformOrigin",
9512 fn(state) {
9513 const {
9514 elements: elements2,
9515 middlewareData: middlewareData2,
9516 placement: renderedPlacement2,
9517 rects,
9518 y: y3
9519 } = state;
9520 const currentRenderedSide = getSide(renderedPlacement2);
9521 const currentRenderedAxis = getSideAxis(currentRenderedSide);
9522 const arrowEl = arrowRef.current;
9523 const arrowX = middlewareData2.arrow?.x || 0;
9524 const arrowY = middlewareData2.arrow?.y || 0;
9525 const arrowWidth = arrowEl?.clientWidth || 0;
9526 const arrowHeight = arrowEl?.clientHeight || 0;
9527 const transformX = arrowX + arrowWidth / 2;
9528 const transformY = arrowY + arrowHeight / 2;
9529 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
9530 const halfAnchorHeight = rects.reference.height / 2;
9531 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
9532 const isOverlappingAnchor = shiftY > sideOffsetValue;
9533 const adjacentTransformOrigin = {
9534 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
9535 bottom: `${transformX}px ${-sideOffsetValue}px`,
9536 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
9537 right: `${-sideOffsetValue}px ${transformY}px`
9538 }[currentRenderedSide];
9539 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
9540 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
9541 return {};
9542 }
9543 }, hide4, adaptiveOrigin2);
9544 useIsoLayoutEffect(() => {
9545 if (!mounted && floatingRootContext) {
9546 floatingRootContext.update({
9547 referenceElement: null,
9548 floatingElement: null,
9549 domReferenceElement: null,
9550 positionReference: null
9551 });
9552 }
9553 }, [mounted, floatingRootContext]);
9554 const autoUpdateOptions = React44.useMemo(() => ({
9555 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
9556 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
9557 }), [disableAnchorTracking]);
9558 const {
9559 refs,
9560 elements,
9561 x: x2,
9562 y: y2,
9563 middlewareData,
9564 update: update2,
9565 placement: renderedPlacement,
9566 context,
9567 isPositioned,
9568 floatingStyles: originalFloatingStyles
9569 } = useFloating2({
9570 rootContext: floatingRootContext,
9571 open: keepMounted ? mounted : void 0,
9572 placement,
9573 middleware,
9574 strategy: positionMethod,
9575 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
9576 nodeId,
9577 externalTree
9578 });
9579 const {
9580 sideX,
9581 sideY
9582 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
9583 const resolvedPosition = isPositioned ? positionMethod : "fixed";
9584 const floatingStyles = React44.useMemo(() => {
9585 const base = adaptiveOrigin2 ? {
9586 position: resolvedPosition,
9587 [sideX]: x2,
9588 [sideY]: y2
9589 } : {
9590 position: resolvedPosition,
9591 ...originalFloatingStyles
9592 };
9593 if (!isPositioned) {
9594 base.opacity = 0;
9595 }
9596 return base;
9597 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
9598 const registeredPositionReferenceRef = React44.useRef(null);
9599 useIsoLayoutEffect(() => {
9600 if (!mounted) {
9601 return;
9602 }
9603 const anchorValue = anchorValueRef.current;
9604 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
9605 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
9606 const finalAnchor = unwrappedElement || null;
9607 if (finalAnchor !== registeredPositionReferenceRef.current) {
9608 refs.setPositionReference(finalAnchor);
9609 registeredPositionReferenceRef.current = finalAnchor;
9610 }
9611 }, [mounted, refs, anchorDep, anchorValueRef]);
9612 React44.useEffect(() => {
9613 if (!mounted) {
9614 return;
9615 }
9616 const anchorValue = anchorValueRef.current;
9617 if (typeof anchorValue === "function") {
9618 return;
9619 }
9620 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
9621 refs.setPositionReference(anchorValue.current);
9622 registeredPositionReferenceRef.current = anchorValue.current;
9623 }
9624 }, [mounted, refs, anchorDep, anchorValueRef]);
9625 React44.useEffect(() => {
9626 if (keepMounted && mounted && elements.domReference && elements.floating) {
9627 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
9628 }
9629 return void 0;
9630 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
9631 const renderedSide = getSide(renderedPlacement);
9632 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
9633 const renderedAlign = getAlignment(renderedPlacement) || "center";
9634 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
9635 useIsoLayoutEffect(() => {
9636 if (lazyFlip && mounted && isPositioned) {
9637 setMountSide(renderedSide);
9638 }
9639 }, [lazyFlip, mounted, isPositioned, renderedSide]);
9640 const arrowStyles = React44.useMemo(() => ({
9641 position: "absolute",
9642 top: middlewareData.arrow?.y,
9643 left: middlewareData.arrow?.x
9644 }), [middlewareData.arrow]);
9645 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
9646 return React44.useMemo(() => ({
9647 positionerStyles: floatingStyles,
9648 arrowStyles,
9649 arrowRef,
9650 arrowUncentered,
9651 side: logicalRenderedSide,
9652 align: renderedAlign,
9653 physicalSide: renderedSide,
9654 anchorHidden,
9655 refs,
9656 context,
9657 isPositioned,
9658 update: update2
9659 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
9660 }
9661 function isRef(param) {
9662 return param != null && "current" in param;
9663 }
9664
9665 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
9666 function getDisabledMountTransitionStyles(transitionStatus) {
9667 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
9668 }
9669
9670 // node_modules/@base-ui/react/esm/utils/usePositioner.js
9671 function usePositioner(componentProps, state, {
9672 styles,
9673 transitionStatus,
9674 props,
9675 refs,
9676 hidden,
9677 inert = false
9678 }) {
9679 const style = {
9680 ...styles
9681 };
9682 if (inert) {
9683 style.pointerEvents = "none";
9684 }
9685 return useRenderElement("div", componentProps, {
9686 state,
9687 ref: refs,
9688 props: [{
9689 role: "presentation",
9690 hidden,
9691 style
9692 }, getDisabledMountTransitionStyles(transitionStatus), props],
9693 stateAttributesMapping: popupStateMapping
9694 });
9695 }
9696
9697 // node_modules/@base-ui/react/esm/utils/useAnchoredPopupScrollLock.js
9698 var React45 = __toESM(require_react(), 1);
9699 var VIEWPORT_WIDTH_TOLERANCE_PX = 20;
9700 function useAnchoredPopupScrollLock(enabled, touchOpen, positionerElement, referenceElement) {
9701 const [touchOpenShouldLockScroll, setTouchOpenShouldLockScroll] = React45.useState(false);
9702 useIsoLayoutEffect(() => {
9703 if (!enabled || !touchOpen || positionerElement == null) {
9704 setTouchOpenShouldLockScroll(false);
9705 return;
9706 }
9707 const viewportWidth = ownerDocument(positionerElement).documentElement.clientWidth;
9708 const popupWidth = positionerElement.offsetWidth;
9709 setTouchOpenShouldLockScroll(viewportWidth > 0 && popupWidth > 0 && popupWidth >= viewportWidth - VIEWPORT_WIDTH_TOLERANCE_PX);
9710 }, [enabled, touchOpen, positionerElement]);
9711 useScrollLock(enabled && (!touchOpen || touchOpenShouldLockScroll), referenceElement);
9712 }
9713
9714 // node_modules/@base-ui/react/esm/button/Button.js
9715 var React46 = __toESM(require_react(), 1);
9716 var Button = /* @__PURE__ */ React46.forwardRef(function Button2(componentProps, forwardedRef) {
9717 const {
9718 render: render4,
9719 className,
9720 disabled: disabled2 = false,
9721 focusableWhenDisabled = false,
9722 nativeButton = true,
9723 style,
9724 ...elementProps
9725 } = componentProps;
9726 const {
9727 getButtonProps,
9728 buttonRef
9729 } = useButton({
9730 disabled: disabled2,
9731 focusableWhenDisabled,
9732 native: nativeButton
9733 });
9734 const state = {
9735 disabled: disabled2
9736 };
9737 return useRenderElement("button", componentProps, {
9738 state,
9739 ref: [forwardedRef, buttonRef],
9740 props: [elementProps, getButtonProps]
9741 });
9742 });
9743 if (true) Button.displayName = "Button";
9744
9745 // node_modules/@base-ui/react/esm/collapsible/index.parts.js
9746 var index_parts_exports = {};
9747 __export(index_parts_exports, {
9748 Panel: () => CollapsiblePanel,
9749 Root: () => CollapsibleRoot,
9750 Trigger: () => CollapsibleTrigger
9751 });
9752
9753 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
9754 var React47 = __toESM(require_react(), 1);
9755
9756 // node_modules/@base-ui/react/esm/collapsible/root/stateAttributesMapping.js
9757 var collapsibleStateAttributesMapping = {
9758 ...collapsibleOpenStateMapping,
9759 ...transitionStatusMapping
9760 };
9761
9762 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
9763 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
9764 var CollapsibleRoot = /* @__PURE__ */ React47.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) {
9765 const {
9766 render: render4,
9767 className,
9768 defaultOpen = false,
9769 disabled: disabled2 = false,
9770 onOpenChange: onOpenChangeProp,
9771 open,
9772 style,
9773 ...elementProps
9774 } = componentProps;
9775 const onOpenChange = useStableCallback(onOpenChangeProp);
9776 const collapsible = useCollapsibleRoot({
9777 open,
9778 defaultOpen,
9779 onOpenChange,
9780 disabled: disabled2
9781 });
9782 const state = React47.useMemo(() => ({
9783 open: collapsible.open,
9784 disabled: collapsible.disabled,
9785 transitionStatus: collapsible.transitionStatus
9786 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]);
9787 const contextValue = React47.useMemo(() => ({
9788 ...collapsible,
9789 onOpenChange,
9790 state
9791 }), [collapsible, onOpenChange, state]);
9792 const element = useRenderElement("div", componentProps, {
9793 state,
9794 ref: forwardedRef,
9795 props: elementProps,
9796 stateAttributesMapping: collapsibleStateAttributesMapping
9797 });
9798 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CollapsibleRootContext.Provider, {
9799 value: contextValue,
9800 children: element
9801 });
9802 });
9803 if (true) CollapsibleRoot.displayName = "CollapsibleRoot";
9804
9805 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTrigger.js
9806 var React48 = __toESM(require_react(), 1);
9807 var stateAttributesMapping = {
9808 ...triggerOpenStateMapping,
9809 ...transitionStatusMapping
9810 };
9811 var CollapsibleTrigger = /* @__PURE__ */ React48.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) {
9812 const {
9813 panelId,
9814 open,
9815 handleTrigger,
9816 state,
9817 disabled: contextDisabled
9818 } = useCollapsibleRootContext();
9819 const {
9820 className,
9821 disabled: disabled2 = contextDisabled,
9822 id,
9823 render: render4,
9824 nativeButton = true,
9825 style,
9826 ...elementProps
9827 } = componentProps;
9828 const {
9829 getButtonProps,
9830 buttonRef
9831 } = useButton({
9832 disabled: disabled2,
9833 focusableWhenDisabled: true,
9834 native: nativeButton
9835 });
9836 const props = React48.useMemo(() => ({
9837 "aria-controls": open ? panelId : void 0,
9838 "aria-expanded": open,
9839 onClick: handleTrigger
9840 }), [panelId, open, handleTrigger]);
9841 const element = useRenderElement("button", componentProps, {
9842 state,
9843 ref: [forwardedRef, buttonRef],
9844 props: [props, elementProps, getButtonProps],
9845 stateAttributesMapping
9846 });
9847 return element;
9848 });
9849 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger";
9850
9851 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
9852 var React49 = __toESM(require_react(), 1);
9853
9854 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelCssVars.js
9855 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) {
9856 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height";
9857 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width";
9858 return CollapsiblePanelCssVars2;
9859 })({});
9860
9861 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
9862 var CollapsiblePanel = /* @__PURE__ */ React49.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) {
9863 const {
9864 className,
9865 hiddenUntilFound: hiddenUntilFoundProp,
9866 keepMounted: keepMountedProp,
9867 render: render4,
9868 id: idProp,
9869 style,
9870 ...elementProps
9871 } = componentProps;
9872 if (true) {
9873 useIsoLayoutEffect(() => {
9874 if (hiddenUntilFoundProp && keepMountedProp === false) {
9875 warn("The `keepMounted={false}` prop on a Collapsible will be ignored when using `hiddenUntilFound` since it requires the Panel to remain mounted even when closed.");
9876 }
9877 }, [hiddenUntilFoundProp, keepMountedProp]);
9878 }
9879 const {
9880 abortControllerRef,
9881 animationTypeRef,
9882 height,
9883 mounted,
9884 onOpenChange,
9885 open,
9886 panelId,
9887 panelRef,
9888 runOnceAnimationsFinish,
9889 setDimensions,
9890 setHiddenUntilFound,
9891 setKeepMounted,
9892 setMounted,
9893 setPanelIdState,
9894 setOpen,
9895 setVisible,
9896 state,
9897 transitionDimensionRef,
9898 visible,
9899 width,
9900 transitionStatus
9901 } = useCollapsibleRootContext();
9902 const hiddenUntilFound = hiddenUntilFoundProp ?? false;
9903 const keepMounted = keepMountedProp ?? false;
9904 useIsoLayoutEffect(() => {
9905 if (idProp) {
9906 setPanelIdState(idProp);
9907 return () => {
9908 setPanelIdState(void 0);
9909 };
9910 }
9911 return void 0;
9912 }, [idProp, setPanelIdState]);
9913 useIsoLayoutEffect(() => {
9914 setHiddenUntilFound(hiddenUntilFound);
9915 }, [setHiddenUntilFound, hiddenUntilFound]);
9916 useIsoLayoutEffect(() => {
9917 setKeepMounted(keepMounted);
9918 }, [setKeepMounted, keepMounted]);
9919 const {
9920 props
9921 } = useCollapsiblePanel({
9922 abortControllerRef,
9923 animationTypeRef,
9924 externalRef: forwardedRef,
9925 height,
9926 hiddenUntilFound,
9927 id: panelId,
9928 keepMounted,
9929 mounted,
9930 onOpenChange,
9931 open,
9932 panelRef,
9933 runOnceAnimationsFinish,
9934 setDimensions,
9935 setMounted,
9936 setOpen,
9937 setVisible,
9938 transitionDimensionRef,
9939 visible,
9940 width
9941 });
9942 useOpenChangeComplete({
9943 open: open && transitionStatus === "idle",
9944 ref: panelRef,
9945 onComplete() {
9946 if (!open) {
9947 return;
9948 }
9949 setDimensions({
9950 height: void 0,
9951 width: void 0
9952 });
9953 }
9954 });
9955 const panelState = React49.useMemo(() => ({
9956 ...state,
9957 transitionStatus
9958 }), [state, transitionStatus]);
9959 const element = useRenderElement("div", componentProps, {
9960 state: panelState,
9961 ref: [forwardedRef, panelRef],
9962 props: [props, {
9963 style: {
9964 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `${height}px`,
9965 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `${width}px`
9966 }
9967 }, elementProps],
9968 stateAttributesMapping: collapsibleStateAttributesMapping
9969 });
9970 const shouldRender = keepMounted || hiddenUntilFound || mounted;
9971 if (!shouldRender) {
9972 return null;
9973 }
9974 return element;
9975 });
9976 if (true) CollapsiblePanel.displayName = "CollapsiblePanel";
9977
9978 // node_modules/@base-ui/react/esm/toolbar/root/ToolbarRootContext.js
9979 var React50 = __toESM(require_react(), 1);
9980 var ToolbarRootContext = /* @__PURE__ */ React50.createContext(void 0);
9981 if (true) ToolbarRootContext.displayName = "ToolbarRootContext";
9982 function useToolbarRootContext(optional) {
9983 const context = React50.useContext(ToolbarRootContext);
9984 if (context === void 0 && !optional) {
9985 throw new Error(true ? "Base UI: ToolbarRootContext is missing. Toolbar parts must be placed within <Toolbar.Root>." : formatErrorMessage_default(69));
9986 }
9987 return context;
9988 }
9989
9990 // node_modules/@base-ui/react/esm/utils/popups/useTriggerFocusGuards.js
9991 var React51 = __toESM(require_react(), 1);
9992 var ReactDOM5 = __toESM(require_react_dom(), 1);
9993 function useTriggerFocusGuards(store, triggerElementRef) {
9994 const preFocusGuardRef = React51.useRef(null);
9995 const handlePreFocusGuardFocus = useStableCallback((event) => {
9996 ReactDOM5.flushSync(() => {
9997 store.setOpen(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent, event.currentTarget));
9998 });
9999 const previousTabbable = getTabbableBeforeElement(preFocusGuardRef.current);
10000 previousTabbable?.focus();
10001 });
10002 const handleFocusTargetFocus = useStableCallback((event) => {
10003 const positionerElement = store.select("positionerElement");
10004 if (positionerElement && isOutsideEvent(event, positionerElement)) {
10005 store.context.beforeContentFocusGuardRef.current?.focus();
10006 } else {
10007 ReactDOM5.flushSync(() => {
10008 store.setOpen(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent, event.currentTarget));
10009 });
10010 let nextTabbable = getTabbableAfterElement(store.context.triggerFocusTargetRef.current || triggerElementRef.current);
10011 while (nextTabbable !== null && contains(positionerElement, nextTabbable)) {
10012 const prevTabbable = nextTabbable;
10013 nextTabbable = getNextTabbable(nextTabbable);
10014 if (nextTabbable === prevTabbable) {
10015 break;
10016 }
10017 }
10018 nextTabbable?.focus();
10019 }
10020 });
10021 return {
10022 preFocusGuardRef,
10023 handlePreFocusGuardFocus,
10024 handleFocusTargetFocus
10025 };
10026 }
10027
10028 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
10029 var React54 = __toESM(require_react(), 1);
10030 var ReactDOM6 = __toESM(require_react_dom(), 1);
10031
10032 // node_modules/@base-ui/utils/esm/usePreviousValue.js
10033 var React52 = __toESM(require_react(), 1);
10034 function usePreviousValue(value) {
10035 const [state, setState] = React52.useState({
10036 current: value,
10037 previous: null
10038 });
10039 if (value !== state.current) {
10040 setState({
10041 current: value,
10042 previous: state.current
10043 });
10044 }
10045 return state.previous;
10046 }
10047
10048 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
10049 var React53 = __toESM(require_react(), 1);
10050
10051 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
10052 function getCssDimensions2(element) {
10053 const css = getComputedStyle2(element);
10054 let width = parseFloat(css.width) || 0;
10055 let height = parseFloat(css.height) || 0;
10056 const hasOffset = isHTMLElement(element);
10057 const offsetWidth = hasOffset ? element.offsetWidth : width;
10058 const offsetHeight = hasOffset ? element.offsetHeight : height;
10059 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
10060 if (shouldFallback) {
10061 width = offsetWidth;
10062 height = offsetHeight;
10063 }
10064 return {
10065 width,
10066 height
10067 };
10068 }
10069
10070 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
10071 var DEFAULT_ENABLED = () => true;
10072 function usePopupAutoResize(parameters) {
10073 const {
10074 popupElement,
10075 positionerElement,
10076 content,
10077 mounted,
10078 enabled = DEFAULT_ENABLED,
10079 onMeasureLayout: onMeasureLayoutParam,
10080 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
10081 side,
10082 direction
10083 } = parameters;
10084 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
10085 const animationFrame = useAnimationFrame();
10086 const committedDimensionsRef = React53.useRef(null);
10087 const liveDimensionsRef = React53.useRef(null);
10088 const isInitialRenderRef = React53.useRef(true);
10089 const restoreAnchoringStylesRef = React53.useRef(NOOP);
10090 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
10091 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
10092 const anchoringStyles = React53.useMemo(() => {
10093 let isOriginSide = side === "top";
10094 let isPhysicalLeft = side === "left";
10095 if (direction === "rtl") {
10096 isOriginSide = isOriginSide || side === "inline-end";
10097 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
10098 } else {
10099 isOriginSide = isOriginSide || side === "inline-start";
10100 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
10101 }
10102 return isOriginSide ? {
10103 position: "absolute",
10104 [side === "top" ? "bottom" : "top"]: "0",
10105 [isPhysicalLeft ? "right" : "left"]: "0"
10106 } : EMPTY_OBJECT;
10107 }, [side, direction]);
10108 useIsoLayoutEffect(() => {
10109 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
10110 restoreAnchoringStylesRef.current = NOOP;
10111 isInitialRenderRef.current = true;
10112 committedDimensionsRef.current = null;
10113 liveDimensionsRef.current = null;
10114 return void 0;
10115 }
10116 if (!popupElement || !positionerElement) {
10117 return void 0;
10118 }
10119 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
10120 const observer = new ResizeObserver((entries) => {
10121 const entry = entries[0];
10122 if (entry) {
10123 liveDimensionsRef.current = {
10124 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
10125 height: Math.ceil(entry.borderBoxSize[0].blockSize)
10126 };
10127 }
10128 });
10129 observer.observe(popupElement);
10130 setPopupCssSize(popupElement, "auto");
10131 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
10132 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
10133 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
10134 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
10135 "--available-width": "max-content",
10136 "--available-height": "max-content"
10137 });
10138 function restoreMeasurementOverrides() {
10139 restorePopupPosition();
10140 restorePopupTransform();
10141 restorePositionerAvailableSize();
10142 }
10143 function restoreMeasurementOverridesIncludingScale() {
10144 restoreMeasurementOverrides();
10145 restorePopupScale();
10146 }
10147 onMeasureLayout?.();
10148 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
10149 setPositionerCssSize(positionerElement, "max-content");
10150 const dimensions = getCssDimensions2(popupElement);
10151 committedDimensionsRef.current = dimensions;
10152 setPositionerCssSize(positionerElement, dimensions);
10153 restoreMeasurementOverridesIncludingScale();
10154 onMeasureLayoutComplete?.(null, dimensions);
10155 isInitialRenderRef.current = false;
10156 return () => {
10157 observer.disconnect();
10158 restoreAnchoringStylesRef.current();
10159 restoreAnchoringStylesRef.current = NOOP;
10160 };
10161 }
10162 setPopupCssSize(popupElement, "auto");
10163 setPositionerCssSize(positionerElement, "max-content");
10164 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
10165 const newDimensions = getCssDimensions2(popupElement);
10166 committedDimensionsRef.current = newDimensions;
10167 if (!previousDimensions) {
10168 setPositionerCssSize(positionerElement, newDimensions);
10169 restoreMeasurementOverridesIncludingScale();
10170 onMeasureLayoutComplete?.(null, newDimensions);
10171 return () => {
10172 observer.disconnect();
10173 animationFrame.cancel();
10174 restoreAnchoringStylesRef.current();
10175 restoreAnchoringStylesRef.current = NOOP;
10176 };
10177 }
10178 setPopupCssSize(popupElement, previousDimensions);
10179 restoreMeasurementOverridesIncludingScale();
10180 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
10181 setPositionerCssSize(positionerElement, newDimensions);
10182 const abortController = new AbortController();
10183 animationFrame.request(() => {
10184 setPopupCssSize(popupElement, newDimensions);
10185 runOnceAnimationsFinish(() => {
10186 popupElement.style.setProperty("--popup-width", "auto");
10187 popupElement.style.setProperty("--popup-height", "auto");
10188 }, abortController.signal);
10189 });
10190 return () => {
10191 observer.disconnect();
10192 abortController.abort();
10193 animationFrame.cancel();
10194 restoreAnchoringStylesRef.current();
10195 restoreAnchoringStylesRef.current = NOOP;
10196 };
10197 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
10198 }
10199 function overrideElementStyle(element, property, value) {
10200 const originalValue = element.style.getPropertyValue(property);
10201 element.style.setProperty(property, value);
10202 return () => {
10203 element.style.setProperty(property, originalValue);
10204 };
10205 }
10206 function applyElementStyles(element, styles) {
10207 const restorers = [];
10208 for (const [key, value] of Object.entries(styles)) {
10209 restorers.push(overrideElementStyle(element, key, value));
10210 }
10211 return restorers.length ? () => {
10212 restorers.forEach((restore) => restore());
10213 } : NOOP;
10214 }
10215 function setPopupCssSize(popupElement, size4) {
10216 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
10217 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
10218 popupElement.style.setProperty("--popup-width", width);
10219 popupElement.style.setProperty("--popup-height", height);
10220 }
10221 function setPositionerCssSize(positionerElement, size4) {
10222 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
10223 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
10224 positionerElement.style.setProperty("--positioner-width", width);
10225 positionerElement.style.setProperty("--positioner-height", height);
10226 }
10227
10228 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
10229 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
10230 function usePopupViewport(parameters) {
10231 const {
10232 store,
10233 side,
10234 cssVars,
10235 children
10236 } = parameters;
10237 const direction = useDirection();
10238 const activeTrigger = store.useState("activeTriggerElement");
10239 const activeTriggerId = store.useState("activeTriggerId");
10240 const open = store.useState("open");
10241 const payload = store.useState("payload");
10242 const mounted = store.useState("mounted");
10243 const popupElement = store.useState("popupElement");
10244 const positionerElement = store.useState("positionerElement");
10245 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
10246 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
10247 const capturedNodeRef = React54.useRef(null);
10248 const [previousContentNode, setPreviousContentNode] = React54.useState(null);
10249 const [newTriggerOffset, setNewTriggerOffset] = React54.useState(null);
10250 const currentContainerRef = React54.useRef(null);
10251 const previousContainerRef = React54.useRef(null);
10252 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
10253 const cleanupFrame = useAnimationFrame();
10254 const [previousContentDimensions, setPreviousContentDimensions] = React54.useState(null);
10255 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React54.useState(false);
10256 useIsoLayoutEffect(() => {
10257 store.set("hasViewport", true);
10258 return () => {
10259 store.set("hasViewport", false);
10260 };
10261 }, [store]);
10262 const handleMeasureLayout = useStableCallback(() => {
10263 currentContainerRef.current?.style.setProperty("animation", "none");
10264 currentContainerRef.current?.style.setProperty("transition", "none");
10265 previousContainerRef.current?.style.setProperty("display", "none");
10266 });
10267 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
10268 currentContainerRef.current?.style.removeProperty("animation");
10269 currentContainerRef.current?.style.removeProperty("transition");
10270 previousContainerRef.current?.style.removeProperty("display");
10271 if (previousDimensions) {
10272 setPreviousContentDimensions(previousDimensions);
10273 }
10274 });
10275 const lastHandledTriggerRef = React54.useRef(null);
10276 useIsoLayoutEffect(() => {
10277 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
10278 setPreviousContentNode(capturedNodeRef.current);
10279 setShowStartingStyleAttribute(true);
10280 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
10281 setNewTriggerOffset(offset4);
10282 cleanupFrame.request(() => {
10283 ReactDOM6.flushSync(() => {
10284 setShowStartingStyleAttribute(false);
10285 });
10286 onAnimationsFinished(() => {
10287 setPreviousContentNode(null);
10288 setPreviousContentDimensions(null);
10289 capturedNodeRef.current = null;
10290 });
10291 });
10292 lastHandledTriggerRef.current = activeTrigger;
10293 }
10294 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
10295 useIsoLayoutEffect(() => {
10296 const source = currentContainerRef.current;
10297 if (!source) {
10298 return;
10299 }
10300 const wrapper = ownerDocument(source).createElement("div");
10301 for (const child of Array.from(source.childNodes)) {
10302 wrapper.appendChild(child.cloneNode(true));
10303 }
10304 capturedNodeRef.current = wrapper;
10305 });
10306 const isTransitioning = previousContentNode != null;
10307 let childrenToRender;
10308 if (!isTransitioning) {
10309 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
10310 "data-current": true,
10311 ref: currentContainerRef,
10312 children
10313 }, currentContentKey);
10314 } else {
10315 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(React54.Fragment, {
10316 children: [/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
10317 "data-previous": true,
10318 inert: inertValue(true),
10319 ref: previousContainerRef,
10320 style: {
10321 ...previousContentDimensions ? {
10322 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
10323 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
10324 } : null,
10325 position: "absolute"
10326 },
10327 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
10328 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
10329 "data-current": true,
10330 ref: currentContainerRef,
10331 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
10332 children
10333 }, currentContentKey)]
10334 });
10335 }
10336 useIsoLayoutEffect(() => {
10337 const container = previousContainerRef.current;
10338 if (!container || !previousContentNode) {
10339 return;
10340 }
10341 container.replaceChildren(...Array.from(previousContentNode.childNodes));
10342 }, [previousContentNode]);
10343 usePopupAutoResize({
10344 popupElement,
10345 positionerElement,
10346 mounted,
10347 content: payload,
10348 onMeasureLayout: handleMeasureLayout,
10349 onMeasureLayoutComplete: handleMeasureLayoutComplete,
10350 side,
10351 direction
10352 });
10353 const state = {
10354 activationDirection: getActivationDirection(newTriggerOffset),
10355 transitioning: isTransitioning
10356 };
10357 return {
10358 children: childrenToRender,
10359 state
10360 };
10361 }
10362 function getActivationDirection(offset4) {
10363 if (!offset4) {
10364 return void 0;
10365 }
10366 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
10367 }
10368 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
10369 if (value > tolerance) {
10370 return positiveLabel;
10371 }
10372 if (value < -tolerance) {
10373 return negativeLabel;
10374 }
10375 return "";
10376 }
10377 function calculateRelativePosition(from, to) {
10378 const fromRect = from.getBoundingClientRect();
10379 const toRect = to.getBoundingClientRect();
10380 const fromCenter = {
10381 x: fromRect.left + fromRect.width / 2,
10382 y: fromRect.top + fromRect.height / 2
10383 };
10384 const toCenter = {
10385 x: toRect.left + toRect.width / 2,
10386 y: toRect.top + toRect.height / 2
10387 };
10388 return {
10389 horizontal: toCenter.x - fromCenter.x,
10390 vertical: toCenter.y - fromCenter.y
10391 };
10392 }
10393 function usePopupContentKey(activeTriggerId, payload) {
10394 const [contentKey, setContentKey] = React54.useState(0);
10395 const previousActiveTriggerIdRef = React54.useRef(activeTriggerId);
10396 const previousPayloadRef = React54.useRef(payload);
10397 const pendingPayloadUpdateRef = React54.useRef(false);
10398 useIsoLayoutEffect(() => {
10399 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
10400 const previousPayload = previousPayloadRef.current;
10401 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
10402 const payloadChanged = payload !== previousPayload;
10403 if (triggerIdChanged) {
10404 setContentKey((value) => value + 1);
10405 pendingPayloadUpdateRef.current = !payloadChanged;
10406 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
10407 setContentKey((value) => value + 1);
10408 pendingPayloadUpdateRef.current = false;
10409 }
10410 previousActiveTriggerIdRef.current = activeTriggerId;
10411 previousPayloadRef.current = payload;
10412 }, [activeTriggerId, payload]);
10413 return `${activeTriggerId ?? "current"}-${contentKey}`;
10414 }
10415
10416 // node_modules/@base-ui/react/esm/popover/index.parts.js
10417 var index_parts_exports2 = {};
10418 __export(index_parts_exports2, {
10419 Arrow: () => PopoverArrow,
10420 Backdrop: () => PopoverBackdrop,
10421 Close: () => PopoverClose,
10422 Description: () => PopoverDescription,
10423 Handle: () => PopoverHandle,
10424 Popup: () => PopoverPopup,
10425 Portal: () => PopoverPortal,
10426 Positioner: () => PopoverPositioner,
10427 Root: () => PopoverRoot,
10428 Title: () => PopoverTitle,
10429 Trigger: () => PopoverTrigger,
10430 Viewport: () => PopoverViewport,
10431 createHandle: () => createPopoverHandle
10432 });
10433
10434 // node_modules/@base-ui/react/esm/popover/root/PopoverRoot.js
10435 var React57 = __toESM(require_react(), 1);
10436
10437 // node_modules/@base-ui/react/esm/popover/root/PopoverRootContext.js
10438 var React55 = __toESM(require_react(), 1);
10439 var PopoverRootContext = /* @__PURE__ */ React55.createContext(void 0);
10440 if (true) PopoverRootContext.displayName = "PopoverRootContext";
10441 function usePopoverRootContext(optional) {
10442 const context = React55.useContext(PopoverRootContext);
10443 if (context === void 0 && !optional) {
10444 throw new Error(true ? "Base UI: PopoverRootContext is missing. Popover parts must be placed within <Popover.Root>." : formatErrorMessage_default(47));
10445 }
10446 return context;
10447 }
10448
10449 // node_modules/@base-ui/react/esm/popover/store/PopoverStore.js
10450 var React56 = __toESM(require_react(), 1);
10451 var ReactDOM7 = __toESM(require_react_dom(), 1);
10452 function createInitialState() {
10453 return {
10454 ...createInitialPopupStoreState(),
10455 disabled: false,
10456 modal: false,
10457 focusManagerModal: false,
10458 instantType: void 0,
10459 openMethod: null,
10460 openChangeReason: null,
10461 titleElementId: void 0,
10462 descriptionElementId: void 0,
10463 stickIfOpen: true,
10464 nested: false,
10465 openOnHover: false,
10466 closeDelay: 0,
10467 hasViewport: false
10468 };
10469 }
10470 var selectors2 = {
10471 ...popupStoreSelectors,
10472 disabled: createSelector((state) => state.disabled),
10473 instantType: createSelector((state) => state.instantType),
10474 openMethod: createSelector((state) => state.openMethod),
10475 openChangeReason: createSelector((state) => state.openChangeReason),
10476 modal: createSelector((state) => state.modal),
10477 focusManagerModal: createSelector((state) => state.focusManagerModal),
10478 stickIfOpen: createSelector((state) => state.stickIfOpen),
10479 titleElementId: createSelector((state) => state.titleElementId),
10480 descriptionElementId: createSelector((state) => state.descriptionElementId),
10481 openOnHover: createSelector((state) => state.openOnHover),
10482 closeDelay: createSelector((state) => state.closeDelay),
10483 hasViewport: createSelector((state) => state.hasViewport)
10484 };
10485 var PopoverStore = class _PopoverStore extends ReactStore {
10486 constructor(initialState) {
10487 const initial = {
10488 ...createInitialState(),
10489 ...initialState
10490 };
10491 if (initial.open && initialState?.mounted === void 0) {
10492 initial.mounted = true;
10493 }
10494 super(initial, {
10495 popupRef: /* @__PURE__ */ React56.createRef(),
10496 backdropRef: /* @__PURE__ */ React56.createRef(),
10497 internalBackdropRef: /* @__PURE__ */ React56.createRef(),
10498 onOpenChange: void 0,
10499 onOpenChangeComplete: void 0,
10500 triggerFocusTargetRef: /* @__PURE__ */ React56.createRef(),
10501 beforeContentFocusGuardRef: /* @__PURE__ */ React56.createRef(),
10502 stickIfOpenTimeout: new Timeout(),
10503 triggerElements: new PopupTriggerMap()
10504 }, selectors2);
10505 }
10506 setOpen = (nextOpen, eventDetails) => {
10507 const isHover = eventDetails.reason === reason_parts_exports.triggerHover;
10508 const isKeyboardClick = eventDetails.reason === reason_parts_exports.triggerPress && eventDetails.event.detail === 0;
10509 const isDismissClose = !nextOpen && (eventDetails.reason === reason_parts_exports.escapeKey || eventDetails.reason == null);
10510 eventDetails.preventUnmountOnClose = () => {
10511 this.set("preventUnmountingOnClose", true);
10512 };
10513 this.context.onOpenChange?.(nextOpen, eventDetails);
10514 if (eventDetails.isCanceled) {
10515 return;
10516 }
10517 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
10518 const changeState = () => {
10519 const updatedState = {
10520 open: nextOpen,
10521 openChangeReason: eventDetails.reason
10522 };
10523 const newTriggerId = eventDetails.trigger?.id ?? null;
10524 if (newTriggerId || nextOpen) {
10525 updatedState.activeTriggerId = newTriggerId;
10526 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
10527 }
10528 this.update(updatedState);
10529 };
10530 if (isHover) {
10531 this.set("stickIfOpen", true);
10532 this.context.stickIfOpenTimeout.start(PATIENT_CLICK_THRESHOLD, () => {
10533 this.set("stickIfOpen", false);
10534 });
10535 ReactDOM7.flushSync(changeState);
10536 } else {
10537 changeState();
10538 }
10539 if (isKeyboardClick || isDismissClose) {
10540 this.set("instantType", isKeyboardClick ? "click" : "dismiss");
10541 } else if (eventDetails.reason === reason_parts_exports.focusOut) {
10542 this.set("instantType", "focus");
10543 } else {
10544 this.set("instantType", void 0);
10545 }
10546 };
10547 static useStore(externalStore, initialState) {
10548 const internalStore = useRefWithInit(() => {
10549 return new _PopoverStore(initialState);
10550 }).current;
10551 const store = externalStore ?? internalStore;
10552 useOnMount(internalStore.disposeEffect);
10553 return store;
10554 }
10555 disposeEffect = () => {
10556 return this.context.stickIfOpenTimeout.disposeEffect();
10557 };
10558 };
10559
10560 // node_modules/@base-ui/react/esm/popover/root/PopoverRoot.js
10561 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
10562 function PopoverRootComponent({
10563 props
10564 }) {
10565 const {
10566 children,
10567 open: openProp,
10568 defaultOpen = false,
10569 onOpenChange,
10570 onOpenChangeComplete,
10571 modal = false,
10572 handle,
10573 triggerId: triggerIdProp,
10574 defaultTriggerId: defaultTriggerIdProp = null
10575 } = props;
10576 const store = PopoverStore.useStore(handle?.store, {
10577 modal,
10578 open: defaultOpen,
10579 openProp,
10580 activeTriggerId: defaultTriggerIdProp,
10581 triggerIdProp
10582 });
10583 useOnFirstRender(() => {
10584 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
10585 store.update({
10586 open: true,
10587 activeTriggerId: defaultTriggerIdProp
10588 });
10589 }
10590 });
10591 store.useControlledProp("openProp", openProp);
10592 store.useControlledProp("triggerIdProp", triggerIdProp);
10593 const open = store.useState("open");
10594 const payload = store.useState("payload");
10595 store.useContextCallback("onOpenChange", onOpenChange);
10596 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
10597 const {
10598 openMethod,
10599 triggerProps: interactionTypeTriggerProps
10600 } = useOpenInteractionType(open);
10601 useImplicitActiveTrigger(store);
10602 const {
10603 forceUnmount
10604 } = useOpenStateTransitions(open, store, () => {
10605 store.update({
10606 stickIfOpen: true,
10607 openChangeReason: null
10608 });
10609 });
10610 React57.useEffect(() => {
10611 if (!open) {
10612 store.context.stickIfOpenTimeout.clear();
10613 }
10614 }, [store, open]);
10615 const handleImperativeClose = React57.useCallback(() => {
10616 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
10617 }, [store]);
10618 React57.useImperativeHandle(props.actionsRef, () => ({
10619 unmount: forceUnmount,
10620 close: handleImperativeClose
10621 }), [forceUnmount, handleImperativeClose]);
10622 const floatingRootContext = useSyncedFloatingRootContext({
10623 popupStore: store,
10624 onOpenChange: store.setOpen
10625 });
10626 const dismiss = useDismiss(floatingRootContext, {
10627 outsidePressEvent: {
10628 // Ensure `aria-hidden` on outside elements is removed immediately
10629 // on outside press when trapping focus.
10630 mouse: modal === "trap-focus" ? "sloppy" : "intentional",
10631 touch: "sloppy"
10632 }
10633 });
10634 const role = useRole(floatingRootContext);
10635 const {
10636 getReferenceProps,
10637 getFloatingProps,
10638 getTriggerProps
10639 } = useInteractions([dismiss, role]);
10640 const activeTriggerProps = React57.useMemo(() => {
10641 return getReferenceProps(interactionTypeTriggerProps);
10642 }, [getReferenceProps, interactionTypeTriggerProps]);
10643 const inactiveTriggerProps = React57.useMemo(() => {
10644 return getTriggerProps(interactionTypeTriggerProps);
10645 }, [getTriggerProps, interactionTypeTriggerProps]);
10646 const popupProps = React57.useMemo(() => {
10647 return getFloatingProps();
10648 }, [getFloatingProps]);
10649 store.useSyncedValues({
10650 modal,
10651 openMethod,
10652 activeTriggerProps,
10653 inactiveTriggerProps,
10654 popupProps,
10655 floatingRootContext,
10656 nested: useFloatingParentNodeId() != null
10657 });
10658 const popoverContext = React57.useMemo(() => ({
10659 store
10660 }), [store]);
10661 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverRootContext.Provider, {
10662 value: popoverContext,
10663 children: typeof children === "function" ? children({
10664 payload
10665 }) : children
10666 });
10667 }
10668 function PopoverRoot(props) {
10669 if (usePopoverRootContext(true)) {
10670 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverRootComponent, {
10671 props
10672 });
10673 }
10674 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloatingTree, {
10675 children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverRootComponent, {
10676 props
10677 })
10678 });
10679 }
10680
10681 // node_modules/@base-ui/react/esm/popover/trigger/PopoverTrigger.js
10682 var React58 = __toESM(require_react(), 1);
10683
10684 // node_modules/@base-ui/react/esm/popover/utils/constants.js
10685 var OPEN_DELAY = 300;
10686
10687 // node_modules/@base-ui/react/esm/popover/trigger/PopoverTrigger.js
10688 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
10689 var PopoverTrigger = /* @__PURE__ */ React58.forwardRef(function PopoverTrigger2(componentProps, forwardedRef) {
10690 const {
10691 render: render4,
10692 className,
10693 disabled: disabled2 = false,
10694 nativeButton = true,
10695 handle,
10696 payload,
10697 openOnHover = false,
10698 delay = OPEN_DELAY,
10699 closeDelay = 0,
10700 id: idProp,
10701 style,
10702 ...elementProps
10703 } = componentProps;
10704 const rootContext = usePopoverRootContext(true);
10705 const store = handle?.store ?? rootContext?.store;
10706 if (!store) {
10707 throw new Error(true ? "Base UI: <Popover.Trigger> must be either used within a <Popover.Root> component or provided with a handle." : formatErrorMessage_default(74));
10708 }
10709 const thisTriggerId = useBaseUiId(idProp);
10710 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
10711 const floatingContext = store.useState("floatingRootContext");
10712 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
10713 const triggerElementRef = React58.useRef(null);
10714 const {
10715 registerTrigger,
10716 isMountedByThisTrigger
10717 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
10718 payload,
10719 disabled: disabled2,
10720 openOnHover,
10721 closeDelay
10722 });
10723 const openReason = store.useState("openChangeReason");
10724 const stickIfOpen = store.useState("stickIfOpen");
10725 const openMethod = store.useState("openMethod");
10726 const focusManagerModal = store.useState("focusManagerModal");
10727 const hoverProps = useHoverReferenceInteraction(floatingContext, {
10728 enabled: floatingContext != null && openOnHover && (openMethod !== "touch" || openReason !== reason_parts_exports.triggerPress),
10729 mouseOnly: true,
10730 move: false,
10731 handleClose: safePolygon(),
10732 restMs: delay,
10733 delay: {
10734 close: closeDelay
10735 },
10736 triggerElementRef,
10737 isActiveTrigger: isTriggerActive,
10738 isClosing: () => store.select("transitionStatus") === "ending"
10739 });
10740 const click = useClick(floatingContext, {
10741 enabled: floatingContext != null,
10742 stickIfOpen
10743 });
10744 const localProps = useInteractions([click]);
10745 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
10746 const state = {
10747 disabled: disabled2,
10748 open: isOpenedByThisTrigger
10749 };
10750 const {
10751 getButtonProps,
10752 buttonRef
10753 } = useButton({
10754 disabled: disabled2,
10755 native: nativeButton
10756 });
10757 const stateAttributesMapping7 = React58.useMemo(() => ({
10758 open(value) {
10759 if (value && openReason === reason_parts_exports.triggerPress) {
10760 return pressableTriggerOpenStateMapping.open(value);
10761 }
10762 return triggerOpenStateMapping2.open(value);
10763 }
10764 }), [openReason]);
10765 const element = useRenderElement("button", componentProps, {
10766 state,
10767 ref: [buttonRef, forwardedRef, registerTrigger, triggerElementRef],
10768 props: [localProps.getReferenceProps(), hoverProps, rootTriggerProps, {
10769 [CLICK_TRIGGER_IDENTIFIER]: "",
10770 id: thisTriggerId
10771 }, elementProps, getButtonProps],
10772 stateAttributesMapping: stateAttributesMapping7
10773 });
10774 const {
10775 preFocusGuardRef,
10776 handlePreFocusGuardFocus,
10777 handleFocusTargetFocus
10778 } = useTriggerFocusGuards(store, triggerElementRef);
10779 if (isTriggerActive && !focusManagerModal) {
10780 return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(React58.Fragment, {
10781 children: [/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FocusGuard, {
10782 ref: preFocusGuardRef,
10783 onFocus: handlePreFocusGuardFocus
10784 }), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(React58.Fragment, {
10785 children: element
10786 }, thisTriggerId), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FocusGuard, {
10787 ref: store.context.triggerFocusTargetRef,
10788 onFocus: handleFocusTargetFocus
10789 })]
10790 });
10791 }
10792 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(React58.Fragment, {
10793 children: element
10794 }, thisTriggerId);
10795 });
10796 if (true) PopoverTrigger.displayName = "PopoverTrigger";
10797
10798 // node_modules/@base-ui/react/esm/popover/portal/PopoverPortal.js
10799 var React60 = __toESM(require_react(), 1);
10800
10801 // node_modules/@base-ui/react/esm/popover/portal/PopoverPortalContext.js
10802 var React59 = __toESM(require_react(), 1);
10803 var PopoverPortalContext = /* @__PURE__ */ React59.createContext(void 0);
10804 if (true) PopoverPortalContext.displayName = "PopoverPortalContext";
10805 function usePopoverPortalContext() {
10806 const value = React59.useContext(PopoverPortalContext);
10807 if (value === void 0) {
10808 throw new Error(true ? "Base UI: <Popover.Portal> is missing." : formatErrorMessage_default(45));
10809 }
10810 return value;
10811 }
10812
10813 // node_modules/@base-ui/react/esm/popover/portal/PopoverPortal.js
10814 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
10815 var PopoverPortal = /* @__PURE__ */ React60.forwardRef(function PopoverPortal2(props, forwardedRef) {
10816 const {
10817 keepMounted = false,
10818 ...portalProps
10819 } = props;
10820 const {
10821 store
10822 } = usePopoverRootContext();
10823 const mounted = store.useState("mounted");
10824 const shouldRender = mounted || keepMounted;
10825 if (!shouldRender) {
10826 return null;
10827 }
10828 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PopoverPortalContext.Provider, {
10829 value: keepMounted,
10830 children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FloatingPortal, {
10831 ref: forwardedRef,
10832 ...portalProps
10833 })
10834 });
10835 });
10836 if (true) PopoverPortal.displayName = "PopoverPortal";
10837
10838 // node_modules/@base-ui/react/esm/popover/positioner/PopoverPositioner.js
10839 var React62 = __toESM(require_react(), 1);
10840
10841 // node_modules/@base-ui/react/esm/popover/positioner/PopoverPositionerContext.js
10842 var React61 = __toESM(require_react(), 1);
10843 var PopoverPositionerContext = /* @__PURE__ */ React61.createContext(void 0);
10844 if (true) PopoverPositionerContext.displayName = "PopoverPositionerContext";
10845 function usePopoverPositionerContext() {
10846 const context = React61.useContext(PopoverPositionerContext);
10847 if (!context) {
10848 throw new Error(true ? "Base UI: PopoverPositionerContext is missing. PopoverPositioner parts must be placed within <Popover.Positioner>." : formatErrorMessage_default(46));
10849 }
10850 return context;
10851 }
10852
10853 // node_modules/@base-ui/react/esm/popover/positioner/PopoverPositioner.js
10854 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
10855 var PopoverPositioner = /* @__PURE__ */ React62.forwardRef(function PopoverPositioner2(componentProps, forwardedRef) {
10856 const {
10857 render: render4,
10858 className,
10859 anchor,
10860 positionMethod = "absolute",
10861 side = "bottom",
10862 align = "center",
10863 sideOffset = 0,
10864 alignOffset = 0,
10865 collisionBoundary = "clipping-ancestors",
10866 collisionPadding = 5,
10867 arrowPadding = 5,
10868 sticky = false,
10869 disableAnchorTracking = false,
10870 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
10871 style,
10872 ...elementProps
10873 } = componentProps;
10874 const {
10875 store
10876 } = usePopoverRootContext();
10877 const keepMounted = usePopoverPortalContext();
10878 const nodeId = useFloatingNodeId();
10879 const floatingRootContext = store.useState("floatingRootContext");
10880 const mounted = store.useState("mounted");
10881 const open = store.useState("open");
10882 const openReason = store.useState("openChangeReason");
10883 const triggerElement = store.useState("activeTriggerElement");
10884 const modal = store.useState("modal");
10885 const openMethod = store.useState("openMethod");
10886 const positionerElement = store.useState("positionerElement");
10887 const instantType = store.useState("instantType");
10888 const transitionStatus = store.useState("transitionStatus");
10889 const hasViewport = store.useState("hasViewport");
10890 const prevTriggerElementRef = React62.useRef(null);
10891 const runOnceAnimationsFinish = useAnimationsFinished(positionerElement, false, false);
10892 const positioning = useAnchorPositioning({
10893 anchor,
10894 floatingRootContext,
10895 positionMethod,
10896 mounted,
10897 side,
10898 sideOffset,
10899 align,
10900 alignOffset,
10901 arrowPadding,
10902 collisionBoundary,
10903 collisionPadding,
10904 sticky,
10905 disableAnchorTracking,
10906 keepMounted,
10907 nodeId,
10908 collisionAvoidance,
10909 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
10910 });
10911 const domReference = floatingRootContext.useState("domReferenceElement");
10912 useIsoLayoutEffect(() => {
10913 const currentTriggerElement = domReference;
10914 const prevTriggerElement = prevTriggerElementRef.current;
10915 if (currentTriggerElement) {
10916 prevTriggerElementRef.current = currentTriggerElement;
10917 }
10918 if (prevTriggerElement && currentTriggerElement && currentTriggerElement !== prevTriggerElement) {
10919 store.set("instantType", void 0);
10920 const ac = new AbortController();
10921 runOnceAnimationsFinish(() => {
10922 store.set("instantType", "trigger-change");
10923 }, ac.signal);
10924 return () => {
10925 ac.abort();
10926 };
10927 }
10928 return void 0;
10929 }, [domReference, runOnceAnimationsFinish, store]);
10930 const state = {
10931 open,
10932 side: positioning.side,
10933 align: positioning.align,
10934 anchorHidden: positioning.anchorHidden,
10935 instant: instantType
10936 };
10937 useAnchoredPopupScrollLock(open && modal === true && openReason !== reason_parts_exports.triggerHover, openMethod === "touch", positionerElement, triggerElement);
10938 const setPositionerElement = React62.useCallback((element2) => {
10939 store.set("positionerElement", element2);
10940 }, [store]);
10941 const element = usePositioner(componentProps, state, {
10942 styles: positioning.positionerStyles,
10943 transitionStatus,
10944 props: elementProps,
10945 refs: [forwardedRef, setPositionerElement],
10946 hidden: !mounted,
10947 inert: !open
10948 });
10949 return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(PopoverPositionerContext.Provider, {
10950 value: positioning,
10951 children: [mounted && modal === true && openReason !== reason_parts_exports.triggerHover && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(InternalBackdrop, {
10952 ref: store.context.internalBackdropRef,
10953 inert: inertValue(!open),
10954 cutout: triggerElement
10955 }), /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FloatingNode, {
10956 id: nodeId,
10957 children: element
10958 })]
10959 });
10960 });
10961 if (true) PopoverPositioner.displayName = "PopoverPositioner";
10962
10963 // node_modules/@base-ui/react/esm/popover/popup/PopoverPopup.js
10964 var React64 = __toESM(require_react(), 1);
10965
10966 // node_modules/@base-ui/react/esm/utils/closePart.js
10967 var React63 = __toESM(require_react(), 1);
10968 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
10969 var ClosePartContext = /* @__PURE__ */ React63.createContext(void 0);
10970 if (true) ClosePartContext.displayName = "ClosePartContext";
10971 function useClosePartCount() {
10972 const [closePartCount, setClosePartCount] = React63.useState(0);
10973 const register2 = useStableCallback(() => {
10974 setClosePartCount((count) => count + 1);
10975 return () => {
10976 setClosePartCount((count) => Math.max(0, count - 1));
10977 };
10978 });
10979 const context = React63.useMemo(() => ({
10980 register: register2
10981 }), [register2]);
10982 return {
10983 context,
10984 hasClosePart: closePartCount > 0
10985 };
10986 }
10987 function ClosePartProvider(props) {
10988 const {
10989 value,
10990 children
10991 } = props;
10992 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ClosePartContext.Provider, {
10993 value,
10994 children
10995 });
10996 }
10997 function useClosePartRegistration() {
10998 const context = React63.useContext(ClosePartContext);
10999 useIsoLayoutEffect(() => {
11000 return context?.register();
11001 }, [context]);
11002 }
11003
11004 // node_modules/@base-ui/react/esm/popover/popup/PopoverPopup.js
11005 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
11006 var stateAttributesMapping2 = {
11007 ...popupStateMapping,
11008 ...transitionStatusMapping
11009 };
11010 var PopoverPopup = /* @__PURE__ */ React64.forwardRef(function PopoverPopup2(componentProps, forwardedRef) {
11011 const {
11012 className,
11013 render: render4,
11014 initialFocus,
11015 finalFocus,
11016 style,
11017 ...elementProps
11018 } = componentProps;
11019 const {
11020 store
11021 } = usePopoverRootContext();
11022 const positioner = usePopoverPositionerContext();
11023 const insideToolbar = useToolbarRootContext(true) != null;
11024 const {
11025 context: closePartContext,
11026 hasClosePart
11027 } = useClosePartCount();
11028 const open = store.useState("open");
11029 const openMethod = store.useState("openMethod");
11030 const instantType = store.useState("instantType");
11031 const transitionStatus = store.useState("transitionStatus");
11032 const popupProps = store.useState("popupProps");
11033 const titleId = store.useState("titleElementId");
11034 const descriptionId = store.useState("descriptionElementId");
11035 const modal = store.useState("modal");
11036 const mounted = store.useState("mounted");
11037 const openReason = store.useState("openChangeReason");
11038 const activeTriggerElement = store.useState("activeTriggerElement");
11039 const floatingContext = store.useState("floatingRootContext");
11040 useOpenChangeComplete({
11041 open,
11042 ref: store.context.popupRef,
11043 onComplete() {
11044 if (open) {
11045 store.context.onOpenChangeComplete?.(true);
11046 }
11047 }
11048 });
11049 const disabled2 = store.useState("disabled");
11050 const openOnHover = store.useState("openOnHover");
11051 const closeDelay = store.useState("closeDelay");
11052 useHoverFloatingInteraction(floatingContext, {
11053 enabled: openOnHover && !disabled2,
11054 closeDelay
11055 });
11056 function defaultInitialFocus(interactionType) {
11057 if (interactionType === "touch") {
11058 return store.context.popupRef.current;
11059 }
11060 return true;
11061 }
11062 const resolvedInitialFocus = initialFocus === void 0 ? defaultInitialFocus : initialFocus;
11063 const state = {
11064 open,
11065 side: positioner.side,
11066 align: positioner.align,
11067 instant: instantType,
11068 transitionStatus
11069 };
11070 const focusManagerModal = modal !== false && hasClosePart;
11071 store.useSyncedValue("focusManagerModal", focusManagerModal);
11072 const setPopupElement = React64.useCallback((element2) => {
11073 store.set("popupElement", element2);
11074 }, [store]);
11075 const element = useRenderElement("div", componentProps, {
11076 state,
11077 ref: [forwardedRef, store.context.popupRef, setPopupElement],
11078 props: [popupProps, {
11079 "aria-labelledby": titleId,
11080 "aria-describedby": descriptionId,
11081 onKeyDown(event) {
11082 if (insideToolbar && COMPOSITE_KEYS.has(event.key)) {
11083 event.stopPropagation();
11084 }
11085 }
11086 }, getDisabledMountTransitionStyles(transitionStatus), elementProps],
11087 stateAttributesMapping: stateAttributesMapping2
11088 });
11089 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FloatingFocusManager, {
11090 context: floatingContext,
11091 openInteractionType: openMethod,
11092 modal: focusManagerModal,
11093 disabled: !mounted || openReason === reason_parts_exports.triggerHover,
11094 initialFocus: resolvedInitialFocus,
11095 returnFocus: finalFocus,
11096 restoreFocus: "popup",
11097 previousFocusableElement: isHTMLElement(activeTriggerElement) ? activeTriggerElement : void 0,
11098 nextFocusableElement: store.context.triggerFocusTargetRef,
11099 beforeContentFocusGuardRef: store.context.beforeContentFocusGuardRef,
11100 children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ClosePartProvider, {
11101 value: closePartContext,
11102 children: element
11103 })
11104 });
11105 });
11106 if (true) PopoverPopup.displayName = "PopoverPopup";
11107
11108 // node_modules/@base-ui/react/esm/popover/arrow/PopoverArrow.js
11109 var React65 = __toESM(require_react(), 1);
11110 var PopoverArrow = /* @__PURE__ */ React65.forwardRef(function PopoverArrow2(componentProps, forwardedRef) {
11111 const {
11112 className,
11113 render: render4,
11114 style,
11115 ...elementProps
11116 } = componentProps;
11117 const {
11118 store
11119 } = usePopoverRootContext();
11120 const open = store.useState("open");
11121 const {
11122 arrowRef,
11123 side,
11124 align,
11125 arrowUncentered,
11126 arrowStyles
11127 } = usePopoverPositionerContext();
11128 const state = {
11129 open,
11130 side,
11131 align,
11132 uncentered: arrowUncentered
11133 };
11134 const element = useRenderElement("div", componentProps, {
11135 state,
11136 ref: [forwardedRef, arrowRef],
11137 props: [{
11138 style: arrowStyles,
11139 "aria-hidden": true
11140 }, elementProps],
11141 stateAttributesMapping: popupStateMapping
11142 });
11143 return element;
11144 });
11145 if (true) PopoverArrow.displayName = "PopoverArrow";
11146
11147 // node_modules/@base-ui/react/esm/popover/backdrop/PopoverBackdrop.js
11148 var React66 = __toESM(require_react(), 1);
11149 var stateAttributesMapping3 = {
11150 ...popupStateMapping,
11151 ...transitionStatusMapping
11152 };
11153 var PopoverBackdrop = /* @__PURE__ */ React66.forwardRef(function PopoverBackdrop2(props, forwardedRef) {
11154 const {
11155 className,
11156 render: render4,
11157 style,
11158 ...elementProps
11159 } = props;
11160 const {
11161 store
11162 } = usePopoverRootContext();
11163 const open = store.useState("open");
11164 const mounted = store.useState("mounted");
11165 const transitionStatus = store.useState("transitionStatus");
11166 const openReason = store.useState("openChangeReason");
11167 const state = {
11168 open,
11169 transitionStatus
11170 };
11171 const element = useRenderElement("div", props, {
11172 state,
11173 ref: [store.context.backdropRef, forwardedRef],
11174 props: [{
11175 role: "presentation",
11176 hidden: !mounted,
11177 style: {
11178 pointerEvents: openReason === reason_parts_exports.triggerHover ? "none" : void 0,
11179 userSelect: "none",
11180 WebkitUserSelect: "none"
11181 }
11182 }, elementProps],
11183 stateAttributesMapping: stateAttributesMapping3
11184 });
11185 return element;
11186 });
11187 if (true) PopoverBackdrop.displayName = "PopoverBackdrop";
11188
11189 // node_modules/@base-ui/react/esm/popover/title/PopoverTitle.js
11190 var React67 = __toESM(require_react(), 1);
11191 var PopoverTitle = /* @__PURE__ */ React67.forwardRef(function PopoverTitle2(componentProps, forwardedRef) {
11192 const {
11193 render: render4,
11194 className,
11195 style,
11196 ...elementProps
11197 } = componentProps;
11198 const {
11199 store
11200 } = usePopoverRootContext();
11201 const id = useBaseUiId(elementProps.id);
11202 useIsoLayoutEffect(() => {
11203 store.set("titleElementId", id);
11204 return () => {
11205 store.set("titleElementId", void 0);
11206 };
11207 }, [store, id]);
11208 const element = useRenderElement("h2", componentProps, {
11209 ref: forwardedRef,
11210 props: [{
11211 id
11212 }, elementProps]
11213 });
11214 return element;
11215 });
11216 if (true) PopoverTitle.displayName = "PopoverTitle";
11217
11218 // node_modules/@base-ui/react/esm/popover/description/PopoverDescription.js
11219 var React68 = __toESM(require_react(), 1);
11220 var PopoverDescription = /* @__PURE__ */ React68.forwardRef(function PopoverDescription2(componentProps, forwardedRef) {
11221 const {
11222 render: render4,
11223 className,
11224 style,
11225 ...elementProps
11226 } = componentProps;
11227 const {
11228 store
11229 } = usePopoverRootContext();
11230 const id = useBaseUiId(elementProps.id);
11231 useIsoLayoutEffect(() => {
11232 store.set("descriptionElementId", id);
11233 return () => {
11234 store.set("descriptionElementId", void 0);
11235 };
11236 }, [store, id]);
11237 const element = useRenderElement("p", componentProps, {
11238 ref: forwardedRef,
11239 props: [{
11240 id
11241 }, elementProps]
11242 });
11243 return element;
11244 });
11245 if (true) PopoverDescription.displayName = "PopoverDescription";
11246
11247 // node_modules/@base-ui/react/esm/popover/close/PopoverClose.js
11248 var React69 = __toESM(require_react(), 1);
11249 var PopoverClose = /* @__PURE__ */ React69.forwardRef(function PopoverClose2(componentProps, forwardedRef) {
11250 const {
11251 render: render4,
11252 className,
11253 disabled: disabled2 = false,
11254 nativeButton = true,
11255 style,
11256 ...elementProps
11257 } = componentProps;
11258 const {
11259 buttonRef,
11260 getButtonProps
11261 } = useButton({
11262 disabled: disabled2,
11263 focusableWhenDisabled: false,
11264 native: nativeButton
11265 });
11266 const {
11267 store
11268 } = usePopoverRootContext();
11269 useClosePartRegistration();
11270 const element = useRenderElement("button", componentProps, {
11271 ref: [forwardedRef, buttonRef],
11272 props: [{
11273 onClick(event) {
11274 store.setOpen(false, createChangeEventDetails(reason_parts_exports.closePress, event.nativeEvent, event.currentTarget));
11275 }
11276 }, elementProps, getButtonProps]
11277 });
11278 return element;
11279 });
11280 if (true) PopoverClose.displayName = "PopoverClose";
11281
11282 // node_modules/@base-ui/react/esm/popover/viewport/PopoverViewport.js
11283 var React70 = __toESM(require_react(), 1);
11284
11285 // node_modules/@base-ui/react/esm/popover/viewport/PopoverViewportCssVars.js
11286 var PopoverViewportCssVars = /* @__PURE__ */ (function(PopoverViewportCssVars2) {
11287 PopoverViewportCssVars2["popupWidth"] = "--popup-width";
11288 PopoverViewportCssVars2["popupHeight"] = "--popup-height";
11289 return PopoverViewportCssVars2;
11290 })({});
11291
11292 // node_modules/@base-ui/react/esm/popover/viewport/PopoverViewport.js
11293 var stateAttributesMapping4 = {
11294 activationDirection: (value) => value ? {
11295 "data-activation-direction": value
11296 } : null
11297 };
11298 var PopoverViewport = /* @__PURE__ */ React70.forwardRef(function PopoverViewport2(componentProps, forwardedRef) {
11299 const {
11300 render: render4,
11301 className,
11302 style,
11303 children,
11304 ...elementProps
11305 } = componentProps;
11306 const {
11307 store
11308 } = usePopoverRootContext();
11309 const {
11310 side
11311 } = usePopoverPositionerContext();
11312 const instantType = store.useState("instantType");
11313 const {
11314 children: childrenToRender,
11315 state: viewportState
11316 } = usePopupViewport({
11317 store,
11318 side,
11319 cssVars: PopoverViewportCssVars,
11320 children
11321 });
11322 const state = {
11323 activationDirection: viewportState.activationDirection,
11324 transitioning: viewportState.transitioning,
11325 instant: instantType
11326 };
11327 return useRenderElement("div", componentProps, {
11328 state,
11329 ref: forwardedRef,
11330 props: [elementProps, {
11331 children: childrenToRender
11332 }],
11333 stateAttributesMapping: stateAttributesMapping4
11334 });
11335 });
11336 if (true) PopoverViewport.displayName = "PopoverViewport";
11337
11338 // node_modules/@base-ui/react/esm/popover/store/PopoverHandle.js
11339 var PopoverHandle = class {
11340 /**
11341 * Internal store holding the popover's state.
11342 * @internal
11343 */
11344 constructor() {
11345 this.store = new PopoverStore();
11346 }
11347 /**
11348 * Opens the popover and associates it with the trigger with the given id.
11349 * The trigger must be a Popover.Trigger component with this handle passed as a prop.
11350 *
11351 * @param triggerId ID of the trigger to associate with the popover.
11352 */
11353 open(triggerId) {
11354 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) ?? void 0 : void 0;
11355 if (triggerId && !triggerElement) {
11356 throw new Error(true ? `Base UI: PopoverHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(80, triggerId));
11357 }
11358 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
11359 }
11360 /**
11361 * Closes the popover.
11362 */
11363 close() {
11364 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
11365 }
11366 /**
11367 * Indicates whether the popover is currently open.
11368 */
11369 get isOpen() {
11370 return this.store.state.open;
11371 }
11372 };
11373 function createPopoverHandle() {
11374 return new PopoverHandle();
11375 }
11376
11377 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
11378 var React71 = __toESM(require_react(), 1);
11379 var ReactDOM8 = __toESM(require_react_dom(), 1);
11380 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
11381 var FloatingPortalLite = /* @__PURE__ */ React71.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
11382 const {
11383 children,
11384 container,
11385 className,
11386 render: render4,
11387 style,
11388 ...elementProps
11389 } = componentProps;
11390 const {
11391 portalNode,
11392 portalSubtree
11393 } = useFloatingPortalNode({
11394 container,
11395 ref: forwardedRef,
11396 componentProps,
11397 elementProps
11398 });
11399 if (!portalSubtree && !portalNode) {
11400 return null;
11401 }
11402 return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(React71.Fragment, {
11403 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM8.createPortal(children, portalNode)]
11404 });
11405 });
11406 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
11407
11408 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
11409 var index_parts_exports3 = {};
11410 __export(index_parts_exports3, {
11411 Arrow: () => TooltipArrow,
11412 Handle: () => TooltipHandle,
11413 Popup: () => TooltipPopup,
11414 Portal: () => TooltipPortal,
11415 Positioner: () => TooltipPositioner,
11416 Provider: () => TooltipProvider,
11417 Root: () => TooltipRoot,
11418 Trigger: () => TooltipTrigger,
11419 Viewport: () => TooltipViewport,
11420 createHandle: () => createTooltipHandle
11421 });
11422
11423 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
11424 var React74 = __toESM(require_react(), 1);
11425
11426 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
11427 var React72 = __toESM(require_react(), 1);
11428 var TooltipRootContext = /* @__PURE__ */ React72.createContext(void 0);
11429 if (true) TooltipRootContext.displayName = "TooltipRootContext";
11430 function useTooltipRootContext(optional) {
11431 const context = React72.useContext(TooltipRootContext);
11432 if (context === void 0 && !optional) {
11433 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
11434 }
11435 return context;
11436 }
11437
11438 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
11439 var React73 = __toESM(require_react(), 1);
11440 var ReactDOM9 = __toESM(require_react_dom(), 1);
11441 var selectors3 = {
11442 ...popupStoreSelectors,
11443 disabled: createSelector((state) => state.disabled),
11444 instantType: createSelector((state) => state.instantType),
11445 isInstantPhase: createSelector((state) => state.isInstantPhase),
11446 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
11447 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
11448 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
11449 closeOnClick: createSelector((state) => state.closeOnClick),
11450 closeDelay: createSelector((state) => state.closeDelay),
11451 hasViewport: createSelector((state) => state.hasViewport)
11452 };
11453 var TooltipStore = class _TooltipStore extends ReactStore {
11454 constructor(initialState) {
11455 super({
11456 ...createInitialState2(),
11457 ...initialState
11458 }, {
11459 popupRef: /* @__PURE__ */ React73.createRef(),
11460 onOpenChange: void 0,
11461 onOpenChangeComplete: void 0,
11462 triggerElements: new PopupTriggerMap()
11463 }, selectors3);
11464 }
11465 setOpen = (nextOpen, eventDetails) => {
11466 const reason = eventDetails.reason;
11467 const isHover = reason === reason_parts_exports.triggerHover;
11468 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
11469 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
11470 eventDetails.preventUnmountOnClose = () => {
11471 this.set("preventUnmountingOnClose", true);
11472 };
11473 this.context.onOpenChange?.(nextOpen, eventDetails);
11474 if (eventDetails.isCanceled) {
11475 return;
11476 }
11477 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
11478 const changeState = () => {
11479 const updatedState = {
11480 open: nextOpen,
11481 openChangeReason: reason
11482 };
11483 if (isFocusOpen) {
11484 updatedState.instantType = "focus";
11485 } else if (isDismissClose) {
11486 updatedState.instantType = "dismiss";
11487 } else if (reason === reason_parts_exports.triggerHover) {
11488 updatedState.instantType = void 0;
11489 }
11490 const newTriggerId = eventDetails.trigger?.id ?? null;
11491 if (newTriggerId || nextOpen) {
11492 updatedState.activeTriggerId = newTriggerId;
11493 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
11494 }
11495 this.update(updatedState);
11496 };
11497 if (isHover) {
11498 ReactDOM9.flushSync(changeState);
11499 } else {
11500 changeState();
11501 }
11502 };
11503 static useStore(externalStore, initialState) {
11504 const internalStore = useRefWithInit(() => {
11505 return new _TooltipStore(initialState);
11506 }).current;
11507 const store = externalStore ?? internalStore;
11508 const floatingRootContext = useSyncedFloatingRootContext({
11509 popupStore: store,
11510 onOpenChange: store.setOpen
11511 });
11512 store.state.floatingRootContext = floatingRootContext;
11513 return store;
11514 }
11515 };
11516 function createInitialState2() {
11517 return {
11518 ...createInitialPopupStoreState(),
11519 disabled: false,
11520 instantType: void 0,
11521 isInstantPhase: false,
11522 trackCursorAxis: "none",
11523 disableHoverablePopup: false,
11524 openChangeReason: null,
11525 closeOnClick: true,
11526 closeDelay: 0,
11527 hasViewport: false
11528 };
11529 }
11530
11531 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
11532 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
11533 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
11534 const {
11535 disabled: disabled2 = false,
11536 defaultOpen = false,
11537 open: openProp,
11538 disableHoverablePopup = false,
11539 trackCursorAxis = "none",
11540 actionsRef,
11541 onOpenChange,
11542 onOpenChangeComplete,
11543 handle,
11544 triggerId: triggerIdProp,
11545 defaultTriggerId: defaultTriggerIdProp = null,
11546 children
11547 } = props;
11548 const store = TooltipStore.useStore(handle?.store, {
11549 open: defaultOpen,
11550 openProp,
11551 activeTriggerId: defaultTriggerIdProp,
11552 triggerIdProp
11553 });
11554 useOnFirstRender(() => {
11555 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
11556 store.update({
11557 open: true,
11558 activeTriggerId: defaultTriggerIdProp
11559 });
11560 }
11561 });
11562 store.useControlledProp("openProp", openProp);
11563 store.useControlledProp("triggerIdProp", triggerIdProp);
11564 store.useContextCallback("onOpenChange", onOpenChange);
11565 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
11566 const openState = store.useState("open");
11567 const open = !disabled2 && openState;
11568 const activeTriggerId = store.useState("activeTriggerId");
11569 const payload = store.useState("payload");
11570 store.useSyncedValues({
11571 trackCursorAxis,
11572 disableHoverablePopup
11573 });
11574 useIsoLayoutEffect(() => {
11575 if (openState && disabled2) {
11576 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
11577 }
11578 }, [openState, disabled2, store]);
11579 store.useSyncedValue("disabled", disabled2);
11580 useImplicitActiveTrigger(store);
11581 const {
11582 forceUnmount,
11583 transitionStatus
11584 } = useOpenStateTransitions(open, store);
11585 const floatingRootContext = store.select("floatingRootContext");
11586 const isInstantPhase = store.useState("isInstantPhase");
11587 const instantType = store.useState("instantType");
11588 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
11589 const previousInstantTypeRef = React74.useRef(null);
11590 useIsoLayoutEffect(() => {
11591 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
11592 if (instantType !== "delay") {
11593 previousInstantTypeRef.current = instantType;
11594 }
11595 store.set("instantType", "delay");
11596 } else if (previousInstantTypeRef.current !== null) {
11597 store.set("instantType", previousInstantTypeRef.current);
11598 previousInstantTypeRef.current = null;
11599 }
11600 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
11601 useIsoLayoutEffect(() => {
11602 if (open) {
11603 if (activeTriggerId == null) {
11604 store.set("payload", void 0);
11605 }
11606 }
11607 }, [store, activeTriggerId, open]);
11608 const handleImperativeClose = React74.useCallback(() => {
11609 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
11610 }, [store]);
11611 React74.useImperativeHandle(actionsRef, () => ({
11612 unmount: forceUnmount,
11613 close: handleImperativeClose
11614 }), [forceUnmount, handleImperativeClose]);
11615 const dismiss = useDismiss(floatingRootContext, {
11616 enabled: !disabled2,
11617 referencePress: () => store.select("closeOnClick")
11618 });
11619 const clientPoint = useClientPoint(floatingRootContext, {
11620 enabled: !disabled2 && trackCursorAxis !== "none",
11621 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
11622 });
11623 const {
11624 getReferenceProps,
11625 getFloatingProps,
11626 getTriggerProps
11627 } = useInteractions([dismiss, clientPoint]);
11628 const activeTriggerProps = React74.useMemo(() => getReferenceProps(), [getReferenceProps]);
11629 const inactiveTriggerProps = React74.useMemo(() => getTriggerProps(), [getTriggerProps]);
11630 const popupProps = React74.useMemo(() => getFloatingProps(), [getFloatingProps]);
11631 store.useSyncedValues({
11632 activeTriggerProps,
11633 inactiveTriggerProps,
11634 popupProps
11635 });
11636 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TooltipRootContext.Provider, {
11637 value: store,
11638 children: typeof children === "function" ? children({
11639 payload
11640 }) : children
11641 });
11642 });
11643 if (true) TooltipRoot.displayName = "TooltipRoot";
11644
11645 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
11646 var React76 = __toESM(require_react(), 1);
11647
11648 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
11649 var React75 = __toESM(require_react(), 1);
11650 var TooltipProviderContext = /* @__PURE__ */ React75.createContext(void 0);
11651 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
11652 function useTooltipProviderContext() {
11653 return React75.useContext(TooltipProviderContext);
11654 }
11655
11656 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
11657 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
11658 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
11659 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
11660 return TooltipTriggerDataAttributes2;
11661 })({});
11662
11663 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
11664 var OPEN_DELAY2 = 600;
11665
11666 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
11667 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
11668 const {
11669 className,
11670 render: render4,
11671 handle,
11672 payload,
11673 disabled: disabledProp,
11674 delay,
11675 closeOnClick = true,
11676 closeDelay,
11677 id: idProp,
11678 style,
11679 ...elementProps
11680 } = componentProps;
11681 const rootContext = useTooltipRootContext(true);
11682 const store = handle?.store ?? rootContext;
11683 if (!store) {
11684 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));
11685 }
11686 const thisTriggerId = useBaseUiId(idProp);
11687 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
11688 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
11689 const floatingRootContext = store.useState("floatingRootContext");
11690 const triggerElementRef = React76.useRef(null);
11691 const delayWithDefault = delay ?? OPEN_DELAY2;
11692 const closeDelayWithDefault = closeDelay ?? 0;
11693 const {
11694 registerTrigger,
11695 isMountedByThisTrigger
11696 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
11697 payload,
11698 closeOnClick,
11699 closeDelay: closeDelayWithDefault
11700 });
11701 const providerContext = useTooltipProviderContext();
11702 const {
11703 delayRef,
11704 isInstantPhase,
11705 hasProvider
11706 } = useDelayGroup(floatingRootContext, {
11707 open: isOpenedByThisTrigger
11708 });
11709 store.useSyncedValue("isInstantPhase", isInstantPhase);
11710 const rootDisabled = store.useState("disabled");
11711 const disabled2 = disabledProp ?? rootDisabled;
11712 const trackCursorAxis = store.useState("trackCursorAxis");
11713 const disableHoverablePopup = store.useState("disableHoverablePopup");
11714 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
11715 enabled: !disabled2,
11716 mouseOnly: true,
11717 move: false,
11718 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
11719 restMs() {
11720 const providerDelay = providerContext?.delay;
11721 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
11722 let computedRestMs = delayWithDefault;
11723 if (hasProvider) {
11724 if (groupOpenValue !== 0) {
11725 computedRestMs = delay ?? providerDelay ?? delayWithDefault;
11726 } else {
11727 computedRestMs = 0;
11728 }
11729 }
11730 return computedRestMs;
11731 },
11732 delay() {
11733 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
11734 let computedCloseDelay = closeDelayWithDefault;
11735 if (closeDelay == null && hasProvider) {
11736 computedCloseDelay = closeValue;
11737 }
11738 return {
11739 close: computedCloseDelay
11740 };
11741 },
11742 triggerElementRef,
11743 isActiveTrigger: isTriggerActive,
11744 isClosing: () => store.select("transitionStatus") === "ending"
11745 });
11746 const focusProps = useFocus(floatingRootContext, {
11747 enabled: !disabled2
11748 }).reference;
11749 const state = {
11750 open: isOpenedByThisTrigger
11751 };
11752 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
11753 const element = useRenderElement("button", componentProps, {
11754 state,
11755 ref: [forwardedRef, registerTrigger, triggerElementRef],
11756 props: [hoverProps, focusProps, rootTriggerProps, {
11757 onPointerDown() {
11758 store.set("closeOnClick", closeOnClick);
11759 },
11760 id: thisTriggerId,
11761 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0
11762 }, elementProps],
11763 stateAttributesMapping: triggerOpenStateMapping2
11764 });
11765 return element;
11766 });
11767 if (true) TooltipTrigger.displayName = "TooltipTrigger";
11768
11769 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
11770 var React78 = __toESM(require_react(), 1);
11771
11772 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
11773 var React77 = __toESM(require_react(), 1);
11774 var TooltipPortalContext = /* @__PURE__ */ React77.createContext(void 0);
11775 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
11776 function useTooltipPortalContext() {
11777 const value = React77.useContext(TooltipPortalContext);
11778 if (value === void 0) {
11779 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
11780 }
11781 return value;
11782 }
11783
11784 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
11785 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
11786 var TooltipPortal = /* @__PURE__ */ React78.forwardRef(function TooltipPortal2(props, forwardedRef) {
11787 const {
11788 keepMounted = false,
11789 ...portalProps
11790 } = props;
11791 const store = useTooltipRootContext();
11792 const mounted = store.useState("mounted");
11793 const shouldRender = mounted || keepMounted;
11794 if (!shouldRender) {
11795 return null;
11796 }
11797 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TooltipPortalContext.Provider, {
11798 value: keepMounted,
11799 children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FloatingPortalLite, {
11800 ref: forwardedRef,
11801 ...portalProps
11802 })
11803 });
11804 });
11805 if (true) TooltipPortal.displayName = "TooltipPortal";
11806
11807 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
11808 var React80 = __toESM(require_react(), 1);
11809
11810 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
11811 var React79 = __toESM(require_react(), 1);
11812 var TooltipPositionerContext = /* @__PURE__ */ React79.createContext(void 0);
11813 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
11814 function useTooltipPositionerContext() {
11815 const context = React79.useContext(TooltipPositionerContext);
11816 if (context === void 0) {
11817 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
11818 }
11819 return context;
11820 }
11821
11822 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
11823 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
11824 var TooltipPositioner = /* @__PURE__ */ React80.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
11825 const {
11826 render: render4,
11827 className,
11828 anchor,
11829 positionMethod = "absolute",
11830 side = "top",
11831 align = "center",
11832 sideOffset = 0,
11833 alignOffset = 0,
11834 collisionBoundary = "clipping-ancestors",
11835 collisionPadding = 5,
11836 arrowPadding = 5,
11837 sticky = false,
11838 disableAnchorTracking = false,
11839 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
11840 style,
11841 ...elementProps
11842 } = componentProps;
11843 const store = useTooltipRootContext();
11844 const keepMounted = useTooltipPortalContext();
11845 const open = store.useState("open");
11846 const mounted = store.useState("mounted");
11847 const trackCursorAxis = store.useState("trackCursorAxis");
11848 const disableHoverablePopup = store.useState("disableHoverablePopup");
11849 const floatingRootContext = store.useState("floatingRootContext");
11850 const instantType = store.useState("instantType");
11851 const transitionStatus = store.useState("transitionStatus");
11852 const hasViewport = store.useState("hasViewport");
11853 const positioning = useAnchorPositioning({
11854 anchor,
11855 positionMethod,
11856 floatingRootContext,
11857 mounted,
11858 side,
11859 sideOffset,
11860 align,
11861 alignOffset,
11862 collisionBoundary,
11863 collisionPadding,
11864 sticky,
11865 arrowPadding,
11866 disableAnchorTracking,
11867 keepMounted,
11868 collisionAvoidance,
11869 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
11870 });
11871 const state = React80.useMemo(() => ({
11872 open,
11873 side: positioning.side,
11874 align: positioning.align,
11875 anchorHidden: positioning.anchorHidden,
11876 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
11877 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
11878 const element = usePositioner(componentProps, state, {
11879 styles: positioning.positionerStyles,
11880 transitionStatus,
11881 props: elementProps,
11882 refs: [forwardedRef, store.useStateSetter("positionerElement")],
11883 hidden: !mounted,
11884 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
11885 });
11886 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipPositionerContext.Provider, {
11887 value: positioning,
11888 children: element
11889 });
11890 });
11891 if (true) TooltipPositioner.displayName = "TooltipPositioner";
11892
11893 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
11894 var React81 = __toESM(require_react(), 1);
11895 var stateAttributesMapping5 = {
11896 ...popupStateMapping,
11897 ...transitionStatusMapping
11898 };
11899 var TooltipPopup = /* @__PURE__ */ React81.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
11900 const {
11901 className,
11902 render: render4,
11903 style,
11904 ...elementProps
11905 } = componentProps;
11906 const store = useTooltipRootContext();
11907 const {
11908 side,
11909 align
11910 } = useTooltipPositionerContext();
11911 const open = store.useState("open");
11912 const instantType = store.useState("instantType");
11913 const transitionStatus = store.useState("transitionStatus");
11914 const popupProps = store.useState("popupProps");
11915 const floatingContext = store.useState("floatingRootContext");
11916 useOpenChangeComplete({
11917 open,
11918 ref: store.context.popupRef,
11919 onComplete() {
11920 if (open) {
11921 store.context.onOpenChangeComplete?.(true);
11922 }
11923 }
11924 });
11925 const disabled2 = store.useState("disabled");
11926 const closeDelay = store.useState("closeDelay");
11927 useHoverFloatingInteraction(floatingContext, {
11928 enabled: !disabled2,
11929 closeDelay
11930 });
11931 const state = {
11932 open,
11933 side,
11934 align,
11935 instant: instantType,
11936 transitionStatus
11937 };
11938 const element = useRenderElement("div", componentProps, {
11939 state,
11940 ref: [forwardedRef, store.context.popupRef, store.useStateSetter("popupElement")],
11941 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
11942 stateAttributesMapping: stateAttributesMapping5
11943 });
11944 return element;
11945 });
11946 if (true) TooltipPopup.displayName = "TooltipPopup";
11947
11948 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
11949 var React82 = __toESM(require_react(), 1);
11950 var TooltipArrow = /* @__PURE__ */ React82.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
11951 const {
11952 className,
11953 render: render4,
11954 style,
11955 ...elementProps
11956 } = componentProps;
11957 const store = useTooltipRootContext();
11958 const open = store.useState("open");
11959 const instantType = store.useState("instantType");
11960 const {
11961 arrowRef,
11962 side,
11963 align,
11964 arrowUncentered,
11965 arrowStyles
11966 } = useTooltipPositionerContext();
11967 const state = {
11968 open,
11969 side,
11970 align,
11971 uncentered: arrowUncentered,
11972 instant: instantType
11973 };
11974 const element = useRenderElement("div", componentProps, {
11975 state,
11976 ref: [forwardedRef, arrowRef],
11977 props: [{
11978 style: arrowStyles,
11979 "aria-hidden": true
11980 }, elementProps],
11981 stateAttributesMapping: popupStateMapping
11982 });
11983 return element;
11984 });
11985 if (true) TooltipArrow.displayName = "TooltipArrow";
11986
11987 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
11988 var React83 = __toESM(require_react(), 1);
11989 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
11990 var TooltipProvider = function TooltipProvider2(props) {
11991 const {
11992 delay,
11993 closeDelay,
11994 timeout = 400
11995 } = props;
11996 const contextValue = React83.useMemo(() => ({
11997 delay,
11998 closeDelay
11999 }), [delay, closeDelay]);
12000 const delayValue = React83.useMemo(() => ({
12001 open: delay,
12002 close: closeDelay
12003 }), [delay, closeDelay]);
12004 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TooltipProviderContext.Provider, {
12005 value: contextValue,
12006 children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(FloatingDelayGroup, {
12007 delay: delayValue,
12008 timeoutMs: timeout,
12009 children: props.children
12010 })
12011 });
12012 };
12013 if (true) TooltipProvider.displayName = "TooltipProvider";
12014
12015 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
12016 var React84 = __toESM(require_react(), 1);
12017
12018 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
12019 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
12020 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
12021 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
12022 return TooltipViewportCssVars2;
12023 })({});
12024
12025 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
12026 var stateAttributesMapping6 = {
12027 activationDirection: (value) => value ? {
12028 "data-activation-direction": value
12029 } : null
12030 };
12031 var TooltipViewport = /* @__PURE__ */ React84.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
12032 const {
12033 render: render4,
12034 className,
12035 style,
12036 children,
12037 ...elementProps
12038 } = componentProps;
12039 const store = useTooltipRootContext();
12040 const positioner = useTooltipPositionerContext();
12041 const instantType = store.useState("instantType");
12042 const {
12043 children: childrenToRender,
12044 state: viewportState
12045 } = usePopupViewport({
12046 store,
12047 side: positioner.side,
12048 cssVars: TooltipViewportCssVars,
12049 children
12050 });
12051 const state = {
12052 activationDirection: viewportState.activationDirection,
12053 transitioning: viewportState.transitioning,
12054 instant: instantType
12055 };
12056 return useRenderElement("div", componentProps, {
12057 state,
12058 ref: forwardedRef,
12059 props: [elementProps, {
12060 children: childrenToRender
12061 }],
12062 stateAttributesMapping: stateAttributesMapping6
12063 });
12064 });
12065 if (true) TooltipViewport.displayName = "TooltipViewport";
12066
12067 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
12068 var TooltipHandle = class {
12069 /**
12070 * Internal store holding the tooltip state.
12071 * @internal
12072 */
12073 constructor() {
12074 this.store = new TooltipStore();
12075 }
12076 /**
12077 * Opens the tooltip and associates it with the trigger with the given ID.
12078 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
12079 *
12080 * This method should only be called in an event handler or an effect (not during rendering).
12081 *
12082 * @param triggerId ID of the trigger to associate with the tooltip.
12083 */
12084 open(triggerId) {
12085 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
12086 if (triggerId && !triggerElement) {
12087 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
12088 }
12089 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
12090 }
12091 /**
12092 * Closes the tooltip.
12093 */
12094 close() {
12095 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
12096 }
12097 /**
12098 * Indicates whether the tooltip is currently open.
12099 */
12100 get isOpen() {
12101 return this.store.state.open;
12102 }
12103 };
12104 function createTooltipHandle() {
12105 return new TooltipHandle();
12106 }
12107
12108 // node_modules/@base-ui/react/esm/use-render/useRender.js
12109 function useRender(params) {
12110 return useRenderElement(params.defaultTagName ?? "div", params, params);
12111 }
12112
12113 // packages/ui/build-module/text/text.mjs
12114 var import_element11 = __toESM(require_element(), 1);
12115 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
12116 function getRuntime() {
12117 const globalScope = globalThis;
12118 if (globalScope.__wpStyleRuntime) {
12119 return globalScope.__wpStyleRuntime;
12120 }
12121 globalScope.__wpStyleRuntime = {
12122 documents: /* @__PURE__ */ new Map(),
12123 styles: /* @__PURE__ */ new Map(),
12124 injectedStyles: /* @__PURE__ */ new WeakMap()
12125 };
12126 if (typeof document !== "undefined") {
12127 registerDocument(document);
12128 }
12129 return globalScope.__wpStyleRuntime;
12130 }
12131 function documentContainsStyleHash(targetDocument, hash) {
12132 if (!targetDocument.head) {
12133 return false;
12134 }
12135 for (const style of targetDocument.head.querySelectorAll(
12136 `style[${STYLE_HASH_ATTRIBUTE}]`
12137 )) {
12138 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
12139 return true;
12140 }
12141 }
12142 return false;
12143 }
12144 function injectStyle(targetDocument, hash, css) {
12145 if (!targetDocument.head) {
12146 return;
12147 }
12148 const runtime = getRuntime();
12149 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12150 if (!injectedStyles) {
12151 injectedStyles = /* @__PURE__ */ new Set();
12152 runtime.injectedStyles.set(targetDocument, injectedStyles);
12153 }
12154 if (injectedStyles.has(hash)) {
12155 return;
12156 }
12157 if (documentContainsStyleHash(targetDocument, hash)) {
12158 injectedStyles.add(hash);
12159 return;
12160 }
12161 const style = targetDocument.createElement("style");
12162 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
12163 style.appendChild(targetDocument.createTextNode(css));
12164 targetDocument.head.appendChild(style);
12165 injectedStyles.add(hash);
12166 }
12167 function registerDocument(targetDocument) {
12168 const runtime = getRuntime();
12169 runtime.documents.set(
12170 targetDocument,
12171 (runtime.documents.get(targetDocument) ?? 0) + 1
12172 );
12173 for (const [hash, css] of runtime.styles) {
12174 injectStyle(targetDocument, hash, css);
12175 }
12176 return () => {
12177 const count = runtime.documents.get(targetDocument);
12178 if (count === void 0) {
12179 return;
12180 }
12181 if (count <= 1) {
12182 runtime.documents.delete(targetDocument);
12183 return;
12184 }
12185 runtime.documents.set(targetDocument, count - 1);
12186 };
12187 }
12188 function registerStyle(hash, css) {
12189 const runtime = getRuntime();
12190 runtime.styles.set(hash, css);
12191 for (const targetDocument of runtime.documents.keys()) {
12192 injectStyle(targetDocument, hash, css);
12193 }
12194 }
12195 if (typeof process === "undefined" || true) {
12196 registerStyle("0c8601dd83", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}');
12197 }
12198 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" };
12199 if (typeof process === "undefined" || true) {
12200 registerStyle("1fb29d3a3c", "._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,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-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,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-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 #0000)}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-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
12201 }
12202 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" };
12203 var Text = (0, import_element11.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
12204 const element = useRender({
12205 render: render4,
12206 defaultTagName: "span",
12207 ref,
12208 props: mergeProps(props, {
12209 className: clsx_default(
12210 style_default.text,
12211 global_css_defense_default.heading,
12212 global_css_defense_default.p,
12213 style_default[variant],
12214 className
12215 )
12216 })
12217 });
12218 return element;
12219 });
12220
12221 // packages/ui/build-module/badge/badge.mjs
12222 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
12223 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
12224 function getRuntime2() {
12225 const globalScope = globalThis;
12226 if (globalScope.__wpStyleRuntime) {
12227 return globalScope.__wpStyleRuntime;
12228 }
12229 globalScope.__wpStyleRuntime = {
12230 documents: /* @__PURE__ */ new Map(),
12231 styles: /* @__PURE__ */ new Map(),
12232 injectedStyles: /* @__PURE__ */ new WeakMap()
12233 };
12234 if (typeof document !== "undefined") {
12235 registerDocument2(document);
12236 }
12237 return globalScope.__wpStyleRuntime;
12238 }
12239 function documentContainsStyleHash2(targetDocument, hash) {
12240 if (!targetDocument.head) {
12241 return false;
12242 }
12243 for (const style of targetDocument.head.querySelectorAll(
12244 `style[${STYLE_HASH_ATTRIBUTE2}]`
12245 )) {
12246 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
12247 return true;
12248 }
12249 }
12250 return false;
12251 }
12252 function injectStyle2(targetDocument, hash, css) {
12253 if (!targetDocument.head) {
12254 return;
12255 }
12256 const runtime = getRuntime2();
12257 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12258 if (!injectedStyles) {
12259 injectedStyles = /* @__PURE__ */ new Set();
12260 runtime.injectedStyles.set(targetDocument, injectedStyles);
12261 }
12262 if (injectedStyles.has(hash)) {
12263 return;
12264 }
12265 if (documentContainsStyleHash2(targetDocument, hash)) {
12266 injectedStyles.add(hash);
12267 return;
12268 }
12269 const style = targetDocument.createElement("style");
12270 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
12271 style.appendChild(targetDocument.createTextNode(css));
12272 targetDocument.head.appendChild(style);
12273 injectedStyles.add(hash);
12274 }
12275 function registerDocument2(targetDocument) {
12276 const runtime = getRuntime2();
12277 runtime.documents.set(
12278 targetDocument,
12279 (runtime.documents.get(targetDocument) ?? 0) + 1
12280 );
12281 for (const [hash, css] of runtime.styles) {
12282 injectStyle2(targetDocument, hash, css);
12283 }
12284 return () => {
12285 const count = runtime.documents.get(targetDocument);
12286 if (count === void 0) {
12287 return;
12288 }
12289 if (count <= 1) {
12290 runtime.documents.delete(targetDocument);
12291 return;
12292 }
12293 runtime.documents.set(targetDocument, count - 1);
12294 };
12295 }
12296 function registerStyle2(hash, css) {
12297 const runtime = getRuntime2();
12298 runtime.styles.set(hash, css);
12299 for (const targetDocument of runtime.documents.keys()) {
12300 injectStyle2(targetDocument, hash, css);
12301 }
12302 }
12303 if (typeof process === "undefined" || true) {
12304 registerStyle2("d6a685e1aa", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-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-bg-surface-error,#f6e6e3);color:var(--wpds-color-fg-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-bg-surface-warning,#fde6be);color:var(--wpds-color-fg-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-bg-surface-caution,#fee995);color:var(--wpds-color-fg-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-bg-surface-success,#c6f7cd);color:var(--wpds-color-fg-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-bg-surface-info,#deebfa);color:var(--wpds-color-fg-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-fg-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))}}");
12305 }
12306 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" };
12307 var Badge = (0, import_element12.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) {
12308 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
12309 Text,
12310 {
12311 ref,
12312 className: clsx_default(
12313 style_default2.badge,
12314 style_default2[`is-${intent}-intent`],
12315 className
12316 ),
12317 ...props,
12318 variant: "body-sm"
12319 }
12320 );
12321 });
12322
12323 // packages/ui/build-module/button/button.mjs
12324 var import_element13 = __toESM(require_element(), 1);
12325 var import_i18n = __toESM(require_i18n(), 1);
12326 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
12327 import { speak } from "@wordpress/a11y";
12328 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
12329 function getRuntime3() {
12330 const globalScope = globalThis;
12331 if (globalScope.__wpStyleRuntime) {
12332 return globalScope.__wpStyleRuntime;
12333 }
12334 globalScope.__wpStyleRuntime = {
12335 documents: /* @__PURE__ */ new Map(),
12336 styles: /* @__PURE__ */ new Map(),
12337 injectedStyles: /* @__PURE__ */ new WeakMap()
12338 };
12339 if (typeof document !== "undefined") {
12340 registerDocument3(document);
12341 }
12342 return globalScope.__wpStyleRuntime;
12343 }
12344 function documentContainsStyleHash3(targetDocument, hash) {
12345 if (!targetDocument.head) {
12346 return false;
12347 }
12348 for (const style of targetDocument.head.querySelectorAll(
12349 `style[${STYLE_HASH_ATTRIBUTE3}]`
12350 )) {
12351 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
12352 return true;
12353 }
12354 }
12355 return false;
12356 }
12357 function injectStyle3(targetDocument, hash, css) {
12358 if (!targetDocument.head) {
12359 return;
12360 }
12361 const runtime = getRuntime3();
12362 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12363 if (!injectedStyles) {
12364 injectedStyles = /* @__PURE__ */ new Set();
12365 runtime.injectedStyles.set(targetDocument, injectedStyles);
12366 }
12367 if (injectedStyles.has(hash)) {
12368 return;
12369 }
12370 if (documentContainsStyleHash3(targetDocument, hash)) {
12371 injectedStyles.add(hash);
12372 return;
12373 }
12374 const style = targetDocument.createElement("style");
12375 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
12376 style.appendChild(targetDocument.createTextNode(css));
12377 targetDocument.head.appendChild(style);
12378 injectedStyles.add(hash);
12379 }
12380 function registerDocument3(targetDocument) {
12381 const runtime = getRuntime3();
12382 runtime.documents.set(
12383 targetDocument,
12384 (runtime.documents.get(targetDocument) ?? 0) + 1
12385 );
12386 for (const [hash, css] of runtime.styles) {
12387 injectStyle3(targetDocument, hash, css);
12388 }
12389 return () => {
12390 const count = runtime.documents.get(targetDocument);
12391 if (count === void 0) {
12392 return;
12393 }
12394 if (count <= 1) {
12395 runtime.documents.delete(targetDocument);
12396 return;
12397 }
12398 runtime.documents.set(targetDocument, count - 1);
12399 };
12400 }
12401 function registerStyle3(hash, css) {
12402 const runtime = getRuntime3();
12403 runtime.styles.set(hash, css);
12404 for (const targetDocument of runtime.documents.keys()) {
12405 injectStyle3(targetDocument, hash, css);
12406 }
12407 }
12408 if (typeof process === "undefined" || true) {
12409 registerStyle3("7d54255a4c", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._97b0fc33c028be1a__button,.abbb272e2ce49bd6__is-unstyled{appearance:none;padding:0}._97b0fc33c028be1a__button{--wp-ui-button-font-weight:499;--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-strong,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-background-color-active:var(--wpds-color-bg-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-bg-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-brand-strong,#fff);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-brand-strong-active,#fff);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-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: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-border-color:var(--wp-ui-button-background-color);--wp-ui-button-border-color-active:var(--wp-ui-button-background-color-active);--wp-ui-button-border-color-disabled:var(--wp-ui-button-background-color-disabled);--_gcd-button-font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);--_gcd-button-font-size:var(--wp-ui-button-font-size);--_gcd-button-font-weight:var(--wp-ui-button-font-weight);align-items:center;aspect-ratio:var(--wp-ui-button-aspect-ratio);background-clip:padding-box;background-color:var(--wp-ui-button-background-color);border-color:var(--wp-ui-button-border-color);border-radius:var(--wpds-border-radius-sm,2px);border-style:solid;border-width:1px;color:var(--wp-ui-button-foreground-color);display:inline-flex;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wp-ui-button-font-size);font-weight:var(--wp-ui-button-font-weight);gap:var(--wpds-dimension-gap-sm,8px);justify-content:center;line-height:var(--wpds-typography-line-height-sm,20px);max-width:100%;min-height:var(--wp-ui-button-height);min-width:var(--wp-ui-button-min-width);overflow-wrap:anywhere;padding-block:var(--wp-ui-button-padding-block);padding-inline:var(--wp-ui-button-padding-inline);position:relative;text-align:center;text-decoration:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}@media not (prefers-reduced-motion){transition:color .1s ease-out;*{transition:opacity .1s ease-out}}&[href]{cursor:pointer}[href]{color:inherit;text-decoration:inherit}&:not([data-disabled]):is(:hover,:active,:focus){background-color:var(--wp-ui-button-background-color-active);border-color:var(--wp-ui-button-border-color-active);color:var(--wp-ui-button-foreground-color-active)}&[data-disabled]:not(._914b42f315c0e580__is-loading){background-color:var(--wp-ui-button-background-color-disabled);border-color:var(--wp-ui-button-border-color-disabled);color:var(--wp-ui-button-foreground-color-disabled);@media (forced-colors:active){border-bottom-color:GrayText;border-left-color:GrayText;border-right-color:GrayText;border-top-color:GrayText;color:GrayText}}&:before{aspect-ratio:1;border:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid;border-block-end-color:#0000;border-block-start-color:var(--wp-ui-button-foreground-color);border-inline-end-color:var(--wp-ui-button-foreground-color);border-inline-start-color:#0000;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}}}._908205475f9f2a92__is-small{--wp-ui-button-padding-block:0;--wp-ui-button-padding-inline:var(--wpds-dimension-padding-sm,8px);--wp-ui-button-height:24px}.dd460c965226cc77__is-brand{&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9));--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-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-bg-interactive-neutral-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-neutral-disabled,#dbdbdb)}&.ad0619a3217c6a5b__is-minimal{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-brand-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-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-bg-interactive-neutral-weak-disabled,#0000)}}.e722a8f96726aa99__is-neutral{&.ad0619a3217c6a5b__is-minimal[aria-pressed=true],&.b50b3358c5fb4d0b__is-solid{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-strong,#2d2d2d);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-strong-active,#1e1e1e);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-strong-disabled,#e6e6e6);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-neutral-strong,#f0f0f0);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-neutral-strong-active,#f0f0f0);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-strong-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline,&.ad0619a3217c6a5b__is-minimal:not([aria-pressed=true]){--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e);--wp-ui-button-foreground-color-disabled:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}&._62d5a778b7b258ee__is-outline{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-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-bg-interactive-neutral-weak,#0000);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-neutral-weak-active,#ededed);--wp-ui-button-background-color-disabled:var(--wpds-color-bg-interactive-neutral-weak-disabled,#0000)}}.abbb272e2ce49bd6__is-unstyled{background:none;border:none;min-width:unset}.cf59cf1b69629838__is-compact{--wp-ui-button-height:32px}._914b42f315c0e580__is-loading{color:#0000;&:not([data-disabled]):is(:hover,:active,:focus){color:#0000}*{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)}}');
12410 }
12411 var style_default3 = { "button": "_97b0fc33c028be1a__button", "is-unstyled": "abbb272e2ce49bd6__is-unstyled", "is-loading": "_914b42f315c0e580__is-loading", "is-small": "_908205475f9f2a92__is-small", "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" };
12412 if (typeof process === "undefined" || true) {
12413 registerStyle3("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
12414 }
12415 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
12416 if (typeof process === "undefined" || true) {
12417 registerStyle3("2a5ab8f3a7", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._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-brand,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-brand,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-brand,var(--wp-admin-theme-color,#3858e9))}}");
12418 }
12419 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" };
12420 if (typeof process === "undefined" || true) {
12421 registerStyle3("1fb29d3a3c", "._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,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-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,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-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 #0000)}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-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
12422 }
12423 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" };
12424 var Button3 = (0, import_element13.forwardRef)(
12425 function Button22({
12426 tone = "brand",
12427 variant = "solid",
12428 size: size4 = "default",
12429 className,
12430 focusableWhenDisabled = true,
12431 disabled: disabled2,
12432 loading,
12433 loadingAnnouncement = (0, import_i18n.__)("Loading"),
12434 children,
12435 ...props
12436 }, ref) {
12437 const mergedClassName = clsx_default(
12438 global_css_defense_default2.button,
12439 resets_default["box-sizing"],
12440 focus_default["outset-ring--focus-except-active"],
12441 variant !== "unstyled" && style_default3.button,
12442 style_default3[`is-${tone}`],
12443 style_default3[`is-${variant}`],
12444 style_default3[`is-${size4}`],
12445 loading && style_default3["is-loading"],
12446 className
12447 );
12448 (0, import_element13.useEffect)(() => {
12449 if (loading && loadingAnnouncement) {
12450 speak(loadingAnnouncement);
12451 }
12452 }, [loading, loadingAnnouncement]);
12453 return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
12454 Button,
12455 {
12456 ref,
12457 className: mergedClassName,
12458 focusableWhenDisabled,
12459 disabled: disabled2 ?? loading,
12460 ...props,
12461 children
12462 }
12463 );
12464 }
12465 );
12466
12467 // packages/ui/build-module/button/icon.mjs
12468 var import_element15 = __toESM(require_element(), 1);
12469
12470 // packages/ui/build-module/icon/icon.mjs
12471 var import_element14 = __toESM(require_element(), 1);
12472 var import_primitives = __toESM(require_primitives(), 1);
12473 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
12474 var Icon = (0, import_element14.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
12475 return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
12476 import_primitives.SVG,
12477 {
12478 ref,
12479 fill: "currentColor",
12480 ...icon.props,
12481 ...restProps,
12482 width: size4,
12483 height: size4
12484 }
12485 );
12486 });
12487
12488 // packages/ui/build-module/button/icon.mjs
12489 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
12490 var ButtonIcon = (0, import_element15.forwardRef)(
12491 function ButtonIcon2({ icon, ...props }, ref) {
12492 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
12493 Icon,
12494 {
12495 ref,
12496 icon,
12497 viewBox: "4 4 16 16",
12498 size: 16,
12499 ...props
12500 }
12501 );
12502 }
12503 );
12504
12505 // packages/ui/build-module/button/index.mjs
12506 ButtonIcon.displayName = "Button.Icon";
12507 var Button4 = Object.assign(Button3, {
12508 /**
12509 * An icon component specifically designed to work well when rendered inside
12510 * a `Button` component.
12511 */
12512 Icon: ButtonIcon
12513 });
12514
12515 // packages/ui/build-module/card/index.mjs
12516 var card_exports = {};
12517 __export(card_exports, {
12518 Content: () => Content,
12519 FullBleed: () => FullBleed,
12520 Header: () => Header,
12521 Root: () => Root,
12522 Title: () => Title
12523 });
12524
12525 // packages/ui/build-module/card/root.mjs
12526 var import_element16 = __toESM(require_element(), 1);
12527 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
12528 function getRuntime4() {
12529 const globalScope = globalThis;
12530 if (globalScope.__wpStyleRuntime) {
12531 return globalScope.__wpStyleRuntime;
12532 }
12533 globalScope.__wpStyleRuntime = {
12534 documents: /* @__PURE__ */ new Map(),
12535 styles: /* @__PURE__ */ new Map(),
12536 injectedStyles: /* @__PURE__ */ new WeakMap()
12537 };
12538 if (typeof document !== "undefined") {
12539 registerDocument4(document);
12540 }
12541 return globalScope.__wpStyleRuntime;
12542 }
12543 function documentContainsStyleHash4(targetDocument, hash) {
12544 if (!targetDocument.head) {
12545 return false;
12546 }
12547 for (const style of targetDocument.head.querySelectorAll(
12548 `style[${STYLE_HASH_ATTRIBUTE4}]`
12549 )) {
12550 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
12551 return true;
12552 }
12553 }
12554 return false;
12555 }
12556 function injectStyle4(targetDocument, hash, css) {
12557 if (!targetDocument.head) {
12558 return;
12559 }
12560 const runtime = getRuntime4();
12561 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12562 if (!injectedStyles) {
12563 injectedStyles = /* @__PURE__ */ new Set();
12564 runtime.injectedStyles.set(targetDocument, injectedStyles);
12565 }
12566 if (injectedStyles.has(hash)) {
12567 return;
12568 }
12569 if (documentContainsStyleHash4(targetDocument, hash)) {
12570 injectedStyles.add(hash);
12571 return;
12572 }
12573 const style = targetDocument.createElement("style");
12574 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
12575 style.appendChild(targetDocument.createTextNode(css));
12576 targetDocument.head.appendChild(style);
12577 injectedStyles.add(hash);
12578 }
12579 function registerDocument4(targetDocument) {
12580 const runtime = getRuntime4();
12581 runtime.documents.set(
12582 targetDocument,
12583 (runtime.documents.get(targetDocument) ?? 0) + 1
12584 );
12585 for (const [hash, css] of runtime.styles) {
12586 injectStyle4(targetDocument, hash, css);
12587 }
12588 return () => {
12589 const count = runtime.documents.get(targetDocument);
12590 if (count === void 0) {
12591 return;
12592 }
12593 if (count <= 1) {
12594 runtime.documents.delete(targetDocument);
12595 return;
12596 }
12597 runtime.documents.set(targetDocument, count - 1);
12598 };
12599 }
12600 function registerStyle4(hash, css) {
12601 const runtime = getRuntime4();
12602 runtime.styles.set(hash, css);
12603 for (const targetDocument of runtime.documents.keys()) {
12604 injectStyle4(targetDocument, hash, css);
12605 }
12606 }
12607 if (typeof process === "undefined" || true) {
12608 registerStyle4("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
12609 }
12610 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
12611 if (typeof process === "undefined" || true) {
12612 registerStyle4("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-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-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-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)}}");
12613 }
12614 var style_default4 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
12615 var Root = (0, import_element16.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
12616 const mergedClassName = clsx_default(style_default4.root, resets_default2["box-sizing"]);
12617 const element = useRender({
12618 defaultTagName: "div",
12619 render: render4,
12620 ref,
12621 props: mergeProps({ className: mergedClassName }, restProps)
12622 });
12623 return element;
12624 });
12625
12626 // packages/ui/build-module/card/header.mjs
12627 var import_element17 = __toESM(require_element(), 1);
12628 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
12629 function getRuntime5() {
12630 const globalScope = globalThis;
12631 if (globalScope.__wpStyleRuntime) {
12632 return globalScope.__wpStyleRuntime;
12633 }
12634 globalScope.__wpStyleRuntime = {
12635 documents: /* @__PURE__ */ new Map(),
12636 styles: /* @__PURE__ */ new Map(),
12637 injectedStyles: /* @__PURE__ */ new WeakMap()
12638 };
12639 if (typeof document !== "undefined") {
12640 registerDocument5(document);
12641 }
12642 return globalScope.__wpStyleRuntime;
12643 }
12644 function documentContainsStyleHash5(targetDocument, hash) {
12645 if (!targetDocument.head) {
12646 return false;
12647 }
12648 for (const style of targetDocument.head.querySelectorAll(
12649 `style[${STYLE_HASH_ATTRIBUTE5}]`
12650 )) {
12651 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
12652 return true;
12653 }
12654 }
12655 return false;
12656 }
12657 function injectStyle5(targetDocument, hash, css) {
12658 if (!targetDocument.head) {
12659 return;
12660 }
12661 const runtime = getRuntime5();
12662 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12663 if (!injectedStyles) {
12664 injectedStyles = /* @__PURE__ */ new Set();
12665 runtime.injectedStyles.set(targetDocument, injectedStyles);
12666 }
12667 if (injectedStyles.has(hash)) {
12668 return;
12669 }
12670 if (documentContainsStyleHash5(targetDocument, hash)) {
12671 injectedStyles.add(hash);
12672 return;
12673 }
12674 const style = targetDocument.createElement("style");
12675 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
12676 style.appendChild(targetDocument.createTextNode(css));
12677 targetDocument.head.appendChild(style);
12678 injectedStyles.add(hash);
12679 }
12680 function registerDocument5(targetDocument) {
12681 const runtime = getRuntime5();
12682 runtime.documents.set(
12683 targetDocument,
12684 (runtime.documents.get(targetDocument) ?? 0) + 1
12685 );
12686 for (const [hash, css] of runtime.styles) {
12687 injectStyle5(targetDocument, hash, css);
12688 }
12689 return () => {
12690 const count = runtime.documents.get(targetDocument);
12691 if (count === void 0) {
12692 return;
12693 }
12694 if (count <= 1) {
12695 runtime.documents.delete(targetDocument);
12696 return;
12697 }
12698 runtime.documents.set(targetDocument, count - 1);
12699 };
12700 }
12701 function registerStyle5(hash, css) {
12702 const runtime = getRuntime5();
12703 runtime.styles.set(hash, css);
12704 for (const targetDocument of runtime.documents.keys()) {
12705 injectStyle5(targetDocument, hash, css);
12706 }
12707 }
12708 if (typeof process === "undefined" || true) {
12709 registerStyle5("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-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-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-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)}}");
12710 }
12711 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
12712 var Header = (0, import_element17.forwardRef)(
12713 function CardHeader({ render: render4, ...props }, ref) {
12714 const element = useRender({
12715 defaultTagName: "div",
12716 render: render4,
12717 ref,
12718 props: mergeProps({ className: style_default5.header }, props)
12719 });
12720 return element;
12721 }
12722 );
12723
12724 // packages/ui/build-module/card/content.mjs
12725 var import_element18 = __toESM(require_element(), 1);
12726 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
12727 function getRuntime6() {
12728 const globalScope = globalThis;
12729 if (globalScope.__wpStyleRuntime) {
12730 return globalScope.__wpStyleRuntime;
12731 }
12732 globalScope.__wpStyleRuntime = {
12733 documents: /* @__PURE__ */ new Map(),
12734 styles: /* @__PURE__ */ new Map(),
12735 injectedStyles: /* @__PURE__ */ new WeakMap()
12736 };
12737 if (typeof document !== "undefined") {
12738 registerDocument6(document);
12739 }
12740 return globalScope.__wpStyleRuntime;
12741 }
12742 function documentContainsStyleHash6(targetDocument, hash) {
12743 if (!targetDocument.head) {
12744 return false;
12745 }
12746 for (const style of targetDocument.head.querySelectorAll(
12747 `style[${STYLE_HASH_ATTRIBUTE6}]`
12748 )) {
12749 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
12750 return true;
12751 }
12752 }
12753 return false;
12754 }
12755 function injectStyle6(targetDocument, hash, css) {
12756 if (!targetDocument.head) {
12757 return;
12758 }
12759 const runtime = getRuntime6();
12760 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12761 if (!injectedStyles) {
12762 injectedStyles = /* @__PURE__ */ new Set();
12763 runtime.injectedStyles.set(targetDocument, injectedStyles);
12764 }
12765 if (injectedStyles.has(hash)) {
12766 return;
12767 }
12768 if (documentContainsStyleHash6(targetDocument, hash)) {
12769 injectedStyles.add(hash);
12770 return;
12771 }
12772 const style = targetDocument.createElement("style");
12773 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
12774 style.appendChild(targetDocument.createTextNode(css));
12775 targetDocument.head.appendChild(style);
12776 injectedStyles.add(hash);
12777 }
12778 function registerDocument6(targetDocument) {
12779 const runtime = getRuntime6();
12780 runtime.documents.set(
12781 targetDocument,
12782 (runtime.documents.get(targetDocument) ?? 0) + 1
12783 );
12784 for (const [hash, css] of runtime.styles) {
12785 injectStyle6(targetDocument, hash, css);
12786 }
12787 return () => {
12788 const count = runtime.documents.get(targetDocument);
12789 if (count === void 0) {
12790 return;
12791 }
12792 if (count <= 1) {
12793 runtime.documents.delete(targetDocument);
12794 return;
12795 }
12796 runtime.documents.set(targetDocument, count - 1);
12797 };
12798 }
12799 function registerStyle6(hash, css) {
12800 const runtime = getRuntime6();
12801 runtime.styles.set(hash, css);
12802 for (const targetDocument of runtime.documents.keys()) {
12803 injectStyle6(targetDocument, hash, css);
12804 }
12805 }
12806 if (typeof process === "undefined" || true) {
12807 registerStyle6("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-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-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-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)}}");
12808 }
12809 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
12810 var Content = (0, import_element18.forwardRef)(
12811 function CardContent({ render: render4, ...props }, ref) {
12812 const element = useRender({
12813 defaultTagName: "div",
12814 render: render4,
12815 ref,
12816 props: mergeProps({ className: style_default6.content }, props)
12817 });
12818 return element;
12819 }
12820 );
12821
12822 // packages/ui/build-module/card/full-bleed.mjs
12823 var import_element19 = __toESM(require_element(), 1);
12824 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
12825 function getRuntime7() {
12826 const globalScope = globalThis;
12827 if (globalScope.__wpStyleRuntime) {
12828 return globalScope.__wpStyleRuntime;
12829 }
12830 globalScope.__wpStyleRuntime = {
12831 documents: /* @__PURE__ */ new Map(),
12832 styles: /* @__PURE__ */ new Map(),
12833 injectedStyles: /* @__PURE__ */ new WeakMap()
12834 };
12835 if (typeof document !== "undefined") {
12836 registerDocument7(document);
12837 }
12838 return globalScope.__wpStyleRuntime;
12839 }
12840 function documentContainsStyleHash7(targetDocument, hash) {
12841 if (!targetDocument.head) {
12842 return false;
12843 }
12844 for (const style of targetDocument.head.querySelectorAll(
12845 `style[${STYLE_HASH_ATTRIBUTE7}]`
12846 )) {
12847 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
12848 return true;
12849 }
12850 }
12851 return false;
12852 }
12853 function injectStyle7(targetDocument, hash, css) {
12854 if (!targetDocument.head) {
12855 return;
12856 }
12857 const runtime = getRuntime7();
12858 let injectedStyles = runtime.injectedStyles.get(targetDocument);
12859 if (!injectedStyles) {
12860 injectedStyles = /* @__PURE__ */ new Set();
12861 runtime.injectedStyles.set(targetDocument, injectedStyles);
12862 }
12863 if (injectedStyles.has(hash)) {
12864 return;
12865 }
12866 if (documentContainsStyleHash7(targetDocument, hash)) {
12867 injectedStyles.add(hash);
12868 return;
12869 }
12870 const style = targetDocument.createElement("style");
12871 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
12872 style.appendChild(targetDocument.createTextNode(css));
12873 targetDocument.head.appendChild(style);
12874 injectedStyles.add(hash);
12875 }
12876 function registerDocument7(targetDocument) {
12877 const runtime = getRuntime7();
12878 runtime.documents.set(
12879 targetDocument,
12880 (runtime.documents.get(targetDocument) ?? 0) + 1
12881 );
12882 for (const [hash, css] of runtime.styles) {
12883 injectStyle7(targetDocument, hash, css);
12884 }
12885 return () => {
12886 const count = runtime.documents.get(targetDocument);
12887 if (count === void 0) {
12888 return;
12889 }
12890 if (count <= 1) {
12891 runtime.documents.delete(targetDocument);
12892 return;
12893 }
12894 runtime.documents.set(targetDocument, count - 1);
12895 };
12896 }
12897 function registerStyle7(hash, css) {
12898 const runtime = getRuntime7();
12899 runtime.styles.set(hash, css);
12900 for (const targetDocument of runtime.documents.keys()) {
12901 injectStyle7(targetDocument, hash, css);
12902 }
12903 }
12904 if (typeof process === "undefined" || true) {
12905 registerStyle7("7bb6e0116a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-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-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-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)}}");
12906 }
12907 var style_default7 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
12908 var FullBleed = (0, import_element19.forwardRef)(
12909 function CardFullBleed({ render: render4, ...props }, ref) {
12910 const element = useRender({
12911 defaultTagName: "div",
12912 render: render4,
12913 ref,
12914 props: mergeProps(
12915 { className: style_default7.fullbleed },
12916 props
12917 )
12918 });
12919 return element;
12920 }
12921 );
12922
12923 // packages/ui/build-module/card/title.mjs
12924 var import_element20 = __toESM(require_element(), 1);
12925 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
12926 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", {});
12927 var Title = (0, import_element20.forwardRef)(
12928 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
12929 return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
12930 Text,
12931 {
12932 ref,
12933 variant: "heading-lg",
12934 render: render4,
12935 ...props,
12936 children
12937 }
12938 );
12939 }
12940 );
12941
12942 // packages/ui/build-module/collapsible/panel.mjs
12943 var import_element21 = __toESM(require_element(), 1);
12944 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
12945 var Panel = (0, import_element21.forwardRef)(
12946 function CollapsiblePanel3(props, forwardedRef) {
12947 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props });
12948 }
12949 );
12950
12951 // packages/ui/build-module/collapsible/root.mjs
12952 var import_element22 = __toESM(require_element(), 1);
12953 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
12954 var Root2 = (0, import_element22.forwardRef)(
12955 function CollapsibleRoot3(props, forwardedRef) {
12956 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props });
12957 }
12958 );
12959
12960 // packages/ui/build-module/collapsible/trigger.mjs
12961 var import_element23 = __toESM(require_element(), 1);
12962 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
12963 var Trigger = (0, import_element23.forwardRef)(
12964 function CollapsibleTrigger3(props, forwardedRef) {
12965 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props });
12966 }
12967 );
12968
12969 // packages/ui/build-module/collapsible-card/index.mjs
12970 var collapsible_card_exports = {};
12971 __export(collapsible_card_exports, {
12972 Content: () => Content2,
12973 Header: () => Header2,
12974 HeaderDescription: () => HeaderDescription,
12975 Root: () => Root3
12976 });
12977
12978 // packages/ui/build-module/collapsible-card/root.mjs
12979 var import_element24 = __toESM(require_element(), 1);
12980 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
12981 var Root3 = (0, import_element24.forwardRef)(
12982 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) {
12983 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
12984 Root2,
12985 {
12986 ref,
12987 render: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Root, { render: render4 }),
12988 ...restProps
12989 }
12990 );
12991 }
12992 );
12993
12994 // packages/ui/build-module/collapsible-card/header.mjs
12995 var import_element26 = __toESM(require_element(), 1);
12996
12997 // packages/icons/build-module/library/arrow-down.mjs
12998 var import_primitives2 = __toESM(require_primitives(), 1);
12999 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
13000 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.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" }) });
13001
13002 // packages/icons/build-module/library/arrow-left.mjs
13003 var import_primitives3 = __toESM(require_primitives(), 1);
13004 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
13005 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.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" }) });
13006
13007 // packages/icons/build-module/library/arrow-right.mjs
13008 var import_primitives4 = __toESM(require_primitives(), 1);
13009 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
13010 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.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" }) });
13011
13012 // packages/icons/build-module/library/arrow-up.mjs
13013 var import_primitives5 = __toESM(require_primitives(), 1);
13014 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
13015 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
13016
13017 // packages/icons/build-module/library/block-table.mjs
13018 var import_primitives6 = __toESM(require_primitives(), 1);
13019 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
13020 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.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" }) });
13021
13022 // packages/icons/build-module/library/category.mjs
13023 var import_primitives7 = __toESM(require_primitives(), 1);
13024 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
13025 var category_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.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" }) });
13026
13027 // packages/icons/build-module/library/caution.mjs
13028 var import_primitives8 = __toESM(require_primitives(), 1);
13029 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
13030 var caution_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives8.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm-.75 12v-1.5h1.5V16h-1.5Zm0-8v5h1.5V8h-1.5Z" }) });
13031
13032 // packages/icons/build-module/library/check.mjs
13033 var import_primitives9 = __toESM(require_primitives(), 1);
13034 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
13035 var check_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives9.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
13036
13037 // packages/icons/build-module/library/chevron-down.mjs
13038 var import_primitives10 = __toESM(require_primitives(), 1);
13039 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
13040 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives10.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
13041
13042 // packages/icons/build-module/library/close-small.mjs
13043 var import_primitives11 = __toESM(require_primitives(), 1);
13044 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
13045 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives11.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) });
13046
13047 // packages/icons/build-module/library/cog.mjs
13048 var import_primitives12 = __toESM(require_primitives(), 1);
13049 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
13050 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives12.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z" }) });
13051
13052 // packages/icons/build-module/library/copy.mjs
13053 var import_primitives13 = __toESM(require_primitives(), 1);
13054 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
13055 var copy_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives13.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z" }) });
13056
13057 // packages/icons/build-module/library/envelope.mjs
13058 var import_primitives14 = __toESM(require_primitives(), 1);
13059 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
13060 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives14.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" }) });
13061
13062 // packages/icons/build-module/library/error.mjs
13063 var import_primitives15 = __toESM(require_primitives(), 1);
13064 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
13065 var error_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives15.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" }) });
13066
13067 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
13068 var import_primitives16 = __toESM(require_primitives(), 1);
13069 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
13070 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives16.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) });
13071
13072 // packages/icons/build-module/library/format-list-bullets.mjs
13073 var import_primitives17 = __toESM(require_primitives(), 1);
13074 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
13075 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives17.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) });
13076
13077 // packages/icons/build-module/library/funnel.mjs
13078 var import_primitives18 = __toESM(require_primitives(), 1);
13079 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
13080 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives18.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
13081
13082 // packages/icons/build-module/library/info.mjs
13083 var import_primitives19 = __toESM(require_primitives(), 1);
13084 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
13085 var info_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives19.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z" }) });
13086
13087 // packages/icons/build-module/library/link.mjs
13088 var import_primitives20 = __toESM(require_primitives(), 1);
13089 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
13090 var link_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime47.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" }) });
13091
13092 // packages/icons/build-module/library/mobile.mjs
13093 var import_primitives21 = __toESM(require_primitives(), 1);
13094 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
13095 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime48.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" }) });
13096
13097 // packages/icons/build-module/library/more-vertical.mjs
13098 var import_primitives22 = __toESM(require_primitives(), 1);
13099 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
13100 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
13101
13102 // packages/icons/build-module/library/next.mjs
13103 var import_primitives23 = __toESM(require_primitives(), 1);
13104 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
13105 var next_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime50.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" }) });
13106
13107 // packages/icons/build-module/library/pencil.mjs
13108 var import_primitives24 = __toESM(require_primitives(), 1);
13109 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
13110 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives24.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) });
13111
13112 // packages/icons/build-module/library/previous.mjs
13113 var import_primitives25 = __toESM(require_primitives(), 1);
13114 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
13115 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives25.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" }) });
13116
13117 // packages/icons/build-module/library/published.mjs
13118 var import_primitives26 = __toESM(require_primitives(), 1);
13119 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
13120 var published_default = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives26.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 0Zm11.53-1.47-1.06-1.06L11 12.94l-1.47-1.47-1.06 1.06L11 15.06l4.53-4.53Z" }) });
13121
13122 // packages/icons/build-module/library/scheduled.mjs
13123 var import_primitives27 = __toESM(require_primitives(), 1);
13124 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
13125 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime54.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" }) });
13126
13127 // packages/icons/build-module/library/search.mjs
13128 var import_primitives28 = __toESM(require_primitives(), 1);
13129 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
13130 var search_default = /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime55.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" }) });
13131
13132 // packages/icons/build-module/library/seen.mjs
13133 var import_primitives29 = __toESM(require_primitives(), 1);
13134 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
13135 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime56.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" }) });
13136
13137 // packages/icons/build-module/library/trash.mjs
13138 var import_primitives30 = __toESM(require_primitives(), 1);
13139 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
13140 var trash_default = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime57.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" }) });
13141
13142 // packages/icons/build-module/library/unseen.mjs
13143 var import_primitives31 = __toESM(require_primitives(), 1);
13144 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
13145 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives31.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime58.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" }) });
13146
13147 // packages/ui/build-module/collapsible-card/context.mjs
13148 var import_element25 = __toESM(require_element(), 1);
13149 var HeaderDescriptionIdContext = (0, import_element25.createContext)({
13150 setDescriptionId: () => {
13151 }
13152 });
13153
13154 // packages/ui/build-module/collapsible-card/header.mjs
13155 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13156 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
13157 function getRuntime8() {
13158 const globalScope = globalThis;
13159 if (globalScope.__wpStyleRuntime) {
13160 return globalScope.__wpStyleRuntime;
13161 }
13162 globalScope.__wpStyleRuntime = {
13163 documents: /* @__PURE__ */ new Map(),
13164 styles: /* @__PURE__ */ new Map(),
13165 injectedStyles: /* @__PURE__ */ new WeakMap()
13166 };
13167 if (typeof document !== "undefined") {
13168 registerDocument8(document);
13169 }
13170 return globalScope.__wpStyleRuntime;
13171 }
13172 function documentContainsStyleHash8(targetDocument, hash) {
13173 if (!targetDocument.head) {
13174 return false;
13175 }
13176 for (const style of targetDocument.head.querySelectorAll(
13177 `style[${STYLE_HASH_ATTRIBUTE8}]`
13178 )) {
13179 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
13180 return true;
13181 }
13182 }
13183 return false;
13184 }
13185 function injectStyle8(targetDocument, hash, css) {
13186 if (!targetDocument.head) {
13187 return;
13188 }
13189 const runtime = getRuntime8();
13190 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13191 if (!injectedStyles) {
13192 injectedStyles = /* @__PURE__ */ new Set();
13193 runtime.injectedStyles.set(targetDocument, injectedStyles);
13194 }
13195 if (injectedStyles.has(hash)) {
13196 return;
13197 }
13198 if (documentContainsStyleHash8(targetDocument, hash)) {
13199 injectedStyles.add(hash);
13200 return;
13201 }
13202 const style = targetDocument.createElement("style");
13203 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
13204 style.appendChild(targetDocument.createTextNode(css));
13205 targetDocument.head.appendChild(style);
13206 injectedStyles.add(hash);
13207 }
13208 function registerDocument8(targetDocument) {
13209 const runtime = getRuntime8();
13210 runtime.documents.set(
13211 targetDocument,
13212 (runtime.documents.get(targetDocument) ?? 0) + 1
13213 );
13214 for (const [hash, css] of runtime.styles) {
13215 injectStyle8(targetDocument, hash, css);
13216 }
13217 return () => {
13218 const count = runtime.documents.get(targetDocument);
13219 if (count === void 0) {
13220 return;
13221 }
13222 if (count <= 1) {
13223 runtime.documents.delete(targetDocument);
13224 return;
13225 }
13226 runtime.documents.set(targetDocument, count - 1);
13227 };
13228 }
13229 function registerStyle8(hash, css) {
13230 const runtime = getRuntime8();
13231 runtime.styles.set(hash, css);
13232 for (const targetDocument of runtime.documents.keys()) {
13233 injectStyle8(targetDocument, hash, css);
13234 }
13235 }
13236 if (typeof process === "undefined" || true) {
13237 registerStyle8("f1b9bb6252", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-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-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-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)}}}");
13238 }
13239 var style_default8 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
13240 if (typeof process === "undefined" || true) {
13241 registerStyle8("1fb29d3a3c", "._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,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-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,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-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 #0000)}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-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
13242 }
13243 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" };
13244 if (typeof process === "undefined" || true) {
13245 registerStyle8("2a5ab8f3a7", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._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-brand,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-brand,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-brand,var(--wp-admin-theme-color,#3858e9))}}");
13246 }
13247 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" };
13248 var Header2 = (0, import_element26.forwardRef)(
13249 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) {
13250 const [descriptionId, setDescriptionId] = (0, import_element26.useState)();
13251 const contextValue = (0, import_element26.useMemo)(
13252 () => ({ setDescriptionId }),
13253 [setDescriptionId]
13254 );
13255 return useRender({
13256 defaultTagName: "div",
13257 render: render4,
13258 ref,
13259 props: mergeProps(restProps, {
13260 className: clsx_default(
13261 global_css_defense_default3.heading,
13262 style_default8["heading-wrapper"],
13263 className
13264 ),
13265 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13266 Trigger,
13267 {
13268 className: style_default8.header,
13269 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Header, {}),
13270 nativeButton: false,
13271 "aria-describedby": descriptionId,
13272 children: [
13273 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: style_default8["header-content"], children }),
13274 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13275 "div",
13276 {
13277 className: clsx_default(
13278 style_default8["header-trigger-positioner"]
13279 ),
13280 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13281 "div",
13282 {
13283 className: clsx_default(
13284 style_default8["header-trigger-wrapper"],
13285 global_css_defense_default3.div,
13286 // While the interactive trigger element is the whole header,
13287 // the focus ring will be displayed only on the icon to visually
13288 // emulate it being the button.
13289 focus_default2["outset-ring--focus-parent-visible"]
13290 ),
13291 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13292 Icon,
13293 {
13294 icon: chevron_down_default,
13295 className: style_default8["header-trigger"]
13296 }
13297 )
13298 }
13299 )
13300 }
13301 )
13302 ]
13303 }
13304 ) })
13305 })
13306 });
13307 }
13308 );
13309
13310 // packages/ui/build-module/collapsible-card/header-description.mjs
13311 var import_element27 = __toESM(require_element(), 1);
13312 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13313 var HeaderDescription = (0, import_element27.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) {
13314 const descriptionId = (0, import_element27.useId)();
13315 const { setDescriptionId } = (0, import_element27.useContext)(HeaderDescriptionIdContext);
13316 (0, import_element27.useEffect)(() => {
13317 setDescriptionId(descriptionId);
13318 return () => setDescriptionId(void 0);
13319 }, [descriptionId, setDescriptionId]);
13320 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13321 "div",
13322 {
13323 ref,
13324 id: descriptionId,
13325 "aria-hidden": "true",
13326 className,
13327 ...restProps,
13328 children
13329 }
13330 );
13331 });
13332
13333 // packages/ui/build-module/collapsible-card/content.mjs
13334 var import_element28 = __toESM(require_element(), 1);
13335 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13336 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
13337 function getRuntime9() {
13338 const globalScope = globalThis;
13339 if (globalScope.__wpStyleRuntime) {
13340 return globalScope.__wpStyleRuntime;
13341 }
13342 globalScope.__wpStyleRuntime = {
13343 documents: /* @__PURE__ */ new Map(),
13344 styles: /* @__PURE__ */ new Map(),
13345 injectedStyles: /* @__PURE__ */ new WeakMap()
13346 };
13347 if (typeof document !== "undefined") {
13348 registerDocument9(document);
13349 }
13350 return globalScope.__wpStyleRuntime;
13351 }
13352 function documentContainsStyleHash9(targetDocument, hash) {
13353 if (!targetDocument.head) {
13354 return false;
13355 }
13356 for (const style of targetDocument.head.querySelectorAll(
13357 `style[${STYLE_HASH_ATTRIBUTE9}]`
13358 )) {
13359 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
13360 return true;
13361 }
13362 }
13363 return false;
13364 }
13365 function injectStyle9(targetDocument, hash, css) {
13366 if (!targetDocument.head) {
13367 return;
13368 }
13369 const runtime = getRuntime9();
13370 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13371 if (!injectedStyles) {
13372 injectedStyles = /* @__PURE__ */ new Set();
13373 runtime.injectedStyles.set(targetDocument, injectedStyles);
13374 }
13375 if (injectedStyles.has(hash)) {
13376 return;
13377 }
13378 if (documentContainsStyleHash9(targetDocument, hash)) {
13379 injectedStyles.add(hash);
13380 return;
13381 }
13382 const style = targetDocument.createElement("style");
13383 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
13384 style.appendChild(targetDocument.createTextNode(css));
13385 targetDocument.head.appendChild(style);
13386 injectedStyles.add(hash);
13387 }
13388 function registerDocument9(targetDocument) {
13389 const runtime = getRuntime9();
13390 runtime.documents.set(
13391 targetDocument,
13392 (runtime.documents.get(targetDocument) ?? 0) + 1
13393 );
13394 for (const [hash, css] of runtime.styles) {
13395 injectStyle9(targetDocument, hash, css);
13396 }
13397 return () => {
13398 const count = runtime.documents.get(targetDocument);
13399 if (count === void 0) {
13400 return;
13401 }
13402 if (count <= 1) {
13403 runtime.documents.delete(targetDocument);
13404 return;
13405 }
13406 runtime.documents.set(targetDocument, count - 1);
13407 };
13408 }
13409 function registerStyle9(hash, css) {
13410 const runtime = getRuntime9();
13411 runtime.styles.set(hash, css);
13412 for (const targetDocument of runtime.documents.keys()) {
13413 injectStyle9(targetDocument, hash, css);
13414 }
13415 }
13416 if (typeof process === "undefined" || true) {
13417 registerStyle9("f1b9bb6252", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-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-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-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)}}}");
13418 }
13419 var style_default9 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
13420 var Content2 = (0, import_element28.forwardRef)(
13421 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) {
13422 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13423 Panel,
13424 {
13425 ref,
13426 className: (state) => clsx_default(
13427 style_default9.content,
13428 state.open && state.transitionStatus === "idle" && style_default9.overflowVisible,
13429 className
13430 ),
13431 hiddenUntilFound,
13432 ...restProps,
13433 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13434 Content,
13435 {
13436 className: style_default9["content-inner"],
13437 render: render4,
13438 children
13439 }
13440 )
13441 }
13442 );
13443 }
13444 );
13445
13446 // packages/ui/build-module/utils/render-slot-with-children.mjs
13447 var import_element29 = __toESM(require_element(), 1);
13448 function renderSlotWithChildren(slot, defaultSlot, children) {
13449 return (0, import_element29.cloneElement)(slot ?? defaultSlot, { children });
13450 }
13451
13452 // packages/ui/build-module/utils/use-deprioritized-initial-focus.mjs
13453 var import_element30 = __toESM(require_element(), 1);
13454
13455 // node_modules/tabbable/dist/index.esm.js
13456 var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"];
13457 var candidateSelector = /* @__PURE__ */ candidateSelectors.join(",");
13458 var NoElement = typeof Element === "undefined";
13459 var matches = NoElement ? function() {
13460 } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
13461 var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
13462 var _element$getRootNode;
13463 return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
13464 } : function(element) {
13465 return element === null || element === void 0 ? void 0 : element.ownerDocument;
13466 };
13467 var _isInert = function isInert(node, lookUp) {
13468 var _node$getAttribute;
13469 if (lookUp === void 0) {
13470 lookUp = true;
13471 }
13472 var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, "inert");
13473 var inert = inertAtt === "" || inertAtt === "true";
13474 var result = inert || lookUp && node && // closest does not exist on shadow roots, so we fall back to a manual
13475 // lookup upward, in case it is not defined.
13476 (typeof node.closest === "function" ? node.closest("[inert]") : _isInert(node.parentNode));
13477 return result;
13478 };
13479 var isContentEditable = function isContentEditable2(node) {
13480 var _node$getAttribute2;
13481 var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable");
13482 return attValue === "" || attValue === "true";
13483 };
13484 var getCandidates = function getCandidates2(el, includeContainer, filter) {
13485 if (_isInert(el)) {
13486 return [];
13487 }
13488 var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
13489 if (includeContainer && matches.call(el, candidateSelector)) {
13490 candidates.unshift(el);
13491 }
13492 candidates = candidates.filter(filter);
13493 return candidates;
13494 };
13495 var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
13496 var candidates = [];
13497 var elementsToCheck = Array.from(elements);
13498 while (elementsToCheck.length) {
13499 var element = elementsToCheck.shift();
13500 if (_isInert(element, false)) {
13501 continue;
13502 }
13503 if (element.tagName === "SLOT") {
13504 var assigned = element.assignedElements();
13505 var content = assigned.length ? assigned : element.children;
13506 var nestedCandidates = _getCandidatesIteratively(content, true, options);
13507 if (options.flatten) {
13508 candidates.push.apply(candidates, nestedCandidates);
13509 } else {
13510 candidates.push({
13511 scopeParent: element,
13512 candidates: nestedCandidates
13513 });
13514 }
13515 } else {
13516 var validCandidate = matches.call(element, candidateSelector);
13517 if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
13518 candidates.push(element);
13519 }
13520 var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
13521 typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
13522 var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
13523 if (shadowRoot && validShadowRoot) {
13524 var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
13525 if (options.flatten) {
13526 candidates.push.apply(candidates, _nestedCandidates);
13527 } else {
13528 candidates.push({
13529 scopeParent: element,
13530 candidates: _nestedCandidates
13531 });
13532 }
13533 } else {
13534 elementsToCheck.unshift.apply(elementsToCheck, element.children);
13535 }
13536 }
13537 }
13538 return candidates;
13539 };
13540 var hasTabIndex = function hasTabIndex2(node) {
13541 return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
13542 };
13543 var getTabIndex2 = function getTabIndex3(node) {
13544 if (!node) {
13545 throw new Error("No node provided");
13546 }
13547 if (node.tabIndex < 0) {
13548 if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
13549 return 0;
13550 }
13551 }
13552 return node.tabIndex;
13553 };
13554 var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) {
13555 var tabIndex = getTabIndex2(node);
13556 if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
13557 return 0;
13558 }
13559 return tabIndex;
13560 };
13561 var sortOrderedTabbables = function sortOrderedTabbables2(a2, b2) {
13562 return a2.tabIndex === b2.tabIndex ? a2.documentOrder - b2.documentOrder : a2.tabIndex - b2.tabIndex;
13563 };
13564 var isInput = function isInput2(node) {
13565 return node.tagName === "INPUT";
13566 };
13567 var isHiddenInput = function isHiddenInput2(node) {
13568 return isInput(node) && node.type === "hidden";
13569 };
13570 var isDetailsWithSummary = function isDetailsWithSummary2(node) {
13571 var r3 = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
13572 return child.tagName === "SUMMARY";
13573 });
13574 return r3;
13575 };
13576 var getCheckedRadio = function getCheckedRadio2(nodes, form) {
13577 for (var i2 = 0; i2 < nodes.length; i2++) {
13578 if (nodes[i2].checked && nodes[i2].form === form) {
13579 return nodes[i2];
13580 }
13581 }
13582 };
13583 var isTabbableRadio2 = function isTabbableRadio3(node) {
13584 if (!node.name) {
13585 return true;
13586 }
13587 var radioScope = node.form || getRootNode(node);
13588 var queryRadios = function queryRadios2(name) {
13589 return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
13590 };
13591 var radioSet;
13592 if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
13593 radioSet = queryRadios(window.CSS.escape(node.name));
13594 } else {
13595 try {
13596 radioSet = queryRadios(node.name);
13597 } catch (err) {
13598 console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
13599 return false;
13600 }
13601 }
13602 var checked = getCheckedRadio(radioSet, node.form);
13603 return !checked || checked === node;
13604 };
13605 var isRadio = function isRadio2(node) {
13606 return isInput(node) && node.type === "radio";
13607 };
13608 var isNonTabbableRadio = function isNonTabbableRadio2(node) {
13609 return isRadio(node) && !isTabbableRadio2(node);
13610 };
13611 var isNodeAttached = function isNodeAttached2(node) {
13612 var _nodeRoot;
13613 var nodeRoot = node && getRootNode(node);
13614 var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
13615 var attached = false;
13616 if (nodeRoot && nodeRoot !== node) {
13617 var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
13618 attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
13619 while (!attached && nodeRootHost) {
13620 var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
13621 nodeRoot = getRootNode(nodeRootHost);
13622 nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
13623 attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
13624 }
13625 }
13626 return attached;
13627 };
13628 var isZeroArea = function isZeroArea2(node) {
13629 var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
13630 return width === 0 && height === 0;
13631 };
13632 var isHidden = function isHidden2(node, _ref) {
13633 var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
13634 if (displayCheck === "full-native") {
13635 if ("checkVisibility" in node) {
13636 var visible = node.checkVisibility({
13637 // Checking opacity might be desirable for some use cases, but natively,
13638 // opacity zero elements _are_ focusable and tabbable.
13639 checkOpacity: false,
13640 opacityProperty: false,
13641 contentVisibilityAuto: true,
13642 visibilityProperty: true,
13643 // This is an alias for `visibilityProperty`. Contemporary browsers
13644 // support both. However, this alias has wider browser support (Chrome
13645 // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
13646 // we include it anyway.
13647 checkVisibilityCSS: true
13648 });
13649 return !visible;
13650 }
13651 }
13652 if (getComputedStyle(node).visibility === "hidden") {
13653 return true;
13654 }
13655 var isDirectSummary = matches.call(node, "details>summary:first-of-type");
13656 var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
13657 if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
13658 return true;
13659 }
13660 if (!displayCheck || displayCheck === "full" || // full-native can run this branch when it falls through in case
13661 // Element#checkVisibility is unsupported
13662 displayCheck === "full-native" || displayCheck === "legacy-full") {
13663 if (typeof getShadowRoot === "function") {
13664 var originalNode = node;
13665 while (node) {
13666 var parentElement = node.parentElement;
13667 var rootNode = getRootNode(node);
13668 if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
13669 return isZeroArea(node);
13670 } else if (node.assignedSlot) {
13671 node = node.assignedSlot;
13672 } else if (!parentElement && rootNode !== node.ownerDocument) {
13673 node = rootNode.host;
13674 } else {
13675 node = parentElement;
13676 }
13677 }
13678 node = originalNode;
13679 }
13680 if (isNodeAttached(node)) {
13681 return !node.getClientRects().length;
13682 }
13683 if (displayCheck !== "legacy-full") {
13684 return true;
13685 }
13686 } else if (displayCheck === "non-zero-area") {
13687 return isZeroArea(node);
13688 }
13689 return false;
13690 };
13691 var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
13692 if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
13693 var parentNode = node.parentElement;
13694 while (parentNode) {
13695 if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
13696 for (var i2 = 0; i2 < parentNode.children.length; i2++) {
13697 var child = parentNode.children.item(i2);
13698 if (child.tagName === "LEGEND") {
13699 return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
13700 }
13701 }
13702 return true;
13703 }
13704 parentNode = parentNode.parentElement;
13705 }
13706 }
13707 return false;
13708 };
13709 var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
13710 if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
13711 isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
13712 return false;
13713 }
13714 return true;
13715 };
13716 var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
13717 if (isNonTabbableRadio(node) || getTabIndex2(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
13718 return false;
13719 }
13720 return true;
13721 };
13722 var isShadowRootTabbable = function isShadowRootTabbable2(shadowHostNode) {
13723 var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
13724 if (isNaN(tabIndex) || tabIndex >= 0) {
13725 return true;
13726 }
13727 return false;
13728 };
13729 var _sortByOrder = function sortByOrder(candidates) {
13730 var regularTabbables = [];
13731 var orderedTabbables = [];
13732 candidates.forEach(function(item, i2) {
13733 var isScope = !!item.scopeParent;
13734 var element = isScope ? item.scopeParent : item;
13735 var candidateTabindex = getSortOrderTabIndex(element, isScope);
13736 var elements = isScope ? _sortByOrder(item.candidates) : element;
13737 if (candidateTabindex === 0) {
13738 isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
13739 } else {
13740 orderedTabbables.push({
13741 documentOrder: i2,
13742 tabIndex: candidateTabindex,
13743 item,
13744 isScope,
13745 content: elements
13746 });
13747 }
13748 });
13749 return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
13750 sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
13751 return acc;
13752 }, []).concat(regularTabbables);
13753 };
13754 var tabbable2 = function tabbable3(container, options) {
13755 options = options || {};
13756 var candidates;
13757 if (options.getShadowRoot) {
13758 candidates = _getCandidatesIteratively([container], options.includeContainer, {
13759 filter: isNodeMatchingSelectorTabbable.bind(null, options),
13760 flatten: false,
13761 getShadowRoot: options.getShadowRoot,
13762 shadowRootFilter: isShadowRootTabbable
13763 });
13764 } else {
13765 candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
13766 }
13767 return _sortByOrder(candidates);
13768 };
13769
13770 // packages/ui/build-module/utils/use-deprioritized-initial-focus.mjs
13771 var getTabbableOptions = () => ({
13772 getShadowRoot: true,
13773 displayCheck: typeof ResizeObserver === "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
13774 });
13775 function useDeprioritizedInitialFocus({
13776 initialFocus,
13777 deprioritizedAttributes
13778 }) {
13779 const popupRef = (0, import_element30.useRef)(null);
13780 let resolvedInitialFocus = initialFocus;
13781 if (initialFocus === void 0 || initialFocus === true) {
13782 resolvedInitialFocus = (interactionType) => {
13783 if (interactionType === "touch") {
13784 return popupRef.current ?? true;
13785 }
13786 const popup = popupRef.current;
13787 if (!popup) {
13788 return true;
13789 }
13790 const tabbables = tabbable2(popup, getTabbableOptions());
13791 for (const el of tabbables) {
13792 if (el instanceof HTMLElement && !deprioritizedAttributes.some(
13793 (attr2) => el.hasAttribute(attr2)
13794 )) {
13795 return el;
13796 }
13797 }
13798 return true;
13799 };
13800 }
13801 return { resolvedInitialFocus, popupRef };
13802 }
13803
13804 // packages/ui/build-module/lock-unlock.mjs
13805 var import_private_apis = __toESM(require_private_apis(), 1);
13806 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
13807 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
13808 "@wordpress/ui"
13809 );
13810
13811 // packages/ui/build-module/stack/stack.mjs
13812 var import_element31 = __toESM(require_element(), 1);
13813 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
13814 function getRuntime10() {
13815 const globalScope = globalThis;
13816 if (globalScope.__wpStyleRuntime) {
13817 return globalScope.__wpStyleRuntime;
13818 }
13819 globalScope.__wpStyleRuntime = {
13820 documents: /* @__PURE__ */ new Map(),
13821 styles: /* @__PURE__ */ new Map(),
13822 injectedStyles: /* @__PURE__ */ new WeakMap()
13823 };
13824 if (typeof document !== "undefined") {
13825 registerDocument10(document);
13826 }
13827 return globalScope.__wpStyleRuntime;
13828 }
13829 function documentContainsStyleHash10(targetDocument, hash) {
13830 if (!targetDocument.head) {
13831 return false;
13832 }
13833 for (const style of targetDocument.head.querySelectorAll(
13834 `style[${STYLE_HASH_ATTRIBUTE10}]`
13835 )) {
13836 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
13837 return true;
13838 }
13839 }
13840 return false;
13841 }
13842 function injectStyle10(targetDocument, hash, css) {
13843 if (!targetDocument.head) {
13844 return;
13845 }
13846 const runtime = getRuntime10();
13847 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13848 if (!injectedStyles) {
13849 injectedStyles = /* @__PURE__ */ new Set();
13850 runtime.injectedStyles.set(targetDocument, injectedStyles);
13851 }
13852 if (injectedStyles.has(hash)) {
13853 return;
13854 }
13855 if (documentContainsStyleHash10(targetDocument, hash)) {
13856 injectedStyles.add(hash);
13857 return;
13858 }
13859 const style = targetDocument.createElement("style");
13860 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
13861 style.appendChild(targetDocument.createTextNode(css));
13862 targetDocument.head.appendChild(style);
13863 injectedStyles.add(hash);
13864 }
13865 function registerDocument10(targetDocument) {
13866 const runtime = getRuntime10();
13867 runtime.documents.set(
13868 targetDocument,
13869 (runtime.documents.get(targetDocument) ?? 0) + 1
13870 );
13871 for (const [hash, css] of runtime.styles) {
13872 injectStyle10(targetDocument, hash, css);
13873 }
13874 return () => {
13875 const count = runtime.documents.get(targetDocument);
13876 if (count === void 0) {
13877 return;
13878 }
13879 if (count <= 1) {
13880 runtime.documents.delete(targetDocument);
13881 return;
13882 }
13883 runtime.documents.set(targetDocument, count - 1);
13884 };
13885 }
13886 function registerStyle10(hash, css) {
13887 const runtime = getRuntime10();
13888 runtime.styles.set(hash, css);
13889 for (const targetDocument of runtime.documents.keys()) {
13890 injectStyle10(targetDocument, hash, css);
13891 }
13892 }
13893 if (typeof process === "undefined" || true) {
13894 registerStyle10("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
13895 }
13896 var style_default10 = { "stack": "_19ce0419607e1896__stack" };
13897 var gapTokens = {
13898 xs: "var(--wpds-dimension-gap-xs, 4px)",
13899 sm: "var(--wpds-dimension-gap-sm, 8px)",
13900 md: "var(--wpds-dimension-gap-md, 12px)",
13901 lg: "var(--wpds-dimension-gap-lg, 16px)",
13902 xl: "var(--wpds-dimension-gap-xl, 24px)",
13903 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
13904 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
13905 };
13906 var Stack = (0, import_element31.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
13907 const style = {
13908 gap: gap && gapTokens[gap],
13909 alignItems: align,
13910 justifyContent: justify,
13911 flexDirection: direction,
13912 flexWrap: wrap
13913 };
13914 const element = useRender({
13915 render: render4,
13916 ref,
13917 props: mergeProps(props, { style, className: style_default10.stack })
13918 });
13919 return element;
13920 });
13921
13922 // packages/ui/build-module/icon-button/icon-button.mjs
13923 var import_element36 = __toESM(require_element(), 1);
13924
13925 // packages/ui/build-module/tooltip/index.mjs
13926 var tooltip_exports = {};
13927 __export(tooltip_exports, {
13928 Popup: () => Popup,
13929 Portal: () => Portal,
13930 Positioner: () => Positioner,
13931 Provider: () => Provider,
13932 Root: () => Root4,
13933 Trigger: () => Trigger2
13934 });
13935
13936 // packages/ui/build-module/tooltip/popup.mjs
13937 var import_element34 = __toESM(require_element(), 1);
13938 var import_theme = __toESM(require_theme(), 1);
13939
13940 // packages/ui/build-module/tooltip/portal.mjs
13941 var import_element32 = __toESM(require_element(), 1);
13942
13943 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
13944 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
13945 function getRuntime11() {
13946 const globalScope = globalThis;
13947 if (globalScope.__wpStyleRuntime) {
13948 return globalScope.__wpStyleRuntime;
13949 }
13950 globalScope.__wpStyleRuntime = {
13951 documents: /* @__PURE__ */ new Map(),
13952 styles: /* @__PURE__ */ new Map(),
13953 injectedStyles: /* @__PURE__ */ new WeakMap()
13954 };
13955 if (typeof document !== "undefined") {
13956 registerDocument11(document);
13957 }
13958 return globalScope.__wpStyleRuntime;
13959 }
13960 function documentContainsStyleHash11(targetDocument, hash) {
13961 if (!targetDocument.head) {
13962 return false;
13963 }
13964 for (const style of targetDocument.head.querySelectorAll(
13965 `style[${STYLE_HASH_ATTRIBUTE11}]`
13966 )) {
13967 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
13968 return true;
13969 }
13970 }
13971 return false;
13972 }
13973 function injectStyle11(targetDocument, hash, css) {
13974 if (!targetDocument.head) {
13975 return;
13976 }
13977 const runtime = getRuntime11();
13978 let injectedStyles = runtime.injectedStyles.get(targetDocument);
13979 if (!injectedStyles) {
13980 injectedStyles = /* @__PURE__ */ new Set();
13981 runtime.injectedStyles.set(targetDocument, injectedStyles);
13982 }
13983 if (injectedStyles.has(hash)) {
13984 return;
13985 }
13986 if (documentContainsStyleHash11(targetDocument, hash)) {
13987 injectedStyles.add(hash);
13988 return;
13989 }
13990 const style = targetDocument.createElement("style");
13991 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
13992 style.appendChild(targetDocument.createTextNode(css));
13993 targetDocument.head.appendChild(style);
13994 injectedStyles.add(hash);
13995 }
13996 function registerDocument11(targetDocument) {
13997 const runtime = getRuntime11();
13998 runtime.documents.set(
13999 targetDocument,
14000 (runtime.documents.get(targetDocument) ?? 0) + 1
14001 );
14002 for (const [hash, css] of runtime.styles) {
14003 injectStyle11(targetDocument, hash, css);
14004 }
14005 return () => {
14006 const count = runtime.documents.get(targetDocument);
14007 if (count === void 0) {
14008 return;
14009 }
14010 if (count <= 1) {
14011 runtime.documents.delete(targetDocument);
14012 return;
14013 }
14014 runtime.documents.set(targetDocument, count - 1);
14015 };
14016 }
14017 function registerStyle11(hash, css) {
14018 const runtime = getRuntime11();
14019 runtime.styles.set(hash, css);
14020 for (const targetDocument of runtime.documents.keys()) {
14021 injectStyle11(targetDocument, hash, css);
14022 }
14023 }
14024 if (typeof process === "undefined" || true) {
14025 registerStyle11("45eb1fe20f", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui-utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}");
14026 }
14027 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
14028 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
14029 function resolveOwnerDocument() {
14030 return typeof document === "undefined" ? null : document;
14031 }
14032 function isInWordPressEnvironment() {
14033 let topWp;
14034 try {
14035 topWp = window.top?.wp;
14036 } catch {
14037 }
14038 const wp = topWp ?? window.wp;
14039 return typeof wp?.components === "object" && wp.components !== null;
14040 }
14041 var cachedSlot = null;
14042 function createSlot(ownerDocument2) {
14043 const element = ownerDocument2.createElement("div");
14044 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
14045 if (wp_compat_overlay_slot_default.slot) {
14046 element.classList.add(wp_compat_overlay_slot_default.slot);
14047 }
14048 ownerDocument2.body.appendChild(element);
14049 return element;
14050 }
14051 function getWpCompatOverlaySlot() {
14052 if (typeof window === "undefined") {
14053 return void 0;
14054 }
14055 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
14056 return void 0;
14057 }
14058 const ownerDocument2 = resolveOwnerDocument();
14059 if (!ownerDocument2 || !ownerDocument2.body) {
14060 return void 0;
14061 }
14062 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
14063 return cachedSlot;
14064 }
14065 const existing = ownerDocument2.querySelector(
14066 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
14067 );
14068 if (existing instanceof HTMLDivElement) {
14069 cachedSlot = existing;
14070 return existing;
14071 }
14072 if (cachedSlot?.isConnected) {
14073 cachedSlot.remove();
14074 }
14075 cachedSlot = createSlot(ownerDocument2);
14076 return cachedSlot;
14077 }
14078
14079 // packages/ui/build-module/tooltip/portal.mjs
14080 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
14081 var Portal = (0, import_element32.forwardRef)(
14082 function TooltipPortal3({ container, ...restProps }, ref) {
14083 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
14084 index_parts_exports3.Portal,
14085 {
14086 container: container ?? getWpCompatOverlaySlot(),
14087 ...restProps,
14088 ref
14089 }
14090 );
14091 }
14092 );
14093
14094 // packages/ui/build-module/tooltip/positioner.mjs
14095 var import_element33 = __toESM(require_element(), 1);
14096 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
14097 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
14098 function getRuntime12() {
14099 const globalScope = globalThis;
14100 if (globalScope.__wpStyleRuntime) {
14101 return globalScope.__wpStyleRuntime;
14102 }
14103 globalScope.__wpStyleRuntime = {
14104 documents: /* @__PURE__ */ new Map(),
14105 styles: /* @__PURE__ */ new Map(),
14106 injectedStyles: /* @__PURE__ */ new WeakMap()
14107 };
14108 if (typeof document !== "undefined") {
14109 registerDocument12(document);
14110 }
14111 return globalScope.__wpStyleRuntime;
14112 }
14113 function documentContainsStyleHash12(targetDocument, hash) {
14114 if (!targetDocument.head) {
14115 return false;
14116 }
14117 for (const style of targetDocument.head.querySelectorAll(
14118 `style[${STYLE_HASH_ATTRIBUTE12}]`
14119 )) {
14120 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
14121 return true;
14122 }
14123 }
14124 return false;
14125 }
14126 function injectStyle12(targetDocument, hash, css) {
14127 if (!targetDocument.head) {
14128 return;
14129 }
14130 const runtime = getRuntime12();
14131 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14132 if (!injectedStyles) {
14133 injectedStyles = /* @__PURE__ */ new Set();
14134 runtime.injectedStyles.set(targetDocument, injectedStyles);
14135 }
14136 if (injectedStyles.has(hash)) {
14137 return;
14138 }
14139 if (documentContainsStyleHash12(targetDocument, hash)) {
14140 injectedStyles.add(hash);
14141 return;
14142 }
14143 const style = targetDocument.createElement("style");
14144 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
14145 style.appendChild(targetDocument.createTextNode(css));
14146 targetDocument.head.appendChild(style);
14147 injectedStyles.add(hash);
14148 }
14149 function registerDocument12(targetDocument) {
14150 const runtime = getRuntime12();
14151 runtime.documents.set(
14152 targetDocument,
14153 (runtime.documents.get(targetDocument) ?? 0) + 1
14154 );
14155 for (const [hash, css] of runtime.styles) {
14156 injectStyle12(targetDocument, hash, css);
14157 }
14158 return () => {
14159 const count = runtime.documents.get(targetDocument);
14160 if (count === void 0) {
14161 return;
14162 }
14163 if (count <= 1) {
14164 runtime.documents.delete(targetDocument);
14165 return;
14166 }
14167 runtime.documents.set(targetDocument, count - 1);
14168 };
14169 }
14170 function registerStyle12(hash, css) {
14171 const runtime = getRuntime12();
14172 runtime.styles.set(hash, css);
14173 for (const targetDocument of runtime.documents.keys()) {
14174 injectStyle12(targetDocument, hash, css);
14175 }
14176 }
14177 if (typeof process === "undefined" || true) {
14178 registerStyle12("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
14179 }
14180 var resets_default3 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
14181 if (typeof process === "undefined" || true) {
14182 registerStyle12("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-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}}}');
14183 }
14184 var style_default11 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
14185 var Positioner = (0, import_element33.forwardRef)(
14186 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
14187 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
14188 index_parts_exports3.Positioner,
14189 {
14190 ref,
14191 align,
14192 side,
14193 sideOffset,
14194 ...props,
14195 className: clsx_default(
14196 resets_default3["box-sizing"],
14197 style_default11.positioner,
14198 className
14199 )
14200 }
14201 );
14202 }
14203 );
14204
14205 // packages/ui/build-module/tooltip/popup.mjs
14206 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
14207 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
14208 function getRuntime13() {
14209 const globalScope = globalThis;
14210 if (globalScope.__wpStyleRuntime) {
14211 return globalScope.__wpStyleRuntime;
14212 }
14213 globalScope.__wpStyleRuntime = {
14214 documents: /* @__PURE__ */ new Map(),
14215 styles: /* @__PURE__ */ new Map(),
14216 injectedStyles: /* @__PURE__ */ new WeakMap()
14217 };
14218 if (typeof document !== "undefined") {
14219 registerDocument13(document);
14220 }
14221 return globalScope.__wpStyleRuntime;
14222 }
14223 function documentContainsStyleHash13(targetDocument, hash) {
14224 if (!targetDocument.head) {
14225 return false;
14226 }
14227 for (const style of targetDocument.head.querySelectorAll(
14228 `style[${STYLE_HASH_ATTRIBUTE13}]`
14229 )) {
14230 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
14231 return true;
14232 }
14233 }
14234 return false;
14235 }
14236 function injectStyle13(targetDocument, hash, css) {
14237 if (!targetDocument.head) {
14238 return;
14239 }
14240 const runtime = getRuntime13();
14241 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14242 if (!injectedStyles) {
14243 injectedStyles = /* @__PURE__ */ new Set();
14244 runtime.injectedStyles.set(targetDocument, injectedStyles);
14245 }
14246 if (injectedStyles.has(hash)) {
14247 return;
14248 }
14249 if (documentContainsStyleHash13(targetDocument, hash)) {
14250 injectedStyles.add(hash);
14251 return;
14252 }
14253 const style = targetDocument.createElement("style");
14254 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
14255 style.appendChild(targetDocument.createTextNode(css));
14256 targetDocument.head.appendChild(style);
14257 injectedStyles.add(hash);
14258 }
14259 function registerDocument13(targetDocument) {
14260 const runtime = getRuntime13();
14261 runtime.documents.set(
14262 targetDocument,
14263 (runtime.documents.get(targetDocument) ?? 0) + 1
14264 );
14265 for (const [hash, css] of runtime.styles) {
14266 injectStyle13(targetDocument, hash, css);
14267 }
14268 return () => {
14269 const count = runtime.documents.get(targetDocument);
14270 if (count === void 0) {
14271 return;
14272 }
14273 if (count <= 1) {
14274 runtime.documents.delete(targetDocument);
14275 return;
14276 }
14277 runtime.documents.set(targetDocument, count - 1);
14278 };
14279 }
14280 function registerStyle13(hash, css) {
14281 const runtime = getRuntime13();
14282 runtime.styles.set(hash, css);
14283 for (const targetDocument of runtime.documents.keys()) {
14284 injectStyle13(targetDocument, hash, css);
14285 }
14286 }
14287 if (typeof process === "undefined" || true) {
14288 registerStyle13("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-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}}}');
14289 }
14290 var style_default12 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
14291 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider;
14292 var Popup = (0, import_element34.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
14293 const popupContent = (
14294 /* This should ideally use whatever dark color makes sense,
14295 * and not be hardcoded to #1e1e1e. The solutions would be to:
14296 * - review the design of the tooltip, in case we want to stop
14297 * hardcoding it to a dark background
14298 * - create new semantic tokens as needed (aliasing either the
14299 * "inverted bg" or "perma-dark bg" private tokens) and have
14300 * Tooltip.Popup use them;
14301 * - remove the hardcoded `bg` setting from the `ThemeProvider`
14302 * below
14303 */
14304 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ThemeProvider, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
14305 index_parts_exports3.Popup,
14306 {
14307 ref,
14308 className: clsx_default(style_default12.popup, className),
14309 ...props,
14310 children
14311 }
14312 ) })
14313 );
14314 const positionedPopup = renderSlotWithChildren(
14315 positioner,
14316 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Positioner, {}),
14317 popupContent
14318 );
14319 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Portal, {}), positionedPopup);
14320 });
14321
14322 // packages/ui/build-module/tooltip/trigger.mjs
14323 var import_element35 = __toESM(require_element(), 1);
14324 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
14325 var Trigger2 = (0, import_element35.forwardRef)(
14326 function TooltipTrigger3(props, ref) {
14327 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(index_parts_exports3.Trigger, { ref, ...props });
14328 }
14329 );
14330
14331 // packages/ui/build-module/tooltip/root.mjs
14332 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14333 function Root4(props) {
14334 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(index_parts_exports3.Root, { ...props });
14335 }
14336
14337 // packages/ui/build-module/tooltip/provider.mjs
14338 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14339 function Provider({ ...props }) {
14340 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(index_parts_exports3.Provider, { ...props });
14341 }
14342
14343 // packages/ui/build-module/icon-button/icon-button.mjs
14344 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14345 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
14346 function getRuntime14() {
14347 const globalScope = globalThis;
14348 if (globalScope.__wpStyleRuntime) {
14349 return globalScope.__wpStyleRuntime;
14350 }
14351 globalScope.__wpStyleRuntime = {
14352 documents: /* @__PURE__ */ new Map(),
14353 styles: /* @__PURE__ */ new Map(),
14354 injectedStyles: /* @__PURE__ */ new WeakMap()
14355 };
14356 if (typeof document !== "undefined") {
14357 registerDocument14(document);
14358 }
14359 return globalScope.__wpStyleRuntime;
14360 }
14361 function documentContainsStyleHash14(targetDocument, hash) {
14362 if (!targetDocument.head) {
14363 return false;
14364 }
14365 for (const style of targetDocument.head.querySelectorAll(
14366 `style[${STYLE_HASH_ATTRIBUTE14}]`
14367 )) {
14368 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
14369 return true;
14370 }
14371 }
14372 return false;
14373 }
14374 function injectStyle14(targetDocument, hash, css) {
14375 if (!targetDocument.head) {
14376 return;
14377 }
14378 const runtime = getRuntime14();
14379 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14380 if (!injectedStyles) {
14381 injectedStyles = /* @__PURE__ */ new Set();
14382 runtime.injectedStyles.set(targetDocument, injectedStyles);
14383 }
14384 if (injectedStyles.has(hash)) {
14385 return;
14386 }
14387 if (documentContainsStyleHash14(targetDocument, hash)) {
14388 injectedStyles.add(hash);
14389 return;
14390 }
14391 const style = targetDocument.createElement("style");
14392 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
14393 style.appendChild(targetDocument.createTextNode(css));
14394 targetDocument.head.appendChild(style);
14395 injectedStyles.add(hash);
14396 }
14397 function registerDocument14(targetDocument) {
14398 const runtime = getRuntime14();
14399 runtime.documents.set(
14400 targetDocument,
14401 (runtime.documents.get(targetDocument) ?? 0) + 1
14402 );
14403 for (const [hash, css] of runtime.styles) {
14404 injectStyle14(targetDocument, hash, css);
14405 }
14406 return () => {
14407 const count = runtime.documents.get(targetDocument);
14408 if (count === void 0) {
14409 return;
14410 }
14411 if (count <= 1) {
14412 runtime.documents.delete(targetDocument);
14413 return;
14414 }
14415 runtime.documents.set(targetDocument, count - 1);
14416 };
14417 }
14418 function registerStyle14(hash, css) {
14419 const runtime = getRuntime14();
14420 runtime.styles.set(hash, css);
14421 for (const targetDocument of runtime.documents.keys()) {
14422 injectStyle14(targetDocument, hash, css);
14423 }
14424 }
14425 if (typeof process === "undefined" || true) {
14426 registerStyle14("358a2a646a", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-compositions{._28cfdc260e755391__icon-button{--wp-ui-button-aspect-ratio:1;--wp-ui-button-padding-inline:0;--wp-ui-button-min-width:unset}.f1c70d719989a85a__icon{margin:-1px}}");
14427 }
14428 var style_default13 = { "icon-button": "_28cfdc260e755391__icon-button", "icon": "f1c70d719989a85a__icon" };
14429 var IconButton = (0, import_element36.forwardRef)(
14430 function IconButton2({
14431 label,
14432 className,
14433 // Prevent accidental forwarding of `children`
14434 children: _children,
14435 disabled: disabled2,
14436 focusableWhenDisabled = true,
14437 icon,
14438 size: size4,
14439 shortcut,
14440 positioner,
14441 ...restProps
14442 }, ref) {
14443 const classes = clsx_default(style_default13["icon-button"], className);
14444 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Provider, { delay: 0, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Root4, { children: [
14445 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14446 Trigger2,
14447 {
14448 ref,
14449 disabled: disabled2 && !focusableWhenDisabled,
14450 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14451 Button4,
14452 {
14453 ...restProps,
14454 size: size4,
14455 "aria-label": label,
14456 "aria-keyshortcuts": shortcut?.ariaKeyShortcut,
14457 disabled: disabled2,
14458 focusableWhenDisabled
14459 }
14460 ),
14461 className: classes,
14462 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14463 Icon,
14464 {
14465 icon,
14466 size: 24,
14467 className: style_default13.icon
14468 }
14469 )
14470 }
14471 ),
14472 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Popup, { positioner, children: [
14473 label,
14474 shortcut && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
14475 " ",
14476 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { "aria-hidden": "true", children: shortcut.displayShortcut })
14477 ] })
14478 ] })
14479 ] }) });
14480 }
14481 );
14482
14483 // packages/ui/build-module/utils/create-overlay-title-validation.mjs
14484 var import_element38 = __toESM(require_element(), 1);
14485
14486 // packages/ui/build-module/utils/use-schedule-validation.mjs
14487 var import_element37 = __toESM(require_element(), 1);
14488 function useScheduleValidation(validate) {
14489 const validateRef = (0, import_element37.useRef)(validate);
14490 validateRef.current = validate;
14491 const timerRef = (0, import_element37.useRef)(null);
14492 const unmountedRef = (0, import_element37.useRef)(false);
14493 const scheduleValidation = (0, import_element37.useCallback)(() => {
14494 if (unmountedRef.current) {
14495 return;
14496 }
14497 if (timerRef.current) {
14498 clearTimeout(timerRef.current);
14499 }
14500 timerRef.current = setTimeout(() => {
14501 validateRef.current();
14502 timerRef.current = null;
14503 }, 0);
14504 }, []);
14505 (0, import_element37.useEffect)(() => {
14506 unmountedRef.current = false;
14507 return () => {
14508 unmountedRef.current = true;
14509 if (timerRef.current) {
14510 clearTimeout(timerRef.current);
14511 }
14512 };
14513 }, []);
14514 return scheduleValidation;
14515 }
14516
14517 // packages/ui/build-module/utils/create-overlay-title-validation.mjs
14518 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
14519 var VALIDATION_ENABLED = true;
14520 function createOverlayTitleValidation(componentName) {
14521 const componentNameLowerCase = componentName.toLowerCase();
14522 const OverlayValidationContext = VALIDATION_ENABLED ? (0, import_element38.createContext)(null) : null;
14523 function useValidationContextDev() {
14524 return (0, import_element38.useContext)(OverlayValidationContext);
14525 }
14526 function useValidationContextProd() {
14527 return null;
14528 }
14529 const useValidationContext = VALIDATION_ENABLED ? useValidationContextDev : useValidationContextProd;
14530 function ValidationProviderDev({
14531 children
14532 }) {
14533 const titleElementRef = (0, import_element38.useRef)(null);
14534 const scheduleValidation = useScheduleValidation(() => {
14535 const titleElement = titleElementRef.current;
14536 if (!titleElement) {
14537 throw new Error(
14538 `${componentName}: Missing <${componentName}.Title>. For accessibility, every ${componentNameLowerCase} requires a title. If needed, the title can be visually hidden but must not be omitted.`
14539 );
14540 }
14541 const textContent = titleElement.textContent?.trim();
14542 if (!textContent) {
14543 throw new Error(
14544 `${componentName}: <${componentName}.Title> cannot be empty. Provide meaningful text content for the ${componentNameLowerCase} title.`
14545 );
14546 }
14547 });
14548 const registerTitle = (0, import_element38.useCallback)(
14549 (element) => {
14550 titleElementRef.current = element;
14551 scheduleValidation();
14552 return () => {
14553 titleElementRef.current = null;
14554 scheduleValidation();
14555 };
14556 },
14557 [scheduleValidation]
14558 );
14559 const contextValue = (0, import_element38.useMemo)(
14560 () => ({ registerTitle }),
14561 [registerTitle]
14562 );
14563 (0, import_element38.useEffect)(() => {
14564 scheduleValidation();
14565 }, [scheduleValidation]);
14566 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(OverlayValidationContext.Provider, { value: contextValue, children });
14567 }
14568 function ValidationProviderProd({
14569 children
14570 }) {
14571 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_jsx_runtime69.Fragment, { children });
14572 }
14573 const ValidationProvider = VALIDATION_ENABLED ? ValidationProviderDev : ValidationProviderProd;
14574 return {
14575 ValidationProvider,
14576 useValidationContext
14577 };
14578 }
14579
14580 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
14581 var import_element39 = __toESM(require_element(), 1);
14582 var STYLE_HASH_ATTRIBUTE15 = "data-wp-hash";
14583 function getRuntime15() {
14584 const globalScope = globalThis;
14585 if (globalScope.__wpStyleRuntime) {
14586 return globalScope.__wpStyleRuntime;
14587 }
14588 globalScope.__wpStyleRuntime = {
14589 documents: /* @__PURE__ */ new Map(),
14590 styles: /* @__PURE__ */ new Map(),
14591 injectedStyles: /* @__PURE__ */ new WeakMap()
14592 };
14593 if (typeof document !== "undefined") {
14594 registerDocument15(document);
14595 }
14596 return globalScope.__wpStyleRuntime;
14597 }
14598 function documentContainsStyleHash15(targetDocument, hash) {
14599 if (!targetDocument.head) {
14600 return false;
14601 }
14602 for (const style of targetDocument.head.querySelectorAll(
14603 `style[${STYLE_HASH_ATTRIBUTE15}]`
14604 )) {
14605 if (style.getAttribute(STYLE_HASH_ATTRIBUTE15) === hash) {
14606 return true;
14607 }
14608 }
14609 return false;
14610 }
14611 function injectStyle15(targetDocument, hash, css) {
14612 if (!targetDocument.head) {
14613 return;
14614 }
14615 const runtime = getRuntime15();
14616 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14617 if (!injectedStyles) {
14618 injectedStyles = /* @__PURE__ */ new Set();
14619 runtime.injectedStyles.set(targetDocument, injectedStyles);
14620 }
14621 if (injectedStyles.has(hash)) {
14622 return;
14623 }
14624 if (documentContainsStyleHash15(targetDocument, hash)) {
14625 injectedStyles.add(hash);
14626 return;
14627 }
14628 const style = targetDocument.createElement("style");
14629 style.setAttribute(STYLE_HASH_ATTRIBUTE15, hash);
14630 style.appendChild(targetDocument.createTextNode(css));
14631 targetDocument.head.appendChild(style);
14632 injectedStyles.add(hash);
14633 }
14634 function registerDocument15(targetDocument) {
14635 const runtime = getRuntime15();
14636 runtime.documents.set(
14637 targetDocument,
14638 (runtime.documents.get(targetDocument) ?? 0) + 1
14639 );
14640 for (const [hash, css] of runtime.styles) {
14641 injectStyle15(targetDocument, hash, css);
14642 }
14643 return () => {
14644 const count = runtime.documents.get(targetDocument);
14645 if (count === void 0) {
14646 return;
14647 }
14648 if (count <= 1) {
14649 runtime.documents.delete(targetDocument);
14650 return;
14651 }
14652 runtime.documents.set(targetDocument, count - 1);
14653 };
14654 }
14655 function registerStyle15(hash, css) {
14656 const runtime = getRuntime15();
14657 runtime.styles.set(hash, css);
14658 for (const targetDocument of runtime.documents.keys()) {
14659 injectStyle15(targetDocument, hash, css);
14660 }
14661 }
14662 if (typeof process === "undefined" || true) {
14663 registerStyle15("c46e8cb841", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-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}}");
14664 }
14665 var style_default14 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
14666 var VisuallyHidden = (0, import_element39.forwardRef)(
14667 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
14668 const element = useRender({
14669 render: render4,
14670 ref,
14671 props: mergeProps(
14672 { className: style_default14["visually-hidden"] },
14673 restProps,
14674 {
14675 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
14676 "data-visually-hidden": ""
14677 }
14678 )
14679 });
14680 return element;
14681 }
14682 );
14683
14684 // packages/ui/build-module/link/link.mjs
14685 var import_element40 = __toESM(require_element(), 1);
14686 var import_i18n2 = __toESM(require_i18n(), 1);
14687 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
14688 var STYLE_HASH_ATTRIBUTE16 = "data-wp-hash";
14689 function getRuntime16() {
14690 const globalScope = globalThis;
14691 if (globalScope.__wpStyleRuntime) {
14692 return globalScope.__wpStyleRuntime;
14693 }
14694 globalScope.__wpStyleRuntime = {
14695 documents: /* @__PURE__ */ new Map(),
14696 styles: /* @__PURE__ */ new Map(),
14697 injectedStyles: /* @__PURE__ */ new WeakMap()
14698 };
14699 if (typeof document !== "undefined") {
14700 registerDocument16(document);
14701 }
14702 return globalScope.__wpStyleRuntime;
14703 }
14704 function documentContainsStyleHash16(targetDocument, hash) {
14705 if (!targetDocument.head) {
14706 return false;
14707 }
14708 for (const style of targetDocument.head.querySelectorAll(
14709 `style[${STYLE_HASH_ATTRIBUTE16}]`
14710 )) {
14711 if (style.getAttribute(STYLE_HASH_ATTRIBUTE16) === hash) {
14712 return true;
14713 }
14714 }
14715 return false;
14716 }
14717 function injectStyle16(targetDocument, hash, css) {
14718 if (!targetDocument.head) {
14719 return;
14720 }
14721 const runtime = getRuntime16();
14722 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14723 if (!injectedStyles) {
14724 injectedStyles = /* @__PURE__ */ new Set();
14725 runtime.injectedStyles.set(targetDocument, injectedStyles);
14726 }
14727 if (injectedStyles.has(hash)) {
14728 return;
14729 }
14730 if (documentContainsStyleHash16(targetDocument, hash)) {
14731 injectedStyles.add(hash);
14732 return;
14733 }
14734 const style = targetDocument.createElement("style");
14735 style.setAttribute(STYLE_HASH_ATTRIBUTE16, hash);
14736 style.appendChild(targetDocument.createTextNode(css));
14737 targetDocument.head.appendChild(style);
14738 injectedStyles.add(hash);
14739 }
14740 function registerDocument16(targetDocument) {
14741 const runtime = getRuntime16();
14742 runtime.documents.set(
14743 targetDocument,
14744 (runtime.documents.get(targetDocument) ?? 0) + 1
14745 );
14746 for (const [hash, css] of runtime.styles) {
14747 injectStyle16(targetDocument, hash, css);
14748 }
14749 return () => {
14750 const count = runtime.documents.get(targetDocument);
14751 if (count === void 0) {
14752 return;
14753 }
14754 if (count <= 1) {
14755 runtime.documents.delete(targetDocument);
14756 return;
14757 }
14758 runtime.documents.set(targetDocument, count - 1);
14759 };
14760 }
14761 function registerStyle16(hash, css) {
14762 const runtime = getRuntime16();
14763 runtime.styles.set(hash, css);
14764 for (const targetDocument of runtime.documents.keys()) {
14765 injectStyle16(targetDocument, hash, css);
14766 }
14767 }
14768 if (typeof process === "undefined" || true) {
14769 registerStyle16("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
14770 }
14771 var resets_default4 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
14772 if (typeof process === "undefined" || true) {
14773 registerStyle16("2a5ab8f3a7", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._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-brand,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-brand,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-brand,var(--wp-admin-theme-color,#3858e9))}}");
14774 }
14775 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" };
14776 if (typeof process === "undefined" || true) {
14777 registerStyle16("90a23568f8", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-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-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);color:var(--wpds-color-fg-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-fg-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-regular,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}');
14778 }
14779 var style_default15 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
14780 if (typeof process === "undefined" || true) {
14781 registerStyle16("1fb29d3a3c", "._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,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-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,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-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 #0000)}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-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
14782 }
14783 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" };
14784 var Link = (0, import_element40.forwardRef)(function Link2({
14785 children,
14786 variant = "default",
14787 tone = "brand",
14788 openInNewTab = false,
14789 render: render4,
14790 className,
14791 ...props
14792 }, ref) {
14793 const element = useRender({
14794 render: render4,
14795 defaultTagName: "a",
14796 ref,
14797 props: mergeProps(props, {
14798 className: clsx_default(
14799 global_css_defense_default4.a,
14800 resets_default4["box-sizing"],
14801 focus_default3["outset-ring--focus"],
14802 variant !== "unstyled" && style_default15.link,
14803 variant !== "unstyled" && style_default15[`is-${tone}`],
14804 variant === "unstyled" && style_default15["is-unstyled"],
14805 className
14806 ),
14807 target: openInNewTab ? "_blank" : void 0,
14808 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
14809 children,
14810 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14811 "span",
14812 {
14813 className: style_default15["link-icon"],
14814 role: "img",
14815 "aria-label": (
14816 /* translators: accessibility text appended to link text */
14817 (0, import_i18n2.__)("(opens in a new tab)")
14818 )
14819 }
14820 )
14821 ] })
14822 })
14823 });
14824 return element;
14825 });
14826
14827 // packages/ui/build-module/notice/index.mjs
14828 var notice_exports = {};
14829 __export(notice_exports, {
14830 ActionButton: () => ActionButton,
14831 ActionLink: () => ActionLink,
14832 Actions: () => Actions,
14833 CloseIcon: () => CloseIcon,
14834 Description: () => Description,
14835 Root: () => Root5,
14836 Title: () => Title2
14837 });
14838
14839 // packages/ui/build-module/notice/root.mjs
14840 var import_element41 = __toESM(require_element(), 1);
14841 import { speak as speak2 } from "@wordpress/a11y";
14842 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
14843 var STYLE_HASH_ATTRIBUTE17 = "data-wp-hash";
14844 function getRuntime17() {
14845 const globalScope = globalThis;
14846 if (globalScope.__wpStyleRuntime) {
14847 return globalScope.__wpStyleRuntime;
14848 }
14849 globalScope.__wpStyleRuntime = {
14850 documents: /* @__PURE__ */ new Map(),
14851 styles: /* @__PURE__ */ new Map(),
14852 injectedStyles: /* @__PURE__ */ new WeakMap()
14853 };
14854 if (typeof document !== "undefined") {
14855 registerDocument17(document);
14856 }
14857 return globalScope.__wpStyleRuntime;
14858 }
14859 function documentContainsStyleHash17(targetDocument, hash) {
14860 if (!targetDocument.head) {
14861 return false;
14862 }
14863 for (const style of targetDocument.head.querySelectorAll(
14864 `style[${STYLE_HASH_ATTRIBUTE17}]`
14865 )) {
14866 if (style.getAttribute(STYLE_HASH_ATTRIBUTE17) === hash) {
14867 return true;
14868 }
14869 }
14870 return false;
14871 }
14872 function injectStyle17(targetDocument, hash, css) {
14873 if (!targetDocument.head) {
14874 return;
14875 }
14876 const runtime = getRuntime17();
14877 let injectedStyles = runtime.injectedStyles.get(targetDocument);
14878 if (!injectedStyles) {
14879 injectedStyles = /* @__PURE__ */ new Set();
14880 runtime.injectedStyles.set(targetDocument, injectedStyles);
14881 }
14882 if (injectedStyles.has(hash)) {
14883 return;
14884 }
14885 if (documentContainsStyleHash17(targetDocument, hash)) {
14886 injectedStyles.add(hash);
14887 return;
14888 }
14889 const style = targetDocument.createElement("style");
14890 style.setAttribute(STYLE_HASH_ATTRIBUTE17, hash);
14891 style.appendChild(targetDocument.createTextNode(css));
14892 targetDocument.head.appendChild(style);
14893 injectedStyles.add(hash);
14894 }
14895 function registerDocument17(targetDocument) {
14896 const runtime = getRuntime17();
14897 runtime.documents.set(
14898 targetDocument,
14899 (runtime.documents.get(targetDocument) ?? 0) + 1
14900 );
14901 for (const [hash, css] of runtime.styles) {
14902 injectStyle17(targetDocument, hash, css);
14903 }
14904 return () => {
14905 const count = runtime.documents.get(targetDocument);
14906 if (count === void 0) {
14907 return;
14908 }
14909 if (count <= 1) {
14910 runtime.documents.delete(targetDocument);
14911 return;
14912 }
14913 runtime.documents.set(targetDocument, count - 1);
14914 };
14915 }
14916 function registerStyle17(hash, css) {
14917 const runtime = getRuntime17();
14918 runtime.styles.set(hash, css);
14919 for (const targetDocument of runtime.documents.keys()) {
14920 injectStyle17(targetDocument, hash, css);
14921 }
14922 }
14923 if (typeof process === "undefined" || true) {
14924 registerStyle17("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
14925 }
14926 var resets_default5 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
14927 if (typeof process === "undefined" || true) {
14928 registerStyle17("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer wp-ui-compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
14929 }
14930 var style_default16 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
14931 var icons = {
14932 neutral: null,
14933 info: info_default,
14934 warning: caution_default,
14935 success: published_default,
14936 error: error_default
14937 };
14938 function getDefaultPoliteness(intent) {
14939 return intent === "error" ? "assertive" : "polite";
14940 }
14941 function safeRenderToString(message2) {
14942 if (!message2) {
14943 return void 0;
14944 }
14945 if (typeof message2 === "string") {
14946 return message2;
14947 }
14948 try {
14949 return (0, import_element41.renderToString)(message2);
14950 } catch {
14951 return void 0;
14952 }
14953 }
14954 function useSpokenMessage(message2, politeness) {
14955 const spokenMessage = safeRenderToString(message2);
14956 (0, import_element41.useEffect)(() => {
14957 if (spokenMessage) {
14958 speak2(spokenMessage, politeness);
14959 }
14960 }, [spokenMessage, politeness]);
14961 }
14962 var Root5 = (0, import_element41.forwardRef)(function Notice({
14963 intent = "neutral",
14964 children,
14965 icon,
14966 spokenMessage = children,
14967 politeness = getDefaultPoliteness(intent),
14968 render: render4,
14969 ...restProps
14970 }, ref) {
14971 useSpokenMessage(spokenMessage, politeness);
14972 const iconElement = icon === null ? null : icon ?? icons[intent];
14973 const mergedClassName = clsx_default(
14974 style_default16.notice,
14975 style_default16[`is-${intent}`],
14976 resets_default5["box-sizing"]
14977 );
14978 const element = useRender({
14979 defaultTagName: "div",
14980 render: render4,
14981 ref,
14982 props: mergeProps(
14983 {
14984 className: mergedClassName,
14985 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
14986 children,
14987 iconElement && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14988 Icon,
14989 {
14990 className: style_default16.icon,
14991 icon: iconElement
14992 }
14993 )
14994 ] })
14995 },
14996 restProps
14997 )
14998 });
14999 return element;
15000 });
15001
15002 // packages/ui/build-module/notice/title.mjs
15003 var import_element42 = __toESM(require_element(), 1);
15004 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
15005 var STYLE_HASH_ATTRIBUTE18 = "data-wp-hash";
15006 function getRuntime18() {
15007 const globalScope = globalThis;
15008 if (globalScope.__wpStyleRuntime) {
15009 return globalScope.__wpStyleRuntime;
15010 }
15011 globalScope.__wpStyleRuntime = {
15012 documents: /* @__PURE__ */ new Map(),
15013 styles: /* @__PURE__ */ new Map(),
15014 injectedStyles: /* @__PURE__ */ new WeakMap()
15015 };
15016 if (typeof document !== "undefined") {
15017 registerDocument18(document);
15018 }
15019 return globalScope.__wpStyleRuntime;
15020 }
15021 function documentContainsStyleHash18(targetDocument, hash) {
15022 if (!targetDocument.head) {
15023 return false;
15024 }
15025 for (const style of targetDocument.head.querySelectorAll(
15026 `style[${STYLE_HASH_ATTRIBUTE18}]`
15027 )) {
15028 if (style.getAttribute(STYLE_HASH_ATTRIBUTE18) === hash) {
15029 return true;
15030 }
15031 }
15032 return false;
15033 }
15034 function injectStyle18(targetDocument, hash, css) {
15035 if (!targetDocument.head) {
15036 return;
15037 }
15038 const runtime = getRuntime18();
15039 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15040 if (!injectedStyles) {
15041 injectedStyles = /* @__PURE__ */ new Set();
15042 runtime.injectedStyles.set(targetDocument, injectedStyles);
15043 }
15044 if (injectedStyles.has(hash)) {
15045 return;
15046 }
15047 if (documentContainsStyleHash18(targetDocument, hash)) {
15048 injectedStyles.add(hash);
15049 return;
15050 }
15051 const style = targetDocument.createElement("style");
15052 style.setAttribute(STYLE_HASH_ATTRIBUTE18, hash);
15053 style.appendChild(targetDocument.createTextNode(css));
15054 targetDocument.head.appendChild(style);
15055 injectedStyles.add(hash);
15056 }
15057 function registerDocument18(targetDocument) {
15058 const runtime = getRuntime18();
15059 runtime.documents.set(
15060 targetDocument,
15061 (runtime.documents.get(targetDocument) ?? 0) + 1
15062 );
15063 for (const [hash, css] of runtime.styles) {
15064 injectStyle18(targetDocument, hash, css);
15065 }
15066 return () => {
15067 const count = runtime.documents.get(targetDocument);
15068 if (count === void 0) {
15069 return;
15070 }
15071 if (count <= 1) {
15072 runtime.documents.delete(targetDocument);
15073 return;
15074 }
15075 runtime.documents.set(targetDocument, count - 1);
15076 };
15077 }
15078 function registerStyle18(hash, css) {
15079 const runtime = getRuntime18();
15080 runtime.styles.set(hash, css);
15081 for (const targetDocument of runtime.documents.keys()) {
15082 injectStyle18(targetDocument, hash, css);
15083 }
15084 }
15085 if (typeof process === "undefined" || true) {
15086 registerStyle18("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer wp-ui-compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15087 }
15088 var style_default17 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15089 var Title2 = (0, import_element42.forwardRef)(
15090 function NoticeTitle({ className, ...props }, ref) {
15091 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
15092 Text,
15093 {
15094 ref,
15095 variant: "heading-md",
15096 className: clsx_default(style_default17.title, className),
15097 ...props
15098 }
15099 );
15100 }
15101 );
15102
15103 // packages/ui/build-module/notice/description.mjs
15104 var import_element43 = __toESM(require_element(), 1);
15105 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
15106 var STYLE_HASH_ATTRIBUTE19 = "data-wp-hash";
15107 function getRuntime19() {
15108 const globalScope = globalThis;
15109 if (globalScope.__wpStyleRuntime) {
15110 return globalScope.__wpStyleRuntime;
15111 }
15112 globalScope.__wpStyleRuntime = {
15113 documents: /* @__PURE__ */ new Map(),
15114 styles: /* @__PURE__ */ new Map(),
15115 injectedStyles: /* @__PURE__ */ new WeakMap()
15116 };
15117 if (typeof document !== "undefined") {
15118 registerDocument19(document);
15119 }
15120 return globalScope.__wpStyleRuntime;
15121 }
15122 function documentContainsStyleHash19(targetDocument, hash) {
15123 if (!targetDocument.head) {
15124 return false;
15125 }
15126 for (const style of targetDocument.head.querySelectorAll(
15127 `style[${STYLE_HASH_ATTRIBUTE19}]`
15128 )) {
15129 if (style.getAttribute(STYLE_HASH_ATTRIBUTE19) === hash) {
15130 return true;
15131 }
15132 }
15133 return false;
15134 }
15135 function injectStyle19(targetDocument, hash, css) {
15136 if (!targetDocument.head) {
15137 return;
15138 }
15139 const runtime = getRuntime19();
15140 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15141 if (!injectedStyles) {
15142 injectedStyles = /* @__PURE__ */ new Set();
15143 runtime.injectedStyles.set(targetDocument, injectedStyles);
15144 }
15145 if (injectedStyles.has(hash)) {
15146 return;
15147 }
15148 if (documentContainsStyleHash19(targetDocument, hash)) {
15149 injectedStyles.add(hash);
15150 return;
15151 }
15152 const style = targetDocument.createElement("style");
15153 style.setAttribute(STYLE_HASH_ATTRIBUTE19, hash);
15154 style.appendChild(targetDocument.createTextNode(css));
15155 targetDocument.head.appendChild(style);
15156 injectedStyles.add(hash);
15157 }
15158 function registerDocument19(targetDocument) {
15159 const runtime = getRuntime19();
15160 runtime.documents.set(
15161 targetDocument,
15162 (runtime.documents.get(targetDocument) ?? 0) + 1
15163 );
15164 for (const [hash, css] of runtime.styles) {
15165 injectStyle19(targetDocument, hash, css);
15166 }
15167 return () => {
15168 const count = runtime.documents.get(targetDocument);
15169 if (count === void 0) {
15170 return;
15171 }
15172 if (count <= 1) {
15173 runtime.documents.delete(targetDocument);
15174 return;
15175 }
15176 runtime.documents.set(targetDocument, count - 1);
15177 };
15178 }
15179 function registerStyle19(hash, css) {
15180 const runtime = getRuntime19();
15181 runtime.styles.set(hash, css);
15182 for (const targetDocument of runtime.documents.keys()) {
15183 injectStyle19(targetDocument, hash, css);
15184 }
15185 }
15186 if (typeof process === "undefined" || true) {
15187 registerStyle19("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer wp-ui-compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15188 }
15189 var style_default18 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15190 var Description = (0, import_element43.forwardRef)(
15191 function NoticeDescription({ className, ...props }, ref) {
15192 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
15193 Text,
15194 {
15195 ref,
15196 variant: "body-md",
15197 className: clsx_default(style_default18.description, className),
15198 ...props
15199 }
15200 );
15201 }
15202 );
15203
15204 // packages/ui/build-module/notice/actions.mjs
15205 var import_element44 = __toESM(require_element(), 1);
15206 var STYLE_HASH_ATTRIBUTE20 = "data-wp-hash";
15207 function getRuntime20() {
15208 const globalScope = globalThis;
15209 if (globalScope.__wpStyleRuntime) {
15210 return globalScope.__wpStyleRuntime;
15211 }
15212 globalScope.__wpStyleRuntime = {
15213 documents: /* @__PURE__ */ new Map(),
15214 styles: /* @__PURE__ */ new Map(),
15215 injectedStyles: /* @__PURE__ */ new WeakMap()
15216 };
15217 if (typeof document !== "undefined") {
15218 registerDocument20(document);
15219 }
15220 return globalScope.__wpStyleRuntime;
15221 }
15222 function documentContainsStyleHash20(targetDocument, hash) {
15223 if (!targetDocument.head) {
15224 return false;
15225 }
15226 for (const style of targetDocument.head.querySelectorAll(
15227 `style[${STYLE_HASH_ATTRIBUTE20}]`
15228 )) {
15229 if (style.getAttribute(STYLE_HASH_ATTRIBUTE20) === hash) {
15230 return true;
15231 }
15232 }
15233 return false;
15234 }
15235 function injectStyle20(targetDocument, hash, css) {
15236 if (!targetDocument.head) {
15237 return;
15238 }
15239 const runtime = getRuntime20();
15240 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15241 if (!injectedStyles) {
15242 injectedStyles = /* @__PURE__ */ new Set();
15243 runtime.injectedStyles.set(targetDocument, injectedStyles);
15244 }
15245 if (injectedStyles.has(hash)) {
15246 return;
15247 }
15248 if (documentContainsStyleHash20(targetDocument, hash)) {
15249 injectedStyles.add(hash);
15250 return;
15251 }
15252 const style = targetDocument.createElement("style");
15253 style.setAttribute(STYLE_HASH_ATTRIBUTE20, hash);
15254 style.appendChild(targetDocument.createTextNode(css));
15255 targetDocument.head.appendChild(style);
15256 injectedStyles.add(hash);
15257 }
15258 function registerDocument20(targetDocument) {
15259 const runtime = getRuntime20();
15260 runtime.documents.set(
15261 targetDocument,
15262 (runtime.documents.get(targetDocument) ?? 0) + 1
15263 );
15264 for (const [hash, css] of runtime.styles) {
15265 injectStyle20(targetDocument, hash, css);
15266 }
15267 return () => {
15268 const count = runtime.documents.get(targetDocument);
15269 if (count === void 0) {
15270 return;
15271 }
15272 if (count <= 1) {
15273 runtime.documents.delete(targetDocument);
15274 return;
15275 }
15276 runtime.documents.set(targetDocument, count - 1);
15277 };
15278 }
15279 function registerStyle20(hash, css) {
15280 const runtime = getRuntime20();
15281 runtime.styles.set(hash, css);
15282 for (const targetDocument of runtime.documents.keys()) {
15283 injectStyle20(targetDocument, hash, css);
15284 }
15285 }
15286 if (typeof process === "undefined" || true) {
15287 registerStyle20("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer wp-ui-compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15288 }
15289 var style_default19 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15290 var Actions = (0, import_element44.forwardRef)(
15291 function NoticeActions({ render: render4, ...props }, ref) {
15292 const element = useRender({
15293 defaultTagName: "div",
15294 render: render4,
15295 ref,
15296 props: mergeProps(
15297 {
15298 className: style_default19.actions
15299 },
15300 props
15301 )
15302 });
15303 return element;
15304 }
15305 );
15306
15307 // packages/ui/build-module/notice/close-icon.mjs
15308 var import_element45 = __toESM(require_element(), 1);
15309 var import_i18n3 = __toESM(require_i18n(), 1);
15310 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
15311 var STYLE_HASH_ATTRIBUTE21 = "data-wp-hash";
15312 function getRuntime21() {
15313 const globalScope = globalThis;
15314 if (globalScope.__wpStyleRuntime) {
15315 return globalScope.__wpStyleRuntime;
15316 }
15317 globalScope.__wpStyleRuntime = {
15318 documents: /* @__PURE__ */ new Map(),
15319 styles: /* @__PURE__ */ new Map(),
15320 injectedStyles: /* @__PURE__ */ new WeakMap()
15321 };
15322 if (typeof document !== "undefined") {
15323 registerDocument21(document);
15324 }
15325 return globalScope.__wpStyleRuntime;
15326 }
15327 function documentContainsStyleHash21(targetDocument, hash) {
15328 if (!targetDocument.head) {
15329 return false;
15330 }
15331 for (const style of targetDocument.head.querySelectorAll(
15332 `style[${STYLE_HASH_ATTRIBUTE21}]`
15333 )) {
15334 if (style.getAttribute(STYLE_HASH_ATTRIBUTE21) === hash) {
15335 return true;
15336 }
15337 }
15338 return false;
15339 }
15340 function injectStyle21(targetDocument, hash, css) {
15341 if (!targetDocument.head) {
15342 return;
15343 }
15344 const runtime = getRuntime21();
15345 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15346 if (!injectedStyles) {
15347 injectedStyles = /* @__PURE__ */ new Set();
15348 runtime.injectedStyles.set(targetDocument, injectedStyles);
15349 }
15350 if (injectedStyles.has(hash)) {
15351 return;
15352 }
15353 if (documentContainsStyleHash21(targetDocument, hash)) {
15354 injectedStyles.add(hash);
15355 return;
15356 }
15357 const style = targetDocument.createElement("style");
15358 style.setAttribute(STYLE_HASH_ATTRIBUTE21, hash);
15359 style.appendChild(targetDocument.createTextNode(css));
15360 targetDocument.head.appendChild(style);
15361 injectedStyles.add(hash);
15362 }
15363 function registerDocument21(targetDocument) {
15364 const runtime = getRuntime21();
15365 runtime.documents.set(
15366 targetDocument,
15367 (runtime.documents.get(targetDocument) ?? 0) + 1
15368 );
15369 for (const [hash, css] of runtime.styles) {
15370 injectStyle21(targetDocument, hash, css);
15371 }
15372 return () => {
15373 const count = runtime.documents.get(targetDocument);
15374 if (count === void 0) {
15375 return;
15376 }
15377 if (count <= 1) {
15378 runtime.documents.delete(targetDocument);
15379 return;
15380 }
15381 runtime.documents.set(targetDocument, count - 1);
15382 };
15383 }
15384 function registerStyle21(hash, css) {
15385 const runtime = getRuntime21();
15386 runtime.styles.set(hash, css);
15387 for (const targetDocument of runtime.documents.keys()) {
15388 injectStyle21(targetDocument, hash, css);
15389 }
15390 }
15391 if (typeof process === "undefined" || true) {
15392 registerStyle21("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer wp-ui-compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15393 }
15394 var style_default20 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15395 var CloseIcon = (0, import_element45.forwardRef)(
15396 function NoticeCloseIcon({ className, icon = close_small_default, label = (0, import_i18n3.__)("Dismiss"), ...props }, ref) {
15397 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
15398 IconButton,
15399 {
15400 ...props,
15401 ref,
15402 className: clsx_default(style_default20["close-icon"], className),
15403 variant: "minimal",
15404 size: "small",
15405 tone: "neutral",
15406 icon,
15407 label
15408 }
15409 );
15410 }
15411 );
15412
15413 // packages/ui/build-module/notice/action-button.mjs
15414 var import_element46 = __toESM(require_element(), 1);
15415 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
15416 var STYLE_HASH_ATTRIBUTE22 = "data-wp-hash";
15417 function getRuntime22() {
15418 const globalScope = globalThis;
15419 if (globalScope.__wpStyleRuntime) {
15420 return globalScope.__wpStyleRuntime;
15421 }
15422 globalScope.__wpStyleRuntime = {
15423 documents: /* @__PURE__ */ new Map(),
15424 styles: /* @__PURE__ */ new Map(),
15425 injectedStyles: /* @__PURE__ */ new WeakMap()
15426 };
15427 if (typeof document !== "undefined") {
15428 registerDocument22(document);
15429 }
15430 return globalScope.__wpStyleRuntime;
15431 }
15432 function documentContainsStyleHash22(targetDocument, hash) {
15433 if (!targetDocument.head) {
15434 return false;
15435 }
15436 for (const style of targetDocument.head.querySelectorAll(
15437 `style[${STYLE_HASH_ATTRIBUTE22}]`
15438 )) {
15439 if (style.getAttribute(STYLE_HASH_ATTRIBUTE22) === hash) {
15440 return true;
15441 }
15442 }
15443 return false;
15444 }
15445 function injectStyle22(targetDocument, hash, css) {
15446 if (!targetDocument.head) {
15447 return;
15448 }
15449 const runtime = getRuntime22();
15450 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15451 if (!injectedStyles) {
15452 injectedStyles = /* @__PURE__ */ new Set();
15453 runtime.injectedStyles.set(targetDocument, injectedStyles);
15454 }
15455 if (injectedStyles.has(hash)) {
15456 return;
15457 }
15458 if (documentContainsStyleHash22(targetDocument, hash)) {
15459 injectedStyles.add(hash);
15460 return;
15461 }
15462 const style = targetDocument.createElement("style");
15463 style.setAttribute(STYLE_HASH_ATTRIBUTE22, hash);
15464 style.appendChild(targetDocument.createTextNode(css));
15465 targetDocument.head.appendChild(style);
15466 injectedStyles.add(hash);
15467 }
15468 function registerDocument22(targetDocument) {
15469 const runtime = getRuntime22();
15470 runtime.documents.set(
15471 targetDocument,
15472 (runtime.documents.get(targetDocument) ?? 0) + 1
15473 );
15474 for (const [hash, css] of runtime.styles) {
15475 injectStyle22(targetDocument, hash, css);
15476 }
15477 return () => {
15478 const count = runtime.documents.get(targetDocument);
15479 if (count === void 0) {
15480 return;
15481 }
15482 if (count <= 1) {
15483 runtime.documents.delete(targetDocument);
15484 return;
15485 }
15486 runtime.documents.set(targetDocument, count - 1);
15487 };
15488 }
15489 function registerStyle22(hash, css) {
15490 const runtime = getRuntime22();
15491 runtime.styles.set(hash, css);
15492 for (const targetDocument of runtime.documents.keys()) {
15493 injectStyle22(targetDocument, hash, css);
15494 }
15495 }
15496 if (typeof process === "undefined" || true) {
15497 registerStyle22("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer wp-ui-compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15498 }
15499 var style_default21 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15500 var ActionButton = (0, import_element46.forwardRef)(
15501 function NoticeActionButton({ className, loading, loadingAnnouncement, variant, ...props }, ref) {
15502 const loadingProps = loading !== void 0 ? { loading, loadingAnnouncement: loadingAnnouncement ?? "" } : {};
15503 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15504 Button4,
15505 {
15506 ...props,
15507 ...loadingProps,
15508 ref,
15509 size: "compact",
15510 tone: "neutral",
15511 variant,
15512 className: clsx_default(
15513 style_default21["action-button"],
15514 style_default21[`is-action-button-${variant}`],
15515 className
15516 )
15517 }
15518 );
15519 }
15520 );
15521
15522 // packages/ui/build-module/notice/action-link.mjs
15523 var import_element47 = __toESM(require_element(), 1);
15524 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
15525 var STYLE_HASH_ATTRIBUTE23 = "data-wp-hash";
15526 function getRuntime23() {
15527 const globalScope = globalThis;
15528 if (globalScope.__wpStyleRuntime) {
15529 return globalScope.__wpStyleRuntime;
15530 }
15531 globalScope.__wpStyleRuntime = {
15532 documents: /* @__PURE__ */ new Map(),
15533 styles: /* @__PURE__ */ new Map(),
15534 injectedStyles: /* @__PURE__ */ new WeakMap()
15535 };
15536 if (typeof document !== "undefined") {
15537 registerDocument23(document);
15538 }
15539 return globalScope.__wpStyleRuntime;
15540 }
15541 function documentContainsStyleHash23(targetDocument, hash) {
15542 if (!targetDocument.head) {
15543 return false;
15544 }
15545 for (const style of targetDocument.head.querySelectorAll(
15546 `style[${STYLE_HASH_ATTRIBUTE23}]`
15547 )) {
15548 if (style.getAttribute(STYLE_HASH_ATTRIBUTE23) === hash) {
15549 return true;
15550 }
15551 }
15552 return false;
15553 }
15554 function injectStyle23(targetDocument, hash, css) {
15555 if (!targetDocument.head) {
15556 return;
15557 }
15558 const runtime = getRuntime23();
15559 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15560 if (!injectedStyles) {
15561 injectedStyles = /* @__PURE__ */ new Set();
15562 runtime.injectedStyles.set(targetDocument, injectedStyles);
15563 }
15564 if (injectedStyles.has(hash)) {
15565 return;
15566 }
15567 if (documentContainsStyleHash23(targetDocument, hash)) {
15568 injectedStyles.add(hash);
15569 return;
15570 }
15571 const style = targetDocument.createElement("style");
15572 style.setAttribute(STYLE_HASH_ATTRIBUTE23, hash);
15573 style.appendChild(targetDocument.createTextNode(css));
15574 targetDocument.head.appendChild(style);
15575 injectedStyles.add(hash);
15576 }
15577 function registerDocument23(targetDocument) {
15578 const runtime = getRuntime23();
15579 runtime.documents.set(
15580 targetDocument,
15581 (runtime.documents.get(targetDocument) ?? 0) + 1
15582 );
15583 for (const [hash, css] of runtime.styles) {
15584 injectStyle23(targetDocument, hash, css);
15585 }
15586 return () => {
15587 const count = runtime.documents.get(targetDocument);
15588 if (count === void 0) {
15589 return;
15590 }
15591 if (count <= 1) {
15592 runtime.documents.delete(targetDocument);
15593 return;
15594 }
15595 runtime.documents.set(targetDocument, count - 1);
15596 };
15597 }
15598 function registerStyle23(hash, css) {
15599 const runtime = getRuntime23();
15600 runtime.styles.set(hash, css);
15601 for (const targetDocument of runtime.documents.keys()) {
15602 injectStyle23(targetDocument, hash, css);
15603 }
15604 }
15605 if (typeof process === "undefined" || true) {
15606 registerStyle23("60dd1d4d42", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._4145abab73d17514__notice{--icon-height:24px;--text-vertical-padding:calc((var(--icon-height) - var(--wpds-typography-line-height-sm, 20px))/2);--wp-ui-notice-background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);--wp-ui-notice-text-color:var(--wpds-color-fg-content-neutral,#1e1e1e);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-neutral,#1e1e1e);align-items:start;background-color:var(--wp-ui-notice-background-color);border:1px solid var(--wp-ui-notice-border-color);border-radius:var(--wpds-border-radius-lg,8px);container-type:inline-size;display:grid;grid-template-columns:auto 1fr auto;padding:var(--wpds-dimension-padding-md,12px)}.d0a25570cb528528__icon{color:var(--wp-ui-notice-decorative-icon-color);grid-column:1;grid-row:1;margin-inline-end:var(--wpds-dimension-gap-xs,4px)}._1904b570a89bb815__description,.b5397fb9d05389e3__title{color:var(--wp-ui-notice-text-color);grid-column:2;padding-block:var(--text-vertical-padding)}._1904b570a89bb815__description{text-wrap:pretty}._0a1270dcdd79c031__actions{display:flex;flex-wrap:wrap;gap:var(--wpds-dimension-gap-md,12px);grid-column:2}._4145abab73d17514__notice:has(._1904b570a89bb815__description) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions{margin-block-start:var(--wpds-dimension-gap-sm,8px)}._983740ab855c4e09__action-button{flex-shrink:0}.d329e7416d368d31__action-link{flex-shrink:0;&:not(:first-child){margin-inline-start:var(--wpds-dimension-gap-xs,4px)}&:not(:last-child){margin-inline-end:var(--wpds-dimension-gap-xs,4px)}}._487e6a5c1375f7dc__close-icon{grid-column:3;grid-row:1;margin-inline-start:var(--wpds-dimension-gap-xs,4px)}._531c140826094795__is-info{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-info-weak,#f3f9ff);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-info,#9fbcdc);--wp-ui-notice-text-color:var(--wpds-color-fg-content-info,#001b4f);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-info-weak,#006bd7)}.ae2e1004697cce95__is-warning{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-warning-weak,#fff7e1);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-warning,#d0b481);--wp-ui-notice-text-color:var(--wpds-color-fg-content-warning,#2e1900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-warning-weak,#926300)}._2e614a76af494837__is-success{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-success-weak,#ebffed);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-success,#8ac894);--wp-ui-notice-text-color:var(--wpds-color-fg-content-success,#002900);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-success-weak,#008030)}.af00331ae17a0065__is-error{--wp-ui-notice-background-color:var(--wpds-color-bg-surface-error-weak,#fff6f5);--wp-ui-notice-border-color:var(--wpds-color-stroke-surface-error,#daa39b);--wp-ui-notice-text-color:var(--wpds-color-fg-content-error,#470000);--wp-ui-notice-decorative-icon-color:var(--wpds-color-fg-content-error-weak,#cc1818)}@container (max-width: 320px){._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._0a1270dcdd79c031__actions,._4145abab73d17514__notice:has(.b5397fb9d05389e3__title) ._1904b570a89bb815__description{grid-column:1/3}}}@layer wp-ui-compositions{.d329e7416d368d31__action-link{margin-block:auto}._487e6a5c1375f7dc__close-icon,._983740ab855c4e09__action-button:is(._8ddb8fb33fbf3d38__is-action-button-outline,._77bbde495a8a0af3__is-action-button-minimal){--wp-ui-button-background-color-active:color-mix(in srgb,#0000 50%,var(--wpds-color-bg-interactive-neutral-weak-active,#ededed))}}");
15607 }
15608 var style_default22 = { "notice": "_4145abab73d17514__notice", "icon": "d0a25570cb528528__icon", "title": "b5397fb9d05389e3__title", "description": "_1904b570a89bb815__description", "actions": "_0a1270dcdd79c031__actions", "action-button": "_983740ab855c4e09__action-button", "action-link": "d329e7416d368d31__action-link", "close-icon": "_487e6a5c1375f7dc__close-icon", "is-info": "_531c140826094795__is-info", "is-warning": "ae2e1004697cce95__is-warning", "is-success": "_2e614a76af494837__is-success", "is-error": "af00331ae17a0065__is-error", "is-action-button-outline": "_8ddb8fb33fbf3d38__is-action-button-outline", "is-action-button-minimal": "_77bbde495a8a0af3__is-action-button-minimal" };
15609 var ActionLink = (0, import_element47.forwardRef)(
15610 function NoticeActionLink({ className, render: render4, ...props }, ref) {
15611 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15612 Text,
15613 {
15614 ref,
15615 className: clsx_default(style_default22["action-link"], className),
15616 ...props,
15617 variant: "body-md",
15618 render: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Link, { tone: "neutral", variant: "default", render: render4 })
15619 }
15620 );
15621 }
15622 );
15623
15624 // packages/ui/build-module/popover/index.mjs
15625 var popover_exports = {};
15626 __export(popover_exports, {
15627 Arrow: () => Arrow,
15628 Close: () => Close,
15629 Description: () => Description2,
15630 Popup: () => Popup2,
15631 Portal: () => Portal2,
15632 Positioner: () => Positioner2,
15633 Root: () => Root6,
15634 Title: () => Title3,
15635 Trigger: () => Trigger3
15636 });
15637
15638 // packages/ui/build-module/popover/arrow.mjs
15639 var import_element48 = __toESM(require_element(), 1);
15640 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
15641 var STYLE_HASH_ATTRIBUTE24 = "data-wp-hash";
15642 function getRuntime24() {
15643 const globalScope = globalThis;
15644 if (globalScope.__wpStyleRuntime) {
15645 return globalScope.__wpStyleRuntime;
15646 }
15647 globalScope.__wpStyleRuntime = {
15648 documents: /* @__PURE__ */ new Map(),
15649 styles: /* @__PURE__ */ new Map(),
15650 injectedStyles: /* @__PURE__ */ new WeakMap()
15651 };
15652 if (typeof document !== "undefined") {
15653 registerDocument24(document);
15654 }
15655 return globalScope.__wpStyleRuntime;
15656 }
15657 function documentContainsStyleHash24(targetDocument, hash) {
15658 if (!targetDocument.head) {
15659 return false;
15660 }
15661 for (const style of targetDocument.head.querySelectorAll(
15662 `style[${STYLE_HASH_ATTRIBUTE24}]`
15663 )) {
15664 if (style.getAttribute(STYLE_HASH_ATTRIBUTE24) === hash) {
15665 return true;
15666 }
15667 }
15668 return false;
15669 }
15670 function injectStyle24(targetDocument, hash, css) {
15671 if (!targetDocument.head) {
15672 return;
15673 }
15674 const runtime = getRuntime24();
15675 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15676 if (!injectedStyles) {
15677 injectedStyles = /* @__PURE__ */ new Set();
15678 runtime.injectedStyles.set(targetDocument, injectedStyles);
15679 }
15680 if (injectedStyles.has(hash)) {
15681 return;
15682 }
15683 if (documentContainsStyleHash24(targetDocument, hash)) {
15684 injectedStyles.add(hash);
15685 return;
15686 }
15687 const style = targetDocument.createElement("style");
15688 style.setAttribute(STYLE_HASH_ATTRIBUTE24, hash);
15689 style.appendChild(targetDocument.createTextNode(css));
15690 targetDocument.head.appendChild(style);
15691 injectedStyles.add(hash);
15692 }
15693 function registerDocument24(targetDocument) {
15694 const runtime = getRuntime24();
15695 runtime.documents.set(
15696 targetDocument,
15697 (runtime.documents.get(targetDocument) ?? 0) + 1
15698 );
15699 for (const [hash, css] of runtime.styles) {
15700 injectStyle24(targetDocument, hash, css);
15701 }
15702 return () => {
15703 const count = runtime.documents.get(targetDocument);
15704 if (count === void 0) {
15705 return;
15706 }
15707 if (count <= 1) {
15708 runtime.documents.delete(targetDocument);
15709 return;
15710 }
15711 runtime.documents.set(targetDocument, count - 1);
15712 };
15713 }
15714 function registerStyle24(hash, css) {
15715 const runtime = getRuntime24();
15716 runtime.styles.set(hash, css);
15717 for (const targetDocument of runtime.documents.keys()) {
15718 injectStyle24(targetDocument, hash, css);
15719 }
15720 }
15721 if (typeof process === "undefined" || true) {
15722 registerStyle24("cc851ac208", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-md,0 2px 3px 0 #0000000d,0 4px 5px 0 #0000000a,0 12px 12px 0 #00000008,0 16px 16px 0 #00000005);color:var(--wpds-color-fg-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-md,13px);line-height:var(--wpds-typography-line-height-md,24px);outline:0;padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._84e8f597bcf683b8__popup{border-color:#0000}@media (forced-colors:active){._84e8f597bcf683b8__popup,.e4d544aa033f05c6__backdrop~* ._84e8f597bcf683b8__popup{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-bg-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:#00000026;inset:0;position:fixed;z-index:var(--wp-ui-popover-z-index,initial)}}');
15723 }
15724 var style_default23 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" };
15725 function DefaultArrowSvg(props) {
15726 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15727 "svg",
15728 {
15729 width: "20",
15730 height: "10",
15731 viewBox: "0 0 20 10",
15732 fill: "none",
15733 ...props,
15734 children: [
15735 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15736 "path",
15737 {
15738 d: "M20 10H0V8h1.465a4 4 0 0 0 2.676-1.027l5.19-4.388c.378-.341.96-.341 1.338 0l5.19 4.388A4 4 0 0 0 18.535 8H20z",
15739 className: style_default23["arrow-fill"]
15740 }
15741 ),
15742 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15743 "path",
15744 {
15745 d: "M10 3.097 4.81 7.486A5 5 0 0 1 1.465 8.77H0V8h1.465a4 4 0 0 0 2.676-1.027l5.19-4.388c.378-.341.96-.341 1.338 0l5.19 4.388A4 4 0 0 0 18.535 8H20v.77h-1.465a5 5 0 0 1-3.345-1.284z",
15746 className: style_default23["arrow-stroke"]
15747 }
15748 )
15749 ]
15750 }
15751 );
15752 }
15753 var Arrow = (0, import_element48.forwardRef)(function PopoverArrow3({ children, className, ...props }, ref) {
15754 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15755 index_parts_exports2.Arrow,
15756 {
15757 ref,
15758 className: clsx_default(style_default23.arrow, className),
15759 ...props,
15760 children: children ?? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(DefaultArrowSvg, {})
15761 }
15762 );
15763 });
15764
15765 // packages/ui/build-module/popover/close.mjs
15766 var import_element49 = __toESM(require_element(), 1);
15767 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
15768 var Close = (0, import_element49.forwardRef)(
15769 function PopoverClose3(props, ref) {
15770 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15771 index_parts_exports2.Close,
15772 {
15773 ref,
15774 "data-wp-ui-popover-close": "",
15775 ...props
15776 }
15777 );
15778 }
15779 );
15780
15781 // packages/ui/build-module/popover/description.mjs
15782 var import_element50 = __toESM(require_element(), 1);
15783 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
15784 var Description2 = (0, import_element50.forwardRef)(
15785 function PopoverDescription3({ children, ...props }, ref) {
15786 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15787 Text,
15788 {
15789 ref,
15790 variant: "body-md",
15791 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(index_parts_exports2.Description, { ...props }),
15792 children
15793 }
15794 );
15795 }
15796 );
15797
15798 // packages/ui/build-module/popover/popup.mjs
15799 var import_element53 = __toESM(require_element(), 1);
15800 var import_compose = __toESM(require_compose(), 1);
15801 var import_theme2 = __toESM(require_theme(), 1);
15802
15803 // packages/ui/build-module/popover/context.mjs
15804 var popoverTitleValidation = createOverlayTitleValidation("Popover");
15805 var usePopoverValidationContext = popoverTitleValidation.useValidationContext;
15806 var PopoverValidationProvider = popoverTitleValidation.ValidationProvider;
15807
15808 // packages/ui/build-module/popover/portal.mjs
15809 var import_element51 = __toESM(require_element(), 1);
15810 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
15811 var Portal2 = (0, import_element51.forwardRef)(
15812 function PopoverPortal3(props, ref) {
15813 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(index_parts_exports2.Portal, { ref, ...props });
15814 }
15815 );
15816
15817 // packages/ui/build-module/popover/positioner.mjs
15818 var import_element52 = __toESM(require_element(), 1);
15819 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
15820 var STYLE_HASH_ATTRIBUTE25 = "data-wp-hash";
15821 function getRuntime25() {
15822 const globalScope = globalThis;
15823 if (globalScope.__wpStyleRuntime) {
15824 return globalScope.__wpStyleRuntime;
15825 }
15826 globalScope.__wpStyleRuntime = {
15827 documents: /* @__PURE__ */ new Map(),
15828 styles: /* @__PURE__ */ new Map(),
15829 injectedStyles: /* @__PURE__ */ new WeakMap()
15830 };
15831 if (typeof document !== "undefined") {
15832 registerDocument25(document);
15833 }
15834 return globalScope.__wpStyleRuntime;
15835 }
15836 function documentContainsStyleHash25(targetDocument, hash) {
15837 if (!targetDocument.head) {
15838 return false;
15839 }
15840 for (const style of targetDocument.head.querySelectorAll(
15841 `style[${STYLE_HASH_ATTRIBUTE25}]`
15842 )) {
15843 if (style.getAttribute(STYLE_HASH_ATTRIBUTE25) === hash) {
15844 return true;
15845 }
15846 }
15847 return false;
15848 }
15849 function injectStyle25(targetDocument, hash, css) {
15850 if (!targetDocument.head) {
15851 return;
15852 }
15853 const runtime = getRuntime25();
15854 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15855 if (!injectedStyles) {
15856 injectedStyles = /* @__PURE__ */ new Set();
15857 runtime.injectedStyles.set(targetDocument, injectedStyles);
15858 }
15859 if (injectedStyles.has(hash)) {
15860 return;
15861 }
15862 if (documentContainsStyleHash25(targetDocument, hash)) {
15863 injectedStyles.add(hash);
15864 return;
15865 }
15866 const style = targetDocument.createElement("style");
15867 style.setAttribute(STYLE_HASH_ATTRIBUTE25, hash);
15868 style.appendChild(targetDocument.createTextNode(css));
15869 targetDocument.head.appendChild(style);
15870 injectedStyles.add(hash);
15871 }
15872 function registerDocument25(targetDocument) {
15873 const runtime = getRuntime25();
15874 runtime.documents.set(
15875 targetDocument,
15876 (runtime.documents.get(targetDocument) ?? 0) + 1
15877 );
15878 for (const [hash, css] of runtime.styles) {
15879 injectStyle25(targetDocument, hash, css);
15880 }
15881 return () => {
15882 const count = runtime.documents.get(targetDocument);
15883 if (count === void 0) {
15884 return;
15885 }
15886 if (count <= 1) {
15887 runtime.documents.delete(targetDocument);
15888 return;
15889 }
15890 runtime.documents.set(targetDocument, count - 1);
15891 };
15892 }
15893 function registerStyle25(hash, css) {
15894 const runtime = getRuntime25();
15895 runtime.styles.set(hash, css);
15896 for (const targetDocument of runtime.documents.keys()) {
15897 injectStyle25(targetDocument, hash, css);
15898 }
15899 }
15900 if (typeof process === "undefined" || true) {
15901 registerStyle25("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
15902 }
15903 var resets_default6 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
15904 if (typeof process === "undefined" || true) {
15905 registerStyle25("cc851ac208", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-md,0 2px 3px 0 #0000000d,0 4px 5px 0 #0000000a,0 12px 12px 0 #00000008,0 16px 16px 0 #00000005);color:var(--wpds-color-fg-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-md,13px);line-height:var(--wpds-typography-line-height-md,24px);outline:0;padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._84e8f597bcf683b8__popup{border-color:#0000}@media (forced-colors:active){._84e8f597bcf683b8__popup,.e4d544aa033f05c6__backdrop~* ._84e8f597bcf683b8__popup{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-bg-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:#00000026;inset:0;position:fixed;z-index:var(--wp-ui-popover-z-index,initial)}}');
15906 }
15907 var style_default24 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" };
15908 var Positioner2 = (0, import_element52.forwardRef)(
15909 function PopoverPositioner3({
15910 align = "center",
15911 // Matches the popup's border-radius (--wpds-border-radius-md).
15912 arrowPadding = 8,
15913 className,
15914 side = "bottom",
15915 sideOffset = 8,
15916 ...props
15917 }, ref) {
15918 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15919 index_parts_exports2.Positioner,
15920 {
15921 ref,
15922 align,
15923 arrowPadding,
15924 side,
15925 sideOffset,
15926 ...props,
15927 className: clsx_default(
15928 resets_default6["box-sizing"],
15929 style_default24.positioner,
15930 className
15931 )
15932 }
15933 );
15934 }
15935 );
15936
15937 // packages/ui/build-module/popover/popup.mjs
15938 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
15939 var STYLE_HASH_ATTRIBUTE26 = "data-wp-hash";
15940 function getRuntime26() {
15941 const globalScope = globalThis;
15942 if (globalScope.__wpStyleRuntime) {
15943 return globalScope.__wpStyleRuntime;
15944 }
15945 globalScope.__wpStyleRuntime = {
15946 documents: /* @__PURE__ */ new Map(),
15947 styles: /* @__PURE__ */ new Map(),
15948 injectedStyles: /* @__PURE__ */ new WeakMap()
15949 };
15950 if (typeof document !== "undefined") {
15951 registerDocument26(document);
15952 }
15953 return globalScope.__wpStyleRuntime;
15954 }
15955 function documentContainsStyleHash26(targetDocument, hash) {
15956 if (!targetDocument.head) {
15957 return false;
15958 }
15959 for (const style of targetDocument.head.querySelectorAll(
15960 `style[${STYLE_HASH_ATTRIBUTE26}]`
15961 )) {
15962 if (style.getAttribute(STYLE_HASH_ATTRIBUTE26) === hash) {
15963 return true;
15964 }
15965 }
15966 return false;
15967 }
15968 function injectStyle26(targetDocument, hash, css) {
15969 if (!targetDocument.head) {
15970 return;
15971 }
15972 const runtime = getRuntime26();
15973 let injectedStyles = runtime.injectedStyles.get(targetDocument);
15974 if (!injectedStyles) {
15975 injectedStyles = /* @__PURE__ */ new Set();
15976 runtime.injectedStyles.set(targetDocument, injectedStyles);
15977 }
15978 if (injectedStyles.has(hash)) {
15979 return;
15980 }
15981 if (documentContainsStyleHash26(targetDocument, hash)) {
15982 injectedStyles.add(hash);
15983 return;
15984 }
15985 const style = targetDocument.createElement("style");
15986 style.setAttribute(STYLE_HASH_ATTRIBUTE26, hash);
15987 style.appendChild(targetDocument.createTextNode(css));
15988 targetDocument.head.appendChild(style);
15989 injectedStyles.add(hash);
15990 }
15991 function registerDocument26(targetDocument) {
15992 const runtime = getRuntime26();
15993 runtime.documents.set(
15994 targetDocument,
15995 (runtime.documents.get(targetDocument) ?? 0) + 1
15996 );
15997 for (const [hash, css] of runtime.styles) {
15998 injectStyle26(targetDocument, hash, css);
15999 }
16000 return () => {
16001 const count = runtime.documents.get(targetDocument);
16002 if (count === void 0) {
16003 return;
16004 }
16005 if (count <= 1) {
16006 runtime.documents.delete(targetDocument);
16007 return;
16008 }
16009 runtime.documents.set(targetDocument, count - 1);
16010 };
16011 }
16012 function registerStyle26(hash, css) {
16013 const runtime = getRuntime26();
16014 runtime.styles.set(hash, css);
16015 for (const targetDocument of runtime.documents.keys()) {
16016 injectStyle26(targetDocument, hash, css);
16017 }
16018 }
16019 if (typeof process === "undefined" || true) {
16020 registerStyle26("cc851ac208", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-md,0 2px 3px 0 #0000000d,0 4px 5px 0 #0000000a,0 12px 12px 0 #00000008,0 16px 16px 0 #00000005);color:var(--wpds-color-fg-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-md,13px);line-height:var(--wpds-typography-line-height-md,24px);outline:0;padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._84e8f597bcf683b8__popup{border-color:#0000}@media (forced-colors:active){._84e8f597bcf683b8__popup,.e4d544aa033f05c6__backdrop~* ._84e8f597bcf683b8__popup{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-bg-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:#00000026;inset:0;position:fixed;z-index:var(--wp-ui-popover-z-index,initial)}}');
16021 }
16022 var style_default25 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" };
16023 var ThemeProvider2 = unlock(import_theme2.privateApis).ThemeProvider;
16024 var CLOSE_ATTR = "data-wp-ui-popover-close";
16025 var Popup2 = (0, import_element53.forwardRef)(function PopoverPopup3({
16026 backdrop = false,
16027 children,
16028 className,
16029 portal,
16030 positioner,
16031 finalFocus,
16032 initialFocus,
16033 variant = "default",
16034 ...props
16035 }, ref) {
16036 const { resolvedInitialFocus, popupRef } = useDeprioritizedInitialFocus({
16037 initialFocus,
16038 deprioritizedAttributes: [CLOSE_ATTR]
16039 });
16040 const mergedPopupRef = (0, import_compose.useMergeRefs)([ref, popupRef]);
16041 const backdropElement = backdrop ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(index_parts_exports2.Backdrop, { className: style_default25.backdrop }) : null;
16042 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ThemeProvider2, { children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
16043 index_parts_exports2.Popup,
16044 {
16045 ref: mergedPopupRef,
16046 initialFocus: resolvedInitialFocus,
16047 finalFocus,
16048 className: clsx_default(
16049 variant !== "unstyled" && style_default25.popup,
16050 className
16051 ),
16052 ...props,
16053 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(PopoverValidationProvider, { children })
16054 }
16055 ) });
16056 const positionedPopup = renderSlotWithChildren(
16057 positioner,
16058 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Positioner2, {}),
16059 popupContent
16060 );
16061 const portalChildren = /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(import_jsx_runtime82.Fragment, { children: [
16062 backdropElement,
16063 positionedPopup
16064 ] });
16065 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Portal2, {}), portalChildren);
16066 });
16067
16068 // packages/ui/build-module/popover/root.mjs
16069 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
16070 function Root6(props) {
16071 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(index_parts_exports2.Root, { ...props });
16072 }
16073
16074 // packages/ui/build-module/popover/title.mjs
16075 var import_compose2 = __toESM(require_compose(), 1);
16076 var import_element54 = __toESM(require_element(), 1);
16077 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
16078 var STYLE_HASH_ATTRIBUTE27 = "data-wp-hash";
16079 function getRuntime27() {
16080 const globalScope = globalThis;
16081 if (globalScope.__wpStyleRuntime) {
16082 return globalScope.__wpStyleRuntime;
16083 }
16084 globalScope.__wpStyleRuntime = {
16085 documents: /* @__PURE__ */ new Map(),
16086 styles: /* @__PURE__ */ new Map(),
16087 injectedStyles: /* @__PURE__ */ new WeakMap()
16088 };
16089 if (typeof document !== "undefined") {
16090 registerDocument27(document);
16091 }
16092 return globalScope.__wpStyleRuntime;
16093 }
16094 function documentContainsStyleHash27(targetDocument, hash) {
16095 if (!targetDocument.head) {
16096 return false;
16097 }
16098 for (const style of targetDocument.head.querySelectorAll(
16099 `style[${STYLE_HASH_ATTRIBUTE27}]`
16100 )) {
16101 if (style.getAttribute(STYLE_HASH_ATTRIBUTE27) === hash) {
16102 return true;
16103 }
16104 }
16105 return false;
16106 }
16107 function injectStyle27(targetDocument, hash, css) {
16108 if (!targetDocument.head) {
16109 return;
16110 }
16111 const runtime = getRuntime27();
16112 let injectedStyles = runtime.injectedStyles.get(targetDocument);
16113 if (!injectedStyles) {
16114 injectedStyles = /* @__PURE__ */ new Set();
16115 runtime.injectedStyles.set(targetDocument, injectedStyles);
16116 }
16117 if (injectedStyles.has(hash)) {
16118 return;
16119 }
16120 if (documentContainsStyleHash27(targetDocument, hash)) {
16121 injectedStyles.add(hash);
16122 return;
16123 }
16124 const style = targetDocument.createElement("style");
16125 style.setAttribute(STYLE_HASH_ATTRIBUTE27, hash);
16126 style.appendChild(targetDocument.createTextNode(css));
16127 targetDocument.head.appendChild(style);
16128 injectedStyles.add(hash);
16129 }
16130 function registerDocument27(targetDocument) {
16131 const runtime = getRuntime27();
16132 runtime.documents.set(
16133 targetDocument,
16134 (runtime.documents.get(targetDocument) ?? 0) + 1
16135 );
16136 for (const [hash, css] of runtime.styles) {
16137 injectStyle27(targetDocument, hash, css);
16138 }
16139 return () => {
16140 const count = runtime.documents.get(targetDocument);
16141 if (count === void 0) {
16142 return;
16143 }
16144 if (count <= 1) {
16145 runtime.documents.delete(targetDocument);
16146 return;
16147 }
16148 runtime.documents.set(targetDocument, count - 1);
16149 };
16150 }
16151 function registerStyle27(hash, css) {
16152 const runtime = getRuntime27();
16153 runtime.styles.set(hash, css);
16154 for (const targetDocument of runtime.documents.keys()) {
16155 injectStyle27(targetDocument, hash, css);
16156 }
16157 }
16158 if (typeof process === "undefined" || true) {
16159 registerStyle27("cc851ac208", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._10450722b9676f78__positioner{z-index:var(--wp-ui-popover-z-index,initial)}._84e8f597bcf683b8__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-md,0 2px 3px 0 #0000000d,0 4px 5px 0 #0000000a,0 12px 12px 0 #00000008,0 16px 16px 0 #00000005);color:var(--wpds-color-fg-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-md,13px);line-height:var(--wpds-typography-line-height-md,24px);outline:0;padding:var(--wpds-dimension-padding-lg,16px)}.e4d544aa033f05c6__backdrop~* ._84e8f597bcf683b8__popup{border-color:#0000}@media (forced-colors:active){._84e8f597bcf683b8__popup,.e4d544aa033f05c6__backdrop~* ._84e8f597bcf683b8__popup{border-color:CanvasText}}.ca05d3eb89321fcd__arrow{display:flex;&[data-side=top]{bottom:-8px;rotate:180deg}&[data-side=bottom]{rotate:0deg;top:-8px}&[data-side=left]{inset-inline-end:-13px;rotate:90deg}&[data-side=right]{inset-inline-start:-13px;rotate:-90deg}}._12d8edd9eb946b5f__arrow-fill{fill:var(--wpds-color-bg-surface-neutral-strong,#fff)}._6ddab482bd929dad__arrow-stroke{fill:var(--wpds-color-stroke-surface-neutral,#dbdbdb)}._6d7e4729cd96960e__title{--_gcd-heading-color:var(--wpds-color-fg-content-neutral,#1e1e1e);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}.e4d544aa033f05c6__backdrop{background-color:#00000026;inset:0;position:fixed;z-index:var(--wp-ui-popover-z-index,initial)}}');
16160 }
16161 var style_default26 = { "positioner": "_10450722b9676f78__positioner", "popup": "_84e8f597bcf683b8__popup", "backdrop": "e4d544aa033f05c6__backdrop", "arrow": "ca05d3eb89321fcd__arrow", "arrow-fill": "_12d8edd9eb946b5f__arrow-fill", "arrow-stroke": "_6ddab482bd929dad__arrow-stroke", "title": "_6d7e4729cd96960e__title" };
16162 var Title3 = (0, import_element54.forwardRef)(
16163 function PopoverTitle3({ children, ...props }, forwardedRef) {
16164 const validationContext = usePopoverValidationContext();
16165 const internalRef = (0, import_element54.useRef)(null);
16166 const mergedRef = (0, import_compose2.useMergeRefs)([internalRef, forwardedRef]);
16167 (0, import_element54.useEffect)(() => {
16168 if (validationContext) {
16169 return validationContext.registerTitle(internalRef.current);
16170 }
16171 return void 0;
16172 }, [validationContext]);
16173 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16174 Text,
16175 {
16176 ref: mergedRef,
16177 variant: "heading-xl",
16178 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(index_parts_exports2.Title, { ...props }),
16179 className: style_default26.title,
16180 children
16181 }
16182 );
16183 }
16184 );
16185
16186 // packages/ui/build-module/popover/trigger.mjs
16187 var import_element55 = __toESM(require_element(), 1);
16188 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
16189 var Trigger3 = (0, import_element55.forwardRef)(
16190 function PopoverTrigger3(props, ref) {
16191 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(index_parts_exports2.Trigger, { ref, ...props });
16192 }
16193 );
16194
16195 // packages/admin-ui/build-module/breadcrumbs/index.mjs
16196 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
16197 var STYLE_HASH_ATTRIBUTE28 = "data-wp-hash";
16198 function getRuntime28() {
16199 const globalScope = globalThis;
16200 if (globalScope.__wpStyleRuntime) {
16201 return globalScope.__wpStyleRuntime;
16202 }
16203 globalScope.__wpStyleRuntime = {
16204 documents: /* @__PURE__ */ new Map(),
16205 styles: /* @__PURE__ */ new Map(),
16206 injectedStyles: /* @__PURE__ */ new WeakMap()
16207 };
16208 if (typeof document !== "undefined") {
16209 registerDocument28(document);
16210 }
16211 return globalScope.__wpStyleRuntime;
16212 }
16213 function documentContainsStyleHash28(targetDocument, hash) {
16214 if (!targetDocument.head) {
16215 return false;
16216 }
16217 for (const style of targetDocument.head.querySelectorAll(
16218 `style[${STYLE_HASH_ATTRIBUTE28}]`
16219 )) {
16220 if (style.getAttribute(STYLE_HASH_ATTRIBUTE28) === hash) {
16221 return true;
16222 }
16223 }
16224 return false;
16225 }
16226 function injectStyle28(targetDocument, hash, css) {
16227 if (!targetDocument.head) {
16228 return;
16229 }
16230 const runtime = getRuntime28();
16231 let injectedStyles = runtime.injectedStyles.get(targetDocument);
16232 if (!injectedStyles) {
16233 injectedStyles = /* @__PURE__ */ new Set();
16234 runtime.injectedStyles.set(targetDocument, injectedStyles);
16235 }
16236 if (injectedStyles.has(hash)) {
16237 return;
16238 }
16239 if (documentContainsStyleHash28(targetDocument, hash)) {
16240 injectedStyles.add(hash);
16241 return;
16242 }
16243 const style = targetDocument.createElement("style");
16244 style.setAttribute(STYLE_HASH_ATTRIBUTE28, hash);
16245 style.appendChild(targetDocument.createTextNode(css));
16246 targetDocument.head.appendChild(style);
16247 injectedStyles.add(hash);
16248 }
16249 function registerDocument28(targetDocument) {
16250 const runtime = getRuntime28();
16251 runtime.documents.set(
16252 targetDocument,
16253 (runtime.documents.get(targetDocument) ?? 0) + 1
16254 );
16255 for (const [hash, css] of runtime.styles) {
16256 injectStyle28(targetDocument, hash, css);
16257 }
16258 return () => {
16259 const count = runtime.documents.get(targetDocument);
16260 if (count === void 0) {
16261 return;
16262 }
16263 if (count <= 1) {
16264 runtime.documents.delete(targetDocument);
16265 return;
16266 }
16267 runtime.documents.set(targetDocument, count - 1);
16268 };
16269 }
16270 function registerStyle28(hash, css) {
16271 const runtime = getRuntime28();
16272 runtime.styles.set(hash, css);
16273 for (const targetDocument of runtime.documents.keys()) {
16274 injectStyle28(targetDocument, hash, css);
16275 }
16276 }
16277 if (typeof process === "undefined" || true) {
16278 registerStyle28("846edc217c", "._5f4053eba32ce092__list{list-style:none;margin:0;padding:0}._5f4053eba32ce092__list>li{flex-shrink:0}._5f4053eba32ce092__list>li:last-child{flex-shrink:1;min-width:0}.d1978551971a3360__current{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._6d9152063d443376__separator{color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);margin:0 var(--wpds-dimension-gap-sm,8px);user-select:none}");
16279 }
16280 var style_default27 = { "list": "_5f4053eba32ce092__list", "current": "d1978551971a3360__current", "separator": "_6d9152063d443376__separator" };
16281 var Breadcrumbs = ({ items }) => {
16282 if (!items.length) {
16283 return null;
16284 }
16285 const precedingItems = items.slice(0, -1);
16286 const lastItem = items[items.length - 1];
16287 if (true) {
16288 const invalidItem = precedingItems.find((item) => !item.to);
16289 if (invalidItem) {
16290 throw new Error(
16291 `Breadcrumbs: item "${invalidItem.label}" is missing a \`to\` prop. All items except the last one must have a \`to\` prop.`
16292 );
16293 }
16294 }
16295 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("nav", { "aria-label": (0, import_i18n4.__)("Breadcrumbs"), children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
16296 Stack,
16297 {
16298 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("ul", {}),
16299 direction: "row",
16300 align: "center",
16301 className: style_default27.list,
16302 children: [
16303 precedingItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("li", { children: [
16304 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16305 Text,
16306 {
16307 variant: "body-lg",
16308 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16309 Link,
16310 {
16311 tone: "neutral",
16312 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(RouterLink, { to: item.to })
16313 }
16314 ),
16315 children: item.label
16316 }
16317 ),
16318 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16319 Text,
16320 {
16321 variant: "body-lg",
16322 "aria-hidden": "true",
16323 className: style_default27.separator,
16324 children: "/"
16325 }
16326 )
16327 ] }, index2)),
16328 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("li", { children: lastItem.to ? /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16329 Text,
16330 {
16331 variant: "body-lg",
16332 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16333 Link,
16334 {
16335 tone: "neutral",
16336 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(RouterLink, { to: lastItem.to })
16337 }
16338 ),
16339 children: lastItem.label
16340 }
16341 ) : /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16342 Text,
16343 {
16344 variant: "heading-lg",
16345 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("h1", {}),
16346 className: style_default27.current,
16347 children: lastItem.label
16348 }
16349 ) })
16350 ]
16351 }
16352 ) });
16353 };
16354 var breadcrumbs_default = Breadcrumbs;
16355
16356 // packages/admin-ui/build-module/navigable-region/index.mjs
16357 var import_element56 = __toESM(require_element(), 1);
16358 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
16359 var NavigableRegion = (0, import_element56.forwardRef)(
16360 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
16361 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
16362 Tag,
16363 {
16364 ref,
16365 className: clsx_default("admin-ui-navigable-region", className),
16366 "aria-label": ariaLabel,
16367 role: "region",
16368 tabIndex: "-1",
16369 ...props,
16370 children
16371 }
16372 );
16373 }
16374 );
16375 NavigableRegion.displayName = "NavigableRegion";
16376 var navigable_region_default = NavigableRegion;
16377
16378 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
16379 var import_components = __toESM(require_components(), 1);
16380 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle");
16381
16382 // packages/admin-ui/build-module/page/header.mjs
16383 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
16384 var STYLE_HASH_ATTRIBUTE29 = "data-wp-hash";
16385 function getRuntime29() {
16386 const globalScope = globalThis;
16387 if (globalScope.__wpStyleRuntime) {
16388 return globalScope.__wpStyleRuntime;
16389 }
16390 globalScope.__wpStyleRuntime = {
16391 documents: /* @__PURE__ */ new Map(),
16392 styles: /* @__PURE__ */ new Map(),
16393 injectedStyles: /* @__PURE__ */ new WeakMap()
16394 };
16395 if (typeof document !== "undefined") {
16396 registerDocument29(document);
16397 }
16398 return globalScope.__wpStyleRuntime;
16399 }
16400 function documentContainsStyleHash29(targetDocument, hash) {
16401 if (!targetDocument.head) {
16402 return false;
16403 }
16404 for (const style of targetDocument.head.querySelectorAll(
16405 `style[${STYLE_HASH_ATTRIBUTE29}]`
16406 )) {
16407 if (style.getAttribute(STYLE_HASH_ATTRIBUTE29) === hash) {
16408 return true;
16409 }
16410 }
16411 return false;
16412 }
16413 function injectStyle29(targetDocument, hash, css) {
16414 if (!targetDocument.head) {
16415 return;
16416 }
16417 const runtime = getRuntime29();
16418 let injectedStyles = runtime.injectedStyles.get(targetDocument);
16419 if (!injectedStyles) {
16420 injectedStyles = /* @__PURE__ */ new Set();
16421 runtime.injectedStyles.set(targetDocument, injectedStyles);
16422 }
16423 if (injectedStyles.has(hash)) {
16424 return;
16425 }
16426 if (documentContainsStyleHash29(targetDocument, hash)) {
16427 injectedStyles.add(hash);
16428 return;
16429 }
16430 const style = targetDocument.createElement("style");
16431 style.setAttribute(STYLE_HASH_ATTRIBUTE29, hash);
16432 style.appendChild(targetDocument.createTextNode(css));
16433 targetDocument.head.appendChild(style);
16434 injectedStyles.add(hash);
16435 }
16436 function registerDocument29(targetDocument) {
16437 const runtime = getRuntime29();
16438 runtime.documents.set(
16439 targetDocument,
16440 (runtime.documents.get(targetDocument) ?? 0) + 1
16441 );
16442 for (const [hash, css] of runtime.styles) {
16443 injectStyle29(targetDocument, hash, css);
16444 }
16445 return () => {
16446 const count = runtime.documents.get(targetDocument);
16447 if (count === void 0) {
16448 return;
16449 }
16450 if (count <= 1) {
16451 runtime.documents.delete(targetDocument);
16452 return;
16453 }
16454 runtime.documents.set(targetDocument, count - 1);
16455 };
16456 }
16457 function registerStyle29(hash, css) {
16458 const runtime = getRuntime29();
16459 runtime.styles.set(hash, css);
16460 for (const targetDocument of runtime.documents.keys()) {
16461 injectStyle29(targetDocument, hash, css);
16462 }
16463 }
16464 if (typeof process === "undefined" || true) {
16465 registerStyle29("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
16466 }
16467 var style_default28 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
16468 function Header3({
16469 headingLevel = 1,
16470 breadcrumbs,
16471 badges,
16472 visual,
16473 title,
16474 subTitle,
16475 actions,
16476 showSidebarToggle = true
16477 }) {
16478 const HeadingTag = `h${headingLevel}`;
16479 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "column", className: style_default28.header, children: [
16480 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
16481 Stack,
16482 {
16483 className: style_default28["header-content"],
16484 direction: "row",
16485 gap: "sm",
16486 justify: "space-between",
16487 children: [
16488 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
16489 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16490 SidebarToggleSlot,
16491 {
16492 bubblesVirtually: true,
16493 className: style_default28["sidebar-toggle-slot"]
16494 }
16495 ),
16496 visual && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16497 "div",
16498 {
16499 className: style_default28["header-visual"],
16500 "aria-hidden": "true",
16501 children: visual
16502 }
16503 ),
16504 title && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16505 Text,
16506 {
16507 className: style_default28["header-title"],
16508 render: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(HeadingTag, {}),
16509 variant: "heading-lg",
16510 children: title
16511 }
16512 ),
16513 breadcrumbs,
16514 badges
16515 ] }),
16516 actions && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16517 Stack,
16518 {
16519 align: "center",
16520 className: style_default28["header-actions"],
16521 direction: "row",
16522 gap: "sm",
16523 children: actions
16524 }
16525 )
16526 ]
16527 }
16528 ),
16529 subTitle && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16530 Text,
16531 {
16532 render: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", {}),
16533 variant: "body-md",
16534 className: style_default28["header-subtitle"],
16535 children: subTitle
16536 }
16537 )
16538 ] });
16539 }
16540
16541 // packages/admin-ui/build-module/page/index.mjs
16542 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
16543 var STYLE_HASH_ATTRIBUTE30 = "data-wp-hash";
16544 function getRuntime30() {
16545 const globalScope = globalThis;
16546 if (globalScope.__wpStyleRuntime) {
16547 return globalScope.__wpStyleRuntime;
16548 }
16549 globalScope.__wpStyleRuntime = {
16550 documents: /* @__PURE__ */ new Map(),
16551 styles: /* @__PURE__ */ new Map(),
16552 injectedStyles: /* @__PURE__ */ new WeakMap()
16553 };
16554 if (typeof document !== "undefined") {
16555 registerDocument30(document);
16556 }
16557 return globalScope.__wpStyleRuntime;
16558 }
16559 function documentContainsStyleHash30(targetDocument, hash) {
16560 if (!targetDocument.head) {
16561 return false;
16562 }
16563 for (const style of targetDocument.head.querySelectorAll(
16564 `style[${STYLE_HASH_ATTRIBUTE30}]`
16565 )) {
16566 if (style.getAttribute(STYLE_HASH_ATTRIBUTE30) === hash) {
16567 return true;
16568 }
16569 }
16570 return false;
16571 }
16572 function injectStyle30(targetDocument, hash, css) {
16573 if (!targetDocument.head) {
16574 return;
16575 }
16576 const runtime = getRuntime30();
16577 let injectedStyles = runtime.injectedStyles.get(targetDocument);
16578 if (!injectedStyles) {
16579 injectedStyles = /* @__PURE__ */ new Set();
16580 runtime.injectedStyles.set(targetDocument, injectedStyles);
16581 }
16582 if (injectedStyles.has(hash)) {
16583 return;
16584 }
16585 if (documentContainsStyleHash30(targetDocument, hash)) {
16586 injectedStyles.add(hash);
16587 return;
16588 }
16589 const style = targetDocument.createElement("style");
16590 style.setAttribute(STYLE_HASH_ATTRIBUTE30, hash);
16591 style.appendChild(targetDocument.createTextNode(css));
16592 targetDocument.head.appendChild(style);
16593 injectedStyles.add(hash);
16594 }
16595 function registerDocument30(targetDocument) {
16596 const runtime = getRuntime30();
16597 runtime.documents.set(
16598 targetDocument,
16599 (runtime.documents.get(targetDocument) ?? 0) + 1
16600 );
16601 for (const [hash, css] of runtime.styles) {
16602 injectStyle30(targetDocument, hash, css);
16603 }
16604 return () => {
16605 const count = runtime.documents.get(targetDocument);
16606 if (count === void 0) {
16607 return;
16608 }
16609 if (count <= 1) {
16610 runtime.documents.delete(targetDocument);
16611 return;
16612 }
16613 runtime.documents.set(targetDocument, count - 1);
16614 };
16615 }
16616 function registerStyle30(hash, css) {
16617 const runtime = getRuntime30();
16618 runtime.styles.set(hash, css);
16619 for (const targetDocument of runtime.documents.keys()) {
16620 injectStyle30(targetDocument, hash, css);
16621 }
16622 }
16623 if (typeof process === "undefined" || true) {
16624 registerStyle30("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
16625 }
16626 var style_default29 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
16627 function Page({
16628 headingLevel,
16629 breadcrumbs,
16630 badges,
16631 visual,
16632 title,
16633 subTitle,
16634 children,
16635 className,
16636 actions,
16637 ariaLabel,
16638 hasPadding = false,
16639 showSidebarToggle = true
16640 }) {
16641 const classes = clsx_default(style_default29.page, className);
16642 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
16643 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
16644 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16645 Header3,
16646 {
16647 headingLevel,
16648 breadcrumbs,
16649 badges,
16650 visual,
16651 title,
16652 subTitle,
16653 actions,
16654 showSidebarToggle
16655 }
16656 ),
16657 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16658 "div",
16659 {
16660 className: clsx_default(
16661 style_default29.content,
16662 style_default29["has-padding"]
16663 ),
16664 children
16665 }
16666 ) : children
16667 ] });
16668 }
16669 Page.SidebarToggleFill = SidebarToggleFill;
16670 var page_default = Page;
16671
16672 // packages/content-types/build-module/components/layout/index.mjs
16673 var import_components2 = __toESM(require_components(), 1);
16674 var import_i18n5 = __toESM(require_i18n(), 1);
16675 import { useNavigate } from "@wordpress/route";
16676
16677 // packages/content-types/build-module/lock-unlock.mjs
16678 var import_private_apis2 = __toESM(require_private_apis(), 1);
16679 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
16680 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
16681 "@wordpress/content-types"
16682 );
16683
16684 // packages/content-types/build-module/components/layout/index.mjs
16685 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
16686 var { Tabs } = unlock2(import_components2.privateApis);
16687 function Layout({ activeTab, children }) {
16688 const navigate = useNavigate();
16689 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
16690 page_default,
16691 {
16692 ariaLabel: (0, import_i18n5.__)("Content Types"),
16693 className: "content-types-page",
16694 children: [
16695 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16696 Tabs,
16697 {
16698 selectedTabId: activeTab,
16699 onSelect: (tabId) => navigate({ to: `/${tabId}` }),
16700 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "content-types-tabs-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Tabs.TabList, { children: [
16701 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Tabs.Tab, { tabId: "post-types", children: (0, import_i18n5.__)("Post Types") }),
16702 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Tabs.Tab, { tabId: "taxonomies", children: (0, import_i18n5.__)("Taxonomies") })
16703 ] }) })
16704 }
16705 ),
16706 children
16707 ]
16708 }
16709 );
16710 }
16711
16712 // packages/content-types/build-module/post-types/list.mjs
16713 var import_components58 = __toESM(require_components(), 1);
16714
16715 // packages/dataviews/build-module/dataviews/index.mjs
16716 var import_element112 = __toESM(require_element(), 1);
16717 var import_compose14 = __toESM(require_compose(), 1);
16718
16719 // packages/dataviews/build-module/components/dataviews-context/index.mjs
16720 var import_element57 = __toESM(require_element(), 1);
16721
16722 // packages/dataviews/build-module/constants.mjs
16723 var import_i18n6 = __toESM(require_i18n(), 1);
16724 var OPERATOR_IS_ANY = "isAny";
16725 var OPERATOR_IS_NONE = "isNone";
16726 var OPERATOR_IS_ALL = "isAll";
16727 var OPERATOR_IS_NOT_ALL = "isNotAll";
16728 var OPERATOR_BETWEEN = "between";
16729 var OPERATOR_IN_THE_PAST = "inThePast";
16730 var OPERATOR_OVER = "over";
16731 var OPERATOR_IS = "is";
16732 var OPERATOR_IS_NOT = "isNot";
16733 var OPERATOR_LESS_THAN = "lessThan";
16734 var OPERATOR_GREATER_THAN = "greaterThan";
16735 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
16736 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
16737 var OPERATOR_BEFORE = "before";
16738 var OPERATOR_AFTER = "after";
16739 var OPERATOR_BEFORE_INC = "beforeInc";
16740 var OPERATOR_AFTER_INC = "afterInc";
16741 var OPERATOR_CONTAINS = "contains";
16742 var OPERATOR_NOT_CONTAINS = "notContains";
16743 var OPERATOR_STARTS_WITH = "startsWith";
16744 var OPERATOR_ON = "on";
16745 var OPERATOR_NOT_ON = "notOn";
16746 var SORTING_DIRECTIONS = ["asc", "desc"];
16747 var sortArrows = { asc: "\u2191", desc: "\u2193" };
16748 var sortValues = { asc: "ascending", desc: "descending" };
16749 var sortLabels = {
16750 asc: (0, import_i18n6.__)("Sort ascending"),
16751 desc: (0, import_i18n6.__)("Sort descending")
16752 };
16753 var sortIcons = {
16754 asc: arrow_up_default,
16755 desc: arrow_down_default
16756 };
16757 var LAYOUT_TABLE = "table";
16758 var LAYOUT_GRID = "grid";
16759 var LAYOUT_LIST = "list";
16760 var LAYOUT_ACTIVITY = "activity";
16761 var LAYOUT_PICKER_GRID = "pickerGrid";
16762 var LAYOUT_PICKER_TABLE = "pickerTable";
16763
16764 // packages/dataviews/build-module/components/dataviews-context/index.mjs
16765 var DataViewsContext = (0, import_element57.createContext)({
16766 view: { type: LAYOUT_TABLE },
16767 onChangeView: () => {
16768 },
16769 fields: [],
16770 data: [],
16771 paginationInfo: {
16772 totalItems: 0,
16773 totalPages: 0
16774 },
16775 selection: [],
16776 onChangeSelection: () => {
16777 },
16778 setOpenedFilter: () => {
16779 },
16780 openedFilter: null,
16781 getItemId: (item) => item.id,
16782 isItemClickable: () => true,
16783 renderItemLink: void 0,
16784 containerWidth: 0,
16785 containerRef: (0, import_element57.createRef)(),
16786 resizeObserverRef: () => {
16787 },
16788 defaultLayouts: { list: {}, grid: {}, table: {} },
16789 filters: [],
16790 isShowingFilter: false,
16791 setIsShowingFilter: () => {
16792 },
16793 hasInitiallyLoaded: false,
16794 config: {
16795 perPageSizes: []
16796 },
16797 intersectionObserver: null
16798 });
16799 DataViewsContext.displayName = "DataViewsContext";
16800 var dataviews_context_default = DataViewsContext;
16801
16802 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
16803 var import_i18n26 = __toESM(require_i18n(), 1);
16804
16805 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
16806 var import_i18n14 = __toESM(require_i18n(), 1);
16807 var import_components8 = __toESM(require_components(), 1);
16808 var import_element65 = __toESM(require_element(), 1);
16809 var import_keycodes = __toESM(require_keycodes(), 1);
16810
16811 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
16812 var import_components3 = __toESM(require_components(), 1);
16813 var import_i18n7 = __toESM(require_i18n(), 1);
16814 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
16815 function DataViewsSelectionCheckbox({
16816 selection,
16817 onChangeSelection,
16818 item,
16819 getItemId,
16820 titleField: titleField2,
16821 disabled: disabled2,
16822 ...extraProps
16823 }) {
16824 const id = getItemId(item);
16825 const isInSelectionArray = selection.includes(id);
16826 const checked = !disabled2 && isInSelectionArray;
16827 const selectionLabel = titleField2?.getValue?.({ item }) || (0, import_i18n7.__)("(no title)");
16828 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16829 import_components3.CheckboxControl,
16830 {
16831 className: "dataviews-selection-checkbox",
16832 "aria-label": selectionLabel,
16833 "aria-disabled": disabled2,
16834 checked,
16835 onChange: () => {
16836 if (disabled2) {
16837 return;
16838 }
16839 onChangeSelection(
16840 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
16841 );
16842 },
16843 ...extraProps
16844 }
16845 );
16846 }
16847
16848 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
16849 var import_components4 = __toESM(require_components(), 1);
16850 var import_i18n8 = __toESM(require_i18n(), 1);
16851 var import_element58 = __toESM(require_element(), 1);
16852 var import_data = __toESM(require_data(), 1);
16853 var import_compose3 = __toESM(require_compose(), 1);
16854
16855 // packages/dataviews/build-module/lock-unlock.mjs
16856 var import_private_apis3 = __toESM(require_private_apis(), 1);
16857 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
16858 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
16859 "@wordpress/dataviews"
16860 );
16861
16862 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
16863 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
16864 var { Menu, kebabCase } = unlock3(import_components4.privateApis);
16865 function ButtonTrigger({
16866 action,
16867 onClick,
16868 items,
16869 variant
16870 }) {
16871 const label = typeof action.label === "string" ? action.label : action.label(items);
16872 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
16873 import_components4.Button,
16874 {
16875 disabled: !!action.disabled,
16876 accessibleWhenDisabled: true,
16877 size: "compact",
16878 variant,
16879 onClick,
16880 children: label
16881 }
16882 );
16883 }
16884 function MenuItemTrigger({
16885 action,
16886 onClick,
16887 items
16888 }) {
16889 const label = typeof action.label === "string" ? action.label : action.label(items);
16890 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu.ItemLabel, { children: label }) });
16891 }
16892 function ActionModal({
16893 action,
16894 items,
16895 closeModal
16896 }) {
16897 const label = typeof action.label === "string" ? action.label : action.label(items);
16898 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
16899 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
16900 import_components4.Modal,
16901 {
16902 title: modalHeader || label,
16903 __experimentalHideHeader: !!action.hideModalHeader,
16904 onRequestClose: closeModal,
16905 focusOnMount: action.modalFocusOnMount ?? true,
16906 size: action.modalSize || "medium",
16907 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
16908 action.id
16909 )}`,
16910 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(action.RenderModal, { items, closeModal })
16911 }
16912 );
16913 }
16914 function ActionsMenuGroup({
16915 actions,
16916 item,
16917 registry,
16918 setActiveModalAction
16919 }) {
16920 const { primaryActions, regularActions } = (0, import_element58.useMemo)(() => {
16921 return actions.reduce(
16922 (acc, action) => {
16923 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
16924 return acc;
16925 },
16926 {
16927 primaryActions: [],
16928 regularActions: []
16929 }
16930 );
16931 }, [actions]);
16932 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
16933 MenuItemTrigger,
16934 {
16935 action,
16936 onClick: () => {
16937 if ("RenderModal" in action) {
16938 setActiveModalAction(action);
16939 return;
16940 }
16941 action.callback([item], { registry });
16942 },
16943 items: [item]
16944 },
16945 action.id
16946 ));
16947 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Menu.Group, { children: [
16948 renderActionGroup(primaryActions),
16949 renderActionGroup(regularActions)
16950 ] });
16951 }
16952 function ItemActions({
16953 item,
16954 actions,
16955 isCompact
16956 }) {
16957 const registry = (0, import_data.useRegistry)();
16958 const { primaryActions, eligibleActions } = (0, import_element58.useMemo)(() => {
16959 const _eligibleActions = actions.filter(
16960 (action) => !action.isEligible || action.isEligible(item)
16961 );
16962 const _primaryActions = _eligibleActions.filter(
16963 (action) => action.isPrimary
16964 );
16965 return {
16966 primaryActions: _primaryActions,
16967 eligibleActions: _eligibleActions
16968 };
16969 }, [actions, item]);
16970 const isMobileViewport = (0, import_compose3.useViewportMatch)("medium", "<");
16971 if (isCompact) {
16972 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
16973 CompactItemActions,
16974 {
16975 item,
16976 actions: eligibleActions,
16977 isSmall: true,
16978 registry
16979 }
16980 );
16981 }
16982 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
16983 Stack,
16984 {
16985 direction: "row",
16986 justify: "flex-end",
16987 className: "dataviews-item-actions",
16988 style: {
16989 flexShrink: 0,
16990 width: "auto"
16991 },
16992 children: [
16993 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
16994 PrimaryActions,
16995 {
16996 item,
16997 actions: primaryActions,
16998 registry
16999 }
17000 ),
17001 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
17002 // there if there are any actions at all.
17003 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17004 CompactItemActions,
17005 {
17006 item,
17007 actions: eligibleActions,
17008 registry
17009 }
17010 )
17011 ]
17012 }
17013 );
17014 }
17015 function CompactItemActions({
17016 item,
17017 actions,
17018 isSmall,
17019 registry
17020 }) {
17021 const [activeModalAction, setActiveModalAction] = (0, import_element58.useState)(
17022 null
17023 );
17024 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [
17025 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Menu, { placement: "bottom-end", children: [
17026 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17027 Menu.TriggerButton,
17028 {
17029 render: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17030 import_components4.Button,
17031 {
17032 size: isSmall ? "small" : "compact",
17033 icon: more_vertical_default,
17034 label: (0, import_i18n8.__)("Actions"),
17035 accessibleWhenDisabled: true,
17036 disabled: !actions.length,
17037 className: "dataviews-all-actions-button"
17038 }
17039 )
17040 }
17041 ),
17042 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17043 ActionsMenuGroup,
17044 {
17045 actions,
17046 item,
17047 registry,
17048 setActiveModalAction
17049 }
17050 ) })
17051 ] }),
17052 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17053 ActionModal,
17054 {
17055 action: activeModalAction,
17056 items: [item],
17057 closeModal: () => setActiveModalAction(null)
17058 }
17059 )
17060 ] });
17061 }
17062 function PrimaryActions({
17063 item,
17064 actions,
17065 registry,
17066 buttonVariant
17067 }) {
17068 const [activeModalAction, setActiveModalAction] = (0, import_element58.useState)(null);
17069 const isMobileViewport = (0, import_compose3.useViewportMatch)("medium", "<");
17070 if (isMobileViewport) {
17071 return null;
17072 }
17073 if (!Array.isArray(actions) || actions.length === 0) {
17074 return null;
17075 }
17076 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [
17077 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17078 ButtonTrigger,
17079 {
17080 action,
17081 onClick: () => {
17082 if ("RenderModal" in action) {
17083 setActiveModalAction(action);
17084 return;
17085 }
17086 action.callback([item], { registry });
17087 },
17088 items: [item],
17089 variant: buttonVariant
17090 },
17091 action.id
17092 )),
17093 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17094 ActionModal,
17095 {
17096 action: activeModalAction,
17097 items: [item],
17098 closeModal: () => setActiveModalAction(null)
17099 }
17100 )
17101 ] });
17102 }
17103
17104 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
17105 var import_components5 = __toESM(require_components(), 1);
17106 var import_i18n10 = __toESM(require_i18n(), 1);
17107 var import_element59 = __toESM(require_element(), 1);
17108 var import_data2 = __toESM(require_data(), 1);
17109 var import_compose4 = __toESM(require_compose(), 1);
17110
17111 // packages/dataviews/build-module/utils/get-footer-message.mjs
17112 var import_i18n9 = __toESM(require_i18n(), 1);
17113 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
17114 if (selectionCount > 0) {
17115 return (0, import_i18n9.sprintf)(
17116 /* translators: %d: number of items. */
17117 (0, import_i18n9._n)("%d Item selected", "%d Items selected", selectionCount),
17118 selectionCount
17119 );
17120 }
17121 if (onlyTotalCount || totalItems <= itemsCount) {
17122 return (0, import_i18n9.sprintf)(
17123 /* translators: %d: number of items. */
17124 (0, import_i18n9._n)("%d Item", "%d Items", totalItems),
17125 totalItems
17126 );
17127 }
17128 return (0, import_i18n9.sprintf)(
17129 /* translators: %1$d: number of items. %2$d: total number of items. */
17130 (0, import_i18n9._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
17131 itemsCount,
17132 totalItems
17133 );
17134 }
17135
17136 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
17137 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
17138 function ActionWithModal({
17139 action,
17140 items,
17141 ActionTriggerComponent
17142 }) {
17143 const [isModalOpen, setIsModalOpen] = (0, import_element59.useState)(false);
17144 const actionTriggerProps = {
17145 action,
17146 onClick: () => {
17147 setIsModalOpen(true);
17148 },
17149 items
17150 };
17151 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(import_jsx_runtime93.Fragment, { children: [
17152 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
17153 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17154 ActionModal,
17155 {
17156 action,
17157 items,
17158 closeModal: () => setIsModalOpen(false)
17159 }
17160 )
17161 ] });
17162 }
17163 function useHasAPossibleBulkAction(actions, item) {
17164 return (0, import_element59.useMemo)(() => {
17165 return actions.some((action) => {
17166 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
17167 });
17168 }, [actions, item]);
17169 }
17170 function useSomeItemHasAPossibleBulkAction(actions, data) {
17171 return (0, import_element59.useMemo)(() => {
17172 return data.some((item) => {
17173 return actions.some((action) => {
17174 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
17175 });
17176 });
17177 }, [actions, data]);
17178 }
17179 function BulkSelectionCheckbox({
17180 selection,
17181 onChangeSelection,
17182 data,
17183 actions,
17184 getItemId,
17185 disableSelectAll = false
17186 }) {
17187 const selectableItems = (0, import_element59.useMemo)(() => {
17188 return data.filter((item) => {
17189 return actions.some(
17190 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
17191 );
17192 });
17193 }, [data, actions]);
17194 const selectedItems = data.filter(
17195 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
17196 );
17197 const hasSelection = selection.length > 0;
17198 const areAllSelected = selectedItems.length === selectableItems.length;
17199 if (disableSelectAll) {
17200 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17201 import_components5.CheckboxControl,
17202 {
17203 className: "dataviews-view-table-selection-checkbox",
17204 checked: hasSelection,
17205 disabled: !hasSelection,
17206 onChange: () => {
17207 onChangeSelection([]);
17208 },
17209 "aria-label": (0, import_i18n10.__)("Deselect all")
17210 }
17211 );
17212 }
17213 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17214 import_components5.CheckboxControl,
17215 {
17216 className: "dataviews-view-table-selection-checkbox",
17217 checked: areAllSelected,
17218 indeterminate: !areAllSelected && !!selectedItems.length,
17219 onChange: () => {
17220 if (areAllSelected) {
17221 onChangeSelection([]);
17222 } else {
17223 onChangeSelection(
17224 selectableItems.map((item) => getItemId(item))
17225 );
17226 }
17227 },
17228 "aria-label": areAllSelected ? (0, import_i18n10.__)("Deselect all") : (0, import_i18n10.__)("Select all")
17229 }
17230 );
17231 }
17232 function ActionTrigger({
17233 action,
17234 onClick,
17235 isBusy,
17236 items
17237 }) {
17238 const label = typeof action.label === "string" ? action.label : action.label(items);
17239 const isMobile = (0, import_compose4.useViewportMatch)("medium", "<");
17240 if (isMobile) {
17241 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17242 import_components5.Button,
17243 {
17244 disabled: isBusy,
17245 accessibleWhenDisabled: true,
17246 label,
17247 icon: action.icon,
17248 size: "compact",
17249 onClick,
17250 isBusy
17251 }
17252 );
17253 }
17254 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17255 import_components5.Button,
17256 {
17257 disabled: isBusy,
17258 accessibleWhenDisabled: true,
17259 size: "compact",
17260 onClick,
17261 isBusy,
17262 children: label
17263 }
17264 );
17265 }
17266 var EMPTY_ARRAY2 = [];
17267 function ActionButton2({
17268 action,
17269 selectedItems,
17270 actionInProgress,
17271 setActionInProgress
17272 }) {
17273 const registry = (0, import_data2.useRegistry)();
17274 const selectedEligibleItems = (0, import_element59.useMemo)(() => {
17275 return selectedItems.filter((item) => {
17276 return !action.isEligible || action.isEligible(item);
17277 });
17278 }, [action, selectedItems]);
17279 if ("RenderModal" in action) {
17280 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17281 ActionWithModal,
17282 {
17283 action,
17284 items: selectedEligibleItems,
17285 ActionTriggerComponent: ActionTrigger
17286 },
17287 action.id
17288 );
17289 }
17290 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17291 ActionTrigger,
17292 {
17293 action,
17294 onClick: async () => {
17295 setActionInProgress(action.id);
17296 await action.callback(selectedItems, {
17297 registry
17298 });
17299 setActionInProgress(null);
17300 },
17301 items: selectedEligibleItems,
17302 isBusy: actionInProgress === action.id
17303 },
17304 action.id
17305 );
17306 }
17307 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
17308 const message2 = getFooterMessage(
17309 selection.length,
17310 data.length,
17311 paginationInfo.totalItems,
17312 isInfiniteScroll
17313 );
17314 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
17315 Stack,
17316 {
17317 direction: "row",
17318 className: "dataviews-bulk-actions-footer__container",
17319 gap: "md",
17320 align: "center",
17321 children: [
17322 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17323 BulkSelectionCheckbox,
17324 {
17325 selection,
17326 onChangeSelection,
17327 data,
17328 actions,
17329 getItemId,
17330 disableSelectAll: isInfiniteScroll
17331 }
17332 ),
17333 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
17334 /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
17335 Stack,
17336 {
17337 direction: "row",
17338 className: "dataviews-bulk-actions-footer__action-buttons",
17339 gap: "xs",
17340 children: [
17341 actionsToShow.map((action) => {
17342 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17343 ActionButton2,
17344 {
17345 action,
17346 selectedItems,
17347 actionInProgress,
17348 setActionInProgress
17349 },
17350 action.id
17351 );
17352 }),
17353 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17354 import_components5.Button,
17355 {
17356 icon: close_small_default,
17357 showTooltip: true,
17358 tooltipPosition: "top",
17359 size: "compact",
17360 label: (0, import_i18n10.__)("Cancel"),
17361 disabled: !!actionInProgress,
17362 accessibleWhenDisabled: false,
17363 onClick: () => {
17364 onChangeSelection(EMPTY_ARRAY2);
17365 }
17366 }
17367 )
17368 ]
17369 }
17370 )
17371 ]
17372 }
17373 );
17374 }
17375 function FooterContent({
17376 selection,
17377 actions,
17378 onChangeSelection,
17379 data,
17380 getItemId,
17381 isInfiniteScroll,
17382 paginationInfo
17383 }) {
17384 const [actionInProgress, setActionInProgress] = (0, import_element59.useState)(
17385 null
17386 );
17387 const footerContentRef = (0, import_element59.useRef)(void 0);
17388 const isMobile = (0, import_compose4.useViewportMatch)("medium", "<");
17389 const bulkActions = (0, import_element59.useMemo)(
17390 () => actions.filter((action) => action.supportsBulk),
17391 [actions]
17392 );
17393 const selectableItems = (0, import_element59.useMemo)(() => {
17394 return data.filter((item) => {
17395 return bulkActions.some(
17396 (action) => !action.isEligible || action.isEligible(item)
17397 );
17398 });
17399 }, [data, bulkActions]);
17400 const selectedItems = (0, import_element59.useMemo)(() => {
17401 return data.filter(
17402 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
17403 );
17404 }, [selection, data, getItemId, selectableItems]);
17405 const actionsToShow = (0, import_element59.useMemo)(
17406 () => actions.filter((action) => {
17407 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
17408 (item) => !action.isEligible || action.isEligible(item)
17409 );
17410 }),
17411 [actions, selectedItems, isMobile]
17412 );
17413 if (!actionInProgress) {
17414 if (footerContentRef.current) {
17415 footerContentRef.current = void 0;
17416 }
17417 return renderFooterContent(
17418 data,
17419 actions,
17420 getItemId,
17421 isInfiniteScroll,
17422 selection,
17423 actionsToShow,
17424 selectedItems,
17425 actionInProgress,
17426 setActionInProgress,
17427 onChangeSelection,
17428 paginationInfo
17429 );
17430 } else if (!footerContentRef.current) {
17431 footerContentRef.current = renderFooterContent(
17432 data,
17433 actions,
17434 getItemId,
17435 isInfiniteScroll,
17436 selection,
17437 actionsToShow,
17438 selectedItems,
17439 actionInProgress,
17440 setActionInProgress,
17441 onChangeSelection,
17442 paginationInfo
17443 );
17444 }
17445 return footerContentRef.current;
17446 }
17447 function BulkActionsFooter() {
17448 const {
17449 data,
17450 selection,
17451 actions = EMPTY_ARRAY2,
17452 onChangeSelection,
17453 getItemId,
17454 paginationInfo,
17455 view
17456 } = (0, import_element59.useContext)(dataviews_context_default);
17457 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17458 FooterContent,
17459 {
17460 selection,
17461 onChangeSelection,
17462 data,
17463 actions,
17464 getItemId,
17465 isInfiniteScroll: !!view.infiniteScrollEnabled,
17466 paginationInfo
17467 }
17468 );
17469 }
17470
17471 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
17472 var import_i18n11 = __toESM(require_i18n(), 1);
17473 var import_components6 = __toESM(require_components(), 1);
17474 var import_element60 = __toESM(require_element(), 1);
17475
17476 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
17477 function getHideableFields(view, fields) {
17478 const togglableFields = [
17479 view?.titleField,
17480 view?.mediaField,
17481 view?.descriptionField
17482 ].filter(Boolean);
17483 return fields.filter(
17484 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
17485 );
17486 }
17487
17488 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
17489 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
17490 var { Menu: Menu2 } = unlock3(import_components6.privateApis);
17491 function WithMenuSeparators({ children }) {
17492 return import_element60.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(import_element60.Fragment, { children: [
17493 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Separator, {}),
17494 child
17495 ] }, i2));
17496 }
17497 var _HeaderMenu = (0, import_element60.forwardRef)(function HeaderMenu({
17498 fieldId,
17499 view,
17500 fields,
17501 onChangeView,
17502 onHide,
17503 setOpenedFilter,
17504 canMove = true,
17505 canInsertLeft = true,
17506 canInsertRight = true
17507 }, ref) {
17508 const visibleFieldIds = view.fields ?? [];
17509 const index2 = visibleFieldIds?.indexOf(fieldId);
17510 const isSorted = view.sort?.field === fieldId;
17511 let isHidable = false;
17512 let isSortable = false;
17513 let canAddFilter = false;
17514 let operators = [];
17515 const field = fields.find((f2) => f2.id === fieldId);
17516 const { setIsShowingFilter } = (0, import_element60.useContext)(dataviews_context_default);
17517 if (!field) {
17518 return null;
17519 }
17520 isHidable = field.enableHiding !== false;
17521 isSortable = field.enableSorting !== false;
17522 const header = field.header;
17523 operators = !!field.filterBy && field.filterBy?.operators || [];
17524 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
17525 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
17526 return header;
17527 }
17528 const hiddenFields = getHideableFields(view, fields).filter(
17529 (f2) => !visibleFieldIds.includes(f2.id)
17530 );
17531 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
17532 const isRtl = (0, import_i18n11.isRTL)();
17533 return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2, { children: [
17534 /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
17535 Menu2.TriggerButton,
17536 {
17537 render: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17538 import_components6.Button,
17539 {
17540 size: "compact",
17541 className: "dataviews-view-table-header-button",
17542 ref,
17543 variant: "tertiary"
17544 }
17545 ),
17546 children: [
17547 header,
17548 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
17549 ]
17550 }
17551 ),
17552 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(WithMenuSeparators, { children: [
17553 isSortable && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
17554 (direction) => {
17555 const isChecked = view.sort && isSorted && view.sort.direction === direction;
17556 const value = `${fieldId}-${direction}`;
17557 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17558 Menu2.RadioItem,
17559 {
17560 name: "view-table-sorting",
17561 value,
17562 checked: isChecked,
17563 onChange: () => {
17564 onChangeView({
17565 ...view,
17566 sort: {
17567 field: fieldId,
17568 direction
17569 },
17570 showLevels: false
17571 });
17572 },
17573 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
17574 },
17575 value
17576 );
17577 }
17578 ) }),
17579 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17580 Menu2.Item,
17581 {
17582 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: funnel_default }),
17583 onClick: () => {
17584 setOpenedFilter(fieldId);
17585 setIsShowingFilter(true);
17586 onChangeView({
17587 ...view,
17588 page: 1,
17589 filters: [
17590 ...view.filters || [],
17591 {
17592 field: fieldId,
17593 value: void 0,
17594 operator: operators[0]
17595 }
17596 ]
17597 });
17598 },
17599 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Add filter") })
17600 }
17601 ) }),
17602 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2.Group, { children: [
17603 canMove && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17604 Menu2.Item,
17605 {
17606 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: arrow_left_default }),
17607 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
17608 onClick: () => {
17609 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
17610 const newFields = [
17611 ...visibleFieldIds
17612 ];
17613 newFields.splice(index2, 1);
17614 newFields.splice(
17615 targetIndex,
17616 0,
17617 fieldId
17618 );
17619 onChangeView({
17620 ...view,
17621 fields: newFields
17622 });
17623 },
17624 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Move left") })
17625 }
17626 ),
17627 canMove && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17628 Menu2.Item,
17629 {
17630 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: arrow_right_default }),
17631 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
17632 onClick: () => {
17633 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
17634 const newFields = [
17635 ...visibleFieldIds
17636 ];
17637 newFields.splice(index2, 1);
17638 newFields.splice(
17639 targetIndex,
17640 0,
17641 fieldId
17642 );
17643 onChangeView({
17644 ...view,
17645 fields: newFields
17646 });
17647 },
17648 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Move right") })
17649 }
17650 ),
17651 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2, { children: [
17652 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Insert left") }) }),
17653 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
17654 const insertIndex = isRtl ? index2 + 1 : index2;
17655 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17656 Menu2.Item,
17657 {
17658 onClick: () => {
17659 onChangeView({
17660 ...view,
17661 fields: [
17662 ...visibleFieldIds.slice(
17663 0,
17664 insertIndex
17665 ),
17666 hiddenField.id,
17667 ...visibleFieldIds.slice(
17668 insertIndex
17669 )
17670 ]
17671 });
17672 },
17673 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
17674 },
17675 hiddenField.id
17676 );
17677 }) })
17678 ] }),
17679 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Menu2, { children: [
17680 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Insert right") }) }),
17681 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
17682 const insertIndex = isRtl ? index2 : index2 + 1;
17683 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17684 Menu2.Item,
17685 {
17686 onClick: () => {
17687 onChangeView({
17688 ...view,
17689 fields: [
17690 ...visibleFieldIds.slice(
17691 0,
17692 insertIndex
17693 ),
17694 hiddenField.id,
17695 ...visibleFieldIds.slice(
17696 insertIndex
17697 )
17698 ]
17699 });
17700 },
17701 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
17702 },
17703 hiddenField.id
17704 );
17705 }) })
17706 ] }),
17707 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17708 Menu2.Item,
17709 {
17710 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components6.Icon, { icon: unseen_default }),
17711 onClick: () => {
17712 onHide(field);
17713 onChangeView({
17714 ...view,
17715 fields: visibleFieldIds.filter(
17716 (id) => id !== fieldId
17717 )
17718 });
17719 },
17720 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Menu2.ItemLabel, { children: (0, import_i18n11.__)("Hide column") })
17721 }
17722 )
17723 ] })
17724 ] }) })
17725 ] });
17726 });
17727 var ColumnHeaderMenu = _HeaderMenu;
17728 var column_header_menu_default = ColumnHeaderMenu;
17729
17730 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
17731 var import_element61 = __toESM(require_element(), 1);
17732 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
17733 function getClickableItemProps({
17734 item,
17735 isItemClickable,
17736 onClickItem,
17737 className
17738 }) {
17739 if (!isItemClickable(item) || !onClickItem) {
17740 return { className };
17741 }
17742 return {
17743 className: className ? `${className} ${className}--clickable` : void 0,
17744 role: "button",
17745 tabIndex: 0,
17746 onClick: (event) => {
17747 event.stopPropagation();
17748 onClickItem(item);
17749 },
17750 onKeyDown: (event) => {
17751 if (event.key === "Enter" || event.key === "" || event.key === " ") {
17752 event.stopPropagation();
17753 onClickItem(item);
17754 }
17755 }
17756 };
17757 }
17758 function ItemClickWrapper({
17759 item,
17760 isItemClickable,
17761 onClickItem,
17762 renderItemLink,
17763 className,
17764 children,
17765 ...extraProps
17766 }) {
17767 if (!isItemClickable(item)) {
17768 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className, ...extraProps, children });
17769 }
17770 if (renderItemLink) {
17771 const renderedElement = renderItemLink({
17772 item,
17773 className: `${className} ${className}--clickable`,
17774 ...extraProps,
17775 children
17776 });
17777 return (0, import_element61.cloneElement)(renderedElement, {
17778 onClick: (event) => {
17779 event.stopPropagation();
17780 if (renderedElement.props.onClick) {
17781 renderedElement.props.onClick(event);
17782 }
17783 },
17784 onKeyDown: (event) => {
17785 if (event.key === "Enter" || event.key === "" || event.key === " ") {
17786 event.stopPropagation();
17787 if (renderedElement.props.onKeyDown) {
17788 renderedElement.props.onKeyDown(event);
17789 }
17790 }
17791 }
17792 });
17793 }
17794 const clickProps = getClickableItemProps({
17795 item,
17796 isItemClickable,
17797 onClickItem,
17798 className
17799 });
17800 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { ...clickProps, ...extraProps, children });
17801 }
17802
17803 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
17804 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
17805 function ColumnPrimary({
17806 item,
17807 level,
17808 titleField: titleField2,
17809 mediaField,
17810 descriptionField: descriptionField3,
17811 onClickItem,
17812 renderItemLink,
17813 isItemClickable
17814 }) {
17815 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
17816 mediaField && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
17817 ItemClickWrapper,
17818 {
17819 item,
17820 isItemClickable,
17821 onClickItem,
17822 renderItemLink,
17823 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
17824 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField2 ? titleField2.getValue?.({ item }) : void 0,
17825 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
17826 mediaField.render,
17827 {
17828 item,
17829 field: mediaField,
17830 config: { sizes: "32px" }
17831 }
17832 )
17833 }
17834 ),
17835 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
17836 Stack,
17837 {
17838 direction: "column",
17839 align: "flex-start",
17840 className: "dataviews-view-table__primary-column-content",
17841 children: [
17842 titleField2 && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
17843 ItemClickWrapper,
17844 {
17845 item,
17846 isItemClickable,
17847 onClickItem,
17848 renderItemLink,
17849 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
17850 children: [
17851 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("span", { className: "dataviews-view-table__level", children: [
17852 Array(level).fill("\u2014").join(" "),
17853 "\xA0"
17854 ] }),
17855 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(titleField2.render, { item, field: titleField2 })
17856 ]
17857 }
17858 ),
17859 descriptionField3 && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
17860 descriptionField3.render,
17861 {
17862 item,
17863 field: descriptionField3
17864 }
17865 )
17866 ]
17867 }
17868 )
17869 ] });
17870 }
17871 var column_primary_default = ColumnPrimary;
17872
17873 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
17874 var import_element62 = __toESM(require_element(), 1);
17875 var import_i18n12 = __toESM(require_i18n(), 1);
17876 var isScrolledToEnd = (element) => {
17877 if ((0, import_i18n12.isRTL)()) {
17878 const scrollLeft = Math.abs(element.scrollLeft);
17879 return scrollLeft <= 1;
17880 }
17881 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
17882 };
17883 function useScrollState({
17884 scrollContainerRef,
17885 enabledHorizontal = false
17886 }) {
17887 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element62.useState)(false);
17888 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element62.useState)(false);
17889 const handleScroll = (0, import_element62.useCallback)(() => {
17890 const scrollContainer = scrollContainerRef.current;
17891 if (!scrollContainer) {
17892 return;
17893 }
17894 if (enabledHorizontal) {
17895 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
17896 }
17897 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
17898 }, [scrollContainerRef, enabledHorizontal]);
17899 (0, import_element62.useEffect)(() => {
17900 if (typeof window === "undefined" || !scrollContainerRef.current) {
17901 return () => {
17902 };
17903 }
17904 const scrollContainer = scrollContainerRef.current;
17905 handleScroll();
17906 scrollContainer.addEventListener("scroll", handleScroll);
17907 window.addEventListener("resize", handleScroll);
17908 return () => {
17909 scrollContainer.removeEventListener("scroll", handleScroll);
17910 window.removeEventListener("resize", handleScroll);
17911 };
17912 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
17913 return { isHorizontalScrollEnd, isVerticallyScrolled };
17914 }
17915
17916 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
17917 function getDataByGroup(data, groupByField) {
17918 return data.reduce((groups, item) => {
17919 const groupName = groupByField.getValue({ item });
17920 if (!groups.has(groupName)) {
17921 groups.set(groupName, []);
17922 }
17923 groups.get(groupName)?.push(item);
17924 return groups;
17925 }, /* @__PURE__ */ new Map());
17926 }
17927
17928 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
17929 var import_components7 = __toESM(require_components(), 1);
17930 var import_i18n13 = __toESM(require_i18n(), 1);
17931 var import_element63 = __toESM(require_element(), 1);
17932 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
17933 function FieldItem({
17934 field,
17935 isVisible: isVisible2,
17936 onToggleVisibility
17937 }) {
17938 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components7.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
17939 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components7.Icon, { icon: check_default }) }),
17940 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
17941 ] }) });
17942 }
17943 function isDefined(item) {
17944 return !!item;
17945 }
17946 function PropertiesSection({
17947 showLabel = true
17948 }) {
17949 const { view, fields, onChangeView } = (0, import_element63.useContext)(dataviews_context_default);
17950 const regularFields = getHideableFields(view, fields);
17951 if (!regularFields?.length) {
17952 return null;
17953 }
17954 const titleField2 = fields.find((f2) => f2.id === view.titleField);
17955 const previewField = fields.find((f2) => f2.id === view.mediaField);
17956 const descriptionField3 = fields.find(
17957 (f2) => f2.id === view.descriptionField
17958 );
17959 const lockedFields = [
17960 {
17961 field: titleField2,
17962 isVisibleFlag: "showTitle"
17963 },
17964 {
17965 field: previewField,
17966 isVisibleFlag: "showMedia"
17967 },
17968 {
17969 field: descriptionField3,
17970 isVisibleFlag: "showDescription"
17971 }
17972 ].filter(({ field }) => isDefined(field));
17973 const visibleFieldIds = view.fields ?? [];
17974 const visibleRegularFieldsCount = regularFields.filter(
17975 (f2) => visibleFieldIds.includes(f2.id)
17976 ).length;
17977 const visibleLockedFields = lockedFields.filter(
17978 ({ isVisibleFlag }) => (
17979 // @ts-expect-error
17980 view[isVisibleFlag] ?? true
17981 )
17982 );
17983 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
17984 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
17985 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
17986 showLabel && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components7.BaseControl.VisualLabel, { children: (0, import_i18n13.__)("Properties") }),
17987 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
17988 Stack,
17989 {
17990 direction: "column",
17991 className: "dataviews-view-config__properties",
17992 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(import_components7.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
17993 lockedFields.map(({ field, isVisibleFlag }) => {
17994 const isVisible2 = view[isVisibleFlag] ?? true;
17995 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
17996 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
17997 FieldItem,
17998 {
17999 field: fieldToRender,
18000 isVisible: isVisible2,
18001 onToggleVisibility: () => {
18002 onChangeView({
18003 ...view,
18004 [isVisibleFlag]: !isVisible2
18005 });
18006 }
18007 },
18008 field.id
18009 );
18010 }),
18011 regularFields.map((field) => {
18012 const isVisible2 = visibleFieldIds.includes(field.id);
18013 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
18014 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
18015 FieldItem,
18016 {
18017 field: fieldToRender,
18018 isVisible: isVisible2,
18019 onToggleVisibility: () => {
18020 onChangeView({
18021 ...view,
18022 fields: isVisible2 ? visibleFieldIds.filter(
18023 (fieldId) => fieldId !== field.id
18024 ) : [...visibleFieldIds, field.id]
18025 });
18026 }
18027 },
18028 field.id
18029 );
18030 })
18031 ] })
18032 }
18033 )
18034 ] });
18035 }
18036
18037 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
18038 var import_element64 = __toESM(require_element(), 1);
18039 function useDelayedLoading(isLoading, options = { delay: 400 }) {
18040 const [showLoader, setShowLoader] = (0, import_element64.useState)(false);
18041 (0, import_element64.useEffect)(() => {
18042 if (!isLoading) {
18043 return;
18044 }
18045 const timeout = setTimeout(() => {
18046 setShowLoader(true);
18047 }, options.delay);
18048 return () => {
18049 clearTimeout(timeout);
18050 setShowLoader(false);
18051 };
18052 }, [isLoading, options.delay]);
18053 return showLoader;
18054 }
18055
18056 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
18057 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
18058 function getEffectiveAlign(explicitAlign, fieldType) {
18059 if (explicitAlign) {
18060 return explicitAlign;
18061 }
18062 if (fieldType === "integer" || fieldType === "number") {
18063 return "end";
18064 }
18065 return void 0;
18066 }
18067 function TableColumnField({
18068 item,
18069 fields,
18070 column,
18071 align
18072 }) {
18073 const field = fields.find((f2) => f2.id === column);
18074 if (!field) {
18075 return null;
18076 }
18077 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
18078 "dataviews-view-table__cell-align-end": align === "end",
18079 "dataviews-view-table__cell-align-center": align === "center"
18080 });
18081 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(field.render, { item, field }) });
18082 }
18083 function TableRow({
18084 hasBulkActions,
18085 item,
18086 level,
18087 actions,
18088 fields,
18089 id,
18090 view,
18091 titleField: titleField2,
18092 mediaField,
18093 descriptionField: descriptionField3,
18094 selection,
18095 getItemId,
18096 isItemClickable,
18097 onClickItem,
18098 renderItemLink,
18099 onChangeSelection,
18100 isActionsColumnSticky,
18101 posinset
18102 }) {
18103 const { paginationInfo } = (0, import_element65.useContext)(dataviews_context_default);
18104 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
18105 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
18106 const {
18107 showTitle = true,
18108 showMedia = true,
18109 showDescription = true,
18110 infiniteScrollEnabled
18111 } = view;
18112 const isTouchDeviceRef = (0, import_element65.useRef)(false);
18113 const columns = view.fields ?? [];
18114 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription;
18115 return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
18116 "tr",
18117 {
18118 className: clsx_default("dataviews-view-table__row", {
18119 "is-selected": hasPossibleBulkAction && isSelected2,
18120 "has-bulk-actions": hasPossibleBulkAction
18121 }),
18122 onTouchStart: () => {
18123 isTouchDeviceRef.current = true;
18124 },
18125 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
18126 "aria-posinset": posinset,
18127 role: infiniteScrollEnabled ? "article" : void 0,
18128 onMouseDown: (event) => {
18129 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
18130 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
18131 event?.preventDefault();
18132 }
18133 },
18134 onClick: (event) => {
18135 if (!hasPossibleBulkAction) {
18136 return;
18137 }
18138 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
18139 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
18140 onChangeSelection(
18141 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
18142 );
18143 }
18144 },
18145 children: [
18146 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18147 DataViewsSelectionCheckbox,
18148 {
18149 item,
18150 selection,
18151 onChangeSelection,
18152 getItemId,
18153 titleField: titleField2,
18154 disabled: !hasPossibleBulkAction
18155 }
18156 ) }) }),
18157 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18158 column_primary_default,
18159 {
18160 item,
18161 level,
18162 titleField: showTitle ? titleField2 : void 0,
18163 mediaField: showMedia ? mediaField : void 0,
18164 descriptionField: showDescription ? descriptionField3 : void 0,
18165 isItemClickable,
18166 onClickItem,
18167 renderItemLink
18168 }
18169 ) }),
18170 columns.map((column) => {
18171 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
18172 const field = fields.find((f2) => f2.id === column);
18173 const effectiveAlign = getEffectiveAlign(align, field?.type);
18174 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18175 "td",
18176 {
18177 style: {
18178 width,
18179 maxWidth,
18180 minWidth
18181 },
18182 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18183 TableColumnField,
18184 {
18185 fields,
18186 item,
18187 column,
18188 align: effectiveAlign
18189 }
18190 )
18191 },
18192 column
18193 );
18194 }),
18195 !!actions?.length && // Disable reason: we are not making the element interactive,
18196 // but preventing any click events from bubbling up to the
18197 // table row. This allows us to add a click handler to the row
18198 // itself (to toggle row selection) without erroneously
18199 // intercepting click events from ItemActions.
18200 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18201 "td",
18202 {
18203 className: clsx_default("dataviews-view-table__actions-column", {
18204 "dataviews-view-table__actions-column--sticky": true,
18205 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
18206 }),
18207 onClick: (e2) => e2.stopPropagation(),
18208 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ItemActions, { item, actions })
18209 }
18210 )
18211 ]
18212 }
18213 );
18214 }
18215 function ViewTable({
18216 actions,
18217 data,
18218 fields,
18219 getItemId,
18220 getItemLevel,
18221 isLoading = false,
18222 onChangeView,
18223 onChangeSelection,
18224 selection,
18225 setOpenedFilter,
18226 onClickItem,
18227 isItemClickable,
18228 renderItemLink,
18229 view,
18230 className,
18231 empty
18232 }) {
18233 const { containerRef } = (0, import_element65.useContext)(dataviews_context_default);
18234 const isDelayedLoading = useDelayedLoading(isLoading);
18235 const headerMenuRefs = (0, import_element65.useRef)(/* @__PURE__ */ new Map());
18236 const headerMenuToFocusRef = (0, import_element65.useRef)(void 0);
18237 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element65.useState)();
18238 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element65.useState)(null);
18239 (0, import_element65.useEffect)(() => {
18240 if (headerMenuToFocusRef.current) {
18241 headerMenuToFocusRef.current.focus();
18242 headerMenuToFocusRef.current = void 0;
18243 }
18244 });
18245 const tableNoticeId = (0, import_element65.useId)();
18246 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
18247 scrollContainerRef: containerRef,
18248 enabledHorizontal: !!actions?.length
18249 });
18250 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
18251 if (nextHeaderMenuToFocus) {
18252 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
18253 setNextHeaderMenuToFocus(void 0);
18254 return;
18255 }
18256 const onHide = (field) => {
18257 const hidden = headerMenuRefs.current.get(field.id);
18258 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
18259 setNextHeaderMenuToFocus(fallback?.node);
18260 };
18261 const handleHeaderContextMenu = (event) => {
18262 event.preventDefault();
18263 event.stopPropagation();
18264 const virtualAnchor = {
18265 getBoundingClientRect: () => ({
18266 x: event.clientX,
18267 y: event.clientY,
18268 top: event.clientY,
18269 left: event.clientX,
18270 right: event.clientX,
18271 bottom: event.clientY,
18272 width: 0,
18273 height: 0,
18274 toJSON: () => ({})
18275 })
18276 };
18277 window.requestAnimationFrame(() => {
18278 setContextMenuAnchor(virtualAnchor);
18279 });
18280 };
18281 const hasData = !!data?.length;
18282 const titleField2 = fields.find((field) => field.id === view.titleField);
18283 const mediaField = fields.find((field) => field.id === view.mediaField);
18284 const descriptionField3 = fields.find(
18285 (field) => field.id === view.descriptionField
18286 );
18287 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
18288 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
18289 const { showTitle = true, showMedia = true, showDescription = true } = view;
18290 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription;
18291 const columns = view.fields ?? [];
18292 const headerMenuRef = (column, index2) => (node) => {
18293 if (node) {
18294 headerMenuRefs.current.set(column, {
18295 node,
18296 fallback: columns[index2 > 0 ? index2 - 1 : 1]
18297 });
18298 } else {
18299 headerMenuRefs.current.delete(column);
18300 }
18301 };
18302 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
18303 const isRtl = (0, import_i18n14.isRTL)();
18304 if (!hasData) {
18305 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18306 "div",
18307 {
18308 className: clsx_default("dataviews-no-results", {
18309 "is-refreshing": isDelayedLoading
18310 }),
18311 id: tableNoticeId,
18312 children: empty
18313 }
18314 );
18315 }
18316 return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_jsx_runtime98.Fragment, { children: [
18317 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
18318 "table",
18319 {
18320 className: clsx_default("dataviews-view-table", className, {
18321 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
18322 view.layout.density
18323 ),
18324 "has-bulk-actions": hasBulkActions,
18325 "is-refreshing": !isInfiniteScroll && isDelayedLoading
18326 }),
18327 "aria-busy": isLoading,
18328 "aria-describedby": tableNoticeId,
18329 role: isInfiniteScroll ? "feed" : void 0,
18330 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
18331 children: [
18332 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("colgroup", { children: [
18333 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
18334 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
18335 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18336 "col",
18337 {
18338 className: clsx_default(
18339 `dataviews-view-table__col-${column}`,
18340 {
18341 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
18342 }
18343 )
18344 },
18345 `col-${column}`
18346 )),
18347 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("col", { className: "dataviews-view-table__col-actions" })
18348 ] }),
18349 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18350 import_components8.Popover,
18351 {
18352 anchor: contextMenuAnchor,
18353 onClose: () => setContextMenuAnchor(null),
18354 placement: "bottom-start",
18355 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(PropertiesSection, { showLabel: false })
18356 }
18357 ),
18358 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18359 "thead",
18360 {
18361 className: clsx_default({
18362 "dataviews-view-table__thead--stuck": isVerticallyScrolled
18363 }),
18364 onContextMenu: handleHeaderContextMenu,
18365 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("tr", { className: "dataviews-view-table__row", children: [
18366 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18367 "th",
18368 {
18369 className: "dataviews-view-table__checkbox-column",
18370 scope: "col",
18371 onContextMenu: handleHeaderContextMenu,
18372 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18373 BulkSelectionCheckbox,
18374 {
18375 selection,
18376 onChangeSelection,
18377 data,
18378 actions,
18379 getItemId
18380 }
18381 )
18382 }
18383 ),
18384 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("th", { scope: "col", children: titleField2 && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18385 column_header_menu_default,
18386 {
18387 ref: headerMenuRef(
18388 titleField2.id,
18389 0
18390 ),
18391 fieldId: titleField2.id,
18392 view,
18393 fields,
18394 onChangeView,
18395 onHide,
18396 setOpenedFilter,
18397 canMove: false,
18398 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
18399 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
18400 }
18401 ) }),
18402 columns.map((column, index2) => {
18403 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
18404 const field = fields.find(
18405 (f2) => f2.id === column
18406 );
18407 const effectiveAlign = getEffectiveAlign(
18408 align,
18409 field?.type
18410 );
18411 const canInsertOrMove = view.layout?.enableMoving ?? true;
18412 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18413 "th",
18414 {
18415 style: {
18416 width,
18417 maxWidth,
18418 minWidth,
18419 textAlign: effectiveAlign
18420 },
18421 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
18422 scope: "col",
18423 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18424 column_header_menu_default,
18425 {
18426 ref: headerMenuRef(column, index2),
18427 fieldId: column,
18428 view,
18429 fields,
18430 onChangeView,
18431 onHide,
18432 setOpenedFilter,
18433 canMove: canInsertOrMove,
18434 canInsertLeft: canInsertOrMove,
18435 canInsertRight: canInsertOrMove
18436 }
18437 )
18438 },
18439 column
18440 );
18441 }),
18442 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18443 "th",
18444 {
18445 className: clsx_default(
18446 "dataviews-view-table__actions-column",
18447 {
18448 "dataviews-view-table__actions-column--sticky": true,
18449 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
18450 }
18451 ),
18452 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n14.__)("Actions") })
18453 }
18454 )
18455 ] })
18456 }
18457 ),
18458 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
18459 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("tbody", { children: [
18460 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18461 "td",
18462 {
18463 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
18464 className: "dataviews-view-table__group-header-cell",
18465 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
18466 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
18467 (0, import_i18n14.__)("%1$s: %2$s"),
18468 groupField.label,
18469 groupName
18470 )
18471 }
18472 ) }),
18473 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18474 TableRow,
18475 {
18476 item,
18477 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
18478 hasBulkActions,
18479 actions,
18480 fields,
18481 id: getItemId(item) || index2.toString(),
18482 view,
18483 titleField: titleField2,
18484 mediaField,
18485 descriptionField: descriptionField3,
18486 selection,
18487 getItemId,
18488 onChangeSelection,
18489 onClickItem,
18490 renderItemLink,
18491 isItemClickable,
18492 isActionsColumnSticky: !isHorizontalScrollEnd
18493 },
18494 getItemId(item)
18495 ))
18496 ] }, `group-${groupName}`)
18497 ) : /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18498 TableRow,
18499 {
18500 item,
18501 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
18502 hasBulkActions,
18503 actions,
18504 fields,
18505 id: getItemId(item) || index2.toString(),
18506 view,
18507 titleField: titleField2,
18508 mediaField,
18509 descriptionField: descriptionField3,
18510 selection,
18511 getItemId,
18512 onChangeSelection,
18513 onClickItem,
18514 renderItemLink,
18515 isItemClickable,
18516 isActionsColumnSticky: !isHorizontalScrollEnd,
18517 posinset: isInfiniteScroll ? index2 + 1 : void 0
18518 },
18519 getItemId(item)
18520 )) })
18521 ]
18522 }
18523 ),
18524 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components8.Spinner, {}) }) })
18525 ] });
18526 }
18527 var table_default = ViewTable;
18528
18529 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
18530 var import_components11 = __toESM(require_components(), 1);
18531 var import_i18n17 = __toESM(require_i18n(), 1);
18532
18533 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
18534 var import_components10 = __toESM(require_components(), 1);
18535 var import_i18n16 = __toESM(require_i18n(), 1);
18536 var import_compose5 = __toESM(require_compose(), 1);
18537 var import_keycodes2 = __toESM(require_keycodes(), 1);
18538 var import_element69 = __toESM(require_element(), 1);
18539
18540 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
18541 var import_components9 = __toESM(require_components(), 1);
18542 var import_i18n15 = __toESM(require_i18n(), 1);
18543 var import_element66 = __toESM(require_element(), 1);
18544 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
18545 var imageSizes = [
18546 {
18547 value: 120,
18548 breakpoint: 1
18549 },
18550 {
18551 value: 170,
18552 breakpoint: 1
18553 },
18554 {
18555 value: 230,
18556 breakpoint: 1
18557 },
18558 {
18559 value: 290,
18560 breakpoint: 1112
18561 // at minimum image width, 4 images display at this container size
18562 },
18563 {
18564 value: 350,
18565 breakpoint: 1636
18566 // at minimum image width, 6 images display at this container size
18567 },
18568 {
18569 value: 430,
18570 breakpoint: 588
18571 // at minimum image width, 2 images display at this container size
18572 }
18573 ];
18574 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
18575 function useGridColumns() {
18576 const context = (0, import_element66.useContext)(dataviews_context_default);
18577 const view = context.view;
18578 return (0, import_element66.useMemo)(() => {
18579 const containerWidth = context.containerWidth;
18580 const gap = 32;
18581 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
18582 const columns = Math.floor(
18583 (containerWidth + gap) / (previewSize + gap)
18584 );
18585 return Math.max(1, columns);
18586 }, [context.containerWidth, view.layout?.previewSize]);
18587 }
18588
18589 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
18590 var import_element67 = __toESM(require_element(), 1);
18591 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
18592 var GridItems = (0, import_element67.forwardRef)(({ className, previewSize, ...props }, ref) => {
18593 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
18594 "div",
18595 {
18596 ref,
18597 className: clsx_default("dataviews-view-grid-items", className),
18598 style: {
18599 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
18600 },
18601 ...props
18602 }
18603 );
18604 });
18605
18606 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
18607 var import_element68 = __toESM(require_element(), 1);
18608 function useIntersectionObserver(elementRef, posinset) {
18609 const { intersectionObserver } = (0, import_element68.useContext)(dataviews_context_default);
18610 (0, import_element68.useEffect)(() => {
18611 const element = elementRef.current;
18612 if (!element || posinset === void 0 || !intersectionObserver) {
18613 return;
18614 }
18615 intersectionObserver.observe(element);
18616 return () => {
18617 intersectionObserver.unobserve(element);
18618 };
18619 }, [elementRef, intersectionObserver, posinset]);
18620 }
18621 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
18622 const hasData = !!data?.length;
18623 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
18624 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
18625 }
18626
18627 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
18628 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
18629 var { Badge: WCBadge } = unlock3(import_components10.privateApis);
18630 function chunk(array, size4) {
18631 const chunks = [];
18632 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
18633 chunks.push(array.slice(i2, i2 + size4));
18634 }
18635 return chunks;
18636 }
18637 var GridItem = (0, import_element69.forwardRef)(
18638 function GridItem2({
18639 view,
18640 selection,
18641 onChangeSelection,
18642 onClickItem,
18643 isItemClickable,
18644 renderItemLink,
18645 getItemId,
18646 item,
18647 actions,
18648 mediaField,
18649 titleField: titleField2,
18650 descriptionField: descriptionField3,
18651 regularFields,
18652 badgeFields,
18653 hasBulkActions,
18654 config,
18655 posinset,
18656 setsize,
18657 ...props
18658 }, forwardedRef) {
18659 const {
18660 showTitle = true,
18661 showMedia = true,
18662 showDescription = true
18663 } = view;
18664 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
18665 const id = getItemId(item);
18666 const elementRef = (0, import_element69.useRef)(null);
18667 const setRefs = (0, import_element69.useCallback)(
18668 (node) => {
18669 elementRef.current = node;
18670 if (typeof forwardedRef === "function") {
18671 forwardedRef(node);
18672 } else if (forwardedRef) {
18673 forwardedRef.current = node;
18674 }
18675 },
18676 [forwardedRef]
18677 );
18678 useIntersectionObserver(elementRef, posinset);
18679 const instanceId = (0, import_compose5.useInstanceId)(GridItem2);
18680 const isSelected2 = selection.includes(id);
18681 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
18682 const rendersMediaField = showMedia && mediaField?.render;
18683 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18684 mediaField.render,
18685 {
18686 item,
18687 field: mediaField,
18688 config
18689 }
18690 ) : mediaPlaceholder;
18691 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(titleField2.render, { item, field: titleField2 }) : null;
18692 let mediaA11yProps;
18693 let titleA11yProps;
18694 if (isItemClickable(item) && onClickItem) {
18695 if (renderedTitleField) {
18696 mediaA11yProps = {
18697 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
18698 };
18699 titleA11yProps = {
18700 id: `dataviews-view-grid__title-field-${instanceId}`
18701 };
18702 } else {
18703 mediaA11yProps = {
18704 "aria-label": (0, import_i18n16.__)("Navigate to item")
18705 };
18706 }
18707 }
18708 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(
18709 Stack,
18710 {
18711 direction: "column",
18712 ...props,
18713 ref: setRefs,
18714 "aria-setsize": setsize,
18715 "aria-posinset": posinset,
18716 className: clsx_default(
18717 props.className,
18718 "dataviews-view-grid__row__gridcell",
18719 "dataviews-view-grid__card",
18720 {
18721 "is-selected": hasBulkAction && isSelected2
18722 }
18723 ),
18724 onClickCapture: (event) => {
18725 props.onClickCapture?.(event);
18726 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
18727 event.stopPropagation();
18728 event.preventDefault();
18729 if (!hasBulkAction) {
18730 return;
18731 }
18732 onChangeSelection(
18733 isSelected2 ? selection.filter(
18734 (itemId) => id !== itemId
18735 ) : [...selection, id]
18736 );
18737 }
18738 },
18739 children: [
18740 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18741 ItemClickWrapper,
18742 {
18743 item,
18744 isItemClickable,
18745 onClickItem,
18746 renderItemLink,
18747 className: clsx_default("dataviews-view-grid__media", {
18748 "dataviews-view-grid__media--placeholder": !rendersMediaField
18749 }),
18750 ...mediaA11yProps,
18751 children: renderedMediaField
18752 }
18753 ),
18754 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18755 DataViewsSelectionCheckbox,
18756 {
18757 item,
18758 selection,
18759 onChangeSelection,
18760 getItemId,
18761 titleField: titleField2,
18762 disabled: !hasBulkAction
18763 }
18764 ),
18765 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18766 ItemActions,
18767 {
18768 item,
18769 actions,
18770 isCompact: true
18771 }
18772 ) }),
18773 showTitle && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18774 ItemClickWrapper,
18775 {
18776 item,
18777 isItemClickable,
18778 onClickItem,
18779 renderItemLink,
18780 className: "dataviews-view-grid__title-field dataviews-title-field",
18781 ...titleA11yProps,
18782 title: titleField2?.getValueFormatted({
18783 item,
18784 field: titleField2
18785 }) || void 0,
18786 children: renderedTitleField
18787 }
18788 ) }),
18789 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(Stack, { direction: "column", gap: "xs", children: [
18790 showDescription && descriptionField3?.render && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18791 descriptionField3.render,
18792 {
18793 item,
18794 field: descriptionField3
18795 }
18796 ),
18797 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18798 Stack,
18799 {
18800 direction: "row",
18801 className: "dataviews-view-grid__badge-fields",
18802 gap: "sm",
18803 wrap: "wrap",
18804 align: "top",
18805 justify: "flex-start",
18806 children: badgeFields.map((field) => {
18807 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18808 WCBadge,
18809 {
18810 className: "dataviews-view-grid__field-value",
18811 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18812 field.render,
18813 {
18814 item,
18815 field
18816 }
18817 )
18818 },
18819 field.id
18820 );
18821 })
18822 }
18823 ),
18824 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18825 Stack,
18826 {
18827 direction: "column",
18828 className: "dataviews-view-grid__fields",
18829 gap: "xs",
18830 children: regularFields.map((field) => {
18831 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18832 import_components10.Flex,
18833 {
18834 className: "dataviews-view-grid__field",
18835 gap: 1,
18836 justify: "flex-start",
18837 expanded: true,
18838 style: { height: "auto" },
18839 direction: "row",
18840 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [
18841 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(tooltip_exports.Root, { children: [
18842 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18843 tooltip_exports.Trigger,
18844 {
18845 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components10.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
18846 }
18847 ),
18848 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(tooltip_exports.Popup, { children: field.label })
18849 ] }),
18850 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18851 import_components10.FlexItem,
18852 {
18853 className: "dataviews-view-grid__field-value",
18854 style: { maxHeight: "none" },
18855 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18856 field.render,
18857 {
18858 item,
18859 field
18860 }
18861 )
18862 }
18863 )
18864 ] })
18865 },
18866 field.id
18867 );
18868 })
18869 }
18870 )
18871 ] })
18872 ]
18873 }
18874 );
18875 }
18876 );
18877 function CompositeGrid({
18878 data,
18879 isInfiniteScroll,
18880 className,
18881 inert,
18882 isLoading,
18883 view,
18884 fields,
18885 selection,
18886 onChangeSelection,
18887 onClickItem,
18888 isItemClickable,
18889 renderItemLink,
18890 getItemId,
18891 actions
18892 }) {
18893 const { paginationInfo, resizeObserverRef } = (0, import_element69.useContext)(dataviews_context_default);
18894 const gridColumns = useGridColumns();
18895 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
18896 const titleField2 = fields.find(
18897 (field) => field.id === view?.titleField
18898 );
18899 const mediaField = fields.find(
18900 (field) => field.id === view?.mediaField
18901 );
18902 const descriptionField3 = fields.find(
18903 (field) => field.id === view?.descriptionField
18904 );
18905 const otherFields = view.fields ?? [];
18906 const { regularFields, badgeFields } = otherFields.reduce(
18907 (accumulator, fieldId) => {
18908 const field = fields.find((f2) => f2.id === fieldId);
18909 if (!field) {
18910 return accumulator;
18911 }
18912 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
18913 accumulator[key].push(field);
18914 return accumulator;
18915 },
18916 { regularFields: [], badgeFields: [] }
18917 );
18918 const size4 = "900px";
18919 const totalRows = Math.ceil(data.length / gridColumns);
18920 const placeholdersNeeded = usePlaceholdersNeeded(
18921 data,
18922 isInfiniteScroll,
18923 gridColumns
18924 );
18925 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, {
18926 // Render infinite scroll layout (no rows, feed semantics)
18927 children: [
18928 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(
18929 import_components10.Composite,
18930 {
18931 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18932 GridItems,
18933 {
18934 className: clsx_default(
18935 "dataviews-view-grid-infinite-scroll",
18936 className,
18937 {
18938 [`has-${view.layout?.density}-density`]: view.layout?.density && [
18939 "compact",
18940 "comfortable"
18941 ].includes(view.layout.density)
18942 }
18943 ),
18944 previewSize: view.layout?.previewSize,
18945 "aria-busy": isLoading,
18946 ref: resizeObserverRef
18947 }
18948 ),
18949 role: "feed",
18950 focusWrap: true,
18951 inert,
18952 children: [
18953 Array.from({ length: placeholdersNeeded }).map(
18954 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18955 import_components10.Composite.Item,
18956 {
18957 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18958 Stack,
18959 {
18960 ...props,
18961 direction: "column",
18962 role: "article",
18963 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
18964 }
18965 ),
18966 "aria-hidden": true,
18967 tabIndex: -1
18968 },
18969 `placeholder-${index2}`
18970 )
18971 ),
18972 data.map((item) => {
18973 const itemId = getItemId(item);
18974 const stablePosition = item.position;
18975 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18976 import_components10.Composite.Item,
18977 {
18978 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18979 GridItem,
18980 {
18981 ...props,
18982 id: itemId,
18983 role: "article",
18984 view,
18985 selection,
18986 onChangeSelection,
18987 onClickItem,
18988 isItemClickable,
18989 renderItemLink,
18990 getItemId,
18991 item,
18992 actions,
18993 mediaField,
18994 titleField: titleField2,
18995 descriptionField: descriptionField3,
18996 regularFields,
18997 badgeFields,
18998 hasBulkActions,
18999 posinset: stablePosition,
19000 setsize: paginationInfo.totalItems,
19001 config: {
19002 sizes: size4
19003 }
19004 }
19005 )
19006 },
19007 itemId
19008 );
19009 })
19010 ]
19011 }
19012 ),
19013 // Render standard grid layout (with rows, grid semantics)
19014 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19015 import_components10.Composite,
19016 {
19017 role: "grid",
19018 className: clsx_default("dataviews-view-grid", className, {
19019 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
19020 view.layout.density
19021 )
19022 }),
19023 focusWrap: true,
19024 "aria-busy": isLoading,
19025 "aria-rowcount": totalRows,
19026 ref: resizeObserverRef,
19027 inert,
19028 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19029 import_components10.Composite.Row,
19030 {
19031 render: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19032 "div",
19033 {
19034 role: "row",
19035 "aria-rowindex": i2 + 1,
19036 "aria-label": (0, import_i18n16.sprintf)(
19037 /* translators: %d: The row number in the grid */
19038 (0, import_i18n16.__)("Row %d"),
19039 i2 + 1
19040 ),
19041 className: "dataviews-view-grid__row",
19042 style: {
19043 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
19044 }
19045 }
19046 ),
19047 children: row.map((item) => {
19048 const itemId = getItemId(item);
19049 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19050 import_components10.Composite.Item,
19051 {
19052 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
19053 GridItem,
19054 {
19055 ...props,
19056 id: itemId,
19057 role: "gridcell",
19058 view,
19059 selection,
19060 onChangeSelection,
19061 onClickItem,
19062 isItemClickable,
19063 renderItemLink,
19064 getItemId,
19065 item,
19066 actions,
19067 mediaField,
19068 titleField: titleField2,
19069 descriptionField: descriptionField3,
19070 regularFields,
19071 badgeFields,
19072 hasBulkActions,
19073 config: {
19074 sizes: size4
19075 }
19076 }
19077 )
19078 },
19079 itemId
19080 );
19081 })
19082 },
19083 i2
19084 ))
19085 }
19086 )
19087 ]
19088 });
19089 }
19090
19091 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
19092 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
19093 function ViewGrid({
19094 actions,
19095 data,
19096 fields,
19097 getItemId,
19098 isLoading,
19099 onChangeSelection,
19100 onClickItem,
19101 isItemClickable,
19102 renderItemLink,
19103 selection,
19104 view,
19105 className,
19106 empty
19107 }) {
19108 const isDelayedLoading = useDelayedLoading(!!isLoading);
19109 const hasData = !!data?.length;
19110 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
19111 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
19112 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
19113 if (!hasData) {
19114 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
19115 "div",
19116 {
19117 className: clsx_default("dataviews-no-results", {
19118 "is-refreshing": isDelayedLoading
19119 }),
19120 children: empty
19121 }
19122 );
19123 }
19124 const gridProps = {
19125 className: clsx_default(className, {
19126 "is-refreshing": !isInfiniteScroll && isDelayedLoading
19127 }),
19128 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
19129 isLoading,
19130 view,
19131 fields,
19132 selection,
19133 onChangeSelection,
19134 onClickItem,
19135 isItemClickable,
19136 renderItemLink,
19137 getItemId,
19138 actions
19139 };
19140 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_jsx_runtime102.Fragment, {
19141 // Render multiple groups.
19142 children: [
19143 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
19144 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(
19145 Stack,
19146 {
19147 direction: "column",
19148 gap: "sm",
19149 children: [
19150 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n17.sprintf)(
19151 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
19152 (0, import_i18n17.__)("%1$s: %2$s"),
19153 groupField.label,
19154 groupName
19155 ) }),
19156 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
19157 CompositeGrid,
19158 {
19159 ...gridProps,
19160 data: groupItems,
19161 isInfiniteScroll: false
19162 }
19163 )
19164 ]
19165 },
19166 groupName
19167 )
19168 ) }),
19169 // Render a single grid with all data.
19170 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
19171 CompositeGrid,
19172 {
19173 ...gridProps,
19174 data,
19175 isInfiniteScroll: !!isInfiniteScroll
19176 }
19177 ),
19178 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components11.Spinner, {}) })
19179 ]
19180 });
19181 }
19182 var grid_default = ViewGrid;
19183
19184 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
19185 var import_compose6 = __toESM(require_compose(), 1);
19186 var import_components12 = __toESM(require_components(), 1);
19187 var import_element70 = __toESM(require_element(), 1);
19188 var import_i18n18 = __toESM(require_i18n(), 1);
19189 var import_data3 = __toESM(require_data(), 1);
19190 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
19191 var { Menu: Menu3 } = unlock3(import_components12.privateApis);
19192 function generateItemWrapperCompositeId(idPrefix) {
19193 return `${idPrefix}-item-wrapper`;
19194 }
19195 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
19196 return `${idPrefix}-primary-action-${primaryActionId}`;
19197 }
19198 function generateDropdownTriggerCompositeId(idPrefix) {
19199 return `${idPrefix}-dropdown`;
19200 }
19201 function PrimaryActionGridCell({
19202 idPrefix,
19203 primaryAction,
19204 item
19205 }) {
19206 const registry = (0, import_data3.useRegistry)();
19207 const [isModalOpen, setIsModalOpen] = (0, import_element70.useState)(false);
19208 const compositeItemId = generatePrimaryActionCompositeId(
19209 idPrefix,
19210 primaryAction.id
19211 );
19212 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
19213 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19214 import_components12.Composite.Item,
19215 {
19216 id: compositeItemId,
19217 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19218 import_components12.Button,
19219 {
19220 disabled: !!primaryAction.disabled,
19221 accessibleWhenDisabled: true,
19222 text: label,
19223 size: "small",
19224 onClick: () => setIsModalOpen(true)
19225 }
19226 ),
19227 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19228 ActionModal,
19229 {
19230 action: primaryAction,
19231 items: [item],
19232 closeModal: () => setIsModalOpen(false)
19233 }
19234 )
19235 }
19236 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19237 import_components12.Composite.Item,
19238 {
19239 id: compositeItemId,
19240 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19241 import_components12.Button,
19242 {
19243 disabled: !!primaryAction.disabled,
19244 accessibleWhenDisabled: true,
19245 size: "small",
19246 onClick: () => {
19247 primaryAction.callback([item], { registry });
19248 },
19249 children: label
19250 }
19251 )
19252 }
19253 ) }, primaryAction.id);
19254 }
19255 function ListItem({
19256 view,
19257 actions,
19258 idPrefix,
19259 isSelected: isSelected2,
19260 item,
19261 titleField: titleField2,
19262 mediaField,
19263 descriptionField: descriptionField3,
19264 onSelect,
19265 otherFields,
19266 onDropdownTriggerKeyDown,
19267 posinset
19268 }) {
19269 const {
19270 showTitle = true,
19271 showMedia = true,
19272 showDescription = true,
19273 infiniteScrollEnabled
19274 } = view;
19275 const itemRef = (0, import_element70.useRef)(null);
19276 const labelId = `${idPrefix}-label`;
19277 const descriptionId = `${idPrefix}-description`;
19278 const registry = (0, import_data3.useRegistry)();
19279 const [isHovered, setIsHovered] = (0, import_element70.useState)(false);
19280 const [activeModalAction, setActiveModalAction] = (0, import_element70.useState)(
19281 null
19282 );
19283 const handleHover = ({ type }) => {
19284 const isHover = type === "mouseenter";
19285 setIsHovered(isHover);
19286 };
19287 const { paginationInfo } = (0, import_element70.useContext)(dataviews_context_default);
19288 (0, import_element70.useEffect)(() => {
19289 if (isSelected2) {
19290 itemRef.current?.scrollIntoView({
19291 behavior: "auto",
19292 block: "nearest",
19293 inline: "nearest"
19294 });
19295 }
19296 }, [isSelected2]);
19297 const { primaryAction, eligibleActions } = (0, import_element70.useMemo)(() => {
19298 const _eligibleActions = actions.filter(
19299 (action) => !action.isEligible || action.isEligible(item)
19300 );
19301 const _primaryActions = _eligibleActions.filter(
19302 (action) => action.isPrimary
19303 );
19304 return {
19305 primaryAction: _primaryActions[0],
19306 eligibleActions: _eligibleActions
19307 };
19308 }, [actions, item]);
19309 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
19310 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19311 mediaField.render,
19312 {
19313 item,
19314 field: mediaField,
19315 config: { sizes: "52px" }
19316 }
19317 ) }) : null;
19318 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(titleField2.render, { item, field: titleField2 }) : null;
19319 const renderDescription = showDescription && descriptionField3?.render;
19320 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
19321 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19322 Stack,
19323 {
19324 direction: "row",
19325 gap: "md",
19326 className: "dataviews-view-list__item-actions",
19327 children: [
19328 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19329 PrimaryActionGridCell,
19330 {
19331 idPrefix,
19332 primaryAction,
19333 item
19334 }
19335 ),
19336 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { role: "gridcell", children: [
19337 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(Menu3, { placement: "bottom-end", children: [
19338 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19339 Menu3.TriggerButton,
19340 {
19341 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19342 import_components12.Composite.Item,
19343 {
19344 id: generateDropdownTriggerCompositeId(
19345 idPrefix
19346 ),
19347 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19348 import_components12.Button,
19349 {
19350 size: "small",
19351 icon: more_vertical_default,
19352 label: (0, import_i18n18.__)("Actions"),
19353 accessibleWhenDisabled: true,
19354 disabled: !actions.length,
19355 onKeyDown: onDropdownTriggerKeyDown
19356 }
19357 )
19358 }
19359 )
19360 }
19361 ),
19362 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19363 ActionsMenuGroup,
19364 {
19365 actions: eligibleActions,
19366 item,
19367 registry,
19368 setActiveModalAction
19369 }
19370 ) })
19371 ] }),
19372 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19373 ActionModal,
19374 {
19375 action: activeModalAction,
19376 items: [item],
19377 closeModal: () => setActiveModalAction(null)
19378 }
19379 )
19380 ] })
19381 ]
19382 }
19383 );
19384 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19385 import_components12.Composite.Row,
19386 {
19387 ref: itemRef,
19388 render: (
19389 /* aria-posinset breaks Composite.Row if passed to it directly. */
19390 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19391 "div",
19392 {
19393 "aria-posinset": posinset,
19394 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
19395 }
19396 )
19397 ),
19398 role: infiniteScrollEnabled ? "article" : "row",
19399 className: clsx_default({
19400 "is-selected": isSelected2,
19401 "is-hovered": isHovered
19402 }),
19403 onMouseEnter: handleHover,
19404 onMouseLeave: handleHover,
19405 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19406 Stack,
19407 {
19408 direction: "row",
19409 className: "dataviews-view-list__item-wrapper",
19410 children: [
19411 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19412 import_components12.Composite.Item,
19413 {
19414 id: generateItemWrapperCompositeId(idPrefix),
19415 "aria-pressed": isSelected2,
19416 "aria-labelledby": labelId,
19417 "aria-describedby": descriptionId,
19418 className: "dataviews-view-list__item",
19419 onClick: () => onSelect(item)
19420 }
19421 ) }),
19422 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19423 Stack,
19424 {
19425 direction: "row",
19426 gap: "md",
19427 justify: "start",
19428 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
19429 style: { flex: 1, minWidth: 0 },
19430 children: [
19431 renderedMediaField,
19432 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19433 Stack,
19434 {
19435 direction: "column",
19436 gap: "xs",
19437 className: "dataviews-view-list__field-wrapper",
19438 children: [
19439 /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(Stack, { direction: "row", align: "center", children: [
19440 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19441 "div",
19442 {
19443 className: "dataviews-title-field dataviews-view-list__title-field",
19444 id: labelId,
19445 children: renderedTitleField
19446 }
19447 ),
19448 usedActions
19449 ] }),
19450 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19451 descriptionField3.render,
19452 {
19453 item,
19454 field: descriptionField3
19455 }
19456 ) }),
19457 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19458 "div",
19459 {
19460 className: "dataviews-view-list__fields",
19461 id: descriptionId,
19462 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19463 "div",
19464 {
19465 className: "dataviews-view-list__field",
19466 children: [
19467 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19468 VisuallyHidden,
19469 {
19470 className: "dataviews-view-list__field-label",
19471 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", {}),
19472 children: field.label
19473 }
19474 ),
19475 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19476 field.render,
19477 {
19478 item,
19479 field
19480 }
19481 ) })
19482 ]
19483 },
19484 field.id
19485 ))
19486 }
19487 )
19488 ]
19489 }
19490 )
19491 ]
19492 }
19493 )
19494 ]
19495 }
19496 )
19497 }
19498 );
19499 }
19500 function isDefined2(item) {
19501 return !!item;
19502 }
19503 function ViewList(props) {
19504 const {
19505 actions,
19506 data,
19507 fields,
19508 getItemId,
19509 isLoading,
19510 onChangeSelection,
19511 selection,
19512 view,
19513 className,
19514 empty
19515 } = props;
19516 const baseId = (0, import_compose6.useInstanceId)(ViewList, "view-list");
19517 const isDelayedLoading = useDelayedLoading(!!isLoading);
19518 const selectedItem = data?.findLast(
19519 (item) => selection.includes(getItemId(item))
19520 );
19521 const titleField2 = fields.find((field) => field.id === view.titleField);
19522 const mediaField = fields.find((field) => field.id === view.mediaField);
19523 const descriptionField3 = fields.find(
19524 (field) => field.id === view.descriptionField
19525 );
19526 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
19527 const onSelect = (item) => onChangeSelection([getItemId(item)]);
19528 const generateCompositeItemIdPrefix = (0, import_element70.useCallback)(
19529 (item) => `${baseId}-${getItemId(item)}`,
19530 [baseId, getItemId]
19531 );
19532 const isActiveCompositeItem = (0, import_element70.useCallback)(
19533 (item, idToCheck) => {
19534 return idToCheck.startsWith(
19535 generateCompositeItemIdPrefix(item)
19536 );
19537 },
19538 [generateCompositeItemIdPrefix]
19539 );
19540 const [activeCompositeId, setActiveCompositeId] = (0, import_element70.useState)(void 0);
19541 const compositeRef = (0, import_element70.useRef)(null);
19542 (0, import_element70.useEffect)(() => {
19543 if (selectedItem) {
19544 setActiveCompositeId(
19545 generateItemWrapperCompositeId(
19546 generateCompositeItemIdPrefix(selectedItem)
19547 )
19548 );
19549 }
19550 }, [selectedItem, generateCompositeItemIdPrefix]);
19551 const activeItemIndex = data.findIndex(
19552 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
19553 );
19554 const previousActiveItemIndex = (0, import_compose6.usePrevious)(activeItemIndex);
19555 const isActiveIdInList = activeItemIndex !== -1;
19556 const selectCompositeItem = (0, import_element70.useCallback)(
19557 (targetIndex, generateCompositeId) => {
19558 const clampedIndex = Math.min(
19559 data.length - 1,
19560 Math.max(0, targetIndex)
19561 );
19562 if (!data[clampedIndex]) {
19563 return;
19564 }
19565 const itemIdPrefix = generateCompositeItemIdPrefix(
19566 data[clampedIndex]
19567 );
19568 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
19569 setActiveCompositeId(targetCompositeItemId);
19570 if (compositeRef.current?.contains(
19571 compositeRef.current.ownerDocument.activeElement
19572 )) {
19573 document.getElementById(targetCompositeItemId)?.focus();
19574 }
19575 },
19576 [data, generateCompositeItemIdPrefix]
19577 );
19578 (0, import_element70.useEffect)(() => {
19579 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
19580 if (!isActiveIdInList && wasActiveIdInList) {
19581 selectCompositeItem(
19582 previousActiveItemIndex,
19583 generateItemWrapperCompositeId
19584 );
19585 }
19586 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
19587 const onDropdownTriggerKeyDown = (0, import_element70.useCallback)(
19588 (event) => {
19589 if (event.key === "ArrowDown") {
19590 event.preventDefault();
19591 selectCompositeItem(
19592 activeItemIndex + 1,
19593 generateDropdownTriggerCompositeId
19594 );
19595 }
19596 if (event.key === "ArrowUp") {
19597 event.preventDefault();
19598 selectCompositeItem(
19599 activeItemIndex - 1,
19600 generateDropdownTriggerCompositeId
19601 );
19602 }
19603 },
19604 [selectCompositeItem, activeItemIndex]
19605 );
19606 const hasData = !!data?.length;
19607 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
19608 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
19609 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
19610 if (!hasData) {
19611 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19612 "div",
19613 {
19614 className: clsx_default("dataviews-no-results", {
19615 "is-refreshing": isDelayedLoading
19616 }),
19617 children: empty
19618 }
19619 );
19620 }
19621 if (hasData && groupField && dataByGroup) {
19622 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19623 import_components12.Composite,
19624 {
19625 ref: compositeRef,
19626 id: `${baseId}`,
19627 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", {}),
19628 className: "dataviews-view-list__group",
19629 role: "grid",
19630 activeId: activeCompositeId,
19631 setActiveId: setActiveCompositeId,
19632 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19633 Stack,
19634 {
19635 direction: "column",
19636 gap: "lg",
19637 className: clsx_default("dataviews-view-list", className),
19638 children: Array.from(dataByGroup.entries()).map(
19639 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
19640 Stack,
19641 {
19642 direction: "column",
19643 gap: "sm",
19644 children: [
19645 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
19646 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
19647 (0, import_i18n18.__)("%1$s: %2$s"),
19648 groupField.label,
19649 groupName
19650 ) }),
19651 groupItems.map((item) => {
19652 const id = generateCompositeItemIdPrefix(item);
19653 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19654 ListItem,
19655 {
19656 view,
19657 idPrefix: id,
19658 actions,
19659 item,
19660 isSelected: item === selectedItem,
19661 onSelect,
19662 mediaField,
19663 titleField: titleField2,
19664 descriptionField: descriptionField3,
19665 otherFields,
19666 onDropdownTriggerKeyDown
19667 },
19668 id
19669 );
19670 })
19671 ]
19672 },
19673 groupName
19674 )
19675 )
19676 }
19677 )
19678 }
19679 );
19680 }
19681 return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_jsx_runtime103.Fragment, { children: [
19682 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19683 import_components12.Composite,
19684 {
19685 ref: compositeRef,
19686 id: baseId,
19687 render: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", {}),
19688 className: clsx_default("dataviews-view-list", className, {
19689 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
19690 view.layout.density
19691 ),
19692 "is-refreshing": !isInfiniteScroll && isDelayedLoading
19693 }),
19694 role: view.infiniteScrollEnabled ? "feed" : "grid",
19695 activeId: activeCompositeId,
19696 setActiveId: setActiveCompositeId,
19697 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
19698 children: data.map((item, index2) => {
19699 const id = generateCompositeItemIdPrefix(item);
19700 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
19701 ListItem,
19702 {
19703 view,
19704 idPrefix: id,
19705 actions,
19706 item,
19707 isSelected: item === selectedItem,
19708 onSelect,
19709 mediaField,
19710 titleField: titleField2,
19711 descriptionField: descriptionField3,
19712 otherFields,
19713 onDropdownTriggerKeyDown,
19714 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
19715 },
19716 id
19717 );
19718 })
19719 }
19720 ),
19721 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components12.Spinner, {}) })
19722 ] });
19723 }
19724
19725 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
19726 var import_components13 = __toESM(require_components(), 1);
19727
19728 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
19729 var import_i18n19 = __toESM(require_i18n(), 1);
19730 var import_element71 = __toESM(require_element(), 1);
19731 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
19732 function ActivityGroup({
19733 groupName,
19734 groupData,
19735 groupField,
19736 showLabel = true,
19737 children
19738 }) {
19739 const groupHeader = showLabel ? (0, import_element71.createInterpolateElement)(
19740 // translators: %s: The label of the field e.g. "Status".
19741 (0, import_i18n19.sprintf)((0, import_i18n19.__)("%s: <groupName />"), groupField.label).trim(),
19742 {
19743 groupName: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
19744 groupField.render,
19745 {
19746 item: groupData[0],
19747 field: groupField
19748 }
19749 )
19750 }
19751 ) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(groupField.render, { item: groupData[0], field: groupField });
19752 return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(
19753 Stack,
19754 {
19755 direction: "column",
19756 className: "dataviews-view-activity__group",
19757 children: [
19758 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
19759 children
19760 ]
19761 },
19762 groupName
19763 );
19764 }
19765
19766 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
19767 var import_element72 = __toESM(require_element(), 1);
19768 var import_data4 = __toESM(require_data(), 1);
19769 var import_compose7 = __toESM(require_compose(), 1);
19770 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
19771 function ActivityItem(props) {
19772 const {
19773 view,
19774 actions,
19775 item,
19776 titleField: titleField2,
19777 mediaField,
19778 descriptionField: descriptionField3,
19779 otherFields,
19780 posinset,
19781 onClickItem,
19782 renderItemLink,
19783 isItemClickable
19784 } = props;
19785 const {
19786 showTitle = true,
19787 showMedia = true,
19788 showDescription = true,
19789 infiniteScrollEnabled
19790 } = view;
19791 const itemRef = (0, import_element72.useRef)(null);
19792 const registry = (0, import_data4.useRegistry)();
19793 const { paginationInfo } = (0, import_element72.useContext)(dataviews_context_default);
19794 const { primaryActions, eligibleActions } = (0, import_element72.useMemo)(() => {
19795 const _eligibleActions = actions.filter(
19796 (action) => !action.isEligible || action.isEligible(item)
19797 );
19798 const _primaryActions = _eligibleActions.filter(
19799 (action) => action.isPrimary
19800 );
19801 return {
19802 primaryActions: _primaryActions,
19803 eligibleActions: _eligibleActions
19804 };
19805 }, [actions, item]);
19806 const isMobileViewport = (0, import_compose7.useViewportMatch)("medium", "<");
19807 const density = view.layout?.density ?? "balanced";
19808 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19809 mediaField.render,
19810 {
19811 item,
19812 field: mediaField,
19813 config: {
19814 sizes: density === "comfortable" ? "32px" : "24px"
19815 }
19816 }
19817 ) : null;
19818 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19819 "span",
19820 {
19821 className: "dataviews-view-activity__item-bullet",
19822 "aria-hidden": "true"
19823 }
19824 ) });
19825 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(titleField2.render, { item, field: titleField2 }) : null;
19826 const verticalGap = (0, import_element72.useMemo)(() => {
19827 switch (density) {
19828 case "comfortable":
19829 return "md";
19830 default:
19831 return "sm";
19832 }
19833 }, [density]);
19834 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19835 "div",
19836 {
19837 ref: itemRef,
19838 role: infiniteScrollEnabled ? "article" : void 0,
19839 "aria-posinset": posinset,
19840 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
19841 className: clsx_default(
19842 "dataviews-view-activity__item",
19843 density === "compact" && "is-compact",
19844 density === "balanced" && "is-balanced",
19845 density === "comfortable" && "is-comfortable"
19846 ),
19847 children: /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
19848 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19849 Stack,
19850 {
19851 direction: "column",
19852 gap: "xs",
19853 align: "center",
19854 className: "dataviews-view-activity__item-type",
19855 children: renderedMediaField
19856 }
19857 ),
19858 /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
19859 Stack,
19860 {
19861 direction: "column",
19862 gap: verticalGap,
19863 align: "flex-start",
19864 className: "dataviews-view-activity__item-content",
19865 children: [
19866 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19867 ItemClickWrapper,
19868 {
19869 item,
19870 isItemClickable,
19871 onClickItem,
19872 renderItemLink,
19873 className: "dataviews-view-activity__item-title",
19874 children: renderedTitleField
19875 }
19876 ),
19877 showDescription && descriptionField3 && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19878 descriptionField3.render,
19879 {
19880 item,
19881 field: descriptionField3
19882 }
19883 ) }),
19884 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
19885 "div",
19886 {
19887 className: "dataviews-view-activity__item-field",
19888 children: [
19889 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19890 VisuallyHidden,
19891 {
19892 className: "dataviews-view-activity__item-field-label",
19893 render: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("span", {}),
19894 children: field.label
19895 }
19896 ),
19897 /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19898 field.render,
19899 {
19900 item,
19901 field
19902 }
19903 ) })
19904 ]
19905 },
19906 field.id
19907 )) }),
19908 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19909 PrimaryActions,
19910 {
19911 item,
19912 actions: primaryActions,
19913 registry,
19914 buttonVariant: "secondary"
19915 }
19916 )
19917 ]
19918 }
19919 ),
19920 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
19921 // there if there are any actions at all.
19922 isMobileViewport && // At the same time, only show the menu if there are actions to show.
19923 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
19924 ItemActions,
19925 {
19926 item,
19927 actions: eligibleActions,
19928 isCompact: true
19929 }
19930 ) })
19931 ] })
19932 }
19933 );
19934 }
19935 var activity_item_default = ActivityItem;
19936
19937 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
19938 var import_react14 = __toESM(require_react(), 1);
19939 function isDefined3(item) {
19940 return !!item;
19941 }
19942 function ActivityItems(props) {
19943 const { data, fields, getItemId, view } = props;
19944 const titleField2 = fields.find((field) => field.id === view.titleField);
19945 const mediaField = fields.find((field) => field.id === view.mediaField);
19946 const descriptionField3 = fields.find(
19947 (field) => field.id === view.descriptionField
19948 );
19949 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
19950 return data.map((item, index2) => {
19951 return /* @__PURE__ */ (0, import_react14.createElement)(
19952 activity_item_default,
19953 {
19954 ...props,
19955 key: getItemId(item),
19956 item,
19957 mediaField,
19958 titleField: titleField2,
19959 descriptionField: descriptionField3,
19960 otherFields,
19961 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
19962 }
19963 );
19964 });
19965 }
19966
19967 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
19968 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
19969 function ViewActivity(props) {
19970 const { empty, data, fields, isLoading, view, className } = props;
19971 const isDelayedLoading = useDelayedLoading(!!isLoading);
19972 const hasData = !!data?.length;
19973 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
19974 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
19975 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
19976 if (!hasData) {
19977 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
19978 "div",
19979 {
19980 className: clsx_default("dataviews-no-results", {
19981 "is-refreshing": isDelayedLoading
19982 }),
19983 children: empty
19984 }
19985 );
19986 }
19987 const isInert2 = !isInfiniteScroll && !!isLoading;
19988 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
19989 "is-refreshing": !isInfiniteScroll && isDelayedLoading
19990 });
19991 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
19992 if (hasData && groupField && dataByGroup) {
19993 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
19994 Stack,
19995 {
19996 direction: "column",
19997 gap: "sm",
19998 className: wrapperClassName,
19999 inert: isInert2 ? "true" : void 0,
20000 children: groupedEntries.map(
20001 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20002 ActivityGroup,
20003 {
20004 groupName,
20005 groupData,
20006 groupField,
20007 showLabel: view.groupBy?.showLabel !== false,
20008 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20009 ActivityItems,
20010 {
20011 ...props,
20012 data: groupData
20013 }
20014 )
20015 },
20016 groupName
20017 )
20018 )
20019 }
20020 );
20021 }
20022 return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(import_jsx_runtime106.Fragment, { children: [
20023 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
20024 "div",
20025 {
20026 className: wrapperClassName,
20027 role: view.infiniteScrollEnabled ? "feed" : void 0,
20028 inert: isInert2 ? "true" : void 0,
20029 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(ActivityItems, { ...props })
20030 }
20031 ),
20032 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components13.Spinner, {}) })
20033 ] });
20034 }
20035
20036 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
20037 var import_components16 = __toESM(require_components(), 1);
20038 var import_i18n22 = __toESM(require_i18n(), 1);
20039 var import_compose8 = __toESM(require_compose(), 1);
20040 var import_element75 = __toESM(require_element(), 1);
20041
20042 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
20043 var import_components15 = __toESM(require_components(), 1);
20044 var import_data5 = __toESM(require_data(), 1);
20045 var import_element74 = __toESM(require_element(), 1);
20046 var import_i18n21 = __toESM(require_i18n(), 1);
20047
20048 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
20049 var import_components14 = __toESM(require_components(), 1);
20050 var import_element73 = __toESM(require_element(), 1);
20051 var import_i18n20 = __toESM(require_i18n(), 1);
20052 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
20053 function DataViewsPagination() {
20054 const {
20055 view,
20056 onChangeView,
20057 paginationInfo: { totalItems = 0, totalPages }
20058 } = (0, import_element73.useContext)(dataviews_context_default);
20059 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
20060 return null;
20061 }
20062 const currentPage = view.page ?? 1;
20063 const pageSelectOptions = Array.from(Array(totalPages)).map(
20064 (_, i2) => {
20065 const page = i2 + 1;
20066 return {
20067 value: page.toString(),
20068 label: page.toString(),
20069 "aria-label": currentPage === page ? (0, import_i18n20.sprintf)(
20070 // translators: 1: current page number. 2: total number of pages.
20071 (0, import_i18n20.__)("Page %1$d of %2$d"),
20072 currentPage,
20073 totalPages
20074 ) : page.toString()
20075 };
20076 }
20077 );
20078 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(
20079 Stack,
20080 {
20081 direction: "row",
20082 className: "dataviews-pagination",
20083 justify: "end",
20084 align: "center",
20085 gap: "xl",
20086 children: [
20087 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
20088 Stack,
20089 {
20090 direction: "row",
20091 justify: "flex-start",
20092 align: "center",
20093 gap: "xs",
20094 className: "dataviews-pagination__page-select",
20095 children: (0, import_element73.createInterpolateElement)(
20096 (0, import_i18n20.sprintf)(
20097 // translators: 1: Current page number, 2: Total number of pages.
20098 (0, import_i18n20._x)(
20099 "<div>Page</div>%1$s<div>of %2$d</div>",
20100 "paging"
20101 ),
20102 "<CurrentPage />",
20103 totalPages
20104 ),
20105 {
20106 div: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { "aria-hidden": true }),
20107 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
20108 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
20109 import_components14.SelectControl,
20110 {
20111 "aria-label": (0, import_i18n20.__)("Current page"),
20112 value: currentPage.toString(),
20113 options: pageSelectOptions,
20114 onChange: (newValue) => {
20115 onChangeView({
20116 ...view,
20117 page: +newValue
20118 });
20119 },
20120 size: "small",
20121 variant: "minimal"
20122 }
20123 )
20124 }
20125 )
20126 }
20127 ),
20128 /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
20129 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
20130 import_components14.Button,
20131 {
20132 onClick: () => onChangeView({
20133 ...view,
20134 page: currentPage - 1
20135 }),
20136 disabled: currentPage === 1,
20137 accessibleWhenDisabled: true,
20138 label: (0, import_i18n20.__)("Previous page"),
20139 icon: (0, import_i18n20.isRTL)() ? next_default : previous_default,
20140 showTooltip: true,
20141 size: "compact",
20142 tooltipPosition: "top"
20143 }
20144 ),
20145 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
20146 import_components14.Button,
20147 {
20148 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
20149 disabled: currentPage >= totalPages,
20150 accessibleWhenDisabled: true,
20151 label: (0, import_i18n20.__)("Next page"),
20152 icon: (0, import_i18n20.isRTL)() ? previous_default : next_default,
20153 showTooltip: true,
20154 size: "compact",
20155 tooltipPosition: "top"
20156 }
20157 )
20158 ] })
20159 ]
20160 }
20161 );
20162 }
20163 var dataviews_pagination_default = (0, import_element73.memo)(DataViewsPagination);
20164
20165 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
20166 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
20167 function useIsMultiselectPicker(actions) {
20168 return (0, import_element74.useMemo)(() => {
20169 return actions?.every((action) => action.supportsBulk);
20170 }, [actions]);
20171 }
20172
20173 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
20174 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
20175 var { Badge: WCBadge2 } = unlock3(import_components16.privateApis);
20176 function GridItem3({
20177 view,
20178 multiselect,
20179 selection,
20180 onChangeSelection,
20181 getItemId,
20182 item,
20183 mediaField,
20184 titleField: titleField2,
20185 descriptionField: descriptionField3,
20186 regularFields,
20187 badgeFields,
20188 config,
20189 posinset,
20190 setsize
20191 }) {
20192 const { showTitle = true, showMedia = true, showDescription = true } = view;
20193 const id = getItemId(item);
20194 const elementRef = (0, import_element75.useRef)(null);
20195 const isSelected2 = selection.includes(id);
20196 useIntersectionObserver(elementRef, posinset);
20197 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20198 mediaField.render,
20199 {
20200 item,
20201 field: mediaField,
20202 config
20203 }
20204 ) : null;
20205 const renderedTitleField = showTitle && titleField2?.render ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(titleField2.render, { item, field: titleField2 }) : null;
20206 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
20207 import_components16.Composite.Item,
20208 {
20209 ref: elementRef,
20210 "aria-label": titleField2 ? titleField2.getValue({ item }) || (0, import_i18n22.__)("(no title)") : void 0,
20211 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(Stack, { direction: "column", children, ...props }),
20212 role: "option",
20213 "aria-posinset": posinset,
20214 "aria-setsize": setsize,
20215 className: clsx_default("dataviews-view-picker-grid__card", {
20216 "is-selected": isSelected2
20217 }),
20218 "aria-selected": isSelected2,
20219 onClick: () => {
20220 if (isSelected2) {
20221 onChangeSelection(
20222 selection.filter((itemId) => id !== itemId)
20223 );
20224 } else {
20225 const newSelection = multiselect ? [...selection, id] : [id];
20226 onChangeSelection(newSelection);
20227 }
20228 },
20229 children: [
20230 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
20231 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20232 DataViewsSelectionCheckbox,
20233 {
20234 item,
20235 selection,
20236 onChangeSelection,
20237 getItemId,
20238 titleField: titleField2,
20239 disabled: false,
20240 "aria-hidden": true,
20241 tabIndex: -1
20242 }
20243 ),
20244 showTitle && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20245 Stack,
20246 {
20247 direction: "row",
20248 justify: "space-between",
20249 className: "dataviews-view-picker-grid__title-actions",
20250 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
20251 }
20252 ),
20253 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(Stack, { direction: "column", gap: "xs", children: [
20254 showDescription && descriptionField3?.render && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20255 descriptionField3.render,
20256 {
20257 item,
20258 field: descriptionField3
20259 }
20260 ),
20261 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20262 Stack,
20263 {
20264 direction: "row",
20265 className: "dataviews-view-picker-grid__badge-fields",
20266 gap: "sm",
20267 wrap: "wrap",
20268 align: "top",
20269 justify: "flex-start",
20270 children: badgeFields.map((field) => {
20271 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20272 WCBadge2,
20273 {
20274 className: "dataviews-view-picker-grid__field-value",
20275 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20276 field.render,
20277 {
20278 item,
20279 field
20280 }
20281 )
20282 },
20283 field.id
20284 );
20285 })
20286 }
20287 ),
20288 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20289 Stack,
20290 {
20291 direction: "column",
20292 className: "dataviews-view-picker-grid__fields",
20293 gap: "xs",
20294 children: regularFields.map((field) => {
20295 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20296 import_components16.Flex,
20297 {
20298 className: "dataviews-view-picker-grid__field",
20299 gap: 1,
20300 justify: "flex-start",
20301 expanded: true,
20302 style: { height: "auto" },
20303 direction: "row",
20304 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
20305 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components16.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
20306 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20307 import_components16.FlexItem,
20308 {
20309 className: "dataviews-view-picker-grid__field-value",
20310 style: { maxHeight: "none" },
20311 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20312 field.render,
20313 {
20314 item,
20315 field
20316 }
20317 )
20318 }
20319 )
20320 ] })
20321 },
20322 field.id
20323 );
20324 })
20325 }
20326 )
20327 ] })
20328 ]
20329 },
20330 id
20331 );
20332 }
20333 function GridGroup({
20334 groupName,
20335 groupField,
20336 showLabel = true,
20337 children
20338 }) {
20339 const headerId = (0, import_compose8.useInstanceId)(
20340 GridGroup,
20341 "dataviews-view-picker-grid-group__header"
20342 );
20343 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
20344 Stack,
20345 {
20346 direction: "column",
20347 gap: "sm",
20348 role: "group",
20349 "aria-labelledby": headerId,
20350 children: [
20351 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20352 "h3",
20353 {
20354 className: "dataviews-view-picker-grid-group__header",
20355 id: headerId,
20356 children: showLabel ? (0, import_i18n22.sprintf)(
20357 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
20358 (0, import_i18n22.__)("%1$s: %2$s"),
20359 groupField.label,
20360 groupName
20361 ) : groupName
20362 }
20363 ),
20364 children
20365 ]
20366 },
20367 groupName
20368 );
20369 }
20370 function ViewPickerGrid({
20371 actions,
20372 data,
20373 fields,
20374 getItemId,
20375 isLoading,
20376 onChangeSelection,
20377 selection,
20378 view,
20379 className,
20380 empty
20381 }) {
20382 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element75.useContext)(dataviews_context_default);
20383 const titleField2 = fields.find(
20384 (field) => field.id === view?.titleField
20385 );
20386 const mediaField = fields.find(
20387 (field) => field.id === view?.mediaField
20388 );
20389 const descriptionField3 = fields.find(
20390 (field) => field.id === view?.descriptionField
20391 );
20392 const otherFields = view.fields ?? [];
20393 const { regularFields, badgeFields } = otherFields.reduce(
20394 (accumulator, fieldId) => {
20395 const field = fields.find((f2) => f2.id === fieldId);
20396 if (!field) {
20397 return accumulator;
20398 }
20399 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
20400 accumulator[key].push(field);
20401 return accumulator;
20402 },
20403 { regularFields: [], badgeFields: [] }
20404 );
20405 const hasData = !!data?.length;
20406 const usedPreviewSize = view.layout?.previewSize;
20407 const isMultiselect = useIsMultiselectPicker(actions);
20408 const size4 = "900px";
20409 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
20410 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
20411 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
20412 const currentPage = view?.page ?? 1;
20413 const perPage = view?.perPage ?? 0;
20414 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
20415 const gridColumns = useGridColumns();
20416 const placeholdersNeeded = usePlaceholdersNeeded(
20417 data,
20418 isInfiniteScroll,
20419 gridColumns
20420 );
20421 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, {
20422 // Render multiple groups.
20423 children: [
20424 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20425 import_components16.Composite,
20426 {
20427 virtualFocus: true,
20428 orientation: "horizontal",
20429 role: "listbox",
20430 "aria-multiselectable": isMultiselect,
20431 className: clsx_default(
20432 "dataviews-view-picker-grid",
20433 className,
20434 {
20435 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
20436 view.layout.density
20437 )
20438 }
20439 ),
20440 "aria-label": itemListLabel,
20441 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20442 Stack,
20443 {
20444 direction: "column",
20445 gap: "lg",
20446 children,
20447 ...props
20448 }
20449 ),
20450 children: Array.from(dataByGroup.entries()).map(
20451 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20452 GridGroup,
20453 {
20454 groupName,
20455 groupField,
20456 showLabel: view.groupBy?.showLabel !== false,
20457 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20458 GridItems,
20459 {
20460 previewSize: usedPreviewSize,
20461 style: {
20462 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
20463 },
20464 "aria-busy": isLoading,
20465 ref: resizeObserverRef,
20466 children: groupItems.map((item) => {
20467 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
20468 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20469 GridItem3,
20470 {
20471 view,
20472 multiselect: isMultiselect,
20473 selection,
20474 onChangeSelection,
20475 getItemId,
20476 item,
20477 mediaField,
20478 titleField: titleField2,
20479 descriptionField: descriptionField3,
20480 regularFields,
20481 badgeFields,
20482 config: {
20483 sizes: size4
20484 },
20485 posinset: posInSet,
20486 setsize: setSize
20487 },
20488 getItemId(item)
20489 );
20490 })
20491 }
20492 )
20493 },
20494 groupName
20495 )
20496 )
20497 }
20498 ),
20499 // Render a single grid with all data.
20500 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
20501 import_components16.Composite,
20502 {
20503 render: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20504 GridItems,
20505 {
20506 className: clsx_default(
20507 "dataviews-view-picker-grid",
20508 className,
20509 {
20510 [`has-${view.layout?.density}-density`]: view.layout?.density && [
20511 "compact",
20512 "comfortable"
20513 ].includes(view.layout.density)
20514 }
20515 ),
20516 previewSize: usedPreviewSize,
20517 "aria-busy": isLoading,
20518 ref: resizeObserverRef
20519 }
20520 ),
20521 virtualFocus: true,
20522 orientation: "horizontal",
20523 role: "listbox",
20524 "aria-multiselectable": isMultiselect,
20525 "aria-label": itemListLabel,
20526 children: [
20527 Array.from({ length: placeholdersNeeded }).map(
20528 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20529 import_components16.Composite.Item,
20530 {
20531 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20532 Stack,
20533 {
20534 direction: "column",
20535 children,
20536 ...props
20537 }
20538 ),
20539 role: "option",
20540 "aria-hidden": true,
20541 tabIndex: -1,
20542 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
20543 },
20544 `placeholder-${index2}`
20545 )
20546 ),
20547 data.map((item) => {
20548 const posinset = item.position;
20549 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20550 GridItem3,
20551 {
20552 view,
20553 multiselect: isMultiselect,
20554 selection,
20555 onChangeSelection,
20556 getItemId,
20557 item,
20558 mediaField,
20559 titleField: titleField2,
20560 descriptionField: descriptionField3,
20561 regularFields,
20562 badgeFields,
20563 config: {
20564 sizes: size4
20565 },
20566 posinset,
20567 setsize: setSize
20568 },
20569 getItemId(item)
20570 );
20571 })
20572 ]
20573 }
20574 ),
20575 // Render empty state.
20576 !hasData && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
20577 "div",
20578 {
20579 className: clsx_default({
20580 "dataviews-loading": isLoading,
20581 "dataviews-no-results": !isLoading
20582 }),
20583 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components16.Spinner, {}) }) : empty
20584 }
20585 ),
20586 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components16.Spinner, {}) })
20587 ]
20588 });
20589 }
20590 var picker_grid_default = ViewPickerGrid;
20591
20592 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
20593 var import_i18n23 = __toESM(require_i18n(), 1);
20594 var import_components17 = __toESM(require_components(), 1);
20595 var import_element76 = __toESM(require_element(), 1);
20596 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
20597 function TableColumnField2({
20598 item,
20599 fields,
20600 column,
20601 align
20602 }) {
20603 const field = fields.find((f2) => f2.id === column);
20604 if (!field) {
20605 return null;
20606 }
20607 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
20608 "dataviews-view-table__cell-align-end": align === "end",
20609 "dataviews-view-table__cell-align-center": align === "center"
20610 });
20611 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(field.render, { item, field }) });
20612 }
20613 function TableRow2({
20614 item,
20615 fields,
20616 id,
20617 view,
20618 titleField: titleField2,
20619 mediaField,
20620 descriptionField: descriptionField3,
20621 selection,
20622 getItemId,
20623 onChangeSelection,
20624 multiselect,
20625 posinset
20626 }) {
20627 const { paginationInfo } = (0, import_element76.useContext)(dataviews_context_default);
20628 const isSelected2 = selection.includes(id);
20629 const [isHovered, setIsHovered] = (0, import_element76.useState)(false);
20630 const elementRef = (0, import_element76.useRef)(null);
20631 useIntersectionObserver(elementRef, posinset);
20632 const {
20633 showTitle = true,
20634 showMedia = true,
20635 showDescription = true,
20636 infiniteScrollEnabled
20637 } = view;
20638 const handleMouseEnter = () => {
20639 setIsHovered(true);
20640 };
20641 const handleMouseLeave = () => {
20642 setIsHovered(false);
20643 };
20644 const columns = view.fields ?? [];
20645 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription;
20646 return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
20647 import_components17.Composite.Item,
20648 {
20649 ref: elementRef,
20650 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20651 "tr",
20652 {
20653 className: clsx_default("dataviews-view-table__row", {
20654 "is-selected": isSelected2,
20655 "is-hovered": isHovered
20656 }),
20657 onMouseEnter: handleMouseEnter,
20658 onMouseLeave: handleMouseLeave,
20659 children,
20660 ...props
20661 }
20662 ),
20663 "aria-selected": isSelected2,
20664 "aria-setsize": paginationInfo.totalItems || void 0,
20665 "aria-posinset": posinset,
20666 role: infiniteScrollEnabled ? "article" : "option",
20667 onMouseDown: (event) => {
20668 if (event.button !== 0) {
20669 return;
20670 }
20671 event.currentTarget.parentElement?.focus({
20672 preventScroll: true
20673 });
20674 },
20675 onClick: () => {
20676 if (isSelected2) {
20677 onChangeSelection(
20678 selection.filter((itemId) => id !== itemId)
20679 );
20680 } else {
20681 const newSelection = multiselect ? [...selection, id] : [id];
20682 onChangeSelection(newSelection);
20683 }
20684 },
20685 children: [
20686 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20687 "td",
20688 {
20689 className: "dataviews-view-table__checkbox-column",
20690 role: "presentation",
20691 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20692 DataViewsSelectionCheckbox,
20693 {
20694 item,
20695 selection,
20696 onChangeSelection,
20697 getItemId,
20698 titleField: titleField2,
20699 disabled: false,
20700 "aria-hidden": true,
20701 tabIndex: -1
20702 }
20703 ) })
20704 }
20705 ),
20706 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20707 "td",
20708 {
20709 role: "presentation",
20710 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20711 column_primary_default,
20712 {
20713 item,
20714 titleField: showTitle ? titleField2 : void 0,
20715 mediaField: showMedia ? mediaField : void 0,
20716 descriptionField: showDescription ? descriptionField3 : void 0,
20717 isItemClickable: () => false
20718 }
20719 )
20720 }
20721 ),
20722 columns.map((column) => {
20723 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
20724 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20725 "td",
20726 {
20727 style: {
20728 width,
20729 maxWidth,
20730 minWidth
20731 },
20732 role: "presentation",
20733 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20734 TableColumnField2,
20735 {
20736 fields,
20737 item,
20738 column,
20739 align
20740 }
20741 )
20742 },
20743 column
20744 );
20745 })
20746 ]
20747 },
20748 id
20749 );
20750 }
20751 function ViewPickerTable({
20752 actions,
20753 data,
20754 fields,
20755 getItemId,
20756 isLoading = false,
20757 onChangeView,
20758 onChangeSelection,
20759 selection,
20760 setOpenedFilter,
20761 view,
20762 className,
20763 empty
20764 }) {
20765 const headerMenuRefs = (0, import_element76.useRef)(/* @__PURE__ */ new Map());
20766 const headerMenuToFocusRef = (0, import_element76.useRef)(void 0);
20767 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element76.useState)();
20768 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
20769 (0, import_element76.useEffect)(() => {
20770 if (headerMenuToFocusRef.current) {
20771 headerMenuToFocusRef.current.focus();
20772 headerMenuToFocusRef.current = void 0;
20773 }
20774 });
20775 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
20776 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
20777 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
20778 const tableNoticeId = (0, import_element76.useId)();
20779 if (nextHeaderMenuToFocus) {
20780 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
20781 setNextHeaderMenuToFocus(void 0);
20782 return;
20783 }
20784 const onHide = (field) => {
20785 const hidden = headerMenuRefs.current.get(field.id);
20786 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
20787 setNextHeaderMenuToFocus(fallback?.node);
20788 };
20789 const hasData = !!data?.length;
20790 const titleField2 = fields.find((field) => field.id === view.titleField);
20791 const mediaField = fields.find((field) => field.id === view.mediaField);
20792 const descriptionField3 = fields.find(
20793 (field) => field.id === view.descriptionField
20794 );
20795 const { showTitle = true, showMedia = true, showDescription = true } = view;
20796 const hasPrimaryColumn = titleField2 && showTitle || mediaField && showMedia || descriptionField3 && showDescription;
20797 const columns = view.fields ?? [];
20798 const headerMenuRef = (column, index2) => (node) => {
20799 if (node) {
20800 headerMenuRefs.current.set(column, {
20801 node,
20802 fallback: columns[index2 > 0 ? index2 - 1 : 1]
20803 });
20804 } else {
20805 headerMenuRefs.current.delete(column);
20806 }
20807 };
20808 return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(import_jsx_runtime110.Fragment, { children: [
20809 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
20810 "table",
20811 {
20812 className: clsx_default(
20813 "dataviews-view-table",
20814 "dataviews-view-picker-table",
20815 className,
20816 {
20817 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
20818 view.layout.density
20819 )
20820 }
20821 ),
20822 "aria-busy": isLoading,
20823 "aria-describedby": tableNoticeId,
20824 role: isInfiniteScroll ? "feed" : "listbox",
20825 children: [
20826 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
20827 "tr",
20828 {
20829 className: "dataviews-view-table__row",
20830 role: "presentation",
20831 children: [
20832 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20833 BulkSelectionCheckbox,
20834 {
20835 selection,
20836 onChangeSelection,
20837 data,
20838 actions,
20839 getItemId,
20840 disableSelectAll: isInfiniteScroll
20841 }
20842 ) }),
20843 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("th", { children: titleField2 && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20844 column_header_menu_default,
20845 {
20846 ref: headerMenuRef(
20847 titleField2.id,
20848 0
20849 ),
20850 fieldId: titleField2.id,
20851 view,
20852 fields,
20853 onChangeView,
20854 onHide,
20855 setOpenedFilter,
20856 canMove: false
20857 }
20858 ) }),
20859 columns.map((column, index2) => {
20860 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
20861 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20862 "th",
20863 {
20864 style: {
20865 width,
20866 maxWidth,
20867 minWidth,
20868 textAlign: align
20869 },
20870 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
20871 scope: "col",
20872 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20873 column_header_menu_default,
20874 {
20875 ref: headerMenuRef(column, index2),
20876 fieldId: column,
20877 view,
20878 fields,
20879 onChangeView,
20880 onHide,
20881 setOpenedFilter,
20882 canMove: view.layout?.enableMoving ?? true
20883 }
20884 )
20885 },
20886 column
20887 );
20888 })
20889 ]
20890 }
20891 ) }),
20892 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
20893 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
20894 import_components17.Composite,
20895 {
20896 virtualFocus: true,
20897 orientation: "vertical",
20898 render: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tbody", { role: "group" }),
20899 children: [
20900 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20901 "tr",
20902 {
20903 className: "dataviews-view-table__group-header-row",
20904 role: "presentation",
20905 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20906 "td",
20907 {
20908 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
20909 className: "dataviews-view-table__group-header-cell",
20910 role: "presentation",
20911 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n23.sprintf)(
20912 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
20913 (0, import_i18n23.__)("%1$s: %2$s"),
20914 groupField.label,
20915 groupName
20916 )
20917 }
20918 )
20919 }
20920 ),
20921 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20922 TableRow2,
20923 {
20924 item,
20925 fields,
20926 id: getItemId(item) || index2.toString(),
20927 view,
20928 titleField: titleField2,
20929 mediaField,
20930 descriptionField: descriptionField3,
20931 selection,
20932 getItemId,
20933 onChangeSelection,
20934 multiselect: isMultiselect
20935 },
20936 getItemId(item)
20937 ))
20938 ]
20939 },
20940 `group-${groupName}`
20941 )
20942 ) : /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20943 import_components17.Composite,
20944 {
20945 render: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("tbody", { role: "presentation" }),
20946 virtualFocus: true,
20947 orientation: "vertical",
20948 children: hasData && data.map((item, index2) => {
20949 const itemId = getItemId(item);
20950 const posinset = item.position;
20951 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
20952 TableRow2,
20953 {
20954 item,
20955 fields,
20956 id: itemId || index2.toString(),
20957 view,
20958 titleField: titleField2,
20959 mediaField,
20960 descriptionField: descriptionField3,
20961 selection,
20962 getItemId,
20963 onChangeSelection,
20964 multiselect: isMultiselect,
20965 posinset
20966 },
20967 itemId
20968 );
20969 })
20970 }
20971 )
20972 ]
20973 }
20974 ),
20975 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
20976 "div",
20977 {
20978 className: clsx_default({
20979 "dataviews-loading": isLoading,
20980 "dataviews-no-results": !hasData && !isLoading
20981 }),
20982 id: tableNoticeId,
20983 children: [
20984 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components17.Spinner, {}) }) : empty),
20985 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components17.Spinner, {}) })
20986 ]
20987 }
20988 )
20989 ] });
20990 }
20991 var picker_table_default = ViewPickerTable;
20992
20993 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
20994 var import_components18 = __toESM(require_components(), 1);
20995 var import_i18n24 = __toESM(require_i18n(), 1);
20996 var import_element77 = __toESM(require_element(), 1);
20997 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
20998 function DensityPicker() {
20999 const context = (0, import_element77.useContext)(dataviews_context_default);
21000 const view = context.view;
21001 return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
21002 import_components18.__experimentalToggleGroupControl,
21003 {
21004 size: "__unstable-large",
21005 label: (0, import_i18n24.__)("Density"),
21006 value: view.layout?.density || "balanced",
21007 onChange: (value) => {
21008 context.onChangeView({
21009 ...view,
21010 layout: {
21011 ...view.layout,
21012 density: value
21013 }
21014 });
21015 },
21016 isBlock: true,
21017 children: [
21018 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21019 import_components18.__experimentalToggleGroupControlOption,
21020 {
21021 value: "comfortable",
21022 label: (0, import_i18n24._x)(
21023 "Comfortable",
21024 "Density option for DataView layout"
21025 )
21026 },
21027 "comfortable"
21028 ),
21029 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21030 import_components18.__experimentalToggleGroupControlOption,
21031 {
21032 value: "balanced",
21033 label: (0, import_i18n24._x)("Balanced", "Density option for DataView layout")
21034 },
21035 "balanced"
21036 ),
21037 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
21038 import_components18.__experimentalToggleGroupControlOption,
21039 {
21040 value: "compact",
21041 label: (0, import_i18n24._x)("Compact", "Density option for DataView layout")
21042 },
21043 "compact"
21044 )
21045 ]
21046 }
21047 );
21048 }
21049
21050 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
21051 var import_components19 = __toESM(require_components(), 1);
21052 var import_i18n25 = __toESM(require_i18n(), 1);
21053 var import_element78 = __toESM(require_element(), 1);
21054 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
21055 var imageSizes2 = [
21056 {
21057 value: 120,
21058 breakpoint: 1
21059 },
21060 {
21061 value: 170,
21062 breakpoint: 1
21063 },
21064 {
21065 value: 230,
21066 breakpoint: 1
21067 },
21068 {
21069 value: 290,
21070 breakpoint: 1112
21071 // at minimum image width, 4 images display at this container size
21072 },
21073 {
21074 value: 350,
21075 breakpoint: 1636
21076 // at minimum image width, 6 images display at this container size
21077 },
21078 {
21079 value: 430,
21080 breakpoint: 588
21081 // at minimum image width, 2 images display at this container size
21082 }
21083 ];
21084 function PreviewSizePicker() {
21085 const context = (0, import_element78.useContext)(dataviews_context_default);
21086 const view = context.view;
21087 const breakValues = imageSizes2.filter((size4) => {
21088 return context.containerWidth >= size4.breakpoint;
21089 });
21090 const layoutPreviewSize = view.layout?.previewSize ?? 230;
21091 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
21092 const marks = breakValues.map((size4, index2) => {
21093 return {
21094 value: index2
21095 };
21096 });
21097 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
21098 import_components19.RangeControl,
21099 {
21100 __next40pxDefaultSize: true,
21101 showTooltip: false,
21102 label: (0, import_i18n25.__)("Preview size"),
21103 value: previewSizeToUse,
21104 min: 0,
21105 max: breakValues.length - 1,
21106 withInputField: false,
21107 onChange: (value = 0) => {
21108 context.onChangeView({
21109 ...view,
21110 layout: {
21111 ...view.layout,
21112 previewSize: breakValues[value].value
21113 }
21114 });
21115 },
21116 step: 1,
21117 marks
21118 }
21119 );
21120 }
21121
21122 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
21123 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
21124 function GridConfigOptions() {
21125 return /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(import_jsx_runtime113.Fragment, { children: [
21126 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(DensityPicker, {}),
21127 /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(PreviewSizePicker, {})
21128 ] });
21129 }
21130
21131 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
21132 var VIEW_LAYOUTS = [
21133 {
21134 type: LAYOUT_TABLE,
21135 label: (0, import_i18n26.__)("Table"),
21136 component: table_default,
21137 icon: block_table_default,
21138 viewConfigOptions: DensityPicker
21139 },
21140 {
21141 type: LAYOUT_GRID,
21142 label: (0, import_i18n26.__)("Grid"),
21143 component: grid_default,
21144 icon: category_default,
21145 viewConfigOptions: GridConfigOptions
21146 },
21147 {
21148 type: LAYOUT_LIST,
21149 label: (0, import_i18n26.__)("List"),
21150 component: ViewList,
21151 icon: (0, import_i18n26.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
21152 viewConfigOptions: DensityPicker
21153 },
21154 {
21155 type: LAYOUT_ACTIVITY,
21156 label: (0, import_i18n26.__)("Activity"),
21157 component: ViewActivity,
21158 icon: scheduled_default,
21159 viewConfigOptions: DensityPicker
21160 },
21161 {
21162 type: LAYOUT_PICKER_GRID,
21163 label: (0, import_i18n26.__)("Grid"),
21164 component: picker_grid_default,
21165 icon: category_default,
21166 viewConfigOptions: GridConfigOptions,
21167 isPicker: true
21168 },
21169 {
21170 type: LAYOUT_PICKER_TABLE,
21171 label: (0, import_i18n26.__)("Table"),
21172 component: picker_table_default,
21173 icon: block_table_default,
21174 viewConfigOptions: DensityPicker,
21175 isPicker: true
21176 }
21177 ];
21178
21179 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21180 var import_element86 = __toESM(require_element(), 1);
21181
21182 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21183 var import_components22 = __toESM(require_components(), 1);
21184 var import_i18n29 = __toESM(require_i18n(), 1);
21185 var import_element83 = __toESM(require_element(), 1);
21186
21187 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
21188 function noop4(..._) {
21189 }
21190 function applyState(argument, currentValue) {
21191 if (isUpdater(argument)) {
21192 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
21193 return argument(value);
21194 }
21195 return argument;
21196 }
21197 function isUpdater(argument) {
21198 return typeof argument === "function";
21199 }
21200 function isLazyValue(value) {
21201 return typeof value === "function";
21202 }
21203 function hasOwnProperty(object, prop) {
21204 if (typeof Object.hasOwn === "function") {
21205 return Object.hasOwn(object, prop);
21206 }
21207 return Object.prototype.hasOwnProperty.call(object, prop);
21208 }
21209 function chain(...fns) {
21210 return (...args) => {
21211 for (const fn of fns) {
21212 if (typeof fn === "function") {
21213 fn(...args);
21214 }
21215 }
21216 };
21217 }
21218 function normalizeString(str) {
21219 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
21220 }
21221 function omit(object, keys) {
21222 const result = { ...object };
21223 for (const key of keys) {
21224 if (hasOwnProperty(result, key)) {
21225 delete result[key];
21226 }
21227 }
21228 return result;
21229 }
21230 function pick(object, paths) {
21231 const result = {};
21232 for (const key of paths) {
21233 if (hasOwnProperty(object, key)) {
21234 result[key] = object[key];
21235 }
21236 }
21237 return result;
21238 }
21239 function identity(value) {
21240 return value;
21241 }
21242 function invariant(condition, message2) {
21243 if (condition) return;
21244 if (typeof message2 !== "string") throw new Error("Invariant failed");
21245 throw new Error(message2);
21246 }
21247 function getKeys(obj) {
21248 return Object.keys(obj);
21249 }
21250 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
21251 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
21252 if (result == null) return false;
21253 return !result;
21254 }
21255 function disabledFromProps(props) {
21256 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
21257 }
21258 function removeUndefinedValues(obj) {
21259 const result = {};
21260 for (const key in obj) {
21261 if (obj[key] !== void 0) {
21262 result[key] = obj[key];
21263 }
21264 }
21265 return result;
21266 }
21267 function defaultValue(...values) {
21268 for (const value of values) {
21269 if (value !== void 0) return value;
21270 }
21271 return void 0;
21272 }
21273
21274 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
21275 var import_react15 = __toESM(require_react(), 1);
21276 function setRef(ref, value) {
21277 if (typeof ref === "function") {
21278 ref(value);
21279 } else if (ref) {
21280 ref.current = value;
21281 }
21282 }
21283 function isValidElementWithRef(element) {
21284 if (!element) return false;
21285 if (!(0, import_react15.isValidElement)(element)) return false;
21286 if ("ref" in element.props) return true;
21287 if ("ref" in element) return true;
21288 return false;
21289 }
21290 function getRefProperty(element) {
21291 if (!isValidElementWithRef(element)) return null;
21292 const props = { ...element.props };
21293 return props.ref || element.ref;
21294 }
21295 function mergeProps3(base, overrides) {
21296 const props = { ...base };
21297 for (const key in overrides) {
21298 if (!hasOwnProperty(overrides, key)) continue;
21299 if (key === "className") {
21300 const prop = "className";
21301 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
21302 continue;
21303 }
21304 if (key === "style") {
21305 const prop = "style";
21306 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
21307 continue;
21308 }
21309 const overrideValue = overrides[key];
21310 if (typeof overrideValue === "function" && key.startsWith("on")) {
21311 const baseValue = base[key];
21312 if (typeof baseValue === "function") {
21313 props[key] = (...args) => {
21314 overrideValue(...args);
21315 baseValue(...args);
21316 };
21317 continue;
21318 }
21319 }
21320 props[key] = overrideValue;
21321 }
21322 return props;
21323 }
21324
21325 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
21326 var canUseDOM = checkIsBrowser();
21327 function checkIsBrowser() {
21328 var _a;
21329 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
21330 }
21331 function getDocument(node) {
21332 if (!node) return document;
21333 if ("self" in node) return node.document;
21334 return node.ownerDocument || document;
21335 }
21336 function getActiveElement(node, activeDescendant = false) {
21337 var _a;
21338 const { activeElement: activeElement2 } = getDocument(node);
21339 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
21340 return null;
21341 }
21342 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
21343 return getActiveElement(
21344 activeElement2.contentDocument.body,
21345 activeDescendant
21346 );
21347 }
21348 if (activeDescendant) {
21349 const id = activeElement2.getAttribute("aria-activedescendant");
21350 if (id) {
21351 const element = getDocument(activeElement2).getElementById(id);
21352 if (element) {
21353 return element;
21354 }
21355 }
21356 }
21357 return activeElement2;
21358 }
21359 function contains2(parent, child) {
21360 return parent === child || parent.contains(child);
21361 }
21362 function isFrame(element) {
21363 return element.tagName === "IFRAME";
21364 }
21365 function isButton(element) {
21366 const tagName = element.tagName.toLowerCase();
21367 if (tagName === "button") return true;
21368 if (tagName === "input" && element.type) {
21369 return buttonInputTypes.indexOf(element.type) !== -1;
21370 }
21371 return false;
21372 }
21373 var buttonInputTypes = [
21374 "button",
21375 "color",
21376 "file",
21377 "image",
21378 "reset",
21379 "submit"
21380 ];
21381 function isVisible(element) {
21382 if (typeof element.checkVisibility === "function") {
21383 return element.checkVisibility();
21384 }
21385 const htmlElement = element;
21386 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
21387 }
21388 function isTextField(element) {
21389 try {
21390 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
21391 const isTextArea = element.tagName === "TEXTAREA";
21392 return isTextInput || isTextArea || false;
21393 } catch (_error) {
21394 return false;
21395 }
21396 }
21397 function isTextbox(element) {
21398 return element.isContentEditable || isTextField(element);
21399 }
21400 function getTextboxValue(element) {
21401 if (isTextField(element)) {
21402 return element.value;
21403 }
21404 if (element.isContentEditable) {
21405 const range = getDocument(element).createRange();
21406 range.selectNodeContents(element);
21407 return range.toString();
21408 }
21409 return "";
21410 }
21411 function getTextboxSelection(element) {
21412 let start = 0;
21413 let end = 0;
21414 if (isTextField(element)) {
21415 start = element.selectionStart || 0;
21416 end = element.selectionEnd || 0;
21417 } else if (element.isContentEditable) {
21418 const selection = getDocument(element).getSelection();
21419 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
21420 const range = selection.getRangeAt(0);
21421 const nextRange = range.cloneRange();
21422 nextRange.selectNodeContents(element);
21423 nextRange.setEnd(range.startContainer, range.startOffset);
21424 start = nextRange.toString().length;
21425 nextRange.setEnd(range.endContainer, range.endOffset);
21426 end = nextRange.toString().length;
21427 }
21428 }
21429 return { start, end };
21430 }
21431 function getPopupRole(element, fallback) {
21432 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
21433 const role = element == null ? void 0 : element.getAttribute("role");
21434 if (role && allowedPopupRoles.indexOf(role) !== -1) {
21435 return role;
21436 }
21437 return fallback;
21438 }
21439 function getScrollingElement(element) {
21440 if (!element) return null;
21441 const isScrollableOverflow = (overflow) => {
21442 if (overflow === "auto") return true;
21443 if (overflow === "scroll") return true;
21444 return false;
21445 };
21446 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
21447 const { overflowY } = getComputedStyle(element);
21448 if (isScrollableOverflow(overflowY)) return element;
21449 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
21450 const { overflowX } = getComputedStyle(element);
21451 if (isScrollableOverflow(overflowX)) return element;
21452 }
21453 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
21454 }
21455 function setSelectionRange(element, ...args) {
21456 if (/text|search|password|tel|url/i.test(element.type)) {
21457 element.setSelectionRange(...args);
21458 }
21459 }
21460 function sortBasedOnDOMPosition(items, getElement) {
21461 const pairs = items.map((item, index2) => [index2, item]);
21462 let isOrderDifferent = false;
21463 pairs.sort(([indexA, a2], [indexB, b2]) => {
21464 const elementA = getElement(a2);
21465 const elementB = getElement(b2);
21466 if (elementA === elementB) return 0;
21467 if (!elementA || !elementB) return 0;
21468 if (isElementPreceding(elementA, elementB)) {
21469 if (indexA > indexB) {
21470 isOrderDifferent = true;
21471 }
21472 return -1;
21473 }
21474 if (indexA < indexB) {
21475 isOrderDifferent = true;
21476 }
21477 return 1;
21478 });
21479 if (isOrderDifferent) {
21480 return pairs.map(([_, item]) => item);
21481 }
21482 return items;
21483 }
21484 function isElementPreceding(a2, b2) {
21485 return Boolean(
21486 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
21487 );
21488 }
21489
21490 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
21491 function isTouchDevice() {
21492 return canUseDOM && !!navigator.maxTouchPoints;
21493 }
21494 function isApple() {
21495 if (!canUseDOM) return false;
21496 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
21497 }
21498 function isSafari2() {
21499 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
21500 }
21501 function isFirefox2() {
21502 return canUseDOM && /firefox\//i.test(navigator.userAgent);
21503 }
21504
21505 // node_modules/@ariakit/core/esm/utils/events.js
21506 function isPortalEvent(event) {
21507 return Boolean(
21508 event.currentTarget && !contains2(event.currentTarget, event.target)
21509 );
21510 }
21511 function isSelfTarget(event) {
21512 return event.target === event.currentTarget;
21513 }
21514 function isOpeningInNewTab(event) {
21515 const element = event.currentTarget;
21516 if (!element) return false;
21517 const isAppleDevice = isApple();
21518 if (isAppleDevice && !event.metaKey) return false;
21519 if (!isAppleDevice && !event.ctrlKey) return false;
21520 const tagName = element.tagName.toLowerCase();
21521 if (tagName === "a") return true;
21522 if (tagName === "button" && element.type === "submit") return true;
21523 if (tagName === "input" && element.type === "submit") return true;
21524 return false;
21525 }
21526 function isDownloading(event) {
21527 const element = event.currentTarget;
21528 if (!element) return false;
21529 const tagName = element.tagName.toLowerCase();
21530 if (!event.altKey) return false;
21531 if (tagName === "a") return true;
21532 if (tagName === "button" && element.type === "submit") return true;
21533 if (tagName === "input" && element.type === "submit") return true;
21534 return false;
21535 }
21536 function fireBlurEvent(element, eventInit) {
21537 const event = new FocusEvent("blur", eventInit);
21538 const defaultAllowed = element.dispatchEvent(event);
21539 const bubbleInit = { ...eventInit, bubbles: true };
21540 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
21541 return defaultAllowed;
21542 }
21543 function fireKeyboardEvent(element, type, eventInit) {
21544 const event = new KeyboardEvent(type, eventInit);
21545 return element.dispatchEvent(event);
21546 }
21547 function fireClickEvent(element, eventInit) {
21548 const event = new MouseEvent("click", eventInit);
21549 return element.dispatchEvent(event);
21550 }
21551 function isFocusEventOutside(event, container) {
21552 const containerElement = container || event.currentTarget;
21553 const relatedTarget = event.relatedTarget;
21554 return !relatedTarget || !contains2(containerElement, relatedTarget);
21555 }
21556 function queueBeforeEvent(element, type, callback, timeout) {
21557 const createTimer = (callback2) => {
21558 if (timeout) {
21559 const timerId2 = setTimeout(callback2, timeout);
21560 return () => clearTimeout(timerId2);
21561 }
21562 const timerId = requestAnimationFrame(callback2);
21563 return () => cancelAnimationFrame(timerId);
21564 };
21565 const cancelTimer = createTimer(() => {
21566 element.removeEventListener(type, callSync, true);
21567 callback();
21568 });
21569 const callSync = () => {
21570 cancelTimer();
21571 callback();
21572 };
21573 element.addEventListener(type, callSync, { once: true, capture: true });
21574 return cancelTimer;
21575 }
21576 function addGlobalEventListener(type, listener, options, scope = window) {
21577 const children = [];
21578 try {
21579 scope.document.addEventListener(type, listener, options);
21580 for (const frame of Array.from(scope.frames)) {
21581 children.push(addGlobalEventListener(type, listener, options, frame));
21582 }
21583 } catch (e2) {
21584 }
21585 const removeEventListener = () => {
21586 try {
21587 scope.document.removeEventListener(type, listener, options);
21588 } catch (e2) {
21589 }
21590 for (const remove of children) {
21591 remove();
21592 }
21593 };
21594 return removeEventListener;
21595 }
21596
21597 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
21598 var React85 = __toESM(require_react(), 1);
21599 var import_react16 = __toESM(require_react(), 1);
21600 var _React = { ...React85 };
21601 var useReactId = _React.useId;
21602 var useReactDeferredValue = _React.useDeferredValue;
21603 var useReactInsertionEffect = _React.useInsertionEffect;
21604 var useSafeLayoutEffect = canUseDOM ? import_react16.useLayoutEffect : import_react16.useEffect;
21605 function useInitialValue(value) {
21606 const [initialValue] = (0, import_react16.useState)(value);
21607 return initialValue;
21608 }
21609 function useLiveRef(value) {
21610 const ref = (0, import_react16.useRef)(value);
21611 useSafeLayoutEffect(() => {
21612 ref.current = value;
21613 });
21614 return ref;
21615 }
21616 function useEvent(callback) {
21617 const ref = (0, import_react16.useRef)(() => {
21618 throw new Error("Cannot call an event handler while rendering.");
21619 });
21620 if (useReactInsertionEffect) {
21621 useReactInsertionEffect(() => {
21622 ref.current = callback;
21623 });
21624 } else {
21625 ref.current = callback;
21626 }
21627 return (0, import_react16.useCallback)((...args) => {
21628 var _a;
21629 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
21630 }, []);
21631 }
21632 function useTransactionState(callback) {
21633 const [state, setState] = (0, import_react16.useState)(null);
21634 useSafeLayoutEffect(() => {
21635 if (state == null) return;
21636 if (!callback) return;
21637 let prevState = null;
21638 callback((prev) => {
21639 prevState = prev;
21640 return state;
21641 });
21642 return () => {
21643 callback(prevState);
21644 };
21645 }, [state, callback]);
21646 return [state, setState];
21647 }
21648 function useMergeRefs3(...refs) {
21649 return (0, import_react16.useMemo)(() => {
21650 if (!refs.some(Boolean)) return;
21651 return (value) => {
21652 for (const ref of refs) {
21653 setRef(ref, value);
21654 }
21655 };
21656 }, refs);
21657 }
21658 function useId5(defaultId) {
21659 if (useReactId) {
21660 const reactId = useReactId();
21661 if (defaultId) return defaultId;
21662 return reactId;
21663 }
21664 const [id, setId] = (0, import_react16.useState)(defaultId);
21665 useSafeLayoutEffect(() => {
21666 if (defaultId || id) return;
21667 const random = Math.random().toString(36).slice(2, 8);
21668 setId(`id-${random}`);
21669 }, [defaultId, id]);
21670 return defaultId || id;
21671 }
21672 function useTagName(refOrElement, type) {
21673 const stringOrUndefined = (type2) => {
21674 if (typeof type2 !== "string") return;
21675 return type2;
21676 };
21677 const [tagName, setTagName] = (0, import_react16.useState)(() => stringOrUndefined(type));
21678 useSafeLayoutEffect(() => {
21679 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
21680 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
21681 }, [refOrElement, type]);
21682 return tagName;
21683 }
21684 function useAttribute(refOrElement, attributeName, defaultValue2) {
21685 const initialValue = useInitialValue(defaultValue2);
21686 const [attribute, setAttribute] = (0, import_react16.useState)(initialValue);
21687 (0, import_react16.useEffect)(() => {
21688 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
21689 if (!element) return;
21690 const callback = () => {
21691 const value = element.getAttribute(attributeName);
21692 setAttribute(value == null ? initialValue : value);
21693 };
21694 const observer = new MutationObserver(callback);
21695 observer.observe(element, { attributeFilter: [attributeName] });
21696 callback();
21697 return () => observer.disconnect();
21698 }, [refOrElement, attributeName, initialValue]);
21699 return attribute;
21700 }
21701 function useUpdateEffect(effect, deps) {
21702 const mounted = (0, import_react16.useRef)(false);
21703 (0, import_react16.useEffect)(() => {
21704 if (mounted.current) {
21705 return effect();
21706 }
21707 mounted.current = true;
21708 }, deps);
21709 (0, import_react16.useEffect)(
21710 () => () => {
21711 mounted.current = false;
21712 },
21713 []
21714 );
21715 }
21716 function useUpdateLayoutEffect(effect, deps) {
21717 const mounted = (0, import_react16.useRef)(false);
21718 useSafeLayoutEffect(() => {
21719 if (mounted.current) {
21720 return effect();
21721 }
21722 mounted.current = true;
21723 }, deps);
21724 useSafeLayoutEffect(
21725 () => () => {
21726 mounted.current = false;
21727 },
21728 []
21729 );
21730 }
21731 function useForceUpdate() {
21732 return (0, import_react16.useReducer)(() => [], []);
21733 }
21734 function useBooleanEvent(booleanOrCallback) {
21735 return useEvent(
21736 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
21737 );
21738 }
21739 function useWrapElement(props, callback, deps = []) {
21740 const wrapElement = (0, import_react16.useCallback)(
21741 (element) => {
21742 if (props.wrapElement) {
21743 element = props.wrapElement(element);
21744 }
21745 return callback(element);
21746 },
21747 [...deps, props.wrapElement]
21748 );
21749 return { ...props, wrapElement };
21750 }
21751 function useMetadataProps(props, key, value) {
21752 const parent = props.onLoadedMetadataCapture;
21753 const onLoadedMetadataCapture = (0, import_react16.useMemo)(() => {
21754 return Object.assign(() => {
21755 }, { ...parent, [key]: value });
21756 }, [parent, key, value]);
21757 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
21758 }
21759 var hasInstalledGlobalEventListeners = false;
21760 function useIsMouseMoving() {
21761 (0, import_react16.useEffect)(() => {
21762 if (hasInstalledGlobalEventListeners) return;
21763 addGlobalEventListener("mousemove", setMouseMoving, true);
21764 addGlobalEventListener("mousedown", resetMouseMoving, true);
21765 addGlobalEventListener("mouseup", resetMouseMoving, true);
21766 addGlobalEventListener("keydown", resetMouseMoving, true);
21767 addGlobalEventListener("scroll", resetMouseMoving, true);
21768 hasInstalledGlobalEventListeners = true;
21769 }, []);
21770 const isMouseMoving = useEvent(() => mouseMoving);
21771 return isMouseMoving;
21772 }
21773 var mouseMoving = false;
21774 var previousScreenX = 0;
21775 var previousScreenY = 0;
21776 function hasMouseMovement(event) {
21777 const movementX = event.movementX || event.screenX - previousScreenX;
21778 const movementY = event.movementY || event.screenY - previousScreenY;
21779 previousScreenX = event.screenX;
21780 previousScreenY = event.screenY;
21781 return movementX || movementY || false;
21782 }
21783 function setMouseMoving(event) {
21784 if (!hasMouseMovement(event)) return;
21785 mouseMoving = true;
21786 }
21787 function resetMouseMoving() {
21788 mouseMoving = false;
21789 }
21790
21791 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
21792 var React86 = __toESM(require_react(), 1);
21793 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
21794 function forwardRef210(render4) {
21795 const Role = React86.forwardRef(
21796 // @ts-ignore Incompatible with React 19 types. Ignore for now.
21797 (props, ref) => render4({ ...props, ref })
21798 );
21799 Role.displayName = render4.displayName || render4.name;
21800 return Role;
21801 }
21802 function memo22(Component, propsAreEqual) {
21803 return React86.memo(Component, propsAreEqual);
21804 }
21805 function createElement3(Type, props) {
21806 const { wrapElement, render: render4, ...rest } = props;
21807 const mergedRef = useMergeRefs3(props.ref, getRefProperty(render4));
21808 let element;
21809 if (React86.isValidElement(render4)) {
21810 const renderProps = {
21811 // @ts-ignore Incompatible with React 19 types. Ignore for now.
21812 ...render4.props,
21813 ref: mergedRef
21814 };
21815 element = React86.cloneElement(render4, mergeProps3(rest, renderProps));
21816 } else if (render4) {
21817 element = render4(rest);
21818 } else {
21819 element = /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Type, { ...rest });
21820 }
21821 if (wrapElement) {
21822 return wrapElement(element);
21823 }
21824 return element;
21825 }
21826 function createHook(useProps) {
21827 const useRole2 = (props = {}) => {
21828 return useProps(props);
21829 };
21830 useRole2.displayName = useProps.name;
21831 return useRole2;
21832 }
21833 function createStoreContext(providers = [], scopedProviders = []) {
21834 const context = React86.createContext(void 0);
21835 const scopedContext = React86.createContext(void 0);
21836 const useContext210 = () => React86.useContext(context);
21837 const useScopedContext = (onlyScoped = false) => {
21838 const scoped = React86.useContext(scopedContext);
21839 const store = useContext210();
21840 if (onlyScoped) return scoped;
21841 return scoped || store;
21842 };
21843 const useProviderContext = () => {
21844 const scoped = React86.useContext(scopedContext);
21845 const store = useContext210();
21846 if (scoped && scoped === store) return;
21847 return store;
21848 };
21849 const ContextProvider = (props) => {
21850 return providers.reduceRight(
21851 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Provider2, { ...props, children }),
21852 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(context.Provider, { ...props })
21853 );
21854 };
21855 const ScopedContextProvider = (props) => {
21856 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
21857 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Provider2, { ...props, children }),
21858 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(scopedContext.Provider, { ...props })
21859 ) });
21860 };
21861 return {
21862 context,
21863 scopedContext,
21864 useContext: useContext210,
21865 useScopedContext,
21866 useProviderContext,
21867 ContextProvider,
21868 ScopedContextProvider
21869 };
21870 }
21871
21872 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
21873 var ctx = createStoreContext();
21874 var useCollectionContext = ctx.useContext;
21875 var useCollectionScopedContext = ctx.useScopedContext;
21876 var useCollectionProviderContext = ctx.useProviderContext;
21877 var CollectionContextProvider = ctx.ContextProvider;
21878 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
21879
21880 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
21881 var import_react17 = __toESM(require_react(), 1);
21882 var ctx2 = createStoreContext(
21883 [CollectionContextProvider],
21884 [CollectionScopedContextProvider]
21885 );
21886 var useCompositeContext = ctx2.useContext;
21887 var useCompositeScopedContext = ctx2.useScopedContext;
21888 var useCompositeProviderContext = ctx2.useProviderContext;
21889 var CompositeContextProvider = ctx2.ContextProvider;
21890 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
21891 var CompositeItemContext = (0, import_react17.createContext)(
21892 void 0
21893 );
21894 var CompositeRowContext = (0, import_react17.createContext)(
21895 void 0
21896 );
21897
21898 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
21899 function findFirstEnabledItem(items, excludeId) {
21900 return items.find((item) => {
21901 if (excludeId) {
21902 return !item.disabled && item.id !== excludeId;
21903 }
21904 return !item.disabled;
21905 });
21906 }
21907 function getEnabledItem(store, id) {
21908 if (!id) return null;
21909 return store.item(id) || null;
21910 }
21911 function groupItemsByRows(items) {
21912 const rows = [];
21913 for (const item of items) {
21914 const row = rows.find((currentRow) => {
21915 var _a;
21916 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
21917 });
21918 if (row) {
21919 row.push(item);
21920 } else {
21921 rows.push([item]);
21922 }
21923 }
21924 return rows;
21925 }
21926 function selectTextField(element, collapseToEnd = false) {
21927 if (isTextField(element)) {
21928 element.setSelectionRange(
21929 collapseToEnd ? element.value.length : 0,
21930 element.value.length
21931 );
21932 } else if (element.isContentEditable) {
21933 const selection = getDocument(element).getSelection();
21934 selection == null ? void 0 : selection.selectAllChildren(element);
21935 if (collapseToEnd) {
21936 selection == null ? void 0 : selection.collapseToEnd();
21937 }
21938 }
21939 }
21940 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
21941 function focusSilently(element) {
21942 element[FOCUS_SILENTLY] = true;
21943 element.focus({ preventScroll: true });
21944 }
21945 function silentlyFocused(element) {
21946 const isSilentlyFocused = element[FOCUS_SILENTLY];
21947 delete element[FOCUS_SILENTLY];
21948 return isSilentlyFocused;
21949 }
21950 function isItem(store, element, exclude) {
21951 if (!element) return false;
21952 if (element === exclude) return false;
21953 const item = store.item(element.id);
21954 if (!item) return false;
21955 if (exclude && item.element === exclude) return false;
21956 return true;
21957 }
21958
21959 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
21960 var import_react18 = __toESM(require_react(), 1);
21961 var TagName = "div";
21962 var useCollectionItem = createHook(
21963 function useCollectionItem2({
21964 store,
21965 shouldRegisterItem = true,
21966 getItem = identity,
21967 // @ts-expect-error This prop may come from a collection renderer.
21968 element,
21969 ...props
21970 }) {
21971 const context = useCollectionContext();
21972 store = store || context;
21973 const id = useId5(props.id);
21974 const ref = (0, import_react18.useRef)(element);
21975 (0, import_react18.useEffect)(() => {
21976 const element2 = ref.current;
21977 if (!id) return;
21978 if (!element2) return;
21979 if (!shouldRegisterItem) return;
21980 const item = getItem({ id, element: element2 });
21981 return store == null ? void 0 : store.renderItem(item);
21982 }, [id, shouldRegisterItem, getItem, store]);
21983 props = {
21984 ...props,
21985 ref: useMergeRefs3(ref, props.ref)
21986 };
21987 return removeUndefinedValues(props);
21988 }
21989 );
21990 var CollectionItem = forwardRef210(function CollectionItem2(props) {
21991 const htmlProps = useCollectionItem(props);
21992 return createElement3(TagName, htmlProps);
21993 });
21994
21995 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
21996 var import_react19 = __toESM(require_react(), 1);
21997 var FocusableContext = (0, import_react19.createContext)(true);
21998
21999 // node_modules/@ariakit/core/esm/utils/focus.js
22000 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'])";
22001 function isFocusable(element) {
22002 if (!element.matches(selector)) return false;
22003 if (!isVisible(element)) return false;
22004 if (element.closest("[inert]")) return false;
22005 return true;
22006 }
22007 function getClosestFocusable(element) {
22008 while (element && !isFocusable(element)) {
22009 element = element.closest(selector);
22010 }
22011 return element || null;
22012 }
22013 function hasFocus(element) {
22014 const activeElement2 = getActiveElement(element);
22015 if (!activeElement2) return false;
22016 if (activeElement2 === element) return true;
22017 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
22018 if (!activeDescendant) return false;
22019 return activeDescendant === element.id;
22020 }
22021 function hasFocusWithin(element) {
22022 const activeElement2 = getActiveElement(element);
22023 if (!activeElement2) return false;
22024 if (contains2(element, activeElement2)) return true;
22025 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
22026 if (!activeDescendant) return false;
22027 if (!("id" in element)) return false;
22028 if (activeDescendant === element.id) return true;
22029 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
22030 }
22031 function focusIfNeeded(element) {
22032 if (!hasFocusWithin(element) && isFocusable(element)) {
22033 element.focus();
22034 }
22035 }
22036 function focusIntoView(element, options) {
22037 if (!("scrollIntoView" in element)) {
22038 element.focus();
22039 } else {
22040 element.focus({ preventScroll: true });
22041 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
22042 }
22043 }
22044
22045 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
22046 var import_react20 = __toESM(require_react(), 1);
22047 var TagName2 = "div";
22048 var isSafariBrowser = isSafari2();
22049 var alwaysFocusVisibleInputTypes = [
22050 "text",
22051 "search",
22052 "url",
22053 "tel",
22054 "email",
22055 "password",
22056 "number",
22057 "date",
22058 "month",
22059 "week",
22060 "time",
22061 "datetime",
22062 "datetime-local"
22063 ];
22064 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
22065 function markSafariFocusAncestor(element, value) {
22066 if (!element) return;
22067 element[safariFocusAncestorSymbol] = value;
22068 }
22069 function isAlwaysFocusVisible(element) {
22070 const { tagName, readOnly, type } = element;
22071 if (tagName === "TEXTAREA" && !readOnly) return true;
22072 if (tagName === "SELECT" && !readOnly) return true;
22073 if (tagName === "INPUT" && !readOnly) {
22074 return alwaysFocusVisibleInputTypes.includes(type);
22075 }
22076 if (element.isContentEditable) return true;
22077 const role = element.getAttribute("role");
22078 if (role === "combobox" && element.dataset.name) {
22079 return true;
22080 }
22081 return false;
22082 }
22083 function getLabels(element) {
22084 if ("labels" in element) {
22085 return element.labels;
22086 }
22087 return null;
22088 }
22089 function isNativeCheckboxOrRadio(element) {
22090 const tagName = element.tagName.toLowerCase();
22091 if (tagName === "input" && element.type) {
22092 return element.type === "radio" || element.type === "checkbox";
22093 }
22094 return false;
22095 }
22096 function isNativeTabbable(tagName) {
22097 if (!tagName) return true;
22098 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
22099 }
22100 function supportsDisabledAttribute(tagName) {
22101 if (!tagName) return true;
22102 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
22103 }
22104 function getTabIndex4(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
22105 if (!focusable2) {
22106 return tabIndexProp;
22107 }
22108 if (trulyDisabled) {
22109 if (nativeTabbable && !supportsDisabled) {
22110 return -1;
22111 }
22112 return;
22113 }
22114 if (nativeTabbable) {
22115 return tabIndexProp;
22116 }
22117 return tabIndexProp || 0;
22118 }
22119 function useDisableEvent(onEvent, disabled2) {
22120 return useEvent((event) => {
22121 onEvent == null ? void 0 : onEvent(event);
22122 if (event.defaultPrevented) return;
22123 if (disabled2) {
22124 event.stopPropagation();
22125 event.preventDefault();
22126 }
22127 });
22128 }
22129 var hasInstalledGlobalEventListeners2 = false;
22130 var isKeyboardModality = true;
22131 function onGlobalMouseDown(event) {
22132 const target = event.target;
22133 if (target && "hasAttribute" in target) {
22134 if (!target.hasAttribute("data-focus-visible")) {
22135 isKeyboardModality = false;
22136 }
22137 }
22138 }
22139 function onGlobalKeyDown(event) {
22140 if (event.metaKey) return;
22141 if (event.ctrlKey) return;
22142 if (event.altKey) return;
22143 isKeyboardModality = true;
22144 }
22145 var useFocusable = createHook(
22146 function useFocusable2({
22147 focusable: focusable2 = true,
22148 accessibleWhenDisabled,
22149 autoFocus,
22150 onFocusVisible,
22151 ...props
22152 }) {
22153 const ref = (0, import_react20.useRef)(null);
22154 (0, import_react20.useEffect)(() => {
22155 if (!focusable2) return;
22156 if (hasInstalledGlobalEventListeners2) return;
22157 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
22158 addGlobalEventListener("keydown", onGlobalKeyDown, true);
22159 hasInstalledGlobalEventListeners2 = true;
22160 }, [focusable2]);
22161 if (isSafariBrowser) {
22162 (0, import_react20.useEffect)(() => {
22163 if (!focusable2) return;
22164 const element = ref.current;
22165 if (!element) return;
22166 if (!isNativeCheckboxOrRadio(element)) return;
22167 const labels = getLabels(element);
22168 if (!labels) return;
22169 const onMouseUp = () => queueMicrotask(() => element.focus());
22170 for (const label of labels) {
22171 label.addEventListener("mouseup", onMouseUp);
22172 }
22173 return () => {
22174 for (const label of labels) {
22175 label.removeEventListener("mouseup", onMouseUp);
22176 }
22177 };
22178 }, [focusable2]);
22179 }
22180 const disabled2 = focusable2 && disabledFromProps(props);
22181 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
22182 const [focusVisible, setFocusVisible] = (0, import_react20.useState)(false);
22183 (0, import_react20.useEffect)(() => {
22184 if (!focusable2) return;
22185 if (trulyDisabled && focusVisible) {
22186 setFocusVisible(false);
22187 }
22188 }, [focusable2, trulyDisabled, focusVisible]);
22189 (0, import_react20.useEffect)(() => {
22190 if (!focusable2) return;
22191 if (!focusVisible) return;
22192 const element = ref.current;
22193 if (!element) return;
22194 if (typeof IntersectionObserver === "undefined") return;
22195 const observer = new IntersectionObserver(() => {
22196 if (!isFocusable(element)) {
22197 setFocusVisible(false);
22198 }
22199 });
22200 observer.observe(element);
22201 return () => observer.disconnect();
22202 }, [focusable2, focusVisible]);
22203 const onKeyPressCapture = useDisableEvent(
22204 props.onKeyPressCapture,
22205 disabled2
22206 );
22207 const onMouseDownCapture = useDisableEvent(
22208 props.onMouseDownCapture,
22209 disabled2
22210 );
22211 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
22212 const onMouseDownProp = props.onMouseDown;
22213 const onMouseDown = useEvent((event) => {
22214 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
22215 if (event.defaultPrevented) return;
22216 if (!focusable2) return;
22217 const element = event.currentTarget;
22218 if (!isSafariBrowser) return;
22219 if (isPortalEvent(event)) return;
22220 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
22221 let receivedFocus = false;
22222 const onFocus = () => {
22223 receivedFocus = true;
22224 };
22225 const options = { capture: true, once: true };
22226 element.addEventListener("focusin", onFocus, options);
22227 const focusableContainer = getClosestFocusable(element.parentElement);
22228 markSafariFocusAncestor(focusableContainer, true);
22229 queueBeforeEvent(element, "mouseup", () => {
22230 element.removeEventListener("focusin", onFocus, true);
22231 markSafariFocusAncestor(focusableContainer, false);
22232 if (receivedFocus) return;
22233 focusIfNeeded(element);
22234 });
22235 });
22236 const handleFocusVisible = (event, currentTarget) => {
22237 if (currentTarget) {
22238 event.currentTarget = currentTarget;
22239 }
22240 if (!focusable2) return;
22241 const element = event.currentTarget;
22242 if (!element) return;
22243 if (!hasFocus(element)) return;
22244 onFocusVisible == null ? void 0 : onFocusVisible(event);
22245 if (event.defaultPrevented) return;
22246 element.dataset.focusVisible = "true";
22247 setFocusVisible(true);
22248 };
22249 const onKeyDownCaptureProp = props.onKeyDownCapture;
22250 const onKeyDownCapture = useEvent((event) => {
22251 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
22252 if (event.defaultPrevented) return;
22253 if (!focusable2) return;
22254 if (focusVisible) return;
22255 if (event.metaKey) return;
22256 if (event.altKey) return;
22257 if (event.ctrlKey) return;
22258 if (!isSelfTarget(event)) return;
22259 const element = event.currentTarget;
22260 const applyFocusVisible = () => handleFocusVisible(event, element);
22261 queueBeforeEvent(element, "focusout", applyFocusVisible);
22262 });
22263 const onFocusCaptureProp = props.onFocusCapture;
22264 const onFocusCapture = useEvent((event) => {
22265 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
22266 if (event.defaultPrevented) return;
22267 if (!focusable2) return;
22268 if (!isSelfTarget(event)) {
22269 setFocusVisible(false);
22270 return;
22271 }
22272 const element = event.currentTarget;
22273 const applyFocusVisible = () => handleFocusVisible(event, element);
22274 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
22275 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
22276 } else {
22277 setFocusVisible(false);
22278 }
22279 });
22280 const onBlurProp = props.onBlur;
22281 const onBlur = useEvent((event) => {
22282 onBlurProp == null ? void 0 : onBlurProp(event);
22283 if (!focusable2) return;
22284 if (!isFocusEventOutside(event)) return;
22285 event.currentTarget.removeAttribute("data-focus-visible");
22286 setFocusVisible(false);
22287 });
22288 const autoFocusOnShow = (0, import_react20.useContext)(FocusableContext);
22289 const autoFocusRef = useEvent((element) => {
22290 if (!focusable2) return;
22291 if (!autoFocus) return;
22292 if (!element) return;
22293 if (!autoFocusOnShow) return;
22294 queueMicrotask(() => {
22295 if (hasFocus(element)) return;
22296 if (!isFocusable(element)) return;
22297 element.focus();
22298 });
22299 });
22300 const tagName = useTagName(ref);
22301 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
22302 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
22303 const styleProp = props.style;
22304 const style = (0, import_react20.useMemo)(() => {
22305 if (trulyDisabled) {
22306 return { pointerEvents: "none", ...styleProp };
22307 }
22308 return styleProp;
22309 }, [trulyDisabled, styleProp]);
22310 props = {
22311 "data-focus-visible": focusable2 && focusVisible || void 0,
22312 "data-autofocus": autoFocus || void 0,
22313 "aria-disabled": disabled2 || void 0,
22314 ...props,
22315 ref: useMergeRefs3(ref, autoFocusRef, props.ref),
22316 style,
22317 tabIndex: getTabIndex4(
22318 focusable2,
22319 trulyDisabled,
22320 nativeTabbable,
22321 supportsDisabled,
22322 props.tabIndex
22323 ),
22324 disabled: supportsDisabled && trulyDisabled ? true : void 0,
22325 // TODO: Test Focusable contentEditable.
22326 contentEditable: disabled2 ? void 0 : props.contentEditable,
22327 onKeyPressCapture,
22328 onClickCapture,
22329 onMouseDownCapture,
22330 onMouseDown,
22331 onKeyDownCapture,
22332 onFocusCapture,
22333 onBlur
22334 };
22335 return removeUndefinedValues(props);
22336 }
22337 );
22338 var Focusable = forwardRef210(function Focusable2(props) {
22339 const htmlProps = useFocusable(props);
22340 return createElement3(TagName2, htmlProps);
22341 });
22342
22343 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
22344 var import_react21 = __toESM(require_react(), 1);
22345 var TagName3 = "button";
22346 function isNativeClick(event) {
22347 if (!event.isTrusted) return false;
22348 const element = event.currentTarget;
22349 if (event.key === "Enter") {
22350 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
22351 }
22352 if (event.key === " ") {
22353 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
22354 }
22355 return false;
22356 }
22357 var symbol = /* @__PURE__ */ Symbol("command");
22358 var useCommand = createHook(
22359 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
22360 const ref = (0, import_react21.useRef)(null);
22361 const [isNativeButton, setIsNativeButton] = (0, import_react21.useState)(false);
22362 (0, import_react21.useEffect)(() => {
22363 if (!ref.current) return;
22364 setIsNativeButton(isButton(ref.current));
22365 }, []);
22366 const [active, setActive] = (0, import_react21.useState)(false);
22367 const activeRef = (0, import_react21.useRef)(false);
22368 const disabled2 = disabledFromProps(props);
22369 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
22370 const onKeyDownProp = props.onKeyDown;
22371 const onKeyDown = useEvent((event) => {
22372 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
22373 const element = event.currentTarget;
22374 if (event.defaultPrevented) return;
22375 if (isDuplicate) return;
22376 if (disabled2) return;
22377 if (!isSelfTarget(event)) return;
22378 if (isTextField(element)) return;
22379 if (element.isContentEditable) return;
22380 const isEnter = clickOnEnter && event.key === "Enter";
22381 const isSpace = clickOnSpace && event.key === " ";
22382 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
22383 const shouldPreventSpace = event.key === " " && !clickOnSpace;
22384 if (shouldPreventEnter || shouldPreventSpace) {
22385 event.preventDefault();
22386 return;
22387 }
22388 if (isEnter || isSpace) {
22389 const nativeClick = isNativeClick(event);
22390 if (isEnter) {
22391 if (!nativeClick) {
22392 event.preventDefault();
22393 const { view, ...eventInit } = event;
22394 const click = () => fireClickEvent(element, eventInit);
22395 if (isFirefox2()) {
22396 queueBeforeEvent(element, "keyup", click);
22397 } else {
22398 queueMicrotask(click);
22399 }
22400 }
22401 } else if (isSpace) {
22402 activeRef.current = true;
22403 if (!nativeClick) {
22404 event.preventDefault();
22405 setActive(true);
22406 }
22407 }
22408 }
22409 });
22410 const onKeyUpProp = props.onKeyUp;
22411 const onKeyUp = useEvent((event) => {
22412 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
22413 if (event.defaultPrevented) return;
22414 if (isDuplicate) return;
22415 if (disabled2) return;
22416 if (event.metaKey) return;
22417 const isSpace = clickOnSpace && event.key === " ";
22418 if (activeRef.current && isSpace) {
22419 activeRef.current = false;
22420 if (!isNativeClick(event)) {
22421 event.preventDefault();
22422 setActive(false);
22423 const element = event.currentTarget;
22424 const { view, ...eventInit } = event;
22425 queueMicrotask(() => fireClickEvent(element, eventInit));
22426 }
22427 }
22428 });
22429 props = {
22430 "data-active": active || void 0,
22431 type: isNativeButton ? "button" : void 0,
22432 ...metadataProps,
22433 ...props,
22434 ref: useMergeRefs3(ref, props.ref),
22435 onKeyDown,
22436 onKeyUp
22437 };
22438 props = useFocusable(props);
22439 return props;
22440 }
22441 );
22442 var Command = forwardRef210(function Command2(props) {
22443 const htmlProps = useCommand(props);
22444 return createElement3(TagName3, htmlProps);
22445 });
22446
22447 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
22448 function getInternal(store, key) {
22449 const internals = store.__unstableInternals;
22450 invariant(internals, "Invalid store");
22451 return internals[key];
22452 }
22453 function createStore(initialState, ...stores) {
22454 let state = initialState;
22455 let prevStateBatch = state;
22456 let lastUpdate = /* @__PURE__ */ Symbol();
22457 let destroy = noop4;
22458 const instances = /* @__PURE__ */ new Set();
22459 const updatedKeys = /* @__PURE__ */ new Set();
22460 const setups = /* @__PURE__ */ new Set();
22461 const listeners = /* @__PURE__ */ new Set();
22462 const batchListeners = /* @__PURE__ */ new Set();
22463 const disposables = /* @__PURE__ */ new WeakMap();
22464 const listenerKeys = /* @__PURE__ */ new WeakMap();
22465 const storeSetup = (callback) => {
22466 setups.add(callback);
22467 return () => setups.delete(callback);
22468 };
22469 const storeInit = () => {
22470 const initialized = instances.size;
22471 const instance = /* @__PURE__ */ Symbol();
22472 instances.add(instance);
22473 const maybeDestroy = () => {
22474 instances.delete(instance);
22475 if (instances.size) return;
22476 destroy();
22477 };
22478 if (initialized) return maybeDestroy;
22479 const desyncs = getKeys(state).map(
22480 (key) => chain(
22481 ...stores.map((store) => {
22482 var _a;
22483 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
22484 if (!storeState) return;
22485 if (!hasOwnProperty(storeState, key)) return;
22486 return sync(store, [key], (state2) => {
22487 setState(
22488 key,
22489 state2[key],
22490 // @ts-expect-error - Not public API. This is just to prevent
22491 // infinite loops.
22492 true
22493 );
22494 });
22495 })
22496 )
22497 );
22498 const teardowns = [];
22499 for (const setup2 of setups) {
22500 teardowns.push(setup2());
22501 }
22502 const cleanups = stores.map(init);
22503 destroy = chain(...desyncs, ...teardowns, ...cleanups);
22504 return maybeDestroy;
22505 };
22506 const sub = (keys, listener, set3 = listeners) => {
22507 set3.add(listener);
22508 listenerKeys.set(listener, keys);
22509 return () => {
22510 var _a;
22511 (_a = disposables.get(listener)) == null ? void 0 : _a();
22512 disposables.delete(listener);
22513 listenerKeys.delete(listener);
22514 set3.delete(listener);
22515 };
22516 };
22517 const storeSubscribe = (keys, listener) => sub(keys, listener);
22518 const storeSync = (keys, listener) => {
22519 disposables.set(listener, listener(state, state));
22520 return sub(keys, listener);
22521 };
22522 const storeBatch = (keys, listener) => {
22523 disposables.set(listener, listener(state, prevStateBatch));
22524 return sub(keys, listener, batchListeners);
22525 };
22526 const storePick = (keys) => createStore(pick(state, keys), finalStore);
22527 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
22528 const getState = () => state;
22529 const setState = (key, value, fromStores = false) => {
22530 var _a;
22531 if (!hasOwnProperty(state, key)) return;
22532 const nextValue = applyState(value, state[key]);
22533 if (nextValue === state[key]) return;
22534 if (!fromStores) {
22535 for (const store of stores) {
22536 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
22537 }
22538 }
22539 const prevState = state;
22540 state = { ...state, [key]: nextValue };
22541 const thisUpdate = /* @__PURE__ */ Symbol();
22542 lastUpdate = thisUpdate;
22543 updatedKeys.add(key);
22544 const run = (listener, prev, uKeys) => {
22545 var _a2;
22546 const keys = listenerKeys.get(listener);
22547 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
22548 if (!keys || keys.some(updated)) {
22549 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
22550 disposables.set(listener, listener(state, prev));
22551 }
22552 };
22553 for (const listener of listeners) {
22554 run(listener, prevState);
22555 }
22556 queueMicrotask(() => {
22557 if (lastUpdate !== thisUpdate) return;
22558 const snapshot = state;
22559 for (const listener of batchListeners) {
22560 run(listener, prevStateBatch, updatedKeys);
22561 }
22562 prevStateBatch = snapshot;
22563 updatedKeys.clear();
22564 });
22565 };
22566 const finalStore = {
22567 getState,
22568 setState,
22569 __unstableInternals: {
22570 setup: storeSetup,
22571 init: storeInit,
22572 subscribe: storeSubscribe,
22573 sync: storeSync,
22574 batch: storeBatch,
22575 pick: storePick,
22576 omit: storeOmit
22577 }
22578 };
22579 return finalStore;
22580 }
22581 function setup(store, ...args) {
22582 if (!store) return;
22583 return getInternal(store, "setup")(...args);
22584 }
22585 function init(store, ...args) {
22586 if (!store) return;
22587 return getInternal(store, "init")(...args);
22588 }
22589 function subscribe(store, ...args) {
22590 if (!store) return;
22591 return getInternal(store, "subscribe")(...args);
22592 }
22593 function sync(store, ...args) {
22594 if (!store) return;
22595 return getInternal(store, "sync")(...args);
22596 }
22597 function batch(store, ...args) {
22598 if (!store) return;
22599 return getInternal(store, "batch")(...args);
22600 }
22601 function omit2(store, ...args) {
22602 if (!store) return;
22603 return getInternal(store, "omit")(...args);
22604 }
22605 function pick2(store, ...args) {
22606 if (!store) return;
22607 return getInternal(store, "pick")(...args);
22608 }
22609 function mergeStore(...stores) {
22610 var _a;
22611 const initialState = {};
22612 for (const store2 of stores) {
22613 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
22614 if (nextState) {
22615 Object.assign(initialState, nextState);
22616 }
22617 }
22618 const store = createStore(initialState, ...stores);
22619 return Object.assign({}, ...stores, store);
22620 }
22621 function throwOnConflictingProps(props, store) {
22622 if (false) return;
22623 if (!store) return;
22624 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
22625 var _a;
22626 const stateKey = key.replace("default", "");
22627 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
22628 });
22629 if (!defaultKeys.length) return;
22630 const storeState = store.getState();
22631 const conflictingProps = defaultKeys.filter(
22632 (key) => hasOwnProperty(storeState, key)
22633 );
22634 if (!conflictingProps.length) return;
22635 throw new Error(
22636 `Passing a store prop in conjunction with a default state is not supported.
22637
22638 const store = useSelectStore();
22639 <SelectProvider store={store} defaultValue="Apple" />
22640 ^ ^
22641
22642 Instead, pass the default state to the topmost store:
22643
22644 const store = useSelectStore({ defaultValue: "Apple" });
22645 <SelectProvider store={store} />
22646
22647 See https://github.com/ariakit/ariakit/pull/2745 for more details.
22648
22649 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
22650 `
22651 );
22652 }
22653
22654 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
22655 var React87 = __toESM(require_react(), 1);
22656 var import_shim2 = __toESM(require_shim(), 1);
22657 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
22658 var noopSubscribe = () => () => {
22659 };
22660 function useStoreState(store, keyOrSelector = identity) {
22661 const storeSubscribe = React87.useCallback(
22662 (callback) => {
22663 if (!store) return noopSubscribe();
22664 return subscribe(store, null, callback);
22665 },
22666 [store]
22667 );
22668 const getSnapshot = () => {
22669 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
22670 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
22671 const state = store == null ? void 0 : store.getState();
22672 if (selector2) return selector2(state);
22673 if (!state) return;
22674 if (!key) return;
22675 if (!hasOwnProperty(state, key)) return;
22676 return state[key];
22677 };
22678 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
22679 }
22680 function useStoreStateObject(store, object) {
22681 const objRef = React87.useRef(
22682 {}
22683 );
22684 const storeSubscribe = React87.useCallback(
22685 (callback) => {
22686 if (!store) return noopSubscribe();
22687 return subscribe(store, null, callback);
22688 },
22689 [store]
22690 );
22691 const getSnapshot = () => {
22692 const state = store == null ? void 0 : store.getState();
22693 let updated = false;
22694 const obj = objRef.current;
22695 for (const prop in object) {
22696 const keyOrSelector = object[prop];
22697 if (typeof keyOrSelector === "function") {
22698 const value = keyOrSelector(state);
22699 if (value !== obj[prop]) {
22700 obj[prop] = value;
22701 updated = true;
22702 }
22703 }
22704 if (typeof keyOrSelector === "string") {
22705 if (!state) continue;
22706 if (!hasOwnProperty(state, keyOrSelector)) continue;
22707 const value = state[keyOrSelector];
22708 if (value !== obj[prop]) {
22709 obj[prop] = value;
22710 updated = true;
22711 }
22712 }
22713 }
22714 if (updated) {
22715 objRef.current = { ...obj };
22716 }
22717 return objRef.current;
22718 };
22719 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
22720 }
22721 function useStoreProps(store, props, key, setKey) {
22722 const value = hasOwnProperty(props, key) ? props[key] : void 0;
22723 const setValue = setKey ? props[setKey] : void 0;
22724 const propsRef = useLiveRef({ value, setValue });
22725 useSafeLayoutEffect(() => {
22726 return sync(store, [key], (state, prev) => {
22727 const { value: value2, setValue: setValue2 } = propsRef.current;
22728 if (!setValue2) return;
22729 if (state[key] === prev[key]) return;
22730 if (state[key] === value2) return;
22731 setValue2(state[key]);
22732 });
22733 }, [store, key]);
22734 useSafeLayoutEffect(() => {
22735 if (value === void 0) return;
22736 store.setState(key, value);
22737 return batch(store, [key], () => {
22738 if (value === void 0) return;
22739 store.setState(key, value);
22740 });
22741 });
22742 }
22743 function useStore2(createStore2, props) {
22744 const [store, setStore] = React87.useState(() => createStore2(props));
22745 useSafeLayoutEffect(() => init(store), [store]);
22746 const useState210 = React87.useCallback(
22747 (keyOrSelector) => useStoreState(store, keyOrSelector),
22748 [store]
22749 );
22750 const memoizedStore = React87.useMemo(
22751 () => ({ ...store, useState: useState210 }),
22752 [store, useState210]
22753 );
22754 const updateStore = useEvent(() => {
22755 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
22756 });
22757 return [memoizedStore, updateStore];
22758 }
22759
22760 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
22761 var import_react22 = __toESM(require_react(), 1);
22762 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
22763 var TagName4 = "button";
22764 function isEditableElement(element) {
22765 if (isTextbox(element)) return true;
22766 return element.tagName === "INPUT" && !isButton(element);
22767 }
22768 function getNextPageOffset(scrollingElement, pageUp = false) {
22769 const height = scrollingElement.clientHeight;
22770 const { top } = scrollingElement.getBoundingClientRect();
22771 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
22772 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
22773 if (scrollingElement.tagName === "HTML") {
22774 return pageOffset + scrollingElement.scrollTop;
22775 }
22776 return pageOffset;
22777 }
22778 function getItemOffset(itemElement, pageUp = false) {
22779 const { top } = itemElement.getBoundingClientRect();
22780 if (pageUp) {
22781 return top + itemElement.clientHeight;
22782 }
22783 return top;
22784 }
22785 function findNextPageItemId(element, store, next, pageUp = false) {
22786 var _a;
22787 if (!store) return;
22788 if (!next) return;
22789 const { renderedItems } = store.getState();
22790 const scrollingElement = getScrollingElement(element);
22791 if (!scrollingElement) return;
22792 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
22793 let id;
22794 let prevDifference;
22795 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
22796 const previousId = id;
22797 id = next(i2);
22798 if (!id) break;
22799 if (id === previousId) continue;
22800 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
22801 if (!itemElement) continue;
22802 const itemOffset = getItemOffset(itemElement, pageUp);
22803 const difference = itemOffset - nextPageOffset;
22804 const absDifference = Math.abs(difference);
22805 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
22806 if (prevDifference !== void 0 && prevDifference < absDifference) {
22807 id = previousId;
22808 }
22809 break;
22810 }
22811 prevDifference = absDifference;
22812 }
22813 return id;
22814 }
22815 function targetIsAnotherItem(event, store) {
22816 if (isSelfTarget(event)) return false;
22817 return isItem(store, event.target);
22818 }
22819 var useCompositeItem = createHook(
22820 function useCompositeItem2({
22821 store,
22822 rowId: rowIdProp,
22823 preventScrollOnKeyDown = false,
22824 moveOnKeyPress = true,
22825 tabbable: tabbable4 = false,
22826 getItem: getItemProp,
22827 "aria-setsize": ariaSetSizeProp,
22828 "aria-posinset": ariaPosInSetProp,
22829 ...props
22830 }) {
22831 const context = useCompositeContext();
22832 store = store || context;
22833 const id = useId5(props.id);
22834 const ref = (0, import_react22.useRef)(null);
22835 const row = (0, import_react22.useContext)(CompositeRowContext);
22836 const disabled2 = disabledFromProps(props);
22837 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
22838 const {
22839 rowId,
22840 baseElement,
22841 isActiveItem,
22842 ariaSetSize,
22843 ariaPosInSet,
22844 isTabbable: isTabbable2
22845 } = useStoreStateObject(store, {
22846 rowId(state) {
22847 if (rowIdProp) return rowIdProp;
22848 if (!state) return;
22849 if (!(row == null ? void 0 : row.baseElement)) return;
22850 if (row.baseElement !== state.baseElement) return;
22851 return row.id;
22852 },
22853 baseElement(state) {
22854 return (state == null ? void 0 : state.baseElement) || void 0;
22855 },
22856 isActiveItem(state) {
22857 return !!state && state.activeId === id;
22858 },
22859 ariaSetSize(state) {
22860 if (ariaSetSizeProp != null) return ariaSetSizeProp;
22861 if (!state) return;
22862 if (!(row == null ? void 0 : row.ariaSetSize)) return;
22863 if (row.baseElement !== state.baseElement) return;
22864 return row.ariaSetSize;
22865 },
22866 ariaPosInSet(state) {
22867 if (ariaPosInSetProp != null) return ariaPosInSetProp;
22868 if (!state) return;
22869 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
22870 if (row.baseElement !== state.baseElement) return;
22871 const itemsInRow = state.renderedItems.filter(
22872 (item) => item.rowId === rowId
22873 );
22874 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
22875 },
22876 isTabbable(state) {
22877 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
22878 if (state.virtualFocus) return false;
22879 if (tabbable4) return true;
22880 if (state.activeId === null) return false;
22881 const item = store == null ? void 0 : store.item(state.activeId);
22882 if (item == null ? void 0 : item.disabled) return true;
22883 if (!(item == null ? void 0 : item.element)) return true;
22884 return state.activeId === id;
22885 }
22886 });
22887 const getItem = (0, import_react22.useCallback)(
22888 (item) => {
22889 var _a;
22890 const nextItem = {
22891 ...item,
22892 id: id || item.id,
22893 rowId,
22894 disabled: !!trulyDisabled,
22895 children: (_a = item.element) == null ? void 0 : _a.textContent
22896 };
22897 if (getItemProp) {
22898 return getItemProp(nextItem);
22899 }
22900 return nextItem;
22901 },
22902 [id, rowId, trulyDisabled, getItemProp]
22903 );
22904 const onFocusProp = props.onFocus;
22905 const hasFocusedComposite = (0, import_react22.useRef)(false);
22906 const onFocus = useEvent((event) => {
22907 onFocusProp == null ? void 0 : onFocusProp(event);
22908 if (event.defaultPrevented) return;
22909 if (isPortalEvent(event)) return;
22910 if (!id) return;
22911 if (!store) return;
22912 if (targetIsAnotherItem(event, store)) return;
22913 const { virtualFocus, baseElement: baseElement2 } = store.getState();
22914 store.setActiveId(id);
22915 if (isTextbox(event.currentTarget)) {
22916 selectTextField(event.currentTarget);
22917 }
22918 if (!virtualFocus) return;
22919 if (!isSelfTarget(event)) return;
22920 if (isEditableElement(event.currentTarget)) return;
22921 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
22922 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
22923 event.currentTarget.scrollIntoView({
22924 block: "nearest",
22925 inline: "nearest"
22926 });
22927 }
22928 hasFocusedComposite.current = true;
22929 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
22930 if (fromComposite) {
22931 focusSilently(baseElement2);
22932 } else {
22933 baseElement2.focus();
22934 }
22935 });
22936 const onBlurCaptureProp = props.onBlurCapture;
22937 const onBlurCapture = useEvent((event) => {
22938 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
22939 if (event.defaultPrevented) return;
22940 const state = store == null ? void 0 : store.getState();
22941 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
22942 hasFocusedComposite.current = false;
22943 event.preventDefault();
22944 event.stopPropagation();
22945 }
22946 });
22947 const onKeyDownProp = props.onKeyDown;
22948 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
22949 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
22950 const onKeyDown = useEvent((event) => {
22951 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
22952 if (event.defaultPrevented) return;
22953 if (!isSelfTarget(event)) return;
22954 if (!store) return;
22955 const { currentTarget } = event;
22956 const state = store.getState();
22957 const item = store.item(id);
22958 const isGrid2 = !!(item == null ? void 0 : item.rowId);
22959 const isVertical = state.orientation !== "horizontal";
22960 const isHorizontal = state.orientation !== "vertical";
22961 const canHomeEnd = () => {
22962 if (isGrid2) return true;
22963 if (isHorizontal) return true;
22964 if (!state.baseElement) return true;
22965 if (!isTextField(state.baseElement)) return true;
22966 return false;
22967 };
22968 const keyMap = {
22969 ArrowUp: (isGrid2 || isVertical) && store.up,
22970 ArrowRight: (isGrid2 || isHorizontal) && store.next,
22971 ArrowDown: (isGrid2 || isVertical) && store.down,
22972 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
22973 Home: () => {
22974 if (!canHomeEnd()) return;
22975 if (!isGrid2 || event.ctrlKey) {
22976 return store == null ? void 0 : store.first();
22977 }
22978 return store == null ? void 0 : store.previous(-1);
22979 },
22980 End: () => {
22981 if (!canHomeEnd()) return;
22982 if (!isGrid2 || event.ctrlKey) {
22983 return store == null ? void 0 : store.last();
22984 }
22985 return store == null ? void 0 : store.next(-1);
22986 },
22987 PageUp: () => {
22988 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
22989 },
22990 PageDown: () => {
22991 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
22992 }
22993 };
22994 const action = keyMap[event.key];
22995 if (action) {
22996 if (isTextbox(currentTarget)) {
22997 const selection = getTextboxSelection(currentTarget);
22998 const isLeft = isHorizontal && event.key === "ArrowLeft";
22999 const isRight = isHorizontal && event.key === "ArrowRight";
23000 const isUp = isVertical && event.key === "ArrowUp";
23001 const isDown = isVertical && event.key === "ArrowDown";
23002 if (isRight || isDown) {
23003 const { length: valueLength } = getTextboxValue(currentTarget);
23004 if (selection.end !== valueLength) return;
23005 } else if ((isLeft || isUp) && selection.start !== 0) return;
23006 }
23007 const nextId = action();
23008 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
23009 if (!moveOnKeyPressProp(event)) return;
23010 event.preventDefault();
23011 store.move(nextId);
23012 }
23013 }
23014 });
23015 const providerValue = (0, import_react22.useMemo)(
23016 () => ({ id, baseElement }),
23017 [id, baseElement]
23018 );
23019 props = useWrapElement(
23020 props,
23021 (element) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
23022 [providerValue]
23023 );
23024 props = {
23025 id,
23026 "data-active-item": isActiveItem || void 0,
23027 ...props,
23028 ref: useMergeRefs3(ref, props.ref),
23029 tabIndex: isTabbable2 ? props.tabIndex : -1,
23030 onFocus,
23031 onBlurCapture,
23032 onKeyDown
23033 };
23034 props = useCommand(props);
23035 props = useCollectionItem({
23036 store,
23037 ...props,
23038 getItem,
23039 shouldRegisterItem: id ? props.shouldRegisterItem : false
23040 });
23041 return removeUndefinedValues({
23042 ...props,
23043 "aria-setsize": ariaSetSize,
23044 "aria-posinset": ariaPosInSet
23045 });
23046 }
23047 );
23048 var CompositeItem = memo22(
23049 forwardRef210(function CompositeItem2(props) {
23050 const htmlProps = useCompositeItem(props);
23051 return createElement3(TagName4, htmlProps);
23052 })
23053 );
23054
23055 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
23056 function toArray(arg) {
23057 if (Array.isArray(arg)) {
23058 return arg;
23059 }
23060 return typeof arg !== "undefined" ? [arg] : [];
23061 }
23062 function flatten2DArray(array) {
23063 const flattened = [];
23064 for (const row of array) {
23065 flattened.push(...row);
23066 }
23067 return flattened;
23068 }
23069 function reverseArray(array) {
23070 return array.slice().reverse();
23071 }
23072
23073 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
23074 var import_react23 = __toESM(require_react(), 1);
23075 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
23076 var TagName5 = "div";
23077 function isGrid(items) {
23078 return items.some((item) => !!item.rowId);
23079 }
23080 function isPrintableKey(event) {
23081 const target = event.target;
23082 if (target && !isTextField(target)) return false;
23083 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
23084 }
23085 function isModifierKey(event) {
23086 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
23087 }
23088 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
23089 return useEvent((event) => {
23090 var _a;
23091 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
23092 if (event.defaultPrevented) return;
23093 if (event.isPropagationStopped()) return;
23094 if (!isSelfTarget(event)) return;
23095 if (isModifierKey(event)) return;
23096 if (isPrintableKey(event)) return;
23097 const state = store.getState();
23098 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
23099 if (!activeElement2) return;
23100 const { view, ...eventInit } = event;
23101 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
23102 if (activeElement2 !== previousElement) {
23103 activeElement2.focus();
23104 }
23105 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
23106 event.preventDefault();
23107 }
23108 if (event.currentTarget.contains(activeElement2)) {
23109 event.stopPropagation();
23110 }
23111 });
23112 }
23113 function findFirstEnabledItemInTheLastRow(items) {
23114 return findFirstEnabledItem(
23115 flatten2DArray(reverseArray(groupItemsByRows(items)))
23116 );
23117 }
23118 function useScheduleFocus(store) {
23119 const [scheduled, setScheduled] = (0, import_react23.useState)(false);
23120 const schedule = (0, import_react23.useCallback)(() => setScheduled(true), []);
23121 const activeItem = store.useState(
23122 (state) => getEnabledItem(store, state.activeId)
23123 );
23124 (0, import_react23.useEffect)(() => {
23125 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
23126 if (!scheduled) return;
23127 if (!activeElement2) return;
23128 setScheduled(false);
23129 activeElement2.focus({ preventScroll: true });
23130 }, [activeItem, scheduled]);
23131 return schedule;
23132 }
23133 var useComposite = createHook(
23134 function useComposite2({
23135 store,
23136 composite = true,
23137 focusOnMove = composite,
23138 moveOnKeyPress = true,
23139 ...props
23140 }) {
23141 const context = useCompositeProviderContext();
23142 store = store || context;
23143 invariant(
23144 store,
23145 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
23146 );
23147 const ref = (0, import_react23.useRef)(null);
23148 const previousElementRef = (0, import_react23.useRef)(null);
23149 const scheduleFocus = useScheduleFocus(store);
23150 const moves = store.useState("moves");
23151 const [, setBaseElement] = useTransactionState(
23152 composite ? store.setBaseElement : null
23153 );
23154 (0, import_react23.useEffect)(() => {
23155 var _a;
23156 if (!store) return;
23157 if (!moves) return;
23158 if (!composite) return;
23159 if (!focusOnMove) return;
23160 const { activeId: activeId2 } = store.getState();
23161 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
23162 if (!itemElement) return;
23163 focusIntoView(itemElement);
23164 }, [store, moves, composite, focusOnMove]);
23165 useSafeLayoutEffect(() => {
23166 if (!store) return;
23167 if (!moves) return;
23168 if (!composite) return;
23169 const { baseElement, activeId: activeId2 } = store.getState();
23170 const isSelfAcive = activeId2 === null;
23171 if (!isSelfAcive) return;
23172 if (!baseElement) return;
23173 const previousElement = previousElementRef.current;
23174 previousElementRef.current = null;
23175 if (previousElement) {
23176 fireBlurEvent(previousElement, { relatedTarget: baseElement });
23177 }
23178 if (!hasFocus(baseElement)) {
23179 baseElement.focus();
23180 }
23181 }, [store, moves, composite]);
23182 const activeId = store.useState("activeId");
23183 const virtualFocus = store.useState("virtualFocus");
23184 useSafeLayoutEffect(() => {
23185 var _a;
23186 if (!store) return;
23187 if (!composite) return;
23188 if (!virtualFocus) return;
23189 const previousElement = previousElementRef.current;
23190 previousElementRef.current = null;
23191 if (!previousElement) return;
23192 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
23193 const relatedTarget = activeElement2 || getActiveElement(previousElement);
23194 if (relatedTarget === previousElement) return;
23195 fireBlurEvent(previousElement, { relatedTarget });
23196 }, [store, activeId, virtualFocus, composite]);
23197 const onKeyDownCapture = useKeyboardEventProxy(
23198 store,
23199 props.onKeyDownCapture,
23200 previousElementRef
23201 );
23202 const onKeyUpCapture = useKeyboardEventProxy(
23203 store,
23204 props.onKeyUpCapture,
23205 previousElementRef
23206 );
23207 const onFocusCaptureProp = props.onFocusCapture;
23208 const onFocusCapture = useEvent((event) => {
23209 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
23210 if (event.defaultPrevented) return;
23211 if (!store) return;
23212 const { virtualFocus: virtualFocus2 } = store.getState();
23213 if (!virtualFocus2) return;
23214 const previousActiveElement = event.relatedTarget;
23215 const isSilentlyFocused = silentlyFocused(event.currentTarget);
23216 if (isSelfTarget(event) && isSilentlyFocused) {
23217 event.stopPropagation();
23218 previousElementRef.current = previousActiveElement;
23219 }
23220 });
23221 const onFocusProp = props.onFocus;
23222 const onFocus = useEvent((event) => {
23223 onFocusProp == null ? void 0 : onFocusProp(event);
23224 if (event.defaultPrevented) return;
23225 if (!composite) return;
23226 if (!store) return;
23227 const { relatedTarget } = event;
23228 const { virtualFocus: virtualFocus2 } = store.getState();
23229 if (virtualFocus2) {
23230 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
23231 queueMicrotask(scheduleFocus);
23232 }
23233 } else if (isSelfTarget(event)) {
23234 store.setActiveId(null);
23235 }
23236 });
23237 const onBlurCaptureProp = props.onBlurCapture;
23238 const onBlurCapture = useEvent((event) => {
23239 var _a;
23240 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
23241 if (event.defaultPrevented) return;
23242 if (!store) return;
23243 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
23244 if (!virtualFocus2) return;
23245 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
23246 const nextActiveElement = event.relatedTarget;
23247 const nextActiveElementIsItem = isItem(store, nextActiveElement);
23248 const previousElement = previousElementRef.current;
23249 previousElementRef.current = null;
23250 if (isSelfTarget(event) && nextActiveElementIsItem) {
23251 if (nextActiveElement === activeElement2) {
23252 if (previousElement && previousElement !== nextActiveElement) {
23253 fireBlurEvent(previousElement, event);
23254 }
23255 } else if (activeElement2) {
23256 fireBlurEvent(activeElement2, event);
23257 } else if (previousElement) {
23258 fireBlurEvent(previousElement, event);
23259 }
23260 event.stopPropagation();
23261 } else {
23262 const targetIsItem = isItem(store, event.target);
23263 if (!targetIsItem && activeElement2) {
23264 fireBlurEvent(activeElement2, event);
23265 }
23266 }
23267 });
23268 const onKeyDownProp = props.onKeyDown;
23269 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
23270 const onKeyDown = useEvent((event) => {
23271 var _a;
23272 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
23273 if (event.nativeEvent.isComposing) return;
23274 if (event.defaultPrevented) return;
23275 if (!store) return;
23276 if (!isSelfTarget(event)) return;
23277 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
23278 const activeItem = getEnabledItem(store, activeId2);
23279 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
23280 const isVertical = orientation !== "horizontal";
23281 const isHorizontal = orientation !== "vertical";
23282 const grid = isGrid(renderedItems);
23283 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
23284 if (isHorizontalKey && isTextField(event.currentTarget)) return;
23285 const up = () => {
23286 if (grid) {
23287 const item = findFirstEnabledItemInTheLastRow(renderedItems);
23288 return item == null ? void 0 : item.id;
23289 }
23290 return store == null ? void 0 : store.last();
23291 };
23292 const keyMap = {
23293 ArrowUp: (grid || isVertical) && up,
23294 ArrowRight: (grid || isHorizontal) && store.first,
23295 ArrowDown: (grid || isVertical) && store.first,
23296 ArrowLeft: (grid || isHorizontal) && store.last,
23297 Home: store.first,
23298 End: store.last,
23299 PageUp: store.first,
23300 PageDown: store.last
23301 };
23302 const action = keyMap[event.key];
23303 if (action) {
23304 const id = action();
23305 if (id !== void 0) {
23306 if (!moveOnKeyPressProp(event)) return;
23307 event.preventDefault();
23308 store.move(id);
23309 }
23310 }
23311 });
23312 props = useWrapElement(
23313 props,
23314 (element) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(CompositeContextProvider, { value: store, children: element }),
23315 [store]
23316 );
23317 const activeDescendant = store.useState((state) => {
23318 var _a;
23319 if (!store) return;
23320 if (!composite) return;
23321 if (!state.virtualFocus) return;
23322 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
23323 });
23324 props = {
23325 "aria-activedescendant": activeDescendant,
23326 ...props,
23327 ref: useMergeRefs3(ref, setBaseElement, props.ref),
23328 onKeyDownCapture,
23329 onKeyUpCapture,
23330 onFocusCapture,
23331 onFocus,
23332 onBlurCapture,
23333 onKeyDown
23334 };
23335 const focusable2 = store.useState(
23336 (state) => composite && (state.virtualFocus || state.activeId === null)
23337 );
23338 props = useFocusable({ focusable: focusable2, ...props });
23339 return props;
23340 }
23341 );
23342 var Composite5 = forwardRef210(function Composite22(props) {
23343 const htmlProps = useComposite(props);
23344 return createElement3(TagName5, htmlProps);
23345 });
23346
23347 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
23348 var ctx3 = createStoreContext();
23349 var useDisclosureContext = ctx3.useContext;
23350 var useDisclosureScopedContext = ctx3.useScopedContext;
23351 var useDisclosureProviderContext = ctx3.useProviderContext;
23352 var DisclosureContextProvider = ctx3.ContextProvider;
23353 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
23354
23355 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
23356 var import_react24 = __toESM(require_react(), 1);
23357 var ctx4 = createStoreContext(
23358 [DisclosureContextProvider],
23359 [DisclosureScopedContextProvider]
23360 );
23361 var useDialogContext = ctx4.useContext;
23362 var useDialogScopedContext = ctx4.useScopedContext;
23363 var useDialogProviderContext = ctx4.useProviderContext;
23364 var DialogContextProvider = ctx4.ContextProvider;
23365 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
23366 var DialogHeadingContext = (0, import_react24.createContext)(void 0);
23367 var DialogDescriptionContext = (0, import_react24.createContext)(void 0);
23368
23369 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
23370 var import_react25 = __toESM(require_react(), 1);
23371 var import_react_dom4 = __toESM(require_react_dom(), 1);
23372 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
23373 var TagName6 = "div";
23374 function afterTimeout(timeoutMs, cb) {
23375 const timeoutId = setTimeout(cb, timeoutMs);
23376 return () => clearTimeout(timeoutId);
23377 }
23378 function afterPaint2(cb) {
23379 let raf = requestAnimationFrame(() => {
23380 raf = requestAnimationFrame(cb);
23381 });
23382 return () => cancelAnimationFrame(raf);
23383 }
23384 function parseCSSTime(...times) {
23385 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
23386 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
23387 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
23388 if (currentTime > longestTime) return currentTime;
23389 return longestTime;
23390 }, 0);
23391 }
23392 function isHidden3(mounted, hidden, alwaysVisible) {
23393 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
23394 }
23395 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
23396 const context = useDisclosureProviderContext();
23397 store = store || context;
23398 invariant(
23399 store,
23400 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
23401 );
23402 const ref = (0, import_react25.useRef)(null);
23403 const id = useId5(props.id);
23404 const [transition, setTransition] = (0, import_react25.useState)(null);
23405 const open = store.useState("open");
23406 const mounted = store.useState("mounted");
23407 const animated = store.useState("animated");
23408 const contentElement = store.useState("contentElement");
23409 const otherElement = useStoreState(store.disclosure, "contentElement");
23410 useSafeLayoutEffect(() => {
23411 if (!ref.current) return;
23412 store == null ? void 0 : store.setContentElement(ref.current);
23413 }, [store]);
23414 useSafeLayoutEffect(() => {
23415 let previousAnimated;
23416 store == null ? void 0 : store.setState("animated", (animated2) => {
23417 previousAnimated = animated2;
23418 return true;
23419 });
23420 return () => {
23421 if (previousAnimated === void 0) return;
23422 store == null ? void 0 : store.setState("animated", previousAnimated);
23423 };
23424 }, [store]);
23425 useSafeLayoutEffect(() => {
23426 if (!animated) return;
23427 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
23428 setTransition(null);
23429 return;
23430 }
23431 return afterPaint2(() => {
23432 setTransition(open ? "enter" : mounted ? "leave" : null);
23433 });
23434 }, [animated, contentElement, open, mounted]);
23435 useSafeLayoutEffect(() => {
23436 if (!store) return;
23437 if (!animated) return;
23438 if (!transition) return;
23439 if (!contentElement) return;
23440 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
23441 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
23442 if (transition === "leave" && open) return;
23443 if (transition === "enter" && !open) return;
23444 if (typeof animated === "number") {
23445 const timeout2 = animated;
23446 return afterTimeout(timeout2, stopAnimationSync);
23447 }
23448 const {
23449 transitionDuration,
23450 animationDuration,
23451 transitionDelay,
23452 animationDelay
23453 } = getComputedStyle(contentElement);
23454 const {
23455 transitionDuration: transitionDuration2 = "0",
23456 animationDuration: animationDuration2 = "0",
23457 transitionDelay: transitionDelay2 = "0",
23458 animationDelay: animationDelay2 = "0"
23459 } = otherElement ? getComputedStyle(otherElement) : {};
23460 const delay = parseCSSTime(
23461 transitionDelay,
23462 animationDelay,
23463 transitionDelay2,
23464 animationDelay2
23465 );
23466 const duration = parseCSSTime(
23467 transitionDuration,
23468 animationDuration,
23469 transitionDuration2,
23470 animationDuration2
23471 );
23472 const timeout = delay + duration;
23473 if (!timeout) {
23474 if (transition === "enter") {
23475 store.setState("animated", false);
23476 }
23477 stopAnimation();
23478 return;
23479 }
23480 const frameRate = 1e3 / 60;
23481 const maxTimeout = Math.max(timeout - frameRate, 0);
23482 return afterTimeout(maxTimeout, stopAnimationSync);
23483 }, [store, animated, contentElement, otherElement, open, transition]);
23484 props = useWrapElement(
23485 props,
23486 (element) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DialogScopedContextProvider, { value: store, children: element }),
23487 [store]
23488 );
23489 const hidden = isHidden3(mounted, props.hidden, alwaysVisible);
23490 const styleProp = props.style;
23491 const style = (0, import_react25.useMemo)(() => {
23492 if (hidden) {
23493 return { ...styleProp, display: "none" };
23494 }
23495 return styleProp;
23496 }, [hidden, styleProp]);
23497 props = {
23498 id,
23499 "data-open": open || void 0,
23500 "data-enter": transition === "enter" || void 0,
23501 "data-leave": transition === "leave" || void 0,
23502 hidden,
23503 ...props,
23504 ref: useMergeRefs3(id ? store.setContentElement : null, ref, props.ref),
23505 style
23506 };
23507 return removeUndefinedValues(props);
23508 });
23509 var DisclosureContentImpl = forwardRef210(function DisclosureContentImpl2(props) {
23510 const htmlProps = useDisclosureContent(props);
23511 return createElement3(TagName6, htmlProps);
23512 });
23513 var DisclosureContent = forwardRef210(function DisclosureContent2({
23514 unmountOnHide,
23515 ...props
23516 }) {
23517 const context = useDisclosureProviderContext();
23518 const store = props.store || context;
23519 const mounted = useStoreState(
23520 store,
23521 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
23522 );
23523 if (mounted === false) return null;
23524 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DisclosureContentImpl, { ...props });
23525 });
23526
23527 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
23528 function createDisclosureStore(props = {}) {
23529 const store = mergeStore(
23530 props.store,
23531 omit2(props.disclosure, ["contentElement", "disclosureElement"])
23532 );
23533 throwOnConflictingProps(props, store);
23534 const syncState = store == null ? void 0 : store.getState();
23535 const open = defaultValue(
23536 props.open,
23537 syncState == null ? void 0 : syncState.open,
23538 props.defaultOpen,
23539 false
23540 );
23541 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
23542 const initialState = {
23543 open,
23544 animated,
23545 animating: !!animated && open,
23546 mounted: open,
23547 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
23548 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
23549 };
23550 const disclosure = createStore(initialState, store);
23551 setup(
23552 disclosure,
23553 () => sync(disclosure, ["animated", "animating"], (state) => {
23554 if (state.animated) return;
23555 disclosure.setState("animating", false);
23556 })
23557 );
23558 setup(
23559 disclosure,
23560 () => subscribe(disclosure, ["open"], () => {
23561 if (!disclosure.getState().animated) return;
23562 disclosure.setState("animating", true);
23563 })
23564 );
23565 setup(
23566 disclosure,
23567 () => sync(disclosure, ["open", "animating"], (state) => {
23568 disclosure.setState("mounted", state.open || state.animating);
23569 })
23570 );
23571 return {
23572 ...disclosure,
23573 disclosure: props.disclosure,
23574 setOpen: (value) => disclosure.setState("open", value),
23575 show: () => disclosure.setState("open", true),
23576 hide: () => disclosure.setState("open", false),
23577 toggle: () => disclosure.setState("open", (open2) => !open2),
23578 stopAnimation: () => disclosure.setState("animating", false),
23579 setContentElement: (value) => disclosure.setState("contentElement", value),
23580 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
23581 };
23582 }
23583
23584 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
23585 function useDisclosureStoreProps(store, update2, props) {
23586 useUpdateEffect(update2, [props.store, props.disclosure]);
23587 useStoreProps(store, props, "open", "setOpen");
23588 useStoreProps(store, props, "mounted", "setMounted");
23589 useStoreProps(store, props, "animated");
23590 return Object.assign(store, { disclosure: props.disclosure });
23591 }
23592
23593 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
23594 var ctx5 = createStoreContext(
23595 [DialogContextProvider],
23596 [DialogScopedContextProvider]
23597 );
23598 var usePopoverContext = ctx5.useContext;
23599 var usePopoverScopedContext = ctx5.useScopedContext;
23600 var usePopoverProviderContext = ctx5.useProviderContext;
23601 var PopoverContextProvider = ctx5.ContextProvider;
23602 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
23603
23604 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
23605 function getCommonParent(items) {
23606 var _a;
23607 const firstItem = items.find((item) => !!item.element);
23608 const lastItem = [...items].reverse().find((item) => !!item.element);
23609 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
23610 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
23611 const parent = parentElement;
23612 if (lastItem && parent.contains(lastItem.element)) {
23613 return parentElement;
23614 }
23615 parentElement = parentElement.parentElement;
23616 }
23617 return getDocument(parentElement).body;
23618 }
23619 function getPrivateStore(store) {
23620 return store == null ? void 0 : store.__unstablePrivateStore;
23621 }
23622 function createCollectionStore(props = {}) {
23623 var _a;
23624 throwOnConflictingProps(props, props.store);
23625 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
23626 const items = defaultValue(
23627 props.items,
23628 syncState == null ? void 0 : syncState.items,
23629 props.defaultItems,
23630 []
23631 );
23632 const itemsMap = new Map(items.map((item) => [item.id, item]));
23633 const initialState = {
23634 items,
23635 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
23636 };
23637 const syncPrivateStore = getPrivateStore(props.store);
23638 const privateStore = createStore(
23639 { items, renderedItems: initialState.renderedItems },
23640 syncPrivateStore
23641 );
23642 const collection = createStore(initialState, props.store);
23643 const sortItems = (renderedItems) => {
23644 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
23645 privateStore.setState("renderedItems", sortedItems);
23646 collection.setState("renderedItems", sortedItems);
23647 };
23648 setup(collection, () => init(privateStore));
23649 setup(privateStore, () => {
23650 return batch(privateStore, ["items"], (state) => {
23651 collection.setState("items", state.items);
23652 });
23653 });
23654 setup(privateStore, () => {
23655 return batch(privateStore, ["renderedItems"], (state) => {
23656 let firstRun = true;
23657 let raf = requestAnimationFrame(() => {
23658 const { renderedItems } = collection.getState();
23659 if (state.renderedItems === renderedItems) return;
23660 sortItems(state.renderedItems);
23661 });
23662 if (typeof IntersectionObserver !== "function") {
23663 return () => cancelAnimationFrame(raf);
23664 }
23665 const ioCallback = () => {
23666 if (firstRun) {
23667 firstRun = false;
23668 return;
23669 }
23670 cancelAnimationFrame(raf);
23671 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
23672 };
23673 const root = getCommonParent(state.renderedItems);
23674 const observer = new IntersectionObserver(ioCallback, { root });
23675 for (const item of state.renderedItems) {
23676 if (!item.element) continue;
23677 observer.observe(item.element);
23678 }
23679 return () => {
23680 cancelAnimationFrame(raf);
23681 observer.disconnect();
23682 };
23683 });
23684 });
23685 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
23686 let prevItem;
23687 setItems((items2) => {
23688 const index2 = items2.findIndex(({ id }) => id === item.id);
23689 const nextItems = items2.slice();
23690 if (index2 !== -1) {
23691 prevItem = items2[index2];
23692 const nextItem = { ...prevItem, ...item };
23693 nextItems[index2] = nextItem;
23694 itemsMap.set(item.id, nextItem);
23695 } else {
23696 nextItems.push(item);
23697 itemsMap.set(item.id, item);
23698 }
23699 return nextItems;
23700 });
23701 const unmergeItem = () => {
23702 setItems((items2) => {
23703 if (!prevItem) {
23704 if (canDeleteFromMap) {
23705 itemsMap.delete(item.id);
23706 }
23707 return items2.filter(({ id }) => id !== item.id);
23708 }
23709 const index2 = items2.findIndex(({ id }) => id === item.id);
23710 if (index2 === -1) return items2;
23711 const nextItems = items2.slice();
23712 nextItems[index2] = prevItem;
23713 itemsMap.set(item.id, prevItem);
23714 return nextItems;
23715 });
23716 };
23717 return unmergeItem;
23718 };
23719 const registerItem = (item) => mergeItem(
23720 item,
23721 (getItems) => privateStore.setState("items", getItems),
23722 true
23723 );
23724 return {
23725 ...collection,
23726 registerItem,
23727 renderItem: (item) => chain(
23728 registerItem(item),
23729 mergeItem(
23730 item,
23731 (getItems) => privateStore.setState("renderedItems", getItems)
23732 )
23733 ),
23734 item: (id) => {
23735 if (!id) return null;
23736 let item = itemsMap.get(id);
23737 if (!item) {
23738 const { items: items2 } = privateStore.getState();
23739 item = items2.find((item2) => item2.id === id);
23740 if (item) {
23741 itemsMap.set(id, item);
23742 }
23743 }
23744 return item || null;
23745 },
23746 // @ts-expect-error Internal
23747 __unstablePrivateStore: privateStore
23748 };
23749 }
23750
23751 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
23752 function useCollectionStoreProps(store, update2, props) {
23753 useUpdateEffect(update2, [props.store]);
23754 useStoreProps(store, props, "items", "setItems");
23755 return store;
23756 }
23757
23758 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
23759 var NULL_ITEM = { id: null };
23760 function findFirstEnabledItem2(items, excludeId) {
23761 return items.find((item) => {
23762 if (excludeId) {
23763 return !item.disabled && item.id !== excludeId;
23764 }
23765 return !item.disabled;
23766 });
23767 }
23768 function getEnabledItems(items, excludeId) {
23769 return items.filter((item) => {
23770 if (excludeId) {
23771 return !item.disabled && item.id !== excludeId;
23772 }
23773 return !item.disabled;
23774 });
23775 }
23776 function getItemsInRow(items, rowId) {
23777 return items.filter((item) => item.rowId === rowId);
23778 }
23779 function flipItems(items, activeId, shouldInsertNullItem = false) {
23780 const index2 = items.findIndex((item) => item.id === activeId);
23781 return [
23782 ...items.slice(index2 + 1),
23783 ...shouldInsertNullItem ? [NULL_ITEM] : [],
23784 ...items.slice(0, index2)
23785 ];
23786 }
23787 function groupItemsByRows2(items) {
23788 const rows = [];
23789 for (const item of items) {
23790 const row = rows.find((currentRow) => {
23791 var _a;
23792 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
23793 });
23794 if (row) {
23795 row.push(item);
23796 } else {
23797 rows.push([item]);
23798 }
23799 }
23800 return rows;
23801 }
23802 function getMaxRowLength(array) {
23803 let maxLength = 0;
23804 for (const { length } of array) {
23805 if (length > maxLength) {
23806 maxLength = length;
23807 }
23808 }
23809 return maxLength;
23810 }
23811 function createEmptyItem(rowId) {
23812 return {
23813 id: "__EMPTY_ITEM__",
23814 disabled: true,
23815 rowId
23816 };
23817 }
23818 function normalizeRows(rows, activeId, focusShift) {
23819 const maxLength = getMaxRowLength(rows);
23820 for (const row of rows) {
23821 for (let i2 = 0; i2 < maxLength; i2 += 1) {
23822 const item = row[i2];
23823 if (!item || focusShift && item.disabled) {
23824 const isFirst = i2 === 0;
23825 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
23826 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
23827 }
23828 }
23829 }
23830 return rows;
23831 }
23832 function verticalizeItems(items) {
23833 const rows = groupItemsByRows2(items);
23834 const maxLength = getMaxRowLength(rows);
23835 const verticalized = [];
23836 for (let i2 = 0; i2 < maxLength; i2 += 1) {
23837 for (const row of rows) {
23838 const item = row[i2];
23839 if (item) {
23840 verticalized.push({
23841 ...item,
23842 // If there's no rowId, it means that it's not a grid composite, but
23843 // a single row instead. So, instead of verticalizing it, that is,
23844 // assigning a different rowId based on the column index, we keep it
23845 // undefined so they will be part of the same row. This is useful
23846 // when using up/down on one-dimensional composites.
23847 rowId: item.rowId ? `${i2}` : void 0
23848 });
23849 }
23850 }
23851 }
23852 return verticalized;
23853 }
23854 function createCompositeStore(props = {}) {
23855 var _a;
23856 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
23857 const collection = createCollectionStore(props);
23858 const activeId = defaultValue(
23859 props.activeId,
23860 syncState == null ? void 0 : syncState.activeId,
23861 props.defaultActiveId
23862 );
23863 const initialState = {
23864 ...collection.getState(),
23865 id: defaultValue(
23866 props.id,
23867 syncState == null ? void 0 : syncState.id,
23868 `id-${Math.random().toString(36).slice(2, 8)}`
23869 ),
23870 activeId,
23871 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
23872 includesBaseElement: defaultValue(
23873 props.includesBaseElement,
23874 syncState == null ? void 0 : syncState.includesBaseElement,
23875 activeId === null
23876 ),
23877 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
23878 orientation: defaultValue(
23879 props.orientation,
23880 syncState == null ? void 0 : syncState.orientation,
23881 "both"
23882 ),
23883 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
23884 virtualFocus: defaultValue(
23885 props.virtualFocus,
23886 syncState == null ? void 0 : syncState.virtualFocus,
23887 false
23888 ),
23889 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
23890 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
23891 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
23892 };
23893 const composite = createStore(initialState, collection, props.store);
23894 setup(
23895 composite,
23896 () => sync(composite, ["renderedItems", "activeId"], (state) => {
23897 composite.setState("activeId", (activeId2) => {
23898 var _a2;
23899 if (activeId2 !== void 0) return activeId2;
23900 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
23901 });
23902 })
23903 );
23904 const getNextId = (direction = "next", options = {}) => {
23905 var _a2, _b;
23906 const defaultState = composite.getState();
23907 const {
23908 skip = 0,
23909 activeId: activeId2 = defaultState.activeId,
23910 focusShift = defaultState.focusShift,
23911 focusLoop = defaultState.focusLoop,
23912 focusWrap = defaultState.focusWrap,
23913 includesBaseElement = defaultState.includesBaseElement,
23914 renderedItems = defaultState.renderedItems,
23915 rtl = defaultState.rtl
23916 } = options;
23917 const isVerticalDirection = direction === "up" || direction === "down";
23918 const isNextDirection = direction === "next" || direction === "down";
23919 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
23920 const canShift = focusShift && !skip;
23921 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
23922 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
23923 );
23924 items = canReverse ? reverseArray(items) : items;
23925 items = isVerticalDirection ? verticalizeItems(items) : items;
23926 if (activeId2 == null) {
23927 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
23928 }
23929 const activeItem = items.find((item) => item.id === activeId2);
23930 if (!activeItem) {
23931 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
23932 }
23933 const isGrid2 = items.some((item) => item.rowId);
23934 const activeIndex = items.indexOf(activeItem);
23935 const nextItems = items.slice(activeIndex + 1);
23936 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
23937 if (skip) {
23938 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
23939 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
23940 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
23941 return nextItem2 == null ? void 0 : nextItem2.id;
23942 }
23943 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
23944 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
23945 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
23946 if (canLoop) {
23947 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
23948 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
23949 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
23950 return nextItem2 == null ? void 0 : nextItem2.id;
23951 }
23952 if (canWrap) {
23953 const nextItem2 = findFirstEnabledItem2(
23954 // We can use nextItems, which contains all the next items, including
23955 // items from other rows, to wrap between rows. However, if there is a
23956 // null item (the composite container), we'll only use the next items in
23957 // the row. So moving next from the last item will focus on the
23958 // composite container. On grid composites, horizontal navigation never
23959 // focuses on the composite container, only vertical.
23960 hasNullItem ? nextItemsInRow : nextItems,
23961 activeId2
23962 );
23963 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
23964 return nextId;
23965 }
23966 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
23967 if (!nextItem && hasNullItem) {
23968 return null;
23969 }
23970 return nextItem == null ? void 0 : nextItem.id;
23971 };
23972 return {
23973 ...collection,
23974 ...composite,
23975 setBaseElement: (element) => composite.setState("baseElement", element),
23976 setActiveId: (id) => composite.setState("activeId", id),
23977 move: (id) => {
23978 if (id === void 0) return;
23979 composite.setState("activeId", id);
23980 composite.setState("moves", (moves) => moves + 1);
23981 },
23982 first: () => {
23983 var _a2;
23984 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
23985 },
23986 last: () => {
23987 var _a2;
23988 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
23989 },
23990 next: (options) => {
23991 if (options !== void 0 && typeof options === "number") {
23992 options = { skip: options };
23993 }
23994 return getNextId("next", options);
23995 },
23996 previous: (options) => {
23997 if (options !== void 0 && typeof options === "number") {
23998 options = { skip: options };
23999 }
24000 return getNextId("previous", options);
24001 },
24002 down: (options) => {
24003 if (options !== void 0 && typeof options === "number") {
24004 options = { skip: options };
24005 }
24006 return getNextId("down", options);
24007 },
24008 up: (options) => {
24009 if (options !== void 0 && typeof options === "number") {
24010 options = { skip: options };
24011 }
24012 return getNextId("up", options);
24013 }
24014 };
24015 }
24016
24017 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
24018 function useCompositeStoreOptions(props) {
24019 const id = useId5(props.id);
24020 return { id, ...props };
24021 }
24022 function useCompositeStoreProps(store, update2, props) {
24023 store = useCollectionStoreProps(store, update2, props);
24024 useStoreProps(store, props, "activeId", "setActiveId");
24025 useStoreProps(store, props, "includesBaseElement");
24026 useStoreProps(store, props, "virtualFocus");
24027 useStoreProps(store, props, "orientation");
24028 useStoreProps(store, props, "rtl");
24029 useStoreProps(store, props, "focusLoop");
24030 useStoreProps(store, props, "focusWrap");
24031 useStoreProps(store, props, "focusShift");
24032 return store;
24033 }
24034
24035 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
24036 var import_react26 = __toESM(require_react(), 1);
24037 var ComboboxListRoleContext = (0, import_react26.createContext)(
24038 void 0
24039 );
24040 var ctx6 = createStoreContext(
24041 [PopoverContextProvider, CompositeContextProvider],
24042 [PopoverScopedContextProvider, CompositeScopedContextProvider]
24043 );
24044 var useComboboxContext = ctx6.useContext;
24045 var useComboboxScopedContext = ctx6.useScopedContext;
24046 var useComboboxProviderContext = ctx6.useProviderContext;
24047 var ComboboxContextProvider = ctx6.ContextProvider;
24048 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
24049 var ComboboxItemValueContext = (0, import_react26.createContext)(
24050 void 0
24051 );
24052 var ComboboxItemCheckedContext = (0, import_react26.createContext)(false);
24053
24054 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
24055 function createDialogStore(props = {}) {
24056 return createDisclosureStore(props);
24057 }
24058
24059 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
24060 function useDialogStoreProps(store, update2, props) {
24061 return useDisclosureStoreProps(store, update2, props);
24062 }
24063
24064 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
24065 function createPopoverStore({
24066 popover: otherPopover,
24067 ...props
24068 } = {}) {
24069 const store = mergeStore(
24070 props.store,
24071 omit2(otherPopover, [
24072 "arrowElement",
24073 "anchorElement",
24074 "contentElement",
24075 "popoverElement",
24076 "disclosureElement"
24077 ])
24078 );
24079 throwOnConflictingProps(props, store);
24080 const syncState = store == null ? void 0 : store.getState();
24081 const dialog = createDialogStore({ ...props, store });
24082 const placement = defaultValue(
24083 props.placement,
24084 syncState == null ? void 0 : syncState.placement,
24085 "bottom"
24086 );
24087 const initialState = {
24088 ...dialog.getState(),
24089 placement,
24090 currentPlacement: placement,
24091 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
24092 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
24093 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
24094 rendered: /* @__PURE__ */ Symbol("rendered")
24095 };
24096 const popover = createStore(initialState, dialog, store);
24097 return {
24098 ...dialog,
24099 ...popover,
24100 setAnchorElement: (element) => popover.setState("anchorElement", element),
24101 setPopoverElement: (element) => popover.setState("popoverElement", element),
24102 setArrowElement: (element) => popover.setState("arrowElement", element),
24103 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
24104 };
24105 }
24106
24107 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
24108 function usePopoverStoreProps(store, update2, props) {
24109 useUpdateEffect(update2, [props.popover]);
24110 useStoreProps(store, props, "placement");
24111 return useDialogStoreProps(store, update2, props);
24112 }
24113
24114 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
24115 var TagName7 = "div";
24116 var usePopoverAnchor = createHook(
24117 function usePopoverAnchor2({ store, ...props }) {
24118 const context = usePopoverProviderContext();
24119 store = store || context;
24120 props = {
24121 ...props,
24122 ref: useMergeRefs3(store == null ? void 0 : store.setAnchorElement, props.ref)
24123 };
24124 return props;
24125 }
24126 );
24127 var PopoverAnchor = forwardRef210(function PopoverAnchor2(props) {
24128 const htmlProps = usePopoverAnchor(props);
24129 return createElement3(TagName7, htmlProps);
24130 });
24131
24132 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
24133 var import_react27 = __toESM(require_react(), 1);
24134 var TagName8 = "div";
24135 function getMouseDestination(event) {
24136 const relatedTarget = event.relatedTarget;
24137 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
24138 return relatedTarget;
24139 }
24140 return null;
24141 }
24142 function hoveringInside(event) {
24143 const nextElement = getMouseDestination(event);
24144 if (!nextElement) return false;
24145 return contains2(event.currentTarget, nextElement);
24146 }
24147 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
24148 function movingToAnotherItem(event) {
24149 let dest = getMouseDestination(event);
24150 if (!dest) return false;
24151 do {
24152 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
24153 dest = dest.parentElement;
24154 } while (dest);
24155 return false;
24156 }
24157 var useCompositeHover = createHook(
24158 function useCompositeHover2({
24159 store,
24160 focusOnHover = true,
24161 blurOnHoverEnd = !!focusOnHover,
24162 ...props
24163 }) {
24164 const context = useCompositeContext();
24165 store = store || context;
24166 invariant(
24167 store,
24168 "CompositeHover must be wrapped in a Composite component."
24169 );
24170 const isMouseMoving = useIsMouseMoving();
24171 const onMouseMoveProp = props.onMouseMove;
24172 const focusOnHoverProp = useBooleanEvent(focusOnHover);
24173 const onMouseMove = useEvent((event) => {
24174 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
24175 if (event.defaultPrevented) return;
24176 if (!isMouseMoving()) return;
24177 if (!focusOnHoverProp(event)) return;
24178 if (!hasFocusWithin(event.currentTarget)) {
24179 const baseElement = store == null ? void 0 : store.getState().baseElement;
24180 if (baseElement && !hasFocus(baseElement)) {
24181 baseElement.focus();
24182 }
24183 }
24184 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
24185 });
24186 const onMouseLeaveProp = props.onMouseLeave;
24187 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
24188 const onMouseLeave = useEvent((event) => {
24189 var _a;
24190 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
24191 if (event.defaultPrevented) return;
24192 if (!isMouseMoving()) return;
24193 if (hoveringInside(event)) return;
24194 if (movingToAnotherItem(event)) return;
24195 if (!focusOnHoverProp(event)) return;
24196 if (!blurOnHoverEndProp(event)) return;
24197 store == null ? void 0 : store.setActiveId(null);
24198 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
24199 });
24200 const ref = (0, import_react27.useCallback)((element) => {
24201 if (!element) return;
24202 element[symbol2] = true;
24203 }, []);
24204 props = {
24205 ...props,
24206 ref: useMergeRefs3(ref, props.ref),
24207 onMouseMove,
24208 onMouseLeave
24209 };
24210 return removeUndefinedValues(props);
24211 }
24212 );
24213 var CompositeHover = memo22(
24214 forwardRef210(function CompositeHover2(props) {
24215 const htmlProps = useCompositeHover(props);
24216 return createElement3(TagName8, htmlProps);
24217 })
24218 );
24219
24220 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
24221 var import_react28 = __toESM(require_react(), 1);
24222 var TagName9 = "input";
24223 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
24224 if (!autoSelect) return false;
24225 const firstItem = items.find((item) => !item.disabled && item.value);
24226 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
24227 }
24228 function hasCompletionString(value, activeValue) {
24229 if (!activeValue) return false;
24230 if (value == null) return false;
24231 value = normalizeString(value);
24232 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
24233 }
24234 function isInputEvent(event) {
24235 return event.type === "input";
24236 }
24237 function isAriaAutoCompleteValue(value) {
24238 return value === "inline" || value === "list" || value === "both" || value === "none";
24239 }
24240 function getDefaultAutoSelectId(items) {
24241 const item = items.find((item2) => {
24242 var _a;
24243 if (item2.disabled) return false;
24244 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
24245 });
24246 return item == null ? void 0 : item.id;
24247 }
24248 var useCombobox = createHook(
24249 function useCombobox2({
24250 store,
24251 focusable: focusable2 = true,
24252 autoSelect: autoSelectProp = false,
24253 getAutoSelectId,
24254 setValueOnChange,
24255 showMinLength = 0,
24256 showOnChange,
24257 showOnMouseDown,
24258 showOnClick = showOnMouseDown,
24259 showOnKeyDown,
24260 showOnKeyPress = showOnKeyDown,
24261 blurActiveItemOnClick,
24262 setValueOnClick = true,
24263 moveOnKeyPress = true,
24264 autoComplete = "list",
24265 ...props
24266 }) {
24267 const context = useComboboxProviderContext();
24268 store = store || context;
24269 invariant(
24270 store,
24271 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
24272 );
24273 const ref = (0, import_react28.useRef)(null);
24274 const [valueUpdated, forceValueUpdate] = useForceUpdate();
24275 const canAutoSelectRef = (0, import_react28.useRef)(false);
24276 const composingRef = (0, import_react28.useRef)(false);
24277 const autoSelect = store.useState(
24278 (state) => state.virtualFocus && autoSelectProp
24279 );
24280 const inline4 = autoComplete === "inline" || autoComplete === "both";
24281 const [canInline, setCanInline] = (0, import_react28.useState)(inline4);
24282 useUpdateLayoutEffect(() => {
24283 if (!inline4) return;
24284 setCanInline(true);
24285 }, [inline4]);
24286 const storeValue = store.useState("value");
24287 const prevSelectedValueRef = (0, import_react28.useRef)(void 0);
24288 (0, import_react28.useEffect)(() => {
24289 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
24290 prevSelectedValueRef.current = prev.selectedValue;
24291 });
24292 }, []);
24293 const inlineActiveValue = store.useState((state) => {
24294 var _a;
24295 if (!inline4) return;
24296 if (!canInline) return;
24297 if (state.activeValue && Array.isArray(state.selectedValue)) {
24298 if (state.selectedValue.includes(state.activeValue)) return;
24299 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
24300 }
24301 return state.activeValue;
24302 });
24303 const items = store.useState("renderedItems");
24304 const open = store.useState("open");
24305 const contentElement = store.useState("contentElement");
24306 const value = (0, import_react28.useMemo)(() => {
24307 if (!inline4) return storeValue;
24308 if (!canInline) return storeValue;
24309 const firstItemAutoSelected = isFirstItemAutoSelected(
24310 items,
24311 inlineActiveValue,
24312 autoSelect
24313 );
24314 if (firstItemAutoSelected) {
24315 if (hasCompletionString(storeValue, inlineActiveValue)) {
24316 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
24317 return storeValue + slice;
24318 }
24319 return storeValue;
24320 }
24321 return inlineActiveValue || storeValue;
24322 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
24323 (0, import_react28.useEffect)(() => {
24324 const element = ref.current;
24325 if (!element) return;
24326 const onCompositeItemMove = () => setCanInline(true);
24327 element.addEventListener("combobox-item-move", onCompositeItemMove);
24328 return () => {
24329 element.removeEventListener("combobox-item-move", onCompositeItemMove);
24330 };
24331 }, []);
24332 (0, import_react28.useEffect)(() => {
24333 if (!inline4) return;
24334 if (!canInline) return;
24335 if (!inlineActiveValue) return;
24336 const firstItemAutoSelected = isFirstItemAutoSelected(
24337 items,
24338 inlineActiveValue,
24339 autoSelect
24340 );
24341 if (!firstItemAutoSelected) return;
24342 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
24343 let cleanup = noop4;
24344 queueMicrotask(() => {
24345 const element = ref.current;
24346 if (!element) return;
24347 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
24348 const nextStart = storeValue.length;
24349 const nextEnd = inlineActiveValue.length;
24350 setSelectionRange(element, nextStart, nextEnd);
24351 cleanup = () => {
24352 if (!hasFocus(element)) return;
24353 const { start, end } = getTextboxSelection(element);
24354 if (start !== nextStart) return;
24355 if (end !== nextEnd) return;
24356 setSelectionRange(element, prevStart, prevEnd);
24357 };
24358 });
24359 return () => cleanup();
24360 }, [
24361 valueUpdated,
24362 inline4,
24363 canInline,
24364 inlineActiveValue,
24365 items,
24366 autoSelect,
24367 storeValue
24368 ]);
24369 const scrollingElementRef = (0, import_react28.useRef)(null);
24370 const getAutoSelectIdProp = useEvent(getAutoSelectId);
24371 const autoSelectIdRef = (0, import_react28.useRef)(null);
24372 (0, import_react28.useEffect)(() => {
24373 if (!open) return;
24374 if (!contentElement) return;
24375 const scrollingElement = getScrollingElement(contentElement);
24376 if (!scrollingElement) return;
24377 scrollingElementRef.current = scrollingElement;
24378 const onUserScroll = () => {
24379 canAutoSelectRef.current = false;
24380 };
24381 const onScroll = () => {
24382 if (!store) return;
24383 if (!canAutoSelectRef.current) return;
24384 const { activeId } = store.getState();
24385 if (activeId === null) return;
24386 if (activeId === autoSelectIdRef.current) return;
24387 canAutoSelectRef.current = false;
24388 };
24389 const options = { passive: true, capture: true };
24390 scrollingElement.addEventListener("wheel", onUserScroll, options);
24391 scrollingElement.addEventListener("touchmove", onUserScroll, options);
24392 scrollingElement.addEventListener("scroll", onScroll, options);
24393 return () => {
24394 scrollingElement.removeEventListener("wheel", onUserScroll, true);
24395 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
24396 scrollingElement.removeEventListener("scroll", onScroll, true);
24397 };
24398 }, [open, contentElement, store]);
24399 useSafeLayoutEffect(() => {
24400 if (!storeValue) return;
24401 if (composingRef.current) return;
24402 canAutoSelectRef.current = true;
24403 }, [storeValue]);
24404 useSafeLayoutEffect(() => {
24405 if (autoSelect !== "always" && open) return;
24406 canAutoSelectRef.current = open;
24407 }, [autoSelect, open]);
24408 const resetValueOnSelect = store.useState("resetValueOnSelect");
24409 useUpdateEffect(() => {
24410 var _a, _b;
24411 const canAutoSelect = canAutoSelectRef.current;
24412 if (!store) return;
24413 if (!open) return;
24414 if (!canAutoSelect && !resetValueOnSelect) return;
24415 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
24416 if (baseElement && !hasFocus(baseElement)) return;
24417 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
24418 const observer = new MutationObserver(forceValueUpdate);
24419 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
24420 return () => observer.disconnect();
24421 }
24422 if (autoSelect && canAutoSelect) {
24423 const userAutoSelectId = getAutoSelectIdProp(items);
24424 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
24425 autoSelectIdRef.current = autoSelectId;
24426 store.move(autoSelectId != null ? autoSelectId : null);
24427 } else {
24428 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
24429 if (element && "scrollIntoView" in element) {
24430 element.scrollIntoView({ block: "nearest", inline: "nearest" });
24431 }
24432 }
24433 return;
24434 }, [
24435 store,
24436 open,
24437 valueUpdated,
24438 storeValue,
24439 autoSelect,
24440 resetValueOnSelect,
24441 getAutoSelectIdProp,
24442 items
24443 ]);
24444 (0, import_react28.useEffect)(() => {
24445 if (!inline4) return;
24446 const combobox = ref.current;
24447 if (!combobox) return;
24448 const elements = [combobox, contentElement].filter(
24449 (value2) => !!value2
24450 );
24451 const onBlur2 = (event) => {
24452 if (elements.every((el) => isFocusEventOutside(event, el))) {
24453 store == null ? void 0 : store.setValue(value);
24454 }
24455 };
24456 for (const element of elements) {
24457 element.addEventListener("focusout", onBlur2);
24458 }
24459 return () => {
24460 for (const element of elements) {
24461 element.removeEventListener("focusout", onBlur2);
24462 }
24463 };
24464 }, [inline4, contentElement, store, value]);
24465 const canShow = (event) => {
24466 const currentTarget = event.currentTarget;
24467 return currentTarget.value.length >= showMinLength;
24468 };
24469 const onChangeProp = props.onChange;
24470 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
24471 const setValueOnChangeProp = useBooleanEvent(
24472 // If the combobox is combined with tags, the value will be set by the tag
24473 // input component.
24474 setValueOnChange != null ? setValueOnChange : !store.tag
24475 );
24476 const onChange = useEvent((event) => {
24477 onChangeProp == null ? void 0 : onChangeProp(event);
24478 if (event.defaultPrevented) return;
24479 if (!store) return;
24480 const currentTarget = event.currentTarget;
24481 const { value: value2, selectionStart, selectionEnd } = currentTarget;
24482 const nativeEvent = event.nativeEvent;
24483 canAutoSelectRef.current = true;
24484 if (isInputEvent(nativeEvent)) {
24485 if (nativeEvent.isComposing) {
24486 canAutoSelectRef.current = false;
24487 composingRef.current = true;
24488 }
24489 if (inline4) {
24490 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
24491 const caretAtEnd = selectionStart === value2.length;
24492 setCanInline(textInserted && caretAtEnd);
24493 }
24494 }
24495 if (setValueOnChangeProp(event)) {
24496 const isSameValue = value2 === store.getState().value;
24497 store.setValue(value2);
24498 queueMicrotask(() => {
24499 setSelectionRange(currentTarget, selectionStart, selectionEnd);
24500 });
24501 if (inline4 && autoSelect && isSameValue) {
24502 forceValueUpdate();
24503 }
24504 }
24505 if (showOnChangeProp(event)) {
24506 store.show();
24507 }
24508 if (!autoSelect || !canAutoSelectRef.current) {
24509 store.setActiveId(null);
24510 }
24511 });
24512 const onCompositionEndProp = props.onCompositionEnd;
24513 const onCompositionEnd = useEvent((event) => {
24514 canAutoSelectRef.current = true;
24515 composingRef.current = false;
24516 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
24517 if (event.defaultPrevented) return;
24518 if (!autoSelect) return;
24519 forceValueUpdate();
24520 });
24521 const onMouseDownProp = props.onMouseDown;
24522 const blurActiveItemOnClickProp = useBooleanEvent(
24523 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
24524 );
24525 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
24526 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
24527 const onMouseDown = useEvent((event) => {
24528 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
24529 if (event.defaultPrevented) return;
24530 if (event.button) return;
24531 if (event.ctrlKey) return;
24532 if (!store) return;
24533 if (blurActiveItemOnClickProp(event)) {
24534 store.setActiveId(null);
24535 }
24536 if (setValueOnClickProp(event)) {
24537 store.setValue(value);
24538 }
24539 if (showOnClickProp(event)) {
24540 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
24541 }
24542 });
24543 const onKeyDownProp = props.onKeyDown;
24544 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
24545 const onKeyDown = useEvent((event) => {
24546 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
24547 if (!event.repeat) {
24548 canAutoSelectRef.current = false;
24549 }
24550 if (event.defaultPrevented) return;
24551 if (event.ctrlKey) return;
24552 if (event.altKey) return;
24553 if (event.shiftKey) return;
24554 if (event.metaKey) return;
24555 if (!store) return;
24556 const { open: open2 } = store.getState();
24557 if (open2) return;
24558 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
24559 if (showOnKeyPressProp(event)) {
24560 event.preventDefault();
24561 store.show();
24562 }
24563 }
24564 });
24565 const onBlurProp = props.onBlur;
24566 const onBlur = useEvent((event) => {
24567 canAutoSelectRef.current = false;
24568 onBlurProp == null ? void 0 : onBlurProp(event);
24569 if (event.defaultPrevented) return;
24570 });
24571 const id = useId5(props.id);
24572 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
24573 const isActiveItem = store.useState((state) => state.activeId === null);
24574 props = {
24575 id,
24576 role: "combobox",
24577 "aria-autocomplete": ariaAutoComplete,
24578 "aria-haspopup": getPopupRole(contentElement, "listbox"),
24579 "aria-expanded": open,
24580 "aria-controls": contentElement == null ? void 0 : contentElement.id,
24581 "data-active-item": isActiveItem || void 0,
24582 value,
24583 ...props,
24584 ref: useMergeRefs3(ref, props.ref),
24585 onChange,
24586 onCompositionEnd,
24587 onMouseDown,
24588 onKeyDown,
24589 onBlur
24590 };
24591 props = useComposite({
24592 store,
24593 focusable: focusable2,
24594 ...props,
24595 // Enable inline autocomplete when the user moves from the combobox input
24596 // to an item.
24597 moveOnKeyPress: (event) => {
24598 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
24599 if (inline4) setCanInline(true);
24600 return true;
24601 }
24602 });
24603 props = usePopoverAnchor({ store, ...props });
24604 return { autoComplete: "off", ...props };
24605 }
24606 );
24607 var Combobox = forwardRef210(function Combobox2(props) {
24608 const htmlProps = useCombobox(props);
24609 return createElement3(TagName9, htmlProps);
24610 });
24611
24612 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
24613 var import_react29 = __toESM(require_react(), 1);
24614 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
24615 var TagName10 = "div";
24616 function isSelected(storeValue, itemValue) {
24617 if (itemValue == null) return;
24618 if (storeValue == null) return false;
24619 if (Array.isArray(storeValue)) {
24620 return storeValue.includes(itemValue);
24621 }
24622 return storeValue === itemValue;
24623 }
24624 function getItemRole(popupRole) {
24625 var _a;
24626 const itemRoleByPopupRole = {
24627 menu: "menuitem",
24628 listbox: "option",
24629 tree: "treeitem"
24630 };
24631 const key = popupRole;
24632 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
24633 }
24634 var useComboboxItem = createHook(
24635 function useComboboxItem2({
24636 store,
24637 value,
24638 hideOnClick,
24639 setValueOnClick,
24640 selectValueOnClick = true,
24641 resetValueOnSelect,
24642 focusOnHover = false,
24643 moveOnKeyPress = true,
24644 getItem: getItemProp,
24645 ...props
24646 }) {
24647 var _a;
24648 const context = useComboboxScopedContext();
24649 store = store || context;
24650 invariant(
24651 store,
24652 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
24653 );
24654 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
24655 resetValueOnSelectState: "resetValueOnSelect",
24656 multiSelectable(state) {
24657 return Array.isArray(state.selectedValue);
24658 },
24659 selected(state) {
24660 return isSelected(state.selectedValue, value);
24661 }
24662 });
24663 const getItem = (0, import_react29.useCallback)(
24664 (item) => {
24665 const nextItem = { ...item, value };
24666 if (getItemProp) {
24667 return getItemProp(nextItem);
24668 }
24669 return nextItem;
24670 },
24671 [value, getItemProp]
24672 );
24673 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
24674 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
24675 const onClickProp = props.onClick;
24676 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
24677 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
24678 const resetValueOnSelectProp = useBooleanEvent(
24679 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
24680 );
24681 const hideOnClickProp = useBooleanEvent(hideOnClick);
24682 const onClick = useEvent((event) => {
24683 onClickProp == null ? void 0 : onClickProp(event);
24684 if (event.defaultPrevented) return;
24685 if (isDownloading(event)) return;
24686 if (isOpeningInNewTab(event)) return;
24687 if (value != null) {
24688 if (selectValueOnClickProp(event)) {
24689 if (resetValueOnSelectProp(event)) {
24690 store == null ? void 0 : store.resetValue();
24691 }
24692 store == null ? void 0 : store.setSelectedValue((prevValue) => {
24693 if (!Array.isArray(prevValue)) return value;
24694 if (prevValue.includes(value)) {
24695 return prevValue.filter((v2) => v2 !== value);
24696 }
24697 return [...prevValue, value];
24698 });
24699 }
24700 if (setValueOnClickProp(event)) {
24701 store == null ? void 0 : store.setValue(value);
24702 }
24703 }
24704 if (hideOnClickProp(event)) {
24705 store == null ? void 0 : store.hide();
24706 }
24707 });
24708 const onKeyDownProp = props.onKeyDown;
24709 const onKeyDown = useEvent((event) => {
24710 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
24711 if (event.defaultPrevented) return;
24712 const baseElement = store == null ? void 0 : store.getState().baseElement;
24713 if (!baseElement) return;
24714 if (hasFocus(baseElement)) return;
24715 const printable = event.key.length === 1;
24716 if (printable || event.key === "Backspace" || event.key === "Delete") {
24717 queueMicrotask(() => baseElement.focus());
24718 if (isTextField(baseElement)) {
24719 store == null ? void 0 : store.setValue(baseElement.value);
24720 }
24721 }
24722 });
24723 if (multiSelectable && selected != null) {
24724 props = {
24725 "aria-selected": selected,
24726 ...props
24727 };
24728 }
24729 props = useWrapElement(
24730 props,
24731 (element) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
24732 [value, selected]
24733 );
24734 const popupRole = (0, import_react29.useContext)(ComboboxListRoleContext);
24735 props = {
24736 role: getItemRole(popupRole),
24737 children: value,
24738 ...props,
24739 onClick,
24740 onKeyDown
24741 };
24742 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
24743 props = useCompositeItem({
24744 store,
24745 ...props,
24746 getItem,
24747 // Dispatch a custom event on the combobox input when moving to an item
24748 // with the keyboard so the Combobox component can enable inline
24749 // autocompletion.
24750 moveOnKeyPress: (event) => {
24751 if (!moveOnKeyPressProp(event)) return false;
24752 const moveEvent = new Event("combobox-item-move");
24753 const baseElement = store == null ? void 0 : store.getState().baseElement;
24754 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
24755 return true;
24756 }
24757 });
24758 props = useCompositeHover({ store, focusOnHover, ...props });
24759 return props;
24760 }
24761 );
24762 var ComboboxItem = memo22(
24763 forwardRef210(function ComboboxItem2(props) {
24764 const htmlProps = useComboboxItem(props);
24765 return createElement3(TagName10, htmlProps);
24766 })
24767 );
24768
24769 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
24770 var import_react30 = __toESM(require_react(), 1);
24771 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
24772 var TagName11 = "span";
24773 function normalizeValue(value) {
24774 return normalizeString(value).toLowerCase();
24775 }
24776 function getOffsets(string, values) {
24777 const offsets = [];
24778 for (const value of values) {
24779 let pos = 0;
24780 const length = value.length;
24781 while (string.indexOf(value, pos) !== -1) {
24782 const index2 = string.indexOf(value, pos);
24783 if (index2 !== -1) {
24784 offsets.push([index2, length]);
24785 }
24786 pos = index2 + 1;
24787 }
24788 }
24789 return offsets;
24790 }
24791 function filterOverlappingOffsets(offsets) {
24792 return offsets.filter(([offset4, length], i2, arr) => {
24793 return !arr.some(
24794 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
24795 );
24796 });
24797 }
24798 function sortOffsets(offsets) {
24799 return offsets.sort(([a2], [b2]) => a2 - b2);
24800 }
24801 function splitValue(itemValue, userValue) {
24802 if (!itemValue) return itemValue;
24803 if (!userValue) return itemValue;
24804 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
24805 const parts = [];
24806 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
24807 "span",
24808 {
24809 "data-autocomplete-value": autocomplete ? "" : void 0,
24810 "data-user-value": autocomplete ? void 0 : "",
24811 children: value
24812 },
24813 parts.length
24814 );
24815 const offsets = sortOffsets(
24816 filterOverlappingOffsets(
24817 // Convert userValues into a set to avoid duplicates
24818 getOffsets(normalizeValue(itemValue), new Set(userValues))
24819 )
24820 );
24821 if (!offsets.length) {
24822 parts.push(span(itemValue, true));
24823 return parts;
24824 }
24825 const [firstOffset] = offsets[0];
24826 const values = [
24827 itemValue.slice(0, firstOffset),
24828 ...offsets.flatMap(([offset4, length], i2) => {
24829 var _a;
24830 const value = itemValue.slice(offset4, offset4 + length);
24831 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
24832 const nextValue = itemValue.slice(offset4 + length, nextOffset);
24833 return [value, nextValue];
24834 })
24835 ];
24836 values.forEach((value, i2) => {
24837 if (!value) return;
24838 parts.push(span(value, i2 % 2 === 0));
24839 });
24840 return parts;
24841 }
24842 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
24843 const context = useComboboxScopedContext();
24844 store = store || context;
24845 const itemContext = (0, import_react30.useContext)(ComboboxItemValueContext);
24846 const itemValue = value != null ? value : itemContext;
24847 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
24848 const children = (0, import_react30.useMemo)(() => {
24849 if (!itemValue) return;
24850 if (!inputValue) return itemValue;
24851 return splitValue(itemValue, inputValue);
24852 }, [itemValue, inputValue]);
24853 props = {
24854 children,
24855 ...props
24856 };
24857 return removeUndefinedValues(props);
24858 });
24859 var ComboboxItemValue = forwardRef210(function ComboboxItemValue2(props) {
24860 const htmlProps = useComboboxItemValue(props);
24861 return createElement3(TagName11, htmlProps);
24862 });
24863
24864 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
24865 var TagName12 = "label";
24866 var useComboboxLabel = createHook(
24867 function useComboboxLabel2({ store, ...props }) {
24868 const context = useComboboxProviderContext();
24869 store = store || context;
24870 invariant(
24871 store,
24872 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
24873 );
24874 const comboboxId = store.useState((state) => {
24875 var _a;
24876 return (_a = state.baseElement) == null ? void 0 : _a.id;
24877 });
24878 props = {
24879 htmlFor: comboboxId,
24880 ...props
24881 };
24882 return removeUndefinedValues(props);
24883 }
24884 );
24885 var ComboboxLabel = memo22(
24886 forwardRef210(function ComboboxLabel2(props) {
24887 const htmlProps = useComboboxLabel(props);
24888 return createElement3(TagName12, htmlProps);
24889 })
24890 );
24891
24892 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
24893 var import_react31 = __toESM(require_react(), 1);
24894 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
24895 var TagName13 = "div";
24896 var useComboboxList = createHook(
24897 function useComboboxList2({ store, alwaysVisible, ...props }) {
24898 const scopedContext = useComboboxScopedContext(true);
24899 const context = useComboboxContext();
24900 store = store || context;
24901 const scopedContextSameStore = !!store && store === scopedContext;
24902 invariant(
24903 store,
24904 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
24905 );
24906 const ref = (0, import_react31.useRef)(null);
24907 const id = useId5(props.id);
24908 const mounted = store.useState("mounted");
24909 const hidden = isHidden3(mounted, props.hidden, alwaysVisible);
24910 const style = hidden ? { ...props.style, display: "none" } : props.style;
24911 const multiSelectable = store.useState(
24912 (state) => Array.isArray(state.selectedValue)
24913 );
24914 const role = useAttribute(ref, "role", props.role);
24915 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
24916 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
24917 const [hasListboxInside, setHasListboxInside] = (0, import_react31.useState)(false);
24918 const contentElement = store.useState("contentElement");
24919 useSafeLayoutEffect(() => {
24920 if (!mounted) return;
24921 const element = ref.current;
24922 if (!element) return;
24923 if (contentElement !== element) return;
24924 const callback = () => {
24925 setHasListboxInside(!!element.querySelector("[role='listbox']"));
24926 };
24927 const observer = new MutationObserver(callback);
24928 observer.observe(element, {
24929 subtree: true,
24930 childList: true,
24931 attributeFilter: ["role"]
24932 });
24933 callback();
24934 return () => observer.disconnect();
24935 }, [mounted, contentElement]);
24936 if (!hasListboxInside) {
24937 props = {
24938 role: "listbox",
24939 "aria-multiselectable": ariaMultiSelectable,
24940 ...props
24941 };
24942 }
24943 props = useWrapElement(
24944 props,
24945 (element) => /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
24946 [store, role]
24947 );
24948 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
24949 props = {
24950 id,
24951 hidden,
24952 ...props,
24953 ref: useMergeRefs3(setContentElement, ref, props.ref),
24954 style
24955 };
24956 return removeUndefinedValues(props);
24957 }
24958 );
24959 var ComboboxList = forwardRef210(function ComboboxList2(props) {
24960 const htmlProps = useComboboxList(props);
24961 return createElement3(TagName13, htmlProps);
24962 });
24963
24964 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
24965 var import_react32 = __toESM(require_react(), 1);
24966 var TagValueContext = (0, import_react32.createContext)(null);
24967 var TagRemoveIdContext = (0, import_react32.createContext)(
24968 null
24969 );
24970 var ctx7 = createStoreContext(
24971 [CompositeContextProvider],
24972 [CompositeScopedContextProvider]
24973 );
24974 var useTagContext = ctx7.useContext;
24975 var useTagScopedContext = ctx7.useScopedContext;
24976 var useTagProviderContext = ctx7.useProviderContext;
24977 var TagContextProvider = ctx7.ContextProvider;
24978 var TagScopedContextProvider = ctx7.ScopedContextProvider;
24979
24980 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
24981 var isTouchSafari = isSafari2() && isTouchDevice();
24982 function createComboboxStore({
24983 tag,
24984 ...props
24985 } = {}) {
24986 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
24987 throwOnConflictingProps(props, store);
24988 const tagState = tag == null ? void 0 : tag.getState();
24989 const syncState = store == null ? void 0 : store.getState();
24990 const activeId = defaultValue(
24991 props.activeId,
24992 syncState == null ? void 0 : syncState.activeId,
24993 props.defaultActiveId,
24994 null
24995 );
24996 const composite = createCompositeStore({
24997 ...props,
24998 activeId,
24999 includesBaseElement: defaultValue(
25000 props.includesBaseElement,
25001 syncState == null ? void 0 : syncState.includesBaseElement,
25002 true
25003 ),
25004 orientation: defaultValue(
25005 props.orientation,
25006 syncState == null ? void 0 : syncState.orientation,
25007 "vertical"
25008 ),
25009 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
25010 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
25011 virtualFocus: defaultValue(
25012 props.virtualFocus,
25013 syncState == null ? void 0 : syncState.virtualFocus,
25014 true
25015 )
25016 });
25017 const popover = createPopoverStore({
25018 ...props,
25019 placement: defaultValue(
25020 props.placement,
25021 syncState == null ? void 0 : syncState.placement,
25022 "bottom-start"
25023 )
25024 });
25025 const value = defaultValue(
25026 props.value,
25027 syncState == null ? void 0 : syncState.value,
25028 props.defaultValue,
25029 ""
25030 );
25031 const selectedValue = defaultValue(
25032 props.selectedValue,
25033 syncState == null ? void 0 : syncState.selectedValue,
25034 tagState == null ? void 0 : tagState.values,
25035 props.defaultSelectedValue,
25036 ""
25037 );
25038 const multiSelectable = Array.isArray(selectedValue);
25039 const initialState = {
25040 ...composite.getState(),
25041 ...popover.getState(),
25042 value,
25043 selectedValue,
25044 resetValueOnSelect: defaultValue(
25045 props.resetValueOnSelect,
25046 syncState == null ? void 0 : syncState.resetValueOnSelect,
25047 multiSelectable
25048 ),
25049 resetValueOnHide: defaultValue(
25050 props.resetValueOnHide,
25051 syncState == null ? void 0 : syncState.resetValueOnHide,
25052 multiSelectable && !tag
25053 ),
25054 activeValue: syncState == null ? void 0 : syncState.activeValue
25055 };
25056 const combobox = createStore(initialState, composite, popover, store);
25057 if (isTouchSafari) {
25058 setup(
25059 combobox,
25060 () => sync(combobox, ["virtualFocus"], () => {
25061 combobox.setState("virtualFocus", false);
25062 })
25063 );
25064 }
25065 setup(combobox, () => {
25066 if (!tag) return;
25067 return chain(
25068 sync(combobox, ["selectedValue"], (state) => {
25069 if (!Array.isArray(state.selectedValue)) return;
25070 tag.setValues(state.selectedValue);
25071 }),
25072 sync(tag, ["values"], (state) => {
25073 combobox.setState("selectedValue", state.values);
25074 })
25075 );
25076 });
25077 setup(
25078 combobox,
25079 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
25080 if (!state.resetValueOnHide) return;
25081 if (state.mounted) return;
25082 combobox.setState("value", value);
25083 })
25084 );
25085 setup(
25086 combobox,
25087 () => sync(combobox, ["open"], (state) => {
25088 if (state.open) return;
25089 combobox.setState("activeId", activeId);
25090 combobox.setState("moves", 0);
25091 })
25092 );
25093 setup(
25094 combobox,
25095 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
25096 if (state.moves === prevState.moves) {
25097 combobox.setState("activeValue", void 0);
25098 }
25099 })
25100 );
25101 setup(
25102 combobox,
25103 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
25104 if (state.moves === prev.moves) return;
25105 const { activeId: activeId2 } = combobox.getState();
25106 const activeItem = composite.item(activeId2);
25107 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
25108 })
25109 );
25110 return {
25111 ...popover,
25112 ...composite,
25113 ...combobox,
25114 tag,
25115 setValue: (value2) => combobox.setState("value", value2),
25116 resetValue: () => combobox.setState("value", initialState.value),
25117 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
25118 };
25119 }
25120
25121 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
25122 function useComboboxStoreOptions(props) {
25123 const tag = useTagContext();
25124 props = {
25125 ...props,
25126 tag: props.tag !== void 0 ? props.tag : tag
25127 };
25128 return useCompositeStoreOptions(props);
25129 }
25130 function useComboboxStoreProps(store, update2, props) {
25131 useUpdateEffect(update2, [props.tag]);
25132 useStoreProps(store, props, "value", "setValue");
25133 useStoreProps(store, props, "selectedValue", "setSelectedValue");
25134 useStoreProps(store, props, "resetValueOnHide");
25135 useStoreProps(store, props, "resetValueOnSelect");
25136 return Object.assign(
25137 useCompositeStoreProps(
25138 usePopoverStoreProps(store, update2, props),
25139 update2,
25140 props
25141 ),
25142 { tag: props.tag }
25143 );
25144 }
25145 function useComboboxStore(props = {}) {
25146 props = useComboboxStoreOptions(props);
25147 const [store, update2] = useStore2(createComboboxStore, props);
25148 return useComboboxStoreProps(store, update2, props);
25149 }
25150
25151 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
25152 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
25153 function ComboboxProvider(props = {}) {
25154 const store = useComboboxStore(props);
25155 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ComboboxContextProvider, { value: store, children: props.children });
25156 }
25157
25158 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
25159 var import_remove_accents = __toESM(require_remove_accents(), 1);
25160 var import_compose9 = __toESM(require_compose(), 1);
25161 var import_i18n27 = __toESM(require_i18n(), 1);
25162 var import_element80 = __toESM(require_element(), 1);
25163 var import_components20 = __toESM(require_components(), 1);
25164
25165 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
25166 var EMPTY_ARRAY3 = [];
25167 var getCurrentValue = (filterDefinition, currentFilter) => {
25168 if (filterDefinition.singleSelection) {
25169 return currentFilter?.value;
25170 }
25171 if (Array.isArray(currentFilter?.value)) {
25172 return currentFilter.value;
25173 }
25174 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
25175 return [currentFilter.value];
25176 }
25177 return EMPTY_ARRAY3;
25178 };
25179
25180 // packages/dataviews/build-module/hooks/use-elements.mjs
25181 var import_element79 = __toESM(require_element(), 1);
25182 var EMPTY_ARRAY4 = [];
25183 function useElements({
25184 elements,
25185 getElements
25186 }) {
25187 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
25188 const [records, setRecords] = (0, import_element79.useState)(staticElements);
25189 const [isLoading, setIsLoading] = (0, import_element79.useState)(false);
25190 (0, import_element79.useEffect)(() => {
25191 if (!getElements) {
25192 setRecords(staticElements);
25193 return;
25194 }
25195 let cancelled = false;
25196 setIsLoading(true);
25197 getElements().then((fetchedElements) => {
25198 if (!cancelled) {
25199 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
25200 setRecords(dynamicElements);
25201 }
25202 }).catch(() => {
25203 if (!cancelled) {
25204 setRecords(staticElements);
25205 }
25206 }).finally(() => {
25207 if (!cancelled) {
25208 setIsLoading(false);
25209 }
25210 });
25211 return () => {
25212 cancelled = true;
25213 };
25214 }, [getElements, staticElements]);
25215 return {
25216 elements: records,
25217 isLoading
25218 };
25219 }
25220
25221 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
25222 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
25223 function normalizeSearchInput(input = "") {
25224 return (0, import_remove_accents.default)(input.trim().toLowerCase());
25225 }
25226 var getNewValue = (filterDefinition, currentFilter, value) => {
25227 if (filterDefinition.singleSelection) {
25228 return value;
25229 }
25230 if (Array.isArray(currentFilter?.value)) {
25231 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
25232 }
25233 return [value];
25234 };
25235 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
25236 return `${prefix}-${filterElementValue}`;
25237 }
25238 var MultiSelectionOption = ({ selected }) => {
25239 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25240 "span",
25241 {
25242 className: clsx_default(
25243 "dataviews-filters__search-widget-listitem-multi-selection",
25244 { "is-selected": selected }
25245 ),
25246 children: selected && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components20.Icon, { icon: check_default })
25247 }
25248 );
25249 };
25250 var SingleSelectionOption = ({ selected }) => {
25251 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25252 "span",
25253 {
25254 className: clsx_default(
25255 "dataviews-filters__search-widget-listitem-single-selection",
25256 { "is-selected": selected }
25257 )
25258 }
25259 );
25260 };
25261 function ListBox({ view, filter, onChangeView }) {
25262 const baseId = (0, import_compose9.useInstanceId)(ListBox, "dataviews-filter-list-box");
25263 const [activeCompositeId, setActiveCompositeId] = (0, import_element80.useState)(
25264 // When there are one or less operators, the first item is set as active
25265 // (by setting the initial `activeId` to `undefined`).
25266 // With 2 or more operators, the focus is moved on the operators control
25267 // (by setting the initial `activeId` to `null`), meaning that there won't
25268 // be an active item initially. Focus is then managed via the
25269 // `onFocusVisible` callback.
25270 filter.operators?.length === 1 ? void 0 : null
25271 );
25272 const currentFilter = view.filters?.find(
25273 (f2) => f2.field === filter.field
25274 );
25275 const currentValue = getCurrentValue(filter, currentFilter);
25276 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25277 import_components20.Composite,
25278 {
25279 virtualFocus: true,
25280 focusLoop: true,
25281 activeId: activeCompositeId,
25282 setActiveId: setActiveCompositeId,
25283 role: "listbox",
25284 className: "dataviews-filters__search-widget-listbox",
25285 "aria-label": (0, import_i18n27.sprintf)(
25286 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
25287 (0, import_i18n27.__)("List of: %1$s"),
25288 filter.name
25289 ),
25290 onFocusVisible: () => {
25291 if (!activeCompositeId && filter.elements.length) {
25292 setActiveCompositeId(
25293 generateFilterElementCompositeItemId(
25294 baseId,
25295 filter.elements[0].value
25296 )
25297 );
25298 }
25299 },
25300 render: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components20.Composite.Typeahead, {}),
25301 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
25302 import_components20.Composite.Hover,
25303 {
25304 render: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25305 import_components20.Composite.Item,
25306 {
25307 id: generateFilterElementCompositeItemId(
25308 baseId,
25309 element.value
25310 ),
25311 render: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25312 "div",
25313 {
25314 "aria-label": element.label,
25315 role: "option",
25316 className: "dataviews-filters__search-widget-listitem"
25317 }
25318 ),
25319 onClick: () => {
25320 const newFilters = currentFilter ? [
25321 ...(view.filters ?? []).map(
25322 (_filter) => {
25323 if (_filter.field === filter.field) {
25324 return {
25325 ..._filter,
25326 operator: currentFilter.operator || filter.operators[0],
25327 value: getNewValue(
25328 filter,
25329 currentFilter,
25330 element.value
25331 )
25332 };
25333 }
25334 return _filter;
25335 }
25336 )
25337 ] : [
25338 ...view.filters ?? [],
25339 {
25340 field: filter.field,
25341 operator: filter.operators[0],
25342 value: getNewValue(
25343 filter,
25344 currentFilter,
25345 element.value
25346 )
25347 }
25348 ];
25349 onChangeView({
25350 ...view,
25351 page: 1,
25352 filters: newFilters
25353 });
25354 }
25355 }
25356 ),
25357 children: [
25358 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25359 SingleSelectionOption,
25360 {
25361 selected: currentValue === element.value
25362 }
25363 ),
25364 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25365 MultiSelectionOption,
25366 {
25367 selected: currentValue.includes(element.value)
25368 }
25369 ),
25370 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25371 "span",
25372 {
25373 className: "dataviews-filters__search-widget-listitem-value",
25374 title: element.label,
25375 children: element.label
25376 }
25377 )
25378 ]
25379 },
25380 element.value
25381 ))
25382 }
25383 );
25384 }
25385 function ComboboxList22({ view, filter, onChangeView }) {
25386 const [searchValue, setSearchValue] = (0, import_element80.useState)("");
25387 const deferredSearchValue = (0, import_element80.useDeferredValue)(searchValue);
25388 const currentFilter = view.filters?.find(
25389 (_filter) => _filter.field === filter.field
25390 );
25391 const currentValue = getCurrentValue(filter, currentFilter);
25392 const matches2 = (0, import_element80.useMemo)(() => {
25393 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
25394 return filter.elements.filter(
25395 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
25396 );
25397 }, [filter.elements, deferredSearchValue]);
25398 return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
25399 ComboboxProvider,
25400 {
25401 selectedValue: currentValue,
25402 setSelectedValue: (value) => {
25403 const newFilters = currentFilter ? [
25404 ...(view.filters ?? []).map((_filter) => {
25405 if (_filter.field === filter.field) {
25406 return {
25407 ..._filter,
25408 operator: currentFilter.operator || filter.operators[0],
25409 value
25410 };
25411 }
25412 return _filter;
25413 })
25414 ] : [
25415 ...view.filters ?? [],
25416 {
25417 field: filter.field,
25418 operator: filter.operators[0],
25419 value
25420 }
25421 ];
25422 onChangeView({
25423 ...view,
25424 page: 1,
25425 filters: newFilters
25426 });
25427 },
25428 setValue: setSearchValue,
25429 children: [
25430 /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
25431 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(ComboboxLabel, {}), children: (0, import_i18n27.__)("Search items") }),
25432 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25433 Combobox,
25434 {
25435 autoSelect: "always",
25436 placeholder: (0, import_i18n27.__)("Search"),
25437 className: "dataviews-filters__search-widget-filter-combobox__input"
25438 }
25439 ),
25440 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components20.Icon, { icon: search_default }) })
25441 ] }),
25442 /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
25443 ComboboxList,
25444 {
25445 className: "dataviews-filters__search-widget-filter-combobox-list",
25446 alwaysVisible: true,
25447 children: [
25448 matches2.map((element) => {
25449 return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
25450 ComboboxItem,
25451 {
25452 resetValueOnSelect: false,
25453 value: element.value,
25454 className: "dataviews-filters__search-widget-listitem",
25455 hideOnClick: false,
25456 setValueOnClick: false,
25457 focusOnHover: true,
25458 children: [
25459 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25460 SingleSelectionOption,
25461 {
25462 selected: currentValue === element.value
25463 }
25464 ),
25465 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25466 MultiSelectionOption,
25467 {
25468 selected: currentValue.includes(
25469 element.value
25470 )
25471 }
25472 ),
25473 /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
25474 "span",
25475 {
25476 className: "dataviews-filters__search-widget-listitem-value",
25477 title: element.label,
25478 children: [
25479 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
25480 ComboboxItemValue,
25481 {
25482 className: "dataviews-filters__search-widget-filter-combobox-item-value",
25483 value: element.label
25484 }
25485 ),
25486 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
25487 ]
25488 }
25489 )
25490 ]
25491 },
25492 element.value
25493 );
25494 }),
25495 !matches2.length && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("p", { children: (0, import_i18n27.__)("No results found") })
25496 ]
25497 }
25498 )
25499 ]
25500 }
25501 );
25502 }
25503 function SearchWidget(props) {
25504 const { elements, isLoading } = useElements({
25505 elements: props.filter.elements,
25506 getElements: props.filter.getElements
25507 });
25508 if (isLoading) {
25509 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components20.Spinner, {}) });
25510 }
25511 if (elements.length === 0) {
25512 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n27.__)("No elements found") });
25513 }
25514 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
25515 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
25516 }
25517
25518 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
25519 var import_es6 = __toESM(require_es6(), 1);
25520 var import_compose10 = __toESM(require_compose(), 1);
25521 var import_element81 = __toESM(require_element(), 1);
25522 var import_components21 = __toESM(require_components(), 1);
25523 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
25524 function InputWidget({
25525 filter,
25526 view,
25527 onChangeView,
25528 fields
25529 }) {
25530 const currentFilter = view.filters?.find(
25531 (f2) => f2.field === filter.field
25532 );
25533 const currentValue = getCurrentValue(filter, currentFilter);
25534 const field = (0, import_element81.useMemo)(() => {
25535 const currentField = fields.find((f2) => f2.id === filter.field);
25536 if (currentField) {
25537 return {
25538 ...currentField,
25539 // Deactivate validation for filters.
25540 isValid: {},
25541 // Filter controls are always enabled.
25542 isDisabled: () => false,
25543 // Filter controls are always visible.
25544 isVisible: () => true,
25545 // Configure getValue/setValue as if Item was a plain object.
25546 getValue: ({ item }) => item[currentField.id],
25547 setValue: ({ value }) => ({
25548 [currentField.id]: value
25549 })
25550 };
25551 }
25552 return currentField;
25553 }, [fields, filter.field]);
25554 const data = (0, import_element81.useMemo)(() => {
25555 return (view.filters ?? []).reduce(
25556 (acc, activeFilter) => {
25557 acc[activeFilter.field] = activeFilter.value;
25558 return acc;
25559 },
25560 {}
25561 );
25562 }, [view.filters]);
25563 const handleChange = (0, import_compose10.useEvent)((updatedData) => {
25564 if (!field || !currentFilter) {
25565 return;
25566 }
25567 const nextValue = field.getValue({ item: updatedData });
25568 if ((0, import_es6.default)(nextValue, currentValue)) {
25569 return;
25570 }
25571 onChangeView({
25572 ...view,
25573 filters: (view.filters ?? []).map(
25574 (_filter) => _filter.field === filter.field ? {
25575 ..._filter,
25576 operator: currentFilter.operator || filter.operators[0],
25577 // Consider empty strings as undefined:
25578 //
25579 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
25580 // - empty string as value means "search empty string": returns only the records that have an empty string as value
25581 //
25582 // In practice, this means the filter will not be able to find an empty string as the value.
25583 value: nextValue === "" ? void 0 : nextValue
25584 } : _filter
25585 )
25586 });
25587 });
25588 if (!field || !field.Edit || !currentFilter) {
25589 return null;
25590 }
25591 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25592 import_components21.Flex,
25593 {
25594 className: "dataviews-filters__user-input-widget",
25595 gap: 2.5,
25596 direction: "column",
25597 children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
25598 field.Edit,
25599 {
25600 hideLabelFromVision: true,
25601 data,
25602 field,
25603 operator: currentFilter.operator,
25604 onChange: handleChange
25605 }
25606 )
25607 }
25608 );
25609 }
25610
25611 // node_modules/date-fns/constants.js
25612 var daysInYear = 365.2425;
25613 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
25614 var minTime = -maxTime;
25615 var millisecondsInWeek = 6048e5;
25616 var millisecondsInDay = 864e5;
25617 var secondsInHour = 3600;
25618 var secondsInDay = secondsInHour * 24;
25619 var secondsInWeek = secondsInDay * 7;
25620 var secondsInYear = secondsInDay * daysInYear;
25621 var secondsInMonth = secondsInYear / 12;
25622 var secondsInQuarter = secondsInMonth * 3;
25623 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
25624
25625 // node_modules/date-fns/constructFrom.js
25626 function constructFrom(date, value) {
25627 if (typeof date === "function") return date(value);
25628 if (date && typeof date === "object" && constructFromSymbol in date)
25629 return date[constructFromSymbol](value);
25630 if (date instanceof Date) return new date.constructor(value);
25631 return new Date(value);
25632 }
25633
25634 // node_modules/date-fns/toDate.js
25635 function toDate(argument, context) {
25636 return constructFrom(context || argument, argument);
25637 }
25638
25639 // node_modules/date-fns/addDays.js
25640 function addDays(date, amount, options) {
25641 const _date = toDate(date, options?.in);
25642 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
25643 if (!amount) return _date;
25644 _date.setDate(_date.getDate() + amount);
25645 return _date;
25646 }
25647
25648 // node_modules/date-fns/addMonths.js
25649 function addMonths(date, amount, options) {
25650 const _date = toDate(date, options?.in);
25651 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
25652 if (!amount) {
25653 return _date;
25654 }
25655 const dayOfMonth = _date.getDate();
25656 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
25657 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
25658 const daysInMonth = endOfDesiredMonth.getDate();
25659 if (dayOfMonth >= daysInMonth) {
25660 return endOfDesiredMonth;
25661 } else {
25662 _date.setFullYear(
25663 endOfDesiredMonth.getFullYear(),
25664 endOfDesiredMonth.getMonth(),
25665 dayOfMonth
25666 );
25667 return _date;
25668 }
25669 }
25670
25671 // node_modules/date-fns/_lib/defaultOptions.js
25672 var defaultOptions = {};
25673 function getDefaultOptions() {
25674 return defaultOptions;
25675 }
25676
25677 // node_modules/date-fns/startOfWeek.js
25678 function startOfWeek(date, options) {
25679 const defaultOptions2 = getDefaultOptions();
25680 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
25681 const _date = toDate(date, options?.in);
25682 const day = _date.getDay();
25683 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
25684 _date.setDate(_date.getDate() - diff);
25685 _date.setHours(0, 0, 0, 0);
25686 return _date;
25687 }
25688
25689 // node_modules/date-fns/startOfISOWeek.js
25690 function startOfISOWeek(date, options) {
25691 return startOfWeek(date, { ...options, weekStartsOn: 1 });
25692 }
25693
25694 // node_modules/date-fns/getISOWeekYear.js
25695 function getISOWeekYear(date, options) {
25696 const _date = toDate(date, options?.in);
25697 const year = _date.getFullYear();
25698 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
25699 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
25700 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
25701 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
25702 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
25703 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
25704 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
25705 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
25706 if (_date.getTime() >= startOfNextYear.getTime()) {
25707 return year + 1;
25708 } else if (_date.getTime() >= startOfThisYear.getTime()) {
25709 return year;
25710 } else {
25711 return year - 1;
25712 }
25713 }
25714
25715 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
25716 function getTimezoneOffsetInMilliseconds(date) {
25717 const _date = toDate(date);
25718 const utcDate = new Date(
25719 Date.UTC(
25720 _date.getFullYear(),
25721 _date.getMonth(),
25722 _date.getDate(),
25723 _date.getHours(),
25724 _date.getMinutes(),
25725 _date.getSeconds(),
25726 _date.getMilliseconds()
25727 )
25728 );
25729 utcDate.setUTCFullYear(_date.getFullYear());
25730 return +date - +utcDate;
25731 }
25732
25733 // node_modules/date-fns/_lib/normalizeDates.js
25734 function normalizeDates(context, ...dates) {
25735 const normalize = constructFrom.bind(
25736 null,
25737 context || dates.find((date) => typeof date === "object")
25738 );
25739 return dates.map(normalize);
25740 }
25741
25742 // node_modules/date-fns/startOfDay.js
25743 function startOfDay(date, options) {
25744 const _date = toDate(date, options?.in);
25745 _date.setHours(0, 0, 0, 0);
25746 return _date;
25747 }
25748
25749 // node_modules/date-fns/differenceInCalendarDays.js
25750 function differenceInCalendarDays(laterDate, earlierDate, options) {
25751 const [laterDate_, earlierDate_] = normalizeDates(
25752 options?.in,
25753 laterDate,
25754 earlierDate
25755 );
25756 const laterStartOfDay = startOfDay(laterDate_);
25757 const earlierStartOfDay = startOfDay(earlierDate_);
25758 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
25759 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
25760 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
25761 }
25762
25763 // node_modules/date-fns/startOfISOWeekYear.js
25764 function startOfISOWeekYear(date, options) {
25765 const year = getISOWeekYear(date, options);
25766 const fourthOfJanuary = constructFrom(options?.in || date, 0);
25767 fourthOfJanuary.setFullYear(year, 0, 4);
25768 fourthOfJanuary.setHours(0, 0, 0, 0);
25769 return startOfISOWeek(fourthOfJanuary);
25770 }
25771
25772 // node_modules/date-fns/addWeeks.js
25773 function addWeeks(date, amount, options) {
25774 return addDays(date, amount * 7, options);
25775 }
25776
25777 // node_modules/date-fns/addYears.js
25778 function addYears(date, amount, options) {
25779 return addMonths(date, amount * 12, options);
25780 }
25781
25782 // node_modules/date-fns/isDate.js
25783 function isDate(value) {
25784 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
25785 }
25786
25787 // node_modules/date-fns/isValid.js
25788 function isValid(date) {
25789 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
25790 }
25791
25792 // node_modules/date-fns/startOfMonth.js
25793 function startOfMonth(date, options) {
25794 const _date = toDate(date, options?.in);
25795 _date.setDate(1);
25796 _date.setHours(0, 0, 0, 0);
25797 return _date;
25798 }
25799
25800 // node_modules/date-fns/startOfYear.js
25801 function startOfYear(date, options) {
25802 const date_ = toDate(date, options?.in);
25803 date_.setFullYear(date_.getFullYear(), 0, 1);
25804 date_.setHours(0, 0, 0, 0);
25805 return date_;
25806 }
25807
25808 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
25809 var formatDistanceLocale = {
25810 lessThanXSeconds: {
25811 one: "less than a second",
25812 other: "less than {{count}} seconds"
25813 },
25814 xSeconds: {
25815 one: "1 second",
25816 other: "{{count}} seconds"
25817 },
25818 halfAMinute: "half a minute",
25819 lessThanXMinutes: {
25820 one: "less than a minute",
25821 other: "less than {{count}} minutes"
25822 },
25823 xMinutes: {
25824 one: "1 minute",
25825 other: "{{count}} minutes"
25826 },
25827 aboutXHours: {
25828 one: "about 1 hour",
25829 other: "about {{count}} hours"
25830 },
25831 xHours: {
25832 one: "1 hour",
25833 other: "{{count}} hours"
25834 },
25835 xDays: {
25836 one: "1 day",
25837 other: "{{count}} days"
25838 },
25839 aboutXWeeks: {
25840 one: "about 1 week",
25841 other: "about {{count}} weeks"
25842 },
25843 xWeeks: {
25844 one: "1 week",
25845 other: "{{count}} weeks"
25846 },
25847 aboutXMonths: {
25848 one: "about 1 month",
25849 other: "about {{count}} months"
25850 },
25851 xMonths: {
25852 one: "1 month",
25853 other: "{{count}} months"
25854 },
25855 aboutXYears: {
25856 one: "about 1 year",
25857 other: "about {{count}} years"
25858 },
25859 xYears: {
25860 one: "1 year",
25861 other: "{{count}} years"
25862 },
25863 overXYears: {
25864 one: "over 1 year",
25865 other: "over {{count}} years"
25866 },
25867 almostXYears: {
25868 one: "almost 1 year",
25869 other: "almost {{count}} years"
25870 }
25871 };
25872 var formatDistance = (token, count, options) => {
25873 let result;
25874 const tokenValue = formatDistanceLocale[token];
25875 if (typeof tokenValue === "string") {
25876 result = tokenValue;
25877 } else if (count === 1) {
25878 result = tokenValue.one;
25879 } else {
25880 result = tokenValue.other.replace("{{count}}", count.toString());
25881 }
25882 if (options?.addSuffix) {
25883 if (options.comparison && options.comparison > 0) {
25884 return "in " + result;
25885 } else {
25886 return result + " ago";
25887 }
25888 }
25889 return result;
25890 };
25891
25892 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
25893 function buildFormatLongFn(args) {
25894 return (options = {}) => {
25895 const width = options.width ? String(options.width) : args.defaultWidth;
25896 const format6 = args.formats[width] || args.formats[args.defaultWidth];
25897 return format6;
25898 };
25899 }
25900
25901 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
25902 var dateFormats = {
25903 full: "EEEE, MMMM do, y",
25904 long: "MMMM do, y",
25905 medium: "MMM d, y",
25906 short: "MM/dd/yyyy"
25907 };
25908 var timeFormats = {
25909 full: "h:mm:ss a zzzz",
25910 long: "h:mm:ss a z",
25911 medium: "h:mm:ss a",
25912 short: "h:mm a"
25913 };
25914 var dateTimeFormats = {
25915 full: "{{date}} 'at' {{time}}",
25916 long: "{{date}} 'at' {{time}}",
25917 medium: "{{date}}, {{time}}",
25918 short: "{{date}}, {{time}}"
25919 };
25920 var formatLong = {
25921 date: buildFormatLongFn({
25922 formats: dateFormats,
25923 defaultWidth: "full"
25924 }),
25925 time: buildFormatLongFn({
25926 formats: timeFormats,
25927 defaultWidth: "full"
25928 }),
25929 dateTime: buildFormatLongFn({
25930 formats: dateTimeFormats,
25931 defaultWidth: "full"
25932 })
25933 };
25934
25935 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
25936 var formatRelativeLocale = {
25937 lastWeek: "'last' eeee 'at' p",
25938 yesterday: "'yesterday at' p",
25939 today: "'today at' p",
25940 tomorrow: "'tomorrow at' p",
25941 nextWeek: "eeee 'at' p",
25942 other: "P"
25943 };
25944 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
25945
25946 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
25947 function buildLocalizeFn(args) {
25948 return (value, options) => {
25949 const context = options?.context ? String(options.context) : "standalone";
25950 let valuesArray;
25951 if (context === "formatting" && args.formattingValues) {
25952 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
25953 const width = options?.width ? String(options.width) : defaultWidth;
25954 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
25955 } else {
25956 const defaultWidth = args.defaultWidth;
25957 const width = options?.width ? String(options.width) : args.defaultWidth;
25958 valuesArray = args.values[width] || args.values[defaultWidth];
25959 }
25960 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
25961 return valuesArray[index2];
25962 };
25963 }
25964
25965 // node_modules/date-fns/locale/en-US/_lib/localize.js
25966 var eraValues = {
25967 narrow: ["B", "A"],
25968 abbreviated: ["BC", "AD"],
25969 wide: ["Before Christ", "Anno Domini"]
25970 };
25971 var quarterValues = {
25972 narrow: ["1", "2", "3", "4"],
25973 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
25974 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
25975 };
25976 var monthValues = {
25977 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
25978 abbreviated: [
25979 "Jan",
25980 "Feb",
25981 "Mar",
25982 "Apr",
25983 "May",
25984 "Jun",
25985 "Jul",
25986 "Aug",
25987 "Sep",
25988 "Oct",
25989 "Nov",
25990 "Dec"
25991 ],
25992 wide: [
25993 "January",
25994 "February",
25995 "March",
25996 "April",
25997 "May",
25998 "June",
25999 "July",
26000 "August",
26001 "September",
26002 "October",
26003 "November",
26004 "December"
26005 ]
26006 };
26007 var dayValues = {
26008 narrow: ["S", "M", "T", "W", "T", "F", "S"],
26009 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
26010 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
26011 wide: [
26012 "Sunday",
26013 "Monday",
26014 "Tuesday",
26015 "Wednesday",
26016 "Thursday",
26017 "Friday",
26018 "Saturday"
26019 ]
26020 };
26021 var dayPeriodValues = {
26022 narrow: {
26023 am: "a",
26024 pm: "p",
26025 midnight: "mi",
26026 noon: "n",
26027 morning: "morning",
26028 afternoon: "afternoon",
26029 evening: "evening",
26030 night: "night"
26031 },
26032 abbreviated: {
26033 am: "AM",
26034 pm: "PM",
26035 midnight: "midnight",
26036 noon: "noon",
26037 morning: "morning",
26038 afternoon: "afternoon",
26039 evening: "evening",
26040 night: "night"
26041 },
26042 wide: {
26043 am: "a.m.",
26044 pm: "p.m.",
26045 midnight: "midnight",
26046 noon: "noon",
26047 morning: "morning",
26048 afternoon: "afternoon",
26049 evening: "evening",
26050 night: "night"
26051 }
26052 };
26053 var formattingDayPeriodValues = {
26054 narrow: {
26055 am: "a",
26056 pm: "p",
26057 midnight: "mi",
26058 noon: "n",
26059 morning: "in the morning",
26060 afternoon: "in the afternoon",
26061 evening: "in the evening",
26062 night: "at night"
26063 },
26064 abbreviated: {
26065 am: "AM",
26066 pm: "PM",
26067 midnight: "midnight",
26068 noon: "noon",
26069 morning: "in the morning",
26070 afternoon: "in the afternoon",
26071 evening: "in the evening",
26072 night: "at night"
26073 },
26074 wide: {
26075 am: "a.m.",
26076 pm: "p.m.",
26077 midnight: "midnight",
26078 noon: "noon",
26079 morning: "in the morning",
26080 afternoon: "in the afternoon",
26081 evening: "in the evening",
26082 night: "at night"
26083 }
26084 };
26085 var ordinalNumber = (dirtyNumber, _options) => {
26086 const number = Number(dirtyNumber);
26087 const rem100 = number % 100;
26088 if (rem100 > 20 || rem100 < 10) {
26089 switch (rem100 % 10) {
26090 case 1:
26091 return number + "st";
26092 case 2:
26093 return number + "nd";
26094 case 3:
26095 return number + "rd";
26096 }
26097 }
26098 return number + "th";
26099 };
26100 var localize = {
26101 ordinalNumber,
26102 era: buildLocalizeFn({
26103 values: eraValues,
26104 defaultWidth: "wide"
26105 }),
26106 quarter: buildLocalizeFn({
26107 values: quarterValues,
26108 defaultWidth: "wide",
26109 argumentCallback: (quarter) => quarter - 1
26110 }),
26111 month: buildLocalizeFn({
26112 values: monthValues,
26113 defaultWidth: "wide"
26114 }),
26115 day: buildLocalizeFn({
26116 values: dayValues,
26117 defaultWidth: "wide"
26118 }),
26119 dayPeriod: buildLocalizeFn({
26120 values: dayPeriodValues,
26121 defaultWidth: "wide",
26122 formattingValues: formattingDayPeriodValues,
26123 defaultFormattingWidth: "wide"
26124 })
26125 };
26126
26127 // node_modules/date-fns/locale/_lib/buildMatchFn.js
26128 function buildMatchFn(args) {
26129 return (string, options = {}) => {
26130 const width = options.width;
26131 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
26132 const matchResult = string.match(matchPattern);
26133 if (!matchResult) {
26134 return null;
26135 }
26136 const matchedString = matchResult[0];
26137 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
26138 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
26139 // [TODO] -- I challenge you to fix the type
26140 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
26141 );
26142 let value;
26143 value = args.valueCallback ? args.valueCallback(key) : key;
26144 value = options.valueCallback ? (
26145 // [TODO] -- I challenge you to fix the type
26146 options.valueCallback(value)
26147 ) : value;
26148 const rest = string.slice(matchedString.length);
26149 return { value, rest };
26150 };
26151 }
26152 function findKey(object, predicate) {
26153 for (const key in object) {
26154 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
26155 return key;
26156 }
26157 }
26158 return void 0;
26159 }
26160 function findIndex(array, predicate) {
26161 for (let key = 0; key < array.length; key++) {
26162 if (predicate(array[key])) {
26163 return key;
26164 }
26165 }
26166 return void 0;
26167 }
26168
26169 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
26170 function buildMatchPatternFn(args) {
26171 return (string, options = {}) => {
26172 const matchResult = string.match(args.matchPattern);
26173 if (!matchResult) return null;
26174 const matchedString = matchResult[0];
26175 const parseResult = string.match(args.parsePattern);
26176 if (!parseResult) return null;
26177 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
26178 value = options.valueCallback ? options.valueCallback(value) : value;
26179 const rest = string.slice(matchedString.length);
26180 return { value, rest };
26181 };
26182 }
26183
26184 // node_modules/date-fns/locale/en-US/_lib/match.js
26185 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
26186 var parseOrdinalNumberPattern = /\d+/i;
26187 var matchEraPatterns = {
26188 narrow: /^(b|a)/i,
26189 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
26190 wide: /^(before christ|before common era|anno domini|common era)/i
26191 };
26192 var parseEraPatterns = {
26193 any: [/^b/i, /^(a|c)/i]
26194 };
26195 var matchQuarterPatterns = {
26196 narrow: /^[1234]/i,
26197 abbreviated: /^q[1234]/i,
26198 wide: /^[1234](th|st|nd|rd)? quarter/i
26199 };
26200 var parseQuarterPatterns = {
26201 any: [/1/i, /2/i, /3/i, /4/i]
26202 };
26203 var matchMonthPatterns = {
26204 narrow: /^[jfmasond]/i,
26205 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
26206 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
26207 };
26208 var parseMonthPatterns = {
26209 narrow: [
26210 /^j/i,
26211 /^f/i,
26212 /^m/i,
26213 /^a/i,
26214 /^m/i,
26215 /^j/i,
26216 /^j/i,
26217 /^a/i,
26218 /^s/i,
26219 /^o/i,
26220 /^n/i,
26221 /^d/i
26222 ],
26223 any: [
26224 /^ja/i,
26225 /^f/i,
26226 /^mar/i,
26227 /^ap/i,
26228 /^may/i,
26229 /^jun/i,
26230 /^jul/i,
26231 /^au/i,
26232 /^s/i,
26233 /^o/i,
26234 /^n/i,
26235 /^d/i
26236 ]
26237 };
26238 var matchDayPatterns = {
26239 narrow: /^[smtwf]/i,
26240 short: /^(su|mo|tu|we|th|fr|sa)/i,
26241 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
26242 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
26243 };
26244 var parseDayPatterns = {
26245 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
26246 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
26247 };
26248 var matchDayPeriodPatterns = {
26249 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
26250 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
26251 };
26252 var parseDayPeriodPatterns = {
26253 any: {
26254 am: /^a/i,
26255 pm: /^p/i,
26256 midnight: /^mi/i,
26257 noon: /^no/i,
26258 morning: /morning/i,
26259 afternoon: /afternoon/i,
26260 evening: /evening/i,
26261 night: /night/i
26262 }
26263 };
26264 var match = {
26265 ordinalNumber: buildMatchPatternFn({
26266 matchPattern: matchOrdinalNumberPattern,
26267 parsePattern: parseOrdinalNumberPattern,
26268 valueCallback: (value) => parseInt(value, 10)
26269 }),
26270 era: buildMatchFn({
26271 matchPatterns: matchEraPatterns,
26272 defaultMatchWidth: "wide",
26273 parsePatterns: parseEraPatterns,
26274 defaultParseWidth: "any"
26275 }),
26276 quarter: buildMatchFn({
26277 matchPatterns: matchQuarterPatterns,
26278 defaultMatchWidth: "wide",
26279 parsePatterns: parseQuarterPatterns,
26280 defaultParseWidth: "any",
26281 valueCallback: (index2) => index2 + 1
26282 }),
26283 month: buildMatchFn({
26284 matchPatterns: matchMonthPatterns,
26285 defaultMatchWidth: "wide",
26286 parsePatterns: parseMonthPatterns,
26287 defaultParseWidth: "any"
26288 }),
26289 day: buildMatchFn({
26290 matchPatterns: matchDayPatterns,
26291 defaultMatchWidth: "wide",
26292 parsePatterns: parseDayPatterns,
26293 defaultParseWidth: "any"
26294 }),
26295 dayPeriod: buildMatchFn({
26296 matchPatterns: matchDayPeriodPatterns,
26297 defaultMatchWidth: "any",
26298 parsePatterns: parseDayPeriodPatterns,
26299 defaultParseWidth: "any"
26300 })
26301 };
26302
26303 // node_modules/date-fns/locale/en-US.js
26304 var enUS = {
26305 code: "en-US",
26306 formatDistance,
26307 formatLong,
26308 formatRelative,
26309 localize,
26310 match,
26311 options: {
26312 weekStartsOn: 0,
26313 firstWeekContainsDate: 1
26314 }
26315 };
26316
26317 // node_modules/date-fns/getDayOfYear.js
26318 function getDayOfYear(date, options) {
26319 const _date = toDate(date, options?.in);
26320 const diff = differenceInCalendarDays(_date, startOfYear(_date));
26321 const dayOfYear = diff + 1;
26322 return dayOfYear;
26323 }
26324
26325 // node_modules/date-fns/getISOWeek.js
26326 function getISOWeek(date, options) {
26327 const _date = toDate(date, options?.in);
26328 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
26329 return Math.round(diff / millisecondsInWeek) + 1;
26330 }
26331
26332 // node_modules/date-fns/getWeekYear.js
26333 function getWeekYear(date, options) {
26334 const _date = toDate(date, options?.in);
26335 const year = _date.getFullYear();
26336 const defaultOptions2 = getDefaultOptions();
26337 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
26338 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
26339 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
26340 firstWeekOfNextYear.setHours(0, 0, 0, 0);
26341 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
26342 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
26343 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
26344 firstWeekOfThisYear.setHours(0, 0, 0, 0);
26345 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
26346 if (+_date >= +startOfNextYear) {
26347 return year + 1;
26348 } else if (+_date >= +startOfThisYear) {
26349 return year;
26350 } else {
26351 return year - 1;
26352 }
26353 }
26354
26355 // node_modules/date-fns/startOfWeekYear.js
26356 function startOfWeekYear(date, options) {
26357 const defaultOptions2 = getDefaultOptions();
26358 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
26359 const year = getWeekYear(date, options);
26360 const firstWeek = constructFrom(options?.in || date, 0);
26361 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
26362 firstWeek.setHours(0, 0, 0, 0);
26363 const _date = startOfWeek(firstWeek, options);
26364 return _date;
26365 }
26366
26367 // node_modules/date-fns/getWeek.js
26368 function getWeek(date, options) {
26369 const _date = toDate(date, options?.in);
26370 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
26371 return Math.round(diff / millisecondsInWeek) + 1;
26372 }
26373
26374 // node_modules/date-fns/_lib/addLeadingZeros.js
26375 function addLeadingZeros(number, targetLength) {
26376 const sign = number < 0 ? "-" : "";
26377 const output = Math.abs(number).toString().padStart(targetLength, "0");
26378 return sign + output;
26379 }
26380
26381 // node_modules/date-fns/_lib/format/lightFormatters.js
26382 var lightFormatters = {
26383 // Year
26384 y(date, token) {
26385 const signedYear = date.getFullYear();
26386 const year = signedYear > 0 ? signedYear : 1 - signedYear;
26387 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
26388 },
26389 // Month
26390 M(date, token) {
26391 const month = date.getMonth();
26392 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
26393 },
26394 // Day of the month
26395 d(date, token) {
26396 return addLeadingZeros(date.getDate(), token.length);
26397 },
26398 // AM or PM
26399 a(date, token) {
26400 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
26401 switch (token) {
26402 case "a":
26403 case "aa":
26404 return dayPeriodEnumValue.toUpperCase();
26405 case "aaa":
26406 return dayPeriodEnumValue;
26407 case "aaaaa":
26408 return dayPeriodEnumValue[0];
26409 case "aaaa":
26410 default:
26411 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
26412 }
26413 },
26414 // Hour [1-12]
26415 h(date, token) {
26416 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
26417 },
26418 // Hour [0-23]
26419 H(date, token) {
26420 return addLeadingZeros(date.getHours(), token.length);
26421 },
26422 // Minute
26423 m(date, token) {
26424 return addLeadingZeros(date.getMinutes(), token.length);
26425 },
26426 // Second
26427 s(date, token) {
26428 return addLeadingZeros(date.getSeconds(), token.length);
26429 },
26430 // Fraction of second
26431 S(date, token) {
26432 const numberOfDigits = token.length;
26433 const milliseconds = date.getMilliseconds();
26434 const fractionalSeconds = Math.trunc(
26435 milliseconds * Math.pow(10, numberOfDigits - 3)
26436 );
26437 return addLeadingZeros(fractionalSeconds, token.length);
26438 }
26439 };
26440
26441 // node_modules/date-fns/_lib/format/formatters.js
26442 var dayPeriodEnum = {
26443 am: "am",
26444 pm: "pm",
26445 midnight: "midnight",
26446 noon: "noon",
26447 morning: "morning",
26448 afternoon: "afternoon",
26449 evening: "evening",
26450 night: "night"
26451 };
26452 var formatters = {
26453 // Era
26454 G: function(date, token, localize2) {
26455 const era = date.getFullYear() > 0 ? 1 : 0;
26456 switch (token) {
26457 // AD, BC
26458 case "G":
26459 case "GG":
26460 case "GGG":
26461 return localize2.era(era, { width: "abbreviated" });
26462 // A, B
26463 case "GGGGG":
26464 return localize2.era(era, { width: "narrow" });
26465 // Anno Domini, Before Christ
26466 case "GGGG":
26467 default:
26468 return localize2.era(era, { width: "wide" });
26469 }
26470 },
26471 // Year
26472 y: function(date, token, localize2) {
26473 if (token === "yo") {
26474 const signedYear = date.getFullYear();
26475 const year = signedYear > 0 ? signedYear : 1 - signedYear;
26476 return localize2.ordinalNumber(year, { unit: "year" });
26477 }
26478 return lightFormatters.y(date, token);
26479 },
26480 // Local week-numbering year
26481 Y: function(date, token, localize2, options) {
26482 const signedWeekYear = getWeekYear(date, options);
26483 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
26484 if (token === "YY") {
26485 const twoDigitYear = weekYear % 100;
26486 return addLeadingZeros(twoDigitYear, 2);
26487 }
26488 if (token === "Yo") {
26489 return localize2.ordinalNumber(weekYear, { unit: "year" });
26490 }
26491 return addLeadingZeros(weekYear, token.length);
26492 },
26493 // ISO week-numbering year
26494 R: function(date, token) {
26495 const isoWeekYear = getISOWeekYear(date);
26496 return addLeadingZeros(isoWeekYear, token.length);
26497 },
26498 // Extended year. This is a single number designating the year of this calendar system.
26499 // The main difference between `y` and `u` localizers are B.C. years:
26500 // | Year | `y` | `u` |
26501 // |------|-----|-----|
26502 // | AC 1 | 1 | 1 |
26503 // | BC 1 | 1 | 0 |
26504 // | BC 2 | 2 | -1 |
26505 // Also `yy` always returns the last two digits of a year,
26506 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
26507 u: function(date, token) {
26508 const year = date.getFullYear();
26509 return addLeadingZeros(year, token.length);
26510 },
26511 // Quarter
26512 Q: function(date, token, localize2) {
26513 const quarter = Math.ceil((date.getMonth() + 1) / 3);
26514 switch (token) {
26515 // 1, 2, 3, 4
26516 case "Q":
26517 return String(quarter);
26518 // 01, 02, 03, 04
26519 case "QQ":
26520 return addLeadingZeros(quarter, 2);
26521 // 1st, 2nd, 3rd, 4th
26522 case "Qo":
26523 return localize2.ordinalNumber(quarter, { unit: "quarter" });
26524 // Q1, Q2, Q3, Q4
26525 case "QQQ":
26526 return localize2.quarter(quarter, {
26527 width: "abbreviated",
26528 context: "formatting"
26529 });
26530 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
26531 case "QQQQQ":
26532 return localize2.quarter(quarter, {
26533 width: "narrow",
26534 context: "formatting"
26535 });
26536 // 1st quarter, 2nd quarter, ...
26537 case "QQQQ":
26538 default:
26539 return localize2.quarter(quarter, {
26540 width: "wide",
26541 context: "formatting"
26542 });
26543 }
26544 },
26545 // Stand-alone quarter
26546 q: function(date, token, localize2) {
26547 const quarter = Math.ceil((date.getMonth() + 1) / 3);
26548 switch (token) {
26549 // 1, 2, 3, 4
26550 case "q":
26551 return String(quarter);
26552 // 01, 02, 03, 04
26553 case "qq":
26554 return addLeadingZeros(quarter, 2);
26555 // 1st, 2nd, 3rd, 4th
26556 case "qo":
26557 return localize2.ordinalNumber(quarter, { unit: "quarter" });
26558 // Q1, Q2, Q3, Q4
26559 case "qqq":
26560 return localize2.quarter(quarter, {
26561 width: "abbreviated",
26562 context: "standalone"
26563 });
26564 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
26565 case "qqqqq":
26566 return localize2.quarter(quarter, {
26567 width: "narrow",
26568 context: "standalone"
26569 });
26570 // 1st quarter, 2nd quarter, ...
26571 case "qqqq":
26572 default:
26573 return localize2.quarter(quarter, {
26574 width: "wide",
26575 context: "standalone"
26576 });
26577 }
26578 },
26579 // Month
26580 M: function(date, token, localize2) {
26581 const month = date.getMonth();
26582 switch (token) {
26583 case "M":
26584 case "MM":
26585 return lightFormatters.M(date, token);
26586 // 1st, 2nd, ..., 12th
26587 case "Mo":
26588 return localize2.ordinalNumber(month + 1, { unit: "month" });
26589 // Jan, Feb, ..., Dec
26590 case "MMM":
26591 return localize2.month(month, {
26592 width: "abbreviated",
26593 context: "formatting"
26594 });
26595 // J, F, ..., D
26596 case "MMMMM":
26597 return localize2.month(month, {
26598 width: "narrow",
26599 context: "formatting"
26600 });
26601 // January, February, ..., December
26602 case "MMMM":
26603 default:
26604 return localize2.month(month, { width: "wide", context: "formatting" });
26605 }
26606 },
26607 // Stand-alone month
26608 L: function(date, token, localize2) {
26609 const month = date.getMonth();
26610 switch (token) {
26611 // 1, 2, ..., 12
26612 case "L":
26613 return String(month + 1);
26614 // 01, 02, ..., 12
26615 case "LL":
26616 return addLeadingZeros(month + 1, 2);
26617 // 1st, 2nd, ..., 12th
26618 case "Lo":
26619 return localize2.ordinalNumber(month + 1, { unit: "month" });
26620 // Jan, Feb, ..., Dec
26621 case "LLL":
26622 return localize2.month(month, {
26623 width: "abbreviated",
26624 context: "standalone"
26625 });
26626 // J, F, ..., D
26627 case "LLLLL":
26628 return localize2.month(month, {
26629 width: "narrow",
26630 context: "standalone"
26631 });
26632 // January, February, ..., December
26633 case "LLLL":
26634 default:
26635 return localize2.month(month, { width: "wide", context: "standalone" });
26636 }
26637 },
26638 // Local week of year
26639 w: function(date, token, localize2, options) {
26640 const week = getWeek(date, options);
26641 if (token === "wo") {
26642 return localize2.ordinalNumber(week, { unit: "week" });
26643 }
26644 return addLeadingZeros(week, token.length);
26645 },
26646 // ISO week of year
26647 I: function(date, token, localize2) {
26648 const isoWeek = getISOWeek(date);
26649 if (token === "Io") {
26650 return localize2.ordinalNumber(isoWeek, { unit: "week" });
26651 }
26652 return addLeadingZeros(isoWeek, token.length);
26653 },
26654 // Day of the month
26655 d: function(date, token, localize2) {
26656 if (token === "do") {
26657 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
26658 }
26659 return lightFormatters.d(date, token);
26660 },
26661 // Day of year
26662 D: function(date, token, localize2) {
26663 const dayOfYear = getDayOfYear(date);
26664 if (token === "Do") {
26665 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
26666 }
26667 return addLeadingZeros(dayOfYear, token.length);
26668 },
26669 // Day of week
26670 E: function(date, token, localize2) {
26671 const dayOfWeek = date.getDay();
26672 switch (token) {
26673 // Tue
26674 case "E":
26675 case "EE":
26676 case "EEE":
26677 return localize2.day(dayOfWeek, {
26678 width: "abbreviated",
26679 context: "formatting"
26680 });
26681 // T
26682 case "EEEEE":
26683 return localize2.day(dayOfWeek, {
26684 width: "narrow",
26685 context: "formatting"
26686 });
26687 // Tu
26688 case "EEEEEE":
26689 return localize2.day(dayOfWeek, {
26690 width: "short",
26691 context: "formatting"
26692 });
26693 // Tuesday
26694 case "EEEE":
26695 default:
26696 return localize2.day(dayOfWeek, {
26697 width: "wide",
26698 context: "formatting"
26699 });
26700 }
26701 },
26702 // Local day of week
26703 e: function(date, token, localize2, options) {
26704 const dayOfWeek = date.getDay();
26705 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
26706 switch (token) {
26707 // Numerical value (Nth day of week with current locale or weekStartsOn)
26708 case "e":
26709 return String(localDayOfWeek);
26710 // Padded numerical value
26711 case "ee":
26712 return addLeadingZeros(localDayOfWeek, 2);
26713 // 1st, 2nd, ..., 7th
26714 case "eo":
26715 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
26716 case "eee":
26717 return localize2.day(dayOfWeek, {
26718 width: "abbreviated",
26719 context: "formatting"
26720 });
26721 // T
26722 case "eeeee":
26723 return localize2.day(dayOfWeek, {
26724 width: "narrow",
26725 context: "formatting"
26726 });
26727 // Tu
26728 case "eeeeee":
26729 return localize2.day(dayOfWeek, {
26730 width: "short",
26731 context: "formatting"
26732 });
26733 // Tuesday
26734 case "eeee":
26735 default:
26736 return localize2.day(dayOfWeek, {
26737 width: "wide",
26738 context: "formatting"
26739 });
26740 }
26741 },
26742 // Stand-alone local day of week
26743 c: function(date, token, localize2, options) {
26744 const dayOfWeek = date.getDay();
26745 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
26746 switch (token) {
26747 // Numerical value (same as in `e`)
26748 case "c":
26749 return String(localDayOfWeek);
26750 // Padded numerical value
26751 case "cc":
26752 return addLeadingZeros(localDayOfWeek, token.length);
26753 // 1st, 2nd, ..., 7th
26754 case "co":
26755 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
26756 case "ccc":
26757 return localize2.day(dayOfWeek, {
26758 width: "abbreviated",
26759 context: "standalone"
26760 });
26761 // T
26762 case "ccccc":
26763 return localize2.day(dayOfWeek, {
26764 width: "narrow",
26765 context: "standalone"
26766 });
26767 // Tu
26768 case "cccccc":
26769 return localize2.day(dayOfWeek, {
26770 width: "short",
26771 context: "standalone"
26772 });
26773 // Tuesday
26774 case "cccc":
26775 default:
26776 return localize2.day(dayOfWeek, {
26777 width: "wide",
26778 context: "standalone"
26779 });
26780 }
26781 },
26782 // ISO day of week
26783 i: function(date, token, localize2) {
26784 const dayOfWeek = date.getDay();
26785 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
26786 switch (token) {
26787 // 2
26788 case "i":
26789 return String(isoDayOfWeek);
26790 // 02
26791 case "ii":
26792 return addLeadingZeros(isoDayOfWeek, token.length);
26793 // 2nd
26794 case "io":
26795 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
26796 // Tue
26797 case "iii":
26798 return localize2.day(dayOfWeek, {
26799 width: "abbreviated",
26800 context: "formatting"
26801 });
26802 // T
26803 case "iiiii":
26804 return localize2.day(dayOfWeek, {
26805 width: "narrow",
26806 context: "formatting"
26807 });
26808 // Tu
26809 case "iiiiii":
26810 return localize2.day(dayOfWeek, {
26811 width: "short",
26812 context: "formatting"
26813 });
26814 // Tuesday
26815 case "iiii":
26816 default:
26817 return localize2.day(dayOfWeek, {
26818 width: "wide",
26819 context: "formatting"
26820 });
26821 }
26822 },
26823 // AM or PM
26824 a: function(date, token, localize2) {
26825 const hours = date.getHours();
26826 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
26827 switch (token) {
26828 case "a":
26829 case "aa":
26830 return localize2.dayPeriod(dayPeriodEnumValue, {
26831 width: "abbreviated",
26832 context: "formatting"
26833 });
26834 case "aaa":
26835 return localize2.dayPeriod(dayPeriodEnumValue, {
26836 width: "abbreviated",
26837 context: "formatting"
26838 }).toLowerCase();
26839 case "aaaaa":
26840 return localize2.dayPeriod(dayPeriodEnumValue, {
26841 width: "narrow",
26842 context: "formatting"
26843 });
26844 case "aaaa":
26845 default:
26846 return localize2.dayPeriod(dayPeriodEnumValue, {
26847 width: "wide",
26848 context: "formatting"
26849 });
26850 }
26851 },
26852 // AM, PM, midnight, noon
26853 b: function(date, token, localize2) {
26854 const hours = date.getHours();
26855 let dayPeriodEnumValue;
26856 if (hours === 12) {
26857 dayPeriodEnumValue = dayPeriodEnum.noon;
26858 } else if (hours === 0) {
26859 dayPeriodEnumValue = dayPeriodEnum.midnight;
26860 } else {
26861 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
26862 }
26863 switch (token) {
26864 case "b":
26865 case "bb":
26866 return localize2.dayPeriod(dayPeriodEnumValue, {
26867 width: "abbreviated",
26868 context: "formatting"
26869 });
26870 case "bbb":
26871 return localize2.dayPeriod(dayPeriodEnumValue, {
26872 width: "abbreviated",
26873 context: "formatting"
26874 }).toLowerCase();
26875 case "bbbbb":
26876 return localize2.dayPeriod(dayPeriodEnumValue, {
26877 width: "narrow",
26878 context: "formatting"
26879 });
26880 case "bbbb":
26881 default:
26882 return localize2.dayPeriod(dayPeriodEnumValue, {
26883 width: "wide",
26884 context: "formatting"
26885 });
26886 }
26887 },
26888 // in the morning, in the afternoon, in the evening, at night
26889 B: function(date, token, localize2) {
26890 const hours = date.getHours();
26891 let dayPeriodEnumValue;
26892 if (hours >= 17) {
26893 dayPeriodEnumValue = dayPeriodEnum.evening;
26894 } else if (hours >= 12) {
26895 dayPeriodEnumValue = dayPeriodEnum.afternoon;
26896 } else if (hours >= 4) {
26897 dayPeriodEnumValue = dayPeriodEnum.morning;
26898 } else {
26899 dayPeriodEnumValue = dayPeriodEnum.night;
26900 }
26901 switch (token) {
26902 case "B":
26903 case "BB":
26904 case "BBB":
26905 return localize2.dayPeriod(dayPeriodEnumValue, {
26906 width: "abbreviated",
26907 context: "formatting"
26908 });
26909 case "BBBBB":
26910 return localize2.dayPeriod(dayPeriodEnumValue, {
26911 width: "narrow",
26912 context: "formatting"
26913 });
26914 case "BBBB":
26915 default:
26916 return localize2.dayPeriod(dayPeriodEnumValue, {
26917 width: "wide",
26918 context: "formatting"
26919 });
26920 }
26921 },
26922 // Hour [1-12]
26923 h: function(date, token, localize2) {
26924 if (token === "ho") {
26925 let hours = date.getHours() % 12;
26926 if (hours === 0) hours = 12;
26927 return localize2.ordinalNumber(hours, { unit: "hour" });
26928 }
26929 return lightFormatters.h(date, token);
26930 },
26931 // Hour [0-23]
26932 H: function(date, token, localize2) {
26933 if (token === "Ho") {
26934 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
26935 }
26936 return lightFormatters.H(date, token);
26937 },
26938 // Hour [0-11]
26939 K: function(date, token, localize2) {
26940 const hours = date.getHours() % 12;
26941 if (token === "Ko") {
26942 return localize2.ordinalNumber(hours, { unit: "hour" });
26943 }
26944 return addLeadingZeros(hours, token.length);
26945 },
26946 // Hour [1-24]
26947 k: function(date, token, localize2) {
26948 let hours = date.getHours();
26949 if (hours === 0) hours = 24;
26950 if (token === "ko") {
26951 return localize2.ordinalNumber(hours, { unit: "hour" });
26952 }
26953 return addLeadingZeros(hours, token.length);
26954 },
26955 // Minute
26956 m: function(date, token, localize2) {
26957 if (token === "mo") {
26958 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
26959 }
26960 return lightFormatters.m(date, token);
26961 },
26962 // Second
26963 s: function(date, token, localize2) {
26964 if (token === "so") {
26965 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
26966 }
26967 return lightFormatters.s(date, token);
26968 },
26969 // Fraction of second
26970 S: function(date, token) {
26971 return lightFormatters.S(date, token);
26972 },
26973 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
26974 X: function(date, token, _localize) {
26975 const timezoneOffset = date.getTimezoneOffset();
26976 if (timezoneOffset === 0) {
26977 return "Z";
26978 }
26979 switch (token) {
26980 // Hours and optional minutes
26981 case "X":
26982 return formatTimezoneWithOptionalMinutes(timezoneOffset);
26983 // Hours, minutes and optional seconds without `:` delimiter
26984 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
26985 // so this token always has the same output as `XX`
26986 case "XXXX":
26987 case "XX":
26988 return formatTimezone(timezoneOffset);
26989 // Hours, minutes and optional seconds with `:` delimiter
26990 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
26991 // so this token always has the same output as `XXX`
26992 case "XXXXX":
26993 case "XXX":
26994 // Hours and minutes with `:` delimiter
26995 default:
26996 return formatTimezone(timezoneOffset, ":");
26997 }
26998 },
26999 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
27000 x: function(date, token, _localize) {
27001 const timezoneOffset = date.getTimezoneOffset();
27002 switch (token) {
27003 // Hours and optional minutes
27004 case "x":
27005 return formatTimezoneWithOptionalMinutes(timezoneOffset);
27006 // Hours, minutes and optional seconds without `:` delimiter
27007 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
27008 // so this token always has the same output as `xx`
27009 case "xxxx":
27010 case "xx":
27011 return formatTimezone(timezoneOffset);
27012 // Hours, minutes and optional seconds with `:` delimiter
27013 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
27014 // so this token always has the same output as `xxx`
27015 case "xxxxx":
27016 case "xxx":
27017 // Hours and minutes with `:` delimiter
27018 default:
27019 return formatTimezone(timezoneOffset, ":");
27020 }
27021 },
27022 // Timezone (GMT)
27023 O: function(date, token, _localize) {
27024 const timezoneOffset = date.getTimezoneOffset();
27025 switch (token) {
27026 // Short
27027 case "O":
27028 case "OO":
27029 case "OOO":
27030 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
27031 // Long
27032 case "OOOO":
27033 default:
27034 return "GMT" + formatTimezone(timezoneOffset, ":");
27035 }
27036 },
27037 // Timezone (specific non-location)
27038 z: function(date, token, _localize) {
27039 const timezoneOffset = date.getTimezoneOffset();
27040 switch (token) {
27041 // Short
27042 case "z":
27043 case "zz":
27044 case "zzz":
27045 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
27046 // Long
27047 case "zzzz":
27048 default:
27049 return "GMT" + formatTimezone(timezoneOffset, ":");
27050 }
27051 },
27052 // Seconds timestamp
27053 t: function(date, token, _localize) {
27054 const timestamp = Math.trunc(+date / 1e3);
27055 return addLeadingZeros(timestamp, token.length);
27056 },
27057 // Milliseconds timestamp
27058 T: function(date, token, _localize) {
27059 return addLeadingZeros(+date, token.length);
27060 }
27061 };
27062 function formatTimezoneShort(offset4, delimiter = "") {
27063 const sign = offset4 > 0 ? "-" : "+";
27064 const absOffset = Math.abs(offset4);
27065 const hours = Math.trunc(absOffset / 60);
27066 const minutes = absOffset % 60;
27067 if (minutes === 0) {
27068 return sign + String(hours);
27069 }
27070 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
27071 }
27072 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
27073 if (offset4 % 60 === 0) {
27074 const sign = offset4 > 0 ? "-" : "+";
27075 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
27076 }
27077 return formatTimezone(offset4, delimiter);
27078 }
27079 function formatTimezone(offset4, delimiter = "") {
27080 const sign = offset4 > 0 ? "-" : "+";
27081 const absOffset = Math.abs(offset4);
27082 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
27083 const minutes = addLeadingZeros(absOffset % 60, 2);
27084 return sign + hours + delimiter + minutes;
27085 }
27086
27087 // node_modules/date-fns/_lib/format/longFormatters.js
27088 var dateLongFormatter = (pattern, formatLong2) => {
27089 switch (pattern) {
27090 case "P":
27091 return formatLong2.date({ width: "short" });
27092 case "PP":
27093 return formatLong2.date({ width: "medium" });
27094 case "PPP":
27095 return formatLong2.date({ width: "long" });
27096 case "PPPP":
27097 default:
27098 return formatLong2.date({ width: "full" });
27099 }
27100 };
27101 var timeLongFormatter = (pattern, formatLong2) => {
27102 switch (pattern) {
27103 case "p":
27104 return formatLong2.time({ width: "short" });
27105 case "pp":
27106 return formatLong2.time({ width: "medium" });
27107 case "ppp":
27108 return formatLong2.time({ width: "long" });
27109 case "pppp":
27110 default:
27111 return formatLong2.time({ width: "full" });
27112 }
27113 };
27114 var dateTimeLongFormatter = (pattern, formatLong2) => {
27115 const matchResult = pattern.match(/(P+)(p+)?/) || [];
27116 const datePattern = matchResult[1];
27117 const timePattern = matchResult[2];
27118 if (!timePattern) {
27119 return dateLongFormatter(pattern, formatLong2);
27120 }
27121 let dateTimeFormat;
27122 switch (datePattern) {
27123 case "P":
27124 dateTimeFormat = formatLong2.dateTime({ width: "short" });
27125 break;
27126 case "PP":
27127 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
27128 break;
27129 case "PPP":
27130 dateTimeFormat = formatLong2.dateTime({ width: "long" });
27131 break;
27132 case "PPPP":
27133 default:
27134 dateTimeFormat = formatLong2.dateTime({ width: "full" });
27135 break;
27136 }
27137 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
27138 };
27139 var longFormatters = {
27140 p: timeLongFormatter,
27141 P: dateTimeLongFormatter
27142 };
27143
27144 // node_modules/date-fns/_lib/protectedTokens.js
27145 var dayOfYearTokenRE = /^D+$/;
27146 var weekYearTokenRE = /^Y+$/;
27147 var throwTokens = ["D", "DD", "YY", "YYYY"];
27148 function isProtectedDayOfYearToken(token) {
27149 return dayOfYearTokenRE.test(token);
27150 }
27151 function isProtectedWeekYearToken(token) {
27152 return weekYearTokenRE.test(token);
27153 }
27154 function warnOrThrowProtectedError(token, format6, input) {
27155 const _message = message(token, format6, input);
27156 console.warn(_message);
27157 if (throwTokens.includes(token)) throw new RangeError(_message);
27158 }
27159 function message(token, format6, input) {
27160 const subject = token[0] === "Y" ? "years" : "days of the month";
27161 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`;
27162 }
27163
27164 // node_modules/date-fns/format.js
27165 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
27166 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
27167 var escapedStringRegExp = /^'([^]*?)'?$/;
27168 var doubleQuoteRegExp = /''/g;
27169 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
27170 function format(date, formatStr, options) {
27171 const defaultOptions2 = getDefaultOptions();
27172 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
27173 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
27174 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
27175 const originalDate = toDate(date, options?.in);
27176 if (!isValid(originalDate)) {
27177 throw new RangeError("Invalid time value");
27178 }
27179 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
27180 const firstCharacter = substring[0];
27181 if (firstCharacter === "p" || firstCharacter === "P") {
27182 const longFormatter = longFormatters[firstCharacter];
27183 return longFormatter(substring, locale.formatLong);
27184 }
27185 return substring;
27186 }).join("").match(formattingTokensRegExp).map((substring) => {
27187 if (substring === "''") {
27188 return { isToken: false, value: "'" };
27189 }
27190 const firstCharacter = substring[0];
27191 if (firstCharacter === "'") {
27192 return { isToken: false, value: cleanEscapedString(substring) };
27193 }
27194 if (formatters[firstCharacter]) {
27195 return { isToken: true, value: substring };
27196 }
27197 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
27198 throw new RangeError(
27199 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
27200 );
27201 }
27202 return { isToken: false, value: substring };
27203 });
27204 if (locale.localize.preprocessor) {
27205 parts = locale.localize.preprocessor(originalDate, parts);
27206 }
27207 const formatterOptions = {
27208 firstWeekContainsDate,
27209 weekStartsOn,
27210 locale
27211 };
27212 return parts.map((part) => {
27213 if (!part.isToken) return part.value;
27214 const token = part.value;
27215 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
27216 warnOrThrowProtectedError(token, formatStr, String(date));
27217 }
27218 const formatter = formatters[token[0]];
27219 return formatter(originalDate, token, locale.localize, formatterOptions);
27220 }).join("");
27221 }
27222 function cleanEscapedString(input) {
27223 const matched = input.match(escapedStringRegExp);
27224 if (!matched) {
27225 return input;
27226 }
27227 return matched[1].replace(doubleQuoteRegExp, "'");
27228 }
27229
27230 // node_modules/date-fns/subDays.js
27231 function subDays(date, amount, options) {
27232 return addDays(date, -amount, options);
27233 }
27234
27235 // node_modules/date-fns/subMonths.js
27236 function subMonths(date, amount, options) {
27237 return addMonths(date, -amount, options);
27238 }
27239
27240 // node_modules/date-fns/subWeeks.js
27241 function subWeeks(date, amount, options) {
27242 return addWeeks(date, -amount, options);
27243 }
27244
27245 // node_modules/date-fns/subYears.js
27246 function subYears(date, amount, options) {
27247 return addYears(date, -amount, options);
27248 }
27249
27250 // packages/dataviews/build-module/utils/operators.mjs
27251 var import_i18n28 = __toESM(require_i18n(), 1);
27252 var import_element82 = __toESM(require_element(), 1);
27253 var import_date = __toESM(require_date(), 1);
27254 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
27255 var filterTextWrappers = {
27256 Name: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
27257 Value: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
27258 };
27259 function getRelativeDate(value, unit) {
27260 switch (unit) {
27261 case "days":
27262 return subDays(/* @__PURE__ */ new Date(), value);
27263 case "weeks":
27264 return subWeeks(/* @__PURE__ */ new Date(), value);
27265 case "months":
27266 return subMonths(/* @__PURE__ */ new Date(), value);
27267 case "years":
27268 return subYears(/* @__PURE__ */ new Date(), value);
27269 default:
27270 return /* @__PURE__ */ new Date();
27271 }
27272 }
27273 var isNoneOperatorDefinition = {
27274 /* translators: DataViews operator name */
27275 label: (0, import_i18n28.__)("Is none of"),
27276 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27277 (0, import_i18n28.sprintf)(
27278 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
27279 (0, import_i18n28.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
27280 filter.name,
27281 activeElements.map((element) => element.label).join(", ")
27282 ),
27283 filterTextWrappers
27284 ),
27285 filter: ((item, field, filterValue) => {
27286 if (!filterValue?.length) {
27287 return true;
27288 }
27289 const fieldValue = field.getValue({ item });
27290 if (Array.isArray(fieldValue)) {
27291 return !filterValue.some(
27292 (fv) => fieldValue.includes(fv)
27293 );
27294 } else if (typeof fieldValue === "string") {
27295 return !filterValue.includes(fieldValue);
27296 }
27297 return false;
27298 }),
27299 selection: "multi"
27300 };
27301 var OPERATORS = [
27302 {
27303 name: OPERATOR_IS_ANY,
27304 /* translators: DataViews operator name */
27305 label: (0, import_i18n28.__)("Includes"),
27306 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27307 (0, import_i18n28.sprintf)(
27308 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
27309 (0, import_i18n28.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
27310 filter.name,
27311 activeElements.map((element) => element.label).join(", ")
27312 ),
27313 filterTextWrappers
27314 ),
27315 filter(item, field, filterValue) {
27316 if (!filterValue?.length) {
27317 return true;
27318 }
27319 const fieldValue = field.getValue({ item });
27320 if (Array.isArray(fieldValue)) {
27321 return filterValue.some(
27322 (fv) => fieldValue.includes(fv)
27323 );
27324 } else if (typeof fieldValue === "string") {
27325 return filterValue.includes(fieldValue);
27326 }
27327 return false;
27328 },
27329 selection: "multi"
27330 },
27331 {
27332 name: OPERATOR_IS_NONE,
27333 ...isNoneOperatorDefinition
27334 },
27335 {
27336 name: OPERATOR_IS_ALL,
27337 /* translators: DataViews operator name */
27338 label: (0, import_i18n28.__)("Includes all"),
27339 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27340 (0, import_i18n28.sprintf)(
27341 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
27342 (0, import_i18n28.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
27343 filter.name,
27344 activeElements.map((element) => element.label).join(", ")
27345 ),
27346 filterTextWrappers
27347 ),
27348 filter(item, field, filterValue) {
27349 if (!filterValue?.length) {
27350 return true;
27351 }
27352 return filterValue.every((value) => {
27353 return field.getValue({ item })?.includes(value);
27354 });
27355 },
27356 selection: "multi"
27357 },
27358 {
27359 name: OPERATOR_IS_NOT_ALL,
27360 ...isNoneOperatorDefinition
27361 },
27362 {
27363 name: OPERATOR_BETWEEN,
27364 /* translators: DataViews operator name */
27365 label: (0, import_i18n28.__)("Between (inc)"),
27366 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27367 (0, import_i18n28.sprintf)(
27368 /* 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". */
27369 (0, import_i18n28.__)(
27370 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
27371 ),
27372 filter.name,
27373 activeElements[0].label[0],
27374 activeElements[0].label[1]
27375 ),
27376 filterTextWrappers
27377 ),
27378 filter(item, field, filterValue) {
27379 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
27380 return true;
27381 }
27382 const fieldValue = field.getValue({ item });
27383 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
27384 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
27385 }
27386 return false;
27387 },
27388 selection: "custom"
27389 },
27390 {
27391 name: OPERATOR_IN_THE_PAST,
27392 /* translators: DataViews operator name */
27393 label: (0, import_i18n28.__)("In the past"),
27394 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27395 (0, import_i18n28.sprintf)(
27396 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
27397 (0, import_i18n28.__)(
27398 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
27399 ),
27400 filter.name,
27401 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
27402 ),
27403 filterTextWrappers
27404 ),
27405 filter(item, field, filterValue) {
27406 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
27407 return true;
27408 }
27409 const targetDate = getRelativeDate(
27410 filterValue.value,
27411 filterValue.unit
27412 );
27413 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
27414 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
27415 },
27416 selection: "custom"
27417 },
27418 {
27419 name: OPERATOR_OVER,
27420 /* translators: DataViews operator name */
27421 label: (0, import_i18n28.__)("Over"),
27422 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27423 (0, import_i18n28.sprintf)(
27424 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
27425 (0, import_i18n28.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
27426 filter.name,
27427 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
27428 ),
27429 filterTextWrappers
27430 ),
27431 filter(item, field, filterValue) {
27432 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
27433 return true;
27434 }
27435 const targetDate = getRelativeDate(
27436 filterValue.value,
27437 filterValue.unit
27438 );
27439 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
27440 return fieldValue < targetDate;
27441 },
27442 selection: "custom"
27443 },
27444 {
27445 name: OPERATOR_IS,
27446 /* translators: DataViews operator name */
27447 label: (0, import_i18n28.__)("Is"),
27448 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27449 (0, import_i18n28.sprintf)(
27450 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
27451 (0, import_i18n28.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
27452 filter.name,
27453 activeElements[0].label
27454 ),
27455 filterTextWrappers
27456 ),
27457 filter(item, field, filterValue) {
27458 return filterValue === field.getValue({ item }) || filterValue === void 0;
27459 },
27460 selection: "single"
27461 },
27462 {
27463 name: OPERATOR_IS_NOT,
27464 /* translators: DataViews operator name */
27465 label: (0, import_i18n28.__)("Is not"),
27466 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27467 (0, import_i18n28.sprintf)(
27468 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
27469 (0, import_i18n28.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
27470 filter.name,
27471 activeElements[0].label
27472 ),
27473 filterTextWrappers
27474 ),
27475 filter(item, field, filterValue) {
27476 return filterValue !== field.getValue({ item });
27477 },
27478 selection: "single"
27479 },
27480 {
27481 name: OPERATOR_LESS_THAN,
27482 /* translators: DataViews operator name */
27483 label: (0, import_i18n28.__)("Less than"),
27484 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27485 (0, import_i18n28.sprintf)(
27486 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
27487 (0, import_i18n28.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
27488 filter.name,
27489 activeElements[0].label
27490 ),
27491 filterTextWrappers
27492 ),
27493 filter(item, field, filterValue) {
27494 if (filterValue === void 0) {
27495 return true;
27496 }
27497 const fieldValue = field.getValue({ item });
27498 return fieldValue < filterValue;
27499 },
27500 selection: "single"
27501 },
27502 {
27503 name: OPERATOR_GREATER_THAN,
27504 /* translators: DataViews operator name */
27505 label: (0, import_i18n28.__)("Greater than"),
27506 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27507 (0, import_i18n28.sprintf)(
27508 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
27509 (0, import_i18n28.__)(
27510 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
27511 ),
27512 filter.name,
27513 activeElements[0].label
27514 ),
27515 filterTextWrappers
27516 ),
27517 filter(item, field, filterValue) {
27518 if (filterValue === void 0) {
27519 return true;
27520 }
27521 const fieldValue = field.getValue({ item });
27522 return fieldValue > filterValue;
27523 },
27524 selection: "single"
27525 },
27526 {
27527 name: OPERATOR_LESS_THAN_OR_EQUAL,
27528 /* translators: DataViews operator name */
27529 label: (0, import_i18n28.__)("Less than or equal"),
27530 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27531 (0, import_i18n28.sprintf)(
27532 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
27533 (0, import_i18n28.__)(
27534 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
27535 ),
27536 filter.name,
27537 activeElements[0].label
27538 ),
27539 filterTextWrappers
27540 ),
27541 filter(item, field, filterValue) {
27542 if (filterValue === void 0) {
27543 return true;
27544 }
27545 const fieldValue = field.getValue({ item });
27546 return fieldValue <= filterValue;
27547 },
27548 selection: "single"
27549 },
27550 {
27551 name: OPERATOR_GREATER_THAN_OR_EQUAL,
27552 /* translators: DataViews operator name */
27553 label: (0, import_i18n28.__)("Greater than or equal"),
27554 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27555 (0, import_i18n28.sprintf)(
27556 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
27557 (0, import_i18n28.__)(
27558 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
27559 ),
27560 filter.name,
27561 activeElements[0].label
27562 ),
27563 filterTextWrappers
27564 ),
27565 filter(item, field, filterValue) {
27566 if (filterValue === void 0) {
27567 return true;
27568 }
27569 const fieldValue = field.getValue({ item });
27570 return fieldValue >= filterValue;
27571 },
27572 selection: "single"
27573 },
27574 {
27575 name: OPERATOR_BEFORE,
27576 /* translators: DataViews operator name */
27577 label: (0, import_i18n28.__)("Before"),
27578 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27579 (0, import_i18n28.sprintf)(
27580 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
27581 (0, import_i18n28.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
27582 filter.name,
27583 activeElements[0].label
27584 ),
27585 filterTextWrappers
27586 ),
27587 filter(item, field, filterValue) {
27588 if (filterValue === void 0) {
27589 return true;
27590 }
27591 const filterDate = (0, import_date.getDate)(filterValue);
27592 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27593 return fieldDate < filterDate;
27594 },
27595 selection: "single"
27596 },
27597 {
27598 name: OPERATOR_AFTER,
27599 /* translators: DataViews operator name */
27600 label: (0, import_i18n28.__)("After"),
27601 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27602 (0, import_i18n28.sprintf)(
27603 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
27604 (0, import_i18n28.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
27605 filter.name,
27606 activeElements[0].label
27607 ),
27608 filterTextWrappers
27609 ),
27610 filter(item, field, filterValue) {
27611 if (filterValue === void 0) {
27612 return true;
27613 }
27614 const filterDate = (0, import_date.getDate)(filterValue);
27615 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27616 return fieldDate > filterDate;
27617 },
27618 selection: "single"
27619 },
27620 {
27621 name: OPERATOR_BEFORE_INC,
27622 /* translators: DataViews operator name */
27623 label: (0, import_i18n28.__)("Before (inc)"),
27624 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27625 (0, import_i18n28.sprintf)(
27626 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
27627 (0, import_i18n28.__)(
27628 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
27629 ),
27630 filter.name,
27631 activeElements[0].label
27632 ),
27633 filterTextWrappers
27634 ),
27635 filter(item, field, filterValue) {
27636 if (filterValue === void 0) {
27637 return true;
27638 }
27639 const filterDate = (0, import_date.getDate)(filterValue);
27640 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27641 return fieldDate <= filterDate;
27642 },
27643 selection: "single"
27644 },
27645 {
27646 name: OPERATOR_AFTER_INC,
27647 /* translators: DataViews operator name */
27648 label: (0, import_i18n28.__)("After (inc)"),
27649 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27650 (0, import_i18n28.sprintf)(
27651 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
27652 (0, import_i18n28.__)(
27653 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
27654 ),
27655 filter.name,
27656 activeElements[0].label
27657 ),
27658 filterTextWrappers
27659 ),
27660 filter(item, field, filterValue) {
27661 if (filterValue === void 0) {
27662 return true;
27663 }
27664 const filterDate = (0, import_date.getDate)(filterValue);
27665 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27666 return fieldDate >= filterDate;
27667 },
27668 selection: "single"
27669 },
27670 {
27671 name: OPERATOR_CONTAINS,
27672 /* translators: DataViews operator name */
27673 label: (0, import_i18n28.__)("Contains"),
27674 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27675 (0, import_i18n28.sprintf)(
27676 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
27677 (0, import_i18n28.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
27678 filter.name,
27679 activeElements[0].label
27680 ),
27681 filterTextWrappers
27682 ),
27683 filter(item, field, filterValue) {
27684 if (filterValue === void 0) {
27685 return true;
27686 }
27687 const fieldValue = field.getValue({ item });
27688 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
27689 },
27690 selection: "single"
27691 },
27692 {
27693 name: OPERATOR_NOT_CONTAINS,
27694 /* translators: DataViews operator name */
27695 label: (0, import_i18n28.__)("Doesn't contain"),
27696 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27697 (0, import_i18n28.sprintf)(
27698 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
27699 (0, import_i18n28.__)(
27700 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
27701 ),
27702 filter.name,
27703 activeElements[0].label
27704 ),
27705 filterTextWrappers
27706 ),
27707 filter(item, field, filterValue) {
27708 if (filterValue === void 0) {
27709 return true;
27710 }
27711 const fieldValue = field.getValue({ item });
27712 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
27713 },
27714 selection: "single"
27715 },
27716 {
27717 name: OPERATOR_STARTS_WITH,
27718 /* translators: DataViews operator name */
27719 label: (0, import_i18n28.__)("Starts with"),
27720 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27721 (0, import_i18n28.sprintf)(
27722 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
27723 (0, import_i18n28.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
27724 filter.name,
27725 activeElements[0].label
27726 ),
27727 filterTextWrappers
27728 ),
27729 filter(item, field, filterValue) {
27730 if (filterValue === void 0) {
27731 return true;
27732 }
27733 const fieldValue = field.getValue({ item });
27734 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
27735 },
27736 selection: "single"
27737 },
27738 {
27739 name: OPERATOR_ON,
27740 /* translators: DataViews operator name */
27741 label: (0, import_i18n28.__)("On"),
27742 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27743 (0, import_i18n28.sprintf)(
27744 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
27745 (0, import_i18n28.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
27746 filter.name,
27747 activeElements[0].label
27748 ),
27749 filterTextWrappers
27750 ),
27751 filter(item, field, filterValue) {
27752 if (filterValue === void 0) {
27753 return true;
27754 }
27755 const filterDate = (0, import_date.getDate)(filterValue);
27756 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27757 return filterDate.getTime() === fieldDate.getTime();
27758 },
27759 selection: "single"
27760 },
27761 {
27762 name: OPERATOR_NOT_ON,
27763 /* translators: DataViews operator name */
27764 label: (0, import_i18n28.__)("Not on"),
27765 filterText: (filter, activeElements) => (0, import_element82.createInterpolateElement)(
27766 (0, import_i18n28.sprintf)(
27767 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
27768 (0, import_i18n28.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
27769 filter.name,
27770 activeElements[0].label
27771 ),
27772 filterTextWrappers
27773 ),
27774 filter(item, field, filterValue) {
27775 if (filterValue === void 0) {
27776 return true;
27777 }
27778 const filterDate = (0, import_date.getDate)(filterValue);
27779 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
27780 return filterDate.getTime() !== fieldDate.getTime();
27781 },
27782 selection: "single"
27783 }
27784 ];
27785 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
27786 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
27787 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
27788 (op) => op.name === name
27789 );
27790 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
27791
27792 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
27793 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
27794 var ENTER = "Enter";
27795 var SPACE = " ";
27796 var FilterText = ({
27797 activeElements,
27798 filterInView,
27799 filter
27800 }) => {
27801 if (activeElements === void 0 || activeElements.length === 0) {
27802 return filter.name;
27803 }
27804 const operator = getOperatorByName(filterInView?.operator);
27805 if (operator !== void 0) {
27806 return operator.filterText(filter, activeElements);
27807 }
27808 return (0, import_i18n29.sprintf)(
27809 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
27810 (0, import_i18n29.__)("Unknown status for %1$s"),
27811 filter.name
27812 );
27813 };
27814 function OperatorSelector({
27815 filter,
27816 view,
27817 onChangeView
27818 }) {
27819 const operatorOptions = filter.operators?.map((operator) => ({
27820 value: operator,
27821 label: getOperatorByName(operator)?.label || operator
27822 }));
27823 const currentFilter = view.filters?.find(
27824 (_filter) => _filter.field === filter.field
27825 );
27826 const value = currentFilter?.operator || filter.operators[0];
27827 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(
27828 Stack,
27829 {
27830 direction: "row",
27831 gap: "sm",
27832 justify: "flex-start",
27833 className: "dataviews-filters__summary-operators-container",
27834 align: "center",
27835 children: [
27836 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(import_components22.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
27837 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27838 import_components22.SelectControl,
27839 {
27840 className: "dataviews-filters__summary-operators-filter-select",
27841 label: (0, import_i18n29.__)("Conditions"),
27842 value,
27843 options: operatorOptions,
27844 onChange: (newValue) => {
27845 const newOperator = newValue;
27846 const currentOperator = currentFilter?.operator;
27847 const newFilters = currentFilter ? [
27848 ...(view.filters ?? []).map(
27849 (_filter) => {
27850 if (_filter.field === filter.field) {
27851 const currentOpSelectionModel = getOperatorByName(
27852 currentOperator
27853 )?.selection;
27854 const newOpSelectionModel = getOperatorByName(
27855 newOperator
27856 )?.selection;
27857 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
27858 currentOpSelectionModel,
27859 newOpSelectionModel
27860 ].includes("custom");
27861 return {
27862 ..._filter,
27863 value: shouldResetValue ? void 0 : _filter.value,
27864 operator: newOperator
27865 };
27866 }
27867 return _filter;
27868 }
27869 )
27870 ] : [
27871 ...view.filters ?? [],
27872 {
27873 field: filter.field,
27874 operator: newOperator,
27875 value: void 0
27876 }
27877 ];
27878 onChangeView({
27879 ...view,
27880 page: 1,
27881 filters: newFilters
27882 });
27883 },
27884 size: "small",
27885 variant: "minimal",
27886 hideLabelFromVision: true
27887 }
27888 )
27889 ]
27890 }
27891 );
27892 }
27893 function Filter({
27894 addFilterRef,
27895 openedFilter,
27896 fields,
27897 ...commonProps
27898 }) {
27899 const toggleRef = (0, import_element83.useRef)(null);
27900 const { filter, view, onChangeView } = commonProps;
27901 const filterInView = view.filters?.find(
27902 (f2) => f2.field === filter.field
27903 );
27904 let activeElements = [];
27905 const field = (0, import_element83.useMemo)(() => {
27906 const currentField = fields.find((f2) => f2.id === filter.field);
27907 if (currentField) {
27908 return {
27909 ...currentField,
27910 // Configure getValue as if Item was a plain object.
27911 // See related input-widget.tsx
27912 getValue: ({ item }) => item[currentField.id]
27913 };
27914 }
27915 return currentField;
27916 }, [fields, filter.field]);
27917 const { elements } = useElements({
27918 elements: filter.elements,
27919 getElements: filter.getElements
27920 });
27921 if (elements.length > 0) {
27922 activeElements = elements.filter((element) => {
27923 if (filter.singleSelection) {
27924 return element.value === filterInView?.value;
27925 }
27926 return filterInView?.value?.includes(element.value);
27927 });
27928 } else if (Array.isArray(filterInView?.value)) {
27929 const label = filterInView.value.map((v2) => {
27930 const formattedValue = field?.getValueFormatted({
27931 item: { [field.id]: v2 },
27932 field
27933 });
27934 return formattedValue || String(v2);
27935 });
27936 activeElements = [
27937 {
27938 value: filterInView.value,
27939 // @ts-ignore
27940 label
27941 }
27942 ];
27943 } else if (typeof filterInView?.value === "object") {
27944 activeElements = [
27945 { value: filterInView.value, label: filterInView.value }
27946 ];
27947 } else if (filterInView?.value !== void 0) {
27948 const label = field !== void 0 ? field.getValueFormatted({
27949 item: { [field.id]: filterInView.value },
27950 field
27951 }) : String(filterInView.value);
27952 activeElements = [
27953 {
27954 value: filterInView.value,
27955 label
27956 }
27957 ];
27958 }
27959 const isPrimary = filter.isPrimary;
27960 const isLocked = filterInView?.isLocked;
27961 const hasValues = !isLocked && filterInView?.value !== void 0;
27962 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
27963 const resetOrRemoveLabel = isPrimary ? (0, import_i18n29.__)("Reset") : (0, import_i18n29.__)("Remove");
27964 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27965 import_components22.Dropdown,
27966 {
27967 defaultOpen: openedFilter === filter.field,
27968 contentClassName: "dataviews-filters__summary-popover",
27969 popoverProps: { placement: "bottom-start", role: "dialog" },
27970 onClose: () => {
27971 toggleRef.current?.focus();
27972 },
27973 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
27974 /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(tooltip_exports.Root, { children: [
27975 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27976 tooltip_exports.Trigger,
27977 {
27978 render: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
27979 "div",
27980 {
27981 className: clsx_default(
27982 "dataviews-filters__summary-chip",
27983 {
27984 "has-reset": canResetOrRemove,
27985 "has-values": hasValues,
27986 "is-not-clickable": isLocked
27987 }
27988 ),
27989 role: "button",
27990 tabIndex: isLocked ? -1 : 0,
27991 onClick: () => {
27992 if (!isLocked) {
27993 onToggle();
27994 }
27995 },
27996 onKeyDown: (event) => {
27997 if (!isLocked && [ENTER, SPACE].includes(
27998 event.key
27999 )) {
28000 onToggle();
28001 event.preventDefault();
28002 }
28003 },
28004 "aria-disabled": isLocked,
28005 "aria-pressed": isOpen,
28006 "aria-expanded": isOpen,
28007 ref: toggleRef,
28008 children: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
28009 FilterText,
28010 {
28011 activeElements,
28012 filterInView,
28013 filter
28014 }
28015 )
28016 }
28017 )
28018 }
28019 ),
28020 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(tooltip_exports.Popup, { children: (0, import_i18n29.sprintf)(
28021 /* translators: 1: Filter name. */
28022 (0, import_i18n29.__)("Filter by: %1$s"),
28023 filter.name.toLowerCase()
28024 ) })
28025 ] }),
28026 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(tooltip_exports.Root, { children: [
28027 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
28028 tooltip_exports.Trigger,
28029 {
28030 render: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
28031 "button",
28032 {
28033 className: clsx_default(
28034 "dataviews-filters__summary-chip-remove",
28035 { "has-values": hasValues }
28036 ),
28037 "aria-label": resetOrRemoveLabel,
28038 onClick: () => {
28039 onChangeView({
28040 ...view,
28041 page: 1,
28042 filters: view.filters?.filter(
28043 (_filter) => _filter.field !== filter.field
28044 )
28045 });
28046 if (!isPrimary) {
28047 addFilterRef.current?.focus();
28048 } else {
28049 toggleRef.current?.focus();
28050 }
28051 },
28052 children: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(import_components22.Icon, { icon: close_small_default })
28053 }
28054 )
28055 }
28056 ),
28057 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
28058 ] })
28059 ] }),
28060 renderContent: () => {
28061 return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
28062 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(OperatorSelector, { ...commonProps }),
28063 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
28064 SearchWidget,
28065 {
28066 ...commonProps,
28067 filter: {
28068 ...commonProps.filter,
28069 elements
28070 }
28071 }
28072 ) : /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(InputWidget, { ...commonProps, fields })
28073 ] });
28074 }
28075 }
28076 );
28077 }
28078
28079 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
28080 var import_components23 = __toESM(require_components(), 1);
28081 var import_i18n30 = __toESM(require_i18n(), 1);
28082 var import_element84 = __toESM(require_element(), 1);
28083 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
28084 var { Menu: Menu4 } = unlock3(import_components23.privateApis);
28085 function AddFilterMenu({
28086 filters,
28087 view,
28088 onChangeView,
28089 setOpenedFilter,
28090 triggerProps
28091 }) {
28092 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
28093 return /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(Menu4, { children: [
28094 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(Menu4.TriggerButton, { ...triggerProps }),
28095 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
28096 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
28097 Menu4.Item,
28098 {
28099 onClick: () => {
28100 setOpenedFilter(filter.field);
28101 onChangeView({
28102 ...view,
28103 page: 1,
28104 filters: [
28105 ...view.filters || [],
28106 {
28107 field: filter.field,
28108 value: void 0,
28109 operator: filter.operators[0]
28110 }
28111 ]
28112 });
28113 },
28114 children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(Menu4.ItemLabel, { children: filter.name })
28115 },
28116 filter.field
28117 );
28118 }) })
28119 ] });
28120 }
28121 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
28122 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
28123 return null;
28124 }
28125 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
28126 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
28127 AddFilterMenu,
28128 {
28129 triggerProps: {
28130 render: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
28131 import_components23.Button,
28132 {
28133 accessibleWhenDisabled: true,
28134 size: "compact",
28135 className: "dataviews-filters-button",
28136 variant: "tertiary",
28137 disabled: !inactiveFilters.length,
28138 ref
28139 }
28140 ),
28141 children: (0, import_i18n30.__)("Add filter")
28142 },
28143 ...{ filters, view, onChangeView, setOpenedFilter }
28144 }
28145 );
28146 }
28147 var add_filter_default = (0, import_element84.forwardRef)(AddFilter);
28148
28149 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
28150 var import_components24 = __toESM(require_components(), 1);
28151 var import_i18n31 = __toESM(require_i18n(), 1);
28152 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
28153 function ResetFilter({
28154 filters,
28155 view,
28156 onChangeView
28157 }) {
28158 const isPrimary = (field) => filters.some(
28159 (_filter) => _filter.field === field && _filter.isPrimary
28160 );
28161 const isDisabled = !view.search && !view.filters?.some(
28162 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
28163 );
28164 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
28165 import_components24.Button,
28166 {
28167 disabled: isDisabled,
28168 accessibleWhenDisabled: true,
28169 size: "compact",
28170 variant: "tertiary",
28171 className: "dataviews-filters__reset-button",
28172 onClick: () => {
28173 onChangeView({
28174 ...view,
28175 page: 1,
28176 search: "",
28177 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
28178 });
28179 },
28180 children: (0, import_i18n31.__)("Reset")
28181 }
28182 );
28183 }
28184
28185 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
28186 var import_element85 = __toESM(require_element(), 1);
28187 function useFilters(fields, view) {
28188 return (0, import_element85.useMemo)(() => {
28189 const filters = [];
28190 fields.forEach((field) => {
28191 if (field.filterBy === false || !field.hasElements && !field.Edit) {
28192 return;
28193 }
28194 const operators = field.filterBy.operators;
28195 const isPrimary = !!field.filterBy?.isPrimary;
28196 const isLocked = view.filters?.some(
28197 (f2) => f2.field === field.id && !!f2.isLocked
28198 ) ?? false;
28199 filters.push({
28200 field: field.id,
28201 name: field.label,
28202 elements: field.elements,
28203 getElements: field.getElements,
28204 hasElements: field.hasElements,
28205 singleSelection: operators.some(
28206 (op) => isSingleSelectionOperator(op)
28207 ),
28208 operators,
28209 isVisible: isLocked || isPrimary || !!view.filters?.some(
28210 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
28211 ),
28212 isPrimary,
28213 isLocked
28214 });
28215 });
28216 filters.sort((a2, b2) => {
28217 if (a2.isLocked && !b2.isLocked) {
28218 return -1;
28219 }
28220 if (!a2.isLocked && b2.isLocked) {
28221 return 1;
28222 }
28223 if (a2.isPrimary && !b2.isPrimary) {
28224 return -1;
28225 }
28226 if (!a2.isPrimary && b2.isPrimary) {
28227 return 1;
28228 }
28229 return a2.name.localeCompare(b2.name);
28230 });
28231 return filters;
28232 }, [fields, view]);
28233 }
28234 var use_filters_default = useFilters;
28235
28236 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
28237 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
28238 function Filters({ className }) {
28239 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element86.useContext)(dataviews_context_default);
28240 const addFilterRef = (0, import_element86.useRef)(null);
28241 const filters = use_filters_default(fields, view);
28242 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28243 add_filter_default,
28244 {
28245 filters,
28246 view,
28247 onChangeView,
28248 ref: addFilterRef,
28249 setOpenedFilter
28250 },
28251 "add-filter"
28252 );
28253 const visibleFilters = filters.filter((filter) => filter.isVisible);
28254 if (visibleFilters.length === 0) {
28255 return null;
28256 }
28257 const filterComponents = [
28258 ...visibleFilters.map((filter) => {
28259 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28260 Filter,
28261 {
28262 filter,
28263 view,
28264 fields,
28265 onChangeView,
28266 addFilterRef,
28267 openedFilter
28268 },
28269 filter.field
28270 );
28271 }),
28272 addFilter
28273 ];
28274 filterComponents.push(
28275 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28276 ResetFilter,
28277 {
28278 filters,
28279 view,
28280 onChangeView
28281 },
28282 "reset-filters"
28283 )
28284 );
28285 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
28286 Stack,
28287 {
28288 direction: "row",
28289 justify: "flex-start",
28290 gap: "sm",
28291 style: { width: "fit-content" },
28292 wrap: "wrap",
28293 className,
28294 children: filterComponents
28295 }
28296 );
28297 }
28298 var filters_default = (0, import_element86.memo)(Filters);
28299
28300 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
28301 var import_element87 = __toESM(require_element(), 1);
28302 var import_components25 = __toESM(require_components(), 1);
28303 var import_i18n32 = __toESM(require_i18n(), 1);
28304 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
28305 function FiltersToggle() {
28306 const {
28307 filters,
28308 view,
28309 onChangeView,
28310 setOpenedFilter,
28311 isShowingFilter,
28312 setIsShowingFilter
28313 } = (0, import_element87.useContext)(dataviews_context_default);
28314 const buttonRef = (0, import_element87.useRef)(null);
28315 const onChangeViewWithFilterVisibility = (0, import_element87.useCallback)(
28316 (_view) => {
28317 onChangeView(_view);
28318 setIsShowingFilter(true);
28319 },
28320 [onChangeView, setIsShowingFilter]
28321 );
28322 if (filters.length === 0) {
28323 return null;
28324 }
28325 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
28326 const addFilterButtonProps = {
28327 label: (0, import_i18n32.__)("Add filter"),
28328 "aria-expanded": false,
28329 isPressed: false
28330 };
28331 const toggleFiltersButtonProps = {
28332 label: (0, import_i18n32._x)("Filter", "verb"),
28333 "aria-expanded": isShowingFilter,
28334 isPressed: isShowingFilter,
28335 onClick: () => {
28336 if (!isShowingFilter) {
28337 setOpenedFilter(null);
28338 }
28339 setIsShowingFilter(!isShowingFilter);
28340 }
28341 };
28342 const hasPrimaryOrLockedFilters = filters.some(
28343 (filter) => filter.isPrimary || filter.isLocked
28344 );
28345 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28346 import_components25.Button,
28347 {
28348 ref: buttonRef,
28349 className: "dataviews-filters__visibility-toggle",
28350 size: "compact",
28351 icon: funnel_default,
28352 disabled: hasPrimaryOrLockedFilters,
28353 accessibleWhenDisabled: true,
28354 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
28355 }
28356 );
28357 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28358 AddFilterMenu,
28359 {
28360 filters,
28361 view,
28362 onChangeView: onChangeViewWithFilterVisibility,
28363 setOpenedFilter,
28364 triggerProps: { render: buttonComponent }
28365 }
28366 ) : /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
28367 FilterVisibilityToggle,
28368 {
28369 buttonRef,
28370 filtersCount: view.filters?.length,
28371 children: buttonComponent
28372 }
28373 ) });
28374 }
28375 function FilterVisibilityToggle({
28376 buttonRef,
28377 filtersCount,
28378 children
28379 }) {
28380 (0, import_element87.useEffect)(
28381 () => () => {
28382 buttonRef.current?.focus();
28383 },
28384 [buttonRef]
28385 );
28386 return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(import_jsx_runtime129.Fragment, { children: [
28387 children,
28388 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
28389 ] });
28390 }
28391 var toggle_default = FiltersToggle;
28392
28393 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
28394 var import_element88 = __toESM(require_element(), 1);
28395 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
28396 function FiltersToggled(props) {
28397 const { isShowingFilter } = (0, import_element88.useContext)(dataviews_context_default);
28398 if (!isShowingFilter) {
28399 return null;
28400 }
28401 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(filters_default, { ...props });
28402 }
28403 var filters_toggled_default = FiltersToggled;
28404
28405 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
28406 var import_element89 = __toESM(require_element(), 1);
28407 var import_components26 = __toESM(require_components(), 1);
28408 var import_i18n33 = __toESM(require_i18n(), 1);
28409 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1);
28410 function DataViewsLayout({ className }) {
28411 const {
28412 actions = [],
28413 data,
28414 fields,
28415 getItemId,
28416 getItemLevel,
28417 hasInitiallyLoaded,
28418 isLoading,
28419 view,
28420 onChangeView,
28421 selection,
28422 onChangeSelection,
28423 setOpenedFilter,
28424 onClickItem,
28425 isItemClickable,
28426 renderItemLink,
28427 defaultLayouts: defaultLayouts3,
28428 containerRef,
28429 empty = /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("p", { children: (0, import_i18n33.__)("No results") })
28430 } = (0, import_element89.useContext)(dataviews_context_default);
28431 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
28432 delay: 200
28433 });
28434 if (!hasInitiallyLoaded) {
28435 if (!isDelayedInitialLoading) {
28436 return null;
28437 }
28438 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(import_components26.Spinner, {}) }) });
28439 }
28440 const ViewComponent = VIEW_LAYOUTS.find(
28441 (v2) => v2.type === view.type && defaultLayouts3[v2.type]
28442 )?.component;
28443 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
28444 ViewComponent,
28445 {
28446 className,
28447 actions,
28448 data,
28449 fields,
28450 getItemId,
28451 getItemLevel,
28452 isLoading,
28453 onChangeView,
28454 onChangeSelection,
28455 selection,
28456 setOpenedFilter,
28457 onClickItem,
28458 renderItemLink,
28459 isItemClickable,
28460 view,
28461 empty
28462 }
28463 ) });
28464 }
28465
28466 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
28467 var import_element90 = __toESM(require_element(), 1);
28468 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1);
28469 var EMPTY_ARRAY5 = [];
28470 function DataViewsFooter() {
28471 const {
28472 view,
28473 paginationInfo: { totalItems = 0, totalPages },
28474 data,
28475 actions = EMPTY_ARRAY5,
28476 isLoading,
28477 hasInitiallyLoaded
28478 } = (0, import_element90.useContext)(dataviews_context_default);
28479 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
28480 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
28481 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
28482 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
28483 return null;
28484 }
28485 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
28486 "div",
28487 {
28488 className: "dataviews-footer",
28489 inert: isRefreshing ? "true" : void 0,
28490 children: /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(
28491 Stack,
28492 {
28493 direction: "row",
28494 justify: "end",
28495 align: "center",
28496 className: clsx_default("dataviews-footer__content", {
28497 "is-refreshing": isDelayedRefreshing
28498 }),
28499 gap: "sm",
28500 children: [
28501 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(BulkActionsFooter, {}),
28502 /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(dataviews_pagination_default, {})
28503 ]
28504 }
28505 )
28506 }
28507 );
28508 }
28509
28510 // packages/dataviews/build-module/components/dataviews-search/index.mjs
28511 var import_i18n34 = __toESM(require_i18n(), 1);
28512 var import_element91 = __toESM(require_element(), 1);
28513 var import_components27 = __toESM(require_components(), 1);
28514 var import_compose11 = __toESM(require_compose(), 1);
28515 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1);
28516 var DataViewsSearch = (0, import_element91.memo)(function Search({ label }) {
28517 const { view, onChangeView } = (0, import_element91.useContext)(dataviews_context_default);
28518 const [search, setSearch, debouncedSearch] = (0, import_compose11.useDebouncedInput)(
28519 view.search
28520 );
28521 (0, import_element91.useEffect)(() => {
28522 if (view.search !== debouncedSearch) {
28523 setSearch(view.search ?? "");
28524 }
28525 }, [view.search, setSearch]);
28526 const onChangeViewRef = (0, import_element91.useRef)(onChangeView);
28527 const viewRef = (0, import_element91.useRef)(view);
28528 (0, import_element91.useEffect)(() => {
28529 onChangeViewRef.current = onChangeView;
28530 viewRef.current = view;
28531 }, [onChangeView, view]);
28532 (0, import_element91.useEffect)(() => {
28533 if (debouncedSearch !== viewRef.current?.search) {
28534 onChangeViewRef.current({
28535 ...viewRef.current,
28536 page: view.page ? 1 : void 0,
28537 startPosition: view.startPosition ? 1 : void 0,
28538 search: debouncedSearch
28539 });
28540 }
28541 }, [debouncedSearch]);
28542 const searchLabel = label || (0, import_i18n34.__)("Search");
28543 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
28544 import_components27.SearchControl,
28545 {
28546 className: "dataviews-search",
28547 onChange: setSearch,
28548 value: search,
28549 label: searchLabel,
28550 placeholder: searchLabel,
28551 size: "compact"
28552 }
28553 );
28554 });
28555 var dataviews_search_default = DataViewsSearch;
28556
28557 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
28558 var import_components28 = __toESM(require_components(), 1);
28559 var import_i18n35 = __toESM(require_i18n(), 1);
28560 var import_element92 = __toESM(require_element(), 1);
28561 var import_warning = __toESM(require_warning(), 1);
28562 var import_compose12 = __toESM(require_compose(), 1);
28563 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1);
28564 var { Menu: Menu5 } = unlock3(import_components28.privateApis);
28565 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
28566 className: "dataviews-config__popover",
28567 placement: "bottom-end",
28568 offset: 9
28569 };
28570 function ViewTypeMenu() {
28571 const { view, onChangeView, defaultLayouts: defaultLayouts3 } = (0, import_element92.useContext)(dataviews_context_default);
28572 const availableLayouts = Object.keys(defaultLayouts3);
28573 if (availableLayouts.length <= 1) {
28574 return null;
28575 }
28576 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
28577 return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(Menu5, { children: [
28578 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28579 Menu5.TriggerButton,
28580 {
28581 render: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28582 import_components28.Button,
28583 {
28584 size: "compact",
28585 icon: activeView?.icon,
28586 label: (0, import_i18n35.__)("Layout")
28587 }
28588 )
28589 }
28590 ),
28591 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
28592 const config = VIEW_LAYOUTS.find(
28593 (v2) => v2.type === layout
28594 );
28595 if (!config) {
28596 return null;
28597 }
28598 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28599 Menu5.RadioItem,
28600 {
28601 value: layout,
28602 name: "view-actions-available-view",
28603 checked: layout === view.type,
28604 hideOnClick: true,
28605 onChange: (e2) => {
28606 switch (e2.target.value) {
28607 case "list":
28608 case "grid":
28609 case "table":
28610 case "pickerGrid":
28611 case "pickerTable":
28612 case "activity":
28613 const viewWithoutLayout = { ...view };
28614 if ("layout" in viewWithoutLayout) {
28615 delete viewWithoutLayout.layout;
28616 }
28617 return onChangeView({
28618 ...viewWithoutLayout,
28619 type: e2.target.value,
28620 ...defaultLayouts3[e2.target.value]
28621 });
28622 }
28623 (0, import_warning.default)("Invalid dataview");
28624 },
28625 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(Menu5.ItemLabel, { children: config.label })
28626 },
28627 layout
28628 );
28629 }) })
28630 ] });
28631 }
28632 function SortFieldControl() {
28633 const { view, fields, onChangeView } = (0, import_element92.useContext)(dataviews_context_default);
28634 const orderOptions = (0, import_element92.useMemo)(() => {
28635 const sortableFields = fields.filter(
28636 (field) => field.enableSorting !== false
28637 );
28638 return sortableFields.map((field) => {
28639 return {
28640 label: field.label,
28641 value: field.id
28642 };
28643 });
28644 }, [fields]);
28645 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28646 import_components28.SelectControl,
28647 {
28648 __next40pxDefaultSize: true,
28649 label: (0, import_i18n35.__)("Sort by"),
28650 value: view.sort?.field,
28651 options: orderOptions,
28652 onChange: (value) => {
28653 onChangeView({
28654 ...view,
28655 sort: {
28656 direction: view?.sort?.direction || "desc",
28657 field: value
28658 },
28659 showLevels: false
28660 });
28661 }
28662 }
28663 );
28664 }
28665 function SortDirectionControl() {
28666 const { view, fields, onChangeView } = (0, import_element92.useContext)(dataviews_context_default);
28667 const sortableFields = fields.filter(
28668 (field) => field.enableSorting !== false
28669 );
28670 if (sortableFields.length === 0) {
28671 return null;
28672 }
28673 let value = view.sort?.direction;
28674 if (!value && view.sort?.field) {
28675 value = "desc";
28676 }
28677 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28678 import_components28.__experimentalToggleGroupControl,
28679 {
28680 className: "dataviews-view-config__sort-direction",
28681 __next40pxDefaultSize: true,
28682 isBlock: true,
28683 label: (0, import_i18n35.__)("Order"),
28684 value,
28685 onChange: (newDirection) => {
28686 if (newDirection === "asc" || newDirection === "desc") {
28687 onChangeView({
28688 ...view,
28689 sort: {
28690 direction: newDirection,
28691 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
28692 fields.find(
28693 (field) => field.enableSorting !== false
28694 )?.id || ""
28695 },
28696 showLevels: false
28697 });
28698 return;
28699 }
28700 (0, import_warning.default)("Invalid direction");
28701 },
28702 children: SORTING_DIRECTIONS.map((direction) => {
28703 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28704 import_components28.__experimentalToggleGroupControlOptionIcon,
28705 {
28706 value: direction,
28707 icon: sortIcons[direction],
28708 label: sortLabels[direction]
28709 },
28710 direction
28711 );
28712 })
28713 }
28714 );
28715 }
28716 function ItemsPerPageControl() {
28717 const { view, config, onChangeView } = (0, import_element92.useContext)(dataviews_context_default);
28718 const { infiniteScrollEnabled } = view;
28719 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
28720 return null;
28721 }
28722 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28723 import_components28.__experimentalToggleGroupControl,
28724 {
28725 __next40pxDefaultSize: true,
28726 isBlock: true,
28727 label: (0, import_i18n35.__)("Items per page"),
28728 value: view.perPage || 10,
28729 disabled: !view?.sort?.field,
28730 onChange: (newItemsPerPage) => {
28731 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
28732 onChangeView({
28733 ...view,
28734 perPage: newItemsPerPageNumber,
28735 page: 1
28736 });
28737 },
28738 children: config.perPageSizes.map((value) => {
28739 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28740 import_components28.__experimentalToggleGroupControlOption,
28741 {
28742 value,
28743 label: value.toString()
28744 },
28745 value
28746 );
28747 })
28748 }
28749 );
28750 }
28751 function ResetViewButton() {
28752 const { onReset } = (0, import_element92.useContext)(dataviews_context_default);
28753 if (onReset === void 0) {
28754 return null;
28755 }
28756 const isDisabled = onReset === false;
28757 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28758 import_components28.Button,
28759 {
28760 variant: "tertiary",
28761 size: "compact",
28762 disabled: isDisabled,
28763 accessibleWhenDisabled: true,
28764 className: "dataviews-view-config__reset-button",
28765 onClick: () => {
28766 if (typeof onReset === "function") {
28767 onReset();
28768 }
28769 },
28770 children: (0, import_i18n35.__)("Reset view")
28771 }
28772 );
28773 }
28774 function DataviewsViewConfigDropdown() {
28775 const { view, onReset } = (0, import_element92.useContext)(dataviews_context_default);
28776 const popoverId = (0, import_compose12.useInstanceId)(
28777 _DataViewsViewConfig,
28778 "dataviews-view-config-dropdown"
28779 );
28780 const activeLayout = VIEW_LAYOUTS.find(
28781 (layout) => layout.type === view.type
28782 );
28783 const isModified = typeof onReset === "function";
28784 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28785 import_components28.Dropdown,
28786 {
28787 expandOnMobile: true,
28788 popoverProps: {
28789 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
28790 id: popoverId
28791 },
28792 renderToggle: ({ onToggle, isOpen }) => {
28793 return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
28794 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28795 import_components28.Button,
28796 {
28797 size: "compact",
28798 icon: cog_default,
28799 label: (0, import_i18n35._x)(
28800 "View options",
28801 "View is used as a noun"
28802 ),
28803 onClick: onToggle,
28804 "aria-expanded": isOpen ? "true" : "false",
28805 "aria-controls": popoverId
28806 }
28807 ),
28808 isModified && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
28809 ] });
28810 },
28811 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28812 import_components28.__experimentalDropdownContentWrapper,
28813 {
28814 paddingSize: "medium",
28815 className: "dataviews-config__popover-content-wrapper",
28816 children: /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
28817 Stack,
28818 {
28819 direction: "column",
28820 className: "dataviews-view-config",
28821 gap: "xl",
28822 children: [
28823 /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
28824 Stack,
28825 {
28826 direction: "row",
28827 justify: "space-between",
28828 align: "center",
28829 className: "dataviews-view-config__header",
28830 children: [
28831 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
28832 import_components28.__experimentalHeading,
28833 {
28834 level: 2,
28835 className: "dataviews-settings-section__title",
28836 children: (0, import_i18n35.__)("Appearance")
28837 }
28838 ),
28839 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(ResetViewButton, {})
28840 ]
28841 }
28842 ),
28843 /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(Stack, { direction: "column", gap: "lg", children: [
28844 /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
28845 Stack,
28846 {
28847 direction: "row",
28848 gap: "sm",
28849 className: "dataviews-view-config__sort-controls",
28850 children: [
28851 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(SortFieldControl, {}),
28852 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(SortDirectionControl, {})
28853 ]
28854 }
28855 ),
28856 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(activeLayout.viewConfigOptions, {}),
28857 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(ItemsPerPageControl, {}),
28858 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(PropertiesSection, {})
28859 ] })
28860 ]
28861 }
28862 )
28863 }
28864 )
28865 }
28866 );
28867 }
28868 function _DataViewsViewConfig() {
28869 return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(import_jsx_runtime134.Fragment, { children: [
28870 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(ViewTypeMenu, {}),
28871 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(DataviewsViewConfigDropdown, {})
28872 ] });
28873 }
28874 var DataViewsViewConfig = (0, import_element92.memo)(_DataViewsViewConfig);
28875 var dataviews_view_config_default = DataViewsViewConfig;
28876
28877 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
28878 var import_components29 = __toESM(require_components(), 1);
28879 var import_element93 = __toESM(require_element(), 1);
28880
28881 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
28882 function getCustomValidity(isValid2, validity) {
28883 let customValidity;
28884 if (isValid2?.required && validity?.required) {
28885 customValidity = validity?.required?.message ? validity.required : void 0;
28886 } else if (isValid2?.pattern && validity?.pattern) {
28887 customValidity = validity.pattern;
28888 } else if (isValid2?.min && validity?.min) {
28889 customValidity = validity.min;
28890 } else if (isValid2?.max && validity?.max) {
28891 customValidity = validity.max;
28892 } else if (isValid2?.minLength && validity?.minLength) {
28893 customValidity = validity.minLength;
28894 } else if (isValid2?.maxLength && validity?.maxLength) {
28895 customValidity = validity.maxLength;
28896 } else if (isValid2?.elements && validity?.elements) {
28897 customValidity = validity.elements;
28898 } else if (validity?.custom) {
28899 customValidity = validity.custom;
28900 }
28901 return customValidity;
28902 }
28903
28904 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
28905 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1);
28906 var { ValidatedCheckboxControl } = unlock3(import_components29.privateApis);
28907 function Checkbox({
28908 field,
28909 onChange,
28910 data,
28911 hideLabelFromVision,
28912 markWhenOptional,
28913 validity
28914 }) {
28915 const { getValue, setValue, label, description, isValid: isValid2 } = field;
28916 const disabled2 = field.isDisabled({ item: data, field });
28917 const onChangeControl = (0, import_element93.useCallback)(() => {
28918 onChange(
28919 setValue({ item: data, value: !getValue({ item: data }) })
28920 );
28921 }, [data, getValue, onChange, setValue]);
28922 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
28923 ValidatedCheckboxControl,
28924 {
28925 required: !!field.isValid?.required,
28926 markWhenOptional,
28927 customValidity: getCustomValidity(isValid2, validity),
28928 hidden: hideLabelFromVision,
28929 label,
28930 help: description,
28931 checked: getValue({ item: data }),
28932 onChange: onChangeControl,
28933 disabled: disabled2
28934 }
28935 );
28936 }
28937
28938 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
28939 var import_components30 = __toESM(require_components(), 1);
28940 var import_element94 = __toESM(require_element(), 1);
28941 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1);
28942 var { ValidatedComboboxControl } = unlock3(import_components30.privateApis);
28943 function Combobox3({
28944 data,
28945 field,
28946 onChange,
28947 hideLabelFromVision,
28948 validity
28949 }) {
28950 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
28951 const value = getValue({ item: data }) ?? "";
28952 const onChangeControl = (0, import_element94.useCallback)(
28953 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
28954 [data, onChange, setValue]
28955 );
28956 const { elements, isLoading } = useElements({
28957 elements: field.elements,
28958 getElements: field.getElements
28959 });
28960 if (isLoading) {
28961 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_components30.Spinner, {});
28962 }
28963 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
28964 ValidatedComboboxControl,
28965 {
28966 required: !!field.isValid?.required,
28967 customValidity: getCustomValidity(isValid2, validity),
28968 label,
28969 value,
28970 help: description,
28971 placeholder,
28972 options: elements,
28973 onChange: onChangeControl,
28974 hideLabelFromVision,
28975 allowReset: true,
28976 expandOnFocus: true
28977 }
28978 );
28979 }
28980
28981 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
28982 var import_components32 = __toESM(require_components(), 1);
28983 var import_element97 = __toESM(require_element(), 1);
28984 var import_i18n37 = __toESM(require_i18n(), 1);
28985 var import_date3 = __toESM(require_date(), 1);
28986
28987 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
28988 var import_components31 = __toESM(require_components(), 1);
28989 var import_element95 = __toESM(require_element(), 1);
28990 var import_i18n36 = __toESM(require_i18n(), 1);
28991 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
28992 var TIME_UNITS_OPTIONS = {
28993 [OPERATOR_IN_THE_PAST]: [
28994 { value: "days", label: (0, import_i18n36.__)("Days") },
28995 { value: "weeks", label: (0, import_i18n36.__)("Weeks") },
28996 { value: "months", label: (0, import_i18n36.__)("Months") },
28997 { value: "years", label: (0, import_i18n36.__)("Years") }
28998 ],
28999 [OPERATOR_OVER]: [
29000 { value: "days", label: (0, import_i18n36.__)("Days ago") },
29001 { value: "weeks", label: (0, import_i18n36.__)("Weeks ago") },
29002 { value: "months", label: (0, import_i18n36.__)("Months ago") },
29003 { value: "years", label: (0, import_i18n36.__)("Years ago") }
29004 ]
29005 };
29006 function RelativeDateControl({
29007 className,
29008 data,
29009 field,
29010 onChange,
29011 hideLabelFromVision,
29012 operator
29013 }) {
29014 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
29015 const { id, label, description, getValue, setValue } = field;
29016 const disabled2 = field.isDisabled({ item: data, field });
29017 const fieldValue = getValue({ item: data });
29018 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
29019 const onChangeValue = (0, import_element95.useCallback)(
29020 (newValue) => onChange(
29021 setValue({
29022 item: data,
29023 value: { value: Number(newValue), unit }
29024 })
29025 ),
29026 [onChange, setValue, data, unit]
29027 );
29028 const onChangeUnit = (0, import_element95.useCallback)(
29029 (newUnit) => onChange(
29030 setValue({
29031 item: data,
29032 value: { value: relValue, unit: newUnit }
29033 })
29034 ),
29035 [onChange, setValue, data, relValue]
29036 );
29037 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29038 import_components31.BaseControl,
29039 {
29040 id,
29041 className: clsx_default(className, "dataviews-controls__relative-date"),
29042 label,
29043 hideLabelFromVision,
29044 help: description,
29045 children: /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(Stack, { direction: "row", gap: "sm", children: [
29046 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29047 import_components31.__experimentalNumberControl,
29048 {
29049 __next40pxDefaultSize: true,
29050 className: "dataviews-controls__relative-date-number",
29051 spinControls: "none",
29052 min: 1,
29053 step: 1,
29054 value: relValue,
29055 onChange: onChangeValue,
29056 disabled: disabled2
29057 }
29058 ),
29059 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
29060 import_components31.SelectControl,
29061 {
29062 className: "dataviews-controls__relative-date-unit",
29063 __next40pxDefaultSize: true,
29064 label: (0, import_i18n36.__)("Unit"),
29065 value: unit,
29066 options,
29067 onChange: onChangeUnit,
29068 hideLabelFromVision: true,
29069 disabled: disabled2
29070 }
29071 )
29072 ] })
29073 }
29074 );
29075 }
29076
29077 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
29078 var import_element96 = __toESM(require_element(), 1);
29079 function useDisabledDateMatchers(isValid2, parseDateFn) {
29080 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
29081 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
29082 const disabledMatchers = (0, import_element96.useMemo)(() => {
29083 const matchers = [];
29084 if (minConstraint) {
29085 const minDate = parseDateFn(minConstraint);
29086 if (minDate) {
29087 matchers.push({ before: minDate });
29088 }
29089 }
29090 if (maxConstraint) {
29091 const maxDate = parseDateFn(maxConstraint);
29092 if (maxDate) {
29093 matchers.push({ after: maxDate });
29094 }
29095 }
29096 return matchers.length > 0 ? matchers : void 0;
29097 }, [minConstraint, maxConstraint, parseDateFn]);
29098 return { minConstraint, maxConstraint, disabledMatchers };
29099 }
29100
29101 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
29102 var import_date2 = __toESM(require_date(), 1);
29103 function parseDateTime(dateTimeString) {
29104 if (!dateTimeString) {
29105 return null;
29106 }
29107 const parsed = (0, import_date2.getDate)(dateTimeString);
29108 return parsed && isValid(parsed) ? parsed : null;
29109 }
29110
29111 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
29112 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1);
29113 var { DateCalendar, ValidatedInputControl } = unlock3(import_components32.privateApis);
29114 var formatDateTime = (value) => {
29115 if (!value) {
29116 return "";
29117 }
29118 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
29119 };
29120 function CalendarDateTimeControl({
29121 data,
29122 field,
29123 onChange,
29124 hideLabelFromVision,
29125 markWhenOptional,
29126 validity,
29127 config
29128 }) {
29129 const { compact } = config || {};
29130 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
29131 const disabled2 = field.isDisabled({ item: data, field });
29132 const fieldValue = getValue({ item: data });
29133 const value = typeof fieldValue === "string" ? fieldValue : void 0;
29134 const [calendarMonth, setCalendarMonth] = (0, import_element97.useState)(() => {
29135 const parsedDate = parseDateTime(value);
29136 return parsedDate || /* @__PURE__ */ new Date();
29137 });
29138 const inputControlRef = (0, import_element97.useRef)(null);
29139 const validationTimeoutRef = (0, import_element97.useRef)(void 0);
29140 const previousFocusRef = (0, import_element97.useRef)(null);
29141 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
29142 const onChangeCallback = (0, import_element97.useCallback)(
29143 (newValue) => onChange(setValue({ item: data, value: newValue })),
29144 [data, onChange, setValue]
29145 );
29146 (0, import_element97.useEffect)(() => {
29147 return () => {
29148 if (validationTimeoutRef.current) {
29149 clearTimeout(validationTimeoutRef.current);
29150 }
29151 };
29152 }, []);
29153 const onSelectDate = (0, import_element97.useCallback)(
29154 (newDate) => {
29155 let dateTimeValue;
29156 if (newDate) {
29157 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
29158 let wpTime;
29159 if (value) {
29160 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
29161 } else {
29162 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
29163 }
29164 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
29165 dateTimeValue = finalDateTime.toISOString();
29166 onChangeCallback(dateTimeValue);
29167 if (validationTimeoutRef.current) {
29168 clearTimeout(validationTimeoutRef.current);
29169 }
29170 } else {
29171 onChangeCallback(void 0);
29172 }
29173 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
29174 validationTimeoutRef.current = setTimeout(() => {
29175 if (inputControlRef.current) {
29176 inputControlRef.current.focus();
29177 inputControlRef.current.blur();
29178 onChangeCallback(dateTimeValue);
29179 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
29180 previousFocusRef.current.focus();
29181 }
29182 }
29183 }, 0);
29184 },
29185 [onChangeCallback, value]
29186 );
29187 const handleManualDateTimeChange = (0, import_element97.useCallback)(
29188 (newValue) => {
29189 if (newValue) {
29190 const dateTime = (0, import_date3.getDate)(newValue);
29191 onChangeCallback(dateTime.toISOString());
29192 const parsedDate = parseDateTime(dateTime.toISOString());
29193 if (parsedDate) {
29194 setCalendarMonth(parsedDate);
29195 }
29196 } else {
29197 onChangeCallback(void 0);
29198 }
29199 },
29200 [onChangeCallback]
29201 );
29202 const { format: fieldFormat } = field;
29203 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
29204 const {
29205 timezone: { string: timezoneString }
29206 } = (0, import_date3.getSettings)();
29207 let displayLabel = label;
29208 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
29209 displayLabel = `${label} (${(0, import_i18n37.__)("Required")})`;
29210 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
29211 displayLabel = `${label} (${(0, import_i18n37.__)("Optional")})`;
29212 }
29213 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
29214 import_components32.BaseControl,
29215 {
29216 id,
29217 label: displayLabel,
29218 help: description,
29219 hideLabelFromVision,
29220 children: /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(Stack, { direction: "column", gap: "lg", children: [
29221 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
29222 ValidatedInputControl,
29223 {
29224 ref: inputControlRef,
29225 __next40pxDefaultSize: true,
29226 required: !!isValid2?.required,
29227 customValidity: getCustomValidity(isValid2, validity),
29228 type: "datetime-local",
29229 label: (0, import_i18n37.__)("Date time"),
29230 hideLabelFromVision: true,
29231 value: formatDateTime(value),
29232 onChange: handleManualDateTimeChange,
29233 disabled: disabled2,
29234 min: minConstraint ? formatDateTime(minConstraint) : void 0,
29235 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
29236 }
29237 ),
29238 !compact && /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
29239 DateCalendar,
29240 {
29241 style: { width: "100%" },
29242 selected: value ? parseDateTime(value) || void 0 : void 0,
29243 onSelect: onSelectDate,
29244 month: calendarMonth,
29245 onMonthChange: setCalendarMonth,
29246 timeZone: timezoneString || void 0,
29247 weekStartsOn,
29248 disabled: disabled2 || disabledMatchers
29249 }
29250 )
29251 ] })
29252 }
29253 );
29254 }
29255 function DateTime({
29256 data,
29257 field,
29258 onChange,
29259 hideLabelFromVision,
29260 markWhenOptional,
29261 operator,
29262 validity,
29263 config
29264 }) {
29265 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
29266 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
29267 RelativeDateControl,
29268 {
29269 className: "dataviews-controls__datetime",
29270 data,
29271 field,
29272 onChange,
29273 hideLabelFromVision,
29274 operator
29275 }
29276 );
29277 }
29278 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
29279 CalendarDateTimeControl,
29280 {
29281 data,
29282 field,
29283 onChange,
29284 hideLabelFromVision,
29285 markWhenOptional,
29286 validity,
29287 config
29288 }
29289 );
29290 }
29291
29292 // packages/dataviews/build-module/components/dataform-controls/date.mjs
29293 var import_components33 = __toESM(require_components(), 1);
29294 var import_element98 = __toESM(require_element(), 1);
29295 var import_i18n38 = __toESM(require_i18n(), 1);
29296 var import_date4 = __toESM(require_date(), 1);
29297 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1);
29298 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components33.privateApis);
29299 var DATE_PRESETS = [
29300 {
29301 id: "today",
29302 label: (0, import_i18n38.__)("Today"),
29303 getValue: () => (0, import_date4.getDate)(null)
29304 },
29305 {
29306 id: "yesterday",
29307 label: (0, import_i18n38.__)("Yesterday"),
29308 getValue: () => {
29309 const today = (0, import_date4.getDate)(null);
29310 return subDays(today, 1);
29311 }
29312 },
29313 {
29314 id: "past-week",
29315 label: (0, import_i18n38.__)("Past week"),
29316 getValue: () => {
29317 const today = (0, import_date4.getDate)(null);
29318 return subDays(today, 7);
29319 }
29320 },
29321 {
29322 id: "past-month",
29323 label: (0, import_i18n38.__)("Past month"),
29324 getValue: () => {
29325 const today = (0, import_date4.getDate)(null);
29326 return subMonths(today, 1);
29327 }
29328 }
29329 ];
29330 var DATE_RANGE_PRESETS = [
29331 {
29332 id: "last-7-days",
29333 label: (0, import_i18n38.__)("Last 7 days"),
29334 getValue: () => {
29335 const today = (0, import_date4.getDate)(null);
29336 return [subDays(today, 7), today];
29337 }
29338 },
29339 {
29340 id: "last-30-days",
29341 label: (0, import_i18n38.__)("Last 30 days"),
29342 getValue: () => {
29343 const today = (0, import_date4.getDate)(null);
29344 return [subDays(today, 30), today];
29345 }
29346 },
29347 {
29348 id: "month-to-date",
29349 label: (0, import_i18n38.__)("Month to date"),
29350 getValue: () => {
29351 const today = (0, import_date4.getDate)(null);
29352 return [startOfMonth(today), today];
29353 }
29354 },
29355 {
29356 id: "last-year",
29357 label: (0, import_i18n38.__)("Last year"),
29358 getValue: () => {
29359 const today = (0, import_date4.getDate)(null);
29360 return [subYears(today, 1), today];
29361 }
29362 },
29363 {
29364 id: "year-to-date",
29365 label: (0, import_i18n38.__)("Year to date"),
29366 getValue: () => {
29367 const today = (0, import_date4.getDate)(null);
29368 return [startOfYear(today), today];
29369 }
29370 }
29371 ];
29372 var parseDate = (dateString) => {
29373 if (!dateString) {
29374 return null;
29375 }
29376 const parsed = (0, import_date4.getDate)(dateString);
29377 return parsed && isValid(parsed) ? parsed : null;
29378 };
29379 var formatDate = (date) => {
29380 if (!date) {
29381 return "";
29382 }
29383 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
29384 };
29385 function ValidatedDateControl({
29386 field,
29387 validity,
29388 inputRefs,
29389 isTouched,
29390 setIsTouched,
29391 children
29392 }) {
29393 const { isValid: isValid2 } = field;
29394 const [customValidity, setCustomValidity] = (0, import_element98.useState)(void 0);
29395 const validateRefs = (0, import_element98.useCallback)(() => {
29396 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
29397 for (const ref of refs) {
29398 const input = ref.current;
29399 if (input && !input.validity.valid) {
29400 setCustomValidity({
29401 type: "invalid",
29402 message: input.validationMessage
29403 });
29404 return;
29405 }
29406 }
29407 setCustomValidity(void 0);
29408 }, [inputRefs]);
29409 (0, import_element98.useEffect)(() => {
29410 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
29411 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
29412 for (const ref of refs) {
29413 const input = ref.current;
29414 if (input) {
29415 input.setCustomValidity(
29416 result?.type === "invalid" && result.message ? result.message : ""
29417 );
29418 }
29419 }
29420 }, [inputRefs, isValid2, validity]);
29421 (0, import_element98.useEffect)(() => {
29422 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
29423 const handleInvalid = (event) => {
29424 event.preventDefault();
29425 setIsTouched(true);
29426 };
29427 for (const ref of refs) {
29428 ref.current?.addEventListener("invalid", handleInvalid);
29429 }
29430 return () => {
29431 for (const ref of refs) {
29432 ref.current?.removeEventListener("invalid", handleInvalid);
29433 }
29434 };
29435 }, [inputRefs, setIsTouched]);
29436 (0, import_element98.useEffect)(() => {
29437 if (!isTouched) {
29438 return;
29439 }
29440 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
29441 if (result) {
29442 setCustomValidity(result);
29443 } else {
29444 validateRefs();
29445 }
29446 }, [isTouched, isValid2, validity, validateRefs]);
29447 const onBlur = (event) => {
29448 if (isTouched) {
29449 return;
29450 }
29451 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
29452 setIsTouched(true);
29453 }
29454 };
29455 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)("div", { onBlur, children: [
29456 children,
29457 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(
29458 "p",
29459 {
29460 className: clsx_default(
29461 "components-validated-control__indicator",
29462 customValidity.type === "invalid" ? "is-invalid" : void 0
29463 ),
29464 children: [
29465 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29466 import_components33.Icon,
29467 {
29468 className: "components-validated-control__indicator-icon",
29469 icon: error_default,
29470 size: 16,
29471 fill: "currentColor"
29472 }
29473 ),
29474 customValidity.message
29475 ]
29476 }
29477 ) })
29478 ] });
29479 }
29480 function CalendarDateControl({
29481 data,
29482 field,
29483 onChange,
29484 hideLabelFromVision,
29485 markWhenOptional,
29486 validity
29487 }) {
29488 const {
29489 id,
29490 label,
29491 description,
29492 setValue,
29493 getValue,
29494 isValid: isValid2,
29495 format: fieldFormat
29496 } = field;
29497 const disabled2 = field.isDisabled({ item: data, field });
29498 const [selectedPresetId, setSelectedPresetId] = (0, import_element98.useState)(
29499 null
29500 );
29501 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
29502 const fieldValue = getValue({ item: data });
29503 const value = typeof fieldValue === "string" ? fieldValue : void 0;
29504 const [calendarMonth, setCalendarMonth] = (0, import_element98.useState)(() => {
29505 const parsedDate = parseDate(value);
29506 return parsedDate || /* @__PURE__ */ new Date();
29507 });
29508 const [isTouched, setIsTouched] = (0, import_element98.useState)(false);
29509 const validityTargetRef = (0, import_element98.useRef)(null);
29510 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
29511 const onChangeCallback = (0, import_element98.useCallback)(
29512 (newValue) => onChange(setValue({ item: data, value: newValue })),
29513 [data, onChange, setValue]
29514 );
29515 const onSelectDate = (0, import_element98.useCallback)(
29516 (newDate) => {
29517 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
29518 onChangeCallback(dateValue);
29519 setSelectedPresetId(null);
29520 setIsTouched(true);
29521 },
29522 [onChangeCallback]
29523 );
29524 const handlePresetClick = (0, import_element98.useCallback)(
29525 (preset) => {
29526 const presetDate = preset.getValue();
29527 const dateValue = formatDate(presetDate);
29528 setCalendarMonth(presetDate);
29529 onChangeCallback(dateValue);
29530 setSelectedPresetId(preset.id);
29531 setIsTouched(true);
29532 },
29533 [onChangeCallback]
29534 );
29535 const handleManualDateChange = (0, import_element98.useCallback)(
29536 (newValue) => {
29537 onChangeCallback(newValue);
29538 if (newValue) {
29539 const parsedDate = parseDate(newValue);
29540 if (parsedDate) {
29541 setCalendarMonth(parsedDate);
29542 }
29543 }
29544 setSelectedPresetId(null);
29545 setIsTouched(true);
29546 },
29547 [onChangeCallback]
29548 );
29549 const {
29550 timezone: { string: timezoneString }
29551 } = (0, import_date4.getSettings)();
29552 let displayLabel = label;
29553 if (isValid2?.required && !markWhenOptional) {
29554 displayLabel = `${label} (${(0, import_i18n38.__)("Required")})`;
29555 } else if (!isValid2?.required && markWhenOptional) {
29556 displayLabel = `${label} (${(0, import_i18n38.__)("Optional")})`;
29557 }
29558 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29559 ValidatedDateControl,
29560 {
29561 field,
29562 validity,
29563 inputRefs: validityTargetRef,
29564 isTouched,
29565 setIsTouched,
29566 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29567 import_components33.BaseControl,
29568 {
29569 id,
29570 className: "dataviews-controls__date",
29571 label: displayLabel,
29572 help: description,
29573 hideLabelFromVision,
29574 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(Stack, { direction: "column", gap: "lg", children: [
29575 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(
29576 Stack,
29577 {
29578 direction: "row",
29579 gap: "sm",
29580 wrap: "wrap",
29581 justify: "flex-start",
29582 children: [
29583 DATE_PRESETS.map((preset) => {
29584 const isSelected2 = selectedPresetId === preset.id;
29585 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29586 import_components33.Button,
29587 {
29588 className: "dataviews-controls__date-preset",
29589 variant: "tertiary",
29590 isPressed: isSelected2,
29591 size: "small",
29592 disabled: disabled2,
29593 accessibleWhenDisabled: true,
29594 onClick: () => handlePresetClick(preset),
29595 children: preset.label
29596 },
29597 preset.id
29598 );
29599 }),
29600 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29601 import_components33.Button,
29602 {
29603 className: "dataviews-controls__date-preset",
29604 variant: "tertiary",
29605 isPressed: !selectedPresetId,
29606 size: "small",
29607 disabled: !!selectedPresetId || disabled2,
29608 accessibleWhenDisabled: true,
29609 children: (0, import_i18n38.__)("Custom")
29610 }
29611 )
29612 ]
29613 }
29614 ),
29615 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29616 import_components33.__experimentalInputControl,
29617 {
29618 __next40pxDefaultSize: true,
29619 ref: validityTargetRef,
29620 type: "date",
29621 label: (0, import_i18n38.__)("Date"),
29622 hideLabelFromVision: true,
29623 value,
29624 onChange: handleManualDateChange,
29625 required: !!field.isValid?.required,
29626 disabled: disabled2,
29627 min: minConstraint,
29628 max: maxConstraint
29629 }
29630 ),
29631 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29632 DateCalendar2,
29633 {
29634 style: { width: "100%" },
29635 selected: value ? parseDate(value) || void 0 : void 0,
29636 onSelect: onSelectDate,
29637 month: calendarMonth,
29638 onMonthChange: setCalendarMonth,
29639 timeZone: timezoneString || void 0,
29640 weekStartsOn,
29641 disabled: disabled2 || disabledMatchers,
29642 disableNavigation: disabled2
29643 }
29644 )
29645 ] })
29646 }
29647 )
29648 }
29649 );
29650 }
29651 function CalendarDateRangeControl({
29652 data,
29653 field,
29654 onChange,
29655 hideLabelFromVision,
29656 markWhenOptional,
29657 validity
29658 }) {
29659 const {
29660 id,
29661 label,
29662 description,
29663 getValue,
29664 setValue,
29665 isValid: isValid2,
29666 format: fieldFormat
29667 } = field;
29668 const disabled2 = field.isDisabled({ item: data, field });
29669 let value;
29670 const fieldValue = getValue({ item: data });
29671 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
29672 value = fieldValue;
29673 }
29674 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
29675 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
29676 const onChangeCallback = (0, import_element98.useCallback)(
29677 (newValue) => {
29678 onChange(
29679 setValue({
29680 item: data,
29681 value: newValue
29682 })
29683 );
29684 },
29685 [data, onChange, setValue]
29686 );
29687 const [selectedPresetId, setSelectedPresetId] = (0, import_element98.useState)(
29688 null
29689 );
29690 const selectedRange = (0, import_element98.useMemo)(() => {
29691 if (!value) {
29692 return { from: void 0, to: void 0 };
29693 }
29694 const [from, to] = value;
29695 return {
29696 from: parseDate(from) || void 0,
29697 to: parseDate(to) || void 0
29698 };
29699 }, [value]);
29700 const [calendarMonth, setCalendarMonth] = (0, import_element98.useState)(() => {
29701 return selectedRange.from || /* @__PURE__ */ new Date();
29702 });
29703 const [isTouched, setIsTouched] = (0, import_element98.useState)(false);
29704 const fromInputRef = (0, import_element98.useRef)(null);
29705 const toInputRef = (0, import_element98.useRef)(null);
29706 const updateDateRange = (0, import_element98.useCallback)(
29707 (fromDate, toDate2) => {
29708 if (fromDate && toDate2) {
29709 onChangeCallback([
29710 formatDate(fromDate),
29711 formatDate(toDate2)
29712 ]);
29713 } else if (!fromDate && !toDate2) {
29714 onChangeCallback(void 0);
29715 }
29716 },
29717 [onChangeCallback]
29718 );
29719 const onSelectCalendarRange = (0, import_element98.useCallback)(
29720 (newRange) => {
29721 updateDateRange(newRange?.from, newRange?.to);
29722 setSelectedPresetId(null);
29723 setIsTouched(true);
29724 },
29725 [updateDateRange]
29726 );
29727 const handlePresetClick = (0, import_element98.useCallback)(
29728 (preset) => {
29729 const [startDate, endDate] = preset.getValue();
29730 setCalendarMonth(startDate);
29731 updateDateRange(startDate, endDate);
29732 setSelectedPresetId(preset.id);
29733 setIsTouched(true);
29734 },
29735 [updateDateRange]
29736 );
29737 const handleManualDateChange = (0, import_element98.useCallback)(
29738 (fromOrTo, newValue) => {
29739 const [currentFrom, currentTo] = value || [
29740 void 0,
29741 void 0
29742 ];
29743 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
29744 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
29745 updateDateRange(updatedFrom, updatedTo);
29746 if (newValue) {
29747 const parsedDate = parseDate(newValue);
29748 if (parsedDate) {
29749 setCalendarMonth(parsedDate);
29750 }
29751 }
29752 setSelectedPresetId(null);
29753 setIsTouched(true);
29754 },
29755 [value, updateDateRange]
29756 );
29757 const { timezone } = (0, import_date4.getSettings)();
29758 let displayLabel = label;
29759 if (field.isValid?.required && !markWhenOptional) {
29760 displayLabel = `${label} (${(0, import_i18n38.__)("Required")})`;
29761 } else if (!field.isValid?.required && markWhenOptional) {
29762 displayLabel = `${label} (${(0, import_i18n38.__)("Optional")})`;
29763 }
29764 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29765 ValidatedDateControl,
29766 {
29767 field,
29768 validity,
29769 inputRefs: [fromInputRef, toInputRef],
29770 isTouched,
29771 setIsTouched,
29772 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29773 import_components33.BaseControl,
29774 {
29775 id,
29776 className: "dataviews-controls__date",
29777 label: displayLabel,
29778 help: description,
29779 hideLabelFromVision,
29780 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(Stack, { direction: "column", gap: "lg", children: [
29781 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(
29782 Stack,
29783 {
29784 direction: "row",
29785 gap: "sm",
29786 wrap: "wrap",
29787 justify: "flex-start",
29788 children: [
29789 DATE_RANGE_PRESETS.map((preset) => {
29790 const isSelected2 = selectedPresetId === preset.id;
29791 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29792 import_components33.Button,
29793 {
29794 className: "dataviews-controls__date-preset",
29795 variant: "tertiary",
29796 isPressed: isSelected2,
29797 size: "small",
29798 disabled: disabled2,
29799 accessibleWhenDisabled: true,
29800 onClick: () => handlePresetClick(preset),
29801 children: preset.label
29802 },
29803 preset.id
29804 );
29805 }),
29806 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29807 import_components33.Button,
29808 {
29809 className: "dataviews-controls__date-preset",
29810 variant: "tertiary",
29811 isPressed: !selectedPresetId,
29812 size: "small",
29813 accessibleWhenDisabled: true,
29814 disabled: !!selectedPresetId || disabled2,
29815 children: (0, import_i18n38.__)("Custom")
29816 }
29817 )
29818 ]
29819 }
29820 ),
29821 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(
29822 Stack,
29823 {
29824 direction: "row",
29825 gap: "sm",
29826 justify: "space-between",
29827 className: "dataviews-controls__date-range-inputs",
29828 children: [
29829 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29830 import_components33.__experimentalInputControl,
29831 {
29832 __next40pxDefaultSize: true,
29833 ref: fromInputRef,
29834 type: "date",
29835 label: (0, import_i18n38.__)("From"),
29836 hideLabelFromVision: true,
29837 value: value?.[0],
29838 onChange: (newValue) => handleManualDateChange("from", newValue),
29839 required: !!field.isValid?.required,
29840 disabled: disabled2,
29841 min: minConstraint,
29842 max: maxConstraint
29843 }
29844 ),
29845 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29846 import_components33.__experimentalInputControl,
29847 {
29848 __next40pxDefaultSize: true,
29849 ref: toInputRef,
29850 type: "date",
29851 label: (0, import_i18n38.__)("To"),
29852 hideLabelFromVision: true,
29853 value: value?.[1],
29854 onChange: (newValue) => handleManualDateChange("to", newValue),
29855 required: !!field.isValid?.required,
29856 disabled: disabled2,
29857 min: minConstraint,
29858 max: maxConstraint
29859 }
29860 )
29861 ]
29862 }
29863 ),
29864 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29865 DateRangeCalendar,
29866 {
29867 style: { width: "100%" },
29868 selected: selectedRange,
29869 onSelect: onSelectCalendarRange,
29870 month: calendarMonth,
29871 onMonthChange: setCalendarMonth,
29872 timeZone: timezone.string || void 0,
29873 weekStartsOn,
29874 disabled: disabled2 || disabledMatchers
29875 }
29876 )
29877 ] })
29878 }
29879 )
29880 }
29881 );
29882 }
29883 function DateControl({
29884 data,
29885 field,
29886 onChange,
29887 hideLabelFromVision,
29888 markWhenOptional,
29889 operator,
29890 validity
29891 }) {
29892 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
29893 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29894 RelativeDateControl,
29895 {
29896 className: "dataviews-controls__date",
29897 data,
29898 field,
29899 onChange,
29900 hideLabelFromVision,
29901 operator
29902 }
29903 );
29904 }
29905 if (operator === OPERATOR_BETWEEN) {
29906 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29907 CalendarDateRangeControl,
29908 {
29909 data,
29910 field,
29911 onChange,
29912 hideLabelFromVision,
29913 markWhenOptional,
29914 validity
29915 }
29916 );
29917 }
29918 return /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
29919 CalendarDateControl,
29920 {
29921 data,
29922 field,
29923 onChange,
29924 hideLabelFromVision,
29925 markWhenOptional,
29926 validity
29927 }
29928 );
29929 }
29930
29931 // packages/dataviews/build-module/components/dataform-controls/select.mjs
29932 var import_components34 = __toESM(require_components(), 1);
29933 var import_element99 = __toESM(require_element(), 1);
29934 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1);
29935 var { ValidatedSelectControl } = unlock3(import_components34.privateApis);
29936 function Select({
29937 data,
29938 field,
29939 onChange,
29940 hideLabelFromVision,
29941 markWhenOptional,
29942 validity
29943 }) {
29944 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
29945 const disabled2 = field.isDisabled({ item: data, field });
29946 const isMultiple = type === "array";
29947 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
29948 const onChangeControl = (0, import_element99.useCallback)(
29949 (newValue) => onChange(setValue({ item: data, value: newValue })),
29950 [data, onChange, setValue]
29951 );
29952 const { elements, isLoading } = useElements({
29953 elements: field.elements,
29954 getElements: field.getElements
29955 });
29956 if (isLoading) {
29957 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components34.Spinner, {});
29958 }
29959 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
29960 ValidatedSelectControl,
29961 {
29962 required: !!field.isValid?.required,
29963 markWhenOptional,
29964 customValidity: getCustomValidity(isValid2, validity),
29965 label,
29966 value,
29967 help: description,
29968 options: elements,
29969 onChange: onChangeControl,
29970 __next40pxDefaultSize: true,
29971 hideLabelFromVision,
29972 multiple: isMultiple,
29973 disabled: disabled2
29974 }
29975 );
29976 }
29977
29978 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
29979 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1);
29980 var ELEMENTS_THRESHOLD = 10;
29981 function AdaptiveSelect(props) {
29982 const { field } = props;
29983 const { elements } = useElements({
29984 elements: field.elements,
29985 getElements: field.getElements
29986 });
29987 if (elements.length >= ELEMENTS_THRESHOLD) {
29988 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Combobox3, { ...props });
29989 }
29990 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Select, { ...props });
29991 }
29992
29993 // packages/dataviews/build-module/components/dataform-controls/email.mjs
29994 var import_components36 = __toESM(require_components(), 1);
29995
29996 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
29997 var import_components35 = __toESM(require_components(), 1);
29998 var import_element100 = __toESM(require_element(), 1);
29999 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1);
30000 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components35.privateApis);
30001 function ValidatedText({
30002 data,
30003 field,
30004 onChange,
30005 hideLabelFromVision,
30006 markWhenOptional,
30007 type,
30008 prefix,
30009 suffix,
30010 validity
30011 }) {
30012 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
30013 const value = getValue({ item: data });
30014 const disabled2 = field.isDisabled({ item: data, field });
30015 const onChangeControl = (0, import_element100.useCallback)(
30016 (newValue) => onChange(
30017 setValue({
30018 item: data,
30019 value: newValue
30020 })
30021 ),
30022 [data, setValue, onChange]
30023 );
30024 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
30025 ValidatedInputControl2,
30026 {
30027 required: !!isValid2.required,
30028 markWhenOptional,
30029 customValidity: getCustomValidity(isValid2, validity),
30030 label,
30031 placeholder,
30032 value: value ?? "",
30033 help: description,
30034 onChange: onChangeControl,
30035 hideLabelFromVision,
30036 type,
30037 prefix,
30038 suffix,
30039 disabled: disabled2,
30040 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
30041 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
30042 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
30043 __next40pxDefaultSize: true
30044 }
30045 );
30046 }
30047
30048 // packages/dataviews/build-module/components/dataform-controls/email.mjs
30049 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1);
30050 function Email({
30051 data,
30052 field,
30053 onChange,
30054 hideLabelFromVision,
30055 markWhenOptional,
30056 validity
30057 }) {
30058 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
30059 ValidatedText,
30060 {
30061 ...{
30062 data,
30063 field,
30064 onChange,
30065 hideLabelFromVision,
30066 markWhenOptional,
30067 validity,
30068 type: "email",
30069 prefix: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_components36.Icon, { icon: envelope_default }) })
30070 }
30071 }
30072 );
30073 }
30074
30075 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
30076 var import_components37 = __toESM(require_components(), 1);
30077 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1);
30078 function Telephone({
30079 data,
30080 field,
30081 onChange,
30082 hideLabelFromVision,
30083 markWhenOptional,
30084 validity
30085 }) {
30086 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
30087 ValidatedText,
30088 {
30089 ...{
30090 data,
30091 field,
30092 onChange,
30093 hideLabelFromVision,
30094 markWhenOptional,
30095 validity,
30096 type: "tel",
30097 prefix: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components37.Icon, { icon: mobile_default }) })
30098 }
30099 }
30100 );
30101 }
30102
30103 // packages/dataviews/build-module/components/dataform-controls/url.mjs
30104 var import_components38 = __toESM(require_components(), 1);
30105 var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1);
30106 function Url({
30107 data,
30108 field,
30109 onChange,
30110 hideLabelFromVision,
30111 markWhenOptional,
30112 validity
30113 }) {
30114 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
30115 ValidatedText,
30116 {
30117 ...{
30118 data,
30119 field,
30120 onChange,
30121 hideLabelFromVision,
30122 markWhenOptional,
30123 validity,
30124 type: "url",
30125 prefix: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components38.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components38.Icon, { icon: link_default }) })
30126 }
30127 }
30128 );
30129 }
30130
30131 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
30132 var import_components39 = __toESM(require_components(), 1);
30133 var import_element101 = __toESM(require_element(), 1);
30134 var import_i18n39 = __toESM(require_i18n(), 1);
30135 var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1);
30136 var { ValidatedNumberControl } = unlock3(import_components39.privateApis);
30137 function toNumberOrEmpty(value) {
30138 if (value === "" || value === void 0) {
30139 return "";
30140 }
30141 const number = Number(value);
30142 return Number.isFinite(number) ? number : "";
30143 }
30144 function BetweenControls({
30145 value,
30146 onChange,
30147 hideLabelFromVision,
30148 step
30149 }) {
30150 const [min2 = "", max2 = ""] = value;
30151 const onChangeMin = (0, import_element101.useCallback)(
30152 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
30153 [onChange, max2]
30154 );
30155 const onChangeMax = (0, import_element101.useCallback)(
30156 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
30157 [onChange, min2]
30158 );
30159 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
30160 import_components39.BaseControl,
30161 {
30162 help: (0, import_i18n39.__)("The max. value must be greater than the min. value."),
30163 children: /* @__PURE__ */ (0, import_jsx_runtime146.jsxs)(import_components39.Flex, { direction: "row", gap: 4, children: [
30164 /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
30165 import_components39.__experimentalNumberControl,
30166 {
30167 label: (0, import_i18n39.__)("Min."),
30168 value: min2,
30169 max: max2 ? Number(max2) - step : void 0,
30170 onChange: onChangeMin,
30171 __next40pxDefaultSize: true,
30172 hideLabelFromVision,
30173 step
30174 }
30175 ),
30176 /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
30177 import_components39.__experimentalNumberControl,
30178 {
30179 label: (0, import_i18n39.__)("Max."),
30180 value: max2,
30181 min: min2 ? Number(min2) + step : void 0,
30182 onChange: onChangeMax,
30183 __next40pxDefaultSize: true,
30184 hideLabelFromVision,
30185 step
30186 }
30187 )
30188 ] })
30189 }
30190 );
30191 }
30192 function ValidatedNumber({
30193 data,
30194 field,
30195 onChange,
30196 hideLabelFromVision,
30197 markWhenOptional,
30198 operator,
30199 validity
30200 }) {
30201 const decimals = field.format?.decimals ?? 0;
30202 const step = Math.pow(10, Math.abs(decimals) * -1);
30203 const { label, description, getValue, setValue, isValid: isValid2 } = field;
30204 const value = getValue({ item: data }) ?? "";
30205 const disabled2 = field.isDisabled({ item: data, field });
30206 const onChangeControl = (0, import_element101.useCallback)(
30207 (newValue) => {
30208 onChange(
30209 setValue({
30210 item: data,
30211 // Do not convert an empty string or undefined to a number,
30212 // otherwise there's a mismatch between the UI control (empty)
30213 // and the data relied by onChange (0).
30214 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
30215 })
30216 );
30217 },
30218 [data, onChange, setValue]
30219 );
30220 const onChangeBetweenControls = (0, import_element101.useCallback)(
30221 (newValue) => {
30222 onChange(
30223 setValue({
30224 item: data,
30225 value: newValue
30226 })
30227 );
30228 },
30229 [data, onChange, setValue]
30230 );
30231 if (operator === OPERATOR_BETWEEN) {
30232 let valueBetween = ["", ""];
30233 if (Array.isArray(value) && value.length === 2 && value.every(
30234 (element) => typeof element === "number" || element === ""
30235 )) {
30236 valueBetween = value;
30237 }
30238 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
30239 BetweenControls,
30240 {
30241 value: valueBetween,
30242 onChange: onChangeBetweenControls,
30243 hideLabelFromVision,
30244 step
30245 }
30246 );
30247 }
30248 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
30249 ValidatedNumberControl,
30250 {
30251 required: !!isValid2.required,
30252 markWhenOptional,
30253 customValidity: getCustomValidity(isValid2, validity),
30254 label,
30255 help: description,
30256 value,
30257 onChange: onChangeControl,
30258 __next40pxDefaultSize: true,
30259 hideLabelFromVision,
30260 step,
30261 min: isValid2.min ? isValid2.min.constraint : void 0,
30262 max: isValid2.max ? isValid2.max.constraint : void 0,
30263 disabled: disabled2
30264 }
30265 );
30266 }
30267
30268 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
30269 var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1);
30270 function Integer(props) {
30271 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(ValidatedNumber, { ...props });
30272 }
30273
30274 // packages/dataviews/build-module/components/dataform-controls/number.mjs
30275 var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1);
30276 function Number2(props) {
30277 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(ValidatedNumber, { ...props });
30278 }
30279
30280 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
30281 var import_components40 = __toESM(require_components(), 1);
30282 var import_element102 = __toESM(require_element(), 1);
30283 var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1);
30284 var { ValidatedRadioControl } = unlock3(import_components40.privateApis);
30285 function Radio({
30286 data,
30287 field,
30288 onChange,
30289 hideLabelFromVision,
30290 markWhenOptional,
30291 validity
30292 }) {
30293 const { label, description, getValue, setValue, isValid: isValid2 } = field;
30294 const disabled2 = field.isDisabled({ item: data, field });
30295 const { elements, isLoading } = useElements({
30296 elements: field.elements,
30297 getElements: field.getElements
30298 });
30299 const value = getValue({ item: data });
30300 const onChangeControl = (0, import_element102.useCallback)(
30301 (newValue) => onChange(setValue({ item: data, value: newValue })),
30302 [data, onChange, setValue]
30303 );
30304 if (isLoading) {
30305 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_components40.Spinner, {});
30306 }
30307 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
30308 ValidatedRadioControl,
30309 {
30310 required: !!field.isValid?.required,
30311 markWhenOptional,
30312 customValidity: getCustomValidity(isValid2, validity),
30313 label,
30314 help: description,
30315 onChange: onChangeControl,
30316 options: elements,
30317 selected: value,
30318 hideLabelFromVision,
30319 disabled: disabled2
30320 }
30321 );
30322 }
30323
30324 // packages/dataviews/build-module/components/dataform-controls/text.mjs
30325 var import_element103 = __toESM(require_element(), 1);
30326 var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1);
30327 function Text3({
30328 data,
30329 field,
30330 onChange,
30331 hideLabelFromVision,
30332 markWhenOptional,
30333 config,
30334 validity
30335 }) {
30336 const { prefix, suffix } = config || {};
30337 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
30338 ValidatedText,
30339 {
30340 ...{
30341 data,
30342 field,
30343 onChange,
30344 hideLabelFromVision,
30345 markWhenOptional,
30346 validity,
30347 prefix: prefix ? (0, import_element103.createElement)(prefix) : void 0,
30348 suffix: suffix ? (0, import_element103.createElement)(suffix) : void 0
30349 }
30350 }
30351 );
30352 }
30353
30354 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
30355 var import_components41 = __toESM(require_components(), 1);
30356 var import_element104 = __toESM(require_element(), 1);
30357 var import_jsx_runtime151 = __toESM(require_jsx_runtime(), 1);
30358 var { ValidatedToggleControl } = unlock3(import_components41.privateApis);
30359 function Toggle({
30360 field,
30361 onChange,
30362 data,
30363 hideLabelFromVision,
30364 markWhenOptional,
30365 validity
30366 }) {
30367 const { label, description, getValue, setValue, isValid: isValid2 } = field;
30368 const disabled2 = field.isDisabled({ item: data, field });
30369 const onChangeControl = (0, import_element104.useCallback)(() => {
30370 onChange(
30371 setValue({ item: data, value: !getValue({ item: data }) })
30372 );
30373 }, [onChange, setValue, data, getValue]);
30374 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
30375 ValidatedToggleControl,
30376 {
30377 required: !!isValid2.required,
30378 markWhenOptional,
30379 customValidity: getCustomValidity(isValid2, validity),
30380 hidden: hideLabelFromVision,
30381 label,
30382 help: description,
30383 checked: getValue({ item: data }),
30384 onChange: onChangeControl,
30385 disabled: disabled2
30386 }
30387 );
30388 }
30389
30390 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
30391 var import_components42 = __toESM(require_components(), 1);
30392 var import_element105 = __toESM(require_element(), 1);
30393 var import_jsx_runtime152 = __toESM(require_jsx_runtime(), 1);
30394 var { ValidatedTextareaControl } = unlock3(import_components42.privateApis);
30395 function Textarea({
30396 data,
30397 field,
30398 onChange,
30399 hideLabelFromVision,
30400 markWhenOptional,
30401 config,
30402 validity
30403 }) {
30404 const { rows = 4 } = config || {};
30405 const disabled2 = field.isDisabled({ item: data, field });
30406 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
30407 const value = field.getValue({ item: data });
30408 const onChangeControl = (0, import_element105.useCallback)(
30409 (newValue) => onChange(setValue({ item: data, value: newValue })),
30410 [data, onChange, setValue]
30411 );
30412 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
30413 ValidatedTextareaControl,
30414 {
30415 required: !!isValid2.required,
30416 markWhenOptional,
30417 customValidity: getCustomValidity(isValid2, validity),
30418 label,
30419 placeholder,
30420 value: value ?? "",
30421 help: description,
30422 onChange: onChangeControl,
30423 rows,
30424 disabled: disabled2,
30425 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
30426 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
30427 __next40pxDefaultSize: true,
30428 hideLabelFromVision
30429 }
30430 );
30431 }
30432
30433 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
30434 var import_components43 = __toESM(require_components(), 1);
30435 var import_element106 = __toESM(require_element(), 1);
30436 var import_jsx_runtime153 = __toESM(require_jsx_runtime(), 1);
30437 var { ValidatedToggleGroupControl } = unlock3(import_components43.privateApis);
30438 function ToggleGroup({
30439 data,
30440 field,
30441 onChange,
30442 hideLabelFromVision,
30443 markWhenOptional,
30444 validity
30445 }) {
30446 const { getValue, setValue, isValid: isValid2 } = field;
30447 const disabled2 = field.isDisabled({ item: data, field });
30448 const value = getValue({ item: data });
30449 const onChangeControl = (0, import_element106.useCallback)(
30450 (newValue) => onChange(setValue({ item: data, value: newValue })),
30451 [data, onChange, setValue]
30452 );
30453 const { elements, isLoading } = useElements({
30454 elements: field.elements,
30455 getElements: field.getElements
30456 });
30457 if (isLoading) {
30458 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_components43.Spinner, {});
30459 }
30460 if (elements.length === 0) {
30461 return null;
30462 }
30463 const selectedOption = elements.find((el) => el.value === value);
30464 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
30465 ValidatedToggleGroupControl,
30466 {
30467 required: !!field.isValid?.required,
30468 markWhenOptional,
30469 customValidity: getCustomValidity(isValid2, validity),
30470 __next40pxDefaultSize: true,
30471 isBlock: true,
30472 label: field.label,
30473 help: selectedOption?.description || field.description,
30474 onChange: onChangeControl,
30475 value,
30476 hideLabelFromVision,
30477 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
30478 import_components43.__experimentalToggleGroupControlOption,
30479 {
30480 label: el.label,
30481 value: el.value,
30482 disabled: disabled2
30483 },
30484 el.value
30485 ))
30486 }
30487 );
30488 }
30489
30490 // packages/dataviews/build-module/components/dataform-controls/array.mjs
30491 var import_components44 = __toESM(require_components(), 1);
30492 var import_element107 = __toESM(require_element(), 1);
30493 var import_jsx_runtime154 = __toESM(require_jsx_runtime(), 1);
30494 var { ValidatedFormTokenField } = unlock3(import_components44.privateApis);
30495 function ArrayControl({
30496 data,
30497 field,
30498 onChange,
30499 hideLabelFromVision,
30500 markWhenOptional,
30501 validity
30502 }) {
30503 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
30504 const value = getValue({ item: data });
30505 const disabled2 = field.isDisabled({ item: data, field });
30506 const { elements, isLoading } = useElements({
30507 elements: field.elements,
30508 getElements: field.getElements
30509 });
30510 const arrayValueAsElements = (0, import_element107.useMemo)(
30511 () => Array.isArray(value) ? value.map((token) => {
30512 const element = elements?.find(
30513 (suggestion) => suggestion.value === token
30514 );
30515 return element || { value: token, label: token };
30516 }) : [],
30517 [value, elements]
30518 );
30519 const onChangeControl = (0, import_element107.useCallback)(
30520 (tokens) => {
30521 const valueTokens = tokens.map((token) => {
30522 if (typeof token === "object" && "value" in token) {
30523 return token.value;
30524 }
30525 return token;
30526 });
30527 onChange(setValue({ item: data, value: valueTokens }));
30528 },
30529 [onChange, setValue, data]
30530 );
30531 if (isLoading) {
30532 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(import_components44.Spinner, {});
30533 }
30534 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
30535 ValidatedFormTokenField,
30536 {
30537 required: !!isValid2?.required,
30538 markWhenOptional,
30539 customValidity: getCustomValidity(isValid2, validity),
30540 label: hideLabelFromVision ? void 0 : label,
30541 value: arrayValueAsElements,
30542 onChange: onChangeControl,
30543 placeholder,
30544 suggestions: elements?.map((element) => element.value),
30545 disabled: disabled2,
30546 __experimentalValidateInput: (token) => {
30547 if (field.isValid?.elements && elements) {
30548 return elements.some(
30549 (element) => element.value === token || element.label === token
30550 );
30551 }
30552 return true;
30553 },
30554 __experimentalExpandOnFocus: elements && elements.length > 0,
30555 help: description ?? (field.isValid?.elements ? "" : void 0),
30556 displayTransform: (token) => {
30557 if (typeof token === "object" && "label" in token) {
30558 return token.label;
30559 }
30560 if (typeof token === "string" && elements) {
30561 const element = elements.find(
30562 (el) => el.value === token
30563 );
30564 return element?.label || token;
30565 }
30566 return token;
30567 },
30568 __experimentalRenderItem: ({ item }) => {
30569 if (typeof item === "string" && elements) {
30570 const element = elements.find(
30571 (el) => el.value === item
30572 );
30573 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { children: element?.label || item });
30574 }
30575 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("span", { children: item });
30576 }
30577 }
30578 );
30579 }
30580
30581 // node_modules/colord/index.mjs
30582 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
30583 var t = function(r3) {
30584 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
30585 };
30586 var n = function(r3, t2, n2) {
30587 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
30588 };
30589 var e = function(r3, t2, n2) {
30590 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
30591 };
30592 var u = function(r3) {
30593 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
30594 };
30595 var a = function(r3) {
30596 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
30597 };
30598 var o = function(r3) {
30599 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
30600 };
30601 var i = /^#([0-9a-f]{3,8})$/i;
30602 var s = function(r3) {
30603 var t2 = r3.toString(16);
30604 return t2.length < 2 ? "0" + t2 : t2;
30605 };
30606 var h = function(r3) {
30607 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;
30608 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
30609 };
30610 var b = function(r3) {
30611 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
30612 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
30613 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;
30614 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 };
30615 };
30616 var g = function(r3) {
30617 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
30618 };
30619 var d = function(r3) {
30620 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
30621 };
30622 var f = function(r3) {
30623 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 }));
30624 var t2, n2, e2;
30625 };
30626 var c = function(r3) {
30627 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 };
30628 var t2, n2, e2, u2;
30629 };
30630 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30631 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30632 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30633 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
30634 var y = { string: [[function(r3) {
30635 var t2 = i.exec(r3);
30636 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;
30637 }, "hex"], [function(r3) {
30638 var t2 = v.exec(r3) || m.exec(r3);
30639 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;
30640 }, "rgb"], [function(t2) {
30641 var n2 = l.exec(t2) || p.exec(t2);
30642 if (!n2) return null;
30643 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) });
30644 return f(a2);
30645 }, "hsl"]], object: [[function(r3) {
30646 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
30647 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
30648 }, "rgb"], [function(r3) {
30649 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
30650 if (!t(n2) || !t(e2) || !t(u2)) return null;
30651 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
30652 return f(i2);
30653 }, "hsl"], [function(r3) {
30654 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
30655 if (!t(n2) || !t(a2) || !t(o2)) return null;
30656 var h2 = (function(r4) {
30657 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
30658 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
30659 return b(h2);
30660 }, "hsv"]] };
30661 var N = function(r3, t2) {
30662 for (var n2 = 0; n2 < t2.length; n2++) {
30663 var e2 = t2[n2][0](r3);
30664 if (e2) return [e2, t2[n2][1]];
30665 }
30666 return [null, void 0];
30667 };
30668 var x = function(r3) {
30669 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
30670 };
30671 var M = function(r3, t2) {
30672 var n2 = c(r3);
30673 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
30674 };
30675 var H = function(r3) {
30676 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
30677 };
30678 var $ = function(r3, t2) {
30679 var n2 = c(r3);
30680 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
30681 };
30682 var j = (function() {
30683 function r3(r4) {
30684 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
30685 }
30686 return r3.prototype.isValid = function() {
30687 return null !== this.parsed;
30688 }, r3.prototype.brightness = function() {
30689 return n(H(this.rgba), 2);
30690 }, r3.prototype.isDark = function() {
30691 return H(this.rgba) < 0.5;
30692 }, r3.prototype.isLight = function() {
30693 return H(this.rgba) >= 0.5;
30694 }, r3.prototype.toHex = function() {
30695 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;
30696 var r4, t2, e2, u2, a2, i2;
30697 }, r3.prototype.toRgb = function() {
30698 return o(this.rgba);
30699 }, r3.prototype.toRgbString = function() {
30700 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 + ")";
30701 var r4, t2, n2, e2, u2;
30702 }, r3.prototype.toHsl = function() {
30703 return d(c(this.rgba));
30704 }, r3.prototype.toHslString = function() {
30705 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 + "%)";
30706 var r4, t2, n2, e2, u2;
30707 }, r3.prototype.toHsv = function() {
30708 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
30709 var r4;
30710 }, r3.prototype.invert = function() {
30711 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
30712 var r4;
30713 }, r3.prototype.saturate = function(r4) {
30714 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
30715 }, r3.prototype.desaturate = function(r4) {
30716 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
30717 }, r3.prototype.grayscale = function() {
30718 return w(M(this.rgba, -1));
30719 }, r3.prototype.lighten = function(r4) {
30720 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
30721 }, r3.prototype.darken = function(r4) {
30722 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
30723 }, r3.prototype.rotate = function(r4) {
30724 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
30725 }, r3.prototype.alpha = function(r4) {
30726 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
30727 var t2;
30728 }, r3.prototype.hue = function(r4) {
30729 var t2 = c(this.rgba);
30730 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
30731 }, r3.prototype.isEqual = function(r4) {
30732 return this.toHex() === w(r4).toHex();
30733 }, r3;
30734 })();
30735 var w = function(r3) {
30736 return r3 instanceof j ? r3 : new j(r3);
30737 };
30738
30739 // packages/dataviews/build-module/components/dataform-controls/color.mjs
30740 var import_components45 = __toESM(require_components(), 1);
30741 var import_element108 = __toESM(require_element(), 1);
30742 var import_i18n40 = __toESM(require_i18n(), 1);
30743 var import_jsx_runtime155 = __toESM(require_jsx_runtime(), 1);
30744 var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components45.privateApis);
30745 var ColorPickerDropdown = ({
30746 color,
30747 onColorChange,
30748 disabled: disabled2
30749 }) => {
30750 const validColor = color && w(color).isValid() ? color : "#ffffff";
30751 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
30752 import_components45.Dropdown,
30753 {
30754 className: "dataviews-controls__color-picker-dropdown",
30755 popoverProps: { resize: false },
30756 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
30757 import_components45.Button,
30758 {
30759 onClick: onToggle,
30760 "aria-label": (0, import_i18n40.__)("Open color picker"),
30761 size: "small",
30762 disabled: disabled2,
30763 accessibleWhenDisabled: true,
30764 icon: () => /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
30765 }
30766 ),
30767 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
30768 import_components45.ColorPicker,
30769 {
30770 color: validColor,
30771 onChange: onColorChange,
30772 enableAlpha: true
30773 }
30774 ) })
30775 }
30776 );
30777 };
30778 function Color({
30779 data,
30780 field,
30781 onChange,
30782 hideLabelFromVision,
30783 markWhenOptional,
30784 validity
30785 }) {
30786 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
30787 const disabled2 = field.isDisabled({ item: data, field });
30788 const value = field.getValue({ item: data }) || "";
30789 const handleColorChange = (0, import_element108.useCallback)(
30790 (newColor) => {
30791 onChange(setValue({ item: data, value: newColor }));
30792 },
30793 [data, onChange, setValue]
30794 );
30795 const handleInputChange = (0, import_element108.useCallback)(
30796 (newValue) => {
30797 onChange(setValue({ item: data, value: newValue || "" }));
30798 },
30799 [data, onChange, setValue]
30800 );
30801 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
30802 ValidatedInputControl3,
30803 {
30804 required: !!field.isValid?.required,
30805 markWhenOptional,
30806 customValidity: getCustomValidity(isValid2, validity),
30807 label,
30808 placeholder,
30809 value,
30810 help: description,
30811 onChange: handleInputChange,
30812 hideLabelFromVision,
30813 type: "text",
30814 disabled: disabled2,
30815 prefix: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
30816 ColorPickerDropdown,
30817 {
30818 color: value,
30819 onColorChange: handleColorChange,
30820 disabled: disabled2
30821 }
30822 ) })
30823 }
30824 );
30825 }
30826
30827 // packages/dataviews/build-module/components/dataform-controls/password.mjs
30828 var import_components46 = __toESM(require_components(), 1);
30829 var import_element109 = __toESM(require_element(), 1);
30830 var import_i18n41 = __toESM(require_i18n(), 1);
30831 var import_jsx_runtime156 = __toESM(require_jsx_runtime(), 1);
30832 function Password({
30833 data,
30834 field,
30835 onChange,
30836 hideLabelFromVision,
30837 markWhenOptional,
30838 validity
30839 }) {
30840 const [isVisible2, setIsVisible] = (0, import_element109.useState)(false);
30841 const disabled2 = field.isDisabled({ item: data, field });
30842 const toggleVisibility = (0, import_element109.useCallback)(() => {
30843 setIsVisible((prev) => !prev);
30844 }, []);
30845 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
30846 ValidatedText,
30847 {
30848 ...{
30849 data,
30850 field,
30851 onChange,
30852 hideLabelFromVision,
30853 markWhenOptional,
30854 validity,
30855 type: isVisible2 ? "text" : "password",
30856 suffix: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
30857 import_components46.Button,
30858 {
30859 icon: isVisible2 ? unseen_default : seen_default,
30860 onClick: toggleVisibility,
30861 size: "small",
30862 label: isVisible2 ? (0, import_i18n41.__)("Hide password") : (0, import_i18n41.__)("Show password"),
30863 disabled: disabled2,
30864 accessibleWhenDisabled: true
30865 }
30866 ) })
30867 }
30868 }
30869 );
30870 }
30871
30872 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
30873 function hasElements(field) {
30874 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
30875 }
30876
30877 // packages/dataviews/build-module/components/dataform-controls/index.mjs
30878 var import_jsx_runtime157 = __toESM(require_jsx_runtime(), 1);
30879 var FORM_CONTROLS = {
30880 adaptiveSelect: AdaptiveSelect,
30881 array: ArrayControl,
30882 checkbox: Checkbox,
30883 color: Color,
30884 combobox: Combobox3,
30885 datetime: DateTime,
30886 date: DateControl,
30887 email: Email,
30888 telephone: Telephone,
30889 url: Url,
30890 integer: Integer,
30891 number: Number2,
30892 password: Password,
30893 radio: Radio,
30894 select: Select,
30895 text: Text3,
30896 toggle: Toggle,
30897 textarea: Textarea,
30898 toggleGroup: ToggleGroup
30899 };
30900 function isEditConfig(value) {
30901 return value && typeof value === "object" && typeof value.control === "string";
30902 }
30903 function createConfiguredControl(config) {
30904 const { control, ...controlConfig } = config;
30905 const BaseControlType = getControlByType(control);
30906 if (BaseControlType === null) {
30907 return null;
30908 }
30909 return function ConfiguredControl(props) {
30910 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(BaseControlType, { ...props, config: controlConfig });
30911 };
30912 }
30913 function getControl(field, fallback) {
30914 if (typeof field.Edit === "function") {
30915 return field.Edit;
30916 }
30917 if (typeof field.Edit === "string") {
30918 return getControlByType(field.Edit);
30919 }
30920 if (isEditConfig(field.Edit)) {
30921 return createConfiguredControl(field.Edit);
30922 }
30923 if (hasElements(field) && field.type !== "array") {
30924 return getControlByType("adaptiveSelect");
30925 }
30926 if (fallback === null) {
30927 return null;
30928 }
30929 return getControlByType(fallback);
30930 }
30931 function getControlByType(type) {
30932 if (Object.keys(FORM_CONTROLS).includes(type)) {
30933 return FORM_CONTROLS[type];
30934 }
30935 return null;
30936 }
30937
30938 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
30939 function getFilterBy(field, defaultOperators, validOperators) {
30940 if (field.filterBy === false) {
30941 return false;
30942 }
30943 const operators = field.filterBy?.operators?.filter(
30944 (op) => validOperators.includes(op)
30945 ) ?? defaultOperators;
30946 if (operators.length === 0) {
30947 return false;
30948 }
30949 return {
30950 isPrimary: !!field.filterBy?.isPrimary,
30951 operators
30952 };
30953 }
30954 var get_filter_by_default = getFilterBy;
30955
30956 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
30957 var getValueFromId = (id) => ({ item }) => {
30958 const path = id.split(".");
30959 let value = item;
30960 for (const segment of path) {
30961 if (value.hasOwnProperty(segment)) {
30962 value = value[segment];
30963 } else {
30964 value = void 0;
30965 }
30966 }
30967 return value;
30968 };
30969 var get_value_from_id_default = getValueFromId;
30970
30971 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
30972 var setValueFromId = (id) => ({ value }) => {
30973 const path = id.split(".");
30974 const result = {};
30975 let current = result;
30976 for (const segment of path.slice(0, -1)) {
30977 current[segment] = {};
30978 current = current[segment];
30979 }
30980 current[path.at(-1)] = value;
30981 return result;
30982 };
30983 var set_value_from_id_default = setValueFromId;
30984
30985 // packages/dataviews/build-module/field-types/email.mjs
30986 var import_i18n42 = __toESM(require_i18n(), 1);
30987
30988 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
30989 function RenderFromElements({
30990 item,
30991 field
30992 }) {
30993 const { elements, isLoading } = useElements({
30994 elements: field.elements,
30995 getElements: field.getElements
30996 });
30997 const value = field.getValue({ item });
30998 if (isLoading) {
30999 return value;
31000 }
31001 if (elements.length === 0) {
31002 return value;
31003 }
31004 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
31005 }
31006
31007 // packages/dataviews/build-module/field-types/utils/render-default.mjs
31008 var import_jsx_runtime158 = __toESM(require_jsx_runtime(), 1);
31009 function render({
31010 item,
31011 field
31012 }) {
31013 if (field.hasElements) {
31014 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(RenderFromElements, { item, field });
31015 }
31016 return field.getValueFormatted({ item, field });
31017 }
31018
31019 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
31020 var sort_text_default = (a2, b2, direction) => {
31021 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
31022 };
31023
31024 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
31025 function isValidRequired(item, field) {
31026 const value = field.getValue({ item });
31027 return ![void 0, "", null].includes(value);
31028 }
31029
31030 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
31031 function isValidMinLength(item, field) {
31032 if (typeof field.isValid.minLength?.constraint !== "number") {
31033 return false;
31034 }
31035 const value = field.getValue({ item });
31036 if ([void 0, "", null].includes(value)) {
31037 return true;
31038 }
31039 return String(value).length >= field.isValid.minLength.constraint;
31040 }
31041
31042 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
31043 function isValidMaxLength(item, field) {
31044 if (typeof field.isValid.maxLength?.constraint !== "number") {
31045 return false;
31046 }
31047 const value = field.getValue({ item });
31048 if ([void 0, "", null].includes(value)) {
31049 return true;
31050 }
31051 return String(value).length <= field.isValid.maxLength.constraint;
31052 }
31053
31054 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
31055 function isValidPattern(item, field) {
31056 if (field.isValid.pattern?.constraint === void 0) {
31057 return true;
31058 }
31059 try {
31060 const regexp = new RegExp(field.isValid.pattern.constraint);
31061 const value = field.getValue({ item });
31062 if ([void 0, "", null].includes(value)) {
31063 return true;
31064 }
31065 return regexp.test(String(value));
31066 } catch {
31067 return false;
31068 }
31069 }
31070
31071 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
31072 function isValidElements(item, field) {
31073 const elements = field.elements ?? [];
31074 const validValues = elements.map((el) => el.value);
31075 if (validValues.length === 0) {
31076 return true;
31077 }
31078 const value = field.getValue({ item });
31079 return [].concat(value).every((v2) => validValues.includes(v2));
31080 }
31081
31082 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
31083 function getValueFormatted({
31084 item,
31085 field
31086 }) {
31087 return field.getValue({ item });
31088 }
31089 var get_value_formatted_default_default = getValueFormatted;
31090
31091 // packages/dataviews/build-module/field-types/email.mjs
31092 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])?)*$/;
31093 function isValidCustom(item, field) {
31094 const value = field.getValue({ item });
31095 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
31096 return (0, import_i18n42.__)("Value must be a valid email address.");
31097 }
31098 return null;
31099 }
31100 var email_default = {
31101 type: "email",
31102 render,
31103 Edit: "email",
31104 sort: sort_text_default,
31105 enableSorting: true,
31106 enableGlobalSearch: false,
31107 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31108 validOperators: [
31109 OPERATOR_IS,
31110 OPERATOR_IS_NOT,
31111 OPERATOR_CONTAINS,
31112 OPERATOR_NOT_CONTAINS,
31113 OPERATOR_STARTS_WITH,
31114 // Multiple selection
31115 OPERATOR_IS_ANY,
31116 OPERATOR_IS_NONE,
31117 OPERATOR_IS_ALL,
31118 OPERATOR_IS_NOT_ALL
31119 ],
31120 format: {},
31121 getValueFormatted: get_value_formatted_default_default,
31122 validate: {
31123 required: isValidRequired,
31124 pattern: isValidPattern,
31125 minLength: isValidMinLength,
31126 maxLength: isValidMaxLength,
31127 elements: isValidElements,
31128 custom: isValidCustom
31129 }
31130 };
31131
31132 // packages/dataviews/build-module/field-types/integer.mjs
31133 var import_i18n43 = __toESM(require_i18n(), 1);
31134
31135 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
31136 var sort_number_default = (a2, b2, direction) => {
31137 return direction === "asc" ? a2 - b2 : b2 - a2;
31138 };
31139
31140 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
31141 function isValidMin(item, field) {
31142 if (typeof field.isValid.min?.constraint !== "number") {
31143 return false;
31144 }
31145 const value = field.getValue({ item });
31146 if ([void 0, "", null].includes(value)) {
31147 return true;
31148 }
31149 return Number(value) >= field.isValid.min.constraint;
31150 }
31151
31152 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
31153 function isValidMax(item, field) {
31154 if (typeof field.isValid.max?.constraint !== "number") {
31155 return false;
31156 }
31157 const value = field.getValue({ item });
31158 if ([void 0, "", null].includes(value)) {
31159 return true;
31160 }
31161 return Number(value) <= field.isValid.max.constraint;
31162 }
31163
31164 // packages/dataviews/build-module/field-types/integer.mjs
31165 var format2 = {
31166 separatorThousand: ","
31167 };
31168 function getValueFormatted2({
31169 item,
31170 field
31171 }) {
31172 let value = field.getValue({ item });
31173 if (value === null || value === void 0) {
31174 return "";
31175 }
31176 value = Number(value);
31177 if (!Number.isFinite(value)) {
31178 return String(value);
31179 }
31180 let formatInteger;
31181 if (field.type !== "integer") {
31182 formatInteger = format2;
31183 } else {
31184 formatInteger = field.format;
31185 }
31186 const { separatorThousand } = formatInteger;
31187 const integerValue = Math.trunc(value);
31188 if (!separatorThousand) {
31189 return String(integerValue);
31190 }
31191 return String(integerValue).replace(
31192 /\B(?=(\d{3})+(?!\d))/g,
31193 separatorThousand
31194 );
31195 }
31196 function isValidCustom2(item, field) {
31197 const value = field.getValue({ item });
31198 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
31199 return (0, import_i18n43.__)("Value must be an integer.");
31200 }
31201 return null;
31202 }
31203 var integer_default = {
31204 type: "integer",
31205 render,
31206 Edit: "integer",
31207 sort: sort_number_default,
31208 enableSorting: true,
31209 enableGlobalSearch: false,
31210 defaultOperators: [
31211 OPERATOR_IS,
31212 OPERATOR_IS_NOT,
31213 OPERATOR_LESS_THAN,
31214 OPERATOR_GREATER_THAN,
31215 OPERATOR_LESS_THAN_OR_EQUAL,
31216 OPERATOR_GREATER_THAN_OR_EQUAL,
31217 OPERATOR_BETWEEN
31218 ],
31219 validOperators: [
31220 // Single-selection
31221 OPERATOR_IS,
31222 OPERATOR_IS_NOT,
31223 OPERATOR_LESS_THAN,
31224 OPERATOR_GREATER_THAN,
31225 OPERATOR_LESS_THAN_OR_EQUAL,
31226 OPERATOR_GREATER_THAN_OR_EQUAL,
31227 OPERATOR_BETWEEN,
31228 // Multiple-selection
31229 OPERATOR_IS_ANY,
31230 OPERATOR_IS_NONE,
31231 OPERATOR_IS_ALL,
31232 OPERATOR_IS_NOT_ALL
31233 ],
31234 format: format2,
31235 getValueFormatted: getValueFormatted2,
31236 validate: {
31237 required: isValidRequired,
31238 min: isValidMin,
31239 max: isValidMax,
31240 elements: isValidElements,
31241 custom: isValidCustom2
31242 }
31243 };
31244
31245 // packages/dataviews/build-module/field-types/number.mjs
31246 var import_i18n44 = __toESM(require_i18n(), 1);
31247 var format3 = {
31248 separatorThousand: ",",
31249 separatorDecimal: ".",
31250 decimals: 2
31251 };
31252 function getValueFormatted3({
31253 item,
31254 field
31255 }) {
31256 let value = field.getValue({ item });
31257 if (value === null || value === void 0) {
31258 return "";
31259 }
31260 value = Number(value);
31261 if (!Number.isFinite(value)) {
31262 return String(value);
31263 }
31264 let formatNumber;
31265 if (field.type !== "number") {
31266 formatNumber = format3;
31267 } else {
31268 formatNumber = field.format;
31269 }
31270 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
31271 const fixedValue = value.toFixed(decimals);
31272 const [integerPart, decimalPart] = fixedValue.split(".");
31273 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
31274 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
31275 }
31276 function isEmpty2(value) {
31277 return value === "" || value === void 0 || value === null;
31278 }
31279 function isValidCustom3(item, field) {
31280 const value = field.getValue({ item });
31281 if (!isEmpty2(value) && !Number.isFinite(value)) {
31282 return (0, import_i18n44.__)("Value must be a number.");
31283 }
31284 return null;
31285 }
31286 var number_default = {
31287 type: "number",
31288 render,
31289 Edit: "number",
31290 sort: sort_number_default,
31291 enableSorting: true,
31292 enableGlobalSearch: false,
31293 defaultOperators: [
31294 OPERATOR_IS,
31295 OPERATOR_IS_NOT,
31296 OPERATOR_LESS_THAN,
31297 OPERATOR_GREATER_THAN,
31298 OPERATOR_LESS_THAN_OR_EQUAL,
31299 OPERATOR_GREATER_THAN_OR_EQUAL,
31300 OPERATOR_BETWEEN
31301 ],
31302 validOperators: [
31303 // Single-selection
31304 OPERATOR_IS,
31305 OPERATOR_IS_NOT,
31306 OPERATOR_LESS_THAN,
31307 OPERATOR_GREATER_THAN,
31308 OPERATOR_LESS_THAN_OR_EQUAL,
31309 OPERATOR_GREATER_THAN_OR_EQUAL,
31310 OPERATOR_BETWEEN,
31311 // Multiple-selection
31312 OPERATOR_IS_ANY,
31313 OPERATOR_IS_NONE,
31314 OPERATOR_IS_ALL,
31315 OPERATOR_IS_NOT_ALL
31316 ],
31317 format: format3,
31318 getValueFormatted: getValueFormatted3,
31319 validate: {
31320 required: isValidRequired,
31321 min: isValidMin,
31322 max: isValidMax,
31323 elements: isValidElements,
31324 custom: isValidCustom3
31325 }
31326 };
31327
31328 // packages/dataviews/build-module/field-types/text.mjs
31329 var text_default = {
31330 type: "text",
31331 render,
31332 Edit: "text",
31333 sort: sort_text_default,
31334 enableSorting: true,
31335 enableGlobalSearch: false,
31336 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31337 validOperators: [
31338 // Single selection
31339 OPERATOR_IS,
31340 OPERATOR_IS_NOT,
31341 OPERATOR_CONTAINS,
31342 OPERATOR_NOT_CONTAINS,
31343 OPERATOR_STARTS_WITH,
31344 // Multiple selection
31345 OPERATOR_IS_ANY,
31346 OPERATOR_IS_NONE,
31347 OPERATOR_IS_ALL,
31348 OPERATOR_IS_NOT_ALL
31349 ],
31350 format: {},
31351 getValueFormatted: get_value_formatted_default_default,
31352 validate: {
31353 required: isValidRequired,
31354 pattern: isValidPattern,
31355 minLength: isValidMinLength,
31356 maxLength: isValidMaxLength,
31357 elements: isValidElements
31358 }
31359 };
31360
31361 // packages/dataviews/build-module/field-types/datetime.mjs
31362 var import_date7 = __toESM(require_date(), 1);
31363
31364 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
31365 var import_date6 = __toESM(require_date(), 1);
31366 function parseDateLike(value) {
31367 if (!value) {
31368 return null;
31369 }
31370 if (!isValid(new Date(value))) {
31371 return null;
31372 }
31373 const parsed = (0, import_date6.getDate)(value);
31374 return parsed && isValid(parsed) ? parsed : null;
31375 }
31376 function validateDateLikeBoundary(item, field, boundary) {
31377 const constraint = field.isValid[boundary]?.constraint;
31378 if (typeof constraint !== "string") {
31379 return false;
31380 }
31381 const value = field.getValue({ item });
31382 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
31383 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
31384 return true;
31385 }
31386 const parsedConstraint = parseDateLike(constraint);
31387 const parsedValue = parseDateLike(String(boundaryValue));
31388 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
31389 }
31390 function isValidMinDate(item, field) {
31391 return validateDateLikeBoundary(item, field, "min");
31392 }
31393 function isValidMaxDate(item, field) {
31394 return validateDateLikeBoundary(item, field, "max");
31395 }
31396
31397 // packages/dataviews/build-module/field-types/datetime.mjs
31398 var format4 = {
31399 datetime: (0, import_date7.getSettings)().formats.datetime,
31400 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
31401 };
31402 function getValueFormatted4({
31403 item,
31404 field
31405 }) {
31406 const value = field.getValue({ item });
31407 if (["", void 0, null].includes(value)) {
31408 return "";
31409 }
31410 let formatDatetime;
31411 if (field.type !== "datetime") {
31412 formatDatetime = format4;
31413 } else {
31414 formatDatetime = field.format;
31415 }
31416 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
31417 }
31418 var sort = (a2, b2, direction) => {
31419 const timeA = new Date(a2).getTime();
31420 const timeB = new Date(b2).getTime();
31421 return direction === "asc" ? timeA - timeB : timeB - timeA;
31422 };
31423 var datetime_default = {
31424 type: "datetime",
31425 render,
31426 Edit: "datetime",
31427 sort,
31428 enableSorting: true,
31429 enableGlobalSearch: false,
31430 defaultOperators: [
31431 OPERATOR_ON,
31432 OPERATOR_NOT_ON,
31433 OPERATOR_BEFORE,
31434 OPERATOR_AFTER,
31435 OPERATOR_BEFORE_INC,
31436 OPERATOR_AFTER_INC,
31437 OPERATOR_IN_THE_PAST,
31438 OPERATOR_OVER
31439 ],
31440 validOperators: [
31441 OPERATOR_ON,
31442 OPERATOR_NOT_ON,
31443 OPERATOR_BEFORE,
31444 OPERATOR_AFTER,
31445 OPERATOR_BEFORE_INC,
31446 OPERATOR_AFTER_INC,
31447 OPERATOR_IN_THE_PAST,
31448 OPERATOR_OVER
31449 ],
31450 format: format4,
31451 getValueFormatted: getValueFormatted4,
31452 validate: {
31453 required: isValidRequired,
31454 elements: isValidElements,
31455 min: isValidMinDate,
31456 max: isValidMaxDate
31457 }
31458 };
31459
31460 // packages/dataviews/build-module/field-types/date.mjs
31461 var import_date8 = __toESM(require_date(), 1);
31462 var format5 = {
31463 date: (0, import_date8.getSettings)().formats.date,
31464 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
31465 };
31466 function getValueFormatted5({
31467 item,
31468 field
31469 }) {
31470 const value = field.getValue({ item });
31471 if (["", void 0, null].includes(value)) {
31472 return "";
31473 }
31474 let formatDate2;
31475 if (field.type !== "date") {
31476 formatDate2 = format5;
31477 } else {
31478 formatDate2 = field.format;
31479 }
31480 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
31481 }
31482 var sort2 = (a2, b2, direction) => {
31483 const timeA = new Date(a2).getTime();
31484 const timeB = new Date(b2).getTime();
31485 return direction === "asc" ? timeA - timeB : timeB - timeA;
31486 };
31487 var date_default = {
31488 type: "date",
31489 render,
31490 Edit: "date",
31491 sort: sort2,
31492 enableSorting: true,
31493 enableGlobalSearch: false,
31494 defaultOperators: [
31495 OPERATOR_ON,
31496 OPERATOR_NOT_ON,
31497 OPERATOR_BEFORE,
31498 OPERATOR_AFTER,
31499 OPERATOR_BEFORE_INC,
31500 OPERATOR_AFTER_INC,
31501 OPERATOR_IN_THE_PAST,
31502 OPERATOR_OVER,
31503 OPERATOR_BETWEEN
31504 ],
31505 validOperators: [
31506 OPERATOR_ON,
31507 OPERATOR_NOT_ON,
31508 OPERATOR_BEFORE,
31509 OPERATOR_AFTER,
31510 OPERATOR_BEFORE_INC,
31511 OPERATOR_AFTER_INC,
31512 OPERATOR_IN_THE_PAST,
31513 OPERATOR_OVER,
31514 OPERATOR_BETWEEN
31515 ],
31516 format: format5,
31517 getValueFormatted: getValueFormatted5,
31518 validate: {
31519 required: isValidRequired,
31520 elements: isValidElements,
31521 min: isValidMinDate,
31522 max: isValidMaxDate
31523 }
31524 };
31525
31526 // packages/dataviews/build-module/field-types/boolean.mjs
31527 var import_i18n45 = __toESM(require_i18n(), 1);
31528
31529 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
31530 function isValidRequiredForBool(item, field) {
31531 const value = field.getValue({ item });
31532 return value === true;
31533 }
31534
31535 // packages/dataviews/build-module/field-types/boolean.mjs
31536 function getValueFormatted6({
31537 item,
31538 field
31539 }) {
31540 const value = field.getValue({ item });
31541 if (value === true) {
31542 return (0, import_i18n45.__)("True");
31543 }
31544 if (value === false) {
31545 return (0, import_i18n45.__)("False");
31546 }
31547 return "";
31548 }
31549 function isValidCustom4(item, field) {
31550 const value = field.getValue({ item });
31551 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
31552 return (0, import_i18n45.__)("Value must be true, false, or undefined");
31553 }
31554 return null;
31555 }
31556 var sort3 = (a2, b2, direction) => {
31557 const boolA = Boolean(a2);
31558 const boolB = Boolean(b2);
31559 if (boolA === boolB) {
31560 return 0;
31561 }
31562 if (direction === "asc") {
31563 return boolA ? 1 : -1;
31564 }
31565 return boolA ? -1 : 1;
31566 };
31567 var boolean_default = {
31568 type: "boolean",
31569 render,
31570 Edit: "checkbox",
31571 sort: sort3,
31572 validate: {
31573 required: isValidRequiredForBool,
31574 elements: isValidElements,
31575 custom: isValidCustom4
31576 },
31577 enableSorting: true,
31578 enableGlobalSearch: false,
31579 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
31580 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
31581 format: {},
31582 getValueFormatted: getValueFormatted6
31583 };
31584
31585 // packages/dataviews/build-module/field-types/media.mjs
31586 var media_default = {
31587 type: "media",
31588 render: () => null,
31589 Edit: null,
31590 sort: () => 0,
31591 enableSorting: false,
31592 enableGlobalSearch: false,
31593 defaultOperators: [],
31594 validOperators: [],
31595 format: {},
31596 getValueFormatted: get_value_formatted_default_default,
31597 // cannot validate any constraint, so
31598 // the only available validation for the field author
31599 // would be providing a custom validator.
31600 validate: {}
31601 };
31602
31603 // packages/dataviews/build-module/field-types/array.mjs
31604 var import_i18n46 = __toESM(require_i18n(), 1);
31605
31606 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
31607 function isValidRequiredForArray(item, field) {
31608 const value = field.getValue({ item });
31609 return Array.isArray(value) && value.length > 0 && value.every(
31610 (element) => ![void 0, "", null].includes(element)
31611 );
31612 }
31613
31614 // packages/dataviews/build-module/field-types/array.mjs
31615 function getValueFormatted7({
31616 item,
31617 field
31618 }) {
31619 const value = field.getValue({ item });
31620 const arr = Array.isArray(value) ? value : [];
31621 return arr.join(", ");
31622 }
31623 function render2({ item, field }) {
31624 return getValueFormatted7({ item, field });
31625 }
31626 function isValidCustom5(item, field) {
31627 const value = field.getValue({ item });
31628 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
31629 return (0, import_i18n46.__)("Value must be an array.");
31630 }
31631 if (!value.every((v2) => typeof v2 === "string")) {
31632 return (0, import_i18n46.__)("Every value must be a string.");
31633 }
31634 return null;
31635 }
31636 var sort4 = (a2, b2, direction) => {
31637 const arrA = Array.isArray(a2) ? a2 : [];
31638 const arrB = Array.isArray(b2) ? b2 : [];
31639 if (arrA.length !== arrB.length) {
31640 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
31641 }
31642 const joinedA = arrA.join(",");
31643 const joinedB = arrB.join(",");
31644 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
31645 };
31646 var array_default = {
31647 type: "array",
31648 render: render2,
31649 Edit: "array",
31650 sort: sort4,
31651 enableSorting: true,
31652 enableGlobalSearch: false,
31653 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31654 validOperators: [
31655 OPERATOR_IS_ANY,
31656 OPERATOR_IS_NONE,
31657 OPERATOR_IS_ALL,
31658 OPERATOR_IS_NOT_ALL
31659 ],
31660 format: {},
31661 getValueFormatted: getValueFormatted7,
31662 validate: {
31663 required: isValidRequiredForArray,
31664 elements: isValidElements,
31665 custom: isValidCustom5
31666 }
31667 };
31668
31669 // packages/dataviews/build-module/field-types/password.mjs
31670 function getValueFormatted8({
31671 item,
31672 field
31673 }) {
31674 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
31675 }
31676 var password_default = {
31677 type: "password",
31678 render,
31679 Edit: "password",
31680 sort: () => 0,
31681 // Passwords should not be sortable for security reasons
31682 enableSorting: false,
31683 enableGlobalSearch: false,
31684 defaultOperators: [],
31685 validOperators: [],
31686 format: {},
31687 getValueFormatted: getValueFormatted8,
31688 validate: {
31689 required: isValidRequired,
31690 pattern: isValidPattern,
31691 minLength: isValidMinLength,
31692 maxLength: isValidMaxLength,
31693 elements: isValidElements
31694 }
31695 };
31696
31697 // packages/dataviews/build-module/field-types/telephone.mjs
31698 var telephone_default = {
31699 type: "telephone",
31700 render,
31701 Edit: "telephone",
31702 sort: sort_text_default,
31703 enableSorting: true,
31704 enableGlobalSearch: false,
31705 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31706 validOperators: [
31707 OPERATOR_IS,
31708 OPERATOR_IS_NOT,
31709 OPERATOR_CONTAINS,
31710 OPERATOR_NOT_CONTAINS,
31711 OPERATOR_STARTS_WITH,
31712 // Multiple selection
31713 OPERATOR_IS_ANY,
31714 OPERATOR_IS_NONE,
31715 OPERATOR_IS_ALL,
31716 OPERATOR_IS_NOT_ALL
31717 ],
31718 format: {},
31719 getValueFormatted: get_value_formatted_default_default,
31720 validate: {
31721 required: isValidRequired,
31722 pattern: isValidPattern,
31723 minLength: isValidMinLength,
31724 maxLength: isValidMaxLength,
31725 elements: isValidElements
31726 }
31727 };
31728
31729 // packages/dataviews/build-module/field-types/color.mjs
31730 var import_i18n47 = __toESM(require_i18n(), 1);
31731 var import_jsx_runtime159 = __toESM(require_jsx_runtime(), 1);
31732 function render3({ item, field }) {
31733 if (field.hasElements) {
31734 return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(RenderFromElements, { item, field });
31735 }
31736 const value = get_value_formatted_default_default({ item, field });
31737 if (!value || !w(value).isValid()) {
31738 return value;
31739 }
31740 return /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
31741 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(
31742 "div",
31743 {
31744 style: {
31745 width: "16px",
31746 height: "16px",
31747 borderRadius: "50%",
31748 backgroundColor: value,
31749 border: "1px solid #ddd",
31750 flexShrink: 0
31751 }
31752 }
31753 ),
31754 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)("span", { children: value })
31755 ] });
31756 }
31757 function isValidCustom6(item, field) {
31758 const value = field.getValue({ item });
31759 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
31760 return (0, import_i18n47.__)("Value must be a valid color.");
31761 }
31762 return null;
31763 }
31764 var sort5 = (a2, b2, direction) => {
31765 const colorA = w(a2);
31766 const colorB = w(b2);
31767 if (!colorA.isValid() && !colorB.isValid()) {
31768 return 0;
31769 }
31770 if (!colorA.isValid()) {
31771 return direction === "asc" ? 1 : -1;
31772 }
31773 if (!colorB.isValid()) {
31774 return direction === "asc" ? -1 : 1;
31775 }
31776 const hslA = colorA.toHsl();
31777 const hslB = colorB.toHsl();
31778 if (hslA.h !== hslB.h) {
31779 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
31780 }
31781 if (hslA.s !== hslB.s) {
31782 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
31783 }
31784 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
31785 };
31786 var color_default = {
31787 type: "color",
31788 render: render3,
31789 Edit: "color",
31790 sort: sort5,
31791 enableSorting: true,
31792 enableGlobalSearch: false,
31793 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31794 validOperators: [
31795 OPERATOR_IS,
31796 OPERATOR_IS_NOT,
31797 OPERATOR_IS_ANY,
31798 OPERATOR_IS_NONE
31799 ],
31800 format: {},
31801 getValueFormatted: get_value_formatted_default_default,
31802 validate: {
31803 required: isValidRequired,
31804 elements: isValidElements,
31805 custom: isValidCustom6
31806 }
31807 };
31808
31809 // packages/dataviews/build-module/field-types/url.mjs
31810 var url_default = {
31811 type: "url",
31812 render,
31813 Edit: "url",
31814 sort: sort_text_default,
31815 enableSorting: true,
31816 enableGlobalSearch: false,
31817 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
31818 validOperators: [
31819 OPERATOR_IS,
31820 OPERATOR_IS_NOT,
31821 OPERATOR_CONTAINS,
31822 OPERATOR_NOT_CONTAINS,
31823 OPERATOR_STARTS_WITH,
31824 // Multiple selection
31825 OPERATOR_IS_ANY,
31826 OPERATOR_IS_NONE,
31827 OPERATOR_IS_ALL,
31828 OPERATOR_IS_NOT_ALL
31829 ],
31830 format: {},
31831 getValueFormatted: get_value_formatted_default_default,
31832 validate: {
31833 required: isValidRequired,
31834 pattern: isValidPattern,
31835 minLength: isValidMinLength,
31836 maxLength: isValidMaxLength,
31837 elements: isValidElements
31838 }
31839 };
31840
31841 // packages/dataviews/build-module/field-types/no-type.mjs
31842 var sort6 = (a2, b2, direction) => {
31843 if (typeof a2 === "number" && typeof b2 === "number") {
31844 return sort_number_default(a2, b2, direction);
31845 }
31846 return sort_text_default(a2, b2, direction);
31847 };
31848 var no_type_default = {
31849 // type: no type for this one
31850 render,
31851 Edit: null,
31852 sort: sort6,
31853 enableSorting: true,
31854 enableGlobalSearch: false,
31855 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
31856 validOperators: getAllOperatorNames(),
31857 format: {},
31858 getValueFormatted: get_value_formatted_default_default,
31859 validate: {
31860 required: isValidRequired,
31861 elements: isValidElements
31862 }
31863 };
31864
31865 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
31866 function supportsNumericRangeConstraint(type) {
31867 return type === "integer" || type === "number";
31868 }
31869 function supportsDateRangeConstraint(type) {
31870 return type === "date" || type === "datetime";
31871 }
31872 function normalizeRangeRule(value, fieldType, key) {
31873 const validator = fieldType.validate[key];
31874 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
31875 return { constraint: value, validate: validator };
31876 }
31877 return void 0;
31878 }
31879 function getIsValid(field, fieldType) {
31880 const rules = field.isValid;
31881 let required;
31882 if (rules?.required === true && fieldType.validate.required !== void 0) {
31883 required = {
31884 constraint: true,
31885 validate: fieldType.validate.required
31886 };
31887 }
31888 let elements;
31889 if ((rules?.elements === true || // elements is enabled unless the field opts-out
31890 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
31891 elements = {
31892 constraint: true,
31893 validate: fieldType.validate.elements
31894 };
31895 }
31896 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
31897 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
31898 const minLengthValue = rules?.minLength;
31899 let minLength;
31900 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
31901 minLength = {
31902 constraint: minLengthValue,
31903 validate: fieldType.validate.minLength
31904 };
31905 }
31906 const maxLengthValue = rules?.maxLength;
31907 let maxLength;
31908 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
31909 maxLength = {
31910 constraint: maxLengthValue,
31911 validate: fieldType.validate.maxLength
31912 };
31913 }
31914 const patternValue = rules?.pattern;
31915 let pattern;
31916 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
31917 pattern = {
31918 constraint: patternValue,
31919 validate: fieldType.validate.pattern
31920 };
31921 }
31922 const custom = rules?.custom ?? fieldType.validate.custom;
31923 return {
31924 required,
31925 elements,
31926 min: min2,
31927 max: max2,
31928 minLength,
31929 maxLength,
31930 pattern,
31931 custom
31932 };
31933 }
31934
31935 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
31936 function getFilter(fieldType) {
31937 return fieldType.validOperators.reduce((accumulator, operator) => {
31938 const operatorObj = getOperatorByName(operator);
31939 if (operatorObj?.filter) {
31940 accumulator[operator] = operatorObj.filter;
31941 }
31942 return accumulator;
31943 }, {});
31944 }
31945
31946 // packages/dataviews/build-module/field-types/utils/get-format.mjs
31947 function getFormat(field, fieldType) {
31948 return {
31949 ...fieldType.format,
31950 ...field.format
31951 };
31952 }
31953 var get_format_default = getFormat;
31954
31955 // packages/dataviews/build-module/field-types/index.mjs
31956 function getFieldTypeByName(type) {
31957 const found = [
31958 email_default,
31959 integer_default,
31960 number_default,
31961 text_default,
31962 datetime_default,
31963 date_default,
31964 boolean_default,
31965 media_default,
31966 array_default,
31967 password_default,
31968 telephone_default,
31969 color_default,
31970 url_default
31971 ].find((fieldType) => fieldType?.type === type);
31972 if (!!found) {
31973 return found;
31974 }
31975 return no_type_default;
31976 }
31977 function normalizeFields(fields) {
31978 return fields.map((field) => {
31979 const fieldType = getFieldTypeByName(field.type);
31980 const getValue = field.getValue || get_value_from_id_default(field.id);
31981 const sort7 = function(a2, b2, direction) {
31982 const aValue = getValue({ item: a2 });
31983 const bValue = getValue({ item: b2 });
31984 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
31985 };
31986 return {
31987 id: field.id,
31988 label: field.label || field.id,
31989 header: field.header || field.label || field.id,
31990 description: field.description,
31991 placeholder: field.placeholder,
31992 getValue,
31993 setValue: field.setValue || set_value_from_id_default(field.id),
31994 elements: field.elements,
31995 getElements: field.getElements,
31996 hasElements: hasElements(field),
31997 isVisible: field.isVisible,
31998 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
31999 enableHiding: field.enableHiding ?? true,
32000 readOnly: field.readOnly ?? false,
32001 // The type provides defaults for the following props
32002 type: fieldType.type,
32003 render: field.render ?? fieldType.render,
32004 Edit: getControl(field, fieldType.Edit),
32005 sort: sort7,
32006 enableSorting: field.enableSorting ?? fieldType.enableSorting,
32007 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
32008 isValid: getIsValid(field, fieldType),
32009 filterBy: get_filter_by_default(
32010 field,
32011 fieldType.defaultOperators,
32012 fieldType.validOperators
32013 ),
32014 filter: getFilter(fieldType),
32015 format: get_format_default(field, fieldType),
32016 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
32017 };
32018 });
32019 }
32020
32021 // packages/dataviews/build-module/hooks/use-data.mjs
32022 var import_element110 = __toESM(require_element(), 1);
32023 function useData({
32024 view,
32025 data: shownData,
32026 getItemId,
32027 isLoading,
32028 paginationInfo,
32029 selection
32030 }) {
32031 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
32032 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element110.useState)(
32033 !isLoading
32034 );
32035 (0, import_element110.useEffect)(() => {
32036 if (!isLoading) {
32037 setHasInitiallyLoaded(true);
32038 }
32039 }, [isLoading]);
32040 const previousDataRef = (0, import_element110.useRef)(shownData);
32041 const previousPaginationInfoRef = (0, import_element110.useRef)(paginationInfo);
32042 (0, import_element110.useEffect)(() => {
32043 if (!isLoading) {
32044 previousDataRef.current = shownData;
32045 previousPaginationInfoRef.current = paginationInfo;
32046 }
32047 }, [shownData, isLoading, paginationInfo]);
32048 const [visibleEntries, setVisibleEntries] = (0, import_element110.useState)([]);
32049 const positionMapRef = (0, import_element110.useRef)(/* @__PURE__ */ new Map());
32050 const allLoadedRecordsRef = (0, import_element110.useRef)([]);
32051 const prevViewParamsRef = (0, import_element110.useRef)({
32052 search: void 0,
32053 filters: void 0,
32054 perPage: void 0
32055 });
32056 const scrollDirectionRef = (0, import_element110.useRef)(void 0);
32057 const prevStartPositionRef = (0, import_element110.useRef)(void 0);
32058 const hasInitializedRef = (0, import_element110.useRef)(false);
32059 const allLoadedRecords = (0, import_element110.useMemo)(() => {
32060 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
32061 if (view.startPosition < prevStartPositionRef.current) {
32062 scrollDirectionRef.current = "up";
32063 } else if (view.startPosition > prevStartPositionRef.current) {
32064 scrollDirectionRef.current = "down";
32065 }
32066 }
32067 prevStartPositionRef.current = view.startPosition;
32068 const currentFiltersKey = JSON.stringify(view.filters ?? []);
32069 const prevFiltersKey = prevViewParamsRef.current.filters;
32070 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
32071 hasInitializedRef.current = true;
32072 prevViewParamsRef.current = {
32073 search: view.search,
32074 filters: currentFiltersKey,
32075 perPage: view.perPage
32076 };
32077 if (shouldReset) {
32078 positionMapRef.current.clear();
32079 scrollDirectionRef.current = void 0;
32080 const startPosition = view.search ? 1 : view.startPosition ?? 1;
32081 const records = shownData.map((record, index2) => {
32082 const position = startPosition + index2;
32083 positionMapRef.current.set(getItemId(record), position);
32084 return {
32085 ...record,
32086 position
32087 };
32088 });
32089 allLoadedRecordsRef.current = records;
32090 return records;
32091 }
32092 const prev = allLoadedRecordsRef.current;
32093 const shownDataIds = new Set(shownData.map(getItemId));
32094 const scrollDirection = scrollDirectionRef.current;
32095 const basePosition = view.search ? 1 : view.startPosition ?? 1;
32096 const newRecords = shownData.map((record, index2) => {
32097 const itemId = getItemId(record);
32098 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
32099 if (position !== void 0) {
32100 positionMapRef.current.set(itemId, position);
32101 }
32102 return {
32103 ...record,
32104 position
32105 };
32106 });
32107 if (newRecords.length === 0) {
32108 return prev;
32109 }
32110 const prevWithoutDuplicates = prev.filter(
32111 (record) => !shownDataIds.has(getItemId(record))
32112 );
32113 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
32114 allRecords.sort((a2, b2) => {
32115 const posA = a2.position;
32116 const posB = b2.position;
32117 return posA - posB;
32118 });
32119 let result = allRecords;
32120 if (visibleEntries.length > 0) {
32121 const visibleMin = Math.min(...visibleEntries);
32122 const visibleMax = Math.max(...visibleEntries);
32123 const buffer = 20;
32124 const recordPositions = allRecords.map(
32125 (r3) => r3.position
32126 );
32127 const minRecordPos = Math.min(...recordPositions);
32128 const maxRecordPos = Math.max(...recordPositions);
32129 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
32130 if (hasOverlap) {
32131 result = allRecords.filter((record) => {
32132 const itemId = getItemId(record);
32133 const isSelected2 = selection?.includes(itemId);
32134 if (isSelected2) {
32135 return true;
32136 }
32137 const itemPosition = record.position;
32138 if (scrollDirection === "up") {
32139 return itemPosition <= visibleMax + buffer;
32140 } else if (scrollDirection === "down") {
32141 return itemPosition >= visibleMin - buffer;
32142 }
32143 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
32144 });
32145 }
32146 }
32147 allLoadedRecordsRef.current = result;
32148 return result;
32149 }, [
32150 shownData,
32151 view.search,
32152 view.filters,
32153 view.perPage,
32154 view.startPosition,
32155 view.infiniteScrollEnabled,
32156 visibleEntries,
32157 selection,
32158 getItemId
32159 ]);
32160 if (!isInfiniteScrollEnabled) {
32161 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
32162 return {
32163 data: dataToReturn.map((item) => ({
32164 ...item,
32165 position: void 0
32166 })),
32167 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
32168 hasInitiallyLoaded,
32169 setVisibleEntries: void 0
32170 };
32171 }
32172 return {
32173 data: allLoadedRecords,
32174 paginationInfo,
32175 hasInitiallyLoaded,
32176 setVisibleEntries
32177 };
32178 }
32179
32180 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
32181 var import_element111 = __toESM(require_element(), 1);
32182 var import_compose13 = __toESM(require_compose(), 1);
32183 function captureAnchorElement(container, anchorElementRef, direction) {
32184 const containerRect = container.getBoundingClientRect();
32185 const centerY = containerRect.top + containerRect.height / 2;
32186 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
32187 if (items.length === 0) {
32188 return false;
32189 }
32190 const bestAnchor = items.reduce((best, item) => {
32191 const itemRect = item.getBoundingClientRect();
32192 const itemCenterY = itemRect.top + itemRect.height / 2;
32193 const distance = Math.abs(itemCenterY - centerY);
32194 const bestRect = best.getBoundingClientRect();
32195 const bestCenterY = bestRect.top + bestRect.height / 2;
32196 const bestDistance = Math.abs(bestCenterY - centerY);
32197 return distance < bestDistance ? item : best;
32198 });
32199 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
32200 const anchorRect = bestAnchor.getBoundingClientRect();
32201 anchorElementRef.current = {
32202 posinset,
32203 viewportOffset: anchorRect.top - containerRect.top,
32204 direction
32205 };
32206 return true;
32207 }
32208 function useInfiniteScroll({
32209 view,
32210 onChangeView,
32211 isLoading,
32212 paginationInfo,
32213 containerRef,
32214 setVisibleEntries
32215 }) {
32216 const anchorElementRef = (0, import_element111.useRef)(null);
32217 const viewRef = (0, import_element111.useRef)(view);
32218 const isLoadingRef = (0, import_element111.useRef)(isLoading);
32219 const onChangeViewRef = (0, import_element111.useRef)(onChangeView);
32220 const totalItemsRef = (0, import_element111.useRef)(paginationInfo.totalItems);
32221 (0, import_element111.useLayoutEffect)(() => {
32222 viewRef.current = view;
32223 isLoadingRef.current = isLoading;
32224 onChangeViewRef.current = onChangeView;
32225 totalItemsRef.current = paginationInfo.totalItems;
32226 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
32227 const intersectionObserverCallback = (0, import_element111.useCallback)(
32228 (entries) => {
32229 if (!setVisibleEntries) {
32230 return;
32231 }
32232 setVisibleEntries((prev) => {
32233 const newVisibleEntries = new Set(prev);
32234 let hasChanged = false;
32235 entries.forEach((entry) => {
32236 const posInSet = Number(
32237 entry.target?.attributes?.getNamedItem(
32238 "aria-posinset"
32239 )?.value
32240 );
32241 if (isNaN(posInSet)) {
32242 return;
32243 }
32244 if (entry.isIntersecting) {
32245 if (!newVisibleEntries.has(posInSet)) {
32246 newVisibleEntries.add(posInSet);
32247 hasChanged = true;
32248 }
32249 } else if (newVisibleEntries.has(posInSet)) {
32250 newVisibleEntries.delete(posInSet);
32251 hasChanged = true;
32252 }
32253 });
32254 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
32255 });
32256 },
32257 [setVisibleEntries]
32258 );
32259 (0, import_element111.useLayoutEffect)(() => {
32260 const container = containerRef.current;
32261 const anchor = anchorElementRef.current;
32262 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
32263 return;
32264 }
32265 const anchorElement = container.querySelector(
32266 `[aria-posinset="${anchor.posinset}"]`
32267 );
32268 if (anchorElement) {
32269 const containerRect = container.getBoundingClientRect();
32270 const anchorRect = anchorElement.getBoundingClientRect();
32271 const currentOffset = anchorRect.top - containerRect.top;
32272 const scrollAdjustment = currentOffset - anchor.viewportOffset;
32273 if (Math.abs(scrollAdjustment) > 1) {
32274 container.scrollTop += scrollAdjustment;
32275 }
32276 }
32277 anchorElementRef.current = null;
32278 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
32279 const intersectionObserverRef = (0, import_element111.useRef)(
32280 null
32281 );
32282 (0, import_element111.useEffect)(() => {
32283 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
32284 if (intersectionObserverRef.current) {
32285 intersectionObserverRef.current.disconnect();
32286 intersectionObserverRef.current = null;
32287 }
32288 return;
32289 }
32290 intersectionObserverRef.current = new IntersectionObserver(
32291 intersectionObserverCallback,
32292 { root: null, rootMargin: "0px", threshold: 0.1 }
32293 );
32294 return () => {
32295 if (intersectionObserverRef.current) {
32296 intersectionObserverRef.current.disconnect();
32297 intersectionObserverRef.current = null;
32298 }
32299 };
32300 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
32301 (0, import_element111.useEffect)(() => {
32302 if (!view.infiniteScrollEnabled || !containerRef.current) {
32303 return;
32304 }
32305 let lastScrollTop = 0;
32306 const BOTTOM_THRESHOLD = 600;
32307 const TOP_THRESHOLD = 800;
32308 const handleScroll = (0, import_compose13.throttle)((event) => {
32309 const currentView = viewRef.current;
32310 const totalItems = totalItemsRef.current;
32311 const target = event.target;
32312 const scrollTop = target.scrollTop;
32313 const scrollHeight = target.scrollHeight;
32314 const clientHeight = target.clientHeight;
32315 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
32316 lastScrollTop = scrollTop;
32317 if (isLoadingRef.current) {
32318 return;
32319 }
32320 const currentStartPosition = currentView.startPosition || 1;
32321 const batchSize = currentView.perPage || 10;
32322 const currentEndPosition = Math.min(
32323 currentStartPosition + batchSize,
32324 totalItems
32325 );
32326 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
32327 if (currentEndPosition < totalItems) {
32328 const newStartPosition = currentEndPosition;
32329 captureAnchorElement(target, anchorElementRef, "down");
32330 onChangeViewRef.current({
32331 ...currentView,
32332 startPosition: newStartPosition
32333 });
32334 }
32335 }
32336 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
32337 if (currentStartPosition > 1) {
32338 const calculatedStartPosition = currentStartPosition - batchSize;
32339 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
32340 captureAnchorElement(target, anchorElementRef, "up");
32341 onChangeViewRef.current({
32342 ...currentView,
32343 startPosition: newStartPosition
32344 });
32345 }
32346 }
32347 }, 50);
32348 const container = containerRef.current;
32349 container.addEventListener("scroll", handleScroll);
32350 return () => {
32351 container.removeEventListener("scroll", handleScroll);
32352 handleScroll.cancel();
32353 };
32354 }, [containerRef, view.infiniteScrollEnabled]);
32355 return {
32356 intersectionObserver: intersectionObserverRef.current
32357 };
32358 }
32359
32360 // packages/dataviews/build-module/dataviews/index.mjs
32361 var import_jsx_runtime160 = __toESM(require_jsx_runtime(), 1);
32362 var defaultGetItemId = (item) => item.id;
32363 var defaultIsItemClickable = () => true;
32364 var EMPTY_ARRAY6 = [];
32365 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
32366 var dataViewsLayouts = VIEW_LAYOUTS.filter(
32367 (viewLayout) => !viewLayout.isPicker
32368 );
32369 function DefaultUI({
32370 header,
32371 search = true,
32372 searchLabel = void 0
32373 }) {
32374 const { view } = (0, import_element112.useContext)(dataviews_context_default);
32375 const isInfiniteScroll = view.infiniteScrollEnabled;
32376 return /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)(import_jsx_runtime160.Fragment, { children: [
32377 /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)(
32378 Stack,
32379 {
32380 direction: "row",
32381 align: "top",
32382 justify: "space-between",
32383 className: clsx_default("dataviews__view-actions", {
32384 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
32385 }),
32386 gap: "xs",
32387 children: [
32388 /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)(
32389 Stack,
32390 {
32391 direction: "row",
32392 justify: "start",
32393 gap: "sm",
32394 className: "dataviews__search",
32395 children: [
32396 search && /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(dataviews_search_default, { label: searchLabel }),
32397 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(toggle_default, {})
32398 ]
32399 }
32400 ),
32401 /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
32402 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(dataviews_view_config_default, {}),
32403 header
32404 ] })
32405 ]
32406 }
32407 ),
32408 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
32409 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(DataViewsLayout, {}),
32410 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(DataViewsFooter, {})
32411 ] });
32412 }
32413 function DataViews({
32414 view,
32415 onChangeView,
32416 fields,
32417 search = true,
32418 searchLabel = void 0,
32419 actions = EMPTY_ARRAY6,
32420 data,
32421 getItemId = defaultGetItemId,
32422 getItemLevel,
32423 isLoading = false,
32424 paginationInfo,
32425 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
32426 selection: selectionProperty,
32427 onChangeSelection,
32428 onClickItem,
32429 renderItemLink,
32430 isItemClickable = defaultIsItemClickable,
32431 header,
32432 children,
32433 config = { perPageSizes: [10, 20, 50, 100] },
32434 empty,
32435 onReset
32436 }) {
32437 const [selectionState, setSelectionState] = (0, import_element112.useState)([]);
32438 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
32439 const selection = isUncontrolled ? selectionState : selectionProperty;
32440 const {
32441 data: displayData,
32442 paginationInfo: displayPaginationInfo,
32443 hasInitiallyLoaded,
32444 setVisibleEntries
32445 } = useData({
32446 view,
32447 data,
32448 getItemId,
32449 isLoading,
32450 selection,
32451 paginationInfo
32452 });
32453 const containerRef = (0, import_element112.useRef)(null);
32454 const [containerWidth, setContainerWidth] = (0, import_element112.useState)(0);
32455 const resizeObserverRef = (0, import_compose14.useResizeObserver)(
32456 (resizeObserverEntries) => {
32457 setContainerWidth(
32458 resizeObserverEntries[0].borderBoxSize[0].inlineSize
32459 );
32460 },
32461 { box: "border-box" }
32462 );
32463 const [openedFilter, setOpenedFilter] = (0, import_element112.useState)(null);
32464 function setSelectionWithChange(value) {
32465 const newValue = typeof value === "function" ? value(selection) : value;
32466 if (isUncontrolled) {
32467 setSelectionState(newValue);
32468 }
32469 if (onChangeSelection) {
32470 onChangeSelection(newValue);
32471 }
32472 }
32473 const _fields = (0, import_element112.useMemo)(() => normalizeFields(fields), [fields]);
32474 const _selection = (0, import_element112.useMemo)(() => {
32475 if (view.infiniteScrollEnabled) {
32476 return selection;
32477 }
32478 return selection.filter(
32479 (id) => data.some((item) => getItemId(item) === id)
32480 );
32481 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
32482 const filters = use_filters_default(_fields, view);
32483 const hasPrimaryOrLockedFilters = (0, import_element112.useMemo)(
32484 () => (filters || []).some(
32485 (filter) => filter.isPrimary || filter.isLocked
32486 ),
32487 [filters]
32488 );
32489 const [isShowingFilter, setIsShowingFilter] = (0, import_element112.useState)(
32490 hasPrimaryOrLockedFilters
32491 );
32492 const { intersectionObserver } = useInfiniteScroll({
32493 view,
32494 onChangeView,
32495 isLoading,
32496 paginationInfo,
32497 containerRef,
32498 setVisibleEntries
32499 });
32500 (0, import_element112.useEffect)(() => {
32501 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
32502 setIsShowingFilter(true);
32503 }
32504 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
32505 const defaultLayouts3 = (0, import_element112.useMemo)(
32506 () => Object.fromEntries(
32507 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
32508 return dataViewsLayouts.some(
32509 (viewLayout) => viewLayout.type === layoutType
32510 );
32511 }).map(([key, value]) => [
32512 key,
32513 value === true ? {} : value
32514 ])
32515 ),
32516 [defaultLayoutsProperty]
32517 );
32518 if (!defaultLayouts3[view.type]) {
32519 return null;
32520 }
32521 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
32522 dataviews_context_default.Provider,
32523 {
32524 value: {
32525 view,
32526 onChangeView,
32527 fields: _fields,
32528 actions,
32529 data: displayData,
32530 isLoading,
32531 paginationInfo: displayPaginationInfo,
32532 selection: _selection,
32533 onChangeSelection: setSelectionWithChange,
32534 openedFilter,
32535 setOpenedFilter,
32536 getItemId,
32537 getItemLevel,
32538 isItemClickable,
32539 onClickItem,
32540 renderItemLink,
32541 containerWidth,
32542 containerRef,
32543 resizeObserverRef,
32544 defaultLayouts: defaultLayouts3,
32545 filters,
32546 isShowingFilter,
32547 setIsShowingFilter,
32548 config,
32549 empty,
32550 hasInitiallyLoaded,
32551 onReset,
32552 intersectionObserver
32553 },
32554 children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
32555 DefaultUI,
32556 {
32557 header,
32558 search,
32559 searchLabel
32560 }
32561 ) })
32562 }
32563 );
32564 }
32565 var DataViewsSubComponents = DataViews;
32566 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
32567 DataViewsSubComponents.Filters = filters_default;
32568 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
32569 DataViewsSubComponents.FiltersToggle = toggle_default;
32570 DataViewsSubComponents.Layout = DataViewsLayout;
32571 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
32572 DataViewsSubComponents.Pagination = DataViewsPagination;
32573 DataViewsSubComponents.Search = dataviews_search_default;
32574 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
32575 DataViewsSubComponents.Footer = DataViewsFooter;
32576 var dataviews_default = DataViewsSubComponents;
32577
32578 // packages/dataviews/build-module/dataform/index.mjs
32579 var import_element124 = __toESM(require_element(), 1);
32580
32581 // packages/dataviews/build-module/components/dataform-context/index.mjs
32582 var import_element113 = __toESM(require_element(), 1);
32583 var import_jsx_runtime161 = __toESM(require_jsx_runtime(), 1);
32584 var DataFormContext = (0, import_element113.createContext)({
32585 fields: []
32586 });
32587 DataFormContext.displayName = "DataFormContext";
32588 function DataFormProvider({
32589 fields,
32590 children
32591 }) {
32592 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(DataFormContext.Provider, { value: { fields }, children });
32593 }
32594 var dataform_context_default = DataFormContext;
32595
32596 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
32597 var import_element123 = __toESM(require_element(), 1);
32598
32599 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
32600 var import_element114 = __toESM(require_element(), 1);
32601 var import_components47 = __toESM(require_components(), 1);
32602
32603 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
32604 var import_i18n48 = __toESM(require_i18n(), 1);
32605 var DEFAULT_LAYOUT = {
32606 type: "regular",
32607 labelPosition: "top"
32608 };
32609 var normalizeCardSummaryField = (sum) => {
32610 if (typeof sum === "string") {
32611 return [{ id: sum, visibility: "when-collapsed" }];
32612 }
32613 return sum.map((item) => {
32614 if (typeof item === "string") {
32615 return { id: item, visibility: "when-collapsed" };
32616 }
32617 return { id: item.id, visibility: item.visibility };
32618 });
32619 };
32620 function normalizeLayout(layout) {
32621 let normalizedLayout = DEFAULT_LAYOUT;
32622 if (layout?.type === "regular") {
32623 normalizedLayout = {
32624 type: "regular",
32625 labelPosition: layout?.labelPosition ?? "top"
32626 };
32627 } else if (layout?.type === "panel") {
32628 const summary = layout.summary ?? [];
32629 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
32630 const openAs = layout?.openAs;
32631 let normalizedOpenAs;
32632 if (typeof openAs === "object" && openAs.type === "modal") {
32633 normalizedOpenAs = {
32634 type: "modal",
32635 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n48.__)("Apply"),
32636 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n48.__)("Cancel")
32637 };
32638 } else if (openAs === "modal") {
32639 normalizedOpenAs = {
32640 type: "modal",
32641 applyLabel: (0, import_i18n48.__)("Apply"),
32642 cancelLabel: (0, import_i18n48.__)("Cancel")
32643 };
32644 } else {
32645 normalizedOpenAs = { type: "dropdown" };
32646 }
32647 normalizedLayout = {
32648 type: "panel",
32649 labelPosition: layout?.labelPosition ?? "side",
32650 openAs: normalizedOpenAs,
32651 summary: normalizedSummary,
32652 editVisibility: layout?.editVisibility ?? "on-hover"
32653 };
32654 } else if (layout?.type === "card") {
32655 if (layout.withHeader === false) {
32656 normalizedLayout = {
32657 type: "card",
32658 withHeader: false,
32659 isOpened: true,
32660 summary: [],
32661 isCollapsible: false
32662 };
32663 } else {
32664 const summary = layout.summary ?? [];
32665 normalizedLayout = {
32666 type: "card",
32667 withHeader: true,
32668 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
32669 summary: normalizeCardSummaryField(summary),
32670 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
32671 };
32672 }
32673 } else if (layout?.type === "row") {
32674 normalizedLayout = {
32675 type: "row",
32676 alignment: layout?.alignment ?? "center",
32677 styles: layout?.styles ?? {}
32678 };
32679 } else if (layout?.type === "details") {
32680 normalizedLayout = {
32681 type: "details",
32682 summary: layout?.summary ?? ""
32683 };
32684 }
32685 return normalizedLayout;
32686 }
32687 function normalizeForm(form) {
32688 const normalizedFormLayout = normalizeLayout(form?.layout);
32689 const normalizedFields = (form.fields ?? []).map(
32690 (field) => {
32691 if (typeof field === "string") {
32692 return {
32693 id: field,
32694 layout: normalizedFormLayout
32695 };
32696 }
32697 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
32698 return {
32699 id: field.id,
32700 layout: fieldLayout,
32701 ...!!field.label && { label: field.label },
32702 ...!!field.description && {
32703 description: field.description
32704 },
32705 ..."children" in field && Array.isArray(field.children) && {
32706 children: normalizeForm({
32707 fields: field.children,
32708 layout: DEFAULT_LAYOUT
32709 }).fields
32710 }
32711 };
32712 }
32713 );
32714 return {
32715 layout: normalizedFormLayout,
32716 fields: normalizedFields
32717 };
32718 }
32719 var normalize_form_default = normalizeForm;
32720
32721 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
32722 var import_jsx_runtime162 = __toESM(require_jsx_runtime(), 1);
32723 function Header4({ title }) {
32724 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
32725 Stack,
32726 {
32727 direction: "column",
32728 className: "dataforms-layouts-regular__header",
32729 gap: "lg",
32730 children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components47.__experimentalHeading, { level: 2, size: 13, children: title }) })
32731 }
32732 );
32733 }
32734 function FormRegularField({
32735 data,
32736 field,
32737 onChange,
32738 hideLabelFromVision,
32739 markWhenOptional,
32740 validity
32741 }) {
32742 const { fields } = (0, import_element114.useContext)(dataform_context_default);
32743 const layout = field.layout;
32744 const form = (0, import_element114.useMemo)(
32745 () => ({
32746 layout: DEFAULT_LAYOUT,
32747 fields: !!field.children ? field.children : []
32748 }),
32749 [field]
32750 );
32751 if (!!field.children) {
32752 return /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_jsx_runtime162.Fragment, { children: [
32753 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Header4, { title: field.label }),
32754 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
32755 DataFormLayout,
32756 {
32757 data,
32758 form,
32759 onChange,
32760 validity: validity?.children
32761 }
32762 )
32763 ] });
32764 }
32765 const labelPosition = layout.labelPosition;
32766 const fieldDefinition = fields.find(
32767 (fieldDef) => fieldDef.id === field.id
32768 );
32769 if (!fieldDefinition || !fieldDefinition.Edit) {
32770 return null;
32771 }
32772 if (labelPosition === "side") {
32773 return /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(
32774 Stack,
32775 {
32776 direction: "row",
32777 className: "dataforms-layouts-regular__field",
32778 gap: "sm",
32779 children: [
32780 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
32781 "div",
32782 {
32783 className: clsx_default(
32784 "dataforms-layouts-regular__field-label",
32785 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
32786 ),
32787 children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components47.BaseControl.VisualLabel, { children: fieldDefinition.label })
32788 }
32789 ),
32790 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
32791 fieldDefinition.render,
32792 {
32793 item: data,
32794 field: fieldDefinition
32795 }
32796 ) : /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
32797 fieldDefinition.Edit,
32798 {
32799 data,
32800 field: fieldDefinition,
32801 onChange,
32802 hideLabelFromVision: true,
32803 markWhenOptional,
32804 validity
32805 },
32806 fieldDefinition.id
32807 ) })
32808 ]
32809 }
32810 );
32811 }
32812 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_jsx_runtime162.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_jsx_runtime162.Fragment, { children: [
32813 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components47.BaseControl.VisualLabel, { children: fieldDefinition.label }),
32814 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
32815 fieldDefinition.render,
32816 {
32817 item: data,
32818 field: fieldDefinition
32819 }
32820 )
32821 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
32822 fieldDefinition.Edit,
32823 {
32824 data,
32825 field: fieldDefinition,
32826 onChange,
32827 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
32828 markWhenOptional,
32829 validity
32830 }
32831 ) });
32832 }
32833
32834 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
32835 var import_deepmerge2 = __toESM(require_cjs(), 1);
32836 var import_components50 = __toESM(require_components(), 1);
32837 var import_element119 = __toESM(require_element(), 1);
32838 var import_compose16 = __toESM(require_compose(), 1);
32839
32840 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
32841 var import_components49 = __toESM(require_components(), 1);
32842 var import_i18n49 = __toESM(require_i18n(), 1);
32843 var import_compose15 = __toESM(require_compose(), 1);
32844 var import_element115 = __toESM(require_element(), 1);
32845
32846 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
32847 function getLabelClassName(labelPosition, showError) {
32848 return clsx_default(
32849 "dataforms-layouts-panel__field-label",
32850 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
32851 { "has-error": showError }
32852 );
32853 }
32854 var get_label_classname_default = getLabelClassName;
32855
32856 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
32857 var import_components48 = __toESM(require_components(), 1);
32858 var import_jsx_runtime163 = __toESM(require_jsx_runtime(), 1);
32859 function getLabelContent(showError, errorMessage, fieldLabel) {
32860 return showError ? /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(tooltip_exports.Root, { children: [
32861 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
32862 tooltip_exports.Trigger,
32863 {
32864 render: /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
32865 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_components48.Icon, { icon: error_default, size: 16 }),
32866 /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(VisuallyHidden, { children: [
32867 errorMessage,
32868 ": "
32869 ] }),
32870 fieldLabel
32871 ] })
32872 }
32873 ),
32874 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(tooltip_exports.Popup, { children: errorMessage })
32875 ] }) : fieldLabel;
32876 }
32877 var get_label_content_default = getLabelContent;
32878
32879 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
32880 function getFirstValidationError(validity) {
32881 if (!validity) {
32882 return void 0;
32883 }
32884 const validityRules = Object.keys(validity).filter(
32885 (key) => key !== "children"
32886 );
32887 for (const key of validityRules) {
32888 const rule = validity[key];
32889 if (rule === void 0) {
32890 continue;
32891 }
32892 if (rule.type === "invalid") {
32893 if (rule.message) {
32894 return rule.message;
32895 }
32896 if (key === "required") {
32897 return "A required field is empty";
32898 }
32899 return "Unidentified validation error";
32900 }
32901 }
32902 if (validity.children) {
32903 for (const childValidity of Object.values(validity.children)) {
32904 const childError = getFirstValidationError(childValidity);
32905 if (childError) {
32906 return childError;
32907 }
32908 }
32909 }
32910 return void 0;
32911 }
32912 var get_first_validation_error_default = getFirstValidationError;
32913
32914 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
32915 var import_jsx_runtime164 = __toESM(require_jsx_runtime(), 1);
32916 function SummaryButton({
32917 data,
32918 field,
32919 fieldLabel,
32920 summaryFields,
32921 validity,
32922 touched,
32923 disabled: disabled2,
32924 onClick,
32925 "aria-expanded": ariaExpanded
32926 }) {
32927 const { labelPosition, editVisibility } = field.layout;
32928 const errorMessage = get_first_validation_error_default(validity);
32929 const showError = touched && !!errorMessage;
32930 const labelClassName = get_label_classname_default(labelPosition, showError);
32931 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
32932 const className = clsx_default(
32933 "dataforms-layouts-panel__field-trigger",
32934 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
32935 {
32936 "is-disabled": disabled2,
32937 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
32938 }
32939 );
32940 const controlId = (0, import_compose15.useInstanceId)(
32941 SummaryButton,
32942 "dataforms-layouts-panel__field-control"
32943 );
32944 const ariaLabel = showError ? (0, import_i18n49.sprintf)(
32945 // translators: %s: Field name.
32946 (0, import_i18n49._x)("Edit %s (has errors)", "field"),
32947 fieldLabel || ""
32948 ) : (0, import_i18n49.sprintf)(
32949 // translators: %s: Field name.
32950 (0, import_i18n49._x)("Edit %s", "field"),
32951 fieldLabel || ""
32952 );
32953 const rowRef = (0, import_element115.useRef)(null);
32954 const handleRowClick = () => {
32955 const selection = rowRef.current?.ownerDocument.defaultView?.getSelection();
32956 if (selection && selection.toString().length > 0) {
32957 return;
32958 }
32959 onClick();
32960 };
32961 const handleKeyDown = (event) => {
32962 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
32963 event.preventDefault();
32964 onClick();
32965 }
32966 };
32967 return /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(
32968 "div",
32969 {
32970 ref: rowRef,
32971 className,
32972 onClick: !disabled2 ? handleRowClick : void 0,
32973 onKeyDown: !disabled2 ? handleKeyDown : void 0,
32974 children: [
32975 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime164.jsx)("span", { className: labelClassName, children: labelContent }),
32976 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(tooltip_exports.Root, { children: [
32977 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
32978 tooltip_exports.Trigger,
32979 {
32980 render: /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
32981 "span",
32982 {
32983 className: "dataforms-layouts-panel__field-label-error-content",
32984 role: "img",
32985 "aria-label": errorMessage,
32986 children: /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(import_components49.Icon, { icon: error_default, size: 16 })
32987 }
32988 )
32989 }
32990 ),
32991 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(tooltip_exports.Popup, { children: errorMessage })
32992 ] }),
32993 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
32994 "span",
32995 {
32996 id: `${controlId}`,
32997 className: "dataforms-layouts-panel__field-control",
32998 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
32999 "span",
33000 {
33001 style: {
33002 display: "flex",
33003 flexDirection: "column",
33004 alignItems: "flex-start",
33005 width: "100%",
33006 gap: "2px"
33007 },
33008 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
33009 "span",
33010 {
33011 style: { width: "100%" },
33012 children: /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
33013 summaryField.render,
33014 {
33015 item: data,
33016 field: summaryField
33017 }
33018 )
33019 },
33020 summaryField.id
33021 ))
33022 }
33023 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
33024 summaryField.render,
33025 {
33026 item: data,
33027 field: summaryField
33028 },
33029 summaryField.id
33030 ))
33031 }
33032 ),
33033 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
33034 import_components49.Button,
33035 {
33036 className: "dataforms-layouts-panel__field-trigger-icon",
33037 label: ariaLabel,
33038 icon: pencil_default,
33039 size: "small",
33040 "aria-expanded": ariaExpanded,
33041 "aria-haspopup": "dialog",
33042 "aria-describedby": `${controlId}`
33043 }
33044 )
33045 ]
33046 }
33047 );
33048 }
33049
33050 // packages/dataviews/build-module/hooks/use-form-validity.mjs
33051 var import_deepmerge = __toESM(require_cjs(), 1);
33052 var import_es62 = __toESM(require_es6(), 1);
33053 var import_element116 = __toESM(require_element(), 1);
33054 var import_i18n50 = __toESM(require_i18n(), 1);
33055 function isFormValid(formValidity) {
33056 if (!formValidity) {
33057 return true;
33058 }
33059 return Object.values(formValidity).every((fieldValidation) => {
33060 return Object.entries(fieldValidation).every(
33061 ([key, validation]) => {
33062 if (key === "children" && validation && typeof validation === "object") {
33063 return isFormValid(validation);
33064 }
33065 return validation.type !== "invalid" && validation.type !== "validating";
33066 }
33067 );
33068 });
33069 }
33070 function getFormFieldsToValidate(form, fields) {
33071 const normalizedForm = normalize_form_default(form);
33072 if (normalizedForm.fields.length === 0) {
33073 return [];
33074 }
33075 const fieldsMap = /* @__PURE__ */ new Map();
33076 fields.forEach((field) => {
33077 fieldsMap.set(field.id, field);
33078 });
33079 function processFormField(formField) {
33080 if ("children" in formField && Array.isArray(formField.children)) {
33081 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
33082 if (processedChildren.length === 0) {
33083 return null;
33084 }
33085 const fieldDef2 = fieldsMap.get(formField.id);
33086 if (fieldDef2) {
33087 const [normalizedField2] = normalizeFields([
33088 fieldDef2
33089 ]);
33090 return {
33091 id: formField.id,
33092 children: processedChildren,
33093 field: normalizedField2
33094 };
33095 }
33096 return {
33097 id: formField.id,
33098 children: processedChildren
33099 };
33100 }
33101 const fieldDef = fieldsMap.get(formField.id);
33102 if (!fieldDef) {
33103 return null;
33104 }
33105 const [normalizedField] = normalizeFields([fieldDef]);
33106 return {
33107 id: formField.id,
33108 children: [],
33109 field: normalizedField
33110 };
33111 }
33112 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
33113 return toValidate;
33114 }
33115 function setValidityAtPath(formValidity, fieldValidity, path) {
33116 if (!formValidity) {
33117 formValidity = {};
33118 }
33119 if (path.length === 0) {
33120 return formValidity;
33121 }
33122 const result = { ...formValidity };
33123 let current = result;
33124 for (let i2 = 0; i2 < path.length - 1; i2++) {
33125 const segment = path[i2];
33126 if (!current[segment]) {
33127 current[segment] = {};
33128 }
33129 current[segment] = { ...current[segment] };
33130 current = current[segment];
33131 }
33132 const finalKey = path[path.length - 1];
33133 current[finalKey] = {
33134 ...current[finalKey] || {},
33135 ...fieldValidity
33136 };
33137 return result;
33138 }
33139 function removeValidationProperty(formValidity, path, property) {
33140 if (!formValidity || path.length === 0) {
33141 return formValidity;
33142 }
33143 const result = { ...formValidity };
33144 let current = result;
33145 for (let i2 = 0; i2 < path.length - 1; i2++) {
33146 const segment = path[i2];
33147 if (!current[segment]) {
33148 return formValidity;
33149 }
33150 current[segment] = { ...current[segment] };
33151 current = current[segment];
33152 }
33153 const finalKey = path[path.length - 1];
33154 if (!current[finalKey]) {
33155 return formValidity;
33156 }
33157 const fieldValidity = { ...current[finalKey] };
33158 delete fieldValidity[property];
33159 if (Object.keys(fieldValidity).length === 0) {
33160 delete current[finalKey];
33161 } else {
33162 current[finalKey] = fieldValidity;
33163 }
33164 if (Object.keys(result).length === 0) {
33165 return void 0;
33166 }
33167 return result;
33168 }
33169 function handleElementsValidationAsync(promise, formField, promiseHandler) {
33170 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
33171 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
33172 elementsCounterRef.current[formField.id] = currentToken;
33173 promise.then((result) => {
33174 if (currentToken !== elementsCounterRef.current[formField.id]) {
33175 return;
33176 }
33177 if (!Array.isArray(result)) {
33178 setFormValidity((prev) => {
33179 const newFormValidity = setValidityAtPath(
33180 prev,
33181 {
33182 elements: {
33183 type: "invalid",
33184 message: (0, import_i18n50.__)("Could not validate elements.")
33185 }
33186 },
33187 [...path, formField.id]
33188 );
33189 return newFormValidity;
33190 });
33191 return;
33192 }
33193 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
33194 ...formField.field,
33195 elements: result
33196 })) {
33197 setFormValidity((prev) => {
33198 const newFormValidity = setValidityAtPath(
33199 prev,
33200 {
33201 elements: {
33202 type: "invalid",
33203 message: (0, import_i18n50.__)(
33204 "Value must be one of the elements."
33205 )
33206 }
33207 },
33208 [...path, formField.id]
33209 );
33210 return newFormValidity;
33211 });
33212 } else {
33213 setFormValidity((prev) => {
33214 return removeValidationProperty(
33215 prev,
33216 [...path, formField.id],
33217 "elements"
33218 );
33219 });
33220 }
33221 }).catch((error2) => {
33222 if (currentToken !== elementsCounterRef.current[formField.id]) {
33223 return;
33224 }
33225 let errorMessage;
33226 if (error2 instanceof Error) {
33227 errorMessage = error2.message;
33228 } else {
33229 errorMessage = String(error2) || (0, import_i18n50.__)(
33230 "Unknown error when running elements validation asynchronously."
33231 );
33232 }
33233 setFormValidity((prev) => {
33234 const newFormValidity = setValidityAtPath(
33235 prev,
33236 {
33237 elements: {
33238 type: "invalid",
33239 message: errorMessage
33240 }
33241 },
33242 [...path, formField.id]
33243 );
33244 return newFormValidity;
33245 });
33246 });
33247 }
33248 function handleCustomValidationAsync(promise, formField, promiseHandler) {
33249 const { customCounterRef, setFormValidity, path } = promiseHandler;
33250 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
33251 customCounterRef.current[formField.id] = currentToken;
33252 promise.then((result) => {
33253 if (currentToken !== customCounterRef.current[formField.id]) {
33254 return;
33255 }
33256 if (result === null) {
33257 setFormValidity((prev) => {
33258 return removeValidationProperty(
33259 prev,
33260 [...path, formField.id],
33261 "custom"
33262 );
33263 });
33264 return;
33265 }
33266 if (typeof result === "string") {
33267 setFormValidity((prev) => {
33268 const newFormValidity = setValidityAtPath(
33269 prev,
33270 {
33271 custom: {
33272 type: "invalid",
33273 message: result
33274 }
33275 },
33276 [...path, formField.id]
33277 );
33278 return newFormValidity;
33279 });
33280 return;
33281 }
33282 setFormValidity((prev) => {
33283 const newFormValidity = setValidityAtPath(
33284 prev,
33285 {
33286 custom: {
33287 type: "invalid",
33288 message: (0, import_i18n50.__)("Validation could not be processed.")
33289 }
33290 },
33291 [...path, formField.id]
33292 );
33293 return newFormValidity;
33294 });
33295 }).catch((error2) => {
33296 if (currentToken !== customCounterRef.current[formField.id]) {
33297 return;
33298 }
33299 let errorMessage;
33300 if (error2 instanceof Error) {
33301 errorMessage = error2.message;
33302 } else {
33303 errorMessage = String(error2) || (0, import_i18n50.__)(
33304 "Unknown error when running custom validation asynchronously."
33305 );
33306 }
33307 setFormValidity((prev) => {
33308 const newFormValidity = setValidityAtPath(
33309 prev,
33310 {
33311 custom: {
33312 type: "invalid",
33313 message: errorMessage
33314 }
33315 },
33316 [...path, formField.id]
33317 );
33318 return newFormValidity;
33319 });
33320 });
33321 }
33322 function validateFormField(item, formField, promiseHandler) {
33323 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
33324 return {
33325 required: { type: "invalid" }
33326 };
33327 }
33328 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
33329 return {
33330 pattern: {
33331 type: "invalid",
33332 message: (0, import_i18n50.__)("Value does not match the required pattern.")
33333 }
33334 };
33335 }
33336 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
33337 return {
33338 min: {
33339 type: "invalid",
33340 message: (0, import_i18n50.__)("Value is below the minimum.")
33341 }
33342 };
33343 }
33344 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
33345 return {
33346 max: {
33347 type: "invalid",
33348 message: (0, import_i18n50.__)("Value is above the maximum.")
33349 }
33350 };
33351 }
33352 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
33353 return {
33354 minLength: {
33355 type: "invalid",
33356 message: (0, import_i18n50.__)("Value is too short.")
33357 }
33358 };
33359 }
33360 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
33361 return {
33362 maxLength: {
33363 type: "invalid",
33364 message: (0, import_i18n50.__)("Value is too long.")
33365 }
33366 };
33367 }
33368 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
33369 return {
33370 elements: {
33371 type: "invalid",
33372 message: (0, import_i18n50.__)("Value must be one of the elements.")
33373 }
33374 };
33375 }
33376 let customError;
33377 if (!!formField.field && formField.field.isValid.custom) {
33378 try {
33379 const value = formField.field.getValue({ item });
33380 customError = formField.field.isValid.custom(
33381 (0, import_deepmerge.default)(
33382 item,
33383 formField.field.setValue({
33384 item,
33385 value
33386 })
33387 ),
33388 formField.field
33389 );
33390 } catch (error2) {
33391 let errorMessage;
33392 if (error2 instanceof Error) {
33393 errorMessage = error2.message;
33394 } else {
33395 errorMessage = String(error2) || (0, import_i18n50.__)("Unknown error when running custom validation.");
33396 }
33397 return {
33398 custom: {
33399 type: "invalid",
33400 message: errorMessage
33401 }
33402 };
33403 }
33404 }
33405 if (typeof customError === "string") {
33406 return {
33407 custom: {
33408 type: "invalid",
33409 message: customError
33410 }
33411 };
33412 }
33413 const fieldValidity = {};
33414 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
33415 handleElementsValidationAsync(
33416 formField.field.getElements(),
33417 formField,
33418 promiseHandler
33419 );
33420 fieldValidity.elements = {
33421 type: "validating",
33422 message: (0, import_i18n50.__)("Validating\u2026")
33423 };
33424 }
33425 if (customError instanceof Promise) {
33426 handleCustomValidationAsync(customError, formField, promiseHandler);
33427 fieldValidity.custom = {
33428 type: "validating",
33429 message: (0, import_i18n50.__)("Validating\u2026")
33430 };
33431 }
33432 if (Object.keys(fieldValidity).length > 0) {
33433 return fieldValidity;
33434 }
33435 if (formField.children.length > 0) {
33436 const result = {};
33437 formField.children.forEach((child) => {
33438 result[child.id] = validateFormField(item, child, {
33439 ...promiseHandler,
33440 path: [...promiseHandler.path, formField.id, "children"]
33441 });
33442 });
33443 const filteredResult = {};
33444 Object.entries(result).forEach(([key, value]) => {
33445 if (value !== void 0) {
33446 filteredResult[key] = value;
33447 }
33448 });
33449 if (Object.keys(filteredResult).length === 0) {
33450 return void 0;
33451 }
33452 return {
33453 children: filteredResult
33454 };
33455 }
33456 return void 0;
33457 }
33458 function getFormFieldValue(formField, item) {
33459 const fieldValue = formField?.field?.getValue({ item });
33460 if (formField.children.length === 0) {
33461 return fieldValue;
33462 }
33463 const childrenValues = formField.children.map(
33464 (child) => getFormFieldValue(child, item)
33465 );
33466 if (!childrenValues) {
33467 return fieldValue;
33468 }
33469 return {
33470 value: fieldValue,
33471 children: childrenValues
33472 };
33473 }
33474 function useFormValidity(item, fields, form) {
33475 const [formValidity, setFormValidity] = (0, import_element116.useState)();
33476 const customCounterRef = (0, import_element116.useRef)({});
33477 const elementsCounterRef = (0, import_element116.useRef)({});
33478 const previousValuesRef = (0, import_element116.useRef)({});
33479 const validate = (0, import_element116.useCallback)(() => {
33480 const promiseHandler = {
33481 customCounterRef,
33482 elementsCounterRef,
33483 setFormValidity,
33484 path: [],
33485 item
33486 };
33487 const formFieldsToValidate = getFormFieldsToValidate(form, fields);
33488 if (formFieldsToValidate.length === 0) {
33489 setFormValidity(void 0);
33490 return;
33491 }
33492 const newFormValidity = {};
33493 const untouchedFields = [];
33494 formFieldsToValidate.forEach((formField) => {
33495 const value = getFormFieldValue(formField, item);
33496 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)(
33497 previousValuesRef.current[formField.id],
33498 value
33499 )) {
33500 untouchedFields.push(formField.id);
33501 return;
33502 }
33503 previousValuesRef.current[formField.id] = value;
33504 const fieldValidity = validateFormField(
33505 item,
33506 formField,
33507 promiseHandler
33508 );
33509 if (fieldValidity !== void 0) {
33510 newFormValidity[formField.id] = fieldValidity;
33511 }
33512 });
33513 setFormValidity((existingFormValidity) => {
33514 let validity = {
33515 ...existingFormValidity,
33516 ...newFormValidity
33517 };
33518 const fieldsToKeep = [
33519 ...untouchedFields,
33520 ...Object.keys(newFormValidity)
33521 ];
33522 Object.keys(validity).forEach((key) => {
33523 if (validity && !fieldsToKeep.includes(key)) {
33524 delete validity[key];
33525 }
33526 });
33527 if (Object.keys(validity).length === 0) {
33528 validity = void 0;
33529 }
33530 const areEqual = (0, import_es62.default)(existingFormValidity, validity);
33531 if (areEqual) {
33532 return existingFormValidity;
33533 }
33534 return validity;
33535 });
33536 }, [item, fields, form]);
33537 (0, import_element116.useEffect)(() => {
33538 validate();
33539 }, [validate]);
33540 return {
33541 validity: formValidity,
33542 isValid: isFormValid(formValidity)
33543 };
33544 }
33545 var use_form_validity_default = useFormValidity;
33546
33547 // packages/dataviews/build-module/hooks/use-report-validity.mjs
33548 var import_element117 = __toESM(require_element(), 1);
33549 function useReportValidity(ref, shouldReport) {
33550 (0, import_element117.useEffect)(() => {
33551 if (shouldReport && ref.current) {
33552 const inputs = ref.current.querySelectorAll(
33553 "input, textarea, select"
33554 );
33555 inputs.forEach((input) => {
33556 input.reportValidity();
33557 });
33558 }
33559 }, [shouldReport, ref]);
33560 }
33561
33562 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
33563 var import_element118 = __toESM(require_element(), 1);
33564
33565 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
33566 function extractSummaryIds(summary) {
33567 if (Array.isArray(summary)) {
33568 return summary.map(
33569 (item) => typeof item === "string" ? item : item.id
33570 );
33571 }
33572 return [];
33573 }
33574 var getSummaryFields = (summaryField, fields) => {
33575 if (Array.isArray(summaryField) && summaryField.length > 0) {
33576 const summaryIds = extractSummaryIds(summaryField);
33577 return summaryIds.map(
33578 (summaryId) => fields.find((_field) => _field.id === summaryId)
33579 ).filter((_field) => _field !== void 0);
33580 }
33581 return [];
33582 };
33583
33584 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
33585 var getFieldDefinition = (field, fields) => {
33586 const fieldDefinition = fields.find((_field) => _field.id === field.id);
33587 if (!fieldDefinition) {
33588 return fields.find((_field) => {
33589 if (!!field.children) {
33590 const simpleChildren = field.children.filter(
33591 (child) => !child.children
33592 );
33593 if (simpleChildren.length === 0) {
33594 return false;
33595 }
33596 return _field.id === simpleChildren[0].id;
33597 }
33598 return _field.id === field.id;
33599 });
33600 }
33601 return fieldDefinition;
33602 };
33603 function useFieldFromFormField(field) {
33604 const { fields } = (0, import_element118.useContext)(dataform_context_default);
33605 const layout = field.layout;
33606 const summaryFields = getSummaryFields(layout.summary, fields);
33607 const fieldDefinition = getFieldDefinition(field, fields);
33608 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
33609 if (summaryFields.length === 0) {
33610 return {
33611 summaryFields: fieldDefinition ? [fieldDefinition] : [],
33612 fieldDefinition,
33613 fieldLabel
33614 };
33615 }
33616 return {
33617 summaryFields,
33618 fieldDefinition,
33619 fieldLabel
33620 };
33621 }
33622 var use_field_from_form_field_default = useFieldFromFormField;
33623
33624 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
33625 var import_jsx_runtime165 = __toESM(require_jsx_runtime(), 1);
33626 function ModalContent({
33627 data,
33628 field,
33629 onChange,
33630 fieldLabel,
33631 onClose,
33632 touched
33633 }) {
33634 const { openAs } = field.layout;
33635 const { applyLabel, cancelLabel } = openAs;
33636 const { fields } = (0, import_element119.useContext)(dataform_context_default);
33637 const [changes, setChanges] = (0, import_element119.useState)({});
33638 const modalData = (0, import_element119.useMemo)(() => {
33639 return (0, import_deepmerge2.default)(data, changes, {
33640 arrayMerge: (target, source) => source
33641 });
33642 }, [data, changes]);
33643 const form = (0, import_element119.useMemo)(
33644 () => ({
33645 layout: DEFAULT_LAYOUT,
33646 fields: !!field.children ? field.children : (
33647 // If not explicit children return the field id itself.
33648 [{ id: field.id, layout: DEFAULT_LAYOUT }]
33649 )
33650 }),
33651 [field]
33652 );
33653 const fieldsAsFieldType = fields.map((f2) => ({
33654 ...f2,
33655 Edit: f2.Edit === null ? void 0 : f2.Edit,
33656 isValid: {
33657 required: f2.isValid.required?.constraint,
33658 elements: f2.isValid.elements?.constraint,
33659 min: f2.isValid.min?.constraint,
33660 max: f2.isValid.max?.constraint,
33661 pattern: f2.isValid.pattern?.constraint,
33662 minLength: f2.isValid.minLength?.constraint,
33663 maxLength: f2.isValid.maxLength?.constraint
33664 }
33665 }));
33666 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
33667 const onApply = () => {
33668 onChange(changes);
33669 onClose();
33670 };
33671 const handleOnChange = (newValue) => {
33672 setChanges(
33673 (prev) => (0, import_deepmerge2.default)(prev, newValue, {
33674 arrayMerge: (target, source) => source
33675 })
33676 );
33677 };
33678 const focusOnMountRef = (0, import_compose16.useFocusOnMount)("firstInputElement");
33679 const contentRef = (0, import_element119.useRef)(null);
33680 const mergedRef = (0, import_compose16.useMergeRefs)([focusOnMountRef, contentRef]);
33681 useReportValidity(contentRef, touched);
33682 return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(
33683 import_components50.Modal,
33684 {
33685 className: "dataforms-layouts-panel__modal",
33686 onRequestClose: onClose,
33687 isFullScreen: false,
33688 title: fieldLabel,
33689 size: "medium",
33690 children: [
33691 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
33692 DataFormLayout,
33693 {
33694 data: modalData,
33695 form,
33696 onChange: handleOnChange,
33697 validity,
33698 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
33699 FieldLayout,
33700 {
33701 data: modalData,
33702 field: childField,
33703 onChange: handleOnChange,
33704 hideLabelFromVision: form.fields.length < 2,
33705 markWhenOptional,
33706 validity: childFieldValidity
33707 },
33708 childField.id
33709 )
33710 }
33711 ) }),
33712 /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(
33713 Stack,
33714 {
33715 direction: "row",
33716 className: "dataforms-layouts-panel__modal-footer",
33717 gap: "md",
33718 children: [
33719 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(import_components50.__experimentalSpacer, { style: { flex: 1 } }),
33720 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
33721 import_components50.Button,
33722 {
33723 variant: "tertiary",
33724 onClick: onClose,
33725 __next40pxDefaultSize: true,
33726 children: cancelLabel
33727 }
33728 ),
33729 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
33730 import_components50.Button,
33731 {
33732 variant: "primary",
33733 onClick: onApply,
33734 __next40pxDefaultSize: true,
33735 children: applyLabel
33736 }
33737 )
33738 ]
33739 }
33740 )
33741 ]
33742 }
33743 );
33744 }
33745 function PanelModal({
33746 data,
33747 field,
33748 onChange,
33749 validity
33750 }) {
33751 const [touched, setTouched] = (0, import_element119.useState)(false);
33752 const [isOpen, setIsOpen] = (0, import_element119.useState)(false);
33753 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
33754 if (!fieldDefinition) {
33755 return null;
33756 }
33757 const handleClose = () => {
33758 setIsOpen(false);
33759 setTouched(true);
33760 };
33761 return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(import_jsx_runtime165.Fragment, { children: [
33762 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
33763 SummaryButton,
33764 {
33765 data,
33766 field,
33767 fieldLabel,
33768 summaryFields,
33769 validity,
33770 touched,
33771 disabled: fieldDefinition.readOnly === true,
33772 onClick: () => setIsOpen(true),
33773 "aria-expanded": isOpen
33774 }
33775 ),
33776 isOpen && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
33777 ModalContent,
33778 {
33779 data,
33780 field,
33781 onChange,
33782 fieldLabel: fieldLabel ?? "",
33783 onClose: handleClose,
33784 touched
33785 }
33786 )
33787 ] });
33788 }
33789 var modal_default = PanelModal;
33790
33791 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
33792 var import_components51 = __toESM(require_components(), 1);
33793 var import_i18n51 = __toESM(require_i18n(), 1);
33794 var import_element120 = __toESM(require_element(), 1);
33795 var import_compose17 = __toESM(require_compose(), 1);
33796 var import_jsx_runtime166 = __toESM(require_jsx_runtime(), 1);
33797 function DropdownHeader({
33798 title,
33799 onClose
33800 }) {
33801 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33802 Stack,
33803 {
33804 direction: "column",
33805 className: "dataforms-layouts-panel__dropdown-header",
33806 gap: "lg",
33807 children: /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
33808 title && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(import_components51.__experimentalHeading, { level: 2, size: 13, children: title }),
33809 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(import_components51.__experimentalSpacer, { style: { flex: 1 } }),
33810 onClose && /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33811 import_components51.Button,
33812 {
33813 label: (0, import_i18n51.__)("Close"),
33814 icon: close_small_default,
33815 onClick: onClose,
33816 size: "small"
33817 }
33818 )
33819 ] })
33820 }
33821 );
33822 }
33823 function DropdownContentWithValidation({
33824 touched,
33825 children
33826 }) {
33827 const ref = (0, import_element120.useRef)(null);
33828 useReportValidity(ref, touched);
33829 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)("div", { ref, children });
33830 }
33831 function PanelDropdown({
33832 data,
33833 field,
33834 onChange,
33835 validity
33836 }) {
33837 const [touched, setTouched] = (0, import_element120.useState)(false);
33838 const [popoverAnchor, setPopoverAnchor] = (0, import_element120.useState)(
33839 null
33840 );
33841 const popoverProps = (0, import_element120.useMemo)(
33842 () => ({
33843 // Anchor the popover to the middle of the entire row so that it doesn't
33844 // move around when the label changes.
33845 anchor: popoverAnchor,
33846 placement: "left-start",
33847 offset: 36,
33848 shift: true
33849 }),
33850 [popoverAnchor]
33851 );
33852 const [dialogRef, dialogProps] = (0, import_compose17.__experimentalUseDialog)({
33853 focusOnMount: "firstInputElement"
33854 });
33855 const form = (0, import_element120.useMemo)(
33856 () => ({
33857 layout: DEFAULT_LAYOUT,
33858 fields: !!field.children ? field.children : (
33859 // If not explicit children return the field id itself.
33860 [{ id: field.id, layout: DEFAULT_LAYOUT }]
33861 )
33862 }),
33863 [field]
33864 );
33865 const formValidity = (0, import_element120.useMemo)(() => {
33866 if (validity === void 0) {
33867 return void 0;
33868 }
33869 if (!!field.children) {
33870 return validity?.children;
33871 }
33872 return { [field.id]: validity };
33873 }, [validity, field]);
33874 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
33875 if (!fieldDefinition) {
33876 return null;
33877 }
33878 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33879 "div",
33880 {
33881 ref: setPopoverAnchor,
33882 className: "dataforms-layouts-panel__field-dropdown-anchor",
33883 children: /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33884 import_components51.Dropdown,
33885 {
33886 contentClassName: "dataforms-layouts-panel__field-dropdown",
33887 popoverProps,
33888 focusOnMount: false,
33889 onToggle: (willOpen) => {
33890 if (!willOpen) {
33891 setTouched(true);
33892 }
33893 },
33894 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33895 SummaryButton,
33896 {
33897 data,
33898 field,
33899 fieldLabel,
33900 summaryFields,
33901 validity,
33902 touched,
33903 disabled: fieldDefinition.readOnly === true,
33904 onClick: onToggle,
33905 "aria-expanded": isOpen
33906 }
33907 ),
33908 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
33909 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33910 DropdownHeader,
33911 {
33912 title: fieldLabel,
33913 onClose
33914 }
33915 ),
33916 /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33917 DataFormLayout,
33918 {
33919 data,
33920 form,
33921 onChange,
33922 validity: formValidity,
33923 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
33924 FieldLayout,
33925 {
33926 data,
33927 field: childField,
33928 onChange,
33929 hideLabelFromVision: (form?.fields ?? []).length < 2,
33930 markWhenOptional,
33931 validity: childFieldValidity
33932 },
33933 childField.id
33934 )
33935 }
33936 )
33937 ] }) })
33938 }
33939 )
33940 }
33941 );
33942 }
33943 var dropdown_default = PanelDropdown;
33944
33945 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
33946 var import_jsx_runtime167 = __toESM(require_jsx_runtime(), 1);
33947 function FormPanelField({
33948 data,
33949 field,
33950 onChange,
33951 validity
33952 }) {
33953 const layout = field.layout;
33954 if (layout.openAs.type === "modal") {
33955 return /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
33956 modal_default,
33957 {
33958 data,
33959 field,
33960 onChange,
33961 validity
33962 }
33963 );
33964 }
33965 return /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
33966 dropdown_default,
33967 {
33968 data,
33969 field,
33970 onChange,
33971 validity
33972 }
33973 );
33974 }
33975
33976 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
33977 var import_element121 = __toESM(require_element(), 1);
33978
33979 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
33980 var import_i18n52 = __toESM(require_i18n(), 1);
33981 var import_jsx_runtime168 = __toESM(require_jsx_runtime(), 1);
33982 function countInvalidFields(validity) {
33983 if (!validity) {
33984 return 0;
33985 }
33986 let count = 0;
33987 const validityRules = Object.keys(validity).filter(
33988 (key) => key !== "children"
33989 );
33990 for (const key of validityRules) {
33991 const rule = validity[key];
33992 if (rule?.type === "invalid") {
33993 count++;
33994 }
33995 }
33996 if (validity.children) {
33997 for (const childValidity of Object.values(validity.children)) {
33998 count += countInvalidFields(childValidity);
33999 }
34000 }
34001 return count;
34002 }
34003 function ValidationBadge({
34004 validity
34005 }) {
34006 const invalidCount = countInvalidFields(validity);
34007 if (invalidCount === 0) {
34008 return null;
34009 }
34010 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(Badge, { intent: "high", children: (0, import_i18n52.sprintf)(
34011 /* translators: %d: Number of fields that need attention */
34012 (0, import_i18n52._n)(
34013 "%d field needs attention",
34014 "%d fields need attention",
34015 invalidCount
34016 ),
34017 invalidCount
34018 ) });
34019 }
34020
34021 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
34022 var import_jsx_runtime169 = __toESM(require_jsx_runtime(), 1);
34023 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
34024 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
34025 return false;
34026 }
34027 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
34028 const fieldConfig = summaryConfigArray.find((config) => {
34029 if (typeof config === "string") {
34030 return config === summaryField.id;
34031 }
34032 if (typeof config === "object" && "id" in config) {
34033 return config.id === summaryField.id;
34034 }
34035 return false;
34036 });
34037 if (!fieldConfig) {
34038 return false;
34039 }
34040 if (typeof fieldConfig === "string") {
34041 return true;
34042 }
34043 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
34044 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
34045 }
34046 return true;
34047 }
34048 function HeaderContent({
34049 data,
34050 fields,
34051 label,
34052 layout,
34053 isOpen,
34054 touched,
34055 validity
34056 }) {
34057 const summaryFields = getSummaryFields(layout.summary, fields);
34058 const visibleSummaryFields = summaryFields.filter(
34059 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
34060 );
34061 const hasBadge = touched && layout.isCollapsible;
34062 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader;
34063 return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(
34064 Stack,
34065 {
34066 align: "center",
34067 justify: "space-between",
34068 className: "dataforms-layouts-card__field-header-content",
34069 children: [
34070 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(card_exports.Title, { children: label }),
34071 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [
34072 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(ValidationBadge, { validity }),
34073 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime169.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
34074 summaryField.render,
34075 {
34076 item: data,
34077 field: summaryField
34078 },
34079 summaryField.id
34080 )) })
34081 ] })
34082 ]
34083 }
34084 );
34085 }
34086 function BodyContent({
34087 data,
34088 field,
34089 form,
34090 onChange,
34091 hideLabelFromVision,
34092 markWhenOptional,
34093 validity,
34094 withHeader
34095 }) {
34096 if (field.children) {
34097 return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(import_jsx_runtime169.Fragment, { children: [
34098 field.description && /* @__PURE__ */ (0, import_jsx_runtime169.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
34099 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
34100 DataFormLayout,
34101 {
34102 data,
34103 form,
34104 onChange,
34105 validity: validity?.children
34106 }
34107 )
34108 ] });
34109 }
34110 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
34111 if (!SingleFieldLayout) {
34112 return null;
34113 }
34114 return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
34115 SingleFieldLayout,
34116 {
34117 data,
34118 field,
34119 onChange,
34120 hideLabelFromVision: hideLabelFromVision || withHeader,
34121 markWhenOptional,
34122 validity
34123 }
34124 );
34125 }
34126 function FormCardField({
34127 data,
34128 field,
34129 onChange,
34130 hideLabelFromVision,
34131 markWhenOptional,
34132 validity
34133 }) {
34134 const { fields } = (0, import_element121.useContext)(dataform_context_default);
34135 const layout = field.layout;
34136 const contentRef = (0, import_element121.useRef)(null);
34137 const form = (0, import_element121.useMemo)(
34138 () => ({
34139 layout: DEFAULT_LAYOUT,
34140 fields: field.children ?? []
34141 }),
34142 [field]
34143 );
34144 const { isOpened, isCollapsible } = layout;
34145 const [isOpen, setIsOpen] = (0, import_element121.useState)(isOpened);
34146 const [touched, setTouched] = (0, import_element121.useState)(false);
34147 (0, import_element121.useEffect)(() => {
34148 setIsOpen(isOpened);
34149 }, [isOpened]);
34150 const handleOpenChange = (0, import_element121.useCallback)((open) => {
34151 if (!open) {
34152 setTouched(true);
34153 }
34154 setIsOpen(open);
34155 }, []);
34156 const handleBlur = (0, import_element121.useCallback)(() => {
34157 setTouched(true);
34158 }, []);
34159 useReportValidity(
34160 contentRef,
34161 (isCollapsible ? isOpen : true) && touched
34162 );
34163 let label = field.label;
34164 let withHeader;
34165 if (field.children) {
34166 withHeader = !!label && layout.withHeader;
34167 } else {
34168 const fieldDefinition = fields.find(
34169 (fieldDef) => fieldDef.id === field.id
34170 );
34171 if (!fieldDefinition || !fieldDefinition.Edit) {
34172 return null;
34173 }
34174 label = fieldDefinition.label;
34175 withHeader = !!label && layout.withHeader;
34176 }
34177 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
34178 BodyContent,
34179 {
34180 data,
34181 field,
34182 form,
34183 onChange,
34184 hideLabelFromVision,
34185 markWhenOptional,
34186 validity,
34187 withHeader
34188 }
34189 );
34190 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
34191 HeaderContent,
34192 {
34193 data,
34194 fields,
34195 label,
34196 layout,
34197 isOpen: isCollapsible ? !!isOpen : true,
34198 touched,
34199 validity
34200 }
34201 );
34202 if (withHeader && isCollapsible) {
34203 return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(
34204 collapsible_card_exports.Root,
34205 {
34206 className: "dataforms-layouts-card__field",
34207 open: isOpen,
34208 onOpenChange: handleOpenChange,
34209 children: [
34210 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(collapsible_card_exports.Header, { children: headerContent }),
34211 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
34212 collapsible_card_exports.Content,
34213 {
34214 ref: contentRef,
34215 onBlur: handleBlur,
34216 children: bodyContent
34217 }
34218 )
34219 ]
34220 }
34221 );
34222 }
34223 return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [
34224 withHeader && /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(card_exports.Header, { children: headerContent }),
34225 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent })
34226 ] });
34227 }
34228
34229 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
34230 var import_components52 = __toESM(require_components(), 1);
34231 var import_jsx_runtime170 = __toESM(require_jsx_runtime(), 1);
34232 function Header5({ title }) {
34233 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
34234 Stack,
34235 {
34236 direction: "column",
34237 className: "dataforms-layouts-row__header",
34238 gap: "lg",
34239 children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_components52.__experimentalHeading, { level: 2, size: 13, children: title }) })
34240 }
34241 );
34242 }
34243 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_jsx_runtime170.Fragment, { children });
34244 function FormRowField({
34245 data,
34246 field,
34247 onChange,
34248 hideLabelFromVision,
34249 markWhenOptional,
34250 validity
34251 }) {
34252 const layout = field.layout;
34253 if (!!field.children) {
34254 const form = {
34255 layout: DEFAULT_LAYOUT,
34256 fields: field.children
34257 };
34258 return /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
34259 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(Header5, { title: field.label }),
34260 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
34261 DataFormLayout,
34262 {
34263 data,
34264 form,
34265 onChange,
34266 validity: validity?.children,
34267 as: EMPTY_WRAPPER,
34268 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
34269 "div",
34270 {
34271 className: "dataforms-layouts-row__field-control",
34272 style: layout.styles[childField.id],
34273 children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
34274 FieldLayout,
34275 {
34276 data,
34277 field: childField,
34278 onChange,
34279 hideLabelFromVision,
34280 markWhenOptional,
34281 validity: childFieldValidity
34282 }
34283 )
34284 },
34285 childField.id
34286 )
34287 }
34288 ) })
34289 ] });
34290 }
34291 const RegularLayout = getFormFieldLayout("regular")?.component;
34292 if (!RegularLayout) {
34293 return null;
34294 }
34295 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_jsx_runtime170.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
34296 RegularLayout,
34297 {
34298 data,
34299 field,
34300 onChange,
34301 markWhenOptional,
34302 validity
34303 }
34304 ) }) });
34305 }
34306
34307 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
34308 var import_element122 = __toESM(require_element(), 1);
34309 var import_i18n53 = __toESM(require_i18n(), 1);
34310 var import_jsx_runtime171 = __toESM(require_jsx_runtime(), 1);
34311 function FormDetailsField({
34312 data,
34313 field,
34314 onChange,
34315 validity
34316 }) {
34317 const { fields } = (0, import_element122.useContext)(dataform_context_default);
34318 const detailsRef = (0, import_element122.useRef)(null);
34319 const contentRef = (0, import_element122.useRef)(null);
34320 const [touched, setTouched] = (0, import_element122.useState)(false);
34321 const [isOpen, setIsOpen] = (0, import_element122.useState)(false);
34322 const form = (0, import_element122.useMemo)(
34323 () => ({
34324 layout: DEFAULT_LAYOUT,
34325 fields: field.children ?? []
34326 }),
34327 [field]
34328 );
34329 (0, import_element122.useEffect)(() => {
34330 const details = detailsRef.current;
34331 if (!details) {
34332 return;
34333 }
34334 const handleToggle = () => {
34335 const nowOpen = details.open;
34336 if (!nowOpen) {
34337 setTouched(true);
34338 }
34339 setIsOpen(nowOpen);
34340 };
34341 details.addEventListener("toggle", handleToggle);
34342 return () => {
34343 details.removeEventListener("toggle", handleToggle);
34344 };
34345 }, []);
34346 useReportValidity(contentRef, isOpen && touched);
34347 const handleBlur = (0, import_element122.useCallback)(() => {
34348 setTouched(true);
34349 }, []);
34350 if (!field.children) {
34351 return null;
34352 }
34353 const summaryFieldId = field.layout.summary ?? "";
34354 const summaryField = summaryFieldId ? fields.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
34355 let summaryContent;
34356 if (summaryField && summaryField.render) {
34357 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(summaryField.render, { item: data, field: summaryField });
34358 } else {
34359 summaryContent = field.label || (0, import_i18n53.__)("More details");
34360 }
34361 return /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)(
34362 "details",
34363 {
34364 ref: detailsRef,
34365 className: "dataforms-layouts-details__details",
34366 children: [
34367 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)(
34368 Stack,
34369 {
34370 direction: "row",
34371 align: "center",
34372 gap: "md",
34373 className: "dataforms-layouts-details__summary-content",
34374 children: [
34375 summaryContent,
34376 touched && /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(ValidationBadge, { validity })
34377 ]
34378 }
34379 ) }),
34380 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
34381 "div",
34382 {
34383 ref: contentRef,
34384 className: "dataforms-layouts-details__content",
34385 onBlur: handleBlur,
34386 children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
34387 DataFormLayout,
34388 {
34389 data,
34390 form,
34391 onChange,
34392 validity: validity?.children
34393 }
34394 )
34395 }
34396 )
34397 ]
34398 }
34399 );
34400 }
34401
34402 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
34403 var import_jsx_runtime172 = __toESM(require_jsx_runtime(), 1);
34404 var FORM_FIELD_LAYOUTS = [
34405 {
34406 type: "regular",
34407 component: FormRegularField,
34408 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
34409 Stack,
34410 {
34411 direction: "column",
34412 className: "dataforms-layouts__wrapper",
34413 gap: "lg",
34414 children
34415 }
34416 )
34417 },
34418 {
34419 type: "panel",
34420 component: FormPanelField,
34421 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
34422 Stack,
34423 {
34424 direction: "column",
34425 className: "dataforms-layouts__wrapper",
34426 gap: "md",
34427 children
34428 }
34429 )
34430 },
34431 {
34432 type: "card",
34433 component: FormCardField,
34434 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
34435 Stack,
34436 {
34437 direction: "column",
34438 className: "dataforms-layouts__wrapper",
34439 gap: "xl",
34440 children
34441 }
34442 )
34443 },
34444 {
34445 type: "row",
34446 component: FormRowField,
34447 wrapper: ({
34448 children,
34449 layout
34450 }) => /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
34451 Stack,
34452 {
34453 direction: "column",
34454 className: "dataforms-layouts__wrapper",
34455 gap: "lg",
34456 children: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
34457 Stack,
34458 {
34459 direction: "row",
34460 gap: "lg",
34461 align: layout.alignment,
34462 children
34463 }
34464 ) })
34465 }
34466 )
34467 },
34468 {
34469 type: "details",
34470 component: FormDetailsField
34471 }
34472 ];
34473 function getFormFieldLayout(type) {
34474 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
34475 }
34476
34477 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
34478 var import_jsx_runtime173 = __toESM(require_jsx_runtime(), 1);
34479 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
34480 function DataFormLayout({
34481 data,
34482 form,
34483 onChange,
34484 validity,
34485 children,
34486 as
34487 }) {
34488 const { fields: fieldDefinitions } = (0, import_element123.useContext)(dataform_context_default);
34489 const markWhenOptional = (0, import_element123.useMemo)(() => {
34490 const requiredCount = fieldDefinitions.filter(
34491 (f2) => !!f2.isValid?.required
34492 ).length;
34493 const optionalCount = fieldDefinitions.length - requiredCount;
34494 return requiredCount > optionalCount;
34495 }, [fieldDefinitions]);
34496 function getFieldDefinition2(field) {
34497 return fieldDefinitions.find(
34498 (fieldDefinition) => fieldDefinition.id === field.id
34499 );
34500 }
34501 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
34502 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
34503 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
34504 if (!FieldLayout) {
34505 return null;
34506 }
34507 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
34508 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
34509 return null;
34510 }
34511 if (children) {
34512 return children(
34513 FieldLayout,
34514 formField,
34515 validity?.[formField.id],
34516 markWhenOptional
34517 );
34518 }
34519 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
34520 FieldLayout,
34521 {
34522 data,
34523 field: formField,
34524 onChange,
34525 markWhenOptional,
34526 validity: validity?.[formField.id]
34527 },
34528 formField.id
34529 );
34530 }) });
34531 }
34532
34533 // packages/dataviews/build-module/dataform/index.mjs
34534 var import_jsx_runtime174 = __toESM(require_jsx_runtime(), 1);
34535 function DataForm({
34536 data,
34537 form,
34538 fields,
34539 onChange,
34540 validity
34541 }) {
34542 const normalizedForm = (0, import_element124.useMemo)(() => normalize_form_default(form), [form]);
34543 const normalizedFields = (0, import_element124.useMemo)(
34544 () => normalizeFields(fields),
34545 [fields]
34546 );
34547 if (!form.fields) {
34548 return null;
34549 }
34550 return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
34551 DataFormLayout,
34552 {
34553 data,
34554 form: normalizedForm,
34555 onChange,
34556 validity
34557 }
34558 ) });
34559 }
34560
34561 // packages/content-types/build-module/post-types/list.mjs
34562 var import_core_data9 = __toESM(require_core_data(), 1);
34563 var import_element133 = __toESM(require_element(), 1);
34564 var import_i18n67 = __toESM(require_i18n(), 1);
34565 import { useNavigate as useNavigate3, useSearch } from "@wordpress/route";
34566
34567 // node_modules/dequal/dist/index.mjs
34568 var has = Object.prototype.hasOwnProperty;
34569 function find(iter, tar, key) {
34570 for (key of iter.keys()) {
34571 if (dequal(key, tar)) return key;
34572 }
34573 }
34574 function dequal(foo, bar) {
34575 var ctor, len, tmp;
34576 if (foo === bar) return true;
34577 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
34578 if (ctor === Date) return foo.getTime() === bar.getTime();
34579 if (ctor === RegExp) return foo.toString() === bar.toString();
34580 if (ctor === Array) {
34581 if ((len = foo.length) === bar.length) {
34582 while (len-- && dequal(foo[len], bar[len])) ;
34583 }
34584 return len === -1;
34585 }
34586 if (ctor === Set) {
34587 if (foo.size !== bar.size) {
34588 return false;
34589 }
34590 for (len of foo) {
34591 tmp = len;
34592 if (tmp && typeof tmp === "object") {
34593 tmp = find(bar, tmp);
34594 if (!tmp) return false;
34595 }
34596 if (!bar.has(tmp)) return false;
34597 }
34598 return true;
34599 }
34600 if (ctor === Map) {
34601 if (foo.size !== bar.size) {
34602 return false;
34603 }
34604 for (len of foo) {
34605 tmp = len[0];
34606 if (tmp && typeof tmp === "object") {
34607 tmp = find(bar, tmp);
34608 if (!tmp) return false;
34609 }
34610 if (!dequal(len[1], bar.get(tmp))) {
34611 return false;
34612 }
34613 }
34614 return true;
34615 }
34616 if (ctor === ArrayBuffer) {
34617 foo = new Uint8Array(foo);
34618 bar = new Uint8Array(bar);
34619 } else if (ctor === DataView) {
34620 if ((len = foo.byteLength) === bar.byteLength) {
34621 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
34622 }
34623 return len === -1;
34624 }
34625 if (ArrayBuffer.isView(foo)) {
34626 if ((len = foo.byteLength) === bar.byteLength) {
34627 while (len-- && foo[len] === bar[len]) ;
34628 }
34629 return len === -1;
34630 }
34631 if (!ctor || typeof foo === "object") {
34632 len = 0;
34633 for (ctor in foo) {
34634 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
34635 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
34636 }
34637 return Object.keys(bar).length === len;
34638 }
34639 }
34640 return foo !== foo && bar !== bar;
34641 }
34642
34643 // packages/views/build-module/use-view.mjs
34644 var import_element125 = __toESM(require_element(), 1);
34645 var import_data6 = __toESM(require_data(), 1);
34646 var import_preferences = __toESM(require_preferences(), 1);
34647
34648 // packages/views/build-module/preference-keys.mjs
34649 function generatePreferenceKey(kind, name, slug) {
34650 return `dataviews-${kind}-${name}-${slug}`;
34651 }
34652
34653 // packages/views/build-module/filter-utils.mjs
34654 var SCALAR_VALUES = [
34655 "titleField",
34656 "mediaField",
34657 "descriptionField",
34658 "showTitle",
34659 "showMedia",
34660 "showDescription",
34661 "showLevels",
34662 "infiniteScrollEnabled"
34663 ];
34664 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView) {
34665 if (!activeViewOverrides) {
34666 return view;
34667 }
34668 let result = view;
34669 for (const key of SCALAR_VALUES) {
34670 if (key in activeViewOverrides) {
34671 result = { ...result, [key]: activeViewOverrides[key] };
34672 }
34673 }
34674 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
34675 const activeFields = new Set(
34676 activeViewOverrides.filters.map((f2) => f2.field)
34677 );
34678 const preserved = (view.filters ?? []).filter(
34679 (f2) => !activeFields.has(f2.field)
34680 );
34681 result = {
34682 ...result,
34683 filters: [...preserved, ...activeViewOverrides.filters]
34684 };
34685 }
34686 if (activeViewOverrides.sort) {
34687 const isDefaultSort = defaultView && view.sort?.field === defaultView.sort?.field && view.sort?.direction === defaultView.sort?.direction;
34688 if (isDefaultSort) {
34689 result = {
34690 ...result,
34691 sort: activeViewOverrides.sort
34692 };
34693 }
34694 }
34695 if (activeViewOverrides.layout) {
34696 result = {
34697 ...result,
34698 layout: {
34699 ...result.layout,
34700 ...activeViewOverrides.layout
34701 }
34702 };
34703 }
34704 if (activeViewOverrides.groupBy) {
34705 result = {
34706 ...result,
34707 groupBy: activeViewOverrides.groupBy
34708 };
34709 }
34710 return result;
34711 }
34712 function stripActiveViewOverrides(view, activeViewOverrides, defaultView) {
34713 if (!activeViewOverrides) {
34714 return view;
34715 }
34716 let result = view;
34717 for (const key of SCALAR_VALUES) {
34718 if (key in activeViewOverrides) {
34719 const { [key]: _, ...rest } = result;
34720 result = rest;
34721 }
34722 }
34723 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
34724 const activeFields = new Set(
34725 activeViewOverrides.filters.map((f2) => f2.field)
34726 );
34727 result = {
34728 ...result,
34729 filters: (view.filters ?? []).filter(
34730 (f2) => !activeFields.has(f2.field)
34731 )
34732 };
34733 }
34734 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
34735 result = {
34736 ...result,
34737 sort: defaultView?.sort
34738 };
34739 }
34740 if (activeViewOverrides.layout && "layout" in result && result.layout) {
34741 const layout = { ...result.layout };
34742 for (const key of Object.keys(activeViewOverrides.layout)) {
34743 delete layout[key];
34744 }
34745 result = {
34746 ...result,
34747 layout: Object.keys(layout).length > 0 ? layout : void 0
34748 };
34749 }
34750 if (activeViewOverrides.groupBy && "groupBy" in result) {
34751 const { groupBy: _, ...rest } = result;
34752 result = rest;
34753 }
34754 return result;
34755 }
34756
34757 // packages/views/build-module/use-view.mjs
34758 function omit3(obj, keys) {
34759 const result = { ...obj };
34760 for (const key of keys) {
34761 delete result[key];
34762 }
34763 return result;
34764 }
34765 function useView(config) {
34766 const {
34767 kind,
34768 name,
34769 slug,
34770 defaultView,
34771 activeViewOverrides,
34772 queryParams,
34773 onChangeQueryParams
34774 } = config;
34775 const preferenceKey = generatePreferenceKey(kind, name, slug);
34776 const persistedView = (0, import_data6.useSelect)(
34777 (select2) => {
34778 return select2(import_preferences.store).get(
34779 "core/views",
34780 preferenceKey
34781 );
34782 },
34783 [preferenceKey]
34784 );
34785 const { set: set3 } = (0, import_data6.useDispatch)(import_preferences.store);
34786 const baseView = (0, import_element125.useMemo)(
34787 () => persistedView ?? defaultView ?? {},
34788 [persistedView, defaultView]
34789 );
34790 const page = Number(queryParams?.page ?? baseView.page ?? 1);
34791 const search = queryParams?.search ?? baseView.search ?? "";
34792 const combinedOverrides = (0, import_element125.useMemo)(() => {
34793 const rawDefaults = config.defaultLayouts?.[baseView.type];
34794 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
34795 return { ...layoutTypeDefaults, ...activeViewOverrides };
34796 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
34797 const view = (0, import_element125.useMemo)(() => {
34798 return mergeActiveViewOverrides(
34799 {
34800 ...baseView,
34801 page,
34802 search
34803 },
34804 combinedOverrides,
34805 defaultView
34806 );
34807 }, [baseView, page, search, combinedOverrides, defaultView]);
34808 const isModified = !!persistedView;
34809 const updateView = (0, import_element125.useCallback)(
34810 (newView) => {
34811 const urlParams = {
34812 page: newView?.page,
34813 search: newView?.search
34814 };
34815 const preferenceView = stripActiveViewOverrides(
34816 omit3(newView, ["page", "search"]),
34817 combinedOverrides,
34818 defaultView
34819 );
34820 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
34821 onChangeQueryParams(urlParams);
34822 }
34823 const comparableBaseView = stripActiveViewOverrides(
34824 baseView,
34825 combinedOverrides,
34826 defaultView
34827 );
34828 const comparableDefaultView = stripActiveViewOverrides(
34829 defaultView,
34830 combinedOverrides,
34831 defaultView
34832 );
34833 if (!dequal(comparableBaseView, preferenceView)) {
34834 if (dequal(preferenceView, comparableDefaultView)) {
34835 set3("core/views", preferenceKey, void 0);
34836 } else {
34837 set3("core/views", preferenceKey, preferenceView);
34838 }
34839 }
34840 },
34841 [
34842 onChangeQueryParams,
34843 page,
34844 search,
34845 baseView,
34846 defaultView,
34847 combinedOverrides,
34848 set3,
34849 preferenceKey
34850 ]
34851 );
34852 const resetToDefault = (0, import_element125.useCallback)(() => {
34853 set3("core/views", preferenceKey, void 0);
34854 }, [preferenceKey, set3]);
34855 return {
34856 view,
34857 isModified,
34858 updateView,
34859 resetToDefault
34860 };
34861 }
34862
34863 // packages/views/build-module/load-view.mjs
34864 var import_data7 = __toESM(require_data(), 1);
34865 var import_preferences2 = __toESM(require_preferences(), 1);
34866
34867 // packages/views/build-module/use-view-config.mjs
34868 var import_data8 = __toESM(require_data(), 1);
34869 var import_core_data = __toESM(require_core_data(), 1);
34870
34871 // packages/views/build-module/lock-unlock.mjs
34872 var import_private_apis4 = __toESM(require_private_apis(), 1);
34873 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
34874 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
34875 "@wordpress/views"
34876 );
34877
34878 // packages/content-types/build-module/post-types/actions/activate.mjs
34879 var import_i18n54 = __toESM(require_i18n(), 1);
34880
34881 // packages/content-types/build-module/utils/actions.mjs
34882 var import_core_data2 = __toESM(require_core_data(), 1);
34883 var import_notices = __toESM(require_notices(), 1);
34884 function createStatusAction(config) {
34885 const isEligible = (item) => item.status !== config.targetStatus;
34886 return {
34887 id: config.id,
34888 label: config.label,
34889 supportsBulk: true,
34890 isEligible,
34891 async callback(items, { registry }) {
34892 const itemsToUpdate = items.filter(isEligible);
34893 if (itemsToUpdate.length === 0) {
34894 return;
34895 }
34896 const { saveEntityRecord } = registry.dispatch(import_core_data2.store);
34897 const { createSuccessNotice, createErrorNotice } = registry.dispatch(import_notices.store);
34898 const promiseResult = await Promise.allSettled(
34899 itemsToUpdate.map(
34900 (item) => saveEntityRecord(
34901 "postType",
34902 config.entity,
34903 { id: item.id, status: config.targetStatus },
34904 { throwOnError: true }
34905 )
34906 )
34907 );
34908 if (promiseResult.every(({ status }) => status === "fulfilled")) {
34909 createSuccessNotice(
34910 itemsToUpdate.length === 1 ? config.messages.successSingle : config.messages.successMany(itemsToUpdate.length),
34911 { type: "snackbar" }
34912 );
34913 return;
34914 }
34915 let errorMessage;
34916 if (promiseResult.length === 1) {
34917 const typedError = promiseResult[0];
34918 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
34919 errorMessage = typedError.reason.message;
34920 } else {
34921 errorMessage = config.messages.failSingle;
34922 }
34923 } else {
34924 const errorMessages = /* @__PURE__ */ new Set();
34925 const failedPromises = promiseResult.filter(
34926 ({ status }) => status === "rejected"
34927 );
34928 for (const failedPromise of failedPromises) {
34929 const typedError = failedPromise;
34930 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
34931 errorMessages.add(typedError.reason.message);
34932 }
34933 }
34934 if (errorMessages.size === 0) {
34935 errorMessage = config.messages.failMany;
34936 } else if (errorMessages.size === 1) {
34937 errorMessage = config.messages.errorSingle(
34938 [...errorMessages][0]
34939 );
34940 } else {
34941 errorMessage = config.messages.errorMany(
34942 [...errorMessages].join(",")
34943 );
34944 }
34945 }
34946 createErrorNotice(errorMessage, { type: "snackbar" });
34947 }
34948 };
34949 }
34950
34951 // packages/content-types/build-module/constants.mjs
34952 var POST_TYPES_PATH = "/post-types";
34953 var TAXONOMIES_PATH = "/taxonomies";
34954 var POST_TYPE_ENTITY = "wp_user_post_type";
34955 var TAXONOMY_ENTITY = "wp_user_taxonomy";
34956 var NEW_ID = "new";
34957
34958 // packages/content-types/build-module/post-types/actions/activate.mjs
34959 var activateAction = createStatusAction({
34960 id: "activate",
34961 label: (0, import_i18n54.__)("Activate"),
34962 entity: POST_TYPE_ENTITY,
34963 targetStatus: "publish",
34964 messages: {
34965 successSingle: (0, import_i18n54.__)("Post type activated."),
34966 successMany: (count) => (0, import_i18n54.sprintf)(
34967 /* translators: %d: The number of post types. */
34968 (0, import_i18n54._n)(
34969 "%d post type activated.",
34970 "%d post types activated.",
34971 count
34972 ),
34973 count
34974 ),
34975 failSingle: (0, import_i18n54.__)("Failed to activate post type."),
34976 failMany: (0, import_i18n54.__)("Failed to activate post types."),
34977 errorSingle: (message2) => (0, import_i18n54.sprintf)(
34978 /* translators: %s: an error message */
34979 (0, import_i18n54.__)("An error occurred while activating the post type: %s"),
34980 message2
34981 ),
34982 errorMany: (messages) => (0, import_i18n54.sprintf)(
34983 /* translators: %s: a list of comma separated error messages */
34984 (0, import_i18n54.__)(
34985 "Some errors occurred while activating the post types: %s"
34986 ),
34987 messages
34988 )
34989 }
34990 });
34991 var activate_default = activateAction;
34992
34993 // packages/content-types/build-module/post-types/actions/deactivate.mjs
34994 var import_i18n55 = __toESM(require_i18n(), 1);
34995 var deactivateAction = createStatusAction({
34996 id: "deactivate",
34997 label: (0, import_i18n55.__)("Deactivate"),
34998 entity: POST_TYPE_ENTITY,
34999 targetStatus: "draft",
35000 messages: {
35001 successSingle: (0, import_i18n55.__)("Post type deactivated."),
35002 successMany: (count) => (0, import_i18n55.sprintf)(
35003 /* translators: %d: The number of post types. */
35004 (0, import_i18n55._n)(
35005 "%d post type deactivated.",
35006 "%d post types deactivated.",
35007 count
35008 ),
35009 count
35010 ),
35011 failSingle: (0, import_i18n55.__)("Failed to deactivate post type."),
35012 failMany: (0, import_i18n55.__)("Failed to deactivate post types."),
35013 errorSingle: (message2) => (0, import_i18n55.sprintf)(
35014 /* translators: %s: an error message */
35015 (0, import_i18n55.__)("An error occurred while deactivating the post type: %s"),
35016 message2
35017 ),
35018 errorMany: (messages) => (0, import_i18n55.sprintf)(
35019 /* translators: %s: a list of comma separated error messages */
35020 (0, import_i18n55.__)(
35021 "Some errors occurred while deactivating the post types: %s"
35022 ),
35023 messages
35024 )
35025 }
35026 });
35027 var deactivate_default = deactivateAction;
35028
35029 // packages/content-types/build-module/post-types/actions/delete.mjs
35030 var import_components53 = __toESM(require_components(), 1);
35031 var import_core_data4 = __toESM(require_core_data(), 1);
35032 var import_data10 = __toESM(require_data(), 1);
35033 var import_element127 = __toESM(require_element(), 1);
35034 var import_i18n56 = __toESM(require_i18n(), 1);
35035 var import_notices2 = __toESM(require_notices(), 1);
35036
35037 // packages/content-types/build-module/utils/use-maybe-invalidate-content-type-cache.mjs
35038 var import_element126 = __toESM(require_element(), 1);
35039 var import_core_data3 = __toESM(require_core_data(), 1);
35040 var import_data9 = __toESM(require_data(), 1);
35041 var import_is_shallow_equal = __toESM(require_is_shallow_equal(), 1);
35042 function useMaybeInvalidateContentTypeCache() {
35043 const registry = (0, import_data9.useRegistry)();
35044 return (0, import_element126.useCallback)(
35045 (prev, next, entityName) => {
35046 if ((0, import_is_shallow_equal.isShallowEqual)([...prev].sort(), [...next].sort())) {
35047 return;
35048 }
35049 const resolvers = registry.select(import_core_data3.store).getCachedResolvers();
35050 const cache = resolvers.getEntityRecords;
35051 cache?.forEach((_value, args) => {
35052 if (args[0] === "postType" && args[1] === entityName) {
35053 registry.dispatch(import_core_data3.store).invalidateResolution("getEntityRecords", args);
35054 }
35055 });
35056 },
35057 [registry]
35058 );
35059 }
35060
35061 // packages/content-types/build-module/post-types/actions/delete.mjs
35062 var import_jsx_runtime175 = __toESM(require_jsx_runtime(), 1);
35063 function DeletePostTypeModal({
35064 items,
35065 closeModal,
35066 onActionPerformed
35067 }) {
35068 const [isDeleting, setIsDeleting] = (0, import_element127.useState)(false);
35069 const { deleteEntityRecord } = (0, import_data10.useDispatch)(import_core_data4.store);
35070 const { createSuccessNotice, createErrorNotice } = (0, import_data10.useDispatch)(import_notices2.store);
35071 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
35072 async function onDelete() {
35073 if (isDeleting) {
35074 return;
35075 }
35076 setIsDeleting(true);
35077 const itemsToDelete = items.filter((item) => item.id !== void 0);
35078 const promiseResult = await Promise.allSettled(
35079 itemsToDelete.map(
35080 (item) => deleteEntityRecord(
35081 "postType",
35082 POST_TYPE_ENTITY,
35083 item.id,
35084 { force: true },
35085 { throwOnError: true }
35086 )
35087 )
35088 );
35089 if (promiseResult.every(({ status }) => status === "fulfilled")) {
35090 createSuccessNotice(
35091 itemsToDelete.length === 1 ? (0, import_i18n56.sprintf)(
35092 /* translators: %s: The post type's plural label. */
35093 (0, import_i18n56.__)('"%s" post type deleted.'),
35094 itemsToDelete[0].title.raw
35095 ) : (0, import_i18n56.sprintf)(
35096 /* translators: %d: The number of post types. */
35097 (0, import_i18n56._n)(
35098 "%d post type deleted.",
35099 "%d post types deleted.",
35100 itemsToDelete.length
35101 ),
35102 itemsToDelete.length
35103 ),
35104 { type: "snackbar" }
35105 );
35106 } else {
35107 let errorMessage;
35108 if (promiseResult.length === 1) {
35109 const typedError = promiseResult[0];
35110 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
35111 errorMessage = typedError.reason.message;
35112 } else {
35113 errorMessage = (0, import_i18n56.__)("Failed to delete post type.");
35114 }
35115 } else {
35116 const errorMessages = /* @__PURE__ */ new Set();
35117 const failedPromises = promiseResult.filter(
35118 ({ status }) => status === "rejected"
35119 );
35120 for (const failedPromise of failedPromises) {
35121 const typedError = failedPromise;
35122 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
35123 errorMessages.add(typedError.reason.message);
35124 }
35125 }
35126 if (errorMessages.size === 0) {
35127 errorMessage = (0, import_i18n56.__)("Failed to delete post types.");
35128 } else if (errorMessages.size === 1) {
35129 errorMessage = (0, import_i18n56.sprintf)(
35130 /* translators: %s: an error message */
35131 (0, import_i18n56.__)(
35132 "An error occurred while deleting the post type: %s"
35133 ),
35134 [...errorMessages][0]
35135 );
35136 } else {
35137 errorMessage = (0, import_i18n56.sprintf)(
35138 /* translators: %s: a list of comma separated error messages */
35139 (0, import_i18n56.__)(
35140 "Some errors occurred while deleting the post types: %s"
35141 ),
35142 [...errorMessages].join(",")
35143 );
35144 }
35145 }
35146 createErrorNotice(errorMessage, { type: "snackbar" });
35147 }
35148 const deletedRefs = itemsToDelete.filter((_, i2) => promiseResult[i2].status === "fulfilled").flatMap((item) => item.config.taxonomies);
35149 maybeInvalidateCache(deletedRefs, [], TAXONOMY_ENTITY);
35150 onActionPerformed?.(itemsToDelete);
35151 setIsDeleting(false);
35152 closeModal?.();
35153 }
35154 return /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)(Stack, { direction: "column", gap: "md", children: [
35155 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(Text, { children: items.length > 1 ? (0, import_i18n56.sprintf)(
35156 /* translators: %d: number of post types to delete. */
35157 (0, import_i18n56._n)(
35158 "Are you sure you want to delete %d post type?",
35159 "Are you sure you want to delete %d post types?",
35160 items.length
35161 ),
35162 items.length
35163 ) : (0, import_i18n56.sprintf)(
35164 /* translators: %s: The post type's plural label. */
35165 (0, import_i18n56.__)('Are you sure you want to delete "%s"?'),
35166 items[0].title.raw
35167 ) }),
35168 /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [
35169 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(
35170 import_components53.Button,
35171 {
35172 __next40pxDefaultSize: true,
35173 variant: "tertiary",
35174 onClick: closeModal,
35175 disabled: isDeleting,
35176 accessibleWhenDisabled: true,
35177 children: (0, import_i18n56.__)("Cancel")
35178 }
35179 ),
35180 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(
35181 import_components53.Button,
35182 {
35183 __next40pxDefaultSize: true,
35184 variant: "primary",
35185 isDestructive: true,
35186 isBusy: isDeleting,
35187 disabled: isDeleting,
35188 accessibleWhenDisabled: true,
35189 onClick: onDelete,
35190 children: (0, import_i18n56._x)("Delete", "verb")
35191 }
35192 )
35193 ] })
35194 ] });
35195 }
35196 var deletePostTypeAction = {
35197 id: "delete-post-type",
35198 label: (0, import_i18n56._x)("Delete", "verb"),
35199 icon: trash_default,
35200 supportsBulk: true,
35201 hideModalHeader: true,
35202 modalFocusOnMount: "firstContentElement",
35203 modalSize: "small",
35204 RenderModal: DeletePostTypeModal
35205 };
35206 var delete_default = deletePostTypeAction;
35207
35208 // packages/content-types/build-module/post-types/actions/duplicate.mjs
35209 var import_components55 = __toESM(require_components(), 1);
35210 var import_core_data7 = __toESM(require_core_data(), 1);
35211 var import_data13 = __toESM(require_data(), 1);
35212 var import_element130 = __toESM(require_element(), 1);
35213 var import_i18n61 = __toESM(require_i18n(), 1);
35214 var import_notices3 = __toESM(require_notices(), 1);
35215
35216 // packages/content-types/build-module/post-types/fields/general.mjs
35217 var import_core_data6 = __toESM(require_core_data(), 1);
35218 var import_data12 = __toESM(require_data(), 1);
35219 var import_element129 = __toESM(require_element(), 1);
35220 var import_i18n60 = __toESM(require_i18n(), 1);
35221 var import_url4 = __toESM(require_url(), 1);
35222
35223 // packages/content-types/build-module/utils/fields.mjs
35224 var import_components54 = __toESM(require_components(), 1);
35225 var import_i18n57 = __toESM(require_i18n(), 1);
35226 var import_url3 = __toESM(require_url(), 1);
35227 var import_jsx_runtime176 = __toESM(require_jsx_runtime(), 1);
35228 var { ValidatedInputControl: ValidatedInputControl4, ValidatedToggleControl: ValidatedToggleControl2 } = unlock2(
35229 import_components54.privateApis
35230 );
35231 function getCustomValidity2(validity) {
35232 if (validity?.required?.message) {
35233 return validity.required;
35234 }
35235 if (validity?.pattern) {
35236 return validity.pattern;
35237 }
35238 if (validity?.maxLength) {
35239 return validity.maxLength;
35240 }
35241 return validity?.custom;
35242 }
35243 function createBooleanField(id, label, options) {
35244 const field = {
35245 id,
35246 label,
35247 type: "boolean",
35248 description: options.description,
35249 Edit: "toggle",
35250 getValue: ({ item }) => item.config[id],
35251 setValue: ({ item, value }) => ({
35252 config: { ...item.config, [id]: !!value }
35253 }),
35254 filterBy: false,
35255 enableSorting: false
35256 };
35257 if (options.isVisible) {
35258 field.isVisible = options.isVisible;
35259 }
35260 return field;
35261 }
35262 function createLabelField(id, label, options = {}) {
35263 const field = {
35264 id,
35265 label,
35266 type: "text",
35267 placeholder: options.placeholder,
35268 description: options.description,
35269 getValue: ({ item }) => item.config.labels[id] ?? "",
35270 setValue: ({ item, value }) => ({
35271 config: {
35272 ...item.config,
35273 labels: {
35274 ...item.config.labels,
35275 [id]: String(value ?? "")
35276 }
35277 }
35278 }),
35279 isValid: {
35280 ...options.required ? { required: true } : {},
35281 // Mirrors the server REST schema: 200 chars for labels.
35282 maxLength: 200
35283 },
35284 enableSorting: false
35285 };
35286 if (options.isVisible) {
35287 field.isVisible = options.isVisible;
35288 }
35289 return field;
35290 }
35291 var titleField = {
35292 id: "title",
35293 label: (0, import_i18n57.__)("Title"),
35294 type: "text",
35295 enableGlobalSearch: true,
35296 getValue: ({ item }) => item.title.raw,
35297 setValue: ({ value }) => ({
35298 title: { raw: String(value ?? "") }
35299 }),
35300 isValid: {
35301 required: true,
35302 // Title is stored as the plural label — mirrors the server REST schema (200 chars).
35303 maxLength: 200
35304 },
35305 filterBy: false,
35306 enableHiding: false
35307 };
35308 var pluralLabelField = {
35309 id: "plural_name",
35310 label: (0, import_i18n57.__)("Plural label"),
35311 type: "text",
35312 getValue: ({ item }) => item.title.raw,
35313 setValue: ({ value }) => ({
35314 title: { raw: String(value ?? "") }
35315 }),
35316 isValid: {
35317 required: true,
35318 maxLength: 200
35319 }
35320 };
35321 var singularLabelField = createLabelField(
35322 "singular_name",
35323 (0, import_i18n57.__)("Singular label"),
35324 { required: true }
35325 );
35326 function createDescriptionField(description) {
35327 return {
35328 id: "description",
35329 label: (0, import_i18n57.__)("Description"),
35330 type: "text",
35331 Edit: { control: "textarea", rows: 3 },
35332 description,
35333 getValue: ({ item }) => item.config.description,
35334 setValue: ({ item, value }) => ({
35335 config: { ...item.config, description: String(value ?? "") }
35336 }),
35337 // Mirrors the server REST schema (1000 chars for description).
35338 isValid: { maxLength: 1e3 },
35339 enableSorting: false
35340 };
35341 }
35342 var statusField = {
35343 id: "status",
35344 label: (0, import_i18n57.__)("Status"),
35345 description: (0, import_i18n57.__)("Enabled and registered with WordPress when active."),
35346 // The field keeps `label: 'Status'` so the filter chip and column header
35347 // read naturally ("Status: Active"); the form toggle uses its own "Active"
35348 // label — the on/off semantic is clearer next to a switch.
35349 Edit: ({
35350 data,
35351 field,
35352 onChange,
35353 hideLabelFromVision,
35354 markWhenOptional,
35355 validity
35356 }) => {
35357 const isActive = field.getValue({ item: data }) === "publish";
35358 return /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
35359 ValidatedToggleControl2,
35360 {
35361 label: (0, import_i18n57.__)("Active"),
35362 hidden: hideLabelFromVision,
35363 help: field.description,
35364 markWhenOptional,
35365 customValidity: getCustomValidity2(validity),
35366 checked: isActive,
35367 onChange: (next) => onChange(
35368 field.setValue({
35369 item: data,
35370 value: next ? "publish" : "draft"
35371 })
35372 )
35373 }
35374 );
35375 },
35376 elements: [
35377 { value: "publish", label: (0, import_i18n57.__)("Active") },
35378 { value: "draft", label: (0, import_i18n57.__)("Inactive") }
35379 ],
35380 render: ({ item }) => {
35381 const isActive = item.status === "publish";
35382 return /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(Badge, { intent: isActive ? "stable" : "draft", children: isActive ? (0, import_i18n57.__)("Active") : (0, import_i18n57.__)("Inactive") });
35383 },
35384 enableSorting: false
35385 };
35386 function SlugEdit({
35387 data,
35388 field,
35389 onChange,
35390 hideLabelFromVision,
35391 markWhenOptional,
35392 validity
35393 }) {
35394 const { label, description, getValue, setValue } = field;
35395 const isValid2 = field.isValid;
35396 const value = getValue({ item: data }) ?? "";
35397 const handleChange = (newValue) => onChange(setValue({ item: data, value: newValue }));
35398 const onFocus = () => {
35399 if (data.id !== void 0 || data.slug) {
35400 return;
35401 }
35402 const singular = data.config.labels.singular_name?.trim();
35403 if (!singular) {
35404 return;
35405 }
35406 const cleaned = (0, import_url3.cleanForSlug)(singular);
35407 if (/[^a-z0-9_-]/.test(cleaned)) {
35408 return;
35409 }
35410 const trimmed = cleaned.slice(0, isValid2.maxLength.constraint).replace(/-+$/, "");
35411 if (trimmed) {
35412 handleChange(trimmed);
35413 }
35414 };
35415 return /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
35416 ValidatedInputControl4,
35417 {
35418 __next40pxDefaultSize: true,
35419 required: !!isValid2.required,
35420 markWhenOptional,
35421 customValidity: getCustomValidity2(validity),
35422 label,
35423 value,
35424 help: description,
35425 onChange: handleChange,
35426 onFocus,
35427 hideLabelFromVision,
35428 pattern: isValid2.pattern?.constraint,
35429 maxLength: isValid2.maxLength.constraint
35430 }
35431 );
35432 }
35433
35434 // packages/content-types/build-module/utils/overflowing-badges.mjs
35435 var import_i18n58 = __toESM(require_i18n(), 1);
35436 var import_jsx_runtime177 = __toESM(require_jsx_runtime(), 1);
35437 var DEFAULT_MAX = 3;
35438 function OverflowingBadges({
35439 items,
35440 max: max2 = DEFAULT_MAX
35441 }) {
35442 const visible = items.slice(0, max2);
35443 const hidden = items.slice(max2);
35444 const moreLabel = (0, import_i18n58.sprintf)(
35445 /* translators: %d: number of additional items */
35446 (0, import_i18n58._n)("Show %d more", "Show %d more", hidden.length),
35447 hidden.length
35448 );
35449 const popoverTitle = (0, import_i18n58.sprintf)(
35450 /* translators: %d: number of additional items */
35451 (0, import_i18n58._n)("%d more item", "%d more items", hidden.length),
35452 hidden.length
35453 );
35454 return /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)(
35455 Stack,
35456 {
35457 direction: "row",
35458 wrap: "wrap",
35459 gap: "xs",
35460 align: "center",
35461 render: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)("span", {}),
35462 children: [
35463 visible.map((item) => /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Badge, { children: item.label }, item.key)),
35464 hidden.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(tooltip_exports.Provider, { delay: 0, children: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(tooltip_exports.Root, { children: /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)(popover_exports.Root, { children: [
35465 /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
35466 tooltip_exports.Trigger,
35467 {
35468 render: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
35469 popover_exports.Trigger,
35470 {
35471 render: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
35472 Button4,
35473 {
35474 variant: "outline",
35475 tone: "neutral",
35476 size: "small",
35477 "aria-label": moreLabel,
35478 style: {
35479 minWidth: "auto",
35480 borderRadius: "var(--wpds-border-radius-lg, 8px)",
35481 fontWeight: "normal"
35482 },
35483 children: (0, import_i18n58.sprintf)(
35484 /* translators: %d: number of additional items */
35485 (0, import_i18n58.__)("+%d"),
35486 hidden.length
35487 )
35488 }
35489 )
35490 }
35491 )
35492 }
35493 ),
35494 /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)(popover_exports.Popup, { style: { maxWidth: 320 }, children: [
35495 /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(popover_exports.Title, {}), children: popoverTitle }),
35496 /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Stack, { direction: "row", wrap: "wrap", gap: "xs", children: hidden.map((item) => /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(Badge, { children: item.label }, item.key)) })
35497 ] }),
35498 /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(tooltip_exports.Popup, { children: moreLabel })
35499 ] }) }) })
35500 ]
35501 }
35502 );
35503 }
35504
35505 // packages/content-types/build-module/post-types/utils.mjs
35506 var import_core_data5 = __toESM(require_core_data(), 1);
35507 var import_data11 = __toESM(require_data(), 1);
35508 var import_element128 = __toESM(require_element(), 1);
35509 var import_i18n59 = __toESM(require_i18n(), 1);
35510
35511 // packages/content-types/build-module/utils/form-data.mjs
35512 function pickStoredLabels(source, keys) {
35513 const labels = {};
35514 for (const key of keys) {
35515 const value = source?.[key];
35516 if (typeof value === "string") {
35517 labels[key] = value;
35518 }
35519 }
35520 return labels;
35521 }
35522 function serializeLabels(source, keys) {
35523 const labels = {};
35524 for (const key of keys) {
35525 const value = source[key];
35526 if (typeof value === "string" && value.trim() !== "") {
35527 labels[key] = value.trim();
35528 }
35529 }
35530 labels.singular_name = source.singular_name;
35531 return labels;
35532 }
35533
35534 // packages/content-types/build-module/post-types/utils.mjs
35535 var DEFAULT_SUPPORTS = ["title", "editor"];
35536 var BLANK_RECORD = {
35537 slug: "",
35538 status: "publish",
35539 title: { raw: "" },
35540 config: {
35541 labels: { singular_name: "" },
35542 taxonomies: [],
35543 supports: [...DEFAULT_SUPPORTS],
35544 description: "",
35545 public: true,
35546 hierarchical: false,
35547 has_archive: false,
35548 show_in_rest: true
35549 }
35550 };
35551 var STRING_LABEL_KEYS = [
35552 "singular_name",
35553 "menu_name",
35554 "all_items",
35555 "add_new",
35556 "add_new_item",
35557 "edit_item",
35558 "new_item",
35559 "view_item",
35560 "view_items",
35561 "search_items",
35562 "not_found",
35563 "not_found_in_trash",
35564 "parent_item_colon",
35565 "archives",
35566 "attributes",
35567 "insert_into_item",
35568 "uploaded_to_this_item",
35569 "featured_image",
35570 "set_featured_image",
35571 "remove_featured_image",
35572 "use_featured_image",
35573 "filter_items_list",
35574 "items_list_navigation",
35575 "items_list"
35576 ];
35577 function deriveLabels(plural, singular) {
35578 const lcPlural = plural.toLowerCase();
35579 const lcSingular = singular.toLowerCase();
35580 return {
35581 menu_name: plural,
35582 all_items: (0, import_i18n59.sprintf)(
35583 /* translators: %s: Plural post type label. */
35584 (0, import_i18n59.__)("All %s"),
35585 plural
35586 ),
35587 add_new: (0, import_i18n59.__)("Add New"),
35588 add_new_item: (0, import_i18n59.sprintf)(
35589 /* translators: %s: Singular post type label. */
35590 (0, import_i18n59.__)("Add New %s"),
35591 singular
35592 ),
35593 edit_item: (0, import_i18n59.sprintf)(
35594 /* translators: %s: Singular post type label. */
35595 (0, import_i18n59.__)("Edit %s"),
35596 singular
35597 ),
35598 new_item: (0, import_i18n59.sprintf)(
35599 /* translators: %s: Singular post type label. */
35600 (0, import_i18n59.__)("New %s"),
35601 singular
35602 ),
35603 view_item: (0, import_i18n59.sprintf)(
35604 /* translators: %s: Singular post type label. */
35605 (0, import_i18n59.__)("View %s"),
35606 singular
35607 ),
35608 view_items: (0, import_i18n59.sprintf)(
35609 /* translators: %s: Plural post type label. */
35610 (0, import_i18n59.__)("View %s"),
35611 plural
35612 ),
35613 search_items: (0, import_i18n59.sprintf)(
35614 /* translators: %s: Plural post type label. */
35615 (0, import_i18n59.__)("Search %s"),
35616 plural
35617 ),
35618 not_found: (0, import_i18n59.sprintf)(
35619 /* translators: %s: Plural post type label, lowercase. */
35620 (0, import_i18n59.__)("No %s found."),
35621 lcPlural
35622 ),
35623 not_found_in_trash: (0, import_i18n59.sprintf)(
35624 /* translators: %s: Plural post type label, lowercase. */
35625 (0, import_i18n59.__)("No %s found in Trash."),
35626 lcPlural
35627 ),
35628 parent_item_colon: (0, import_i18n59.sprintf)(
35629 /* translators: %s: Singular post type label. */
35630 (0, import_i18n59.__)("Parent %s:"),
35631 singular
35632 ),
35633 archives: (0, import_i18n59.sprintf)(
35634 /* translators: %s: Singular post type label. */
35635 (0, import_i18n59.__)("%s Archives"),
35636 singular
35637 ),
35638 attributes: (0, import_i18n59.sprintf)(
35639 /* translators: %s: Singular post type label. */
35640 (0, import_i18n59.__)("%s Attributes"),
35641 singular
35642 ),
35643 insert_into_item: (0, import_i18n59.sprintf)(
35644 /* translators: %s: Singular post type label, lowercase. */
35645 (0, import_i18n59.__)("Insert into %s"),
35646 lcSingular
35647 ),
35648 uploaded_to_this_item: (0, import_i18n59.sprintf)(
35649 /* translators: %s: Singular post type label, lowercase. */
35650 (0, import_i18n59.__)("Uploaded to this %s"),
35651 lcSingular
35652 ),
35653 featured_image: (0, import_i18n59.__)("Featured image"),
35654 set_featured_image: (0, import_i18n59.__)("Set featured image"),
35655 remove_featured_image: (0, import_i18n59.__)("Remove featured image"),
35656 use_featured_image: (0, import_i18n59.__)("Use as featured image"),
35657 filter_items_list: (0, import_i18n59.sprintf)(
35658 /* translators: %s: Plural post type label, lowercase. */
35659 (0, import_i18n59.__)("Filter %s list"),
35660 lcPlural
35661 ),
35662 items_list_navigation: (0, import_i18n59.sprintf)(
35663 /* translators: %s: Plural post type label. */
35664 (0, import_i18n59.__)("%s list navigation"),
35665 plural
35666 ),
35667 items_list: (0, import_i18n59.sprintf)(
35668 /* translators: %s: Plural post type label. */
35669 (0, import_i18n59.__)("%s list"),
35670 plural
35671 )
35672 };
35673 }
35674 var SUPPORT_FEATURES = [
35675 "title",
35676 "editor",
35677 "thumbnail",
35678 "excerpt",
35679 "comments",
35680 "revisions",
35681 "author",
35682 "page-attributes",
35683 "custom-fields",
35684 "trackbacks",
35685 "post-formats"
35686 ];
35687 function toFormData(row) {
35688 const config = row.config ?? {};
35689 const labels = pickStoredLabels(
35690 config.labels,
35691 STRING_LABEL_KEYS
35692 );
35693 const supports = Array.isArray(config.supports) ? config.supports.filter(
35694 (s2) => SUPPORT_FEATURES.includes(s2)
35695 ) : [...DEFAULT_SUPPORTS];
35696 return {
35697 id: row.id,
35698 slug: row.slug,
35699 status: row.status,
35700 title: { raw: row.title.raw },
35701 config: {
35702 labels: { singular_name: "", ...labels },
35703 taxonomies: Array.isArray(config.taxonomies) ? config.taxonomies : [],
35704 supports,
35705 description: config.description ?? "",
35706 public: config.public ?? true,
35707 hierarchical: config.hierarchical ?? false,
35708 has_archive: config.has_archive ?? false,
35709 show_in_rest: config.show_in_rest ?? true
35710 },
35711 count: row.count
35712 };
35713 }
35714 function serializeForSave(data) {
35715 const { config } = data;
35716 const labels = serializeLabels(
35717 config.labels,
35718 STRING_LABEL_KEYS
35719 );
35720 const description = config.description.trim();
35721 return {
35722 ...data.id !== void 0 ? { id: data.id } : {},
35723 slug: data.slug,
35724 status: data.status,
35725 title: data.title.raw,
35726 config: {
35727 labels,
35728 taxonomies: config.taxonomies,
35729 supports: config.supports,
35730 public: config.public,
35731 hierarchical: config.hierarchical,
35732 has_archive: config.has_archive,
35733 show_in_rest: config.show_in_rest,
35734 ...description !== "" ? { description } : {}
35735 }
35736 };
35737 }
35738 var CORE_TAXONOMY_SLUGS = ["category", "post_tag"];
35739 function usePublicTaxonomies() {
35740 const taxonomies = (0, import_data11.useSelect)(
35741 (select2) => select2(import_core_data5.store).getTaxonomies({ per_page: -1 }),
35742 []
35743 );
35744 return (0, import_element128.useMemo)(() => {
35745 return taxonomies?.filter((t2) => !!t2.visibility?.public).sort((a2, b2) => {
35746 const aIsCore = CORE_TAXONOMY_SLUGS.includes(a2.slug);
35747 const bIsCore = CORE_TAXONOMY_SLUGS.includes(b2.slug);
35748 if (aIsCore !== bIsCore) {
35749 return aIsCore ? -1 : 1;
35750 }
35751 return a2.name.localeCompare(b2.name);
35752 });
35753 }, [taxonomies]);
35754 }
35755
35756 // packages/content-types/build-module/post-types/fields/general.mjs
35757 var import_jsx_runtime178 = __toESM(require_jsx_runtime(), 1);
35758 var SUPPORT_LABELS = {
35759 title: (0, import_i18n60.__)("Title"),
35760 editor: (0, import_i18n60.__)("Editor"),
35761 thumbnail: (0, import_i18n60.__)("Featured image"),
35762 excerpt: (0, import_i18n60.__)("Excerpt"),
35763 comments: (0, import_i18n60.__)("Comments"),
35764 revisions: (0, import_i18n60.__)("Revisions"),
35765 author: (0, import_i18n60.__)("Author"),
35766 "page-attributes": (0, import_i18n60.__)("Page attributes"),
35767 "custom-fields": (0, import_i18n60.__)("Custom fields"),
35768 trackbacks: (0, import_i18n60.__)("Trackbacks"),
35769 "post-formats": (0, import_i18n60.__)("Post formats")
35770 };
35771 var descriptionField = createDescriptionField(
35772 (0, import_i18n60.__)(
35773 "Optional summary of the post type. Shown in admin UIs that surface post type details."
35774 )
35775 );
35776 var publicField = createBooleanField("public", (0, import_i18n60.__)("Public"), {
35777 description: (0, import_i18n60.__)(
35778 "Whether the post type is intended for use publicly either via the admin interface or by front-end users."
35779 )
35780 });
35781 var hierarchicalField = createBooleanField(
35782 "hierarchical",
35783 (0, import_i18n60.__)("Hierarchical"),
35784 {
35785 description: (0, import_i18n60.__)(
35786 "When on, posts of this type can have parent-child relationships like pages, and the parent picker is shown in the editor. When off, they behave like posts."
35787 )
35788 }
35789 );
35790 var hasArchiveField = createBooleanField(
35791 "has_archive",
35792 (0, import_i18n60.__)("Has archive"),
35793 {
35794 description: (0, import_i18n60.__)(
35795 "Whether the post type has an archive page (e.g. /book/). Requires permalink rewrite rules to be flushed after enabling."
35796 )
35797 }
35798 );
35799 var showInRestField = createBooleanField(
35800 "show_in_rest",
35801 (0, import_i18n60.__)("Show in REST API"),
35802 {
35803 description: (0, import_i18n60.__)(
35804 "Required for the block editor. Disable only if posts of this type should not be available via the REST API."
35805 )
35806 }
35807 );
35808 var countField = {
35809 id: "count",
35810 label: (0, import_i18n60.__)("Posts"),
35811 type: "integer",
35812 readOnly: true,
35813 render: ({ item }) => {
35814 const count = item.count;
35815 if (item.status !== "publish" || !count) {
35816 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)("span", { "aria-hidden": "true", children: "\u2014" });
35817 }
35818 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
35819 Link,
35820 {
35821 href: (0, import_url4.addQueryArgs)("edit.php", {
35822 post_type: item.slug
35823 }),
35824 children: count
35825 }
35826 );
35827 },
35828 enableSorting: false,
35829 filterBy: false
35830 };
35831 var supportsField = {
35832 id: "supports",
35833 label: (0, import_i18n60.__)("Supports"),
35834 type: "array",
35835 description: (0, import_i18n60.__)(
35836 "Editor features and metadata enabled for posts of this type."
35837 ),
35838 elements: SUPPORT_FEATURES.map((feature) => ({
35839 value: feature,
35840 label: SUPPORT_LABELS[feature]
35841 })),
35842 enableSorting: false,
35843 getValue: ({ item }) => item.config.supports,
35844 setValue: ({ item, value }) => ({
35845 config: {
35846 ...item.config,
35847 supports: Array.isArray(value) ? value.filter(
35848 (v2) => SUPPORT_FEATURES.includes(v2)
35849 ) : []
35850 }
35851 }),
35852 render: ({ item }) => {
35853 const features = item.config.supports;
35854 if (!features || features.length === 0) {
35855 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)("span", { "aria-hidden": "true", children: "\u2014" });
35856 }
35857 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
35858 OverflowingBadges,
35859 {
35860 items: features.map((f2) => ({
35861 key: f2,
35862 label: SUPPORT_LABELS[f2] ?? f2
35863 }))
35864 }
35865 );
35866 },
35867 filterBy: false
35868 };
35869 var SLUG_MAX_LENGTH = 20;
35870 function useSlugField(originalSlug, currentValue) {
35871 const registeredPostTypes = (0, import_data12.useSelect)(
35872 (select2) => select2(import_core_data6.store).getPostTypes(),
35873 []
35874 );
35875 const showRenameWarning = originalSlug !== void 0 && currentValue !== originalSlug;
35876 return (0, import_element129.useMemo)(
35877 () => ({
35878 id: "slug",
35879 label: (0, import_i18n60.__)("Post type key"),
35880 type: "text",
35881 enableGlobalSearch: true,
35882 description: /* @__PURE__ */ (0, import_jsx_runtime178.jsxs)(Stack, { direction: "column", gap: "sm", render: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)("span", {}), children: [
35883 showRenameWarning && /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(notice_exports.Root, { intent: "warning", render: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)("span", {}), children: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(notice_exports.Description, { children: (0, import_i18n60.__)(
35884 "Changing the key renames the post type \u2014 existing posts may become inaccessible until a migration updates the database."
35885 ) }) }),
35886 /* @__PURE__ */ (0, import_jsx_runtime178.jsx)("span", { children: (0, import_i18n60.__)(
35887 "Lower case letters, numbers, underscores, and dashes only. Maximum length: 20 characters."
35888 ) })
35889 ] }),
35890 isValid: {
35891 required: true,
35892 pattern: "^[a-z0-9_\\-]+$",
35893 maxLength: SLUG_MAX_LENGTH,
35894 custom: async (value) => {
35895 const slug = value.slug;
35896 if (originalSlug !== void 0 && slug === originalSlug) {
35897 return null;
35898 }
35899 const slugTaken = (registeredPostTypes ?? []).some(
35900 (pt) => pt.slug === slug
35901 );
35902 if (slugTaken) {
35903 return (0, import_i18n60.__)("This post type key is already in use.");
35904 }
35905 const drafts = await (0, import_data12.resolveSelect)(
35906 import_core_data6.store
35907 ).getEntityRecords("postType", POST_TYPE_ENTITY, {
35908 slug,
35909 status: "draft",
35910 _fields: "id,name",
35911 per_page: 1
35912 });
35913 return drafts?.length ? (0, import_i18n60.__)("This post type key is already in use.") : null;
35914 }
35915 },
35916 Edit: SlugEdit,
35917 filterBy: false,
35918 enableSorting: false
35919 }),
35920 [registeredPostTypes, originalSlug, showRenameWarning]
35921 );
35922 }
35923 function useTaxonomiesField() {
35924 const publicTaxonomies = usePublicTaxonomies();
35925 return (0, import_element129.useMemo)(() => {
35926 const elements = (publicTaxonomies ?? []).map((tax) => ({
35927 value: tax.slug,
35928 label: tax.name
35929 }));
35930 const labelMap = Object.fromEntries(
35931 elements.map((e2) => [e2.value, e2.label])
35932 );
35933 return {
35934 id: "taxonomies",
35935 label: (0, import_i18n60.__)("Taxonomies"),
35936 type: "array",
35937 description: (0, import_i18n60.__)(
35938 "One or more taxonomies that should be associated with this post type."
35939 ),
35940 elements,
35941 enableSorting: false,
35942 getValue: ({ item }) => item.config.taxonomies,
35943 setValue: ({ item, value }) => ({
35944 config: {
35945 ...item.config,
35946 taxonomies: Array.isArray(value) ? value : []
35947 }
35948 }),
35949 render: ({ item }) => {
35950 const slugs = item.config.taxonomies;
35951 if (!slugs || slugs.length === 0) {
35952 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)("span", { "aria-hidden": "true", children: "\u2014" });
35953 }
35954 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
35955 OverflowingBadges,
35956 {
35957 items: slugs.map((s2) => ({
35958 key: s2,
35959 label: labelMap[s2] ?? s2
35960 }))
35961 }
35962 );
35963 },
35964 filterBy: false
35965 };
35966 }, [publicTaxonomies]);
35967 }
35968 var defaultForm = {
35969 layout: { type: "regular" },
35970 fields: [
35971 "plural_name",
35972 "singular_name",
35973 "slug",
35974 "taxonomies",
35975 "public",
35976 "hierarchical",
35977 "has_archive",
35978 "status"
35979 ]
35980 };
35981 var generalForm = {
35982 layout: { type: "regular" },
35983 fields: [
35984 "plural_name",
35985 "singular_name",
35986 "slug",
35987 "description",
35988 "taxonomies",
35989 "supports",
35990 "public",
35991 "hierarchical",
35992 "has_archive",
35993 "show_in_rest",
35994 "status"
35995 ]
35996 };
35997
35998 // packages/content-types/build-module/post-types/actions/duplicate.mjs
35999 var import_jsx_runtime179 = __toESM(require_jsx_runtime(), 1);
36000 var SLUG_MAX_LENGTH2 = 20;
36001 var duplicateForm = {
36002 layout: { type: "regular" },
36003 fields: ["plural_name", "singular_name", "slug"]
36004 };
36005 function buildCopySlug(slug) {
36006 const match2 = slug.match(/^(.*?)(\d+)$/);
36007 const base = match2 ? match2[1] : slug;
36008 const nextNumber = String(match2 ? parseInt(match2[2], 10) + 1 : 2);
36009 return `${base.slice(
36010 0,
36011 SLUG_MAX_LENGTH2 - nextNumber.length
36012 )}${nextNumber}`;
36013 }
36014 function DuplicatePostTypeModal({
36015 items,
36016 closeModal,
36017 onActionPerformed
36018 }) {
36019 const source = items[0];
36020 const [data, setData] = (0, import_element130.useState)(() => ({
36021 ...source,
36022 id: void 0,
36023 status: "draft",
36024 title: {
36025 raw: (0, import_i18n61.sprintf)(
36026 /* translators: %s: existing post type title. */
36027 (0, import_i18n61._x)("%s (Copy)", "post type"),
36028 source.title.raw
36029 )
36030 },
36031 slug: buildCopySlug(source.slug)
36032 }));
36033 const [isDuplicating, setIsDuplicating] = (0, import_element130.useState)(false);
36034 const slugField = useSlugField(void 0, data.slug);
36035 const fields = (0, import_element130.useMemo)(
36036 () => [
36037 pluralLabelField,
36038 singularLabelField,
36039 slugField
36040 ],
36041 [slugField]
36042 );
36043 const { validity, isValid: isValid2 } = use_form_validity_default(
36044 data,
36045 fields,
36046 duplicateForm
36047 );
36048 const { saveEntityRecord } = (0, import_data13.useDispatch)(import_core_data7.store);
36049 const { createSuccessNotice, createErrorNotice } = (0, import_data13.useDispatch)(import_notices3.store);
36050 async function onDuplicate() {
36051 if (isDuplicating || !isValid2) {
36052 return;
36053 }
36054 setIsDuplicating(true);
36055 try {
36056 await saveEntityRecord(
36057 "postType",
36058 POST_TYPE_ENTITY,
36059 serializeForSave(data),
36060 { throwOnError: true }
36061 );
36062 createSuccessNotice(
36063 (0, import_i18n61.sprintf)(
36064 /* translators: %s: post type plural label. */
36065 (0, import_i18n61.__)('"%s" post type created.'),
36066 data.title.raw
36067 ),
36068 { type: "snackbar" }
36069 );
36070 onActionPerformed?.(items);
36071 closeModal?.();
36072 } catch (error2) {
36073 const typedError = error2;
36074 createErrorNotice(
36075 typedError?.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n61.__)("Failed to duplicate post type."),
36076 { type: "snackbar" }
36077 );
36078 } finally {
36079 setIsDuplicating(false);
36080 }
36081 }
36082 return /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(Stack, { direction: "column", gap: "md", children: [
36083 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
36084 DataForm,
36085 {
36086 data,
36087 fields,
36088 form: duplicateForm,
36089 validity,
36090 onChange: (edits) => setData(
36091 (prev) => ({ ...prev, ...edits })
36092 )
36093 }
36094 ),
36095 /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [
36096 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
36097 import_components55.Button,
36098 {
36099 __next40pxDefaultSize: true,
36100 variant: "tertiary",
36101 onClick: closeModal,
36102 disabled: isDuplicating,
36103 accessibleWhenDisabled: true,
36104 children: (0, import_i18n61.__)("Cancel")
36105 }
36106 ),
36107 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
36108 import_components55.Button,
36109 {
36110 __next40pxDefaultSize: true,
36111 variant: "primary",
36112 isBusy: isDuplicating,
36113 disabled: isDuplicating || !isValid2,
36114 accessibleWhenDisabled: true,
36115 onClick: onDuplicate,
36116 children: (0, import_i18n61._x)("Duplicate", "action label")
36117 }
36118 )
36119 ] })
36120 ] });
36121 }
36122 var duplicatePostTypeAction = {
36123 id: "duplicate-post-type",
36124 label: (0, import_i18n61._x)("Duplicate", "action label"),
36125 icon: copy_default,
36126 modalHeader: (0, import_i18n61.__)("Duplicate post type"),
36127 modalFocusOnMount: "firstContentElement",
36128 RenderModal: DuplicatePostTypeModal
36129 };
36130 var duplicate_default = duplicatePostTypeAction;
36131
36132 // packages/content-types/build-module/post-types/actions/view-posts.mjs
36133 var import_i18n62 = __toESM(require_i18n(), 1);
36134 var import_url5 = __toESM(require_url(), 1);
36135 var viewPostsAction = {
36136 id: "view-posts",
36137 label: (items) => items[0]?.config.labels.view_items || (items[0]?.config.hierarchical ? (0, import_i18n62.__)("View pages") : (0, import_i18n62.__)("View posts")),
36138 // Drafts are not registered with WordPress, so `edit.php?post_type=…`
36139 // would 404. Only surface the link for active post types.
36140 isEligible: (item) => item.status === "publish",
36141 callback: (items, { onActionPerformed }) => {
36142 const item = items[0];
36143 if (!item?.slug) {
36144 return;
36145 }
36146 document.location.href = (0, import_url5.addQueryArgs)("edit.php", {
36147 post_type: item.slug
36148 });
36149 onActionPerformed?.(items);
36150 }
36151 };
36152 var view_posts_default = viewPostsAction;
36153
36154 // packages/content-types/build-module/post-types/fields/labels.mjs
36155 var import_i18n64 = __toESM(require_i18n(), 1);
36156
36157 // packages/content-types/build-module/utils/labels.mjs
36158 var import_components56 = __toESM(require_components(), 1);
36159 var import_i18n63 = __toESM(require_i18n(), 1);
36160 var import_jsx_runtime180 = __toESM(require_jsx_runtime(), 1);
36161 var LABELS_ACTIONS_FIELD_ID = "__labels_actions";
36162 function createLabelsActionsField(options) {
36163 const { labelKeys, deriveLabels: deriveLabels3, helpText } = options;
36164 function LabelsActionsEdit({
36165 data,
36166 onChange
36167 }) {
36168 const plural = data.title.raw.trim();
36169 const singular = data.config.labels.singular_name.trim();
36170 const canAutoFill = !!plural.length && !!singular.length;
36171 const currentLabels = data.config.labels;
36172 const hasOverrides = labelKeys.some(
36173 (key) => key !== "singular_name" && (currentLabels[key] ?? "") !== ""
36174 );
36175 return /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(Stack, { direction: "column", gap: "md", children: [
36176 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(Text, { variant: "body-md", children: helpText }),
36177 /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [
36178 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36179 import_components56.Button,
36180 {
36181 __next40pxDefaultSize: true,
36182 variant: "secondary",
36183 size: "compact",
36184 accessibleWhenDisabled: true,
36185 disabled: !canAutoFill,
36186 onClick: () => onChange({
36187 config: {
36188 ...data.config,
36189 labels: {
36190 ...data.config.labels,
36191 ...deriveLabels3(plural, singular)
36192 }
36193 }
36194 }),
36195 children: (0, import_i18n63.__)("Auto-fill labels")
36196 }
36197 ),
36198 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36199 import_components56.Button,
36200 {
36201 __next40pxDefaultSize: true,
36202 size: "compact",
36203 icon: trash_default,
36204 isDestructive: true,
36205 label: (0, import_i18n63.__)("Clear labels"),
36206 accessibleWhenDisabled: true,
36207 disabled: !hasOverrides,
36208 onClick: () => {
36209 const cleared = {
36210 singular_name: data.config.labels.singular_name
36211 };
36212 for (const key of labelKeys) {
36213 if (key !== "singular_name") {
36214 cleared[key] = "";
36215 }
36216 }
36217 onChange({
36218 config: { ...data.config, labels: cleared }
36219 });
36220 }
36221 }
36222 )
36223 ] })
36224 ] });
36225 }
36226 return {
36227 id: LABELS_ACTIONS_FIELD_ID,
36228 label: "",
36229 getValue: () => "",
36230 setValue: () => ({}),
36231 Edit: LabelsActionsEdit,
36232 enableSorting: false,
36233 filterBy: false
36234 };
36235 }
36236
36237 // packages/content-types/build-module/post-types/fields/labels.mjs
36238 var menuNameField = createLabelField("menu_name", (0, import_i18n64.__)("Menu name"), {
36239 placeholder: (0, import_i18n64.__)("Posts"),
36240 description: (0, import_i18n64.__)("Defaults to the plural label.")
36241 });
36242 var allItemsField = createLabelField("all_items", (0, import_i18n64.__)("All items"), {
36243 placeholder: (0, import_i18n64.__)("All Posts")
36244 });
36245 var addNewField = createLabelField("add_new", (0, import_i18n64.__)("Add new"), {
36246 placeholder: (0, import_i18n64.__)("Add New"),
36247 description: (0, import_i18n64.__)("Shown in the admin menu and on toolbar buttons.")
36248 });
36249 var addNewItemLabelField = createLabelField(
36250 "add_new_item",
36251 (0, import_i18n64.__)("Add new item"),
36252 { placeholder: (0, import_i18n64.__)("Add New Post") }
36253 );
36254 var editItemField = createLabelField("edit_item", (0, import_i18n64.__)("Edit item"), {
36255 placeholder: (0, import_i18n64.__)("Edit Post")
36256 });
36257 var newItemField = createLabelField("new_item", (0, import_i18n64.__)("New item"), {
36258 placeholder: (0, import_i18n64.__)("New Post")
36259 });
36260 var viewItemField = createLabelField("view_item", (0, import_i18n64.__)("View item"), {
36261 placeholder: (0, import_i18n64.__)("View Post")
36262 });
36263 var viewItemsField = createLabelField(
36264 "view_items",
36265 (0, import_i18n64.__)("View items"),
36266 {
36267 placeholder: (0, import_i18n64.__)("View Posts"),
36268 description: (0, import_i18n64.__)("Used as the link label for the post type archive.")
36269 }
36270 );
36271 var searchItemsField = createLabelField(
36272 "search_items",
36273 (0, import_i18n64.__)("Search items"),
36274 { placeholder: (0, import_i18n64.__)("Search Posts") }
36275 );
36276 var notFoundField = createLabelField("not_found", (0, import_i18n64.__)("Not found"), {
36277 placeholder: (0, import_i18n64.__)("No posts found."),
36278 description: (0, import_i18n64.__)("Shown in the admin list when no posts match.")
36279 });
36280 var notFoundInTrashField = createLabelField(
36281 "not_found_in_trash",
36282 (0, import_i18n64.__)("Not found in trash"),
36283 { placeholder: (0, import_i18n64.__)("No posts found in Trash.") }
36284 );
36285 var archivesField = createLabelField("archives", (0, import_i18n64.__)("Archives"), {
36286 placeholder: (0, import_i18n64.__)("Post Archives"),
36287 description: (0, import_i18n64.__)(
36288 "Used in the navigation menus block when adding a link to the post type archive."
36289 )
36290 });
36291 var attributesField = createLabelField(
36292 "attributes",
36293 (0, import_i18n64.__)("Attributes"),
36294 {
36295 placeholder: (0, import_i18n64.__)("Post Attributes"),
36296 description: (0, import_i18n64.__)(
36297 "Title of the Attributes meta box. Not used on non-hierarchical post types."
36298 ),
36299 isVisible: (item) => item.config.hierarchical
36300 }
36301 );
36302 var parentItemColonField = createLabelField(
36303 "parent_item_colon",
36304 (0, import_i18n64.__)("Parent item with colon"),
36305 {
36306 placeholder: (0, import_i18n64.__)("Parent Page:"),
36307 description: (0, import_i18n64.__)(
36308 "Shown above the parent dropdown. Not used on non-hierarchical post types."
36309 ),
36310 isVisible: (item) => item.config.hierarchical
36311 }
36312 );
36313 var insertIntoItemField = createLabelField(
36314 "insert_into_item",
36315 (0, import_i18n64.__)("Insert into item"),
36316 {
36317 placeholder: (0, import_i18n64.__)("Insert into post"),
36318 description: (0, import_i18n64.__)("Shown in the media library uploader.")
36319 }
36320 );
36321 var uploadedToThisItemField = createLabelField(
36322 "uploaded_to_this_item",
36323 (0, import_i18n64.__)("Uploaded to this item"),
36324 {
36325 placeholder: (0, import_i18n64.__)("Uploaded to this post")
36326 }
36327 );
36328 var featuredImageField = createLabelField(
36329 "featured_image",
36330 (0, import_i18n64.__)("Featured image"),
36331 {
36332 placeholder: (0, import_i18n64.__)("Featured image")
36333 }
36334 );
36335 var setFeaturedImageField = createLabelField(
36336 "set_featured_image",
36337 (0, import_i18n64.__)("Set featured image"),
36338 {
36339 placeholder: (0, import_i18n64.__)("Set featured image")
36340 }
36341 );
36342 var removeFeaturedImageField = createLabelField(
36343 "remove_featured_image",
36344 (0, import_i18n64.__)("Remove featured image"),
36345 {
36346 placeholder: (0, import_i18n64.__)("Remove featured image")
36347 }
36348 );
36349 var useFeaturedImageField = createLabelField(
36350 "use_featured_image",
36351 (0, import_i18n64.__)("Use as featured image"),
36352 {
36353 placeholder: (0, import_i18n64.__)("Use as featured image")
36354 }
36355 );
36356 var filterItemsListField = createLabelField(
36357 "filter_items_list",
36358 (0, import_i18n64.__)("Filter items list"),
36359 {
36360 placeholder: (0, import_i18n64.__)("Filter posts list"),
36361 description: (0, import_i18n64.__)(
36362 "Screen reader text for the admin list filter controls."
36363 )
36364 }
36365 );
36366 var itemsListNavigationField = createLabelField(
36367 "items_list_navigation",
36368 (0, import_i18n64.__)("Items list navigation"),
36369 {
36370 placeholder: (0, import_i18n64.__)("Posts list navigation"),
36371 description: (0, import_i18n64.__)("Screen reader text for the admin list pagination.")
36372 }
36373 );
36374 var itemsListField = createLabelField(
36375 "items_list",
36376 (0, import_i18n64.__)("Items list"),
36377 {
36378 placeholder: (0, import_i18n64.__)("Posts list"),
36379 description: (0, import_i18n64.__)("Screen reader text for the admin list table.")
36380 }
36381 );
36382 var labelsActionsField = createLabelsActionsField(
36383 {
36384 labelKeys: STRING_LABEL_KEYS,
36385 deriveLabels,
36386 helpText: (0, import_i18n64.__)(
36387 "Override the text WordPress shows in admin lists, menus, and forms. Auto-fill replaces every label below with values derived from the current plural and singular names \u2014 including any you have already customized. Clearing removes all overrides so WordPress falls back to its defaults. If you rename the post type after auto-filling, click Auto-fill again to keep them in sync."
36388 )
36389 }
36390 );
36391 var labelsForm = {
36392 layout: { type: "regular" },
36393 fields: [
36394 {
36395 id: LABELS_ACTIONS_FIELD_ID,
36396 layout: { type: "regular", labelPosition: "none" }
36397 },
36398 // singular_name lives in the General card, so exclude it here.
36399 ...STRING_LABEL_KEYS.filter((key) => key !== "singular_name")
36400 ]
36401 };
36402
36403 // packages/content-types/build-module/post-types/actions/edit.mjs
36404 var import_element131 = __toESM(require_element(), 1);
36405 var import_i18n65 = __toESM(require_i18n(), 1);
36406 import { useNavigate as useNavigate2 } from "@wordpress/route";
36407 function useEditPostTypeAction() {
36408 const navigate = useNavigate2();
36409 return (0, import_element131.useMemo)(
36410 () => ({
36411 id: "edit-post-type",
36412 label: (0, import_i18n65.__)("Edit"),
36413 callback: (items) => {
36414 const item = items[0];
36415 if (item?.id === void 0) {
36416 return;
36417 }
36418 navigate({
36419 to: `${POST_TYPES_PATH}/${item.id}`
36420 });
36421 }
36422 }),
36423 [navigate]
36424 );
36425 }
36426
36427 // packages/content-types/build-module/post-types/actions/quick-edit.mjs
36428 var import_components57 = __toESM(require_components(), 1);
36429 var import_core_data8 = __toESM(require_core_data(), 1);
36430 var import_data14 = __toESM(require_data(), 1);
36431 var import_element132 = __toESM(require_element(), 1);
36432 var import_i18n66 = __toESM(require_i18n(), 1);
36433 var import_notices4 = __toESM(require_notices(), 1);
36434 var import_jsx_runtime181 = __toESM(require_jsx_runtime(), 1);
36435 function QuickEditPostTypeModal({
36436 items,
36437 closeModal
36438 }) {
36439 const item = items[0];
36440 const [data, setData] = (0, import_element132.useState)(item);
36441 const [isSaving, setIsSaving] = (0, import_element132.useState)(false);
36442 const slugField = useSlugField(item.slug, data.slug);
36443 const taxonomiesField = useTaxonomiesField();
36444 const fields = (0, import_element132.useMemo)(
36445 () => [
36446 pluralLabelField,
36447 singularLabelField,
36448 slugField,
36449 taxonomiesField,
36450 publicField,
36451 hierarchicalField,
36452 hasArchiveField,
36453 statusField
36454 ],
36455 [slugField, taxonomiesField]
36456 );
36457 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, defaultForm);
36458 const { saveEntityRecord } = (0, import_data14.useDispatch)(import_core_data8.store);
36459 const { createSuccessNotice, createErrorNotice } = (0, import_data14.useDispatch)(import_notices4.store);
36460 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
36461 async function onSave() {
36462 if (isSaving || !isValid2) {
36463 return;
36464 }
36465 setIsSaving(true);
36466 try {
36467 await saveEntityRecord(
36468 "postType",
36469 POST_TYPE_ENTITY,
36470 serializeForSave({ ...data, id: item.id }),
36471 { throwOnError: true }
36472 );
36473 createSuccessNotice(
36474 (0, import_i18n66.sprintf)(
36475 /* translators: %s: post type plural label. */
36476 (0, import_i18n66.__)('"%s" post type updated.'),
36477 data.title.raw
36478 ),
36479 { type: "snackbar" }
36480 );
36481 maybeInvalidateCache(
36482 item.config.taxonomies,
36483 data.config.taxonomies,
36484 TAXONOMY_ENTITY
36485 );
36486 closeModal?.();
36487 } catch (error2) {
36488 createErrorNotice(
36489 error2?.message && error2?.code !== "unknown_error" ? error2.message : (0, import_i18n66.__)("Failed to update post type."),
36490 { type: "snackbar" }
36491 );
36492 } finally {
36493 setIsSaving(false);
36494 }
36495 }
36496 return /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(
36497 "form",
36498 {
36499 onSubmit: (event) => {
36500 event.preventDefault();
36501 onSave();
36502 },
36503 children: [
36504 /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(
36505 Stack,
36506 {
36507 className: "dataviews-action-modal__quick-edit-post-type-header",
36508 direction: "row",
36509 justify: "space-between",
36510 align: "center",
36511 children: [
36512 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(Text, { variant: "heading-sm", render: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)("h2", {}), children: (0, import_i18n66.__)("Quick edit post type") }),
36513 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36514 import_components57.Button,
36515 {
36516 size: "small",
36517 icon: close_small_default,
36518 label: (0, import_i18n66.__)("Close"),
36519 onClick: closeModal
36520 }
36521 )
36522 ]
36523 }
36524 ),
36525 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)("div", { className: "dataviews-action-modal__quick-edit-post-type-content", children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36526 DataForm,
36527 {
36528 data,
36529 fields,
36530 form: defaultForm,
36531 validity,
36532 onChange: (edits) => setData(
36533 (prev) => ({ ...prev, ...edits })
36534 )
36535 }
36536 ) }),
36537 /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(
36538 Stack,
36539 {
36540 className: "dataviews-action-modal__quick-edit-post-type-footer",
36541 direction: "row",
36542 gap: "sm",
36543 children: [
36544 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36545 import_components57.Button,
36546 {
36547 __next40pxDefaultSize: true,
36548 variant: "secondary",
36549 onClick: closeModal,
36550 children: (0, import_i18n66.__)("Cancel")
36551 }
36552 ),
36553 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36554 import_components57.Button,
36555 {
36556 __next40pxDefaultSize: true,
36557 variant: "primary",
36558 type: "submit",
36559 isBusy: isSaving,
36560 disabled: isSaving || !isValid2,
36561 accessibleWhenDisabled: true,
36562 children: (0, import_i18n66.__)("Done")
36563 }
36564 )
36565 ]
36566 }
36567 )
36568 ]
36569 }
36570 );
36571 }
36572 var quickEditPostTypeAction = {
36573 id: "quick-edit-post-type",
36574 label: (0, import_i18n66.__)("Quick edit"),
36575 icon: pencil_default,
36576 isPrimary: true,
36577 hideModalHeader: true,
36578 RenderModal: QuickEditPostTypeModal
36579 };
36580 var quick_edit_default = quickEditPostTypeAction;
36581
36582 // packages/content-types/build-module/post-types/list.mjs
36583 var import_jsx_runtime182 = __toESM(require_jsx_runtime(), 1);
36584 var defaultLayouts = {
36585 table: {}
36586 };
36587 var DEFAULT_VIEW = {
36588 type: "table",
36589 perPage: 20,
36590 page: 1,
36591 fields: ["taxonomies", "count", "status"],
36592 titleField: "title",
36593 layout: {
36594 styles: {
36595 taxonomies: { minWidth: 230 },
36596 supports: { minWidth: 230 }
36597 }
36598 }
36599 };
36600 function PostTypesList() {
36601 const navigate = useNavigate3();
36602 const searchParams = useSearch({ from: POST_TYPES_PATH });
36603 const handleQueryParamsChange = (0, import_element133.useCallback)(
36604 (params) => {
36605 navigate({
36606 search: {
36607 ...searchParams,
36608 ...params
36609 }
36610 });
36611 },
36612 [searchParams, navigate]
36613 );
36614 const { view, updateView, isModified, resetToDefault } = useView({
36615 kind: "postType",
36616 name: POST_TYPE_ENTITY,
36617 slug: "default",
36618 defaultView: DEFAULT_VIEW,
36619 queryParams: searchParams,
36620 onChangeQueryParams: handleQueryParamsChange
36621 });
36622 const editAction = useEditPostTypeAction();
36623 const postTypeActions = (0, import_element133.useMemo)(
36624 () => [
36625 editAction,
36626 quick_edit_default,
36627 duplicate_default,
36628 view_posts_default,
36629 activate_default,
36630 deactivate_default,
36631 delete_default
36632 ],
36633 [editAction]
36634 );
36635 const slugField = useSlugField();
36636 const taxonomiesField = useTaxonomiesField();
36637 const fields = (0, import_element133.useMemo)(
36638 () => [
36639 titleField,
36640 taxonomiesField,
36641 countField,
36642 statusField,
36643 publicField,
36644 slugField,
36645 hierarchicalField,
36646 hasArchiveField,
36647 supportsField
36648 ],
36649 [slugField, taxonomiesField]
36650 );
36651 const queryArgs = (0, import_element133.useMemo)(() => {
36652 const statusFilter = view.filters?.find(
36653 (filter) => filter.field === "status"
36654 );
36655 return {
36656 per_page: view.perPage,
36657 page: view.page,
36658 context: "edit",
36659 order: view.sort?.direction,
36660 orderby: view.sort?.field,
36661 search: view.search,
36662 status: statusFilter?.value ?? ["publish", "draft"]
36663 };
36664 }, [view]);
36665 const { records, isResolving, hasResolved, totalItems, totalPages } = (0, import_core_data9.useEntityRecords)(
36666 "postType",
36667 POST_TYPE_ENTITY,
36668 queryArgs
36669 );
36670 const data = (0, import_element133.useMemo)(
36671 () => (records ?? []).map(toFormData),
36672 [records]
36673 );
36674 const paginationInfo = (0, import_element133.useMemo)(
36675 () => ({
36676 totalItems: totalItems ?? 0,
36677 totalPages: totalPages ?? 0
36678 }),
36679 [totalItems, totalPages]
36680 );
36681 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
36682 dataviews_default,
36683 {
36684 data,
36685 fields,
36686 actions: postTypeActions,
36687 view,
36688 onChangeView: updateView,
36689 onReset: isModified ? resetToDefault : false,
36690 isLoading: isResolving || !hasResolved,
36691 paginationInfo,
36692 defaultLayouts,
36693 getItemId: (item) => String(item.id),
36694 isItemClickable: () => true,
36695 onClickItem: (item) => navigate({
36696 to: `${POST_TYPES_PATH}/${item.id}`
36697 }),
36698 header: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
36699 import_components58.Button,
36700 {
36701 variant: "primary",
36702 size: "compact",
36703 __next40pxDefaultSize: true,
36704 onClick: () => navigate({
36705 to: `${POST_TYPES_PATH}/${NEW_ID}`
36706 }),
36707 children: (0, import_i18n67.__)("Add post type")
36708 }
36709 )
36710 }
36711 );
36712 }
36713
36714 // packages/content-types/build-module/post-types/edit.mjs
36715 var import_components59 = __toESM(require_components(), 1);
36716 var import_compose18 = __toESM(require_compose(), 1);
36717 var import_core_data10 = __toESM(require_core_data(), 1);
36718 var import_data15 = __toESM(require_data(), 1);
36719 var import_element134 = __toESM(require_element(), 1);
36720 var import_i18n68 = __toESM(require_i18n(), 1);
36721 var import_notices5 = __toESM(require_notices(), 1);
36722 import { useNavigate as useNavigate4, useParams } from "@wordpress/route";
36723 var import_jsx_runtime183 = __toESM(require_jsx_runtime(), 1);
36724 function PostTypeEdit() {
36725 const { id } = useParams({ from: `${POST_TYPES_PATH}/$id` });
36726 const navigate = useNavigate4();
36727 const isAddMode = id === NEW_ID;
36728 const postTypeId = parseInt(id, 10);
36729 const record = (0, import_data15.useSelect)(
36730 (select2) => {
36731 return !isAddMode && // beforeLoad (route.ts) guarantees the record is in cache.
36732 select2(import_core_data10.store).getEntityRecord(
36733 "postType",
36734 POST_TYPE_ENTITY,
36735 postTypeId
36736 );
36737 },
36738 [isAddMode, postTypeId]
36739 );
36740 const initialData = !isAddMode && record ? toFormData(record) : BLANK_RECORD;
36741 const title = isAddMode ? (0, import_i18n68.__)("Add post type") : initialData.title.raw;
36742 const commonProps = { initialData, title };
36743 const postTypePageProps = isAddMode ? {
36744 ...commonProps,
36745 isAddMode: true,
36746 breadcrumbLabel: (0, import_i18n68.__)("Add new"),
36747 subTitle: (0, import_i18n68.__)(
36748 "Define a new post type. Fill in the essentials under General; expand Labels to customize."
36749 ),
36750 onSaved: (saved) => navigate({
36751 to: `${POST_TYPES_PATH}/${saved.id}`
36752 })
36753 } : {
36754 ...commonProps,
36755 isAddMode: false,
36756 breadcrumbLabel: title,
36757 subTitle: (0, import_i18n68.__)(
36758 "Edit this post type. Expand the Labels section to adjust labels."
36759 )
36760 };
36761 return /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(PostTypePage, { ...postTypePageProps }, id);
36762 }
36763 function PostTypePage({
36764 isAddMode,
36765 initialData,
36766 title,
36767 breadcrumbLabel,
36768 subTitle,
36769 onSaved
36770 }) {
36771 const [data, setData] = (0, import_element134.useState)(initialData);
36772 const [isSaving, setIsSaving] = (0, import_element134.useState)(false);
36773 const originalSlug = !isAddMode ? initialData.slug : void 0;
36774 const slugField = useSlugField(originalSlug, data.slug);
36775 const taxonomiesField = useTaxonomiesField();
36776 const fields = (0, import_element134.useMemo)(
36777 () => [
36778 // General
36779 pluralLabelField,
36780 singularLabelField,
36781 slugField,
36782 descriptionField,
36783 taxonomiesField,
36784 supportsField,
36785 publicField,
36786 hierarchicalField,
36787 hasArchiveField,
36788 showInRestField,
36789 statusField,
36790 // Labels
36791 labelsActionsField,
36792 menuNameField,
36793 allItemsField,
36794 addNewField,
36795 addNewItemLabelField,
36796 editItemField,
36797 newItemField,
36798 viewItemField,
36799 viewItemsField,
36800 searchItemsField,
36801 notFoundField,
36802 notFoundInTrashField,
36803 parentItemColonField,
36804 archivesField,
36805 attributesField,
36806 insertIntoItemField,
36807 uploadedToThisItemField,
36808 featuredImageField,
36809 setFeaturedImageField,
36810 removeFeaturedImageField,
36811 useFeaturedImageField,
36812 filterItemsListField,
36813 itemsListNavigationField,
36814 itemsListField
36815 ],
36816 [slugField, taxonomiesField]
36817 );
36818 const form = (0, import_element134.useMemo)(
36819 () => ({
36820 layout: { type: "card", isCollapsible: true },
36821 fields: [
36822 {
36823 id: "general",
36824 label: (0, import_i18n68.__)("General"),
36825 description: (0, import_i18n68.__)(
36826 "Core identity, taxonomies, supports, and activation."
36827 ),
36828 layout: {
36829 type: "card",
36830 isCollapsible: true,
36831 isOpened: true
36832 },
36833 children: generalForm.fields
36834 },
36835 {
36836 id: "labels",
36837 label: (0, import_i18n68.__)("Labels"),
36838 layout: {
36839 type: "card",
36840 isCollapsible: true,
36841 isOpened: false
36842 },
36843 children: labelsForm.fields
36844 }
36845 ]
36846 }),
36847 []
36848 );
36849 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, form);
36850 const formId = (0, import_compose18.useInstanceId)(PostTypePage, "post-type-form");
36851 const { saveEntityRecord } = (0, import_data15.useDispatch)(import_core_data10.store);
36852 const { createSuccessNotice, createErrorNotice } = (0, import_data15.useDispatch)(import_notices5.store);
36853 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
36854 async function onSave() {
36855 if (isSaving || !isValid2) {
36856 return;
36857 }
36858 setIsSaving(true);
36859 try {
36860 const saved = await saveEntityRecord(
36861 "postType",
36862 POST_TYPE_ENTITY,
36863 serializeForSave(data),
36864 { throwOnError: true }
36865 );
36866 const successMessage = isAddMode ? (0, import_i18n68.sprintf)(
36867 /* translators: %s: post type plural label. */
36868 (0, import_i18n68.__)('"%s" post type created.'),
36869 data.title.raw
36870 ) : (0, import_i18n68.sprintf)(
36871 /* translators: %s: post type plural label. */
36872 (0, import_i18n68.__)('"%s" post type updated.'),
36873 data.title.raw
36874 );
36875 createSuccessNotice(successMessage, { type: "snackbar" });
36876 maybeInvalidateCache(
36877 initialData.config.taxonomies,
36878 data.config.taxonomies,
36879 TAXONOMY_ENTITY
36880 );
36881 if (saved?.id !== void 0) {
36882 onSaved?.({ ...data, id: saved.id });
36883 }
36884 } catch (error2) {
36885 let errorMessage;
36886 if (error2?.message && error2?.code !== "unknown_error") {
36887 errorMessage = error2.message;
36888 } else if (isAddMode) {
36889 errorMessage = (0, import_i18n68.__)("Failed to create post type.");
36890 } else {
36891 errorMessage = (0, import_i18n68.__)("Failed to update post type.");
36892 }
36893 createErrorNotice(errorMessage, { type: "snackbar" });
36894 } finally {
36895 setIsSaving(false);
36896 }
36897 }
36898 return /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
36899 page_default,
36900 {
36901 ariaLabel: title,
36902 breadcrumbs: /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
36903 breadcrumbs_default,
36904 {
36905 items: [
36906 { label: (0, import_i18n68.__)("Post Types"), to: POST_TYPES_PATH },
36907 { label: breadcrumbLabel }
36908 ]
36909 }
36910 ),
36911 subTitle,
36912 actions: /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
36913 import_components59.Button,
36914 {
36915 __next40pxDefaultSize: true,
36916 variant: "primary",
36917 size: "compact",
36918 type: "submit",
36919 form: formId,
36920 isBusy: isSaving,
36921 disabled: isSaving || !isValid2,
36922 accessibleWhenDisabled: true,
36923 children: isAddMode ? (0, import_i18n68.__)("Create") : (0, import_i18n68.__)("Save")
36924 }
36925 ),
36926 children: /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
36927 Stack,
36928 {
36929 direction: "column",
36930 gap: "md",
36931 className: "post-type-form",
36932 render: /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
36933 "form",
36934 {
36935 id: formId,
36936 onSubmit: (event) => {
36937 event.preventDefault();
36938 onSave();
36939 }
36940 }
36941 ),
36942 children: /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
36943 DataForm,
36944 {
36945 data,
36946 fields,
36947 form,
36948 validity,
36949 onChange: (edits) => setData(
36950 (prev) => ({
36951 ...prev,
36952 ...edits
36953 })
36954 )
36955 }
36956 )
36957 }
36958 )
36959 }
36960 );
36961 }
36962
36963 // packages/content-types/build-module/taxonomies/list.mjs
36964 var import_components63 = __toESM(require_components(), 1);
36965 var import_core_data16 = __toESM(require_core_data(), 1);
36966 var import_element141 = __toESM(require_element(), 1);
36967 var import_i18n81 = __toESM(require_i18n(), 1);
36968 import { useNavigate as useNavigate6, useSearch as useSearch2 } from "@wordpress/route";
36969
36970 // packages/content-types/build-module/taxonomies/actions/activate.mjs
36971 var import_i18n69 = __toESM(require_i18n(), 1);
36972 var activateAction2 = createStatusAction({
36973 id: "activate",
36974 label: (0, import_i18n69.__)("Activate"),
36975 entity: TAXONOMY_ENTITY,
36976 targetStatus: "publish",
36977 messages: {
36978 successSingle: (0, import_i18n69.__)("Taxonomy activated."),
36979 successMany: (count) => (0, import_i18n69.sprintf)(
36980 /* translators: %d: The number of taxonomies. */
36981 (0, import_i18n69._n)(
36982 "%d taxonomy activated.",
36983 "%d taxonomies activated.",
36984 count
36985 ),
36986 count
36987 ),
36988 failSingle: (0, import_i18n69.__)("Failed to activate taxonomy."),
36989 failMany: (0, import_i18n69.__)("Failed to activate taxonomies."),
36990 errorSingle: (message2) => (0, import_i18n69.sprintf)(
36991 /* translators: %s: an error message */
36992 (0, import_i18n69.__)("An error occurred while activating the taxonomy: %s"),
36993 message2
36994 ),
36995 errorMany: (messages) => (0, import_i18n69.sprintf)(
36996 /* translators: %s: a list of comma separated error messages */
36997 (0, import_i18n69.__)(
36998 "Some errors occurred while activating the taxonomies: %s"
36999 ),
37000 messages
37001 )
37002 }
37003 });
37004 var activate_default2 = activateAction2;
37005
37006 // packages/content-types/build-module/taxonomies/actions/deactivate.mjs
37007 var import_i18n70 = __toESM(require_i18n(), 1);
37008 var deactivateAction2 = createStatusAction({
37009 id: "deactivate",
37010 label: (0, import_i18n70.__)("Deactivate"),
37011 entity: TAXONOMY_ENTITY,
37012 targetStatus: "draft",
37013 messages: {
37014 successSingle: (0, import_i18n70.__)("Taxonomy deactivated."),
37015 successMany: (count) => (0, import_i18n70.sprintf)(
37016 /* translators: %d: The number of taxonomies. */
37017 (0, import_i18n70._n)(
37018 "%d taxonomy deactivated.",
37019 "%d taxonomies deactivated.",
37020 count
37021 ),
37022 count
37023 ),
37024 failSingle: (0, import_i18n70.__)("Failed to deactivate taxonomy."),
37025 failMany: (0, import_i18n70.__)("Failed to deactivate taxonomies."),
37026 errorSingle: (message2) => (0, import_i18n70.sprintf)(
37027 /* translators: %s: an error message */
37028 (0, import_i18n70.__)("An error occurred while deactivating the taxonomy: %s"),
37029 message2
37030 ),
37031 errorMany: (messages) => (0, import_i18n70.sprintf)(
37032 /* translators: %s: a list of comma separated error messages */
37033 (0, import_i18n70.__)(
37034 "Some errors occurred while deactivating the taxonomies: %s"
37035 ),
37036 messages
37037 )
37038 }
37039 });
37040 var deactivate_default2 = deactivateAction2;
37041
37042 // packages/content-types/build-module/taxonomies/actions/delete.mjs
37043 var import_components60 = __toESM(require_components(), 1);
37044 var import_core_data11 = __toESM(require_core_data(), 1);
37045 var import_data16 = __toESM(require_data(), 1);
37046 var import_element135 = __toESM(require_element(), 1);
37047 var import_i18n71 = __toESM(require_i18n(), 1);
37048 var import_notices6 = __toESM(require_notices(), 1);
37049 var import_jsx_runtime184 = __toESM(require_jsx_runtime(), 1);
37050 function DeleteTaxonomyModal({
37051 items,
37052 closeModal,
37053 onActionPerformed
37054 }) {
37055 const [isDeleting, setIsDeleting] = (0, import_element135.useState)(false);
37056 const { deleteEntityRecord } = (0, import_data16.useDispatch)(import_core_data11.store);
37057 const { createSuccessNotice, createErrorNotice } = (0, import_data16.useDispatch)(import_notices6.store);
37058 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
37059 async function onDelete() {
37060 if (isDeleting) {
37061 return;
37062 }
37063 setIsDeleting(true);
37064 const itemsToDelete = items.filter((item) => item.id !== void 0);
37065 const promiseResult = await Promise.allSettled(
37066 itemsToDelete.map(
37067 (item) => deleteEntityRecord(
37068 "postType",
37069 TAXONOMY_ENTITY,
37070 item.id,
37071 { force: true },
37072 { throwOnError: true }
37073 )
37074 )
37075 );
37076 if (promiseResult.every(({ status }) => status === "fulfilled")) {
37077 createSuccessNotice(
37078 itemsToDelete.length === 1 ? (0, import_i18n71.sprintf)(
37079 /* translators: %s: The taxonomy's plural label. */
37080 (0, import_i18n71.__)('"%s" taxonomy deleted.'),
37081 itemsToDelete[0].title.raw
37082 ) : (0, import_i18n71.sprintf)(
37083 /* translators: %d: The number of taxonomies. */
37084 (0, import_i18n71._n)(
37085 "%d taxonomy deleted.",
37086 "%d taxonomies deleted.",
37087 itemsToDelete.length
37088 ),
37089 itemsToDelete.length
37090 ),
37091 { type: "snackbar" }
37092 );
37093 } else {
37094 let errorMessage;
37095 if (promiseResult.length === 1) {
37096 const typedError = promiseResult[0];
37097 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
37098 errorMessage = typedError.reason.message;
37099 } else {
37100 errorMessage = (0, import_i18n71.__)("Failed to delete taxonomy.");
37101 }
37102 } else {
37103 const errorMessages = /* @__PURE__ */ new Set();
37104 const failedPromises = promiseResult.filter(
37105 ({ status }) => status === "rejected"
37106 );
37107 for (const failedPromise of failedPromises) {
37108 const typedError = failedPromise;
37109 if (typedError.reason?.message && typedError.reason.code !== "unknown_error") {
37110 errorMessages.add(typedError.reason.message);
37111 }
37112 }
37113 if (errorMessages.size === 0) {
37114 errorMessage = (0, import_i18n71.__)("Failed to delete taxonomies.");
37115 } else if (errorMessages.size === 1) {
37116 errorMessage = (0, import_i18n71.sprintf)(
37117 /* translators: %s: an error message */
37118 (0, import_i18n71.__)(
37119 "An error occurred while deleting the taxonomy: %s"
37120 ),
37121 [...errorMessages][0]
37122 );
37123 } else {
37124 errorMessage = (0, import_i18n71.sprintf)(
37125 /* translators: %s: a list of comma separated error messages */
37126 (0, import_i18n71.__)(
37127 "Some errors occurred while deleting the taxonomies: %s"
37128 ),
37129 [...errorMessages].join(",")
37130 );
37131 }
37132 }
37133 createErrorNotice(errorMessage, { type: "snackbar" });
37134 }
37135 const deletedRefs = itemsToDelete.filter((_, i2) => promiseResult[i2].status === "fulfilled").flatMap((item) => item.config.object_type);
37136 maybeInvalidateCache(deletedRefs, [], POST_TYPE_ENTITY);
37137 onActionPerformed?.(itemsToDelete);
37138 setIsDeleting(false);
37139 closeModal?.();
37140 }
37141 return /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(Stack, { direction: "column", gap: "md", children: [
37142 /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(Text, { children: items.length > 1 ? (0, import_i18n71.sprintf)(
37143 /* translators: %d: number of taxonomies to delete. */
37144 (0, import_i18n71._n)(
37145 "Are you sure you want to delete %d taxonomy?",
37146 "Are you sure you want to delete %d taxonomies?",
37147 items.length
37148 ),
37149 items.length
37150 ) : (0, import_i18n71.sprintf)(
37151 /* translators: %s: The taxonomy's plural label. */
37152 (0, import_i18n71.__)('Are you sure you want to delete "%s"?'),
37153 items[0].title.raw
37154 ) }),
37155 /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [
37156 /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
37157 import_components60.Button,
37158 {
37159 __next40pxDefaultSize: true,
37160 variant: "tertiary",
37161 onClick: closeModal,
37162 disabled: isDeleting,
37163 accessibleWhenDisabled: true,
37164 children: (0, import_i18n71.__)("Cancel")
37165 }
37166 ),
37167 /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
37168 import_components60.Button,
37169 {
37170 __next40pxDefaultSize: true,
37171 variant: "primary",
37172 isDestructive: true,
37173 isBusy: isDeleting,
37174 disabled: isDeleting,
37175 accessibleWhenDisabled: true,
37176 onClick: onDelete,
37177 children: (0, import_i18n71._x)("Delete", "verb")
37178 }
37179 )
37180 ] })
37181 ] });
37182 }
37183 var deleteTaxonomyAction = {
37184 id: "delete-taxonomy",
37185 label: (0, import_i18n71._x)("Delete", "verb"),
37186 icon: trash_default,
37187 supportsBulk: true,
37188 hideModalHeader: true,
37189 modalFocusOnMount: "firstContentElement",
37190 modalSize: "small",
37191 RenderModal: DeleteTaxonomyModal
37192 };
37193 var delete_default2 = deleteTaxonomyAction;
37194
37195 // packages/content-types/build-module/taxonomies/actions/duplicate.mjs
37196 var import_components61 = __toESM(require_components(), 1);
37197 var import_core_data14 = __toESM(require_core_data(), 1);
37198 var import_data19 = __toESM(require_data(), 1);
37199 var import_element138 = __toESM(require_element(), 1);
37200 var import_i18n74 = __toESM(require_i18n(), 1);
37201 var import_notices7 = __toESM(require_notices(), 1);
37202
37203 // packages/content-types/build-module/taxonomies/fields/general.mjs
37204 var import_core_data13 = __toESM(require_core_data(), 1);
37205 var import_data18 = __toESM(require_data(), 1);
37206 var import_element137 = __toESM(require_element(), 1);
37207 var import_i18n73 = __toESM(require_i18n(), 1);
37208 var import_url6 = __toESM(require_url(), 1);
37209
37210 // packages/content-types/build-module/taxonomies/utils.mjs
37211 var import_core_data12 = __toESM(require_core_data(), 1);
37212 var import_data17 = __toESM(require_data(), 1);
37213 var import_element136 = __toESM(require_element(), 1);
37214 var import_i18n72 = __toESM(require_i18n(), 1);
37215 var BLANK_RECORD2 = {
37216 slug: "",
37217 status: "publish",
37218 title: { raw: "" },
37219 config: {
37220 labels: { singular_name: "" },
37221 object_type: [],
37222 description: "",
37223 public: true,
37224 hierarchical: false,
37225 publicly_queryable: true,
37226 show_ui: true,
37227 show_in_menu: true,
37228 show_in_nav_menus: true,
37229 show_tagcloud: true,
37230 show_in_quick_edit: true,
37231 show_admin_column: false,
37232 show_in_rest: true,
37233 sort: false,
37234 default_term_enabled: false,
37235 default_term: { name: "" }
37236 }
37237 };
37238 var STRING_LABEL_KEYS2 = [
37239 "singular_name",
37240 "menu_name",
37241 "all_items",
37242 "edit_item",
37243 "view_item",
37244 "update_item",
37245 "add_new_item",
37246 "new_item_name",
37247 "search_items",
37248 "not_found",
37249 "back_to_items",
37250 "parent_item",
37251 "popular_items",
37252 "separate_items_with_commas",
37253 "parent_item_colon",
37254 "add_or_remove_items",
37255 "choose_from_most_used"
37256 ];
37257 function deriveLabels2(plural, singular) {
37258 const lcPlural = plural.toLowerCase();
37259 return {
37260 menu_name: plural,
37261 all_items: (0, import_i18n72.sprintf)(
37262 /* translators: %s: Plural taxonomy label. */
37263 (0, import_i18n72.__)("All %s"),
37264 plural
37265 ),
37266 edit_item: (0, import_i18n72.sprintf)(
37267 /* translators: %s: Singular taxonomy label. */
37268 (0, import_i18n72.__)("Edit %s"),
37269 singular
37270 ),
37271 view_item: (0, import_i18n72.sprintf)(
37272 /* translators: %s: Singular taxonomy label. */
37273 (0, import_i18n72.__)("View %s"),
37274 singular
37275 ),
37276 update_item: (0, import_i18n72.sprintf)(
37277 /* translators: %s: Singular taxonomy label. */
37278 (0, import_i18n72.__)("Update %s"),
37279 singular
37280 ),
37281 add_new_item: (0, import_i18n72.sprintf)(
37282 /* translators: %s: Singular taxonomy label. */
37283 (0, import_i18n72.__)("Add New %s"),
37284 singular
37285 ),
37286 new_item_name: (0, import_i18n72.sprintf)(
37287 /* translators: %s: Singular taxonomy label. */
37288 (0, import_i18n72.__)("New %s Name"),
37289 singular
37290 ),
37291 search_items: (0, import_i18n72.sprintf)(
37292 /* translators: %s: Plural taxonomy label. */
37293 (0, import_i18n72.__)("Search %s"),
37294 plural
37295 ),
37296 not_found: (0, import_i18n72.sprintf)(
37297 /* translators: %s: Plural taxonomy label, lowercase. */
37298 (0, import_i18n72.__)("No %s found."),
37299 lcPlural
37300 ),
37301 back_to_items: (0, import_i18n72.sprintf)(
37302 /* translators: %s: Plural taxonomy label. */
37303 (0, import_i18n72.__)("\u2190 Back to %s"),
37304 plural
37305 ),
37306 parent_item: (0, import_i18n72.sprintf)(
37307 /* translators: %s: Singular taxonomy label. */
37308 (0, import_i18n72.__)("Parent %s"),
37309 singular
37310 ),
37311 popular_items: (0, import_i18n72.sprintf)(
37312 /* translators: %s: Plural taxonomy label. */
37313 (0, import_i18n72.__)("Popular %s"),
37314 plural
37315 ),
37316 separate_items_with_commas: (0, import_i18n72.sprintf)(
37317 /* translators: %s: Plural taxonomy label, lowercase. */
37318 (0, import_i18n72.__)("Separate %s with commas"),
37319 lcPlural
37320 ),
37321 parent_item_colon: (0, import_i18n72.sprintf)(
37322 /* translators: %s: Singular taxonomy label. */
37323 (0, import_i18n72.__)("Parent %s:"),
37324 singular
37325 ),
37326 add_or_remove_items: (0, import_i18n72.sprintf)(
37327 /* translators: %s: Plural taxonomy label, lowercase. */
37328 (0, import_i18n72.__)("Add or remove %s"),
37329 lcPlural
37330 ),
37331 choose_from_most_used: (0, import_i18n72.sprintf)(
37332 /* translators: %s: Plural taxonomy label, lowercase. */
37333 (0, import_i18n72.__)("Choose from the most used %s"),
37334 lcPlural
37335 )
37336 };
37337 }
37338 function toFormData2(row) {
37339 const config = row.config ?? {};
37340 const labels = pickStoredLabels(
37341 config.labels,
37342 STRING_LABEL_KEYS2
37343 );
37344 const defaultTermName = config.default_term?.name ?? "";
37345 const formConfig = {
37346 labels: { singular_name: "", ...labels },
37347 object_type: Array.isArray(row.object_type) ? row.object_type : [],
37348 description: config.description ?? "",
37349 public: config.public,
37350 hierarchical: config.hierarchical,
37351 publicly_queryable: config.publicly_queryable,
37352 show_ui: config.show_ui,
37353 show_in_menu: config.show_in_menu,
37354 show_in_nav_menus: config.show_in_nav_menus,
37355 show_tagcloud: config.show_tagcloud,
37356 show_in_quick_edit: config.show_in_quick_edit,
37357 show_admin_column: config.show_admin_column,
37358 show_in_rest: config.show_in_rest,
37359 sort: !!config.sort,
37360 default_term_enabled: defaultTermName !== "",
37361 default_term: { name: defaultTermName }
37362 };
37363 return {
37364 id: row.id,
37365 slug: row.slug,
37366 status: row.status,
37367 title: { raw: row.title.raw },
37368 config: formConfig,
37369 count: row.count
37370 };
37371 }
37372 function serializeForSave2(data) {
37373 const { config } = data;
37374 const labels = serializeLabels(
37375 config.labels,
37376 STRING_LABEL_KEYS2
37377 );
37378 const description = config.description.trim();
37379 const defaultTermName = config.default_term.name.trim();
37380 const includeDefaultTerm = config.default_term_enabled && defaultTermName !== "";
37381 return {
37382 ...data.id !== void 0 ? { id: data.id } : {},
37383 slug: data.slug,
37384 status: data.status,
37385 title: data.title.raw,
37386 object_type: config.object_type,
37387 config: {
37388 labels,
37389 public: config.public,
37390 hierarchical: config.hierarchical,
37391 publicly_queryable: config.publicly_queryable,
37392 show_ui: config.show_ui,
37393 show_in_menu: config.show_in_menu,
37394 show_in_nav_menus: config.show_in_nav_menus,
37395 show_tagcloud: config.show_tagcloud,
37396 show_in_quick_edit: config.show_in_quick_edit,
37397 show_admin_column: config.show_admin_column,
37398 show_in_rest: config.show_in_rest,
37399 sort: config.sort,
37400 ...description !== "" ? { description } : {},
37401 ...includeDefaultTerm ? { default_term: { name: defaultTermName } } : {}
37402 }
37403 };
37404 }
37405 function usePublicPostTypes() {
37406 const postTypes = (0, import_data17.useSelect)(
37407 (select2) => select2(import_core_data12.store).getPostTypes({ per_page: -1 }),
37408 []
37409 );
37410 return (0, import_element136.useMemo)(() => {
37411 return postTypes?.filter(({ viewable }) => viewable).sort((a2, b2) => {
37412 if (a2.slug === "post") {
37413 return -1;
37414 }
37415 if (b2.slug === "post") {
37416 return 1;
37417 }
37418 return a2.name.localeCompare(b2.name);
37419 });
37420 }, [postTypes]);
37421 }
37422
37423 // packages/content-types/build-module/taxonomies/fields/general.mjs
37424 var import_jsx_runtime185 = __toESM(require_jsx_runtime(), 1);
37425 var descriptionField2 = createDescriptionField(
37426 (0, import_i18n73.__)(
37427 "Optional summary of the taxonomy. Shown in admin UIs that surface taxonomy details."
37428 )
37429 );
37430 var hierarchicalField2 = createBooleanField(
37431 "hierarchical",
37432 (0, import_i18n73.__)("Hierarchical"),
37433 {
37434 description: (0, import_i18n73.__)(
37435 "When on, terms behave like categories with parent-child relationships. When off, terms behave like tags."
37436 )
37437 }
37438 );
37439 var SLUG_MAX_LENGTH3 = 32;
37440 function useSlugField2(originalSlug, currentValue) {
37441 const registeredTaxonomies = (0, import_data18.useSelect)(
37442 (select2) => select2(import_core_data13.store).getTaxonomies(),
37443 []
37444 );
37445 const showRenameWarning = originalSlug !== void 0 && currentValue !== originalSlug;
37446 return (0, import_element137.useMemo)(
37447 () => ({
37448 id: "slug",
37449 label: (0, import_i18n73.__)("Taxonomy key"),
37450 type: "text",
37451 enableGlobalSearch: true,
37452 description: /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(Stack, { direction: "column", gap: "sm", render: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("span", {}), children: [
37453 showRenameWarning && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(notice_exports.Root, { intent: "warning", render: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("span", {}), children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(notice_exports.Description, { children: (0, import_i18n73.__)(
37454 "Changing the key renames the taxonomy \u2014 existing terms may become inaccessible until a migration updates the database."
37455 ) }) }),
37456 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("span", { children: (0, import_i18n73.__)(
37457 "Lower case letters, numbers, underscores, and dashes only. Maximum length: 32 characters."
37458 ) })
37459 ] }),
37460 isValid: {
37461 required: true,
37462 pattern: "^[a-z0-9_\\-]+$",
37463 maxLength: SLUG_MAX_LENGTH3,
37464 custom: async (value) => {
37465 const slug = value.slug;
37466 if (originalSlug !== void 0 && slug === originalSlug) {
37467 return null;
37468 }
37469 const slugTaken = (registeredTaxonomies ?? []).some(
37470 (t2) => t2.slug === slug
37471 );
37472 if (slugTaken) {
37473 return (0, import_i18n73.__)("This taxonomy key is already in use.");
37474 }
37475 const drafts = await (0, import_data18.resolveSelect)(
37476 import_core_data13.store
37477 ).getEntityRecords("postType", TAXONOMY_ENTITY, {
37478 slug,
37479 status: "draft",
37480 _fields: "id,name",
37481 per_page: 1
37482 });
37483 return drafts?.length ? (0, import_i18n73.__)("This taxonomy key is already in use.") : null;
37484 }
37485 },
37486 Edit: SlugEdit,
37487 filterBy: false,
37488 enableSorting: false
37489 }),
37490 [registeredTaxonomies, originalSlug, showRenameWarning]
37491 );
37492 }
37493 function useObjectTypeField() {
37494 const publicPostTypes = usePublicPostTypes();
37495 return (0, import_element137.useMemo)(() => {
37496 const elements = (publicPostTypes ?? []).map((pt) => ({
37497 value: pt.slug,
37498 label: pt.name
37499 }));
37500 const labelMap = Object.fromEntries(
37501 elements.map((e2) => [e2.value, e2.label])
37502 );
37503 return {
37504 id: "object_type",
37505 label: (0, import_i18n73.__)("Post types"),
37506 type: "array",
37507 description: (0, import_i18n73.__)(
37508 "One or more post types with which the taxonomy should be associated."
37509 ),
37510 elements,
37511 enableSorting: false,
37512 getValue: ({ item }) => item.config.object_type,
37513 setValue: ({ item, value }) => ({
37514 config: {
37515 ...item.config,
37516 object_type: Array.isArray(value) ? value : []
37517 }
37518 }),
37519 render: ({ item }) => {
37520 const slugs = item.config.object_type;
37521 if (!slugs || slugs.length === 0) {
37522 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("span", { "aria-hidden": "true", children: "\u2014" });
37523 }
37524 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
37525 OverflowingBadges,
37526 {
37527 items: slugs.map((s2) => ({
37528 key: s2,
37529 label: labelMap[s2] ?? s2
37530 }))
37531 }
37532 );
37533 },
37534 isValid: { required: true },
37535 filterBy: { operators: ["isAny"] }
37536 };
37537 }, [publicPostTypes]);
37538 }
37539 var countField2 = {
37540 id: "count",
37541 label: (0, import_i18n73.__)("Terms"),
37542 type: "integer",
37543 readOnly: true,
37544 render: ({ item }) => {
37545 const count = item.count;
37546 if (item.status !== "publish" || !count) {
37547 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("span", { "aria-hidden": "true", children: "\u2014" });
37548 }
37549 const postType = item.config.object_type?.[0];
37550 if (!postType) {
37551 return count;
37552 }
37553 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
37554 Link,
37555 {
37556 href: (0, import_url6.addQueryArgs)("edit-tags.php", {
37557 taxonomy: item.slug,
37558 post_type: postType
37559 }),
37560 children: count
37561 }
37562 );
37563 },
37564 enableSorting: false,
37565 filterBy: false
37566 };
37567 var defaultForm2 = {
37568 layout: { type: "regular" },
37569 fields: [
37570 "plural_name",
37571 "singular_name",
37572 "slug",
37573 "object_type",
37574 "hierarchical",
37575 "status"
37576 ]
37577 };
37578 var generalFormFields = [
37579 "plural_name",
37580 "singular_name",
37581 "slug",
37582 "object_type",
37583 "description",
37584 "hierarchical",
37585 "status"
37586 ];
37587
37588 // packages/content-types/build-module/taxonomies/actions/duplicate.mjs
37589 var import_jsx_runtime186 = __toESM(require_jsx_runtime(), 1);
37590 var SLUG_MAX_LENGTH4 = 32;
37591 var duplicateForm2 = {
37592 layout: { type: "regular" },
37593 fields: ["plural_name", "singular_name", "slug"]
37594 };
37595 function buildCopySlug2(slug) {
37596 const match2 = slug.match(/^(.*?)(\d+)$/);
37597 const base = match2 ? match2[1] : slug;
37598 const nextNumber = String(match2 ? parseInt(match2[2], 10) + 1 : 2);
37599 return `${base.slice(
37600 0,
37601 SLUG_MAX_LENGTH4 - nextNumber.length
37602 )}${nextNumber}`;
37603 }
37604 function DuplicateTaxonomyModal({
37605 items,
37606 closeModal,
37607 onActionPerformed
37608 }) {
37609 const source = items[0];
37610 const [data, setData] = (0, import_element138.useState)(() => ({
37611 ...source,
37612 id: void 0,
37613 status: "draft",
37614 title: {
37615 raw: (0, import_i18n74.sprintf)(
37616 /* translators: %s: existing taxonomy title. */
37617 (0, import_i18n74._x)("%s (Copy)", "taxonomy"),
37618 source.title.raw
37619 )
37620 },
37621 slug: buildCopySlug2(source.slug)
37622 }));
37623 const [isDuplicating, setIsDuplicating] = (0, import_element138.useState)(false);
37624 const slugField = useSlugField2(void 0, data.slug);
37625 const fields = (0, import_element138.useMemo)(
37626 () => [
37627 pluralLabelField,
37628 singularLabelField,
37629 slugField
37630 ],
37631 [slugField]
37632 );
37633 const { validity, isValid: isValid2 } = use_form_validity_default(
37634 data,
37635 fields,
37636 duplicateForm2
37637 );
37638 const { saveEntityRecord } = (0, import_data19.useDispatch)(import_core_data14.store);
37639 const { createSuccessNotice, createErrorNotice } = (0, import_data19.useDispatch)(import_notices7.store);
37640 async function onDuplicate() {
37641 if (isDuplicating || !isValid2) {
37642 return;
37643 }
37644 setIsDuplicating(true);
37645 try {
37646 await saveEntityRecord(
37647 "postType",
37648 TAXONOMY_ENTITY,
37649 serializeForSave2(data),
37650 { throwOnError: true }
37651 );
37652 createSuccessNotice(
37653 (0, import_i18n74.sprintf)(
37654 /* translators: %s: taxonomy plural label. */
37655 (0, import_i18n74.__)('"%s" taxonomy created.'),
37656 data.title.raw
37657 ),
37658 { type: "snackbar" }
37659 );
37660 onActionPerformed?.(items);
37661 closeModal?.();
37662 } catch (error2) {
37663 const typedError = error2;
37664 createErrorNotice(
37665 typedError?.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n74.__)("Failed to duplicate taxonomy."),
37666 { type: "snackbar" }
37667 );
37668 } finally {
37669 setIsDuplicating(false);
37670 }
37671 }
37672 return /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(Stack, { direction: "column", gap: "md", children: [
37673 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
37674 DataForm,
37675 {
37676 data,
37677 fields,
37678 form: duplicateForm2,
37679 validity,
37680 onChange: (edits) => setData(
37681 (prev) => ({ ...prev, ...edits })
37682 )
37683 }
37684 ),
37685 /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(Stack, { direction: "row", justify: "flex-end", gap: "sm", children: [
37686 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
37687 import_components61.Button,
37688 {
37689 __next40pxDefaultSize: true,
37690 variant: "tertiary",
37691 onClick: closeModal,
37692 disabled: isDuplicating,
37693 accessibleWhenDisabled: true,
37694 children: (0, import_i18n74.__)("Cancel")
37695 }
37696 ),
37697 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
37698 import_components61.Button,
37699 {
37700 __next40pxDefaultSize: true,
37701 variant: "primary",
37702 isBusy: isDuplicating,
37703 disabled: isDuplicating || !isValid2,
37704 accessibleWhenDisabled: true,
37705 onClick: onDuplicate,
37706 children: (0, import_i18n74._x)("Duplicate", "action label")
37707 }
37708 )
37709 ] })
37710 ] });
37711 }
37712 var duplicateTaxonomyAction = {
37713 id: "duplicate-taxonomy",
37714 label: (0, import_i18n74._x)("Duplicate", "action label"),
37715 icon: copy_default,
37716 modalHeader: (0, import_i18n74.__)("Duplicate taxonomy"),
37717 modalFocusOnMount: "firstContentElement",
37718 RenderModal: DuplicateTaxonomyModal
37719 };
37720 var duplicate_default2 = duplicateTaxonomyAction;
37721
37722 // packages/content-types/build-module/taxonomies/actions/view-terms.mjs
37723 var import_i18n75 = __toESM(require_i18n(), 1);
37724 var import_url7 = __toESM(require_url(), 1);
37725 var viewTermsAction = {
37726 id: "view-terms",
37727 label: (0, import_i18n75.__)("View terms"),
37728 // Drafts aren't registered, and `edit-tags.php` requires a `post_type`
37729 // query arg to render the term list, so the taxonomy must also be
37730 // attached to at least one post type.
37731 isEligible: (item) => item.status === "publish" && Array.isArray(item.config.object_type) && item.config.object_type.length > 0,
37732 callback: (items, { onActionPerformed }) => {
37733 const item = items[0];
37734 const postType = item?.config.object_type?.[0];
37735 if (!item?.slug || !postType) {
37736 return;
37737 }
37738 document.location.href = (0, import_url7.addQueryArgs)("edit-tags.php", {
37739 taxonomy: item.slug,
37740 post_type: postType
37741 });
37742 onActionPerformed?.(items);
37743 }
37744 };
37745 var view_terms_default = viewTermsAction;
37746
37747 // packages/content-types/build-module/taxonomies/fields/advanced.mjs
37748 var import_i18n76 = __toESM(require_i18n(), 1);
37749 var sortField = createBooleanField("sort", (0, import_i18n76.__)("Sort terms"), {
37750 description: (0, import_i18n76.__)(
37751 "Whether terms in this taxonomy should be saved in the order they are assigned to an item."
37752 )
37753 });
37754 var defaultTermEnabledField = createBooleanField(
37755 "default_term_enabled",
37756 (0, import_i18n76.__)("Set a default term"),
37757 {
37758 description: (0, import_i18n76.__)(
37759 'Default term to be used for the taxonomy, similar to how "Uncategorized" works for categories.'
37760 )
37761 }
37762 );
37763 var defaultTermNameField = {
37764 id: "default_term_name",
37765 label: (0, import_i18n76.__)("Default term name"),
37766 type: "text",
37767 description: (0, import_i18n76.__)(
37768 "Once saved, updating the name creates a new term \u2014 the previous default term remains in the terms list. To change the term's slug or description, edit it from the terms list."
37769 ),
37770 getValue: ({ item }) => item.config.default_term.name,
37771 setValue: ({ item, value }) => ({
37772 config: {
37773 ...item.config,
37774 default_term: { name: String(value ?? "") }
37775 }
37776 }),
37777 isValid: {
37778 // `useFormValidity` does not skip invisible fields, so `required:
37779 // true` would mark the form invalid whenever the toggle is off.
37780 // Gate the requirement on the toggle via `custom` instead.
37781 custom: (item) => {
37782 if (!item.config.default_term_enabled) {
37783 return null;
37784 }
37785 return item.config.default_term.name.trim() ? null : (0, import_i18n76.__)("A default term name is required.");
37786 },
37787 // Mirrors `wp_terms.name` column width (varchar(200)).
37788 maxLength: 200
37789 },
37790 isVisible: (item) => item.config.default_term_enabled,
37791 enableSorting: false,
37792 filterBy: false
37793 };
37794 var advancedFormFields = [
37795 "sort",
37796 "default_term_enabled",
37797 "default_term_name"
37798 ];
37799
37800 // packages/content-types/build-module/taxonomies/fields/labels.mjs
37801 var import_i18n77 = __toESM(require_i18n(), 1);
37802 var menuNameField2 = createLabelField("menu_name", (0, import_i18n77.__)("Menu name"), {
37803 placeholder: (0, import_i18n77.__)("Categories"),
37804 description: (0, import_i18n77.__)("Defaults to the plural label.")
37805 });
37806 var allItemsField2 = createLabelField("all_items", (0, import_i18n77.__)("All items"), {
37807 placeholder: (0, import_i18n77.__)("All Categories")
37808 });
37809 var editItemField2 = createLabelField("edit_item", (0, import_i18n77.__)("Edit item"), {
37810 placeholder: (0, import_i18n77.__)("Edit Category")
37811 });
37812 var viewItemField2 = createLabelField("view_item", (0, import_i18n77.__)("View item"), {
37813 placeholder: (0, import_i18n77.__)("View Category")
37814 });
37815 var updateItemField = createLabelField(
37816 "update_item",
37817 (0, import_i18n77.__)("Update item"),
37818 { placeholder: (0, import_i18n77.__)("Update Category") }
37819 );
37820 var addNewItemLabelField2 = createLabelField(
37821 "add_new_item",
37822 (0, import_i18n77.__)("Add new item"),
37823 { placeholder: (0, import_i18n77.__)("Add New Category") }
37824 );
37825 var newItemNameField = createLabelField(
37826 "new_item_name",
37827 (0, import_i18n77.__)("New item name"),
37828 { placeholder: (0, import_i18n77.__)("New Category Name") }
37829 );
37830 var searchItemsField2 = createLabelField(
37831 "search_items",
37832 (0, import_i18n77.__)("Search items"),
37833 { placeholder: (0, import_i18n77.__)("Search Categories") }
37834 );
37835 var notFoundField2 = createLabelField("not_found", (0, import_i18n77.__)("Not found"), {
37836 placeholder: (0, import_i18n77.__)("No categories found."),
37837 description: (0, import_i18n77.__)(
37838 "The text displayed when no terms are available in the term meta box and tag cloud."
37839 )
37840 });
37841 var backToItemsField = createLabelField(
37842 "back_to_items",
37843 (0, import_i18n77.__)("Back to items"),
37844 {
37845 placeholder: (0, import_i18n77.__)("\u2190 Back to Categories"),
37846 description: (0, import_i18n77.__)("Label displayed after a term has been updated.")
37847 }
37848 );
37849 var parentItemField = createLabelField(
37850 "parent_item",
37851 (0, import_i18n77.__)("Parent item"),
37852 {
37853 placeholder: (0, import_i18n77.__)("Parent Category"),
37854 description: (0, import_i18n77.__)("Not used on non-hierarchical taxonomies."),
37855 isVisible: (item) => item.config.hierarchical
37856 }
37857 );
37858 var popularItemsField = createLabelField(
37859 "popular_items",
37860 (0, import_i18n77.__)("Popular items"),
37861 {
37862 placeholder: (0, import_i18n77.__)("Popular Tags"),
37863 description: (0, import_i18n77.__)(
37864 "The popular items text. Not used on hierarchical taxonomies."
37865 ),
37866 isVisible: (item) => !item.config.hierarchical
37867 }
37868 );
37869 var separateItemsField = createLabelField(
37870 "separate_items_with_commas",
37871 (0, import_i18n77.__)("Separate items with commas"),
37872 {
37873 placeholder: (0, import_i18n77.__)("Separate tags with commas"),
37874 description: (0, import_i18n77.__)(
37875 "Shown in the taxonomy meta box. Not used on hierarchical taxonomies."
37876 ),
37877 isVisible: (item) => !item.config.hierarchical
37878 }
37879 );
37880 var parentItemColonField2 = createLabelField(
37881 "parent_item_colon",
37882 (0, import_i18n77.__)("Parent item with colon"),
37883 {
37884 placeholder: (0, import_i18n77.__)("Parent Category:"),
37885 description: (0, import_i18n77.__)("Same as Parent item, with a colon at the end."),
37886 isVisible: (item) => item.config.hierarchical
37887 }
37888 );
37889 var addOrRemoveItemsField = createLabelField(
37890 "add_or_remove_items",
37891 (0, import_i18n77.__)("Add or remove items"),
37892 {
37893 placeholder: (0, import_i18n77.__)("Add or remove tags"),
37894 description: (0, import_i18n77.__)(
37895 "Shown in the meta box when JavaScript is disabled. Not used on hierarchical taxonomies."
37896 ),
37897 isVisible: (item) => !item.config.hierarchical
37898 }
37899 );
37900 var chooseFromMostUsedField = createLabelField(
37901 "choose_from_most_used",
37902 (0, import_i18n77.__)("Choose from the most used"),
37903 {
37904 placeholder: (0, import_i18n77.__)("Choose from the most used tags"),
37905 description: (0, import_i18n77.__)(
37906 "Shown in the taxonomy meta box. Not used on hierarchical taxonomies."
37907 ),
37908 isVisible: (item) => !item.config.hierarchical
37909 }
37910 );
37911 var labelsActionsField2 = createLabelsActionsField(
37912 {
37913 labelKeys: STRING_LABEL_KEYS2,
37914 deriveLabels: deriveLabels2,
37915 helpText: (0, import_i18n77.__)(
37916 "Override the text WordPress shows in admin lists, menus, and forms. Auto-fill replaces every label below with values derived from the current plural and singular names \u2014 including any you have already customized. Clearing removes all overrides so WordPress falls back to its defaults. If you rename the taxonomy after auto-filling, click Auto-fill again to keep them in sync."
37917 )
37918 }
37919 );
37920 var labelsFormFields = [
37921 {
37922 id: LABELS_ACTIONS_FIELD_ID,
37923 layout: { type: "regular", labelPosition: "none" }
37924 },
37925 // singular_name lives in the General card, so exclude it here.
37926 ...STRING_LABEL_KEYS2.filter((key) => key !== "singular_name")
37927 ];
37928
37929 // packages/content-types/build-module/taxonomies/fields/visibility.mjs
37930 var import_i18n78 = __toESM(require_i18n(), 1);
37931 var publicField2 = createBooleanField("public", (0, import_i18n78.__)("Public"), {
37932 description: (0, import_i18n78.__)(
37933 "Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users."
37934 )
37935 });
37936 var showInRestField2 = createBooleanField(
37937 "show_in_rest",
37938 (0, import_i18n78.__)("Show in REST API"),
37939 {
37940 description: (0, import_i18n78.__)(
37941 "Required for the block editor. Turn off only for taxonomies that should not be exposed via REST."
37942 )
37943 }
37944 );
37945 var publiclyQueryableField = createBooleanField(
37946 "publicly_queryable",
37947 (0, import_i18n78.__)("Publicly queryable"),
37948 {
37949 description: (0, import_i18n78.__)(
37950 "Whether front-end queries (e.g. ?taxonomy=\u2026&term=\u2026) can return terms from this taxonomy."
37951 )
37952 }
37953 );
37954 var showUiField = createBooleanField(
37955 "show_ui",
37956 (0, import_i18n78.__)("Show admin UI"),
37957 {
37958 description: (0, import_i18n78.__)(
37959 "Whether to generate a default admin interface for managing terms."
37960 )
37961 }
37962 );
37963 var showInMenuField = createBooleanField(
37964 "show_in_menu",
37965 (0, import_i18n78.__)("Show in admin menu"),
37966 {
37967 description: (0, import_i18n78.__)(
37968 "Whether to show the taxonomy in the admin menu. Has no effect when Show admin UI is off; the value is preserved either way."
37969 ),
37970 // Hide when `show_ui` is off — `show_in_menu` is silently ignored by
37971 // register_taxonomy() in that case, so showing the toggle would be
37972 // misleading. The stored value is preserved across the toggle.
37973 isVisible: (item) => item.config.show_ui
37974 }
37975 );
37976 var showInQuickEditField = createBooleanField(
37977 "show_in_quick_edit",
37978 (0, import_i18n78.__)("Show in Quick Edit"),
37979 {
37980 description: (0, import_i18n78.__)(
37981 "Whether to show the taxonomy in the Quick/Bulk Edit panel."
37982 )
37983 }
37984 );
37985 var showAdminColumnField = createBooleanField(
37986 "show_admin_column",
37987 (0, import_i18n78.__)("Show admin column"),
37988 {
37989 description: (0, import_i18n78.__)(
37990 "Whether to display a column for the taxonomy on the associated post type list tables."
37991 )
37992 }
37993 );
37994 var showInNavMenusField = createBooleanField(
37995 "show_in_nav_menus",
37996 (0, import_i18n78.__)("Available in nav menus"),
37997 {
37998 description: (0, import_i18n78.__)(
37999 "Whether terms are selectable in the theme nav menu builder."
38000 )
38001 }
38002 );
38003 var showTagcloudField = createBooleanField(
38004 "show_tagcloud",
38005 (0, import_i18n78.__)("Available in Tag Cloud widget"),
38006 {
38007 description: (0, import_i18n78.__)(
38008 "Whether terms can be displayed in the Tag Cloud widget."
38009 )
38010 }
38011 );
38012 var visibilityFormFields = [
38013 "public",
38014 "show_in_rest",
38015 "publicly_queryable",
38016 "show_ui",
38017 "show_in_menu",
38018 "show_in_quick_edit",
38019 "show_in_nav_menus",
38020 "show_tagcloud",
38021 "show_admin_column"
38022 ];
38023
38024 // packages/content-types/build-module/taxonomies/actions/edit.mjs
38025 var import_element139 = __toESM(require_element(), 1);
38026 var import_i18n79 = __toESM(require_i18n(), 1);
38027 import { useNavigate as useNavigate5 } from "@wordpress/route";
38028 function useEditTaxonomyAction() {
38029 const navigate = useNavigate5();
38030 return (0, import_element139.useMemo)(
38031 () => ({
38032 id: "edit-taxonomy",
38033 label: (0, import_i18n79.__)("Edit"),
38034 callback: (items) => {
38035 const item = items[0];
38036 if (item?.id === void 0) {
38037 return;
38038 }
38039 navigate({
38040 to: `${TAXONOMIES_PATH}/${item.id}`
38041 });
38042 }
38043 }),
38044 [navigate]
38045 );
38046 }
38047
38048 // packages/content-types/build-module/taxonomies/actions/quick-edit.mjs
38049 var import_components62 = __toESM(require_components(), 1);
38050 var import_core_data15 = __toESM(require_core_data(), 1);
38051 var import_data20 = __toESM(require_data(), 1);
38052 var import_element140 = __toESM(require_element(), 1);
38053 var import_i18n80 = __toESM(require_i18n(), 1);
38054 var import_notices8 = __toESM(require_notices(), 1);
38055 var import_jsx_runtime187 = __toESM(require_jsx_runtime(), 1);
38056 function QuickEditTaxonomyModal({
38057 items,
38058 closeModal
38059 }) {
38060 const item = items[0];
38061 const [data, setData] = (0, import_element140.useState)(item);
38062 const [isSaving, setIsSaving] = (0, import_element140.useState)(false);
38063 const slugField = useSlugField2(item.slug, data.slug);
38064 const objectTypeField = useObjectTypeField();
38065 const fields = (0, import_element140.useMemo)(
38066 () => [
38067 pluralLabelField,
38068 singularLabelField,
38069 slugField,
38070 objectTypeField,
38071 publicField2,
38072 hierarchicalField2,
38073 statusField
38074 ],
38075 [slugField, objectTypeField]
38076 );
38077 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, defaultForm2);
38078 const { saveEntityRecord } = (0, import_data20.useDispatch)(import_core_data15.store);
38079 const { createSuccessNotice, createErrorNotice } = (0, import_data20.useDispatch)(import_notices8.store);
38080 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
38081 async function onSave() {
38082 if (isSaving || !isValid2) {
38083 return;
38084 }
38085 setIsSaving(true);
38086 try {
38087 await saveEntityRecord(
38088 "postType",
38089 TAXONOMY_ENTITY,
38090 serializeForSave2({ ...data, id: item.id }),
38091 { throwOnError: true }
38092 );
38093 createSuccessNotice(
38094 (0, import_i18n80.sprintf)(
38095 /* translators: %s: taxonomy plural label. */
38096 (0, import_i18n80.__)('"%s" taxonomy updated.'),
38097 data.title.raw
38098 ),
38099 { type: "snackbar" }
38100 );
38101 maybeInvalidateCache(
38102 item.config.object_type,
38103 data.config.object_type,
38104 POST_TYPE_ENTITY
38105 );
38106 closeModal?.();
38107 } catch (error2) {
38108 createErrorNotice(
38109 error2?.message && error2?.code !== "unknown_error" ? error2.message : (0, import_i18n80.__)("Failed to update taxonomy."),
38110 { type: "snackbar" }
38111 );
38112 } finally {
38113 setIsSaving(false);
38114 }
38115 }
38116 return /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(
38117 "form",
38118 {
38119 onSubmit: (event) => {
38120 event.preventDefault();
38121 onSave();
38122 },
38123 children: [
38124 /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(
38125 Stack,
38126 {
38127 className: "dataviews-action-modal__quick-edit-taxonomy-header",
38128 direction: "row",
38129 justify: "space-between",
38130 align: "center",
38131 children: [
38132 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Text, { variant: "heading-sm", render: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)("h2", {}), children: (0, import_i18n80.__)("Quick edit taxonomy") }),
38133 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
38134 import_components62.Button,
38135 {
38136 size: "small",
38137 icon: close_small_default,
38138 label: (0, import_i18n80.__)("Close"),
38139 onClick: closeModal
38140 }
38141 )
38142 ]
38143 }
38144 ),
38145 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)("div", { className: "dataviews-action-modal__quick-edit-taxonomy-content", children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
38146 DataForm,
38147 {
38148 data,
38149 fields,
38150 form: defaultForm2,
38151 validity,
38152 onChange: (edits) => setData(
38153 (prev) => ({ ...prev, ...edits })
38154 )
38155 }
38156 ) }),
38157 /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(
38158 Stack,
38159 {
38160 className: "dataviews-action-modal__quick-edit-taxonomy-footer",
38161 direction: "row",
38162 gap: "sm",
38163 children: [
38164 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
38165 import_components62.Button,
38166 {
38167 __next40pxDefaultSize: true,
38168 variant: "secondary",
38169 onClick: closeModal,
38170 children: (0, import_i18n80.__)("Cancel")
38171 }
38172 ),
38173 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
38174 import_components62.Button,
38175 {
38176 __next40pxDefaultSize: true,
38177 variant: "primary",
38178 type: "submit",
38179 isBusy: isSaving,
38180 disabled: isSaving || !isValid2,
38181 accessibleWhenDisabled: true,
38182 children: (0, import_i18n80.__)("Done")
38183 }
38184 )
38185 ]
38186 }
38187 )
38188 ]
38189 }
38190 );
38191 }
38192 var quickEditTaxonomyAction = {
38193 id: "quick-edit-taxonomy",
38194 label: (0, import_i18n80.__)("Quick edit"),
38195 icon: pencil_default,
38196 isPrimary: true,
38197 hideModalHeader: true,
38198 RenderModal: QuickEditTaxonomyModal
38199 };
38200 var quick_edit_default2 = quickEditTaxonomyAction;
38201
38202 // packages/content-types/build-module/taxonomies/list.mjs
38203 var import_jsx_runtime188 = __toESM(require_jsx_runtime(), 1);
38204 var defaultLayouts2 = {
38205 table: {}
38206 };
38207 var DEFAULT_VIEW2 = {
38208 type: "table",
38209 perPage: 20,
38210 page: 1,
38211 fields: ["object_type", "count", "status"],
38212 titleField: "title",
38213 layout: {
38214 styles: {
38215 object_type: { minWidth: 230 }
38216 }
38217 }
38218 };
38219 function TaxonomiesList() {
38220 const navigate = useNavigate6();
38221 const searchParams = useSearch2({ from: TAXONOMIES_PATH });
38222 const handleQueryParamsChange = (0, import_element141.useCallback)(
38223 (params) => {
38224 navigate({
38225 search: {
38226 ...searchParams,
38227 ...params
38228 }
38229 });
38230 },
38231 [searchParams, navigate]
38232 );
38233 const { view, updateView, isModified, resetToDefault } = useView({
38234 kind: "postType",
38235 name: TAXONOMY_ENTITY,
38236 slug: "default",
38237 defaultView: DEFAULT_VIEW2,
38238 queryParams: searchParams,
38239 onChangeQueryParams: handleQueryParamsChange
38240 });
38241 const editAction = useEditTaxonomyAction();
38242 const taxonomyActions = (0, import_element141.useMemo)(
38243 () => [
38244 editAction,
38245 quick_edit_default2,
38246 duplicate_default2,
38247 view_terms_default,
38248 activate_default2,
38249 deactivate_default2,
38250 delete_default2
38251 ],
38252 [editAction]
38253 );
38254 const slugField = useSlugField2();
38255 const objectTypeField = useObjectTypeField();
38256 const fields = (0, import_element141.useMemo)(
38257 () => [
38258 titleField,
38259 objectTypeField,
38260 countField2,
38261 statusField,
38262 publicField2,
38263 slugField,
38264 hierarchicalField2
38265 ],
38266 [slugField, objectTypeField]
38267 );
38268 const queryArgs = (0, import_element141.useMemo)(() => {
38269 const statusFilter = view.filters?.find(
38270 (filter) => filter.field === "status"
38271 );
38272 const objectTypeFilter = view.filters?.find(
38273 (filter) => filter.field === "object_type"
38274 );
38275 return {
38276 per_page: view.perPage,
38277 page: view.page,
38278 context: "edit",
38279 order: view.sort?.direction,
38280 orderby: view.sort?.field,
38281 search: view.search,
38282 status: statusFilter?.value ?? ["publish", "draft"],
38283 object_type: objectTypeFilter?.value
38284 };
38285 }, [view]);
38286 const { records, isResolving, hasResolved, totalItems, totalPages } = (0, import_core_data16.useEntityRecords)(
38287 "postType",
38288 TAXONOMY_ENTITY,
38289 queryArgs
38290 );
38291 const data = (0, import_element141.useMemo)(
38292 () => (records ?? []).map(toFormData2),
38293 [records]
38294 );
38295 const paginationInfo = (0, import_element141.useMemo)(
38296 () => ({
38297 totalItems: totalItems ?? 0,
38298 totalPages: totalPages ?? 0
38299 }),
38300 [totalItems, totalPages]
38301 );
38302 return /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
38303 dataviews_default,
38304 {
38305 data,
38306 fields,
38307 actions: taxonomyActions,
38308 view,
38309 onChangeView: updateView,
38310 onReset: isModified ? resetToDefault : false,
38311 isLoading: isResolving || !hasResolved,
38312 paginationInfo,
38313 defaultLayouts: defaultLayouts2,
38314 getItemId: (item) => String(item.id),
38315 isItemClickable: () => true,
38316 onClickItem: (item) => navigate({
38317 to: `${TAXONOMIES_PATH}/${item.id}`
38318 }),
38319 header: /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
38320 import_components63.Button,
38321 {
38322 variant: "primary",
38323 size: "compact",
38324 __next40pxDefaultSize: true,
38325 onClick: () => navigate({
38326 to: `${TAXONOMIES_PATH}/${NEW_ID}`
38327 }),
38328 children: (0, import_i18n81.__)("Add taxonomy")
38329 }
38330 )
38331 }
38332 );
38333 }
38334
38335 // packages/content-types/build-module/taxonomies/edit.mjs
38336 var import_components64 = __toESM(require_components(), 1);
38337 var import_compose19 = __toESM(require_compose(), 1);
38338 var import_core_data17 = __toESM(require_core_data(), 1);
38339 var import_data21 = __toESM(require_data(), 1);
38340 var import_element142 = __toESM(require_element(), 1);
38341 var import_i18n82 = __toESM(require_i18n(), 1);
38342 var import_notices9 = __toESM(require_notices(), 1);
38343 import { useNavigate as useNavigate7, useParams as useParams2 } from "@wordpress/route";
38344 var import_jsx_runtime189 = __toESM(require_jsx_runtime(), 1);
38345 function TaxonomyEdit() {
38346 const { id } = useParams2({ from: `${TAXONOMIES_PATH}/$id` });
38347 const navigate = useNavigate7();
38348 const isAddMode = id === NEW_ID;
38349 const taxonomyId = parseInt(id, 10);
38350 const record = (0, import_data21.useSelect)(
38351 (select2) => {
38352 return !isAddMode && // beforeLoad (route.ts) guarantees the record is in cache.
38353 select2(import_core_data17.store).getEntityRecord(
38354 "postType",
38355 TAXONOMY_ENTITY,
38356 taxonomyId
38357 );
38358 },
38359 [isAddMode, taxonomyId]
38360 );
38361 const initialData = !isAddMode && record ? toFormData2(record) : BLANK_RECORD2;
38362 const title = isAddMode ? (0, import_i18n82.__)("Add taxonomy") : initialData.title.raw;
38363 const commonProps = { initialData, title };
38364 const taxonomyPageProps = isAddMode ? {
38365 ...commonProps,
38366 isAddMode: true,
38367 breadcrumbLabel: (0, import_i18n82.__)("Add new"),
38368 subTitle: (0, import_i18n82.__)(
38369 "Define a new taxonomy. Fill in the essentials under General; expand Labels to customize."
38370 ),
38371 onSaved: (saved) => navigate({
38372 to: `${TAXONOMIES_PATH}/${saved.id}`
38373 })
38374 } : {
38375 ...commonProps,
38376 isAddMode: false,
38377 breadcrumbLabel: title,
38378 subTitle: (0, import_i18n82.__)(
38379 "Edit this taxonomy. Expand the Labels section to adjust labels."
38380 )
38381 };
38382 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(TaxonomyPage, { ...taxonomyPageProps }, id);
38383 }
38384 function TaxonomyPage({
38385 isAddMode,
38386 initialData,
38387 title,
38388 breadcrumbLabel,
38389 subTitle,
38390 onSaved
38391 }) {
38392 const [data, setData] = (0, import_element142.useState)(initialData);
38393 const [isSaving, setIsSaving] = (0, import_element142.useState)(false);
38394 const originalSlug = !isAddMode ? initialData.slug : void 0;
38395 const slugField = useSlugField2(originalSlug, data.slug);
38396 const objectTypeField = useObjectTypeField();
38397 const fields = (0, import_element142.useMemo)(
38398 () => [
38399 // General
38400 pluralLabelField,
38401 singularLabelField,
38402 slugField,
38403 descriptionField2,
38404 objectTypeField,
38405 hierarchicalField2,
38406 statusField,
38407 // Visibility
38408 publicField2,
38409 showInRestField2,
38410 publiclyQueryableField,
38411 showUiField,
38412 showInMenuField,
38413 showInQuickEditField,
38414 showAdminColumnField,
38415 showInNavMenusField,
38416 showTagcloudField,
38417 // Labels
38418 labelsActionsField2,
38419 menuNameField2,
38420 allItemsField2,
38421 editItemField2,
38422 viewItemField2,
38423 updateItemField,
38424 addNewItemLabelField2,
38425 newItemNameField,
38426 searchItemsField2,
38427 notFoundField2,
38428 backToItemsField,
38429 parentItemField,
38430 popularItemsField,
38431 separateItemsField,
38432 parentItemColonField2,
38433 addOrRemoveItemsField,
38434 chooseFromMostUsedField,
38435 // Advanced
38436 sortField,
38437 defaultTermEnabledField,
38438 defaultTermNameField
38439 ],
38440 [slugField, objectTypeField]
38441 );
38442 const form = (0, import_element142.useMemo)(
38443 () => ({
38444 layout: { type: "card", isCollapsible: true },
38445 fields: [
38446 {
38447 id: "general",
38448 label: (0, import_i18n82.__)("General"),
38449 description: (0, import_i18n82.__)(
38450 "Core identity, post types, and activation."
38451 ),
38452 layout: {
38453 type: "card",
38454 isCollapsible: true,
38455 isOpened: true
38456 },
38457 children: generalFormFields
38458 },
38459 {
38460 id: "visibility",
38461 label: (0, import_i18n82.__)("Visibility"),
38462 description: (0, import_i18n82.__)(
38463 "Where this taxonomy appears: REST API, admin UI, and front-end surfaces."
38464 ),
38465 layout: {
38466 type: "card",
38467 isCollapsible: true,
38468 isOpened: false
38469 },
38470 children: visibilityFormFields
38471 },
38472 {
38473 id: "labels",
38474 label: (0, import_i18n82.__)("Labels"),
38475 layout: {
38476 type: "card",
38477 isCollapsible: true,
38478 isOpened: false
38479 },
38480 children: labelsFormFields
38481 },
38482 {
38483 id: "advanced",
38484 label: (0, import_i18n82.__)("Advanced"),
38485 layout: {
38486 type: "card",
38487 isCollapsible: true,
38488 isOpened: false
38489 },
38490 children: advancedFormFields
38491 }
38492 ]
38493 }),
38494 []
38495 );
38496 const { validity, isValid: isValid2 } = use_form_validity_default(data, fields, form);
38497 const formId = (0, import_compose19.useInstanceId)(TaxonomyPage, "taxonomy-form");
38498 const { saveEntityRecord } = (0, import_data21.useDispatch)(import_core_data17.store);
38499 const { createSuccessNotice, createErrorNotice } = (0, import_data21.useDispatch)(import_notices9.store);
38500 const maybeInvalidateCache = useMaybeInvalidateContentTypeCache();
38501 async function onSave() {
38502 if (isSaving || !isValid2) {
38503 return;
38504 }
38505 setIsSaving(true);
38506 try {
38507 const saved = await saveEntityRecord(
38508 "postType",
38509 TAXONOMY_ENTITY,
38510 serializeForSave2(data),
38511 { throwOnError: true }
38512 );
38513 const successMessage = isAddMode ? (0, import_i18n82.sprintf)(
38514 /* translators: %s: taxonomy plural label. */
38515 (0, import_i18n82.__)('"%s" taxonomy created.'),
38516 data.title.raw
38517 ) : (0, import_i18n82.sprintf)(
38518 /* translators: %s: taxonomy plural label. */
38519 (0, import_i18n82.__)('"%s" taxonomy updated.'),
38520 data.title.raw
38521 );
38522 createSuccessNotice(successMessage, { type: "snackbar" });
38523 maybeInvalidateCache(
38524 initialData.config.object_type,
38525 data.config.object_type,
38526 POST_TYPE_ENTITY
38527 );
38528 if (saved?.id !== void 0) {
38529 onSaved?.({ ...data, id: saved.id });
38530 }
38531 } catch (error2) {
38532 let errorMessage;
38533 if (error2?.message && error2?.code !== "unknown_error") {
38534 errorMessage = error2.message;
38535 } else if (isAddMode) {
38536 errorMessage = (0, import_i18n82.__)("Failed to create taxonomy.");
38537 } else {
38538 errorMessage = (0, import_i18n82.__)("Failed to update taxonomy.");
38539 }
38540 createErrorNotice(errorMessage, { type: "snackbar" });
38541 } finally {
38542 setIsSaving(false);
38543 }
38544 }
38545 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
38546 page_default,
38547 {
38548 ariaLabel: title,
38549 breadcrumbs: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
38550 breadcrumbs_default,
38551 {
38552 items: [
38553 { label: (0, import_i18n82.__)("Taxonomies"), to: TAXONOMIES_PATH },
38554 { label: breadcrumbLabel }
38555 ]
38556 }
38557 ),
38558 subTitle,
38559 actions: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
38560 import_components64.Button,
38561 {
38562 __next40pxDefaultSize: true,
38563 variant: "primary",
38564 size: "compact",
38565 type: "submit",
38566 form: formId,
38567 isBusy: isSaving,
38568 disabled: isSaving || !isValid2,
38569 accessibleWhenDisabled: true,
38570 children: isAddMode ? (0, import_i18n82.__)("Create") : (0, import_i18n82.__)("Save")
38571 }
38572 ),
38573 children: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
38574 Stack,
38575 {
38576 direction: "column",
38577 gap: "md",
38578 className: "taxonomy-form",
38579 render: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
38580 "form",
38581 {
38582 id: formId,
38583 onSubmit: (event) => {
38584 event.preventDefault();
38585 onSave();
38586 }
38587 }
38588 ),
38589 children: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
38590 DataForm,
38591 {
38592 data,
38593 fields,
38594 form,
38595 validity,
38596 onChange: (edits) => setData(
38597 (prev) => ({
38598 ...prev,
38599 ...edits
38600 })
38601 )
38602 }
38603 )
38604 }
38605 )
38606 }
38607 );
38608 }
38609 export {
38610 Layout,
38611 NEW_ID,
38612 POST_TYPES_PATH,
38613 POST_TYPE_ENTITY,
38614 PostTypeEdit,
38615 PostTypesList,
38616 TAXONOMIES_PATH,
38617 TAXONOMY_ENTITY,
38618 TaxonomiesList,
38619 TaxonomyEdit
38620 };
38621 /*! Bundled license information:
38622
38623 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
38624 (**
38625 * @license React
38626 * use-sync-external-store-shim.development.js
38627 *
38628 * Copyright (c) Meta Platforms, Inc. and affiliates.
38629 *
38630 * This source code is licensed under the MIT license found in the
38631 * LICENSE file in the root directory of this source tree.
38632 *)
38633
38634 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
38635 (**
38636 * @license React
38637 * use-sync-external-store-shim/with-selector.development.js
38638 *
38639 * Copyright (c) Meta Platforms, Inc. and affiliates.
38640 *
38641 * This source code is licensed under the MIT license found in the
38642 * LICENSE file in the root directory of this source tree.
38643 *)
38644
38645 tabbable/dist/index.esm.js:
38646 (*!
38647 * tabbable 6.4.0
38648 * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
38649 *)
38650 */
38651 //# sourceMappingURL=index.js.map
38652