PluginProbe
Gutenberg / 23.5.1
Gutenberg v23.5.1
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 / block-directory / index.js

index.js in Gutenberg 23.5.1, at build/scripts/block-directory/index.js

10,171 lines 369.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var wp;
2 (wp ||= {}).blockDirectory = (() => {
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/plugins
35 var require_plugins = __commonJS({
36 "package-external:@wordpress/plugins"(exports, module) {
37 module.exports = window.wp.plugins;
38 }
39 });
40
41 // package-external:@wordpress/hooks
42 var require_hooks = __commonJS({
43 "package-external:@wordpress/hooks"(exports, module) {
44 module.exports = window.wp.hooks;
45 }
46 });
47
48 // package-external:@wordpress/blocks
49 var require_blocks = __commonJS({
50 "package-external:@wordpress/blocks"(exports, module) {
51 module.exports = window.wp.blocks;
52 }
53 });
54
55 // package-external:@wordpress/data
56 var require_data = __commonJS({
57 "package-external:@wordpress/data"(exports, module) {
58 module.exports = window.wp.data;
59 }
60 });
61
62 // package-external:@wordpress/element
63 var require_element = __commonJS({
64 "package-external:@wordpress/element"(exports, module) {
65 module.exports = window.wp.element;
66 }
67 });
68
69 // package-external:@wordpress/editor
70 var require_editor = __commonJS({
71 "package-external:@wordpress/editor"(exports, module) {
72 module.exports = window.wp.editor;
73 }
74 });
75
76 // package-external:@wordpress/block-editor
77 var require_block_editor = __commonJS({
78 "package-external:@wordpress/block-editor"(exports, module) {
79 module.exports = window.wp.blockEditor;
80 }
81 });
82
83 // package-external:@wordpress/i18n
84 var require_i18n = __commonJS({
85 "package-external:@wordpress/i18n"(exports, module) {
86 module.exports = window.wp.i18n;
87 }
88 });
89
90 // package-external:@wordpress/api-fetch
91 var require_api_fetch = __commonJS({
92 "package-external:@wordpress/api-fetch"(exports, module) {
93 module.exports = window.wp.apiFetch;
94 }
95 });
96
97 // package-external:@wordpress/notices
98 var require_notices = __commonJS({
99 "package-external:@wordpress/notices"(exports, module) {
100 module.exports = window.wp.notices;
101 }
102 });
103
104 // package-external:@wordpress/url
105 var require_url = __commonJS({
106 "package-external:@wordpress/url"(exports, module) {
107 module.exports = window.wp.url;
108 }
109 });
110
111 // package-external:@wordpress/compose
112 var require_compose = __commonJS({
113 "package-external:@wordpress/compose"(exports, module) {
114 module.exports = window.wp.compose;
115 }
116 });
117
118 // package-external:@wordpress/components
119 var require_components = __commonJS({
120 "package-external:@wordpress/components"(exports, module) {
121 module.exports = window.wp.components;
122 }
123 });
124
125 // package-external:@wordpress/core-data
126 var require_core_data = __commonJS({
127 "package-external:@wordpress/core-data"(exports, module) {
128 module.exports = window.wp.coreData;
129 }
130 });
131
132 // package-external:@wordpress/html-entities
133 var require_html_entities = __commonJS({
134 "package-external:@wordpress/html-entities"(exports, module) {
135 module.exports = window.wp.htmlEntities;
136 }
137 });
138
139 // vendor-external:react
140 var require_react = __commonJS({
141 "vendor-external:react"(exports, module) {
142 module.exports = window.React;
143 }
144 });
145
146 // vendor-external:react/jsx-runtime
147 var require_jsx_runtime = __commonJS({
148 "vendor-external:react/jsx-runtime"(exports, module) {
149 module.exports = window.ReactJSXRuntime;
150 }
151 });
152
153 // vendor-external:react-dom
154 var require_react_dom = __commonJS({
155 "vendor-external:react-dom"(exports, module) {
156 module.exports = window.ReactDOM;
157 }
158 });
159
160 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
161 var require_use_sync_external_store_shim_development = __commonJS({
162 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
163 "use strict";
164 (function() {
165 function is(x, y) {
166 return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
167 }
168 function useSyncExternalStore$2(subscribe, getSnapshot) {
169 didWarnOld18Alpha || void 0 === React47.startTransition || (didWarnOld18Alpha = true, console.error(
170 "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."
171 ));
172 var value = getSnapshot();
173 if (!didWarnUncachedGetSnapshot) {
174 var cachedValue = getSnapshot();
175 objectIs(value, cachedValue) || (console.error(
176 "The result of getSnapshot should be cached to avoid an infinite loop"
177 ), didWarnUncachedGetSnapshot = true);
178 }
179 cachedValue = useState13({
180 inst: { value, getSnapshot }
181 });
182 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
183 useLayoutEffect3(
184 function() {
185 inst.value = value;
186 inst.getSnapshot = getSnapshot;
187 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
188 },
189 [subscribe, value, getSnapshot]
190 );
191 useEffect13(
192 function() {
193 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
194 return subscribe(function() {
195 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
196 });
197 },
198 [subscribe]
199 );
200 useDebugValue2(value);
201 return value;
202 }
203 function checkIfSnapshotChanged(inst) {
204 var latestGetSnapshot = inst.getSnapshot;
205 inst = inst.value;
206 try {
207 var nextValue = latestGetSnapshot();
208 return !objectIs(inst, nextValue);
209 } catch (error) {
210 return true;
211 }
212 }
213 function useSyncExternalStore$1(subscribe, getSnapshot) {
214 return getSnapshot();
215 }
216 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
217 var React47 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState13 = React47.useState, useEffect13 = React47.useEffect, useLayoutEffect3 = React47.useLayoutEffect, useDebugValue2 = React47.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
218 exports.useSyncExternalStore = void 0 !== React47.useSyncExternalStore ? React47.useSyncExternalStore : shim;
219 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
220 })();
221 }
222 });
223
224 // node_modules/use-sync-external-store/shim/index.js
225 var require_shim = __commonJS({
226 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
227 "use strict";
228 if (false) {
229 module.exports = null;
230 } else {
231 module.exports = require_use_sync_external_store_shim_development();
232 }
233 }
234 });
235
236 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
237 var require_with_selector_development = __commonJS({
238 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
239 "use strict";
240 (function() {
241 function is(x, y) {
242 return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
243 }
244 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
245 var React47 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore2 = shim.useSyncExternalStore, useRef19 = React47.useRef, useEffect13 = React47.useEffect, useMemo15 = React47.useMemo, useDebugValue2 = React47.useDebugValue;
246 exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
247 var instRef = useRef19(null);
248 if (null === instRef.current) {
249 var inst = { hasValue: false, value: null };
250 instRef.current = inst;
251 } else inst = instRef.current;
252 instRef = useMemo15(
253 function() {
254 function memoizedSelector(nextSnapshot) {
255 if (!hasMemo) {
256 hasMemo = true;
257 memoizedSnapshot = nextSnapshot;
258 nextSnapshot = selector(nextSnapshot);
259 if (void 0 !== isEqual && inst.hasValue) {
260 var currentSelection = inst.value;
261 if (isEqual(currentSelection, nextSnapshot))
262 return memoizedSelection = currentSelection;
263 }
264 return memoizedSelection = nextSnapshot;
265 }
266 currentSelection = memoizedSelection;
267 if (objectIs(memoizedSnapshot, nextSnapshot))
268 return currentSelection;
269 var nextSelection = selector(nextSnapshot);
270 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
271 return memoizedSnapshot = nextSnapshot, currentSelection;
272 memoizedSnapshot = nextSnapshot;
273 return memoizedSelection = nextSelection;
274 }
275 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
276 return [
277 function() {
278 return memoizedSelector(getSnapshot());
279 },
280 null === maybeGetServerSnapshot ? void 0 : function() {
281 return memoizedSelector(maybeGetServerSnapshot());
282 }
283 ];
284 },
285 [getSnapshot, getServerSnapshot, selector, isEqual]
286 );
287 var value = useSyncExternalStore2(subscribe, instRef[0], instRef[1]);
288 useEffect13(
289 function() {
290 inst.hasValue = true;
291 inst.value = value;
292 },
293 [value]
294 );
295 useDebugValue2(value);
296 return value;
297 };
298 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
299 })();
300 }
301 });
302
303 // node_modules/use-sync-external-store/shim/with-selector.js
304 var require_with_selector = __commonJS({
305 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
306 "use strict";
307 if (false) {
308 module.exports = null;
309 } else {
310 module.exports = require_with_selector_development();
311 }
312 }
313 });
314
315 // package-external:@wordpress/a11y
316 var require_a11y = __commonJS({
317 "package-external:@wordpress/a11y"(exports, module) {
318 module.exports = window.wp.a11y;
319 }
320 });
321
322 // package-external:@wordpress/primitives
323 var require_primitives = __commonJS({
324 "package-external:@wordpress/primitives"(exports, module) {
325 module.exports = window.wp.primitives;
326 }
327 });
328
329 // package-external:@wordpress/theme
330 var require_theme = __commonJS({
331 "package-external:@wordpress/theme"(exports, module) {
332 module.exports = window.wp.theme;
333 }
334 });
335
336 // package-external:@wordpress/private-apis
337 var require_private_apis = __commonJS({
338 "package-external:@wordpress/private-apis"(exports, module) {
339 module.exports = window.wp.privateApis;
340 }
341 });
342
343 // packages/block-directory/build-module/index.mjs
344 var index_exports = {};
345 __export(index_exports, {
346 store: () => store
347 });
348
349 // packages/block-directory/build-module/plugins/index.mjs
350 var import_plugins = __toESM(require_plugins(), 1);
351 var import_hooks = __toESM(require_hooks(), 1);
352
353 // packages/block-directory/build-module/components/auto-block-uninstaller/index.mjs
354 var import_blocks2 = __toESM(require_blocks(), 1);
355 var import_data4 = __toESM(require_data(), 1);
356 var import_element = __toESM(require_element(), 1);
357 var import_editor = __toESM(require_editor(), 1);
358
359 // packages/block-directory/build-module/store/index.mjs
360 var import_data3 = __toESM(require_data(), 1);
361
362 // packages/block-directory/build-module/store/reducer.mjs
363 var import_data = __toESM(require_data(), 1);
364 var downloadableBlocks = (state = {}, action) => {
365 switch (action.type) {
366 case "FETCH_DOWNLOADABLE_BLOCKS":
367 return {
368 ...state,
369 [action.filterValue]: {
370 isRequesting: true
371 }
372 };
373 case "RECEIVE_DOWNLOADABLE_BLOCKS":
374 return {
375 ...state,
376 [action.filterValue]: {
377 results: action.downloadableBlocks,
378 isRequesting: false
379 }
380 };
381 }
382 return state;
383 };
384 var blockManagement = (state = {
385 installedBlockTypes: [],
386 isInstalling: {}
387 }, action) => {
388 switch (action.type) {
389 case "ADD_INSTALLED_BLOCK_TYPE":
390 return {
391 ...state,
392 installedBlockTypes: [
393 ...state.installedBlockTypes,
394 action.item
395 ]
396 };
397 case "REMOVE_INSTALLED_BLOCK_TYPE":
398 return {
399 ...state,
400 installedBlockTypes: state.installedBlockTypes.filter(
401 (blockType) => blockType.name !== action.item.name
402 )
403 };
404 case "SET_INSTALLING_BLOCK":
405 return {
406 ...state,
407 isInstalling: {
408 ...state.isInstalling,
409 [action.blockId]: action.isInstalling
410 }
411 };
412 }
413 return state;
414 };
415 var errorNotices = (state = {}, action) => {
416 switch (action.type) {
417 case "SET_ERROR_NOTICE":
418 return {
419 ...state,
420 [action.blockId]: {
421 message: action.message,
422 isFatal: action.isFatal
423 }
424 };
425 case "CLEAR_ERROR_NOTICE":
426 const { [action.blockId]: blockId, ...restState } = state;
427 return restState;
428 }
429 return state;
430 };
431 var reducer_default = (0, import_data.combineReducers)({
432 downloadableBlocks,
433 blockManagement,
434 errorNotices
435 });
436
437 // packages/block-directory/build-module/store/selectors.mjs
438 var selectors_exports = {};
439 __export(selectors_exports, {
440 getDownloadableBlocks: () => getDownloadableBlocks,
441 getErrorNoticeForBlock: () => getErrorNoticeForBlock,
442 getErrorNotices: () => getErrorNotices,
443 getInstalledBlockTypes: () => getInstalledBlockTypes,
444 getNewBlockTypes: () => getNewBlockTypes,
445 getUnusedBlockTypes: () => getUnusedBlockTypes,
446 isInstalling: () => isInstalling,
447 isRequestingDownloadableBlocks: () => isRequestingDownloadableBlocks
448 });
449 var import_data2 = __toESM(require_data(), 1);
450 var import_block_editor = __toESM(require_block_editor(), 1);
451 var EMPTY_ARRAY = [];
452 function isRequestingDownloadableBlocks(state, filterValue) {
453 return state.downloadableBlocks[filterValue]?.isRequesting ?? false;
454 }
455 function getDownloadableBlocks(state, filterValue) {
456 return state.downloadableBlocks[filterValue]?.results ?? EMPTY_ARRAY;
457 }
458 function getInstalledBlockTypes(state) {
459 return state.blockManagement.installedBlockTypes;
460 }
461 var getNewBlockTypes = (0, import_data2.createRegistrySelector)(
462 (select) => (0, import_data2.createSelector)(
463 (state) => {
464 const installedBlockTypes = getInstalledBlockTypes(state);
465 if (!installedBlockTypes.length) {
466 return EMPTY_ARRAY;
467 }
468 const { getBlockName, getClientIdsWithDescendants } = select(import_block_editor.store);
469 const installedBlockNames = installedBlockTypes.map(
470 (blockType) => blockType.name
471 );
472 const foundBlockNames = getClientIdsWithDescendants().flatMap(
473 (clientId) => {
474 const blockName = getBlockName(clientId);
475 return installedBlockNames.includes(blockName) ? blockName : [];
476 }
477 );
478 const newBlockTypes = installedBlockTypes.filter(
479 (blockType) => foundBlockNames.includes(blockType.name)
480 );
481 return newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY;
482 },
483 (state) => [
484 getInstalledBlockTypes(state),
485 select(import_block_editor.store).getClientIdsWithDescendants()
486 ]
487 )
488 );
489 var getUnusedBlockTypes = (0, import_data2.createRegistrySelector)(
490 (select) => (0, import_data2.createSelector)(
491 (state) => {
492 const installedBlockTypes = getInstalledBlockTypes(state);
493 if (!installedBlockTypes.length) {
494 return EMPTY_ARRAY;
495 }
496 const { getBlockName, getClientIdsWithDescendants } = select(import_block_editor.store);
497 const installedBlockNames = installedBlockTypes.map(
498 (blockType) => blockType.name
499 );
500 const foundBlockNames = getClientIdsWithDescendants().flatMap(
501 (clientId) => {
502 const blockName = getBlockName(clientId);
503 return installedBlockNames.includes(blockName) ? blockName : [];
504 }
505 );
506 const unusedBlockTypes = installedBlockTypes.filter(
507 (blockType) => !foundBlockNames.includes(blockType.name)
508 );
509 return unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;
510 },
511 (state) => [
512 getInstalledBlockTypes(state),
513 select(import_block_editor.store).getClientIdsWithDescendants()
514 ]
515 )
516 );
517 function isInstalling(state, blockId) {
518 return state.blockManagement.isInstalling[blockId] || false;
519 }
520 function getErrorNotices(state) {
521 return state.errorNotices;
522 }
523 function getErrorNoticeForBlock(state, blockId) {
524 return state.errorNotices[blockId];
525 }
526
527 // packages/block-directory/build-module/store/actions.mjs
528 var actions_exports = {};
529 __export(actions_exports, {
530 addInstalledBlockType: () => addInstalledBlockType,
531 clearErrorNotice: () => clearErrorNotice,
532 fetchDownloadableBlocks: () => fetchDownloadableBlocks,
533 installBlockType: () => installBlockType,
534 receiveDownloadableBlocks: () => receiveDownloadableBlocks,
535 removeInstalledBlockType: () => removeInstalledBlockType,
536 setErrorNotice: () => setErrorNotice,
537 setIsInstalling: () => setIsInstalling,
538 uninstallBlockType: () => uninstallBlockType
539 });
540 var import_blocks = __toESM(require_blocks(), 1);
541 var import_i18n = __toESM(require_i18n(), 1);
542 var import_api_fetch2 = __toESM(require_api_fetch(), 1);
543 var import_notices = __toESM(require_notices(), 1);
544 var import_url = __toESM(require_url(), 1);
545
546 // packages/block-directory/build-module/store/load-assets.mjs
547 var import_api_fetch = __toESM(require_api_fetch(), 1);
548 var loadAsset = (el) => {
549 return new Promise((resolve, reject) => {
550 const newNode = document.createElement(el.nodeName);
551 ["id", "rel", "src", "href", "type"].forEach((attr2) => {
552 if (el[attr2]) {
553 newNode[attr2] = el[attr2];
554 }
555 });
556 if (el.innerHTML) {
557 newNode.appendChild(document.createTextNode(el.innerHTML));
558 }
559 newNode.onload = () => resolve(true);
560 newNode.onerror = () => reject(new Error("Error loading asset."));
561 document.body.appendChild(newNode);
562 if ("link" === newNode.nodeName.toLowerCase() || "script" === newNode.nodeName.toLowerCase() && !newNode.src) {
563 resolve();
564 }
565 });
566 };
567 async function loadAssets() {
568 const response = await (0, import_api_fetch.default)({
569 url: document.location.href,
570 parse: false
571 });
572 const data = await response.text();
573 const doc = new window.DOMParser().parseFromString(data, "text/html");
574 const newAssets = Array.from(
575 doc.querySelectorAll('link[rel="stylesheet"],script')
576 ).filter((asset) => asset.id && !document.getElementById(asset.id));
577 for (const newAsset of newAssets) {
578 await loadAsset(newAsset);
579 }
580 }
581
582 // packages/block-directory/build-module/store/utils/get-plugin-url.mjs
583 function getPluginUrl(block) {
584 if (!block) {
585 return false;
586 }
587 const link = block.links["wp:plugin"] || block.links.self;
588 if (link && link.length) {
589 return link[0].href;
590 }
591 return false;
592 }
593
594 // packages/block-directory/build-module/store/actions.mjs
595 function fetchDownloadableBlocks(filterValue) {
596 return { type: "FETCH_DOWNLOADABLE_BLOCKS", filterValue };
597 }
598 function receiveDownloadableBlocks(downloadableBlocks2, filterValue) {
599 return {
600 type: "RECEIVE_DOWNLOADABLE_BLOCKS",
601 downloadableBlocks: downloadableBlocks2,
602 filterValue
603 };
604 }
605 var installBlockType = (block) => async ({ registry, dispatch }) => {
606 const { id, name } = block;
607 let success = false;
608 dispatch.clearErrorNotice(id);
609 try {
610 dispatch.setIsInstalling(id, true);
611 const url = getPluginUrl(block);
612 let links = {};
613 if (url) {
614 await (0, import_api_fetch2.default)({
615 method: "PUT",
616 url,
617 data: { status: "active" }
618 });
619 } else {
620 const response = await (0, import_api_fetch2.default)({
621 method: "POST",
622 path: "wp/v2/plugins",
623 data: { slug: id, status: "active" }
624 });
625 links = response._links;
626 }
627 dispatch.addInstalledBlockType({
628 ...block,
629 links: { ...block.links, ...links }
630 });
631 const metadataFields = [
632 "api_version",
633 "title",
634 "category",
635 "parent",
636 "ancestor",
637 "icon",
638 "description",
639 "keywords",
640 "attributes",
641 "provides_context",
642 "uses_context",
643 "selectors",
644 "supports",
645 "styles",
646 "example",
647 "variations",
648 "allowed_blocks",
649 "block_hooks"
650 ];
651 await (0, import_api_fetch2.default)({
652 path: (0, import_url.addQueryArgs)(`/wp/v2/block-types/${name}`, {
653 _fields: metadataFields
654 })
655 }).catch(() => {
656 }).then((response) => {
657 if (!response) {
658 return;
659 }
660 (0, import_blocks.unstable__bootstrapServerSideBlockDefinitions)({
661 [name]: Object.fromEntries(
662 Object.entries(response).filter(
663 ([key]) => metadataFields.includes(key)
664 )
665 )
666 });
667 });
668 await loadAssets();
669 const registeredBlocks = registry.select(import_blocks.store).getBlockTypes();
670 if (!registeredBlocks.some((i) => i.name === name)) {
671 throw new Error(
672 (0, import_i18n.__)("Error registering block. Try reloading the page.")
673 );
674 }
675 registry.dispatch(import_notices.store).createInfoNotice(
676 (0, import_i18n.sprintf)(
677 // translators: %s is the block title.
678 (0, import_i18n.__)("Block %s installed and added."),
679 block.title
680 ),
681 {
682 speak: true,
683 type: "snackbar"
684 }
685 );
686 success = true;
687 } catch (error) {
688 let message = error.message || (0, import_i18n.__)("An error occurred.");
689 let isFatal = error instanceof Error;
690 const fatalAPIErrors = {
691 folder_exists: (0, import_i18n.__)(
692 "This block is already installed. Try reloading the page."
693 ),
694 unable_to_connect_to_filesystem: (0, import_i18n.__)(
695 "Error installing block. You can reload the page and try again."
696 )
697 };
698 if (fatalAPIErrors[error.code]) {
699 isFatal = true;
700 message = fatalAPIErrors[error.code];
701 }
702 dispatch.setErrorNotice(id, message, isFatal);
703 registry.dispatch(import_notices.store).createErrorNotice(message, {
704 speak: true,
705 isDismissible: true
706 });
707 }
708 dispatch.setIsInstalling(id, false);
709 return success;
710 };
711 var uninstallBlockType = (block) => async ({ registry, dispatch }) => {
712 try {
713 const url = getPluginUrl(block);
714 await (0, import_api_fetch2.default)({
715 method: "PUT",
716 url,
717 data: { status: "inactive" }
718 });
719 await (0, import_api_fetch2.default)({
720 method: "DELETE",
721 url
722 });
723 dispatch.removeInstalledBlockType(block);
724 } catch (error) {
725 registry.dispatch(import_notices.store).createErrorNotice(
726 error.message || (0, import_i18n.__)("An error occurred.")
727 );
728 }
729 };
730 function addInstalledBlockType(item) {
731 return {
732 type: "ADD_INSTALLED_BLOCK_TYPE",
733 item
734 };
735 }
736 function removeInstalledBlockType(item) {
737 return {
738 type: "REMOVE_INSTALLED_BLOCK_TYPE",
739 item
740 };
741 }
742 function setIsInstalling(blockId, isInstalling2) {
743 return {
744 type: "SET_INSTALLING_BLOCK",
745 blockId,
746 isInstalling: isInstalling2
747 };
748 }
749 function setErrorNotice(blockId, message, isFatal = false) {
750 return {
751 type: "SET_ERROR_NOTICE",
752 blockId,
753 message,
754 isFatal
755 };
756 }
757 function clearErrorNotice(blockId) {
758 return {
759 type: "CLEAR_ERROR_NOTICE",
760 blockId
761 };
762 }
763
764 // packages/block-directory/build-module/store/resolvers.mjs
765 var resolvers_exports = {};
766 __export(resolvers_exports, {
767 getDownloadableBlocks: () => getDownloadableBlocks2
768 });
769
770 // node_modules/tslib/tslib.es6.mjs
771 var __assign = function() {
772 __assign = Object.assign || function __assign2(t) {
773 for (var s, i = 1, n = arguments.length; i < n; i++) {
774 s = arguments[i];
775 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
776 }
777 return t;
778 };
779 return __assign.apply(this, arguments);
780 };
781
782 // node_modules/lower-case/dist.es2015/index.js
783 function lowerCase(str) {
784 return str.toLowerCase();
785 }
786
787 // node_modules/no-case/dist.es2015/index.js
788 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
789 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
790 function noCase(input, options) {
791 if (options === void 0) {
792 options = {};
793 }
794 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
795 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
796 var start = 0;
797 var end = result.length;
798 while (result.charAt(start) === "\0")
799 start++;
800 while (result.charAt(end - 1) === "\0")
801 end--;
802 return result.slice(start, end).split("\0").map(transform).join(delimiter);
803 }
804 function replace(input, re, value) {
805 if (re instanceof RegExp)
806 return input.replace(re, value);
807 return re.reduce(function(input2, re2) {
808 return input2.replace(re2, value);
809 }, input);
810 }
811
812 // node_modules/pascal-case/dist.es2015/index.js
813 function pascalCaseTransform(input, index2) {
814 var firstChar = input.charAt(0);
815 var lowerChars = input.substr(1).toLowerCase();
816 if (index2 > 0 && firstChar >= "0" && firstChar <= "9") {
817 return "_" + firstChar + lowerChars;
818 }
819 return "" + firstChar.toUpperCase() + lowerChars;
820 }
821 function pascalCase(input, options) {
822 if (options === void 0) {
823 options = {};
824 }
825 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
826 }
827
828 // node_modules/camel-case/dist.es2015/index.js
829 function camelCaseTransform(input, index2) {
830 if (index2 === 0)
831 return input.toLowerCase();
832 return pascalCaseTransform(input, index2);
833 }
834 function camelCase(input, options) {
835 if (options === void 0) {
836 options = {};
837 }
838 return pascalCase(input, __assign({ transform: camelCaseTransform }, options));
839 }
840
841 // packages/block-directory/build-module/store/resolvers.mjs
842 var import_api_fetch3 = __toESM(require_api_fetch(), 1);
843 var getDownloadableBlocks2 = (filterValue) => async ({ dispatch }) => {
844 if (!filterValue) {
845 return;
846 }
847 try {
848 dispatch(fetchDownloadableBlocks(filterValue));
849 const results = await (0, import_api_fetch3.default)({
850 path: `wp/v2/block-directory/search?term=${filterValue}`
851 });
852 const blocks = results.map(
853 (result) => Object.fromEntries(
854 Object.entries(result).map(([key, value]) => [
855 camelCase(key),
856 value
857 ])
858 )
859 );
860 dispatch(receiveDownloadableBlocks(blocks, filterValue));
861 } catch {
862 dispatch(receiveDownloadableBlocks([], filterValue));
863 }
864 };
865
866 // packages/block-directory/build-module/store/index.mjs
867 var STORE_NAME = "core/block-directory";
868 var storeConfig = {
869 reducer: reducer_default,
870 selectors: selectors_exports,
871 actions: actions_exports,
872 resolvers: resolvers_exports
873 };
874 var store = (0, import_data3.createReduxStore)(STORE_NAME, storeConfig);
875 (0, import_data3.register)(store);
876
877 // packages/block-directory/build-module/components/auto-block-uninstaller/index.mjs
878 function AutoBlockUninstaller() {
879 const { uninstallBlockType: uninstallBlockType2 } = (0, import_data4.useDispatch)(store);
880 const shouldRemoveBlockTypes = (0, import_data4.useSelect)((select) => {
881 const { isAutosavingPost, isSavingPost } = select(import_editor.store);
882 return isSavingPost() && !isAutosavingPost();
883 }, []);
884 const unusedBlockTypes = (0, import_data4.useSelect)(
885 (select) => select(store).getUnusedBlockTypes(),
886 []
887 );
888 (0, import_element.useEffect)(() => {
889 if (shouldRemoveBlockTypes && unusedBlockTypes.length) {
890 unusedBlockTypes.forEach((blockType) => {
891 uninstallBlockType2(blockType);
892 (0, import_blocks2.unregisterBlockType)(blockType.name);
893 });
894 }
895 }, [shouldRemoveBlockTypes]);
896 return null;
897 }
898
899 // packages/block-directory/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs
900 var import_block_editor3 = __toESM(require_block_editor(), 1);
901 var import_compose = __toESM(require_compose(), 1);
902 var import_element20 = __toESM(require_element(), 1);
903
904 // packages/block-directory/build-module/components/downloadable-blocks-panel/index.mjs
905 var import_i18n8 = __toESM(require_i18n(), 1);
906 var import_components4 = __toESM(require_components(), 1);
907 var import_core_data = __toESM(require_core_data(), 1);
908 var import_data8 = __toESM(require_data(), 1);
909 var import_blocks5 = __toESM(require_blocks(), 1);
910
911 // packages/block-directory/build-module/components/downloadable-blocks-list/index.mjs
912 var import_i18n5 = __toESM(require_i18n(), 1);
913 var import_components2 = __toESM(require_components(), 1);
914 var import_blocks4 = __toESM(require_blocks(), 1);
915 var import_data7 = __toESM(require_data(), 1);
916
917 // node_modules/clsx/dist/clsx.mjs
918 function r(e) {
919 var t, f, n = "";
920 if ("string" == typeof e || "number" == typeof e) n += e;
921 else if ("object" == typeof e) if (Array.isArray(e)) {
922 var o = e.length;
923 for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
924 } else for (f in e) e[f] && (n && (n += " "), n += f);
925 return n;
926 }
927 function clsx() {
928 for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
929 return n;
930 }
931 var clsx_default = clsx;
932
933 // packages/block-directory/build-module/components/downloadable-block-list-item/index.mjs
934 var import_i18n4 = __toESM(require_i18n(), 1);
935 var import_components = __toESM(require_components(), 1);
936 var import_element18 = __toESM(require_element(), 1);
937 var import_html_entities = __toESM(require_html_entities(), 1);
938 var import_blocks3 = __toESM(require_blocks(), 1);
939 var import_data6 = __toESM(require_data(), 1);
940
941 // node_modules/@base-ui/utils/esm/safeReact.js
942 var React = __toESM(require_react(), 1);
943 var SafeReact = {
944 ...React
945 };
946
947 // node_modules/@base-ui/utils/esm/useRefWithInit.js
948 var React2 = __toESM(require_react(), 1);
949 var UNINITIALIZED = {};
950 function useRefWithInit(init, initArg) {
951 const ref = React2.useRef(UNINITIALIZED);
952 if (ref.current === UNINITIALIZED) {
953 ref.current = init(initArg);
954 }
955 return ref;
956 }
957
958 // node_modules/@base-ui/utils/esm/useStableCallback.js
959 var useInsertionEffect = SafeReact.useInsertionEffect;
960 var useSafeInsertionEffect = (
961 // React 17 doesn't have useInsertionEffect.
962 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
963 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
964 );
965 function useStableCallback(callback) {
966 const stable = useRefWithInit(createStableCallback).current;
967 stable.next = callback;
968 useSafeInsertionEffect(stable.effect);
969 return stable.trampoline;
970 }
971 function createStableCallback() {
972 const stable = {
973 next: void 0,
974 callback: assertNotCalled,
975 trampoline: (...args) => stable.callback?.(...args),
976 effect: () => {
977 stable.callback = stable.next;
978 }
979 };
980 return stable;
981 }
982 function assertNotCalled() {
983 if (true) {
984 throw (
985 /* minify-error-disabled */
986 new Error("Base UI: Cannot call an event handler while rendering.")
987 );
988 }
989 }
990
991 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
992 var React3 = __toESM(require_react(), 1);
993 var noop = () => {
994 };
995 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
996
997 // node_modules/@base-ui/utils/esm/warn.js
998 var set;
999 if (true) {
1000 set = /* @__PURE__ */ new Set();
1001 }
1002 function warn(...messages) {
1003 if (true) {
1004 const messageKey = messages.join(" ");
1005 if (!set.has(messageKey)) {
1006 set.add(messageKey);
1007 console.warn(`Base UI: ${messageKey}`);
1008 }
1009 }
1010 }
1011
1012 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1013 var React4 = __toESM(require_react(), 1);
1014 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
1015 if (true) DirectionContext.displayName = "DirectionContext";
1016 function useDirection() {
1017 const context = React4.useContext(DirectionContext);
1018 return context?.direction ?? "ltr";
1019 }
1020
1021 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1022 var React7 = __toESM(require_react(), 1);
1023
1024 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1025 function useMergedRefs(a, b, c, d) {
1026 const forkRef = useRefWithInit(createForkRef).current;
1027 if (didChange(forkRef, a, b, c, d)) {
1028 update(forkRef, [a, b, c, d]);
1029 }
1030 return forkRef.callback;
1031 }
1032 function useMergedRefsN(refs) {
1033 const forkRef = useRefWithInit(createForkRef).current;
1034 if (didChangeN(forkRef, refs)) {
1035 update(forkRef, refs);
1036 }
1037 return forkRef.callback;
1038 }
1039 function createForkRef() {
1040 return {
1041 callback: null,
1042 cleanup: null,
1043 refs: []
1044 };
1045 }
1046 function didChange(forkRef, a, b, c, d) {
1047 return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
1048 }
1049 function didChangeN(forkRef, newRefs) {
1050 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1051 }
1052 function update(forkRef, refs) {
1053 forkRef.refs = refs;
1054 if (refs.every((ref) => ref == null)) {
1055 forkRef.callback = null;
1056 return;
1057 }
1058 forkRef.callback = (instance) => {
1059 if (forkRef.cleanup) {
1060 forkRef.cleanup();
1061 forkRef.cleanup = null;
1062 }
1063 if (instance != null) {
1064 const cleanupCallbacks = Array(refs.length).fill(null);
1065 for (let i = 0; i < refs.length; i += 1) {
1066 const ref = refs[i];
1067 if (ref == null) {
1068 continue;
1069 }
1070 switch (typeof ref) {
1071 case "function": {
1072 const refCleanup = ref(instance);
1073 if (typeof refCleanup === "function") {
1074 cleanupCallbacks[i] = refCleanup;
1075 }
1076 break;
1077 }
1078 case "object": {
1079 ref.current = instance;
1080 break;
1081 }
1082 default:
1083 }
1084 }
1085 forkRef.cleanup = () => {
1086 for (let i = 0; i < refs.length; i += 1) {
1087 const ref = refs[i];
1088 if (ref == null) {
1089 continue;
1090 }
1091 switch (typeof ref) {
1092 case "function": {
1093 const cleanupCallback = cleanupCallbacks[i];
1094 if (typeof cleanupCallback === "function") {
1095 cleanupCallback();
1096 } else {
1097 ref(null);
1098 }
1099 break;
1100 }
1101 case "object": {
1102 ref.current = null;
1103 break;
1104 }
1105 default:
1106 }
1107 }
1108 };
1109 }
1110 };
1111 }
1112
1113 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1114 var React6 = __toESM(require_react(), 1);
1115
1116 // node_modules/@base-ui/utils/esm/reactVersion.js
1117 var React5 = __toESM(require_react(), 1);
1118 var majorVersion = parseInt(React5.version, 10);
1119 function isReactVersionAtLeast(reactVersionToCheck) {
1120 return majorVersion >= reactVersionToCheck;
1121 }
1122
1123 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1124 function getReactElementRef(element) {
1125 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1126 return null;
1127 }
1128 const reactElement = element;
1129 const propsWithRef = reactElement.props;
1130 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1131 }
1132
1133 // node_modules/@base-ui/utils/esm/mergeObjects.js
1134 function mergeObjects(a, b) {
1135 if (a && !b) {
1136 return a;
1137 }
1138 if (!a && b) {
1139 return b;
1140 }
1141 if (a || b) {
1142 return {
1143 ...a,
1144 ...b
1145 };
1146 }
1147 return void 0;
1148 }
1149
1150 // node_modules/@base-ui/utils/esm/empty.js
1151 function NOOP() {
1152 }
1153 var EMPTY_ARRAY2 = Object.freeze([]);
1154 var EMPTY_OBJECT = Object.freeze({});
1155
1156 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1157 function getStateAttributesProps(state, customMapping) {
1158 const props = {};
1159 for (const key in state) {
1160 const value = state[key];
1161 if (customMapping?.hasOwnProperty(key)) {
1162 const customProps = customMapping[key](value);
1163 if (customProps != null) {
1164 Object.assign(props, customProps);
1165 }
1166 continue;
1167 }
1168 if (value === true) {
1169 props[`data-${key.toLowerCase()}`] = "";
1170 } else if (value) {
1171 props[`data-${key.toLowerCase()}`] = value.toString();
1172 }
1173 }
1174 return props;
1175 }
1176
1177 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1178 function resolveClassName(className, state) {
1179 return typeof className === "function" ? className(state) : className;
1180 }
1181
1182 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1183 function resolveStyle(style, state) {
1184 return typeof style === "function" ? style(state) : style;
1185 }
1186
1187 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1188 var EMPTY_PROPS = {};
1189 function mergeProps(a, b, c, d, e) {
1190 if (!c && !d && !e && !a) {
1191 return createInitialMergedProps(b);
1192 }
1193 let merged = createInitialMergedProps(a);
1194 if (b) {
1195 merged = mergeInto(merged, b);
1196 }
1197 if (c) {
1198 merged = mergeInto(merged, c);
1199 }
1200 if (d) {
1201 merged = mergeInto(merged, d);
1202 }
1203 if (e) {
1204 merged = mergeInto(merged, e);
1205 }
1206 return merged;
1207 }
1208 function mergePropsN(props) {
1209 if (props.length === 0) {
1210 return EMPTY_PROPS;
1211 }
1212 if (props.length === 1) {
1213 return createInitialMergedProps(props[0]);
1214 }
1215 let merged = createInitialMergedProps(props[0]);
1216 for (let i = 1; i < props.length; i += 1) {
1217 merged = mergeInto(merged, props[i]);
1218 }
1219 return merged;
1220 }
1221 function createInitialMergedProps(inputProps) {
1222 if (isPropsGetter(inputProps)) {
1223 return {
1224 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1225 };
1226 }
1227 return copyInitialProps(inputProps);
1228 }
1229 function mergeInto(merged, inputProps) {
1230 if (isPropsGetter(inputProps)) {
1231 return resolvePropsGetter(inputProps, merged);
1232 }
1233 return mutablyMergeInto(merged, inputProps);
1234 }
1235 function copyInitialProps(inputProps) {
1236 const copiedProps = {
1237 ...inputProps
1238 };
1239 for (const propName in copiedProps) {
1240 const propValue = copiedProps[propName];
1241 if (isEventHandler(propName, propValue)) {
1242 copiedProps[propName] = wrapEventHandler(propValue);
1243 }
1244 }
1245 return copiedProps;
1246 }
1247 function mutablyMergeInto(mergedProps, externalProps) {
1248 if (!externalProps) {
1249 return mergedProps;
1250 }
1251 for (const propName in externalProps) {
1252 const externalPropValue = externalProps[propName];
1253 switch (propName) {
1254 case "style": {
1255 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1256 break;
1257 }
1258 case "className": {
1259 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1260 break;
1261 }
1262 default: {
1263 if (isEventHandler(propName, externalPropValue)) {
1264 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1265 } else {
1266 mergedProps[propName] = externalPropValue;
1267 }
1268 }
1269 }
1270 }
1271 return mergedProps;
1272 }
1273 function isEventHandler(key, value) {
1274 const code0 = key.charCodeAt(0);
1275 const code1 = key.charCodeAt(1);
1276 const code2 = key.charCodeAt(2);
1277 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1278 }
1279 function isPropsGetter(inputProps) {
1280 return typeof inputProps === "function";
1281 }
1282 function resolvePropsGetter(inputProps, previousProps) {
1283 if (isPropsGetter(inputProps)) {
1284 return inputProps(previousProps);
1285 }
1286 return inputProps ?? EMPTY_PROPS;
1287 }
1288 function mergeEventHandlers(ourHandler, theirHandler) {
1289 if (!theirHandler) {
1290 return ourHandler;
1291 }
1292 if (!ourHandler) {
1293 return wrapEventHandler(theirHandler);
1294 }
1295 return (...args) => {
1296 const event = args[0];
1297 if (isSyntheticEvent(event)) {
1298 const baseUIEvent = event;
1299 makeEventPreventable(baseUIEvent);
1300 const result2 = theirHandler(...args);
1301 if (!baseUIEvent.baseUIHandlerPrevented) {
1302 ourHandler?.(...args);
1303 }
1304 return result2;
1305 }
1306 const result = theirHandler(...args);
1307 ourHandler?.(...args);
1308 return result;
1309 };
1310 }
1311 function wrapEventHandler(handler) {
1312 if (!handler) {
1313 return handler;
1314 }
1315 return (...args) => {
1316 const event = args[0];
1317 if (isSyntheticEvent(event)) {
1318 makeEventPreventable(event);
1319 }
1320 return handler(...args);
1321 };
1322 }
1323 function makeEventPreventable(event) {
1324 event.preventBaseUIHandler = () => {
1325 event.baseUIHandlerPrevented = true;
1326 };
1327 return event;
1328 }
1329 function mergeClassNames(ourClassName, theirClassName) {
1330 if (theirClassName) {
1331 if (ourClassName) {
1332 return theirClassName + " " + ourClassName;
1333 }
1334 return theirClassName;
1335 }
1336 return ourClassName;
1337 }
1338 function isSyntheticEvent(event) {
1339 return event != null && typeof event === "object" && "nativeEvent" in event;
1340 }
1341
1342 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1343 var import_react = __toESM(require_react(), 1);
1344 function useRenderElement(element, componentProps, params = {}) {
1345 const renderProp = componentProps.render;
1346 const outProps = useRenderElementProps(componentProps, params);
1347 if (params.enabled === false) {
1348 return null;
1349 }
1350 const state = params.state ?? EMPTY_OBJECT;
1351 return evaluateRenderProp(element, renderProp, outProps, state);
1352 }
1353 function useRenderElementProps(componentProps, params = {}) {
1354 const {
1355 className: classNameProp,
1356 style: styleProp,
1357 render: renderProp
1358 } = componentProps;
1359 const {
1360 state = EMPTY_OBJECT,
1361 ref,
1362 props,
1363 stateAttributesMapping: stateAttributesMapping3,
1364 enabled = true
1365 } = params;
1366 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1367 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1368 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1369 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1370 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1371 if (typeof document !== "undefined") {
1372 if (!enabled) {
1373 useMergedRefs(null, null);
1374 } else if (Array.isArray(ref)) {
1375 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1376 } else {
1377 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1378 }
1379 }
1380 if (!enabled) {
1381 return EMPTY_OBJECT;
1382 }
1383 if (className !== void 0) {
1384 outProps.className = mergeClassNames(outProps.className, className);
1385 }
1386 if (style !== void 0) {
1387 outProps.style = mergeObjects(outProps.style, style);
1388 }
1389 return outProps;
1390 }
1391 function resolveRenderFunctionProps(props) {
1392 if (Array.isArray(props)) {
1393 return mergePropsN(props);
1394 }
1395 return mergeProps(void 0, props);
1396 }
1397 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1398 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1399 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1400 function evaluateRenderProp(element, render, props, state) {
1401 if (render) {
1402 if (typeof render === "function") {
1403 if (true) {
1404 warnIfRenderPropLooksLikeComponent(render);
1405 }
1406 return render(props, state);
1407 }
1408 const mergedProps = mergeProps(props, render.props);
1409 mergedProps.ref = props.ref;
1410 let newElement = render;
1411 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1412 const children = React7.Children.toArray(render);
1413 newElement = children[0];
1414 }
1415 if (true) {
1416 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
1417 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"));
1418 }
1419 }
1420 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
1421 }
1422 if (element) {
1423 if (typeof element === "string") {
1424 return renderTag(element, props);
1425 }
1426 }
1427 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1428 }
1429 function warnIfRenderPropLooksLikeComponent(renderFn) {
1430 const functionName = renderFn.name;
1431 if (functionName.length === 0) {
1432 return;
1433 }
1434 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1435 return;
1436 }
1437 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1438 return;
1439 }
1440 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");
1441 }
1442 function renderTag(Tag, props) {
1443 if (Tag === "button") {
1444 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1445 type: "button",
1446 ...props,
1447 key: props.key
1448 });
1449 }
1450 if (Tag === "img") {
1451 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1452 alt: "",
1453 ...props,
1454 key: props.key
1455 });
1456 }
1457 return /* @__PURE__ */ React7.createElement(Tag, props);
1458 }
1459
1460 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1461 var reason_parts_exports = {};
1462 __export(reason_parts_exports, {
1463 cancelOpen: () => cancelOpen,
1464 chipRemovePress: () => chipRemovePress,
1465 clearPress: () => clearPress,
1466 closePress: () => closePress,
1467 closeWatcher: () => closeWatcher,
1468 decrementPress: () => decrementPress,
1469 disabled: () => disabled,
1470 drag: () => drag,
1471 escapeKey: () => escapeKey,
1472 focusOut: () => focusOut,
1473 imperativeAction: () => imperativeAction,
1474 incrementPress: () => incrementPress,
1475 initial: () => initial,
1476 inputBlur: () => inputBlur,
1477 inputChange: () => inputChange,
1478 inputClear: () => inputClear,
1479 inputPaste: () => inputPaste,
1480 inputPress: () => inputPress,
1481 itemPress: () => itemPress,
1482 keyboard: () => keyboard,
1483 linkPress: () => linkPress,
1484 listNavigation: () => listNavigation,
1485 missing: () => missing,
1486 none: () => none,
1487 outsidePress: () => outsidePress,
1488 pointer: () => pointer,
1489 scrub: () => scrub,
1490 siblingOpen: () => siblingOpen,
1491 swipe: () => swipe,
1492 trackPress: () => trackPress,
1493 triggerFocus: () => triggerFocus,
1494 triggerHover: () => triggerHover,
1495 triggerPress: () => triggerPress,
1496 wheel: () => wheel,
1497 windowResize: () => windowResize
1498 });
1499 var none = "none";
1500 var triggerPress = "trigger-press";
1501 var triggerHover = "trigger-hover";
1502 var triggerFocus = "trigger-focus";
1503 var outsidePress = "outside-press";
1504 var itemPress = "item-press";
1505 var closePress = "close-press";
1506 var linkPress = "link-press";
1507 var clearPress = "clear-press";
1508 var chipRemovePress = "chip-remove-press";
1509 var trackPress = "track-press";
1510 var incrementPress = "increment-press";
1511 var decrementPress = "decrement-press";
1512 var inputChange = "input-change";
1513 var inputClear = "input-clear";
1514 var inputBlur = "input-blur";
1515 var inputPaste = "input-paste";
1516 var inputPress = "input-press";
1517 var focusOut = "focus-out";
1518 var escapeKey = "escape-key";
1519 var closeWatcher = "close-watcher";
1520 var listNavigation = "list-navigation";
1521 var keyboard = "keyboard";
1522 var pointer = "pointer";
1523 var drag = "drag";
1524 var wheel = "wheel";
1525 var scrub = "scrub";
1526 var cancelOpen = "cancel-open";
1527 var siblingOpen = "sibling-open";
1528 var disabled = "disabled";
1529 var missing = "missing";
1530 var initial = "initial";
1531 var imperativeAction = "imperative-action";
1532 var swipe = "swipe";
1533 var windowResize = "window-resize";
1534
1535 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1536 function createChangeEventDetails(reason, event, trigger, customProperties) {
1537 let canceled = false;
1538 let allowPropagation = false;
1539 const custom = customProperties ?? EMPTY_OBJECT;
1540 const details = {
1541 reason,
1542 event: event ?? new Event("base-ui"),
1543 cancel() {
1544 canceled = true;
1545 },
1546 allowPropagation() {
1547 allowPropagation = true;
1548 },
1549 get isCanceled() {
1550 return canceled;
1551 },
1552 get isPropagationAllowed() {
1553 return allowPropagation;
1554 },
1555 trigger,
1556 ...custom
1557 };
1558 return details;
1559 }
1560
1561 // node_modules/@base-ui/utils/esm/useId.js
1562 var React8 = __toESM(require_react(), 1);
1563 var globalId = 0;
1564 function useGlobalId(idOverride, prefix = "mui") {
1565 const [defaultId, setDefaultId] = React8.useState(idOverride);
1566 const id = idOverride || defaultId;
1567 React8.useEffect(() => {
1568 if (defaultId == null) {
1569 globalId += 1;
1570 setDefaultId(`${prefix}-${globalId}`);
1571 }
1572 }, [defaultId, prefix]);
1573 return id;
1574 }
1575 var maybeReactUseId = SafeReact.useId;
1576 function useId(idOverride, prefix) {
1577 if (maybeReactUseId !== void 0) {
1578 const reactId = maybeReactUseId();
1579 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1580 }
1581 return useGlobalId(idOverride, prefix);
1582 }
1583
1584 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1585 function useBaseUiId(idOverride) {
1586 return useId(idOverride, "base-ui");
1587 }
1588
1589 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1590 var React10 = __toESM(require_react(), 1);
1591
1592 // node_modules/@base-ui/utils/esm/useOnMount.js
1593 var React9 = __toESM(require_react(), 1);
1594 var EMPTY = [];
1595 function useOnMount(fn) {
1596 React9.useEffect(fn, EMPTY);
1597 }
1598
1599 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1600 var EMPTY2 = null;
1601 var LAST_RAF = globalThis.requestAnimationFrame;
1602 var Scheduler = class {
1603 /* This implementation uses an array as a backing data-structure for frame callbacks.
1604 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1605 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1606 * be much more efficient if there is a call pattern that alterns as
1607 * "request-cancel-request-cancel-…".
1608 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1609 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1610 callbacks = [];
1611 callbacksCount = 0;
1612 nextId = 1;
1613 startId = 1;
1614 isScheduled = false;
1615 tick = (timestamp) => {
1616 this.isScheduled = false;
1617 const currentCallbacks = this.callbacks;
1618 const currentCallbacksCount = this.callbacksCount;
1619 this.callbacks = [];
1620 this.callbacksCount = 0;
1621 this.startId = this.nextId;
1622 if (currentCallbacksCount > 0) {
1623 for (let i = 0; i < currentCallbacks.length; i += 1) {
1624 currentCallbacks[i]?.(timestamp);
1625 }
1626 }
1627 };
1628 request(fn) {
1629 const id = this.nextId;
1630 this.nextId += 1;
1631 this.callbacks.push(fn);
1632 this.callbacksCount += 1;
1633 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1634 if (!this.isScheduled || didRAFChange) {
1635 requestAnimationFrame(this.tick);
1636 this.isScheduled = true;
1637 }
1638 return id;
1639 }
1640 cancel(id) {
1641 const index2 = id - this.startId;
1642 if (index2 < 0 || index2 >= this.callbacks.length) {
1643 return;
1644 }
1645 this.callbacks[index2] = null;
1646 this.callbacksCount -= 1;
1647 }
1648 };
1649 var scheduler = new Scheduler();
1650 var AnimationFrame = class _AnimationFrame {
1651 static create() {
1652 return new _AnimationFrame();
1653 }
1654 static request(fn) {
1655 return scheduler.request(fn);
1656 }
1657 static cancel(id) {
1658 return scheduler.cancel(id);
1659 }
1660 currentId = EMPTY2;
1661 /**
1662 * Executes `fn` after `delay`, clearing any previously scheduled call.
1663 */
1664 request(fn) {
1665 this.cancel();
1666 this.currentId = scheduler.request(() => {
1667 this.currentId = EMPTY2;
1668 fn();
1669 });
1670 }
1671 cancel = () => {
1672 if (this.currentId !== EMPTY2) {
1673 scheduler.cancel(this.currentId);
1674 this.currentId = EMPTY2;
1675 }
1676 };
1677 disposeEffect = () => {
1678 return this.cancel;
1679 };
1680 };
1681 function useAnimationFrame() {
1682 const timeout = useRefWithInit(AnimationFrame.create).current;
1683 useOnMount(timeout.disposeEffect);
1684 return timeout;
1685 }
1686
1687 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1688 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1689 const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0);
1690 const [mounted, setMounted] = React10.useState(open);
1691 if (open && !mounted) {
1692 setMounted(true);
1693 setTransitionStatus("starting");
1694 }
1695 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1696 setTransitionStatus("ending");
1697 }
1698 if (!open && !mounted && transitionStatus === "ending") {
1699 setTransitionStatus(void 0);
1700 }
1701 useIsoLayoutEffect(() => {
1702 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1703 const frame = AnimationFrame.request(() => {
1704 setTransitionStatus("ending");
1705 });
1706 return () => {
1707 AnimationFrame.cancel(frame);
1708 };
1709 }
1710 return void 0;
1711 }, [open, mounted, transitionStatus, deferEndingState]);
1712 useIsoLayoutEffect(() => {
1713 if (!open || enableIdleState) {
1714 return void 0;
1715 }
1716 const frame = AnimationFrame.request(() => {
1717 setTransitionStatus(void 0);
1718 });
1719 return () => {
1720 AnimationFrame.cancel(frame);
1721 };
1722 }, [enableIdleState, open]);
1723 useIsoLayoutEffect(() => {
1724 if (!open || !enableIdleState) {
1725 return void 0;
1726 }
1727 if (open && mounted && transitionStatus !== "idle") {
1728 setTransitionStatus("starting");
1729 }
1730 const frame = AnimationFrame.request(() => {
1731 setTransitionStatus("idle");
1732 });
1733 return () => {
1734 AnimationFrame.cancel(frame);
1735 };
1736 }, [enableIdleState, open, mounted, transitionStatus]);
1737 return {
1738 mounted,
1739 setMounted,
1740 transitionStatus
1741 };
1742 }
1743
1744 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1745 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1746 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1747 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1748 return TransitionStatusDataAttributes2;
1749 })({});
1750 var STARTING_HOOK = {
1751 [TransitionStatusDataAttributes.startingStyle]: ""
1752 };
1753 var ENDING_HOOK = {
1754 [TransitionStatusDataAttributes.endingStyle]: ""
1755 };
1756 var transitionStatusMapping = {
1757 transitionStatus(value) {
1758 if (value === "starting") {
1759 return STARTING_HOOK;
1760 }
1761 if (value === "ending") {
1762 return ENDING_HOOK;
1763 }
1764 return null;
1765 }
1766 };
1767
1768 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1769 function hasWindow() {
1770 return typeof window !== "undefined";
1771 }
1772 function getNodeName(node) {
1773 if (isNode(node)) {
1774 return (node.nodeName || "").toLowerCase();
1775 }
1776 return "#document";
1777 }
1778 function getWindow(node) {
1779 var _node$ownerDocument;
1780 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1781 }
1782 function getDocumentElement(node) {
1783 var _ref;
1784 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1785 }
1786 function isNode(value) {
1787 if (!hasWindow()) {
1788 return false;
1789 }
1790 return value instanceof Node || value instanceof getWindow(value).Node;
1791 }
1792 function isElement(value) {
1793 if (!hasWindow()) {
1794 return false;
1795 }
1796 return value instanceof Element || value instanceof getWindow(value).Element;
1797 }
1798 function isHTMLElement(value) {
1799 if (!hasWindow()) {
1800 return false;
1801 }
1802 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1803 }
1804 function isShadowRoot(value) {
1805 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1806 return false;
1807 }
1808 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1809 }
1810 function isOverflowElement(element) {
1811 const {
1812 overflow,
1813 overflowX,
1814 overflowY,
1815 display
1816 } = getComputedStyle2(element);
1817 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1818 }
1819 function isTableElement(element) {
1820 return /^(table|td|th)$/.test(getNodeName(element));
1821 }
1822 function isTopLayer(element) {
1823 try {
1824 if (element.matches(":popover-open")) {
1825 return true;
1826 }
1827 } catch (_e) {
1828 }
1829 try {
1830 return element.matches(":modal");
1831 } catch (_e) {
1832 return false;
1833 }
1834 }
1835 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1836 var containRe = /paint|layout|strict|content/;
1837 var isNotNone = (value) => !!value && value !== "none";
1838 var isWebKitValue;
1839 function isContainingBlock(elementOrCss) {
1840 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1841 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 || "");
1842 }
1843 function getContainingBlock(element) {
1844 let currentNode = getParentNode(element);
1845 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1846 if (isContainingBlock(currentNode)) {
1847 return currentNode;
1848 } else if (isTopLayer(currentNode)) {
1849 return null;
1850 }
1851 currentNode = getParentNode(currentNode);
1852 }
1853 return null;
1854 }
1855 function isWebKit() {
1856 if (isWebKitValue == null) {
1857 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1858 }
1859 return isWebKitValue;
1860 }
1861 function isLastTraversableNode(node) {
1862 return /^(html|body|#document)$/.test(getNodeName(node));
1863 }
1864 function getComputedStyle2(element) {
1865 return getWindow(element).getComputedStyle(element);
1866 }
1867 function getNodeScroll(element) {
1868 if (isElement(element)) {
1869 return {
1870 scrollLeft: element.scrollLeft,
1871 scrollTop: element.scrollTop
1872 };
1873 }
1874 return {
1875 scrollLeft: element.scrollX,
1876 scrollTop: element.scrollY
1877 };
1878 }
1879 function getParentNode(node) {
1880 if (getNodeName(node) === "html") {
1881 return node;
1882 }
1883 const result = (
1884 // Step into the shadow DOM of the parent of a slotted node.
1885 node.assignedSlot || // DOM Element detected.
1886 node.parentNode || // ShadowRoot detected.
1887 isShadowRoot(node) && node.host || // Fallback.
1888 getDocumentElement(node)
1889 );
1890 return isShadowRoot(result) ? result.host : result;
1891 }
1892 function getNearestOverflowAncestor(node) {
1893 const parentNode = getParentNode(node);
1894 if (isLastTraversableNode(parentNode)) {
1895 return node.ownerDocument ? node.ownerDocument.body : node.body;
1896 }
1897 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1898 return parentNode;
1899 }
1900 return getNearestOverflowAncestor(parentNode);
1901 }
1902 function getOverflowAncestors(node, list, traverseIframes) {
1903 var _node$ownerDocument2;
1904 if (list === void 0) {
1905 list = [];
1906 }
1907 if (traverseIframes === void 0) {
1908 traverseIframes = true;
1909 }
1910 const scrollableAncestor = getNearestOverflowAncestor(node);
1911 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1912 const win = getWindow(scrollableAncestor);
1913 if (isBody) {
1914 const frameElement = getFrameElement(win);
1915 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1916 } else {
1917 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1918 }
1919 }
1920 function getFrameElement(win) {
1921 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1922 }
1923
1924 // node_modules/@base-ui/utils/esm/detectBrowser.js
1925 var hasNavigator = typeof navigator !== "undefined";
1926 var nav = getNavigatorData();
1927 var platform = getPlatform();
1928 var userAgent = getUserAgent();
1929 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
1930 var isIOS = (
1931 // iPads can claim to be MacIntel
1932 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
1933 );
1934 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
1935 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
1936 var isEdge = hasNavigator && /Edg/i.test(userAgent);
1937 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
1938 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
1939 var isJSDOM = userAgent.includes("jsdom/");
1940 function getNavigatorData() {
1941 if (!hasNavigator) {
1942 return {
1943 platform: "",
1944 maxTouchPoints: -1
1945 };
1946 }
1947 const uaData = navigator.userAgentData;
1948 if (uaData?.platform) {
1949 return {
1950 platform: uaData.platform,
1951 maxTouchPoints: navigator.maxTouchPoints
1952 };
1953 }
1954 return {
1955 platform: navigator.platform ?? "",
1956 maxTouchPoints: navigator.maxTouchPoints ?? -1
1957 };
1958 }
1959 function getUserAgent() {
1960 if (!hasNavigator) {
1961 return "";
1962 }
1963 const uaData = navigator.userAgentData;
1964 if (uaData && Array.isArray(uaData.brands)) {
1965 return uaData.brands.map(({
1966 brand,
1967 version: version2
1968 }) => `${brand}/${version2}`).join(" ");
1969 }
1970 return navigator.userAgent;
1971 }
1972 function getPlatform() {
1973 if (!hasNavigator) {
1974 return "";
1975 }
1976 const uaData = navigator.userAgentData;
1977 if (uaData?.platform) {
1978 return uaData.platform;
1979 }
1980 return navigator.platform ?? "";
1981 }
1982
1983 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
1984 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
1985 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
1986
1987 // node_modules/@base-ui/react/esm/internals/shadowDom.js
1988 function activeElement(doc) {
1989 let element = doc.activeElement;
1990 while (element?.shadowRoot?.activeElement != null) {
1991 element = element.shadowRoot.activeElement;
1992 }
1993 return element;
1994 }
1995 function contains(parent, child) {
1996 if (!parent || !child) {
1997 return false;
1998 }
1999 const rootNode = child.getRootNode?.();
2000 if (parent.contains(child)) {
2001 return true;
2002 }
2003 if (rootNode && isShadowRoot(rootNode)) {
2004 let next = child;
2005 while (next) {
2006 if (parent === next) {
2007 return true;
2008 }
2009 next = next.parentNode || next.host;
2010 }
2011 }
2012 return false;
2013 }
2014 function getTarget(event) {
2015 if ("composedPath" in event) {
2016 return event.composedPath()[0];
2017 }
2018 return event.target;
2019 }
2020
2021 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2022 function isTargetInsideEnabledTrigger(target, triggerElements) {
2023 if (!isElement(target)) {
2024 return false;
2025 }
2026 const targetElement = target;
2027 if (triggerElements.hasElement(targetElement)) {
2028 return !targetElement.hasAttribute("data-trigger-disabled");
2029 }
2030 for (const [, trigger] of triggerElements.entries()) {
2031 if (contains(trigger, targetElement)) {
2032 return !trigger.hasAttribute("data-trigger-disabled");
2033 }
2034 }
2035 return false;
2036 }
2037 function isEventTargetWithin(event, node) {
2038 if (node == null) {
2039 return false;
2040 }
2041 if ("composedPath" in event) {
2042 return event.composedPath().includes(node);
2043 }
2044 const eventAgain = event;
2045 return eventAgain.target != null && node.contains(eventAgain.target);
2046 }
2047 function isRootElement(element) {
2048 return element.matches("html,body");
2049 }
2050 function isTypeableElement(element) {
2051 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2052 }
2053 function isInteractiveElement(element) {
2054 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2055 }
2056 function matchesFocusVisible(element) {
2057 if (!element || isJSDOM) {
2058 return true;
2059 }
2060 try {
2061 return element.matches(":focus-visible");
2062 } catch (_e) {
2063 return true;
2064 }
2065 }
2066
2067 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2068 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2069 const directChildren = nodes.filter((node) => node.parentId === id);
2070 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2071 }
2072
2073 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2074 function isReactEvent(event) {
2075 return "nativeEvent" in event;
2076 }
2077 function isMouseLikePointerType(pointerType, strict) {
2078 const values = ["mouse", "pen"];
2079 if (!strict) {
2080 values.push("", void 0);
2081 }
2082 return values.includes(pointerType);
2083 }
2084 function isClickLikeEvent(event) {
2085 const type = event.type;
2086 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2087 }
2088
2089 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2090 var sides = ["top", "right", "bottom", "left"];
2091 var min = Math.min;
2092 var max = Math.max;
2093 var round = Math.round;
2094 var floor = Math.floor;
2095 var createCoords = (v) => ({
2096 x: v,
2097 y: v
2098 });
2099 var oppositeSideMap = {
2100 left: "right",
2101 right: "left",
2102 bottom: "top",
2103 top: "bottom"
2104 };
2105 function clamp(start, value, end) {
2106 return max(start, min(value, end));
2107 }
2108 function evaluate(value, param) {
2109 return typeof value === "function" ? value(param) : value;
2110 }
2111 function getSide(placement) {
2112 return placement.split("-")[0];
2113 }
2114 function getAlignment(placement) {
2115 return placement.split("-")[1];
2116 }
2117 function getOppositeAxis(axis) {
2118 return axis === "x" ? "y" : "x";
2119 }
2120 function getAxisLength(axis) {
2121 return axis === "y" ? "height" : "width";
2122 }
2123 function getSideAxis(placement) {
2124 const firstChar = placement[0];
2125 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2126 }
2127 function getAlignmentAxis(placement) {
2128 return getOppositeAxis(getSideAxis(placement));
2129 }
2130 function getAlignmentSides(placement, rects, rtl) {
2131 if (rtl === void 0) {
2132 rtl = false;
2133 }
2134 const alignment = getAlignment(placement);
2135 const alignmentAxis = getAlignmentAxis(placement);
2136 const length = getAxisLength(alignmentAxis);
2137 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2138 if (rects.reference[length] > rects.floating[length]) {
2139 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2140 }
2141 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2142 }
2143 function getExpandedPlacements(placement) {
2144 const oppositePlacement = getOppositePlacement(placement);
2145 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2146 }
2147 function getOppositeAlignmentPlacement(placement) {
2148 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2149 }
2150 var lrPlacement = ["left", "right"];
2151 var rlPlacement = ["right", "left"];
2152 var tbPlacement = ["top", "bottom"];
2153 var btPlacement = ["bottom", "top"];
2154 function getSideList(side, isStart, rtl) {
2155 switch (side) {
2156 case "top":
2157 case "bottom":
2158 if (rtl) return isStart ? rlPlacement : lrPlacement;
2159 return isStart ? lrPlacement : rlPlacement;
2160 case "left":
2161 case "right":
2162 return isStart ? tbPlacement : btPlacement;
2163 default:
2164 return [];
2165 }
2166 }
2167 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2168 const alignment = getAlignment(placement);
2169 let list = getSideList(getSide(placement), direction === "start", rtl);
2170 if (alignment) {
2171 list = list.map((side) => side + "-" + alignment);
2172 if (flipAlignment) {
2173 list = list.concat(list.map(getOppositeAlignmentPlacement));
2174 }
2175 }
2176 return list;
2177 }
2178 function getOppositePlacement(placement) {
2179 const side = getSide(placement);
2180 return oppositeSideMap[side] + placement.slice(side.length);
2181 }
2182 function expandPaddingObject(padding) {
2183 return {
2184 top: 0,
2185 right: 0,
2186 bottom: 0,
2187 left: 0,
2188 ...padding
2189 };
2190 }
2191 function getPaddingObject(padding) {
2192 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2193 top: padding,
2194 right: padding,
2195 bottom: padding,
2196 left: padding
2197 };
2198 }
2199 function rectToClientRect(rect) {
2200 const {
2201 x,
2202 y,
2203 width,
2204 height
2205 } = rect;
2206 return {
2207 width,
2208 height,
2209 top: y,
2210 left: x,
2211 right: x + width,
2212 bottom: y + height,
2213 x,
2214 y
2215 };
2216 }
2217
2218 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2219 function isHiddenByStyles(styles) {
2220 return styles.visibility === "hidden" || styles.visibility === "collapse";
2221 }
2222 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2223 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2224 return false;
2225 }
2226 if (typeof element.checkVisibility === "function") {
2227 return element.checkVisibility();
2228 }
2229 return styles.display !== "none" && styles.display !== "contents";
2230 }
2231
2232 // node_modules/@base-ui/utils/esm/owner.js
2233 function ownerDocument(node) {
2234 return node?.ownerDocument || document;
2235 }
2236
2237 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2238 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2239 function getParentElement(element) {
2240 const assignedSlot = element.assignedSlot;
2241 if (assignedSlot) {
2242 return assignedSlot;
2243 }
2244 if (element.parentElement) {
2245 return element.parentElement;
2246 }
2247 const rootNode = element.getRootNode();
2248 return isShadowRoot(rootNode) ? rootNode.host : null;
2249 }
2250 function getDetailsSummary(details) {
2251 for (const child of Array.from(details.children)) {
2252 if (getNodeName(child) === "summary") {
2253 return child;
2254 }
2255 }
2256 return null;
2257 }
2258 function isWithinOpenDetailsSummary(element, details) {
2259 const summary = getDetailsSummary(details);
2260 return !!summary && (element === summary || contains(summary, element));
2261 }
2262 function isFocusableCandidate(element) {
2263 const nodeName = element ? getNodeName(element) : "";
2264 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");
2265 }
2266 function isFocusableElement(element) {
2267 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2268 return false;
2269 }
2270 for (let current = element; current; current = getParentElement(current)) {
2271 const isAncestor = current !== element;
2272 const isSlot = getNodeName(current) === "slot";
2273 if (current.hasAttribute("inert")) {
2274 return false;
2275 }
2276 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2277 return false;
2278 }
2279 }
2280 return true;
2281 }
2282 function isVisibleInTabbableTree(element, isAncestor) {
2283 const styles = getComputedStyle2(element);
2284 if (!isAncestor) {
2285 return isElementVisible(element, styles);
2286 }
2287 return styles.display !== "none";
2288 }
2289 function getTabIndex(element) {
2290 const tabIndex = element.tabIndex;
2291 if (tabIndex < 0) {
2292 const nodeName = getNodeName(element);
2293 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2294 return 0;
2295 }
2296 }
2297 return tabIndex;
2298 }
2299 function getNamedRadioInput(element) {
2300 if (getNodeName(element) !== "input") {
2301 return null;
2302 }
2303 const input = element;
2304 return input.type === "radio" && input.name !== "" ? input : null;
2305 }
2306 function isTabbableRadio(element, candidates) {
2307 const input = getNamedRadioInput(element);
2308 if (!input) {
2309 return true;
2310 }
2311 const checkedRadio = candidates.find((candidate) => {
2312 const radio = getNamedRadioInput(candidate);
2313 return radio?.name === input.name && radio.form === input.form && radio.checked;
2314 });
2315 if (checkedRadio) {
2316 return checkedRadio === input;
2317 }
2318 return candidates.find((candidate) => {
2319 const radio = getNamedRadioInput(candidate);
2320 return radio?.name === input.name && radio.form === input.form;
2321 }) === input;
2322 }
2323 function getComposedChildren(container) {
2324 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2325 const assignedElements = container.assignedElements({
2326 flatten: true
2327 });
2328 if (assignedElements.length > 0) {
2329 return assignedElements;
2330 }
2331 }
2332 if (isHTMLElement(container) && container.shadowRoot) {
2333 return Array.from(container.shadowRoot.children);
2334 }
2335 return Array.from(container.children);
2336 }
2337 function appendCandidates(container, list) {
2338 getComposedChildren(container).forEach((child) => {
2339 if (isFocusableCandidate(child)) {
2340 list.push(child);
2341 }
2342 appendCandidates(child, list);
2343 });
2344 }
2345 function appendMatchingElements(container, selector, list) {
2346 getComposedChildren(container).forEach((child) => {
2347 if (isHTMLElement(child) && child.matches(selector)) {
2348 list.push(child);
2349 }
2350 appendMatchingElements(child, selector, list);
2351 });
2352 }
2353 function focusable(container) {
2354 const candidates = [];
2355 appendCandidates(container, candidates);
2356 return candidates.filter(isFocusableElement);
2357 }
2358 function tabbable(container) {
2359 const candidates = focusable(container);
2360 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2361 }
2362 function getTabbableIn(container, dir) {
2363 const list = tabbable(container);
2364 const len = list.length;
2365 if (len === 0) {
2366 return void 0;
2367 }
2368 const active = activeElement(ownerDocument(container));
2369 const index2 = list.indexOf(active);
2370 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2371 return list[nextIndex];
2372 }
2373 function getNextTabbable(referenceElement) {
2374 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2375 }
2376 function getPreviousTabbable(referenceElement) {
2377 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2378 }
2379 function isOutsideEvent(event, container) {
2380 const containerElement = container || event.currentTarget;
2381 const relatedTarget = event.relatedTarget;
2382 return !relatedTarget || !contains(containerElement, relatedTarget);
2383 }
2384 function disableFocusInside(container) {
2385 const tabbableElements = tabbable(container);
2386 tabbableElements.forEach((element) => {
2387 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2388 element.setAttribute("tabindex", "-1");
2389 });
2390 }
2391 function enableFocusInside(container) {
2392 const elements = [];
2393 appendMatchingElements(container, "[data-tabindex]", elements);
2394 elements.forEach((element) => {
2395 const tabindex = element.dataset.tabindex;
2396 delete element.dataset.tabindex;
2397 if (tabindex) {
2398 element.setAttribute("tabindex", tabindex);
2399 } else {
2400 element.removeAttribute("tabindex");
2401 }
2402 });
2403 }
2404
2405 // node_modules/@base-ui/utils/esm/addEventListener.js
2406 function addEventListener(target, type, listener, options) {
2407 target.addEventListener(type, listener, options);
2408 return () => {
2409 target.removeEventListener(type, listener, options);
2410 };
2411 }
2412
2413 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2414 function useValueAsRef(value) {
2415 const latest = useRefWithInit(createLatestRef, value).current;
2416 latest.next = value;
2417 useIsoLayoutEffect(latest.effect);
2418 return latest;
2419 }
2420 function createLatestRef(value) {
2421 const latest = {
2422 current: value,
2423 next: value,
2424 effect: () => {
2425 latest.current = latest.next;
2426 }
2427 };
2428 return latest;
2429 }
2430
2431 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2432 var React11 = __toESM(require_react(), 1);
2433
2434 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2435 var ReactDOM = __toESM(require_react_dom(), 1);
2436
2437 // node_modules/@base-ui/react/esm/utils/resolveRef.js
2438 function resolveRef(maybeRef) {
2439 if (maybeRef == null) {
2440 return maybeRef;
2441 }
2442 return "current" in maybeRef ? maybeRef.current : maybeRef;
2443 }
2444
2445 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2446 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2447 const frame = useAnimationFrame();
2448 return useStableCallback((fnToExecute, signal = null) => {
2449 frame.cancel();
2450 const element = resolveRef(elementOrRef);
2451 if (element == null) {
2452 return;
2453 }
2454 const resolvedElement = element;
2455 const done = () => {
2456 ReactDOM.flushSync(fnToExecute);
2457 };
2458 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2459 fnToExecute();
2460 return;
2461 }
2462 function exec() {
2463 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2464 if (!signal?.aborted) {
2465 done();
2466 }
2467 }).catch(() => {
2468 if (treatAbortedAsFinished) {
2469 if (!signal?.aborted) {
2470 done();
2471 }
2472 return;
2473 }
2474 const currentAnimations = resolvedElement.getAnimations();
2475 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2476 exec();
2477 }
2478 });
2479 }
2480 if (waitForStartingStyleRemoved) {
2481 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2482 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2483 frame.request(exec);
2484 return;
2485 }
2486 const attributeObserver = new MutationObserver(() => {
2487 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2488 attributeObserver.disconnect();
2489 exec();
2490 }
2491 });
2492 attributeObserver.observe(resolvedElement, {
2493 attributes: true,
2494 attributeFilter: [startingStyleAttribute]
2495 });
2496 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2497 once: true
2498 });
2499 return;
2500 }
2501 frame.request(exec);
2502 });
2503 }
2504
2505 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2506 function useOpenChangeComplete(parameters) {
2507 const {
2508 enabled = true,
2509 open,
2510 ref,
2511 onComplete: onCompleteParam
2512 } = parameters;
2513 const onComplete = useStableCallback(onCompleteParam);
2514 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2515 React11.useEffect(() => {
2516 if (!enabled) {
2517 return void 0;
2518 }
2519 const abortController = new AbortController();
2520 runOnceAnimationsFinish(onComplete, abortController.signal);
2521 return () => {
2522 abortController.abort();
2523 };
2524 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2525 }
2526
2527 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2528 var React12 = __toESM(require_react(), 1);
2529 function useOnFirstRender(fn) {
2530 const ref = React12.useRef(true);
2531 if (ref.current) {
2532 ref.current = false;
2533 fn();
2534 }
2535 }
2536
2537 // node_modules/@base-ui/utils/esm/useTimeout.js
2538 var EMPTY3 = 0;
2539 var Timeout = class _Timeout {
2540 static create() {
2541 return new _Timeout();
2542 }
2543 currentId = EMPTY3;
2544 /**
2545 * Executes `fn` after `delay`, clearing any previously scheduled call.
2546 */
2547 start(delay, fn) {
2548 this.clear();
2549 this.currentId = setTimeout(() => {
2550 this.currentId = EMPTY3;
2551 fn();
2552 }, delay);
2553 }
2554 isStarted() {
2555 return this.currentId !== EMPTY3;
2556 }
2557 clear = () => {
2558 if (this.currentId !== EMPTY3) {
2559 clearTimeout(this.currentId);
2560 this.currentId = EMPTY3;
2561 }
2562 };
2563 disposeEffect = () => {
2564 return this.clear;
2565 };
2566 };
2567 function useTimeout() {
2568 const timeout = useRefWithInit(Timeout.create).current;
2569 useOnMount(timeout.disposeEffect);
2570 return timeout;
2571 }
2572
2573 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2574 var React13 = __toESM(require_react(), 1);
2575
2576 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2577 function resolveValue(value, pointerType) {
2578 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2579 return 0;
2580 }
2581 if (typeof value === "function") {
2582 return value();
2583 }
2584 return value;
2585 }
2586 function getDelay(value, prop, pointerType) {
2587 const result = resolveValue(value, pointerType);
2588 if (typeof result === "number") {
2589 return result;
2590 }
2591 return result?.[prop];
2592 }
2593 function getRestMs(value) {
2594 if (typeof value === "function") {
2595 return value();
2596 }
2597 return value;
2598 }
2599 function isClickLikeOpenEvent(openEventType, interactedInside) {
2600 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2601 }
2602 function isHoverOpenEvent(openEventType) {
2603 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2604 }
2605
2606 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2607 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2608 var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({
2609 hasProvider: false,
2610 timeoutMs: 0,
2611 delayRef: {
2612 current: 0
2613 },
2614 initialDelayRef: {
2615 current: 0
2616 },
2617 timeout: new Timeout(),
2618 currentIdRef: {
2619 current: null
2620 },
2621 currentContextRef: {
2622 current: null
2623 }
2624 });
2625 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2626 function FloatingDelayGroup(props) {
2627 const {
2628 children,
2629 delay,
2630 timeoutMs = 0
2631 } = props;
2632 const delayRef = React13.useRef(delay);
2633 const initialDelayRef = React13.useRef(delay);
2634 const currentIdRef = React13.useRef(null);
2635 const currentContextRef = React13.useRef(null);
2636 const timeout = useTimeout();
2637 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2638 value: React13.useMemo(() => ({
2639 hasProvider: true,
2640 delayRef,
2641 initialDelayRef,
2642 currentIdRef,
2643 timeoutMs,
2644 currentContextRef,
2645 timeout
2646 }), [timeoutMs, timeout]),
2647 children
2648 });
2649 }
2650 function useDelayGroup(context, options = {
2651 open: false
2652 }) {
2653 const {
2654 open
2655 } = options;
2656 const store2 = "rootStore" in context ? context.rootStore : context;
2657 const floatingId = store2.useState("floatingId");
2658 const groupContext = React13.useContext(FloatingDelayGroupContext);
2659 const {
2660 currentIdRef,
2661 delayRef,
2662 timeoutMs,
2663 initialDelayRef,
2664 currentContextRef,
2665 hasProvider,
2666 timeout
2667 } = groupContext;
2668 const [isInstantPhase, setIsInstantPhase] = React13.useState(false);
2669 useIsoLayoutEffect(() => {
2670 function unset() {
2671 setIsInstantPhase(false);
2672 currentContextRef.current?.setIsInstantPhase(false);
2673 currentIdRef.current = null;
2674 currentContextRef.current = null;
2675 delayRef.current = initialDelayRef.current;
2676 }
2677 if (!currentIdRef.current) {
2678 return void 0;
2679 }
2680 if (!open && currentIdRef.current === floatingId) {
2681 setIsInstantPhase(false);
2682 if (timeoutMs) {
2683 const closingId = floatingId;
2684 timeout.start(timeoutMs, () => {
2685 if (store2.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2686 return;
2687 }
2688 unset();
2689 });
2690 return () => {
2691 timeout.clear();
2692 };
2693 }
2694 unset();
2695 }
2696 return void 0;
2697 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store2]);
2698 useIsoLayoutEffect(() => {
2699 if (!open) {
2700 return;
2701 }
2702 const prevContext = currentContextRef.current;
2703 const prevId = currentIdRef.current;
2704 timeout.clear();
2705 currentContextRef.current = {
2706 onOpenChange: store2.setOpen,
2707 setIsInstantPhase
2708 };
2709 currentIdRef.current = floatingId;
2710 delayRef.current = {
2711 open: 0,
2712 close: getDelay(initialDelayRef.current, "close")
2713 };
2714 if (prevId !== null && prevId !== floatingId) {
2715 setIsInstantPhase(true);
2716 prevContext?.setIsInstantPhase(true);
2717 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2718 } else {
2719 setIsInstantPhase(false);
2720 prevContext?.setIsInstantPhase(false);
2721 }
2722 }, [open, floatingId, store2, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
2723 useIsoLayoutEffect(() => {
2724 return () => {
2725 currentContextRef.current = null;
2726 };
2727 }, [currentContextRef]);
2728 return React13.useMemo(() => ({
2729 hasProvider,
2730 delayRef,
2731 isInstantPhase
2732 }), [hasProvider, delayRef, isInstantPhase]);
2733 }
2734
2735 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2736 function mergeCleanups(...cleanups) {
2737 return () => {
2738 for (let i = 0; i < cleanups.length; i += 1) {
2739 const cleanup = cleanups[i];
2740 if (cleanup) {
2741 cleanup();
2742 }
2743 }
2744 };
2745 }
2746
2747 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2748 var React14 = __toESM(require_react(), 1);
2749
2750 // node_modules/@base-ui/utils/esm/visuallyHidden.js
2751 var visuallyHiddenBase = {
2752 clipPath: "inset(50%)",
2753 overflow: "hidden",
2754 whiteSpace: "nowrap",
2755 border: 0,
2756 padding: 0,
2757 width: 1,
2758 height: 1,
2759 margin: -1
2760 };
2761 var visuallyHidden = {
2762 ...visuallyHiddenBase,
2763 position: "fixed",
2764 top: 0,
2765 left: 0
2766 };
2767 var visuallyHiddenInput = {
2768 ...visuallyHiddenBase,
2769 position: "absolute"
2770 };
2771
2772 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2773 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2774 var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) {
2775 const [role, setRole] = React14.useState();
2776 useIsoLayoutEffect(() => {
2777 if (isSafari) {
2778 setRole("button");
2779 }
2780 }, []);
2781 const restProps = {
2782 tabIndex: 0,
2783 // Role is only for VoiceOver
2784 role
2785 };
2786 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
2787 ...props,
2788 ref,
2789 style: visuallyHidden,
2790 "aria-hidden": role ? void 0 : true,
2791 ...restProps,
2792 "data-base-ui-focus-guard": ""
2793 });
2794 });
2795 if (true) FocusGuard.displayName = "FocusGuard";
2796
2797 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
2798 function createAttribute(name) {
2799 return `data-base-ui-${name}`;
2800 }
2801
2802 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2803 var React15 = __toESM(require_react(), 1);
2804 var ReactDOM2 = __toESM(require_react_dom(), 1);
2805
2806 // node_modules/@base-ui/react/esm/internals/constants.js
2807 var DISABLED_TRANSITIONS_STYLE = {
2808 style: {
2809 transition: "none"
2810 }
2811 };
2812 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2813 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2814 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2815 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2816 var POPUP_COLLISION_AVOIDANCE = {
2817 fallbackAxisSide: "end"
2818 };
2819 var ownerVisuallyHidden = {
2820 clipPath: "inset(50%)",
2821 position: "fixed",
2822 top: 0,
2823 left: 0
2824 };
2825
2826 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2827 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
2828 var PortalContext = /* @__PURE__ */ React15.createContext(null);
2829 if (true) PortalContext.displayName = "PortalContext";
2830 var usePortalContext = () => React15.useContext(PortalContext);
2831 var attr = createAttribute("portal");
2832 function useFloatingPortalNode(props = {}) {
2833 const {
2834 ref,
2835 container: containerProp,
2836 componentProps = EMPTY_OBJECT,
2837 elementProps
2838 } = props;
2839 const uniqueId = useId();
2840 const portalContext = usePortalContext();
2841 const parentPortalNode = portalContext?.portalNode;
2842 const [containerElement, setContainerElement] = React15.useState(null);
2843 const [portalNode, setPortalNode] = React15.useState(null);
2844 const setPortalNodeRef = useStableCallback((node) => {
2845 if (node !== null) {
2846 setPortalNode(node);
2847 }
2848 });
2849 const containerRef = React15.useRef(null);
2850 useIsoLayoutEffect(() => {
2851 if (containerProp === null) {
2852 if (containerRef.current) {
2853 containerRef.current = null;
2854 setPortalNode(null);
2855 setContainerElement(null);
2856 }
2857 return;
2858 }
2859 if (uniqueId == null) {
2860 return;
2861 }
2862 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2863 if (resolvedContainer == null) {
2864 if (containerRef.current) {
2865 containerRef.current = null;
2866 setPortalNode(null);
2867 setContainerElement(null);
2868 }
2869 return;
2870 }
2871 if (containerRef.current !== resolvedContainer) {
2872 containerRef.current = resolvedContainer;
2873 setPortalNode(null);
2874 setContainerElement(resolvedContainer);
2875 }
2876 }, [containerProp, parentPortalNode, uniqueId]);
2877 const portalElement = useRenderElement("div", componentProps, {
2878 ref: [ref, setPortalNodeRef],
2879 props: [{
2880 id: uniqueId,
2881 [attr]: ""
2882 }, elementProps]
2883 });
2884 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2885 return {
2886 portalNode,
2887 portalSubtree
2888 };
2889 }
2890 var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2891 const {
2892 render,
2893 className,
2894 style,
2895 children,
2896 container,
2897 renderGuards,
2898 ...elementProps
2899 } = componentProps;
2900 const {
2901 portalNode,
2902 portalSubtree
2903 } = useFloatingPortalNode({
2904 container,
2905 ref: forwardedRef,
2906 componentProps,
2907 elementProps
2908 });
2909 const beforeOutsideRef = React15.useRef(null);
2910 const afterOutsideRef = React15.useRef(null);
2911 const beforeInsideRef = React15.useRef(null);
2912 const afterInsideRef = React15.useRef(null);
2913 const [focusManagerState, setFocusManagerState] = React15.useState(null);
2914 const focusInsideDisabledRef = React15.useRef(false);
2915 const modal = focusManagerState?.modal;
2916 const open = focusManagerState?.open;
2917 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2918 React15.useEffect(() => {
2919 if (!portalNode || modal) {
2920 return void 0;
2921 }
2922 function onFocus(event) {
2923 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2924 if (event.type === "focusin") {
2925 if (focusInsideDisabledRef.current) {
2926 enableFocusInside(portalNode);
2927 focusInsideDisabledRef.current = false;
2928 }
2929 } else {
2930 disableFocusInside(portalNode);
2931 focusInsideDisabledRef.current = true;
2932 }
2933 }
2934 }
2935 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
2936 }, [portalNode, modal]);
2937 React15.useEffect(() => {
2938 if (!portalNode || open !== false) {
2939 return;
2940 }
2941 enableFocusInside(portalNode);
2942 focusInsideDisabledRef.current = false;
2943 }, [open, portalNode]);
2944 const portalContextValue = React15.useMemo(() => ({
2945 beforeOutsideRef,
2946 afterOutsideRef,
2947 beforeInsideRef,
2948 afterInsideRef,
2949 portalNode,
2950 setFocusManagerState
2951 }), [portalNode]);
2952 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React15.Fragment, {
2953 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
2954 value: portalContextValue,
2955 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2956 "data-type": "outside",
2957 ref: beforeOutsideRef,
2958 onFocus: (event) => {
2959 if (isOutsideEvent(event, portalNode)) {
2960 beforeInsideRef.current?.focus();
2961 } else {
2962 const domReference = focusManagerState ? focusManagerState.domReference : null;
2963 const prevTabbable = getPreviousTabbable(domReference);
2964 prevTabbable?.focus();
2965 }
2966 }
2967 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
2968 "aria-owns": portalNode.id,
2969 style: ownerVisuallyHidden
2970 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2971 "data-type": "outside",
2972 ref: afterOutsideRef,
2973 onFocus: (event) => {
2974 if (isOutsideEvent(event, portalNode)) {
2975 afterInsideRef.current?.focus();
2976 } else {
2977 const domReference = focusManagerState ? focusManagerState.domReference : null;
2978 const nextTabbable = getNextTabbable(domReference);
2979 nextTabbable?.focus();
2980 if (focusManagerState?.closeOnFocusOut) {
2981 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
2982 }
2983 }
2984 }
2985 })]
2986 })]
2987 });
2988 });
2989 if (true) FloatingPortal.displayName = "FloatingPortal";
2990
2991 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2992 var React16 = __toESM(require_react(), 1);
2993
2994 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
2995 function createEventEmitter() {
2996 const map = /* @__PURE__ */ new Map();
2997 return {
2998 emit(event, data) {
2999 map.get(event)?.forEach((listener) => listener(data));
3000 },
3001 on(event, listener) {
3002 if (!map.has(event)) {
3003 map.set(event, /* @__PURE__ */ new Set());
3004 }
3005 map.get(event).add(listener);
3006 },
3007 off(event, listener) {
3008 map.get(event)?.delete(listener);
3009 }
3010 };
3011 }
3012
3013 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3014 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3015 var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null);
3016 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3017 var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null);
3018 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3019 var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null;
3020 var useFloatingTree = (externalTree) => {
3021 const contextTree = React16.useContext(FloatingTreeContext);
3022 return externalTree ?? contextTree;
3023 };
3024
3025 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3026 var React17 = __toESM(require_react(), 1);
3027 function createVirtualElement(domElement, data) {
3028 let offsetX = null;
3029 let offsetY = null;
3030 let isAutoUpdateEvent = false;
3031 return {
3032 contextElement: domElement || void 0,
3033 getBoundingClientRect() {
3034 const domRect = domElement?.getBoundingClientRect() || {
3035 width: 0,
3036 height: 0,
3037 x: 0,
3038 y: 0
3039 };
3040 const isXAxis = data.axis === "x" || data.axis === "both";
3041 const isYAxis = data.axis === "y" || data.axis === "both";
3042 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3043 let width = domRect.width;
3044 let height = domRect.height;
3045 let x = domRect.x;
3046 let y = domRect.y;
3047 if (offsetX == null && data.x && isXAxis) {
3048 offsetX = domRect.x - data.x;
3049 }
3050 if (offsetY == null && data.y && isYAxis) {
3051 offsetY = domRect.y - data.y;
3052 }
3053 x -= offsetX || 0;
3054 y -= offsetY || 0;
3055 width = 0;
3056 height = 0;
3057 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3058 width = data.axis === "y" ? domRect.width : 0;
3059 height = data.axis === "x" ? domRect.height : 0;
3060 x = isXAxis && data.x != null ? data.x : x;
3061 y = isYAxis && data.y != null ? data.y : y;
3062 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3063 height = data.axis === "x" ? domRect.height : height;
3064 width = data.axis === "y" ? domRect.width : width;
3065 }
3066 isAutoUpdateEvent = true;
3067 return {
3068 width,
3069 height,
3070 x,
3071 y,
3072 top: y,
3073 right: x + width,
3074 bottom: y + height,
3075 left: x
3076 };
3077 }
3078 };
3079 }
3080 function isMouseBasedEvent(event) {
3081 return event != null && event.clientX != null;
3082 }
3083 function useClientPoint(context, props = {}) {
3084 const {
3085 enabled = true,
3086 axis = "both"
3087 } = props;
3088 const store2 = "rootStore" in context ? context.rootStore : context;
3089 const open = store2.useState("open");
3090 const floating = store2.useState("floatingElement");
3091 const domReference = store2.useState("domReferenceElement");
3092 const dataRef = store2.context.dataRef;
3093 const initialRef = React17.useRef(false);
3094 const cleanupListenerRef = React17.useRef(null);
3095 const [pointerType, setPointerType] = React17.useState();
3096 const [reactive, setReactive] = React17.useState([]);
3097 const resetReference = useStableCallback((reference2) => {
3098 store2.set("positionReference", reference2);
3099 });
3100 const setReference = useStableCallback((newX, newY, referenceElement) => {
3101 if (initialRef.current) {
3102 return;
3103 }
3104 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3105 return;
3106 }
3107 store2.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3108 x: newX,
3109 y: newY,
3110 axis,
3111 dataRef,
3112 pointerType
3113 }));
3114 });
3115 const handleReferenceEnterOrMove = useStableCallback((event) => {
3116 if (!open) {
3117 setReference(event.clientX, event.clientY, event.currentTarget);
3118 } else if (!cleanupListenerRef.current) {
3119 setReference(event.clientX, event.clientY, event.currentTarget);
3120 setReactive([]);
3121 }
3122 });
3123 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3124 React17.useEffect(() => {
3125 if (!enabled) {
3126 resetReference(domReference);
3127 return void 0;
3128 }
3129 if (!openCheck) {
3130 return void 0;
3131 }
3132 function cleanupListener() {
3133 cleanupListenerRef.current?.();
3134 cleanupListenerRef.current = null;
3135 }
3136 const win = getWindow(floating);
3137 function handleMouseMove(event) {
3138 const target = getTarget(event);
3139 if (!contains(floating, target)) {
3140 setReference(event.clientX, event.clientY);
3141 } else {
3142 cleanupListener();
3143 }
3144 }
3145 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3146 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3147 } else {
3148 resetReference(domReference);
3149 }
3150 return cleanupListener;
3151 }, [openCheck, enabled, floating, dataRef, domReference, store2, setReference, resetReference, reactive]);
3152 React17.useEffect(() => () => {
3153 store2.set("positionReference", null);
3154 }, [store2]);
3155 React17.useEffect(() => {
3156 if (enabled && !floating) {
3157 initialRef.current = false;
3158 }
3159 }, [enabled, floating]);
3160 React17.useEffect(() => {
3161 if (!enabled && open) {
3162 initialRef.current = true;
3163 }
3164 }, [enabled, open]);
3165 const reference = React17.useMemo(() => {
3166 function setPointerTypeRef(event) {
3167 setPointerType(event.pointerType);
3168 }
3169 return {
3170 onPointerDown: setPointerTypeRef,
3171 onPointerEnter: setPointerTypeRef,
3172 onMouseMove: handleReferenceEnterOrMove,
3173 onMouseEnter: handleReferenceEnterOrMove
3174 };
3175 }, [handleReferenceEnterOrMove]);
3176 return React17.useMemo(() => enabled ? {
3177 reference,
3178 trigger: reference
3179 } : {}, [enabled, reference]);
3180 }
3181
3182 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3183 var React18 = __toESM(require_react(), 1);
3184 var bubbleHandlerKeys = {
3185 intentional: "onClick",
3186 sloppy: "onPointerDown"
3187 };
3188 function alwaysFalse() {
3189 return false;
3190 }
3191 function normalizeProp(normalizable) {
3192 return {
3193 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3194 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3195 };
3196 }
3197 function useDismiss(context, props = {}) {
3198 const {
3199 enabled = true,
3200 escapeKey: escapeKey2 = true,
3201 outsidePress: outsidePressProp = true,
3202 outsidePressEvent = "sloppy",
3203 referencePress = alwaysFalse,
3204 referencePressEvent = "sloppy",
3205 bubbles,
3206 externalTree
3207 } = props;
3208 const store2 = "rootStore" in context ? context.rootStore : context;
3209 const open = store2.useState("open");
3210 const floatingElement = store2.useState("floatingElement");
3211 const {
3212 dataRef
3213 } = store2.context;
3214 const tree = useFloatingTree(externalTree);
3215 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3216 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3217 const outsidePressEnabled = outsidePress2 !== false;
3218 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3219 const {
3220 escapeKey: escapeKeyBubbles,
3221 outsidePress: outsidePressBubbles
3222 } = normalizeProp(bubbles);
3223 const pressStartedInsideRef = React18.useRef(false);
3224 const pressStartPreventedRef = React18.useRef(false);
3225 const suppressNextOutsideClickRef = React18.useRef(false);
3226 const isComposingRef = React18.useRef(false);
3227 const currentPointerTypeRef = React18.useRef("");
3228 const touchStateRef = React18.useRef(null);
3229 const cancelDismissOnEndTimeout = useTimeout();
3230 const clearInsideReactTreeTimeout = useTimeout();
3231 const clearInsideReactTree = useStableCallback(() => {
3232 clearInsideReactTreeTimeout.clear();
3233 dataRef.current.insideReactTree = false;
3234 });
3235 const hasBlockingChild = useStableCallback((bubbleKey) => {
3236 const nodeId = dataRef.current.floatingContext?.nodeId;
3237 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3238 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3239 });
3240 const isEventWithinOwnElements = useStableCallback((event) => {
3241 return isEventTargetWithin(event, store2.select("floatingElement")) || isEventTargetWithin(event, store2.select("domReferenceElement"));
3242 });
3243 const closeOnReferencePress = useStableCallback((event) => {
3244 if (!referencePress()) {
3245 return;
3246 }
3247 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3248 });
3249 const closeOnEscapeKeyDown = useStableCallback((event) => {
3250 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3251 return;
3252 }
3253 if (isComposingRef.current) {
3254 return;
3255 }
3256 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3257 return;
3258 }
3259 const native = isReactEvent(event) ? event.nativeEvent : event;
3260 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3261 store2.setOpen(false, eventDetails);
3262 if (!eventDetails.isCanceled) {
3263 event.preventDefault();
3264 }
3265 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3266 event.stopPropagation();
3267 }
3268 });
3269 const markInsideReactTree = useStableCallback(() => {
3270 dataRef.current.insideReactTree = true;
3271 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3272 });
3273 const markPressStartedInsideReactTree = useStableCallback((event) => {
3274 if (!open || !enabled || event.button !== 0) {
3275 return;
3276 }
3277 const target = getTarget(event.nativeEvent);
3278 if (!contains(store2.select("floatingElement"), target)) {
3279 return;
3280 }
3281 if (!pressStartedInsideRef.current) {
3282 pressStartedInsideRef.current = true;
3283 pressStartPreventedRef.current = false;
3284 }
3285 });
3286 const markInsidePressStartPrevented = useStableCallback((event) => {
3287 if (!open || !enabled) {
3288 return;
3289 }
3290 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3291 return;
3292 }
3293 if (pressStartedInsideRef.current) {
3294 pressStartPreventedRef.current = true;
3295 }
3296 });
3297 React18.useEffect(() => {
3298 if (!open || !enabled) {
3299 return void 0;
3300 }
3301 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3302 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3303 const compositionTimeout = new Timeout();
3304 const preventedPressSuppressionTimeout = new Timeout();
3305 function handleCompositionStart() {
3306 compositionTimeout.clear();
3307 isComposingRef.current = true;
3308 }
3309 function handleCompositionEnd() {
3310 compositionTimeout.start(
3311 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3312 // Only apply to WebKit for the test to remain 0ms.
3313 isWebKit() ? 5 : 0,
3314 () => {
3315 isComposingRef.current = false;
3316 }
3317 );
3318 }
3319 function suppressImmediateOutsideClickAfterPreventedStart() {
3320 suppressNextOutsideClickRef.current = true;
3321 preventedPressSuppressionTimeout.start(0, () => {
3322 suppressNextOutsideClickRef.current = false;
3323 });
3324 }
3325 function resetPressStartState() {
3326 pressStartedInsideRef.current = false;
3327 pressStartPreventedRef.current = false;
3328 }
3329 function getOutsidePressEvent() {
3330 const type = currentPointerTypeRef.current;
3331 const computedType = type === "pen" || !type ? "mouse" : type;
3332 const outsidePressEventValue = getOutsidePressEventProp();
3333 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3334 if (typeof resolved === "string") {
3335 return resolved;
3336 }
3337 return resolved[computedType];
3338 }
3339 function shouldIgnoreEvent(event) {
3340 const computedOutsidePressEvent = getOutsidePressEvent();
3341 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3342 }
3343 function isEventWithinFloatingTree(event) {
3344 const nodeId = dataRef.current.floatingContext?.nodeId;
3345 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3346 return isEventWithinOwnElements(event) || targetIsInsideChildren;
3347 }
3348 function closeOnPressOutside(event) {
3349 if (shouldIgnoreEvent(event)) {
3350 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
3351 preventedPressSuppressionTimeout.clear();
3352 suppressNextOutsideClickRef.current = false;
3353 }
3354 clearInsideReactTree();
3355 return;
3356 }
3357 if (dataRef.current.insideReactTree) {
3358 clearInsideReactTree();
3359 return;
3360 }
3361 const target = getTarget(event);
3362 const inertSelector = `[${createAttribute("inert")}]`;
3363 const targetRoot = isElement(target) ? target.getRootNode() : null;
3364 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store2.select("floatingElement"))).querySelectorAll(inertSelector));
3365 const triggers = store2.context.triggerElements;
3366 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3367 return;
3368 }
3369 let targetRootAncestor = isElement(target) ? target : null;
3370 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3371 const nextParent = getParentNode(targetRootAncestor);
3372 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3373 break;
3374 }
3375 targetRootAncestor = nextParent;
3376 }
3377 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3378 !contains(target, store2.select("floatingElement")) && // If the target root element contains none of the markers, then the
3379 // element was injected after the floating element rendered.
3380 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3381 return;
3382 }
3383 if (isHTMLElement(target) && !("touches" in event)) {
3384 const lastTraversableNode = isLastTraversableNode(target);
3385 const style = getComputedStyle2(target);
3386 const scrollRe = /auto|scroll/;
3387 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3388 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3389 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3390 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3391 const isRTL2 = style.direction === "rtl";
3392 const pressedVerticalScrollbar = canScrollY && (isRTL2 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3393 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3394 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3395 return;
3396 }
3397 }
3398 if (isEventWithinFloatingTree(event)) {
3399 return;
3400 }
3401 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3402 preventedPressSuppressionTimeout.clear();
3403 suppressNextOutsideClickRef.current = false;
3404 return;
3405 }
3406 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3407 return;
3408 }
3409 if (hasBlockingChild("__outsidePressBubbles")) {
3410 return;
3411 }
3412 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3413 clearInsideReactTree();
3414 }
3415 function handlePointerDown(event) {
3416 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) {
3417 return;
3418 }
3419 closeOnPressOutside(event);
3420 }
3421 function handleTouchStart(event) {
3422 if (getOutsidePressEvent() !== "sloppy" || !store2.select("open") || !enabled || isEventWithinOwnElements(event)) {
3423 return;
3424 }
3425 const touch = event.touches[0];
3426 if (touch) {
3427 touchStateRef.current = {
3428 startTime: Date.now(),
3429 startX: touch.clientX,
3430 startY: touch.clientY,
3431 dismissOnTouchEnd: false,
3432 dismissOnMouseDown: true
3433 };
3434 cancelDismissOnEndTimeout.start(1e3, () => {
3435 if (touchStateRef.current) {
3436 touchStateRef.current.dismissOnTouchEnd = false;
3437 touchStateRef.current.dismissOnMouseDown = false;
3438 }
3439 });
3440 }
3441 }
3442 function addTargetEventListenerOnce(event, listener) {
3443 const target = getTarget(event);
3444 if (!target) {
3445 return;
3446 }
3447 const unsubscribe2 = addEventListener(target, event.type, () => {
3448 listener(event);
3449 unsubscribe2();
3450 });
3451 }
3452 function handleTouchStartCapture(event) {
3453 currentPointerTypeRef.current = "touch";
3454 addTargetEventListenerOnce(event, handleTouchStart);
3455 }
3456 function closeOnPressOutsideCapture(event) {
3457 cancelDismissOnEndTimeout.clear();
3458 if (event.type === "pointerdown") {
3459 currentPointerTypeRef.current = event.pointerType;
3460 }
3461 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3462 return;
3463 }
3464 addTargetEventListenerOnce(event, (targetEvent) => {
3465 if (targetEvent.type === "pointerdown") {
3466 handlePointerDown(targetEvent);
3467 } else {
3468 closeOnPressOutside(targetEvent);
3469 }
3470 });
3471 }
3472 function handlePressEndCapture(event) {
3473 if (!pressStartedInsideRef.current) {
3474 return;
3475 }
3476 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3477 resetPressStartState();
3478 if (getOutsidePressEvent() !== "intentional") {
3479 return;
3480 }
3481 if (event.type === "pointercancel") {
3482 if (pressStartedInsideDefaultPrevented) {
3483 suppressImmediateOutsideClickAfterPreventedStart();
3484 }
3485 return;
3486 }
3487 if (isEventWithinFloatingTree(event)) {
3488 return;
3489 }
3490 if (pressStartedInsideDefaultPrevented) {
3491 suppressImmediateOutsideClickAfterPreventedStart();
3492 return;
3493 }
3494 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3495 return;
3496 }
3497 preventedPressSuppressionTimeout.clear();
3498 suppressNextOutsideClickRef.current = true;
3499 clearInsideReactTree();
3500 }
3501 function handleTouchMove(event) {
3502 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3503 return;
3504 }
3505 const touch = event.touches[0];
3506 if (!touch) {
3507 return;
3508 }
3509 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3510 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3511 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3512 if (distance > 5) {
3513 touchStateRef.current.dismissOnTouchEnd = true;
3514 }
3515 if (distance > 10) {
3516 closeOnPressOutside(event);
3517 cancelDismissOnEndTimeout.clear();
3518 touchStateRef.current = null;
3519 }
3520 }
3521 function handleTouchMoveCapture(event) {
3522 addTargetEventListenerOnce(event, handleTouchMove);
3523 }
3524 function handleTouchEnd(event) {
3525 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3526 return;
3527 }
3528 if (touchStateRef.current.dismissOnTouchEnd) {
3529 closeOnPressOutside(event);
3530 }
3531 cancelDismissOnEndTimeout.clear();
3532 touchStateRef.current = null;
3533 }
3534 function handleTouchEndCapture(event) {
3535 addTargetEventListenerOnce(event, handleTouchEnd);
3536 }
3537 const doc = ownerDocument(floatingElement);
3538 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)));
3539 return () => {
3540 unsubscribe();
3541 compositionTimeout.clear();
3542 preventedPressSuppressionTimeout.clear();
3543 resetPressStartState();
3544 suppressNextOutsideClickRef.current = false;
3545 };
3546 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store2, cancelDismissOnEndTimeout]);
3547 React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3548 const reference = React18.useMemo(() => ({
3549 onKeyDown: closeOnEscapeKeyDown,
3550 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress,
3551 ...referencePressEvent !== "intentional" && {
3552 onClick: closeOnReferencePress
3553 }
3554 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]);
3555 const floating = React18.useMemo(() => ({
3556 onKeyDown: closeOnEscapeKeyDown,
3557 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3558 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3559 // See https://github.com/mui/base-ui/pull/3379
3560 onPointerDown: markInsidePressStartPrevented,
3561 onMouseDown: markInsidePressStartPrevented,
3562 onClickCapture: markInsideReactTree,
3563 onMouseDownCapture(event) {
3564 markInsideReactTree();
3565 markPressStartedInsideReactTree(event);
3566 },
3567 onPointerDownCapture(event) {
3568 markInsideReactTree();
3569 markPressStartedInsideReactTree(event);
3570 },
3571 onMouseUpCapture: markInsideReactTree,
3572 onTouchEndCapture: markInsideReactTree,
3573 onTouchMoveCapture: markInsideReactTree
3574 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3575 return React18.useMemo(() => enabled ? {
3576 reference,
3577 floating,
3578 trigger: reference
3579 } : {}, [enabled, reference, floating]);
3580 }
3581
3582 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3583 var React25 = __toESM(require_react(), 1);
3584
3585 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3586 function computeCoordsFromPlacement(_ref, placement, rtl) {
3587 let {
3588 reference,
3589 floating
3590 } = _ref;
3591 const sideAxis = getSideAxis(placement);
3592 const alignmentAxis = getAlignmentAxis(placement);
3593 const alignLength = getAxisLength(alignmentAxis);
3594 const side = getSide(placement);
3595 const isVertical = sideAxis === "y";
3596 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3597 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3598 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3599 let coords;
3600 switch (side) {
3601 case "top":
3602 coords = {
3603 x: commonX,
3604 y: reference.y - floating.height
3605 };
3606 break;
3607 case "bottom":
3608 coords = {
3609 x: commonX,
3610 y: reference.y + reference.height
3611 };
3612 break;
3613 case "right":
3614 coords = {
3615 x: reference.x + reference.width,
3616 y: commonY
3617 };
3618 break;
3619 case "left":
3620 coords = {
3621 x: reference.x - floating.width,
3622 y: commonY
3623 };
3624 break;
3625 default:
3626 coords = {
3627 x: reference.x,
3628 y: reference.y
3629 };
3630 }
3631 switch (getAlignment(placement)) {
3632 case "start":
3633 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3634 break;
3635 case "end":
3636 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3637 break;
3638 }
3639 return coords;
3640 }
3641 async function detectOverflow(state, options) {
3642 var _await$platform$isEle;
3643 if (options === void 0) {
3644 options = {};
3645 }
3646 const {
3647 x,
3648 y,
3649 platform: platform3,
3650 rects,
3651 elements,
3652 strategy
3653 } = state;
3654 const {
3655 boundary = "clippingAncestors",
3656 rootBoundary = "viewport",
3657 elementContext = "floating",
3658 altBoundary = false,
3659 padding = 0
3660 } = evaluate(options, state);
3661 const paddingObject = getPaddingObject(padding);
3662 const altContext = elementContext === "floating" ? "reference" : "floating";
3663 const element = elements[altBoundary ? altContext : elementContext];
3664 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3665 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)),
3666 boundary,
3667 rootBoundary,
3668 strategy
3669 }));
3670 const rect = elementContext === "floating" ? {
3671 x,
3672 y,
3673 width: rects.floating.width,
3674 height: rects.floating.height
3675 } : rects.reference;
3676 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3677 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3678 x: 1,
3679 y: 1
3680 } : {
3681 x: 1,
3682 y: 1
3683 };
3684 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3685 elements,
3686 rect,
3687 offsetParent,
3688 strategy
3689 }) : rect);
3690 return {
3691 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3692 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3693 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3694 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3695 };
3696 }
3697 var MAX_RESET_COUNT = 50;
3698 var computePosition = async (reference, floating, config) => {
3699 const {
3700 placement = "bottom",
3701 strategy = "absolute",
3702 middleware = [],
3703 platform: platform3
3704 } = config;
3705 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3706 ...platform3,
3707 detectOverflow
3708 };
3709 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3710 let rects = await platform3.getElementRects({
3711 reference,
3712 floating,
3713 strategy
3714 });
3715 let {
3716 x,
3717 y
3718 } = computeCoordsFromPlacement(rects, placement, rtl);
3719 let statefulPlacement = placement;
3720 let resetCount = 0;
3721 const middlewareData = {};
3722 for (let i = 0; i < middleware.length; i++) {
3723 const currentMiddleware = middleware[i];
3724 if (!currentMiddleware) {
3725 continue;
3726 }
3727 const {
3728 name,
3729 fn
3730 } = currentMiddleware;
3731 const {
3732 x: nextX,
3733 y: nextY,
3734 data,
3735 reset
3736 } = await fn({
3737 x,
3738 y,
3739 initialPlacement: placement,
3740 placement: statefulPlacement,
3741 strategy,
3742 middlewareData,
3743 rects,
3744 platform: platformWithDetectOverflow,
3745 elements: {
3746 reference,
3747 floating
3748 }
3749 });
3750 x = nextX != null ? nextX : x;
3751 y = nextY != null ? nextY : y;
3752 middlewareData[name] = {
3753 ...middlewareData[name],
3754 ...data
3755 };
3756 if (reset && resetCount < MAX_RESET_COUNT) {
3757 resetCount++;
3758 if (typeof reset === "object") {
3759 if (reset.placement) {
3760 statefulPlacement = reset.placement;
3761 }
3762 if (reset.rects) {
3763 rects = reset.rects === true ? await platform3.getElementRects({
3764 reference,
3765 floating,
3766 strategy
3767 }) : reset.rects;
3768 }
3769 ({
3770 x,
3771 y
3772 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3773 }
3774 i = -1;
3775 }
3776 }
3777 return {
3778 x,
3779 y,
3780 placement: statefulPlacement,
3781 strategy,
3782 middlewareData
3783 };
3784 };
3785 var flip = function(options) {
3786 if (options === void 0) {
3787 options = {};
3788 }
3789 return {
3790 name: "flip",
3791 options,
3792 async fn(state) {
3793 var _middlewareData$arrow, _middlewareData$flip;
3794 const {
3795 placement,
3796 middlewareData,
3797 rects,
3798 initialPlacement,
3799 platform: platform3,
3800 elements
3801 } = state;
3802 const {
3803 mainAxis: checkMainAxis = true,
3804 crossAxis: checkCrossAxis = true,
3805 fallbackPlacements: specifiedFallbackPlacements,
3806 fallbackStrategy = "bestFit",
3807 fallbackAxisSideDirection = "none",
3808 flipAlignment = true,
3809 ...detectOverflowOptions
3810 } = evaluate(options, state);
3811 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3812 return {};
3813 }
3814 const side = getSide(placement);
3815 const initialSideAxis = getSideAxis(initialPlacement);
3816 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3817 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3818 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3819 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3820 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3821 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3822 }
3823 const placements2 = [initialPlacement, ...fallbackPlacements];
3824 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3825 const overflows = [];
3826 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3827 if (checkMainAxis) {
3828 overflows.push(overflow[side]);
3829 }
3830 if (checkCrossAxis) {
3831 const sides2 = getAlignmentSides(placement, rects, rtl);
3832 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3833 }
3834 overflowsData = [...overflowsData, {
3835 placement,
3836 overflows
3837 }];
3838 if (!overflows.every((side2) => side2 <= 0)) {
3839 var _middlewareData$flip2, _overflowsData$filter;
3840 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3841 const nextPlacement = placements2[nextIndex];
3842 if (nextPlacement) {
3843 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3844 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3845 // overflows the main axis.
3846 overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
3847 return {
3848 data: {
3849 index: nextIndex,
3850 overflows: overflowsData
3851 },
3852 reset: {
3853 placement: nextPlacement
3854 }
3855 };
3856 }
3857 }
3858 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;
3859 if (!resetPlacement) {
3860 switch (fallbackStrategy) {
3861 case "bestFit": {
3862 var _overflowsData$filter2;
3863 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
3864 if (hasFallbackAxisSideDirection) {
3865 const currentSideAxis = getSideAxis(d.placement);
3866 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3867 // reading directions favoring greater width.
3868 currentSideAxis === "y";
3869 }
3870 return true;
3871 }).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];
3872 if (placement2) {
3873 resetPlacement = placement2;
3874 }
3875 break;
3876 }
3877 case "initialPlacement":
3878 resetPlacement = initialPlacement;
3879 break;
3880 }
3881 }
3882 if (placement !== resetPlacement) {
3883 return {
3884 reset: {
3885 placement: resetPlacement
3886 }
3887 };
3888 }
3889 }
3890 return {};
3891 }
3892 };
3893 };
3894 function getSideOffsets(overflow, rect) {
3895 return {
3896 top: overflow.top - rect.height,
3897 right: overflow.right - rect.width,
3898 bottom: overflow.bottom - rect.height,
3899 left: overflow.left - rect.width
3900 };
3901 }
3902 function isAnySideFullyClipped(overflow) {
3903 return sides.some((side) => overflow[side] >= 0);
3904 }
3905 var hide = function(options) {
3906 if (options === void 0) {
3907 options = {};
3908 }
3909 return {
3910 name: "hide",
3911 options,
3912 async fn(state) {
3913 const {
3914 rects,
3915 platform: platform3
3916 } = state;
3917 const {
3918 strategy = "referenceHidden",
3919 ...detectOverflowOptions
3920 } = evaluate(options, state);
3921 switch (strategy) {
3922 case "referenceHidden": {
3923 const overflow = await platform3.detectOverflow(state, {
3924 ...detectOverflowOptions,
3925 elementContext: "reference"
3926 });
3927 const offsets = getSideOffsets(overflow, rects.reference);
3928 return {
3929 data: {
3930 referenceHiddenOffsets: offsets,
3931 referenceHidden: isAnySideFullyClipped(offsets)
3932 }
3933 };
3934 }
3935 case "escaped": {
3936 const overflow = await platform3.detectOverflow(state, {
3937 ...detectOverflowOptions,
3938 altBoundary: true
3939 });
3940 const offsets = getSideOffsets(overflow, rects.floating);
3941 return {
3942 data: {
3943 escapedOffsets: offsets,
3944 escaped: isAnySideFullyClipped(offsets)
3945 }
3946 };
3947 }
3948 default: {
3949 return {};
3950 }
3951 }
3952 }
3953 };
3954 };
3955 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
3956 async function convertValueToCoords(state, options) {
3957 const {
3958 placement,
3959 platform: platform3,
3960 elements
3961 } = state;
3962 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3963 const side = getSide(placement);
3964 const alignment = getAlignment(placement);
3965 const isVertical = getSideAxis(placement) === "y";
3966 const mainAxisMulti = originSides.has(side) ? -1 : 1;
3967 const crossAxisMulti = rtl && isVertical ? -1 : 1;
3968 const rawValue = evaluate(options, state);
3969 let {
3970 mainAxis,
3971 crossAxis,
3972 alignmentAxis
3973 } = typeof rawValue === "number" ? {
3974 mainAxis: rawValue,
3975 crossAxis: 0,
3976 alignmentAxis: null
3977 } : {
3978 mainAxis: rawValue.mainAxis || 0,
3979 crossAxis: rawValue.crossAxis || 0,
3980 alignmentAxis: rawValue.alignmentAxis
3981 };
3982 if (alignment && typeof alignmentAxis === "number") {
3983 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
3984 }
3985 return isVertical ? {
3986 x: crossAxis * crossAxisMulti,
3987 y: mainAxis * mainAxisMulti
3988 } : {
3989 x: mainAxis * mainAxisMulti,
3990 y: crossAxis * crossAxisMulti
3991 };
3992 }
3993 var offset = function(options) {
3994 if (options === void 0) {
3995 options = 0;
3996 }
3997 return {
3998 name: "offset",
3999 options,
4000 async fn(state) {
4001 var _middlewareData$offse, _middlewareData$arrow;
4002 const {
4003 x,
4004 y,
4005 placement,
4006 middlewareData
4007 } = state;
4008 const diffCoords = await convertValueToCoords(state, options);
4009 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4010 return {};
4011 }
4012 return {
4013 x: x + diffCoords.x,
4014 y: y + diffCoords.y,
4015 data: {
4016 ...diffCoords,
4017 placement
4018 }
4019 };
4020 }
4021 };
4022 };
4023 var shift = function(options) {
4024 if (options === void 0) {
4025 options = {};
4026 }
4027 return {
4028 name: "shift",
4029 options,
4030 async fn(state) {
4031 const {
4032 x,
4033 y,
4034 placement,
4035 platform: platform3
4036 } = state;
4037 const {
4038 mainAxis: checkMainAxis = true,
4039 crossAxis: checkCrossAxis = false,
4040 limiter = {
4041 fn: (_ref) => {
4042 let {
4043 x: x2,
4044 y: y2
4045 } = _ref;
4046 return {
4047 x: x2,
4048 y: y2
4049 };
4050 }
4051 },
4052 ...detectOverflowOptions
4053 } = evaluate(options, state);
4054 const coords = {
4055 x,
4056 y
4057 };
4058 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4059 const crossAxis = getSideAxis(getSide(placement));
4060 const mainAxis = getOppositeAxis(crossAxis);
4061 let mainAxisCoord = coords[mainAxis];
4062 let crossAxisCoord = coords[crossAxis];
4063 if (checkMainAxis) {
4064 const minSide = mainAxis === "y" ? "top" : "left";
4065 const maxSide = mainAxis === "y" ? "bottom" : "right";
4066 const min2 = mainAxisCoord + overflow[minSide];
4067 const max2 = mainAxisCoord - overflow[maxSide];
4068 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4069 }
4070 if (checkCrossAxis) {
4071 const minSide = crossAxis === "y" ? "top" : "left";
4072 const maxSide = crossAxis === "y" ? "bottom" : "right";
4073 const min2 = crossAxisCoord + overflow[minSide];
4074 const max2 = crossAxisCoord - overflow[maxSide];
4075 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4076 }
4077 const limitedCoords = limiter.fn({
4078 ...state,
4079 [mainAxis]: mainAxisCoord,
4080 [crossAxis]: crossAxisCoord
4081 });
4082 return {
4083 ...limitedCoords,
4084 data: {
4085 x: limitedCoords.x - x,
4086 y: limitedCoords.y - y,
4087 enabled: {
4088 [mainAxis]: checkMainAxis,
4089 [crossAxis]: checkCrossAxis
4090 }
4091 }
4092 };
4093 }
4094 };
4095 };
4096 var limitShift = function(options) {
4097 if (options === void 0) {
4098 options = {};
4099 }
4100 return {
4101 options,
4102 fn(state) {
4103 const {
4104 x,
4105 y,
4106 placement,
4107 rects,
4108 middlewareData
4109 } = state;
4110 const {
4111 offset: offset4 = 0,
4112 mainAxis: checkMainAxis = true,
4113 crossAxis: checkCrossAxis = true
4114 } = evaluate(options, state);
4115 const coords = {
4116 x,
4117 y
4118 };
4119 const crossAxis = getSideAxis(placement);
4120 const mainAxis = getOppositeAxis(crossAxis);
4121 let mainAxisCoord = coords[mainAxis];
4122 let crossAxisCoord = coords[crossAxis];
4123 const rawOffset = evaluate(offset4, state);
4124 const computedOffset = typeof rawOffset === "number" ? {
4125 mainAxis: rawOffset,
4126 crossAxis: 0
4127 } : {
4128 mainAxis: 0,
4129 crossAxis: 0,
4130 ...rawOffset
4131 };
4132 if (checkMainAxis) {
4133 const len = mainAxis === "y" ? "height" : "width";
4134 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4135 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4136 if (mainAxisCoord < limitMin) {
4137 mainAxisCoord = limitMin;
4138 } else if (mainAxisCoord > limitMax) {
4139 mainAxisCoord = limitMax;
4140 }
4141 }
4142 if (checkCrossAxis) {
4143 var _middlewareData$offse, _middlewareData$offse2;
4144 const len = mainAxis === "y" ? "width" : "height";
4145 const isOriginSide = originSides.has(getSide(placement));
4146 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);
4147 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);
4148 if (crossAxisCoord < limitMin) {
4149 crossAxisCoord = limitMin;
4150 } else if (crossAxisCoord > limitMax) {
4151 crossAxisCoord = limitMax;
4152 }
4153 }
4154 return {
4155 [mainAxis]: mainAxisCoord,
4156 [crossAxis]: crossAxisCoord
4157 };
4158 }
4159 };
4160 };
4161 var size = function(options) {
4162 if (options === void 0) {
4163 options = {};
4164 }
4165 return {
4166 name: "size",
4167 options,
4168 async fn(state) {
4169 var _state$middlewareData, _state$middlewareData2;
4170 const {
4171 placement,
4172 rects,
4173 platform: platform3,
4174 elements
4175 } = state;
4176 const {
4177 apply = () => {
4178 },
4179 ...detectOverflowOptions
4180 } = evaluate(options, state);
4181 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4182 const side = getSide(placement);
4183 const alignment = getAlignment(placement);
4184 const isYAxis = getSideAxis(placement) === "y";
4185 const {
4186 width,
4187 height
4188 } = rects.floating;
4189 let heightSide;
4190 let widthSide;
4191 if (side === "top" || side === "bottom") {
4192 heightSide = side;
4193 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4194 } else {
4195 widthSide = side;
4196 heightSide = alignment === "end" ? "top" : "bottom";
4197 }
4198 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4199 const maximumClippingWidth = width - overflow.left - overflow.right;
4200 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4201 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4202 const noShift = !state.middlewareData.shift;
4203 let availableHeight = overflowAvailableHeight;
4204 let availableWidth = overflowAvailableWidth;
4205 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4206 availableWidth = maximumClippingWidth;
4207 }
4208 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4209 availableHeight = maximumClippingHeight;
4210 }
4211 if (noShift && !alignment) {
4212 const xMin = max(overflow.left, 0);
4213 const xMax = max(overflow.right, 0);
4214 const yMin = max(overflow.top, 0);
4215 const yMax = max(overflow.bottom, 0);
4216 if (isYAxis) {
4217 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4218 } else {
4219 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4220 }
4221 }
4222 await apply({
4223 ...state,
4224 availableWidth,
4225 availableHeight
4226 });
4227 const nextDimensions = await platform3.getDimensions(elements.floating);
4228 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4229 return {
4230 reset: {
4231 rects: true
4232 }
4233 };
4234 }
4235 return {};
4236 }
4237 };
4238 };
4239
4240 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4241 function getCssDimensions(element) {
4242 const css = getComputedStyle2(element);
4243 let width = parseFloat(css.width) || 0;
4244 let height = parseFloat(css.height) || 0;
4245 const hasOffset = isHTMLElement(element);
4246 const offsetWidth = hasOffset ? element.offsetWidth : width;
4247 const offsetHeight = hasOffset ? element.offsetHeight : height;
4248 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4249 if (shouldFallback) {
4250 width = offsetWidth;
4251 height = offsetHeight;
4252 }
4253 return {
4254 width,
4255 height,
4256 $: shouldFallback
4257 };
4258 }
4259 function unwrapElement(element) {
4260 return !isElement(element) ? element.contextElement : element;
4261 }
4262 function getScale(element) {
4263 const domElement = unwrapElement(element);
4264 if (!isHTMLElement(domElement)) {
4265 return createCoords(1);
4266 }
4267 const rect = domElement.getBoundingClientRect();
4268 const {
4269 width,
4270 height,
4271 $
4272 } = getCssDimensions(domElement);
4273 let x = ($ ? round(rect.width) : rect.width) / width;
4274 let y = ($ ? round(rect.height) : rect.height) / height;
4275 if (!x || !Number.isFinite(x)) {
4276 x = 1;
4277 }
4278 if (!y || !Number.isFinite(y)) {
4279 y = 1;
4280 }
4281 return {
4282 x,
4283 y
4284 };
4285 }
4286 var noOffsets = /* @__PURE__ */ createCoords(0);
4287 function getVisualOffsets(element) {
4288 const win = getWindow(element);
4289 if (!isWebKit() || !win.visualViewport) {
4290 return noOffsets;
4291 }
4292 return {
4293 x: win.visualViewport.offsetLeft,
4294 y: win.visualViewport.offsetTop
4295 };
4296 }
4297 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4298 if (isFixed === void 0) {
4299 isFixed = false;
4300 }
4301 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4302 return false;
4303 }
4304 return isFixed;
4305 }
4306 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4307 if (includeScale === void 0) {
4308 includeScale = false;
4309 }
4310 if (isFixedStrategy === void 0) {
4311 isFixedStrategy = false;
4312 }
4313 const clientRect = element.getBoundingClientRect();
4314 const domElement = unwrapElement(element);
4315 let scale = createCoords(1);
4316 if (includeScale) {
4317 if (offsetParent) {
4318 if (isElement(offsetParent)) {
4319 scale = getScale(offsetParent);
4320 }
4321 } else {
4322 scale = getScale(element);
4323 }
4324 }
4325 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4326 let x = (clientRect.left + visualOffsets.x) / scale.x;
4327 let y = (clientRect.top + visualOffsets.y) / scale.y;
4328 let width = clientRect.width / scale.x;
4329 let height = clientRect.height / scale.y;
4330 if (domElement) {
4331 const win = getWindow(domElement);
4332 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4333 let currentWin = win;
4334 let currentIFrame = getFrameElement(currentWin);
4335 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4336 const iframeScale = getScale(currentIFrame);
4337 const iframeRect = currentIFrame.getBoundingClientRect();
4338 const css = getComputedStyle2(currentIFrame);
4339 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4340 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4341 x *= iframeScale.x;
4342 y *= iframeScale.y;
4343 width *= iframeScale.x;
4344 height *= iframeScale.y;
4345 x += left;
4346 y += top;
4347 currentWin = getWindow(currentIFrame);
4348 currentIFrame = getFrameElement(currentWin);
4349 }
4350 }
4351 return rectToClientRect({
4352 width,
4353 height,
4354 x,
4355 y
4356 });
4357 }
4358 function getWindowScrollBarX(element, rect) {
4359 const leftScroll = getNodeScroll(element).scrollLeft;
4360 if (!rect) {
4361 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4362 }
4363 return rect.left + leftScroll;
4364 }
4365 function getHTMLOffset(documentElement, scroll) {
4366 const htmlRect = documentElement.getBoundingClientRect();
4367 const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4368 const y = htmlRect.top + scroll.scrollTop;
4369 return {
4370 x,
4371 y
4372 };
4373 }
4374 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4375 let {
4376 elements,
4377 rect,
4378 offsetParent,
4379 strategy
4380 } = _ref;
4381 const isFixed = strategy === "fixed";
4382 const documentElement = getDocumentElement(offsetParent);
4383 const topLayer = elements ? isTopLayer(elements.floating) : false;
4384 if (offsetParent === documentElement || topLayer && isFixed) {
4385 return rect;
4386 }
4387 let scroll = {
4388 scrollLeft: 0,
4389 scrollTop: 0
4390 };
4391 let scale = createCoords(1);
4392 const offsets = createCoords(0);
4393 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4394 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4395 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4396 scroll = getNodeScroll(offsetParent);
4397 }
4398 if (isOffsetParentAnElement) {
4399 const offsetRect = getBoundingClientRect(offsetParent);
4400 scale = getScale(offsetParent);
4401 offsets.x = offsetRect.x + offsetParent.clientLeft;
4402 offsets.y = offsetRect.y + offsetParent.clientTop;
4403 }
4404 }
4405 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4406 return {
4407 width: rect.width * scale.x,
4408 height: rect.height * scale.y,
4409 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4410 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4411 };
4412 }
4413 function getClientRects(element) {
4414 return Array.from(element.getClientRects());
4415 }
4416 function getDocumentRect(element) {
4417 const html = getDocumentElement(element);
4418 const scroll = getNodeScroll(element);
4419 const body = element.ownerDocument.body;
4420 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4421 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4422 let x = -scroll.scrollLeft + getWindowScrollBarX(element);
4423 const y = -scroll.scrollTop;
4424 if (getComputedStyle2(body).direction === "rtl") {
4425 x += max(html.clientWidth, body.clientWidth) - width;
4426 }
4427 return {
4428 width,
4429 height,
4430 x,
4431 y
4432 };
4433 }
4434 var SCROLLBAR_MAX = 25;
4435 function getViewportRect(element, strategy) {
4436 const win = getWindow(element);
4437 const html = getDocumentElement(element);
4438 const visualViewport = win.visualViewport;
4439 let width = html.clientWidth;
4440 let height = html.clientHeight;
4441 let x = 0;
4442 let y = 0;
4443 if (visualViewport) {
4444 width = visualViewport.width;
4445 height = visualViewport.height;
4446 const visualViewportBased = isWebKit();
4447 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4448 x = visualViewport.offsetLeft;
4449 y = visualViewport.offsetTop;
4450 }
4451 }
4452 const windowScrollbarX = getWindowScrollBarX(html);
4453 if (windowScrollbarX <= 0) {
4454 const doc = html.ownerDocument;
4455 const body = doc.body;
4456 const bodyStyles = getComputedStyle(body);
4457 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4458 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4459 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4460 width -= clippingStableScrollbarWidth;
4461 }
4462 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4463 width += windowScrollbarX;
4464 }
4465 return {
4466 width,
4467 height,
4468 x,
4469 y
4470 };
4471 }
4472 function getInnerBoundingClientRect(element, strategy) {
4473 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4474 const top = clientRect.top + element.clientTop;
4475 const left = clientRect.left + element.clientLeft;
4476 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4477 const width = element.clientWidth * scale.x;
4478 const height = element.clientHeight * scale.y;
4479 const x = left * scale.x;
4480 const y = top * scale.y;
4481 return {
4482 width,
4483 height,
4484 x,
4485 y
4486 };
4487 }
4488 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4489 let rect;
4490 if (clippingAncestor === "viewport") {
4491 rect = getViewportRect(element, strategy);
4492 } else if (clippingAncestor === "document") {
4493 rect = getDocumentRect(getDocumentElement(element));
4494 } else if (isElement(clippingAncestor)) {
4495 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4496 } else {
4497 const visualOffsets = getVisualOffsets(element);
4498 rect = {
4499 x: clippingAncestor.x - visualOffsets.x,
4500 y: clippingAncestor.y - visualOffsets.y,
4501 width: clippingAncestor.width,
4502 height: clippingAncestor.height
4503 };
4504 }
4505 return rectToClientRect(rect);
4506 }
4507 function hasFixedPositionAncestor(element, stopNode) {
4508 const parentNode = getParentNode(element);
4509 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4510 return false;
4511 }
4512 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4513 }
4514 function getClippingElementAncestors(element, cache) {
4515 const cachedResult = cache.get(element);
4516 if (cachedResult) {
4517 return cachedResult;
4518 }
4519 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4520 let currentContainingBlockComputedStyle = null;
4521 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4522 let currentNode = elementIsFixed ? getParentNode(element) : element;
4523 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4524 const computedStyle = getComputedStyle2(currentNode);
4525 const currentNodeIsContaining = isContainingBlock(currentNode);
4526 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4527 currentContainingBlockComputedStyle = null;
4528 }
4529 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4530 if (shouldDropCurrentNode) {
4531 result = result.filter((ancestor) => ancestor !== currentNode);
4532 } else {
4533 currentContainingBlockComputedStyle = computedStyle;
4534 }
4535 currentNode = getParentNode(currentNode);
4536 }
4537 cache.set(element, result);
4538 return result;
4539 }
4540 function getClippingRect(_ref) {
4541 let {
4542 element,
4543 boundary,
4544 rootBoundary,
4545 strategy
4546 } = _ref;
4547 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4548 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4549 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4550 let top = firstRect.top;
4551 let right = firstRect.right;
4552 let bottom = firstRect.bottom;
4553 let left = firstRect.left;
4554 for (let i = 1; i < clippingAncestors.length; i++) {
4555 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
4556 top = max(rect.top, top);
4557 right = min(rect.right, right);
4558 bottom = min(rect.bottom, bottom);
4559 left = max(rect.left, left);
4560 }
4561 return {
4562 width: right - left,
4563 height: bottom - top,
4564 x: left,
4565 y: top
4566 };
4567 }
4568 function getDimensions(element) {
4569 const {
4570 width,
4571 height
4572 } = getCssDimensions(element);
4573 return {
4574 width,
4575 height
4576 };
4577 }
4578 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4579 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4580 const documentElement = getDocumentElement(offsetParent);
4581 const isFixed = strategy === "fixed";
4582 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4583 let scroll = {
4584 scrollLeft: 0,
4585 scrollTop: 0
4586 };
4587 const offsets = createCoords(0);
4588 function setLeftRTLScrollbarOffset() {
4589 offsets.x = getWindowScrollBarX(documentElement);
4590 }
4591 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4592 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4593 scroll = getNodeScroll(offsetParent);
4594 }
4595 if (isOffsetParentAnElement) {
4596 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4597 offsets.x = offsetRect.x + offsetParent.clientLeft;
4598 offsets.y = offsetRect.y + offsetParent.clientTop;
4599 } else if (documentElement) {
4600 setLeftRTLScrollbarOffset();
4601 }
4602 }
4603 if (isFixed && !isOffsetParentAnElement && documentElement) {
4604 setLeftRTLScrollbarOffset();
4605 }
4606 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4607 const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4608 const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4609 return {
4610 x,
4611 y,
4612 width: rect.width,
4613 height: rect.height
4614 };
4615 }
4616 function isStaticPositioned(element) {
4617 return getComputedStyle2(element).position === "static";
4618 }
4619 function getTrueOffsetParent(element, polyfill) {
4620 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4621 return null;
4622 }
4623 if (polyfill) {
4624 return polyfill(element);
4625 }
4626 let rawOffsetParent = element.offsetParent;
4627 if (getDocumentElement(element) === rawOffsetParent) {
4628 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4629 }
4630 return rawOffsetParent;
4631 }
4632 function getOffsetParent(element, polyfill) {
4633 const win = getWindow(element);
4634 if (isTopLayer(element)) {
4635 return win;
4636 }
4637 if (!isHTMLElement(element)) {
4638 let svgOffsetParent = getParentNode(element);
4639 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4640 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4641 return svgOffsetParent;
4642 }
4643 svgOffsetParent = getParentNode(svgOffsetParent);
4644 }
4645 return win;
4646 }
4647 let offsetParent = getTrueOffsetParent(element, polyfill);
4648 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4649 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4650 }
4651 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4652 return win;
4653 }
4654 return offsetParent || getContainingBlock(element) || win;
4655 }
4656 var getElementRects = async function(data) {
4657 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4658 const getDimensionsFn = this.getDimensions;
4659 const floatingDimensions = await getDimensionsFn(data.floating);
4660 return {
4661 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4662 floating: {
4663 x: 0,
4664 y: 0,
4665 width: floatingDimensions.width,
4666 height: floatingDimensions.height
4667 }
4668 };
4669 };
4670 function isRTL(element) {
4671 return getComputedStyle2(element).direction === "rtl";
4672 }
4673 var platform2 = {
4674 convertOffsetParentRelativeRectToViewportRelativeRect,
4675 getDocumentElement,
4676 getClippingRect,
4677 getOffsetParent,
4678 getElementRects,
4679 getClientRects,
4680 getDimensions,
4681 getScale,
4682 isElement,
4683 isRTL
4684 };
4685 function rectsAreEqual(a, b) {
4686 return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
4687 }
4688 function observeMove(element, onMove) {
4689 let io = null;
4690 let timeoutId;
4691 const root = getDocumentElement(element);
4692 function cleanup() {
4693 var _io;
4694 clearTimeout(timeoutId);
4695 (_io = io) == null || _io.disconnect();
4696 io = null;
4697 }
4698 function refresh(skip, threshold) {
4699 if (skip === void 0) {
4700 skip = false;
4701 }
4702 if (threshold === void 0) {
4703 threshold = 1;
4704 }
4705 cleanup();
4706 const elementRectForRootMargin = element.getBoundingClientRect();
4707 const {
4708 left,
4709 top,
4710 width,
4711 height
4712 } = elementRectForRootMargin;
4713 if (!skip) {
4714 onMove();
4715 }
4716 if (!width || !height) {
4717 return;
4718 }
4719 const insetTop = floor(top);
4720 const insetRight = floor(root.clientWidth - (left + width));
4721 const insetBottom = floor(root.clientHeight - (top + height));
4722 const insetLeft = floor(left);
4723 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4724 const options = {
4725 rootMargin,
4726 threshold: max(0, min(1, threshold)) || 1
4727 };
4728 let isFirstUpdate = true;
4729 function handleObserve(entries) {
4730 const ratio = entries[0].intersectionRatio;
4731 if (ratio !== threshold) {
4732 if (!isFirstUpdate) {
4733 return refresh();
4734 }
4735 if (!ratio) {
4736 timeoutId = setTimeout(() => {
4737 refresh(false, 1e-7);
4738 }, 1e3);
4739 } else {
4740 refresh(false, ratio);
4741 }
4742 }
4743 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4744 refresh();
4745 }
4746 isFirstUpdate = false;
4747 }
4748 try {
4749 io = new IntersectionObserver(handleObserve, {
4750 ...options,
4751 // Handle <iframe>s
4752 root: root.ownerDocument
4753 });
4754 } catch (_e) {
4755 io = new IntersectionObserver(handleObserve, options);
4756 }
4757 io.observe(element);
4758 }
4759 refresh(true);
4760 return cleanup;
4761 }
4762 function autoUpdate(reference, floating, update2, options) {
4763 if (options === void 0) {
4764 options = {};
4765 }
4766 const {
4767 ancestorScroll = true,
4768 ancestorResize = true,
4769 elementResize = typeof ResizeObserver === "function",
4770 layoutShift = typeof IntersectionObserver === "function",
4771 animationFrame = false
4772 } = options;
4773 const referenceEl = unwrapElement(reference);
4774 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4775 ancestors.forEach((ancestor) => {
4776 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4777 passive: true
4778 });
4779 ancestorResize && ancestor.addEventListener("resize", update2);
4780 });
4781 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4782 let reobserveFrame = -1;
4783 let resizeObserver = null;
4784 if (elementResize) {
4785 resizeObserver = new ResizeObserver((_ref) => {
4786 let [firstEntry] = _ref;
4787 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4788 resizeObserver.unobserve(floating);
4789 cancelAnimationFrame(reobserveFrame);
4790 reobserveFrame = requestAnimationFrame(() => {
4791 var _resizeObserver;
4792 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4793 });
4794 }
4795 update2();
4796 });
4797 if (referenceEl && !animationFrame) {
4798 resizeObserver.observe(referenceEl);
4799 }
4800 if (floating) {
4801 resizeObserver.observe(floating);
4802 }
4803 }
4804 let frameId;
4805 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4806 if (animationFrame) {
4807 frameLoop();
4808 }
4809 function frameLoop() {
4810 const nextRefRect = getBoundingClientRect(reference);
4811 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4812 update2();
4813 }
4814 prevRefRect = nextRefRect;
4815 frameId = requestAnimationFrame(frameLoop);
4816 }
4817 update2();
4818 return () => {
4819 var _resizeObserver2;
4820 ancestors.forEach((ancestor) => {
4821 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4822 ancestorResize && ancestor.removeEventListener("resize", update2);
4823 });
4824 cleanupIo == null || cleanupIo();
4825 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4826 resizeObserver = null;
4827 if (animationFrame) {
4828 cancelAnimationFrame(frameId);
4829 }
4830 };
4831 }
4832 var offset2 = offset;
4833 var shift2 = shift;
4834 var flip2 = flip;
4835 var size2 = size;
4836 var hide2 = hide;
4837 var limitShift2 = limitShift;
4838 var computePosition2 = (reference, floating, options) => {
4839 const cache = /* @__PURE__ */ new Map();
4840 const mergedOptions = {
4841 platform: platform2,
4842 ...options
4843 };
4844 const platformWithCache = {
4845 ...mergedOptions.platform,
4846 _c: cache
4847 };
4848 return computePosition(reference, floating, {
4849 ...mergedOptions,
4850 platform: platformWithCache
4851 });
4852 };
4853
4854 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4855 var React19 = __toESM(require_react(), 1);
4856 var import_react2 = __toESM(require_react(), 1);
4857 var ReactDOM3 = __toESM(require_react_dom(), 1);
4858 var isClient = typeof document !== "undefined";
4859 var noop2 = function noop3() {
4860 };
4861 var index = isClient ? import_react2.useLayoutEffect : noop2;
4862 function deepEqual(a, b) {
4863 if (a === b) {
4864 return true;
4865 }
4866 if (typeof a !== typeof b) {
4867 return false;
4868 }
4869 if (typeof a === "function" && a.toString() === b.toString()) {
4870 return true;
4871 }
4872 let length;
4873 let i;
4874 let keys;
4875 if (a && b && typeof a === "object") {
4876 if (Array.isArray(a)) {
4877 length = a.length;
4878 if (length !== b.length) return false;
4879 for (i = length; i-- !== 0; ) {
4880 if (!deepEqual(a[i], b[i])) {
4881 return false;
4882 }
4883 }
4884 return true;
4885 }
4886 keys = Object.keys(a);
4887 length = keys.length;
4888 if (length !== Object.keys(b).length) {
4889 return false;
4890 }
4891 for (i = length; i-- !== 0; ) {
4892 if (!{}.hasOwnProperty.call(b, keys[i])) {
4893 return false;
4894 }
4895 }
4896 for (i = length; i-- !== 0; ) {
4897 const key = keys[i];
4898 if (key === "_owner" && a.$$typeof) {
4899 continue;
4900 }
4901 if (!deepEqual(a[key], b[key])) {
4902 return false;
4903 }
4904 }
4905 return true;
4906 }
4907 return a !== a && b !== b;
4908 }
4909 function getDPR(element) {
4910 if (typeof window === "undefined") {
4911 return 1;
4912 }
4913 const win = element.ownerDocument.defaultView || window;
4914 return win.devicePixelRatio || 1;
4915 }
4916 function roundByDPR(element, value) {
4917 const dpr = getDPR(element);
4918 return Math.round(value * dpr) / dpr;
4919 }
4920 function useLatestRef(value) {
4921 const ref = React19.useRef(value);
4922 index(() => {
4923 ref.current = value;
4924 });
4925 return ref;
4926 }
4927 function useFloating(options) {
4928 if (options === void 0) {
4929 options = {};
4930 }
4931 const {
4932 placement = "bottom",
4933 strategy = "absolute",
4934 middleware = [],
4935 platform: platform3,
4936 elements: {
4937 reference: externalReference,
4938 floating: externalFloating
4939 } = {},
4940 transform = true,
4941 whileElementsMounted,
4942 open
4943 } = options;
4944 const [data, setData] = React19.useState({
4945 x: 0,
4946 y: 0,
4947 strategy,
4948 placement,
4949 middlewareData: {},
4950 isPositioned: false
4951 });
4952 const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware);
4953 if (!deepEqual(latestMiddleware, middleware)) {
4954 setLatestMiddleware(middleware);
4955 }
4956 const [_reference, _setReference] = React19.useState(null);
4957 const [_floating, _setFloating] = React19.useState(null);
4958 const setReference = React19.useCallback((node) => {
4959 if (node !== referenceRef.current) {
4960 referenceRef.current = node;
4961 _setReference(node);
4962 }
4963 }, []);
4964 const setFloating = React19.useCallback((node) => {
4965 if (node !== floatingRef.current) {
4966 floatingRef.current = node;
4967 _setFloating(node);
4968 }
4969 }, []);
4970 const referenceEl = externalReference || _reference;
4971 const floatingEl = externalFloating || _floating;
4972 const referenceRef = React19.useRef(null);
4973 const floatingRef = React19.useRef(null);
4974 const dataRef = React19.useRef(data);
4975 const hasWhileElementsMounted = whileElementsMounted != null;
4976 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
4977 const platformRef = useLatestRef(platform3);
4978 const openRef = useLatestRef(open);
4979 const update2 = React19.useCallback(() => {
4980 if (!referenceRef.current || !floatingRef.current) {
4981 return;
4982 }
4983 const config = {
4984 placement,
4985 strategy,
4986 middleware: latestMiddleware
4987 };
4988 if (platformRef.current) {
4989 config.platform = platformRef.current;
4990 }
4991 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
4992 const fullData = {
4993 ...data2,
4994 // The floating element's position may be recomputed while it's closed
4995 // but still mounted (such as when transitioning out). To ensure
4996 // `isPositioned` will be `false` initially on the next open, avoid
4997 // setting it to `true` when `open === false` (must be specified).
4998 isPositioned: openRef.current !== false
4999 };
5000 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5001 dataRef.current = fullData;
5002 ReactDOM3.flushSync(() => {
5003 setData(fullData);
5004 });
5005 }
5006 });
5007 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5008 index(() => {
5009 if (open === false && dataRef.current.isPositioned) {
5010 dataRef.current.isPositioned = false;
5011 setData((data2) => ({
5012 ...data2,
5013 isPositioned: false
5014 }));
5015 }
5016 }, [open]);
5017 const isMountedRef = React19.useRef(false);
5018 index(() => {
5019 isMountedRef.current = true;
5020 return () => {
5021 isMountedRef.current = false;
5022 };
5023 }, []);
5024 index(() => {
5025 if (referenceEl) referenceRef.current = referenceEl;
5026 if (floatingEl) floatingRef.current = floatingEl;
5027 if (referenceEl && floatingEl) {
5028 if (whileElementsMountedRef.current) {
5029 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5030 }
5031 update2();
5032 }
5033 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5034 const refs = React19.useMemo(() => ({
5035 reference: referenceRef,
5036 floating: floatingRef,
5037 setReference,
5038 setFloating
5039 }), [setReference, setFloating]);
5040 const elements = React19.useMemo(() => ({
5041 reference: referenceEl,
5042 floating: floatingEl
5043 }), [referenceEl, floatingEl]);
5044 const floatingStyles = React19.useMemo(() => {
5045 const initialStyles = {
5046 position: strategy,
5047 left: 0,
5048 top: 0
5049 };
5050 if (!elements.floating) {
5051 return initialStyles;
5052 }
5053 const x = roundByDPR(elements.floating, data.x);
5054 const y = roundByDPR(elements.floating, data.y);
5055 if (transform) {
5056 return {
5057 ...initialStyles,
5058 transform: "translate(" + x + "px, " + y + "px)",
5059 ...getDPR(elements.floating) >= 1.5 && {
5060 willChange: "transform"
5061 }
5062 };
5063 }
5064 return {
5065 position: strategy,
5066 left: x,
5067 top: y
5068 };
5069 }, [strategy, transform, elements.floating, data.x, data.y]);
5070 return React19.useMemo(() => ({
5071 ...data,
5072 update: update2,
5073 refs,
5074 elements,
5075 floatingStyles
5076 }), [data, update2, refs, elements, floatingStyles]);
5077 }
5078 var offset3 = (options, deps) => {
5079 const result = offset2(options);
5080 return {
5081 name: result.name,
5082 fn: result.fn,
5083 options: [options, deps]
5084 };
5085 };
5086 var shift3 = (options, deps) => {
5087 const result = shift2(options);
5088 return {
5089 name: result.name,
5090 fn: result.fn,
5091 options: [options, deps]
5092 };
5093 };
5094 var limitShift3 = (options, deps) => {
5095 const result = limitShift2(options);
5096 return {
5097 fn: result.fn,
5098 options: [options, deps]
5099 };
5100 };
5101 var flip3 = (options, deps) => {
5102 const result = flip2(options);
5103 return {
5104 name: result.name,
5105 fn: result.fn,
5106 options: [options, deps]
5107 };
5108 };
5109 var size3 = (options, deps) => {
5110 const result = size2(options);
5111 return {
5112 name: result.name,
5113 fn: result.fn,
5114 options: [options, deps]
5115 };
5116 };
5117 var hide3 = (options, deps) => {
5118 const result = hide2(options);
5119 return {
5120 name: result.name,
5121 fn: result.fn,
5122 options: [options, deps]
5123 };
5124 };
5125
5126 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5127 var React24 = __toESM(require_react(), 1);
5128
5129 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5130 var React23 = __toESM(require_react(), 1);
5131
5132 // node_modules/@base-ui/utils/esm/store/createSelector.js
5133 var createSelector2 = (a, b, c, d, e, f, ...other) => {
5134 if (other.length > 0) {
5135 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5136 }
5137 let selector;
5138 if (a && b && c && d && e && f) {
5139 selector = (state, a1, a2, a3) => {
5140 const va = a(state, a1, a2, a3);
5141 const vb = b(state, a1, a2, a3);
5142 const vc = c(state, a1, a2, a3);
5143 const vd = d(state, a1, a2, a3);
5144 const ve = e(state, a1, a2, a3);
5145 return f(va, vb, vc, vd, ve, a1, a2, a3);
5146 };
5147 } else if (a && b && c && d && e) {
5148 selector = (state, a1, a2, a3) => {
5149 const va = a(state, a1, a2, a3);
5150 const vb = b(state, a1, a2, a3);
5151 const vc = c(state, a1, a2, a3);
5152 const vd = d(state, a1, a2, a3);
5153 return e(va, vb, vc, vd, a1, a2, a3);
5154 };
5155 } else if (a && b && c && d) {
5156 selector = (state, a1, a2, a3) => {
5157 const va = a(state, a1, a2, a3);
5158 const vb = b(state, a1, a2, a3);
5159 const vc = c(state, a1, a2, a3);
5160 return d(va, vb, vc, a1, a2, a3);
5161 };
5162 } else if (a && b && c) {
5163 selector = (state, a1, a2, a3) => {
5164 const va = a(state, a1, a2, a3);
5165 const vb = b(state, a1, a2, a3);
5166 return c(va, vb, a1, a2, a3);
5167 };
5168 } else if (a && b) {
5169 selector = (state, a1, a2, a3) => {
5170 const va = a(state, a1, a2, a3);
5171 return b(va, a1, a2, a3);
5172 };
5173 } else if (a) {
5174 selector = a;
5175 } else {
5176 throw (
5177 /* minify-error-disabled */
5178 new Error("Missing arguments")
5179 );
5180 }
5181 return selector;
5182 };
5183
5184 // node_modules/@base-ui/utils/esm/store/useStore.js
5185 var React21 = __toESM(require_react(), 1);
5186 var import_shim = __toESM(require_shim(), 1);
5187 var import_with_selector = __toESM(require_with_selector(), 1);
5188
5189 // node_modules/@base-ui/utils/esm/fastHooks.js
5190 var React20 = __toESM(require_react(), 1);
5191 var hooks = [];
5192 var currentInstance = void 0;
5193 function getInstance() {
5194 return currentInstance;
5195 }
5196 function register2(hook) {
5197 hooks.push(hook);
5198 }
5199 function fastComponent(fn) {
5200 const FastComponent = (props, forwardedRef) => {
5201 const instance = useRefWithInit(createInstance).current;
5202 let result;
5203 try {
5204 currentInstance = instance;
5205 for (const hook of hooks) {
5206 hook.before(instance);
5207 }
5208 result = fn(props, forwardedRef);
5209 for (const hook of hooks) {
5210 hook.after(instance);
5211 }
5212 instance.didInitialize = true;
5213 } finally {
5214 currentInstance = void 0;
5215 }
5216 return result;
5217 };
5218 FastComponent.displayName = fn.displayName || fn.name;
5219 return FastComponent;
5220 }
5221 function fastComponentRef(fn) {
5222 return /* @__PURE__ */ React20.forwardRef(fastComponent(fn));
5223 }
5224 function createInstance() {
5225 return {
5226 didInitialize: false
5227 };
5228 }
5229
5230 // node_modules/@base-ui/utils/esm/store/useStore.js
5231 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5232 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5233 function useStore(store2, selector, a1, a2, a3) {
5234 return useStoreImplementation(store2, selector, a1, a2, a3);
5235 }
5236 function useStoreR19(store2, selector, a1, a2, a3) {
5237 const getSelection = React21.useCallback(() => selector(store2.getSnapshot(), a1, a2, a3), [store2, selector, a1, a2, a3]);
5238 return (0, import_shim.useSyncExternalStore)(store2.subscribe, getSelection, getSelection);
5239 }
5240 register2({
5241 before(instance) {
5242 instance.syncIndex = 0;
5243 if (!instance.didInitialize) {
5244 instance.syncTick = 1;
5245 instance.syncHooks = [];
5246 instance.didChangeStore = true;
5247 instance.getSnapshot = () => {
5248 let didChange2 = false;
5249 for (let i = 0; i < instance.syncHooks.length; i += 1) {
5250 const hook = instance.syncHooks[i];
5251 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5252 if (hook.didChange || !Object.is(hook.value, value)) {
5253 didChange2 = true;
5254 hook.value = value;
5255 hook.didChange = false;
5256 }
5257 }
5258 if (didChange2) {
5259 instance.syncTick += 1;
5260 }
5261 return instance.syncTick;
5262 };
5263 }
5264 },
5265 after(instance) {
5266 if (instance.syncHooks.length > 0) {
5267 if (instance.didChangeStore) {
5268 instance.didChangeStore = false;
5269 instance.subscribe = (onStoreChange) => {
5270 const stores = /* @__PURE__ */ new Set();
5271 for (const hook of instance.syncHooks) {
5272 stores.add(hook.store);
5273 }
5274 const unsubscribes = [];
5275 for (const store2 of stores) {
5276 unsubscribes.push(store2.subscribe(onStoreChange));
5277 }
5278 return () => {
5279 for (const unsubscribe of unsubscribes) {
5280 unsubscribe();
5281 }
5282 };
5283 };
5284 }
5285 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5286 }
5287 }
5288 });
5289 function useStoreFast(store2, selector, a1, a2, a3) {
5290 const instance = getInstance();
5291 if (!instance) {
5292 return useStoreR19(store2, selector, a1, a2, a3);
5293 }
5294 const index2 = instance.syncIndex;
5295 instance.syncIndex += 1;
5296 let hook;
5297 if (!instance.didInitialize) {
5298 hook = {
5299 store: store2,
5300 selector,
5301 a1,
5302 a2,
5303 a3,
5304 value: selector(store2.getSnapshot(), a1, a2, a3),
5305 didChange: false
5306 };
5307 instance.syncHooks.push(hook);
5308 } else {
5309 hook = instance.syncHooks[index2];
5310 if (hook.store !== store2 || hook.selector !== selector || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5311 if (hook.store !== store2) {
5312 instance.didChangeStore = true;
5313 }
5314 hook.store = store2;
5315 hook.selector = selector;
5316 hook.a1 = a1;
5317 hook.a2 = a2;
5318 hook.a3 = a3;
5319 hook.didChange = true;
5320 }
5321 }
5322 return hook.value;
5323 }
5324 function useStoreLegacy(store2, selector, a1, a2, a3) {
5325 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store2.subscribe, store2.getSnapshot, store2.getSnapshot, (state) => selector(state, a1, a2, a3));
5326 }
5327
5328 // node_modules/@base-ui/utils/esm/store/Store.js
5329 var Store = class {
5330 /**
5331 * The current state of the store.
5332 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5333 * 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).
5334 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5335 *
5336 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5337 */
5338 // Internal state to handle recursive `setState()` calls
5339 constructor(state) {
5340 this.state = state;
5341 this.listeners = /* @__PURE__ */ new Set();
5342 this.updateTick = 0;
5343 }
5344 /**
5345 * Registers a listener that will be called whenever the store's state changes.
5346 *
5347 * @param fn The listener function to be called on state changes.
5348 * @returns A function to unsubscribe the listener.
5349 */
5350 subscribe = (fn) => {
5351 this.listeners.add(fn);
5352 return () => {
5353 this.listeners.delete(fn);
5354 };
5355 };
5356 /**
5357 * Returns the current state of the store.
5358 */
5359 getSnapshot = () => {
5360 return this.state;
5361 };
5362 /**
5363 * Updates the entire store's state and notifies all registered listeners.
5364 *
5365 * @param newState The new state to set for the store.
5366 */
5367 setState(newState) {
5368 if (this.state === newState) {
5369 return;
5370 }
5371 this.state = newState;
5372 this.updateTick += 1;
5373 const currentTick = this.updateTick;
5374 for (const listener of this.listeners) {
5375 if (currentTick !== this.updateTick) {
5376 return;
5377 }
5378 listener(newState);
5379 }
5380 }
5381 /**
5382 * Merges the provided changes into the current state and notifies listeners if there are changes.
5383 *
5384 * @param changes An object containing the changes to apply to the current state.
5385 */
5386 update(changes) {
5387 for (const key in changes) {
5388 if (!Object.is(this.state[key], changes[key])) {
5389 this.setState({
5390 ...this.state,
5391 ...changes
5392 });
5393 return;
5394 }
5395 }
5396 }
5397 /**
5398 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5399 *
5400 * @param key The key in the store's state to update.
5401 * @param value The new value to set for the specified key.
5402 */
5403 set(key, value) {
5404 if (!Object.is(this.state[key], value)) {
5405 this.setState({
5406 ...this.state,
5407 [key]: value
5408 });
5409 }
5410 }
5411 /**
5412 * Gives the state a new reference and updates all registered listeners.
5413 */
5414 notifyAll() {
5415 const newState = {
5416 ...this.state
5417 };
5418 this.setState(newState);
5419 }
5420 use(selector, a1, a2, a3) {
5421 return useStore(this, selector, a1, a2, a3);
5422 }
5423 };
5424
5425 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5426 var React22 = __toESM(require_react(), 1);
5427 var ReactStore = class extends Store {
5428 /**
5429 * Creates a new ReactStore instance.
5430 *
5431 * @param state Initial state of the store.
5432 * @param context Non-reactive context values.
5433 * @param selectors Optional selectors for use with `useState`.
5434 */
5435 constructor(state, context = {}, selectors3) {
5436 super(state);
5437 this.context = context;
5438 this.selectors = selectors3;
5439 }
5440 /**
5441 * Non-reactive values such as refs, callbacks, etc.
5442 */
5443 /**
5444 * Synchronizes a single external value into the store.
5445 *
5446 * Note that the while the value in `state` is updated immediately, the value returned
5447 * by `useState` is updated before the next render (similarly to React's `useState`).
5448 */
5449 useSyncedValue(key, value) {
5450 React22.useDebugValue(key);
5451 const store2 = this;
5452 useIsoLayoutEffect(() => {
5453 if (store2.state[key] !== value) {
5454 store2.set(key, value);
5455 }
5456 }, [store2, key, value]);
5457 }
5458 /**
5459 * Synchronizes a single external value into the store and
5460 * cleans it up (sets to `undefined`) on unmount.
5461 *
5462 * Note that the while the value in `state` is updated immediately, the value returned
5463 * by `useState` is updated before the next render (similarly to React's `useState`).
5464 */
5465 useSyncedValueWithCleanup(key, value) {
5466 const store2 = this;
5467 useIsoLayoutEffect(() => {
5468 if (store2.state[key] !== value) {
5469 store2.set(key, value);
5470 }
5471 return () => {
5472 store2.set(key, void 0);
5473 };
5474 }, [store2, key, value]);
5475 }
5476 /**
5477 * Synchronizes multiple external values into the store.
5478 *
5479 * Note that the while the values in `state` are updated immediately, the values returned
5480 * by `useState` are updated before the next render (similarly to React's `useState`).
5481 */
5482 useSyncedValues(statePart) {
5483 const store2 = this;
5484 if (true) {
5485 React22.useDebugValue(statePart, (p) => Object.keys(p));
5486 const keys = React22.useRef(Object.keys(statePart)).current;
5487 const nextKeys = Object.keys(statePart);
5488 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5489 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5490 }
5491 }
5492 const dependencies = Object.values(statePart);
5493 useIsoLayoutEffect(() => {
5494 store2.update(statePart);
5495 }, [store2, ...dependencies]);
5496 }
5497 /**
5498 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5499 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5500 */
5501 useControlledProp(key, controlled) {
5502 React22.useDebugValue(key);
5503 const store2 = this;
5504 const isControlled = controlled !== void 0;
5505 useIsoLayoutEffect(() => {
5506 if (isControlled && !Object.is(store2.state[key], controlled)) {
5507 store2.setState({
5508 ...store2.state,
5509 [key]: controlled
5510 });
5511 }
5512 }, [store2, key, controlled, isControlled]);
5513 if (true) {
5514 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5515 if (!cache.has(key)) {
5516 cache.set(key, isControlled);
5517 }
5518 const previouslyControlled = cache.get(key);
5519 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5520 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).`);
5521 }
5522 }
5523 }
5524 /** Gets the current value from the store using a selector with the provided key.
5525 *
5526 * @param key Key of the selector to use.
5527 */
5528 select(key, a1, a2, a3) {
5529 const selector = this.selectors[key];
5530 return selector(this.state, a1, a2, a3);
5531 }
5532 /**
5533 * Returns a value from the store's state using a selector function.
5534 * Used to subscribe to specific parts of the state.
5535 * This methods causes a rerender whenever the selected state changes.
5536 *
5537 * @param key Key of the selector to use.
5538 */
5539 useState(key, a1, a2, a3) {
5540 React22.useDebugValue(key);
5541 return useStore(this, this.selectors[key], a1, a2, a3);
5542 }
5543 /**
5544 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5545 * and assigns it to the context.
5546 *
5547 * @param key Key of the event callback. Must be a function in the context.
5548 * @param fn Function to assign.
5549 */
5550 useContextCallback(key, fn) {
5551 React22.useDebugValue(key);
5552 const stableFunction = useStableCallback(fn ?? NOOP);
5553 this.context[key] = stableFunction;
5554 }
5555 /**
5556 * Returns a stable setter function for a specific key in the store's state.
5557 * It's commonly used to pass as a ref callback to React elements.
5558 *
5559 * @param key Key of the state to set.
5560 */
5561 useStateSetter(key) {
5562 const ref = React22.useRef(void 0);
5563 if (ref.current === void 0) {
5564 ref.current = (value) => {
5565 this.set(key, value);
5566 };
5567 }
5568 return ref.current;
5569 }
5570 /**
5571 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5572 *
5573 * @param key Key of the selector to observe.
5574 * @param listener Listener function called when the selector result changes.
5575 */
5576 observe(selector, listener) {
5577 let selectFn;
5578 if (typeof selector === "function") {
5579 selectFn = selector;
5580 } else {
5581 selectFn = this.selectors[selector];
5582 }
5583 let prevValue = selectFn(this.state);
5584 listener(prevValue, prevValue, this);
5585 return this.subscribe((nextState) => {
5586 const nextValue = selectFn(nextState);
5587 if (!Object.is(prevValue, nextValue)) {
5588 const oldValue = prevValue;
5589 prevValue = nextValue;
5590 listener(nextValue, oldValue, this);
5591 }
5592 });
5593 }
5594 };
5595
5596 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5597 var selectors = {
5598 open: createSelector2((state) => state.open),
5599 transitionStatus: createSelector2((state) => state.transitionStatus),
5600 domReferenceElement: createSelector2((state) => state.domReferenceElement),
5601 referenceElement: createSelector2((state) => state.positionReference ?? state.referenceElement),
5602 floatingElement: createSelector2((state) => state.floatingElement),
5603 floatingId: createSelector2((state) => state.floatingId)
5604 };
5605 var FloatingRootStore = class extends ReactStore {
5606 constructor(options) {
5607 const {
5608 syncOnly,
5609 nested,
5610 onOpenChange,
5611 triggerElements,
5612 ...initialState
5613 } = options;
5614 super({
5615 ...initialState,
5616 positionReference: initialState.referenceElement,
5617 domReferenceElement: initialState.referenceElement
5618 }, {
5619 onOpenChange,
5620 dataRef: {
5621 current: {}
5622 },
5623 events: createEventEmitter(),
5624 nested,
5625 triggerElements
5626 }, selectors);
5627 this.syncOnly = syncOnly;
5628 }
5629 /**
5630 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5631 */
5632 syncOpenEvent = (newOpen, event) => {
5633 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5634 // click events to upgrade a hover-open.
5635 event != null && isClickLikeEvent(event)) {
5636 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5637 }
5638 };
5639 /**
5640 * Runs the root-owned side effects for an open state change.
5641 */
5642 dispatchOpenChange = (newOpen, eventDetails) => {
5643 this.syncOpenEvent(newOpen, eventDetails.event);
5644 const details = {
5645 open: newOpen,
5646 reason: eventDetails.reason,
5647 nativeEvent: eventDetails.event,
5648 nested: this.context.nested,
5649 triggerElement: eventDetails.trigger
5650 };
5651 this.context.events.emit("openchange", details);
5652 };
5653 /**
5654 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5655 *
5656 * @param newOpen The new open state.
5657 * @param eventDetails Details about the event that triggered the open state change.
5658 */
5659 setOpen = (newOpen, eventDetails) => {
5660 if (this.syncOnly) {
5661 this.context.onOpenChange?.(newOpen, eventDetails);
5662 return;
5663 }
5664 this.dispatchOpenChange(newOpen, eventDetails);
5665 this.context.onOpenChange?.(newOpen, eventDetails);
5666 };
5667 };
5668
5669 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5670 function useSyncedFloatingRootContext(options) {
5671 const {
5672 popupStore,
5673 treatPopupAsFloatingElement = false,
5674 floatingRootContext: floatingRootContextProp,
5675 floatingId,
5676 nested,
5677 onOpenChange
5678 } = options;
5679 const open = popupStore.useState("open");
5680 const referenceElement = popupStore.useState("activeTriggerElement");
5681 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5682 const triggerElements = popupStore.context.triggerElements;
5683 const handleOpenChange = onOpenChange;
5684 const internalStoreRef = React23.useRef(null);
5685 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
5686 internalStoreRef.current = new FloatingRootStore({
5687 open,
5688 transitionStatus: void 0,
5689 referenceElement,
5690 floatingElement,
5691 triggerElements,
5692 onOpenChange: handleOpenChange,
5693 floatingId,
5694 syncOnly: true,
5695 nested
5696 });
5697 }
5698 const store2 = floatingRootContextProp ?? internalStoreRef.current;
5699 popupStore.useSyncedValue("floatingId", floatingId);
5700 useIsoLayoutEffect(() => {
5701 const valuesToSync = {
5702 open,
5703 floatingId,
5704 referenceElement,
5705 floatingElement
5706 };
5707 if (isElement(referenceElement)) {
5708 valuesToSync.domReferenceElement = referenceElement;
5709 }
5710 if (store2.state.positionReference === store2.state.referenceElement) {
5711 valuesToSync.positionReference = referenceElement;
5712 }
5713 store2.update(valuesToSync);
5714 }, [open, floatingId, referenceElement, floatingElement, store2]);
5715 store2.context.onOpenChange = handleOpenChange;
5716 store2.context.nested = nested;
5717 return store2;
5718 }
5719
5720 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5721 var FOCUSABLE_POPUP_PROPS = {
5722 tabIndex: -1,
5723 [FOCUSABLE_ATTRIBUTE]: ""
5724 };
5725 function usePopupStore(externalStore, createStore, treatPopupAsFloatingElement = false) {
5726 const floatingId = useId();
5727 const nested = useFloatingParentNodeId() != null;
5728 const internalStoreRef = React24.useRef(null);
5729 if (externalStore === void 0 && internalStoreRef.current === null) {
5730 internalStoreRef.current = createStore(floatingId, nested);
5731 }
5732 const store2 = externalStore ?? internalStoreRef.current;
5733 useSyncedFloatingRootContext({
5734 popupStore: store2,
5735 treatPopupAsFloatingElement,
5736 floatingRootContext: store2.state.floatingRootContext,
5737 floatingId,
5738 nested,
5739 onOpenChange: store2.setOpen
5740 });
5741 return {
5742 store: store2,
5743 internalStore: internalStoreRef.current
5744 };
5745 }
5746 function useTriggerRegistration(id, store2) {
5747 const registeredElementIdRef = React24.useRef(null);
5748 const registeredElementRef = React24.useRef(null);
5749 return React24.useCallback((element) => {
5750 if (id === void 0) {
5751 return;
5752 }
5753 let shouldSyncTriggerCount = false;
5754 if (registeredElementIdRef.current !== null) {
5755 const registeredId = registeredElementIdRef.current;
5756 const registeredElement = registeredElementRef.current;
5757 const currentElement = store2.context.triggerElements.getById(registeredId);
5758 if (registeredElement && currentElement === registeredElement) {
5759 store2.context.triggerElements.delete(registeredId);
5760 shouldSyncTriggerCount = true;
5761 }
5762 registeredElementIdRef.current = null;
5763 registeredElementRef.current = null;
5764 }
5765 if (element !== null) {
5766 registeredElementIdRef.current = id;
5767 registeredElementRef.current = element;
5768 store2.context.triggerElements.add(id, element);
5769 shouldSyncTriggerCount = true;
5770 }
5771 if (shouldSyncTriggerCount) {
5772 const triggerCount = store2.context.triggerElements.size;
5773 if (store2.select("open") && store2.state.triggerCount !== triggerCount) {
5774 store2.set("triggerCount", triggerCount);
5775 }
5776 }
5777 }, [store2, id]);
5778 }
5779 function setOpenTriggerState(state, open, trigger) {
5780 const triggerId = trigger?.id ?? null;
5781 if (triggerId || open) {
5782 state.activeTriggerId = triggerId;
5783 state.activeTriggerElement = trigger ?? null;
5784 }
5785 }
5786 function useTriggerDataForwarding(triggerId, triggerElementRef, store2, stateUpdates) {
5787 const isMountedByThisTrigger = store2.useState("isMountedByTrigger", triggerId);
5788 const baseRegisterTrigger = useTriggerRegistration(triggerId, store2);
5789 const registerTrigger = useStableCallback((element) => {
5790 baseRegisterTrigger(element);
5791 if (!element) {
5792 return;
5793 }
5794 const open = store2.select("open");
5795 const activeTriggerId = store2.select("activeTriggerId");
5796 if (activeTriggerId === triggerId) {
5797 store2.update({
5798 activeTriggerElement: element,
5799 ...open ? stateUpdates : null
5800 });
5801 return;
5802 }
5803 if (activeTriggerId == null && open) {
5804 store2.update({
5805 activeTriggerId: triggerId,
5806 activeTriggerElement: element,
5807 ...stateUpdates
5808 });
5809 }
5810 });
5811 useIsoLayoutEffect(() => {
5812 if (isMountedByThisTrigger) {
5813 store2.update({
5814 activeTriggerElement: triggerElementRef.current,
5815 ...stateUpdates
5816 });
5817 }
5818 }, [isMountedByThisTrigger, store2, triggerElementRef, ...Object.values(stateUpdates)]);
5819 return {
5820 registerTrigger,
5821 isMountedByThisTrigger
5822 };
5823 }
5824 function useImplicitActiveTrigger(store2) {
5825 const open = store2.useState("open");
5826 const reactiveTriggerCount = store2.useState("triggerCount");
5827 useIsoLayoutEffect(() => {
5828 if (!open) {
5829 if (store2.state.triggerCount !== 0) {
5830 store2.set("triggerCount", 0);
5831 }
5832 return;
5833 }
5834 const triggerCount = store2.context.triggerElements.size;
5835 const stateUpdates = {};
5836 if (store2.state.triggerCount !== triggerCount) {
5837 stateUpdates.triggerCount = triggerCount;
5838 }
5839 if (!store2.select("activeTriggerId") && triggerCount === 1) {
5840 const iteratorResult = store2.context.triggerElements.entries().next();
5841 if (!iteratorResult.done) {
5842 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5843 stateUpdates.activeTriggerId = implicitTriggerId;
5844 stateUpdates.activeTriggerElement = implicitTriggerElement;
5845 }
5846 }
5847 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) {
5848 store2.update(stateUpdates);
5849 }
5850 }, [open, store2, reactiveTriggerCount]);
5851 }
5852 function useOpenStateTransitions(open, store2, onUnmount) {
5853 const {
5854 mounted,
5855 setMounted,
5856 transitionStatus
5857 } = useTransitionStatus(open);
5858 store2.useSyncedValues({
5859 mounted,
5860 transitionStatus
5861 });
5862 const forceUnmount = useStableCallback(() => {
5863 setMounted(false);
5864 store2.update({
5865 activeTriggerId: null,
5866 activeTriggerElement: null,
5867 mounted: false,
5868 preventUnmountingOnClose: false
5869 });
5870 onUnmount?.();
5871 store2.context.onOpenChangeComplete?.(false);
5872 });
5873 const preventUnmountingOnClose = store2.useState("preventUnmountingOnClose");
5874 useOpenChangeComplete({
5875 enabled: mounted && !open && !preventUnmountingOnClose,
5876 open,
5877 ref: store2.context.popupRef,
5878 onComplete() {
5879 if (!open) {
5880 forceUnmount();
5881 }
5882 }
5883 });
5884 return {
5885 forceUnmount,
5886 transitionStatus
5887 };
5888 }
5889 function usePopupInteractionProps(store2, statePart) {
5890 store2.useSyncedValues(statePart);
5891 useIsoLayoutEffect(() => () => {
5892 store2.update({
5893 activeTriggerProps: EMPTY_OBJECT,
5894 inactiveTriggerProps: EMPTY_OBJECT,
5895 popupProps: EMPTY_OBJECT
5896 });
5897 }, [store2]);
5898 }
5899
5900 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
5901 var PopupTriggerMap = class {
5902 constructor() {
5903 this.elementsSet = /* @__PURE__ */ new Set();
5904 this.idMap = /* @__PURE__ */ new Map();
5905 }
5906 /**
5907 * Adds a trigger element with the given ID.
5908 *
5909 * Note: The provided element is assumed to not be registered under multiple IDs.
5910 */
5911 add(id, element) {
5912 const existingElement = this.idMap.get(id);
5913 if (existingElement === element) {
5914 return;
5915 }
5916 if (existingElement !== void 0) {
5917 this.elementsSet.delete(existingElement);
5918 }
5919 this.elementsSet.add(element);
5920 this.idMap.set(id, element);
5921 if (true) {
5922 if (this.elementsSet.size !== this.idMap.size) {
5923 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5924 }
5925 }
5926 }
5927 /**
5928 * Removes the trigger element with the given ID.
5929 */
5930 delete(id) {
5931 const element = this.idMap.get(id);
5932 if (element) {
5933 this.elementsSet.delete(element);
5934 this.idMap.delete(id);
5935 }
5936 }
5937 /**
5938 * Whether the given element is registered as a trigger.
5939 */
5940 hasElement(element) {
5941 return this.elementsSet.has(element);
5942 }
5943 /**
5944 * Whether there is a registered trigger element matching the given predicate.
5945 */
5946 hasMatchingElement(predicate) {
5947 for (const element of this.elementsSet) {
5948 if (predicate(element)) {
5949 return true;
5950 }
5951 }
5952 return false;
5953 }
5954 /**
5955 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
5956 */
5957 getById(id) {
5958 return this.idMap.get(id);
5959 }
5960 /**
5961 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
5962 */
5963 entries() {
5964 return this.idMap.entries();
5965 }
5966 /**
5967 * Returns an iterable of all registered trigger elements.
5968 */
5969 elements() {
5970 return this.elementsSet.values();
5971 }
5972 /**
5973 * Returns the number of registered trigger elements.
5974 */
5975 get size() {
5976 return this.idMap.size;
5977 }
5978 };
5979
5980 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
5981 function getEmptyRootContext() {
5982 return new FloatingRootStore({
5983 open: false,
5984 transitionStatus: void 0,
5985 floatingElement: null,
5986 referenceElement: null,
5987 triggerElements: new PopupTriggerMap(),
5988 floatingId: void 0,
5989 syncOnly: false,
5990 nested: false,
5991 onOpenChange: void 0
5992 });
5993 }
5994
5995 // node_modules/@base-ui/react/esm/utils/popups/store.js
5996 function createInitialPopupStoreState() {
5997 return {
5998 open: false,
5999 openProp: void 0,
6000 mounted: false,
6001 transitionStatus: void 0,
6002 floatingRootContext: getEmptyRootContext(),
6003 floatingId: void 0,
6004 triggerCount: 0,
6005 preventUnmountingOnClose: false,
6006 payload: void 0,
6007 activeTriggerId: null,
6008 activeTriggerElement: null,
6009 triggerIdProp: void 0,
6010 popupElement: null,
6011 positionerElement: null,
6012 activeTriggerProps: EMPTY_OBJECT,
6013 inactiveTriggerProps: EMPTY_OBJECT,
6014 popupProps: EMPTY_OBJECT
6015 };
6016 }
6017 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6018 return new FloatingRootStore({
6019 open: false,
6020 transitionStatus: void 0,
6021 floatingElement: null,
6022 referenceElement: null,
6023 triggerElements,
6024 floatingId,
6025 syncOnly: true,
6026 nested,
6027 onOpenChange: void 0
6028 });
6029 }
6030 var activeTriggerIdSelector = createSelector2((state) => state.triggerIdProp ?? state.activeTriggerId);
6031 var openSelector = createSelector2((state) => state.openProp ?? state.open);
6032 var popupIdSelector = createSelector2((state) => {
6033 const popupId = state.popupElement?.id ?? state.floatingId;
6034 return popupId || void 0;
6035 });
6036 function triggerOwnsOpenPopup(state, triggerId) {
6037 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6038 }
6039 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6040 if (triggerOwnsOpenPopup(state, triggerId)) {
6041 return true;
6042 }
6043 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6044 }
6045 var popupStoreSelectors = {
6046 open: openSelector,
6047 mounted: createSelector2((state) => state.mounted),
6048 transitionStatus: createSelector2((state) => state.transitionStatus),
6049 floatingRootContext: createSelector2((state) => state.floatingRootContext),
6050 triggerCount: createSelector2((state) => state.triggerCount),
6051 preventUnmountingOnClose: createSelector2((state) => state.preventUnmountingOnClose),
6052 payload: createSelector2((state) => state.payload),
6053 activeTriggerId: activeTriggerIdSelector,
6054 activeTriggerElement: createSelector2((state) => state.mounted ? state.activeTriggerElement : null),
6055 popupId: popupIdSelector,
6056 /**
6057 * Whether the trigger with the given ID was used to open the popup.
6058 */
6059 isTriggerActive: createSelector2((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6060 /**
6061 * Whether the popup is open and was activated by a trigger with the given ID.
6062 */
6063 isOpenedByTrigger: createSelector2((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6064 /**
6065 * Whether the popup is mounted and was activated by a trigger with the given ID.
6066 */
6067 isMountedByTrigger: createSelector2((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6068 triggerProps: createSelector2((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6069 /**
6070 * Popup id for the trigger that currently owns the open popup.
6071 */
6072 triggerPopupId: createSelector2((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6073 popupProps: createSelector2((state) => state.popupProps),
6074 popupElement: createSelector2((state) => state.popupElement),
6075 positionerElement: createSelector2((state) => state.positionerElement)
6076 };
6077
6078 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
6079 function useFloatingRootContext(options) {
6080 const {
6081 open = false,
6082 onOpenChange,
6083 elements = {}
6084 } = options;
6085 const floatingId = useId();
6086 const nested = useFloatingParentNodeId() != null;
6087 if (true) {
6088 const optionDomReference = elements.reference;
6089 if (optionDomReference && !isElement(optionDomReference)) {
6090 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6091 }
6092 }
6093 const store2 = useRefWithInit(() => new FloatingRootStore({
6094 open,
6095 transitionStatus: void 0,
6096 onOpenChange,
6097 referenceElement: elements.reference ?? null,
6098 floatingElement: elements.floating ?? null,
6099 triggerElements: new PopupTriggerMap(),
6100 floatingId,
6101 syncOnly: false,
6102 nested
6103 })).current;
6104 useIsoLayoutEffect(() => {
6105 const valuesToSync = {
6106 open,
6107 floatingId
6108 };
6109 if (elements.reference !== void 0) {
6110 valuesToSync.referenceElement = elements.reference;
6111 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6112 }
6113 if (elements.floating !== void 0) {
6114 valuesToSync.floatingElement = elements.floating;
6115 }
6116 store2.update(valuesToSync);
6117 }, [open, floatingId, elements.reference, elements.floating, store2]);
6118 store2.context.onOpenChange = onOpenChange;
6119 store2.context.nested = nested;
6120 return store2;
6121 }
6122
6123 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6124 function useFloating2(options = {}) {
6125 const {
6126 nodeId,
6127 externalTree
6128 } = options;
6129 const internalStore = useFloatingRootContext(options);
6130 const store2 = options.rootContext || internalStore;
6131 const referenceElement = store2.useState("referenceElement");
6132 const floatingElement = store2.useState("floatingElement");
6133 const domReferenceElement = store2.useState("domReferenceElement");
6134 const open = store2.useState("open");
6135 const floatingId = store2.useState("floatingId");
6136 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
6137 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
6138 const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0);
6139 const domReferenceRef = React25.useRef(null);
6140 const tree = useFloatingTree(externalTree);
6141 const storeElements = React25.useMemo(() => ({
6142 reference: referenceElement,
6143 floating: floatingElement,
6144 domReference: domReferenceElement
6145 }), [referenceElement, floatingElement, domReferenceElement]);
6146 const position = useFloating({
6147 ...options,
6148 elements: {
6149 ...storeElements,
6150 ...positionReference && {
6151 reference: positionReference
6152 }
6153 }
6154 });
6155 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6156 const syncedFloatingElement = localFloatingElement === void 0 ? store2.state.floatingElement : localFloatingElement;
6157 store2.useSyncedValue("referenceElement", localDomReference ?? null);
6158 store2.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6159 store2.useSyncedValue("floatingElement", syncedFloatingElement);
6160 const setPositionReference = React25.useCallback((node) => {
6161 const computedPositionReference = isElement(node) ? {
6162 getBoundingClientRect: () => node.getBoundingClientRect(),
6163 getClientRects: () => node.getClientRects(),
6164 contextElement: node
6165 } : node;
6166 setPositionReferenceRaw(computedPositionReference);
6167 position.refs.setReference(computedPositionReference);
6168 }, [position.refs]);
6169 const setReference = React25.useCallback((node) => {
6170 if (isElement(node) || node === null) {
6171 domReferenceRef.current = node;
6172 setLocalDomReference(node);
6173 }
6174 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6175 // `null` to support `positionReference` + an unstable `reference`
6176 // callback ref.
6177 node !== null && !isElement(node)) {
6178 position.refs.setReference(node);
6179 }
6180 }, [position.refs, setLocalDomReference]);
6181 const setFloating = React25.useCallback((node) => {
6182 setLocalFloatingElement(node);
6183 position.refs.setFloating(node);
6184 }, [position.refs]);
6185 const refs = React25.useMemo(() => ({
6186 ...position.refs,
6187 setReference,
6188 setFloating,
6189 setPositionReference,
6190 domReference: domReferenceRef
6191 }), [position.refs, setReference, setFloating, setPositionReference]);
6192 const elements = React25.useMemo(() => ({
6193 ...position.elements,
6194 domReference: domReferenceElement
6195 }), [position.elements, domReferenceElement]);
6196 const context = React25.useMemo(() => ({
6197 ...position,
6198 dataRef: store2.context.dataRef,
6199 open,
6200 onOpenChange: store2.setOpen,
6201 events: store2.context.events,
6202 floatingId,
6203 refs,
6204 elements,
6205 nodeId,
6206 rootStore: store2
6207 }), [position, refs, elements, nodeId, store2, open, floatingId]);
6208 useIsoLayoutEffect(() => {
6209 if (domReferenceElement) {
6210 domReferenceRef.current = domReferenceElement;
6211 }
6212 }, [domReferenceElement]);
6213 useIsoLayoutEffect(() => {
6214 store2.context.dataRef.current.floatingContext = context;
6215 const node = tree?.nodesRef.current.find((n) => n.id === nodeId);
6216 if (node) {
6217 node.context = context;
6218 }
6219 });
6220 return React25.useMemo(() => ({
6221 ...position,
6222 context,
6223 refs,
6224 elements,
6225 rootStore: store2
6226 }), [position, refs, elements, context, store2]);
6227 }
6228
6229 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6230 var React26 = __toESM(require_react(), 1);
6231 var isMacSafari = isMac && isSafari;
6232 function useFocus(context, props = {}) {
6233 const {
6234 enabled = true,
6235 delay
6236 } = props;
6237 const store2 = "rootStore" in context ? context.rootStore : context;
6238 const {
6239 events,
6240 dataRef
6241 } = store2.context;
6242 const blockFocusRef = React26.useRef(false);
6243 const blockedReferenceRef = React26.useRef(null);
6244 const keyboardModalityRef = React26.useRef(true);
6245 const timeout = useTimeout();
6246 React26.useEffect(() => {
6247 const domReference = store2.select("domReferenceElement");
6248 if (!enabled) {
6249 return void 0;
6250 }
6251 const win = getWindow(domReference);
6252 function onBlur() {
6253 const currentDomReference = store2.select("domReferenceElement");
6254 if (!store2.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6255 blockFocusRef.current = true;
6256 }
6257 }
6258 function onKeyDown() {
6259 keyboardModalityRef.current = true;
6260 }
6261 function onPointerDown() {
6262 keyboardModalityRef.current = false;
6263 }
6264 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6265 }, [store2, enabled]);
6266 React26.useEffect(() => {
6267 if (!enabled) {
6268 return void 0;
6269 }
6270 function onOpenChangeLocal(details) {
6271 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6272 const referenceElement = store2.select("domReferenceElement");
6273 if (isElement(referenceElement)) {
6274 blockedReferenceRef.current = referenceElement;
6275 blockFocusRef.current = true;
6276 }
6277 }
6278 }
6279 events.on("openchange", onOpenChangeLocal);
6280 return () => {
6281 events.off("openchange", onOpenChangeLocal);
6282 };
6283 }, [events, enabled, store2]);
6284 const reference = React26.useMemo(() => {
6285 function resetBlockedFocus() {
6286 blockFocusRef.current = false;
6287 blockedReferenceRef.current = null;
6288 }
6289 return {
6290 onMouseLeave() {
6291 resetBlockedFocus();
6292 },
6293 onFocus(event) {
6294 const focusTarget = event.currentTarget;
6295 if (blockFocusRef.current) {
6296 if (blockedReferenceRef.current === focusTarget) {
6297 return;
6298 }
6299 resetBlockedFocus();
6300 }
6301 const target = getTarget(event.nativeEvent);
6302 if (isElement(target)) {
6303 if (isMacSafari && !event.relatedTarget) {
6304 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6305 return;
6306 }
6307 } else if (!matchesFocusVisible(target)) {
6308 return;
6309 }
6310 }
6311 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements);
6312 const {
6313 nativeEvent,
6314 currentTarget
6315 } = event;
6316 const delayValue = typeof delay === "function" ? delay() : delay;
6317 if (store2.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6318 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6319 return;
6320 }
6321 timeout.start(delayValue, () => {
6322 if (blockFocusRef.current) {
6323 return;
6324 }
6325 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6326 });
6327 },
6328 onBlur(event) {
6329 resetBlockedFocus();
6330 const relatedTarget = event.relatedTarget;
6331 const nativeEvent = event.nativeEvent;
6332 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6333 timeout.start(0, () => {
6334 const domReference = store2.select("domReferenceElement");
6335 const activeEl = activeElement(ownerDocument(domReference));
6336 if (!relatedTarget && activeEl === domReference) {
6337 return;
6338 }
6339 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6340 return;
6341 }
6342 const nextFocusedElement = relatedTarget ?? activeEl;
6343 if (isTargetInsideEnabledTrigger(nextFocusedElement, store2.context.triggerElements)) {
6344 return;
6345 }
6346 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6347 });
6348 }
6349 };
6350 }, [dataRef, delay, store2, timeout]);
6351 return React26.useMemo(() => enabled ? {
6352 reference,
6353 trigger: reference
6354 } : {}, [enabled, reference]);
6355 }
6356
6357 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6358 var React27 = __toESM(require_react(), 1);
6359
6360 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6361 var HoverInteraction = class _HoverInteraction {
6362 constructor() {
6363 this.pointerType = void 0;
6364 this.interactedInside = false;
6365 this.handler = void 0;
6366 this.blockMouseMove = true;
6367 this.performedPointerEventsMutation = false;
6368 this.pointerEventsScopeElement = null;
6369 this.pointerEventsReferenceElement = null;
6370 this.pointerEventsFloatingElement = null;
6371 this.restTimeoutPending = false;
6372 this.openChangeTimeout = new Timeout();
6373 this.restTimeout = new Timeout();
6374 this.handleCloseOptions = void 0;
6375 }
6376 static create() {
6377 return new _HoverInteraction();
6378 }
6379 dispose = () => {
6380 this.openChangeTimeout.clear();
6381 this.restTimeout.clear();
6382 };
6383 disposeEffect = () => {
6384 return this.dispose;
6385 };
6386 };
6387 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6388 function clearSafePolygonPointerEventsMutation(instance) {
6389 if (!instance.performedPointerEventsMutation) {
6390 return;
6391 }
6392 const scopeElement = instance.pointerEventsScopeElement;
6393 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6394 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6395 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6396 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6397 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6398 }
6399 instance.performedPointerEventsMutation = false;
6400 instance.pointerEventsScopeElement = null;
6401 instance.pointerEventsReferenceElement = null;
6402 instance.pointerEventsFloatingElement = null;
6403 }
6404 function applySafePolygonPointerEventsMutation(instance, options) {
6405 const {
6406 scopeElement,
6407 referenceElement,
6408 floatingElement
6409 } = options;
6410 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6411 if (existingOwner && existingOwner !== instance) {
6412 clearSafePolygonPointerEventsMutation(existingOwner);
6413 }
6414 clearSafePolygonPointerEventsMutation(instance);
6415 instance.performedPointerEventsMutation = true;
6416 instance.pointerEventsScopeElement = scopeElement;
6417 instance.pointerEventsReferenceElement = referenceElement;
6418 instance.pointerEventsFloatingElement = floatingElement;
6419 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6420 scopeElement.style.pointerEvents = "none";
6421 referenceElement.style.pointerEvents = "auto";
6422 floatingElement.style.pointerEvents = "auto";
6423 }
6424 function useHoverInteractionSharedState(store2) {
6425 const data = store2.context.dataRef.current;
6426 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
6427 if (!data.hoverInteractionState) {
6428 data.hoverInteractionState = instance;
6429 }
6430 useOnMount(data.hoverInteractionState.disposeEffect);
6431 return data.hoverInteractionState;
6432 }
6433
6434 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6435 function useHoverFloatingInteraction(context, parameters = {}) {
6436 const {
6437 enabled = true,
6438 closeDelay: closeDelayProp = 0,
6439 nodeId: nodeIdProp
6440 } = parameters;
6441 const store2 = "rootStore" in context ? context.rootStore : context;
6442 const open = store2.useState("open");
6443 const floatingElement = store2.useState("floatingElement");
6444 const domReferenceElement = store2.useState("domReferenceElement");
6445 const {
6446 dataRef
6447 } = store2.context;
6448 const tree = useFloatingTree();
6449 const parentId = useFloatingParentNodeId();
6450 const instance = useHoverInteractionSharedState(store2);
6451 const childClosedTimeout = useTimeout();
6452 const isClickLikeOpenEvent2 = useStableCallback(() => {
6453 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6454 });
6455 const isHoverOpen = useStableCallback(() => {
6456 return isHoverOpenEvent(dataRef.current.openEvent?.type);
6457 });
6458 const clearPointerEvents = useStableCallback(() => {
6459 clearSafePolygonPointerEventsMutation(instance);
6460 });
6461 useIsoLayoutEffect(() => {
6462 if (!open) {
6463 instance.pointerType = void 0;
6464 instance.restTimeoutPending = false;
6465 instance.interactedInside = false;
6466 clearPointerEvents();
6467 }
6468 }, [open, instance, clearPointerEvents]);
6469 React27.useEffect(() => {
6470 return clearPointerEvents;
6471 }, [clearPointerEvents]);
6472 useIsoLayoutEffect(() => {
6473 if (!enabled) {
6474 return void 0;
6475 }
6476 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6477 const ref = domReferenceElement;
6478 const floatingEl = floatingElement;
6479 const doc = ownerDocument(floatingElement);
6480 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6481 if (parentFloating) {
6482 parentFloating.style.pointerEvents = "";
6483 }
6484 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
6485 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
6486 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
6487 applySafePolygonPointerEventsMutation(instance, {
6488 scopeElement,
6489 referenceElement: ref,
6490 floatingElement: floatingEl
6491 });
6492 return () => {
6493 clearPointerEvents();
6494 };
6495 }
6496 return void 0;
6497 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6498 React27.useEffect(() => {
6499 if (!enabled) {
6500 return void 0;
6501 }
6502 function hasParentChildren() {
6503 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
6504 }
6505 function closeWithDelay(event) {
6506 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6507 const close = () => {
6508 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6509 tree?.events.emit("floating.closed", event);
6510 };
6511 if (closeDelay) {
6512 instance.openChangeTimeout.start(closeDelay, close);
6513 } else {
6514 instance.openChangeTimeout.clear();
6515 close();
6516 }
6517 }
6518 function handleInteractInside(event) {
6519 const target = getTarget(event);
6520 if (!isInteractiveElement(target)) {
6521 instance.interactedInside = false;
6522 return;
6523 }
6524 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6525 }
6526 function onFloatingMouseEnter() {
6527 instance.openChangeTimeout.clear();
6528 childClosedTimeout.clear();
6529 tree?.events.off("floating.closed", onNodeClosed);
6530 clearPointerEvents();
6531 }
6532 function onFloatingMouseLeave(event) {
6533 if (hasParentChildren() && tree) {
6534 tree.events.on("floating.closed", onNodeClosed);
6535 return;
6536 }
6537 if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) {
6538 return;
6539 }
6540 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6541 const relatedTarget = event.relatedTarget;
6542 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6543 if (isMovingIntoDescendantFloating) {
6544 return;
6545 }
6546 if (instance.handler) {
6547 instance.handler(event);
6548 return;
6549 }
6550 clearPointerEvents();
6551 if (!isClickLikeOpenEvent2()) {
6552 closeWithDelay(event);
6553 }
6554 }
6555 function onNodeClosed(event) {
6556 if (!tree || !parentId || hasParentChildren()) {
6557 return;
6558 }
6559 childClosedTimeout.start(0, () => {
6560 tree.events.off("floating.closed", onNodeClosed);
6561 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6562 tree.events.emit("floating.closed", event);
6563 });
6564 }
6565 const floating = floatingElement;
6566 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6567 tree?.events.off("floating.closed", onNodeClosed);
6568 });
6569 }, [enabled, floatingElement, store2, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
6570 }
6571
6572 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6573 var React28 = __toESM(require_react(), 1);
6574 var ReactDOM4 = __toESM(require_react_dom(), 1);
6575 var EMPTY_REF = {
6576 current: null
6577 };
6578 function useHoverReferenceInteraction(context, props = {}) {
6579 const {
6580 enabled = true,
6581 delay = 0,
6582 handleClose = null,
6583 mouseOnly = false,
6584 restMs = 0,
6585 move = true,
6586 triggerElementRef = EMPTY_REF,
6587 externalTree,
6588 isActiveTrigger = true,
6589 getHandleCloseContext,
6590 isClosing,
6591 shouldOpen: shouldOpenProp
6592 } = props;
6593 const store2 = "rootStore" in context ? context.rootStore : context;
6594 const {
6595 dataRef,
6596 events
6597 } = store2.context;
6598 const tree = useFloatingTree(externalTree);
6599 const instance = useHoverInteractionSharedState(store2);
6600 const isHoverCloseActiveRef = React28.useRef(false);
6601 const handleCloseRef = useValueAsRef(handleClose);
6602 const delayRef = useValueAsRef(delay);
6603 const restMsRef = useValueAsRef(restMs);
6604 const enabledRef = useValueAsRef(enabled);
6605 const shouldOpenRef = useValueAsRef(shouldOpenProp);
6606 const isClosingRef = useValueAsRef(isClosing);
6607 const isClickLikeOpenEvent2 = useStableCallback(() => {
6608 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6609 });
6610 const checkShouldOpen = useStableCallback(() => {
6611 return shouldOpenRef.current?.() !== false;
6612 });
6613 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6614 const allTriggers = store2.context.triggerElements;
6615 if (allTriggers.hasElement(currentTarget)) {
6616 return !currentDomReference || !contains(currentDomReference, currentTarget);
6617 }
6618 if (!isElement(target)) {
6619 return false;
6620 }
6621 const targetElement = target;
6622 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6623 });
6624 const cleanupMouseMoveHandler = useStableCallback(() => {
6625 if (!instance.handler) {
6626 return;
6627 }
6628 const doc = ownerDocument(store2.select("domReferenceElement"));
6629 doc.removeEventListener("mousemove", instance.handler);
6630 instance.handler = void 0;
6631 });
6632 const clearPointerEvents = useStableCallback(() => {
6633 clearSafePolygonPointerEventsMutation(instance);
6634 });
6635 if (isActiveTrigger) {
6636 instance.handleCloseOptions = handleCloseRef.current?.__options;
6637 }
6638 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6639 React28.useEffect(() => {
6640 if (!enabled) {
6641 return void 0;
6642 }
6643 function onOpenChangeLocal(details) {
6644 if (!details.open) {
6645 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6646 cleanupMouseMoveHandler();
6647 instance.openChangeTimeout.clear();
6648 instance.restTimeout.clear();
6649 instance.blockMouseMove = true;
6650 instance.restTimeoutPending = false;
6651 } else {
6652 isHoverCloseActiveRef.current = false;
6653 }
6654 }
6655 events.on("openchange", onOpenChangeLocal);
6656 return () => {
6657 events.off("openchange", onOpenChangeLocal);
6658 };
6659 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6660 React28.useEffect(() => {
6661 if (!enabled) {
6662 return void 0;
6663 }
6664 function closeWithDelay(event, runElseBranch = true) {
6665 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6666 if (closeDelay) {
6667 instance.openChangeTimeout.start(closeDelay, () => {
6668 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6669 tree?.events.emit("floating.closed", event);
6670 });
6671 } else if (runElseBranch) {
6672 instance.openChangeTimeout.clear();
6673 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6674 tree?.events.emit("floating.closed", event);
6675 }
6676 }
6677 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store2.select("domReferenceElement") : null);
6678 if (!isElement(trigger)) {
6679 return void 0;
6680 }
6681 function onMouseEnter(event) {
6682 instance.openChangeTimeout.clear();
6683 instance.blockMouseMove = false;
6684 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6685 return;
6686 }
6687 const restMsValue = getRestMs(restMsRef.current);
6688 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6689 const eventTarget = getTarget(event);
6690 const currentTarget = event.currentTarget ?? null;
6691 const currentDomReference = store2.select("domReferenceElement");
6692 let triggerNode = currentTarget;
6693 if (isElement(eventTarget) && !store2.context.triggerElements.hasElement(eventTarget)) {
6694 for (const triggerElement of store2.context.triggerElements.elements()) {
6695 if (contains(triggerElement, eventTarget)) {
6696 triggerNode = triggerElement;
6697 break;
6698 }
6699 }
6700 }
6701 if (isElement(currentTarget) && isElement(currentDomReference) && !store2.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6702 triggerNode = currentDomReference;
6703 }
6704 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6705 const isOpen = store2.select("open");
6706 const isInClosingTransition = isClosingRef.current?.() ?? store2.select("transitionStatus") === "ending";
6707 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6708 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6709 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6710 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6711 const shouldOpen = !isOpen || isOverInactive;
6712 if (shouldOpenImmediately) {
6713 if (checkShouldOpen()) {
6714 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6715 }
6716 return;
6717 }
6718 if (isRestOnlyDelay) {
6719 return;
6720 }
6721 if (openDelay) {
6722 instance.openChangeTimeout.start(openDelay, () => {
6723 if (shouldOpen && checkShouldOpen()) {
6724 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6725 }
6726 });
6727 } else if (shouldOpen) {
6728 if (checkShouldOpen()) {
6729 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6730 }
6731 }
6732 }
6733 function onMouseLeave(event) {
6734 if (isClickLikeOpenEvent2()) {
6735 clearPointerEvents();
6736 return;
6737 }
6738 cleanupMouseMoveHandler();
6739 const domReferenceElement = store2.select("domReferenceElement");
6740 const doc = ownerDocument(domReferenceElement);
6741 instance.restTimeout.clear();
6742 instance.restTimeoutPending = false;
6743 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6744 if (isTargetInsideEnabledTrigger(event.relatedTarget, store2.context.triggerElements)) {
6745 return;
6746 }
6747 if (handleCloseRef.current && handleCloseContextBase) {
6748 if (!store2.select("open")) {
6749 instance.openChangeTimeout.clear();
6750 }
6751 const currentTrigger = triggerElementRef.current;
6752 instance.handler = handleCloseRef.current({
6753 ...handleCloseContextBase,
6754 tree,
6755 x: event.clientX,
6756 y: event.clientY,
6757 onClose() {
6758 clearPointerEvents();
6759 cleanupMouseMoveHandler();
6760 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store2.select("domReferenceElement")) {
6761 closeWithDelay(event, true);
6762 }
6763 }
6764 });
6765 doc.addEventListener("mousemove", instance.handler);
6766 instance.handler(event);
6767 return;
6768 }
6769 const shouldClose = instance.pointerType === "touch" ? !contains(store2.select("floatingElement"), event.relatedTarget) : true;
6770 if (shouldClose) {
6771 closeWithDelay(event);
6772 }
6773 }
6774 if (move) {
6775 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6776 once: true
6777 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6778 }
6779 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6780 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store2, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
6781 return React28.useMemo(() => {
6782 if (!enabled) {
6783 return void 0;
6784 }
6785 function setPointerRef(event) {
6786 instance.pointerType = event.pointerType;
6787 }
6788 return {
6789 onPointerDown: setPointerRef,
6790 onPointerEnter: setPointerRef,
6791 onMouseMove(event) {
6792 const {
6793 nativeEvent
6794 } = event;
6795 const trigger = event.currentTarget;
6796 const currentDomReference = store2.select("domReferenceElement");
6797 const currentOpen = store2.select("open");
6798 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6799 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6800 return;
6801 }
6802 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6803 const floatingElement = store2.select("floatingElement");
6804 if (floatingElement) {
6805 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6806 applySafePolygonPointerEventsMutation(instance, {
6807 scopeElement,
6808 referenceElement: trigger,
6809 floatingElement
6810 });
6811 }
6812 }
6813 const restMsValue = getRestMs(restMsRef.current);
6814 if (currentOpen && !isOverInactive || restMsValue === 0) {
6815 return;
6816 }
6817 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6818 return;
6819 }
6820 instance.restTimeout.clear();
6821 function handleMouseMove() {
6822 instance.restTimeoutPending = false;
6823 if (isClickLikeOpenEvent2()) {
6824 return;
6825 }
6826 const latestOpen = store2.select("open");
6827 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
6828 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6829 }
6830 }
6831 if (instance.pointerType === "touch") {
6832 ReactDOM4.flushSync(() => {
6833 handleMouseMove();
6834 });
6835 } else if (isOverInactive && currentOpen) {
6836 handleMouseMove();
6837 } else {
6838 instance.restTimeoutPending = true;
6839 instance.restTimeout.start(restMsValue, handleMouseMove);
6840 }
6841 }
6842 };
6843 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store2, restMsRef, checkShouldOpen]);
6844 }
6845
6846 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
6847 var CURSOR_SPEED_THRESHOLD = 0.1;
6848 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6849 var POLYGON_BUFFER = 0.5;
6850 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6851 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6852 }
6853 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6854 let isInsideValue = false;
6855 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6856 isInsideValue = !isInsideValue;
6857 }
6858 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6859 isInsideValue = !isInsideValue;
6860 }
6861 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6862 isInsideValue = !isInsideValue;
6863 }
6864 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6865 isInsideValue = !isInsideValue;
6866 }
6867 return isInsideValue;
6868 }
6869 function isInsideRect(pointX, pointY, rect) {
6870 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6871 }
6872 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6873 const minX = Math.min(x1, x2);
6874 const maxX = Math.max(x1, x2);
6875 const minY = Math.min(y1, y2);
6876 const maxY = Math.max(y1, y2);
6877 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6878 }
6879 function safePolygon(options = {}) {
6880 const {
6881 blockPointerEvents = false
6882 } = options;
6883 const timeout = new Timeout();
6884 const fn = ({
6885 x,
6886 y,
6887 placement,
6888 elements,
6889 onClose,
6890 nodeId,
6891 tree
6892 }) => {
6893 const side = placement?.split("-")[0];
6894 let hasLanded = false;
6895 let lastX = null;
6896 let lastY = null;
6897 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6898 function isCursorMovingSlowly(nextX, nextY) {
6899 const currentTime = performance.now();
6900 const elapsedTime = currentTime - lastCursorTime;
6901 if (lastX === null || lastY === null || elapsedTime === 0) {
6902 lastX = nextX;
6903 lastY = nextY;
6904 lastCursorTime = currentTime;
6905 return false;
6906 }
6907 const deltaX = nextX - lastX;
6908 const deltaY = nextY - lastY;
6909 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6910 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6911 lastX = nextX;
6912 lastY = nextY;
6913 lastCursorTime = currentTime;
6914 return distanceSquared < thresholdSquared;
6915 }
6916 function close() {
6917 timeout.clear();
6918 onClose();
6919 }
6920 return function onMouseMove(event) {
6921 timeout.clear();
6922 const domReference = elements.domReference;
6923 const floating = elements.floating;
6924 if (!domReference || !floating || side == null || x == null || y == null) {
6925 return void 0;
6926 }
6927 const {
6928 clientX,
6929 clientY
6930 } = event;
6931 const target = getTarget(event);
6932 const isLeave = event.type === "mouseleave";
6933 const isOverFloatingEl = contains(floating, target);
6934 const isOverReferenceEl = contains(domReference, target);
6935 if (isOverFloatingEl) {
6936 hasLanded = true;
6937 if (!isLeave) {
6938 return void 0;
6939 }
6940 }
6941 if (isOverReferenceEl) {
6942 hasLanded = false;
6943 if (!isLeave) {
6944 hasLanded = true;
6945 return void 0;
6946 }
6947 }
6948 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
6949 return void 0;
6950 }
6951 function hasOpenChildNode() {
6952 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
6953 }
6954 function closeIfNoOpenChild() {
6955 if (!hasOpenChildNode()) {
6956 close();
6957 }
6958 }
6959 if (hasOpenChildNode()) {
6960 return void 0;
6961 }
6962 const refRect = domReference.getBoundingClientRect();
6963 const rect = floating.getBoundingClientRect();
6964 const cursorLeaveFromRight = x > rect.right - rect.width / 2;
6965 const cursorLeaveFromBottom = y > rect.bottom - rect.height / 2;
6966 const isFloatingWider = rect.width > refRect.width;
6967 const isFloatingTaller = rect.height > refRect.height;
6968 const left = (isFloatingWider ? refRect : rect).left;
6969 const right = (isFloatingWider ? refRect : rect).right;
6970 const top = (isFloatingTaller ? refRect : rect).top;
6971 const bottom = (isFloatingTaller ? refRect : rect).bottom;
6972 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) {
6973 closeIfNoOpenChild();
6974 return void 0;
6975 }
6976 let isInsideTroughRect = false;
6977 switch (side) {
6978 case "top":
6979 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
6980 break;
6981 case "bottom":
6982 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
6983 break;
6984 case "left":
6985 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
6986 break;
6987 case "right":
6988 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
6989 break;
6990 default:
6991 }
6992 if (isInsideTroughRect) {
6993 return void 0;
6994 }
6995 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
6996 closeIfNoOpenChild();
6997 return void 0;
6998 }
6999 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7000 closeIfNoOpenChild();
7001 return void 0;
7002 }
7003 let isInsidePolygon = false;
7004 switch (side) {
7005 case "top": {
7006 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7007 const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
7008 const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
7009 const cursorPointY = y + POLYGON_BUFFER + 1;
7010 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7011 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7012 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7013 break;
7014 }
7015 case "bottom": {
7016 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7017 const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
7018 const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
7019 const cursorPointY = y - POLYGON_BUFFER;
7020 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7021 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7022 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7023 break;
7024 }
7025 case "left": {
7026 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7027 const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
7028 const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
7029 const cursorPointX = x + POLYGON_BUFFER + 1;
7030 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7031 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7032 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7033 break;
7034 }
7035 case "right": {
7036 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7037 const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
7038 const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
7039 const cursorPointX = x - POLYGON_BUFFER;
7040 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7041 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7042 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7043 break;
7044 }
7045 default:
7046 }
7047 if (!isInsidePolygon) {
7048 closeIfNoOpenChild();
7049 } else if (!hasLanded) {
7050 timeout.start(40, closeIfNoOpenChild);
7051 }
7052 return void 0;
7053 };
7054 };
7055 fn.__options = {
7056 ...options,
7057 blockPointerEvents
7058 };
7059 return fn;
7060 }
7061
7062 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7063 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7064 CommonPopupDataAttributes2["open"] = "data-open";
7065 CommonPopupDataAttributes2["closed"] = "data-closed";
7066 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7067 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7068 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7069 CommonPopupDataAttributes2["side"] = "data-side";
7070 CommonPopupDataAttributes2["align"] = "data-align";
7071 return CommonPopupDataAttributes2;
7072 })({});
7073 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7074 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7075 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7076 return CommonTriggerDataAttributes2;
7077 })({});
7078 var TRIGGER_HOOK = {
7079 [CommonTriggerDataAttributes.popupOpen]: ""
7080 };
7081 var PRESSABLE_TRIGGER_HOOK = {
7082 [CommonTriggerDataAttributes.popupOpen]: "",
7083 [CommonTriggerDataAttributes.pressed]: ""
7084 };
7085 var POPUP_OPEN_HOOK = {
7086 [CommonPopupDataAttributes.open]: ""
7087 };
7088 var POPUP_CLOSED_HOOK = {
7089 [CommonPopupDataAttributes.closed]: ""
7090 };
7091 var ANCHOR_HIDDEN_HOOK = {
7092 [CommonPopupDataAttributes.anchorHidden]: ""
7093 };
7094 var triggerOpenStateMapping = {
7095 open(value) {
7096 if (value) {
7097 return TRIGGER_HOOK;
7098 }
7099 return null;
7100 }
7101 };
7102 var popupStateMapping = {
7103 open(value) {
7104 if (value) {
7105 return POPUP_OPEN_HOOK;
7106 }
7107 return POPUP_CLOSED_HOOK;
7108 },
7109 anchorHidden(value) {
7110 if (value) {
7111 return ANCHOR_HIDDEN_HOOK;
7112 }
7113 return null;
7114 }
7115 };
7116
7117 // node_modules/@base-ui/utils/esm/inertValue.js
7118 function inertValue(value) {
7119 if (isReactVersionAtLeast(19)) {
7120 return value;
7121 }
7122 return value ? "true" : void 0;
7123 }
7124
7125 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7126 var React29 = __toESM(require_react(), 1);
7127
7128 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7129 var baseArrow = (options) => ({
7130 name: "arrow",
7131 options,
7132 async fn(state) {
7133 const {
7134 x,
7135 y,
7136 placement,
7137 rects,
7138 platform: platform3,
7139 elements,
7140 middlewareData
7141 } = state;
7142 const {
7143 element,
7144 padding = 0,
7145 offsetParent = "real"
7146 } = evaluate(options, state) || {};
7147 if (element == null) {
7148 return {};
7149 }
7150 const paddingObject = getPaddingObject(padding);
7151 const coords = {
7152 x,
7153 y
7154 };
7155 const axis = getAlignmentAxis(placement);
7156 const length = getAxisLength(axis);
7157 const arrowDimensions = await platform3.getDimensions(element);
7158 const isYAxis = axis === "y";
7159 const minProp = isYAxis ? "top" : "left";
7160 const maxProp = isYAxis ? "bottom" : "right";
7161 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7162 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7163 const startDiff = coords[axis] - rects.reference[axis];
7164 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7165 let clientSize = elements.floating[clientProp] || rects.floating[length];
7166 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7167 clientSize = elements.floating[clientProp] || rects.floating[length];
7168 }
7169 const centerToReference = endDiff / 2 - startDiff / 2;
7170 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7171 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7172 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7173 const min2 = minPadding;
7174 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7175 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7176 const offset4 = clamp(min2, center, max2);
7177 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7178 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7179 return {
7180 [axis]: coords[axis] + alignmentOffset,
7181 data: {
7182 [axis]: offset4,
7183 centerOffset: center - offset4 - alignmentOffset,
7184 ...shouldAddOffset && {
7185 alignmentOffset
7186 }
7187 },
7188 reset: shouldAddOffset
7189 };
7190 }
7191 });
7192 var arrow4 = (options, deps) => ({
7193 ...baseArrow(options),
7194 options: [options, deps]
7195 });
7196
7197 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7198 var hide4 = {
7199 name: "hide",
7200 async fn(state) {
7201 const {
7202 width,
7203 height,
7204 x,
7205 y
7206 } = state.rects.reference;
7207 const anchorHidden = width === 0 && height === 0 && x === 0 && y === 0;
7208 const nativeHideResult = await hide3().fn(state);
7209 return {
7210 data: {
7211 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7212 }
7213 };
7214 }
7215 };
7216
7217 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7218 var DEFAULT_SIDES = {
7219 sideX: "left",
7220 sideY: "top"
7221 };
7222 var adaptiveOrigin = {
7223 name: "adaptiveOrigin",
7224 async fn(state) {
7225 const {
7226 x: rawX,
7227 y: rawY,
7228 rects: {
7229 floating: floatRect
7230 },
7231 elements: {
7232 floating
7233 },
7234 platform: platform3,
7235 strategy,
7236 placement
7237 } = state;
7238 const win = getWindow(floating);
7239 const styles = win.getComputedStyle(floating);
7240 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7241 if (!hasTransition) {
7242 return {
7243 x: rawX,
7244 y: rawY,
7245 data: DEFAULT_SIDES
7246 };
7247 }
7248 const offsetParent = await platform3.getOffsetParent?.(floating);
7249 let offsetDimensions = {
7250 width: 0,
7251 height: 0
7252 };
7253 if (strategy === "fixed" && win?.visualViewport) {
7254 offsetDimensions = {
7255 width: win.visualViewport.width,
7256 height: win.visualViewport.height
7257 };
7258 } else if (offsetParent === win) {
7259 const doc = ownerDocument(floating);
7260 offsetDimensions = {
7261 width: doc.documentElement.clientWidth,
7262 height: doc.documentElement.clientHeight
7263 };
7264 } else if (await platform3.isElement?.(offsetParent)) {
7265 offsetDimensions = await platform3.getDimensions(offsetParent);
7266 }
7267 const currentSide = getSide(placement);
7268 let x = rawX;
7269 let y = rawY;
7270 if (currentSide === "left") {
7271 x = offsetDimensions.width - (rawX + floatRect.width);
7272 }
7273 if (currentSide === "top") {
7274 y = offsetDimensions.height - (rawY + floatRect.height);
7275 }
7276 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7277 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7278 return {
7279 x,
7280 y,
7281 data: {
7282 sideX,
7283 sideY
7284 }
7285 };
7286 }
7287 };
7288
7289 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7290 function getLogicalSide(sideParam, renderedSide, isRtl) {
7291 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7292 const logicalRight = isRtl ? "inline-start" : "inline-end";
7293 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7294 return {
7295 top: "top",
7296 right: isLogicalSideParam ? logicalRight : "right",
7297 bottom: "bottom",
7298 left: isLogicalSideParam ? logicalLeft : "left"
7299 }[renderedSide];
7300 }
7301 function getOffsetData(state, sideParam, isRtl) {
7302 const {
7303 rects,
7304 placement
7305 } = state;
7306 const data = {
7307 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7308 align: getAlignment(placement) || "center",
7309 anchor: {
7310 width: rects.reference.width,
7311 height: rects.reference.height
7312 },
7313 positioner: {
7314 width: rects.floating.width,
7315 height: rects.floating.height
7316 }
7317 };
7318 return data;
7319 }
7320 function useAnchorPositioning(params) {
7321 const {
7322 // Public parameters
7323 anchor,
7324 positionMethod = "absolute",
7325 side: sideParam = "bottom",
7326 sideOffset = 0,
7327 align = "center",
7328 alignOffset = 0,
7329 collisionBoundary,
7330 collisionPadding: collisionPaddingParam = 5,
7331 sticky = false,
7332 arrowPadding = 5,
7333 disableAnchorTracking = false,
7334 inline: inlineMiddleware,
7335 // Private parameters
7336 keepMounted = false,
7337 floatingRootContext,
7338 mounted,
7339 collisionAvoidance,
7340 shiftCrossAxis = false,
7341 nodeId,
7342 adaptiveOrigin: adaptiveOrigin2,
7343 lazyFlip = false,
7344 externalTree
7345 } = params;
7346 const [mountSide, setMountSide] = React29.useState(null);
7347 if (!mounted && mountSide !== null) {
7348 setMountSide(null);
7349 }
7350 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7351 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7352 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7353 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7354 const anchorFnCallback = useStableCallback(anchorFn);
7355 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7356 const anchorValueRef = useValueAsRef(anchor);
7357 const mountedRef = useValueAsRef(mounted);
7358 const direction = useDirection();
7359 const isRtl = direction === "rtl";
7360 const side = mountSide || {
7361 top: "top",
7362 right: "right",
7363 bottom: "bottom",
7364 left: "left",
7365 "inline-end": isRtl ? "left" : "right",
7366 "inline-start": isRtl ? "right" : "left"
7367 }[sideParam];
7368 const placement = align === "center" ? side : `${side}-${align}`;
7369 let collisionPadding = collisionPaddingParam;
7370 const bias = 1;
7371 const biasTop = sideParam === "bottom" ? bias : 0;
7372 const biasBottom = sideParam === "top" ? bias : 0;
7373 const biasLeft = sideParam === "right" ? bias : 0;
7374 const biasRight = sideParam === "left" ? bias : 0;
7375 if (typeof collisionPadding === "number") {
7376 collisionPadding = {
7377 top: collisionPadding + biasTop,
7378 right: collisionPadding + biasRight,
7379 bottom: collisionPadding + biasBottom,
7380 left: collisionPadding + biasLeft
7381 };
7382 } else if (collisionPadding) {
7383 collisionPadding = {
7384 top: (collisionPadding.top || 0) + biasTop,
7385 right: (collisionPadding.right || 0) + biasRight,
7386 bottom: (collisionPadding.bottom || 0) + biasBottom,
7387 left: (collisionPadding.left || 0) + biasLeft
7388 };
7389 }
7390 const commonCollisionProps = {
7391 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7392 padding: collisionPadding
7393 };
7394 const arrowRef = React29.useRef(null);
7395 const sideOffsetRef = useValueAsRef(sideOffset);
7396 const alignOffsetRef = useValueAsRef(alignOffset);
7397 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7398 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7399 const middleware = [];
7400 if (inlineMiddleware) {
7401 middleware.push(inlineMiddleware);
7402 }
7403 middleware.push(offset3((state) => {
7404 const data = getOffsetData(state, sideParam, isRtl);
7405 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7406 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7407 return {
7408 mainAxis: sideAxis,
7409 crossAxis: alignAxis,
7410 alignmentAxis: alignAxis
7411 };
7412 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
7413 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7414 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7415 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7416 ...commonCollisionProps,
7417 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7418 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7419 padding: {
7420 top: collisionPadding.top + bias,
7421 right: collisionPadding.right + bias,
7422 bottom: collisionPadding.bottom + bias,
7423 left: collisionPadding.left + bias
7424 },
7425 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7426 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7427 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7428 });
7429 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7430 const html = ownerDocument(data.elements.floating).documentElement;
7431 return {
7432 ...commonCollisionProps,
7433 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7434 // for context menus.
7435 rootBoundary: shiftCrossAxis ? {
7436 x: 0,
7437 y: 0,
7438 width: html.clientWidth,
7439 height: html.clientHeight
7440 } : void 0,
7441 mainAxis: collisionAvoidanceAlign !== "none",
7442 crossAxis: crossAxisShiftEnabled,
7443 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7444 if (!arrowRef.current) {
7445 return {};
7446 }
7447 const {
7448 width,
7449 height
7450 } = arrowRef.current.getBoundingClientRect();
7451 const sideAxis = getSideAxis(getSide(limitData.placement));
7452 const arrowSize = sideAxis === "y" ? width : height;
7453 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7454 return {
7455 offset: arrowSize / 2 + offsetAmount / 2
7456 };
7457 })
7458 };
7459 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7460 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7461 middleware.push(shiftMiddleware, flipMiddleware);
7462 } else {
7463 middleware.push(flipMiddleware, shiftMiddleware);
7464 }
7465 middleware.push(size3({
7466 ...commonCollisionProps,
7467 apply({
7468 elements: {
7469 floating
7470 },
7471 availableWidth,
7472 availableHeight,
7473 rects
7474 }) {
7475 if (!mountedRef.current) {
7476 return;
7477 }
7478 const floatingStyle = floating.style;
7479 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7480 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7481 const dpr = getWindow(floating).devicePixelRatio || 1;
7482 const {
7483 x: x2,
7484 y: y2,
7485 width,
7486 height
7487 } = rects.reference;
7488 const anchorWidth = (Math.round((x2 + width) * dpr) - Math.round(x2 * dpr)) / dpr;
7489 const anchorHeight = (Math.round((y2 + height) * dpr) - Math.round(y2 * dpr)) / dpr;
7490 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7491 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7492 }
7493 }), arrow4((state) => ({
7494 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7495 // we'll create a fake element.
7496 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
7497 padding: arrowPadding,
7498 offsetParent: "floating"
7499 }), [arrowPadding]), {
7500 name: "transformOrigin",
7501 fn(state) {
7502 const {
7503 elements: elements2,
7504 middlewareData: middlewareData2,
7505 placement: renderedPlacement2,
7506 rects,
7507 y: y2
7508 } = state;
7509 const currentRenderedSide = getSide(renderedPlacement2);
7510 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7511 const arrowEl = arrowRef.current;
7512 const arrowX = middlewareData2.arrow?.x || 0;
7513 const arrowY = middlewareData2.arrow?.y || 0;
7514 const arrowWidth = arrowEl?.clientWidth || 0;
7515 const arrowHeight = arrowEl?.clientHeight || 0;
7516 const transformX = arrowX + arrowWidth / 2;
7517 const transformY = arrowY + arrowHeight / 2;
7518 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7519 const halfAnchorHeight = rects.reference.height / 2;
7520 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7521 const isOverlappingAnchor = shiftY > sideOffsetValue;
7522 const adjacentTransformOrigin = {
7523 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7524 bottom: `${transformX}px ${-sideOffsetValue}px`,
7525 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7526 right: `${-sideOffsetValue}px ${transformY}px`
7527 }[currentRenderedSide];
7528 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y2}px`;
7529 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7530 return {};
7531 }
7532 }, hide4, adaptiveOrigin2);
7533 useIsoLayoutEffect(() => {
7534 if (!mounted && floatingRootContext) {
7535 floatingRootContext.update({
7536 referenceElement: null,
7537 floatingElement: null,
7538 domReferenceElement: null,
7539 positionReference: null
7540 });
7541 }
7542 }, [mounted, floatingRootContext]);
7543 const autoUpdateOptions = React29.useMemo(() => ({
7544 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7545 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7546 }), [disableAnchorTracking]);
7547 const {
7548 refs,
7549 elements,
7550 x,
7551 y,
7552 middlewareData,
7553 update: update2,
7554 placement: renderedPlacement,
7555 context,
7556 isPositioned,
7557 floatingStyles: originalFloatingStyles
7558 } = useFloating2({
7559 rootContext: floatingRootContext,
7560 open: keepMounted ? mounted : void 0,
7561 placement,
7562 middleware,
7563 strategy: positionMethod,
7564 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7565 nodeId,
7566 externalTree
7567 });
7568 const {
7569 sideX,
7570 sideY
7571 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7572 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7573 const floatingStyles = React29.useMemo(() => {
7574 const base = adaptiveOrigin2 ? {
7575 position: resolvedPosition,
7576 [sideX]: x,
7577 [sideY]: y
7578 } : {
7579 position: resolvedPosition,
7580 ...originalFloatingStyles
7581 };
7582 if (!isPositioned) {
7583 base.opacity = 0;
7584 }
7585 return base;
7586 }, [adaptiveOrigin2, resolvedPosition, sideX, x, sideY, y, originalFloatingStyles, isPositioned]);
7587 const registeredPositionReferenceRef = React29.useRef(null);
7588 useIsoLayoutEffect(() => {
7589 if (!mounted) {
7590 return;
7591 }
7592 const anchorValue = anchorValueRef.current;
7593 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7594 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7595 const finalAnchor = unwrappedElement || null;
7596 if (finalAnchor !== registeredPositionReferenceRef.current) {
7597 refs.setPositionReference(finalAnchor);
7598 registeredPositionReferenceRef.current = finalAnchor;
7599 }
7600 }, [mounted, refs, anchorDep, anchorValueRef]);
7601 React29.useEffect(() => {
7602 if (!mounted) {
7603 return;
7604 }
7605 const anchorValue = anchorValueRef.current;
7606 if (typeof anchorValue === "function") {
7607 return;
7608 }
7609 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7610 refs.setPositionReference(anchorValue.current);
7611 registeredPositionReferenceRef.current = anchorValue.current;
7612 }
7613 }, [mounted, refs, anchorDep, anchorValueRef]);
7614 React29.useEffect(() => {
7615 if (keepMounted && mounted && elements.domReference && elements.floating) {
7616 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7617 }
7618 return void 0;
7619 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7620 const renderedSide = getSide(renderedPlacement);
7621 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7622 const renderedAlign = getAlignment(renderedPlacement) || "center";
7623 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7624 useIsoLayoutEffect(() => {
7625 if (lazyFlip && mounted && isPositioned) {
7626 setMountSide(renderedSide);
7627 }
7628 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7629 const arrowStyles = React29.useMemo(() => ({
7630 position: "absolute",
7631 top: middlewareData.arrow?.y,
7632 left: middlewareData.arrow?.x
7633 }), [middlewareData.arrow]);
7634 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7635 return React29.useMemo(() => ({
7636 positionerStyles: floatingStyles,
7637 arrowStyles,
7638 arrowRef,
7639 arrowUncentered,
7640 side: logicalRenderedSide,
7641 align: renderedAlign,
7642 physicalSide: renderedSide,
7643 anchorHidden,
7644 refs,
7645 context,
7646 isPositioned,
7647 update: update2
7648 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7649 }
7650 function isRef(param) {
7651 return param != null && "current" in param;
7652 }
7653
7654 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7655 function getDisabledMountTransitionStyles(transitionStatus) {
7656 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7657 }
7658
7659 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7660 function usePositioner(componentProps, state, {
7661 styles,
7662 transitionStatus,
7663 props,
7664 refs,
7665 hidden,
7666 inert = false
7667 }) {
7668 const style = {
7669 ...styles
7670 };
7671 if (inert) {
7672 style.pointerEvents = "none";
7673 }
7674 return useRenderElement("div", componentProps, {
7675 state,
7676 ref: refs,
7677 props: [{
7678 role: "presentation",
7679 hidden,
7680 style
7681 }, getDisabledMountTransitionStyles(transitionStatus), props],
7682 stateAttributesMapping: popupStateMapping
7683 });
7684 }
7685
7686 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7687 var React32 = __toESM(require_react(), 1);
7688 var ReactDOM5 = __toESM(require_react_dom(), 1);
7689
7690 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7691 var React30 = __toESM(require_react(), 1);
7692 function usePreviousValue(value) {
7693 const [state, setState] = React30.useState({
7694 current: value,
7695 previous: null
7696 });
7697 if (value !== state.current) {
7698 setState({
7699 current: value,
7700 previous: state.current
7701 });
7702 }
7703 return state.previous;
7704 }
7705
7706 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7707 var React31 = __toESM(require_react(), 1);
7708
7709 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7710 function getCssDimensions2(element) {
7711 const css = getComputedStyle2(element);
7712 let width = parseFloat(css.width) || 0;
7713 let height = parseFloat(css.height) || 0;
7714 const hasOffset = isHTMLElement(element);
7715 const offsetWidth = hasOffset ? element.offsetWidth : width;
7716 const offsetHeight = hasOffset ? element.offsetHeight : height;
7717 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7718 if (shouldFallback) {
7719 width = offsetWidth;
7720 height = offsetHeight;
7721 }
7722 return {
7723 width,
7724 height
7725 };
7726 }
7727
7728 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7729 var DEFAULT_ENABLED = () => true;
7730 function usePopupAutoResize(parameters) {
7731 const {
7732 popupElement,
7733 positionerElement,
7734 content,
7735 mounted,
7736 enabled = DEFAULT_ENABLED,
7737 onMeasureLayout: onMeasureLayoutParam,
7738 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7739 side,
7740 direction
7741 } = parameters;
7742 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7743 const animationFrame = useAnimationFrame();
7744 const committedDimensionsRef = React31.useRef(null);
7745 const liveDimensionsRef = React31.useRef(null);
7746 const isInitialRenderRef = React31.useRef(true);
7747 const restoreAnchoringStylesRef = React31.useRef(NOOP);
7748 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7749 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7750 const anchoringStyles = React31.useMemo(() => {
7751 let isOriginSide = side === "top";
7752 let isPhysicalLeft = side === "left";
7753 if (direction === "rtl") {
7754 isOriginSide = isOriginSide || side === "inline-end";
7755 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7756 } else {
7757 isOriginSide = isOriginSide || side === "inline-start";
7758 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7759 }
7760 return isOriginSide ? {
7761 position: "absolute",
7762 [side === "top" ? "bottom" : "top"]: "0",
7763 [isPhysicalLeft ? "right" : "left"]: "0"
7764 } : EMPTY_OBJECT;
7765 }, [side, direction]);
7766 useIsoLayoutEffect(() => {
7767 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7768 restoreAnchoringStylesRef.current = NOOP;
7769 isInitialRenderRef.current = true;
7770 committedDimensionsRef.current = null;
7771 liveDimensionsRef.current = null;
7772 return void 0;
7773 }
7774 if (!popupElement || !positionerElement) {
7775 return void 0;
7776 }
7777 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7778 const observer = new ResizeObserver((entries) => {
7779 const entry = entries[0];
7780 if (entry) {
7781 liveDimensionsRef.current = {
7782 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
7783 height: Math.ceil(entry.borderBoxSize[0].blockSize)
7784 };
7785 }
7786 });
7787 observer.observe(popupElement);
7788 setPopupCssSize(popupElement, "auto");
7789 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7790 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7791 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7792 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7793 "--available-width": "max-content",
7794 "--available-height": "max-content"
7795 });
7796 function restoreMeasurementOverrides() {
7797 restorePopupPosition();
7798 restorePopupTransform();
7799 restorePositionerAvailableSize();
7800 }
7801 function restoreMeasurementOverridesIncludingScale() {
7802 restoreMeasurementOverrides();
7803 restorePopupScale();
7804 }
7805 onMeasureLayout?.();
7806 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7807 setPositionerCssSize(positionerElement, "max-content");
7808 const dimensions = getCssDimensions2(popupElement);
7809 committedDimensionsRef.current = dimensions;
7810 setPositionerCssSize(positionerElement, dimensions);
7811 restoreMeasurementOverridesIncludingScale();
7812 onMeasureLayoutComplete?.(null, dimensions);
7813 isInitialRenderRef.current = false;
7814 return () => {
7815 observer.disconnect();
7816 restoreAnchoringStylesRef.current();
7817 restoreAnchoringStylesRef.current = NOOP;
7818 };
7819 }
7820 setPopupCssSize(popupElement, "auto");
7821 setPositionerCssSize(positionerElement, "max-content");
7822 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
7823 const newDimensions = getCssDimensions2(popupElement);
7824 committedDimensionsRef.current = newDimensions;
7825 if (!previousDimensions) {
7826 setPositionerCssSize(positionerElement, newDimensions);
7827 restoreMeasurementOverridesIncludingScale();
7828 onMeasureLayoutComplete?.(null, newDimensions);
7829 return () => {
7830 observer.disconnect();
7831 animationFrame.cancel();
7832 restoreAnchoringStylesRef.current();
7833 restoreAnchoringStylesRef.current = NOOP;
7834 };
7835 }
7836 setPopupCssSize(popupElement, previousDimensions);
7837 restoreMeasurementOverridesIncludingScale();
7838 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7839 setPositionerCssSize(positionerElement, newDimensions);
7840 const abortController = new AbortController();
7841 animationFrame.request(() => {
7842 setPopupCssSize(popupElement, newDimensions);
7843 runOnceAnimationsFinish(() => {
7844 popupElement.style.setProperty("--popup-width", "auto");
7845 popupElement.style.setProperty("--popup-height", "auto");
7846 }, abortController.signal);
7847 });
7848 return () => {
7849 observer.disconnect();
7850 abortController.abort();
7851 animationFrame.cancel();
7852 restoreAnchoringStylesRef.current();
7853 restoreAnchoringStylesRef.current = NOOP;
7854 };
7855 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7856 }
7857 function overrideElementStyle(element, property, value) {
7858 const originalValue = element.style.getPropertyValue(property);
7859 element.style.setProperty(property, value);
7860 return () => {
7861 element.style.setProperty(property, originalValue);
7862 };
7863 }
7864 function applyElementStyles(element, styles) {
7865 const restorers = [];
7866 for (const [key, value] of Object.entries(styles)) {
7867 restorers.push(overrideElementStyle(element, key, value));
7868 }
7869 return restorers.length ? () => {
7870 restorers.forEach((restore) => restore());
7871 } : NOOP;
7872 }
7873 function setPopupCssSize(popupElement, size4) {
7874 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7875 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7876 popupElement.style.setProperty("--popup-width", width);
7877 popupElement.style.setProperty("--popup-height", height);
7878 }
7879 function setPositionerCssSize(positionerElement, size4) {
7880 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7881 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7882 positionerElement.style.setProperty("--positioner-width", width);
7883 positionerElement.style.setProperty("--positioner-height", height);
7884 }
7885
7886 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7887 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
7888 function usePopupViewport(parameters) {
7889 const {
7890 store: store2,
7891 side,
7892 cssVars,
7893 children
7894 } = parameters;
7895 const direction = useDirection();
7896 const activeTrigger = store2.useState("activeTriggerElement");
7897 const activeTriggerId = store2.useState("activeTriggerId");
7898 const open = store2.useState("open");
7899 const payload = store2.useState("payload");
7900 const mounted = store2.useState("mounted");
7901 const popupElement = store2.useState("popupElement");
7902 const positionerElement = store2.useState("positionerElement");
7903 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7904 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7905 const capturedNodeRef = React32.useRef(null);
7906 const [previousContentNode, setPreviousContentNode] = React32.useState(null);
7907 const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null);
7908 const currentContainerRef = React32.useRef(null);
7909 const previousContainerRef = React32.useRef(null);
7910 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7911 const cleanupFrame = useAnimationFrame();
7912 const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null);
7913 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false);
7914 useIsoLayoutEffect(() => {
7915 store2.set("hasViewport", true);
7916 return () => {
7917 store2.set("hasViewport", false);
7918 };
7919 }, [store2]);
7920 const handleMeasureLayout = useStableCallback(() => {
7921 currentContainerRef.current?.style.setProperty("animation", "none");
7922 currentContainerRef.current?.style.setProperty("transition", "none");
7923 previousContainerRef.current?.style.setProperty("display", "none");
7924 });
7925 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7926 currentContainerRef.current?.style.removeProperty("animation");
7927 currentContainerRef.current?.style.removeProperty("transition");
7928 previousContainerRef.current?.style.removeProperty("display");
7929 if (previousDimensions) {
7930 setPreviousContentDimensions(previousDimensions);
7931 }
7932 });
7933 const lastHandledTriggerRef = React32.useRef(null);
7934 useIsoLayoutEffect(() => {
7935 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
7936 setPreviousContentNode(capturedNodeRef.current);
7937 setShowStartingStyleAttribute(true);
7938 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
7939 setNewTriggerOffset(offset4);
7940 cleanupFrame.request(() => {
7941 ReactDOM5.flushSync(() => {
7942 setShowStartingStyleAttribute(false);
7943 });
7944 onAnimationsFinished(() => {
7945 setPreviousContentNode(null);
7946 setPreviousContentDimensions(null);
7947 capturedNodeRef.current = null;
7948 });
7949 });
7950 lastHandledTriggerRef.current = activeTrigger;
7951 }
7952 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
7953 useIsoLayoutEffect(() => {
7954 const source = currentContainerRef.current;
7955 if (!source) {
7956 return;
7957 }
7958 const wrapper = ownerDocument(source).createElement("div");
7959 for (const child of Array.from(source.childNodes)) {
7960 wrapper.appendChild(child.cloneNode(true));
7961 }
7962 capturedNodeRef.current = wrapper;
7963 });
7964 const isTransitioning = previousContentNode != null;
7965 let childrenToRender;
7966 if (!isTransitioning) {
7967 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7968 "data-current": true,
7969 ref: currentContainerRef,
7970 children
7971 }, currentContentKey);
7972 } else {
7973 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React32.Fragment, {
7974 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7975 "data-previous": true,
7976 inert: inertValue(true),
7977 ref: previousContainerRef,
7978 style: {
7979 ...previousContentDimensions ? {
7980 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
7981 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
7982 } : null,
7983 position: "absolute"
7984 },
7985 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
7986 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7987 "data-current": true,
7988 ref: currentContainerRef,
7989 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
7990 children
7991 }, currentContentKey)]
7992 });
7993 }
7994 useIsoLayoutEffect(() => {
7995 const container = previousContainerRef.current;
7996 if (!container || !previousContentNode) {
7997 return;
7998 }
7999 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8000 }, [previousContentNode]);
8001 usePopupAutoResize({
8002 popupElement,
8003 positionerElement,
8004 mounted,
8005 content: payload,
8006 onMeasureLayout: handleMeasureLayout,
8007 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8008 side,
8009 direction
8010 });
8011 const state = {
8012 activationDirection: getActivationDirection(newTriggerOffset),
8013 transitioning: isTransitioning
8014 };
8015 return {
8016 children: childrenToRender,
8017 state
8018 };
8019 }
8020 function getActivationDirection(offset4) {
8021 if (!offset4) {
8022 return void 0;
8023 }
8024 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8025 }
8026 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8027 if (value > tolerance) {
8028 return positiveLabel;
8029 }
8030 if (value < -tolerance) {
8031 return negativeLabel;
8032 }
8033 return "";
8034 }
8035 function calculateRelativePosition(from, to) {
8036 const fromRect = from.getBoundingClientRect();
8037 const toRect = to.getBoundingClientRect();
8038 const fromCenter = {
8039 x: fromRect.left + fromRect.width / 2,
8040 y: fromRect.top + fromRect.height / 2
8041 };
8042 const toCenter = {
8043 x: toRect.left + toRect.width / 2,
8044 y: toRect.top + toRect.height / 2
8045 };
8046 return {
8047 horizontal: toCenter.x - fromCenter.x,
8048 vertical: toCenter.y - fromCenter.y
8049 };
8050 }
8051 function usePopupContentKey(activeTriggerId, payload) {
8052 const [contentKey, setContentKey] = React32.useState(0);
8053 const previousActiveTriggerIdRef = React32.useRef(activeTriggerId);
8054 const previousPayloadRef = React32.useRef(payload);
8055 const pendingPayloadUpdateRef = React32.useRef(false);
8056 useIsoLayoutEffect(() => {
8057 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8058 const previousPayload = previousPayloadRef.current;
8059 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8060 const payloadChanged = payload !== previousPayload;
8061 if (triggerIdChanged) {
8062 setContentKey((value) => value + 1);
8063 pendingPayloadUpdateRef.current = !payloadChanged;
8064 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8065 setContentKey((value) => value + 1);
8066 pendingPayloadUpdateRef.current = false;
8067 }
8068 previousActiveTriggerIdRef.current = activeTriggerId;
8069 previousPayloadRef.current = payload;
8070 }, [activeTriggerId, payload]);
8071 return `${activeTriggerId ?? "current"}-${contentKey}`;
8072 }
8073
8074 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
8075 var React33 = __toESM(require_react(), 1);
8076 var ReactDOM6 = __toESM(require_react_dom(), 1);
8077 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8078 var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8079 const {
8080 children,
8081 container,
8082 className,
8083 render,
8084 style,
8085 ...elementProps
8086 } = componentProps;
8087 const {
8088 portalNode,
8089 portalSubtree
8090 } = useFloatingPortalNode({
8091 container,
8092 ref: forwardedRef,
8093 componentProps,
8094 elementProps
8095 });
8096 if (!portalSubtree && !portalNode) {
8097 return null;
8098 }
8099 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React33.Fragment, {
8100 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8101 });
8102 });
8103 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8104
8105 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8106 var index_parts_exports = {};
8107 __export(index_parts_exports, {
8108 Arrow: () => TooltipArrow,
8109 Handle: () => TooltipHandle,
8110 Popup: () => TooltipPopup,
8111 Portal: () => TooltipPortal,
8112 Positioner: () => TooltipPositioner,
8113 Provider: () => TooltipProvider,
8114 Root: () => TooltipRoot,
8115 Trigger: () => TooltipTrigger,
8116 Viewport: () => TooltipViewport,
8117 createHandle: () => createTooltipHandle
8118 });
8119
8120 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8121 var React36 = __toESM(require_react(), 1);
8122
8123 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8124 var React34 = __toESM(require_react(), 1);
8125 var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0);
8126 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8127 function useTooltipRootContext(optional) {
8128 const context = React34.useContext(TooltipRootContext);
8129 if (context === void 0 && !optional) {
8130 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8131 }
8132 return context;
8133 }
8134
8135 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8136 var React35 = __toESM(require_react(), 1);
8137 var ReactDOM7 = __toESM(require_react_dom(), 1);
8138 var selectors2 = {
8139 ...popupStoreSelectors,
8140 disabled: createSelector2((state) => state.disabled),
8141 instantType: createSelector2((state) => state.instantType),
8142 isInstantPhase: createSelector2((state) => state.isInstantPhase),
8143 trackCursorAxis: createSelector2((state) => state.trackCursorAxis),
8144 disableHoverablePopup: createSelector2((state) => state.disableHoverablePopup),
8145 lastOpenChangeReason: createSelector2((state) => state.openChangeReason),
8146 closeOnClick: createSelector2((state) => state.closeOnClick),
8147 closeDelay: createSelector2((state) => state.closeDelay),
8148 hasViewport: createSelector2((state) => state.hasViewport)
8149 };
8150 var TooltipStore = class _TooltipStore extends ReactStore {
8151 constructor(initialState, floatingId, nested = false) {
8152 const triggerElements = new PopupTriggerMap();
8153 const state = {
8154 ...createInitialState(),
8155 ...initialState
8156 };
8157 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
8158 super(state, {
8159 popupRef: /* @__PURE__ */ React35.createRef(),
8160 onOpenChange: void 0,
8161 onOpenChangeComplete: void 0,
8162 triggerElements
8163 }, selectors2);
8164 }
8165 setOpen = (nextOpen, eventDetails) => {
8166 const reason = eventDetails.reason;
8167 const isHover = reason === reason_parts_exports.triggerHover;
8168 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8169 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8170 eventDetails.preventUnmountOnClose = () => {
8171 this.set("preventUnmountingOnClose", true);
8172 };
8173 this.context.onOpenChange?.(nextOpen, eventDetails);
8174 if (eventDetails.isCanceled) {
8175 return;
8176 }
8177 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8178 const changeState = () => {
8179 const updatedState = {
8180 open: nextOpen,
8181 openChangeReason: reason
8182 };
8183 if (isFocusOpen) {
8184 updatedState.instantType = "focus";
8185 } else if (isDismissClose) {
8186 updatedState.instantType = "dismiss";
8187 } else if (reason === reason_parts_exports.triggerHover) {
8188 updatedState.instantType = void 0;
8189 }
8190 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
8191 this.update(updatedState);
8192 };
8193 if (isHover) {
8194 ReactDOM7.flushSync(changeState);
8195 } else {
8196 changeState();
8197 }
8198 };
8199 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
8200 cancelPendingOpen(event) {
8201 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
8202 }
8203 static useStore(externalStore, initialState) {
8204 const store2 = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
8205 return store2;
8206 }
8207 };
8208 function createInitialState() {
8209 return {
8210 ...createInitialPopupStoreState(),
8211 disabled: false,
8212 instantType: void 0,
8213 isInstantPhase: false,
8214 trackCursorAxis: "none",
8215 disableHoverablePopup: false,
8216 openChangeReason: null,
8217 closeOnClick: true,
8218 closeDelay: 0,
8219 hasViewport: false
8220 };
8221 }
8222
8223 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8224 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8225 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8226 const {
8227 disabled: disabled2 = false,
8228 defaultOpen = false,
8229 open: openProp,
8230 disableHoverablePopup = false,
8231 trackCursorAxis = "none",
8232 actionsRef,
8233 onOpenChange,
8234 onOpenChangeComplete,
8235 handle,
8236 triggerId: triggerIdProp,
8237 defaultTriggerId: defaultTriggerIdProp = null,
8238 children
8239 } = props;
8240 const store2 = TooltipStore.useStore(handle?.store, {
8241 open: defaultOpen,
8242 openProp,
8243 activeTriggerId: defaultTriggerIdProp,
8244 triggerIdProp
8245 });
8246 useOnFirstRender(() => {
8247 if (openProp === void 0 && store2.state.open === false && defaultOpen === true) {
8248 store2.update({
8249 open: true,
8250 activeTriggerId: defaultTriggerIdProp
8251 });
8252 }
8253 });
8254 store2.useControlledProp("openProp", openProp);
8255 store2.useControlledProp("triggerIdProp", triggerIdProp);
8256 store2.useContextCallback("onOpenChange", onOpenChange);
8257 store2.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8258 const openState = store2.useState("open");
8259 const open = !disabled2 && openState;
8260 const activeTriggerId = store2.useState("activeTriggerId");
8261 const mounted = store2.useState("mounted");
8262 const payload = store2.useState("payload");
8263 store2.useSyncedValues({
8264 trackCursorAxis,
8265 disableHoverablePopup
8266 });
8267 store2.useSyncedValue("disabled", disabled2);
8268 useImplicitActiveTrigger(store2);
8269 const {
8270 forceUnmount,
8271 transitionStatus
8272 } = useOpenStateTransitions(open, store2);
8273 const isInstantPhase = store2.useState("isInstantPhase");
8274 const instantType = store2.useState("instantType");
8275 const lastOpenChangeReason = store2.useState("lastOpenChangeReason");
8276 const previousInstantTypeRef = React36.useRef(null);
8277 useIsoLayoutEffect(() => {
8278 if (openState && disabled2) {
8279 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8280 }
8281 }, [openState, disabled2, store2]);
8282 useIsoLayoutEffect(() => {
8283 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8284 if (instantType !== "delay") {
8285 previousInstantTypeRef.current = instantType;
8286 }
8287 store2.set("instantType", "delay");
8288 } else if (previousInstantTypeRef.current !== null) {
8289 store2.set("instantType", previousInstantTypeRef.current);
8290 previousInstantTypeRef.current = null;
8291 }
8292 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store2]);
8293 useIsoLayoutEffect(() => {
8294 if (open) {
8295 if (activeTriggerId == null) {
8296 store2.set("payload", void 0);
8297 }
8298 }
8299 }, [store2, activeTriggerId, open]);
8300 const handleImperativeClose = React36.useCallback(() => {
8301 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8302 }, [store2]);
8303 React36.useImperativeHandle(actionsRef, () => ({
8304 unmount: forceUnmount,
8305 close: handleImperativeClose
8306 }), [forceUnmount, handleImperativeClose]);
8307 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
8308 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, {
8309 value: store2,
8310 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, {
8311 store: store2,
8312 disabled: disabled2,
8313 trackCursorAxis
8314 }), typeof children === "function" ? children({
8315 payload
8316 }) : children]
8317 });
8318 });
8319 if (true) TooltipRoot.displayName = "TooltipRoot";
8320 function TooltipInteractions({
8321 store: store2,
8322 disabled: disabled2,
8323 trackCursorAxis
8324 }) {
8325 const floatingRootContext = store2.useState("floatingRootContext");
8326 const dismiss = useDismiss(floatingRootContext, {
8327 enabled: !disabled2,
8328 referencePress: () => store2.select("closeOnClick")
8329 });
8330 const clientPoint = useClientPoint(floatingRootContext, {
8331 enabled: !disabled2 && trackCursorAxis !== "none",
8332 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8333 });
8334 const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
8335 const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
8336 const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
8337 usePopupInteractionProps(store2, {
8338 activeTriggerProps,
8339 inactiveTriggerProps,
8340 popupProps
8341 });
8342 return null;
8343 }
8344
8345 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8346 var React38 = __toESM(require_react(), 1);
8347
8348 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8349 var React37 = __toESM(require_react(), 1);
8350 var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0);
8351 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8352 function useTooltipProviderContext() {
8353 return React37.useContext(TooltipProviderContext);
8354 }
8355
8356 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8357 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8358 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8359 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8360 return TooltipTriggerDataAttributes2;
8361 })({});
8362
8363 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8364 var OPEN_DELAY = 600;
8365
8366 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8367 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
8368 function getTargetElement(event) {
8369 if ("composedPath" in event) {
8370 const path = event.composedPath();
8371 for (let i = 0; i < path.length; i += 1) {
8372 const element = path[i];
8373 if (isElement(element)) {
8374 return element;
8375 }
8376 }
8377 }
8378 const target = event.target;
8379 if (isElement(target)) {
8380 return target;
8381 }
8382 return null;
8383 }
8384 function closestEnabledTooltipTrigger(element) {
8385 let current = element;
8386 while (current) {
8387 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
8388 return current;
8389 }
8390 const parentElement = current.parentElement;
8391 if (parentElement) {
8392 current = parentElement;
8393 continue;
8394 }
8395 const root = current.getRootNode();
8396 current = "host" in root && isElement(root.host) ? root.host : null;
8397 }
8398 return null;
8399 }
8400 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8401 const {
8402 render,
8403 className,
8404 style,
8405 handle,
8406 payload,
8407 disabled: disabledProp,
8408 delay,
8409 closeOnClick = true,
8410 closeDelay,
8411 id: idProp,
8412 ...elementProps
8413 } = componentProps;
8414 const rootContext = useTooltipRootContext(true);
8415 const store2 = handle?.store ?? rootContext;
8416 if (!store2) {
8417 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));
8418 }
8419 const thisTriggerId = useBaseUiId(idProp);
8420 const isTriggerActive = store2.useState("isTriggerActive", thisTriggerId);
8421 const isOpenedByThisTrigger = store2.useState("isOpenedByTrigger", thisTriggerId);
8422 const floatingRootContext = store2.useState("floatingRootContext");
8423 const triggerElementRef = React38.useRef(null);
8424 const delayWithDefault = delay ?? OPEN_DELAY;
8425 const closeDelayWithDefault = closeDelay ?? 0;
8426 const {
8427 registerTrigger,
8428 isMountedByThisTrigger
8429 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store2, {
8430 payload,
8431 closeOnClick,
8432 closeDelay: closeDelayWithDefault
8433 });
8434 const providerContext = useTooltipProviderContext();
8435 const {
8436 delayRef,
8437 isInstantPhase,
8438 hasProvider
8439 } = useDelayGroup(floatingRootContext, {
8440 open: isOpenedByThisTrigger
8441 });
8442 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
8443 store2.useSyncedValue("isInstantPhase", isInstantPhase);
8444 const rootDisabled = store2.useState("disabled");
8445 const disabled2 = disabledProp ?? rootDisabled;
8446 const disabledRef = useValueAsRef(disabled2);
8447 const trackCursorAxis = store2.useState("trackCursorAxis");
8448 const disableHoverablePopup = store2.useState("disableHoverablePopup");
8449 const isNestedTriggerHoveredRef = React38.useRef(false);
8450 const nestedTriggerOpenTimeout = useTimeout();
8451 const pointerTypeRef = React38.useRef(void 0);
8452 function getOpenDelay() {
8453 const providerDelay = providerContext?.delay;
8454 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8455 let computedOpenDelay = delayWithDefault;
8456 if (hasProvider) {
8457 if (groupOpenValue !== 0) {
8458 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
8459 } else {
8460 computedOpenDelay = 0;
8461 }
8462 }
8463 return computedOpenDelay;
8464 }
8465 function isEnabledNestedTriggerTarget(target) {
8466 const triggerEl = triggerElementRef.current;
8467 if (!triggerEl || !target) {
8468 return false;
8469 }
8470 const nearestTrigger = closestEnabledTooltipTrigger(target);
8471 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
8472 }
8473 function detectNestedTriggerHover(target) {
8474 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
8475 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
8476 if (nestedTriggerHovered) {
8477 hoverInteraction.openChangeTimeout.clear();
8478 hoverInteraction.restTimeout.clear();
8479 hoverInteraction.restTimeoutPending = false;
8480 nestedTriggerOpenTimeout.clear();
8481 }
8482 return nestedTriggerHovered;
8483 }
8484 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8485 enabled: !disabled2,
8486 mouseOnly: true,
8487 move: false,
8488 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8489 restMs: getOpenDelay,
8490 delay() {
8491 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8492 let computedCloseDelay = closeDelayWithDefault;
8493 if (closeDelay == null && hasProvider) {
8494 computedCloseDelay = closeValue;
8495 }
8496 return {
8497 close: computedCloseDelay
8498 };
8499 },
8500 triggerElementRef,
8501 isActiveTrigger: isTriggerActive,
8502 isClosing: () => store2.select("transitionStatus") === "ending",
8503 shouldOpen() {
8504 return !isNestedTriggerHoveredRef.current;
8505 }
8506 });
8507 const focusProps = useFocus(floatingRootContext, {
8508 enabled: !disabled2
8509 }).reference;
8510 const handleNestedTriggerHover = (event) => {
8511 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
8512 const target = getTargetElement(event);
8513 const nestedTriggerHovered = detectNestedTriggerHover(target);
8514 const triggerEl = triggerElementRef.current;
8515 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
8516 if (nestedTriggerHovered && store2.select("open") && store2.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
8517 store2.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8518 return;
8519 }
8520 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store2.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
8521 isMouseLikePointerType(pointerTypeRef.current)) {
8522 const open = () => {
8523 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store2.select("open")) {
8524 store2.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
8525 }
8526 };
8527 const openDelay = getOpenDelay();
8528 if (openDelay === 0) {
8529 nestedTriggerOpenTimeout.clear();
8530 open();
8531 } else {
8532 nestedTriggerOpenTimeout.start(openDelay, open);
8533 }
8534 }
8535 };
8536 const rootTriggerProps = store2.useState("triggerProps", isMountedByThisTrigger);
8537 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
8538 const state = {
8539 open: isOpenedByThisTrigger
8540 };
8541 const element = useRenderElement("button", componentProps, {
8542 state,
8543 ref: [forwardedRef, registerTrigger, triggerElementRef],
8544 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
8545 onMouseOver(event) {
8546 handleNestedTriggerHover(event.nativeEvent);
8547 },
8548 onFocus(event) {
8549 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
8550 event.preventBaseUIHandler();
8551 }
8552 },
8553 onMouseLeave() {
8554 isNestedTriggerHoveredRef.current = false;
8555 nestedTriggerOpenTimeout.clear();
8556 pointerTypeRef.current = void 0;
8557 },
8558 onPointerEnter(event) {
8559 pointerTypeRef.current = event.pointerType;
8560 },
8561 onPointerDown(event) {
8562 pointerTypeRef.current = event.pointerType;
8563 store2.set("closeOnClick", closeOnClick);
8564 if (closeOnClick && !store2.select("open")) {
8565 store2.cancelPendingOpen(event.nativeEvent);
8566 }
8567 },
8568 onClick(event) {
8569 if (closeOnClick && !store2.select("open")) {
8570 store2.cancelPendingOpen(event.nativeEvent);
8571 }
8572 },
8573 id: thisTriggerId,
8574 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
8575 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
8576 }, elementProps],
8577 stateAttributesMapping: triggerOpenStateMapping
8578 });
8579 return element;
8580 });
8581 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8582
8583 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8584 var React40 = __toESM(require_react(), 1);
8585
8586 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8587 var React39 = __toESM(require_react(), 1);
8588 var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0);
8589 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8590 function useTooltipPortalContext() {
8591 const value = React39.useContext(TooltipPortalContext);
8592 if (value === void 0) {
8593 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8594 }
8595 return value;
8596 }
8597
8598 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8599 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8600 var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) {
8601 const {
8602 keepMounted = false,
8603 ...portalProps
8604 } = props;
8605 const store2 = useTooltipRootContext();
8606 const mounted = store2.useState("mounted");
8607 const shouldRender = mounted || keepMounted;
8608 if (!shouldRender) {
8609 return null;
8610 }
8611 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8612 value: keepMounted,
8613 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8614 ref: forwardedRef,
8615 ...portalProps
8616 })
8617 });
8618 });
8619 if (true) TooltipPortal.displayName = "TooltipPortal";
8620
8621 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8622 var React42 = __toESM(require_react(), 1);
8623
8624 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8625 var React41 = __toESM(require_react(), 1);
8626 var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0);
8627 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8628 function useTooltipPositionerContext() {
8629 const context = React41.useContext(TooltipPositionerContext);
8630 if (context === void 0) {
8631 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8632 }
8633 return context;
8634 }
8635
8636 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8637 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8638 var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8639 const {
8640 render,
8641 className,
8642 anchor,
8643 positionMethod = "absolute",
8644 side = "top",
8645 align = "center",
8646 sideOffset = 0,
8647 alignOffset = 0,
8648 collisionBoundary = "clipping-ancestors",
8649 collisionPadding = 5,
8650 arrowPadding = 5,
8651 sticky = false,
8652 disableAnchorTracking = false,
8653 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8654 style,
8655 ...elementProps
8656 } = componentProps;
8657 const store2 = useTooltipRootContext();
8658 const keepMounted = useTooltipPortalContext();
8659 const open = store2.useState("open");
8660 const mounted = store2.useState("mounted");
8661 const trackCursorAxis = store2.useState("trackCursorAxis");
8662 const disableHoverablePopup = store2.useState("disableHoverablePopup");
8663 const floatingRootContext = store2.useState("floatingRootContext");
8664 const instantType = store2.useState("instantType");
8665 const transitionStatus = store2.useState("transitionStatus");
8666 const hasViewport = store2.useState("hasViewport");
8667 const positioning = useAnchorPositioning({
8668 anchor,
8669 positionMethod,
8670 floatingRootContext,
8671 mounted,
8672 side,
8673 sideOffset,
8674 align,
8675 alignOffset,
8676 collisionBoundary,
8677 collisionPadding,
8678 sticky,
8679 arrowPadding,
8680 disableAnchorTracking,
8681 keepMounted,
8682 collisionAvoidance,
8683 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8684 });
8685 const state = React42.useMemo(() => ({
8686 open,
8687 side: positioning.side,
8688 align: positioning.align,
8689 anchorHidden: positioning.anchorHidden,
8690 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8691 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8692 const element = usePositioner(componentProps, state, {
8693 styles: positioning.positionerStyles,
8694 transitionStatus,
8695 props: elementProps,
8696 refs: [forwardedRef, store2.useStateSetter("positionerElement")],
8697 hidden: !mounted,
8698 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8699 });
8700 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8701 value: positioning,
8702 children: element
8703 });
8704 });
8705 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8706
8707 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8708 var React43 = __toESM(require_react(), 1);
8709 var stateAttributesMapping = {
8710 ...popupStateMapping,
8711 ...transitionStatusMapping
8712 };
8713 var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8714 const {
8715 render,
8716 className,
8717 style,
8718 ...elementProps
8719 } = componentProps;
8720 const store2 = useTooltipRootContext();
8721 const {
8722 side,
8723 align
8724 } = useTooltipPositionerContext();
8725 const open = store2.useState("open");
8726 const instantType = store2.useState("instantType");
8727 const transitionStatus = store2.useState("transitionStatus");
8728 const popupProps = store2.useState("popupProps");
8729 const floatingContext = store2.useState("floatingRootContext");
8730 const disabled2 = store2.useState("disabled");
8731 const closeDelay = store2.useState("closeDelay");
8732 useOpenChangeComplete({
8733 open,
8734 ref: store2.context.popupRef,
8735 onComplete() {
8736 if (open) {
8737 store2.context.onOpenChangeComplete?.(true);
8738 }
8739 }
8740 });
8741 useHoverFloatingInteraction(floatingContext, {
8742 enabled: !disabled2,
8743 closeDelay
8744 });
8745 const setPopupElement = store2.useStateSetter("popupElement");
8746 const state = {
8747 open,
8748 side,
8749 align,
8750 instant: instantType,
8751 transitionStatus
8752 };
8753 const element = useRenderElement("div", componentProps, {
8754 state,
8755 ref: [forwardedRef, store2.context.popupRef, setPopupElement],
8756 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8757 stateAttributesMapping
8758 });
8759 return element;
8760 });
8761 if (true) TooltipPopup.displayName = "TooltipPopup";
8762
8763 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8764 var React44 = __toESM(require_react(), 1);
8765 var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8766 const {
8767 render,
8768 className,
8769 style,
8770 ...elementProps
8771 } = componentProps;
8772 const store2 = useTooltipRootContext();
8773 const {
8774 arrowRef,
8775 side,
8776 align,
8777 arrowUncentered,
8778 arrowStyles
8779 } = useTooltipPositionerContext();
8780 const open = store2.useState("open");
8781 const instantType = store2.useState("instantType");
8782 const state = {
8783 open,
8784 side,
8785 align,
8786 uncentered: arrowUncentered,
8787 instant: instantType
8788 };
8789 const element = useRenderElement("div", componentProps, {
8790 state,
8791 ref: [forwardedRef, arrowRef],
8792 props: [{
8793 style: arrowStyles,
8794 "aria-hidden": true
8795 }, elementProps],
8796 stateAttributesMapping: popupStateMapping
8797 });
8798 return element;
8799 });
8800 if (true) TooltipArrow.displayName = "TooltipArrow";
8801
8802 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8803 var React45 = __toESM(require_react(), 1);
8804 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
8805 var TooltipProvider = function TooltipProvider2(props) {
8806 const {
8807 delay,
8808 closeDelay,
8809 timeout = 400
8810 } = props;
8811 const contextValue = React45.useMemo(() => ({
8812 delay,
8813 closeDelay
8814 }), [delay, closeDelay]);
8815 const delayValue = React45.useMemo(() => ({
8816 open: delay,
8817 close: closeDelay
8818 }), [delay, closeDelay]);
8819 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
8820 value: contextValue,
8821 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
8822 delay: delayValue,
8823 timeoutMs: timeout,
8824 children: props.children
8825 })
8826 });
8827 };
8828 if (true) TooltipProvider.displayName = "TooltipProvider";
8829
8830 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8831 var React46 = __toESM(require_react(), 1);
8832
8833 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8834 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8835 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8836 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8837 return TooltipViewportCssVars2;
8838 })({});
8839
8840 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8841 var stateAttributesMapping2 = {
8842 activationDirection: (value) => value ? {
8843 "data-activation-direction": value
8844 } : null
8845 };
8846 var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8847 const {
8848 render,
8849 className,
8850 style,
8851 children,
8852 ...elementProps
8853 } = componentProps;
8854 const store2 = useTooltipRootContext();
8855 const positioner = useTooltipPositionerContext();
8856 const instantType = store2.useState("instantType");
8857 const {
8858 children: childrenToRender,
8859 state: viewportState
8860 } = usePopupViewport({
8861 store: store2,
8862 side: positioner.side,
8863 cssVars: TooltipViewportCssVars,
8864 children
8865 });
8866 const state = {
8867 activationDirection: viewportState.activationDirection,
8868 transitioning: viewportState.transitioning,
8869 instant: instantType
8870 };
8871 return useRenderElement("div", componentProps, {
8872 state,
8873 ref: forwardedRef,
8874 props: [elementProps, {
8875 children: childrenToRender
8876 }],
8877 stateAttributesMapping: stateAttributesMapping2
8878 });
8879 });
8880 if (true) TooltipViewport.displayName = "TooltipViewport";
8881
8882 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8883 var TooltipHandle = class {
8884 /**
8885 * Internal store holding the tooltip state.
8886 * @internal
8887 */
8888 constructor() {
8889 this.store = new TooltipStore();
8890 }
8891 /**
8892 * Opens the tooltip and associates it with the trigger with the given ID.
8893 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8894 *
8895 * This method should only be called in an event handler or an effect (not during rendering).
8896 *
8897 * @param triggerId ID of the trigger to associate with the tooltip.
8898 */
8899 open(triggerId) {
8900 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8901 if (triggerId && !triggerElement) {
8902 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8903 }
8904 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8905 }
8906 /**
8907 * Closes the tooltip.
8908 */
8909 close() {
8910 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8911 }
8912 /**
8913 * Indicates whether the tooltip is currently open.
8914 */
8915 get isOpen() {
8916 return this.store.select("open");
8917 }
8918 };
8919 function createTooltipHandle() {
8920 return new TooltipHandle();
8921 }
8922
8923 // node_modules/@base-ui/react/esm/use-render/useRender.js
8924 function useRender(params) {
8925 return useRenderElement(params.defaultTagName ?? "div", params, params);
8926 }
8927
8928 // packages/icons/build-module/icon/index.mjs
8929 var import_element11 = __toESM(require_element(), 1);
8930 var icon_default = (0, import_element11.forwardRef)(
8931 ({ icon, size: size4 = 24, ...props }, ref) => {
8932 return (0, import_element11.cloneElement)(icon, {
8933 width: size4,
8934 height: size4,
8935 ...props,
8936 ref
8937 });
8938 }
8939 );
8940
8941 // packages/icons/build-module/library/star-empty.mjs
8942 var import_primitives = __toESM(require_primitives(), 1);
8943 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
8944 var star_empty_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z" }) });
8945
8946 // packages/icons/build-module/library/star-filled.mjs
8947 var import_primitives2 = __toESM(require_primitives(), 1);
8948 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
8949 var star_filled_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.Path, { d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z" }) });
8950
8951 // packages/icons/build-module/library/star-half.mjs
8952 var import_primitives3 = __toESM(require_primitives(), 1);
8953 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
8954 var star_half_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.Path, { d: "M9.518 8.783a.25.25 0 00.188-.137l2.069-4.192a.25.25 0 01.448 0l2.07 4.192a.25.25 0 00.187.137l4.626.672a.25.25 0 01.139.427l-3.347 3.262a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.363.264l-4.137-2.176a.25.25 0 00-.233 0l-4.138 2.175a.25.25 0 01-.362-.263l.79-4.607a.25.25 0 00-.072-.222L4.753 9.882a.25.25 0 01.14-.427l4.625-.672zM12 14.533c.28 0 .559.067.814.2l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39v7.143z" }) });
8955
8956 // packages/ui/build-module/utils/render-slot-with-children.mjs
8957 var import_element12 = __toESM(require_element(), 1);
8958 function renderSlotWithChildren(slot, defaultSlot, children) {
8959 return (0, import_element12.cloneElement)(slot ?? defaultSlot, { children });
8960 }
8961
8962 // packages/ui/build-module/utils/theme-provider.mjs
8963 var theme = __toESM(require_theme(), 1);
8964
8965 // packages/ui/build-module/lock-unlock.mjs
8966 var import_private_apis = __toESM(require_private_apis(), 1);
8967 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
8968 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
8969 "@wordpress/ui"
8970 );
8971
8972 // packages/ui/build-module/utils/theme-provider.mjs
8973 function getThemeProvider() {
8974 const themePackage = theme;
8975 if (themePackage.ThemeProvider) {
8976 return themePackage.ThemeProvider;
8977 }
8978 if (!themePackage.privateApis) {
8979 throw new Error(
8980 "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
8981 );
8982 }
8983 return unlock(
8984 themePackage.privateApis
8985 ).ThemeProvider;
8986 }
8987 var ThemeProvider = getThemeProvider();
8988
8989 // packages/ui/build-module/tooltip/index.mjs
8990 var tooltip_exports = {};
8991 __export(tooltip_exports, {
8992 Popup: () => Popup,
8993 Portal: () => Portal,
8994 Positioner: () => Positioner,
8995 Provider: () => Provider,
8996 Root: () => Root,
8997 Trigger: () => Trigger
8998 });
8999
9000 // packages/ui/build-module/tooltip/popup.mjs
9001 var import_element15 = __toESM(require_element(), 1);
9002
9003 // packages/ui/build-module/tooltip/portal.mjs
9004 var import_element13 = __toESM(require_element(), 1);
9005
9006 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9007 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9008 function getRuntime() {
9009 const globalScope = globalThis;
9010 if (globalScope.__wpStyleRuntime) {
9011 return globalScope.__wpStyleRuntime;
9012 }
9013 globalScope.__wpStyleRuntime = {
9014 documents: /* @__PURE__ */ new Map(),
9015 styles: /* @__PURE__ */ new Map(),
9016 injectedStyles: /* @__PURE__ */ new WeakMap()
9017 };
9018 if (typeof document !== "undefined") {
9019 registerDocument(document);
9020 }
9021 return globalScope.__wpStyleRuntime;
9022 }
9023 function documentContainsStyleHash(targetDocument, hash) {
9024 if (!targetDocument.head) {
9025 return false;
9026 }
9027 for (const style of targetDocument.head.querySelectorAll(
9028 `style[${STYLE_HASH_ATTRIBUTE}]`
9029 )) {
9030 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9031 return true;
9032 }
9033 }
9034 return false;
9035 }
9036 function injectStyle(targetDocument, hash, css) {
9037 if (!targetDocument.head) {
9038 return;
9039 }
9040 const runtime = getRuntime();
9041 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9042 if (!injectedStyles) {
9043 injectedStyles = /* @__PURE__ */ new Set();
9044 runtime.injectedStyles.set(targetDocument, injectedStyles);
9045 }
9046 if (injectedStyles.has(hash)) {
9047 return;
9048 }
9049 if (documentContainsStyleHash(targetDocument, hash)) {
9050 injectedStyles.add(hash);
9051 return;
9052 }
9053 const style = targetDocument.createElement("style");
9054 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9055 style.appendChild(targetDocument.createTextNode(css));
9056 targetDocument.head.appendChild(style);
9057 injectedStyles.add(hash);
9058 }
9059 function registerDocument(targetDocument) {
9060 const runtime = getRuntime();
9061 runtime.documents.set(
9062 targetDocument,
9063 (runtime.documents.get(targetDocument) ?? 0) + 1
9064 );
9065 for (const [hash, css] of runtime.styles) {
9066 injectStyle(targetDocument, hash, css);
9067 }
9068 return () => {
9069 const count = runtime.documents.get(targetDocument);
9070 if (count === void 0) {
9071 return;
9072 }
9073 if (count <= 1) {
9074 runtime.documents.delete(targetDocument);
9075 return;
9076 }
9077 runtime.documents.set(targetDocument, count - 1);
9078 };
9079 }
9080 function registerStyle(hash, css) {
9081 const runtime = getRuntime();
9082 runtime.styles.set(hash, css);
9083 for (const targetDocument of runtime.documents.keys()) {
9084 injectStyle(targetDocument, hash, css);
9085 }
9086 }
9087 if (typeof process === "undefined" || true) {
9088 registerStyle("be37f31c1e", "._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}}");
9089 }
9090 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9091 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9092 function resolveOwnerDocument() {
9093 return typeof document === "undefined" ? null : document;
9094 }
9095 function isInWordPressEnvironment() {
9096 let topWp;
9097 try {
9098 topWp = window.top?.wp;
9099 } catch {
9100 }
9101 const wp = topWp ?? window.wp;
9102 return typeof wp?.components === "object" && wp.components !== null;
9103 }
9104 var cachedSlot = null;
9105 function createSlot(ownerDocument2) {
9106 const element = ownerDocument2.createElement("div");
9107 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9108 if (wp_compat_overlay_slot_default.slot) {
9109 element.classList.add(wp_compat_overlay_slot_default.slot);
9110 }
9111 ownerDocument2.body.appendChild(element);
9112 return element;
9113 }
9114 function getWpCompatOverlaySlot() {
9115 if (typeof window === "undefined") {
9116 return void 0;
9117 }
9118 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9119 return void 0;
9120 }
9121 const ownerDocument2 = resolveOwnerDocument();
9122 if (!ownerDocument2 || !ownerDocument2.body) {
9123 return void 0;
9124 }
9125 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9126 return cachedSlot;
9127 }
9128 const existing = ownerDocument2.querySelector(
9129 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9130 );
9131 if (existing instanceof HTMLDivElement) {
9132 cachedSlot = existing;
9133 return existing;
9134 }
9135 if (cachedSlot?.isConnected) {
9136 cachedSlot.remove();
9137 }
9138 cachedSlot = createSlot(ownerDocument2);
9139 return cachedSlot;
9140 }
9141
9142 // packages/ui/build-module/tooltip/portal.mjs
9143 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
9144 var Portal = (0, import_element13.forwardRef)(
9145 function TooltipPortal3({ container, ...restProps }, ref) {
9146 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
9147 index_parts_exports.Portal,
9148 {
9149 container: container ?? getWpCompatOverlaySlot(),
9150 ...restProps,
9151 ref
9152 }
9153 );
9154 }
9155 );
9156
9157 // packages/ui/build-module/tooltip/positioner.mjs
9158 var import_element14 = __toESM(require_element(), 1);
9159 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
9160 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9161 function getRuntime2() {
9162 const globalScope = globalThis;
9163 if (globalScope.__wpStyleRuntime) {
9164 return globalScope.__wpStyleRuntime;
9165 }
9166 globalScope.__wpStyleRuntime = {
9167 documents: /* @__PURE__ */ new Map(),
9168 styles: /* @__PURE__ */ new Map(),
9169 injectedStyles: /* @__PURE__ */ new WeakMap()
9170 };
9171 if (typeof document !== "undefined") {
9172 registerDocument2(document);
9173 }
9174 return globalScope.__wpStyleRuntime;
9175 }
9176 function documentContainsStyleHash2(targetDocument, hash) {
9177 if (!targetDocument.head) {
9178 return false;
9179 }
9180 for (const style of targetDocument.head.querySelectorAll(
9181 `style[${STYLE_HASH_ATTRIBUTE2}]`
9182 )) {
9183 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9184 return true;
9185 }
9186 }
9187 return false;
9188 }
9189 function injectStyle2(targetDocument, hash, css) {
9190 if (!targetDocument.head) {
9191 return;
9192 }
9193 const runtime = getRuntime2();
9194 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9195 if (!injectedStyles) {
9196 injectedStyles = /* @__PURE__ */ new Set();
9197 runtime.injectedStyles.set(targetDocument, injectedStyles);
9198 }
9199 if (injectedStyles.has(hash)) {
9200 return;
9201 }
9202 if (documentContainsStyleHash2(targetDocument, hash)) {
9203 injectedStyles.add(hash);
9204 return;
9205 }
9206 const style = targetDocument.createElement("style");
9207 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9208 style.appendChild(targetDocument.createTextNode(css));
9209 targetDocument.head.appendChild(style);
9210 injectedStyles.add(hash);
9211 }
9212 function registerDocument2(targetDocument) {
9213 const runtime = getRuntime2();
9214 runtime.documents.set(
9215 targetDocument,
9216 (runtime.documents.get(targetDocument) ?? 0) + 1
9217 );
9218 for (const [hash, css] of runtime.styles) {
9219 injectStyle2(targetDocument, hash, css);
9220 }
9221 return () => {
9222 const count = runtime.documents.get(targetDocument);
9223 if (count === void 0) {
9224 return;
9225 }
9226 if (count <= 1) {
9227 runtime.documents.delete(targetDocument);
9228 return;
9229 }
9230 runtime.documents.set(targetDocument, count - 1);
9231 };
9232 }
9233 function registerStyle2(hash, css) {
9234 const runtime = getRuntime2();
9235 runtime.styles.set(hash, css);
9236 for (const targetDocument of runtime.documents.keys()) {
9237 injectStyle2(targetDocument, hash, css);
9238 }
9239 }
9240 if (typeof process === "undefined" || true) {
9241 registerStyle2("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
9242 }
9243 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9244 if (typeof process === "undefined" || true) {
9245 registerStyle2("789467362f", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
9246 }
9247 var style_default = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9248 var Positioner = (0, import_element14.forwardRef)(
9249 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9250 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
9251 index_parts_exports.Positioner,
9252 {
9253 ref,
9254 align,
9255 side,
9256 sideOffset,
9257 ...props,
9258 className: clsx_default(
9259 resets_default["box-sizing"],
9260 style_default.positioner,
9261 className
9262 )
9263 }
9264 );
9265 }
9266 );
9267
9268 // packages/ui/build-module/tooltip/popup.mjs
9269 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
9270 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9271 function getRuntime3() {
9272 const globalScope = globalThis;
9273 if (globalScope.__wpStyleRuntime) {
9274 return globalScope.__wpStyleRuntime;
9275 }
9276 globalScope.__wpStyleRuntime = {
9277 documents: /* @__PURE__ */ new Map(),
9278 styles: /* @__PURE__ */ new Map(),
9279 injectedStyles: /* @__PURE__ */ new WeakMap()
9280 };
9281 if (typeof document !== "undefined") {
9282 registerDocument3(document);
9283 }
9284 return globalScope.__wpStyleRuntime;
9285 }
9286 function documentContainsStyleHash3(targetDocument, hash) {
9287 if (!targetDocument.head) {
9288 return false;
9289 }
9290 for (const style of targetDocument.head.querySelectorAll(
9291 `style[${STYLE_HASH_ATTRIBUTE3}]`
9292 )) {
9293 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9294 return true;
9295 }
9296 }
9297 return false;
9298 }
9299 function injectStyle3(targetDocument, hash, css) {
9300 if (!targetDocument.head) {
9301 return;
9302 }
9303 const runtime = getRuntime3();
9304 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9305 if (!injectedStyles) {
9306 injectedStyles = /* @__PURE__ */ new Set();
9307 runtime.injectedStyles.set(targetDocument, injectedStyles);
9308 }
9309 if (injectedStyles.has(hash)) {
9310 return;
9311 }
9312 if (documentContainsStyleHash3(targetDocument, hash)) {
9313 injectedStyles.add(hash);
9314 return;
9315 }
9316 const style = targetDocument.createElement("style");
9317 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9318 style.appendChild(targetDocument.createTextNode(css));
9319 targetDocument.head.appendChild(style);
9320 injectedStyles.add(hash);
9321 }
9322 function registerDocument3(targetDocument) {
9323 const runtime = getRuntime3();
9324 runtime.documents.set(
9325 targetDocument,
9326 (runtime.documents.get(targetDocument) ?? 0) + 1
9327 );
9328 for (const [hash, css] of runtime.styles) {
9329 injectStyle3(targetDocument, hash, css);
9330 }
9331 return () => {
9332 const count = runtime.documents.get(targetDocument);
9333 if (count === void 0) {
9334 return;
9335 }
9336 if (count <= 1) {
9337 runtime.documents.delete(targetDocument);
9338 return;
9339 }
9340 runtime.documents.set(targetDocument, count - 1);
9341 };
9342 }
9343 function registerStyle3(hash, css) {
9344 const runtime = getRuntime3();
9345 runtime.styles.set(hash, css);
9346 for (const targetDocument of runtime.documents.keys()) {
9347 injectStyle3(targetDocument, hash, css);
9348 }
9349 }
9350 if (typeof process === "undefined" || true) {
9351 registerStyle3("789467362f", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
9352 }
9353 var style_default2 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9354 var POPUP_COLOR = { background: "#1e1e1e" };
9355 var Popup = (0, import_element15.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9356 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
9357 index_parts_exports.Popup,
9358 {
9359 ref,
9360 className: clsx_default(style_default2.popup, className),
9361 ...props,
9362 children
9363 }
9364 ) });
9365 const positionedPopup = renderSlotWithChildren(
9366 positioner,
9367 /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Positioner, {}),
9368 popupContent
9369 );
9370 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Portal, {}), positionedPopup);
9371 });
9372
9373 // packages/ui/build-module/tooltip/trigger.mjs
9374 var import_element16 = __toESM(require_element(), 1);
9375 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
9376 var Trigger = (0, import_element16.forwardRef)(
9377 function TooltipTrigger3(props, ref) {
9378 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(index_parts_exports.Trigger, { ref, ...props });
9379 }
9380 );
9381
9382 // packages/ui/build-module/tooltip/root.mjs
9383 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
9384 function Root(props) {
9385 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(index_parts_exports.Root, { ...props });
9386 }
9387
9388 // packages/ui/build-module/tooltip/provider.mjs
9389 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
9390 function Provider({ ...props }) {
9391 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(index_parts_exports.Provider, { ...props });
9392 }
9393
9394 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
9395 var import_element17 = __toESM(require_element(), 1);
9396 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9397 function getRuntime4() {
9398 const globalScope = globalThis;
9399 if (globalScope.__wpStyleRuntime) {
9400 return globalScope.__wpStyleRuntime;
9401 }
9402 globalScope.__wpStyleRuntime = {
9403 documents: /* @__PURE__ */ new Map(),
9404 styles: /* @__PURE__ */ new Map(),
9405 injectedStyles: /* @__PURE__ */ new WeakMap()
9406 };
9407 if (typeof document !== "undefined") {
9408 registerDocument4(document);
9409 }
9410 return globalScope.__wpStyleRuntime;
9411 }
9412 function documentContainsStyleHash4(targetDocument, hash) {
9413 if (!targetDocument.head) {
9414 return false;
9415 }
9416 for (const style of targetDocument.head.querySelectorAll(
9417 `style[${STYLE_HASH_ATTRIBUTE4}]`
9418 )) {
9419 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9420 return true;
9421 }
9422 }
9423 return false;
9424 }
9425 function injectStyle4(targetDocument, hash, css) {
9426 if (!targetDocument.head) {
9427 return;
9428 }
9429 const runtime = getRuntime4();
9430 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9431 if (!injectedStyles) {
9432 injectedStyles = /* @__PURE__ */ new Set();
9433 runtime.injectedStyles.set(targetDocument, injectedStyles);
9434 }
9435 if (injectedStyles.has(hash)) {
9436 return;
9437 }
9438 if (documentContainsStyleHash4(targetDocument, hash)) {
9439 injectedStyles.add(hash);
9440 return;
9441 }
9442 const style = targetDocument.createElement("style");
9443 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9444 style.appendChild(targetDocument.createTextNode(css));
9445 targetDocument.head.appendChild(style);
9446 injectedStyles.add(hash);
9447 }
9448 function registerDocument4(targetDocument) {
9449 const runtime = getRuntime4();
9450 runtime.documents.set(
9451 targetDocument,
9452 (runtime.documents.get(targetDocument) ?? 0) + 1
9453 );
9454 for (const [hash, css] of runtime.styles) {
9455 injectStyle4(targetDocument, hash, css);
9456 }
9457 return () => {
9458 const count = runtime.documents.get(targetDocument);
9459 if (count === void 0) {
9460 return;
9461 }
9462 if (count <= 1) {
9463 runtime.documents.delete(targetDocument);
9464 return;
9465 }
9466 runtime.documents.set(targetDocument, count - 1);
9467 };
9468 }
9469 function registerStyle4(hash, css) {
9470 const runtime = getRuntime4();
9471 runtime.styles.set(hash, css);
9472 for (const targetDocument of runtime.documents.keys()) {
9473 injectStyle4(targetDocument, hash, css);
9474 }
9475 }
9476 if (typeof process === "undefined" || true) {
9477 registerStyle4("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}}");
9478 }
9479 var style_default3 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
9480 var VisuallyHidden = (0, import_element17.forwardRef)(
9481 function VisuallyHidden2({ render, ...restProps }, ref) {
9482 const element = useRender({
9483 render,
9484 ref,
9485 props: mergeProps(
9486 { className: style_default3["visually-hidden"] },
9487 restProps,
9488 {
9489 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
9490 "data-visually-hidden": ""
9491 }
9492 )
9493 });
9494 return element;
9495 }
9496 );
9497
9498 // packages/block-directory/build-module/components/block-ratings/stars.mjs
9499 var import_i18n2 = __toESM(require_i18n(), 1);
9500 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
9501 function Stars({ rating }) {
9502 const stars = Math.round(rating / 0.5) * 0.5;
9503 const fullStarCount = Math.floor(rating);
9504 const halfStarCount = Math.ceil(rating - fullStarCount);
9505 const emptyStarCount = 5 - (fullStarCount + halfStarCount);
9506 return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
9507 "span",
9508 {
9509 "aria-label": (0, import_i18n2.sprintf)(
9510 /* translators: %s: number of stars. */
9511 (0, import_i18n2.__)("%s out of 5 stars"),
9512 stars
9513 ),
9514 children: [
9515 Array.from({ length: fullStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
9516 icon_default,
9517 {
9518 className: "block-directory-block-ratings__star-full",
9519 icon: star_filled_default,
9520 size: 16
9521 },
9522 `full_stars_${i}`
9523 )),
9524 Array.from({ length: halfStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
9525 icon_default,
9526 {
9527 className: "block-directory-block-ratings__star-half-full",
9528 icon: star_half_default,
9529 size: 16
9530 },
9531 `half_stars_${i}`
9532 )),
9533 Array.from({ length: emptyStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
9534 icon_default,
9535 {
9536 className: "block-directory-block-ratings__star-empty",
9537 icon: star_empty_default,
9538 size: 16
9539 },
9540 `empty_stars_${i}`
9541 ))
9542 ]
9543 }
9544 );
9545 }
9546 var stars_default = Stars;
9547
9548 // packages/block-directory/build-module/components/block-ratings/index.mjs
9549 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
9550 var BlockRatings = ({ rating }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "block-directory-block-ratings", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(stars_default, { rating }) });
9551 var block_ratings_default = BlockRatings;
9552
9553 // packages/block-directory/build-module/components/downloadable-block-icon/index.mjs
9554 var import_block_editor2 = __toESM(require_block_editor(), 1);
9555 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
9556 function DownloadableBlockIcon({ icon }) {
9557 const className = "block-directory-downloadable-block-icon";
9558 return icon.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/) !== null ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("img", { className, src: icon, alt: "" }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_block_editor2.BlockIcon, { className, icon, showColors: true });
9559 }
9560 var downloadable_block_icon_default = DownloadableBlockIcon;
9561
9562 // packages/block-directory/build-module/components/downloadable-block-notice/index.mjs
9563 var import_i18n3 = __toESM(require_i18n(), 1);
9564 var import_data5 = __toESM(require_data(), 1);
9565 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
9566 var DownloadableBlockNotice = ({ block }) => {
9567 const errorNotice = (0, import_data5.useSelect)(
9568 (select) => select(store).getErrorNoticeForBlock(block.id),
9569 [block]
9570 );
9571 if (!errorNotice) {
9572 return null;
9573 }
9574 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "block-directory-downloadable-block-notice", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "block-directory-downloadable-block-notice__content", children: [
9575 errorNotice.message,
9576 errorNotice.isFatal ? " " + (0, import_i18n3.__)("Try reloading the page.") : null
9577 ] }) });
9578 };
9579 var downloadable_block_notice_default = DownloadableBlockNotice;
9580
9581 // packages/block-directory/build-module/components/downloadable-block-list-item/index.mjs
9582 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
9583 function getDownloadableBlockLabel({ title, rating, ratingCount }, { hasNotice, isInstalled, isInstalling: isInstalling2 }) {
9584 const stars = Math.round(rating / 0.5) * 0.5;
9585 if (!isInstalled && hasNotice) {
9586 return (0, import_i18n4.sprintf)("Retry installing %s.", (0, import_html_entities.decodeEntities)(title));
9587 }
9588 if (isInstalled) {
9589 return (0, import_i18n4.sprintf)("Add %s.", (0, import_html_entities.decodeEntities)(title));
9590 }
9591 if (isInstalling2) {
9592 return (0, import_i18n4.sprintf)("Installing %s.", (0, import_html_entities.decodeEntities)(title));
9593 }
9594 if (ratingCount < 1) {
9595 return (0, import_i18n4.sprintf)("Install %s.", (0, import_html_entities.decodeEntities)(title));
9596 }
9597 return (0, import_i18n4.sprintf)(
9598 /* translators: 1: block title, 2: average rating, 3: total ratings count. */
9599 (0, import_i18n4._n)(
9600 "Install %1$s. %2$s stars with %3$s review.",
9601 "Install %1$s. %2$s stars with %3$s reviews.",
9602 ratingCount
9603 ),
9604 (0, import_html_entities.decodeEntities)(title),
9605 stars,
9606 ratingCount
9607 );
9608 }
9609 function DownloadableBlockListItem({ item, onClick }) {
9610 const { author, description, icon, rating, title } = item;
9611 const isInstalled = !!(0, import_blocks3.getBlockType)(item.name);
9612 const { hasNotice, isInstalling: isInstalling2, isInstallable } = (0, import_data6.useSelect)(
9613 (select) => {
9614 const { getErrorNoticeForBlock: getErrorNoticeForBlock2, isInstalling: isBlockInstalling } = select(store);
9615 const notice = getErrorNoticeForBlock2(item.id);
9616 const hasFatal = notice && notice.isFatal;
9617 return {
9618 hasNotice: !!notice,
9619 isInstalling: isBlockInstalling(item.id),
9620 isInstallable: !hasFatal
9621 };
9622 },
9623 [item]
9624 );
9625 let statusText = "";
9626 if (isInstalled) {
9627 statusText = (0, import_i18n4.__)("Installed!");
9628 } else if (isInstalling2) {
9629 statusText = (0, import_i18n4.__)("Installing\u2026");
9630 }
9631 const itemLabel = getDownloadableBlockLabel(item, {
9632 hasNotice,
9633 isInstalled,
9634 isInstalling: isInstalling2
9635 });
9636 return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(tooltip_exports.Root, { children: [
9637 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
9638 tooltip_exports.Trigger,
9639 {
9640 render: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
9641 import_components.Composite.Item,
9642 {
9643 className: clsx_default(
9644 "block-directory-downloadable-block-list-item",
9645 isInstalling2 && "is-installing"
9646 ),
9647 accessibleWhenDisabled: true,
9648 disabled: isInstalling2 || !isInstallable,
9649 onClick: (event) => {
9650 event.preventDefault();
9651 onClick();
9652 },
9653 "aria-label": itemLabel,
9654 type: "button",
9655 role: "option",
9656 children: [
9657 /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "block-directory-downloadable-block-list-item__icon", children: [
9658 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
9659 downloadable_block_icon_default,
9660 {
9661 icon,
9662 title
9663 }
9664 ),
9665 isInstalling2 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "block-directory-downloadable-block-list-item__spinner", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components.Spinner, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(block_ratings_default, { rating })
9666 ] }),
9667 /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { className: "block-directory-downloadable-block-list-item__details", children: [
9668 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "block-directory-downloadable-block-list-item__title", children: (0, import_element18.createInterpolateElement)(
9669 (0, import_i18n4.sprintf)(
9670 /* translators: 1: block title. 2: author name. */
9671 (0, import_i18n4.__)("%1$s <span>by %2$s</span>"),
9672 (0, import_html_entities.decodeEntities)(title),
9673 author
9674 ),
9675 {
9676 span: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "block-directory-downloadable-block-list-item__author" })
9677 }
9678 ) }),
9679 hasNotice ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(downloadable_block_notice_default, { block: item }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
9680 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "block-directory-downloadable-block-list-item__desc", children: !!statusText ? statusText : (0, import_html_entities.decodeEntities)(description) }),
9681 isInstallable && !(isInstalled || isInstalling2) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(VisuallyHidden, { children: (0, import_i18n4.__)("Install block") })
9682 ] })
9683 ] })
9684 ]
9685 }
9686 )
9687 }
9688 ),
9689 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(tooltip_exports.Popup, { children: itemLabel })
9690 ] });
9691 }
9692 var downloadable_block_list_item_default = DownloadableBlockListItem;
9693
9694 // packages/block-directory/build-module/components/downloadable-blocks-list/index.mjs
9695 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
9696 var noop4 = () => {
9697 };
9698 function DownloadableBlocksList({ items, onHover = noop4, onSelect }) {
9699 const { installBlockType: installBlockType2 } = (0, import_data7.useDispatch)(store);
9700 if (!items.length) {
9701 return null;
9702 }
9703 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
9704 import_components2.Composite,
9705 {
9706 role: "listbox",
9707 className: "block-directory-downloadable-blocks-list",
9708 "aria-label": (0, import_i18n5.__)("Blocks available for install"),
9709 children: items.map((item) => {
9710 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
9711 downloadable_block_list_item_default,
9712 {
9713 onClick: () => {
9714 if ((0, import_blocks4.getBlockType)(item.name)) {
9715 onSelect(item);
9716 } else {
9717 installBlockType2(item).then((success) => {
9718 if (success) {
9719 onSelect(item);
9720 }
9721 });
9722 }
9723 onHover(null);
9724 },
9725 onHover,
9726 item
9727 },
9728 item.id
9729 );
9730 })
9731 }
9732 );
9733 }
9734 var downloadable_blocks_list_default = DownloadableBlocksList;
9735
9736 // packages/block-directory/build-module/components/downloadable-blocks-panel/inserter-panel.mjs
9737 var import_i18n6 = __toESM(require_i18n(), 1);
9738 var import_element19 = __toESM(require_element(), 1);
9739 var import_a11y = __toESM(require_a11y(), 1);
9740 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9741 function DownloadableBlocksInserterPanel({
9742 children,
9743 downloadableItems,
9744 hasLocalBlocks
9745 }) {
9746 const count = downloadableItems.length;
9747 (0, import_element19.useEffect)(() => {
9748 (0, import_a11y.speak)(
9749 (0, import_i18n6.sprintf)(
9750 /* translators: %d: number of available blocks. */
9751 (0, import_i18n6._n)(
9752 "%d additional block is available to install.",
9753 "%d additional blocks are available to install.",
9754 count
9755 ),
9756 count
9757 )
9758 );
9759 }, [count]);
9760 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
9761 !hasLocalBlocks && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "block-directory-downloadable-blocks-panel__no-local", children: (0, import_i18n6.__)("No results available from your installed blocks.") }),
9762 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "block-editor-inserter__quick-inserter-separator" }),
9763 /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "block-directory-downloadable-blocks-panel", children: [
9764 /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "block-directory-downloadable-blocks-panel__header", children: [
9765 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h2", { className: "block-directory-downloadable-blocks-panel__title", children: (0, import_i18n6.__)("Available to install") }),
9766 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "block-directory-downloadable-blocks-panel__description", children: (0, import_i18n6.__)(
9767 "Select a block to install and add it to your post."
9768 ) })
9769 ] }),
9770 children
9771 ] })
9772 ] });
9773 }
9774 var inserter_panel_default = DownloadableBlocksInserterPanel;
9775
9776 // packages/block-directory/build-module/components/downloadable-blocks-panel/no-results.mjs
9777 var import_i18n7 = __toESM(require_i18n(), 1);
9778 var import_components3 = __toESM(require_components(), 1);
9779 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9780 function DownloadableBlocksNoResults() {
9781 return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
9782 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "block-editor-inserter__no-results", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { children: (0, import_i18n7.__)("No results found.") }) }),
9783 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "block-editor-inserter__tips", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_components3.Tip, { children: [
9784 (0, import_i18n7.__)("Interested in creating your own block?"),
9785 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("br", {}),
9786 /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_components3.ExternalLink, { href: "https://developer.wordpress.org/block-editor/", children: [
9787 (0, import_i18n7.__)("Get started here"),
9788 "."
9789 ] })
9790 ] }) })
9791 ] });
9792 }
9793 var no_results_default = DownloadableBlocksNoResults;
9794
9795 // packages/block-directory/build-module/components/downloadable-blocks-panel/index.mjs
9796 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
9797 var EMPTY_ARRAY3 = [];
9798 var useDownloadableBlocks = (filterValue) => (0, import_data8.useSelect)(
9799 (select) => {
9800 const {
9801 getDownloadableBlocks: getDownloadableBlocks3,
9802 isRequestingDownloadableBlocks: isRequestingDownloadableBlocks2,
9803 getInstalledBlockTypes: getInstalledBlockTypes2
9804 } = select(store);
9805 const hasPermission = select(import_core_data.store).canUser(
9806 "read",
9807 "block-directory/search"
9808 );
9809 let downloadableBlocks2 = EMPTY_ARRAY3;
9810 if (hasPermission) {
9811 downloadableBlocks2 = getDownloadableBlocks3(filterValue);
9812 const installedBlockTypes = getInstalledBlockTypes2();
9813 const installableBlocks = downloadableBlocks2.filter(
9814 ({ name }) => {
9815 const isJustInstalled = installedBlockTypes.some(
9816 (blockType) => blockType.name === name
9817 );
9818 const isPreviouslyInstalled = (0, import_blocks5.getBlockType)(name);
9819 return isJustInstalled || !isPreviouslyInstalled;
9820 }
9821 );
9822 if (installableBlocks.length !== downloadableBlocks2.length) {
9823 downloadableBlocks2 = installableBlocks;
9824 }
9825 if (downloadableBlocks2.length === 0) {
9826 downloadableBlocks2 = EMPTY_ARRAY3;
9827 }
9828 }
9829 return {
9830 hasPermission,
9831 downloadableBlocks: downloadableBlocks2,
9832 isLoading: isRequestingDownloadableBlocks2(filterValue)
9833 };
9834 },
9835 [filterValue]
9836 );
9837 function DownloadableBlocksPanel({
9838 onSelect,
9839 onHover,
9840 hasLocalBlocks,
9841 isTyping,
9842 filterValue
9843 }) {
9844 const { hasPermission, downloadableBlocks: downloadableBlocks2, isLoading } = useDownloadableBlocks(filterValue);
9845 if (hasPermission === void 0 || isLoading || isTyping) {
9846 return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
9847 hasPermission && !hasLocalBlocks && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
9848 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "block-directory-downloadable-blocks-panel__no-local", children: (0, import_i18n8.__)(
9849 "No results available from your installed blocks."
9850 ) }),
9851 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "block-editor-inserter__quick-inserter-separator" })
9852 ] }),
9853 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "block-directory-downloadable-blocks-panel has-blocks-loading", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_components4.Spinner, {}) })
9854 ] });
9855 }
9856 if (false === hasPermission) {
9857 if (!hasLocalBlocks) {
9858 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(no_results_default, {});
9859 }
9860 return null;
9861 }
9862 if (downloadableBlocks2.length === 0) {
9863 return hasLocalBlocks ? null : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(no_results_default, {});
9864 }
9865 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
9866 inserter_panel_default,
9867 {
9868 downloadableItems: downloadableBlocks2,
9869 hasLocalBlocks,
9870 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
9871 downloadable_blocks_list_default,
9872 {
9873 items: downloadableBlocks2,
9874 onSelect,
9875 onHover
9876 }
9877 )
9878 }
9879 );
9880 }
9881
9882 // packages/block-directory/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs
9883 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
9884 function InserterMenuDownloadableBlocksPanel() {
9885 const [debouncedFilterValue, setFilterValue] = (0, import_element20.useState)("");
9886 const debouncedSetFilterValue = (0, import_compose.debounce)(setFilterValue, 400);
9887 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_block_editor3.__unstableInserterMenuExtension, { children: ({ onSelect, onHover, filterValue, hasItems }) => {
9888 if (debouncedFilterValue !== filterValue) {
9889 debouncedSetFilterValue(filterValue);
9890 }
9891 if (!debouncedFilterValue) {
9892 return null;
9893 }
9894 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
9895 DownloadableBlocksPanel,
9896 {
9897 onSelect,
9898 onHover,
9899 filterValue: debouncedFilterValue,
9900 hasLocalBlocks: hasItems,
9901 isTyping: filterValue !== debouncedFilterValue
9902 }
9903 );
9904 } });
9905 }
9906 var inserter_menu_downloadable_blocks_panel_default = InserterMenuDownloadableBlocksPanel;
9907
9908 // packages/block-directory/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs
9909 var import_i18n10 = __toESM(require_i18n(), 1);
9910 var import_data9 = __toESM(require_data(), 1);
9911 var import_editor2 = __toESM(require_editor(), 1);
9912
9913 // packages/block-directory/build-module/components/compact-list/index.mjs
9914 var import_i18n9 = __toESM(require_i18n(), 1);
9915 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
9916 function CompactList({ items }) {
9917 if (!items.length) {
9918 return null;
9919 }
9920 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("ul", { className: "block-directory-compact-list", children: items.map(({ icon, id, title, author }) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("li", { className: "block-directory-compact-list__item", children: [
9921 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(downloadable_block_icon_default, { icon, title }),
9922 /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "block-directory-compact-list__item-details", children: [
9923 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "block-directory-compact-list__item-title", children: title }),
9924 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "block-directory-compact-list__item-author", children: (0, import_i18n9.sprintf)(
9925 /* translators: %s: Name of the block author. */
9926 (0, import_i18n9.__)("By %s"),
9927 author
9928 ) })
9929 ] })
9930 ] }, id)) });
9931 }
9932
9933 // packages/block-directory/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs
9934 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
9935 function InstalledBlocksPrePublishPanel() {
9936 const newBlockTypes = (0, import_data9.useSelect)(
9937 (select) => select(store).getNewBlockTypes(),
9938 []
9939 );
9940 if (!newBlockTypes.length) {
9941 return null;
9942 }
9943 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
9944 import_editor2.PluginPrePublishPanel,
9945 {
9946 title: (0, import_i18n10.sprintf)(
9947 // translators: %d: number of blocks (number).
9948 (0, import_i18n10._n)(
9949 "Added: %d block",
9950 "Added: %d blocks",
9951 newBlockTypes.length
9952 ),
9953 newBlockTypes.length
9954 ),
9955 initialOpen: true,
9956 children: [
9957 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "installed-blocks-pre-publish-panel__copy", children: (0, import_i18n10._n)(
9958 "The following block has been added to your site.",
9959 "The following blocks have been added to your site.",
9960 newBlockTypes.length
9961 ) }),
9962 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CompactList, { items: newBlockTypes })
9963 ]
9964 }
9965 );
9966 }
9967
9968 // packages/block-directory/build-module/plugins/get-install-missing/index.mjs
9969 var import_i18n12 = __toESM(require_i18n(), 1);
9970 var import_components6 = __toESM(require_components(), 1);
9971 var import_blocks7 = __toESM(require_blocks(), 1);
9972 var import_element21 = __toESM(require_element(), 1);
9973 var import_data11 = __toESM(require_data(), 1);
9974 var import_core_data2 = __toESM(require_core_data(), 1);
9975 var import_block_editor5 = __toESM(require_block_editor(), 1);
9976
9977 // packages/block-directory/build-module/plugins/get-install-missing/install-button.mjs
9978 var import_i18n11 = __toESM(require_i18n(), 1);
9979 var import_components5 = __toESM(require_components(), 1);
9980 var import_blocks6 = __toESM(require_blocks(), 1);
9981 var import_data10 = __toESM(require_data(), 1);
9982 var import_block_editor4 = __toESM(require_block_editor(), 1);
9983 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
9984 function InstallButton({ attributes, block, clientId }) {
9985 const isInstallingBlock = (0, import_data10.useSelect)(
9986 (select) => select(store).isInstalling(block.id),
9987 [block.id]
9988 );
9989 const { installBlockType: installBlockType2 } = (0, import_data10.useDispatch)(store);
9990 const { replaceBlock } = (0, import_data10.useDispatch)(import_block_editor4.store);
9991 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
9992 import_components5.Button,
9993 {
9994 __next40pxDefaultSize: true,
9995 onClick: () => installBlockType2(block).then((success) => {
9996 if (success) {
9997 const blockType = (0, import_blocks6.getBlockType)(block.name);
9998 const [originalBlock] = (0, import_blocks6.parse)(
9999 attributes.originalContent
10000 );
10001 if (originalBlock && blockType) {
10002 replaceBlock(
10003 clientId,
10004 (0, import_blocks6.createBlock)(
10005 blockType.name,
10006 originalBlock.attributes,
10007 originalBlock.innerBlocks
10008 )
10009 );
10010 }
10011 }
10012 }),
10013 accessibleWhenDisabled: true,
10014 disabled: isInstallingBlock,
10015 isBusy: isInstallingBlock,
10016 variant: "primary",
10017 children: (0, import_i18n11.sprintf)(
10018 /* translators: %s: block name */
10019 (0, import_i18n11.__)("Install %s"),
10020 block.title
10021 )
10022 }
10023 );
10024 }
10025
10026 // packages/block-directory/build-module/plugins/get-install-missing/index.mjs
10027 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
10028 var getInstallMissing = (OriginalComponent) => (props) => {
10029 const { originalName } = props.attributes;
10030 const { block, hasPermission } = (0, import_data11.useSelect)(
10031 (select) => {
10032 const { getDownloadableBlocks: getDownloadableBlocks3 } = select(store);
10033 const blocks = getDownloadableBlocks3(
10034 "block:" + originalName
10035 ).filter(({ name }) => originalName === name);
10036 return {
10037 hasPermission: select(import_core_data2.store).canUser(
10038 "read",
10039 "block-directory/search"
10040 ),
10041 block: blocks.length && blocks[0]
10042 };
10043 },
10044 [originalName]
10045 );
10046 if (!hasPermission || !block) {
10047 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(OriginalComponent, { ...props });
10048 }
10049 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ModifiedWarning, { ...props, originalBlock: block });
10050 };
10051 var ModifiedWarning = ({ originalBlock, ...props }) => {
10052 const { originalName, originalUndelimitedContent, clientId } = props.attributes;
10053 const { replaceBlock } = (0, import_data11.useDispatch)(import_block_editor5.store);
10054 const convertToHTML = () => {
10055 replaceBlock(
10056 props.clientId,
10057 (0, import_blocks7.createBlock)("core/html", {
10058 content: originalUndelimitedContent
10059 })
10060 );
10061 };
10062 const hasContent = !!originalUndelimitedContent;
10063 const hasHTMLBlock = (0, import_data11.useSelect)(
10064 (select) => {
10065 const { canInsertBlockType, getBlockRootClientId } = select(import_block_editor5.store);
10066 return canInsertBlockType(
10067 "core/html",
10068 getBlockRootClientId(clientId)
10069 );
10070 },
10071 [clientId]
10072 );
10073 let messageHTML = (0, import_i18n12.sprintf)(
10074 /* translators: %s: block name */
10075 (0, import_i18n12.__)(
10076 "Your site doesn\u2019t include support for the %s block. You can try installing the block or remove it entirely."
10077 ),
10078 originalBlock.title || originalName
10079 );
10080 const actions = [
10081 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
10082 InstallButton,
10083 {
10084 block: originalBlock,
10085 attributes: props.attributes,
10086 clientId: props.clientId
10087 },
10088 "install"
10089 )
10090 ];
10091 if (hasContent && hasHTMLBlock) {
10092 messageHTML = (0, import_i18n12.sprintf)(
10093 /* translators: %s: block name */
10094 (0, import_i18n12.__)(
10095 "Your site doesn\u2019t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely."
10096 ),
10097 originalBlock.title || originalName
10098 );
10099 actions.push(
10100 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
10101 import_components6.Button,
10102 {
10103 __next40pxDefaultSize: true,
10104 onClick: convertToHTML,
10105 variant: "tertiary",
10106 children: (0, import_i18n12.__)("Keep as HTML")
10107 },
10108 "convert"
10109 )
10110 );
10111 }
10112 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ...(0, import_block_editor5.useBlockProps)(), children: [
10113 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_block_editor5.Warning, { actions, children: messageHTML }),
10114 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_element21.RawHTML, { children: originalUndelimitedContent })
10115 ] });
10116 };
10117 var get_install_missing_default = getInstallMissing;
10118
10119 // packages/block-directory/build-module/plugins/index.mjs
10120 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
10121 (0, import_plugins.registerPlugin)("block-directory", {
10122 // The icon is explicitly set to undefined to prevent PluginPrePublishPanel
10123 // from rendering the fallback icon pluginIcon.
10124 icon: void 0,
10125 render() {
10126 return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
10127 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(AutoBlockUninstaller, {}),
10128 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(inserter_menu_downloadable_blocks_panel_default, {}),
10129 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(InstalledBlocksPrePublishPanel, {})
10130 ] });
10131 }
10132 });
10133 (0, import_hooks.addFilter)(
10134 "blocks.registerBlockType",
10135 "block-directory/fallback",
10136 (settings, name) => {
10137 if (name !== "core/missing") {
10138 return settings;
10139 }
10140 settings.edit = get_install_missing_default(settings.edit);
10141 return settings;
10142 }
10143 );
10144 return __toCommonJS(index_exports);
10145 })();
10146 /*! Bundled license information:
10147
10148 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
10149 (**
10150 * @license React
10151 * use-sync-external-store-shim.development.js
10152 *
10153 * Copyright (c) Meta Platforms, Inc. and affiliates.
10154 *
10155 * This source code is licensed under the MIT license found in the
10156 * LICENSE file in the root directory of this source tree.
10157 *)
10158
10159 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
10160 (**
10161 * @license React
10162 * use-sync-external-store-shim/with-selector.development.js
10163 *
10164 * Copyright (c) Meta Platforms, Inc. and affiliates.
10165 *
10166 * This source code is licensed under the MIT license found in the
10167 * LICENSE file in the root directory of this source tree.
10168 *)
10169 */
10170 //# sourceMappingURL=index.js.map
10171