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 / scripts / edit-post / index.js

index.js in Gutenberg 23.3.2, at build/scripts/edit-post/index.js

11,683 lines 430.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var wp;
2 (wp ||= {}).editPost = (() => {
3 var __create = Object.create;
4 var __defProp = Object.defineProperty;
5 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6 var __getOwnPropNames = Object.getOwnPropertyNames;
7 var __getProtoOf = Object.getPrototypeOf;
8 var __hasOwnProp = Object.prototype.hasOwnProperty;
9 var __commonJS = (cb, mod) => function __require() {
10 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11 };
12 var __export = (target, all) => {
13 for (var name in all)
14 __defProp(target, name, { get: all[name], enumerable: true });
15 };
16 var __copyProps = (to, from, except, desc) => {
17 if (from && typeof from === "object" || typeof from === "function") {
18 for (let key of __getOwnPropNames(from))
19 if (!__hasOwnProp.call(to, key) && key !== except)
20 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21 }
22 return to;
23 };
24 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25 // If the importer is in node compatibility mode or this is not an ESM
26 // file that has been converted to a CommonJS file using a Babel-
27 // compatible transform (i.e. "__esModule" has not been set), then set
28 // "default" to the CommonJS "module.exports" for node compatibility.
29 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30 mod
31 ));
32 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
34 // package-external:@wordpress/blocks
35 var require_blocks = __commonJS({
36 "package-external:@wordpress/blocks"(exports, module) {
37 module.exports = window.wp.blocks;
38 }
39 });
40
41 // package-external:@wordpress/block-library
42 var require_block_library = __commonJS({
43 "package-external:@wordpress/block-library"(exports, module) {
44 module.exports = window.wp.blockLibrary;
45 }
46 });
47
48 // package-external:@wordpress/deprecated
49 var require_deprecated = __commonJS({
50 "package-external:@wordpress/deprecated"(exports, module) {
51 module.exports = window.wp.deprecated;
52 }
53 });
54
55 // package-external:@wordpress/element
56 var require_element = __commonJS({
57 "package-external:@wordpress/element"(exports, module) {
58 module.exports = window.wp.element;
59 }
60 });
61
62 // package-external:@wordpress/data
63 var require_data = __commonJS({
64 "package-external:@wordpress/data"(exports, module) {
65 module.exports = window.wp.data;
66 }
67 });
68
69 // package-external:@wordpress/preferences
70 var require_preferences = __commonJS({
71 "package-external:@wordpress/preferences"(exports, module) {
72 module.exports = window.wp.preferences;
73 }
74 });
75
76 // package-external:@wordpress/widgets
77 var require_widgets = __commonJS({
78 "package-external:@wordpress/widgets"(exports, module) {
79 module.exports = window.wp.widgets;
80 }
81 });
82
83 // package-external:@wordpress/editor
84 var require_editor = __commonJS({
85 "package-external:@wordpress/editor"(exports, module) {
86 module.exports = window.wp.editor;
87 }
88 });
89
90 // package-external:@wordpress/core-data
91 var require_core_data = __commonJS({
92 "package-external:@wordpress/core-data"(exports, module) {
93 module.exports = window.wp.coreData;
94 }
95 });
96
97 // package-external:@wordpress/api-fetch
98 var require_api_fetch = __commonJS({
99 "package-external:@wordpress/api-fetch"(exports, module) {
100 module.exports = window.wp.apiFetch;
101 }
102 });
103
104 // package-external:@wordpress/i18n
105 var require_i18n = __commonJS({
106 "package-external:@wordpress/i18n"(exports, module) {
107 module.exports = window.wp.i18n;
108 }
109 });
110
111 // vendor-external:react
112 var require_react = __commonJS({
113 "vendor-external:react"(exports, module) {
114 module.exports = window.React;
115 }
116 });
117
118 // vendor-external:react/jsx-runtime
119 var require_jsx_runtime = __commonJS({
120 "vendor-external:react/jsx-runtime"(exports, module) {
121 module.exports = window.ReactJSXRuntime;
122 }
123 });
124
125 // vendor-external:react-dom
126 var require_react_dom = __commonJS({
127 "vendor-external:react-dom"(exports, module) {
128 module.exports = window.ReactDOM;
129 }
130 });
131
132 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
133 var require_use_sync_external_store_shim_development = __commonJS({
134 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
135 "use strict";
136 (function() {
137 function is(x, y) {
138 return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
139 }
140 function useSyncExternalStore$2(subscribe, getSnapshot) {
141 didWarnOld18Alpha || void 0 === React48.startTransition || (didWarnOld18Alpha = true, console.error(
142 "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."
143 ));
144 var value = getSnapshot();
145 if (!didWarnUncachedGetSnapshot) {
146 var cachedValue = getSnapshot();
147 objectIs(value, cachedValue) || (console.error(
148 "The result of getSnapshot should be cached to avoid an infinite loop"
149 ), didWarnUncachedGetSnapshot = true);
150 }
151 cachedValue = useState16({
152 inst: { value, getSnapshot }
153 });
154 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
155 useLayoutEffect4(
156 function() {
157 inst.value = value;
158 inst.getSnapshot = getSnapshot;
159 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
160 },
161 [subscribe, value, getSnapshot]
162 );
163 useEffect17(
164 function() {
165 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
166 return subscribe(function() {
167 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
168 });
169 },
170 [subscribe]
171 );
172 useDebugValue2(value);
173 return value;
174 }
175 function checkIfSnapshotChanged(inst) {
176 var latestGetSnapshot = inst.getSnapshot;
177 inst = inst.value;
178 try {
179 var nextValue = latestGetSnapshot();
180 return !objectIs(inst, nextValue);
181 } catch (error) {
182 return true;
183 }
184 }
185 function useSyncExternalStore$1(subscribe, getSnapshot) {
186 return getSnapshot();
187 }
188 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
189 var React48 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState16 = React48.useState, useEffect17 = React48.useEffect, useLayoutEffect4 = React48.useLayoutEffect, useDebugValue2 = React48.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
190 exports.useSyncExternalStore = void 0 !== React48.useSyncExternalStore ? React48.useSyncExternalStore : shim;
191 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
192 })();
193 }
194 });
195
196 // node_modules/use-sync-external-store/shim/index.js
197 var require_shim = __commonJS({
198 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
199 "use strict";
200 if (false) {
201 module.exports = null;
202 } else {
203 module.exports = require_use_sync_external_store_shim_development();
204 }
205 }
206 });
207
208 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
209 var require_with_selector_development = __commonJS({
210 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
211 "use strict";
212 (function() {
213 function is(x, y) {
214 return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
215 }
216 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
217 var React48 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore2 = shim.useSyncExternalStore, useRef21 = React48.useRef, useEffect17 = React48.useEffect, useMemo17 = React48.useMemo, useDebugValue2 = React48.useDebugValue;
218 exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
219 var instRef = useRef21(null);
220 if (null === instRef.current) {
221 var inst = { hasValue: false, value: null };
222 instRef.current = inst;
223 } else inst = instRef.current;
224 instRef = useMemo17(
225 function() {
226 function memoizedSelector(nextSnapshot) {
227 if (!hasMemo) {
228 hasMemo = true;
229 memoizedSnapshot = nextSnapshot;
230 nextSnapshot = selector(nextSnapshot);
231 if (void 0 !== isEqual && inst.hasValue) {
232 var currentSelection = inst.value;
233 if (isEqual(currentSelection, nextSnapshot))
234 return memoizedSelection = currentSelection;
235 }
236 return memoizedSelection = nextSnapshot;
237 }
238 currentSelection = memoizedSelection;
239 if (objectIs(memoizedSnapshot, nextSnapshot))
240 return currentSelection;
241 var nextSelection = selector(nextSnapshot);
242 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
243 return memoizedSnapshot = nextSnapshot, currentSelection;
244 memoizedSnapshot = nextSnapshot;
245 return memoizedSelection = nextSelection;
246 }
247 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
248 return [
249 function() {
250 return memoizedSelector(getSnapshot());
251 },
252 null === maybeGetServerSnapshot ? void 0 : function() {
253 return memoizedSelector(maybeGetServerSnapshot());
254 }
255 ];
256 },
257 [getSnapshot, getServerSnapshot, selector, isEqual]
258 );
259 var value = useSyncExternalStore2(subscribe, instRef[0], instRef[1]);
260 useEffect17(
261 function() {
262 inst.hasValue = true;
263 inst.value = value;
264 },
265 [value]
266 );
267 useDebugValue2(value);
268 return value;
269 };
270 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
271 })();
272 }
273 });
274
275 // node_modules/use-sync-external-store/shim/with-selector.js
276 var require_with_selector = __commonJS({
277 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
278 "use strict";
279 if (false) {
280 module.exports = null;
281 } else {
282 module.exports = require_with_selector_development();
283 }
284 }
285 });
286
287 // package-external:@wordpress/primitives
288 var require_primitives = __commonJS({
289 "package-external:@wordpress/primitives"(exports, module) {
290 module.exports = window.wp.primitives;
291 }
292 });
293
294 // package-external:@wordpress/compose
295 var require_compose = __commonJS({
296 "package-external:@wordpress/compose"(exports, module) {
297 module.exports = window.wp.compose;
298 }
299 });
300
301 // package-external:@wordpress/theme
302 var require_theme = __commonJS({
303 "package-external:@wordpress/theme"(exports, module) {
304 module.exports = window.wp.theme;
305 }
306 });
307
308 // package-external:@wordpress/private-apis
309 var require_private_apis = __commonJS({
310 "package-external:@wordpress/private-apis"(exports, module) {
311 module.exports = window.wp.privateApis;
312 }
313 });
314
315 // package-external:@wordpress/components
316 var require_components = __commonJS({
317 "package-external:@wordpress/components"(exports, module) {
318 module.exports = window.wp.components;
319 }
320 });
321
322 // package-external:@wordpress/block-editor
323 var require_block_editor = __commonJS({
324 "package-external:@wordpress/block-editor"(exports, module) {
325 module.exports = window.wp.blockEditor;
326 }
327 });
328
329 // package-external:@wordpress/style-engine
330 var require_style_engine = __commonJS({
331 "package-external:@wordpress/style-engine"(exports, module) {
332 module.exports = window.wp.styleEngine;
333 }
334 });
335
336 // package-external:@wordpress/plugins
337 var require_plugins = __commonJS({
338 "package-external:@wordpress/plugins"(exports, module) {
339 module.exports = window.wp.plugins;
340 }
341 });
342
343 // package-external:@wordpress/notices
344 var require_notices = __commonJS({
345 "package-external:@wordpress/notices"(exports, module) {
346 module.exports = window.wp.notices;
347 }
348 });
349
350 // package-external:@wordpress/commands
351 var require_commands = __commonJS({
352 "package-external:@wordpress/commands"(exports, module) {
353 module.exports = window.wp.commands;
354 }
355 });
356
357 // package-external:@wordpress/url
358 var require_url = __commonJS({
359 "package-external:@wordpress/url"(exports, module) {
360 module.exports = window.wp.url;
361 }
362 });
363
364 // package-external:@wordpress/html-entities
365 var require_html_entities = __commonJS({
366 "package-external:@wordpress/html-entities"(exports, module) {
367 module.exports = window.wp.htmlEntities;
368 }
369 });
370
371 // package-external:@wordpress/keyboard-shortcuts
372 var require_keyboard_shortcuts = __commonJS({
373 "package-external:@wordpress/keyboard-shortcuts"(exports, module) {
374 module.exports = window.wp.keyboardShortcuts;
375 }
376 });
377
378 // package-external:@wordpress/hooks
379 var require_hooks = __commonJS({
380 "package-external:@wordpress/hooks"(exports, module) {
381 module.exports = window.wp.hooks;
382 }
383 });
384
385 // package-external:@wordpress/keycodes
386 var require_keycodes = __commonJS({
387 "package-external:@wordpress/keycodes"(exports, module) {
388 module.exports = window.wp.keycodes;
389 }
390 });
391
392 // packages/edit-post/build-module/index.mjs
393 var index_exports = {};
394 __export(index_exports, {
395 PluginBlockSettingsMenuItem: () => PluginBlockSettingsMenuItem,
396 PluginDocumentSettingPanel: () => PluginDocumentSettingPanel,
397 PluginMoreMenuItem: () => PluginMoreMenuItem,
398 PluginPostPublishPanel: () => PluginPostPublishPanel,
399 PluginPostStatusInfo: () => PluginPostStatusInfo,
400 PluginPrePublishPanel: () => PluginPrePublishPanel,
401 PluginSidebar: () => PluginSidebar,
402 PluginSidebarMoreMenuItem: () => PluginSidebarMoreMenuItem,
403 __experimentalFullscreenModeClose: () => fullscreen_mode_close_default,
404 __experimentalMainDashboardButton: () => __experimentalMainDashboardButton,
405 __experimentalPluginPostExcerpt: () => __experimentalPluginPostExcerpt,
406 initializeEditor: () => initializeEditor,
407 reinitializeEditor: () => reinitializeEditor,
408 store: () => store
409 });
410 var import_blocks3 = __toESM(require_blocks(), 1);
411 var import_block_library2 = __toESM(require_block_library(), 1);
412 var import_deprecated4 = __toESM(require_deprecated(), 1);
413 var import_element26 = __toESM(require_element(), 1);
414 var import_data26 = __toESM(require_data(), 1);
415 var import_preferences11 = __toESM(require_preferences(), 1);
416 var import_widgets = __toESM(require_widgets(), 1);
417 var import_editor20 = __toESM(require_editor(), 1);
418 var import_core_data9 = __toESM(require_core_data(), 1);
419 var import_api_fetch2 = __toESM(require_api_fetch(), 1);
420
421 // node_modules/clsx/dist/clsx.mjs
422 function r(e) {
423 var t, f, n = "";
424 if ("string" == typeof e || "number" == typeof e) n += e;
425 else if ("object" == typeof e) if (Array.isArray(e)) {
426 var o = e.length;
427 for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
428 } else for (f in e) e[f] && (n && (n += " "), n += f);
429 return n;
430 }
431 function clsx() {
432 for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
433 return n;
434 }
435 var clsx_default = clsx;
436
437 // node_modules/@base-ui/utils/esm/useStableCallback.js
438 var React2 = __toESM(require_react(), 1);
439
440 // node_modules/@base-ui/utils/esm/useRefWithInit.js
441 var React = __toESM(require_react(), 1);
442 var UNINITIALIZED = {};
443 function useRefWithInit(init, initArg) {
444 const ref = React.useRef(UNINITIALIZED);
445 if (ref.current === UNINITIALIZED) {
446 ref.current = init(initArg);
447 }
448 return ref;
449 }
450
451 // node_modules/@base-ui/utils/esm/useStableCallback.js
452 var useInsertionEffect = React2[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
453 var useSafeInsertionEffect = (
454 // React 17 doesn't have useInsertionEffect.
455 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
456 useInsertionEffect !== React2.useLayoutEffect ? useInsertionEffect : (fn) => fn()
457 );
458 function useStableCallback(callback) {
459 const stable = useRefWithInit(createStableCallback).current;
460 stable.next = callback;
461 useSafeInsertionEffect(stable.effect);
462 return stable.trampoline;
463 }
464 function createStableCallback() {
465 const stable = {
466 next: void 0,
467 callback: assertNotCalled,
468 trampoline: (...args) => stable.callback?.(...args),
469 effect: () => {
470 stable.callback = stable.next;
471 }
472 };
473 return stable;
474 }
475 function assertNotCalled() {
476 if (true) {
477 throw (
478 /* minify-error-disabled */
479 new Error("Base UI: Cannot call an event handler while rendering.")
480 );
481 }
482 }
483
484 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
485 var React3 = __toESM(require_react(), 1);
486 var noop = () => {
487 };
488 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
489
490 // node_modules/@base-ui/utils/esm/warn.js
491 var set;
492 if (true) {
493 set = /* @__PURE__ */ new Set();
494 }
495 function warn(...messages) {
496 if (true) {
497 const messageKey = messages.join(" ");
498 if (!set.has(messageKey)) {
499 set.add(messageKey);
500 console.warn(`Base UI: ${messageKey}`);
501 }
502 }
503 }
504
505 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
506 var React4 = __toESM(require_react(), 1);
507 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
508 if (true) DirectionContext.displayName = "DirectionContext";
509 function useDirection() {
510 const context = React4.useContext(DirectionContext);
511 return context?.direction ?? "ltr";
512 }
513
514 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
515 var React7 = __toESM(require_react(), 1);
516
517 // node_modules/@base-ui/utils/esm/useMergedRefs.js
518 function useMergedRefs(a, b, c, d) {
519 const forkRef = useRefWithInit(createForkRef).current;
520 if (didChange(forkRef, a, b, c, d)) {
521 update(forkRef, [a, b, c, d]);
522 }
523 return forkRef.callback;
524 }
525 function useMergedRefsN(refs) {
526 const forkRef = useRefWithInit(createForkRef).current;
527 if (didChangeN(forkRef, refs)) {
528 update(forkRef, refs);
529 }
530 return forkRef.callback;
531 }
532 function createForkRef() {
533 return {
534 callback: null,
535 cleanup: null,
536 refs: []
537 };
538 }
539 function didChange(forkRef, a, b, c, d) {
540 return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
541 }
542 function didChangeN(forkRef, newRefs) {
543 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
544 }
545 function update(forkRef, refs) {
546 forkRef.refs = refs;
547 if (refs.every((ref) => ref == null)) {
548 forkRef.callback = null;
549 return;
550 }
551 forkRef.callback = (instance) => {
552 if (forkRef.cleanup) {
553 forkRef.cleanup();
554 forkRef.cleanup = null;
555 }
556 if (instance != null) {
557 const cleanupCallbacks = Array(refs.length).fill(null);
558 for (let i = 0; i < refs.length; i += 1) {
559 const ref = refs[i];
560 if (ref == null) {
561 continue;
562 }
563 switch (typeof ref) {
564 case "function": {
565 const refCleanup = ref(instance);
566 if (typeof refCleanup === "function") {
567 cleanupCallbacks[i] = refCleanup;
568 }
569 break;
570 }
571 case "object": {
572 ref.current = instance;
573 break;
574 }
575 default:
576 }
577 }
578 forkRef.cleanup = () => {
579 for (let i = 0; i < refs.length; i += 1) {
580 const ref = refs[i];
581 if (ref == null) {
582 continue;
583 }
584 switch (typeof ref) {
585 case "function": {
586 const cleanupCallback = cleanupCallbacks[i];
587 if (typeof cleanupCallback === "function") {
588 cleanupCallback();
589 } else {
590 ref(null);
591 }
592 break;
593 }
594 case "object": {
595 ref.current = null;
596 break;
597 }
598 default:
599 }
600 }
601 };
602 }
603 };
604 }
605
606 // node_modules/@base-ui/utils/esm/getReactElementRef.js
607 var React6 = __toESM(require_react(), 1);
608
609 // node_modules/@base-ui/utils/esm/reactVersion.js
610 var React5 = __toESM(require_react(), 1);
611 var majorVersion = parseInt(React5.version, 10);
612 function isReactVersionAtLeast(reactVersionToCheck) {
613 return majorVersion >= reactVersionToCheck;
614 }
615
616 // node_modules/@base-ui/utils/esm/getReactElementRef.js
617 function getReactElementRef(element) {
618 if (!/* @__PURE__ */ React6.isValidElement(element)) {
619 return null;
620 }
621 const reactElement = element;
622 const propsWithRef = reactElement.props;
623 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
624 }
625
626 // node_modules/@base-ui/utils/esm/mergeObjects.js
627 function mergeObjects(a, b) {
628 if (a && !b) {
629 return a;
630 }
631 if (!a && b) {
632 return b;
633 }
634 if (a || b) {
635 return {
636 ...a,
637 ...b
638 };
639 }
640 return void 0;
641 }
642
643 // node_modules/@base-ui/utils/esm/empty.js
644 function NOOP() {
645 }
646 var EMPTY_ARRAY = Object.freeze([]);
647 var EMPTY_OBJECT = Object.freeze({});
648
649 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
650 function getStateAttributesProps(state, customMapping) {
651 const props = {};
652 for (const key in state) {
653 const value = state[key];
654 if (customMapping?.hasOwnProperty(key)) {
655 const customProps = customMapping[key](value);
656 if (customProps != null) {
657 Object.assign(props, customProps);
658 }
659 continue;
660 }
661 if (value === true) {
662 props[`data-${key.toLowerCase()}`] = "";
663 } else if (value) {
664 props[`data-${key.toLowerCase()}`] = value.toString();
665 }
666 }
667 return props;
668 }
669
670 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
671 function resolveClassName(className, state) {
672 return typeof className === "function" ? className(state) : className;
673 }
674
675 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
676 function resolveStyle(style, state) {
677 return typeof style === "function" ? style(state) : style;
678 }
679
680 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
681 var EMPTY_PROPS = {};
682 function mergeProps(a, b, c, d, e) {
683 if (!c && !d && !e && !a) {
684 return createInitialMergedProps(b);
685 }
686 let merged = createInitialMergedProps(a);
687 if (b) {
688 merged = mergeInto(merged, b);
689 }
690 if (c) {
691 merged = mergeInto(merged, c);
692 }
693 if (d) {
694 merged = mergeInto(merged, d);
695 }
696 if (e) {
697 merged = mergeInto(merged, e);
698 }
699 return merged;
700 }
701 function mergePropsN(props) {
702 if (props.length === 0) {
703 return EMPTY_PROPS;
704 }
705 if (props.length === 1) {
706 return createInitialMergedProps(props[0]);
707 }
708 let merged = createInitialMergedProps(props[0]);
709 for (let i = 1; i < props.length; i += 1) {
710 merged = mergeInto(merged, props[i]);
711 }
712 return merged;
713 }
714 function createInitialMergedProps(inputProps) {
715 if (isPropsGetter(inputProps)) {
716 return {
717 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
718 };
719 }
720 return copyInitialProps(inputProps);
721 }
722 function mergeInto(merged, inputProps) {
723 if (isPropsGetter(inputProps)) {
724 return resolvePropsGetter(inputProps, merged);
725 }
726 return mutablyMergeInto(merged, inputProps);
727 }
728 function copyInitialProps(inputProps) {
729 const copiedProps = {
730 ...inputProps
731 };
732 for (const propName in copiedProps) {
733 const propValue = copiedProps[propName];
734 if (isEventHandler(propName, propValue)) {
735 copiedProps[propName] = wrapEventHandler(propValue);
736 }
737 }
738 return copiedProps;
739 }
740 function mutablyMergeInto(mergedProps, externalProps) {
741 if (!externalProps) {
742 return mergedProps;
743 }
744 for (const propName in externalProps) {
745 const externalPropValue = externalProps[propName];
746 switch (propName) {
747 case "style": {
748 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
749 break;
750 }
751 case "className": {
752 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
753 break;
754 }
755 default: {
756 if (isEventHandler(propName, externalPropValue)) {
757 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
758 } else {
759 mergedProps[propName] = externalPropValue;
760 }
761 }
762 }
763 }
764 return mergedProps;
765 }
766 function isEventHandler(key, value) {
767 const code0 = key.charCodeAt(0);
768 const code1 = key.charCodeAt(1);
769 const code2 = key.charCodeAt(2);
770 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
771 }
772 function isPropsGetter(inputProps) {
773 return typeof inputProps === "function";
774 }
775 function resolvePropsGetter(inputProps, previousProps) {
776 if (isPropsGetter(inputProps)) {
777 return inputProps(previousProps);
778 }
779 return inputProps ?? EMPTY_PROPS;
780 }
781 function mergeEventHandlers(ourHandler, theirHandler) {
782 if (!theirHandler) {
783 return ourHandler;
784 }
785 if (!ourHandler) {
786 return wrapEventHandler(theirHandler);
787 }
788 return (...args) => {
789 const event = args[0];
790 if (isSyntheticEvent(event)) {
791 const baseUIEvent = event;
792 makeEventPreventable(baseUIEvent);
793 const result2 = theirHandler(...args);
794 if (!baseUIEvent.baseUIHandlerPrevented) {
795 ourHandler?.(...args);
796 }
797 return result2;
798 }
799 const result = theirHandler(...args);
800 ourHandler?.(...args);
801 return result;
802 };
803 }
804 function wrapEventHandler(handler) {
805 if (!handler) {
806 return handler;
807 }
808 return (...args) => {
809 const event = args[0];
810 if (isSyntheticEvent(event)) {
811 makeEventPreventable(event);
812 }
813 return handler(...args);
814 };
815 }
816 function makeEventPreventable(event) {
817 event.preventBaseUIHandler = () => {
818 event.baseUIHandlerPrevented = true;
819 };
820 return event;
821 }
822 function mergeClassNames(ourClassName, theirClassName) {
823 if (theirClassName) {
824 if (ourClassName) {
825 return theirClassName + " " + ourClassName;
826 }
827 return theirClassName;
828 }
829 return ourClassName;
830 }
831 function isSyntheticEvent(event) {
832 return event != null && typeof event === "object" && "nativeEvent" in event;
833 }
834
835 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
836 var import_react = __toESM(require_react(), 1);
837 function useRenderElement(element, componentProps, params = {}) {
838 const renderProp = componentProps.render;
839 const outProps = useRenderElementProps(componentProps, params);
840 if (params.enabled === false) {
841 return null;
842 }
843 const state = params.state ?? EMPTY_OBJECT;
844 return evaluateRenderProp(element, renderProp, outProps, state);
845 }
846 function useRenderElementProps(componentProps, params = {}) {
847 const {
848 className: classNameProp,
849 style: styleProp,
850 render: renderProp
851 } = componentProps;
852 const {
853 state = EMPTY_OBJECT,
854 ref,
855 props,
856 stateAttributesMapping: stateAttributesMapping3,
857 enabled = true
858 } = params;
859 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
860 const style = enabled ? resolveStyle(styleProp, state) : void 0;
861 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
862 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
863 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
864 if (typeof document !== "undefined") {
865 if (!enabled) {
866 useMergedRefs(null, null);
867 } else if (Array.isArray(ref)) {
868 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
869 } else {
870 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
871 }
872 }
873 if (!enabled) {
874 return EMPTY_OBJECT;
875 }
876 if (className !== void 0) {
877 outProps.className = mergeClassNames(outProps.className, className);
878 }
879 if (style !== void 0) {
880 outProps.style = mergeObjects(outProps.style, style);
881 }
882 return outProps;
883 }
884 function resolveRenderFunctionProps(props) {
885 if (Array.isArray(props)) {
886 return mergePropsN(props);
887 }
888 return mergeProps(void 0, props);
889 }
890 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
891 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
892 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
893 function evaluateRenderProp(element, render, props, state) {
894 if (render) {
895 if (typeof render === "function") {
896 if (true) {
897 warnIfRenderPropLooksLikeComponent(render);
898 }
899 return render(props, state);
900 }
901 const mergedProps = mergeProps(props, render.props);
902 mergedProps.ref = props.ref;
903 let newElement = render;
904 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
905 const children = React7.Children.toArray(render);
906 newElement = children[0];
907 }
908 if (true) {
909 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
910 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"));
911 }
912 }
913 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
914 }
915 if (element) {
916 if (typeof element === "string") {
917 return renderTag(element, props);
918 }
919 }
920 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
921 }
922 function warnIfRenderPropLooksLikeComponent(renderFn) {
923 const functionName = renderFn.name;
924 if (functionName.length === 0) {
925 return;
926 }
927 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
928 return;
929 }
930 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
931 return;
932 }
933 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");
934 }
935 function renderTag(Tag, props) {
936 if (Tag === "button") {
937 return /* @__PURE__ */ (0, import_react.createElement)("button", {
938 type: "button",
939 ...props,
940 key: props.key
941 });
942 }
943 if (Tag === "img") {
944 return /* @__PURE__ */ (0, import_react.createElement)("img", {
945 alt: "",
946 ...props,
947 key: props.key
948 });
949 }
950 return /* @__PURE__ */ React7.createElement(Tag, props);
951 }
952
953 // node_modules/@base-ui/react/esm/internals/reason-parts.js
954 var reason_parts_exports = {};
955 __export(reason_parts_exports, {
956 cancelOpen: () => cancelOpen,
957 chipRemovePress: () => chipRemovePress,
958 clearPress: () => clearPress,
959 closePress: () => closePress,
960 closeWatcher: () => closeWatcher,
961 decrementPress: () => decrementPress,
962 disabled: () => disabled,
963 drag: () => drag,
964 escapeKey: () => escapeKey,
965 focusOut: () => focusOut,
966 imperativeAction: () => imperativeAction,
967 incrementPress: () => incrementPress,
968 inputBlur: () => inputBlur,
969 inputChange: () => inputChange,
970 inputClear: () => inputClear,
971 inputPaste: () => inputPaste,
972 inputPress: () => inputPress,
973 itemPress: () => itemPress,
974 keyboard: () => keyboard,
975 linkPress: () => linkPress,
976 listNavigation: () => listNavigation,
977 none: () => none,
978 outsidePress: () => outsidePress,
979 pointer: () => pointer,
980 scrub: () => scrub,
981 siblingOpen: () => siblingOpen,
982 swipe: () => swipe,
983 trackPress: () => trackPress,
984 triggerFocus: () => triggerFocus,
985 triggerHover: () => triggerHover,
986 triggerPress: () => triggerPress,
987 wheel: () => wheel,
988 windowResize: () => windowResize
989 });
990 var none = "none";
991 var triggerPress = "trigger-press";
992 var triggerHover = "trigger-hover";
993 var triggerFocus = "trigger-focus";
994 var outsidePress = "outside-press";
995 var itemPress = "item-press";
996 var closePress = "close-press";
997 var linkPress = "link-press";
998 var clearPress = "clear-press";
999 var chipRemovePress = "chip-remove-press";
1000 var trackPress = "track-press";
1001 var incrementPress = "increment-press";
1002 var decrementPress = "decrement-press";
1003 var inputChange = "input-change";
1004 var inputClear = "input-clear";
1005 var inputBlur = "input-blur";
1006 var inputPaste = "input-paste";
1007 var inputPress = "input-press";
1008 var focusOut = "focus-out";
1009 var escapeKey = "escape-key";
1010 var closeWatcher = "close-watcher";
1011 var listNavigation = "list-navigation";
1012 var keyboard = "keyboard";
1013 var pointer = "pointer";
1014 var drag = "drag";
1015 var wheel = "wheel";
1016 var scrub = "scrub";
1017 var cancelOpen = "cancel-open";
1018 var siblingOpen = "sibling-open";
1019 var disabled = "disabled";
1020 var imperativeAction = "imperative-action";
1021 var swipe = "swipe";
1022 var windowResize = "window-resize";
1023
1024 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1025 function createChangeEventDetails(reason, event, trigger, customProperties) {
1026 let canceled = false;
1027 let allowPropagation = false;
1028 const custom = customProperties ?? EMPTY_OBJECT;
1029 const details = {
1030 reason,
1031 event: event ?? new Event("base-ui"),
1032 cancel() {
1033 canceled = true;
1034 },
1035 allowPropagation() {
1036 allowPropagation = true;
1037 },
1038 get isCanceled() {
1039 return canceled;
1040 },
1041 get isPropagationAllowed() {
1042 return allowPropagation;
1043 },
1044 trigger,
1045 ...custom
1046 };
1047 return details;
1048 }
1049
1050 // node_modules/@base-ui/utils/esm/useId.js
1051 var React9 = __toESM(require_react(), 1);
1052
1053 // node_modules/@base-ui/utils/esm/safeReact.js
1054 var React8 = __toESM(require_react(), 1);
1055 var SafeReact = {
1056 ...React8
1057 };
1058
1059 // node_modules/@base-ui/utils/esm/useId.js
1060 var globalId = 0;
1061 function useGlobalId(idOverride, prefix = "mui") {
1062 const [defaultId, setDefaultId] = React9.useState(idOverride);
1063 const id = idOverride || defaultId;
1064 React9.useEffect(() => {
1065 if (defaultId == null) {
1066 globalId += 1;
1067 setDefaultId(`${prefix}-${globalId}`);
1068 }
1069 }, [defaultId, prefix]);
1070 return id;
1071 }
1072 var maybeReactUseId = SafeReact.useId;
1073 function useId(idOverride, prefix) {
1074 if (maybeReactUseId !== void 0) {
1075 const reactId = maybeReactUseId();
1076 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1077 }
1078 return useGlobalId(idOverride, prefix);
1079 }
1080
1081 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1082 function useBaseUiId(idOverride) {
1083 return useId(idOverride, "base-ui");
1084 }
1085
1086 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1087 var ReactDOM = __toESM(require_react_dom(), 1);
1088
1089 // node_modules/@base-ui/utils/esm/useOnMount.js
1090 var React10 = __toESM(require_react(), 1);
1091 var EMPTY = [];
1092 function useOnMount(fn) {
1093 React10.useEffect(fn, EMPTY);
1094 }
1095
1096 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1097 var EMPTY2 = null;
1098 var LAST_RAF = globalThis.requestAnimationFrame;
1099 var Scheduler = class {
1100 /* This implementation uses an array as a backing data-structure for frame callbacks.
1101 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1102 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1103 * be much more efficient if there is a call pattern that alterns as
1104 * "request-cancel-request-cancel-…".
1105 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1106 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1107 callbacks = [];
1108 callbacksCount = 0;
1109 nextId = 1;
1110 startId = 1;
1111 isScheduled = false;
1112 tick = (timestamp) => {
1113 this.isScheduled = false;
1114 const currentCallbacks = this.callbacks;
1115 const currentCallbacksCount = this.callbacksCount;
1116 this.callbacks = [];
1117 this.callbacksCount = 0;
1118 this.startId = this.nextId;
1119 if (currentCallbacksCount > 0) {
1120 for (let i = 0; i < currentCallbacks.length; i += 1) {
1121 currentCallbacks[i]?.(timestamp);
1122 }
1123 }
1124 };
1125 request(fn) {
1126 const id = this.nextId;
1127 this.nextId += 1;
1128 this.callbacks.push(fn);
1129 this.callbacksCount += 1;
1130 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1131 if (!this.isScheduled || didRAFChange) {
1132 requestAnimationFrame(this.tick);
1133 this.isScheduled = true;
1134 }
1135 return id;
1136 }
1137 cancel(id) {
1138 const index2 = id - this.startId;
1139 if (index2 < 0 || index2 >= this.callbacks.length) {
1140 return;
1141 }
1142 this.callbacks[index2] = null;
1143 this.callbacksCount -= 1;
1144 }
1145 };
1146 var scheduler = new Scheduler();
1147 var AnimationFrame = class _AnimationFrame {
1148 static create() {
1149 return new _AnimationFrame();
1150 }
1151 static request(fn) {
1152 return scheduler.request(fn);
1153 }
1154 static cancel(id) {
1155 return scheduler.cancel(id);
1156 }
1157 currentId = EMPTY2;
1158 /**
1159 * Executes `fn` after `delay`, clearing any previously scheduled call.
1160 */
1161 request(fn) {
1162 this.cancel();
1163 this.currentId = scheduler.request(() => {
1164 this.currentId = EMPTY2;
1165 fn();
1166 });
1167 }
1168 cancel = () => {
1169 if (this.currentId !== EMPTY2) {
1170 scheduler.cancel(this.currentId);
1171 this.currentId = EMPTY2;
1172 }
1173 };
1174 disposeEffect = () => {
1175 return this.cancel;
1176 };
1177 };
1178 function useAnimationFrame() {
1179 const timeout = useRefWithInit(AnimationFrame.create).current;
1180 useOnMount(timeout.disposeEffect);
1181 return timeout;
1182 }
1183
1184 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1185 function resolveRef(maybeRef) {
1186 if (maybeRef == null) {
1187 return maybeRef;
1188 }
1189 return "current" in maybeRef ? maybeRef.current : maybeRef;
1190 }
1191
1192 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1193 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1194 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1195 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1196 return TransitionStatusDataAttributes2;
1197 })({});
1198 var STARTING_HOOK = {
1199 [TransitionStatusDataAttributes.startingStyle]: ""
1200 };
1201 var ENDING_HOOK = {
1202 [TransitionStatusDataAttributes.endingStyle]: ""
1203 };
1204 var transitionStatusMapping = {
1205 transitionStatus(value) {
1206 if (value === "starting") {
1207 return STARTING_HOOK;
1208 }
1209 if (value === "ending") {
1210 return ENDING_HOOK;
1211 }
1212 return null;
1213 }
1214 };
1215
1216 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1217 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1218 const frame = useAnimationFrame();
1219 return useStableCallback((fnToExecute, signal = null) => {
1220 frame.cancel();
1221 const element = resolveRef(elementOrRef);
1222 if (element == null) {
1223 return;
1224 }
1225 const resolvedElement = element;
1226 const done = () => {
1227 ReactDOM.flushSync(fnToExecute);
1228 };
1229 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1230 fnToExecute();
1231 return;
1232 }
1233 function exec() {
1234 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
1235 if (!signal?.aborted) {
1236 done();
1237 }
1238 }).catch(() => {
1239 if (treatAbortedAsFinished) {
1240 if (!signal?.aborted) {
1241 done();
1242 }
1243 return;
1244 }
1245 const currentAnimations = resolvedElement.getAnimations();
1246 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
1247 exec();
1248 }
1249 });
1250 }
1251 if (waitForStartingStyleRemoved) {
1252 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
1253 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1254 frame.request(exec);
1255 return;
1256 }
1257 const attributeObserver = new MutationObserver(() => {
1258 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1259 attributeObserver.disconnect();
1260 exec();
1261 }
1262 });
1263 attributeObserver.observe(resolvedElement, {
1264 attributes: true,
1265 attributeFilter: [startingStyleAttribute]
1266 });
1267 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
1268 once: true
1269 });
1270 return;
1271 }
1272 frame.request(exec);
1273 });
1274 }
1275
1276 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1277 var React11 = __toESM(require_react(), 1);
1278 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1279 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1280 const [mounted, setMounted] = React11.useState(open);
1281 if (open && !mounted) {
1282 setMounted(true);
1283 setTransitionStatus("starting");
1284 }
1285 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1286 setTransitionStatus("ending");
1287 }
1288 if (!open && !mounted && transitionStatus === "ending") {
1289 setTransitionStatus(void 0);
1290 }
1291 useIsoLayoutEffect(() => {
1292 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1293 const frame = AnimationFrame.request(() => {
1294 setTransitionStatus("ending");
1295 });
1296 return () => {
1297 AnimationFrame.cancel(frame);
1298 };
1299 }
1300 return void 0;
1301 }, [open, mounted, transitionStatus, deferEndingState]);
1302 useIsoLayoutEffect(() => {
1303 if (!open || enableIdleState) {
1304 return void 0;
1305 }
1306 const frame = AnimationFrame.request(() => {
1307 setTransitionStatus(void 0);
1308 });
1309 return () => {
1310 AnimationFrame.cancel(frame);
1311 };
1312 }, [enableIdleState, open]);
1313 useIsoLayoutEffect(() => {
1314 if (!open || !enableIdleState) {
1315 return void 0;
1316 }
1317 if (open && mounted && transitionStatus !== "idle") {
1318 setTransitionStatus("starting");
1319 }
1320 const frame = AnimationFrame.request(() => {
1321 setTransitionStatus("idle");
1322 });
1323 return () => {
1324 AnimationFrame.cancel(frame);
1325 };
1326 }, [enableIdleState, open, mounted, transitionStatus]);
1327 return {
1328 mounted,
1329 setMounted,
1330 transitionStatus
1331 };
1332 }
1333
1334 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1335 function hasWindow() {
1336 return typeof window !== "undefined";
1337 }
1338 function getNodeName(node) {
1339 if (isNode(node)) {
1340 return (node.nodeName || "").toLowerCase();
1341 }
1342 return "#document";
1343 }
1344 function getWindow(node) {
1345 var _node$ownerDocument;
1346 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1347 }
1348 function getDocumentElement(node) {
1349 var _ref;
1350 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1351 }
1352 function isNode(value) {
1353 if (!hasWindow()) {
1354 return false;
1355 }
1356 return value instanceof Node || value instanceof getWindow(value).Node;
1357 }
1358 function isElement(value) {
1359 if (!hasWindow()) {
1360 return false;
1361 }
1362 return value instanceof Element || value instanceof getWindow(value).Element;
1363 }
1364 function isHTMLElement(value) {
1365 if (!hasWindow()) {
1366 return false;
1367 }
1368 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1369 }
1370 function isShadowRoot(value) {
1371 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1372 return false;
1373 }
1374 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1375 }
1376 function isOverflowElement(element) {
1377 const {
1378 overflow,
1379 overflowX,
1380 overflowY,
1381 display
1382 } = getComputedStyle2(element);
1383 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1384 }
1385 function isTableElement(element) {
1386 return /^(table|td|th)$/.test(getNodeName(element));
1387 }
1388 function isTopLayer(element) {
1389 try {
1390 if (element.matches(":popover-open")) {
1391 return true;
1392 }
1393 } catch (_e) {
1394 }
1395 try {
1396 return element.matches(":modal");
1397 } catch (_e) {
1398 return false;
1399 }
1400 }
1401 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1402 var containRe = /paint|layout|strict|content/;
1403 var isNotNone = (value) => !!value && value !== "none";
1404 var isWebKitValue;
1405 function isContainingBlock(elementOrCss) {
1406 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1407 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 || "");
1408 }
1409 function getContainingBlock(element) {
1410 let currentNode = getParentNode(element);
1411 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1412 if (isContainingBlock(currentNode)) {
1413 return currentNode;
1414 } else if (isTopLayer(currentNode)) {
1415 return null;
1416 }
1417 currentNode = getParentNode(currentNode);
1418 }
1419 return null;
1420 }
1421 function isWebKit() {
1422 if (isWebKitValue == null) {
1423 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1424 }
1425 return isWebKitValue;
1426 }
1427 function isLastTraversableNode(node) {
1428 return /^(html|body|#document)$/.test(getNodeName(node));
1429 }
1430 function getComputedStyle2(element) {
1431 return getWindow(element).getComputedStyle(element);
1432 }
1433 function getNodeScroll(element) {
1434 if (isElement(element)) {
1435 return {
1436 scrollLeft: element.scrollLeft,
1437 scrollTop: element.scrollTop
1438 };
1439 }
1440 return {
1441 scrollLeft: element.scrollX,
1442 scrollTop: element.scrollY
1443 };
1444 }
1445 function getParentNode(node) {
1446 if (getNodeName(node) === "html") {
1447 return node;
1448 }
1449 const result = (
1450 // Step into the shadow DOM of the parent of a slotted node.
1451 node.assignedSlot || // DOM Element detected.
1452 node.parentNode || // ShadowRoot detected.
1453 isShadowRoot(node) && node.host || // Fallback.
1454 getDocumentElement(node)
1455 );
1456 return isShadowRoot(result) ? result.host : result;
1457 }
1458 function getNearestOverflowAncestor(node) {
1459 const parentNode = getParentNode(node);
1460 if (isLastTraversableNode(parentNode)) {
1461 return node.ownerDocument ? node.ownerDocument.body : node.body;
1462 }
1463 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1464 return parentNode;
1465 }
1466 return getNearestOverflowAncestor(parentNode);
1467 }
1468 function getOverflowAncestors(node, list, traverseIframes) {
1469 var _node$ownerDocument2;
1470 if (list === void 0) {
1471 list = [];
1472 }
1473 if (traverseIframes === void 0) {
1474 traverseIframes = true;
1475 }
1476 const scrollableAncestor = getNearestOverflowAncestor(node);
1477 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1478 const win = getWindow(scrollableAncestor);
1479 if (isBody) {
1480 const frameElement = getFrameElement(win);
1481 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1482 } else {
1483 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1484 }
1485 }
1486 function getFrameElement(win) {
1487 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1488 }
1489
1490 // node_modules/@base-ui/utils/esm/detectBrowser.js
1491 var hasNavigator = typeof navigator !== "undefined";
1492 var nav = getNavigatorData();
1493 var platform = getPlatform();
1494 var userAgent = getUserAgent();
1495 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
1496 var isIOS = (
1497 // iPads can claim to be MacIntel
1498 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
1499 );
1500 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
1501 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
1502 var isEdge = hasNavigator && /Edg/i.test(userAgent);
1503 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
1504 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
1505 var isJSDOM = userAgent.includes("jsdom/");
1506 function getNavigatorData() {
1507 if (!hasNavigator) {
1508 return {
1509 platform: "",
1510 maxTouchPoints: -1
1511 };
1512 }
1513 const uaData = navigator.userAgentData;
1514 if (uaData?.platform) {
1515 return {
1516 platform: uaData.platform,
1517 maxTouchPoints: navigator.maxTouchPoints
1518 };
1519 }
1520 return {
1521 platform: navigator.platform ?? "",
1522 maxTouchPoints: navigator.maxTouchPoints ?? -1
1523 };
1524 }
1525 function getUserAgent() {
1526 if (!hasNavigator) {
1527 return "";
1528 }
1529 const uaData = navigator.userAgentData;
1530 if (uaData && Array.isArray(uaData.brands)) {
1531 return uaData.brands.map(({
1532 brand,
1533 version: version2
1534 }) => `${brand}/${version2}`).join(" ");
1535 }
1536 return navigator.userAgent;
1537 }
1538 function getPlatform() {
1539 if (!hasNavigator) {
1540 return "";
1541 }
1542 const uaData = navigator.userAgentData;
1543 if (uaData?.platform) {
1544 return uaData.platform;
1545 }
1546 return navigator.platform ?? "";
1547 }
1548
1549 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
1550 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
1551 var ACTIVE_KEY = "active";
1552 var SELECTED_KEY = "selected";
1553 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
1554
1555 // node_modules/@base-ui/react/esm/internals/shadowDom.js
1556 function activeElement(doc) {
1557 let element = doc.activeElement;
1558 while (element?.shadowRoot?.activeElement != null) {
1559 element = element.shadowRoot.activeElement;
1560 }
1561 return element;
1562 }
1563 function contains(parent, child) {
1564 if (!parent || !child) {
1565 return false;
1566 }
1567 const rootNode = child.getRootNode?.();
1568 if (parent.contains(child)) {
1569 return true;
1570 }
1571 if (rootNode && isShadowRoot(rootNode)) {
1572 let next = child;
1573 while (next) {
1574 if (parent === next) {
1575 return true;
1576 }
1577 next = next.parentNode || next.host;
1578 }
1579 }
1580 return false;
1581 }
1582 function getTarget(event) {
1583 if ("composedPath" in event) {
1584 return event.composedPath()[0];
1585 }
1586 return event.target;
1587 }
1588
1589 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
1590 function isTargetInsideEnabledTrigger(target, triggerElements) {
1591 if (!isElement(target)) {
1592 return false;
1593 }
1594 const targetElement = target;
1595 if (triggerElements.hasElement(targetElement)) {
1596 return !targetElement.hasAttribute("data-trigger-disabled");
1597 }
1598 for (const [, trigger] of triggerElements.entries()) {
1599 if (contains(trigger, targetElement)) {
1600 return !trigger.hasAttribute("data-trigger-disabled");
1601 }
1602 }
1603 return false;
1604 }
1605 function isEventTargetWithin(event, node) {
1606 if (node == null) {
1607 return false;
1608 }
1609 if ("composedPath" in event) {
1610 return event.composedPath().includes(node);
1611 }
1612 const eventAgain = event;
1613 return eventAgain.target != null && node.contains(eventAgain.target);
1614 }
1615 function isRootElement(element) {
1616 return element.matches("html,body");
1617 }
1618 function isTypeableElement(element) {
1619 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
1620 }
1621 function isInteractiveElement(element) {
1622 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
1623 }
1624 function matchesFocusVisible(element) {
1625 if (!element || isJSDOM) {
1626 return true;
1627 }
1628 try {
1629 return element.matches(":focus-visible");
1630 } catch (_e) {
1631 return true;
1632 }
1633 }
1634
1635 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
1636 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
1637 const directChildren = nodes.filter((node) => node.parentId === id);
1638 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
1639 }
1640
1641 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
1642 function isReactEvent(event) {
1643 return "nativeEvent" in event;
1644 }
1645 function isMouseLikePointerType(pointerType, strict) {
1646 const values = ["mouse", "pen"];
1647 if (!strict) {
1648 values.push("", void 0);
1649 }
1650 return values.includes(pointerType);
1651 }
1652 function isClickLikeEvent(event) {
1653 const type = event.type;
1654 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
1655 }
1656
1657 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
1658 var sides = ["top", "right", "bottom", "left"];
1659 var min = Math.min;
1660 var max = Math.max;
1661 var round = Math.round;
1662 var floor = Math.floor;
1663 var createCoords = (v) => ({
1664 x: v,
1665 y: v
1666 });
1667 var oppositeSideMap = {
1668 left: "right",
1669 right: "left",
1670 bottom: "top",
1671 top: "bottom"
1672 };
1673 function clamp(start, value, end) {
1674 return max(start, min(value, end));
1675 }
1676 function evaluate(value, param) {
1677 return typeof value === "function" ? value(param) : value;
1678 }
1679 function getSide(placement) {
1680 return placement.split("-")[0];
1681 }
1682 function getAlignment(placement) {
1683 return placement.split("-")[1];
1684 }
1685 function getOppositeAxis(axis) {
1686 return axis === "x" ? "y" : "x";
1687 }
1688 function getAxisLength(axis) {
1689 return axis === "y" ? "height" : "width";
1690 }
1691 function getSideAxis(placement) {
1692 const firstChar = placement[0];
1693 return firstChar === "t" || firstChar === "b" ? "y" : "x";
1694 }
1695 function getAlignmentAxis(placement) {
1696 return getOppositeAxis(getSideAxis(placement));
1697 }
1698 function getAlignmentSides(placement, rects, rtl) {
1699 if (rtl === void 0) {
1700 rtl = false;
1701 }
1702 const alignment = getAlignment(placement);
1703 const alignmentAxis = getAlignmentAxis(placement);
1704 const length = getAxisLength(alignmentAxis);
1705 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
1706 if (rects.reference[length] > rects.floating[length]) {
1707 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1708 }
1709 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
1710 }
1711 function getExpandedPlacements(placement) {
1712 const oppositePlacement = getOppositePlacement(placement);
1713 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1714 }
1715 function getOppositeAlignmentPlacement(placement) {
1716 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
1717 }
1718 var lrPlacement = ["left", "right"];
1719 var rlPlacement = ["right", "left"];
1720 var tbPlacement = ["top", "bottom"];
1721 var btPlacement = ["bottom", "top"];
1722 function getSideList(side, isStart, rtl) {
1723 switch (side) {
1724 case "top":
1725 case "bottom":
1726 if (rtl) return isStart ? rlPlacement : lrPlacement;
1727 return isStart ? lrPlacement : rlPlacement;
1728 case "left":
1729 case "right":
1730 return isStart ? tbPlacement : btPlacement;
1731 default:
1732 return [];
1733 }
1734 }
1735 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1736 const alignment = getAlignment(placement);
1737 let list = getSideList(getSide(placement), direction === "start", rtl);
1738 if (alignment) {
1739 list = list.map((side) => side + "-" + alignment);
1740 if (flipAlignment) {
1741 list = list.concat(list.map(getOppositeAlignmentPlacement));
1742 }
1743 }
1744 return list;
1745 }
1746 function getOppositePlacement(placement) {
1747 const side = getSide(placement);
1748 return oppositeSideMap[side] + placement.slice(side.length);
1749 }
1750 function expandPaddingObject(padding) {
1751 return {
1752 top: 0,
1753 right: 0,
1754 bottom: 0,
1755 left: 0,
1756 ...padding
1757 };
1758 }
1759 function getPaddingObject(padding) {
1760 return typeof padding !== "number" ? expandPaddingObject(padding) : {
1761 top: padding,
1762 right: padding,
1763 bottom: padding,
1764 left: padding
1765 };
1766 }
1767 function rectToClientRect(rect) {
1768 const {
1769 x,
1770 y,
1771 width,
1772 height
1773 } = rect;
1774 return {
1775 width,
1776 height,
1777 top: y,
1778 left: x,
1779 right: x + width,
1780 bottom: y + height,
1781 x,
1782 y
1783 };
1784 }
1785
1786 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
1787 function isHiddenByStyles(styles) {
1788 return styles.visibility === "hidden" || styles.visibility === "collapse";
1789 }
1790 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
1791 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
1792 return false;
1793 }
1794 if (typeof element.checkVisibility === "function") {
1795 return element.checkVisibility();
1796 }
1797 return styles.display !== "none" && styles.display !== "contents";
1798 }
1799
1800 // node_modules/@base-ui/utils/esm/owner.js
1801 function ownerDocument(node) {
1802 return node?.ownerDocument || document;
1803 }
1804
1805 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
1806 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
1807 function getParentElement(element) {
1808 const assignedSlot = element.assignedSlot;
1809 if (assignedSlot) {
1810 return assignedSlot;
1811 }
1812 if (element.parentElement) {
1813 return element.parentElement;
1814 }
1815 const rootNode = element.getRootNode();
1816 return isShadowRoot(rootNode) ? rootNode.host : null;
1817 }
1818 function getDetailsSummary(details) {
1819 for (const child of Array.from(details.children)) {
1820 if (getNodeName(child) === "summary") {
1821 return child;
1822 }
1823 }
1824 return null;
1825 }
1826 function isWithinOpenDetailsSummary(element, details) {
1827 const summary = getDetailsSummary(details);
1828 return !!summary && (element === summary || contains(summary, element));
1829 }
1830 function isFocusableCandidate(element) {
1831 const nodeName = element ? getNodeName(element) : "";
1832 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");
1833 }
1834 function isFocusableElement(element) {
1835 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
1836 return false;
1837 }
1838 for (let current = element; current; current = getParentElement(current)) {
1839 const isAncestor = current !== element;
1840 const isSlot = getNodeName(current) === "slot";
1841 if (current.hasAttribute("inert")) {
1842 return false;
1843 }
1844 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
1845 return false;
1846 }
1847 }
1848 return true;
1849 }
1850 function isVisibleInTabbableTree(element, isAncestor) {
1851 const styles = getComputedStyle2(element);
1852 if (!isAncestor) {
1853 return isElementVisible(element, styles);
1854 }
1855 return styles.display !== "none";
1856 }
1857 function getTabIndex(element) {
1858 const tabIndex = element.tabIndex;
1859 if (tabIndex < 0) {
1860 const nodeName = getNodeName(element);
1861 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
1862 return 0;
1863 }
1864 }
1865 return tabIndex;
1866 }
1867 function getNamedRadioInput(element) {
1868 if (getNodeName(element) !== "input") {
1869 return null;
1870 }
1871 const input = element;
1872 return input.type === "radio" && input.name !== "" ? input : null;
1873 }
1874 function isTabbableRadio(element, candidates) {
1875 const input = getNamedRadioInput(element);
1876 if (!input) {
1877 return true;
1878 }
1879 const checkedRadio = candidates.find((candidate) => {
1880 const radio = getNamedRadioInput(candidate);
1881 return radio?.name === input.name && radio.form === input.form && radio.checked;
1882 });
1883 if (checkedRadio) {
1884 return checkedRadio === input;
1885 }
1886 return candidates.find((candidate) => {
1887 const radio = getNamedRadioInput(candidate);
1888 return radio?.name === input.name && radio.form === input.form;
1889 }) === input;
1890 }
1891 function getComposedChildren(container) {
1892 if (isHTMLElement(container) && getNodeName(container) === "slot") {
1893 const assignedElements = container.assignedElements({
1894 flatten: true
1895 });
1896 if (assignedElements.length > 0) {
1897 return assignedElements;
1898 }
1899 }
1900 if (isHTMLElement(container) && container.shadowRoot) {
1901 return Array.from(container.shadowRoot.children);
1902 }
1903 return Array.from(container.children);
1904 }
1905 function appendCandidates(container, list) {
1906 getComposedChildren(container).forEach((child) => {
1907 if (isFocusableCandidate(child)) {
1908 list.push(child);
1909 }
1910 appendCandidates(child, list);
1911 });
1912 }
1913 function appendMatchingElements(container, selector, list) {
1914 getComposedChildren(container).forEach((child) => {
1915 if (isHTMLElement(child) && child.matches(selector)) {
1916 list.push(child);
1917 }
1918 appendMatchingElements(child, selector, list);
1919 });
1920 }
1921 function focusable(container) {
1922 const candidates = [];
1923 appendCandidates(container, candidates);
1924 return candidates.filter(isFocusableElement);
1925 }
1926 function tabbable(container) {
1927 const candidates = focusable(container);
1928 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
1929 }
1930 function getTabbableIn(container, dir) {
1931 const list = tabbable(container);
1932 const len = list.length;
1933 if (len === 0) {
1934 return void 0;
1935 }
1936 const active = activeElement(ownerDocument(container));
1937 const index2 = list.indexOf(active);
1938 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
1939 return list[nextIndex];
1940 }
1941 function getNextTabbable(referenceElement) {
1942 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
1943 }
1944 function getPreviousTabbable(referenceElement) {
1945 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
1946 }
1947 function isOutsideEvent(event, container) {
1948 const containerElement = container || event.currentTarget;
1949 const relatedTarget = event.relatedTarget;
1950 return !relatedTarget || !contains(containerElement, relatedTarget);
1951 }
1952 function disableFocusInside(container) {
1953 const tabbableElements = tabbable(container);
1954 tabbableElements.forEach((element) => {
1955 element.dataset.tabindex = element.getAttribute("tabindex") || "";
1956 element.setAttribute("tabindex", "-1");
1957 });
1958 }
1959 function enableFocusInside(container) {
1960 const elements = [];
1961 appendMatchingElements(container, "[data-tabindex]", elements);
1962 elements.forEach((element) => {
1963 const tabindex = element.dataset.tabindex;
1964 delete element.dataset.tabindex;
1965 if (tabindex) {
1966 element.setAttribute("tabindex", tabindex);
1967 } else {
1968 element.removeAttribute("tabindex");
1969 }
1970 });
1971 }
1972
1973 // node_modules/@base-ui/utils/esm/addEventListener.js
1974 function addEventListener(target, type, listener, options) {
1975 target.addEventListener(type, listener, options);
1976 return () => {
1977 target.removeEventListener(type, listener, options);
1978 };
1979 }
1980
1981 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
1982 var React12 = __toESM(require_react(), 1);
1983 function useOpenChangeComplete(parameters) {
1984 const {
1985 enabled = true,
1986 open,
1987 ref,
1988 onComplete: onCompleteParam
1989 } = parameters;
1990 const onComplete = useStableCallback(onCompleteParam);
1991 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
1992 React12.useEffect(() => {
1993 if (!enabled) {
1994 return void 0;
1995 }
1996 const abortController = new AbortController();
1997 runOnceAnimationsFinish(onComplete, abortController.signal);
1998 return () => {
1999 abortController.abort();
2000 };
2001 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2002 }
2003
2004 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2005 var React13 = __toESM(require_react(), 1);
2006 function useOnFirstRender(fn) {
2007 const ref = React13.useRef(true);
2008 if (ref.current) {
2009 ref.current = false;
2010 fn();
2011 }
2012 }
2013
2014 // node_modules/@base-ui/utils/esm/useTimeout.js
2015 var EMPTY3 = 0;
2016 var Timeout = class _Timeout {
2017 static create() {
2018 return new _Timeout();
2019 }
2020 currentId = EMPTY3;
2021 /**
2022 * Executes `fn` after `delay`, clearing any previously scheduled call.
2023 */
2024 start(delay, fn) {
2025 this.clear();
2026 this.currentId = setTimeout(() => {
2027 this.currentId = EMPTY3;
2028 fn();
2029 }, delay);
2030 }
2031 isStarted() {
2032 return this.currentId !== EMPTY3;
2033 }
2034 clear = () => {
2035 if (this.currentId !== EMPTY3) {
2036 clearTimeout(this.currentId);
2037 this.currentId = EMPTY3;
2038 }
2039 };
2040 disposeEffect = () => {
2041 return this.clear;
2042 };
2043 };
2044 function useTimeout() {
2045 const timeout = useRefWithInit(Timeout.create).current;
2046 useOnMount(timeout.disposeEffect);
2047 return timeout;
2048 }
2049
2050 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2051 var React14 = __toESM(require_react(), 1);
2052
2053 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2054 function resolveValue(value, pointerType) {
2055 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2056 return 0;
2057 }
2058 if (typeof value === "function") {
2059 return value();
2060 }
2061 return value;
2062 }
2063 function getDelay(value, prop, pointerType) {
2064 const result = resolveValue(value, pointerType);
2065 if (typeof result === "number") {
2066 return result;
2067 }
2068 return result?.[prop];
2069 }
2070 function getRestMs(value) {
2071 if (typeof value === "function") {
2072 return value();
2073 }
2074 return value;
2075 }
2076 function isClickLikeOpenEvent(openEventType, interactedInside) {
2077 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2078 }
2079
2080 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2081 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2082 var FloatingDelayGroupContext = /* @__PURE__ */ React14.createContext({
2083 hasProvider: false,
2084 timeoutMs: 0,
2085 delayRef: {
2086 current: 0
2087 },
2088 initialDelayRef: {
2089 current: 0
2090 },
2091 timeout: new Timeout(),
2092 currentIdRef: {
2093 current: null
2094 },
2095 currentContextRef: {
2096 current: null
2097 }
2098 });
2099 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2100 function FloatingDelayGroup(props) {
2101 const {
2102 children,
2103 delay,
2104 timeoutMs = 0
2105 } = props;
2106 const delayRef = React14.useRef(delay);
2107 const initialDelayRef = React14.useRef(delay);
2108 const currentIdRef = React14.useRef(null);
2109 const currentContextRef = React14.useRef(null);
2110 const timeout = useTimeout();
2111 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2112 value: React14.useMemo(() => ({
2113 hasProvider: true,
2114 delayRef,
2115 initialDelayRef,
2116 currentIdRef,
2117 timeoutMs,
2118 currentContextRef,
2119 timeout
2120 }), [timeoutMs, timeout]),
2121 children
2122 });
2123 }
2124 function useDelayGroup(context, options = {
2125 open: false
2126 }) {
2127 const store2 = "rootStore" in context ? context.rootStore : context;
2128 const floatingId = store2.useState("floatingId");
2129 const {
2130 open
2131 } = options;
2132 const groupContext = React14.useContext(FloatingDelayGroupContext);
2133 const {
2134 currentIdRef,
2135 delayRef,
2136 timeoutMs,
2137 initialDelayRef,
2138 currentContextRef,
2139 hasProvider,
2140 timeout
2141 } = groupContext;
2142 const [isInstantPhase, setIsInstantPhase] = React14.useState(false);
2143 useIsoLayoutEffect(() => {
2144 function unset() {
2145 setIsInstantPhase(false);
2146 currentContextRef.current?.setIsInstantPhase(false);
2147 currentIdRef.current = null;
2148 currentContextRef.current = null;
2149 delayRef.current = initialDelayRef.current;
2150 }
2151 if (!currentIdRef.current) {
2152 return void 0;
2153 }
2154 if (!open && currentIdRef.current === floatingId) {
2155 setIsInstantPhase(false);
2156 if (timeoutMs) {
2157 const closingId = floatingId;
2158 timeout.start(timeoutMs, () => {
2159 if (store2.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2160 return;
2161 }
2162 unset();
2163 });
2164 return () => {
2165 timeout.clear();
2166 };
2167 }
2168 unset();
2169 }
2170 return void 0;
2171 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store2]);
2172 useIsoLayoutEffect(() => {
2173 if (!open) {
2174 return;
2175 }
2176 const prevContext = currentContextRef.current;
2177 const prevId = currentIdRef.current;
2178 timeout.clear();
2179 currentContextRef.current = {
2180 onOpenChange: store2.setOpen,
2181 setIsInstantPhase
2182 };
2183 currentIdRef.current = floatingId;
2184 delayRef.current = {
2185 open: 0,
2186 close: getDelay(initialDelayRef.current, "close")
2187 };
2188 if (prevId !== null && prevId !== floatingId) {
2189 setIsInstantPhase(true);
2190 prevContext?.setIsInstantPhase(true);
2191 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2192 } else {
2193 setIsInstantPhase(false);
2194 prevContext?.setIsInstantPhase(false);
2195 }
2196 }, [open, floatingId, store2, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]);
2197 useIsoLayoutEffect(() => {
2198 return () => {
2199 currentContextRef.current = null;
2200 };
2201 }, [currentContextRef]);
2202 return React14.useMemo(() => ({
2203 hasProvider,
2204 delayRef,
2205 isInstantPhase
2206 }), [hasProvider, delayRef, isInstantPhase]);
2207 }
2208
2209 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2210 function mergeCleanups(...cleanups) {
2211 return () => {
2212 for (let i = 0; i < cleanups.length; i += 1) {
2213 const cleanup = cleanups[i];
2214 if (cleanup) {
2215 cleanup();
2216 }
2217 }
2218 };
2219 }
2220
2221 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2222 function useValueAsRef(value) {
2223 const latest = useRefWithInit(createLatestRef, value).current;
2224 latest.next = value;
2225 useIsoLayoutEffect(latest.effect);
2226 return latest;
2227 }
2228 function createLatestRef(value) {
2229 const latest = {
2230 current: value,
2231 next: value,
2232 effect: () => {
2233 latest.current = latest.next;
2234 }
2235 };
2236 return latest;
2237 }
2238
2239 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2240 var React15 = __toESM(require_react(), 1);
2241
2242 // node_modules/@base-ui/utils/esm/visuallyHidden.js
2243 var visuallyHiddenBase = {
2244 clipPath: "inset(50%)",
2245 overflow: "hidden",
2246 whiteSpace: "nowrap",
2247 border: 0,
2248 padding: 0,
2249 width: 1,
2250 height: 1,
2251 margin: -1
2252 };
2253 var visuallyHidden = {
2254 ...visuallyHiddenBase,
2255 position: "fixed",
2256 top: 0,
2257 left: 0
2258 };
2259 var visuallyHiddenInput = {
2260 ...visuallyHiddenBase,
2261 position: "absolute"
2262 };
2263
2264 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2265 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2266 var FocusGuard = /* @__PURE__ */ React15.forwardRef(function FocusGuard2(props, ref) {
2267 const [role, setRole] = React15.useState();
2268 useIsoLayoutEffect(() => {
2269 if (isSafari) {
2270 setRole("button");
2271 }
2272 }, []);
2273 const restProps = {
2274 tabIndex: 0,
2275 // Role is only for VoiceOver
2276 role
2277 };
2278 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
2279 ...props,
2280 ref,
2281 style: visuallyHidden,
2282 "aria-hidden": role ? void 0 : true,
2283 ...restProps,
2284 "data-base-ui-focus-guard": ""
2285 });
2286 });
2287 if (true) FocusGuard.displayName = "FocusGuard";
2288
2289 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
2290 function createAttribute(name) {
2291 return `data-base-ui-${name}`;
2292 }
2293
2294 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2295 var React16 = __toESM(require_react(), 1);
2296 var ReactDOM2 = __toESM(require_react_dom(), 1);
2297
2298 // node_modules/@base-ui/react/esm/internals/constants.js
2299 var DISABLED_TRANSITIONS_STYLE = {
2300 style: {
2301 transition: "none"
2302 }
2303 };
2304 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2305 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2306 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2307 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2308 var POPUP_COLLISION_AVOIDANCE = {
2309 fallbackAxisSide: "end"
2310 };
2311 var ownerVisuallyHidden = {
2312 clipPath: "inset(50%)",
2313 position: "fixed",
2314 top: 0,
2315 left: 0
2316 };
2317
2318 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2319 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
2320 var PortalContext = /* @__PURE__ */ React16.createContext(null);
2321 if (true) PortalContext.displayName = "PortalContext";
2322 var usePortalContext = () => React16.useContext(PortalContext);
2323 var attr = createAttribute("portal");
2324 function useFloatingPortalNode(props = {}) {
2325 const {
2326 ref,
2327 container: containerProp,
2328 componentProps = EMPTY_OBJECT,
2329 elementProps
2330 } = props;
2331 const uniqueId = useId();
2332 const portalContext = usePortalContext();
2333 const parentPortalNode = portalContext?.portalNode;
2334 const [containerElement, setContainerElement] = React16.useState(null);
2335 const [portalNode, setPortalNode] = React16.useState(null);
2336 const setPortalNodeRef = useStableCallback((node) => {
2337 if (node !== null) {
2338 setPortalNode(node);
2339 }
2340 });
2341 const containerRef = React16.useRef(null);
2342 useIsoLayoutEffect(() => {
2343 if (containerProp === null) {
2344 if (containerRef.current) {
2345 containerRef.current = null;
2346 setPortalNode(null);
2347 setContainerElement(null);
2348 }
2349 return;
2350 }
2351 if (uniqueId == null) {
2352 return;
2353 }
2354 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2355 if (resolvedContainer == null) {
2356 if (containerRef.current) {
2357 containerRef.current = null;
2358 setPortalNode(null);
2359 setContainerElement(null);
2360 }
2361 return;
2362 }
2363 if (containerRef.current !== resolvedContainer) {
2364 containerRef.current = resolvedContainer;
2365 setPortalNode(null);
2366 setContainerElement(resolvedContainer);
2367 }
2368 }, [containerProp, parentPortalNode, uniqueId]);
2369 const portalElement = useRenderElement("div", componentProps, {
2370 ref: [ref, setPortalNodeRef],
2371 props: [{
2372 id: uniqueId,
2373 [attr]: ""
2374 }, elementProps]
2375 });
2376 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2377 return {
2378 portalNode,
2379 portalSubtree
2380 };
2381 }
2382 var FloatingPortal = /* @__PURE__ */ React16.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2383 const {
2384 children,
2385 container,
2386 className,
2387 render,
2388 renderGuards,
2389 style,
2390 ...elementProps
2391 } = componentProps;
2392 const {
2393 portalNode,
2394 portalSubtree
2395 } = useFloatingPortalNode({
2396 container,
2397 ref: forwardedRef,
2398 componentProps,
2399 elementProps
2400 });
2401 const beforeOutsideRef = React16.useRef(null);
2402 const afterOutsideRef = React16.useRef(null);
2403 const beforeInsideRef = React16.useRef(null);
2404 const afterInsideRef = React16.useRef(null);
2405 const [focusManagerState, setFocusManagerState] = React16.useState(null);
2406 const focusInsideDisabledRef = React16.useRef(false);
2407 const modal = focusManagerState?.modal;
2408 const open = focusManagerState?.open;
2409 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2410 React16.useEffect(() => {
2411 if (!portalNode || modal) {
2412 return void 0;
2413 }
2414 function onFocus(event) {
2415 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2416 if (event.type === "focusin") {
2417 if (focusInsideDisabledRef.current) {
2418 enableFocusInside(portalNode);
2419 focusInsideDisabledRef.current = false;
2420 }
2421 } else {
2422 disableFocusInside(portalNode);
2423 focusInsideDisabledRef.current = true;
2424 }
2425 }
2426 }
2427 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
2428 }, [portalNode, modal]);
2429 React16.useEffect(() => {
2430 if (!portalNode || open !== false) {
2431 return;
2432 }
2433 enableFocusInside(portalNode);
2434 focusInsideDisabledRef.current = false;
2435 }, [open, portalNode]);
2436 const portalContextValue = React16.useMemo(() => ({
2437 beforeOutsideRef,
2438 afterOutsideRef,
2439 beforeInsideRef,
2440 afterInsideRef,
2441 portalNode,
2442 setFocusManagerState
2443 }), [portalNode]);
2444 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React16.Fragment, {
2445 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
2446 value: portalContextValue,
2447 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2448 "data-type": "outside",
2449 ref: beforeOutsideRef,
2450 onFocus: (event) => {
2451 if (isOutsideEvent(event, portalNode)) {
2452 beforeInsideRef.current?.focus();
2453 } else {
2454 const domReference = focusManagerState ? focusManagerState.domReference : null;
2455 const prevTabbable = getPreviousTabbable(domReference);
2456 prevTabbable?.focus();
2457 }
2458 }
2459 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
2460 "aria-owns": portalNode.id,
2461 style: ownerVisuallyHidden
2462 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2463 "data-type": "outside",
2464 ref: afterOutsideRef,
2465 onFocus: (event) => {
2466 if (isOutsideEvent(event, portalNode)) {
2467 afterInsideRef.current?.focus();
2468 } else {
2469 const domReference = focusManagerState ? focusManagerState.domReference : null;
2470 const nextTabbable = getNextTabbable(domReference);
2471 nextTabbable?.focus();
2472 if (focusManagerState?.closeOnFocusOut) {
2473 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
2474 }
2475 }
2476 }
2477 })]
2478 })]
2479 });
2480 });
2481 if (true) FloatingPortal.displayName = "FloatingPortal";
2482
2483 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2484 var React17 = __toESM(require_react(), 1);
2485
2486 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
2487 function createEventEmitter() {
2488 const map = /* @__PURE__ */ new Map();
2489 return {
2490 emit(event, data) {
2491 map.get(event)?.forEach((listener) => listener(data));
2492 },
2493 on(event, listener) {
2494 if (!map.has(event)) {
2495 map.set(event, /* @__PURE__ */ new Set());
2496 }
2497 map.get(event).add(listener);
2498 },
2499 off(event, listener) {
2500 map.get(event)?.delete(listener);
2501 }
2502 };
2503 }
2504
2505 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2506 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
2507 var FloatingNodeContext = /* @__PURE__ */ React17.createContext(null);
2508 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
2509 var FloatingTreeContext = /* @__PURE__ */ React17.createContext(null);
2510 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
2511 var useFloatingParentNodeId = () => React17.useContext(FloatingNodeContext)?.id || null;
2512 var useFloatingTree = (externalTree) => {
2513 const contextTree = React17.useContext(FloatingTreeContext);
2514 return externalTree ?? contextTree;
2515 };
2516
2517 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
2518 var React18 = __toESM(require_react(), 1);
2519 function createVirtualElement(domElement, data) {
2520 let offsetX = null;
2521 let offsetY = null;
2522 let isAutoUpdateEvent = false;
2523 return {
2524 contextElement: domElement || void 0,
2525 getBoundingClientRect() {
2526 const domRect = domElement?.getBoundingClientRect() || {
2527 width: 0,
2528 height: 0,
2529 x: 0,
2530 y: 0
2531 };
2532 const isXAxis = data.axis === "x" || data.axis === "both";
2533 const isYAxis = data.axis === "y" || data.axis === "both";
2534 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
2535 let width = domRect.width;
2536 let height = domRect.height;
2537 let x = domRect.x;
2538 let y = domRect.y;
2539 if (offsetX == null && data.x && isXAxis) {
2540 offsetX = domRect.x - data.x;
2541 }
2542 if (offsetY == null && data.y && isYAxis) {
2543 offsetY = domRect.y - data.y;
2544 }
2545 x -= offsetX || 0;
2546 y -= offsetY || 0;
2547 width = 0;
2548 height = 0;
2549 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
2550 width = data.axis === "y" ? domRect.width : 0;
2551 height = data.axis === "x" ? domRect.height : 0;
2552 x = isXAxis && data.x != null ? data.x : x;
2553 y = isYAxis && data.y != null ? data.y : y;
2554 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
2555 height = data.axis === "x" ? domRect.height : height;
2556 width = data.axis === "y" ? domRect.width : width;
2557 }
2558 isAutoUpdateEvent = true;
2559 return {
2560 width,
2561 height,
2562 x,
2563 y,
2564 top: y,
2565 right: x + width,
2566 bottom: y + height,
2567 left: x
2568 };
2569 }
2570 };
2571 }
2572 function isMouseBasedEvent(event) {
2573 return event != null && event.clientX != null;
2574 }
2575 function useClientPoint(context, props = {}) {
2576 const store2 = "rootStore" in context ? context.rootStore : context;
2577 const open = store2.useState("open");
2578 const floating = store2.useState("floatingElement");
2579 const domReference = store2.useState("domReferenceElement");
2580 const dataRef = store2.context.dataRef;
2581 const {
2582 enabled = true,
2583 axis = "both"
2584 } = props;
2585 const initialRef = React18.useRef(false);
2586 const cleanupListenerRef = React18.useRef(null);
2587 const [pointerType, setPointerType] = React18.useState();
2588 const [reactive, setReactive] = React18.useState([]);
2589 const setReference = useStableCallback((newX, newY, referenceElement) => {
2590 if (initialRef.current) {
2591 return;
2592 }
2593 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
2594 return;
2595 }
2596 store2.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
2597 x: newX,
2598 y: newY,
2599 axis,
2600 dataRef,
2601 pointerType
2602 }));
2603 });
2604 const handleReferenceEnterOrMove = useStableCallback((event) => {
2605 if (!open) {
2606 setReference(event.clientX, event.clientY, event.currentTarget);
2607 } else if (!cleanupListenerRef.current) {
2608 setReactive([]);
2609 }
2610 });
2611 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
2612 const addListener = React18.useCallback(() => {
2613 if (!openCheck || !enabled) {
2614 return void 0;
2615 }
2616 const win = getWindow(floating);
2617 function handleMouseMove(event) {
2618 const target = getTarget(event);
2619 if (!contains(floating, target)) {
2620 setReference(event.clientX, event.clientY);
2621 } else {
2622 cleanupListenerRef.current?.();
2623 cleanupListenerRef.current = null;
2624 }
2625 }
2626 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
2627 const cleanup = () => {
2628 cleanupListenerRef.current?.();
2629 cleanupListenerRef.current = null;
2630 };
2631 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
2632 return cleanup;
2633 }
2634 store2.set("positionReference", domReference);
2635 return void 0;
2636 }, [openCheck, enabled, floating, dataRef, domReference, store2, setReference]);
2637 React18.useEffect(() => {
2638 return addListener();
2639 }, [addListener, reactive]);
2640 React18.useEffect(() => {
2641 if (enabled && !floating) {
2642 initialRef.current = false;
2643 }
2644 }, [enabled, floating]);
2645 React18.useEffect(() => {
2646 if (!enabled && open) {
2647 initialRef.current = true;
2648 }
2649 }, [enabled, open]);
2650 const reference = React18.useMemo(() => {
2651 function setPointerTypeRef(event) {
2652 setPointerType(event.pointerType);
2653 }
2654 return {
2655 onPointerDown: setPointerTypeRef,
2656 onPointerEnter: setPointerTypeRef,
2657 onMouseMove: handleReferenceEnterOrMove,
2658 onMouseEnter: handleReferenceEnterOrMove
2659 };
2660 }, [handleReferenceEnterOrMove]);
2661 return React18.useMemo(() => enabled ? {
2662 reference,
2663 trigger: reference
2664 } : {}, [enabled, reference]);
2665 }
2666
2667 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
2668 var React19 = __toESM(require_react(), 1);
2669 var bubbleHandlerKeys = {
2670 intentional: "onClick",
2671 sloppy: "onPointerDown"
2672 };
2673 function alwaysFalse() {
2674 return false;
2675 }
2676 function normalizeProp(normalizable) {
2677 return {
2678 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
2679 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
2680 };
2681 }
2682 function useDismiss(context, props = {}) {
2683 const store2 = "rootStore" in context ? context.rootStore : context;
2684 const open = store2.useState("open");
2685 const floatingElement = store2.useState("floatingElement");
2686 const {
2687 dataRef
2688 } = store2.context;
2689 const {
2690 enabled = true,
2691 escapeKey: escapeKey2 = true,
2692 outsidePress: outsidePressProp = true,
2693 outsidePressEvent = "sloppy",
2694 referencePress = alwaysFalse,
2695 referencePressEvent = "sloppy",
2696 bubbles,
2697 externalTree
2698 } = props;
2699 const tree = useFloatingTree(externalTree);
2700 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
2701 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
2702 const outsidePressEnabled = outsidePress2 !== false;
2703 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
2704 const pressStartedInsideRef = React19.useRef(false);
2705 const pressStartPreventedRef = React19.useRef(false);
2706 const suppressNextOutsideClickRef = React19.useRef(false);
2707 const {
2708 escapeKey: escapeKeyBubbles,
2709 outsidePress: outsidePressBubbles
2710 } = normalizeProp(bubbles);
2711 const touchStateRef = React19.useRef(null);
2712 const cancelDismissOnEndTimeout = useTimeout();
2713 const clearInsideReactTreeTimeout = useTimeout();
2714 const clearInsideReactTree = useStableCallback(() => {
2715 clearInsideReactTreeTimeout.clear();
2716 dataRef.current.insideReactTree = false;
2717 });
2718 const isComposingRef = React19.useRef(false);
2719 const currentPointerTypeRef = React19.useRef("");
2720 const isReferencePressEnabled = useStableCallback(referencePress);
2721 const closeOnEscapeKeyDown = useStableCallback((event) => {
2722 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
2723 return;
2724 }
2725 if (isComposingRef.current) {
2726 return;
2727 }
2728 const nodeId = dataRef.current.floatingContext?.nodeId;
2729 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
2730 if (!escapeKeyBubbles) {
2731 if (children.length > 0) {
2732 let shouldDismiss = true;
2733 children.forEach((child) => {
2734 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) {
2735 shouldDismiss = false;
2736 }
2737 });
2738 if (!shouldDismiss) {
2739 return;
2740 }
2741 }
2742 }
2743 const native = isReactEvent(event) ? event.nativeEvent : event;
2744 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
2745 store2.setOpen(false, eventDetails);
2746 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
2747 event.stopPropagation();
2748 }
2749 });
2750 const markInsideReactTree = useStableCallback(() => {
2751 dataRef.current.insideReactTree = true;
2752 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
2753 });
2754 React19.useEffect(() => {
2755 if (!open || !enabled) {
2756 return void 0;
2757 }
2758 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
2759 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
2760 const compositionTimeout = new Timeout();
2761 const preventedPressSuppressionTimeout = new Timeout();
2762 function handleCompositionStart() {
2763 compositionTimeout.clear();
2764 isComposingRef.current = true;
2765 }
2766 function handleCompositionEnd() {
2767 compositionTimeout.start(
2768 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
2769 // Only apply to WebKit for the test to remain 0ms.
2770 isWebKit() ? 5 : 0,
2771 () => {
2772 isComposingRef.current = false;
2773 }
2774 );
2775 }
2776 function suppressImmediateOutsideClickAfterPreventedStart() {
2777 suppressNextOutsideClickRef.current = true;
2778 preventedPressSuppressionTimeout.start(0, () => {
2779 suppressNextOutsideClickRef.current = false;
2780 });
2781 }
2782 function resetPressStartState() {
2783 pressStartedInsideRef.current = false;
2784 pressStartPreventedRef.current = false;
2785 }
2786 function getOutsidePressEvent() {
2787 const type = currentPointerTypeRef.current;
2788 const computedType = type === "pen" || !type ? "mouse" : type;
2789 const outsidePressEventValue = getOutsidePressEventProp();
2790 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
2791 if (typeof resolved === "string") {
2792 return resolved;
2793 }
2794 return resolved[computedType];
2795 }
2796 function shouldIgnoreEvent(event) {
2797 const computedOutsidePressEvent = getOutsidePressEvent();
2798 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
2799 }
2800 function isEventWithinFloatingTree(event) {
2801 const nodeId = dataRef.current.floatingContext?.nodeId;
2802 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
2803 return isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement")) || targetIsInsideChildren;
2804 }
2805 function closeOnPressOutside(event) {
2806 if (shouldIgnoreEvent(event)) {
2807 clearInsideReactTree();
2808 return;
2809 }
2810 if (dataRef.current.insideReactTree) {
2811 clearInsideReactTree();
2812 return;
2813 }
2814 const target = getTarget(event);
2815 const inertSelector = `[${createAttribute("inert")}]`;
2816 const targetRoot = isElement(target) ? target.getRootNode() : null;
2817 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store2.select("floatingElement"))).querySelectorAll(inertSelector));
2818 const triggers = store2.context.triggerElements;
2819 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
2820 return;
2821 }
2822 let targetRootAncestor = isElement(target) ? target : null;
2823 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
2824 const nextParent = getParentNode(targetRootAncestor);
2825 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
2826 break;
2827 }
2828 targetRootAncestor = nextParent;
2829 }
2830 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
2831 !contains(target, store2.select("floatingElement")) && // If the target root element contains none of the markers, then the
2832 // element was injected after the floating element rendered.
2833 markers.every((marker) => !contains(targetRootAncestor, marker))) {
2834 return;
2835 }
2836 if (isHTMLElement(target) && !("touches" in event)) {
2837 const lastTraversableNode = isLastTraversableNode(target);
2838 const style = getComputedStyle2(target);
2839 const scrollRe = /auto|scroll/;
2840 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
2841 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
2842 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
2843 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
2844 const isRTL3 = style.direction === "rtl";
2845 const pressedVerticalScrollbar = canScrollY && (isRTL3 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
2846 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
2847 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
2848 return;
2849 }
2850 }
2851 if (isEventWithinFloatingTree(event)) {
2852 return;
2853 }
2854 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
2855 preventedPressSuppressionTimeout.clear();
2856 suppressNextOutsideClickRef.current = false;
2857 return;
2858 }
2859 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
2860 return;
2861 }
2862 const nodeId = dataRef.current.floatingContext?.nodeId;
2863 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
2864 if (children.length > 0) {
2865 let shouldDismiss = true;
2866 children.forEach((child) => {
2867 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) {
2868 shouldDismiss = false;
2869 }
2870 });
2871 if (!shouldDismiss) {
2872 return;
2873 }
2874 }
2875 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
2876 clearInsideReactTree();
2877 }
2878 function handlePointerDown(event) {
2879 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store2.select("open") || !enabled || isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement"))) {
2880 return;
2881 }
2882 closeOnPressOutside(event);
2883 }
2884 function handleTouchStart(event) {
2885 if (getOutsidePressEvent() !== "sloppy" || !store2.select("open") || !enabled || isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement"))) {
2886 return;
2887 }
2888 const touch = event.touches[0];
2889 if (touch) {
2890 touchStateRef.current = {
2891 startTime: Date.now(),
2892 startX: touch.clientX,
2893 startY: touch.clientY,
2894 dismissOnTouchEnd: false,
2895 dismissOnMouseDown: true
2896 };
2897 cancelDismissOnEndTimeout.start(1e3, () => {
2898 if (touchStateRef.current) {
2899 touchStateRef.current.dismissOnTouchEnd = false;
2900 touchStateRef.current.dismissOnMouseDown = false;
2901 }
2902 });
2903 }
2904 }
2905 function addTargetEventListenerOnce(event, listener) {
2906 const target = getTarget(event);
2907 if (!target) {
2908 return;
2909 }
2910 const unsubscribe2 = addEventListener(target, event.type, () => {
2911 listener(event);
2912 unsubscribe2();
2913 });
2914 }
2915 function handleTouchStartCapture(event) {
2916 currentPointerTypeRef.current = "touch";
2917 addTargetEventListenerOnce(event, handleTouchStart);
2918 }
2919 function closeOnPressOutsideCapture(event) {
2920 cancelDismissOnEndTimeout.clear();
2921 if (event.type === "pointerdown") {
2922 currentPointerTypeRef.current = event.pointerType;
2923 }
2924 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
2925 return;
2926 }
2927 addTargetEventListenerOnce(event, (targetEvent) => {
2928 if (targetEvent.type === "pointerdown") {
2929 handlePointerDown(targetEvent);
2930 } else {
2931 closeOnPressOutside(targetEvent);
2932 }
2933 });
2934 }
2935 function handlePressEndCapture(event) {
2936 if (!pressStartedInsideRef.current) {
2937 return;
2938 }
2939 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
2940 resetPressStartState();
2941 if (getOutsidePressEvent() !== "intentional") {
2942 return;
2943 }
2944 if (event.type === "pointercancel") {
2945 if (pressStartedInsideDefaultPrevented) {
2946 suppressImmediateOutsideClickAfterPreventedStart();
2947 }
2948 return;
2949 }
2950 if (isEventWithinFloatingTree(event)) {
2951 return;
2952 }
2953 if (pressStartedInsideDefaultPrevented) {
2954 suppressImmediateOutsideClickAfterPreventedStart();
2955 return;
2956 }
2957 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
2958 return;
2959 }
2960 preventedPressSuppressionTimeout.clear();
2961 suppressNextOutsideClickRef.current = true;
2962 clearInsideReactTree();
2963 }
2964 function handleTouchMove(event) {
2965 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement"))) {
2966 return;
2967 }
2968 const touch = event.touches[0];
2969 if (!touch) {
2970 return;
2971 }
2972 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
2973 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
2974 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
2975 if (distance > 5) {
2976 touchStateRef.current.dismissOnTouchEnd = true;
2977 }
2978 if (distance > 10) {
2979 closeOnPressOutside(event);
2980 cancelDismissOnEndTimeout.clear();
2981 touchStateRef.current = null;
2982 }
2983 }
2984 function handleTouchMoveCapture(event) {
2985 addTargetEventListenerOnce(event, handleTouchMove);
2986 }
2987 function handleTouchEnd(event) {
2988 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement"))) {
2989 return;
2990 }
2991 if (touchStateRef.current.dismissOnTouchEnd) {
2992 closeOnPressOutside(event);
2993 }
2994 cancelDismissOnEndTimeout.clear();
2995 touchStateRef.current = null;
2996 }
2997 function handleTouchEndCapture(event) {
2998 addTargetEventListenerOnce(event, handleTouchEnd);
2999 }
3000 const doc = ownerDocument(floatingElement);
3001 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)));
3002 return () => {
3003 unsubscribe();
3004 compositionTimeout.clear();
3005 preventedPressSuppressionTimeout.clear();
3006 resetPressStartState();
3007 suppressNextOutsideClickRef.current = false;
3008 };
3009 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store2, cancelDismissOnEndTimeout]);
3010 React19.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3011 const reference = React19.useMemo(() => ({
3012 onKeyDown: closeOnEscapeKeyDown,
3013 [bubbleHandlerKeys[referencePressEvent]]: (event) => {
3014 if (!isReferencePressEnabled()) {
3015 return;
3016 }
3017 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3018 },
3019 ...referencePressEvent !== "intentional" && {
3020 onClick(event) {
3021 if (!isReferencePressEnabled()) {
3022 return;
3023 }
3024 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3025 }
3026 }
3027 }), [closeOnEscapeKeyDown, store2, referencePressEvent, isReferencePressEnabled]);
3028 const markPressStartedInsideReactTree = useStableCallback((event) => {
3029 if (!open || !enabled || event.button !== 0) {
3030 return;
3031 }
3032 const target = getTarget(event.nativeEvent);
3033 if (!contains(store2.select("floatingElement"), target)) {
3034 return;
3035 }
3036 if (!pressStartedInsideRef.current) {
3037 pressStartedInsideRef.current = true;
3038 pressStartPreventedRef.current = false;
3039 }
3040 });
3041 const markInsidePressStartPrevented = useStableCallback((event) => {
3042 if (!open || !enabled) {
3043 return;
3044 }
3045 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3046 return;
3047 }
3048 if (pressStartedInsideRef.current) {
3049 pressStartPreventedRef.current = true;
3050 }
3051 });
3052 const floating = React19.useMemo(() => ({
3053 onKeyDown: closeOnEscapeKeyDown,
3054 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3055 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3056 // See https://github.com/mui/base-ui/pull/3379
3057 onPointerDown: markInsidePressStartPrevented,
3058 onMouseDown: markInsidePressStartPrevented,
3059 onClickCapture: markInsideReactTree,
3060 onMouseDownCapture(event) {
3061 markInsideReactTree();
3062 markPressStartedInsideReactTree(event);
3063 },
3064 onPointerDownCapture(event) {
3065 markInsideReactTree();
3066 markPressStartedInsideReactTree(event);
3067 },
3068 onMouseUpCapture: markInsideReactTree,
3069 onTouchEndCapture: markInsideReactTree,
3070 onTouchMoveCapture: markInsideReactTree
3071 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3072 return React19.useMemo(() => enabled ? {
3073 reference,
3074 floating,
3075 trigger: reference
3076 } : {}, [enabled, reference, floating]);
3077 }
3078
3079 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3080 var React25 = __toESM(require_react(), 1);
3081
3082 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3083 function computeCoordsFromPlacement(_ref, placement, rtl) {
3084 let {
3085 reference,
3086 floating
3087 } = _ref;
3088 const sideAxis = getSideAxis(placement);
3089 const alignmentAxis = getAlignmentAxis(placement);
3090 const alignLength = getAxisLength(alignmentAxis);
3091 const side = getSide(placement);
3092 const isVertical = sideAxis === "y";
3093 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3094 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3095 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3096 let coords;
3097 switch (side) {
3098 case "top":
3099 coords = {
3100 x: commonX,
3101 y: reference.y - floating.height
3102 };
3103 break;
3104 case "bottom":
3105 coords = {
3106 x: commonX,
3107 y: reference.y + reference.height
3108 };
3109 break;
3110 case "right":
3111 coords = {
3112 x: reference.x + reference.width,
3113 y: commonY
3114 };
3115 break;
3116 case "left":
3117 coords = {
3118 x: reference.x - floating.width,
3119 y: commonY
3120 };
3121 break;
3122 default:
3123 coords = {
3124 x: reference.x,
3125 y: reference.y
3126 };
3127 }
3128 switch (getAlignment(placement)) {
3129 case "start":
3130 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3131 break;
3132 case "end":
3133 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3134 break;
3135 }
3136 return coords;
3137 }
3138 async function detectOverflow(state, options) {
3139 var _await$platform$isEle;
3140 if (options === void 0) {
3141 options = {};
3142 }
3143 const {
3144 x,
3145 y,
3146 platform: platform3,
3147 rects,
3148 elements,
3149 strategy
3150 } = state;
3151 const {
3152 boundary = "clippingAncestors",
3153 rootBoundary = "viewport",
3154 elementContext = "floating",
3155 altBoundary = false,
3156 padding = 0
3157 } = evaluate(options, state);
3158 const paddingObject = getPaddingObject(padding);
3159 const altContext = elementContext === "floating" ? "reference" : "floating";
3160 const element = elements[altBoundary ? altContext : elementContext];
3161 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3162 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)),
3163 boundary,
3164 rootBoundary,
3165 strategy
3166 }));
3167 const rect = elementContext === "floating" ? {
3168 x,
3169 y,
3170 width: rects.floating.width,
3171 height: rects.floating.height
3172 } : rects.reference;
3173 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3174 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3175 x: 1,
3176 y: 1
3177 } : {
3178 x: 1,
3179 y: 1
3180 };
3181 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3182 elements,
3183 rect,
3184 offsetParent,
3185 strategy
3186 }) : rect);
3187 return {
3188 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3189 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3190 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3191 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3192 };
3193 }
3194 var MAX_RESET_COUNT = 50;
3195 var computePosition = async (reference, floating, config) => {
3196 const {
3197 placement = "bottom",
3198 strategy = "absolute",
3199 middleware = [],
3200 platform: platform3
3201 } = config;
3202 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3203 ...platform3,
3204 detectOverflow
3205 };
3206 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3207 let rects = await platform3.getElementRects({
3208 reference,
3209 floating,
3210 strategy
3211 });
3212 let {
3213 x,
3214 y
3215 } = computeCoordsFromPlacement(rects, placement, rtl);
3216 let statefulPlacement = placement;
3217 let resetCount = 0;
3218 const middlewareData = {};
3219 for (let i = 0; i < middleware.length; i++) {
3220 const currentMiddleware = middleware[i];
3221 if (!currentMiddleware) {
3222 continue;
3223 }
3224 const {
3225 name,
3226 fn
3227 } = currentMiddleware;
3228 const {
3229 x: nextX,
3230 y: nextY,
3231 data,
3232 reset
3233 } = await fn({
3234 x,
3235 y,
3236 initialPlacement: placement,
3237 placement: statefulPlacement,
3238 strategy,
3239 middlewareData,
3240 rects,
3241 platform: platformWithDetectOverflow,
3242 elements: {
3243 reference,
3244 floating
3245 }
3246 });
3247 x = nextX != null ? nextX : x;
3248 y = nextY != null ? nextY : y;
3249 middlewareData[name] = {
3250 ...middlewareData[name],
3251 ...data
3252 };
3253 if (reset && resetCount < MAX_RESET_COUNT) {
3254 resetCount++;
3255 if (typeof reset === "object") {
3256 if (reset.placement) {
3257 statefulPlacement = reset.placement;
3258 }
3259 if (reset.rects) {
3260 rects = reset.rects === true ? await platform3.getElementRects({
3261 reference,
3262 floating,
3263 strategy
3264 }) : reset.rects;
3265 }
3266 ({
3267 x,
3268 y
3269 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3270 }
3271 i = -1;
3272 }
3273 }
3274 return {
3275 x,
3276 y,
3277 placement: statefulPlacement,
3278 strategy,
3279 middlewareData
3280 };
3281 };
3282 var flip = function(options) {
3283 if (options === void 0) {
3284 options = {};
3285 }
3286 return {
3287 name: "flip",
3288 options,
3289 async fn(state) {
3290 var _middlewareData$arrow, _middlewareData$flip;
3291 const {
3292 placement,
3293 middlewareData,
3294 rects,
3295 initialPlacement,
3296 platform: platform3,
3297 elements
3298 } = state;
3299 const {
3300 mainAxis: checkMainAxis = true,
3301 crossAxis: checkCrossAxis = true,
3302 fallbackPlacements: specifiedFallbackPlacements,
3303 fallbackStrategy = "bestFit",
3304 fallbackAxisSideDirection = "none",
3305 flipAlignment = true,
3306 ...detectOverflowOptions
3307 } = evaluate(options, state);
3308 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3309 return {};
3310 }
3311 const side = getSide(placement);
3312 const initialSideAxis = getSideAxis(initialPlacement);
3313 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3314 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3315 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3316 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3317 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3318 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3319 }
3320 const placements2 = [initialPlacement, ...fallbackPlacements];
3321 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3322 const overflows = [];
3323 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3324 if (checkMainAxis) {
3325 overflows.push(overflow[side]);
3326 }
3327 if (checkCrossAxis) {
3328 const sides2 = getAlignmentSides(placement, rects, rtl);
3329 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3330 }
3331 overflowsData = [...overflowsData, {
3332 placement,
3333 overflows
3334 }];
3335 if (!overflows.every((side2) => side2 <= 0)) {
3336 var _middlewareData$flip2, _overflowsData$filter;
3337 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3338 const nextPlacement = placements2[nextIndex];
3339 if (nextPlacement) {
3340 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3341 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3342 // overflows the main axis.
3343 overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
3344 return {
3345 data: {
3346 index: nextIndex,
3347 overflows: overflowsData
3348 },
3349 reset: {
3350 placement: nextPlacement
3351 }
3352 };
3353 }
3354 }
3355 let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
3356 if (!resetPlacement) {
3357 switch (fallbackStrategy) {
3358 case "bestFit": {
3359 var _overflowsData$filter2;
3360 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
3361 if (hasFallbackAxisSideDirection) {
3362 const currentSideAxis = getSideAxis(d.placement);
3363 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3364 // reading directions favoring greater width.
3365 currentSideAxis === "y";
3366 }
3367 return true;
3368 }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
3369 if (placement2) {
3370 resetPlacement = placement2;
3371 }
3372 break;
3373 }
3374 case "initialPlacement":
3375 resetPlacement = initialPlacement;
3376 break;
3377 }
3378 }
3379 if (placement !== resetPlacement) {
3380 return {
3381 reset: {
3382 placement: resetPlacement
3383 }
3384 };
3385 }
3386 }
3387 return {};
3388 }
3389 };
3390 };
3391 function getSideOffsets(overflow, rect) {
3392 return {
3393 top: overflow.top - rect.height,
3394 right: overflow.right - rect.width,
3395 bottom: overflow.bottom - rect.height,
3396 left: overflow.left - rect.width
3397 };
3398 }
3399 function isAnySideFullyClipped(overflow) {
3400 return sides.some((side) => overflow[side] >= 0);
3401 }
3402 var hide = function(options) {
3403 if (options === void 0) {
3404 options = {};
3405 }
3406 return {
3407 name: "hide",
3408 options,
3409 async fn(state) {
3410 const {
3411 rects,
3412 platform: platform3
3413 } = state;
3414 const {
3415 strategy = "referenceHidden",
3416 ...detectOverflowOptions
3417 } = evaluate(options, state);
3418 switch (strategy) {
3419 case "referenceHidden": {
3420 const overflow = await platform3.detectOverflow(state, {
3421 ...detectOverflowOptions,
3422 elementContext: "reference"
3423 });
3424 const offsets = getSideOffsets(overflow, rects.reference);
3425 return {
3426 data: {
3427 referenceHiddenOffsets: offsets,
3428 referenceHidden: isAnySideFullyClipped(offsets)
3429 }
3430 };
3431 }
3432 case "escaped": {
3433 const overflow = await platform3.detectOverflow(state, {
3434 ...detectOverflowOptions,
3435 altBoundary: true
3436 });
3437 const offsets = getSideOffsets(overflow, rects.floating);
3438 return {
3439 data: {
3440 escapedOffsets: offsets,
3441 escaped: isAnySideFullyClipped(offsets)
3442 }
3443 };
3444 }
3445 default: {
3446 return {};
3447 }
3448 }
3449 }
3450 };
3451 };
3452 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
3453 async function convertValueToCoords(state, options) {
3454 const {
3455 placement,
3456 platform: platform3,
3457 elements
3458 } = state;
3459 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3460 const side = getSide(placement);
3461 const alignment = getAlignment(placement);
3462 const isVertical = getSideAxis(placement) === "y";
3463 const mainAxisMulti = originSides.has(side) ? -1 : 1;
3464 const crossAxisMulti = rtl && isVertical ? -1 : 1;
3465 const rawValue = evaluate(options, state);
3466 let {
3467 mainAxis,
3468 crossAxis,
3469 alignmentAxis
3470 } = typeof rawValue === "number" ? {
3471 mainAxis: rawValue,
3472 crossAxis: 0,
3473 alignmentAxis: null
3474 } : {
3475 mainAxis: rawValue.mainAxis || 0,
3476 crossAxis: rawValue.crossAxis || 0,
3477 alignmentAxis: rawValue.alignmentAxis
3478 };
3479 if (alignment && typeof alignmentAxis === "number") {
3480 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
3481 }
3482 return isVertical ? {
3483 x: crossAxis * crossAxisMulti,
3484 y: mainAxis * mainAxisMulti
3485 } : {
3486 x: mainAxis * mainAxisMulti,
3487 y: crossAxis * crossAxisMulti
3488 };
3489 }
3490 var offset = function(options) {
3491 if (options === void 0) {
3492 options = 0;
3493 }
3494 return {
3495 name: "offset",
3496 options,
3497 async fn(state) {
3498 var _middlewareData$offse, _middlewareData$arrow;
3499 const {
3500 x,
3501 y,
3502 placement,
3503 middlewareData
3504 } = state;
3505 const diffCoords = await convertValueToCoords(state, options);
3506 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3507 return {};
3508 }
3509 return {
3510 x: x + diffCoords.x,
3511 y: y + diffCoords.y,
3512 data: {
3513 ...diffCoords,
3514 placement
3515 }
3516 };
3517 }
3518 };
3519 };
3520 var shift = function(options) {
3521 if (options === void 0) {
3522 options = {};
3523 }
3524 return {
3525 name: "shift",
3526 options,
3527 async fn(state) {
3528 const {
3529 x,
3530 y,
3531 placement,
3532 platform: platform3
3533 } = state;
3534 const {
3535 mainAxis: checkMainAxis = true,
3536 crossAxis: checkCrossAxis = false,
3537 limiter = {
3538 fn: (_ref) => {
3539 let {
3540 x: x2,
3541 y: y2
3542 } = _ref;
3543 return {
3544 x: x2,
3545 y: y2
3546 };
3547 }
3548 },
3549 ...detectOverflowOptions
3550 } = evaluate(options, state);
3551 const coords = {
3552 x,
3553 y
3554 };
3555 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3556 const crossAxis = getSideAxis(getSide(placement));
3557 const mainAxis = getOppositeAxis(crossAxis);
3558 let mainAxisCoord = coords[mainAxis];
3559 let crossAxisCoord = coords[crossAxis];
3560 if (checkMainAxis) {
3561 const minSide = mainAxis === "y" ? "top" : "left";
3562 const maxSide = mainAxis === "y" ? "bottom" : "right";
3563 const min2 = mainAxisCoord + overflow[minSide];
3564 const max2 = mainAxisCoord - overflow[maxSide];
3565 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
3566 }
3567 if (checkCrossAxis) {
3568 const minSide = crossAxis === "y" ? "top" : "left";
3569 const maxSide = crossAxis === "y" ? "bottom" : "right";
3570 const min2 = crossAxisCoord + overflow[minSide];
3571 const max2 = crossAxisCoord - overflow[maxSide];
3572 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
3573 }
3574 const limitedCoords = limiter.fn({
3575 ...state,
3576 [mainAxis]: mainAxisCoord,
3577 [crossAxis]: crossAxisCoord
3578 });
3579 return {
3580 ...limitedCoords,
3581 data: {
3582 x: limitedCoords.x - x,
3583 y: limitedCoords.y - y,
3584 enabled: {
3585 [mainAxis]: checkMainAxis,
3586 [crossAxis]: checkCrossAxis
3587 }
3588 }
3589 };
3590 }
3591 };
3592 };
3593 var limitShift = function(options) {
3594 if (options === void 0) {
3595 options = {};
3596 }
3597 return {
3598 options,
3599 fn(state) {
3600 const {
3601 x,
3602 y,
3603 placement,
3604 rects,
3605 middlewareData
3606 } = state;
3607 const {
3608 offset: offset4 = 0,
3609 mainAxis: checkMainAxis = true,
3610 crossAxis: checkCrossAxis = true
3611 } = evaluate(options, state);
3612 const coords = {
3613 x,
3614 y
3615 };
3616 const crossAxis = getSideAxis(placement);
3617 const mainAxis = getOppositeAxis(crossAxis);
3618 let mainAxisCoord = coords[mainAxis];
3619 let crossAxisCoord = coords[crossAxis];
3620 const rawOffset = evaluate(offset4, state);
3621 const computedOffset = typeof rawOffset === "number" ? {
3622 mainAxis: rawOffset,
3623 crossAxis: 0
3624 } : {
3625 mainAxis: 0,
3626 crossAxis: 0,
3627 ...rawOffset
3628 };
3629 if (checkMainAxis) {
3630 const len = mainAxis === "y" ? "height" : "width";
3631 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
3632 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
3633 if (mainAxisCoord < limitMin) {
3634 mainAxisCoord = limitMin;
3635 } else if (mainAxisCoord > limitMax) {
3636 mainAxisCoord = limitMax;
3637 }
3638 }
3639 if (checkCrossAxis) {
3640 var _middlewareData$offse, _middlewareData$offse2;
3641 const len = mainAxis === "y" ? "width" : "height";
3642 const isOriginSide = originSides.has(getSide(placement));
3643 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);
3644 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);
3645 if (crossAxisCoord < limitMin) {
3646 crossAxisCoord = limitMin;
3647 } else if (crossAxisCoord > limitMax) {
3648 crossAxisCoord = limitMax;
3649 }
3650 }
3651 return {
3652 [mainAxis]: mainAxisCoord,
3653 [crossAxis]: crossAxisCoord
3654 };
3655 }
3656 };
3657 };
3658 var size = function(options) {
3659 if (options === void 0) {
3660 options = {};
3661 }
3662 return {
3663 name: "size",
3664 options,
3665 async fn(state) {
3666 var _state$middlewareData, _state$middlewareData2;
3667 const {
3668 placement,
3669 rects,
3670 platform: platform3,
3671 elements
3672 } = state;
3673 const {
3674 apply = () => {
3675 },
3676 ...detectOverflowOptions
3677 } = evaluate(options, state);
3678 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3679 const side = getSide(placement);
3680 const alignment = getAlignment(placement);
3681 const isYAxis = getSideAxis(placement) === "y";
3682 const {
3683 width,
3684 height
3685 } = rects.floating;
3686 let heightSide;
3687 let widthSide;
3688 if (side === "top" || side === "bottom") {
3689 heightSide = side;
3690 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
3691 } else {
3692 widthSide = side;
3693 heightSide = alignment === "end" ? "top" : "bottom";
3694 }
3695 const maximumClippingHeight = height - overflow.top - overflow.bottom;
3696 const maximumClippingWidth = width - overflow.left - overflow.right;
3697 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
3698 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
3699 const noShift = !state.middlewareData.shift;
3700 let availableHeight = overflowAvailableHeight;
3701 let availableWidth = overflowAvailableWidth;
3702 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
3703 availableWidth = maximumClippingWidth;
3704 }
3705 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
3706 availableHeight = maximumClippingHeight;
3707 }
3708 if (noShift && !alignment) {
3709 const xMin = max(overflow.left, 0);
3710 const xMax = max(overflow.right, 0);
3711 const yMin = max(overflow.top, 0);
3712 const yMax = max(overflow.bottom, 0);
3713 if (isYAxis) {
3714 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
3715 } else {
3716 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
3717 }
3718 }
3719 await apply({
3720 ...state,
3721 availableWidth,
3722 availableHeight
3723 });
3724 const nextDimensions = await platform3.getDimensions(elements.floating);
3725 if (width !== nextDimensions.width || height !== nextDimensions.height) {
3726 return {
3727 reset: {
3728 rects: true
3729 }
3730 };
3731 }
3732 return {};
3733 }
3734 };
3735 };
3736
3737 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
3738 function getCssDimensions(element) {
3739 const css = getComputedStyle2(element);
3740 let width = parseFloat(css.width) || 0;
3741 let height = parseFloat(css.height) || 0;
3742 const hasOffset = isHTMLElement(element);
3743 const offsetWidth = hasOffset ? element.offsetWidth : width;
3744 const offsetHeight = hasOffset ? element.offsetHeight : height;
3745 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
3746 if (shouldFallback) {
3747 width = offsetWidth;
3748 height = offsetHeight;
3749 }
3750 return {
3751 width,
3752 height,
3753 $: shouldFallback
3754 };
3755 }
3756 function unwrapElement(element) {
3757 return !isElement(element) ? element.contextElement : element;
3758 }
3759 function getScale(element) {
3760 const domElement = unwrapElement(element);
3761 if (!isHTMLElement(domElement)) {
3762 return createCoords(1);
3763 }
3764 const rect = domElement.getBoundingClientRect();
3765 const {
3766 width,
3767 height,
3768 $
3769 } = getCssDimensions(domElement);
3770 let x = ($ ? round(rect.width) : rect.width) / width;
3771 let y = ($ ? round(rect.height) : rect.height) / height;
3772 if (!x || !Number.isFinite(x)) {
3773 x = 1;
3774 }
3775 if (!y || !Number.isFinite(y)) {
3776 y = 1;
3777 }
3778 return {
3779 x,
3780 y
3781 };
3782 }
3783 var noOffsets = /* @__PURE__ */ createCoords(0);
3784 function getVisualOffsets(element) {
3785 const win = getWindow(element);
3786 if (!isWebKit() || !win.visualViewport) {
3787 return noOffsets;
3788 }
3789 return {
3790 x: win.visualViewport.offsetLeft,
3791 y: win.visualViewport.offsetTop
3792 };
3793 }
3794 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
3795 if (isFixed === void 0) {
3796 isFixed = false;
3797 }
3798 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
3799 return false;
3800 }
3801 return isFixed;
3802 }
3803 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
3804 if (includeScale === void 0) {
3805 includeScale = false;
3806 }
3807 if (isFixedStrategy === void 0) {
3808 isFixedStrategy = false;
3809 }
3810 const clientRect = element.getBoundingClientRect();
3811 const domElement = unwrapElement(element);
3812 let scale = createCoords(1);
3813 if (includeScale) {
3814 if (offsetParent) {
3815 if (isElement(offsetParent)) {
3816 scale = getScale(offsetParent);
3817 }
3818 } else {
3819 scale = getScale(element);
3820 }
3821 }
3822 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
3823 let x = (clientRect.left + visualOffsets.x) / scale.x;
3824 let y = (clientRect.top + visualOffsets.y) / scale.y;
3825 let width = clientRect.width / scale.x;
3826 let height = clientRect.height / scale.y;
3827 if (domElement) {
3828 const win = getWindow(domElement);
3829 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
3830 let currentWin = win;
3831 let currentIFrame = getFrameElement(currentWin);
3832 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
3833 const iframeScale = getScale(currentIFrame);
3834 const iframeRect = currentIFrame.getBoundingClientRect();
3835 const css = getComputedStyle2(currentIFrame);
3836 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
3837 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
3838 x *= iframeScale.x;
3839 y *= iframeScale.y;
3840 width *= iframeScale.x;
3841 height *= iframeScale.y;
3842 x += left;
3843 y += top;
3844 currentWin = getWindow(currentIFrame);
3845 currentIFrame = getFrameElement(currentWin);
3846 }
3847 }
3848 return rectToClientRect({
3849 width,
3850 height,
3851 x,
3852 y
3853 });
3854 }
3855 function getWindowScrollBarX(element, rect) {
3856 const leftScroll = getNodeScroll(element).scrollLeft;
3857 if (!rect) {
3858 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
3859 }
3860 return rect.left + leftScroll;
3861 }
3862 function getHTMLOffset(documentElement, scroll) {
3863 const htmlRect = documentElement.getBoundingClientRect();
3864 const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
3865 const y = htmlRect.top + scroll.scrollTop;
3866 return {
3867 x,
3868 y
3869 };
3870 }
3871 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
3872 let {
3873 elements,
3874 rect,
3875 offsetParent,
3876 strategy
3877 } = _ref;
3878 const isFixed = strategy === "fixed";
3879 const documentElement = getDocumentElement(offsetParent);
3880 const topLayer = elements ? isTopLayer(elements.floating) : false;
3881 if (offsetParent === documentElement || topLayer && isFixed) {
3882 return rect;
3883 }
3884 let scroll = {
3885 scrollLeft: 0,
3886 scrollTop: 0
3887 };
3888 let scale = createCoords(1);
3889 const offsets = createCoords(0);
3890 const isOffsetParentAnElement = isHTMLElement(offsetParent);
3891 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
3892 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
3893 scroll = getNodeScroll(offsetParent);
3894 }
3895 if (isOffsetParentAnElement) {
3896 const offsetRect = getBoundingClientRect(offsetParent);
3897 scale = getScale(offsetParent);
3898 offsets.x = offsetRect.x + offsetParent.clientLeft;
3899 offsets.y = offsetRect.y + offsetParent.clientTop;
3900 }
3901 }
3902 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
3903 return {
3904 width: rect.width * scale.x,
3905 height: rect.height * scale.y,
3906 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
3907 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
3908 };
3909 }
3910 function getClientRects(element) {
3911 return Array.from(element.getClientRects());
3912 }
3913 function getDocumentRect(element) {
3914 const html = getDocumentElement(element);
3915 const scroll = getNodeScroll(element);
3916 const body = element.ownerDocument.body;
3917 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
3918 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
3919 let x = -scroll.scrollLeft + getWindowScrollBarX(element);
3920 const y = -scroll.scrollTop;
3921 if (getComputedStyle2(body).direction === "rtl") {
3922 x += max(html.clientWidth, body.clientWidth) - width;
3923 }
3924 return {
3925 width,
3926 height,
3927 x,
3928 y
3929 };
3930 }
3931 var SCROLLBAR_MAX = 25;
3932 function getViewportRect(element, strategy) {
3933 const win = getWindow(element);
3934 const html = getDocumentElement(element);
3935 const visualViewport = win.visualViewport;
3936 let width = html.clientWidth;
3937 let height = html.clientHeight;
3938 let x = 0;
3939 let y = 0;
3940 if (visualViewport) {
3941 width = visualViewport.width;
3942 height = visualViewport.height;
3943 const visualViewportBased = isWebKit();
3944 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
3945 x = visualViewport.offsetLeft;
3946 y = visualViewport.offsetTop;
3947 }
3948 }
3949 const windowScrollbarX = getWindowScrollBarX(html);
3950 if (windowScrollbarX <= 0) {
3951 const doc = html.ownerDocument;
3952 const body = doc.body;
3953 const bodyStyles = getComputedStyle(body);
3954 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
3955 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
3956 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
3957 width -= clippingStableScrollbarWidth;
3958 }
3959 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
3960 width += windowScrollbarX;
3961 }
3962 return {
3963 width,
3964 height,
3965 x,
3966 y
3967 };
3968 }
3969 function getInnerBoundingClientRect(element, strategy) {
3970 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
3971 const top = clientRect.top + element.clientTop;
3972 const left = clientRect.left + element.clientLeft;
3973 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
3974 const width = element.clientWidth * scale.x;
3975 const height = element.clientHeight * scale.y;
3976 const x = left * scale.x;
3977 const y = top * scale.y;
3978 return {
3979 width,
3980 height,
3981 x,
3982 y
3983 };
3984 }
3985 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
3986 let rect;
3987 if (clippingAncestor === "viewport") {
3988 rect = getViewportRect(element, strategy);
3989 } else if (clippingAncestor === "document") {
3990 rect = getDocumentRect(getDocumentElement(element));
3991 } else if (isElement(clippingAncestor)) {
3992 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
3993 } else {
3994 const visualOffsets = getVisualOffsets(element);
3995 rect = {
3996 x: clippingAncestor.x - visualOffsets.x,
3997 y: clippingAncestor.y - visualOffsets.y,
3998 width: clippingAncestor.width,
3999 height: clippingAncestor.height
4000 };
4001 }
4002 return rectToClientRect(rect);
4003 }
4004 function hasFixedPositionAncestor(element, stopNode) {
4005 const parentNode = getParentNode(element);
4006 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4007 return false;
4008 }
4009 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4010 }
4011 function getClippingElementAncestors(element, cache) {
4012 const cachedResult = cache.get(element);
4013 if (cachedResult) {
4014 return cachedResult;
4015 }
4016 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4017 let currentContainingBlockComputedStyle = null;
4018 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4019 let currentNode = elementIsFixed ? getParentNode(element) : element;
4020 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4021 const computedStyle = getComputedStyle2(currentNode);
4022 const currentNodeIsContaining = isContainingBlock(currentNode);
4023 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4024 currentContainingBlockComputedStyle = null;
4025 }
4026 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4027 if (shouldDropCurrentNode) {
4028 result = result.filter((ancestor) => ancestor !== currentNode);
4029 } else {
4030 currentContainingBlockComputedStyle = computedStyle;
4031 }
4032 currentNode = getParentNode(currentNode);
4033 }
4034 cache.set(element, result);
4035 return result;
4036 }
4037 function getClippingRect(_ref) {
4038 let {
4039 element,
4040 boundary,
4041 rootBoundary,
4042 strategy
4043 } = _ref;
4044 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4045 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4046 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4047 let top = firstRect.top;
4048 let right = firstRect.right;
4049 let bottom = firstRect.bottom;
4050 let left = firstRect.left;
4051 for (let i = 1; i < clippingAncestors.length; i++) {
4052 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
4053 top = max(rect.top, top);
4054 right = min(rect.right, right);
4055 bottom = min(rect.bottom, bottom);
4056 left = max(rect.left, left);
4057 }
4058 return {
4059 width: right - left,
4060 height: bottom - top,
4061 x: left,
4062 y: top
4063 };
4064 }
4065 function getDimensions(element) {
4066 const {
4067 width,
4068 height
4069 } = getCssDimensions(element);
4070 return {
4071 width,
4072 height
4073 };
4074 }
4075 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4076 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4077 const documentElement = getDocumentElement(offsetParent);
4078 const isFixed = strategy === "fixed";
4079 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4080 let scroll = {
4081 scrollLeft: 0,
4082 scrollTop: 0
4083 };
4084 const offsets = createCoords(0);
4085 function setLeftRTLScrollbarOffset() {
4086 offsets.x = getWindowScrollBarX(documentElement);
4087 }
4088 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4089 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4090 scroll = getNodeScroll(offsetParent);
4091 }
4092 if (isOffsetParentAnElement) {
4093 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4094 offsets.x = offsetRect.x + offsetParent.clientLeft;
4095 offsets.y = offsetRect.y + offsetParent.clientTop;
4096 } else if (documentElement) {
4097 setLeftRTLScrollbarOffset();
4098 }
4099 }
4100 if (isFixed && !isOffsetParentAnElement && documentElement) {
4101 setLeftRTLScrollbarOffset();
4102 }
4103 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4104 const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4105 const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4106 return {
4107 x,
4108 y,
4109 width: rect.width,
4110 height: rect.height
4111 };
4112 }
4113 function isStaticPositioned(element) {
4114 return getComputedStyle2(element).position === "static";
4115 }
4116 function getTrueOffsetParent(element, polyfill) {
4117 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4118 return null;
4119 }
4120 if (polyfill) {
4121 return polyfill(element);
4122 }
4123 let rawOffsetParent = element.offsetParent;
4124 if (getDocumentElement(element) === rawOffsetParent) {
4125 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4126 }
4127 return rawOffsetParent;
4128 }
4129 function getOffsetParent(element, polyfill) {
4130 const win = getWindow(element);
4131 if (isTopLayer(element)) {
4132 return win;
4133 }
4134 if (!isHTMLElement(element)) {
4135 let svgOffsetParent = getParentNode(element);
4136 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4137 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4138 return svgOffsetParent;
4139 }
4140 svgOffsetParent = getParentNode(svgOffsetParent);
4141 }
4142 return win;
4143 }
4144 let offsetParent = getTrueOffsetParent(element, polyfill);
4145 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4146 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4147 }
4148 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4149 return win;
4150 }
4151 return offsetParent || getContainingBlock(element) || win;
4152 }
4153 var getElementRects = async function(data) {
4154 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4155 const getDimensionsFn = this.getDimensions;
4156 const floatingDimensions = await getDimensionsFn(data.floating);
4157 return {
4158 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4159 floating: {
4160 x: 0,
4161 y: 0,
4162 width: floatingDimensions.width,
4163 height: floatingDimensions.height
4164 }
4165 };
4166 };
4167 function isRTL(element) {
4168 return getComputedStyle2(element).direction === "rtl";
4169 }
4170 var platform2 = {
4171 convertOffsetParentRelativeRectToViewportRelativeRect,
4172 getDocumentElement,
4173 getClippingRect,
4174 getOffsetParent,
4175 getElementRects,
4176 getClientRects,
4177 getDimensions,
4178 getScale,
4179 isElement,
4180 isRTL
4181 };
4182 function rectsAreEqual(a, b) {
4183 return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
4184 }
4185 function observeMove(element, onMove) {
4186 let io = null;
4187 let timeoutId;
4188 const root = getDocumentElement(element);
4189 function cleanup() {
4190 var _io;
4191 clearTimeout(timeoutId);
4192 (_io = io) == null || _io.disconnect();
4193 io = null;
4194 }
4195 function refresh(skip, threshold) {
4196 if (skip === void 0) {
4197 skip = false;
4198 }
4199 if (threshold === void 0) {
4200 threshold = 1;
4201 }
4202 cleanup();
4203 const elementRectForRootMargin = element.getBoundingClientRect();
4204 const {
4205 left,
4206 top,
4207 width,
4208 height
4209 } = elementRectForRootMargin;
4210 if (!skip) {
4211 onMove();
4212 }
4213 if (!width || !height) {
4214 return;
4215 }
4216 const insetTop = floor(top);
4217 const insetRight = floor(root.clientWidth - (left + width));
4218 const insetBottom = floor(root.clientHeight - (top + height));
4219 const insetLeft = floor(left);
4220 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4221 const options = {
4222 rootMargin,
4223 threshold: max(0, min(1, threshold)) || 1
4224 };
4225 let isFirstUpdate = true;
4226 function handleObserve(entries) {
4227 const ratio = entries[0].intersectionRatio;
4228 if (ratio !== threshold) {
4229 if (!isFirstUpdate) {
4230 return refresh();
4231 }
4232 if (!ratio) {
4233 timeoutId = setTimeout(() => {
4234 refresh(false, 1e-7);
4235 }, 1e3);
4236 } else {
4237 refresh(false, ratio);
4238 }
4239 }
4240 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4241 refresh();
4242 }
4243 isFirstUpdate = false;
4244 }
4245 try {
4246 io = new IntersectionObserver(handleObserve, {
4247 ...options,
4248 // Handle <iframe>s
4249 root: root.ownerDocument
4250 });
4251 } catch (_e) {
4252 io = new IntersectionObserver(handleObserve, options);
4253 }
4254 io.observe(element);
4255 }
4256 refresh(true);
4257 return cleanup;
4258 }
4259 function autoUpdate(reference, floating, update2, options) {
4260 if (options === void 0) {
4261 options = {};
4262 }
4263 const {
4264 ancestorScroll = true,
4265 ancestorResize = true,
4266 elementResize = typeof ResizeObserver === "function",
4267 layoutShift = typeof IntersectionObserver === "function",
4268 animationFrame = false
4269 } = options;
4270 const referenceEl = unwrapElement(reference);
4271 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4272 ancestors.forEach((ancestor) => {
4273 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4274 passive: true
4275 });
4276 ancestorResize && ancestor.addEventListener("resize", update2);
4277 });
4278 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4279 let reobserveFrame = -1;
4280 let resizeObserver = null;
4281 if (elementResize) {
4282 resizeObserver = new ResizeObserver((_ref) => {
4283 let [firstEntry] = _ref;
4284 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4285 resizeObserver.unobserve(floating);
4286 cancelAnimationFrame(reobserveFrame);
4287 reobserveFrame = requestAnimationFrame(() => {
4288 var _resizeObserver;
4289 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4290 });
4291 }
4292 update2();
4293 });
4294 if (referenceEl && !animationFrame) {
4295 resizeObserver.observe(referenceEl);
4296 }
4297 if (floating) {
4298 resizeObserver.observe(floating);
4299 }
4300 }
4301 let frameId;
4302 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4303 if (animationFrame) {
4304 frameLoop();
4305 }
4306 function frameLoop() {
4307 const nextRefRect = getBoundingClientRect(reference);
4308 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4309 update2();
4310 }
4311 prevRefRect = nextRefRect;
4312 frameId = requestAnimationFrame(frameLoop);
4313 }
4314 update2();
4315 return () => {
4316 var _resizeObserver2;
4317 ancestors.forEach((ancestor) => {
4318 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4319 ancestorResize && ancestor.removeEventListener("resize", update2);
4320 });
4321 cleanupIo == null || cleanupIo();
4322 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4323 resizeObserver = null;
4324 if (animationFrame) {
4325 cancelAnimationFrame(frameId);
4326 }
4327 };
4328 }
4329 var offset2 = offset;
4330 var shift2 = shift;
4331 var flip2 = flip;
4332 var size2 = size;
4333 var hide2 = hide;
4334 var limitShift2 = limitShift;
4335 var computePosition2 = (reference, floating, options) => {
4336 const cache = /* @__PURE__ */ new Map();
4337 const mergedOptions = {
4338 platform: platform2,
4339 ...options
4340 };
4341 const platformWithCache = {
4342 ...mergedOptions.platform,
4343 _c: cache
4344 };
4345 return computePosition(reference, floating, {
4346 ...mergedOptions,
4347 platform: platformWithCache
4348 });
4349 };
4350
4351 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4352 var React20 = __toESM(require_react(), 1);
4353 var import_react2 = __toESM(require_react(), 1);
4354 var ReactDOM3 = __toESM(require_react_dom(), 1);
4355 var isClient = typeof document !== "undefined";
4356 var noop2 = function noop3() {
4357 };
4358 var index = isClient ? import_react2.useLayoutEffect : noop2;
4359 function deepEqual(a, b) {
4360 if (a === b) {
4361 return true;
4362 }
4363 if (typeof a !== typeof b) {
4364 return false;
4365 }
4366 if (typeof a === "function" && a.toString() === b.toString()) {
4367 return true;
4368 }
4369 let length;
4370 let i;
4371 let keys;
4372 if (a && b && typeof a === "object") {
4373 if (Array.isArray(a)) {
4374 length = a.length;
4375 if (length !== b.length) return false;
4376 for (i = length; i-- !== 0; ) {
4377 if (!deepEqual(a[i], b[i])) {
4378 return false;
4379 }
4380 }
4381 return true;
4382 }
4383 keys = Object.keys(a);
4384 length = keys.length;
4385 if (length !== Object.keys(b).length) {
4386 return false;
4387 }
4388 for (i = length; i-- !== 0; ) {
4389 if (!{}.hasOwnProperty.call(b, keys[i])) {
4390 return false;
4391 }
4392 }
4393 for (i = length; i-- !== 0; ) {
4394 const key = keys[i];
4395 if (key === "_owner" && a.$$typeof) {
4396 continue;
4397 }
4398 if (!deepEqual(a[key], b[key])) {
4399 return false;
4400 }
4401 }
4402 return true;
4403 }
4404 return a !== a && b !== b;
4405 }
4406 function getDPR(element) {
4407 if (typeof window === "undefined") {
4408 return 1;
4409 }
4410 const win = element.ownerDocument.defaultView || window;
4411 return win.devicePixelRatio || 1;
4412 }
4413 function roundByDPR(element, value) {
4414 const dpr = getDPR(element);
4415 return Math.round(value * dpr) / dpr;
4416 }
4417 function useLatestRef(value) {
4418 const ref = React20.useRef(value);
4419 index(() => {
4420 ref.current = value;
4421 });
4422 return ref;
4423 }
4424 function useFloating(options) {
4425 if (options === void 0) {
4426 options = {};
4427 }
4428 const {
4429 placement = "bottom",
4430 strategy = "absolute",
4431 middleware = [],
4432 platform: platform3,
4433 elements: {
4434 reference: externalReference,
4435 floating: externalFloating
4436 } = {},
4437 transform = true,
4438 whileElementsMounted,
4439 open
4440 } = options;
4441 const [data, setData] = React20.useState({
4442 x: 0,
4443 y: 0,
4444 strategy,
4445 placement,
4446 middlewareData: {},
4447 isPositioned: false
4448 });
4449 const [latestMiddleware, setLatestMiddleware] = React20.useState(middleware);
4450 if (!deepEqual(latestMiddleware, middleware)) {
4451 setLatestMiddleware(middleware);
4452 }
4453 const [_reference, _setReference] = React20.useState(null);
4454 const [_floating, _setFloating] = React20.useState(null);
4455 const setReference = React20.useCallback((node) => {
4456 if (node !== referenceRef.current) {
4457 referenceRef.current = node;
4458 _setReference(node);
4459 }
4460 }, []);
4461 const setFloating = React20.useCallback((node) => {
4462 if (node !== floatingRef.current) {
4463 floatingRef.current = node;
4464 _setFloating(node);
4465 }
4466 }, []);
4467 const referenceEl = externalReference || _reference;
4468 const floatingEl = externalFloating || _floating;
4469 const referenceRef = React20.useRef(null);
4470 const floatingRef = React20.useRef(null);
4471 const dataRef = React20.useRef(data);
4472 const hasWhileElementsMounted = whileElementsMounted != null;
4473 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
4474 const platformRef = useLatestRef(platform3);
4475 const openRef = useLatestRef(open);
4476 const update2 = React20.useCallback(() => {
4477 if (!referenceRef.current || !floatingRef.current) {
4478 return;
4479 }
4480 const config = {
4481 placement,
4482 strategy,
4483 middleware: latestMiddleware
4484 };
4485 if (platformRef.current) {
4486 config.platform = platformRef.current;
4487 }
4488 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
4489 const fullData = {
4490 ...data2,
4491 // The floating element's position may be recomputed while it's closed
4492 // but still mounted (such as when transitioning out). To ensure
4493 // `isPositioned` will be `false` initially on the next open, avoid
4494 // setting it to `true` when `open === false` (must be specified).
4495 isPositioned: openRef.current !== false
4496 };
4497 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
4498 dataRef.current = fullData;
4499 ReactDOM3.flushSync(() => {
4500 setData(fullData);
4501 });
4502 }
4503 });
4504 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
4505 index(() => {
4506 if (open === false && dataRef.current.isPositioned) {
4507 dataRef.current.isPositioned = false;
4508 setData((data2) => ({
4509 ...data2,
4510 isPositioned: false
4511 }));
4512 }
4513 }, [open]);
4514 const isMountedRef = React20.useRef(false);
4515 index(() => {
4516 isMountedRef.current = true;
4517 return () => {
4518 isMountedRef.current = false;
4519 };
4520 }, []);
4521 index(() => {
4522 if (referenceEl) referenceRef.current = referenceEl;
4523 if (floatingEl) floatingRef.current = floatingEl;
4524 if (referenceEl && floatingEl) {
4525 if (whileElementsMountedRef.current) {
4526 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
4527 }
4528 update2();
4529 }
4530 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
4531 const refs = React20.useMemo(() => ({
4532 reference: referenceRef,
4533 floating: floatingRef,
4534 setReference,
4535 setFloating
4536 }), [setReference, setFloating]);
4537 const elements = React20.useMemo(() => ({
4538 reference: referenceEl,
4539 floating: floatingEl
4540 }), [referenceEl, floatingEl]);
4541 const floatingStyles = React20.useMemo(() => {
4542 const initialStyles = {
4543 position: strategy,
4544 left: 0,
4545 top: 0
4546 };
4547 if (!elements.floating) {
4548 return initialStyles;
4549 }
4550 const x = roundByDPR(elements.floating, data.x);
4551 const y = roundByDPR(elements.floating, data.y);
4552 if (transform) {
4553 return {
4554 ...initialStyles,
4555 transform: "translate(" + x + "px, " + y + "px)",
4556 ...getDPR(elements.floating) >= 1.5 && {
4557 willChange: "transform"
4558 }
4559 };
4560 }
4561 return {
4562 position: strategy,
4563 left: x,
4564 top: y
4565 };
4566 }, [strategy, transform, elements.floating, data.x, data.y]);
4567 return React20.useMemo(() => ({
4568 ...data,
4569 update: update2,
4570 refs,
4571 elements,
4572 floatingStyles
4573 }), [data, update2, refs, elements, floatingStyles]);
4574 }
4575 var offset3 = (options, deps) => {
4576 const result = offset2(options);
4577 return {
4578 name: result.name,
4579 fn: result.fn,
4580 options: [options, deps]
4581 };
4582 };
4583 var shift3 = (options, deps) => {
4584 const result = shift2(options);
4585 return {
4586 name: result.name,
4587 fn: result.fn,
4588 options: [options, deps]
4589 };
4590 };
4591 var limitShift3 = (options, deps) => {
4592 const result = limitShift2(options);
4593 return {
4594 fn: result.fn,
4595 options: [options, deps]
4596 };
4597 };
4598 var flip3 = (options, deps) => {
4599 const result = flip2(options);
4600 return {
4601 name: result.name,
4602 fn: result.fn,
4603 options: [options, deps]
4604 };
4605 };
4606 var size3 = (options, deps) => {
4607 const result = size2(options);
4608 return {
4609 name: result.name,
4610 fn: result.fn,
4611 options: [options, deps]
4612 };
4613 };
4614 var hide3 = (options, deps) => {
4615 const result = hide2(options);
4616 return {
4617 name: result.name,
4618 fn: result.fn,
4619 options: [options, deps]
4620 };
4621 };
4622
4623 // node_modules/@base-ui/utils/esm/store/createSelector.js
4624 var createSelector = (a, b, c, d, e, f, ...other) => {
4625 if (other.length > 0) {
4626 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
4627 }
4628 let selector;
4629 if (a && b && c && d && e && f) {
4630 selector = (state, a1, a2, a3) => {
4631 const va = a(state, a1, a2, a3);
4632 const vb = b(state, a1, a2, a3);
4633 const vc = c(state, a1, a2, a3);
4634 const vd = d(state, a1, a2, a3);
4635 const ve = e(state, a1, a2, a3);
4636 return f(va, vb, vc, vd, ve, a1, a2, a3);
4637 };
4638 } else if (a && b && c && d && e) {
4639 selector = (state, a1, a2, a3) => {
4640 const va = a(state, a1, a2, a3);
4641 const vb = b(state, a1, a2, a3);
4642 const vc = c(state, a1, a2, a3);
4643 const vd = d(state, a1, a2, a3);
4644 return e(va, vb, vc, vd, a1, a2, a3);
4645 };
4646 } else if (a && b && c && d) {
4647 selector = (state, a1, a2, a3) => {
4648 const va = a(state, a1, a2, a3);
4649 const vb = b(state, a1, a2, a3);
4650 const vc = c(state, a1, a2, a3);
4651 return d(va, vb, vc, a1, a2, a3);
4652 };
4653 } else if (a && b && c) {
4654 selector = (state, a1, a2, a3) => {
4655 const va = a(state, a1, a2, a3);
4656 const vb = b(state, a1, a2, a3);
4657 return c(va, vb, a1, a2, a3);
4658 };
4659 } else if (a && b) {
4660 selector = (state, a1, a2, a3) => {
4661 const va = a(state, a1, a2, a3);
4662 return b(va, a1, a2, a3);
4663 };
4664 } else if (a) {
4665 selector = a;
4666 } else {
4667 throw (
4668 /* minify-error-disabled */
4669 new Error("Missing arguments")
4670 );
4671 }
4672 return selector;
4673 };
4674
4675 // node_modules/@base-ui/utils/esm/store/useStore.js
4676 var React22 = __toESM(require_react(), 1);
4677 var import_shim = __toESM(require_shim(), 1);
4678 var import_with_selector = __toESM(require_with_selector(), 1);
4679
4680 // node_modules/@base-ui/utils/esm/fastHooks.js
4681 var React21 = __toESM(require_react(), 1);
4682 var hooks = [];
4683 var currentInstance = void 0;
4684 function getInstance() {
4685 return currentInstance;
4686 }
4687 function register(hook) {
4688 hooks.push(hook);
4689 }
4690 function fastComponent(fn) {
4691 const FastComponent = (props, forwardedRef) => {
4692 const instance = useRefWithInit(createInstance).current;
4693 let result;
4694 try {
4695 currentInstance = instance;
4696 for (const hook of hooks) {
4697 hook.before(instance);
4698 }
4699 result = fn(props, forwardedRef);
4700 for (const hook of hooks) {
4701 hook.after(instance);
4702 }
4703 instance.didInitialize = true;
4704 } finally {
4705 currentInstance = void 0;
4706 }
4707 return result;
4708 };
4709 FastComponent.displayName = fn.displayName || fn.name;
4710 return FastComponent;
4711 }
4712 function fastComponentRef(fn) {
4713 return /* @__PURE__ */ React21.forwardRef(fastComponent(fn));
4714 }
4715 function createInstance() {
4716 return {
4717 didInitialize: false
4718 };
4719 }
4720
4721 // node_modules/@base-ui/utils/esm/store/useStore.js
4722 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
4723 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
4724 function useStore(store2, selector, a1, a2, a3) {
4725 return useStoreImplementation(store2, selector, a1, a2, a3);
4726 }
4727 function useStoreR19(store2, selector, a1, a2, a3) {
4728 const getSelection = React22.useCallback(() => selector(store2.getSnapshot(), a1, a2, a3), [store2, selector, a1, a2, a3]);
4729 return (0, import_shim.useSyncExternalStore)(store2.subscribe, getSelection, getSelection);
4730 }
4731 register({
4732 before(instance) {
4733 instance.syncIndex = 0;
4734 if (!instance.didInitialize) {
4735 instance.syncTick = 1;
4736 instance.syncHooks = [];
4737 instance.didChangeStore = true;
4738 instance.getSnapshot = () => {
4739 let didChange2 = false;
4740 for (let i = 0; i < instance.syncHooks.length; i += 1) {
4741 const hook = instance.syncHooks[i];
4742 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
4743 if (hook.didChange || !Object.is(hook.value, value)) {
4744 didChange2 = true;
4745 hook.value = value;
4746 hook.didChange = false;
4747 }
4748 }
4749 if (didChange2) {
4750 instance.syncTick += 1;
4751 }
4752 return instance.syncTick;
4753 };
4754 }
4755 },
4756 after(instance) {
4757 if (instance.syncHooks.length > 0) {
4758 if (instance.didChangeStore) {
4759 instance.didChangeStore = false;
4760 instance.subscribe = (onStoreChange) => {
4761 const stores = /* @__PURE__ */ new Set();
4762 for (const hook of instance.syncHooks) {
4763 stores.add(hook.store);
4764 }
4765 const unsubscribes = [];
4766 for (const store2 of stores) {
4767 unsubscribes.push(store2.subscribe(onStoreChange));
4768 }
4769 return () => {
4770 for (const unsubscribe of unsubscribes) {
4771 unsubscribe();
4772 }
4773 };
4774 };
4775 }
4776 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
4777 }
4778 }
4779 });
4780 function useStoreFast(store2, selector, a1, a2, a3) {
4781 const instance = getInstance();
4782 if (!instance) {
4783 return useStoreR19(store2, selector, a1, a2, a3);
4784 }
4785 const index2 = instance.syncIndex;
4786 instance.syncIndex += 1;
4787 let hook;
4788 if (!instance.didInitialize) {
4789 hook = {
4790 store: store2,
4791 selector,
4792 a1,
4793 a2,
4794 a3,
4795 value: selector(store2.getSnapshot(), a1, a2, a3),
4796 didChange: false
4797 };
4798 instance.syncHooks.push(hook);
4799 } else {
4800 hook = instance.syncHooks[index2];
4801 if (hook.store !== store2 || hook.selector !== selector || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
4802 if (hook.store !== store2) {
4803 instance.didChangeStore = true;
4804 }
4805 hook.store = store2;
4806 hook.selector = selector;
4807 hook.a1 = a1;
4808 hook.a2 = a2;
4809 hook.a3 = a3;
4810 hook.didChange = true;
4811 }
4812 }
4813 return hook.value;
4814 }
4815 function useStoreLegacy(store2, selector, a1, a2, a3) {
4816 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store2.subscribe, store2.getSnapshot, store2.getSnapshot, (state) => selector(state, a1, a2, a3));
4817 }
4818
4819 // node_modules/@base-ui/utils/esm/store/Store.js
4820 var Store = class {
4821 /**
4822 * The current state of the store.
4823 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
4824 * 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).
4825 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
4826 *
4827 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
4828 */
4829 // Internal state to handle recursive `setState()` calls
4830 constructor(state) {
4831 this.state = state;
4832 this.listeners = /* @__PURE__ */ new Set();
4833 this.updateTick = 0;
4834 }
4835 /**
4836 * Registers a listener that will be called whenever the store's state changes.
4837 *
4838 * @param fn The listener function to be called on state changes.
4839 * @returns A function to unsubscribe the listener.
4840 */
4841 subscribe = (fn) => {
4842 this.listeners.add(fn);
4843 return () => {
4844 this.listeners.delete(fn);
4845 };
4846 };
4847 /**
4848 * Returns the current state of the store.
4849 */
4850 getSnapshot = () => {
4851 return this.state;
4852 };
4853 /**
4854 * Updates the entire store's state and notifies all registered listeners.
4855 *
4856 * @param newState The new state to set for the store.
4857 */
4858 setState(newState) {
4859 if (this.state === newState) {
4860 return;
4861 }
4862 this.state = newState;
4863 this.updateTick += 1;
4864 const currentTick = this.updateTick;
4865 for (const listener of this.listeners) {
4866 if (currentTick !== this.updateTick) {
4867 return;
4868 }
4869 listener(newState);
4870 }
4871 }
4872 /**
4873 * Merges the provided changes into the current state and notifies listeners if there are changes.
4874 *
4875 * @param changes An object containing the changes to apply to the current state.
4876 */
4877 update(changes) {
4878 for (const key in changes) {
4879 if (!Object.is(this.state[key], changes[key])) {
4880 this.setState({
4881 ...this.state,
4882 ...changes
4883 });
4884 return;
4885 }
4886 }
4887 }
4888 /**
4889 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
4890 *
4891 * @param key The key in the store's state to update.
4892 * @param value The new value to set for the specified key.
4893 */
4894 set(key, value) {
4895 if (!Object.is(this.state[key], value)) {
4896 this.setState({
4897 ...this.state,
4898 [key]: value
4899 });
4900 }
4901 }
4902 /**
4903 * Gives the state a new reference and updates all registered listeners.
4904 */
4905 notifyAll() {
4906 const newState = {
4907 ...this.state
4908 };
4909 this.setState(newState);
4910 }
4911 use(selector, a1, a2, a3) {
4912 return useStore(this, selector, a1, a2, a3);
4913 }
4914 };
4915
4916 // node_modules/@base-ui/utils/esm/store/ReactStore.js
4917 var React23 = __toESM(require_react(), 1);
4918 var ReactStore = class extends Store {
4919 /**
4920 * Creates a new ReactStore instance.
4921 *
4922 * @param state Initial state of the store.
4923 * @param context Non-reactive context values.
4924 * @param selectors Optional selectors for use with `useState`.
4925 */
4926 constructor(state, context = {}, selectors3) {
4927 super(state);
4928 this.context = context;
4929 this.selectors = selectors3;
4930 }
4931 /**
4932 * Non-reactive values such as refs, callbacks, etc.
4933 */
4934 /**
4935 * Synchronizes a single external value into the store.
4936 *
4937 * Note that the while the value in `state` is updated immediately, the value returned
4938 * by `useState` is updated before the next render (similarly to React's `useState`).
4939 */
4940 useSyncedValue(key, value) {
4941 React23.useDebugValue(key);
4942 useIsoLayoutEffect(() => {
4943 if (this.state[key] !== value) {
4944 this.set(key, value);
4945 }
4946 }, [key, value]);
4947 }
4948 /**
4949 * Synchronizes a single external value into the store and
4950 * cleans it up (sets to `undefined`) on unmount.
4951 *
4952 * Note that the while the value in `state` is updated immediately, the value returned
4953 * by `useState` is updated before the next render (similarly to React's `useState`).
4954 */
4955 useSyncedValueWithCleanup(key, value) {
4956 const store2 = this;
4957 useIsoLayoutEffect(() => {
4958 if (store2.state[key] !== value) {
4959 store2.set(key, value);
4960 }
4961 return () => {
4962 store2.set(key, void 0);
4963 };
4964 }, [store2, key, value]);
4965 }
4966 /**
4967 * Synchronizes multiple external values into the store.
4968 *
4969 * Note that the while the values in `state` are updated immediately, the values returned
4970 * by `useState` are updated before the next render (similarly to React's `useState`).
4971 */
4972 useSyncedValues(statePart) {
4973 const store2 = this;
4974 if (true) {
4975 React23.useDebugValue(statePart, (p) => Object.keys(p));
4976 const keys = React23.useRef(Object.keys(statePart)).current;
4977 const nextKeys = Object.keys(statePart);
4978 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
4979 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
4980 }
4981 }
4982 const dependencies = Object.values(statePart);
4983 useIsoLayoutEffect(() => {
4984 store2.update(statePart);
4985 }, [store2, ...dependencies]);
4986 }
4987 /**
4988 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
4989 * is non-undefined, the store's state at `key` is updated to match `controlled`.
4990 */
4991 useControlledProp(key, controlled) {
4992 React23.useDebugValue(key);
4993 const isControlled = controlled !== void 0;
4994 useIsoLayoutEffect(() => {
4995 if (isControlled && !Object.is(this.state[key], controlled)) {
4996 super.setState({
4997 ...this.state,
4998 [key]: controlled
4999 });
5000 }
5001 }, [key, controlled, isControlled]);
5002 if (true) {
5003 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5004 if (!cache.has(key)) {
5005 cache.set(key, isControlled);
5006 }
5007 const previouslyControlled = cache.get(key);
5008 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5009 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).`);
5010 }
5011 }
5012 }
5013 /** Gets the current value from the store using a selector with the provided key.
5014 *
5015 * @param key Key of the selector to use.
5016 */
5017 select(key, a1, a2, a3) {
5018 const selector = this.selectors[key];
5019 return selector(this.state, a1, a2, a3);
5020 }
5021 /**
5022 * Returns a value from the store's state using a selector function.
5023 * Used to subscribe to specific parts of the state.
5024 * This methods causes a rerender whenever the selected state changes.
5025 *
5026 * @param key Key of the selector to use.
5027 */
5028 useState(key, a1, a2, a3) {
5029 React23.useDebugValue(key);
5030 return useStore(this, this.selectors[key], a1, a2, a3);
5031 }
5032 /**
5033 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5034 * and assigns it to the context.
5035 *
5036 * @param key Key of the event callback. Must be a function in the context.
5037 * @param fn Function to assign.
5038 */
5039 useContextCallback(key, fn) {
5040 React23.useDebugValue(key);
5041 const stableFunction = useStableCallback(fn ?? NOOP);
5042 this.context[key] = stableFunction;
5043 }
5044 /**
5045 * Returns a stable setter function for a specific key in the store's state.
5046 * It's commonly used to pass as a ref callback to React elements.
5047 *
5048 * @param key Key of the state to set.
5049 */
5050 useStateSetter(key) {
5051 const ref = React23.useRef(void 0);
5052 if (ref.current === void 0) {
5053 ref.current = (value) => {
5054 this.set(key, value);
5055 };
5056 }
5057 return ref.current;
5058 }
5059 /**
5060 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5061 *
5062 * @param key Key of the selector to observe.
5063 * @param listener Listener function called when the selector result changes.
5064 */
5065 observe(selector, listener) {
5066 let selectFn;
5067 if (typeof selector === "function") {
5068 selectFn = selector;
5069 } else {
5070 selectFn = this.selectors[selector];
5071 }
5072 let prevValue = selectFn(this.state);
5073 listener(prevValue, prevValue, this);
5074 return this.subscribe((nextState) => {
5075 const nextValue = selectFn(nextState);
5076 if (!Object.is(prevValue, nextValue)) {
5077 const oldValue = prevValue;
5078 prevValue = nextValue;
5079 listener(nextValue, oldValue, this);
5080 }
5081 });
5082 }
5083 };
5084
5085 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5086 var selectors = {
5087 open: createSelector((state) => state.open),
5088 transitionStatus: createSelector((state) => state.transitionStatus),
5089 domReferenceElement: createSelector((state) => state.domReferenceElement),
5090 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5091 floatingElement: createSelector((state) => state.floatingElement),
5092 floatingId: createSelector((state) => state.floatingId)
5093 };
5094 var FloatingRootStore = class extends ReactStore {
5095 constructor(options) {
5096 const {
5097 syncOnly,
5098 nested,
5099 onOpenChange,
5100 triggerElements,
5101 ...initialState
5102 } = options;
5103 super({
5104 ...initialState,
5105 positionReference: initialState.referenceElement,
5106 domReferenceElement: initialState.referenceElement
5107 }, {
5108 onOpenChange,
5109 dataRef: {
5110 current: {}
5111 },
5112 events: createEventEmitter(),
5113 nested,
5114 triggerElements
5115 }, selectors);
5116 this.syncOnly = syncOnly;
5117 }
5118 /**
5119 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5120 */
5121 syncOpenEvent = (newOpen, event) => {
5122 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5123 // click events to upgrade a hover-open.
5124 event != null && isClickLikeEvent(event)) {
5125 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5126 }
5127 };
5128 /**
5129 * Runs the root-owned side effects for an open state change.
5130 */
5131 dispatchOpenChange = (newOpen, eventDetails) => {
5132 this.syncOpenEvent(newOpen, eventDetails.event);
5133 const details = {
5134 open: newOpen,
5135 reason: eventDetails.reason,
5136 nativeEvent: eventDetails.event,
5137 nested: this.context.nested,
5138 triggerElement: eventDetails.trigger
5139 };
5140 this.context.events.emit("openchange", details);
5141 };
5142 /**
5143 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5144 *
5145 * @param newOpen The new open state.
5146 * @param eventDetails Details about the event that triggered the open state change.
5147 */
5148 setOpen = (newOpen, eventDetails) => {
5149 if (this.syncOnly) {
5150 this.context.onOpenChange?.(newOpen, eventDetails);
5151 return;
5152 }
5153 this.dispatchOpenChange(newOpen, eventDetails);
5154 this.context.onOpenChange?.(newOpen, eventDetails);
5155 };
5156 };
5157
5158 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5159 var React24 = __toESM(require_react(), 1);
5160 function useTriggerRegistration(id, store2) {
5161 const registeredElementIdRef = React24.useRef(null);
5162 const registeredElementRef = React24.useRef(null);
5163 return React24.useCallback((element) => {
5164 if (id === void 0) {
5165 return;
5166 }
5167 if (registeredElementIdRef.current !== null) {
5168 const registeredId = registeredElementIdRef.current;
5169 const registeredElement = registeredElementRef.current;
5170 const currentElement = store2.context.triggerElements.getById(registeredId);
5171 if (registeredElement && currentElement === registeredElement) {
5172 store2.context.triggerElements.delete(registeredId);
5173 }
5174 registeredElementIdRef.current = null;
5175 registeredElementRef.current = null;
5176 }
5177 if (element !== null) {
5178 registeredElementIdRef.current = id;
5179 registeredElementRef.current = element;
5180 store2.context.triggerElements.add(id, element);
5181 }
5182 }, [store2, id]);
5183 }
5184 function useTriggerDataForwarding(triggerId, triggerElementRef, store2, stateUpdates) {
5185 const isMountedByThisTrigger = store2.useState("isMountedByTrigger", triggerId);
5186 const baseRegisterTrigger = useTriggerRegistration(triggerId, store2);
5187 const registerTrigger = useStableCallback((element) => {
5188 baseRegisterTrigger(element);
5189 if (!element || !store2.select("open")) {
5190 return;
5191 }
5192 const activeTriggerId = store2.select("activeTriggerId");
5193 if (activeTriggerId === triggerId) {
5194 store2.update({
5195 activeTriggerElement: element,
5196 ...stateUpdates
5197 });
5198 return;
5199 }
5200 if (activeTriggerId == null) {
5201 store2.update({
5202 activeTriggerId: triggerId,
5203 activeTriggerElement: element,
5204 ...stateUpdates
5205 });
5206 }
5207 });
5208 useIsoLayoutEffect(() => {
5209 if (isMountedByThisTrigger) {
5210 store2.update({
5211 activeTriggerElement: triggerElementRef.current,
5212 ...stateUpdates
5213 });
5214 }
5215 }, [isMountedByThisTrigger, store2, triggerElementRef, ...Object.values(stateUpdates)]);
5216 return {
5217 registerTrigger,
5218 isMountedByThisTrigger
5219 };
5220 }
5221 function useImplicitActiveTrigger(store2) {
5222 const open = store2.useState("open");
5223 useIsoLayoutEffect(() => {
5224 if (open && !store2.select("activeTriggerId") && store2.context.triggerElements.size === 1) {
5225 const iteratorResult = store2.context.triggerElements.entries().next();
5226 if (!iteratorResult.done) {
5227 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5228 store2.update({
5229 activeTriggerId: implicitTriggerId,
5230 activeTriggerElement: implicitTriggerElement
5231 });
5232 }
5233 }
5234 }, [open, store2]);
5235 }
5236 function useOpenStateTransitions(open, store2, onUnmount) {
5237 const {
5238 mounted,
5239 setMounted,
5240 transitionStatus
5241 } = useTransitionStatus(open);
5242 store2.useSyncedValues({
5243 mounted,
5244 transitionStatus
5245 });
5246 const forceUnmount = useStableCallback(() => {
5247 setMounted(false);
5248 store2.update({
5249 activeTriggerId: null,
5250 activeTriggerElement: null,
5251 mounted: false
5252 });
5253 onUnmount?.();
5254 store2.context.onOpenChangeComplete?.(false);
5255 });
5256 const preventUnmountingOnClose = store2.useState("preventUnmountingOnClose");
5257 useOpenChangeComplete({
5258 enabled: !preventUnmountingOnClose,
5259 open,
5260 ref: store2.context.popupRef,
5261 onComplete() {
5262 if (!open) {
5263 forceUnmount();
5264 }
5265 }
5266 });
5267 return {
5268 forceUnmount,
5269 transitionStatus
5270 };
5271 }
5272
5273 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
5274 var PopupTriggerMap = class {
5275 constructor() {
5276 this.elementsSet = /* @__PURE__ */ new Set();
5277 this.idMap = /* @__PURE__ */ new Map();
5278 }
5279 /**
5280 * Adds a trigger element with the given ID.
5281 *
5282 * Note: The provided element is assumed to not be registered under multiple IDs.
5283 */
5284 add(id, element) {
5285 const existingElement = this.idMap.get(id);
5286 if (existingElement === element) {
5287 return;
5288 }
5289 if (existingElement !== void 0) {
5290 this.elementsSet.delete(existingElement);
5291 }
5292 this.elementsSet.add(element);
5293 this.idMap.set(id, element);
5294 if (true) {
5295 if (this.elementsSet.size !== this.idMap.size) {
5296 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5297 }
5298 }
5299 }
5300 /**
5301 * Removes the trigger element with the given ID.
5302 */
5303 delete(id) {
5304 const element = this.idMap.get(id);
5305 if (element) {
5306 this.elementsSet.delete(element);
5307 this.idMap.delete(id);
5308 }
5309 }
5310 /**
5311 * Whether the given element is registered as a trigger.
5312 */
5313 hasElement(element) {
5314 return this.elementsSet.has(element);
5315 }
5316 /**
5317 * Whether there is a registered trigger element matching the given predicate.
5318 */
5319 hasMatchingElement(predicate) {
5320 for (const element of this.elementsSet) {
5321 if (predicate(element)) {
5322 return true;
5323 }
5324 }
5325 return false;
5326 }
5327 /**
5328 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
5329 */
5330 getById(id) {
5331 return this.idMap.get(id);
5332 }
5333 /**
5334 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
5335 */
5336 entries() {
5337 return this.idMap.entries();
5338 }
5339 /**
5340 * Returns an iterable of all registered trigger elements.
5341 */
5342 elements() {
5343 return this.elementsSet.values();
5344 }
5345 /**
5346 * Returns the number of registered trigger elements.
5347 */
5348 get size() {
5349 return this.idMap.size;
5350 }
5351 };
5352
5353 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
5354 function getEmptyRootContext() {
5355 return new FloatingRootStore({
5356 open: false,
5357 transitionStatus: void 0,
5358 floatingElement: null,
5359 referenceElement: null,
5360 triggerElements: new PopupTriggerMap(),
5361 floatingId: "",
5362 syncOnly: false,
5363 nested: false,
5364 onOpenChange: void 0
5365 });
5366 }
5367
5368 // node_modules/@base-ui/react/esm/utils/popups/store.js
5369 function createInitialPopupStoreState() {
5370 return {
5371 open: false,
5372 openProp: void 0,
5373 mounted: false,
5374 transitionStatus: void 0,
5375 floatingRootContext: getEmptyRootContext(),
5376 preventUnmountingOnClose: false,
5377 payload: void 0,
5378 activeTriggerId: null,
5379 activeTriggerElement: null,
5380 triggerIdProp: void 0,
5381 popupElement: null,
5382 positionerElement: null,
5383 activeTriggerProps: EMPTY_OBJECT,
5384 inactiveTriggerProps: EMPTY_OBJECT,
5385 popupProps: EMPTY_OBJECT
5386 };
5387 }
5388 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
5389 var popupStoreSelectors = {
5390 open: createSelector((state) => state.openProp ?? state.open),
5391 mounted: createSelector((state) => state.mounted),
5392 transitionStatus: createSelector((state) => state.transitionStatus),
5393 floatingRootContext: createSelector((state) => state.floatingRootContext),
5394 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
5395 payload: createSelector((state) => state.payload),
5396 activeTriggerId: activeTriggerIdSelector,
5397 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
5398 /**
5399 * Whether the trigger with the given ID was used to open the popup.
5400 */
5401 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
5402 /**
5403 * Whether the popup is open and was activated by a trigger with the given ID.
5404 */
5405 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open),
5406 /**
5407 * Whether the popup is mounted and was activated by a trigger with the given ID.
5408 */
5409 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
5410 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
5411 popupProps: createSelector((state) => state.popupProps),
5412 popupElement: createSelector((state) => state.popupElement),
5413 positionerElement: createSelector((state) => state.positionerElement)
5414 };
5415
5416 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
5417 function useFloatingRootContext(options) {
5418 const {
5419 open = false,
5420 onOpenChange,
5421 elements = {}
5422 } = options;
5423 const floatingId = useId();
5424 const nested = useFloatingParentNodeId() != null;
5425 if (true) {
5426 const optionDomReference = elements.reference;
5427 if (optionDomReference && !isElement(optionDomReference)) {
5428 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
5429 }
5430 }
5431 const store2 = useRefWithInit(() => new FloatingRootStore({
5432 open,
5433 transitionStatus: void 0,
5434 onOpenChange,
5435 referenceElement: elements.reference ?? null,
5436 floatingElement: elements.floating ?? null,
5437 triggerElements: new PopupTriggerMap(),
5438 floatingId,
5439 syncOnly: false,
5440 nested
5441 })).current;
5442 useIsoLayoutEffect(() => {
5443 const valuesToSync = {
5444 open,
5445 floatingId
5446 };
5447 if (elements.reference !== void 0) {
5448 valuesToSync.referenceElement = elements.reference;
5449 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
5450 }
5451 if (elements.floating !== void 0) {
5452 valuesToSync.floatingElement = elements.floating;
5453 }
5454 store2.update(valuesToSync);
5455 }, [open, floatingId, elements.reference, elements.floating, store2]);
5456 store2.context.onOpenChange = onOpenChange;
5457 store2.context.nested = nested;
5458 return store2;
5459 }
5460
5461 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
5462 function useFloating2(options = {}) {
5463 const {
5464 nodeId,
5465 externalTree
5466 } = options;
5467 const internalRootStore = useFloatingRootContext(options);
5468 const rootContext = options.rootContext || internalRootStore;
5469 const rootContextElements = {
5470 reference: rootContext.useState("referenceElement"),
5471 floating: rootContext.useState("floatingElement"),
5472 domReference: rootContext.useState("domReferenceElement")
5473 };
5474 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
5475 const domReferenceRef = React25.useRef(null);
5476 const tree = useFloatingTree(externalTree);
5477 useIsoLayoutEffect(() => {
5478 if (rootContextElements.domReference) {
5479 domReferenceRef.current = rootContextElements.domReference;
5480 }
5481 }, [rootContextElements.domReference]);
5482 const position = useFloating({
5483 ...options,
5484 elements: {
5485 ...rootContextElements,
5486 ...positionReference && {
5487 reference: positionReference
5488 }
5489 }
5490 });
5491 const setPositionReference = React25.useCallback((node) => {
5492 const computedPositionReference = isElement(node) ? {
5493 getBoundingClientRect: () => node.getBoundingClientRect(),
5494 getClientRects: () => node.getClientRects(),
5495 contextElement: node
5496 } : node;
5497 setPositionReferenceRaw(computedPositionReference);
5498 position.refs.setReference(computedPositionReference);
5499 }, [position.refs]);
5500 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
5501 const [localFloatingElement, setLocalFloatingElement] = React25.useState(null);
5502 rootContext.useSyncedValue("referenceElement", localDomReference ?? null);
5503 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
5504 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement);
5505 rootContext.useSyncedValue("floatingElement", localFloatingElement);
5506 const setReference = React25.useCallback((node) => {
5507 if (isElement(node) || node === null) {
5508 domReferenceRef.current = node;
5509 setLocalDomReference(node);
5510 }
5511 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
5512 // `null` to support `positionReference` + an unstable `reference`
5513 // callback ref.
5514 node !== null && !isElement(node)) {
5515 position.refs.setReference(node);
5516 }
5517 }, [position.refs, setLocalDomReference]);
5518 const setFloating = React25.useCallback((node) => {
5519 setLocalFloatingElement(node);
5520 position.refs.setFloating(node);
5521 }, [position.refs]);
5522 const refs = React25.useMemo(() => ({
5523 ...position.refs,
5524 setReference,
5525 setFloating,
5526 setPositionReference,
5527 domReference: domReferenceRef
5528 }), [position.refs, setReference, setFloating, setPositionReference]);
5529 const elements = React25.useMemo(() => ({
5530 ...position.elements,
5531 domReference: rootContextElements.domReference
5532 }), [position.elements, rootContextElements.domReference]);
5533 const open = rootContext.useState("open");
5534 const floatingId = rootContext.useState("floatingId");
5535 const context = React25.useMemo(() => ({
5536 ...position,
5537 dataRef: rootContext.context.dataRef,
5538 open,
5539 onOpenChange: rootContext.setOpen,
5540 events: rootContext.context.events,
5541 floatingId,
5542 refs,
5543 elements,
5544 nodeId,
5545 rootStore: rootContext
5546 }), [position, refs, elements, nodeId, rootContext, open, floatingId]);
5547 useIsoLayoutEffect(() => {
5548 rootContext.context.dataRef.current.floatingContext = context;
5549 const node = tree?.nodesRef.current.find((n) => n.id === nodeId);
5550 if (node) {
5551 node.context = context;
5552 }
5553 });
5554 return React25.useMemo(() => ({
5555 ...position,
5556 context,
5557 refs,
5558 elements,
5559 rootStore: rootContext
5560 }), [position, refs, elements, context, rootContext]);
5561 }
5562
5563 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5564 function useSyncedFloatingRootContext(options) {
5565 const {
5566 popupStore,
5567 treatPopupAsFloatingElement = false,
5568 onOpenChange
5569 } = options;
5570 const floatingId = useId();
5571 const nested = useFloatingParentNodeId() != null;
5572 const open = popupStore.useState("open");
5573 const referenceElement = popupStore.useState("activeTriggerElement");
5574 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5575 const triggerElements = popupStore.context.triggerElements;
5576 const store2 = useRefWithInit(() => new FloatingRootStore({
5577 open,
5578 transitionStatus: void 0,
5579 referenceElement,
5580 floatingElement,
5581 triggerElements,
5582 onOpenChange,
5583 floatingId,
5584 syncOnly: true,
5585 nested
5586 })).current;
5587 useIsoLayoutEffect(() => {
5588 const valuesToSync = {
5589 open,
5590 floatingId,
5591 referenceElement,
5592 floatingElement
5593 };
5594 if (isElement(referenceElement)) {
5595 valuesToSync.domReferenceElement = referenceElement;
5596 }
5597 if (store2.state.positionReference === store2.state.referenceElement) {
5598 valuesToSync.positionReference = referenceElement;
5599 }
5600 store2.update(valuesToSync);
5601 }, [open, floatingId, referenceElement, floatingElement, store2]);
5602 store2.context.onOpenChange = onOpenChange;
5603 store2.context.nested = nested;
5604 return store2;
5605 }
5606
5607 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
5608 var React26 = __toESM(require_react(), 1);
5609 var isMacSafari = isMac && isSafari;
5610 function useFocus(context, props = {}) {
5611 const store2 = "rootStore" in context ? context.rootStore : context;
5612 const {
5613 events,
5614 dataRef
5615 } = store2.context;
5616 const {
5617 enabled = true,
5618 delay
5619 } = props;
5620 const blockFocusRef = React26.useRef(false);
5621 const blockedReferenceRef = React26.useRef(null);
5622 const timeout = useTimeout();
5623 const keyboardModalityRef = React26.useRef(true);
5624 React26.useEffect(() => {
5625 const domReference = store2.select("domReferenceElement");
5626 if (!enabled) {
5627 return void 0;
5628 }
5629 const win = getWindow(domReference);
5630 function onBlur() {
5631 const currentDomReference = store2.select("domReferenceElement");
5632 if (!store2.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
5633 blockFocusRef.current = true;
5634 }
5635 }
5636 function onKeyDown() {
5637 keyboardModalityRef.current = true;
5638 }
5639 function onPointerDown() {
5640 keyboardModalityRef.current = false;
5641 }
5642 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
5643 }, [store2, enabled]);
5644 React26.useEffect(() => {
5645 if (!enabled) {
5646 return void 0;
5647 }
5648 function onOpenChangeLocal(details) {
5649 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
5650 const referenceElement = store2.select("domReferenceElement");
5651 if (isElement(referenceElement)) {
5652 blockedReferenceRef.current = referenceElement;
5653 blockFocusRef.current = true;
5654 }
5655 }
5656 }
5657 events.on("openchange", onOpenChangeLocal);
5658 return () => {
5659 events.off("openchange", onOpenChangeLocal);
5660 };
5661 }, [events, enabled, store2]);
5662 const reference = React26.useMemo(() => ({
5663 onMouseLeave() {
5664 blockFocusRef.current = false;
5665 blockedReferenceRef.current = null;
5666 },
5667 onFocus(event) {
5668 const focusTarget = event.currentTarget;
5669 if (blockFocusRef.current) {
5670 if (blockedReferenceRef.current === focusTarget) {
5671 return;
5672 }
5673 blockFocusRef.current = false;
5674 blockedReferenceRef.current = null;
5675 }
5676 const target = getTarget(event.nativeEvent);
5677 if (isElement(target)) {
5678 if (isMacSafari && !event.relatedTarget) {
5679 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
5680 return;
5681 }
5682 } else if (!matchesFocusVisible(target)) {
5683 return;
5684 }
5685 }
5686 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements);
5687 const {
5688 nativeEvent,
5689 currentTarget
5690 } = event;
5691 const delayValue = typeof delay === "function" ? delay() : delay;
5692 if (store2.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
5693 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
5694 return;
5695 }
5696 timeout.start(delayValue, () => {
5697 if (blockFocusRef.current) {
5698 return;
5699 }
5700 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
5701 });
5702 },
5703 onBlur(event) {
5704 blockFocusRef.current = false;
5705 blockedReferenceRef.current = null;
5706 const relatedTarget = event.relatedTarget;
5707 const nativeEvent = event.nativeEvent;
5708 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
5709 timeout.start(0, () => {
5710 const domReference = store2.select("domReferenceElement");
5711 const activeEl = activeElement(ownerDocument(domReference));
5712 if (!relatedTarget && activeEl === domReference) {
5713 return;
5714 }
5715 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
5716 return;
5717 }
5718 const nextFocusedElement = relatedTarget ?? activeEl;
5719 if (isTargetInsideEnabledTrigger(nextFocusedElement, store2.context.triggerElements)) {
5720 return;
5721 }
5722 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
5723 });
5724 }
5725 }), [dataRef, store2, timeout, delay]);
5726 return React26.useMemo(() => enabled ? {
5727 reference,
5728 trigger: reference
5729 } : {}, [enabled, reference]);
5730 }
5731
5732 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
5733 var React27 = __toESM(require_react(), 1);
5734
5735 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
5736 var HoverInteraction = class _HoverInteraction {
5737 constructor() {
5738 this.pointerType = void 0;
5739 this.interactedInside = false;
5740 this.handler = void 0;
5741 this.blockMouseMove = true;
5742 this.performedPointerEventsMutation = false;
5743 this.pointerEventsScopeElement = null;
5744 this.pointerEventsReferenceElement = null;
5745 this.pointerEventsFloatingElement = null;
5746 this.restTimeoutPending = false;
5747 this.openChangeTimeout = new Timeout();
5748 this.restTimeout = new Timeout();
5749 this.handleCloseOptions = void 0;
5750 }
5751 static create() {
5752 return new _HoverInteraction();
5753 }
5754 dispose = () => {
5755 this.openChangeTimeout.clear();
5756 this.restTimeout.clear();
5757 };
5758 disposeEffect = () => {
5759 return this.dispose;
5760 };
5761 };
5762 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
5763 function clearSafePolygonPointerEventsMutation(instance) {
5764 if (!instance.performedPointerEventsMutation) {
5765 return;
5766 }
5767 const scopeElement = instance.pointerEventsScopeElement;
5768 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
5769 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
5770 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
5771 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
5772 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
5773 }
5774 instance.performedPointerEventsMutation = false;
5775 instance.pointerEventsScopeElement = null;
5776 instance.pointerEventsReferenceElement = null;
5777 instance.pointerEventsFloatingElement = null;
5778 }
5779 function applySafePolygonPointerEventsMutation(instance, options) {
5780 const {
5781 scopeElement,
5782 referenceElement,
5783 floatingElement
5784 } = options;
5785 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
5786 if (existingOwner && existingOwner !== instance) {
5787 clearSafePolygonPointerEventsMutation(existingOwner);
5788 }
5789 clearSafePolygonPointerEventsMutation(instance);
5790 instance.performedPointerEventsMutation = true;
5791 instance.pointerEventsScopeElement = scopeElement;
5792 instance.pointerEventsReferenceElement = referenceElement;
5793 instance.pointerEventsFloatingElement = floatingElement;
5794 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
5795 scopeElement.style.pointerEvents = "none";
5796 referenceElement.style.pointerEvents = "auto";
5797 floatingElement.style.pointerEvents = "auto";
5798 }
5799 function useHoverInteractionSharedState(store2) {
5800 const instance = useRefWithInit(HoverInteraction.create).current;
5801 const data = store2.context.dataRef.current;
5802 if (!data.hoverInteractionState) {
5803 data.hoverInteractionState = instance;
5804 }
5805 useOnMount(data.hoverInteractionState.disposeEffect);
5806 return data.hoverInteractionState;
5807 }
5808
5809 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
5810 function useHoverFloatingInteraction(context, parameters = {}) {
5811 const store2 = "rootStore" in context ? context.rootStore : context;
5812 const open = store2.useState("open");
5813 const floatingElement = store2.useState("floatingElement");
5814 const domReferenceElement = store2.useState("domReferenceElement");
5815 const {
5816 dataRef
5817 } = store2.context;
5818 const {
5819 enabled = true,
5820 closeDelay: closeDelayProp = 0,
5821 nodeId: nodeIdProp
5822 } = parameters;
5823 const instance = useHoverInteractionSharedState(store2);
5824 const tree = useFloatingTree();
5825 const parentId = useFloatingParentNodeId();
5826 const isClickLikeOpenEvent2 = useStableCallback(() => {
5827 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
5828 });
5829 const isHoverOpen = useStableCallback(() => {
5830 const type = dataRef.current.openEvent?.type;
5831 return type?.includes("mouse") && type !== "mousedown";
5832 });
5833 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
5834 return isTargetInsideEnabledTrigger(target, store2.context.triggerElements);
5835 });
5836 const closeWithDelay = React27.useCallback((event) => {
5837 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
5838 const close = () => {
5839 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
5840 tree?.events.emit("floating.closed", event);
5841 };
5842 if (closeDelay) {
5843 instance.openChangeTimeout.start(closeDelay, close);
5844 } else {
5845 instance.openChangeTimeout.clear();
5846 close();
5847 }
5848 }, [closeDelayProp, store2, instance, tree]);
5849 const clearPointerEvents = useStableCallback(() => {
5850 clearSafePolygonPointerEventsMutation(instance);
5851 });
5852 const handleInteractInside = useStableCallback((event) => {
5853 const target = getTarget(event);
5854 if (!isInteractiveElement(target)) {
5855 instance.interactedInside = false;
5856 return;
5857 }
5858 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
5859 });
5860 useIsoLayoutEffect(() => {
5861 if (!open) {
5862 instance.pointerType = void 0;
5863 instance.restTimeoutPending = false;
5864 instance.interactedInside = false;
5865 clearPointerEvents();
5866 }
5867 }, [open, instance, clearPointerEvents]);
5868 React27.useEffect(() => {
5869 return clearPointerEvents;
5870 }, [clearPointerEvents]);
5871 useIsoLayoutEffect(() => {
5872 if (!enabled) {
5873 return void 0;
5874 }
5875 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
5876 const ref = domReferenceElement;
5877 const floatingEl = floatingElement;
5878 const doc = ownerDocument(floatingElement);
5879 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
5880 if (parentFloating) {
5881 parentFloating.style.pointerEvents = "";
5882 }
5883 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body;
5884 applySafePolygonPointerEventsMutation(instance, {
5885 scopeElement,
5886 referenceElement: ref,
5887 floatingElement: floatingEl
5888 });
5889 return () => {
5890 clearPointerEvents();
5891 };
5892 }
5893 return void 0;
5894 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
5895 const childClosedTimeout = useTimeout();
5896 React27.useEffect(() => {
5897 if (!enabled) {
5898 return void 0;
5899 }
5900 function onFloatingMouseEnter() {
5901 instance.openChangeTimeout.clear();
5902 childClosedTimeout.clear();
5903 tree?.events.off("floating.closed", onNodeClosed);
5904 clearPointerEvents();
5905 }
5906 function onFloatingMouseLeave(event) {
5907 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
5908 tree.events.on("floating.closed", onNodeClosed);
5909 return;
5910 }
5911 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) {
5912 return;
5913 }
5914 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
5915 const relatedTarget = event.relatedTarget;
5916 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
5917 if (isMovingIntoDescendantFloating) {
5918 return;
5919 }
5920 if (instance.handler) {
5921 instance.handler(event);
5922 return;
5923 }
5924 clearPointerEvents();
5925 if (!isClickLikeOpenEvent2()) {
5926 closeWithDelay(event);
5927 }
5928 }
5929 function onNodeClosed(event) {
5930 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
5931 return;
5932 }
5933 childClosedTimeout.start(0, () => {
5934 tree.events.off("floating.closed", onNodeClosed);
5935 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
5936 tree.events.emit("floating.closed", event);
5937 });
5938 }
5939 const floating = floatingElement;
5940 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
5941 tree?.events.off("floating.closed", onNodeClosed);
5942 });
5943 }, [enabled, floatingElement, store2, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]);
5944 }
5945
5946 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
5947 var React28 = __toESM(require_react(), 1);
5948 var ReactDOM4 = __toESM(require_react_dom(), 1);
5949 var EMPTY_REF = {
5950 current: null
5951 };
5952 function useHoverReferenceInteraction(context, props = {}) {
5953 const store2 = "rootStore" in context ? context.rootStore : context;
5954 const {
5955 dataRef,
5956 events
5957 } = store2.context;
5958 const {
5959 enabled = true,
5960 delay = 0,
5961 handleClose = null,
5962 mouseOnly = false,
5963 restMs = 0,
5964 move = true,
5965 triggerElementRef = EMPTY_REF,
5966 externalTree,
5967 isActiveTrigger = true,
5968 getHandleCloseContext,
5969 isClosing
5970 } = props;
5971 const tree = useFloatingTree(externalTree);
5972 const instance = useHoverInteractionSharedState(store2);
5973 const isHoverCloseActiveRef = React28.useRef(false);
5974 const handleCloseRef = useValueAsRef(handleClose);
5975 const delayRef = useValueAsRef(delay);
5976 const restMsRef = useValueAsRef(restMs);
5977 const enabledRef = useValueAsRef(enabled);
5978 const isClosingRef = useValueAsRef(isClosing);
5979 if (isActiveTrigger) {
5980 instance.handleCloseOptions = handleCloseRef.current?.__options;
5981 }
5982 const isClickLikeOpenEvent2 = useStableCallback(() => {
5983 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
5984 });
5985 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
5986 return isTargetInsideEnabledTrigger(target, store2.context.triggerElements);
5987 });
5988 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
5989 const allTriggers = store2.context.triggerElements;
5990 if (allTriggers.hasElement(currentTarget)) {
5991 return !currentDomReference || !contains(currentDomReference, currentTarget);
5992 }
5993 if (!isElement(target)) {
5994 return false;
5995 }
5996 const targetElement = target;
5997 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
5998 });
5999 const closeWithDelay = useStableCallback((event, runElseBranch = true) => {
6000 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6001 if (closeDelay) {
6002 instance.openChangeTimeout.start(closeDelay, () => {
6003 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6004 tree?.events.emit("floating.closed", event);
6005 });
6006 } else if (runElseBranch) {
6007 instance.openChangeTimeout.clear();
6008 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6009 tree?.events.emit("floating.closed", event);
6010 }
6011 });
6012 const cleanupMouseMoveHandler = useStableCallback(() => {
6013 if (!instance.handler) {
6014 return;
6015 }
6016 const doc = ownerDocument(store2.select("domReferenceElement"));
6017 doc.removeEventListener("mousemove", instance.handler);
6018 instance.handler = void 0;
6019 });
6020 const clearPointerEvents = useStableCallback(() => {
6021 clearSafePolygonPointerEventsMutation(instance);
6022 });
6023 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6024 React28.useEffect(() => {
6025 if (!enabled) {
6026 return void 0;
6027 }
6028 function onOpenChangeLocal(details) {
6029 if (!details.open) {
6030 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6031 cleanupMouseMoveHandler();
6032 instance.openChangeTimeout.clear();
6033 instance.restTimeout.clear();
6034 instance.blockMouseMove = true;
6035 instance.restTimeoutPending = false;
6036 } else {
6037 isHoverCloseActiveRef.current = false;
6038 }
6039 }
6040 events.on("openchange", onOpenChangeLocal);
6041 return () => {
6042 events.off("openchange", onOpenChangeLocal);
6043 };
6044 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6045 React28.useEffect(() => {
6046 if (!enabled) {
6047 return void 0;
6048 }
6049 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store2.select("domReferenceElement") : null);
6050 if (!isElement(trigger)) {
6051 return void 0;
6052 }
6053 function onMouseEnter(event) {
6054 instance.openChangeTimeout.clear();
6055 instance.blockMouseMove = false;
6056 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6057 return;
6058 }
6059 const restMsValue = getRestMs(restMsRef.current);
6060 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6061 const eventTarget = getTarget(event);
6062 const currentTarget = event.currentTarget ?? null;
6063 const currentDomReference = store2.select("domReferenceElement");
6064 let triggerNode = currentTarget;
6065 if (isElement(eventTarget) && !store2.context.triggerElements.hasElement(eventTarget)) {
6066 for (const triggerElement of store2.context.triggerElements.elements()) {
6067 if (contains(triggerElement, eventTarget)) {
6068 triggerNode = triggerElement;
6069 break;
6070 }
6071 }
6072 }
6073 if (isElement(currentTarget) && isElement(currentDomReference) && !store2.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6074 triggerNode = currentDomReference;
6075 }
6076 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6077 const isOpen = store2.select("open");
6078 const isInClosingTransition = isClosingRef.current?.() ?? store2.select("transitionStatus") === "ending";
6079 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6080 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6081 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6082 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6083 const shouldOpen = !isOpen || isOverInactive;
6084 if (shouldOpenImmediately) {
6085 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6086 return;
6087 }
6088 if (isRestOnlyDelay) {
6089 return;
6090 }
6091 if (openDelay) {
6092 instance.openChangeTimeout.start(openDelay, () => {
6093 if (shouldOpen) {
6094 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6095 }
6096 });
6097 } else if (shouldOpen) {
6098 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6099 }
6100 }
6101 function onMouseLeave(event) {
6102 if (isClickLikeOpenEvent2()) {
6103 clearPointerEvents();
6104 return;
6105 }
6106 cleanupMouseMoveHandler();
6107 const domReferenceElement = store2.select("domReferenceElement");
6108 const doc = ownerDocument(domReferenceElement);
6109 instance.restTimeout.clear();
6110 instance.restTimeoutPending = false;
6111 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6112 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget);
6113 if (ignoreRelatedTargetTrigger) {
6114 return;
6115 }
6116 if (handleCloseRef.current && handleCloseContextBase) {
6117 if (!store2.select("open")) {
6118 instance.openChangeTimeout.clear();
6119 }
6120 const currentTrigger = triggerElementRef.current;
6121 instance.handler = handleCloseRef.current({
6122 ...handleCloseContextBase,
6123 tree,
6124 x: event.clientX,
6125 y: event.clientY,
6126 onClose() {
6127 clearPointerEvents();
6128 cleanupMouseMoveHandler();
6129 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store2.select("domReferenceElement")) {
6130 closeWithDelay(event, true);
6131 }
6132 }
6133 });
6134 doc.addEventListener("mousemove", instance.handler);
6135 instance.handler(event);
6136 return;
6137 }
6138 const shouldClose = instance.pointerType === "touch" ? !contains(store2.select("floatingElement"), event.relatedTarget) : true;
6139 if (shouldClose) {
6140 closeWithDelay(event);
6141 }
6142 }
6143 if (move) {
6144 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6145 once: true
6146 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6147 }
6148 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6149 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store2, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]);
6150 return React28.useMemo(() => {
6151 if (!enabled) {
6152 return void 0;
6153 }
6154 function setPointerRef(event) {
6155 instance.pointerType = event.pointerType;
6156 }
6157 return {
6158 onPointerDown: setPointerRef,
6159 onPointerEnter: setPointerRef,
6160 onMouseMove(event) {
6161 const {
6162 nativeEvent
6163 } = event;
6164 const trigger = event.currentTarget;
6165 const currentDomReference = store2.select("domReferenceElement");
6166 const currentOpen = store2.select("open");
6167 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6168 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6169 return;
6170 }
6171 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6172 const floatingElement = store2.select("floatingElement");
6173 if (floatingElement) {
6174 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6175 applySafePolygonPointerEventsMutation(instance, {
6176 scopeElement,
6177 referenceElement: trigger,
6178 floatingElement
6179 });
6180 }
6181 }
6182 const restMsValue = getRestMs(restMsRef.current);
6183 if (currentOpen && !isOverInactive || restMsValue === 0) {
6184 return;
6185 }
6186 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6187 return;
6188 }
6189 instance.restTimeout.clear();
6190 function handleMouseMove() {
6191 instance.restTimeoutPending = false;
6192 if (isClickLikeOpenEvent2()) {
6193 return;
6194 }
6195 const latestOpen = store2.select("open");
6196 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) {
6197 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6198 }
6199 }
6200 if (instance.pointerType === "touch") {
6201 ReactDOM4.flushSync(() => {
6202 handleMouseMove();
6203 });
6204 } else if (isOverInactive && currentOpen) {
6205 handleMouseMove();
6206 } else {
6207 instance.restTimeoutPending = true;
6208 instance.restTimeout.start(restMsValue, handleMouseMove);
6209 }
6210 }
6211 };
6212 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store2, restMsRef]);
6213 }
6214
6215 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js
6216 var React29 = __toESM(require_react(), 1);
6217 function useInteractions(propsList = []) {
6218 const referenceDeps = propsList.map((key) => key?.reference);
6219 const floatingDeps = propsList.map((key) => key?.floating);
6220 const itemDeps = propsList.map((key) => key?.item);
6221 const triggerDeps = propsList.map((key) => key?.trigger);
6222 const getReferenceProps = React29.useCallback(
6223 (userProps) => mergeProps2(userProps, propsList, "reference"),
6224 // eslint-disable-next-line react-hooks/exhaustive-deps
6225 referenceDeps
6226 );
6227 const getFloatingProps = React29.useCallback(
6228 (userProps) => mergeProps2(userProps, propsList, "floating"),
6229 // eslint-disable-next-line react-hooks/exhaustive-deps
6230 floatingDeps
6231 );
6232 const getItemProps = React29.useCallback(
6233 (userProps) => mergeProps2(userProps, propsList, "item"),
6234 // eslint-disable-next-line react-hooks/exhaustive-deps
6235 itemDeps
6236 );
6237 const getTriggerProps = React29.useCallback(
6238 (userProps) => mergeProps2(userProps, propsList, "trigger"),
6239 // eslint-disable-next-line react-hooks/exhaustive-deps
6240 triggerDeps
6241 );
6242 return React29.useMemo(() => ({
6243 getReferenceProps,
6244 getFloatingProps,
6245 getItemProps,
6246 getTriggerProps
6247 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
6248 }
6249 function mergeProps2(userProps, propsList, elementKey) {
6250 const eventHandlers = /* @__PURE__ */ new Map();
6251 const isItem = elementKey === "item";
6252 const outputProps = {};
6253 if (elementKey === "floating") {
6254 outputProps.tabIndex = -1;
6255 outputProps[FOCUSABLE_ATTRIBUTE] = "";
6256 }
6257 for (const key in userProps) {
6258 if (isItem && userProps) {
6259 if (key === ACTIVE_KEY || key === SELECTED_KEY) {
6260 continue;
6261 }
6262 }
6263 outputProps[key] = userProps[key];
6264 }
6265 for (let i = 0; i < propsList.length; i += 1) {
6266 let props;
6267 const propsOrGetProps = propsList[i]?.[elementKey];
6268 if (typeof propsOrGetProps === "function") {
6269 props = userProps ? propsOrGetProps(userProps) : null;
6270 } else {
6271 props = propsOrGetProps;
6272 }
6273 if (!props) {
6274 continue;
6275 }
6276 mutablyMergeProps(outputProps, props, isItem, eventHandlers);
6277 }
6278 mutablyMergeProps(outputProps, userProps, isItem, eventHandlers);
6279 return outputProps;
6280 }
6281 function mutablyMergeProps(outputProps, props, isItem, eventHandlers) {
6282 for (const key in props) {
6283 const value = props[key];
6284 if (isItem && (key === ACTIVE_KEY || key === SELECTED_KEY)) {
6285 continue;
6286 }
6287 if (!key.startsWith("on")) {
6288 outputProps[key] = value;
6289 } else {
6290 if (!eventHandlers.has(key)) {
6291 eventHandlers.set(key, []);
6292 }
6293 if (typeof value === "function") {
6294 eventHandlers.get(key)?.push(value);
6295 outputProps[key] = (...args) => {
6296 return eventHandlers.get(key)?.map((fn) => fn(...args)).find((val) => val !== void 0);
6297 };
6298 }
6299 }
6300 }
6301 }
6302
6303 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
6304 var CURSOR_SPEED_THRESHOLD = 0.1;
6305 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6306 var POLYGON_BUFFER = 0.5;
6307 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6308 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6309 }
6310 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6311 let isInsideValue = false;
6312 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6313 isInsideValue = !isInsideValue;
6314 }
6315 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6316 isInsideValue = !isInsideValue;
6317 }
6318 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6319 isInsideValue = !isInsideValue;
6320 }
6321 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6322 isInsideValue = !isInsideValue;
6323 }
6324 return isInsideValue;
6325 }
6326 function isInsideRect(pointX, pointY, rect) {
6327 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6328 }
6329 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6330 const minX = Math.min(x1, x2);
6331 const maxX = Math.max(x1, x2);
6332 const minY = Math.min(y1, y2);
6333 const maxY = Math.max(y1, y2);
6334 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6335 }
6336 function safePolygon(options = {}) {
6337 const {
6338 blockPointerEvents = false
6339 } = options;
6340 const timeout = new Timeout();
6341 const fn = ({
6342 x,
6343 y,
6344 placement,
6345 elements,
6346 onClose,
6347 nodeId,
6348 tree
6349 }) => {
6350 const side = placement?.split("-")[0];
6351 let hasLanded = false;
6352 let lastX = null;
6353 let lastY = null;
6354 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6355 function isCursorMovingSlowly(nextX, nextY) {
6356 const currentTime = performance.now();
6357 const elapsedTime = currentTime - lastCursorTime;
6358 if (lastX === null || lastY === null || elapsedTime === 0) {
6359 lastX = nextX;
6360 lastY = nextY;
6361 lastCursorTime = currentTime;
6362 return false;
6363 }
6364 const deltaX = nextX - lastX;
6365 const deltaY = nextY - lastY;
6366 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6367 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6368 lastX = nextX;
6369 lastY = nextY;
6370 lastCursorTime = currentTime;
6371 return distanceSquared < thresholdSquared;
6372 }
6373 function close() {
6374 timeout.clear();
6375 onClose();
6376 }
6377 return function onMouseMove(event) {
6378 timeout.clear();
6379 const domReference = elements.domReference;
6380 const floating = elements.floating;
6381 if (!domReference || !floating || side == null || x == null || y == null) {
6382 return void 0;
6383 }
6384 const {
6385 clientX,
6386 clientY
6387 } = event;
6388 const target = getTarget(event);
6389 const isLeave = event.type === "mouseleave";
6390 const isOverFloatingEl = contains(floating, target);
6391 const isOverReferenceEl = contains(domReference, target);
6392 if (isOverFloatingEl) {
6393 hasLanded = true;
6394 if (!isLeave) {
6395 return void 0;
6396 }
6397 }
6398 if (isOverReferenceEl) {
6399 hasLanded = false;
6400 if (!isLeave) {
6401 hasLanded = true;
6402 return void 0;
6403 }
6404 }
6405 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
6406 return void 0;
6407 }
6408 function hasOpenChildNode() {
6409 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
6410 }
6411 function closeIfNoOpenChild() {
6412 if (!hasOpenChildNode()) {
6413 close();
6414 }
6415 }
6416 if (hasOpenChildNode()) {
6417 return void 0;
6418 }
6419 const refRect = domReference.getBoundingClientRect();
6420 const rect = floating.getBoundingClientRect();
6421 const cursorLeaveFromRight = x > rect.right - rect.width / 2;
6422 const cursorLeaveFromBottom = y > rect.bottom - rect.height / 2;
6423 const isFloatingWider = rect.width > refRect.width;
6424 const isFloatingTaller = rect.height > refRect.height;
6425 const left = (isFloatingWider ? refRect : rect).left;
6426 const right = (isFloatingWider ? refRect : rect).right;
6427 const top = (isFloatingTaller ? refRect : rect).top;
6428 const bottom = (isFloatingTaller ? refRect : rect).bottom;
6429 if (side === "top" && y >= refRect.bottom - 1 || side === "bottom" && y <= refRect.top + 1 || side === "left" && x >= refRect.right - 1 || side === "right" && x <= refRect.left + 1) {
6430 closeIfNoOpenChild();
6431 return void 0;
6432 }
6433 let isInsideTroughRect = false;
6434 switch (side) {
6435 case "top":
6436 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
6437 break;
6438 case "bottom":
6439 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
6440 break;
6441 case "left":
6442 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
6443 break;
6444 case "right":
6445 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
6446 break;
6447 default:
6448 }
6449 if (isInsideTroughRect) {
6450 return void 0;
6451 }
6452 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
6453 closeIfNoOpenChild();
6454 return void 0;
6455 }
6456 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
6457 closeIfNoOpenChild();
6458 return void 0;
6459 }
6460 let isInsidePolygon = false;
6461 switch (side) {
6462 case "top": {
6463 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6464 const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
6465 const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
6466 const cursorPointY = y + POLYGON_BUFFER + 1;
6467 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
6468 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
6469 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6470 break;
6471 }
6472 case "bottom": {
6473 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6474 const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
6475 const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
6476 const cursorPointY = y - POLYGON_BUFFER;
6477 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
6478 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
6479 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6480 break;
6481 }
6482 case "left": {
6483 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6484 const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
6485 const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
6486 const cursorPointX = x + POLYGON_BUFFER + 1;
6487 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
6488 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
6489 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
6490 break;
6491 }
6492 case "right": {
6493 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6494 const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
6495 const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
6496 const cursorPointX = x - POLYGON_BUFFER;
6497 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
6498 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
6499 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
6500 break;
6501 }
6502 default:
6503 }
6504 if (!isInsidePolygon) {
6505 closeIfNoOpenChild();
6506 } else if (!hasLanded) {
6507 timeout.start(40, closeIfNoOpenChild);
6508 }
6509 return void 0;
6510 };
6511 };
6512 fn.__options = {
6513 ...options,
6514 blockPointerEvents
6515 };
6516 return fn;
6517 }
6518
6519 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
6520 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
6521 CommonPopupDataAttributes2["open"] = "data-open";
6522 CommonPopupDataAttributes2["closed"] = "data-closed";
6523 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
6524 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
6525 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
6526 CommonPopupDataAttributes2["side"] = "data-side";
6527 CommonPopupDataAttributes2["align"] = "data-align";
6528 return CommonPopupDataAttributes2;
6529 })({});
6530 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
6531 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
6532 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
6533 return CommonTriggerDataAttributes2;
6534 })({});
6535 var TRIGGER_HOOK = {
6536 [CommonTriggerDataAttributes.popupOpen]: ""
6537 };
6538 var PRESSABLE_TRIGGER_HOOK = {
6539 [CommonTriggerDataAttributes.popupOpen]: "",
6540 [CommonTriggerDataAttributes.pressed]: ""
6541 };
6542 var POPUP_OPEN_HOOK = {
6543 [CommonPopupDataAttributes.open]: ""
6544 };
6545 var POPUP_CLOSED_HOOK = {
6546 [CommonPopupDataAttributes.closed]: ""
6547 };
6548 var ANCHOR_HIDDEN_HOOK = {
6549 [CommonPopupDataAttributes.anchorHidden]: ""
6550 };
6551 var triggerOpenStateMapping = {
6552 open(value) {
6553 if (value) {
6554 return TRIGGER_HOOK;
6555 }
6556 return null;
6557 }
6558 };
6559 var popupStateMapping = {
6560 open(value) {
6561 if (value) {
6562 return POPUP_OPEN_HOOK;
6563 }
6564 return POPUP_CLOSED_HOOK;
6565 },
6566 anchorHidden(value) {
6567 if (value) {
6568 return ANCHOR_HIDDEN_HOOK;
6569 }
6570 return null;
6571 }
6572 };
6573
6574 // node_modules/@base-ui/utils/esm/inertValue.js
6575 function inertValue(value) {
6576 if (isReactVersionAtLeast(19)) {
6577 return value;
6578 }
6579 return value ? "true" : void 0;
6580 }
6581
6582 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
6583 var React30 = __toESM(require_react(), 1);
6584
6585 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
6586 var baseArrow = (options) => ({
6587 name: "arrow",
6588 options,
6589 async fn(state) {
6590 const {
6591 x,
6592 y,
6593 placement,
6594 rects,
6595 platform: platform3,
6596 elements,
6597 middlewareData
6598 } = state;
6599 const {
6600 element,
6601 padding = 0,
6602 offsetParent = "real"
6603 } = evaluate(options, state) || {};
6604 if (element == null) {
6605 return {};
6606 }
6607 const paddingObject = getPaddingObject(padding);
6608 const coords = {
6609 x,
6610 y
6611 };
6612 const axis = getAlignmentAxis(placement);
6613 const length = getAxisLength(axis);
6614 const arrowDimensions = await platform3.getDimensions(element);
6615 const isYAxis = axis === "y";
6616 const minProp = isYAxis ? "top" : "left";
6617 const maxProp = isYAxis ? "bottom" : "right";
6618 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
6619 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
6620 const startDiff = coords[axis] - rects.reference[axis];
6621 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
6622 let clientSize = elements.floating[clientProp] || rects.floating[length];
6623 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
6624 clientSize = elements.floating[clientProp] || rects.floating[length];
6625 }
6626 const centerToReference = endDiff / 2 - startDiff / 2;
6627 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
6628 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
6629 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
6630 const min2 = minPadding;
6631 const max2 = clientSize - arrowDimensions[length] - maxPadding;
6632 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
6633 const offset4 = clamp(min2, center, max2);
6634 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
6635 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
6636 return {
6637 [axis]: coords[axis] + alignmentOffset,
6638 data: {
6639 [axis]: offset4,
6640 centerOffset: center - offset4 - alignmentOffset,
6641 ...shouldAddOffset && {
6642 alignmentOffset
6643 }
6644 },
6645 reset: shouldAddOffset
6646 };
6647 }
6648 });
6649 var arrow4 = (options, deps) => ({
6650 ...baseArrow(options),
6651 options: [options, deps]
6652 });
6653
6654 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
6655 var hide4 = {
6656 name: "hide",
6657 async fn(state) {
6658 const {
6659 width,
6660 height,
6661 x,
6662 y
6663 } = state.rects.reference;
6664 const anchorHidden = width === 0 && height === 0 && x === 0 && y === 0;
6665 const nativeHideResult = await hide3().fn(state);
6666 return {
6667 data: {
6668 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
6669 }
6670 };
6671 }
6672 };
6673
6674 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
6675 var DEFAULT_SIDES = {
6676 sideX: "left",
6677 sideY: "top"
6678 };
6679 var adaptiveOrigin = {
6680 name: "adaptiveOrigin",
6681 async fn(state) {
6682 const {
6683 x: rawX,
6684 y: rawY,
6685 rects: {
6686 floating: floatRect
6687 },
6688 elements: {
6689 floating
6690 },
6691 platform: platform3,
6692 strategy,
6693 placement
6694 } = state;
6695 const win = getWindow(floating);
6696 const styles = win.getComputedStyle(floating);
6697 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
6698 if (!hasTransition) {
6699 return {
6700 x: rawX,
6701 y: rawY,
6702 data: DEFAULT_SIDES
6703 };
6704 }
6705 const offsetParent = await platform3.getOffsetParent?.(floating);
6706 let offsetDimensions = {
6707 width: 0,
6708 height: 0
6709 };
6710 if (strategy === "fixed" && win?.visualViewport) {
6711 offsetDimensions = {
6712 width: win.visualViewport.width,
6713 height: win.visualViewport.height
6714 };
6715 } else if (offsetParent === win) {
6716 const doc = ownerDocument(floating);
6717 offsetDimensions = {
6718 width: doc.documentElement.clientWidth,
6719 height: doc.documentElement.clientHeight
6720 };
6721 } else if (await platform3.isElement?.(offsetParent)) {
6722 offsetDimensions = await platform3.getDimensions(offsetParent);
6723 }
6724 const currentSide = getSide(placement);
6725 let x = rawX;
6726 let y = rawY;
6727 if (currentSide === "left") {
6728 x = offsetDimensions.width - (rawX + floatRect.width);
6729 }
6730 if (currentSide === "top") {
6731 y = offsetDimensions.height - (rawY + floatRect.height);
6732 }
6733 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
6734 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
6735 return {
6736 x,
6737 y,
6738 data: {
6739 sideX,
6740 sideY
6741 }
6742 };
6743 }
6744 };
6745
6746 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
6747 function getLogicalSide(sideParam, renderedSide, isRtl) {
6748 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
6749 const logicalRight = isRtl ? "inline-start" : "inline-end";
6750 const logicalLeft = isRtl ? "inline-end" : "inline-start";
6751 return {
6752 top: "top",
6753 right: isLogicalSideParam ? logicalRight : "right",
6754 bottom: "bottom",
6755 left: isLogicalSideParam ? logicalLeft : "left"
6756 }[renderedSide];
6757 }
6758 function getOffsetData(state, sideParam, isRtl) {
6759 const {
6760 rects,
6761 placement
6762 } = state;
6763 const data = {
6764 side: getLogicalSide(sideParam, getSide(placement), isRtl),
6765 align: getAlignment(placement) || "center",
6766 anchor: {
6767 width: rects.reference.width,
6768 height: rects.reference.height
6769 },
6770 positioner: {
6771 width: rects.floating.width,
6772 height: rects.floating.height
6773 }
6774 };
6775 return data;
6776 }
6777 function useAnchorPositioning(params) {
6778 const {
6779 // Public parameters
6780 anchor,
6781 positionMethod = "absolute",
6782 side: sideParam = "bottom",
6783 sideOffset = 0,
6784 align = "center",
6785 alignOffset = 0,
6786 collisionBoundary,
6787 collisionPadding: collisionPaddingParam = 5,
6788 sticky = false,
6789 arrowPadding = 5,
6790 disableAnchorTracking = false,
6791 // Private parameters
6792 keepMounted = false,
6793 floatingRootContext,
6794 mounted,
6795 collisionAvoidance,
6796 shiftCrossAxis = false,
6797 nodeId,
6798 adaptiveOrigin: adaptiveOrigin2,
6799 lazyFlip = false,
6800 externalTree
6801 } = params;
6802 const [mountSide, setMountSide] = React30.useState(null);
6803 if (!mounted && mountSide !== null) {
6804 setMountSide(null);
6805 }
6806 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
6807 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
6808 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
6809 const anchorFn = typeof anchor === "function" ? anchor : void 0;
6810 const anchorFnCallback = useStableCallback(anchorFn);
6811 const anchorDep = anchorFn ? anchorFnCallback : anchor;
6812 const anchorValueRef = useValueAsRef(anchor);
6813 const mountedRef = useValueAsRef(mounted);
6814 const direction = useDirection();
6815 const isRtl = direction === "rtl";
6816 const side = mountSide || {
6817 top: "top",
6818 right: "right",
6819 bottom: "bottom",
6820 left: "left",
6821 "inline-end": isRtl ? "left" : "right",
6822 "inline-start": isRtl ? "right" : "left"
6823 }[sideParam];
6824 const placement = align === "center" ? side : `${side}-${align}`;
6825 let collisionPadding = collisionPaddingParam;
6826 const bias = 1;
6827 const biasTop = sideParam === "bottom" ? bias : 0;
6828 const biasBottom = sideParam === "top" ? bias : 0;
6829 const biasLeft = sideParam === "right" ? bias : 0;
6830 const biasRight = sideParam === "left" ? bias : 0;
6831 if (typeof collisionPadding === "number") {
6832 collisionPadding = {
6833 top: collisionPadding + biasTop,
6834 right: collisionPadding + biasRight,
6835 bottom: collisionPadding + biasBottom,
6836 left: collisionPadding + biasLeft
6837 };
6838 } else if (collisionPadding) {
6839 collisionPadding = {
6840 top: (collisionPadding.top || 0) + biasTop,
6841 right: (collisionPadding.right || 0) + biasRight,
6842 bottom: (collisionPadding.bottom || 0) + biasBottom,
6843 left: (collisionPadding.left || 0) + biasLeft
6844 };
6845 }
6846 const commonCollisionProps = {
6847 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
6848 padding: collisionPadding
6849 };
6850 const arrowRef = React30.useRef(null);
6851 const sideOffsetRef = useValueAsRef(sideOffset);
6852 const alignOffsetRef = useValueAsRef(alignOffset);
6853 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
6854 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
6855 const middleware = [offset3((state) => {
6856 const data = getOffsetData(state, sideParam, isRtl);
6857 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
6858 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
6859 return {
6860 mainAxis: sideAxis,
6861 crossAxis: alignAxis,
6862 alignmentAxis: alignAxis
6863 };
6864 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])];
6865 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
6866 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
6867 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
6868 ...commonCollisionProps,
6869 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
6870 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
6871 padding: {
6872 top: collisionPadding.top + bias,
6873 right: collisionPadding.right + bias,
6874 bottom: collisionPadding.bottom + bias,
6875 left: collisionPadding.left + bias
6876 },
6877 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
6878 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
6879 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
6880 });
6881 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
6882 const html = ownerDocument(data.elements.floating).documentElement;
6883 return {
6884 ...commonCollisionProps,
6885 // Use the Layout Viewport to avoid shifting around when pinch-zooming
6886 // for context menus.
6887 rootBoundary: shiftCrossAxis ? {
6888 x: 0,
6889 y: 0,
6890 width: html.clientWidth,
6891 height: html.clientHeight
6892 } : void 0,
6893 mainAxis: collisionAvoidanceAlign !== "none",
6894 crossAxis: crossAxisShiftEnabled,
6895 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
6896 if (!arrowRef.current) {
6897 return {};
6898 }
6899 const {
6900 width,
6901 height
6902 } = arrowRef.current.getBoundingClientRect();
6903 const sideAxis = getSideAxis(getSide(limitData.placement));
6904 const arrowSize = sideAxis === "y" ? width : height;
6905 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
6906 return {
6907 offset: arrowSize / 2 + offsetAmount / 2
6908 };
6909 })
6910 };
6911 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
6912 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
6913 middleware.push(shiftMiddleware, flipMiddleware);
6914 } else {
6915 middleware.push(flipMiddleware, shiftMiddleware);
6916 }
6917 middleware.push(size3({
6918 ...commonCollisionProps,
6919 apply({
6920 elements: {
6921 floating
6922 },
6923 availableWidth,
6924 availableHeight,
6925 rects
6926 }) {
6927 if (!mountedRef.current) {
6928 return;
6929 }
6930 const floatingStyle = floating.style;
6931 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
6932 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
6933 const dpr = getWindow(floating).devicePixelRatio || 1;
6934 const {
6935 x: x2,
6936 y: y2,
6937 width,
6938 height
6939 } = rects.reference;
6940 const anchorWidth = (Math.round((x2 + width) * dpr) - Math.round(x2 * dpr)) / dpr;
6941 const anchorHeight = (Math.round((y2 + height) * dpr) - Math.round(y2 * dpr)) / dpr;
6942 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
6943 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
6944 }
6945 }), arrow4(() => ({
6946 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
6947 // we'll create a fake element.
6948 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"),
6949 padding: arrowPadding,
6950 offsetParent: "floating"
6951 }), [arrowPadding]), {
6952 name: "transformOrigin",
6953 fn(state) {
6954 const {
6955 elements: elements2,
6956 middlewareData: middlewareData2,
6957 placement: renderedPlacement2,
6958 rects,
6959 y: y2
6960 } = state;
6961 const currentRenderedSide = getSide(renderedPlacement2);
6962 const currentRenderedAxis = getSideAxis(currentRenderedSide);
6963 const arrowEl = arrowRef.current;
6964 const arrowX = middlewareData2.arrow?.x || 0;
6965 const arrowY = middlewareData2.arrow?.y || 0;
6966 const arrowWidth = arrowEl?.clientWidth || 0;
6967 const arrowHeight = arrowEl?.clientHeight || 0;
6968 const transformX = arrowX + arrowWidth / 2;
6969 const transformY = arrowY + arrowHeight / 2;
6970 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
6971 const halfAnchorHeight = rects.reference.height / 2;
6972 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
6973 const isOverlappingAnchor = shiftY > sideOffsetValue;
6974 const adjacentTransformOrigin = {
6975 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
6976 bottom: `${transformX}px ${-sideOffsetValue}px`,
6977 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
6978 right: `${-sideOffsetValue}px ${transformY}px`
6979 }[currentRenderedSide];
6980 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y2}px`;
6981 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
6982 return {};
6983 }
6984 }, hide4, adaptiveOrigin2);
6985 useIsoLayoutEffect(() => {
6986 if (!mounted && floatingRootContext) {
6987 floatingRootContext.update({
6988 referenceElement: null,
6989 floatingElement: null,
6990 domReferenceElement: null,
6991 positionReference: null
6992 });
6993 }
6994 }, [mounted, floatingRootContext]);
6995 const autoUpdateOptions = React30.useMemo(() => ({
6996 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
6997 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
6998 }), [disableAnchorTracking]);
6999 const {
7000 refs,
7001 elements,
7002 x,
7003 y,
7004 middlewareData,
7005 update: update2,
7006 placement: renderedPlacement,
7007 context,
7008 isPositioned,
7009 floatingStyles: originalFloatingStyles
7010 } = useFloating2({
7011 rootContext: floatingRootContext,
7012 open: keepMounted ? mounted : void 0,
7013 placement,
7014 middleware,
7015 strategy: positionMethod,
7016 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7017 nodeId,
7018 externalTree
7019 });
7020 const {
7021 sideX,
7022 sideY
7023 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7024 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7025 const floatingStyles = React30.useMemo(() => {
7026 const base = adaptiveOrigin2 ? {
7027 position: resolvedPosition,
7028 [sideX]: x,
7029 [sideY]: y
7030 } : {
7031 position: resolvedPosition,
7032 ...originalFloatingStyles
7033 };
7034 if (!isPositioned) {
7035 base.opacity = 0;
7036 }
7037 return base;
7038 }, [adaptiveOrigin2, resolvedPosition, sideX, x, sideY, y, originalFloatingStyles, isPositioned]);
7039 const registeredPositionReferenceRef = React30.useRef(null);
7040 useIsoLayoutEffect(() => {
7041 if (!mounted) {
7042 return;
7043 }
7044 const anchorValue = anchorValueRef.current;
7045 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7046 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7047 const finalAnchor = unwrappedElement || null;
7048 if (finalAnchor !== registeredPositionReferenceRef.current) {
7049 refs.setPositionReference(finalAnchor);
7050 registeredPositionReferenceRef.current = finalAnchor;
7051 }
7052 }, [mounted, refs, anchorDep, anchorValueRef]);
7053 React30.useEffect(() => {
7054 if (!mounted) {
7055 return;
7056 }
7057 const anchorValue = anchorValueRef.current;
7058 if (typeof anchorValue === "function") {
7059 return;
7060 }
7061 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7062 refs.setPositionReference(anchorValue.current);
7063 registeredPositionReferenceRef.current = anchorValue.current;
7064 }
7065 }, [mounted, refs, anchorDep, anchorValueRef]);
7066 React30.useEffect(() => {
7067 if (keepMounted && mounted && elements.domReference && elements.floating) {
7068 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7069 }
7070 return void 0;
7071 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7072 const renderedSide = getSide(renderedPlacement);
7073 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7074 const renderedAlign = getAlignment(renderedPlacement) || "center";
7075 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7076 useIsoLayoutEffect(() => {
7077 if (lazyFlip && mounted && isPositioned) {
7078 setMountSide(renderedSide);
7079 }
7080 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7081 const arrowStyles = React30.useMemo(() => ({
7082 position: "absolute",
7083 top: middlewareData.arrow?.y,
7084 left: middlewareData.arrow?.x
7085 }), [middlewareData.arrow]);
7086 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7087 return React30.useMemo(() => ({
7088 positionerStyles: floatingStyles,
7089 arrowStyles,
7090 arrowRef,
7091 arrowUncentered,
7092 side: logicalRenderedSide,
7093 align: renderedAlign,
7094 physicalSide: renderedSide,
7095 anchorHidden,
7096 refs,
7097 context,
7098 isPositioned,
7099 update: update2
7100 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7101 }
7102 function isRef(param) {
7103 return param != null && "current" in param;
7104 }
7105
7106 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7107 function getDisabledMountTransitionStyles(transitionStatus) {
7108 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7109 }
7110
7111 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7112 function usePositioner(componentProps, state, {
7113 styles,
7114 transitionStatus,
7115 props,
7116 refs,
7117 hidden,
7118 inert = false
7119 }) {
7120 const style = {
7121 ...styles
7122 };
7123 if (inert) {
7124 style.pointerEvents = "none";
7125 }
7126 return useRenderElement("div", componentProps, {
7127 state,
7128 ref: refs,
7129 props: [{
7130 role: "presentation",
7131 hidden,
7132 style
7133 }, getDisabledMountTransitionStyles(transitionStatus), props],
7134 stateAttributesMapping: popupStateMapping
7135 });
7136 }
7137
7138 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7139 var React33 = __toESM(require_react(), 1);
7140 var ReactDOM5 = __toESM(require_react_dom(), 1);
7141
7142 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7143 var React31 = __toESM(require_react(), 1);
7144 function usePreviousValue(value) {
7145 const [state, setState] = React31.useState({
7146 current: value,
7147 previous: null
7148 });
7149 if (value !== state.current) {
7150 setState({
7151 current: value,
7152 previous: state.current
7153 });
7154 }
7155 return state.previous;
7156 }
7157
7158 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7159 var React32 = __toESM(require_react(), 1);
7160
7161 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7162 function getCssDimensions2(element) {
7163 const css = getComputedStyle2(element);
7164 let width = parseFloat(css.width) || 0;
7165 let height = parseFloat(css.height) || 0;
7166 const hasOffset = isHTMLElement(element);
7167 const offsetWidth = hasOffset ? element.offsetWidth : width;
7168 const offsetHeight = hasOffset ? element.offsetHeight : height;
7169 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7170 if (shouldFallback) {
7171 width = offsetWidth;
7172 height = offsetHeight;
7173 }
7174 return {
7175 width,
7176 height
7177 };
7178 }
7179
7180 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7181 var DEFAULT_ENABLED = () => true;
7182 function usePopupAutoResize(parameters) {
7183 const {
7184 popupElement,
7185 positionerElement,
7186 content,
7187 mounted,
7188 enabled = DEFAULT_ENABLED,
7189 onMeasureLayout: onMeasureLayoutParam,
7190 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7191 side,
7192 direction
7193 } = parameters;
7194 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7195 const animationFrame = useAnimationFrame();
7196 const committedDimensionsRef = React32.useRef(null);
7197 const liveDimensionsRef = React32.useRef(null);
7198 const isInitialRenderRef = React32.useRef(true);
7199 const restoreAnchoringStylesRef = React32.useRef(NOOP);
7200 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7201 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7202 const anchoringStyles = React32.useMemo(() => {
7203 let isOriginSide = side === "top";
7204 let isPhysicalLeft = side === "left";
7205 if (direction === "rtl") {
7206 isOriginSide = isOriginSide || side === "inline-end";
7207 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7208 } else {
7209 isOriginSide = isOriginSide || side === "inline-start";
7210 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7211 }
7212 return isOriginSide ? {
7213 position: "absolute",
7214 [side === "top" ? "bottom" : "top"]: "0",
7215 [isPhysicalLeft ? "right" : "left"]: "0"
7216 } : EMPTY_OBJECT;
7217 }, [side, direction]);
7218 useIsoLayoutEffect(() => {
7219 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7220 restoreAnchoringStylesRef.current = NOOP;
7221 isInitialRenderRef.current = true;
7222 committedDimensionsRef.current = null;
7223 liveDimensionsRef.current = null;
7224 return void 0;
7225 }
7226 if (!popupElement || !positionerElement) {
7227 return void 0;
7228 }
7229 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7230 const observer = new ResizeObserver((entries) => {
7231 const entry = entries[0];
7232 if (entry) {
7233 liveDimensionsRef.current = {
7234 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
7235 height: Math.ceil(entry.borderBoxSize[0].blockSize)
7236 };
7237 }
7238 });
7239 observer.observe(popupElement);
7240 setPopupCssSize(popupElement, "auto");
7241 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7242 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7243 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7244 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7245 "--available-width": "max-content",
7246 "--available-height": "max-content"
7247 });
7248 function restoreMeasurementOverrides() {
7249 restorePopupPosition();
7250 restorePopupTransform();
7251 restorePositionerAvailableSize();
7252 }
7253 function restoreMeasurementOverridesIncludingScale() {
7254 restoreMeasurementOverrides();
7255 restorePopupScale();
7256 }
7257 onMeasureLayout?.();
7258 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7259 setPositionerCssSize(positionerElement, "max-content");
7260 const dimensions = getCssDimensions2(popupElement);
7261 committedDimensionsRef.current = dimensions;
7262 setPositionerCssSize(positionerElement, dimensions);
7263 restoreMeasurementOverridesIncludingScale();
7264 onMeasureLayoutComplete?.(null, dimensions);
7265 isInitialRenderRef.current = false;
7266 return () => {
7267 observer.disconnect();
7268 restoreAnchoringStylesRef.current();
7269 restoreAnchoringStylesRef.current = NOOP;
7270 };
7271 }
7272 setPopupCssSize(popupElement, "auto");
7273 setPositionerCssSize(positionerElement, "max-content");
7274 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
7275 const newDimensions = getCssDimensions2(popupElement);
7276 committedDimensionsRef.current = newDimensions;
7277 if (!previousDimensions) {
7278 setPositionerCssSize(positionerElement, newDimensions);
7279 restoreMeasurementOverridesIncludingScale();
7280 onMeasureLayoutComplete?.(null, newDimensions);
7281 return () => {
7282 observer.disconnect();
7283 animationFrame.cancel();
7284 restoreAnchoringStylesRef.current();
7285 restoreAnchoringStylesRef.current = NOOP;
7286 };
7287 }
7288 setPopupCssSize(popupElement, previousDimensions);
7289 restoreMeasurementOverridesIncludingScale();
7290 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7291 setPositionerCssSize(positionerElement, newDimensions);
7292 const abortController = new AbortController();
7293 animationFrame.request(() => {
7294 setPopupCssSize(popupElement, newDimensions);
7295 runOnceAnimationsFinish(() => {
7296 popupElement.style.setProperty("--popup-width", "auto");
7297 popupElement.style.setProperty("--popup-height", "auto");
7298 }, abortController.signal);
7299 });
7300 return () => {
7301 observer.disconnect();
7302 abortController.abort();
7303 animationFrame.cancel();
7304 restoreAnchoringStylesRef.current();
7305 restoreAnchoringStylesRef.current = NOOP;
7306 };
7307 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7308 }
7309 function overrideElementStyle(element, property, value) {
7310 const originalValue = element.style.getPropertyValue(property);
7311 element.style.setProperty(property, value);
7312 return () => {
7313 element.style.setProperty(property, originalValue);
7314 };
7315 }
7316 function applyElementStyles(element, styles) {
7317 const restorers = [];
7318 for (const [key, value] of Object.entries(styles)) {
7319 restorers.push(overrideElementStyle(element, key, value));
7320 }
7321 return restorers.length ? () => {
7322 restorers.forEach((restore) => restore());
7323 } : NOOP;
7324 }
7325 function setPopupCssSize(popupElement, size4) {
7326 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7327 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7328 popupElement.style.setProperty("--popup-width", width);
7329 popupElement.style.setProperty("--popup-height", height);
7330 }
7331 function setPositionerCssSize(positionerElement, size4) {
7332 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7333 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7334 positionerElement.style.setProperty("--positioner-width", width);
7335 positionerElement.style.setProperty("--positioner-height", height);
7336 }
7337
7338 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7339 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
7340 function usePopupViewport(parameters) {
7341 const {
7342 store: store2,
7343 side,
7344 cssVars,
7345 children
7346 } = parameters;
7347 const direction = useDirection();
7348 const activeTrigger = store2.useState("activeTriggerElement");
7349 const activeTriggerId = store2.useState("activeTriggerId");
7350 const open = store2.useState("open");
7351 const payload = store2.useState("payload");
7352 const mounted = store2.useState("mounted");
7353 const popupElement = store2.useState("popupElement");
7354 const positionerElement = store2.useState("positionerElement");
7355 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7356 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7357 const capturedNodeRef = React33.useRef(null);
7358 const [previousContentNode, setPreviousContentNode] = React33.useState(null);
7359 const [newTriggerOffset, setNewTriggerOffset] = React33.useState(null);
7360 const currentContainerRef = React33.useRef(null);
7361 const previousContainerRef = React33.useRef(null);
7362 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7363 const cleanupFrame = useAnimationFrame();
7364 const [previousContentDimensions, setPreviousContentDimensions] = React33.useState(null);
7365 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React33.useState(false);
7366 useIsoLayoutEffect(() => {
7367 store2.set("hasViewport", true);
7368 return () => {
7369 store2.set("hasViewport", false);
7370 };
7371 }, [store2]);
7372 const handleMeasureLayout = useStableCallback(() => {
7373 currentContainerRef.current?.style.setProperty("animation", "none");
7374 currentContainerRef.current?.style.setProperty("transition", "none");
7375 previousContainerRef.current?.style.setProperty("display", "none");
7376 });
7377 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7378 currentContainerRef.current?.style.removeProperty("animation");
7379 currentContainerRef.current?.style.removeProperty("transition");
7380 previousContainerRef.current?.style.removeProperty("display");
7381 if (previousDimensions) {
7382 setPreviousContentDimensions(previousDimensions);
7383 }
7384 });
7385 const lastHandledTriggerRef = React33.useRef(null);
7386 useIsoLayoutEffect(() => {
7387 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
7388 setPreviousContentNode(capturedNodeRef.current);
7389 setShowStartingStyleAttribute(true);
7390 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
7391 setNewTriggerOffset(offset4);
7392 cleanupFrame.request(() => {
7393 ReactDOM5.flushSync(() => {
7394 setShowStartingStyleAttribute(false);
7395 });
7396 onAnimationsFinished(() => {
7397 setPreviousContentNode(null);
7398 setPreviousContentDimensions(null);
7399 capturedNodeRef.current = null;
7400 });
7401 });
7402 lastHandledTriggerRef.current = activeTrigger;
7403 }
7404 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
7405 useIsoLayoutEffect(() => {
7406 const source = currentContainerRef.current;
7407 if (!source) {
7408 return;
7409 }
7410 const wrapper = ownerDocument(source).createElement("div");
7411 for (const child of Array.from(source.childNodes)) {
7412 wrapper.appendChild(child.cloneNode(true));
7413 }
7414 capturedNodeRef.current = wrapper;
7415 });
7416 const isTransitioning = previousContentNode != null;
7417 let childrenToRender;
7418 if (!isTransitioning) {
7419 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7420 "data-current": true,
7421 ref: currentContainerRef,
7422 children
7423 }, currentContentKey);
7424 } else {
7425 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React33.Fragment, {
7426 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7427 "data-previous": true,
7428 inert: inertValue(true),
7429 ref: previousContainerRef,
7430 style: {
7431 ...previousContentDimensions ? {
7432 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
7433 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
7434 } : null,
7435 position: "absolute"
7436 },
7437 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
7438 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7439 "data-current": true,
7440 ref: currentContainerRef,
7441 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
7442 children
7443 }, currentContentKey)]
7444 });
7445 }
7446 useIsoLayoutEffect(() => {
7447 const container = previousContainerRef.current;
7448 if (!container || !previousContentNode) {
7449 return;
7450 }
7451 container.replaceChildren(...Array.from(previousContentNode.childNodes));
7452 }, [previousContentNode]);
7453 usePopupAutoResize({
7454 popupElement,
7455 positionerElement,
7456 mounted,
7457 content: payload,
7458 onMeasureLayout: handleMeasureLayout,
7459 onMeasureLayoutComplete: handleMeasureLayoutComplete,
7460 side,
7461 direction
7462 });
7463 const state = {
7464 activationDirection: getActivationDirection(newTriggerOffset),
7465 transitioning: isTransitioning
7466 };
7467 return {
7468 children: childrenToRender,
7469 state
7470 };
7471 }
7472 function getActivationDirection(offset4) {
7473 if (!offset4) {
7474 return void 0;
7475 }
7476 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
7477 }
7478 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
7479 if (value > tolerance) {
7480 return positiveLabel;
7481 }
7482 if (value < -tolerance) {
7483 return negativeLabel;
7484 }
7485 return "";
7486 }
7487 function calculateRelativePosition(from, to) {
7488 const fromRect = from.getBoundingClientRect();
7489 const toRect = to.getBoundingClientRect();
7490 const fromCenter = {
7491 x: fromRect.left + fromRect.width / 2,
7492 y: fromRect.top + fromRect.height / 2
7493 };
7494 const toCenter = {
7495 x: toRect.left + toRect.width / 2,
7496 y: toRect.top + toRect.height / 2
7497 };
7498 return {
7499 horizontal: toCenter.x - fromCenter.x,
7500 vertical: toCenter.y - fromCenter.y
7501 };
7502 }
7503 function usePopupContentKey(activeTriggerId, payload) {
7504 const [contentKey, setContentKey] = React33.useState(0);
7505 const previousActiveTriggerIdRef = React33.useRef(activeTriggerId);
7506 const previousPayloadRef = React33.useRef(payload);
7507 const pendingPayloadUpdateRef = React33.useRef(false);
7508 useIsoLayoutEffect(() => {
7509 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
7510 const previousPayload = previousPayloadRef.current;
7511 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
7512 const payloadChanged = payload !== previousPayload;
7513 if (triggerIdChanged) {
7514 setContentKey((value) => value + 1);
7515 pendingPayloadUpdateRef.current = !payloadChanged;
7516 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
7517 setContentKey((value) => value + 1);
7518 pendingPayloadUpdateRef.current = false;
7519 }
7520 previousActiveTriggerIdRef.current = activeTriggerId;
7521 previousPayloadRef.current = payload;
7522 }, [activeTriggerId, payload]);
7523 return `${activeTriggerId ?? "current"}-${contentKey}`;
7524 }
7525
7526 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
7527 var React34 = __toESM(require_react(), 1);
7528 var ReactDOM6 = __toESM(require_react_dom(), 1);
7529 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
7530 var FloatingPortalLite = /* @__PURE__ */ React34.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
7531 const {
7532 children,
7533 container,
7534 className,
7535 render,
7536 style,
7537 ...elementProps
7538 } = componentProps;
7539 const {
7540 portalNode,
7541 portalSubtree
7542 } = useFloatingPortalNode({
7543 container,
7544 ref: forwardedRef,
7545 componentProps,
7546 elementProps
7547 });
7548 if (!portalSubtree && !portalNode) {
7549 return null;
7550 }
7551 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React34.Fragment, {
7552 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
7553 });
7554 });
7555 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
7556
7557 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
7558 var index_parts_exports = {};
7559 __export(index_parts_exports, {
7560 Arrow: () => TooltipArrow,
7561 Handle: () => TooltipHandle,
7562 Popup: () => TooltipPopup,
7563 Portal: () => TooltipPortal,
7564 Positioner: () => TooltipPositioner,
7565 Provider: () => TooltipProvider,
7566 Root: () => TooltipRoot,
7567 Trigger: () => TooltipTrigger,
7568 Viewport: () => TooltipViewport,
7569 createHandle: () => createTooltipHandle
7570 });
7571
7572 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
7573 var React37 = __toESM(require_react(), 1);
7574
7575 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
7576 var React35 = __toESM(require_react(), 1);
7577 var TooltipRootContext = /* @__PURE__ */ React35.createContext(void 0);
7578 if (true) TooltipRootContext.displayName = "TooltipRootContext";
7579 function useTooltipRootContext(optional) {
7580 const context = React35.useContext(TooltipRootContext);
7581 if (context === void 0 && !optional) {
7582 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
7583 }
7584 return context;
7585 }
7586
7587 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
7588 var React36 = __toESM(require_react(), 1);
7589 var ReactDOM7 = __toESM(require_react_dom(), 1);
7590 var selectors2 = {
7591 ...popupStoreSelectors,
7592 disabled: createSelector((state) => state.disabled),
7593 instantType: createSelector((state) => state.instantType),
7594 isInstantPhase: createSelector((state) => state.isInstantPhase),
7595 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
7596 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
7597 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
7598 closeOnClick: createSelector((state) => state.closeOnClick),
7599 closeDelay: createSelector((state) => state.closeDelay),
7600 hasViewport: createSelector((state) => state.hasViewport)
7601 };
7602 var TooltipStore = class _TooltipStore extends ReactStore {
7603 constructor(initialState) {
7604 super({
7605 ...createInitialState(),
7606 ...initialState
7607 }, {
7608 popupRef: /* @__PURE__ */ React36.createRef(),
7609 onOpenChange: void 0,
7610 onOpenChangeComplete: void 0,
7611 triggerElements: new PopupTriggerMap()
7612 }, selectors2);
7613 }
7614 setOpen = (nextOpen, eventDetails) => {
7615 const reason = eventDetails.reason;
7616 const isHover = reason === reason_parts_exports.triggerHover;
7617 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
7618 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
7619 eventDetails.preventUnmountOnClose = () => {
7620 this.set("preventUnmountingOnClose", true);
7621 };
7622 this.context.onOpenChange?.(nextOpen, eventDetails);
7623 if (eventDetails.isCanceled) {
7624 return;
7625 }
7626 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
7627 const changeState = () => {
7628 const updatedState = {
7629 open: nextOpen,
7630 openChangeReason: reason
7631 };
7632 if (isFocusOpen) {
7633 updatedState.instantType = "focus";
7634 } else if (isDismissClose) {
7635 updatedState.instantType = "dismiss";
7636 } else if (reason === reason_parts_exports.triggerHover) {
7637 updatedState.instantType = void 0;
7638 }
7639 const newTriggerId = eventDetails.trigger?.id ?? null;
7640 if (newTriggerId || nextOpen) {
7641 updatedState.activeTriggerId = newTriggerId;
7642 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
7643 }
7644 this.update(updatedState);
7645 };
7646 if (isHover) {
7647 ReactDOM7.flushSync(changeState);
7648 } else {
7649 changeState();
7650 }
7651 };
7652 static useStore(externalStore, initialState) {
7653 const internalStore = useRefWithInit(() => {
7654 return new _TooltipStore(initialState);
7655 }).current;
7656 const store2 = externalStore ?? internalStore;
7657 const floatingRootContext = useSyncedFloatingRootContext({
7658 popupStore: store2,
7659 onOpenChange: store2.setOpen
7660 });
7661 store2.state.floatingRootContext = floatingRootContext;
7662 return store2;
7663 }
7664 };
7665 function createInitialState() {
7666 return {
7667 ...createInitialPopupStoreState(),
7668 disabled: false,
7669 instantType: void 0,
7670 isInstantPhase: false,
7671 trackCursorAxis: "none",
7672 disableHoverablePopup: false,
7673 openChangeReason: null,
7674 closeOnClick: true,
7675 closeDelay: 0,
7676 hasViewport: false
7677 };
7678 }
7679
7680 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
7681 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
7682 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
7683 const {
7684 disabled: disabled2 = false,
7685 defaultOpen = false,
7686 open: openProp,
7687 disableHoverablePopup = false,
7688 trackCursorAxis = "none",
7689 actionsRef,
7690 onOpenChange,
7691 onOpenChangeComplete,
7692 handle,
7693 triggerId: triggerIdProp,
7694 defaultTriggerId: defaultTriggerIdProp = null,
7695 children
7696 } = props;
7697 const store2 = TooltipStore.useStore(handle?.store, {
7698 open: defaultOpen,
7699 openProp,
7700 activeTriggerId: defaultTriggerIdProp,
7701 triggerIdProp
7702 });
7703 useOnFirstRender(() => {
7704 if (openProp === void 0 && store2.state.open === false && defaultOpen === true) {
7705 store2.update({
7706 open: true,
7707 activeTriggerId: defaultTriggerIdProp
7708 });
7709 }
7710 });
7711 store2.useControlledProp("openProp", openProp);
7712 store2.useControlledProp("triggerIdProp", triggerIdProp);
7713 store2.useContextCallback("onOpenChange", onOpenChange);
7714 store2.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
7715 const openState = store2.useState("open");
7716 const open = !disabled2 && openState;
7717 const activeTriggerId = store2.useState("activeTriggerId");
7718 const payload = store2.useState("payload");
7719 store2.useSyncedValues({
7720 trackCursorAxis,
7721 disableHoverablePopup
7722 });
7723 useIsoLayoutEffect(() => {
7724 if (openState && disabled2) {
7725 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
7726 }
7727 }, [openState, disabled2, store2]);
7728 store2.useSyncedValue("disabled", disabled2);
7729 useImplicitActiveTrigger(store2);
7730 const {
7731 forceUnmount,
7732 transitionStatus
7733 } = useOpenStateTransitions(open, store2);
7734 const floatingRootContext = store2.select("floatingRootContext");
7735 const isInstantPhase = store2.useState("isInstantPhase");
7736 const instantType = store2.useState("instantType");
7737 const lastOpenChangeReason = store2.useState("lastOpenChangeReason");
7738 const previousInstantTypeRef = React37.useRef(null);
7739 useIsoLayoutEffect(() => {
7740 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
7741 if (instantType !== "delay") {
7742 previousInstantTypeRef.current = instantType;
7743 }
7744 store2.set("instantType", "delay");
7745 } else if (previousInstantTypeRef.current !== null) {
7746 store2.set("instantType", previousInstantTypeRef.current);
7747 previousInstantTypeRef.current = null;
7748 }
7749 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store2]);
7750 useIsoLayoutEffect(() => {
7751 if (open) {
7752 if (activeTriggerId == null) {
7753 store2.set("payload", void 0);
7754 }
7755 }
7756 }, [store2, activeTriggerId, open]);
7757 const handleImperativeClose = React37.useCallback(() => {
7758 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
7759 }, [store2]);
7760 React37.useImperativeHandle(actionsRef, () => ({
7761 unmount: forceUnmount,
7762 close: handleImperativeClose
7763 }), [forceUnmount, handleImperativeClose]);
7764 const dismiss = useDismiss(floatingRootContext, {
7765 enabled: !disabled2,
7766 referencePress: () => store2.select("closeOnClick")
7767 });
7768 const clientPoint = useClientPoint(floatingRootContext, {
7769 enabled: !disabled2 && trackCursorAxis !== "none",
7770 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
7771 });
7772 const {
7773 getReferenceProps,
7774 getFloatingProps,
7775 getTriggerProps
7776 } = useInteractions([dismiss, clientPoint]);
7777 const activeTriggerProps = React37.useMemo(() => getReferenceProps(), [getReferenceProps]);
7778 const inactiveTriggerProps = React37.useMemo(() => getTriggerProps(), [getTriggerProps]);
7779 const popupProps = React37.useMemo(() => getFloatingProps(), [getFloatingProps]);
7780 store2.useSyncedValues({
7781 activeTriggerProps,
7782 inactiveTriggerProps,
7783 popupProps
7784 });
7785 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipRootContext.Provider, {
7786 value: store2,
7787 children: typeof children === "function" ? children({
7788 payload
7789 }) : children
7790 });
7791 });
7792 if (true) TooltipRoot.displayName = "TooltipRoot";
7793
7794 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
7795 var React39 = __toESM(require_react(), 1);
7796
7797 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
7798 var React38 = __toESM(require_react(), 1);
7799 var TooltipProviderContext = /* @__PURE__ */ React38.createContext(void 0);
7800 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
7801 function useTooltipProviderContext() {
7802 return React38.useContext(TooltipProviderContext);
7803 }
7804
7805 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
7806 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
7807 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
7808 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
7809 return TooltipTriggerDataAttributes2;
7810 })({});
7811
7812 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
7813 var OPEN_DELAY = 600;
7814
7815 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
7816 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
7817 const {
7818 className,
7819 render,
7820 handle,
7821 payload,
7822 disabled: disabledProp,
7823 delay,
7824 closeOnClick = true,
7825 closeDelay,
7826 id: idProp,
7827 style,
7828 ...elementProps
7829 } = componentProps;
7830 const rootContext = useTooltipRootContext(true);
7831 const store2 = handle?.store ?? rootContext;
7832 if (!store2) {
7833 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));
7834 }
7835 const thisTriggerId = useBaseUiId(idProp);
7836 const isTriggerActive = store2.useState("isTriggerActive", thisTriggerId);
7837 const isOpenedByThisTrigger = store2.useState("isOpenedByTrigger", thisTriggerId);
7838 const floatingRootContext = store2.useState("floatingRootContext");
7839 const triggerElementRef = React39.useRef(null);
7840 const delayWithDefault = delay ?? OPEN_DELAY;
7841 const closeDelayWithDefault = closeDelay ?? 0;
7842 const {
7843 registerTrigger,
7844 isMountedByThisTrigger
7845 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store2, {
7846 payload,
7847 closeOnClick,
7848 closeDelay: closeDelayWithDefault
7849 });
7850 const providerContext = useTooltipProviderContext();
7851 const {
7852 delayRef,
7853 isInstantPhase,
7854 hasProvider
7855 } = useDelayGroup(floatingRootContext, {
7856 open: isOpenedByThisTrigger
7857 });
7858 store2.useSyncedValue("isInstantPhase", isInstantPhase);
7859 const rootDisabled = store2.useState("disabled");
7860 const disabled2 = disabledProp ?? rootDisabled;
7861 const trackCursorAxis = store2.useState("trackCursorAxis");
7862 const disableHoverablePopup = store2.useState("disableHoverablePopup");
7863 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
7864 enabled: !disabled2,
7865 mouseOnly: true,
7866 move: false,
7867 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
7868 restMs() {
7869 const providerDelay = providerContext?.delay;
7870 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
7871 let computedRestMs = delayWithDefault;
7872 if (hasProvider) {
7873 if (groupOpenValue !== 0) {
7874 computedRestMs = delay ?? providerDelay ?? delayWithDefault;
7875 } else {
7876 computedRestMs = 0;
7877 }
7878 }
7879 return computedRestMs;
7880 },
7881 delay() {
7882 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
7883 let computedCloseDelay = closeDelayWithDefault;
7884 if (closeDelay == null && hasProvider) {
7885 computedCloseDelay = closeValue;
7886 }
7887 return {
7888 close: computedCloseDelay
7889 };
7890 },
7891 triggerElementRef,
7892 isActiveTrigger: isTriggerActive,
7893 isClosing: () => store2.select("transitionStatus") === "ending"
7894 });
7895 const focusProps = useFocus(floatingRootContext, {
7896 enabled: !disabled2
7897 }).reference;
7898 const state = {
7899 open: isOpenedByThisTrigger
7900 };
7901 const rootTriggerProps = store2.useState("triggerProps", isMountedByThisTrigger);
7902 const element = useRenderElement("button", componentProps, {
7903 state,
7904 ref: [forwardedRef, registerTrigger, triggerElementRef],
7905 props: [hoverProps, focusProps, rootTriggerProps, {
7906 onPointerDown() {
7907 store2.set("closeOnClick", closeOnClick);
7908 },
7909 id: thisTriggerId,
7910 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0
7911 }, elementProps],
7912 stateAttributesMapping: triggerOpenStateMapping
7913 });
7914 return element;
7915 });
7916 if (true) TooltipTrigger.displayName = "TooltipTrigger";
7917
7918 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
7919 var React41 = __toESM(require_react(), 1);
7920
7921 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
7922 var React40 = __toESM(require_react(), 1);
7923 var TooltipPortalContext = /* @__PURE__ */ React40.createContext(void 0);
7924 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
7925 function useTooltipPortalContext() {
7926 const value = React40.useContext(TooltipPortalContext);
7927 if (value === void 0) {
7928 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
7929 }
7930 return value;
7931 }
7932
7933 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
7934 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
7935 var TooltipPortal = /* @__PURE__ */ React41.forwardRef(function TooltipPortal2(props, forwardedRef) {
7936 const {
7937 keepMounted = false,
7938 ...portalProps
7939 } = props;
7940 const store2 = useTooltipRootContext();
7941 const mounted = store2.useState("mounted");
7942 const shouldRender = mounted || keepMounted;
7943 if (!shouldRender) {
7944 return null;
7945 }
7946 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
7947 value: keepMounted,
7948 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
7949 ref: forwardedRef,
7950 ...portalProps
7951 })
7952 });
7953 });
7954 if (true) TooltipPortal.displayName = "TooltipPortal";
7955
7956 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
7957 var React43 = __toESM(require_react(), 1);
7958
7959 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
7960 var React42 = __toESM(require_react(), 1);
7961 var TooltipPositionerContext = /* @__PURE__ */ React42.createContext(void 0);
7962 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
7963 function useTooltipPositionerContext() {
7964 const context = React42.useContext(TooltipPositionerContext);
7965 if (context === void 0) {
7966 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
7967 }
7968 return context;
7969 }
7970
7971 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
7972 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
7973 var TooltipPositioner = /* @__PURE__ */ React43.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
7974 const {
7975 render,
7976 className,
7977 anchor,
7978 positionMethod = "absolute",
7979 side = "top",
7980 align = "center",
7981 sideOffset = 0,
7982 alignOffset = 0,
7983 collisionBoundary = "clipping-ancestors",
7984 collisionPadding = 5,
7985 arrowPadding = 5,
7986 sticky = false,
7987 disableAnchorTracking = false,
7988 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
7989 style,
7990 ...elementProps
7991 } = componentProps;
7992 const store2 = useTooltipRootContext();
7993 const keepMounted = useTooltipPortalContext();
7994 const open = store2.useState("open");
7995 const mounted = store2.useState("mounted");
7996 const trackCursorAxis = store2.useState("trackCursorAxis");
7997 const disableHoverablePopup = store2.useState("disableHoverablePopup");
7998 const floatingRootContext = store2.useState("floatingRootContext");
7999 const instantType = store2.useState("instantType");
8000 const transitionStatus = store2.useState("transitionStatus");
8001 const hasViewport = store2.useState("hasViewport");
8002 const positioning = useAnchorPositioning({
8003 anchor,
8004 positionMethod,
8005 floatingRootContext,
8006 mounted,
8007 side,
8008 sideOffset,
8009 align,
8010 alignOffset,
8011 collisionBoundary,
8012 collisionPadding,
8013 sticky,
8014 arrowPadding,
8015 disableAnchorTracking,
8016 keepMounted,
8017 collisionAvoidance,
8018 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8019 });
8020 const state = React43.useMemo(() => ({
8021 open,
8022 side: positioning.side,
8023 align: positioning.align,
8024 anchorHidden: positioning.anchorHidden,
8025 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8026 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8027 const element = usePositioner(componentProps, state, {
8028 styles: positioning.positionerStyles,
8029 transitionStatus,
8030 props: elementProps,
8031 refs: [forwardedRef, store2.useStateSetter("positionerElement")],
8032 hidden: !mounted,
8033 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8034 });
8035 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8036 value: positioning,
8037 children: element
8038 });
8039 });
8040 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8041
8042 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8043 var React44 = __toESM(require_react(), 1);
8044 var stateAttributesMapping = {
8045 ...popupStateMapping,
8046 ...transitionStatusMapping
8047 };
8048 var TooltipPopup = /* @__PURE__ */ React44.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8049 const {
8050 className,
8051 render,
8052 style,
8053 ...elementProps
8054 } = componentProps;
8055 const store2 = useTooltipRootContext();
8056 const {
8057 side,
8058 align
8059 } = useTooltipPositionerContext();
8060 const open = store2.useState("open");
8061 const instantType = store2.useState("instantType");
8062 const transitionStatus = store2.useState("transitionStatus");
8063 const popupProps = store2.useState("popupProps");
8064 const floatingContext = store2.useState("floatingRootContext");
8065 useOpenChangeComplete({
8066 open,
8067 ref: store2.context.popupRef,
8068 onComplete() {
8069 if (open) {
8070 store2.context.onOpenChangeComplete?.(true);
8071 }
8072 }
8073 });
8074 const disabled2 = store2.useState("disabled");
8075 const closeDelay = store2.useState("closeDelay");
8076 useHoverFloatingInteraction(floatingContext, {
8077 enabled: !disabled2,
8078 closeDelay
8079 });
8080 const state = {
8081 open,
8082 side,
8083 align,
8084 instant: instantType,
8085 transitionStatus
8086 };
8087 const element = useRenderElement("div", componentProps, {
8088 state,
8089 ref: [forwardedRef, store2.context.popupRef, store2.useStateSetter("popupElement")],
8090 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8091 stateAttributesMapping
8092 });
8093 return element;
8094 });
8095 if (true) TooltipPopup.displayName = "TooltipPopup";
8096
8097 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8098 var React45 = __toESM(require_react(), 1);
8099 var TooltipArrow = /* @__PURE__ */ React45.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8100 const {
8101 className,
8102 render,
8103 style,
8104 ...elementProps
8105 } = componentProps;
8106 const store2 = useTooltipRootContext();
8107 const open = store2.useState("open");
8108 const instantType = store2.useState("instantType");
8109 const {
8110 arrowRef,
8111 side,
8112 align,
8113 arrowUncentered,
8114 arrowStyles
8115 } = useTooltipPositionerContext();
8116 const state = {
8117 open,
8118 side,
8119 align,
8120 uncentered: arrowUncentered,
8121 instant: instantType
8122 };
8123 const element = useRenderElement("div", componentProps, {
8124 state,
8125 ref: [forwardedRef, arrowRef],
8126 props: [{
8127 style: arrowStyles,
8128 "aria-hidden": true
8129 }, elementProps],
8130 stateAttributesMapping: popupStateMapping
8131 });
8132 return element;
8133 });
8134 if (true) TooltipArrow.displayName = "TooltipArrow";
8135
8136 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8137 var React46 = __toESM(require_react(), 1);
8138 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
8139 var TooltipProvider = function TooltipProvider2(props) {
8140 const {
8141 delay,
8142 closeDelay,
8143 timeout = 400
8144 } = props;
8145 const contextValue = React46.useMemo(() => ({
8146 delay,
8147 closeDelay
8148 }), [delay, closeDelay]);
8149 const delayValue = React46.useMemo(() => ({
8150 open: delay,
8151 close: closeDelay
8152 }), [delay, closeDelay]);
8153 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
8154 value: contextValue,
8155 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
8156 delay: delayValue,
8157 timeoutMs: timeout,
8158 children: props.children
8159 })
8160 });
8161 };
8162 if (true) TooltipProvider.displayName = "TooltipProvider";
8163
8164 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8165 var React47 = __toESM(require_react(), 1);
8166
8167 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8168 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8169 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8170 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8171 return TooltipViewportCssVars2;
8172 })({});
8173
8174 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8175 var stateAttributesMapping2 = {
8176 activationDirection: (value) => value ? {
8177 "data-activation-direction": value
8178 } : null
8179 };
8180 var TooltipViewport = /* @__PURE__ */ React47.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8181 const {
8182 render,
8183 className,
8184 style,
8185 children,
8186 ...elementProps
8187 } = componentProps;
8188 const store2 = useTooltipRootContext();
8189 const positioner = useTooltipPositionerContext();
8190 const instantType = store2.useState("instantType");
8191 const {
8192 children: childrenToRender,
8193 state: viewportState
8194 } = usePopupViewport({
8195 store: store2,
8196 side: positioner.side,
8197 cssVars: TooltipViewportCssVars,
8198 children
8199 });
8200 const state = {
8201 activationDirection: viewportState.activationDirection,
8202 transitioning: viewportState.transitioning,
8203 instant: instantType
8204 };
8205 return useRenderElement("div", componentProps, {
8206 state,
8207 ref: forwardedRef,
8208 props: [elementProps, {
8209 children: childrenToRender
8210 }],
8211 stateAttributesMapping: stateAttributesMapping2
8212 });
8213 });
8214 if (true) TooltipViewport.displayName = "TooltipViewport";
8215
8216 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8217 var TooltipHandle = class {
8218 /**
8219 * Internal store holding the tooltip state.
8220 * @internal
8221 */
8222 constructor() {
8223 this.store = new TooltipStore();
8224 }
8225 /**
8226 * Opens the tooltip and associates it with the trigger with the given ID.
8227 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8228 *
8229 * This method should only be called in an event handler or an effect (not during rendering).
8230 *
8231 * @param triggerId ID of the trigger to associate with the tooltip.
8232 */
8233 open(triggerId) {
8234 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8235 if (triggerId && !triggerElement) {
8236 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8237 }
8238 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8239 }
8240 /**
8241 * Closes the tooltip.
8242 */
8243 close() {
8244 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8245 }
8246 /**
8247 * Indicates whether the tooltip is currently open.
8248 */
8249 get isOpen() {
8250 return this.store.state.open;
8251 }
8252 };
8253 function createTooltipHandle() {
8254 return new TooltipHandle();
8255 }
8256
8257 // node_modules/@base-ui/react/esm/use-render/useRender.js
8258 function useRender(params) {
8259 return useRenderElement(params.defaultTagName ?? "div", params, params);
8260 }
8261
8262 // packages/icons/build-module/library/arrow-up-left.mjs
8263 var import_primitives = __toESM(require_primitives(), 1);
8264 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
8265 var arrow_up_left_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.Path, { d: "M14 6H6v8h1.5V8.5L17 18l1-1-9.5-9.5H14V6Z" }) });
8266
8267 // packages/icons/build-module/library/arrow-up-right.mjs
8268 var import_primitives2 = __toESM(require_primitives(), 1);
8269 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
8270 var arrow_up_right_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.Path, { d: "M10 6H18V14H16.5V8.5L7 18L6 17L15.5 7.5H10V6Z" }) });
8271
8272 // packages/icons/build-module/library/chevron-down.mjs
8273 var import_primitives3 = __toESM(require_primitives(), 1);
8274 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
8275 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
8276
8277 // packages/icons/build-module/library/chevron-left.mjs
8278 var import_primitives4 = __toESM(require_primitives(), 1);
8279 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
8280 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) });
8281
8282 // packages/icons/build-module/library/chevron-right.mjs
8283 var import_primitives5 = __toESM(require_primitives(), 1);
8284 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
8285 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) });
8286
8287 // packages/icons/build-module/library/chevron-up.mjs
8288 var import_primitives6 = __toESM(require_primitives(), 1);
8289 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
8290 var chevron_up_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.Path, { d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z" }) });
8291
8292 // packages/icons/build-module/library/fullscreen.mjs
8293 var import_primitives7 = __toESM(require_primitives(), 1);
8294 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
8295 var fullscreen_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.Path, { d: "M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z" }) });
8296
8297 // packages/icons/build-module/library/wordpress.mjs
8298 var import_primitives8 = __toESM(require_primitives(), 1);
8299 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
8300 var wordpress_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -2 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.Path, { d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z" }) });
8301
8302 // packages/ui/build-module/utils/render-slot-with-children.mjs
8303 var import_element8 = __toESM(require_element(), 1);
8304 function renderSlotWithChildren(slot, defaultSlot, children) {
8305 return (0, import_element8.cloneElement)(slot ?? defaultSlot, { children });
8306 }
8307
8308 // packages/ui/build-module/lock-unlock.mjs
8309 var import_private_apis = __toESM(require_private_apis(), 1);
8310 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
8311 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
8312 "@wordpress/ui"
8313 );
8314
8315 // packages/ui/build-module/tooltip/index.mjs
8316 var tooltip_exports = {};
8317 __export(tooltip_exports, {
8318 Popup: () => Popup,
8319 Portal: () => Portal,
8320 Positioner: () => Positioner,
8321 Provider: () => Provider,
8322 Root: () => Root,
8323 Trigger: () => Trigger
8324 });
8325
8326 // packages/ui/build-module/tooltip/popup.mjs
8327 var import_element11 = __toESM(require_element(), 1);
8328 var import_theme = __toESM(require_theme(), 1);
8329
8330 // packages/ui/build-module/tooltip/portal.mjs
8331 var import_element9 = __toESM(require_element(), 1);
8332
8333 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
8334 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
8335 function getRuntime() {
8336 const globalScope = globalThis;
8337 if (globalScope.__wpStyleRuntime) {
8338 return globalScope.__wpStyleRuntime;
8339 }
8340 globalScope.__wpStyleRuntime = {
8341 documents: /* @__PURE__ */ new Map(),
8342 styles: /* @__PURE__ */ new Map(),
8343 injectedStyles: /* @__PURE__ */ new WeakMap()
8344 };
8345 if (typeof document !== "undefined") {
8346 registerDocument(document);
8347 }
8348 return globalScope.__wpStyleRuntime;
8349 }
8350 function documentContainsStyleHash(targetDocument, hash) {
8351 if (!targetDocument.head) {
8352 return false;
8353 }
8354 for (const style of targetDocument.head.querySelectorAll(
8355 `style[${STYLE_HASH_ATTRIBUTE}]`
8356 )) {
8357 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
8358 return true;
8359 }
8360 }
8361 return false;
8362 }
8363 function injectStyle(targetDocument, hash, css) {
8364 if (!targetDocument.head) {
8365 return;
8366 }
8367 const runtime = getRuntime();
8368 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8369 if (!injectedStyles) {
8370 injectedStyles = /* @__PURE__ */ new Set();
8371 runtime.injectedStyles.set(targetDocument, injectedStyles);
8372 }
8373 if (injectedStyles.has(hash)) {
8374 return;
8375 }
8376 if (documentContainsStyleHash(targetDocument, hash)) {
8377 injectedStyles.add(hash);
8378 return;
8379 }
8380 const style = targetDocument.createElement("style");
8381 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
8382 style.appendChild(targetDocument.createTextNode(css));
8383 targetDocument.head.appendChild(style);
8384 injectedStyles.add(hash);
8385 }
8386 function registerDocument(targetDocument) {
8387 const runtime = getRuntime();
8388 runtime.documents.set(
8389 targetDocument,
8390 (runtime.documents.get(targetDocument) ?? 0) + 1
8391 );
8392 for (const [hash, css] of runtime.styles) {
8393 injectStyle(targetDocument, hash, css);
8394 }
8395 return () => {
8396 const count = runtime.documents.get(targetDocument);
8397 if (count === void 0) {
8398 return;
8399 }
8400 if (count <= 1) {
8401 runtime.documents.delete(targetDocument);
8402 return;
8403 }
8404 runtime.documents.set(targetDocument, count - 1);
8405 };
8406 }
8407 function registerStyle(hash, css) {
8408 const runtime = getRuntime();
8409 runtime.styles.set(hash, css);
8410 for (const targetDocument of runtime.documents.keys()) {
8411 injectStyle(targetDocument, hash, css);
8412 }
8413 }
8414 if (typeof process === "undefined" || true) {
8415 registerStyle("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}}");
8416 }
8417 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
8418 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
8419 function resolveOwnerDocument() {
8420 return typeof document === "undefined" ? null : document;
8421 }
8422 function isInWordPressEnvironment() {
8423 let topWp;
8424 try {
8425 topWp = window.top?.wp;
8426 } catch {
8427 }
8428 const wp = topWp ?? window.wp;
8429 return typeof wp?.components === "object" && wp.components !== null;
8430 }
8431 var cachedSlot = null;
8432 function createSlot(ownerDocument2) {
8433 const element = ownerDocument2.createElement("div");
8434 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
8435 if (wp_compat_overlay_slot_default.slot) {
8436 element.classList.add(wp_compat_overlay_slot_default.slot);
8437 }
8438 ownerDocument2.body.appendChild(element);
8439 return element;
8440 }
8441 function getWpCompatOverlaySlot() {
8442 if (typeof window === "undefined") {
8443 return void 0;
8444 }
8445 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
8446 return void 0;
8447 }
8448 const ownerDocument2 = resolveOwnerDocument();
8449 if (!ownerDocument2 || !ownerDocument2.body) {
8450 return void 0;
8451 }
8452 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
8453 return cachedSlot;
8454 }
8455 const existing = ownerDocument2.querySelector(
8456 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
8457 );
8458 if (existing instanceof HTMLDivElement) {
8459 cachedSlot = existing;
8460 return existing;
8461 }
8462 if (cachedSlot?.isConnected) {
8463 cachedSlot.remove();
8464 }
8465 cachedSlot = createSlot(ownerDocument2);
8466 return cachedSlot;
8467 }
8468
8469 // packages/ui/build-module/tooltip/portal.mjs
8470 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
8471 var Portal = (0, import_element9.forwardRef)(
8472 function TooltipPortal3({ container, ...restProps }, ref) {
8473 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
8474 index_parts_exports.Portal,
8475 {
8476 container: container ?? getWpCompatOverlaySlot(),
8477 ...restProps,
8478 ref
8479 }
8480 );
8481 }
8482 );
8483
8484 // packages/ui/build-module/tooltip/positioner.mjs
8485 var import_element10 = __toESM(require_element(), 1);
8486 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
8487 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
8488 function getRuntime2() {
8489 const globalScope = globalThis;
8490 if (globalScope.__wpStyleRuntime) {
8491 return globalScope.__wpStyleRuntime;
8492 }
8493 globalScope.__wpStyleRuntime = {
8494 documents: /* @__PURE__ */ new Map(),
8495 styles: /* @__PURE__ */ new Map(),
8496 injectedStyles: /* @__PURE__ */ new WeakMap()
8497 };
8498 if (typeof document !== "undefined") {
8499 registerDocument2(document);
8500 }
8501 return globalScope.__wpStyleRuntime;
8502 }
8503 function documentContainsStyleHash2(targetDocument, hash) {
8504 if (!targetDocument.head) {
8505 return false;
8506 }
8507 for (const style of targetDocument.head.querySelectorAll(
8508 `style[${STYLE_HASH_ATTRIBUTE2}]`
8509 )) {
8510 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
8511 return true;
8512 }
8513 }
8514 return false;
8515 }
8516 function injectStyle2(targetDocument, hash, css) {
8517 if (!targetDocument.head) {
8518 return;
8519 }
8520 const runtime = getRuntime2();
8521 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8522 if (!injectedStyles) {
8523 injectedStyles = /* @__PURE__ */ new Set();
8524 runtime.injectedStyles.set(targetDocument, injectedStyles);
8525 }
8526 if (injectedStyles.has(hash)) {
8527 return;
8528 }
8529 if (documentContainsStyleHash2(targetDocument, hash)) {
8530 injectedStyles.add(hash);
8531 return;
8532 }
8533 const style = targetDocument.createElement("style");
8534 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
8535 style.appendChild(targetDocument.createTextNode(css));
8536 targetDocument.head.appendChild(style);
8537 injectedStyles.add(hash);
8538 }
8539 function registerDocument2(targetDocument) {
8540 const runtime = getRuntime2();
8541 runtime.documents.set(
8542 targetDocument,
8543 (runtime.documents.get(targetDocument) ?? 0) + 1
8544 );
8545 for (const [hash, css] of runtime.styles) {
8546 injectStyle2(targetDocument, hash, css);
8547 }
8548 return () => {
8549 const count = runtime.documents.get(targetDocument);
8550 if (count === void 0) {
8551 return;
8552 }
8553 if (count <= 1) {
8554 runtime.documents.delete(targetDocument);
8555 return;
8556 }
8557 runtime.documents.set(targetDocument, count - 1);
8558 };
8559 }
8560 function registerStyle2(hash, css) {
8561 const runtime = getRuntime2();
8562 runtime.styles.set(hash, css);
8563 for (const targetDocument of runtime.documents.keys()) {
8564 injectStyle2(targetDocument, hash, css);
8565 }
8566 }
8567 if (typeof process === "undefined" || true) {
8568 registerStyle2("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}}}");
8569 }
8570 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
8571 if (typeof process === "undefined" || true) {
8572 registerStyle2("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}}}');
8573 }
8574 var style_default = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
8575 var Positioner = (0, import_element10.forwardRef)(
8576 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
8577 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
8578 index_parts_exports.Positioner,
8579 {
8580 ref,
8581 align,
8582 side,
8583 sideOffset,
8584 ...props,
8585 className: clsx_default(
8586 resets_default["box-sizing"],
8587 style_default.positioner,
8588 className
8589 )
8590 }
8591 );
8592 }
8593 );
8594
8595 // packages/ui/build-module/tooltip/popup.mjs
8596 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
8597 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
8598 function getRuntime3() {
8599 const globalScope = globalThis;
8600 if (globalScope.__wpStyleRuntime) {
8601 return globalScope.__wpStyleRuntime;
8602 }
8603 globalScope.__wpStyleRuntime = {
8604 documents: /* @__PURE__ */ new Map(),
8605 styles: /* @__PURE__ */ new Map(),
8606 injectedStyles: /* @__PURE__ */ new WeakMap()
8607 };
8608 if (typeof document !== "undefined") {
8609 registerDocument3(document);
8610 }
8611 return globalScope.__wpStyleRuntime;
8612 }
8613 function documentContainsStyleHash3(targetDocument, hash) {
8614 if (!targetDocument.head) {
8615 return false;
8616 }
8617 for (const style of targetDocument.head.querySelectorAll(
8618 `style[${STYLE_HASH_ATTRIBUTE3}]`
8619 )) {
8620 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
8621 return true;
8622 }
8623 }
8624 return false;
8625 }
8626 function injectStyle3(targetDocument, hash, css) {
8627 if (!targetDocument.head) {
8628 return;
8629 }
8630 const runtime = getRuntime3();
8631 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8632 if (!injectedStyles) {
8633 injectedStyles = /* @__PURE__ */ new Set();
8634 runtime.injectedStyles.set(targetDocument, injectedStyles);
8635 }
8636 if (injectedStyles.has(hash)) {
8637 return;
8638 }
8639 if (documentContainsStyleHash3(targetDocument, hash)) {
8640 injectedStyles.add(hash);
8641 return;
8642 }
8643 const style = targetDocument.createElement("style");
8644 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
8645 style.appendChild(targetDocument.createTextNode(css));
8646 targetDocument.head.appendChild(style);
8647 injectedStyles.add(hash);
8648 }
8649 function registerDocument3(targetDocument) {
8650 const runtime = getRuntime3();
8651 runtime.documents.set(
8652 targetDocument,
8653 (runtime.documents.get(targetDocument) ?? 0) + 1
8654 );
8655 for (const [hash, css] of runtime.styles) {
8656 injectStyle3(targetDocument, hash, css);
8657 }
8658 return () => {
8659 const count = runtime.documents.get(targetDocument);
8660 if (count === void 0) {
8661 return;
8662 }
8663 if (count <= 1) {
8664 runtime.documents.delete(targetDocument);
8665 return;
8666 }
8667 runtime.documents.set(targetDocument, count - 1);
8668 };
8669 }
8670 function registerStyle3(hash, css) {
8671 const runtime = getRuntime3();
8672 runtime.styles.set(hash, css);
8673 for (const targetDocument of runtime.documents.keys()) {
8674 injectStyle3(targetDocument, hash, css);
8675 }
8676 }
8677 if (typeof process === "undefined" || true) {
8678 registerStyle3("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}}}');
8679 }
8680 var style_default2 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
8681 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider;
8682 var Popup = (0, import_element11.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
8683 const popupContent = (
8684 /* This should ideally use whatever dark color makes sense,
8685 * and not be hardcoded to #1e1e1e. The solutions would be to:
8686 * - review the design of the tooltip, in case we want to stop
8687 * hardcoding it to a dark background
8688 * - create new semantic tokens as needed (aliasing either the
8689 * "inverted bg" or "perma-dark bg" private tokens) and have
8690 * Tooltip.Popup use them;
8691 * - remove the hardcoded `bg` setting from the `ThemeProvider`
8692 * below
8693 */
8694 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ThemeProvider, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
8695 index_parts_exports.Popup,
8696 {
8697 ref,
8698 className: clsx_default(style_default2.popup, className),
8699 ...props,
8700 children
8701 }
8702 ) })
8703 );
8704 const positionedPopup = renderSlotWithChildren(
8705 positioner,
8706 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Positioner, {}),
8707 popupContent
8708 );
8709 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Portal, {}), positionedPopup);
8710 });
8711
8712 // packages/ui/build-module/tooltip/trigger.mjs
8713 var import_element12 = __toESM(require_element(), 1);
8714 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
8715 var Trigger = (0, import_element12.forwardRef)(
8716 function TooltipTrigger3(props, ref) {
8717 return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(index_parts_exports.Trigger, { ref, ...props });
8718 }
8719 );
8720
8721 // packages/ui/build-module/tooltip/root.mjs
8722 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
8723 function Root(props) {
8724 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(index_parts_exports.Root, { ...props });
8725 }
8726
8727 // packages/ui/build-module/tooltip/provider.mjs
8728 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
8729 function Provider({ ...props }) {
8730 return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(index_parts_exports.Provider, { ...props });
8731 }
8732
8733 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
8734 var import_element13 = __toESM(require_element(), 1);
8735 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
8736 function getRuntime4() {
8737 const globalScope = globalThis;
8738 if (globalScope.__wpStyleRuntime) {
8739 return globalScope.__wpStyleRuntime;
8740 }
8741 globalScope.__wpStyleRuntime = {
8742 documents: /* @__PURE__ */ new Map(),
8743 styles: /* @__PURE__ */ new Map(),
8744 injectedStyles: /* @__PURE__ */ new WeakMap()
8745 };
8746 if (typeof document !== "undefined") {
8747 registerDocument4(document);
8748 }
8749 return globalScope.__wpStyleRuntime;
8750 }
8751 function documentContainsStyleHash4(targetDocument, hash) {
8752 if (!targetDocument.head) {
8753 return false;
8754 }
8755 for (const style of targetDocument.head.querySelectorAll(
8756 `style[${STYLE_HASH_ATTRIBUTE4}]`
8757 )) {
8758 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
8759 return true;
8760 }
8761 }
8762 return false;
8763 }
8764 function injectStyle4(targetDocument, hash, css) {
8765 if (!targetDocument.head) {
8766 return;
8767 }
8768 const runtime = getRuntime4();
8769 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8770 if (!injectedStyles) {
8771 injectedStyles = /* @__PURE__ */ new Set();
8772 runtime.injectedStyles.set(targetDocument, injectedStyles);
8773 }
8774 if (injectedStyles.has(hash)) {
8775 return;
8776 }
8777 if (documentContainsStyleHash4(targetDocument, hash)) {
8778 injectedStyles.add(hash);
8779 return;
8780 }
8781 const style = targetDocument.createElement("style");
8782 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
8783 style.appendChild(targetDocument.createTextNode(css));
8784 targetDocument.head.appendChild(style);
8785 injectedStyles.add(hash);
8786 }
8787 function registerDocument4(targetDocument) {
8788 const runtime = getRuntime4();
8789 runtime.documents.set(
8790 targetDocument,
8791 (runtime.documents.get(targetDocument) ?? 0) + 1
8792 );
8793 for (const [hash, css] of runtime.styles) {
8794 injectStyle4(targetDocument, hash, css);
8795 }
8796 return () => {
8797 const count = runtime.documents.get(targetDocument);
8798 if (count === void 0) {
8799 return;
8800 }
8801 if (count <= 1) {
8802 runtime.documents.delete(targetDocument);
8803 return;
8804 }
8805 runtime.documents.set(targetDocument, count - 1);
8806 };
8807 }
8808 function registerStyle4(hash, css) {
8809 const runtime = getRuntime4();
8810 runtime.styles.set(hash, css);
8811 for (const targetDocument of runtime.documents.keys()) {
8812 injectStyle4(targetDocument, hash, css);
8813 }
8814 }
8815 if (typeof process === "undefined" || true) {
8816 registerStyle4("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}}");
8817 }
8818 var style_default3 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
8819 var VisuallyHidden = (0, import_element13.forwardRef)(
8820 function VisuallyHidden2({ render, ...restProps }, ref) {
8821 const element = useRender({
8822 render,
8823 ref,
8824 props: mergeProps(
8825 { className: style_default3["visually-hidden"] },
8826 restProps,
8827 {
8828 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
8829 "data-visually-hidden": ""
8830 }
8831 )
8832 });
8833 return element;
8834 }
8835 );
8836
8837 // packages/admin-ui/build-module/navigable-region/index.mjs
8838 var import_element14 = __toESM(require_element(), 1);
8839 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
8840 var NavigableRegion = (0, import_element14.forwardRef)(
8841 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
8842 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
8843 Tag,
8844 {
8845 ref,
8846 className: clsx_default("admin-ui-navigable-region", className),
8847 "aria-label": ariaLabel,
8848 role: "region",
8849 tabIndex: "-1",
8850 ...props,
8851 children
8852 }
8853 );
8854 }
8855 );
8856 NavigableRegion.displayName = "NavigableRegion";
8857 var navigable_region_default = NavigableRegion;
8858
8859 // packages/edit-post/build-module/components/layout/index.mjs
8860 var import_editor18 = __toESM(require_editor(), 1);
8861 var import_data25 = __toESM(require_data(), 1);
8862 var import_block_editor2 = __toESM(require_block_editor(), 1);
8863
8864 // packages/global-styles-engine/build-module/utils/common.mjs
8865 var import_style_engine = __toESM(require_style_engine(), 1);
8866 var ROOT_BLOCK_SELECTOR = "body";
8867 var ROOT_CSS_PROPERTIES_SELECTOR = ":root";
8868
8869 // packages/global-styles-engine/build-module/core/render.mjs
8870 var import_blocks = __toESM(require_blocks(), 1);
8871 var import_style_engine2 = __toESM(require_style_engine(), 1);
8872 var import_data = __toESM(require_data(), 1);
8873
8874 // packages/global-styles-engine/build-module/utils/spacing.mjs
8875 function getSpacingPresetCssVar(value) {
8876 if (!value) {
8877 return;
8878 }
8879 const slug = value.match(/var:preset\|spacing\|(.+)/);
8880 if (!slug) {
8881 return value;
8882 }
8883 return `var(--wp--preset--spacing--${slug[1]})`;
8884 }
8885
8886 // packages/global-styles-engine/build-module/utils/gap.mjs
8887 function getGapBoxControlValueFromStyle(blockGapValue) {
8888 if (!blockGapValue) {
8889 return null;
8890 }
8891 const isValueString = typeof blockGapValue === "string";
8892 return {
8893 top: isValueString ? blockGapValue : blockGapValue?.top,
8894 left: isValueString ? blockGapValue : blockGapValue?.left
8895 };
8896 }
8897 function getGapCSSValue(blockGapValue, defaultValue = "0") {
8898 const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue);
8899 if (!blockGapBoxControlValue) {
8900 return null;
8901 }
8902 const row = getSpacingPresetCssVar(blockGapBoxControlValue?.top) || defaultValue;
8903 const column = getSpacingPresetCssVar(blockGapBoxControlValue?.left) || defaultValue;
8904 return row === column ? row : `${row} ${column}`;
8905 }
8906
8907 // packages/global-styles-engine/build-module/utils/layout.mjs
8908 var LAYOUT_DEFINITIONS = {
8909 default: {
8910 name: "default",
8911 slug: "flow",
8912 className: "is-layout-flow",
8913 baseStyles: [
8914 {
8915 selector: " > .alignleft",
8916 rules: {
8917 float: "left",
8918 "margin-inline-start": "0",
8919 "margin-inline-end": "2em"
8920 }
8921 },
8922 {
8923 selector: " > .alignright",
8924 rules: {
8925 float: "right",
8926 "margin-inline-start": "2em",
8927 "margin-inline-end": "0"
8928 }
8929 },
8930 {
8931 selector: " > .aligncenter",
8932 rules: {
8933 "margin-left": "auto !important",
8934 "margin-right": "auto !important"
8935 }
8936 }
8937 ],
8938 spacingStyles: [
8939 {
8940 selector: " > :first-child",
8941 rules: {
8942 "margin-block-start": "0"
8943 }
8944 },
8945 {
8946 selector: " > :last-child",
8947 rules: {
8948 "margin-block-end": "0"
8949 }
8950 },
8951 {
8952 selector: " > *",
8953 rules: {
8954 "margin-block-start": null,
8955 "margin-block-end": "0"
8956 }
8957 }
8958 ]
8959 },
8960 constrained: {
8961 name: "constrained",
8962 slug: "constrained",
8963 className: "is-layout-constrained",
8964 baseStyles: [
8965 {
8966 selector: " > .alignleft",
8967 rules: {
8968 float: "left",
8969 "margin-inline-start": "0",
8970 "margin-inline-end": "2em"
8971 }
8972 },
8973 {
8974 selector: " > .alignright",
8975 rules: {
8976 float: "right",
8977 "margin-inline-start": "2em",
8978 "margin-inline-end": "0"
8979 }
8980 },
8981 {
8982 selector: " > .aligncenter",
8983 rules: {
8984 "margin-left": "auto !important",
8985 "margin-right": "auto !important"
8986 }
8987 },
8988 {
8989 selector: " > :where(:not(.alignleft):not(.alignright):not(.alignfull))",
8990 rules: {
8991 "max-width": "var(--wp--style--global--content-size)",
8992 "margin-left": "auto !important",
8993 "margin-right": "auto !important"
8994 }
8995 },
8996 {
8997 selector: " > .alignwide",
8998 rules: {
8999 "max-width": "var(--wp--style--global--wide-size)"
9000 }
9001 }
9002 ],
9003 spacingStyles: [
9004 {
9005 selector: " > :first-child",
9006 rules: {
9007 "margin-block-start": "0"
9008 }
9009 },
9010 {
9011 selector: " > :last-child",
9012 rules: {
9013 "margin-block-end": "0"
9014 }
9015 },
9016 {
9017 selector: " > *",
9018 rules: {
9019 "margin-block-start": null,
9020 "margin-block-end": "0"
9021 }
9022 }
9023 ]
9024 },
9025 flex: {
9026 name: "flex",
9027 slug: "flex",
9028 className: "is-layout-flex",
9029 displayMode: "flex",
9030 baseStyles: [
9031 {
9032 selector: "",
9033 rules: {
9034 "flex-wrap": "wrap",
9035 "align-items": "center"
9036 }
9037 },
9038 {
9039 selector: " > :is(*, div)",
9040 // :is(*, div) instead of just * increases the specificity by 001.
9041 rules: {
9042 margin: "0"
9043 }
9044 }
9045 ],
9046 spacingStyles: [
9047 {
9048 selector: "",
9049 rules: {
9050 gap: null
9051 }
9052 }
9053 ]
9054 },
9055 grid: {
9056 name: "grid",
9057 slug: "grid",
9058 className: "is-layout-grid",
9059 displayMode: "grid",
9060 baseStyles: [
9061 {
9062 selector: " > :is(*, div)",
9063 // :is(*, div) instead of just * increases the specificity by 001.
9064 rules: {
9065 margin: "0"
9066 }
9067 }
9068 ],
9069 spacingStyles: [
9070 {
9071 selector: "",
9072 rules: {
9073 gap: null
9074 }
9075 }
9076 ]
9077 }
9078 };
9079
9080 // packages/global-styles-engine/build-module/core/render.mjs
9081 function getLayoutStyles({
9082 layoutDefinitions = LAYOUT_DEFINITIONS,
9083 style,
9084 selector,
9085 hasBlockGapSupport,
9086 hasFallbackGapSupport,
9087 fallbackGapValue
9088 }) {
9089 let ruleset = "";
9090 let gapValue = hasBlockGapSupport ? getGapCSSValue(style?.spacing?.blockGap) : "";
9091 if (hasFallbackGapSupport) {
9092 if (selector === ROOT_BLOCK_SELECTOR) {
9093 gapValue = !gapValue ? "0.5em" : gapValue;
9094 } else if (!hasBlockGapSupport && fallbackGapValue) {
9095 gapValue = fallbackGapValue;
9096 }
9097 }
9098 if (gapValue && layoutDefinitions) {
9099 Object.values(layoutDefinitions).forEach(
9100 ({ className, name, spacingStyles }) => {
9101 if (!hasBlockGapSupport && "flex" !== name && "grid" !== name) {
9102 return;
9103 }
9104 if (spacingStyles?.length) {
9105 spacingStyles.forEach((spacingStyle) => {
9106 const declarations = [];
9107 if (spacingStyle.rules) {
9108 Object.entries(spacingStyle.rules).forEach(
9109 ([cssProperty, cssValue]) => {
9110 declarations.push(
9111 `${cssProperty}: ${cssValue ? cssValue : gapValue}`
9112 );
9113 }
9114 );
9115 }
9116 if (declarations.length) {
9117 let combinedSelector = "";
9118 if (!hasBlockGapSupport) {
9119 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:where(.${className}${spacingStyle?.selector || ""})` : `:where(${selector}.${className}${spacingStyle?.selector || ""})`;
9120 } else {
9121 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:root :where(.${className})${spacingStyle?.selector || ""}` : `:root :where(${selector}-${className})${spacingStyle?.selector || ""}`;
9122 }
9123 ruleset += `${combinedSelector} { ${declarations.join(
9124 "; "
9125 )}; }`;
9126 }
9127 });
9128 }
9129 }
9130 );
9131 if (selector === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) {
9132 ruleset += `${ROOT_CSS_PROPERTIES_SELECTOR} { --wp--style--block-gap: ${gapValue}; }`;
9133 }
9134 }
9135 if (selector === ROOT_BLOCK_SELECTOR && layoutDefinitions) {
9136 const validDisplayModes = ["block", "flex", "grid"];
9137 Object.values(layoutDefinitions).forEach(
9138 ({ className, displayMode, baseStyles }) => {
9139 if (displayMode && validDisplayModes.includes(displayMode)) {
9140 ruleset += `${selector} .${className} { display:${displayMode}; }`;
9141 }
9142 if (baseStyles?.length) {
9143 baseStyles.forEach((baseStyle) => {
9144 const declarations = [];
9145 if (baseStyle.rules) {
9146 Object.entries(baseStyle.rules).forEach(
9147 ([cssProperty, cssValue]) => {
9148 declarations.push(
9149 `${cssProperty}: ${cssValue}`
9150 );
9151 }
9152 );
9153 }
9154 if (declarations.length) {
9155 const combinedSelector = `.${className}${baseStyle?.selector || ""}`;
9156 ruleset += `${combinedSelector} { ${declarations.join(
9157 "; "
9158 )}; }`;
9159 }
9160 });
9161 }
9162 }
9163 );
9164 }
9165 return ruleset;
9166 }
9167
9168 // packages/edit-post/build-module/components/layout/index.mjs
9169 var import_plugins = __toESM(require_plugins(), 1);
9170 var import_i18n14 = __toESM(require_i18n(), 1);
9171 var import_element25 = __toESM(require_element(), 1);
9172 var import_notices3 = __toESM(require_notices(), 1);
9173 var import_preferences10 = __toESM(require_preferences(), 1);
9174 var import_commands2 = __toESM(require_commands(), 1);
9175 var import_block_library = __toESM(require_block_library(), 1);
9176 var import_url5 = __toESM(require_url(), 1);
9177 var import_html_entities = __toESM(require_html_entities(), 1);
9178 var import_core_data8 = __toESM(require_core_data(), 1);
9179 var import_components9 = __toESM(require_components(), 1);
9180 var import_compose3 = __toESM(require_compose(), 1);
9181
9182 // packages/edit-post/build-module/components/back-button/index.mjs
9183 var import_editor2 = __toESM(require_editor(), 1);
9184 var import_components2 = __toESM(require_components(), 1);
9185
9186 // packages/edit-post/build-module/components/back-button/fullscreen-mode-close.mjs
9187 var import_data2 = __toESM(require_data(), 1);
9188 var import_components = __toESM(require_components(), 1);
9189 var import_i18n = __toESM(require_i18n(), 1);
9190 var import_url = __toESM(require_url(), 1);
9191 var import_editor = __toESM(require_editor(), 1);
9192 var import_core_data = __toESM(require_core_data(), 1);
9193 var import_compose = __toESM(require_compose(), 1);
9194 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9195 var siteIconVariants = {
9196 edit: {
9197 clipPath: "inset(0% round 0px)"
9198 },
9199 hover: {
9200 clipPath: "inset( 22% round 2px )"
9201 },
9202 tap: {
9203 clipPath: "inset(0% round 0px)"
9204 }
9205 };
9206 var toggleHomeIconVariants = {
9207 edit: {
9208 opacity: 0,
9209 scale: 0.2
9210 },
9211 hover: {
9212 opacity: 1,
9213 scale: 1,
9214 clipPath: "inset( 22% round 2px )"
9215 }
9216 };
9217 function FullscreenModeClose({ showTooltip, icon, href, initialPost }) {
9218 const { isRequestingSiteIcon, postType, siteIconUrl } = (0, import_data2.useSelect)(
9219 (select3) => {
9220 const { getCurrentPostType } = select3(import_editor.store);
9221 const { getEntityRecord, getPostType, isResolving } = select3(import_core_data.store);
9222 const siteData = getEntityRecord("root", "__unstableBase", void 0) || {};
9223 const _postType = initialPost?.type || getCurrentPostType();
9224 return {
9225 isRequestingSiteIcon: isResolving("getEntityRecord", [
9226 "root",
9227 "__unstableBase",
9228 void 0
9229 ]),
9230 postType: getPostType(_postType),
9231 siteIconUrl: siteData.site_icon_url
9232 };
9233 },
9234 [initialPost?.type]
9235 );
9236 const disableMotion = (0, import_compose.useReducedMotion)();
9237 const transition = {
9238 duration: disableMotion ? 0 : 0.2
9239 };
9240 if (!postType) {
9241 return null;
9242 }
9243 let siteIconContent;
9244 if (isRequestingSiteIcon && !siteIconUrl) {
9245 siteIconContent = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "edit-post-fullscreen-mode-close-site-icon__image" });
9246 } else if (siteIconUrl) {
9247 siteIconContent = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9248 "img",
9249 {
9250 className: "edit-post-fullscreen-mode-close-site-icon__image",
9251 alt: (0, import_i18n.__)("Site Icon"),
9252 src: siteIconUrl
9253 }
9254 );
9255 } else {
9256 siteIconContent = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9257 import_components.Icon,
9258 {
9259 className: "edit-post-fullscreen-mode-close-site-icon__icon",
9260 icon: wordpress_default,
9261 size: 48
9262 }
9263 );
9264 }
9265 const buttonIcon = icon ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_components.Icon, { size: "36px", icon }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "edit-post-fullscreen-mode-close-site-icon", children: siteIconContent });
9266 const classes = clsx_default("edit-post-fullscreen-mode-close", {
9267 "has-icon": siteIconUrl
9268 });
9269 const buttonHref = href ?? (0, import_url.addQueryArgs)("edit.php", {
9270 post_type: postType.slug
9271 });
9272 const buttonLabel = postType?.labels?.view_items ?? (0, import_i18n.__)("Back");
9273 const hasAdminBarInEditor = window.__experimentalAdminBarInEditor;
9274 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
9275 import_components.__unstableMotion.div,
9276 {
9277 className: "edit-post-fullscreen-mode-close__view-mode-toggle",
9278 animate: "edit",
9279 initial: "edit",
9280 whileHover: "hover",
9281 whileTap: "tap",
9282 transition,
9283 children: [
9284 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9285 import_components.Button,
9286 {
9287 __next40pxDefaultSize: true,
9288 className: classes,
9289 href: buttonHref,
9290 label: buttonLabel,
9291 showTooltip,
9292 tooltipPosition: "bottom",
9293 children: !hasAdminBarInEditor && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9294 import_components.__unstableMotion.div,
9295 {
9296 variants: !disableMotion && siteIconVariants,
9297 children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "edit-post-fullscreen-mode-close__view-mode-toggle-icon", children: buttonIcon })
9298 }
9299 )
9300 }
9301 ),
9302 hasAdminBarInEditor ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "edit-post-fullscreen-mode-close__back-icon", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_components.Icon, { icon: (0, import_i18n.isRTL)() ? chevron_right_default : chevron_left_default }) }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
9303 import_components.__unstableMotion.div,
9304 {
9305 className: clsx_default(
9306 "edit-post-fullscreen-mode-close__back-icon",
9307 {
9308 "has-site-icon": siteIconUrl
9309 }
9310 ),
9311 variants: !disableMotion && toggleHomeIconVariants,
9312 children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_components.Icon, { icon: (0, import_i18n.isRTL)() ? arrow_up_right_default : arrow_up_left_default })
9313 }
9314 )
9315 ]
9316 }
9317 );
9318 }
9319 var fullscreen_mode_close_default = FullscreenModeClose;
9320
9321 // packages/edit-post/build-module/lock-unlock.mjs
9322 var import_private_apis2 = __toESM(require_private_apis(), 1);
9323 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9324 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9325 "@wordpress/edit-post"
9326 );
9327
9328 // packages/edit-post/build-module/components/back-button/index.mjs
9329 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9330 var { BackButton: BackButtonFill } = unlock2(import_editor2.privateApis);
9331 var slideX = {
9332 hidden: { x: "-100%" },
9333 distractionFreeInactive: { x: 0 },
9334 hover: { x: 0, transition: { type: "tween", delay: 0.2 } }
9335 };
9336 function BackButton({ initialPost }) {
9337 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(BackButtonFill, { children: ({ length }) => length <= 1 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
9338 import_components2.__unstableMotion.div,
9339 {
9340 variants: slideX,
9341 transition: { type: "tween", delay: 0.8 },
9342 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
9343 fullscreen_mode_close_default,
9344 {
9345 showTooltip: true,
9346 initialPost
9347 }
9348 )
9349 }
9350 ) });
9351 }
9352 var back_button_default = BackButton;
9353
9354 // packages/edit-post/build-module/components/editor-initialization/listener-hooks.mjs
9355 var import_data3 = __toESM(require_data(), 1);
9356 var import_element15 = __toESM(require_element(), 1);
9357 var import_editor3 = __toESM(require_editor(), 1);
9358 var import_core_data2 = __toESM(require_core_data(), 1);
9359
9360 // packages/edit-post/build-module/store/constants.mjs
9361 var STORE_NAME = "core/edit-post";
9362 var VIEW_AS_LINK_SELECTOR = "#wp-admin-bar-view a";
9363 var VIEW_AS_PREVIEW_LINK_SELECTOR = "#wp-admin-bar-preview a";
9364
9365 // packages/edit-post/build-module/components/editor-initialization/listener-hooks.mjs
9366 var useUpdatePostLinkListener = () => {
9367 const { isViewable, newPermalink } = (0, import_data3.useSelect)((select3) => {
9368 const { getPostType } = select3(import_core_data2.store);
9369 const { getCurrentPost, getEditedPostAttribute } = select3(import_editor3.store);
9370 const postType = getPostType(getEditedPostAttribute("type"));
9371 return {
9372 isViewable: postType?.viewable,
9373 newPermalink: getCurrentPost().link
9374 };
9375 }, []);
9376 const nodeToUpdateRef = (0, import_element15.useRef)();
9377 (0, import_element15.useEffect)(() => {
9378 nodeToUpdateRef.current = document.querySelector(VIEW_AS_PREVIEW_LINK_SELECTOR) || document.querySelector(VIEW_AS_LINK_SELECTOR);
9379 }, []);
9380 (0, import_element15.useEffect)(() => {
9381 if (!newPermalink || !nodeToUpdateRef.current) {
9382 return;
9383 }
9384 if (!isViewable) {
9385 nodeToUpdateRef.current.style.display = "none";
9386 return;
9387 }
9388 nodeToUpdateRef.current.style.display = "";
9389 nodeToUpdateRef.current.setAttribute("href", newPermalink);
9390 }, [newPermalink, isViewable]);
9391 };
9392
9393 // packages/edit-post/build-module/components/editor-initialization/index.mjs
9394 function EditorInitialization() {
9395 useUpdatePostLinkListener();
9396 return null;
9397 }
9398
9399 // packages/edit-post/build-module/components/keyboard-shortcuts/index.mjs
9400 var import_element16 = __toESM(require_element(), 1);
9401 var import_data7 = __toESM(require_data(), 1);
9402 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1);
9403 var import_i18n3 = __toESM(require_i18n(), 1);
9404
9405 // packages/edit-post/build-module/store/index.mjs
9406 var import_data6 = __toESM(require_data(), 1);
9407
9408 // packages/edit-post/build-module/store/reducer.mjs
9409 var import_data4 = __toESM(require_data(), 1);
9410 function isSavingMetaBoxes(state = false, action) {
9411 switch (action.type) {
9412 case "REQUEST_META_BOX_UPDATES":
9413 return true;
9414 case "META_BOX_UPDATES_SUCCESS":
9415 case "META_BOX_UPDATES_FAILURE":
9416 return false;
9417 default:
9418 return state;
9419 }
9420 }
9421 function mergeMetaboxes(metaboxes = [], newMetaboxes) {
9422 const mergedMetaboxes = [...metaboxes];
9423 for (const metabox of newMetaboxes) {
9424 const existing = mergedMetaboxes.findIndex(
9425 (box) => box.id === metabox.id
9426 );
9427 if (existing !== -1) {
9428 mergedMetaboxes[existing] = {
9429 ...mergedMetaboxes[existing],
9430 ...metabox
9431 };
9432 } else {
9433 mergedMetaboxes.push(metabox);
9434 }
9435 }
9436 return mergedMetaboxes;
9437 }
9438 function metaBoxLocations(state = {}, action) {
9439 switch (action.type) {
9440 case "SET_META_BOXES_PER_LOCATIONS": {
9441 const newState = { ...state };
9442 for (const [location, metaboxes] of Object.entries(
9443 action.metaBoxesPerLocation
9444 )) {
9445 newState[location] = mergeMetaboxes(
9446 newState[location],
9447 metaboxes
9448 );
9449 }
9450 return newState;
9451 }
9452 }
9453 return state;
9454 }
9455 function metaBoxesInitialized(state = false, action) {
9456 switch (action.type) {
9457 case "META_BOXES_INITIALIZED":
9458 return true;
9459 }
9460 return state;
9461 }
9462 var metaBoxes = (0, import_data4.combineReducers)({
9463 isSaving: isSavingMetaBoxes,
9464 locations: metaBoxLocations,
9465 initialized: metaBoxesInitialized
9466 });
9467 var reducer_default = (0, import_data4.combineReducers)({
9468 metaBoxes
9469 });
9470
9471 // packages/edit-post/build-module/store/actions.mjs
9472 var actions_exports = {};
9473 __export(actions_exports, {
9474 __experimentalSetPreviewDeviceType: () => __experimentalSetPreviewDeviceType,
9475 __unstableCreateTemplate: () => __unstableCreateTemplate,
9476 closeGeneralSidebar: () => closeGeneralSidebar,
9477 closeModal: () => closeModal,
9478 closePublishSidebar: () => closePublishSidebar,
9479 hideBlockTypes: () => hideBlockTypes,
9480 initializeMetaBoxes: () => initializeMetaBoxes,
9481 metaBoxUpdatesFailure: () => metaBoxUpdatesFailure,
9482 metaBoxUpdatesSuccess: () => metaBoxUpdatesSuccess,
9483 openGeneralSidebar: () => openGeneralSidebar,
9484 openModal: () => openModal,
9485 openPublishSidebar: () => openPublishSidebar,
9486 removeEditorPanel: () => removeEditorPanel,
9487 requestMetaBoxUpdates: () => requestMetaBoxUpdates,
9488 setAvailableMetaBoxesPerLocation: () => setAvailableMetaBoxesPerLocation,
9489 setIsEditingTemplate: () => setIsEditingTemplate,
9490 setIsInserterOpened: () => setIsInserterOpened,
9491 setIsListViewOpened: () => setIsListViewOpened,
9492 showBlockTypes: () => showBlockTypes,
9493 switchEditorMode: () => switchEditorMode,
9494 toggleDistractionFree: () => toggleDistractionFree,
9495 toggleEditorPanelEnabled: () => toggleEditorPanelEnabled,
9496 toggleEditorPanelOpened: () => toggleEditorPanelOpened,
9497 toggleFeature: () => toggleFeature,
9498 toggleFullscreenMode: () => toggleFullscreenMode,
9499 togglePinnedPluginItem: () => togglePinnedPluginItem,
9500 togglePublishSidebar: () => togglePublishSidebar,
9501 updatePreferredStyleVariations: () => updatePreferredStyleVariations
9502 });
9503 var import_api_fetch = __toESM(require_api_fetch(), 1);
9504 var import_preferences = __toESM(require_preferences(), 1);
9505 var import_editor4 = __toESM(require_editor(), 1);
9506 var import_deprecated = __toESM(require_deprecated(), 1);
9507 var import_hooks = __toESM(require_hooks(), 1);
9508 var import_core_data3 = __toESM(require_core_data(), 1);
9509 var import_notices = __toESM(require_notices(), 1);
9510 var import_i18n2 = __toESM(require_i18n(), 1);
9511
9512 // packages/edit-post/build-module/utils/meta-boxes.mjs
9513 var getMetaBoxContainer = (location) => {
9514 const area = document.querySelector(
9515 `.edit-post-meta-boxes-area.is-${location} .metabox-location-${location}`
9516 );
9517 if (area) {
9518 return area;
9519 }
9520 return document.querySelector("#metaboxes .metabox-location-" + location);
9521 };
9522
9523 // packages/edit-post/build-module/store/actions.mjs
9524 var { interfaceStore } = unlock2(import_editor4.privateApis);
9525 var openGeneralSidebar = (name) => ({ registry }) => {
9526 registry.dispatch(interfaceStore).enableComplementaryArea("core", name);
9527 };
9528 var closeGeneralSidebar = () => ({ registry }) => registry.dispatch(interfaceStore).disableComplementaryArea("core");
9529 var openModal = (name) => ({ registry }) => {
9530 (0, import_deprecated.default)("select( 'core/edit-post' ).openModal( name )", {
9531 since: "6.3",
9532 alternative: "select( 'core/interface').openModal( name )"
9533 });
9534 return registry.dispatch(interfaceStore).openModal(name);
9535 };
9536 var closeModal = () => ({ registry }) => {
9537 (0, import_deprecated.default)("select( 'core/edit-post' ).closeModal()", {
9538 since: "6.3",
9539 alternative: "select( 'core/interface').closeModal()"
9540 });
9541 return registry.dispatch(interfaceStore).closeModal();
9542 };
9543 var openPublishSidebar = () => ({ registry }) => {
9544 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).openPublishSidebar", {
9545 since: "6.6",
9546 alternative: "dispatch( 'core/editor').openPublishSidebar"
9547 });
9548 registry.dispatch(import_editor4.store).openPublishSidebar();
9549 };
9550 var closePublishSidebar = () => ({ registry }) => {
9551 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).closePublishSidebar", {
9552 since: "6.6",
9553 alternative: "dispatch( 'core/editor').closePublishSidebar"
9554 });
9555 registry.dispatch(import_editor4.store).closePublishSidebar();
9556 };
9557 var togglePublishSidebar = () => ({ registry }) => {
9558 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).togglePublishSidebar", {
9559 since: "6.6",
9560 alternative: "dispatch( 'core/editor').togglePublishSidebar"
9561 });
9562 registry.dispatch(import_editor4.store).togglePublishSidebar();
9563 };
9564 var toggleEditorPanelEnabled = (panelName) => ({ registry }) => {
9565 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).toggleEditorPanelEnabled", {
9566 since: "6.5",
9567 alternative: "dispatch( 'core/editor').toggleEditorPanelEnabled"
9568 });
9569 registry.dispatch(import_editor4.store).toggleEditorPanelEnabled(panelName);
9570 };
9571 var toggleEditorPanelOpened = (panelName) => ({ registry }) => {
9572 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).toggleEditorPanelOpened", {
9573 since: "6.5",
9574 alternative: "dispatch( 'core/editor').toggleEditorPanelOpened"
9575 });
9576 registry.dispatch(import_editor4.store).toggleEditorPanelOpened(panelName);
9577 };
9578 var removeEditorPanel = (panelName) => ({ registry }) => {
9579 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).removeEditorPanel", {
9580 since: "6.5",
9581 alternative: "dispatch( 'core/editor').removeEditorPanel"
9582 });
9583 registry.dispatch(import_editor4.store).removeEditorPanel(panelName);
9584 };
9585 var toggleFeature = (feature) => ({ registry }) => registry.dispatch(import_preferences.store).toggle("core/edit-post", feature);
9586 var switchEditorMode = (mode) => ({ registry }) => {
9587 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).switchEditorMode", {
9588 since: "6.6",
9589 alternative: "dispatch( 'core/editor').switchEditorMode"
9590 });
9591 registry.dispatch(import_editor4.store).switchEditorMode(mode);
9592 };
9593 var togglePinnedPluginItem = (pluginName) => ({ registry }) => {
9594 const isPinned = registry.select(interfaceStore).isItemPinned("core", pluginName);
9595 registry.dispatch(interfaceStore)[isPinned ? "unpinItem" : "pinItem"]("core", pluginName);
9596 };
9597 function updatePreferredStyleVariations() {
9598 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).updatePreferredStyleVariations", {
9599 since: "6.6",
9600 hint: "Preferred Style Variations are not supported anymore."
9601 });
9602 return { type: "NOTHING" };
9603 }
9604 var showBlockTypes = (blockNames) => ({ registry }) => {
9605 unlock2(registry.dispatch(import_editor4.store)).showBlockTypes(blockNames);
9606 };
9607 var hideBlockTypes = (blockNames) => ({ registry }) => {
9608 unlock2(registry.dispatch(import_editor4.store)).hideBlockTypes(blockNames);
9609 };
9610 function setAvailableMetaBoxesPerLocation(metaBoxesPerLocation) {
9611 return {
9612 type: "SET_META_BOXES_PER_LOCATIONS",
9613 metaBoxesPerLocation
9614 };
9615 }
9616 var requestMetaBoxUpdates = () => async ({ registry, select: select3, dispatch: dispatch2 }) => {
9617 dispatch2({
9618 type: "REQUEST_META_BOX_UPDATES"
9619 });
9620 if (window.tinyMCE) {
9621 window.tinyMCE.triggerSave();
9622 }
9623 const baseFormData = new window.FormData(
9624 document.querySelector(".metabox-base-form")
9625 );
9626 const postId = baseFormData.get("post_ID");
9627 const postType = baseFormData.get("post_type");
9628 const post = registry.select(import_core_data3.store).getEditedEntityRecord("postType", postType, postId);
9629 const additionalData = [
9630 post.comment_status ? ["comment_status", post.comment_status] : false,
9631 post.ping_status ? ["ping_status", post.ping_status] : false,
9632 post.sticky ? ["sticky", post.sticky] : false,
9633 post.author ? ["post_author", post.author] : false
9634 ].filter(Boolean);
9635 const activeMetaBoxLocations = select3.getActiveMetaBoxLocations();
9636 const formDataToMerge = [
9637 baseFormData,
9638 ...activeMetaBoxLocations.map(
9639 (location) => new window.FormData(getMetaBoxContainer(location))
9640 )
9641 ];
9642 const formData = formDataToMerge.reduce((memo, currentFormData) => {
9643 for (const [key, value] of currentFormData) {
9644 memo.append(key, value);
9645 }
9646 return memo;
9647 }, new window.FormData());
9648 additionalData.forEach(
9649 ([key, value]) => formData.append(key, value)
9650 );
9651 try {
9652 await (0, import_api_fetch.default)({
9653 url: window._wpMetaBoxUrl,
9654 method: "POST",
9655 body: formData,
9656 parse: false
9657 });
9658 dispatch2.metaBoxUpdatesSuccess();
9659 } catch {
9660 dispatch2.metaBoxUpdatesFailure();
9661 }
9662 };
9663 function metaBoxUpdatesSuccess() {
9664 return {
9665 type: "META_BOX_UPDATES_SUCCESS"
9666 };
9667 }
9668 function metaBoxUpdatesFailure() {
9669 return {
9670 type: "META_BOX_UPDATES_FAILURE"
9671 };
9672 }
9673 var __experimentalSetPreviewDeviceType = (deviceType) => ({ registry }) => {
9674 (0, import_deprecated.default)(
9675 "dispatch( 'core/edit-post' ).__experimentalSetPreviewDeviceType",
9676 {
9677 since: "6.5",
9678 version: "6.7",
9679 hint: "registry.dispatch( editorStore ).setDeviceType"
9680 }
9681 );
9682 registry.dispatch(import_editor4.store).setDeviceType(deviceType);
9683 };
9684 var setIsInserterOpened = (value) => ({ registry }) => {
9685 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).setIsInserterOpened", {
9686 since: "6.5",
9687 alternative: "dispatch( 'core/editor').setIsInserterOpened"
9688 });
9689 registry.dispatch(import_editor4.store).setIsInserterOpened(value);
9690 };
9691 var setIsListViewOpened = (isOpen) => ({ registry }) => {
9692 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).setIsListViewOpened", {
9693 since: "6.5",
9694 alternative: "dispatch( 'core/editor').setIsListViewOpened"
9695 });
9696 registry.dispatch(import_editor4.store).setIsListViewOpened(isOpen);
9697 };
9698 function setIsEditingTemplate() {
9699 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).setIsEditingTemplate", {
9700 since: "6.5",
9701 alternative: "dispatch( 'core/editor').setRenderingMode"
9702 });
9703 return { type: "NOTHING" };
9704 }
9705 function __unstableCreateTemplate() {
9706 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).__unstableCreateTemplate", {
9707 since: "6.5"
9708 });
9709 return { type: "NOTHING" };
9710 }
9711 var metaBoxesInitialized2 = false;
9712 var initializeMetaBoxes = () => ({ registry, select: select3, dispatch: dispatch2 }) => {
9713 const isEditorReady = registry.select(import_editor4.store).__unstableIsEditorReady();
9714 if (!isEditorReady) {
9715 return;
9716 }
9717 if (metaBoxesInitialized2) {
9718 return;
9719 }
9720 const postType = registry.select(import_editor4.store).getCurrentPostType();
9721 if (window.postboxes.page !== postType) {
9722 window.postboxes.add_postbox_toggles(postType);
9723 }
9724 metaBoxesInitialized2 = true;
9725 (0, import_hooks.addAction)(
9726 "editor.savePost",
9727 "core/edit-post/save-metaboxes",
9728 async (post, options) => {
9729 if (!options.isAutosave && select3.hasMetaBoxes()) {
9730 await dispatch2.requestMetaBoxUpdates();
9731 }
9732 }
9733 );
9734 dispatch2({
9735 type: "META_BOXES_INITIALIZED"
9736 });
9737 };
9738 var toggleDistractionFree = () => ({ registry }) => {
9739 (0, import_deprecated.default)("dispatch( 'core/edit-post' ).toggleDistractionFree", {
9740 since: "6.6",
9741 alternative: "dispatch( 'core/editor').toggleDistractionFree"
9742 });
9743 registry.dispatch(import_editor4.store).toggleDistractionFree();
9744 };
9745 var toggleFullscreenMode = () => ({ registry }) => {
9746 const isFullscreen = registry.select(import_preferences.store).get("core/edit-post", "fullscreenMode");
9747 registry.dispatch(import_preferences.store).toggle("core/edit-post", "fullscreenMode");
9748 registry.dispatch(import_notices.store).createInfoNotice(
9749 isFullscreen ? (0, import_i18n2.__)("Fullscreen mode deactivated.") : (0, import_i18n2.__)("Fullscreen mode activated."),
9750 {
9751 id: "core/edit-post/toggle-fullscreen-mode/notice",
9752 type: "snackbar",
9753 actions: [
9754 {
9755 label: (0, import_i18n2.__)("Undo"),
9756 onClick: () => {
9757 registry.dispatch(import_preferences.store).toggle(
9758 "core/edit-post",
9759 "fullscreenMode"
9760 );
9761 }
9762 }
9763 ]
9764 }
9765 );
9766 };
9767
9768 // packages/edit-post/build-module/store/selectors.mjs
9769 var selectors_exports = {};
9770 __export(selectors_exports, {
9771 __experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint,
9772 __experimentalGetPreviewDeviceType: () => __experimentalGetPreviewDeviceType,
9773 areMetaBoxesInitialized: () => areMetaBoxesInitialized,
9774 getActiveGeneralSidebarName: () => getActiveGeneralSidebarName,
9775 getActiveMetaBoxLocations: () => getActiveMetaBoxLocations,
9776 getAllMetaBoxes: () => getAllMetaBoxes,
9777 getEditedPostTemplate: () => getEditedPostTemplate,
9778 getEditorMode: () => getEditorMode,
9779 getHiddenBlockTypes: () => getHiddenBlockTypes,
9780 getMetaBoxesPerLocation: () => getMetaBoxesPerLocation,
9781 getPreference: () => getPreference,
9782 getPreferences: () => getPreferences,
9783 hasMetaBoxes: () => hasMetaBoxes,
9784 isEditingTemplate: () => isEditingTemplate,
9785 isEditorPanelEnabled: () => isEditorPanelEnabled,
9786 isEditorPanelOpened: () => isEditorPanelOpened,
9787 isEditorPanelRemoved: () => isEditorPanelRemoved,
9788 isEditorSidebarOpened: () => isEditorSidebarOpened,
9789 isFeatureActive: () => isFeatureActive,
9790 isInserterOpened: () => isInserterOpened,
9791 isListViewOpened: () => isListViewOpened,
9792 isMetaBoxLocationActive: () => isMetaBoxLocationActive,
9793 isMetaBoxLocationVisible: () => isMetaBoxLocationVisible,
9794 isModalActive: () => isModalActive,
9795 isPluginItemPinned: () => isPluginItemPinned,
9796 isPluginSidebarOpened: () => isPluginSidebarOpened,
9797 isPublishSidebarOpened: () => isPublishSidebarOpened,
9798 isSavingMetaBoxes: () => isSavingMetaBoxes2
9799 });
9800 var import_data5 = __toESM(require_data(), 1);
9801 var import_preferences2 = __toESM(require_preferences(), 1);
9802 var import_core_data4 = __toESM(require_core_data(), 1);
9803 var import_editor5 = __toESM(require_editor(), 1);
9804 var import_deprecated2 = __toESM(require_deprecated(), 1);
9805 var { interfaceStore: interfaceStore2 } = unlock2(import_editor5.privateApis);
9806 var EMPTY_ARRAY2 = [];
9807 var EMPTY_OBJECT2 = {};
9808 var getEditorMode = (0, import_data5.createRegistrySelector)(
9809 (select3) => () => select3(import_preferences2.store).get("core", "editorMode") ?? "visual"
9810 );
9811 var isEditorSidebarOpened = (0, import_data5.createRegistrySelector)(
9812 (select3) => () => {
9813 const activeGeneralSidebar = select3(interfaceStore2).getActiveComplementaryArea("core");
9814 return ["edit-post/document", "edit-post/block"].includes(
9815 activeGeneralSidebar
9816 );
9817 }
9818 );
9819 var isPluginSidebarOpened = (0, import_data5.createRegistrySelector)(
9820 (select3) => () => {
9821 const activeGeneralSidebar = select3(interfaceStore2).getActiveComplementaryArea("core");
9822 return !!activeGeneralSidebar && !["edit-post/document", "edit-post/block"].includes(
9823 activeGeneralSidebar
9824 );
9825 }
9826 );
9827 var getActiveGeneralSidebarName = (0, import_data5.createRegistrySelector)(
9828 (select3) => () => {
9829 return select3(interfaceStore2).getActiveComplementaryArea("core");
9830 }
9831 );
9832 function convertPanelsToOldFormat(inactivePanels, openPanels) {
9833 const panelsWithEnabledState = inactivePanels?.reduce(
9834 (accumulatedPanels, panelName) => ({
9835 ...accumulatedPanels,
9836 [panelName]: {
9837 enabled: false
9838 }
9839 }),
9840 {}
9841 );
9842 const panels = openPanels?.reduce((accumulatedPanels, panelName) => {
9843 const currentPanelState = accumulatedPanels?.[panelName];
9844 return {
9845 ...accumulatedPanels,
9846 [panelName]: {
9847 ...currentPanelState,
9848 opened: true
9849 }
9850 };
9851 }, panelsWithEnabledState ?? {});
9852 return panels ?? panelsWithEnabledState ?? EMPTY_OBJECT2;
9853 }
9854 var getPreferences = (0, import_data5.createRegistrySelector)((select3) => () => {
9855 (0, import_deprecated2.default)(`select( 'core/edit-post' ).getPreferences`, {
9856 since: "6.0",
9857 alternative: `select( 'core/preferences' ).get`
9858 });
9859 const corePreferences = ["editorMode", "hiddenBlockTypes"].reduce(
9860 (accumulatedPrefs, preferenceKey) => {
9861 const value = select3(import_preferences2.store).get(
9862 "core",
9863 preferenceKey
9864 );
9865 return {
9866 ...accumulatedPrefs,
9867 [preferenceKey]: value
9868 };
9869 },
9870 {}
9871 );
9872 const inactivePanels = select3(import_preferences2.store).get(
9873 "core",
9874 "inactivePanels"
9875 );
9876 const openPanels = select3(import_preferences2.store).get("core", "openPanels");
9877 const panels = convertPanelsToOldFormat(inactivePanels, openPanels);
9878 return {
9879 ...corePreferences,
9880 panels
9881 };
9882 });
9883 function getPreference(state, preferenceKey, defaultValue) {
9884 (0, import_deprecated2.default)(`select( 'core/edit-post' ).getPreference`, {
9885 since: "6.0",
9886 alternative: `select( 'core/preferences' ).get`
9887 });
9888 const preferences = getPreferences(state);
9889 const value = preferences[preferenceKey];
9890 return value === void 0 ? defaultValue : value;
9891 }
9892 var getHiddenBlockTypes = (0, import_data5.createRegistrySelector)((select3) => () => {
9893 return select3(import_preferences2.store).get("core", "hiddenBlockTypes") ?? EMPTY_ARRAY2;
9894 });
9895 var isPublishSidebarOpened = (0, import_data5.createRegistrySelector)(
9896 (select3) => () => {
9897 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isPublishSidebarOpened`, {
9898 since: "6.6",
9899 alternative: `select( 'core/editor' ).isPublishSidebarOpened`
9900 });
9901 return select3(import_editor5.store).isPublishSidebarOpened();
9902 }
9903 );
9904 var isEditorPanelRemoved = (0, import_data5.createRegistrySelector)(
9905 (select3) => (state, panelName) => {
9906 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isEditorPanelRemoved`, {
9907 since: "6.5",
9908 alternative: `select( 'core/editor' ).isEditorPanelRemoved`
9909 });
9910 return select3(import_editor5.store).isEditorPanelRemoved(panelName);
9911 }
9912 );
9913 var isEditorPanelEnabled = (0, import_data5.createRegistrySelector)(
9914 (select3) => (state, panelName) => {
9915 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isEditorPanelEnabled`, {
9916 since: "6.5",
9917 alternative: `select( 'core/editor' ).isEditorPanelEnabled`
9918 });
9919 return select3(import_editor5.store).isEditorPanelEnabled(panelName);
9920 }
9921 );
9922 var isEditorPanelOpened = (0, import_data5.createRegistrySelector)(
9923 (select3) => (state, panelName) => {
9924 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isEditorPanelOpened`, {
9925 since: "6.5",
9926 alternative: `select( 'core/editor' ).isEditorPanelOpened`
9927 });
9928 return select3(import_editor5.store).isEditorPanelOpened(panelName);
9929 }
9930 );
9931 var isModalActive = (0, import_data5.createRegistrySelector)(
9932 (select3) => (state, modalName) => {
9933 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isModalActive`, {
9934 since: "6.3",
9935 alternative: `select( 'core/interface' ).isModalActive`
9936 });
9937 return !!select3(interfaceStore2).isModalActive(modalName);
9938 }
9939 );
9940 var isFeatureActive = (0, import_data5.createRegistrySelector)(
9941 (select3) => (state, feature) => {
9942 return !!select3(import_preferences2.store).get("core/edit-post", feature);
9943 }
9944 );
9945 var isPluginItemPinned = (0, import_data5.createRegistrySelector)(
9946 (select3) => (state, pluginName) => {
9947 return select3(interfaceStore2).isItemPinned("core", pluginName);
9948 }
9949 );
9950 var getActiveMetaBoxLocations = (0, import_data5.createSelector)(
9951 (state) => {
9952 return Object.keys(state.metaBoxes.locations).filter(
9953 (location) => isMetaBoxLocationActive(state, location)
9954 );
9955 },
9956 (state) => [state.metaBoxes.locations]
9957 );
9958 var isMetaBoxLocationVisible = (0, import_data5.createRegistrySelector)(
9959 (select3) => (state, location) => {
9960 return isMetaBoxLocationActive(state, location) && getMetaBoxesPerLocation(state, location)?.some(({ id }) => {
9961 return select3(import_editor5.store).isEditorPanelEnabled(
9962 `meta-box-${id}`
9963 );
9964 });
9965 }
9966 );
9967 function isMetaBoxLocationActive(state, location) {
9968 const metaBoxes2 = getMetaBoxesPerLocation(state, location);
9969 return !!metaBoxes2 && metaBoxes2.length !== 0;
9970 }
9971 function getMetaBoxesPerLocation(state, location) {
9972 return state.metaBoxes.locations[location];
9973 }
9974 var getAllMetaBoxes = (0, import_data5.createSelector)(
9975 (state) => {
9976 return Object.values(state.metaBoxes.locations).flat();
9977 },
9978 (state) => [state.metaBoxes.locations]
9979 );
9980 function hasMetaBoxes(state) {
9981 return getActiveMetaBoxLocations(state).length > 0;
9982 }
9983 function isSavingMetaBoxes2(state) {
9984 return state.metaBoxes.isSaving;
9985 }
9986 var __experimentalGetPreviewDeviceType = (0, import_data5.createRegistrySelector)(
9987 (select3) => () => {
9988 (0, import_deprecated2.default)(
9989 `select( 'core/edit-site' ).__experimentalGetPreviewDeviceType`,
9990 {
9991 since: "6.5",
9992 version: "6.7",
9993 alternative: `select( 'core/editor' ).getDeviceType`
9994 }
9995 );
9996 return select3(import_editor5.store).getDeviceType();
9997 }
9998 );
9999 var isInserterOpened = (0, import_data5.createRegistrySelector)((select3) => () => {
10000 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isInserterOpened`, {
10001 since: "6.5",
10002 alternative: `select( 'core/editor' ).isInserterOpened`
10003 });
10004 return select3(import_editor5.store).isInserterOpened();
10005 });
10006 var __experimentalGetInsertionPoint = (0, import_data5.createRegistrySelector)(
10007 (select3) => () => {
10008 (0, import_deprecated2.default)(
10009 `select( 'core/edit-post' ).__experimentalGetInsertionPoint`,
10010 {
10011 since: "6.5",
10012 version: "6.7"
10013 }
10014 );
10015 return unlock2(select3(import_editor5.store)).getInserter();
10016 }
10017 );
10018 var isListViewOpened = (0, import_data5.createRegistrySelector)((select3) => () => {
10019 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isListViewOpened`, {
10020 since: "6.5",
10021 alternative: `select( 'core/editor' ).isListViewOpened`
10022 });
10023 return select3(import_editor5.store).isListViewOpened();
10024 });
10025 var isEditingTemplate = (0, import_data5.createRegistrySelector)((select3) => () => {
10026 (0, import_deprecated2.default)(`select( 'core/edit-post' ).isEditingTemplate`, {
10027 since: "6.5",
10028 alternative: `select( 'core/editor' ).getRenderingMode`
10029 });
10030 return select3(import_editor5.store).getCurrentPostType() === "wp_template";
10031 });
10032 function areMetaBoxesInitialized(state) {
10033 return state.metaBoxes.initialized;
10034 }
10035 var getEditedPostTemplate = (0, import_data5.createRegistrySelector)(
10036 (select3) => () => {
10037 const { id: postId, type: postType } = select3(import_editor5.store).getCurrentPost();
10038 const templateId = unlock2(select3(import_core_data4.store)).getTemplateId(
10039 postType,
10040 postId
10041 );
10042 if (!templateId) {
10043 return void 0;
10044 }
10045 return select3(import_core_data4.store).getEditedEntityRecord(
10046 "postType",
10047 "wp_template",
10048 templateId
10049 );
10050 }
10051 );
10052
10053 // packages/edit-post/build-module/store/index.mjs
10054 var store = (0, import_data6.createReduxStore)(STORE_NAME, {
10055 reducer: reducer_default,
10056 actions: actions_exports,
10057 selectors: selectors_exports
10058 });
10059 (0, import_data6.register)(store);
10060
10061 // packages/edit-post/build-module/components/keyboard-shortcuts/index.mjs
10062 function KeyboardShortcuts() {
10063 const { toggleFullscreenMode: toggleFullscreenMode2 } = (0, import_data7.useDispatch)(store);
10064 const { registerShortcut } = (0, import_data7.useDispatch)(import_keyboard_shortcuts.store);
10065 (0, import_element16.useEffect)(() => {
10066 registerShortcut({
10067 name: "core/edit-post/toggle-fullscreen",
10068 category: "global",
10069 description: (0, import_i18n3.__)("Enable or disable fullscreen mode."),
10070 keyCombination: {
10071 modifier: "secondary",
10072 character: "f"
10073 }
10074 });
10075 }, []);
10076 (0, import_keyboard_shortcuts.useShortcut)("core/edit-post/toggle-fullscreen", () => {
10077 toggleFullscreenMode2();
10078 });
10079 return null;
10080 }
10081 var keyboard_shortcuts_default = KeyboardShortcuts;
10082
10083 // packages/edit-post/build-module/components/init-pattern-modal/index.mjs
10084 var import_data8 = __toESM(require_data(), 1);
10085 var import_i18n4 = __toESM(require_i18n(), 1);
10086 var import_components3 = __toESM(require_components(), 1);
10087 var import_element17 = __toESM(require_element(), 1);
10088 var import_editor6 = __toESM(require_editor(), 1);
10089 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
10090 function InitPatternModal() {
10091 const { editPost } = (0, import_data8.useDispatch)(import_editor6.store);
10092 const [syncType, setSyncType] = (0, import_element17.useState)(void 0);
10093 const [title, setTitle] = (0, import_element17.useState)("");
10094 const isNewPost = (0, import_data8.useSelect)(
10095 (select3) => select3(import_editor6.store).isCleanNewPost(),
10096 []
10097 );
10098 const [isModalOpen, setIsModalOpen] = (0, import_element17.useState)(() => isNewPost);
10099 if (!isNewPost) {
10100 return null;
10101 }
10102 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_jsx_runtime28.Fragment, { children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10103 import_components3.Modal,
10104 {
10105 title: (0, import_i18n4.__)("Create pattern"),
10106 onRequestClose: () => {
10107 setIsModalOpen(false);
10108 },
10109 overlayClassName: "reusable-blocks-menu-items__convert-modal",
10110 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10111 "form",
10112 {
10113 onSubmit: (event) => {
10114 event.preventDefault();
10115 setIsModalOpen(false);
10116 editPost({
10117 title,
10118 meta: {
10119 wp_pattern_sync_status: syncType
10120 }
10121 });
10122 },
10123 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_components3.__experimentalVStack, { spacing: "5", children: [
10124 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10125 import_components3.TextControl,
10126 {
10127 label: (0, import_i18n4.__)("Name"),
10128 value: title,
10129 onChange: setTitle,
10130 placeholder: (0, import_i18n4.__)("My pattern"),
10131 className: "patterns-create-modal__name-input",
10132 __next40pxDefaultSize: true
10133 }
10134 ),
10135 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10136 import_components3.ToggleControl,
10137 {
10138 label: (0, import_i18n4._x)("Synced", "pattern (singular)"),
10139 help: (0, import_i18n4.__)(
10140 "Sync this pattern across multiple locations."
10141 ),
10142 checked: !syncType,
10143 onChange: () => {
10144 setSyncType(
10145 !syncType ? "unsynced" : void 0
10146 );
10147 }
10148 }
10149 ),
10150 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_components3.__experimentalHStack, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10151 import_components3.Button,
10152 {
10153 __next40pxDefaultSize: true,
10154 variant: "primary",
10155 type: "submit",
10156 disabled: !title,
10157 accessibleWhenDisabled: true,
10158 children: (0, import_i18n4.__)("Create")
10159 }
10160 ) })
10161 ] })
10162 }
10163 )
10164 }
10165 ) });
10166 }
10167
10168 // packages/edit-post/build-module/components/browser-url/index.mjs
10169 var import_element18 = __toESM(require_element(), 1);
10170 var import_data9 = __toESM(require_data(), 1);
10171 var import_url2 = __toESM(require_url(), 1);
10172 var import_editor7 = __toESM(require_editor(), 1);
10173 function getPostEditURL(postId) {
10174 return (0, import_url2.addQueryArgs)("post.php", { post: postId, action: "edit" });
10175 }
10176 function BrowserURL() {
10177 const [historyId, setHistoryId] = (0, import_element18.useState)(null);
10178 const { postId, postStatus } = (0, import_data9.useSelect)((select3) => {
10179 const { getCurrentPost } = select3(import_editor7.store);
10180 const post = getCurrentPost();
10181 let { id, status, type } = post;
10182 const isTemplate = ["wp_template", "wp_template_part"].includes(
10183 type
10184 );
10185 if (isTemplate) {
10186 id = post.wp_id;
10187 }
10188 return {
10189 postId: id,
10190 postStatus: status
10191 };
10192 }, []);
10193 (0, import_element18.useEffect)(() => {
10194 if (postId && postId !== historyId && postStatus !== "auto-draft") {
10195 window.history.replaceState(
10196 { id: postId },
10197 "Post " + postId,
10198 getPostEditURL(postId)
10199 );
10200 setHistoryId(postId);
10201 }
10202 }, [postId, postStatus, historyId]);
10203 return null;
10204 }
10205
10206 // packages/edit-post/build-module/components/meta-boxes/index.mjs
10207 var import_data12 = __toESM(require_data(), 1);
10208
10209 // packages/edit-post/build-module/components/meta-boxes/meta-boxes-area/index.mjs
10210 var import_element19 = __toESM(require_element(), 1);
10211 var import_components4 = __toESM(require_components(), 1);
10212 var import_data10 = __toESM(require_data(), 1);
10213 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
10214 function MetaBoxesArea({ location }) {
10215 const container = (0, import_element19.useRef)(null);
10216 const formRef = (0, import_element19.useRef)(null);
10217 (0, import_element19.useEffect)(() => {
10218 formRef.current = document.querySelector(
10219 ".metabox-location-" + location
10220 );
10221 if (formRef.current) {
10222 container.current.appendChild(formRef.current);
10223 }
10224 return () => {
10225 if (formRef.current) {
10226 document.querySelector("#metaboxes").appendChild(formRef.current);
10227 }
10228 };
10229 }, [location]);
10230 const isSaving = (0, import_data10.useSelect)((select3) => {
10231 return select3(store).isSavingMetaBoxes();
10232 }, []);
10233 const classes = clsx_default("edit-post-meta-boxes-area", `is-${location}`, {
10234 "is-loading": isSaving
10235 });
10236 return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: classes, children: [
10237 isSaving && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_components4.Spinner, { className: "edit-post-meta-boxes-area__spinner" }),
10238 /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
10239 "div",
10240 {
10241 className: "edit-post-meta-boxes-area__container",
10242 ref: container
10243 }
10244 ),
10245 /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "edit-post-meta-boxes-area__clear" })
10246 ] });
10247 }
10248 var meta_boxes_area_default = MetaBoxesArea;
10249
10250 // packages/edit-post/build-module/components/meta-boxes/meta-box-visibility.mjs
10251 var import_element20 = __toESM(require_element(), 1);
10252 var import_data11 = __toESM(require_data(), 1);
10253 var import_editor8 = __toESM(require_editor(), 1);
10254 function MetaBoxVisibility({ id }) {
10255 const isVisible = (0, import_data11.useSelect)(
10256 (select3) => {
10257 return select3(import_editor8.store).isEditorPanelEnabled(
10258 `meta-box-${id}`
10259 );
10260 },
10261 [id]
10262 );
10263 (0, import_element20.useEffect)(() => {
10264 const element = document.getElementById(id);
10265 if (!element) {
10266 return;
10267 }
10268 if (isVisible) {
10269 element.classList.remove("is-hidden");
10270 } else {
10271 element.classList.add("is-hidden");
10272 }
10273 }, [id, isVisible]);
10274 return null;
10275 }
10276
10277 // packages/edit-post/build-module/components/meta-boxes/index.mjs
10278 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
10279 function MetaBoxes({ location }) {
10280 const metaBoxes2 = (0, import_data12.useSelect)(
10281 (select3) => select3(store).getMetaBoxesPerLocation(location),
10282 [location]
10283 );
10284 return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
10285 (metaBoxes2 ?? []).map(({ id }) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(MetaBoxVisibility, { id }, id)),
10286 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(meta_boxes_area_default, { location })
10287 ] });
10288 }
10289
10290 // packages/edit-post/build-module/components/more-menu/index.mjs
10291 var import_i18n10 = __toESM(require_i18n(), 1);
10292 var import_compose2 = __toESM(require_compose(), 1);
10293 var import_editor14 = __toESM(require_editor(), 1);
10294 var import_keycodes = __toESM(require_keycodes(), 1);
10295 var import_preferences8 = __toESM(require_preferences(), 1);
10296
10297 // packages/edit-post/build-module/components/more-menu/manage-patterns-menu-item.mjs
10298 var import_components5 = __toESM(require_components(), 1);
10299 var import_core_data5 = __toESM(require_core_data(), 1);
10300 var import_data13 = __toESM(require_data(), 1);
10301 var import_i18n5 = __toESM(require_i18n(), 1);
10302 var import_url3 = __toESM(require_url(), 1);
10303 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
10304 function ManagePatternsMenuItem() {
10305 const url = (0, import_data13.useSelect)((select3) => {
10306 const { canUser } = select3(import_core_data5.store);
10307 const defaultUrl = (0, import_url3.addQueryArgs)("edit.php", {
10308 post_type: "wp_block"
10309 });
10310 const patternsUrl = (0, import_url3.addQueryArgs)("site-editor.php", {
10311 p: "/pattern"
10312 });
10313 return canUser("create", {
10314 kind: "postType",
10315 name: "wp_template"
10316 }) ? patternsUrl : defaultUrl;
10317 }, []);
10318 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components5.MenuItem, { role: "menuitem", href: url, children: (0, import_i18n5.__)("Manage patterns") });
10319 }
10320 var manage_patterns_menu_item_default = ManagePatternsMenuItem;
10321
10322 // packages/edit-post/build-module/components/more-menu/welcome-guide-menu-item.mjs
10323 var import_data14 = __toESM(require_data(), 1);
10324 var import_preferences3 = __toESM(require_preferences(), 1);
10325 var import_i18n6 = __toESM(require_i18n(), 1);
10326 var import_editor9 = __toESM(require_editor(), 1);
10327 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
10328 function WelcomeGuideMenuItem() {
10329 const isEditingTemplate2 = (0, import_data14.useSelect)(
10330 (select3) => select3(import_editor9.store).getCurrentPostType() === "wp_template",
10331 []
10332 );
10333 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
10334 import_preferences3.PreferenceToggleMenuItem,
10335 {
10336 scope: "core/edit-post",
10337 name: isEditingTemplate2 ? "welcomeGuideTemplate" : "welcomeGuide",
10338 label: (0, import_i18n6.__)("Welcome Guide")
10339 }
10340 );
10341 }
10342
10343 // packages/edit-post/build-module/components/preferences-modal/index.mjs
10344 var import_i18n9 = __toESM(require_i18n(), 1);
10345 var import_preferences7 = __toESM(require_preferences(), 1);
10346 var import_editor13 = __toESM(require_editor(), 1);
10347
10348 // packages/edit-post/build-module/components/preferences-modal/meta-boxes-section.mjs
10349 var import_i18n8 = __toESM(require_i18n(), 1);
10350 var import_data17 = __toESM(require_data(), 1);
10351 var import_editor12 = __toESM(require_editor(), 1);
10352 var import_preferences6 = __toESM(require_preferences(), 1);
10353
10354 // packages/edit-post/build-module/components/preferences-modal/enable-custom-fields.mjs
10355 var import_element21 = __toESM(require_element(), 1);
10356 var import_i18n7 = __toESM(require_i18n(), 1);
10357 var import_components6 = __toESM(require_components(), 1);
10358 var import_data15 = __toESM(require_data(), 1);
10359 var import_editor10 = __toESM(require_editor(), 1);
10360 var import_preferences4 = __toESM(require_preferences(), 1);
10361 var import_url4 = __toESM(require_url(), 1);
10362 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
10363 var { PreferenceBaseOption } = unlock2(import_preferences4.privateApis);
10364 function submitCustomFieldsForm() {
10365 const customFieldsForm = document.getElementById(
10366 "toggle-custom-fields-form"
10367 );
10368 customFieldsForm.querySelector('[name="_wp_http_referer"]').setAttribute("value", (0, import_url4.getPathAndQueryString)(window.location.href));
10369 customFieldsForm.submit();
10370 }
10371 function CustomFieldsConfirmation({ willEnable }) {
10372 const [isReloading, setIsReloading] = (0, import_element21.useState)(false);
10373 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
10374 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "edit-post-preferences-modal__custom-fields-confirmation-message", children: (0, import_i18n7.__)(
10375 "A page reload is required for this change. Make sure your content is saved before reloading."
10376 ) }),
10377 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
10378 import_components6.Button,
10379 {
10380 __next40pxDefaultSize: true,
10381 variant: "secondary",
10382 isBusy: isReloading,
10383 accessibleWhenDisabled: true,
10384 disabled: isReloading,
10385 onClick: () => {
10386 setIsReloading(true);
10387 submitCustomFieldsForm();
10388 },
10389 children: willEnable ? (0, import_i18n7.__)("Show & Reload Page") : (0, import_i18n7.__)("Hide & Reload Page")
10390 }
10391 )
10392 ] });
10393 }
10394 function EnableCustomFieldsOption({ label }) {
10395 const areCustomFieldsEnabled = (0, import_data15.useSelect)((select3) => {
10396 return !!select3(import_editor10.store).getEditorSettings().enableCustomFields;
10397 }, []);
10398 const [isChecked, setIsChecked] = (0, import_element21.useState)(areCustomFieldsEnabled);
10399 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
10400 PreferenceBaseOption,
10401 {
10402 label,
10403 isChecked,
10404 onChange: setIsChecked,
10405 children: isChecked !== areCustomFieldsEnabled && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(CustomFieldsConfirmation, { willEnable: isChecked })
10406 }
10407 );
10408 }
10409
10410 // packages/edit-post/build-module/components/preferences-modal/enable-panel.mjs
10411 var import_data16 = __toESM(require_data(), 1);
10412 var import_editor11 = __toESM(require_editor(), 1);
10413 var import_preferences5 = __toESM(require_preferences(), 1);
10414 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
10415 var { PreferenceBaseOption: PreferenceBaseOption2 } = unlock2(import_preferences5.privateApis);
10416 function EnablePanelOption(props) {
10417 const { toggleEditorPanelEnabled: toggleEditorPanelEnabled2 } = (0, import_data16.useDispatch)(import_editor11.store);
10418 const { isChecked, isRemoved } = (0, import_data16.useSelect)(
10419 (select3) => {
10420 const { isEditorPanelEnabled: isEditorPanelEnabled2, isEditorPanelRemoved: isEditorPanelRemoved2 } = select3(import_editor11.store);
10421 return {
10422 isChecked: isEditorPanelEnabled2(props.panelName),
10423 isRemoved: isEditorPanelRemoved2(props.panelName)
10424 };
10425 },
10426 [props.panelName]
10427 );
10428 if (isRemoved) {
10429 return null;
10430 }
10431 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
10432 PreferenceBaseOption2,
10433 {
10434 isChecked,
10435 onChange: () => toggleEditorPanelEnabled2(props.panelName),
10436 ...props
10437 }
10438 );
10439 }
10440
10441 // packages/edit-post/build-module/components/preferences-modal/meta-boxes-section.mjs
10442 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
10443 var { PreferencesModalSection } = unlock2(import_preferences6.privateApis);
10444 function MetaBoxesSection({
10445 areCustomFieldsRegistered,
10446 metaBoxes: metaBoxes2,
10447 ...sectionProps
10448 }) {
10449 const thirdPartyMetaBoxes = metaBoxes2.filter(
10450 ({ id }) => id !== "postcustom"
10451 );
10452 if (!areCustomFieldsRegistered && thirdPartyMetaBoxes.length === 0) {
10453 return null;
10454 }
10455 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(PreferencesModalSection, { ...sectionProps, children: [
10456 areCustomFieldsRegistered && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(EnableCustomFieldsOption, { label: (0, import_i18n8.__)("Custom fields") }),
10457 thirdPartyMetaBoxes.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
10458 EnablePanelOption,
10459 {
10460 label: title,
10461 panelName: `meta-box-${id}`
10462 },
10463 id
10464 ))
10465 ] });
10466 }
10467 var meta_boxes_section_default = (0, import_data17.withSelect)((select3) => {
10468 const { getEditorSettings } = select3(import_editor12.store);
10469 const { getAllMetaBoxes: getAllMetaBoxes2 } = select3(store);
10470 return {
10471 // This setting should not live in the block editor's store.
10472 areCustomFieldsRegistered: getEditorSettings().enableCustomFields !== void 0,
10473 metaBoxes: getAllMetaBoxes2()
10474 };
10475 })(MetaBoxesSection);
10476
10477 // packages/edit-post/build-module/components/preferences-modal/index.mjs
10478 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
10479 var { PreferenceToggleControl } = unlock2(import_preferences7.privateApis);
10480 var { PreferencesModal } = unlock2(import_editor13.privateApis);
10481 function EditPostPreferencesModal() {
10482 const extraSections = {
10483 general: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(meta_boxes_section_default, { title: (0, import_i18n9.__)("Advanced") }),
10484 appearance: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
10485 PreferenceToggleControl,
10486 {
10487 scope: "core/edit-post",
10488 featureName: "themeStyles",
10489 help: (0, import_i18n9.__)("Make the editor look like your theme."),
10490 label: (0, import_i18n9.__)("Use theme styles")
10491 }
10492 )
10493 };
10494 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(PreferencesModal, { extraSections });
10495 }
10496
10497 // packages/edit-post/build-module/components/more-menu/index.mjs
10498 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
10499 var { ToolsMoreMenuGroup, ViewMoreMenuGroup } = unlock2(import_editor14.privateApis);
10500 var MoreMenu = () => {
10501 const isLargeViewport = (0, import_compose2.useViewportMatch)("large");
10502 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
10503 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ViewMoreMenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
10504 import_preferences8.PreferenceToggleMenuItem,
10505 {
10506 scope: "core/edit-post",
10507 name: "fullscreenMode",
10508 label: (0, import_i18n10.__)("Fullscreen mode"),
10509 info: (0, import_i18n10.__)("Show and hide the admin user interface"),
10510 messageActivated: (0, import_i18n10.__)("Fullscreen mode activated."),
10511 messageDeactivated: (0, import_i18n10.__)(
10512 "Fullscreen mode deactivated."
10513 ),
10514 shortcut: import_keycodes.displayShortcut.secondary("f")
10515 }
10516 ) }),
10517 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(ToolsMoreMenuGroup, { children: [
10518 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(manage_patterns_menu_item_default, {}),
10519 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(WelcomeGuideMenuItem, {})
10520 ] }),
10521 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(EditPostPreferencesModal, {})
10522 ] });
10523 };
10524 var more_menu_default = MoreMenu;
10525
10526 // packages/edit-post/build-module/components/welcome-guide/index.mjs
10527 var import_data20 = __toESM(require_data(), 1);
10528
10529 // packages/edit-post/build-module/components/welcome-guide/default.mjs
10530 var import_data18 = __toESM(require_data(), 1);
10531 var import_components7 = __toESM(require_components(), 1);
10532 var import_i18n11 = __toESM(require_i18n(), 1);
10533 var import_element22 = __toESM(require_element(), 1);
10534
10535 // packages/edit-post/build-module/components/welcome-guide/image.mjs
10536 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
10537 function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) {
10538 return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("picture", { className: "edit-post-welcome-guide__image", children: [
10539 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
10540 "source",
10541 {
10542 srcSet: nonAnimatedSrc,
10543 media: "(prefers-reduced-motion: reduce)"
10544 }
10545 ),
10546 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" })
10547 ] });
10548 }
10549
10550 // packages/edit-post/build-module/components/welcome-guide/default.mjs
10551 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
10552 function WelcomeGuideDefault() {
10553 const { toggleFeature: toggleFeature2 } = (0, import_data18.useDispatch)(store);
10554 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10555 import_components7.Guide,
10556 {
10557 className: "edit-post-welcome-guide",
10558 contentLabel: (0, import_i18n11.__)("Welcome to the editor"),
10559 finishButtonText: (0, import_i18n11.__)("Get started"),
10560 onFinish: () => toggleFeature2("welcomeGuide"),
10561 pages: [
10562 {
10563 image: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10564 WelcomeGuideImage,
10565 {
10566 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.svg",
10567 animatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.gif"
10568 }
10569 ),
10570 content: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
10571 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h1", { className: "edit-post-welcome-guide__heading", children: (0, import_i18n11.__)("Welcome to the editor") }),
10572 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "edit-post-welcome-guide__text", children: (0, import_i18n11.__)(
10573 "In the WordPress editor, each paragraph, image, or video is presented as a distinct \u201Cblock\u201D of content."
10574 ) })
10575 ] })
10576 },
10577 {
10578 image: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10579 WelcomeGuideImage,
10580 {
10581 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-editor.svg",
10582 animatedSrc: "https://s.w.org/images/block-editor/welcome-editor.gif"
10583 }
10584 ),
10585 content: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
10586 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h1", { className: "edit-post-welcome-guide__heading", children: (0, import_i18n11.__)("Customize each block") }),
10587 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "edit-post-welcome-guide__text", children: (0, import_i18n11.__)(
10588 "Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected."
10589 ) })
10590 ] })
10591 },
10592 {
10593 image: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10594 WelcomeGuideImage,
10595 {
10596 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-library.svg",
10597 animatedSrc: "https://s.w.org/images/block-editor/welcome-library.gif"
10598 }
10599 ),
10600 content: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
10601 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h1", { className: "edit-post-welcome-guide__heading", children: (0, import_i18n11.__)("Explore all blocks") }),
10602 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "edit-post-welcome-guide__text", children: (0, import_element22.createInterpolateElement)(
10603 (0, import_i18n11.__)(
10604 "All of the blocks available to you live in the block library. You\u2019ll find it wherever you see the <InserterIconImage /> icon."
10605 ),
10606 {
10607 InserterIconImage: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10608 "img",
10609 {
10610 alt: (0, import_i18n11.__)("inserter"),
10611 src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A"
10612 }
10613 )
10614 }
10615 ) })
10616 ] })
10617 },
10618 {
10619 image: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10620 WelcomeGuideImage,
10621 {
10622 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
10623 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
10624 }
10625 ),
10626 content: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
10627 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h1", { className: "edit-post-welcome-guide__heading", children: (0, import_i18n11.__)("Learn more") }),
10628 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "edit-post-welcome-guide__text", children: (0, import_element22.createInterpolateElement)(
10629 (0, import_i18n11.__)(
10630 "New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>"
10631 ),
10632 {
10633 a: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
10634 import_components7.ExternalLink,
10635 {
10636 href: (0, import_i18n11.__)(
10637 "https://wordpress.org/documentation/article/wordpress-block-editor/"
10638 )
10639 }
10640 )
10641 }
10642 ) })
10643 ] })
10644 }
10645 ]
10646 }
10647 );
10648 }
10649
10650 // packages/edit-post/build-module/components/welcome-guide/template.mjs
10651 var import_data19 = __toESM(require_data(), 1);
10652 var import_components8 = __toESM(require_components(), 1);
10653 var import_i18n12 = __toESM(require_i18n(), 1);
10654 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
10655 function WelcomeGuideTemplate() {
10656 const { toggleFeature: toggleFeature2 } = (0, import_data19.useDispatch)(store);
10657 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
10658 import_components8.Guide,
10659 {
10660 className: "edit-template-welcome-guide",
10661 contentLabel: (0, import_i18n12.__)("Welcome to the template editor"),
10662 finishButtonText: (0, import_i18n12.__)("Get started"),
10663 onFinish: () => toggleFeature2("welcomeGuideTemplate"),
10664 pages: [
10665 {
10666 image: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
10667 WelcomeGuideImage,
10668 {
10669 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-template-editor.svg",
10670 animatedSrc: "https://s.w.org/images/block-editor/welcome-template-editor.gif"
10671 }
10672 ),
10673 content: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
10674 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h1", { className: "edit-post-welcome-guide__heading", children: (0, import_i18n12.__)("Welcome to the template editor") }),
10675 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "edit-post-welcome-guide__text", children: (0, import_i18n12.__)(
10676 "Templates help define the layout of the site. You can customize all aspects of your posts and pages using blocks and patterns in this editor."
10677 ) })
10678 ] })
10679 }
10680 ]
10681 }
10682 );
10683 }
10684
10685 // packages/edit-post/build-module/components/welcome-guide/index.mjs
10686 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10687 function WelcomeGuide({ postType }) {
10688 const { isActive, isEditingTemplate: isEditingTemplate2 } = (0, import_data20.useSelect)(
10689 (select3) => {
10690 const { isFeatureActive: isFeatureActive2 } = select3(store);
10691 const _isEditingTemplate = postType === "wp_template";
10692 const feature = _isEditingTemplate ? "welcomeGuideTemplate" : "welcomeGuide";
10693 return {
10694 isActive: isFeatureActive2(feature),
10695 isEditingTemplate: _isEditingTemplate
10696 };
10697 },
10698 [postType]
10699 );
10700 if (!isActive) {
10701 return null;
10702 }
10703 return isEditingTemplate2 ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(WelcomeGuideTemplate, {}) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(WelcomeGuideDefault, {});
10704 }
10705
10706 // packages/edit-post/build-module/commands/use-commands.mjs
10707 var import_data21 = __toESM(require_data(), 1);
10708 var import_i18n13 = __toESM(require_i18n(), 1);
10709 var import_commands = __toESM(require_commands(), 1);
10710 var import_preferences9 = __toESM(require_preferences(), 1);
10711 var import_notices2 = __toESM(require_notices(), 1);
10712 function useCommands() {
10713 const { isFullscreen } = (0, import_data21.useSelect)((select3) => {
10714 const { get } = select3(import_preferences9.store);
10715 return {
10716 isFullscreen: get("core/edit-post", "fullscreenMode")
10717 };
10718 }, []);
10719 const { toggle } = (0, import_data21.useDispatch)(import_preferences9.store);
10720 const { createInfoNotice } = (0, import_data21.useDispatch)(import_notices2.store);
10721 (0, import_commands.useCommand)({
10722 name: "core/toggle-fullscreen-mode",
10723 label: isFullscreen ? (0, import_i18n13.__)("Exit fullscreen") : (0, import_i18n13.__)("Enter fullscreen"),
10724 icon: fullscreen_default,
10725 category: "command",
10726 callback: ({ close }) => {
10727 toggle("core/edit-post", "fullscreenMode");
10728 close();
10729 createInfoNotice(
10730 isFullscreen ? (0, import_i18n13.__)("Fullscreen off.") : (0, import_i18n13.__)("Fullscreen on."),
10731 {
10732 id: "core/edit-post/toggle-fullscreen-mode/notice",
10733 type: "snackbar",
10734 actions: [
10735 {
10736 label: (0, import_i18n13.__)("Undo"),
10737 onClick: () => {
10738 toggle("core/edit-post", "fullscreenMode");
10739 }
10740 }
10741 ]
10742 }
10743 );
10744 }
10745 });
10746 }
10747
10748 // packages/edit-post/build-module/components/layout/use-should-iframe.mjs
10749 var import_editor15 = __toESM(require_editor(), 1);
10750 var import_data22 = __toESM(require_data(), 1);
10751 var import_blocks2 = __toESM(require_blocks(), 1);
10752 var import_block_editor = __toESM(require_block_editor(), 1);
10753 var isGutenbergPlugin = true ? true : false;
10754 function useShouldIframe() {
10755 return (0, import_data22.useSelect)((select3) => {
10756 const { getCurrentPostType, getDeviceType } = select3(import_editor15.store);
10757 const { getClientIdsWithDescendants, getBlockName } = select3(import_block_editor.store);
10758 const { getBlockType } = select3(import_blocks2.store);
10759 return (
10760 // If the Gutenberg plugin is active, we ALWAYS use the iframe for
10761 // consistency across the post and site editor. We plan on enforcing
10762 // the iframe in the future, so Gutenberg both serves as way for us
10763 // to warn plugin developers and for plugin developers to test their
10764 // blocks easily. Before GB v22.5, we only enforced it for
10765 // block-based themes (classic themes used the same rules as core).
10766 isGutenbergPlugin || // We also still want to iframe all the special
10767 // editor features and modes such as device previews, zoom out, and
10768 // template/pattern editing.
10769 getDeviceType() !== "Desktop" || ["wp_template", "wp_block"].includes(getCurrentPostType()) || unlock2(select3(import_block_editor.store)).isZoomOut() || // Finally, still iframe the editor if all present blocks are v3
10770 // (which means they are marked as iframe-compatible).
10771 [...new Set(getClientIdsWithDescendants().map(getBlockName))].map(getBlockType).filter(Boolean).every((blockType) => blockType.apiVersion >= 3)
10772 );
10773 }, []);
10774 }
10775
10776 // packages/edit-post/build-module/hooks/use-navigate-to-entity-record.mjs
10777 var import_element23 = __toESM(require_element(), 1);
10778 var import_data23 = __toESM(require_data(), 1);
10779 var import_editor16 = __toESM(require_editor(), 1);
10780 var import_core_data6 = __toESM(require_core_data(), 1);
10781 function useNavigateToEntityRecord(initialPostId, initialPostType, defaultRenderingMode) {
10782 const registry = (0, import_data23.useRegistry)();
10783 const [postHistory, dispatch2] = (0, import_element23.useReducer)(
10784 (historyState, { type, post: post2, previousRenderingMode: previousRenderingMode2, selectedBlockClientId }) => {
10785 if (type === "push") {
10786 const updatedHistory = [...historyState];
10787 const currentIndex = updatedHistory.length - 1;
10788 updatedHistory[currentIndex] = {
10789 ...updatedHistory[currentIndex],
10790 selectedBlockClientId
10791 };
10792 return [...updatedHistory, { post: post2, previousRenderingMode: previousRenderingMode2 }];
10793 }
10794 if (type === "pop") {
10795 if (historyState.length > 1) {
10796 return historyState.slice(0, -1);
10797 }
10798 }
10799 return historyState;
10800 },
10801 [
10802 {
10803 post: { postId: initialPostId, postType: initialPostType }
10804 }
10805 ]
10806 );
10807 const { post, previousRenderingMode } = postHistory[postHistory.length - 1];
10808 const { getRenderingMode } = (0, import_data23.useSelect)(import_editor16.store);
10809 const { setRenderingMode } = (0, import_data23.useDispatch)(import_editor16.store);
10810 const { editEntityRecord } = (0, import_data23.useDispatch)(import_core_data6.store);
10811 const onNavigateToEntityRecord = (0, import_element23.useCallback)(
10812 (params) => {
10813 const entityEdits = registry.select(import_core_data6.store).getEntityRecordEdits("postType", post.postType, post.postId);
10814 const externalClientId = entityEdits?.selection?.selectionStart?.clientId ?? null;
10815 dispatch2({
10816 type: "push",
10817 post: { postId: params.postId, postType: params.postType },
10818 // Save the current rendering mode so we can restore it when navigating back.
10819 previousRenderingMode: getRenderingMode(),
10820 selectedBlockClientId: externalClientId
10821 });
10822 setRenderingMode(defaultRenderingMode);
10823 },
10824 [
10825 registry,
10826 post.postType,
10827 post.postId,
10828 getRenderingMode,
10829 setRenderingMode,
10830 defaultRenderingMode
10831 ]
10832 );
10833 const onNavigateToPreviousEntityRecord = (0, import_element23.useCallback)(() => {
10834 if (postHistory.length > 1) {
10835 const previousItem = postHistory[postHistory.length - 2];
10836 if (previousItem.selectedBlockClientId) {
10837 editEntityRecord(
10838 "postType",
10839 previousItem.post.postType,
10840 previousItem.post.postId,
10841 {
10842 selection: {
10843 selectionStart: {
10844 clientId: previousItem.selectedBlockClientId
10845 },
10846 selectionEnd: {
10847 clientId: previousItem.selectedBlockClientId
10848 }
10849 }
10850 },
10851 { undoIgnore: true }
10852 );
10853 }
10854 }
10855 dispatch2({
10856 type: "pop"
10857 });
10858 if (previousRenderingMode) {
10859 setRenderingMode(previousRenderingMode);
10860 }
10861 }, [
10862 setRenderingMode,
10863 previousRenderingMode,
10864 postHistory,
10865 editEntityRecord
10866 ]);
10867 return {
10868 currentPost: post,
10869 onNavigateToEntityRecord,
10870 onNavigateToPreviousEntityRecord: postHistory.length > 1 ? onNavigateToPreviousEntityRecord : void 0
10871 };
10872 }
10873
10874 // packages/edit-post/build-module/components/meta-boxes/use-meta-box-initialization.mjs
10875 var import_data24 = __toESM(require_data(), 1);
10876 var import_editor17 = __toESM(require_editor(), 1);
10877 var import_core_data7 = __toESM(require_core_data(), 1);
10878 var import_element24 = __toESM(require_element(), 1);
10879 var useMetaBoxInitialization = (enabled) => {
10880 const {
10881 isEnabledAndEditorReady,
10882 isCollaborationEnabled,
10883 hasIncompatibleMetaBoxes,
10884 hasActiveMetaBoxes
10885 } = (0, import_data24.useSelect)(
10886 (select3) => {
10887 const {
10888 __unstableIsEditorReady,
10889 isCollaborationEnabledForCurrentPost
10890 } = unlock2(select3(import_editor17.store));
10891 return {
10892 isEnabledAndEditorReady: enabled && __unstableIsEditorReady(),
10893 isCollaborationEnabled: isCollaborationEnabledForCurrentPost(),
10894 hasIncompatibleMetaBoxes: enabled ? select3(store).getAllMetaBoxes().some((metaBox) => !metaBox.__rtc_compatible) : false,
10895 hasActiveMetaBoxes: enabled && select3(store).hasMetaBoxes()
10896 };
10897 },
10898 [enabled]
10899 );
10900 const { setCollaborationSupported } = unlock2((0, import_data24.useDispatch)(import_core_data7.store));
10901 const { updateEditorSettings } = (0, import_data24.useDispatch)(import_editor17.store);
10902 const { initializeMetaBoxes: initializeMetaBoxes2 } = (0, import_data24.useDispatch)(store);
10903 (0, import_element24.useEffect)(() => {
10904 if (isEnabledAndEditorReady) {
10905 initializeMetaBoxes2();
10906 if (isCollaborationEnabled && hasIncompatibleMetaBoxes) {
10907 setCollaborationSupported(false);
10908 }
10909 if (hasActiveMetaBoxes) {
10910 updateEditorSettings({ disableVisualRevisions: true });
10911 }
10912 }
10913 }, [
10914 isEnabledAndEditorReady,
10915 initializeMetaBoxes2,
10916 isCollaborationEnabled,
10917 setCollaborationSupported,
10918 hasIncompatibleMetaBoxes,
10919 hasActiveMetaBoxes,
10920 updateEditorSettings
10921 ]);
10922 };
10923
10924 // packages/edit-post/build-module/components/layout/index.mjs
10925 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10926 var { useCommandContext } = unlock2(import_commands2.privateApis);
10927 var { useDrag } = unlock2(import_components9.privateApis);
10928 var { Editor, FullscreenMode } = unlock2(import_editor18.privateApis);
10929 var { BlockKeyboardShortcuts } = unlock2(import_block_library.privateApis);
10930 var DESIGN_POST_TYPES = [
10931 "wp_template",
10932 "wp_template_part",
10933 "wp_block",
10934 "wp_navigation"
10935 ];
10936 function useEditorStyles(settings) {
10937 const { hasThemeStyleSupport } = (0, import_data25.useSelect)((select3) => {
10938 return {
10939 hasThemeStyleSupport: select3(store).isFeatureActive("themeStyles")
10940 };
10941 }, []);
10942 return (0, import_element25.useMemo)(() => {
10943 const presetStyles = settings.styles?.filter(
10944 (style) => style.__unstableType && style.__unstableType !== "theme"
10945 ) ?? [];
10946 const defaultEditorStyles = [
10947 ...settings?.defaultEditorStyles ?? [],
10948 ...presetStyles
10949 ];
10950 const hasThemeStyles = hasThemeStyleSupport && presetStyles.length !== (settings.styles?.length ?? 0);
10951 if (!settings.disableLayoutStyles && !hasThemeStyles) {
10952 defaultEditorStyles.push({
10953 css: getLayoutStyles({
10954 style: {},
10955 selector: "body",
10956 hasBlockGapSupport: false,
10957 hasFallbackGapSupport: true,
10958 fallbackGapValue: "0.5em"
10959 })
10960 });
10961 }
10962 return hasThemeStyles ? settings.styles ?? [] : defaultEditorStyles;
10963 }, [
10964 settings.defaultEditorStyles,
10965 settings.disableLayoutStyles,
10966 settings.styles,
10967 hasThemeStyleSupport
10968 ]);
10969 }
10970 function MetaBoxesMain({ isLegacy }) {
10971 const [isOpen, openHeight, hasAnyVisible] = (0, import_data25.useSelect)((select3) => {
10972 const { get } = select3(import_preferences10.store);
10973 const { isMetaBoxLocationVisible: isMetaBoxLocationVisible2 } = select3(store);
10974 return [
10975 !!get("core/edit-post", "metaBoxesMainIsOpen"),
10976 get("core/edit-post", "metaBoxesMainOpenHeight"),
10977 isMetaBoxLocationVisible2("normal") || isMetaBoxLocationVisible2("advanced") || isMetaBoxLocationVisible2("side")
10978 ];
10979 }, []);
10980 const { set: setPreference } = (0, import_data25.useDispatch)(import_preferences10.store);
10981 const isShort = (0, import_compose3.useMediaQuery)("(max-height: 549px)");
10982 const [{ min: min2 = 0, max: max2 }, setHeightConstraints] = (0, import_element25.useState)(() => ({}));
10983 const effectSizeConstraints = (0, import_compose3.useRefEffect)((node) => {
10984 const container = node.closest(
10985 ".interface-interface-skeleton__content"
10986 );
10987 if (!container) {
10988 return;
10989 }
10990 const noticeContainer = container.querySelector(
10991 ":scope > .notices-inline-notices-wrapper"
10992 );
10993 const resizeHandle = container.querySelector(
10994 ".edit-post-meta-boxes-main__presenter"
10995 );
10996 const deriveConstraints = () => {
10997 const fullHeight = container.offsetHeight;
10998 let nextMax = fullHeight;
10999 if (noticeContainer) {
11000 nextMax -= noticeContainer.offsetHeight;
11001 }
11002 const nextMin = resizeHandle?.offsetHeight ?? 0;
11003 setHeightConstraints({ min: nextMin, max: nextMax });
11004 };
11005 const observer = new window.ResizeObserver(deriveConstraints);
11006 observer.observe(container);
11007 if (noticeContainer) {
11008 observer.observe(noticeContainer);
11009 }
11010 return () => observer.disconnect();
11011 }, []);
11012 const metaBoxesMainRef = (0, import_element25.useRef)();
11013 const setMainRefs = (0, import_compose3.useMergeRefs)([
11014 metaBoxesMainRef,
11015 effectSizeConstraints
11016 ]);
11017 const separatorRef = (0, import_element25.useRef)();
11018 const separatorHelpId = (0, import_element25.useId)();
11019 const heightRef = (0, import_element25.useRef)();
11020 const getAriaValueNow = (height) => Math.round((height - min2) / (max2 - min2) * 100);
11021 const persistIsOpen = (to = !isOpen) => setPreference("core/edit-post", "metaBoxesMainIsOpen", to);
11022 const applyHeight = (candidateHeight = "auto", isPersistent) => {
11023 let styleHeight;
11024 if (candidateHeight === "auto") {
11025 isPersistent = false;
11026 styleHeight = candidateHeight;
11027 } else {
11028 candidateHeight = Math.min(max2, Math.max(min2, candidateHeight));
11029 heightRef.current = candidateHeight;
11030 styleHeight = `${candidateHeight}px`;
11031 }
11032 if (isPersistent) {
11033 setPreference(
11034 "core/edit-post",
11035 "metaBoxesMainOpenHeight",
11036 candidateHeight
11037 );
11038 } else {
11039 metaBoxesMainRef.current.style.height = styleHeight;
11040 if (!isShort) {
11041 separatorRef.current.ariaValueNow = getAriaValueNow(candidateHeight);
11042 }
11043 }
11044 };
11045 const bindDragGesture = useDrag(
11046 ({ movement, first, last, memo, tap, args }) => {
11047 const pane = metaBoxesMainRef.current;
11048 const [, yMovement] = movement;
11049 if (first) {
11050 pane.classList.add("is-resizing");
11051 let fromHeight = heightRef.current ?? pane.offsetHeight;
11052 if (isOpen) {
11053 if (fromHeight > max2) {
11054 fromHeight = max2;
11055 }
11056 } else {
11057 fromHeight = min2;
11058 }
11059 applyHeight(fromHeight - yMovement);
11060 return { fromHeight };
11061 }
11062 if (!first && !last && !tap) {
11063 applyHeight(memo.fromHeight - yMovement);
11064 return memo;
11065 }
11066 pane.classList.remove("is-resizing");
11067 if (tap) {
11068 const [onTap] = args;
11069 onTap?.();
11070 return;
11071 }
11072 const nextIsOpen = heightRef.current > min2;
11073 persistIsOpen(nextIsOpen);
11074 applyHeight(heightRef.current, nextIsOpen);
11075 },
11076 { keyboardDisplacement: 20, filterTaps: true }
11077 );
11078 if (!hasAnyVisible) {
11079 return;
11080 }
11081 const contents = /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
11082 "div",
11083 {
11084 className: "edit-post-layout__metaboxes edit-post-meta-boxes-main__liner",
11085 hidden: !isLegacy && !isOpen,
11086 children: [
11087 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(MetaBoxes, { location: "normal" }),
11088 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(MetaBoxes, { location: "advanced" })
11089 ]
11090 }
11091 );
11092 if (isLegacy) {
11093 return contents;
11094 }
11095 const isAutoHeight = openHeight === void 0;
11096 const usedOpenHeight = isShort ? "auto" : openHeight;
11097 const usedHeight = isOpen ? usedOpenHeight : min2;
11098 const usedAriaValueNow = max2 === void 0 || isAutoHeight ? 50 : getAriaValueNow(usedHeight);
11099 const paneLabel = (0, import_i18n14.__)("Meta Boxes");
11100 const toggle = /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
11101 "button",
11102 {
11103 "aria-expanded": isOpen,
11104 onClick: ({ detail }) => {
11105 if (isShort || !detail) {
11106 persistIsOpen();
11107 }
11108 },
11109 ...!isShort && bindDragGesture(persistIsOpen),
11110 children: [
11111 paneLabel,
11112 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components9.Icon, { icon: isOpen ? chevron_up_default : chevron_down_default })
11113 ]
11114 }
11115 );
11116 const separator = !isShort && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
11117 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(tooltip_exports.Root, { children: [
11118 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11119 tooltip_exports.Trigger,
11120 {
11121 render: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11122 "button",
11123 {
11124 ref: separatorRef,
11125 role: "separator",
11126 "aria-valuenow": usedAriaValueNow,
11127 "aria-label": (0, import_i18n14.__)("Drag to resize"),
11128 "aria-describedby": separatorHelpId,
11129 ...bindDragGesture()
11130 }
11131 )
11132 }
11133 ),
11134 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(tooltip_exports.Popup, { children: (0, import_i18n14.__)("Drag to resize") })
11135 ] }),
11136 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(VisuallyHidden, { id: separatorHelpId, children: (0, import_i18n14.__)(
11137 "Use up and down arrow keys to resize the meta box pane."
11138 ) })
11139 ] });
11140 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
11141 navigable_region_default,
11142 {
11143 ariaLabel: paneLabel,
11144 ref: setMainRefs,
11145 className: clsx_default(
11146 "edit-post-meta-boxes-main",
11147 !isShort && "is-resizable"
11148 ),
11149 style: { height: usedHeight },
11150 children: [
11151 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "edit-post-meta-boxes-main__presenter", children: [
11152 toggle,
11153 separator
11154 ] }),
11155 contents
11156 ]
11157 }
11158 );
11159 }
11160 function Layout({
11161 postId: initialPostId,
11162 postType: initialPostType,
11163 settings,
11164 initialEdits
11165 }) {
11166 useCommands();
11167 const shouldIframe = useShouldIframe();
11168 const { createErrorNotice } = (0, import_data25.useDispatch)(import_notices3.store);
11169 const {
11170 currentPost: { postId: currentPostId, postType: currentPostType },
11171 onNavigateToEntityRecord,
11172 onNavigateToPreviousEntityRecord
11173 } = useNavigateToEntityRecord(
11174 initialPostId,
11175 initialPostType,
11176 "post-only"
11177 );
11178 const isEditingTemplate2 = currentPostType === "wp_template";
11179 const {
11180 mode,
11181 isFullscreenActive,
11182 hasResolvedMode,
11183 hasActiveMetaboxes,
11184 hasBlockSelected,
11185 showIconLabels,
11186 isDistractionFree,
11187 showMetaBoxes,
11188 isWelcomeGuideVisible,
11189 templateId,
11190 isDevicePreview
11191 } = (0, import_data25.useSelect)(
11192 (select3) => {
11193 const { get } = select3(import_preferences10.store);
11194 const { isFeatureActive: isFeatureActive2, hasMetaBoxes: hasMetaBoxes2 } = select3(store);
11195 const { canUser, getPostType, getTemplateId } = unlock2(
11196 select3(import_core_data8.store)
11197 );
11198 const supportsTemplateMode = settings.supportsTemplateMode;
11199 const isViewable = getPostType(currentPostType)?.viewable ?? false;
11200 const canViewTemplate = canUser("read", {
11201 kind: "postType",
11202 name: "wp_template"
11203 });
11204 const { getBlockSelectionStart, isZoomOut } = unlock2(
11205 select3(import_block_editor2.store)
11206 );
11207 const { getEditorMode: getEditorMode2, getDefaultRenderingMode, getDeviceType } = unlock2(select3(import_editor18.store));
11208 const isNotDesignPostType = !DESIGN_POST_TYPES.includes(currentPostType);
11209 const isDirectlyEditingPattern = currentPostType === "wp_block" && !onNavigateToPreviousEntityRecord;
11210 const _templateId = getTemplateId(currentPostType, currentPostId);
11211 const defaultMode = getDefaultRenderingMode(currentPostType);
11212 return {
11213 mode: getEditorMode2(),
11214 isFullscreenActive: isFeatureActive2("fullscreenMode"),
11215 hasActiveMetaboxes: hasMetaBoxes2(),
11216 hasResolvedMode: defaultMode === "template-locked" ? !!_templateId : defaultMode !== void 0,
11217 hasBlockSelected: !!getBlockSelectionStart(),
11218 showIconLabels: get("core", "showIconLabels"),
11219 isDistractionFree: get("core", "distractionFree"),
11220 showMetaBoxes: isNotDesignPostType && !isZoomOut() || isDirectlyEditingPattern,
11221 isWelcomeGuideVisible: isFeatureActive2("welcomeGuide"),
11222 templateId: supportsTemplateMode && isViewable && canViewTemplate && !isEditingTemplate2 ? _templateId : null,
11223 isDevicePreview: getDeviceType() !== "Desktop"
11224 };
11225 },
11226 [
11227 currentPostType,
11228 currentPostId,
11229 isEditingTemplate2,
11230 settings.supportsTemplateMode,
11231 onNavigateToPreviousEntityRecord
11232 ]
11233 );
11234 useMetaBoxInitialization(hasActiveMetaboxes && hasResolvedMode);
11235 const commandContext = hasBlockSelected ? "block-selection-edit" : "entity-edit";
11236 useCommandContext(commandContext);
11237 const styles = useEditorStyles(settings);
11238 const editorSettings = (0, import_element25.useMemo)(
11239 () => ({
11240 ...settings,
11241 styles,
11242 onNavigateToEntityRecord,
11243 onNavigateToPreviousEntityRecord
11244 }),
11245 [
11246 settings,
11247 styles,
11248 onNavigateToEntityRecord,
11249 onNavigateToPreviousEntityRecord
11250 ]
11251 );
11252 if (showIconLabels) {
11253 document.body.classList.add("show-icon-labels");
11254 } else {
11255 document.body.classList.remove("show-icon-labels");
11256 }
11257 const navigateRegionsProps = (0, import_components9.__unstableUseNavigateRegions)();
11258 const className = clsx_default("edit-post-layout", "is-mode-" + mode, {
11259 "has-metaboxes": hasActiveMetaboxes
11260 });
11261 function onPluginAreaError(name) {
11262 createErrorNotice(
11263 (0, import_i18n14.sprintf)(
11264 /* translators: %s: plugin name */
11265 (0, import_i18n14.__)(
11266 'The "%s" plugin has encountered an error and cannot be rendered.'
11267 ),
11268 name
11269 )
11270 );
11271 }
11272 const { createSuccessNotice } = (0, import_data25.useDispatch)(import_notices3.store);
11273 const onActionPerformed = (0, import_element25.useCallback)(
11274 (actionId, items) => {
11275 switch (actionId) {
11276 case "move-to-trash":
11277 {
11278 document.location.href = (0, import_url5.addQueryArgs)("edit.php", {
11279 trashed: 1,
11280 post_type: items[0].type,
11281 ids: items[0].id
11282 });
11283 }
11284 break;
11285 case "duplicate-post":
11286 {
11287 const newItem = items[0];
11288 const title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered;
11289 createSuccessNotice(
11290 (0, import_i18n14.sprintf)(
11291 // translators: %s: Title of the created post or template, e.g: "Hello world".
11292 (0, import_i18n14.__)('"%s" successfully created.'),
11293 (0, import_html_entities.decodeEntities)(title) || (0, import_i18n14.__)("(no title)")
11294 ),
11295 {
11296 type: "snackbar",
11297 id: "duplicate-post-action",
11298 actions: [
11299 {
11300 label: (0, import_i18n14.__)("Edit"),
11301 onClick: () => {
11302 const postId = newItem.id;
11303 document.location.href = (0, import_url5.addQueryArgs)("post.php", {
11304 post: postId,
11305 action: "edit"
11306 });
11307 }
11308 }
11309 ]
11310 }
11311 );
11312 }
11313 break;
11314 }
11315 },
11316 [createSuccessNotice]
11317 );
11318 const initialPost = (0, import_element25.useMemo)(() => {
11319 return {
11320 type: initialPostType,
11321 id: initialPostId
11322 };
11323 }, [initialPostType, initialPostId]);
11324 const backButton = (0, import_compose3.useViewportMatch)("medium") && isFullscreenActive ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(back_button_default, { initialPost }) : null;
11325 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components9.SlotFillProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(tooltip_exports.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_editor18.ErrorBoundary, { canCopyContent: true, children: [
11326 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(WelcomeGuide, { postType: currentPostType }),
11327 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...navigateRegionsProps, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
11328 Editor,
11329 {
11330 settings: editorSettings,
11331 initialEdits,
11332 postType: currentPostType,
11333 postId: currentPostId,
11334 templateId,
11335 className,
11336 forceIsDirty: hasActiveMetaboxes,
11337 disableIframe: !shouldIframe,
11338 autoFocus: !isWelcomeGuideVisible,
11339 onActionPerformed,
11340 extraSidebarPanels: showMetaBoxes && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(MetaBoxes, { location: "side" }),
11341 extraContent: !isDistractionFree && showMetaBoxes && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11342 MetaBoxesMain,
11343 {
11344 isLegacy: isDevicePreview
11345 }
11346 ),
11347 children: [
11348 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_editor18.PostLockedModal, {}),
11349 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(EditorInitialization, {}),
11350 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FullscreenMode, { isActive: isFullscreenActive }),
11351 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(BrowserURL, {}),
11352 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_editor18.UnsavedChangesWarning, {}),
11353 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_editor18.AutosaveMonitor, {}),
11354 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_editor18.LocalAutosaveMonitor, {}),
11355 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(keyboard_shortcuts_default, {}),
11356 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_editor18.EditorKeyboardShortcutsRegister, {}),
11357 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(BlockKeyboardShortcuts, {}),
11358 currentPostType === "wp_block" && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(InitPatternModal, {}),
11359 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_plugins.PluginArea, { onError: onPluginAreaError }),
11360 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(more_menu_default, {}),
11361 backButton,
11362 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_notices3.SnackbarNotices, { className: "edit-post-layout__snackbar" })
11363 ]
11364 }
11365 ) })
11366 ] }) }) });
11367 }
11368 var layout_default = Layout;
11369
11370 // packages/edit-post/build-module/deprecated.mjs
11371 var import_editor19 = __toESM(require_editor(), 1);
11372 var import_url6 = __toESM(require_url(), 1);
11373 var import_deprecated3 = __toESM(require_deprecated(), 1);
11374 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
11375 var { PluginPostExcerpt } = unlock2(import_editor19.privateApis);
11376 var isSiteEditor = (0, import_url6.getPath)(window.location.href)?.includes(
11377 "site-editor.php"
11378 );
11379 var deprecateSlot = (name) => {
11380 (0, import_deprecated3.default)(`wp.editPost.${name}`, {
11381 since: "6.6",
11382 alternative: `wp.editor.${name}`
11383 });
11384 };
11385 function PluginBlockSettingsMenuItem(props) {
11386 if (isSiteEditor) {
11387 return null;
11388 }
11389 deprecateSlot("PluginBlockSettingsMenuItem");
11390 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginBlockSettingsMenuItem, { ...props });
11391 }
11392 function PluginDocumentSettingPanel(props) {
11393 if (isSiteEditor) {
11394 return null;
11395 }
11396 deprecateSlot("PluginDocumentSettingPanel");
11397 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginDocumentSettingPanel, { ...props });
11398 }
11399 function PluginMoreMenuItem(props) {
11400 if (isSiteEditor) {
11401 return null;
11402 }
11403 deprecateSlot("PluginMoreMenuItem");
11404 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginMoreMenuItem, { ...props });
11405 }
11406 function PluginPrePublishPanel(props) {
11407 if (isSiteEditor) {
11408 return null;
11409 }
11410 deprecateSlot("PluginPrePublishPanel");
11411 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginPrePublishPanel, { ...props });
11412 }
11413 function PluginPostPublishPanel(props) {
11414 if (isSiteEditor) {
11415 return null;
11416 }
11417 deprecateSlot("PluginPostPublishPanel");
11418 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginPostPublishPanel, { ...props });
11419 }
11420 function PluginPostStatusInfo(props) {
11421 if (isSiteEditor) {
11422 return null;
11423 }
11424 deprecateSlot("PluginPostStatusInfo");
11425 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginPostStatusInfo, { ...props });
11426 }
11427 function PluginSidebar(props) {
11428 if (isSiteEditor) {
11429 return null;
11430 }
11431 deprecateSlot("PluginSidebar");
11432 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginSidebar, { ...props });
11433 }
11434 function PluginSidebarMoreMenuItem(props) {
11435 if (isSiteEditor) {
11436 return null;
11437 }
11438 deprecateSlot("PluginSidebarMoreMenuItem");
11439 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_editor19.PluginSidebarMoreMenuItem, { ...props });
11440 }
11441 function __experimentalPluginPostExcerpt() {
11442 if (isSiteEditor) {
11443 return null;
11444 }
11445 (0, import_deprecated3.default)("wp.editPost.__experimentalPluginPostExcerpt", {
11446 since: "6.6",
11447 hint: "Core and custom panels can be access programmatically using their panel name.",
11448 link: "https://developer.wordpress.org/block-editor/reference-guides/slotfills/plugin-document-setting-panel/#accessing-a-panel-programmatically"
11449 });
11450 return PluginPostExcerpt;
11451 }
11452
11453 // packages/edit-post/build-module/index.mjs
11454 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
11455 var {
11456 BackButton: __experimentalMainDashboardButton,
11457 registerCoreBlockBindingsSources
11458 } = unlock2(import_editor20.privateApis);
11459 var { enablePreloadMultiUse, clearPreloadedData } = unlock2(
11460 import_api_fetch2.default.privateApis
11461 );
11462 function initializeEditor(id, postType, postId, settings, initialEdits) {
11463 const isMediumOrBigger = window.matchMedia("(min-width: 782px)").matches;
11464 const target = document.getElementById(id);
11465 const root = (0, import_element26.createRoot)(target);
11466 (0, import_data26.dispatch)(import_preferences11.store).setDefaults("core/edit-post", {
11467 fullscreenMode: true,
11468 themeStyles: true,
11469 welcomeGuide: true,
11470 welcomeGuideTemplate: true
11471 });
11472 (0, import_data26.dispatch)(import_preferences11.store).setDefaults("core", {
11473 allowRightClickOverrides: true,
11474 editorMode: "visual",
11475 editorTool: "edit",
11476 fixedToolbar: false,
11477 hiddenBlockTypes: [],
11478 inactivePanels: [],
11479 openPanels: ["post-status"],
11480 showBlockBreadcrumbs: true,
11481 showIconLabels: false,
11482 showListViewByDefault: false,
11483 enableChoosePatternModal: true,
11484 isPublishSidebarEnabled: true,
11485 showCollaborationCursor: false,
11486 showCollaborationNotifications: true
11487 });
11488 if (window.__clientSideMediaProcessing) {
11489 (0, import_data26.dispatch)(import_preferences11.store).setDefaults("core/media", {
11490 requireApproval: true,
11491 optimizeOnUpload: true
11492 });
11493 }
11494 (0, import_data26.dispatch)(import_blocks3.store).reapplyBlockTypeFilters();
11495 if (isMediumOrBigger && (0, import_data26.select)(import_preferences11.store).get("core", "showListViewByDefault") && !(0, import_data26.select)(import_preferences11.store).get("core", "distractionFree")) {
11496 (0, import_data26.dispatch)(import_editor20.store).setIsListViewOpened(true);
11497 }
11498 (0, import_block_library2.registerCoreBlocks)();
11499 registerCoreBlockBindingsSources();
11500 (0, import_widgets.registerLegacyWidgetBlock)({ inserter: false });
11501 (0, import_widgets.registerWidgetGroupBlock)({ inserter: false });
11502 if (true) {
11503 (0, import_block_library2.__experimentalRegisterExperimentalCoreBlocks)({
11504 enableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks
11505 });
11506 }
11507 const documentMode = document.compatMode === "CSS1Compat" ? "Standards" : "Quirks";
11508 if (documentMode !== "Standards") {
11509 console.warn(
11510 "Your browser is using Quirks Mode. \nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins."
11511 );
11512 }
11513 const isIphone = window.navigator.userAgent.indexOf("iPhone") !== -1;
11514 if (isIphone) {
11515 window.addEventListener("scroll", (event) => {
11516 const editorScrollContainer = document.getElementsByClassName(
11517 "interface-interface-skeleton__body"
11518 )[0];
11519 if (event.target === document) {
11520 if (window.scrollY > 100) {
11521 editorScrollContainer.scrollTop = editorScrollContainer.scrollTop + window.scrollY;
11522 }
11523 if (document.getElementsByClassName("is-mode-visual")[0]) {
11524 window.scrollTo(0, 0);
11525 }
11526 }
11527 });
11528 }
11529 window.addEventListener("dragover", (e) => e.preventDefault(), false);
11530 window.addEventListener("drop", (e) => e.preventDefault(), false);
11531 enablePreloadMultiUse();
11532 const preloadedResolutions = preloadResolutions(postType, postId);
11533 preloadedResolutions.finally(() => {
11534 clearPreloadedData();
11535 if (postType && postId) {
11536 const post = (0, import_data26.select)(import_core_data9.store).getEntityRecord(
11537 "postType",
11538 postType,
11539 postId
11540 );
11541 if (post) {
11542 (0, import_data26.dispatch)(import_editor20.store).setupEditor(
11543 post,
11544 initialEdits,
11545 settings.template
11546 );
11547 }
11548 }
11549 root.render(
11550 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_element26.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
11551 layout_default,
11552 {
11553 settings,
11554 postId,
11555 postType,
11556 initialEdits
11557 }
11558 ) })
11559 );
11560 });
11561 return root;
11562 }
11563 async function preloadResolutions(postType, postId) {
11564 const core = (0, import_data26.resolveSelect)(import_core_data9.store);
11565 const coreSelect = (0, import_data26.select)(import_core_data9.store);
11566 try {
11567 await Promise.all([
11568 core.getCurrentUser(),
11569 core.getEntitiesConfig("postType"),
11570 core.getEntitiesConfig("taxonomy"),
11571 core.getEntitiesConfig("root"),
11572 core.getEntityRecords("root", "taxonomy"),
11573 core.getCurrentTheme(),
11574 // Forward-resolver alias of `getCurrentTheme` with its own
11575 // resolution metadata, so it needs a separate kick.
11576 core.getThemeSupports(),
11577 core.getBlockPatternCategories(),
11578 core.__experimentalGetCurrentGlobalStylesId(),
11579 core.__experimentalGetCurrentThemeBaseGlobalStyles(),
11580 core.__experimentalGetCurrentThemeGlobalStylesVariations(),
11581 core.getEntityRecord("root", "__unstableBase"),
11582 core.getEntityRecord("root", "site"),
11583 core.canUser("read", { kind: "root", name: "site" }),
11584 core.canUser("create", { kind: "postType", name: "attachment" }),
11585 core.canUser("create", { kind: "postType", name: "page" }),
11586 core.canUser("create", { kind: "postType", name: "wp_block" }),
11587 core.canUser("create", {
11588 kind: "postType",
11589 name: "wp_template"
11590 }),
11591 // Per-post resolvers. `getPostType` and `getEditedEntityRecord`
11592 // are shorthand/forward-resolver aliases with their own
11593 // resolution metadata, so they need separate kicks.
11594 ...postType && postId ? [
11595 core.getPostType(postType),
11596 core.getEntityRecord("postType", postType, postId),
11597 core.getEditedEntityRecord(
11598 "postType",
11599 postType,
11600 postId
11601 ),
11602 core.getAutosaves(postType, postId),
11603 core.getDefaultTemplateId({ slug: "front-page" }),
11604 core.canUser("create", {
11605 kind: "postType",
11606 name: postType
11607 })
11608 ] : []
11609 ]);
11610 const tasks = [];
11611 const globalStylesId = coreSelect.__experimentalGetCurrentGlobalStylesId();
11612 if (globalStylesId) {
11613 tasks.push(
11614 core.getEntityRecord("root", "globalStyles", globalStylesId),
11615 core.canUser("read", {
11616 kind: "root",
11617 name: "globalStyles",
11618 id: globalStylesId
11619 })
11620 );
11621 }
11622 if (postType && postId) {
11623 const post = coreSelect.getEntityRecord(
11624 "postType",
11625 postType,
11626 postId
11627 );
11628 if (post) {
11629 let slug = "page" === postType ? "page" : "single-" + postType;
11630 if (post.slug) {
11631 slug += "-" + post.slug;
11632 }
11633 tasks.push(core.getDefaultTemplateId({ slug }));
11634 if (post.author) {
11635 tasks.push(
11636 core.getUser(post.author, {
11637 context: "view",
11638 _fields: "id,name"
11639 })
11640 );
11641 }
11642 }
11643 }
11644 if (tasks.length) {
11645 await Promise.all(tasks);
11646 }
11647 } catch {
11648 }
11649 }
11650 function reinitializeEditor() {
11651 (0, import_deprecated4.default)("wp.editPost.reinitializeEditor", {
11652 since: "6.2",
11653 version: "6.3"
11654 });
11655 }
11656 return __toCommonJS(index_exports);
11657 })();
11658 /*! Bundled license information:
11659
11660 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
11661 (**
11662 * @license React
11663 * use-sync-external-store-shim.development.js
11664 *
11665 * Copyright (c) Meta Platforms, Inc. and affiliates.
11666 *
11667 * This source code is licensed under the MIT license found in the
11668 * LICENSE file in the root directory of this source tree.
11669 *)
11670
11671 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
11672 (**
11673 * @license React
11674 * use-sync-external-store-shim/with-selector.development.js
11675 *
11676 * Copyright (c) Meta Platforms, Inc. and affiliates.
11677 *
11678 * This source code is licensed under the MIT license found in the
11679 * LICENSE file in the root directory of this source tree.
11680 *)
11681 */
11682 //# sourceMappingURL=index.js.map
11683