(() => { function $parcel$export(e, n, v, s) { Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); } function $parcel$interopDefault(a) { return a && a.__esModule ? a.default : a; } var $parcel$global = globalThis; var parcelRequire = $parcel$global["parcelRequire2d1f"]; var parcelRegister = parcelRequire.register; parcelRegister("h08Qa", function(module, exports) { $parcel$export(module.exports, "Editor", () => $a503cc0911452745$export$7cda8d932e2f33c0); var $lAN3N = parcelRequire("lAN3N"); var $63SH6 = parcelRequire("63SH6"); var $4WfNn = parcelRequire("4WfNn"); var $1CiVi = parcelRequire("1CiVi"); var $bhGVv = parcelRequire("bhGVv"); var $eoQBx = parcelRequire("eoQBx"); var $3xp7a = parcelRequire("3xp7a"); var $7PhiD = parcelRequire("7PhiD"); var $aK4GE = parcelRequire("aK4GE"); var $3i93m = parcelRequire("3i93m"); var $8u89v = parcelRequire("8u89v"); const $a503cc0911452745$export$7cda8d932e2f33c0 = ({ session: session, site_id: site_id, page_id: page_id })=>{ const p = (0, $4WfNn.useGlobal)((0, $eoQBx.EditorGlobal), "EDITOR"); if (p.site.responsive === "mobile-only") p.mode = "mobile"; else if (p.site.responsive === "desktop-only") p.mode = "desktop"; p.session = session; (0, $63SH6.useEffect)(()=>{ const keyDown = async (evt)=>{ if ((evt.key === "s" || evt.key === "s") && (evt.ctrlKey || evt.metaKey)) { evt.preventDefault(); evt.stopPropagation(); } if ((evt.key === "Y" || evt.key === "y") && (evt.ctrlKey || evt.metaKey) && !evt.shiftKey) { (0, $aK4GE.undoManager).redo(p); return; } if ((evt.key === "Z" || evt.key === "z") && (evt.ctrlKey || evt.metaKey) && evt.shiftKey) { (0, $aK4GE.undoManager).redo(p); return; } if ((evt.key === "Z" || evt.key === "z") && (evt.ctrlKey || evt.metaKey) && !evt.shiftKey) (0, $aK4GE.undoManager).undo(p); if ((evt.key === "r" || evt.key === "R" || evt.key === "\xae") && evt.altKey) { evt.preventDefault(); evt.stopPropagation(); p.localReloading = {}; p.render(); await (0, $8u89v.rebuildTree)(p, { mode: "reset", note: "reload" }); } }; window.addEventListener("keydown", keyDown, true); return ()=>{ window.removeEventListener("keydown", keyDown, true); }; }, []); (0, $63SH6.useEffect)(()=>{ if (p.status !== "init" && (0, $3i93m.w).prasiApi) { for (const [k, v] of Object.entries((0, $4WfNn.deepClone)((0, $eoQBx.EditorGlobal))))continue; (0, $3xp7a.execSiteJS)(p); p.render(); } }, [ page_id ]); if (!p.mode) { if (p.site.responsive === "mobile-only") p.mode = "mobile"; else if (p.site.responsive === "desktop-only") p.mode = "desktop"; else p.mode = localStorage.getItem("prasi-editor-mode") || "desktop"; } if (p.status === "init") { window.mok = (window.mok || 0) + 1; p.ui.loading = /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1CiVi.Loading), { note: "load-page" }); p.ui.preload = /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1CiVi.Loading), { note: "preload-root", backdrop: false }); p.ui.notfound = /*#__PURE__*/ (0, $lAN3N.jsx)("div", { className: "flex-1 flex items-center justify-center", children: "NOT FOUND" }); p.ui.error = /*#__PURE__*/ (0, $lAN3N.jsx)("div", { className: "flex-1 flex items-center justify-center", children: "PREVIEW ERROR" }); p.status = "loading"; (0, $3xp7a.initEditor)(p, site_id); } (0, $7PhiD.routeEditor)(p, page_id); if (p.status !== "ready") { if (p.status === "not-found") return p.ui.notfound; if (p.status === "error") return p.ui.error; if (!p.site.id) return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1CiVi.Loading), { note: "editor-prepare" }); } return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $bhGVv.EMainEditor), {}); }; }); parcelRegister("bhGVv", function(module, exports) { $parcel$export(module.exports, "EMainEditor", () => $fa70a53bf60af955$export$4d4121892defa95e); var $lAN3N = parcelRequire("lAN3N"); var $63SH6 = parcelRequire("63SH6"); var $4WfNn = parcelRequire("4WfNn"); var $1CiVi = parcelRequire("1CiVi"); var $cqXgE = parcelRequire("cqXgE"); var $kJk2w = parcelRequire("kJk2w"); var $eoQBx = parcelRequire("eoQBx"); var $cfPLU = parcelRequire("cfPLU"); const $fa70a53bf60af955$var$ETree = /*#__PURE__*/ (0, $63SH6.lazy)(async ()=>({ default: (await Promise.resolve((parcelRequire("1nwyv")))).ETree })); const $fa70a53bf60af955$var$EPage = /*#__PURE__*/ (0, $63SH6.lazy)(async ()=>({ default: (await Promise.resolve((parcelRequire("cqXgE")))).EPage })); const $fa70a53bf60af955$var$ESide = /*#__PURE__*/ (0, $63SH6.lazy)(async ()=>({ default: (await (parcelRequire("8yVvO"))).ESide })); const $fa70a53bf60af955$var$PageManager = /*#__PURE__*/ (0, $63SH6.lazy)(async ()=>({ default: (await (parcelRequire("7WO2G"))).PageManager })); const $fa70a53bf60af955$var$EScriptElement = /*#__PURE__*/ (0, $63SH6.lazy)(async ()=>({ default: (await Promise.resolve((parcelRequire("ax46r")))).EScriptElement })); const $fa70a53bf60af955$var$SiteManager = /*#__PURE__*/ (0, $63SH6.lazy)(async ()=>({ default: (await (parcelRequire("hN3z8"))).SiteManager })); const $fa70a53bf60af955$var$CompManager = /*#__PURE__*/ (0, $63SH6.lazy)(async ()=>({ default: (await (parcelRequire("1aNFf"))).CompManager })); const $fa70a53bf60af955$export$4d4121892defa95e = ()=>{ const p = (0, $4WfNn.useGlobal)((0, $eoQBx.EditorGlobal), "EDITOR"); return /*#__PURE__*/ (0, $lAN3N.jsxs)("div", { className: cx("editor flex-1 flex flex-col items-stretch", (0, $kJk2w.editorStyle)), children: [ /*#__PURE__*/ (0, $lAN3N.jsx)((0, $cfPLU.Toolbar), {}), /*#__PURE__*/ (0, $lAN3N.jsx)("div", { className: cx("editor-box flex flex-row flex-1"), children: p.status !== "ready" ? /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1CiVi.Loading), { note: `editor-${p.status}` }) : /*#__PURE__*/ (0, $lAN3N.jsx)((0, $lAN3N.Fragment), { children: /*#__PURE__*/ (0, $lAN3N.jsxs)((0, $63SH6.Suspense), { fallback: /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1CiVi.Loading), { note: `editor-lazy` }), children: [ /*#__PURE__*/ (0, $lAN3N.jsx)($fa70a53bf60af955$var$ETree, {}), location.search === "?norender" ? /*#__PURE__*/ (0, $lAN3N.jsx)("div", { className: cx("flex-1", (0, $cqXgE.mobileCSS)) }) : /*#__PURE__*/ (0, $lAN3N.jsx)($fa70a53bf60af955$var$EPage, {}), /*#__PURE__*/ (0, $lAN3N.jsx)($fa70a53bf60af955$var$ESide, {}) ] }) }) }), p.status === "ready" && /*#__PURE__*/ (0, $lAN3N.jsxs)((0, $63SH6.Suspense), { fallback: /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1CiVi.Loading), { note: `toolbar` }), children: [ p.manager.site && /*#__PURE__*/ (0, $lAN3N.jsx)($fa70a53bf60af955$var$SiteManager, {}), p.manager.page && /*#__PURE__*/ (0, $lAN3N.jsx)($fa70a53bf60af955$var$PageManager, {}), p.manager.comp && /*#__PURE__*/ (0, $lAN3N.jsx)($fa70a53bf60af955$var$CompManager, {}), p.script.active && !p.script.siteActive && /*#__PURE__*/ (0, $lAN3N.jsx)($fa70a53bf60af955$var$EScriptElement, {}) ] }) ] }); }; }); parcelRegister("cqXgE", function(module, exports) { $parcel$export(module.exports, "EPage", () => $19e1948fe32d4520$export$bf9e6cbd52e43ca); $parcel$export(module.exports, "mobileCSS", () => $19e1948fe32d4520$export$cf7f6ce8f07b1290); var $lAN3N = parcelRequire("lAN3N"); var $4WfNn = parcelRequire("4WfNn"); var $eoQBx = parcelRequire("eoQBx"); var $4r8Go = parcelRequire("4r8Go"); var $18ruq = parcelRequire("18ruq"); const $19e1948fe32d4520$export$bf9e6cbd52e43ca = ()=>{ const p = (0, $4WfNn.useGlobal)((0, $eoQBx.EditorGlobal), "EDITOR"); const local = (0, $4WfNn.useLocal)({}); p.softRender.page = ()=>{ if (!p.focused) local.render(); }; if (0, $18ruq.JS_DEBUG) console.clear(); if (!p.page) return null; const mode = p.mode; let childs = Object.values(p.page?.content_tree.childs || []); // if (p.layout.section && p.layout.content) { // childs = [p.layout.section]; // } const rootChilds = Object.values(childs).map((e)=>e.id); return /*#__PURE__*/ (0, $lAN3N.jsx)("div", { className: cx("w-full h-full relative flex items-center justify-center", mode === "mobile" ? $19e1948fe32d4520$export$cf7f6ce8f07b1290 : "bg-white"), children: /*#__PURE__*/ (0, $lAN3N.jsx)("div", { className: cx("absolute flex flex-col items-stretch flex-1 bg-white ", mode === "mobile" ? css` border-left: 1px solid #ccc; border-right: 1px solid #ccc; width: 375px; top: 0px; overflow-x: hidden; overflow-y: auto; bottom: 0px; ` : "inset-0 overflow-auto", css` contain: content; `), children: rootChilds.map((id)=>/*#__PURE__*/ (0, $lAN3N.jsx)((0, $4r8Go.ESection), { id: id }, id)) }) }); }; const $19e1948fe32d4520$export$cf7f6ce8f07b1290 = css` background-color: white; background-image: linear-gradient(45deg, #fafafa 25%, transparent 25%), linear-gradient(-45deg, #fafafa 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #fafafa 75%), linear-gradient(-45deg, transparent 75%, #fafafa 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0px; `; }); parcelRegister("4r8Go", function(module, exports) { $parcel$export(module.exports, "ESection", () => $b0609cfe0aeb7fc6$export$e32a1d000d2275bd); var $lAN3N = parcelRequire("lAN3N"); var $KfUSb = parcelRequire("KfUSb"); var $1s6dD = parcelRequire("1s6dD"); var $890fz = parcelRequire("890fz"); const $b0609cfe0aeb7fc6$export$e32a1d000d2275bd = ({ id: id })=>{ return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $KfUSb.ErrorBox), { id: id, children: /*#__PURE__*/ (0, $lAN3N.jsx)((0, $890fz.ERender), { id: id, children: (childs)=>childs.map((e)=>{ return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1s6dD.EItem), { id: e.id }, e.id); }) }) }); }; }); parcelRegister("1s6dD", function(module, exports) { $parcel$export(module.exports, "EItem", () => $8c9742dd1dffd442$export$6f695f5b59bda1a4); var $lAN3N = parcelRequire("lAN3N"); var $KfUSb = parcelRequire("KfUSb"); var $890fz = parcelRequire("890fz"); var $8IrKh = parcelRequire("8IrKh"); const $8c9742dd1dffd442$export$6f695f5b59bda1a4 = ({ id: id, fromProp: fromProp })=>{ return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $KfUSb.ErrorBox), { id: id, children: /*#__PURE__*/ (0, $lAN3N.jsx)((0, $890fz.ERender), { id: id, fromProp: fromProp, children: (childs)=>{ return childs.map((e)=>{ if (e.type !== "text") return /*#__PURE__*/ (0, $lAN3N.jsx)($8c9742dd1dffd442$export$6f695f5b59bda1a4, { id: e.id, fromProp: fromProp }, e.id); else return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $8IrKh.EText), { id: e.id, fromProp: fromProp }, e.id); }); } }) }); }; }); parcelRegister("890fz", function(module, exports) { $parcel$export(module.exports, "ERender", () => $7c38a471cbcf09b3$export$6b8e72bf7eb23fa7); var $lAN3N = parcelRequire("lAN3N"); var $4WfNn = parcelRequire("4WfNn"); var $cc0Z8 = parcelRequire("cc0Z8"); var $1CiVi = parcelRequire("1CiVi"); var $eoQBx = parcelRequire("eoQBx"); var $j8xVm = parcelRequire("j8xVm"); var $18ruq = parcelRequire("18ruq"); var $ax46r = parcelRequire("ax46r"); var $dJKat = parcelRequire("dJKat"); var $6QgH2 = parcelRequire("6QgH2"); var $DNtyO = parcelRequire("DNtyO"); var $8IrKh = parcelRequire("8IrKh"); const $7c38a471cbcf09b3$export$6b8e72bf7eb23fa7 = ({ id: id, children: children })=>{ const p = (0, $4WfNn.useGlobal)((0, $eoQBx.EditorGlobal), "EDITOR"); const meta = p.treeMeta[id]; if (!meta) return null; let item = meta.item; if (item.hidden) return null; if (meta.parent_prop && typeof item.adv?.js === "string" && item.adv.js.startsWith("newElement")) { const mitem = meta.mitem; if (mitem && item.type === "item") { (async ()=>{ let childs = []; await Promise.all(mitem.parent.map(async (e, idx)=>{ if (e === mitem && item.adv?.js) { const json = e.toJSON(); const scope = (0, $18ruq.mergeScopeUpwards)(p, meta); let fn = null; const args = { ...window.exports, ...scope, render: (f)=>{}, newElement: (fx)=>{ fn = fx; } }; const rawfn = new Function(...Object.keys(args), item.adv.jsBuilt || ""); rawfn(...Object.values(args)); await Promise.all(json.childs.map(async (e)=>{ const res = await fn((0, $dJKat.fillID)(e)); if (Array.isArray(res)) for (const r of res)childs.push((0, $6QgH2.newMap)((0, $dJKat.fillID)(r))); else childs.push((0, $6QgH2.newMap)(res)); })); } })); mitem.doc?.transact(()=>{ mitem.parent.map(async (e, idx)=>{ if (e === mitem && item.adv?.js) { mitem.parent.delete(idx); mitem.parent.insert(idx, childs); } }); }); })(); return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $lAN3N.Fragment), { children: "Generating" }); } } if (meta.comp && meta.comp.mcomp) { const comp = meta.comp; const props = meta.comp.mcomp.get("component")?.get("props")?.toJSON(); const cprops = Object.entries(props).sort((a, b)=>{ return a[1].idx - b[1].idx; }); if (0, $18ruq.JS_DEBUG) { const args = [ ("~".repeat(meta.depth || 0) + meta.item.name).padEnd(30, "_") + " " + meta.item.id ].join(" "); if (meta.comp) console.log("%c" + args, "color:red", "prop: ", comp.propval); } comp.propval = (0, $j8xVm.treePropEval)(p, meta, cprops); } let _children = null; if (children) { if (item.type === "text") _children = children([]); else _children = children(item.childs || []); } meta.elprop = (0, $DNtyO.createElProp)(item, p); meta.className = (0, $cc0Z8.produceCSS)(item, { mode: p.mode, hover: p.item.sideHover ? false : p.item.hover === item.id, active: p.item.sideHover ? false : p.item.active === item.id }); const elprop = meta.elprop; const className = meta.className; const adv = item.adv; let componentOver = null; if (item.type === "item" && item.component?.id && item.component.props) { if (!Object.values(item.component.props).find((e)=>e.meta?.type === "content-element")) { if (!p.comps.doc[item.component.id]) componentOver = /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1CiVi.Loading), { backdrop: false, note: item.component.id.substring(28) }); else if (item.id !== p.comp?.instance_id) componentOver = /*#__PURE__*/ (0, $lAN3N.jsx)((0, $DNtyO.ComponentOver), { item: item, p: p, elprop: elprop }); } if (meta.comp && (p.comp?.id === meta.comp.id || p.comp?.last.find((e)=>e.comp_id === meta.comp?.id))) componentOver = null; } if (adv && adv.js && !adv.jsBuilt && meta.mitem) { if (!(0, $ax46r.jscript).build) { (0, $ax46r.jscript).init().then(()=>{ p.render(); }); return null; } (0, $ax46r.jscript).build("item [" + meta.item.name + "] -> .tsx", `return ${adv.js}`, undefined, true).then((js)=>{}); return null; } if (!(adv?.jsBuilt && adv?.js) && (meta.scopeAttached || meta.comp)) return (0, $18ruq.treeScopeEval)(p, meta, /*#__PURE__*/ (0, $lAN3N.jsxs)((0, $lAN3N.Fragment), { children: [ _children, componentOver ] }), `render(React.createElement("div",{...props},children));`); if (adv) { if (adv.html) { const html = $7c38a471cbcf09b3$export$1a32bf6229c258c0(className, adv, elprop); if (html) return html; } else if (adv.jsBuilt && adv.js) { const el = (0, $18ruq.treeScopeEval)(p, meta, /*#__PURE__*/ (0, $lAN3N.jsxs)((0, $lAN3N.Fragment), { children: [ _children, componentOver ] }), adv.jsBuilt); return el; } } if (item.type === "text") return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $8IrKh.ETextInternal), { className: className, elprop: elprop, item: item, p: p, _children: item.html || item.text }, item.id); return /*#__PURE__*/ (0, $lAN3N.jsxs)("div", { className: className, ...elprop, children: [ _children, componentOver ] }); }; const $7c38a471cbcf09b3$export$1a32bf6229c258c0 = (className, adv, elprop)=>{ if (adv.html) return /*#__PURE__*/ (0, $lAN3N.jsx)("div", { className: className, dangerouslySetInnerHTML: { __html: adv.html }, ...elprop }); return null; }; }); parcelRegister("j8xVm", function(module, exports) { $parcel$export(module.exports, "treePropEval", () => $abc59d7df391d1cc$export$2f4fe33b8bea4711); var $lAN3N = parcelRequire("lAN3N"); var $isbAn = parcelRequire("isbAn"); var $1s6dD = parcelRequire("1s6dD"); var $18ruq = parcelRequire("18ruq"); const $abc59d7df391d1cc$export$2f4fe33b8bea4711 = (p, meta, cprops)=>{ if (meta.item.type === "item" && meta.item.component) { if (p.site.api_url) { if (!p.script.db) p.script.db = (0, $isbAn.createDB)(p.site.api_url); if (!p.script.api) p.script.api = (0, $isbAn.createAPI)(p.site.api_url); } const props = meta.item.component.props; const w = window; const finalScope = (0, $18ruq.mergeScopeUpwards)(p, meta); const args = { ...w.exports, ...finalScope, db: p.script.db, api: p.script.api }; const result = {}; for (const [name, _prop] of cprops){ const prop = props[name] || _prop; let value = null; if (prop.valueBuilt) try { const fn = new Function(...Object.keys(args), `return ${prop.valueBuilt}`); // note: by default set prop to null // if it is undefined then it will be overidden by parent scope // it is not desirable for prop to inherit from parent scope. value = fn(...Object.values(args)) || null; } catch (e) { const cname = meta.item.name; console.warn(e); console.warn(`ERROR in Component [${cname}], in prop [${name}]:\n ` + prop.value); } if (prop.meta?.type === "content-element") { if (!(typeof value === "object" && !!value && value._jsx)) value = { _jsx: true, Comp: ({ parent_id: parent_id })=>{ if (prop.content) { const meta = p.treeMeta[parent_id]; const scopes = []; (0, $18ruq.mergeScopeUpwards)(p, meta, { each: (m, val)=>{ scopes.push({ meta: m, value: val }); return true; } }); if (p.treeMeta[prop.content.id]) p.treeMeta[prop.content.id].scopeAttached = scopes; return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1s6dD.EItem), { id: prop.content.id, fromProp: true }); } return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $lAN3N.Fragment), {}); } }; } result[name] = value; } const propvis = {}; for (const [name, _prop] of cprops)if (_prop.visible) { const finalArgs = { ...args, ...result }; try { const fn = new Function(...Object.keys(finalArgs), `return ${_prop.visible}`); propvis[name] = fn(...Object.values(finalArgs)); } catch (e) { const cname = meta.item.name; console.warn(e); console.warn(`ERROR in Component [${cname}], in prop [${name}]:\n ` + _prop.visible); } } if (meta.comp) meta.comp.propvis = propvis; return result; } }; }); parcelRegister("18ruq", function(module, exports) { $parcel$export(module.exports, "JS_DEBUG", () => $602692a9f9421b20$export$bc6cda806d54f983); $parcel$export(module.exports, "treeScopeEval", () => $602692a9f9421b20$export$4d9c1e8573de8067); $parcel$export(module.exports, "mergeScopeUpwards", () => $602692a9f9421b20$export$f4fa9221fd311771); var $lAN3N = parcelRequire("lAN3N"); var $63SH6 = parcelRequire("63SH6"); var $4WfNn = parcelRequire("4WfNn"); var $isbAn = parcelRequire("isbAn"); var $KfUSb = parcelRequire("KfUSb"); const $602692a9f9421b20$export$bc6cda806d54f983 = false; const $602692a9f9421b20$export$4d9c1e8573de8067 = (p, meta, children, js)=>{ const className = meta.className; const elprop = meta.elprop; let item = meta.item; const adv = item.adv; let args = {}; if (!meta.memoize) meta.memoize = { Local: $602692a9f9421b20$var$createLocal(p, meta), PassProp: $602692a9f9421b20$var$createPassProp(p, meta) }; // prepare args if (p.site.api_url) { if (!p.script.db) p.script.db = (0, $isbAn.createDB)(p.site.api_url); if (!p.script.api) p.script.api = (0, $isbAn.createAPI)(p.site.api_url); } const w = window; const finalScope = $602692a9f9421b20$export$f4fa9221fd311771(p, meta); for (const [k, v] of Object.entries(finalScope))if (v && typeof v === "object") { const t = v; if (t._jsx && t.Comp) finalScope[k] = /*#__PURE__*/ (0, $lAN3N.jsx)(t.Comp, { parent_id: meta.item.id }); } if ($602692a9f9421b20$export$bc6cda806d54f983) { const args = [ (".".repeat(meta.depth || 0) + meta.item.name).padEnd(30, "_") + " " + meta.item.id ].join(" "); if (meta.comp) console.log("%c" + args, "color:red", finalScope); else console.log(args, finalScope); } const output = { jsx: null }; args = { ...w.exports, ...finalScope, ...meta.memoize, db: p.script.db, api: p.script.api, children: children, props: { ...elprop, className: className }, newElement: (opt)=>children, useEffect: (0, $63SH6.useEffect), render: (jsx)=>{ output.jsx = /*#__PURE__*/ (0, $lAN3N.jsx)((0, $KfUSb.ErrorBox), { meta: meta, children: /*#__PURE__*/ (0, $lAN3N.jsx)((0, $63SH6.Suspense), { fallback: /*#__PURE__*/ (0, $lAN3N.jsx)("div", { className: "flex flex-1 items-center justify-center w-full h-full relative", children: p.ui.loading }), children: jsx }) }); } }; try { // execute const fn = new Function(...Object.keys(args), js); const res = fn(...Object.values(args)); if (res instanceof Promise) res.catch((e)=>{ console.warn(e); console.warn((`ERROR in ${item.type} [${item.name}]:\n ` + (adv?.js || "")).trim()); console.warn(`Available var:`, args, `\n\n`); }); } catch (e) {} return output.jsx; }; const $602692a9f9421b20$export$f4fa9221fd311771 = (p, meta, opt)=>{ if (!meta.scope) meta.scope = {}; let cur = meta; const finalScope = {}; while(cur){ let scope = null; if (cur.scopeAttached) { for (const s of cur.scopeAttached)if (s.value) { for (const [k, v] of Object.entries(s.value))if (typeof finalScope[k] === "undefined") finalScope[k] = v; if (opt?.each) { if (!opt.each(s.meta, s.value)) break; } } } if (cur.scope || cur.comp?.propval) { scope = { ...cur.scope, ...cur.comp?.propval }; for (const [k, v] of Object.entries(scope))if (typeof finalScope[k] === "undefined") finalScope[k] = v; if (opt?.each) { if (!opt.each(cur, scope)) break; } } cur = p.treeMeta[cur.parent_id]; } return finalScope; }; const $602692a9f9421b20$var$createPassProp = (p, meta)=>{ return (arg)=>{ if (!meta.scope) meta.scope = {}; for (const [k, v] of Object.entries(arg)){ if (k === "children") continue; meta.scope[k] = v; } return arg.children; }; }; const $602692a9f9421b20$var$createLocal = (p, meta)=>{ const Local = ({ name: name, value: value, effect: effect, children: children, hook: hook, deps: deps })=>{ if (!meta.scope) meta.scope = {}; const immediateExecute = meta.item.id === p.item.active && p.script.active; if (!meta.scope[name]) try { meta.scope[name] = { ...(0, $4WfNn.deepClone)(value), render: ()=>{ if (!p.focused) p.render(); } }; } catch (e) {} if (typeof hook === "function") try { hook(meta.scope[name]); } catch (e) { console.warn(e); } (0, $63SH6.useEffect)(()=>{ if (effect) { if (immediateExecute) { if (!p.localReloading[p.item.active]) p.localReloading[p.item.active] = true; else return; } try { effect(meta.scope[name]); } catch (e) {} } }, []); return children; }; return Local; }; }); parcelRegister("ax46r", function(module, exports) { $parcel$export(module.exports, "jscript", () => $995080ac362d425a$export$c6b82629a9326816); $parcel$export(module.exports, "EScriptElement", () => $995080ac362d425a$export$d63aac689a6a95d3); var $lAN3N = parcelRequire("lAN3N"); var $4WfNn = parcelRequire("4WfNn"); var $aVHaH = parcelRequire("aVHaH"); var $1CiVi = parcelRequire("1CiVi"); var $axFja = parcelRequire("axFja"); var $eoQBx = parcelRequire("eoQBx"); var $8u89v = parcelRequire("8u89v"); var $eQo3h = parcelRequire("eQo3h"); var $dnwSp = parcelRequire("dnwSp"); const $995080ac362d425a$export$c6b82629a9326816 = { editor: null, build: null, _init: false, async init () { if (!this._init) { this._init = true; const { sendIPC: sendIPC } = await (parcelRequire("NRpjz")); await (0, $eQo3h.initJS)(); this.build = async (entry, src, files, verbose)=>{ const options = { entryPoints: [ entry ], jsx: "transform", bundle: true, format: "cjs", minify: true }; const res = await sendIPC({ command_: "build", input_: { ...files, [entry]: src }, options_: options }); if (verbose && res.stderr_) console.log(res.stderr_); if (res.outputFiles_) return res.outputFiles_[0].text; return ""; }; await this.build("el.tsx", `return ""`); } } }; const $995080ac362d425a$export$d63aac689a6a95d3 = ({})=>{ const p = (0, $4WfNn.useGlobal)((0, $eoQBx.EditorGlobal), "EDITOR"); if (!$995080ac362d425a$export$c6b82629a9326816.editor) Promise.all([ (parcelRequire("aOi4L")).then((e)=>{ $995080ac362d425a$export$c6b82629a9326816.editor = e.Editor; e.loader.config({ paths: { vs: "/min/vs" } }); }), $995080ac362d425a$export$c6b82629a9326816.init() ]).then(()=>{ p.render(); }); if (!p.script.active) return null; const onOpenChange = ()=>{ if (p.script.active) { let mitem = p.treeMeta[p.item.active]?.mitem; if (!mitem) return; mitem.doc?.transact(()=>{ if (!mitem) return; const adv = mitem.get("adv"); if (adv) { const src = adv.get(p.script.type); let txt = ""; if (src && src instanceof $aVHaH.Text) txt = src.toJSON(); else txt = src; if (!txt || typeof txt === "string" && txt.replace(/[\W_]+/g, "") === (0, $dnwSp.DefaultScript)[p.script.type].replace(/[\W_]+/g, "")) { if (p.script.type === "js") { adv.delete("js"); adv.delete("jsBuilt"); } else adv.delete(p.script.type); } } }); } p.script.active = false; p.script.prop = null; p.script.doEdit = null; p.script.toolbar = null; if (typeof p.script.onClose === "function") { p.script.onClose(); p.script.onClose = undefined; } (0, $8u89v.rebuildTree)(p, { mode: "reset", note: "script-closed" }); }; const content = /*#__PURE__*/ (0, $lAN3N.jsx)("div", { className: "bg-white w-[80vw] h-[80vh] flex", children: /*#__PURE__*/ (0, $lAN3N.jsxs)("div", { className: cx("flex flex-1 relative", css` .monaco-editor { .mtk9 { color: #022f62; } .mtk1 { color: #022f62; } .mtk22 { color: #015cc5; } .mtk8 { color: #015cc5; } .mtk5 { color: #55bb8a; } .monaco-editor.showUnused .squiggly-inline-unnecessary { opacity: 0.4; } .jsx-expression-braces { color: #7c3813; } .jsx-tag-angle-bracket { color: #619ac3; } .jsx-tag-name { color: #619ac3; } .jsx-tag-order-1 { color: #23863a; } .jsx-tag-order-2 { color: #4e7ca1; } .jsx-tag-order-3 { color: #020360; } .jsx-tag-attribute-key { color: #6f42c1; } .jsx-text { color: #000000; } } `), children: [ (!$995080ac362d425a$export$c6b82629a9326816.editor || !$995080ac362d425a$export$c6b82629a9326816.build) && /*#__PURE__*/ (0, $lAN3N.jsxs)((0, $lAN3N.Fragment), { children: [ !$995080ac362d425a$export$c6b82629a9326816.editor && !$995080ac362d425a$export$c6b82629a9326816.build && /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1CiVi.Loading), { note: "js-code", backdrop: false }), !$995080ac362d425a$export$c6b82629a9326816.editor && $995080ac362d425a$export$c6b82629a9326816.build && /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1CiVi.Loading), { note: "js-editor", backdrop: false }), !$995080ac362d425a$export$c6b82629a9326816.build && $995080ac362d425a$export$c6b82629a9326816.editor && /*#__PURE__*/ (0, $lAN3N.jsx)((0, $1CiVi.Loading), { note: "js-build", backdrop: false }) ] }), $995080ac362d425a$export$c6b82629a9326816.editor && $995080ac362d425a$export$c6b82629a9326816.build && /*#__PURE__*/ (0, $lAN3N.jsx)((0, $dnwSp.ScriptMonacoElement), { Editor: $995080ac362d425a$export$c6b82629a9326816.editor, build: $995080ac362d425a$export$c6b82629a9326816.build }) ] }) }); return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $axFja.Modal), { onOpenChange: onOpenChange, children: content }); }; }); parcelRegister("axFja", function(module, exports) { $parcel$export(module.exports, "Modal", () => $347af5afa63da731$export$2b77a92f1a5ad772); var $lAN3N = parcelRequire("lAN3N"); var $7rwqM = parcelRequire("7rwqM"); var $63SH6 = parcelRequire("63SH6"); var $4WfNn = parcelRequire("4WfNn"); function $347af5afa63da731$export$33ffd74ebf07f060({ initialOpen: initialOpen = true, open: controlledOpen, onOpenChange: setControlledOpen }) { const [uncontrolledOpen, setUncontrolledOpen] = $63SH6.useState(initialOpen); const [labelId, setLabelId] = $63SH6.useState(); const [descriptionId, setDescriptionId] = $63SH6.useState(); const open = controlledOpen ?? uncontrolledOpen; const setOpen = setControlledOpen ?? setUncontrolledOpen; const data = (0, $7rwqM.useFloating)({ open: open, onOpenChange: setOpen }); const context = data.context; const click = (0, $7rwqM.useClick)(context, { enabled: controlledOpen == null }); const dismiss = (0, $7rwqM.useDismiss)(context, { outsidePressEvent: "mousedown", escapeKey: false }); const role = (0, $7rwqM.useRole)(context); const interactions = (0, $7rwqM.useInteractions)([ click, dismiss, role ]); return $63SH6.useMemo(()=>({ open: open, setOpen: setOpen, ...interactions, ...data, labelId: labelId, descriptionId: descriptionId, setLabelId: setLabelId, setDescriptionId: setDescriptionId }), [ open, setOpen, interactions, data, labelId, descriptionId ]); } const $347af5afa63da731$var$ModalContext = /*#__PURE__*/ $63SH6.createContext(null); const $347af5afa63da731$export$4cc1699d46f42cae = ()=>{ const context = $63SH6.useContext($347af5afa63da731$var$ModalContext); if (context == null) throw new Error("Modal components must be wrapped in "); return context; }; function $347af5afa63da731$export$2b77a92f1a5ad772({ children: children, ...options }) { const dialog = $347af5afa63da731$export$33ffd74ebf07f060(options); return /*#__PURE__*/ (0, $lAN3N.jsx)($347af5afa63da731$var$ModalContext.Provider, { value: dialog, children: /*#__PURE__*/ (0, $lAN3N.jsx)($347af5afa63da731$export$6da19a24bf249f17, { className: cx("modal", "outline-none"), children: children }) }); } const $347af5afa63da731$export$fb10b32cfe19f1e = /*#__PURE__*/ $63SH6.forwardRef(function ModalTrigger({ children: children, asChild: asChild = false, ...props }, propRef) { const context = $347af5afa63da731$export$4cc1699d46f42cae(); const childrenRef = children.ref; const ref = (0, $7rwqM.useMergeRefs)([ context.refs.setReference, propRef, childrenRef ]); // `asChild` allows the user to pass any element as the anchor if (asChild && /*#__PURE__*/ $63SH6.isValidElement(children)) return /*#__PURE__*/ $63SH6.cloneElement(children, context.getReferenceProps({ ref: ref, ...props, ...children.props, "data-state": context.open ? "open" : "closed" })); return /*#__PURE__*/ (0, $lAN3N.jsx)("button", { ref: ref, "data-state": context.open ? "open" : "closed", ...context.getReferenceProps(props), children: children }); }); const $347af5afa63da731$export$6da19a24bf249f17 = /*#__PURE__*/ $63SH6.forwardRef(function ModalContent(props, propRef) { const local = (0, $4WfNn.useLocal)({ preview: false, timeout: null }); const { context: floatingContext, ...context } = $347af5afa63da731$export$4cc1699d46f42cae(); const ref = (0, $7rwqM.useMergeRefs)([ context.refs.setFloating, propRef ]); if (!floatingContext.open) return null; const floatingDivProps = context.getFloatingProps(props); return /*#__PURE__*/ (0, $lAN3N.jsx)((0, $7rwqM.FloatingPortal), { children: /*#__PURE__*/ (0, $lAN3N.jsx)((0, $7rwqM.FloatingOverlay), { className: cx("modal-overlay", "flex items-center justify-center transition-all ", css` background: rgba(0, 0, 0, 0.3); display: grid; place-items: center; `, local.preview ? "opacity-20 duration-1000" : "duration-300"), lockScroll: true, children: /*#__PURE__*/ (0, $lAN3N.jsx)((0, $7rwqM.FloatingFocusManager), { context: floatingContext, children: /*#__PURE__*/ (0, $lAN3N.jsx)("div", { ref: ref, onPointerMove: ()=>{ clearTimeout(local.timeout); if (local.preview) { local.preview = false; local.render(); } }, onPointerLeave: (e)=>{ // if (Object.keys(w.openedPopupID || {}).length > 0) { // return; // } clearTimeout(local.timeout); local.timeout = setTimeout(()=>{ local.preview = true; local.render(); }, 1000); }, "aria-labelledby": context.labelId, "aria-describedby": context.descriptionId, ...floatingDivProps, children: props.children }) }) }) }); }); const $347af5afa63da731$export$9af27c346834c182 = /*#__PURE__*/ $63SH6.forwardRef(function ModalHeading({ children: children, ...props }, ref) { const { setLabelId: setLabelId } = $347af5afa63da731$export$4cc1699d46f42cae(); const id = (0, $7rwqM.useId)(); // Only sets `aria-labelledby` on the Modal root element // if this component is mounted inside it. $63SH6.useLayoutEffect(()=>{ setLabelId(id); return ()=>setLabelId(undefined); }, [ id, setLabelId ]); return /*#__PURE__*/ (0, $lAN3N.jsx)("h2", { ...props, ref: ref, id: id, children: children }); }); const $347af5afa63da731$export$70584796f9410aa4 = /*#__PURE__*/ $63SH6.forwardRef(function ModalDescription({ children: children, ...props }, ref) { const { setDescriptionId: setDescriptionId } = $347af5afa63da731$export$4cc1699d46f42cae(); const id = (0, $7rwqM.useId)(); // Only sets `aria-describedby` on the Modal root element // if this component is mounted inside it. $63SH6.useLayoutEffect(()=>{ setDescriptionId(id); return ()=>setDescriptionId(undefined); }, [ id, setDescriptionId ]); return /*#__PURE__*/ (0, $lAN3N.jsx)("p", { ...props, ref: ref, id: id, children: children }); }); const $347af5afa63da731$export$9bf0f2717ffc648c = /*#__PURE__*/ $63SH6.forwardRef(function ModalClose(props, ref) { const { setOpen: setOpen } = $347af5afa63da731$export$4cc1699d46f42cae(); return /*#__PURE__*/ (0, $lAN3N.jsx)("button", { type: "button", ...props, ref: ref, onClick: ()=>setOpen(false) }); }); }); parcelRegister("7rwqM", function(module, exports) { $parcel$export(module.exports, "useMergeRefs", () => $56b436271f6666d1$export$74665b213cb5c4cf); $parcel$export(module.exports, "useId", () => $56b436271f6666d1$export$f680877a34711e37); $parcel$export(module.exports, "useHover", () => $56b436271f6666d1$export$ae780daf29e6d456); $parcel$export(module.exports, "FloatingPortal", () => $56b436271f6666d1$export$31fa5d718fa2ac09); $parcel$export(module.exports, "FloatingFocusManager", () => $56b436271f6666d1$export$8aeee49171ded61a); $parcel$export(module.exports, "FloatingOverlay", () => $56b436271f6666d1$export$a35954495955337b); $parcel$export(module.exports, "useClick", () => $56b436271f6666d1$export$98524f11226063fc); $parcel$export(module.exports, "useDismiss", () => $56b436271f6666d1$export$fcdf1ba5fafc089b); $parcel$export(module.exports, "useFloating", () => $56b436271f6666d1$export$4e02a5c1d08bac65); $parcel$export(module.exports, "useFocus", () => $56b436271f6666d1$export$f8168d8dd8fd66e6); $parcel$export(module.exports, "useInteractions", () => $56b436271f6666d1$export$a519f7794e446ddd); $parcel$export(module.exports, "useListNavigation", () => $56b436271f6666d1$export$b5d22cac4ad33f40); $parcel$export(module.exports, "useRole", () => $56b436271f6666d1$export$f66572793fa256a1); $parcel$export(module.exports, "useTypeahead", () => $56b436271f6666d1$export$d8d674d50b73ba93); $parcel$export(module.exports, "offset", () => (parcelRequire("l2jTt")).offset); var $63SH6 = parcelRequire("63SH6"); var $d8YHU = parcelRequire("d8YHU"); var $fvpw6 = parcelRequire("fvpw6"); var $2Dcmu = parcelRequire("2Dcmu"); var $91fsP = parcelRequire("91fsP"); var $8Xnp2 = parcelRequire("8Xnp2"); var $l2jTt = parcelRequire("l2jTt"); var $8Xnp2 = parcelRequire("8Xnp2"); var $bqiJA = parcelRequire("bqiJA"); var $grDIR = parcelRequire("grDIR"); /** * Merges an array of refs into a single memoized callback ref or `null`. * @see https://floating-ui.com/docs/useMergeRefs */ function $56b436271f6666d1$export$74665b213cb5c4cf(refs) { return $63SH6.useMemo(()=>{ if (refs.every((ref)=>ref == null)) return null; return (value)=>{ refs.forEach((ref)=>{ if (typeof ref === "function") ref(value); else if (ref != null) ref.current = value; }); }; // eslint-disable-next-line react-hooks/exhaustive-deps }, refs); } // `toString()` prevents bundlers from trying to `import { useInsertionEffect } from 'react'` const $56b436271f6666d1$var$useInsertionEffect = $63SH6[/*#__PURE__*/ "useInsertionEffect".toString()]; const $56b436271f6666d1$var$useSafeInsertionEffect = $56b436271f6666d1$var$useInsertionEffect || ((fn)=>fn()); function $56b436271f6666d1$var$useEffectEvent(callback) { const ref = $63SH6.useRef(()=>{}); $56b436271f6666d1$var$useSafeInsertionEffect(()=>{ ref.current = callback; }); return $63SH6.useCallback(function() { for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)args[_key] = arguments[_key]; return ref.current == null ? void 0 : ref.current(...args); }, []); } const $56b436271f6666d1$var$ARROW_UP = "ArrowUp"; const $56b436271f6666d1$var$ARROW_DOWN = "ArrowDown"; const $56b436271f6666d1$var$ARROW_LEFT = "ArrowLeft"; const $56b436271f6666d1$var$ARROW_RIGHT = "ArrowRight"; function $56b436271f6666d1$var$isDifferentRow(index, cols, prevRow) { return Math.floor(index / cols) !== prevRow; } function $56b436271f6666d1$var$isIndexOutOfBounds(listRef, index) { return index < 0 || index >= listRef.current.length; } function $56b436271f6666d1$var$getMinIndex(listRef, disabledIndices) { return $56b436271f6666d1$var$findNonDisabledIndex(listRef, { disabledIndices: disabledIndices }); } function $56b436271f6666d1$var$getMaxIndex(listRef, disabledIndices) { return $56b436271f6666d1$var$findNonDisabledIndex(listRef, { decrement: true, startingIndex: listRef.current.length, disabledIndices: disabledIndices }); } function $56b436271f6666d1$var$findNonDisabledIndex(listRef, _temp) { let { startingIndex: startingIndex = -1, decrement: decrement = false, disabledIndices: disabledIndices, amount: amount = 1 } = _temp === void 0 ? {} : _temp; const list = listRef.current; let index = startingIndex; do { var _list$index, _list$index2; index = index + (decrement ? -amount : amount); }while (index >= 0 && index <= list.length - 1 && (disabledIndices ? disabledIndices.includes(index) : list[index] == null || ((_list$index = list[index]) == null ? void 0 : _list$index.hasAttribute("disabled")) || ((_list$index2 = list[index]) == null ? void 0 : _list$index2.getAttribute("aria-disabled")) === "true")); return index; } function $56b436271f6666d1$var$getGridNavigatedIndex(elementsRef, _ref) { let { event: event, orientation: orientation, loop: loop, cols: cols, disabledIndices: disabledIndices, minIndex: minIndex, maxIndex: maxIndex, prevIndex: prevIndex, stopEvent: stop = false } = _ref; let nextIndex = prevIndex; if (event.key === $56b436271f6666d1$var$ARROW_UP) { stop && (0, $d8YHU.stopEvent)(event); if (prevIndex === -1) nextIndex = maxIndex; else { nextIndex = $56b436271f6666d1$var$findNonDisabledIndex(elementsRef, { startingIndex: nextIndex, amount: cols, decrement: true, disabledIndices: disabledIndices }); if (loop && (prevIndex - cols < minIndex || nextIndex < 0)) { const col = prevIndex % cols; const maxCol = maxIndex % cols; const offset = maxIndex - (maxCol - col); if (maxCol === col) nextIndex = maxIndex; else nextIndex = maxCol > col ? offset : offset - cols; } } if ($56b436271f6666d1$var$isIndexOutOfBounds(elementsRef, nextIndex)) nextIndex = prevIndex; } if (event.key === $56b436271f6666d1$var$ARROW_DOWN) { stop && (0, $d8YHU.stopEvent)(event); if (prevIndex === -1) nextIndex = minIndex; else { nextIndex = $56b436271f6666d1$var$findNonDisabledIndex(elementsRef, { startingIndex: prevIndex, amount: cols, disabledIndices: disabledIndices }); if (loop && prevIndex + cols > maxIndex) nextIndex = $56b436271f6666d1$var$findNonDisabledIndex(elementsRef, { startingIndex: prevIndex % cols - cols, amount: cols, disabledIndices: disabledIndices }); } if ($56b436271f6666d1$var$isIndexOutOfBounds(elementsRef, nextIndex)) nextIndex = prevIndex; } // Remains on the same row/column. if (orientation === "both") { const prevRow = (0, $fvpw6.floor)(prevIndex / cols); if (event.key === $56b436271f6666d1$var$ARROW_RIGHT) { stop && (0, $d8YHU.stopEvent)(event); if (prevIndex % cols !== cols - 1) { nextIndex = $56b436271f6666d1$var$findNonDisabledIndex(elementsRef, { startingIndex: prevIndex, disabledIndices: disabledIndices }); if (loop && $56b436271f6666d1$var$isDifferentRow(nextIndex, cols, prevRow)) nextIndex = $56b436271f6666d1$var$findNonDisabledIndex(elementsRef, { startingIndex: prevIndex - prevIndex % cols - 1, disabledIndices: disabledIndices }); } else if (loop) nextIndex = $56b436271f6666d1$var$findNonDisabledIndex(elementsRef, { startingIndex: prevIndex - prevIndex % cols - 1, disabledIndices: disabledIndices }); if ($56b436271f6666d1$var$isDifferentRow(nextIndex, cols, prevRow)) nextIndex = prevIndex; } if (event.key === $56b436271f6666d1$var$ARROW_LEFT) { stop && (0, $d8YHU.stopEvent)(event); if (prevIndex % cols !== 0) { nextIndex = $56b436271f6666d1$var$findNonDisabledIndex(elementsRef, { startingIndex: prevIndex, disabledIndices: disabledIndices, decrement: true }); if (loop && $56b436271f6666d1$var$isDifferentRow(nextIndex, cols, prevRow)) nextIndex = $56b436271f6666d1$var$findNonDisabledIndex(elementsRef, { startingIndex: prevIndex + (cols - prevIndex % cols), decrement: true, disabledIndices: disabledIndices }); } else if (loop) nextIndex = $56b436271f6666d1$var$findNonDisabledIndex(elementsRef, { startingIndex: prevIndex + (cols - prevIndex % cols), decrement: true, disabledIndices: disabledIndices }); if ($56b436271f6666d1$var$isDifferentRow(nextIndex, cols, prevRow)) nextIndex = prevIndex; } const lastRow = (0, $fvpw6.floor)(maxIndex / cols) === prevRow; if ($56b436271f6666d1$var$isIndexOutOfBounds(elementsRef, nextIndex)) { if (loop && lastRow) nextIndex = event.key === $56b436271f6666d1$var$ARROW_LEFT ? maxIndex : $56b436271f6666d1$var$findNonDisabledIndex(elementsRef, { startingIndex: prevIndex - prevIndex % cols - 1, disabledIndices: disabledIndices }); else nextIndex = prevIndex; } } return nextIndex; } let $56b436271f6666d1$var$rafId = 0; function $56b436271f6666d1$var$enqueueFocus(el, options) { if (options === void 0) options = {}; const { preventScroll: preventScroll = false, cancelPrevious: cancelPrevious = true, sync: sync = false } = options; cancelPrevious && cancelAnimationFrame($56b436271f6666d1$var$rafId); const exec = ()=>el == null ? void 0 : el.focus({ preventScroll: preventScroll }); if (sync) exec(); else $56b436271f6666d1$var$rafId = requestAnimationFrame(exec); } var $56b436271f6666d1$var$index = typeof document !== "undefined" ? (0, $63SH6.useLayoutEffect) : (0, $63SH6.useEffect); function $56b436271f6666d1$var$sortByDocumentPosition(a, b) { const position = a.compareDocumentPosition(b); if (position & Node.DOCUMENT_POSITION_FOLLOWING || position & Node.DOCUMENT_POSITION_CONTAINED_BY) return -1; if (position & Node.DOCUMENT_POSITION_PRECEDING || position & Node.DOCUMENT_POSITION_CONTAINS) return 1; return 0; } function $56b436271f6666d1$var$areMapsEqual(map1, map2) { if (map1.size !== map2.size) return false; for (const [key, value] of map1.entries()){ if (value !== map2.get(key)) return false; } return true; } const $56b436271f6666d1$var$FloatingListContext = /*#__PURE__*/ $63SH6.createContext({ register: ()=>{}, unregister: ()=>{}, map: /*#__PURE__*/ new Map(), elementsRef: { current: [] } }); /** * Provides context for a list of items within the floating element. * @see https://floating-ui.com/docs/FloatingList */ function $56b436271f6666d1$export$ffe15b0e64951704(_ref) { let { children: children, elementsRef: elementsRef, labelsRef: labelsRef } = _ref; const [map, setMap] = $63SH6.useState(()=>new Map()); const register = $63SH6.useCallback((node)=>{ setMap((prevMap)=>new Map(prevMap).set(node, null)); }, []); const unregister = $63SH6.useCallback((node)=>{ setMap((prevMap)=>{ const map = new Map(prevMap); map.delete(node); return map; }); }, []); $56b436271f6666d1$var$index(()=>{ const newMap = new Map(map); const nodes = Array.from(newMap.keys()).sort($56b436271f6666d1$var$sortByDocumentPosition); nodes.forEach((node, index)=>{ newMap.set(node, index); }); if (!$56b436271f6666d1$var$areMapsEqual(map, newMap)) setMap(newMap); }, [ map ]); return /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$var$FloatingListContext.Provider, { value: $63SH6.useMemo(()=>({ register: register, unregister: unregister, map: map, elementsRef: elementsRef, labelsRef: labelsRef }), [ register, unregister, map, elementsRef, labelsRef ]) }, children); } function $56b436271f6666d1$export$dcdc7ff5149f7d1a(_temp) { let { label: label } = _temp === void 0 ? {} : _temp; const [index$1, setIndex] = $63SH6.useState(null); const componentRef = $63SH6.useRef(null); const { register: register, unregister: unregister, map: map, elementsRef: elementsRef, labelsRef: labelsRef } = $63SH6.useContext($56b436271f6666d1$var$FloatingListContext); const ref = $63SH6.useCallback((node)=>{ componentRef.current = node; if (index$1 !== null) { elementsRef.current[index$1] = node; if (labelsRef) { var _node$textContent; const isLabelDefined = label !== undefined; labelsRef.current[index$1] = isLabelDefined ? label : (_node$textContent = node == null ? void 0 : node.textContent) != null ? _node$textContent : null; } } }, [ index$1, elementsRef, labelsRef, label ]); $56b436271f6666d1$var$index(()=>{ const node = componentRef.current; if (node) { register(node); return ()=>{ unregister(node); }; } }, [ register, unregister ]); $56b436271f6666d1$var$index(()=>{ const index = componentRef.current ? map.get(componentRef.current) : null; if (index != null) setIndex(index); }, [ map ]); return $63SH6.useMemo(()=>({ ref: ref, index: index$1 == null ? -1 : index$1 }), [ index$1, ref ]); } function $56b436271f6666d1$var$renderJsx(render, computedProps) { if (typeof render === "function") return render(computedProps); else if (render) return /*#__PURE__*/ $63SH6.cloneElement(render, computedProps); return /*#__PURE__*/ $63SH6.createElement("div", computedProps); } const $56b436271f6666d1$var$CompositeContext = /*#__PURE__*/ $63SH6.createContext({ activeIndex: 0, onNavigate: ()=>{} }); const $56b436271f6666d1$var$horizontalKeys = [ $56b436271f6666d1$var$ARROW_LEFT, $56b436271f6666d1$var$ARROW_RIGHT ]; const $56b436271f6666d1$var$verticalKeys = [ $56b436271f6666d1$var$ARROW_UP, $56b436271f6666d1$var$ARROW_DOWN ]; const $56b436271f6666d1$var$allKeys = [ ...$56b436271f6666d1$var$horizontalKeys, ...$56b436271f6666d1$var$verticalKeys ]; const $56b436271f6666d1$export$43586241d9db0c6d = /*#__PURE__*/ $63SH6.forwardRef(function Composite(_ref, forwardedRef) { let { render: render, orientation: orientation = "both", loop: loop = true, cols: cols = 1, disabledIndices: disabledIndices, activeIndex: externalActiveIndex, onNavigate: externalSetActiveIndex, ...props } = _ref; const [internalActiveIndex, internalSetActiveIndex] = $63SH6.useState(0); const activeIndex = externalActiveIndex != null ? externalActiveIndex : internalActiveIndex; const onNavigate = $56b436271f6666d1$var$useEffectEvent(externalSetActiveIndex != null ? externalSetActiveIndex : internalSetActiveIndex); const elementsRef = $63SH6.useRef([]); const renderElementProps = render && typeof render !== "function" ? render.props : {}; const contextValue = $63SH6.useMemo(()=>({ activeIndex: activeIndex, onNavigate: onNavigate }), [ activeIndex, onNavigate ]); const isGrid = cols > 1; function handleKeyDown(event) { if (!$56b436271f6666d1$var$allKeys.includes(event.key)) return; const minIndex = $56b436271f6666d1$var$getMinIndex(elementsRef, disabledIndices); const maxIndex = $56b436271f6666d1$var$getMaxIndex(elementsRef, disabledIndices); const prevIndex = activeIndex; let nextIndex = activeIndex; if (isGrid) nextIndex = $56b436271f6666d1$var$getGridNavigatedIndex(elementsRef, { event: event, orientation: orientation, loop: loop, cols: cols, disabledIndices: disabledIndices, minIndex: minIndex, maxIndex: maxIndex, prevIndex: prevIndex }); const toEndKeys = { horizontal: [ $56b436271f6666d1$var$ARROW_RIGHT ], vertical: [ $56b436271f6666d1$var$ARROW_DOWN ], both: [ $56b436271f6666d1$var$ARROW_RIGHT, $56b436271f6666d1$var$ARROW_DOWN ] }[orientation]; const toStartKeys = { horizontal: [ $56b436271f6666d1$var$ARROW_LEFT ], vertical: [ $56b436271f6666d1$var$ARROW_UP ], both: [ $56b436271f6666d1$var$ARROW_LEFT, $56b436271f6666d1$var$ARROW_UP ] }[orientation]; const preventedKeys = isGrid ? $56b436271f6666d1$var$allKeys : ({ horizontal: $56b436271f6666d1$var$horizontalKeys, vertical: $56b436271f6666d1$var$verticalKeys, both: $56b436271f6666d1$var$allKeys })[orientation]; if (nextIndex === activeIndex && [ ...toEndKeys, ...toStartKeys ].includes(event.key)) { if (loop && nextIndex === maxIndex && toEndKeys.includes(event.key)) nextIndex = minIndex; else if (loop && nextIndex === minIndex && toStartKeys.includes(event.key)) nextIndex = maxIndex; else nextIndex = $56b436271f6666d1$var$findNonDisabledIndex(elementsRef, { startingIndex: nextIndex, decrement: toStartKeys.includes(event.key), disabledIndices: disabledIndices }); } if (nextIndex !== activeIndex && !$56b436271f6666d1$var$isIndexOutOfBounds(elementsRef, nextIndex)) { event.stopPropagation(); if (preventedKeys.includes(event.key)) event.preventDefault(); onNavigate(nextIndex); // Wait for FocusManager `returnFocus` to execute. queueMicrotask(()=>{ $56b436271f6666d1$var$enqueueFocus(elementsRef.current[nextIndex]); }); } } const computedProps = { ...props, ...renderElementProps, ref: forwardedRef, "aria-orientation": orientation === "both" ? undefined : orientation, onKeyDown (e) { props.onKeyDown == null || props.onKeyDown(e); renderElementProps.onKeyDown == null || renderElementProps.onKeyDown(e); handleKeyDown(e); } }; return /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$var$CompositeContext.Provider, { value: contextValue }, /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$export$ffe15b0e64951704, { elementsRef: elementsRef }, $56b436271f6666d1$var$renderJsx(render, computedProps))); }); const $56b436271f6666d1$export$ef1ef7a3a43ace8e = /*#__PURE__*/ $63SH6.forwardRef(function CompositeItem(_ref2, forwardedRef) { let { render: render, ...props } = _ref2; const renderElementProps = render && typeof render !== "function" ? render.props : {}; const { activeIndex: activeIndex, onNavigate: onNavigate } = $63SH6.useContext($56b436271f6666d1$var$CompositeContext); const { ref: ref, index: index } = $56b436271f6666d1$export$dcdc7ff5149f7d1a(); const mergedRef = $56b436271f6666d1$export$74665b213cb5c4cf([ ref, forwardedRef, renderElementProps.ref ]); const isActive = activeIndex === index; const computedProps = { ...props, ...renderElementProps, ref: mergedRef, tabIndex: isActive ? 0 : -1, "data-active": isActive ? "" : undefined, onFocus (e) { props.onFocus == null || props.onFocus(e); renderElementProps.onFocus == null || renderElementProps.onFocus(e); onNavigate(index); } }; return $56b436271f6666d1$var$renderJsx(render, computedProps); }); function $56b436271f6666d1$var$_extends() { $56b436271f6666d1$var$_extends = Object.assign ? Object.assign.bind() : function(target) { for(var i = 1; i < arguments.length; i++){ var source = arguments[i]; for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key]; } return target; }; return $56b436271f6666d1$var$_extends.apply(this, arguments); } let $56b436271f6666d1$var$serverHandoffComplete = false; let $56b436271f6666d1$var$count = 0; const $56b436271f6666d1$var$genId = ()=>"floating-ui-" + $56b436271f6666d1$var$count++; function $56b436271f6666d1$var$useFloatingId() { const [id, setId] = $63SH6.useState(()=>$56b436271f6666d1$var$serverHandoffComplete ? $56b436271f6666d1$var$genId() : undefined); $56b436271f6666d1$var$index(()=>{ if (id == null) setId($56b436271f6666d1$var$genId()); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); $63SH6.useEffect(()=>{ if (!$56b436271f6666d1$var$serverHandoffComplete) $56b436271f6666d1$var$serverHandoffComplete = true; }, []); return id; } // `toString()` prevents bundlers from trying to `import { useId } from 'react'` const $56b436271f6666d1$var$useReactId = $63SH6[/*#__PURE__*/ "useId".toString()]; /** * Uses React 18's built-in `useId()` when available, or falls back to a * slightly less performant (requiring a double render) implementation for * earlier React versions. * @see https://floating-ui.com/docs/useId */ const $56b436271f6666d1$export$f680877a34711e37 = $56b436271f6666d1$var$useReactId || $56b436271f6666d1$var$useFloatingId; /** * Renders a pointing arrow triangle. * @see https://floating-ui.com/docs/FloatingArrow */ const $56b436271f6666d1$export$33511391554732bc = /*#__PURE__*/ $63SH6.forwardRef(function FloatingArrow(_ref, ref) { let { context: { placement: placement, elements: { floating: floating }, middlewareData: { arrow: arrow } }, width: width = 14, height: height = 7, tipRadius: tipRadius = 0, strokeWidth: strokeWidth = 0, staticOffset: staticOffset, stroke: stroke, d: d, style: { transform: transform, ...restStyle } = {}, ...rest } = _ref; const clipPathId = $56b436271f6666d1$export$f680877a34711e37(); if (!floating) return null; // Strokes must be double the border width, this ensures the stroke's width // works as you'd expect. strokeWidth *= 2; const halfStrokeWidth = strokeWidth / 2; const svgX = width / 2 * (tipRadius / -8 + 1); const svgY = height / 2 * tipRadius / 4; const [side, alignment] = placement.split("-"); const isRTL = (0, $91fsP.platform).isRTL(floating); const isCustomShape = !!d; const isVerticalSide = side === "top" || side === "bottom"; const yOffsetProp = staticOffset && alignment === "end" ? "bottom" : "top"; let xOffsetProp = staticOffset && alignment === "end" ? "right" : "left"; if (staticOffset && isRTL) xOffsetProp = alignment === "end" ? "left" : "right"; const arrowX = (arrow == null ? void 0 : arrow.x) != null ? staticOffset || arrow.x : ""; const arrowY = (arrow == null ? void 0 : arrow.y) != null ? staticOffset || arrow.y : ""; const dValue = d || "M0,0" + (" H" + width) + (" L" + (width - svgX) + "," + (height - svgY)) + (" Q" + width / 2 + "," + height + " " + svgX + "," + (height - svgY)) + " Z"; const rotation = { top: isCustomShape ? "rotate(180deg)" : "", left: isCustomShape ? "rotate(90deg)" : "rotate(-90deg)", bottom: isCustomShape ? "" : "rotate(180deg)", right: isCustomShape ? "rotate(-90deg)" : "rotate(90deg)" }[side]; return /*#__PURE__*/ $63SH6.createElement("svg", $56b436271f6666d1$var$_extends({}, rest, { "aria-hidden": true, ref: ref, width: isCustomShape ? width : width + strokeWidth, height: width, viewBox: "0 0 " + width + " " + (height > width ? height : width), style: { position: "absolute", pointerEvents: "none", [xOffsetProp]: arrowX, [yOffsetProp]: arrowY, [side]: isVerticalSide || isCustomShape ? "100%" : "calc(100% - " + strokeWidth / 2 + "px)", transform: "" + rotation + (transform != null ? transform : ""), ...restStyle } }), strokeWidth > 0 && /*#__PURE__*/ $63SH6.createElement("path", { clipPath: "url(#" + clipPathId + ")", fill: "none", stroke: stroke, strokeWidth: strokeWidth + (d ? 0 : 1), d: dValue }), /*#__PURE__*/ $63SH6.createElement("path", { stroke: strokeWidth && !d ? rest.fill : "none", d: dValue }), /*#__PURE__*/ $63SH6.createElement("clipPath", { id: clipPathId }, /*#__PURE__*/ $63SH6.createElement("rect", { x: -halfStrokeWidth, y: halfStrokeWidth * (isCustomShape ? -1 : 1), width: width + strokeWidth, height: width }))); }); function $56b436271f6666d1$var$createPubSub() { const map = new Map(); return { emit (event, data) { var _map$get; (_map$get = map.get(event)) == null || _map$get.forEach((handler)=>handler(data)); }, on (event, listener) { map.set(event, [ ...map.get(event) || [], listener ]); }, off (event, listener) { var _map$get2; map.set(event, ((_map$get2 = map.get(event)) == null ? void 0 : _map$get2.filter((l)=>l !== listener)) || []); } }; } const $56b436271f6666d1$var$FloatingNodeContext = /*#__PURE__*/ $63SH6.createContext(null); const $56b436271f6666d1$var$FloatingTreeContext = /*#__PURE__*/ $63SH6.createContext(null); const $56b436271f6666d1$export$165209eae06d3488 = ()=>{ var _React$useContext; return ((_React$useContext = $63SH6.useContext($56b436271f6666d1$var$FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null; }; const $56b436271f6666d1$export$db0c2a7c7a2a4f69 = ()=>$63SH6.useContext($56b436271f6666d1$var$FloatingTreeContext); /** * Registers a node into the floating tree, returning its id. */ function $56b436271f6666d1$export$9b136e0e758a42f4(customParentId) { const id = $56b436271f6666d1$export$f680877a34711e37(); const tree = $56b436271f6666d1$export$db0c2a7c7a2a4f69(); const reactParentId = $56b436271f6666d1$export$165209eae06d3488(); const parentId = customParentId || reactParentId; $56b436271f6666d1$var$index(()=>{ const node = { id: id, parentId: parentId }; tree == null || tree.addNode(node); return ()=>{ tree == null || tree.removeNode(node); }; }, [ tree, id, parentId ]); return id; } /** * Provides parent node context for nested floating elements. * @see https://floating-ui.com/docs/FloatingTree */ function $56b436271f6666d1$export$ca00a83b5b253862(_ref) { let { children: children, id: id } = _ref; const parentId = $56b436271f6666d1$export$165209eae06d3488(); return /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$var$FloatingNodeContext.Provider, { value: $63SH6.useMemo(()=>({ id: id, parentId: parentId }), [ id, parentId ]) }, children); } /** * Provides context for nested floating elements when they are not children of * each other on the DOM (i.e. portalled to a common node, rather than their * respective parent). * @see https://floating-ui.com/docs/FloatingTree */ function $56b436271f6666d1$export$587b60129641c4c8(_ref2) { let { children: children } = _ref2; const nodesRef = $63SH6.useRef([]); const addNode = $63SH6.useCallback((node)=>{ nodesRef.current = [ ...nodesRef.current, node ]; }, []); const removeNode = $63SH6.useCallback((node)=>{ nodesRef.current = nodesRef.current.filter((n)=>n !== node); }, []); const events = $63SH6.useState(()=>$56b436271f6666d1$var$createPubSub())[0]; return /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$var$FloatingTreeContext.Provider, { value: $63SH6.useMemo(()=>({ nodesRef: nodesRef, addNode: addNode, removeNode: removeNode, events: events }), [ nodesRef, addNode, removeNode, events ]) }, children); } function $56b436271f6666d1$var$createAttribute(name) { return "data-floating-ui-" + name; } function $56b436271f6666d1$var$useLatestRef(value) { const ref = (0, $63SH6.useRef)(value); $56b436271f6666d1$var$index(()=>{ ref.current = value; }); return ref; } const $56b436271f6666d1$var$safePolygonIdentifier = /*#__PURE__*/ $56b436271f6666d1$var$createAttribute("safe-polygon"); function $56b436271f6666d1$var$getDelay(value, prop, pointerType) { if (pointerType && !(0, $d8YHU.isMouseLikePointerType)(pointerType)) return 0; if (typeof value === "number") return value; return value == null ? void 0 : value[prop]; } /** * Opens the floating element while hovering over the reference element, like * CSS `:hover`. * @see https://floating-ui.com/docs/useHover */ function $56b436271f6666d1$export$ae780daf29e6d456(context, props) { if (props === void 0) props = {}; const { open: open, onOpenChange: onOpenChange, dataRef: dataRef, events: events, elements: { domReference: domReference, floating: floating }, refs: refs } = context; const { enabled: enabled = true, delay: delay = 0, handleClose: handleClose = null, mouseOnly: mouseOnly = false, restMs: restMs = 0, move: move = true } = props; const tree = $56b436271f6666d1$export$db0c2a7c7a2a4f69(); const parentId = $56b436271f6666d1$export$165209eae06d3488(); const handleCloseRef = $56b436271f6666d1$var$useLatestRef(handleClose); const delayRef = $56b436271f6666d1$var$useLatestRef(delay); const pointerTypeRef = $63SH6.useRef(); const timeoutRef = $63SH6.useRef(); const handlerRef = $63SH6.useRef(); const restTimeoutRef = $63SH6.useRef(); const blockMouseMoveRef = $63SH6.useRef(true); const performedPointerEventsMutationRef = $63SH6.useRef(false); const unbindMouseMoveRef = $63SH6.useRef(()=>{}); const isHoverOpen = $63SH6.useCallback(()=>{ var _dataRef$current$open; const type = (_dataRef$current$open = dataRef.current.openEvent) == null ? void 0 : _dataRef$current$open.type; return (type == null ? void 0 : type.includes("mouse")) && type !== "mousedown"; }, [ dataRef ]); // When dismissing before opening, clear the delay timeouts to cancel it // from showing. $63SH6.useEffect(()=>{ if (!enabled) return; function onDismiss() { clearTimeout(timeoutRef.current); clearTimeout(restTimeoutRef.current); blockMouseMoveRef.current = true; } events.on("dismiss", onDismiss); return ()=>{ events.off("dismiss", onDismiss); }; }, [ enabled, events ]); $63SH6.useEffect(()=>{ if (!enabled || !handleCloseRef.current || !open) return; function onLeave(event) { if (isHoverOpen()) onOpenChange(false, event); } const html = (0, $d8YHU.getDocument)(floating).documentElement; html.addEventListener("mouseleave", onLeave); return ()=>{ html.removeEventListener("mouseleave", onLeave); }; }, [ floating, open, onOpenChange, enabled, handleCloseRef, dataRef, isHoverOpen ]); const closeWithDelay = $63SH6.useCallback(function(event, runElseBranch) { if (runElseBranch === void 0) runElseBranch = true; const closeDelay = $56b436271f6666d1$var$getDelay(delayRef.current, "close", pointerTypeRef.current); if (closeDelay && !handlerRef.current) { clearTimeout(timeoutRef.current); timeoutRef.current = setTimeout(()=>onOpenChange(false, event), closeDelay); } else if (runElseBranch) { clearTimeout(timeoutRef.current); onOpenChange(false, event); } }, [ delayRef, onOpenChange ]); const cleanupMouseMoveHandler = $63SH6.useCallback(()=>{ unbindMouseMoveRef.current(); handlerRef.current = undefined; }, []); const clearPointerEvents = $63SH6.useCallback(()=>{ if (performedPointerEventsMutationRef.current) { const body = (0, $d8YHU.getDocument)(refs.floating.current).body; body.style.pointerEvents = ""; body.removeAttribute($56b436271f6666d1$var$safePolygonIdentifier); performedPointerEventsMutationRef.current = false; } }, [ refs ]); // Registering the mouse events on the reference directly to bypass React's // delegation system. If the cursor was on a disabled element and then entered // the reference (no gap), `mouseenter` doesn't fire in the delegation system. $63SH6.useEffect(()=>{ if (!enabled) return; function isClickLikeOpenEvent() { return dataRef.current.openEvent ? [ "click", "mousedown" ].includes(dataRef.current.openEvent.type) : false; } function onMouseEnter(event) { clearTimeout(timeoutRef.current); blockMouseMoveRef.current = false; if (mouseOnly && !(0, $d8YHU.isMouseLikePointerType)(pointerTypeRef.current) || restMs > 0 && $56b436271f6666d1$var$getDelay(delayRef.current, "open") === 0) return; const openDelay = $56b436271f6666d1$var$getDelay(delayRef.current, "open", pointerTypeRef.current); if (openDelay) timeoutRef.current = setTimeout(()=>{ onOpenChange(true, event); }, openDelay); else onOpenChange(true, event); } function onMouseLeave(event) { if (isClickLikeOpenEvent()) return; unbindMouseMoveRef.current(); const doc = (0, $d8YHU.getDocument)(floating); clearTimeout(restTimeoutRef.current); if (handleCloseRef.current) { // Prevent clearing `onScrollMouseLeave` timeout. if (!open) clearTimeout(timeoutRef.current); handlerRef.current = handleCloseRef.current({ ...context, tree: tree, x: event.clientX, y: event.clientY, onClose () { clearPointerEvents(); cleanupMouseMoveHandler(); // Should the event expose that it was closed by `safePolygon`? closeWithDelay(event); } }); const handler = handlerRef.current; doc.addEventListener("mousemove", handler); unbindMouseMoveRef.current = ()=>{ doc.removeEventListener("mousemove", handler); }; return; } // Allow interactivity without `safePolygon` on touch devices. With a // pointer, a short close delay is an alternative, so it should work // consistently. const shouldClose = pointerTypeRef.current === "touch" ? !(0, $d8YHU.contains)(floating, event.relatedTarget) : true; if (shouldClose) closeWithDelay(event); } // Ensure the floating element closes after scrolling even if the pointer // did not move. // https://github.com/floating-ui/floating-ui/discussions/1692 function onScrollMouseLeave(event) { if (isClickLikeOpenEvent()) return; handleCloseRef.current == null || handleCloseRef.current({ ...context, tree: tree, x: event.clientX, y: event.clientY, onClose () { clearPointerEvents(); cleanupMouseMoveHandler(); closeWithDelay(event); } })(event); } if ((0, $8Xnp2.isElement)(domReference)) { const ref = domReference; open && ref.addEventListener("mouseleave", onScrollMouseLeave); floating == null || floating.addEventListener("mouseleave", onScrollMouseLeave); move && ref.addEventListener("mousemove", onMouseEnter, { once: true }); ref.addEventListener("mouseenter", onMouseEnter); ref.addEventListener("mouseleave", onMouseLeave); return ()=>{ open && ref.removeEventListener("mouseleave", onScrollMouseLeave); floating == null || floating.removeEventListener("mouseleave", onScrollMouseLeave); move && ref.removeEventListener("mousemove", onMouseEnter); ref.removeEventListener("mouseenter", onMouseEnter); ref.removeEventListener("mouseleave", onMouseLeave); }; } }, [ domReference, floating, enabled, context, mouseOnly, restMs, move, closeWithDelay, cleanupMouseMoveHandler, clearPointerEvents, onOpenChange, open, tree, delayRef, handleCloseRef, dataRef ]); // Block pointer-events of every element other than the reference and floating // while the floating element is open and has a `handleClose` handler. Also // handles nested floating elements. // https://github.com/floating-ui/floating-ui/issues/1722 $56b436271f6666d1$var$index(()=>{ var _handleCloseRef$curre; if (!enabled) return; if (open && (_handleCloseRef$curre = handleCloseRef.current) != null && _handleCloseRef$curre.__options.blockPointerEvents && isHoverOpen()) { const body = (0, $d8YHU.getDocument)(floating).body; body.setAttribute($56b436271f6666d1$var$safePolygonIdentifier, ""); body.style.pointerEvents = "none"; performedPointerEventsMutationRef.current = true; if ((0, $8Xnp2.isElement)(domReference) && floating) { var _tree$nodesRef$curren, _tree$nodesRef$curren2; const ref = domReference; const parentFloating = tree == null ? void 0 : (_tree$nodesRef$curren = tree.nodesRef.current.find((node)=>node.id === parentId)) == null ? void 0 : (_tree$nodesRef$curren2 = _tree$nodesRef$curren.context) == null ? void 0 : _tree$nodesRef$curren2.elements.floating; if (parentFloating) parentFloating.style.pointerEvents = ""; ref.style.pointerEvents = "auto"; floating.style.pointerEvents = "auto"; return ()=>{ ref.style.pointerEvents = ""; floating.style.pointerEvents = ""; }; } } }, [ enabled, open, parentId, floating, domReference, tree, handleCloseRef, dataRef, isHoverOpen ]); $56b436271f6666d1$var$index(()=>{ if (!open) { pointerTypeRef.current = undefined; cleanupMouseMoveHandler(); clearPointerEvents(); } }, [ open, cleanupMouseMoveHandler, clearPointerEvents ]); $63SH6.useEffect(()=>{ return ()=>{ cleanupMouseMoveHandler(); clearTimeout(timeoutRef.current); clearTimeout(restTimeoutRef.current); clearPointerEvents(); }; }, [ enabled, domReference, cleanupMouseMoveHandler, clearPointerEvents ]); return $63SH6.useMemo(()=>{ if (!enabled) return {}; function setPointerRef(event) { pointerTypeRef.current = event.pointerType; } return { reference: { onPointerDown: setPointerRef, onPointerEnter: setPointerRef, onMouseMove (event) { if (open || restMs === 0) return; clearTimeout(restTimeoutRef.current); restTimeoutRef.current = setTimeout(()=>{ if (!blockMouseMoveRef.current) onOpenChange(true, event.nativeEvent); }, restMs); } }, floating: { onMouseEnter () { clearTimeout(timeoutRef.current); }, onMouseLeave (event) { events.emit("dismiss", { type: "mouseLeave", data: { returnFocus: false } }); closeWithDelay(event.nativeEvent, false); } } }; }, [ events, enabled, restMs, open, onOpenChange, closeWithDelay ]); } const $56b436271f6666d1$var$FloatingDelayGroupContext = /*#__PURE__*/ $63SH6.createContext({ delay: 0, initialDelay: 0, timeoutMs: 0, currentId: null, setCurrentId: ()=>{}, setState: ()=>{}, isInstantPhase: false }); const $56b436271f6666d1$export$e2411914b150383d = ()=>$63SH6.useContext($56b436271f6666d1$var$FloatingDelayGroupContext); /** * Provides context for a group of floating elements that should share a * `delay`. * @see https://floating-ui.com/docs/FloatingDelayGroup */ const $56b436271f6666d1$export$718279509ff1e241 = (_ref)=>{ let { children: children, delay: delay, timeoutMs: timeoutMs = 0 } = _ref; const [state, setState] = $63SH6.useReducer((prev, next)=>({ ...prev, ...next }), { delay: delay, timeoutMs: timeoutMs, initialDelay: delay, currentId: null, isInstantPhase: false }); const initialCurrentIdRef = $63SH6.useRef(null); const setCurrentId = $63SH6.useCallback((currentId)=>{ setState({ currentId: currentId }); }, []); $56b436271f6666d1$var$index(()=>{ if (state.currentId) { if (initialCurrentIdRef.current === null) initialCurrentIdRef.current = state.currentId; else setState({ isInstantPhase: true }); } else { setState({ isInstantPhase: false }); initialCurrentIdRef.current = null; } }, [ state.currentId ]); return /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$var$FloatingDelayGroupContext.Provider, { value: $63SH6.useMemo(()=>({ ...state, setState: setState, setCurrentId: setCurrentId }), [ state, setState, setCurrentId ]) }, children); }; const $56b436271f6666d1$export$560fc8be89c8b4a8 = (_ref2, _ref3)=>{ let { open: open, onOpenChange: onOpenChange } = _ref2; let { id: id } = _ref3; const { currentId: currentId, setCurrentId: setCurrentId, initialDelay: initialDelay, setState: setState, timeoutMs: timeoutMs } = $56b436271f6666d1$export$e2411914b150383d(); $56b436271f6666d1$var$index(()=>{ if (currentId) { setState({ delay: { open: 1, close: $56b436271f6666d1$var$getDelay(initialDelay, "close") } }); if (currentId !== id) onOpenChange(false); } }, [ id, onOpenChange, setState, currentId, initialDelay ]); $56b436271f6666d1$var$index(()=>{ function unset() { onOpenChange(false); setState({ delay: initialDelay, currentId: null }); } if (!open && currentId === id) { if (timeoutMs) { const timeout = window.setTimeout(unset, timeoutMs); return ()=>{ clearTimeout(timeout); }; } else unset(); } }, [ open, setState, currentId, id, onOpenChange, initialDelay, timeoutMs ]); $56b436271f6666d1$var$index(()=>{ if (open) setCurrentId(id); }, [ open, setCurrentId, id ]); }; function $56b436271f6666d1$var$getAncestors(nodes, id) { var _nodes$find; let allAncestors = []; let currentParentId = (_nodes$find = nodes.find((node)=>node.id === id)) == null ? void 0 : _nodes$find.parentId; while(currentParentId){ const currentNode = nodes.find((node)=>node.id === currentParentId); currentParentId = currentNode == null ? void 0 : currentNode.parentId; if (currentNode) allAncestors = allAncestors.concat(currentNode); } return allAncestors; } function $56b436271f6666d1$var$getChildren(nodes, id) { let allChildren = nodes.filter((node)=>{ var _node$context; return node.parentId === id && ((_node$context = node.context) == null ? void 0 : _node$context.open); }); let currentChildren = allChildren; while(currentChildren.length){ currentChildren = nodes.filter((node)=>{ var _currentChildren; return (_currentChildren = currentChildren) == null ? void 0 : _currentChildren.some((n)=>{ var _node$context2; return node.parentId === n.id && ((_node$context2 = node.context) == null ? void 0 : _node$context2.open); }); }); allChildren = allChildren.concat(currentChildren); } return allChildren; } function $56b436271f6666d1$var$getDeepestNode(nodes, id) { let deepestNodeId; let maxDepth = -1; function findDeepest(nodeId, depth) { if (depth > maxDepth) { deepestNodeId = nodeId; maxDepth = depth; } const children = $56b436271f6666d1$var$getChildren(nodes, nodeId); children.forEach((child)=>{ findDeepest(child.id, depth + 1); }); } findDeepest(id, 0); return nodes.find((node)=>node.id === deepestNodeId); } // Modified to add conditional `aria-hidden` support: // https://github.com/theKashey/aria-hidden/blob/9220c8f4a4fd35f63bee5510a9f41a37264382d4/src/index.ts let $56b436271f6666d1$var$counterMap = /*#__PURE__*/ new WeakMap(); let $56b436271f6666d1$var$uncontrolledElementsSet = /*#__PURE__*/ new WeakSet(); let $56b436271f6666d1$var$markerMap = {}; let $56b436271f6666d1$var$lockCount = 0; const $56b436271f6666d1$var$supportsInert = ()=>typeof HTMLElement !== "undefined" && "inert" in HTMLElement.prototype; const $56b436271f6666d1$var$unwrapHost = (node)=>node && (node.host || $56b436271f6666d1$var$unwrapHost(node.parentNode)); const $56b436271f6666d1$var$correctElements = (parent, targets)=>targets.map((target)=>{ if (parent.contains(target)) return target; const correctedTarget = $56b436271f6666d1$var$unwrapHost(target); if (parent.contains(correctedTarget)) return correctedTarget; return null; }).filter((x)=>x != null); function $56b436271f6666d1$var$applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert) { const markerName = "data-floating-ui-inert"; const controlAttribute = inert ? "inert" : ariaHidden ? "aria-hidden" : null; const avoidElements = $56b436271f6666d1$var$correctElements(body, uncorrectedAvoidElements); const elementsToKeep = new Set(); const elementsToStop = new Set(avoidElements); const hiddenElements = []; if (!$56b436271f6666d1$var$markerMap[markerName]) $56b436271f6666d1$var$markerMap[markerName] = new WeakMap(); const markerCounter = $56b436271f6666d1$var$markerMap[markerName]; avoidElements.forEach(keep); deep(body); elementsToKeep.clear(); function keep(el) { if (!el || elementsToKeep.has(el)) return; elementsToKeep.add(el); el.parentNode && keep(el.parentNode); } function deep(parent) { if (!parent || elementsToStop.has(parent)) return; Array.prototype.forEach.call(parent.children, (node)=>{ if (elementsToKeep.has(node)) deep(node); else { const attr = controlAttribute ? node.getAttribute(controlAttribute) : null; const alreadyHidden = attr !== null && attr !== "false"; const counterValue = ($56b436271f6666d1$var$counterMap.get(node) || 0) + 1; const markerValue = (markerCounter.get(node) || 0) + 1; $56b436271f6666d1$var$counterMap.set(node, counterValue); markerCounter.set(node, markerValue); hiddenElements.push(node); if (counterValue === 1 && alreadyHidden) $56b436271f6666d1$var$uncontrolledElementsSet.add(node); if (markerValue === 1) node.setAttribute(markerName, ""); if (!alreadyHidden && controlAttribute) node.setAttribute(controlAttribute, "true"); } }); } $56b436271f6666d1$var$lockCount++; return ()=>{ hiddenElements.forEach((element)=>{ const counterValue = ($56b436271f6666d1$var$counterMap.get(element) || 0) - 1; const markerValue = (markerCounter.get(element) || 0) - 1; $56b436271f6666d1$var$counterMap.set(element, counterValue); markerCounter.set(element, markerValue); if (!counterValue) { if (!$56b436271f6666d1$var$uncontrolledElementsSet.has(element) && controlAttribute) element.removeAttribute(controlAttribute); $56b436271f6666d1$var$uncontrolledElementsSet.delete(element); } if (!markerValue) element.removeAttribute(markerName); }); $56b436271f6666d1$var$lockCount--; if (!$56b436271f6666d1$var$lockCount) { $56b436271f6666d1$var$counterMap = new WeakMap(); $56b436271f6666d1$var$counterMap = new WeakMap(); $56b436271f6666d1$var$uncontrolledElementsSet = new WeakSet(); $56b436271f6666d1$var$markerMap = {}; } }; } function $56b436271f6666d1$var$markOthers(avoidElements, ariaHidden, inert) { if (ariaHidden === void 0) ariaHidden = false; if (inert === void 0) inert = false; const body = (0, $d8YHU.getDocument)(avoidElements[0]).body; return $56b436271f6666d1$var$applyAttributeToOthers(avoidElements.concat(Array.from(body.querySelectorAll("[aria-live]"))), body, ariaHidden, inert); } const $56b436271f6666d1$var$getTabbableOptions = ()=>({ getShadowRoot: true, displayCheck: // JSDOM does not support the `tabbable` library. To solve this we can // check if `ResizeObserver` is a real function (not polyfilled), which // determines if the current environment is JSDOM-like. typeof ResizeObserver === "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none" }); function $56b436271f6666d1$var$getTabbableIn(container, direction) { const allTabbable = (0, $bqiJA.tabbable)(container, $56b436271f6666d1$var$getTabbableOptions()); if (direction === "prev") allTabbable.reverse(); const activeIndex = allTabbable.indexOf((0, $d8YHU.activeElement)((0, $d8YHU.getDocument)(container))); const nextTabbableElements = allTabbable.slice(activeIndex + 1); return nextTabbableElements[0]; } function $56b436271f6666d1$var$getNextTabbable() { return $56b436271f6666d1$var$getTabbableIn(document.body, "next"); } function $56b436271f6666d1$var$getPreviousTabbable() { return $56b436271f6666d1$var$getTabbableIn(document.body, "prev"); } function $56b436271f6666d1$var$isOutsideEvent(event, container) { const containerElement = container || event.currentTarget; const relatedTarget = event.relatedTarget; return !relatedTarget || !(0, $d8YHU.contains)(containerElement, relatedTarget); } function $56b436271f6666d1$var$disableFocusInside(container) { const tabbableElements = (0, $bqiJA.tabbable)(container, $56b436271f6666d1$var$getTabbableOptions()); tabbableElements.forEach((element)=>{ element.dataset.tabindex = element.getAttribute("tabindex") || ""; element.setAttribute("tabindex", "-1"); }); } function $56b436271f6666d1$var$enableFocusInside(container) { const elements = container.querySelectorAll("[data-tabindex]"); elements.forEach((element)=>{ const tabindex = element.dataset.tabindex; delete element.dataset.tabindex; if (tabindex) element.setAttribute("tabindex", tabindex); else element.removeAttribute("tabindex"); }); } // See Diego Haz's Sandbox for making this logic work well on Safari/iOS: // https://codesandbox.io/s/tabbable-portal-f4tng?file=/src/FocusTrap.tsx const $56b436271f6666d1$var$HIDDEN_STYLES = { border: 0, clip: "rect(0 0 0 0)", height: "1px", margin: "-1px", overflow: "hidden", padding: 0, position: "fixed", whiteSpace: "nowrap", width: "1px", top: 0, left: 0 }; let $56b436271f6666d1$var$timeoutId; function $56b436271f6666d1$var$setActiveElementOnTab(event) { if (event.key === "Tab") { event.target; clearTimeout($56b436271f6666d1$var$timeoutId); } } const $56b436271f6666d1$var$FocusGuard = /*#__PURE__*/ $63SH6.forwardRef(function FocusGuard(props, ref) { const [role, setRole] = $63SH6.useState(); $56b436271f6666d1$var$index(()=>{ if ((0, $d8YHU.isSafari)()) // Unlike other screen readers such as NVDA and JAWS, the virtual cursor // on VoiceOver does trigger the onFocus event, so we can use the focus // trap element. On Safari, only buttons trigger the onFocus event. // NB: "group" role in the Sandbox no longer appears to work, must be a // button role. setRole("button"); document.addEventListener("keydown", $56b436271f6666d1$var$setActiveElementOnTab); return ()=>{ document.removeEventListener("keydown", $56b436271f6666d1$var$setActiveElementOnTab); }; }, []); const restProps = { ref: ref, tabIndex: 0, role: // Role is only for VoiceOver role, "aria-hidden": role ? undefined : true, [$56b436271f6666d1$var$createAttribute("focus-guard")]: "", style: $56b436271f6666d1$var$HIDDEN_STYLES }; return /*#__PURE__*/ $63SH6.createElement("span", $56b436271f6666d1$var$_extends({}, props, restProps)); }); const $56b436271f6666d1$var$PortalContext = /*#__PURE__*/ $63SH6.createContext(null); function $56b436271f6666d1$export$ac107512f3c5cca6(_temp) { let { id: id, root: root } = _temp === void 0 ? {} : _temp; const [portalNode, setPortalNode] = $63SH6.useState(null); const uniqueId = $56b436271f6666d1$export$f680877a34711e37(); const portalContext = $56b436271f6666d1$var$usePortalContext(); const data = $63SH6.useMemo(()=>({ id: id, root: root, portalContext: portalContext, uniqueId: uniqueId }), [ id, root, portalContext, uniqueId ]); const dataRef = $63SH6.useRef(); $56b436271f6666d1$var$index(()=>{ return ()=>{ portalNode == null || portalNode.remove(); }; }, [ portalNode, data ]); $56b436271f6666d1$var$index(()=>{ if (dataRef.current === data) return; dataRef.current = data; const { id: id, root: root, portalContext: portalContext, uniqueId: uniqueId } = data; const existingIdRoot = id ? document.getElementById(id) : null; const attr = $56b436271f6666d1$var$createAttribute("portal"); if (existingIdRoot) { const subRoot = document.createElement("div"); subRoot.id = uniqueId; subRoot.setAttribute(attr, ""); existingIdRoot.appendChild(subRoot); setPortalNode(subRoot); } else { let container = root || (portalContext == null ? void 0 : portalContext.portalNode); if (container && !(0, $8Xnp2.isElement)(container)) container = container.current; container = container || document.body; let idWrapper = null; if (id) { idWrapper = document.createElement("div"); idWrapper.id = id; container.appendChild(idWrapper); } const subRoot = document.createElement("div"); subRoot.id = uniqueId; subRoot.setAttribute(attr, ""); container = idWrapper || container; container.appendChild(subRoot); setPortalNode(subRoot); } }, [ data ]); return portalNode; } /** * Portals the floating element into a given container element — by default, * outside of the app root and into the body. * @see https://floating-ui.com/docs/FloatingPortal */ function $56b436271f6666d1$export$31fa5d718fa2ac09(_ref) { let { children: children, id: id, root: root = null, preserveTabOrder: preserveTabOrder = true } = _ref; const portalNode = $56b436271f6666d1$export$ac107512f3c5cca6({ id: id, root: root }); const [focusManagerState, setFocusManagerState] = $63SH6.useState(null); const beforeOutsideRef = $63SH6.useRef(null); const afterOutsideRef = $63SH6.useRef(null); const beforeInsideRef = $63SH6.useRef(null); const afterInsideRef = $63SH6.useRef(null); const shouldRenderGuards = // The FocusManager and therefore floating element are currently open/ // rendered. !!focusManagerState && // Guards are only for non-modal focus management. !focusManagerState.modal && // Don't render if unmount is transitioning. focusManagerState.open && preserveTabOrder && !!(root || portalNode); // https://codesandbox.io/s/tabbable-portal-f4tng?file=/src/TabbablePortal.tsx $63SH6.useEffect(()=>{ if (!portalNode || !preserveTabOrder || focusManagerState != null && focusManagerState.modal) return; // Make sure elements inside the portal element are tabbable only when the // portal has already been focused, either by tabbing into a focus trap // element outside or using the mouse. function onFocus(event) { if (portalNode && $56b436271f6666d1$var$isOutsideEvent(event)) { const focusing = event.type === "focusin"; const manageFocus = focusing ? $56b436271f6666d1$var$enableFocusInside : $56b436271f6666d1$var$disableFocusInside; manageFocus(portalNode); } } // Listen to the event on the capture phase so they run before the focus // trap elements onFocus prop is called. portalNode.addEventListener("focusin", onFocus, true); portalNode.addEventListener("focusout", onFocus, true); return ()=>{ portalNode.removeEventListener("focusin", onFocus, true); portalNode.removeEventListener("focusout", onFocus, true); }; }, [ portalNode, preserveTabOrder, focusManagerState == null ? void 0 : focusManagerState.modal ]); return /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$var$PortalContext.Provider, { value: $63SH6.useMemo(()=>({ preserveTabOrder: preserveTabOrder, beforeOutsideRef: beforeOutsideRef, afterOutsideRef: afterOutsideRef, beforeInsideRef: beforeInsideRef, afterInsideRef: afterInsideRef, portalNode: portalNode, setFocusManagerState: setFocusManagerState }), [ preserveTabOrder, portalNode ]) }, shouldRenderGuards && portalNode && /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$var$FocusGuard, { "data-type": "outside", ref: beforeOutsideRef, onFocus: (event)=>{ if ($56b436271f6666d1$var$isOutsideEvent(event, portalNode)) { var _beforeInsideRef$curr; (_beforeInsideRef$curr = beforeInsideRef.current) == null || _beforeInsideRef$curr.focus(); } else { const prevTabbable = $56b436271f6666d1$var$getPreviousTabbable() || (focusManagerState == null ? void 0 : focusManagerState.refs.domReference.current); prevTabbable == null || prevTabbable.focus(); } } }), shouldRenderGuards && portalNode && /*#__PURE__*/ $63SH6.createElement("span", { "aria-owns": portalNode.id, style: $56b436271f6666d1$var$HIDDEN_STYLES }), portalNode && /*#__PURE__*/ (0, $grDIR.createPortal)(children, portalNode), shouldRenderGuards && portalNode && /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$var$FocusGuard, { "data-type": "outside", ref: afterOutsideRef, onFocus: (event)=>{ if ($56b436271f6666d1$var$isOutsideEvent(event, portalNode)) { var _afterInsideRef$curre; (_afterInsideRef$curre = afterInsideRef.current) == null || _afterInsideRef$curre.focus(); } else { const nextTabbable = $56b436271f6666d1$var$getNextTabbable() || (focusManagerState == null ? void 0 : focusManagerState.refs.domReference.current); nextTabbable == null || nextTabbable.focus(); (focusManagerState == null ? void 0 : focusManagerState.closeOnFocusOut) && (focusManagerState == null || focusManagerState.onOpenChange(false, event.nativeEvent)); } } })); } const $56b436271f6666d1$var$usePortalContext = ()=>$63SH6.useContext($56b436271f6666d1$var$PortalContext); const $56b436271f6666d1$var$VisuallyHiddenDismiss = /*#__PURE__*/ $63SH6.forwardRef(function VisuallyHiddenDismiss(props, ref) { return /*#__PURE__*/ $63SH6.createElement("button", $56b436271f6666d1$var$_extends({}, props, { type: "button", ref: ref, tabIndex: -1, style: $56b436271f6666d1$var$HIDDEN_STYLES })); }); /** * Provides focus management for the floating element. * @see https://floating-ui.com/docs/FloatingFocusManager */ function $56b436271f6666d1$export$8aeee49171ded61a(props) { const { context: context, children: children, disabled: disabled = false, order: order = [ "content" ], guards: _guards = true, initialFocus: initialFocus = 0, returnFocus: returnFocus = true, modal: originalModal = true, visuallyHiddenDismiss: visuallyHiddenDismiss = false, closeOnFocusOut: closeOnFocusOut = true } = props; const { open: open, refs: refs, nodeId: nodeId, onOpenChange: onOpenChange, events: events, dataRef: dataRef, elements: { domReference: domReference, floating: floating } } = context; const ignoreInitialFocus = typeof initialFocus === "number" && initialFocus < 0; // If the reference is a combobox and is typeable (e.g. input/textarea), // there are different focus semantics. The guards should not be rendered, but // aria-hidden should be applied to all nodes still. Further, the visually // hidden dismiss button should only appear at the end of the list, not the // start. const isUntrappedTypeableCombobox = (domReference == null ? void 0 : domReference.getAttribute("role")) === "combobox" && (0, $d8YHU.isTypeableElement)(domReference) && ignoreInitialFocus; const modal = isUntrappedTypeableCombobox ? false : originalModal; // Force the guards to be rendered if the `inert` attribute is not supported. const guards = $56b436271f6666d1$var$supportsInert() ? _guards : true; const orderRef = $56b436271f6666d1$var$useLatestRef(order); const initialFocusRef = $56b436271f6666d1$var$useLatestRef(initialFocus); const returnFocusRef = $56b436271f6666d1$var$useLatestRef(returnFocus); const tree = $56b436271f6666d1$export$db0c2a7c7a2a4f69(); const portalContext = $56b436271f6666d1$var$usePortalContext(); const startDismissButtonRef = $63SH6.useRef(null); const endDismissButtonRef = $63SH6.useRef(null); const preventReturnFocusRef = $63SH6.useRef(false); const previouslyFocusedElementRef = $63SH6.useRef(null); const isPointerDownRef = $63SH6.useRef(false); const isInsidePortal = portalContext != null; const getTabbableContent = $63SH6.useCallback(function(container) { if (container === void 0) container = floating; return container ? (0, $bqiJA.tabbable)(container, $56b436271f6666d1$var$getTabbableOptions()) : []; }, [ floating ]); const getTabbableElements = $63SH6.useCallback((container)=>{ const content = getTabbableContent(container); return orderRef.current.map((type)=>{ if (domReference && type === "reference") return domReference; if (floating && type === "floating") return floating; return content; }).filter(Boolean).flat(); }, [ domReference, floating, orderRef, getTabbableContent ]); $63SH6.useEffect(()=>{ if (disabled || !modal) return; function onKeyDown(event) { if (event.key === "Tab") { // The focus guards have nothing to focus, so we need to stop the event. if ((0, $d8YHU.contains)(floating, (0, $d8YHU.activeElement)((0, $d8YHU.getDocument)(floating))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) (0, $d8YHU.stopEvent)(event); const els = getTabbableElements(); const target = (0, $d8YHU.getTarget)(event); if (orderRef.current[0] === "reference" && target === domReference) { (0, $d8YHU.stopEvent)(event); if (event.shiftKey) $56b436271f6666d1$var$enqueueFocus(els[els.length - 1]); else $56b436271f6666d1$var$enqueueFocus(els[1]); } if (orderRef.current[1] === "floating" && target === floating && event.shiftKey) { (0, $d8YHU.stopEvent)(event); $56b436271f6666d1$var$enqueueFocus(els[0]); } } } const doc = (0, $d8YHU.getDocument)(floating); doc.addEventListener("keydown", onKeyDown); return ()=>{ doc.removeEventListener("keydown", onKeyDown); }; }, [ disabled, domReference, floating, modal, orderRef, refs, isUntrappedTypeableCombobox, getTabbableContent, getTabbableElements ]); $63SH6.useEffect(()=>{ if (disabled || !closeOnFocusOut) return; // In Safari, buttons lose focus when pressing them. function handlePointerDown() { isPointerDownRef.current = true; setTimeout(()=>{ isPointerDownRef.current = false; }); } function handleFocusOutside(event) { const relatedTarget = event.relatedTarget; queueMicrotask(()=>{ const movedToUnrelatedNode = !((0, $d8YHU.contains)(domReference, relatedTarget) || (0, $d8YHU.contains)(floating, relatedTarget) || (0, $d8YHU.contains)(relatedTarget, floating) || (0, $d8YHU.contains)(portalContext == null ? void 0 : portalContext.portalNode, relatedTarget) || relatedTarget != null && relatedTarget.hasAttribute($56b436271f6666d1$var$createAttribute("focus-guard")) || tree && ($56b436271f6666d1$var$getChildren(tree.nodesRef.current, nodeId).find((node)=>{ var _node$context, _node$context2; return (0, $d8YHU.contains)((_node$context = node.context) == null ? void 0 : _node$context.elements.floating, relatedTarget) || (0, $d8YHU.contains)((_node$context2 = node.context) == null ? void 0 : _node$context2.elements.domReference, relatedTarget); }) || $56b436271f6666d1$var$getAncestors(tree.nodesRef.current, nodeId).find((node)=>{ var _node$context3, _node$context4; return ((_node$context3 = node.context) == null ? void 0 : _node$context3.elements.floating) === relatedTarget || ((_node$context4 = node.context) == null ? void 0 : _node$context4.elements.domReference) === relatedTarget; }))); // Focus did not move inside the floating tree, and there are no tabbable // portal guards to handle closing. if (relatedTarget && movedToUnrelatedNode && !isPointerDownRef.current && // Fix React 18 Strict Mode returnFocus due to double rendering. relatedTarget !== previouslyFocusedElementRef.current) { preventReturnFocusRef.current = true; onOpenChange(false, event); } }); } if (floating && (0, $8Xnp2.isHTMLElement)(domReference)) { domReference.addEventListener("focusout", handleFocusOutside); domReference.addEventListener("pointerdown", handlePointerDown); !modal && floating.addEventListener("focusout", handleFocusOutside); return ()=>{ domReference.removeEventListener("focusout", handleFocusOutside); domReference.removeEventListener("pointerdown", handlePointerDown); !modal && floating.removeEventListener("focusout", handleFocusOutside); }; } }, [ disabled, domReference, floating, modal, nodeId, tree, portalContext, onOpenChange, closeOnFocusOut ]); $63SH6.useEffect(()=>{ var _portalContext$portal; if (disabled) return; // Don't hide portals nested within the parent portal. const portalNodes = Array.from((portalContext == null ? void 0 : (_portalContext$portal = portalContext.portalNode) == null ? void 0 : _portalContext$portal.querySelectorAll("[" + $56b436271f6666d1$var$createAttribute("portal") + "]")) || []); if (floating) { const insideElements = [ floating, ...portalNodes, startDismissButtonRef.current, endDismissButtonRef.current, orderRef.current.includes("reference") || isUntrappedTypeableCombobox ? domReference : null ].filter((x)=>x != null); const cleanup = originalModal || isUntrappedTypeableCombobox ? $56b436271f6666d1$var$markOthers(insideElements, guards, !guards) : $56b436271f6666d1$var$markOthers(insideElements); return ()=>{ cleanup(); }; } }, [ disabled, domReference, floating, originalModal, orderRef, portalContext, isUntrappedTypeableCombobox, guards ]); $56b436271f6666d1$var$index(()=>{ if (disabled || !floating) return; const doc = (0, $d8YHU.getDocument)(floating); const previouslyFocusedElement = (0, $d8YHU.activeElement)(doc); // Wait for any layout effect state setters to execute to set `tabIndex`. queueMicrotask(()=>{ const focusableElements = getTabbableElements(floating); const initialFocusValue = initialFocusRef.current; const elToFocus = (typeof initialFocusValue === "number" ? focusableElements[initialFocusValue] : initialFocusValue.current) || floating; const focusAlreadyInsideFloatingEl = (0, $d8YHU.contains)(floating, previouslyFocusedElement); if (!ignoreInitialFocus && !focusAlreadyInsideFloatingEl && open) $56b436271f6666d1$var$enqueueFocus(elToFocus, { preventScroll: elToFocus === floating }); }); }, [ disabled, open, floating, ignoreInitialFocus, getTabbableElements, initialFocusRef ]); $56b436271f6666d1$var$index(()=>{ if (disabled || !floating) return; let preventReturnFocusScroll = false; const doc = (0, $d8YHU.getDocument)(floating); const previouslyFocusedElement = (0, $d8YHU.activeElement)(doc); const contextData = dataRef.current; previouslyFocusedElementRef.current = previouslyFocusedElement; // Dismissing via outside press should always ignore `returnFocus` to // prevent unwanted scrolling. function onDismiss(payload) { if (payload.type === "escapeKey" && refs.domReference.current) previouslyFocusedElementRef.current = refs.domReference.current; if ([ "referencePress", "escapeKey" ].includes(payload.type)) return; const returnFocus = payload.data.returnFocus; if (typeof returnFocus === "object") { preventReturnFocusRef.current = false; preventReturnFocusScroll = returnFocus.preventScroll; } else preventReturnFocusRef.current = !returnFocus; } events.on("dismiss", onDismiss); return ()=>{ events.off("dismiss", onDismiss); const activeEl = (0, $d8YHU.activeElement)(doc); const shouldFocusReference = (0, $d8YHU.contains)(floating, activeEl) || tree && $56b436271f6666d1$var$getChildren(tree.nodesRef.current, nodeId).some((node)=>{ var _node$context5; return (0, $d8YHU.contains)((_node$context5 = node.context) == null ? void 0 : _node$context5.elements.floating, activeEl); }) || contextData.openEvent && [ "click", "mousedown" ].includes(contextData.openEvent.type); if (shouldFocusReference && refs.domReference.current) previouslyFocusedElementRef.current = refs.domReference.current; if (// eslint-disable-next-line react-hooks/exhaustive-deps returnFocusRef.current && (0, $8Xnp2.isHTMLElement)(previouslyFocusedElementRef.current) && !preventReturnFocusRef.current) $56b436271f6666d1$var$enqueueFocus(previouslyFocusedElementRef.current, { // When dismissing nested floating elements, by the time the rAF has // executed, the menus will all have been unmounted. When they try // to get focused, the calls get ignored — leaving the root // reference focused as desired. cancelPrevious: false, preventScroll: preventReturnFocusScroll }); }; }, [ disabled, floating, returnFocusRef, dataRef, refs, events, tree, nodeId ]); // Synchronize the `context` & `modal` value to the FloatingPortal context. // It will decide whether or not it needs to render its own guards. $56b436271f6666d1$var$index(()=>{ if (disabled || !portalContext) return; portalContext.setFocusManagerState({ modal: modal, closeOnFocusOut: closeOnFocusOut, open: open, onOpenChange: onOpenChange, refs: refs }); return ()=>{ portalContext.setFocusManagerState(null); }; }, [ disabled, portalContext, modal, open, onOpenChange, refs, closeOnFocusOut ]); $56b436271f6666d1$var$index(()=>{ if (disabled || !floating || typeof MutationObserver !== "function" || ignoreInitialFocus) return; const handleMutation = ()=>{ const tabIndex = floating.getAttribute("tabindex"); if (orderRef.current.includes("floating") || (0, $d8YHU.activeElement)((0, $d8YHU.getDocument)(floating)) !== refs.domReference.current && getTabbableContent().length === 0) { if (tabIndex !== "0") floating.setAttribute("tabindex", "0"); } else if (tabIndex !== "-1") floating.setAttribute("tabindex", "-1"); }; handleMutation(); const observer = new MutationObserver(handleMutation); observer.observe(floating, { childList: true, subtree: true, attributes: true }); return ()=>{ observer.disconnect(); }; }, [ disabled, floating, refs, orderRef, getTabbableContent, ignoreInitialFocus ]); function renderDismissButton(location) { if (disabled || !visuallyHiddenDismiss || !modal) return null; return /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$var$VisuallyHiddenDismiss, { ref: location === "start" ? startDismissButtonRef : endDismissButtonRef, onClick: (event)=>onOpenChange(false, event.nativeEvent) }, typeof visuallyHiddenDismiss === "string" ? visuallyHiddenDismiss : "Dismiss"); } const shouldRenderGuards = !disabled && guards && (isInsidePortal || modal); return /*#__PURE__*/ $63SH6.createElement($63SH6.Fragment, null, shouldRenderGuards && /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$var$FocusGuard, { "data-type": "inside", ref: portalContext == null ? void 0 : portalContext.beforeInsideRef, onFocus: (event)=>{ if (modal) { const els = getTabbableElements(); $56b436271f6666d1$var$enqueueFocus(order[0] === "reference" ? els[0] : els[els.length - 1]); } else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) { preventReturnFocusRef.current = false; if ($56b436271f6666d1$var$isOutsideEvent(event, portalContext.portalNode)) { const nextTabbable = $56b436271f6666d1$var$getNextTabbable() || domReference; nextTabbable == null || nextTabbable.focus(); } else { var _portalContext$before; (_portalContext$before = portalContext.beforeOutsideRef.current) == null || _portalContext$before.focus(); } } } }), !isUntrappedTypeableCombobox && renderDismissButton("start"), children, renderDismissButton("end"), shouldRenderGuards && /*#__PURE__*/ $63SH6.createElement($56b436271f6666d1$var$FocusGuard, { "data-type": "inside", ref: portalContext == null ? void 0 : portalContext.afterInsideRef, onFocus: (event)=>{ if (modal) $56b436271f6666d1$var$enqueueFocus(getTabbableElements()[0]); else if (portalContext != null && portalContext.preserveTabOrder && portalContext.portalNode) { if (closeOnFocusOut) preventReturnFocusRef.current = true; if ($56b436271f6666d1$var$isOutsideEvent(event, portalContext.portalNode)) { const prevTabbable = $56b436271f6666d1$var$getPreviousTabbable() || domReference; prevTabbable == null || prevTabbable.focus(); } else { var _portalContext$afterO; (_portalContext$afterO = portalContext.afterOutsideRef.current) == null || _portalContext$afterO.focus(); } } } })); } const $56b436271f6666d1$var$activeLocks = /*#__PURE__*/ new Set(); /** * Provides base styling for a fixed overlay element to dim content or block * pointer events behind a floating element. * It's a regular `
`, so it can be styled via any CSS solution you prefer. * @see https://floating-ui.com/docs/FloatingOverlay */ const $56b436271f6666d1$export$a35954495955337b = /*#__PURE__*/ $63SH6.forwardRef(function FloatingOverlay(_ref, ref) { let { lockScroll: lockScroll = false, ...rest } = _ref; const lockId = $56b436271f6666d1$export$f680877a34711e37(); $56b436271f6666d1$var$index(()=>{ if (!lockScroll) return; $56b436271f6666d1$var$activeLocks.add(lockId); const isIOS = /iP(hone|ad|od)|iOS/.test((0, $d8YHU.getPlatform)()); const bodyStyle = document.body.style; // RTL scrollbar const scrollbarX = Math.round(document.documentElement.getBoundingClientRect().left) + document.documentElement.scrollLeft; const paddingProp = scrollbarX ? "paddingLeft" : "paddingRight"; const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth; const scrollX = bodyStyle.left ? parseFloat(bodyStyle.left) : window.pageXOffset; const scrollY = bodyStyle.top ? parseFloat(bodyStyle.top) : window.pageYOffset; bodyStyle.overflow = "hidden"; if (scrollbarWidth) bodyStyle[paddingProp] = scrollbarWidth + "px"; // Only iOS doesn't respect `overflow: hidden` on document.body, and this // technique has fewer side effects. if (isIOS) { var _window$visualViewpor, _window$visualViewpor2; // iOS 12 does not support `visualViewport`. const offsetLeft = ((_window$visualViewpor = window.visualViewport) == null ? void 0 : _window$visualViewpor.offsetLeft) || 0; const offsetTop = ((_window$visualViewpor2 = window.visualViewport) == null ? void 0 : _window$visualViewpor2.offsetTop) || 0; Object.assign(bodyStyle, { position: "fixed", top: -(scrollY - Math.floor(offsetTop)) + "px", left: -(scrollX - Math.floor(offsetLeft)) + "px", right: "0" }); } return ()=>{ $56b436271f6666d1$var$activeLocks.delete(lockId); if ($56b436271f6666d1$var$activeLocks.size === 0) { Object.assign(bodyStyle, { overflow: "", [paddingProp]: "" }); if (isIOS) { Object.assign(bodyStyle, { position: "", top: "", left: "", right: "" }); window.scrollTo(scrollX, scrollY); } } }; }, [ lockId, lockScroll ]); return /*#__PURE__*/ $63SH6.createElement("div", $56b436271f6666d1$var$_extends({ ref: ref }, rest, { style: { position: "fixed", overflow: "auto", top: 0, right: 0, bottom: 0, left: 0, ...rest.style } })); }); function $56b436271f6666d1$var$isButtonTarget(event) { return (0, $8Xnp2.isHTMLElement)(event.target) && event.target.tagName === "BUTTON"; } function $56b436271f6666d1$var$isSpaceIgnored(element) { return (0, $d8YHU.isTypeableElement)(element); } /** * Opens or closes the floating element when clicking the reference element. * @see https://floating-ui.com/docs/useClick */ function $56b436271f6666d1$export$98524f11226063fc(context, props) { if (props === void 0) props = {}; const { open: open, onOpenChange: onOpenChange, dataRef: dataRef, elements: { domReference: domReference } } = context; const { enabled: enabled = true, event: eventOption = "click", toggle: toggle = true, ignoreMouse: ignoreMouse = false, keyboardHandlers: keyboardHandlers = true } = props; const pointerTypeRef = $63SH6.useRef(); const didKeyDownRef = $63SH6.useRef(false); return $63SH6.useMemo(()=>{ if (!enabled) return {}; return { reference: { onPointerDown (event) { pointerTypeRef.current = event.pointerType; }, onMouseDown (event) { // Ignore all buttons except for the "main" button. // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button if (event.button !== 0) return; if ((0, $d8YHU.isMouseLikePointerType)(pointerTypeRef.current, true) && ignoreMouse) return; if (eventOption === "click") return; if (open && toggle && (dataRef.current.openEvent ? dataRef.current.openEvent.type === "mousedown" : true)) onOpenChange(false, event.nativeEvent); else { // Prevent stealing focus from the floating element event.preventDefault(); onOpenChange(true, event.nativeEvent); } }, onClick (event) { if (eventOption === "mousedown" && pointerTypeRef.current) { pointerTypeRef.current = undefined; return; } if ((0, $d8YHU.isMouseLikePointerType)(pointerTypeRef.current, true) && ignoreMouse) return; if (open && toggle && (dataRef.current.openEvent ? dataRef.current.openEvent.type === "click" : true)) onOpenChange(false, event.nativeEvent); else onOpenChange(true, event.nativeEvent); }, onKeyDown (event) { pointerTypeRef.current = undefined; if (event.defaultPrevented || !keyboardHandlers || $56b436271f6666d1$var$isButtonTarget(event)) return; if (event.key === " " && !$56b436271f6666d1$var$isSpaceIgnored(domReference)) { // Prevent scrolling event.preventDefault(); didKeyDownRef.current = true; } if (event.key === "Enter") { if (open && toggle) onOpenChange(false, event.nativeEvent); else onOpenChange(true, event.nativeEvent); } }, onKeyUp (event) { if (event.defaultPrevented || !keyboardHandlers || $56b436271f6666d1$var$isButtonTarget(event) || $56b436271f6666d1$var$isSpaceIgnored(domReference)) return; if (event.key === " " && didKeyDownRef.current) { didKeyDownRef.current = false; if (open && toggle) onOpenChange(false, event.nativeEvent); else onOpenChange(true, event.nativeEvent); } } } }; }, [ enabled, dataRef, eventOption, ignoreMouse, keyboardHandlers, domReference, toggle, open, onOpenChange ]); } function $56b436271f6666d1$var$createVirtualElement(domRef, data) { let offsetX = null; let offsetY = null; let isAutoUpdateEvent = false; return { contextElement: domRef.current || undefined, getBoundingClientRect () { var _domRef$current, _data$dataRef$current; const domRect = ((_domRef$current = domRef.current) == null ? void 0 : _domRef$current.getBoundingClientRect()) || { width: 0, height: 0, x: 0, y: 0 }; const isXAxis = data.axis === "x" || data.axis === "both"; const isYAxis = data.axis === "y" || data.axis === "both"; const canTrackCursorOnAutoUpdate = [ "mouseenter", "mousemove" ].includes(((_data$dataRef$current = data.dataRef.current.openEvent) == null ? void 0 : _data$dataRef$current.type) || "") && data.pointerType !== "touch"; let width = domRect.width; let height = domRect.height; let x = domRect.x; let y = domRect.y; if (offsetX == null && data.x && isXAxis) offsetX = domRect.x - data.x; if (offsetY == null && data.y && isYAxis) offsetY = domRect.y - data.y; x -= offsetX || 0; y -= offsetY || 0; width = 0; height = 0; if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) { width = data.axis === "y" ? domRect.width : 0; height = data.axis === "x" ? domRect.height : 0; x = isXAxis && data.x != null ? data.x : x; y = isYAxis && data.y != null ? data.y : y; } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) { height = data.axis === "x" ? domRect.height : height; width = data.axis === "y" ? domRect.width : width; } isAutoUpdateEvent = true; return { width: width, height: height, x: x, y: y, top: y, right: x + width, bottom: y + height, left: x }; } }; } function $56b436271f6666d1$var$isMouseBasedEvent(event) { return event != null && event.clientX != null; } /** * Positions the floating element relative to a client point (in the viewport), * such as the mouse position. By default, it follows the mouse cursor. * @see https://floating-ui.com/docs/useClientPoint */ function $56b436271f6666d1$export$7fe170a73a621816(context, props) { if (props === void 0) props = {}; const { open: open, refs: refs, dataRef: dataRef, elements: { floating: floating } } = context; const { enabled: enabled = true, axis: axis = "both", x: x = null, y: y = null } = props; const initialRef = $63SH6.useRef(false); const cleanupListenerRef = $63SH6.useRef(null); const [pointerType, setPointerType] = $63SH6.useState(); const [reactive, setReactive] = $63SH6.useState([]); const setReference = $56b436271f6666d1$var$useEffectEvent((x, y)=>{ if (initialRef.current) return; // Prevent setting if the open event was not a mouse-like one // (e.g. focus to open, then hover over the reference element). // Only apply if the event exists. if (dataRef.current.openEvent && !$56b436271f6666d1$var$isMouseBasedEvent(dataRef.current.openEvent)) return; refs.setPositionReference($56b436271f6666d1$var$createVirtualElement(refs.domReference, { x: x, y: y, axis: axis, dataRef: dataRef, pointerType: pointerType })); }); const handleReferenceEnterOrMove = $56b436271f6666d1$var$useEffectEvent((event)=>{ if (x != null || y != null) return; if (!open) setReference(event.clientX, event.clientY); else if (!cleanupListenerRef.current) // If there's no cleanup, there's no listener, but we want to ensure // we add the listener if the cursor landed on the floating element and // then back on the reference (i.e. it's interactive). setReactive([]); }); // If the pointer is a mouse-like pointer, we want to continue following the // mouse even if the floating element is transitioning out. On touch // devices, this is undesirable because the floating element will move to // the dismissal touch point. const openCheck = (0, $d8YHU.isMouseLikePointerType)(pointerType) ? floating : open; const addListener = $63SH6.useCallback(()=>{ // Explicitly specified `x`/`y` coordinates shouldn't add a listener. if (!openCheck || !enabled || x != null || y != null) return; const win = (0, $8Xnp2.getWindow)(refs.floating.current); function handleMouseMove(event) { const target = (0, $d8YHU.getTarget)(event); if (!(0, $d8YHU.contains)(refs.floating.current, target)) setReference(event.clientX, event.clientY); else { win.removeEventListener("mousemove", handleMouseMove); cleanupListenerRef.current = null; } } if (!dataRef.current.openEvent || $56b436271f6666d1$var$isMouseBasedEvent(dataRef.current.openEvent)) { win.addEventListener("mousemove", handleMouseMove); const cleanup = ()=>{ win.removeEventListener("mousemove", handleMouseMove); cleanupListenerRef.current = null; }; cleanupListenerRef.current = cleanup; return cleanup; } refs.setPositionReference(refs.domReference.current); }, [ dataRef, enabled, openCheck, refs, setReference, x, y ]); $63SH6.useEffect(()=>{ return addListener(); }, [ addListener, reactive ]); $63SH6.useEffect(()=>{ if (enabled && !floating) initialRef.current = false; }, [ enabled, floating ]); $63SH6.useEffect(()=>{ if (!enabled && open) initialRef.current = true; }, [ enabled, open ]); $56b436271f6666d1$var$index(()=>{ if (enabled && (x != null || y != null)) { initialRef.current = false; setReference(x, y); } }, [ enabled, x, y, setReference ]); return $63SH6.useMemo(()=>{ if (!enabled) return {}; function setPointerTypeRef(_ref) { let { pointerType: pointerType } = _ref; setPointerType(pointerType); } return { reference: { onPointerDown: setPointerTypeRef, onPointerEnter: setPointerTypeRef, onMouseMove: handleReferenceEnterOrMove, onMouseEnter: handleReferenceEnterOrMove } }; }, [ enabled, handleReferenceEnterOrMove ]); } const $56b436271f6666d1$var$bubbleHandlerKeys = { pointerdown: "onPointerDown", mousedown: "onMouseDown", click: "onClick" }; const $56b436271f6666d1$var$captureHandlerKeys = { pointerdown: "onPointerDownCapture", mousedown: "onMouseDownCapture", click: "onClickCapture" }; const $56b436271f6666d1$var$normalizeProp = (normalizable)=>{ var _normalizable$escapeK, _normalizable$outside; return { escapeKey: typeof normalizable === "boolean" ? normalizable : (_normalizable$escapeK = normalizable == null ? void 0 : normalizable.escapeKey) != null ? _normalizable$escapeK : false, outsidePress: typeof normalizable === "boolean" ? normalizable : (_normalizable$outside = normalizable == null ? void 0 : normalizable.outsidePress) != null ? _normalizable$outside : true }; }; /** * Closes the floating element when a dismissal is requested — by default, when * the user presses the `escape` key or outside of the floating element. * @see https://floating-ui.com/docs/useDismiss */ function $56b436271f6666d1$export$fcdf1ba5fafc089b(context, props) { if (props === void 0) props = {}; const { open: open, onOpenChange: onOpenChange, events: events, nodeId: nodeId, elements: { reference: reference, domReference: domReference, floating: floating }, dataRef: dataRef } = context; const { enabled: enabled = true, escapeKey: escapeKey = true, outsidePress: unstable_outsidePress = true, outsidePressEvent: outsidePressEvent = "pointerdown", referencePress: referencePress = false, referencePressEvent: referencePressEvent = "pointerdown", ancestorScroll: ancestorScroll = false, bubbles: bubbles, capture: capture } = props; const tree = $56b436271f6666d1$export$db0c2a7c7a2a4f69(); const nested = $56b436271f6666d1$export$165209eae06d3488() != null; const outsidePressFn = $56b436271f6666d1$var$useEffectEvent(typeof unstable_outsidePress === "function" ? unstable_outsidePress : ()=>false); const outsidePress = typeof unstable_outsidePress === "function" ? outsidePressFn : unstable_outsidePress; const insideReactTreeRef = $63SH6.useRef(false); const endedOrStartedInsideRef = $63SH6.useRef(false); const { escapeKey: escapeKeyBubbles, outsidePress: outsidePressBubbles } = $56b436271f6666d1$var$normalizeProp(bubbles); const { escapeKey: escapeKeyCapture, outsidePress: outsidePressCapture } = $56b436271f6666d1$var$normalizeProp(capture); const closeOnEscapeKeyDown = $56b436271f6666d1$var$useEffectEvent((event)=>{ if (!open || !enabled || !escapeKey || event.key !== "Escape") return; const children = tree ? $56b436271f6666d1$var$getChildren(tree.nodesRef.current, nodeId) : []; if (!escapeKeyBubbles) { event.stopPropagation(); if (children.length > 0) { let shouldDismiss = true; children.forEach((child)=>{ var _child$context; if ((_child$context = child.context) != null && _child$context.open && !child.context.dataRef.current.__escapeKeyBubbles) { shouldDismiss = false; return; } }); if (!shouldDismiss) return; } } events.emit("dismiss", { type: "escapeKey", data: { returnFocus: { preventScroll: false } } }); onOpenChange(false, (0, $d8YHU.isReactEvent)(event) ? event.nativeEvent : event); }); const closeOnEscapeKeyDownCapture = $56b436271f6666d1$var$useEffectEvent((event)=>{ var _getTarget2; const callback = ()=>{ var _getTarget; closeOnEscapeKeyDown(event); (_getTarget = (0, $d8YHU.getTarget)(event)) == null || _getTarget.removeEventListener("keydown", callback); }; (_getTarget2 = (0, $d8YHU.getTarget)(event)) == null || _getTarget2.addEventListener("keydown", callback); }); const closeOnPressOutside = $56b436271f6666d1$var$useEffectEvent((event)=>{ // Given developers can stop the propagation of the synthetic event, // we can only be confident with a positive value. const insideReactTree = insideReactTreeRef.current; insideReactTreeRef.current = false; // When click outside is lazy (`click` event), handle dragging. // Don't close if: // - The click started inside the floating element. // - The click ended inside the floating element. const endedOrStartedInside = endedOrStartedInsideRef.current; endedOrStartedInsideRef.current = false; if (outsidePressEvent === "click" && endedOrStartedInside) return; if (insideReactTree) return; if (typeof outsidePress === "function" && !outsidePress(event)) return; const target = (0, $d8YHU.getTarget)(event); const inertSelector = "[" + $56b436271f6666d1$var$createAttribute("inert") + "]"; const markers = (0, $d8YHU.getDocument)(floating).querySelectorAll(inertSelector); let targetRootAncestor = (0, $8Xnp2.isElement)(target) ? target : null; while(targetRootAncestor && !(0, $8Xnp2.isLastTraversableNode)(targetRootAncestor)){ const nextParent = (0, $8Xnp2.getParentNode)(targetRootAncestor); if (nextParent === (0, $d8YHU.getDocument)(floating).body || !(0, $8Xnp2.isElement)(nextParent)) break; else targetRootAncestor = nextParent; } // Check if the click occurred on a third-party element injected after the // floating element rendered. if (markers.length && (0, $8Xnp2.isElement)(target) && !(0, $d8YHU.isRootElement)(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay). !(0, $d8YHU.contains)(target, floating) && // If the target root element contains none of the markers, then the // element was injected after the floating element rendered. Array.from(markers).every((marker)=>!(0, $d8YHU.contains)(targetRootAncestor, marker))) return; // Check if the click occurred on the scrollbar if ((0, $8Xnp2.isHTMLElement)(target) && floating) { // In Firefox, `target.scrollWidth > target.clientWidth` for inline // elements. const canScrollX = target.clientWidth > 0 && target.scrollWidth > target.clientWidth; const canScrollY = target.clientHeight > 0 && target.scrollHeight > target.clientHeight; let xCond = canScrollY && event.offsetX > target.clientWidth; // In some browsers it is possible to change the (or window) // scrollbar to the left side, but is very rare and is difficult to // check for. Plus, for modal dialogs with backdrops, it is more // important that the backdrop is checked but not so much the window. if (canScrollY) { const isRTL = (0, $8Xnp2.getComputedStyle)(target).direction === "rtl"; if (isRTL) xCond = event.offsetX <= target.offsetWidth - target.clientWidth; } if (xCond || canScrollX && event.offsetY > target.clientHeight) return; } const targetIsInsideChildren = tree && $56b436271f6666d1$var$getChildren(tree.nodesRef.current, nodeId).some((node)=>{ var _node$context; return (0, $d8YHU.isEventTargetWithin)(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating); }); if ((0, $d8YHU.isEventTargetWithin)(event, floating) || (0, $d8YHU.isEventTargetWithin)(event, domReference) || targetIsInsideChildren) return; const children = tree ? $56b436271f6666d1$var$getChildren(tree.nodesRef.current, nodeId) : []; if (children.length > 0) { let shouldDismiss = true; children.forEach((child)=>{ var _child$context2; if ((_child$context2 = child.context) != null && _child$context2.open && !child.context.dataRef.current.__outsidePressBubbles) { shouldDismiss = false; return; } }); if (!shouldDismiss) return; } events.emit("dismiss", { type: "outsidePress", data: { returnFocus: nested ? { preventScroll: true } : (0, $d8YHU.isVirtualClick)(event) || (0, $d8YHU.isVirtualPointerEvent)(event) } }); onOpenChange(false, event); }); const closeOnPressOutsideCapture = $56b436271f6666d1$var$useEffectEvent((event)=>{ var _getTarget4; const callback = ()=>{ var _getTarget3; closeOnPressOutside(event); (_getTarget3 = (0, $d8YHU.getTarget)(event)) == null || _getTarget3.removeEventListener(outsidePressEvent, callback); }; (_getTarget4 = (0, $d8YHU.getTarget)(event)) == null || _getTarget4.addEventListener(outsidePressEvent, callback); }); $63SH6.useEffect(()=>{ if (!open || !enabled) return; dataRef.current.__escapeKeyBubbles = escapeKeyBubbles; dataRef.current.__outsidePressBubbles = outsidePressBubbles; function onScroll(event) { onOpenChange(false, event); } const doc = (0, $d8YHU.getDocument)(floating); escapeKey && doc.addEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture); outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture); let ancestors = []; if (ancestorScroll) { if ((0, $8Xnp2.isElement)(domReference)) ancestors = (0, $8Xnp2.getOverflowAncestors)(domReference); if ((0, $8Xnp2.isElement)(floating)) ancestors = ancestors.concat((0, $8Xnp2.getOverflowAncestors)(floating)); if (!(0, $8Xnp2.isElement)(reference) && reference && reference.contextElement) ancestors = ancestors.concat((0, $8Xnp2.getOverflowAncestors)(reference.contextElement)); } // Ignore the visual viewport for scrolling dismissal (allow pinch-zoom) ancestors = ancestors.filter((ancestor)=>{ var _doc$defaultView; return ancestor !== ((_doc$defaultView = doc.defaultView) == null ? void 0 : _doc$defaultView.visualViewport); }); ancestors.forEach((ancestor)=>{ ancestor.addEventListener("scroll", onScroll, { passive: true }); }); return ()=>{ escapeKey && doc.removeEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture); outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture); ancestors.forEach((ancestor)=>{ ancestor.removeEventListener("scroll", onScroll); }); }; }, [ dataRef, floating, domReference, reference, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture ]); $63SH6.useEffect(()=>{ insideReactTreeRef.current = false; }, [ outsidePress, outsidePressEvent ]); return $63SH6.useMemo(()=>{ if (!enabled) return {}; return { reference: { onKeyDown: closeOnEscapeKeyDown, [$56b436271f6666d1$var$bubbleHandlerKeys[referencePressEvent]]: (event)=>{ if (referencePress) { events.emit("dismiss", { type: "referencePress", data: { returnFocus: false } }); onOpenChange(false, event.nativeEvent); } } }, floating: { onKeyDown: closeOnEscapeKeyDown, onMouseDown () { endedOrStartedInsideRef.current = true; }, onMouseUp () { endedOrStartedInsideRef.current = true; }, [$56b436271f6666d1$var$captureHandlerKeys[outsidePressEvent]]: ()=>{ insideReactTreeRef.current = true; } } }; }, [ enabled, events, referencePress, outsidePressEvent, referencePressEvent, onOpenChange, closeOnEscapeKeyDown ]); } let $56b436271f6666d1$var$devMessageSet; /** * Provides data to position a floating element and context to add interactions. * @see https://floating-ui.com/docs/react */ function $56b436271f6666d1$export$4e02a5c1d08bac65(options) { var _options$elements2; if (options === void 0) options = {}; const { open: open = false, onOpenChange: unstable_onOpenChange, nodeId: nodeId } = options; var _options$elements, _devMessageSet, _devMessageSet2; const [_domReference, setDomReference] = $63SH6.useState(null); const domReference = ((_options$elements2 = options.elements) == null ? void 0 : _options$elements2.reference) || _domReference; const position = (0, $2Dcmu.useFloating)(options); const tree = $56b436271f6666d1$export$db0c2a7c7a2a4f69(); const onOpenChange = $56b436271f6666d1$var$useEffectEvent((open, event)=>{ if (open) dataRef.current.openEvent = event; unstable_onOpenChange == null || unstable_onOpenChange(open, event); }); const domReferenceRef = $63SH6.useRef(null); const dataRef = $63SH6.useRef({}); const events = $63SH6.useState(()=>$56b436271f6666d1$var$createPubSub())[0]; const floatingId = $56b436271f6666d1$export$f680877a34711e37(); const setPositionReference = $63SH6.useCallback((node)=>{ const positionReference = (0, $8Xnp2.isElement)(node) ? { getBoundingClientRect: ()=>node.getBoundingClientRect(), contextElement: node } : node; position.refs.setReference(positionReference); }, [ position.refs ]); const setReference = $63SH6.useCallback((node)=>{ if ((0, $8Xnp2.isElement)(node) || node === null) { domReferenceRef.current = node; setDomReference(node); } // Backwards-compatibility for passing a virtual element to `reference` // after it has set the DOM reference. if ((0, $8Xnp2.isElement)(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to // `null` to support `positionReference` + an unstable `reference` // callback ref. node !== null && !(0, $8Xnp2.isElement)(node)) position.refs.setReference(node); }, [ position.refs ]); const refs = $63SH6.useMemo(()=>({ ...position.refs, setReference: setReference, setPositionReference: setPositionReference, domReference: domReferenceRef }), [ position.refs, setReference, setPositionReference ]); const elements = $63SH6.useMemo(()=>({ ...position.elements, domReference: domReference }), [ position.elements, domReference ]); const context = $63SH6.useMemo(()=>({ ...position, refs: refs, elements: elements, dataRef: dataRef, nodeId: nodeId, floatingId: floatingId, events: events, open: open, onOpenChange: onOpenChange }), [ position, nodeId, floatingId, events, open, onOpenChange, refs, elements ]); $56b436271f6666d1$var$index(()=>{ const node = tree == null ? void 0 : tree.nodesRef.current.find((node)=>node.id === nodeId); if (node) node.context = context; }); return $63SH6.useMemo(()=>({ ...position, context: context, refs: refs, elements: elements }), [ position, refs, elements, context ]); } /** * Opens the floating element while the reference element has focus, like CSS * `:focus`. * @see https://floating-ui.com/docs/useFocus */ function $56b436271f6666d1$export$f8168d8dd8fd66e6(context, props) { if (props === void 0) props = {}; const { open: open, onOpenChange: onOpenChange, events: events, refs: refs, elements: { floating: floating, domReference: domReference } } = context; const { enabled: enabled = true, visibleOnly: visibleOnly = true } = props; const blockFocusRef = $63SH6.useRef(false); const timeoutRef = $63SH6.useRef(); const keyboardModalityRef = $63SH6.useRef(true); $63SH6.useEffect(()=>{ if (!enabled) return; const win = (0, $8Xnp2.getWindow)(domReference); // If the reference was focused and the user left the tab/window, and the // floating element was not open, the focus should be blocked when they // return to the tab/window. function onBlur() { if (!open && (0, $8Xnp2.isHTMLElement)(domReference) && domReference === (0, $d8YHU.activeElement)((0, $d8YHU.getDocument)(domReference))) blockFocusRef.current = true; } function onKeyDown() { keyboardModalityRef.current = true; } win.addEventListener("blur", onBlur); win.addEventListener("keydown", onKeyDown, true); return ()=>{ win.removeEventListener("blur", onBlur); win.removeEventListener("keydown", onKeyDown, true); }; }, [ floating, domReference, open, enabled ]); $63SH6.useEffect(()=>{ if (!enabled) return; function onDismiss(payload) { if (payload.type === "referencePress" || payload.type === "escapeKey") blockFocusRef.current = true; } events.on("dismiss", onDismiss); return ()=>{ events.off("dismiss", onDismiss); }; }, [ events, enabled ]); $63SH6.useEffect(()=>{ return ()=>{ clearTimeout(timeoutRef.current); }; }, []); return $63SH6.useMemo(()=>{ if (!enabled) return {}; return { reference: { onPointerDown (event) { if ((0, $d8YHU.isVirtualPointerEvent)(event.nativeEvent)) return; keyboardModalityRef.current = false; }, onMouseLeave () { blockFocusRef.current = false; }, onFocus (event) { if (blockFocusRef.current) return; const target = (0, $d8YHU.getTarget)(event.nativeEvent); if (visibleOnly && (0, $8Xnp2.isElement)(target)) try { // Mac Safari unreliably matches `:focus-visible` on the reference // if focus was outside the page initially - use the fallback // instead. if ((0, $d8YHU.isSafari)() && (0, $d8YHU.isMac)()) throw Error(); if (!target.matches(":focus-visible")) return; } catch (e) { // Old browsers will throw an error when using `:focus-visible`. if (!keyboardModalityRef.current && !(0, $d8YHU.isTypeableElement)(target)) return; } onOpenChange(true, event.nativeEvent); }, onBlur (event) { blockFocusRef.current = false; const relatedTarget = event.relatedTarget; // Hit the non-modal focus management portal guard. Focus will be // moved into the floating element immediately after. const movedToFocusGuard = (0, $8Xnp2.isElement)(relatedTarget) && relatedTarget.hasAttribute($56b436271f6666d1$var$createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside"; // Wait for the window blur listener to fire. timeoutRef.current = window.setTimeout(()=>{ const activeEl = (0, $d8YHU.activeElement)(domReference ? domReference.ownerDocument : document); // Focus left the page, keep it open. if (!relatedTarget && activeEl === domReference) return; // When focusing the reference element (e.g. regular click), then // clicking into the floating element, prevent it from hiding. // Note: it must be focusable, e.g. `tabindex="-1"`. if ((0, $d8YHU.contains)(refs.floating.current, relatedTarget) || (0, $d8YHU.contains)(domReference, relatedTarget) || movedToFocusGuard) return; onOpenChange(false, event.nativeEvent); }); } } }; }, [ enabled, visibleOnly, domReference, refs, onOpenChange ]); } function $56b436271f6666d1$var$mergeProps(userProps, propsList, elementKey) { const map = new Map(); return { ...elementKey === "floating" && { tabIndex: -1 }, ...userProps, ...propsList.map((value)=>value ? value[elementKey] : null).concat(userProps).reduce((acc, props)=>{ if (!props) return acc; Object.entries(props).forEach((_ref)=>{ let [key, value] = _ref; if (key.indexOf("on") === 0) { if (!map.has(key)) map.set(key, []); if (typeof value === "function") { var _map$get; (_map$get = map.get(key)) == null || _map$get.push(value); acc[key] = function() { var _map$get2; for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)args[_key] = arguments[_key]; return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map((fn)=>fn(...args)).find((val)=>val !== undefined); }; } } else acc[key] = value; }); return acc; }, {}) }; } /** * Merges an array of interaction hooks' props into prop getters, allowing * event handler functions to be composed together without overwriting one * another. * @see https://floating-ui.com/docs/react#interaction-hooks */ function $56b436271f6666d1$export$a519f7794e446ddd(propsList) { if (propsList === void 0) propsList = []; // The dependencies are a dynamic array, so we can't use the linter's // suggestion to add it to the deps array. const deps = propsList; const getReferenceProps = $63SH6.useCallback((userProps)=>$56b436271f6666d1$var$mergeProps(userProps, propsList, "reference"), // eslint-disable-next-line react-hooks/exhaustive-deps deps); const getFloatingProps = $63SH6.useCallback((userProps)=>$56b436271f6666d1$var$mergeProps(userProps, propsList, "floating"), // eslint-disable-next-line react-hooks/exhaustive-deps deps); const getItemProps = $63SH6.useCallback((userProps)=>$56b436271f6666d1$var$mergeProps(userProps, propsList, "item"), // Granularly check for `item` changes, because the `getItemProps` getter // should be as referentially stable as possible since it may be passed as // a prop to many components. All `item` key values must therefore be // memoized. // eslint-disable-next-line react-hooks/exhaustive-deps propsList.map((key)=>key == null ? void 0 : key.item)); return $63SH6.useMemo(()=>({ getReferenceProps: getReferenceProps, getFloatingProps: getFloatingProps, getItemProps: getItemProps }), [ getReferenceProps, getFloatingProps, getItemProps ]); } let $56b436271f6666d1$var$isPreventScrollSupported = false; function $56b436271f6666d1$var$doSwitch(orientation, vertical, horizontal) { switch(orientation){ case "vertical": return vertical; case "horizontal": return horizontal; default: return vertical || horizontal; } } function $56b436271f6666d1$var$isMainOrientationKey(key, orientation) { const vertical = key === $56b436271f6666d1$var$ARROW_UP || key === $56b436271f6666d1$var$ARROW_DOWN; const horizontal = key === $56b436271f6666d1$var$ARROW_LEFT || key === $56b436271f6666d1$var$ARROW_RIGHT; return $56b436271f6666d1$var$doSwitch(orientation, vertical, horizontal); } function $56b436271f6666d1$var$isMainOrientationToEndKey(key, orientation, rtl) { const vertical = key === $56b436271f6666d1$var$ARROW_DOWN; const horizontal = rtl ? key === $56b436271f6666d1$var$ARROW_LEFT : key === $56b436271f6666d1$var$ARROW_RIGHT; return $56b436271f6666d1$var$doSwitch(orientation, vertical, horizontal) || key === "Enter" || key == " " || key === ""; } function $56b436271f6666d1$var$isCrossOrientationOpenKey(key, orientation, rtl) { const vertical = rtl ? key === $56b436271f6666d1$var$ARROW_LEFT : key === $56b436271f6666d1$var$ARROW_RIGHT; const horizontal = key === $56b436271f6666d1$var$ARROW_DOWN; return $56b436271f6666d1$var$doSwitch(orientation, vertical, horizontal); } function $56b436271f6666d1$var$isCrossOrientationCloseKey(key, orientation, rtl) { const vertical = rtl ? key === $56b436271f6666d1$var$ARROW_RIGHT : key === $56b436271f6666d1$var$ARROW_LEFT; const horizontal = key === $56b436271f6666d1$var$ARROW_UP; return $56b436271f6666d1$var$doSwitch(orientation, vertical, horizontal); } /** * Adds arrow key-based navigation of a list of items, either using real DOM * focus or virtual focus. * @see https://floating-ui.com/docs/useListNavigation */ function $56b436271f6666d1$export$b5d22cac4ad33f40(context, props) { const { open: open, onOpenChange: onOpenChange, refs: refs, elements: { domReference: domReference, floating: floating } } = context; const { listRef: listRef, activeIndex: activeIndex, onNavigate: unstable_onNavigate = ()=>{}, enabled: enabled = true, selectedIndex: selectedIndex = null, allowEscape: allowEscape = false, loop: loop = false, nested: nested = false, rtl: rtl = false, virtual: virtual = false, focusItemOnOpen: focusItemOnOpen = "auto", focusItemOnHover: focusItemOnHover = true, openOnArrowKeyDown: openOnArrowKeyDown = true, disabledIndices: disabledIndices, orientation: orientation = "vertical", cols: cols = 1, scrollItemIntoView: scrollItemIntoView = true, virtualItemRef: virtualItemRef } = props; const parentId = $56b436271f6666d1$export$165209eae06d3488(); const tree = $56b436271f6666d1$export$db0c2a7c7a2a4f69(); const onNavigate = $56b436271f6666d1$var$useEffectEvent(unstable_onNavigate); const focusItemOnOpenRef = $63SH6.useRef(focusItemOnOpen); const indexRef = $63SH6.useRef(selectedIndex != null ? selectedIndex : -1); const keyRef = $63SH6.useRef(null); const isPointerModalityRef = $63SH6.useRef(true); const previousOnNavigateRef = $63SH6.useRef(onNavigate); const previousMountedRef = $63SH6.useRef(!!floating); const forceSyncFocus = $63SH6.useRef(false); const forceScrollIntoViewRef = $63SH6.useRef(false); const disabledIndicesRef = $56b436271f6666d1$var$useLatestRef(disabledIndices); const latestOpenRef = $56b436271f6666d1$var$useLatestRef(open); const scrollItemIntoViewRef = $56b436271f6666d1$var$useLatestRef(scrollItemIntoView); const [activeId, setActiveId] = $63SH6.useState(); const [virtualId, setVirtualId] = $63SH6.useState(); const focusItem = $56b436271f6666d1$var$useEffectEvent(function(listRef, indexRef, forceScrollIntoView) { if (forceScrollIntoView === void 0) forceScrollIntoView = false; const item = listRef.current[indexRef.current]; if (!item) return; if (virtual) { setActiveId(item.id); tree == null || tree.events.emit("virtualfocus", item); if (virtualItemRef) virtualItemRef.current = item; } else $56b436271f6666d1$var$enqueueFocus(item, { preventScroll: true, // Mac Safari does not move the virtual cursor unless the focus call // is sync. However, for the very first focus call, we need to wait // for the position to be ready in order to prevent unwanted // scrolling. This means the virtual cursor will not move to the first // item when first opening the floating element, but will on // subsequent calls. `preventScroll` is supported in modern Safari, // so we can use that instead. // iOS Safari must be async or the first item will not be focused. sync: (0, $d8YHU.isMac)() && (0, $d8YHU.isSafari)() ? $56b436271f6666d1$var$isPreventScrollSupported || forceSyncFocus.current : false }); requestAnimationFrame(()=>{ const scrollIntoViewOptions = scrollItemIntoViewRef.current; const shouldScrollIntoView = scrollIntoViewOptions && item && (forceScrollIntoView || !isPointerModalityRef.current); if (shouldScrollIntoView) // JSDOM doesn't support `.scrollIntoView()` but it's widely supported // by all browsers. item.scrollIntoView == null || item.scrollIntoView(typeof scrollIntoViewOptions === "boolean" ? { block: "nearest", inline: "nearest" } : scrollIntoViewOptions); }); }); $56b436271f6666d1$var$index(()=>{ document.createElement("div").focus({ get preventScroll () { $56b436271f6666d1$var$isPreventScrollSupported = true; return false; } }); }, []); // Sync `selectedIndex` to be the `activeIndex` upon opening the floating // element. Also, reset `activeIndex` upon closing the floating element. $56b436271f6666d1$var$index(()=>{ if (!enabled) return; if (open && floating) { if (focusItemOnOpenRef.current && selectedIndex != null) { // Regardless of the pointer modality, we want to ensure the selected // item comes into view when the floating element is opened. forceScrollIntoViewRef.current = true; onNavigate(selectedIndex); } } else if (previousMountedRef.current) { // Since the user can specify `onNavigate` conditionally // (onNavigate: open ? setActiveIndex : setSelectedIndex), // we store and call the previous function. indexRef.current = -1; previousOnNavigateRef.current(null); } }, [ enabled, open, floating, selectedIndex, onNavigate ]); // Sync `activeIndex` to be the focused item while the floating element is // open. $56b436271f6666d1$var$index(()=>{ if (!enabled) return; if (open && floating) { if (activeIndex == null) { forceSyncFocus.current = false; if (selectedIndex != null) return; // Reset while the floating element was open (e.g. the list changed). if (previousMountedRef.current) { indexRef.current = -1; focusItem(listRef, indexRef); } // Initial sync. if (!previousMountedRef.current && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) { let runs = 0; const waitForListPopulated = ()=>{ if (listRef.current[0] == null) { // Avoid letting the browser paint if possible on the first try, // otherwise use rAF. Don't try more than twice, since something // is wrong otherwise. if (runs < 2) { const scheduler = runs ? requestAnimationFrame : queueMicrotask; scheduler(waitForListPopulated); } runs++; } else { indexRef.current = keyRef.current == null || $56b436271f6666d1$var$isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? $56b436271f6666d1$var$getMinIndex(listRef, disabledIndicesRef.current) : $56b436271f6666d1$var$getMaxIndex(listRef, disabledIndicesRef.current); keyRef.current = null; onNavigate(indexRef.current); } }; waitForListPopulated(); } } else if (!$56b436271f6666d1$var$isIndexOutOfBounds(listRef, activeIndex)) { indexRef.current = activeIndex; focusItem(listRef, indexRef, forceScrollIntoViewRef.current); forceScrollIntoViewRef.current = false; } } }, [ enabled, open, floating, activeIndex, selectedIndex, nested, listRef, orientation, rtl, onNavigate, focusItem, disabledIndicesRef ]); // Ensure the parent floating element has focus when a nested child closes // to allow arrow key navigation to work after the pointer leaves the child. $56b436271f6666d1$var$index(()=>{ var _nodes$find, _nodes$find$context; if (!enabled || floating || !tree || virtual || !previousMountedRef.current) return; const nodes = tree.nodesRef.current; const parent = (_nodes$find = nodes.find((node)=>node.id === parentId)) == null ? void 0 : (_nodes$find$context = _nodes$find.context) == null ? void 0 : _nodes$find$context.elements.floating; const activeEl = (0, $d8YHU.activeElement)((0, $d8YHU.getDocument)(floating)); const treeContainsActiveEl = nodes.some((node)=>node.context && (0, $d8YHU.contains)(node.context.elements.floating, activeEl)); if (parent && !treeContainsActiveEl && isPointerModalityRef.current) parent.focus({ preventScroll: true }); }, [ enabled, floating, tree, parentId, virtual ]); $56b436271f6666d1$var$index(()=>{ if (!enabled || !tree || !virtual || parentId) return; function handleVirtualFocus(item) { setVirtualId(item.id); if (virtualItemRef) virtualItemRef.current = item; } tree.events.on("virtualfocus", handleVirtualFocus); return ()=>{ tree.events.off("virtualfocus", handleVirtualFocus); }; }, [ enabled, tree, virtual, parentId, virtualItemRef ]); $56b436271f6666d1$var$index(()=>{ previousOnNavigateRef.current = onNavigate; previousMountedRef.current = !!floating; }); $56b436271f6666d1$var$index(()=>{ if (!open) keyRef.current = null; }, [ open ]); const hasActiveIndex = activeIndex != null; const item = $63SH6.useMemo(()=>{ function syncCurrentTarget(currentTarget) { if (!open) return; const index = listRef.current.indexOf(currentTarget); if (index !== -1) onNavigate(index); } const props = { onFocus (_ref) { let { currentTarget: currentTarget } = _ref; syncCurrentTarget(currentTarget); }, onClick: (_ref2)=>{ let { currentTarget: currentTarget } = _ref2; return currentTarget.focus({ preventScroll: true }); }, // Safari ...focusItemOnHover && { onMouseMove (_ref3) { let { currentTarget: currentTarget } = _ref3; syncCurrentTarget(currentTarget); }, onPointerLeave (_ref4) { let { pointerType: pointerType } = _ref4; if (!isPointerModalityRef.current || pointerType === "touch") return; indexRef.current = -1; focusItem(listRef, indexRef); onNavigate(null); if (!virtual) $56b436271f6666d1$var$enqueueFocus(refs.floating.current, { preventScroll: true }); } } }; return props; }, [ open, refs, focusItem, focusItemOnHover, listRef, onNavigate, virtual ]); return $63SH6.useMemo(()=>{ if (!enabled) return {}; const disabledIndices = disabledIndicesRef.current; function onKeyDown(event) { isPointerModalityRef.current = false; forceSyncFocus.current = true; // If the floating element is animating out, ignore navigation. Otherwise, // the `activeIndex` gets set to 0 despite not being open so the next time // the user ArrowDowns, the first item won't be focused. if (!latestOpenRef.current && event.currentTarget === refs.floating.current) return; if (nested && $56b436271f6666d1$var$isCrossOrientationCloseKey(event.key, orientation, rtl)) { (0, $d8YHU.stopEvent)(event); onOpenChange(false, event.nativeEvent); if ((0, $8Xnp2.isHTMLElement)(domReference) && !virtual) domReference.focus(); return; } const currentIndex = indexRef.current; const minIndex = $56b436271f6666d1$var$getMinIndex(listRef, disabledIndices); const maxIndex = $56b436271f6666d1$var$getMaxIndex(listRef, disabledIndices); if (event.key === "Home") { (0, $d8YHU.stopEvent)(event); indexRef.current = minIndex; onNavigate(indexRef.current); } if (event.key === "End") { (0, $d8YHU.stopEvent)(event); indexRef.current = maxIndex; onNavigate(indexRef.current); } // Grid navigation. if (cols > 1) { indexRef.current = $56b436271f6666d1$var$getGridNavigatedIndex(listRef, { event: event, orientation: orientation, loop: loop, cols: cols, disabledIndices: disabledIndices, minIndex: minIndex, maxIndex: maxIndex, prevIndex: indexRef.current, stopEvent: true }); onNavigate(indexRef.current); if (orientation === "both") return; } if ($56b436271f6666d1$var$isMainOrientationKey(event.key, orientation)) { (0, $d8YHU.stopEvent)(event); // Reset the index if no item is focused. if (open && !virtual && (0, $d8YHU.activeElement)(event.currentTarget.ownerDocument) === event.currentTarget) { indexRef.current = $56b436271f6666d1$var$isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex; onNavigate(indexRef.current); return; } if ($56b436271f6666d1$var$isMainOrientationToEndKey(event.key, orientation, rtl)) { if (loop) indexRef.current = currentIndex >= maxIndex ? allowEscape && currentIndex !== listRef.current.length ? -1 : minIndex : $56b436271f6666d1$var$findNonDisabledIndex(listRef, { startingIndex: currentIndex, disabledIndices: disabledIndices }); else indexRef.current = Math.min(maxIndex, $56b436271f6666d1$var$findNonDisabledIndex(listRef, { startingIndex: currentIndex, disabledIndices: disabledIndices })); } else if (loop) indexRef.current = currentIndex <= minIndex ? allowEscape && currentIndex !== -1 ? listRef.current.length : maxIndex : $56b436271f6666d1$var$findNonDisabledIndex(listRef, { startingIndex: currentIndex, decrement: true, disabledIndices: disabledIndices }); else indexRef.current = Math.max(minIndex, $56b436271f6666d1$var$findNonDisabledIndex(listRef, { startingIndex: currentIndex, decrement: true, disabledIndices: disabledIndices })); if ($56b436271f6666d1$var$isIndexOutOfBounds(listRef, indexRef.current)) onNavigate(null); else onNavigate(indexRef.current); } } function checkVirtualMouse(event) { if (focusItemOnOpen === "auto" && (0, $d8YHU.isVirtualClick)(event.nativeEvent)) focusItemOnOpenRef.current = true; } function checkVirtualPointer(event) { // `pointerdown` fires first, reset the state then perform the checks. focusItemOnOpenRef.current = focusItemOnOpen; if (focusItemOnOpen === "auto" && (0, $d8YHU.isVirtualPointerEvent)(event.nativeEvent)) focusItemOnOpenRef.current = true; } const ariaActiveDescendantProp = virtual && open && hasActiveIndex && { "aria-activedescendant": virtualId || activeId }; const activeItem = listRef.current.find((item)=>(item == null ? void 0 : item.id) === activeId); return { reference: { ...ariaActiveDescendantProp, onKeyDown (event) { isPointerModalityRef.current = false; const isArrowKey = event.key.indexOf("Arrow") === 0; const isCrossOpenKey = $56b436271f6666d1$var$isCrossOrientationOpenKey(event.key, orientation, rtl); const isCrossCloseKey = $56b436271f6666d1$var$isCrossOrientationCloseKey(event.key, orientation, rtl); const isMainKey = $56b436271f6666d1$var$isMainOrientationKey(event.key, orientation); const isNavigationKey = (nested ? isCrossOpenKey : isMainKey) || event.key === "Enter" || event.key.trim() === ""; if (virtual && open) { const rootNode = tree == null ? void 0 : tree.nodesRef.current.find((node)=>node.parentId == null); const deepestNode = tree && rootNode ? $56b436271f6666d1$var$getDeepestNode(tree.nodesRef.current, rootNode.id) : null; if (isArrowKey && deepestNode && virtualItemRef) { const eventObject = new KeyboardEvent("keydown", { key: event.key, bubbles: true }); if (isCrossOpenKey || isCrossCloseKey) { var _deepestNode$context, _deepestNode$context2; const isCurrentTarget = ((_deepestNode$context = deepestNode.context) == null ? void 0 : _deepestNode$context.elements.domReference) === event.currentTarget; const dispatchItem = isCrossCloseKey && !isCurrentTarget ? (_deepestNode$context2 = deepestNode.context) == null ? void 0 : _deepestNode$context2.elements.domReference : isCrossOpenKey ? activeItem : null; if (dispatchItem) { (0, $d8YHU.stopEvent)(event); dispatchItem.dispatchEvent(eventObject); setVirtualId(undefined); } } if (isMainKey && deepestNode.context) { if (deepestNode.context.open && deepestNode.parentId && event.currentTarget !== deepestNode.context.elements.domReference) { var _deepestNode$context$; (0, $d8YHU.stopEvent)(event); (_deepestNode$context$ = deepestNode.context.elements.domReference) == null || _deepestNode$context$.dispatchEvent(eventObject); return; } } } return onKeyDown(event); } // If a floating element should not open on arrow key down, avoid // setting `activeIndex` while it's closed. if (!open && !openOnArrowKeyDown && isArrowKey) return; if (isNavigationKey) keyRef.current = nested && isMainKey ? null : event.key; if (nested) { if (isCrossOpenKey) { (0, $d8YHU.stopEvent)(event); if (open) { indexRef.current = $56b436271f6666d1$var$getMinIndex(listRef, disabledIndices); onNavigate(indexRef.current); } else onOpenChange(true, event.nativeEvent); } return; } if (isMainKey) { if (selectedIndex != null) indexRef.current = selectedIndex; (0, $d8YHU.stopEvent)(event); if (!open && openOnArrowKeyDown) onOpenChange(true, event.nativeEvent); else onKeyDown(event); if (open) onNavigate(indexRef.current); } }, onFocus () { if (open) onNavigate(null); }, onPointerDown: checkVirtualPointer, onMouseDown: checkVirtualMouse, onClick: checkVirtualMouse }, floating: { "aria-orientation": orientation === "both" ? undefined : orientation, ...ariaActiveDescendantProp, onKeyDown: onKeyDown, onPointerMove () { isPointerModalityRef.current = true; } }, item: item }; }, [ domReference, refs, activeId, virtualId, disabledIndicesRef, latestOpenRef, listRef, enabled, orientation, rtl, virtual, open, hasActiveIndex, nested, selectedIndex, openOnArrowKeyDown, allowEscape, cols, loop, focusItemOnOpen, onNavigate, onOpenChange, item, tree, virtualItemRef ]); } /** * Adds base screen reader props to the reference and floating elements for a * given floating element `role`. * @see https://floating-ui.com/docs/useRole */ function $56b436271f6666d1$export$f66572793fa256a1(context, props) { if (props === void 0) props = {}; const { open: open, floatingId: floatingId } = context; const { enabled: enabled = true, role: role = "dialog" } = props; const referenceId = $56b436271f6666d1$export$f680877a34711e37(); return $63SH6.useMemo(()=>{ const floatingProps = { id: floatingId, role: role }; if (!enabled) return {}; if (role === "tooltip") return { reference: { "aria-describedby": open ? floatingId : undefined }, floating: floatingProps }; return { reference: { "aria-expanded": open ? "true" : "false", "aria-haspopup": role === "alertdialog" ? "dialog" : role, "aria-controls": open ? floatingId : undefined, ...role === "listbox" && { role: "combobox" }, ...role === "menu" && { id: referenceId } }, floating: { ...floatingProps, ...role === "menu" && { "aria-labelledby": referenceId } } }; }, [ enabled, role, open, floatingId, referenceId ]); } // Converts a JS style key like `backgroundColor` to a CSS transition-property // like `background-color`. const $56b436271f6666d1$var$camelCaseToKebabCase = (str)=>str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs)=>(ofs ? "-" : "") + $.toLowerCase()); function $56b436271f6666d1$var$execWithArgsOrReturn(valueOrFn, args) { return typeof valueOrFn === "function" ? valueOrFn(args) : valueOrFn; } function $56b436271f6666d1$var$useDelayUnmount(open, durationMs) { const [isMounted, setIsMounted] = $63SH6.useState(open); if (open && !isMounted) setIsMounted(true); $63SH6.useEffect(()=>{ if (!open) { const timeout = setTimeout(()=>setIsMounted(false), durationMs); return ()=>clearTimeout(timeout); } }, [ open, durationMs ]); return isMounted; } /** * Provides a status string to apply CSS transitions to a floating element, * correctly handling placement-aware transitions. * @see https://floating-ui.com/docs/useTransition#usetransitionstatus */ function $56b436271f6666d1$export$b2ef21706733f7e5(context, props) { if (props === void 0) props = {}; const { open: open, elements: { floating: floating } } = context; const { duration: duration = 250 } = props; const isNumberDuration = typeof duration === "number"; const closeDuration = (isNumberDuration ? duration : duration.close) || 0; const [initiated, setInitiated] = $63SH6.useState(false); const [status, setStatus] = $63SH6.useState("unmounted"); const isMounted = $56b436271f6666d1$var$useDelayUnmount(open, closeDuration); // `initiated` check prevents this `setState` call from breaking // . This call is necessary to ensure subsequent opens // after the initial one allows the correct side animation to play when the // placement has changed. $56b436271f6666d1$var$index(()=>{ if (initiated && !isMounted) setStatus("unmounted"); }, [ initiated, isMounted ]); $56b436271f6666d1$var$index(()=>{ if (!floating) return; if (open) { setStatus("initial"); const frame = requestAnimationFrame(()=>{ setStatus("open"); }); return ()=>{ cancelAnimationFrame(frame); }; } else { setInitiated(true); setStatus("close"); } }, [ open, floating ]); return { isMounted: isMounted, status: status }; } /** * Provides styles to apply CSS transitions to a floating element, correctly * handling placement-aware transitions. Wrapper around `useTransitionStatus`. * @see https://floating-ui.com/docs/useTransition#usetransitionstyles */ function $56b436271f6666d1$export$769fba13884bc2f4(context, props) { if (props === void 0) props = {}; const { initial: unstable_initial = { opacity: 0 }, open: unstable_open, close: unstable_close, common: unstable_common, duration: duration = 250 } = props; const placement = context.placement; const side = placement.split("-")[0]; const fnArgs = $63SH6.useMemo(()=>({ side: side, placement: placement }), [ side, placement ]); const isNumberDuration = typeof duration === "number"; const openDuration = (isNumberDuration ? duration : duration.open) || 0; const closeDuration = (isNumberDuration ? duration : duration.close) || 0; const [styles, setStyles] = $63SH6.useState(()=>({ ...$56b436271f6666d1$var$execWithArgsOrReturn(unstable_common, fnArgs), ...$56b436271f6666d1$var$execWithArgsOrReturn(unstable_initial, fnArgs) })); const { isMounted: isMounted, status: status } = $56b436271f6666d1$export$b2ef21706733f7e5(context, { duration: duration }); const initialRef = $56b436271f6666d1$var$useLatestRef(unstable_initial); const openRef = $56b436271f6666d1$var$useLatestRef(unstable_open); const closeRef = $56b436271f6666d1$var$useLatestRef(unstable_close); const commonRef = $56b436271f6666d1$var$useLatestRef(unstable_common); $56b436271f6666d1$var$index(()=>{ const initialStyles = $56b436271f6666d1$var$execWithArgsOrReturn(initialRef.current, fnArgs); const closeStyles = $56b436271f6666d1$var$execWithArgsOrReturn(closeRef.current, fnArgs); const commonStyles = $56b436271f6666d1$var$execWithArgsOrReturn(commonRef.current, fnArgs); const openStyles = $56b436271f6666d1$var$execWithArgsOrReturn(openRef.current, fnArgs) || Object.keys(initialStyles).reduce((acc, key)=>{ acc[key] = ""; return acc; }, {}); if (status === "initial") setStyles((styles)=>({ transitionProperty: styles.transitionProperty, ...commonStyles, ...initialStyles })); if (status === "open") setStyles({ transitionProperty: Object.keys(openStyles).map($56b436271f6666d1$var$camelCaseToKebabCase).join(","), transitionDuration: openDuration + "ms", ...commonStyles, ...openStyles }); if (status === "close") { const styles = closeStyles || initialStyles; setStyles({ transitionProperty: Object.keys(styles).map($56b436271f6666d1$var$camelCaseToKebabCase).join(","), transitionDuration: closeDuration + "ms", ...commonStyles, ...styles }); } }, [ closeDuration, closeRef, initialRef, openRef, commonRef, openDuration, status, fnArgs ]); return { isMounted: isMounted, styles: styles }; } /** * Provides a matching callback that can be used to focus an item as the user * types, often used in tandem with `useListNavigation()`. * @see https://floating-ui.com/docs/useTypeahead */ function $56b436271f6666d1$export$d8d674d50b73ba93(context, props) { var _ref; const { open: open, dataRef: dataRef } = context; const { listRef: listRef, activeIndex: activeIndex, onMatch: unstable_onMatch, onTypingChange: unstable_onTypingChange, enabled: enabled = true, findMatch: findMatch = null, resetMs: resetMs = 750, ignoreKeys: ignoreKeys = [], selectedIndex: selectedIndex = null } = props; const timeoutIdRef = $63SH6.useRef(); const stringRef = $63SH6.useRef(""); const prevIndexRef = $63SH6.useRef((_ref = selectedIndex != null ? selectedIndex : activeIndex) != null ? _ref : -1); const matchIndexRef = $63SH6.useRef(null); const onMatch = $56b436271f6666d1$var$useEffectEvent(unstable_onMatch); const onTypingChange = $56b436271f6666d1$var$useEffectEvent(unstable_onTypingChange); const findMatchRef = $56b436271f6666d1$var$useLatestRef(findMatch); const ignoreKeysRef = $56b436271f6666d1$var$useLatestRef(ignoreKeys); $56b436271f6666d1$var$index(()=>{ if (open) { clearTimeout(timeoutIdRef.current); matchIndexRef.current = null; stringRef.current = ""; } }, [ open ]); $56b436271f6666d1$var$index(()=>{ // Sync arrow key navigation but not typeahead navigation. if (open && stringRef.current === "") { var _ref2; prevIndexRef.current = (_ref2 = selectedIndex != null ? selectedIndex : activeIndex) != null ? _ref2 : -1; } }, [ open, selectedIndex, activeIndex ]); return $63SH6.useMemo(()=>{ if (!enabled) return {}; function setTypingChange(value) { if (value) { if (!dataRef.current.typing) { dataRef.current.typing = value; onTypingChange(value); } } else if (dataRef.current.typing) { dataRef.current.typing = value; onTypingChange(value); } } function getMatchingIndex(list, orderedList, string) { const str = findMatchRef.current ? findMatchRef.current(orderedList, string) : orderedList.find((text)=>(text == null ? void 0 : text.toLocaleLowerCase().indexOf(string.toLocaleLowerCase())) === 0); return str ? list.indexOf(str) : -1; } function onKeyDown(event) { const listContent = listRef.current; if (stringRef.current.length > 0 && stringRef.current[0] !== " ") { if (getMatchingIndex(listContent, listContent, stringRef.current) === -1) setTypingChange(false); else if (event.key === " ") (0, $d8YHU.stopEvent)(event); } if (listContent == null || ignoreKeysRef.current.includes(event.key) || // Character key. event.key.length !== 1 || // Modifier key. event.ctrlKey || event.metaKey || event.altKey) return; if (open && event.key !== " ") { (0, $d8YHU.stopEvent)(event); setTypingChange(true); } // Bail out if the list contains a word like "llama" or "aaron". TODO: // allow it in this case, too. const allowRapidSuccessionOfFirstLetter = listContent.every((text)=>{ var _text$, _text$2; return text ? ((_text$ = text[0]) == null ? void 0 : _text$.toLocaleLowerCase()) !== ((_text$2 = text[1]) == null ? void 0 : _text$2.toLocaleLowerCase()) : true; }); // Allows the user to cycle through items that start with the same letter // in rapid succession. if (allowRapidSuccessionOfFirstLetter && stringRef.current === event.key) { stringRef.current = ""; prevIndexRef.current = matchIndexRef.current; } stringRef.current += event.key; clearTimeout(timeoutIdRef.current); timeoutIdRef.current = setTimeout(()=>{ stringRef.current = ""; prevIndexRef.current = matchIndexRef.current; setTypingChange(false); }, resetMs); const prevIndex = prevIndexRef.current; const index = getMatchingIndex(listContent, [ ...listContent.slice((prevIndex || 0) + 1), ...listContent.slice(0, (prevIndex || 0) + 1) ], stringRef.current); if (index !== -1) { onMatch(index); matchIndexRef.current = index; } else if (event.key !== " ") { stringRef.current = ""; setTypingChange(false); } } return { reference: { onKeyDown: onKeyDown }, floating: { onKeyDown: onKeyDown, onKeyUp (event) { if (event.key === " ") setTypingChange(false); } } }; }, [ enabled, open, dataRef, listRef, resetMs, ignoreKeysRef, findMatchRef, onMatch, onTypingChange ]); } function $56b436271f6666d1$var$getArgsWithCustomFloatingHeight(state, height) { return { ...state, rects: { ...state.rects, floating: { ...state.rects.floating, height: height } } }; } /** * Positions the floating element such that an inner element inside * of it is anchored to the reference element. * @see https://floating-ui.com/docs/inner */ const $56b436271f6666d1$export$4ae363f1d88fb658 = (props)=>({ name: "inner", options: props, async fn (state) { const { listRef: listRef, overflowRef: overflowRef, onFallbackChange: onFallbackChange, offset: innerOffset = 0, index: index = 0, minItemsVisible: minItemsVisible = 4, referenceOverflowThreshold: referenceOverflowThreshold = 0, scrollRef: scrollRef, ...detectOverflowOptions } = props; const { rects: rects, elements: { floating: floating } } = state; const item = listRef.current[index]; if (!item) return {}; const nextArgs = { ...state, ...await (0, $l2jTt.offset)(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state) }; const el = (scrollRef == null ? void 0 : scrollRef.current) || floating; const overflow = await (0, $l2jTt.detectOverflow)($56b436271f6666d1$var$getArgsWithCustomFloatingHeight(nextArgs, el.scrollHeight), detectOverflowOptions); const refOverflow = await (0, $l2jTt.detectOverflow)(nextArgs, { ...detectOverflowOptions, elementContext: "reference" }); const diffY = Math.max(0, overflow.top); const nextY = nextArgs.y + diffY; const maxHeight = Math.max(0, el.scrollHeight - diffY - Math.max(0, overflow.bottom)); el.style.maxHeight = maxHeight + "px"; el.scrollTop = diffY; // There is not enough space, fallback to standard anchored positioning if (onFallbackChange) { if (el.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, listRef.current.length - 1) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold) (0, $grDIR.flushSync)(()=>onFallbackChange(true)); else (0, $grDIR.flushSync)(()=>onFallbackChange(false)); } if (overflowRef) overflowRef.current = await (0, $l2jTt.detectOverflow)($56b436271f6666d1$var$getArgsWithCustomFloatingHeight({ ...nextArgs, y: nextY }, el.offsetHeight), detectOverflowOptions); return { y: nextY }; } }); /** * Changes the `inner` middleware's `offset` upon a `wheel` event to * expand the floating element's height, revealing more list items. * @see https://floating-ui.com/docs/inner */ function $56b436271f6666d1$export$3d74b0dda7cc82ff(context, props) { const { open: open, elements: elements } = context; const { enabled: enabled = true, overflowRef: overflowRef, scrollRef: scrollRef, onChange: unstable_onChange } = props; const onChange = $56b436271f6666d1$var$useEffectEvent(unstable_onChange); const controlledScrollingRef = $63SH6.useRef(false); const prevScrollTopRef = $63SH6.useRef(null); const initialOverflowRef = $63SH6.useRef(null); $63SH6.useEffect(()=>{ if (!enabled) return; function onWheel(e) { if (e.ctrlKey || !el || overflowRef.current == null) return; const dY = e.deltaY; const isAtTop = overflowRef.current.top >= -0.5; const isAtBottom = overflowRef.current.bottom >= -0.5; const remainingScroll = el.scrollHeight - el.clientHeight; const sign = dY < 0 ? -1 : 1; const method = dY < 0 ? "max" : "min"; if (el.scrollHeight <= el.clientHeight) return; if (!isAtTop && dY > 0 || !isAtBottom && dY < 0) { e.preventDefault(); (0, $grDIR.flushSync)(()=>{ onChange((d)=>d + Math[method](dY, remainingScroll * sign)); }); } else if (/firefox/i.test((0, $d8YHU.getUserAgent)())) // Needed to propagate scrolling during momentum scrolling phase once // it gets limited by the boundary. UX improvement, not critical. el.scrollTop += dY; } const el = (scrollRef == null ? void 0 : scrollRef.current) || elements.floating; if (open && el) { el.addEventListener("wheel", onWheel); // Wait for the position to be ready. requestAnimationFrame(()=>{ prevScrollTopRef.current = el.scrollTop; if (overflowRef.current != null) initialOverflowRef.current = { ...overflowRef.current }; }); return ()=>{ prevScrollTopRef.current = null; initialOverflowRef.current = null; el.removeEventListener("wheel", onWheel); }; } }, [ enabled, open, elements.floating, overflowRef, scrollRef, onChange ]); return $63SH6.useMemo(()=>{ if (!enabled) return {}; return { floating: { onKeyDown () { controlledScrollingRef.current = true; }, onWheel () { controlledScrollingRef.current = false; }, onPointerMove () { controlledScrollingRef.current = false; }, onScroll () { const el = (scrollRef == null ? void 0 : scrollRef.current) || elements.floating; if (!overflowRef.current || !el || !controlledScrollingRef.current) return; if (prevScrollTopRef.current !== null) { const scrollDiff = el.scrollTop - prevScrollTopRef.current; if (overflowRef.current.bottom < -0.5 && scrollDiff < -1 || overflowRef.current.top < -0.5 && scrollDiff > 1) (0, $grDIR.flushSync)(()=>onChange((d)=>d + scrollDiff)); } // [Firefox] Wait for the height change to have been applied. requestAnimationFrame(()=>{ prevScrollTopRef.current = el.scrollTop; }); } } }; }, [ enabled, overflowRef, elements.floating, scrollRef, onChange ]); } function $56b436271f6666d1$var$isPointInPolygon(point, polygon) { const [x, y] = point; let isInside = false; const length = polygon.length; for(let i = 0, j = length - 1; i < length; j = i++){ const [xi, yi] = polygon[i] || [ 0, 0 ]; const [xj, yj] = polygon[j] || [ 0, 0 ]; const intersect = yi >= y !== yj >= y && x <= (xj - xi) * (y - yi) / (yj - yi) + xi; if (intersect) isInside = !isInside; } return isInside; } function $56b436271f6666d1$var$isInside(point, rect) { return point[0] >= rect.x && point[0] <= rect.x + rect.width && point[1] >= rect.y && point[1] <= rect.y + rect.height; } /** * Generates a safe polygon area that the user can traverse without closing the * floating element once leaving the reference element. * @see https://floating-ui.com/docs/useHover#safePolygon */ function $56b436271f6666d1$export$7484214ab62358d2(options) { if (options === void 0) options = {}; const { buffer: buffer = 0.5, blockPointerEvents: blockPointerEvents = false, requireIntent: requireIntent = true } = options; let timeoutId; let hasLanded = false; let lastX = null; let lastY = null; let lastCursorTime = performance.now(); function getCursorSpeed(x, y) { const currentTime = performance.now(); const elapsedTime = currentTime - lastCursorTime; if (lastX === null || lastY === null || elapsedTime === 0) { lastX = x; lastY = y; lastCursorTime = currentTime; return null; } const deltaX = x - lastX; const deltaY = y - lastY; const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); const speed = distance / elapsedTime; // px / ms lastX = x; lastY = y; lastCursorTime = currentTime; return speed; } const fn = (_ref)=>{ let { x: x, y: y, placement: placement, elements: elements, onClose: onClose, nodeId: nodeId, tree: tree } = _ref; return function onMouseMove(event) { function close() { clearTimeout(timeoutId); onClose(); } clearTimeout(timeoutId); if (!elements.domReference || !elements.floating || placement == null || x == null || y == null) return; const { clientX: clientX, clientY: clientY } = event; const clientPoint = [ clientX, clientY ]; const target = (0, $d8YHU.getTarget)(event); const isLeave = event.type === "mouseleave"; const isOverFloatingEl = (0, $d8YHU.contains)(elements.floating, target); const isOverReferenceEl = (0, $d8YHU.contains)(elements.domReference, target); const refRect = elements.domReference.getBoundingClientRect(); const rect = elements.floating.getBoundingClientRect(); const side = placement.split("-")[0]; const cursorLeaveFromRight = x > rect.right - rect.width / 2; const cursorLeaveFromBottom = y > rect.bottom - rect.height / 2; const isOverReferenceRect = $56b436271f6666d1$var$isInside(clientPoint, refRect); const isFloatingWider = rect.width > refRect.width; const isFloatingTaller = rect.height > refRect.height; const left = (isFloatingWider ? refRect : rect).left; const right = (isFloatingWider ? refRect : rect).right; const top = (isFloatingTaller ? refRect : rect).top; const bottom = (isFloatingTaller ? refRect : rect).bottom; if (isOverFloatingEl) { hasLanded = true; if (!isLeave) return; } if (isOverReferenceEl) hasLanded = false; if (isOverReferenceEl && !isLeave) { hasLanded = true; return; } // Prevent overlapping floating element from being stuck in an open-close // loop: https://github.com/floating-ui/floating-ui/issues/1910 if (isLeave && (0, $8Xnp2.isElement)(event.relatedTarget) && (0, $d8YHU.contains)(elements.floating, event.relatedTarget)) return; // If any nested child is open, abort. if (tree && $56b436271f6666d1$var$getChildren(tree.nodesRef.current, nodeId).some((_ref2)=>{ let { context: context } = _ref2; return context == null ? void 0 : context.open; })) return; // If the pointer is leaving from the opposite side, the "buffer" logic // creates a point where the floating element remains open, but should be // ignored. // A constant of 1 handles floating point rounding errors. 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) return close(); // Ignore when the cursor is within the rectangular trough between the // two elements. Since the triangle is created from the cursor point, // which can start beyond the ref element's edge, traversing back and // forth from the ref to the floating element can cause it to close. This // ensures it always remains open in that case. let rectPoly = []; switch(side){ case "top": rectPoly = [ [ left, refRect.top + 1 ], [ left, rect.bottom - 1 ], [ right, rect.bottom - 1 ], [ right, refRect.top + 1 ] ]; break; case "bottom": rectPoly = [ [ left, rect.top + 1 ], [ left, refRect.bottom - 1 ], [ right, refRect.bottom - 1 ], [ right, rect.top + 1 ] ]; break; case "left": rectPoly = [ [ rect.right - 1, bottom ], [ rect.right - 1, top ], [ refRect.left + 1, top ], [ refRect.left + 1, bottom ] ]; break; case "right": rectPoly = [ [ refRect.right - 1, bottom ], [ refRect.right - 1, top ], [ rect.left + 1, top ], [ rect.left + 1, bottom ] ]; break; } function getPolygon(_ref3) { let [x, y] = _ref3; switch(side){ case "top": { const cursorPointOne = [ isFloatingWider ? x + buffer / 2 : cursorLeaveFromRight ? x + buffer * 4 : x - buffer * 4, y + buffer + 1 ]; const cursorPointTwo = [ isFloatingWider ? x - buffer / 2 : cursorLeaveFromRight ? x + buffer * 4 : x - buffer * 4, y + buffer + 1 ]; const commonPoints = [ [ rect.left, cursorLeaveFromRight ? rect.bottom - buffer : isFloatingWider ? rect.bottom - buffer : rect.top ], [ rect.right, cursorLeaveFromRight ? isFloatingWider ? rect.bottom - buffer : rect.top : rect.bottom - buffer ] ]; return [ cursorPointOne, cursorPointTwo, ...commonPoints ]; } case "bottom": { const cursorPointOne = [ isFloatingWider ? x + buffer / 2 : cursorLeaveFromRight ? x + buffer * 4 : x - buffer * 4, y - buffer ]; const cursorPointTwo = [ isFloatingWider ? x - buffer / 2 : cursorLeaveFromRight ? x + buffer * 4 : x - buffer * 4, y - buffer ]; const commonPoints = [ [ rect.left, cursorLeaveFromRight ? rect.top + buffer : isFloatingWider ? rect.top + buffer : rect.bottom ], [ rect.right, cursorLeaveFromRight ? isFloatingWider ? rect.top + buffer : rect.bottom : rect.top + buffer ] ]; return [ cursorPointOne, cursorPointTwo, ...commonPoints ]; } case "left": { const cursorPointOne = [ x + buffer + 1, isFloatingTaller ? y + buffer / 2 : cursorLeaveFromBottom ? y + buffer * 4 : y - buffer * 4 ]; const cursorPointTwo = [ x + buffer + 1, isFloatingTaller ? y - buffer / 2 : cursorLeaveFromBottom ? y + buffer * 4 : y - buffer * 4 ]; const commonPoints = [ [ cursorLeaveFromBottom ? rect.right - buffer : isFloatingTaller ? rect.right - buffer : rect.left, rect.top ], [ cursorLeaveFromBottom ? isFloatingTaller ? rect.right - buffer : rect.left : rect.right - buffer, rect.bottom ] ]; return [ ...commonPoints, cursorPointOne, cursorPointTwo ]; } case "right": { const cursorPointOne = [ x - buffer, isFloatingTaller ? y + buffer / 2 : cursorLeaveFromBottom ? y + buffer * 4 : y - buffer * 4 ]; const cursorPointTwo = [ x - buffer, isFloatingTaller ? y - buffer / 2 : cursorLeaveFromBottom ? y + buffer * 4 : y - buffer * 4 ]; const commonPoints = [ [ cursorLeaveFromBottom ? rect.left + buffer : isFloatingTaller ? rect.left + buffer : rect.right, rect.top ], [ cursorLeaveFromBottom ? isFloatingTaller ? rect.left + buffer : rect.right : rect.left + buffer, rect.bottom ] ]; return [ cursorPointOne, cursorPointTwo, ...commonPoints ]; } } } if ($56b436271f6666d1$var$isPointInPolygon([ clientX, clientY ], rectPoly)) return; else if (hasLanded && !isOverReferenceRect) return close(); if (!isLeave && requireIntent) { const cursorSpeed = getCursorSpeed(event.clientX, event.clientY); const cursorSpeedThreshold = 0.1; if (cursorSpeed !== null && cursorSpeed < cursorSpeedThreshold) return close(); } if (!$56b436271f6666d1$var$isPointInPolygon([ clientX, clientY ], getPolygon([ x, y ]))) close(); else if (!hasLanded && requireIntent) timeoutId = window.setTimeout(close, 40); }; }; fn.__options = { blockPointerEvents: blockPointerEvents }; return fn; } }); parcelRegister("d8YHU", function(module, exports) { $parcel$export(module.exports, "activeElement", () => $991b1cebdd128441$export$da980962bd2147a4); $parcel$export(module.exports, "contains", () => $991b1cebdd128441$export$2344b14b097df817); $parcel$export(module.exports, "getPlatform", () => $991b1cebdd128441$export$867a782338812cb4); $parcel$export(module.exports, "getUserAgent", () => $991b1cebdd128441$export$7935961ef7719cb0); $parcel$export(module.exports, "isVirtualClick", () => $991b1cebdd128441$export$60278871457622de); $parcel$export(module.exports, "isVirtualPointerEvent", () => $991b1cebdd128441$export$29bf1b5f2c56cf63); $parcel$export(module.exports, "isSafari", () => $991b1cebdd128441$export$95df08bae54cb4df); $parcel$export(module.exports, "isMac", () => $991b1cebdd128441$export$9ac100e40613ea10); $parcel$export(module.exports, "isMouseLikePointerType", () => $991b1cebdd128441$export$81cf264172d31e51); $parcel$export(module.exports, "isReactEvent", () => $991b1cebdd128441$export$94781ce41a161222); $parcel$export(module.exports, "isRootElement", () => $991b1cebdd128441$export$7b296c28e0fa3aed); $parcel$export(module.exports, "getDocument", () => $991b1cebdd128441$export$f65ca476c09acec0); $parcel$export(module.exports, "isEventTargetWithin", () => $991b1cebdd128441$export$43c3154d5bf2c6c2); $parcel$export(module.exports, "getTarget", () => $991b1cebdd128441$export$c22522a4dfa48e9c); $parcel$export(module.exports, "isTypeableElement", () => $991b1cebdd128441$export$42ad131c32f0fb8d); $parcel$export(module.exports, "stopEvent", () => $991b1cebdd128441$export$7ae4cd3a66c1e050); var $8Xnp2 = parcelRequire("8Xnp2"); function $991b1cebdd128441$export$da980962bd2147a4(doc) { let activeElement = doc.activeElement; while(((_activeElement = activeElement) == null ? void 0 : (_activeElement$shadow = _activeElement.shadowRoot) == null ? void 0 : _activeElement$shadow.activeElement) != null){ var _activeElement, _activeElement$shadow; activeElement = activeElement.shadowRoot.activeElement; } return activeElement; } function $991b1cebdd128441$export$2344b14b097df817(parent, child) { if (!parent || !child) return false; const rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method if (parent.contains(child)) return true; // then fallback to custom implementation with Shadow DOM support if (rootNode && (0, $8Xnp2.isShadowRoot)(rootNode)) { let next = child; while(next){ if (parent === next) return true; // @ts-ignore next = next.parentNode || next.host; } } // Give up, the result is false return false; } // Avoid Chrome DevTools blue warning. function $991b1cebdd128441$export$867a782338812cb4() { const uaData = navigator.userAgentData; if (uaData != null && uaData.platform) return uaData.platform; return navigator.platform; } function $991b1cebdd128441$export$7935961ef7719cb0() { const uaData = navigator.userAgentData; if (uaData && Array.isArray(uaData.brands)) return uaData.brands.map((_ref)=>{ let { brand: brand, version: version } = _ref; return brand + "/" + version; }).join(" "); return navigator.userAgent; } // License: https://github.com/adobe/react-spectrum/blob/b35d5c02fe900badccd0cf1a8f23bb593419f238/packages/@react-aria/utils/src/isVirtualEvent.ts function $991b1cebdd128441$export$60278871457622de(event) { // FIXME: Firefox is now emitting a deprecation warning for `mozInputSource`. // Try to find a workaround for this. `react-aria` source still has the check. if (event.mozInputSource === 0 && event.isTrusted) return true; if ($991b1cebdd128441$export$a11b0059900ceec8() && event.pointerType) return event.type === "click" && event.buttons === 1; return event.detail === 0 && !event.pointerType; } function $991b1cebdd128441$export$29bf1b5f2c56cf63(event) { return !$991b1cebdd128441$export$a11b0059900ceec8() && event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height. event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0; } function $991b1cebdd128441$export$95df08bae54cb4df() { // Chrome DevTools does not complain about navigator.vendor return /apple/i.test(navigator.vendor); } function $991b1cebdd128441$export$a11b0059900ceec8() { const re = /android/i; return re.test($991b1cebdd128441$export$867a782338812cb4()) || re.test($991b1cebdd128441$export$7935961ef7719cb0()); } function $991b1cebdd128441$export$9ac100e40613ea10() { return $991b1cebdd128441$export$867a782338812cb4().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints; } function $991b1cebdd128441$export$81cf264172d31e51(pointerType, strict) { // On some Linux machines with Chromium, mouse inputs return a `pointerType` // of "pen": https://github.com/floating-ui/floating-ui/issues/2015 const values = [ "mouse", "pen" ]; if (!strict) values.push("", undefined); return values.includes(pointerType); } function $991b1cebdd128441$export$94781ce41a161222(event) { return "nativeEvent" in event; } function $991b1cebdd128441$export$7b296c28e0fa3aed(element) { return element.matches("html,body"); } function $991b1cebdd128441$export$f65ca476c09acec0(node) { return (node == null ? void 0 : node.ownerDocument) || document; } function $991b1cebdd128441$export$43c3154d5bf2c6c2(event, node) { if (node == null) return false; if ("composedPath" in event) return event.composedPath().includes(node); // TS thinks `event` is of type never as it assumes all browsers support composedPath, but browsers without shadow dom don't const e = event; return e.target != null && node.contains(e.target); } function $991b1cebdd128441$export$c22522a4dfa48e9c(event) { if ("composedPath" in event) return event.composedPath()[0]; // TS thinks `event` is of type never as it assumes all browsers support // `composedPath()`, but browsers without shadow DOM don't. return event.target; } const $991b1cebdd128441$export$78b3d091ff376bc = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"; function $991b1cebdd128441$export$42ad131c32f0fb8d(element) { return (0, $8Xnp2.isHTMLElement)(element) && element.matches($991b1cebdd128441$export$78b3d091ff376bc); } function $991b1cebdd128441$export$7ae4cd3a66c1e050(event) { event.preventDefault(); event.stopPropagation(); } }); parcelRegister("8Xnp2", function(module, exports) { $parcel$export(module.exports, "getNodeName", () => $6855fcb605b0f44b$export$651544f548703224); $parcel$export(module.exports, "getWindow", () => $6855fcb605b0f44b$export$38b2d434cce3ea22); $parcel$export(module.exports, "getDocumentElement", () => $6855fcb605b0f44b$export$e495491855dc5418); $parcel$export(module.exports, "isElement", () => $6855fcb605b0f44b$export$45a5e7f76e0caa8d); $parcel$export(module.exports, "isHTMLElement", () => $6855fcb605b0f44b$export$1b3bfaa9684536aa); $parcel$export(module.exports, "isShadowRoot", () => $6855fcb605b0f44b$export$af51f0f06c0f328a); $parcel$export(module.exports, "isOverflowElement", () => $6855fcb605b0f44b$export$989e911fa9af580a); $parcel$export(module.exports, "getComputedStyle", () => $6855fcb605b0f44b$export$3735103072e4a80); $parcel$export(module.exports, "isTableElement", () => $6855fcb605b0f44b$export$71535ffaa902797f); $parcel$export(module.exports, "isContainingBlock", () => $6855fcb605b0f44b$export$d6c4e8150c35fed1); $parcel$export(module.exports, "isWebKit", () => $6855fcb605b0f44b$export$78551043582a6a98); $parcel$export(module.exports, "getContainingBlock", () => $6855fcb605b0f44b$export$940d8225183e1404); $parcel$export(module.exports, "getParentNode", () => $6855fcb605b0f44b$export$4e12058fc4d51d56); $parcel$export(module.exports, "isLastTraversableNode", () => $6855fcb605b0f44b$export$d1162fb0b6d4cd51); $parcel$export(module.exports, "getNodeScroll", () => $6855fcb605b0f44b$export$dc8fc79fa2800137); $parcel$export(module.exports, "getOverflowAncestors", () => $6855fcb605b0f44b$export$3b57c1601291186b); function $6855fcb605b0f44b$export$651544f548703224(node) { if ($6855fcb605b0f44b$export$8ee0fc9ee280b4ee(node)) return (node.nodeName || "").toLowerCase(); // Mocked nodes in testing environments may not be instances of Node. By // returning `#document` an infinite loop won't occur. // https://github.com/floating-ui/floating-ui/issues/2317 return "#document"; } function $6855fcb605b0f44b$export$38b2d434cce3ea22(node) { var _node$ownerDocument; return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; } function $6855fcb605b0f44b$export$e495491855dc5418(node) { var _ref; return (_ref = ($6855fcb605b0f44b$export$8ee0fc9ee280b4ee(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; } function $6855fcb605b0f44b$export$8ee0fc9ee280b4ee(value) { return value instanceof Node || value instanceof $6855fcb605b0f44b$export$38b2d434cce3ea22(value).Node; } function $6855fcb605b0f44b$export$45a5e7f76e0caa8d(value) { return value instanceof Element || value instanceof $6855fcb605b0f44b$export$38b2d434cce3ea22(value).Element; } function $6855fcb605b0f44b$export$1b3bfaa9684536aa(value) { return value instanceof HTMLElement || value instanceof $6855fcb605b0f44b$export$38b2d434cce3ea22(value).HTMLElement; } function $6855fcb605b0f44b$export$af51f0f06c0f328a(value) { // Browsers without `ShadowRoot` support. if (typeof ShadowRoot === "undefined") return false; return value instanceof ShadowRoot || value instanceof $6855fcb605b0f44b$export$38b2d434cce3ea22(value).ShadowRoot; } function $6855fcb605b0f44b$export$989e911fa9af580a(element) { const { overflow: overflow, overflowX: overflowX, overflowY: overflowY, display: display } = $6855fcb605b0f44b$export$3735103072e4a80(element); return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && ![ "inline", "contents" ].includes(display); } function $6855fcb605b0f44b$export$71535ffaa902797f(element) { return [ "table", "td", "th" ].includes($6855fcb605b0f44b$export$651544f548703224(element)); } function $6855fcb605b0f44b$export$d6c4e8150c35fed1(element) { const webkit = $6855fcb605b0f44b$export$78551043582a6a98(); const css = $6855fcb605b0f44b$export$3735103072e4a80(element); // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || [ "transform", "perspective", "filter" ].some((value)=>(css.willChange || "").includes(value)) || [ "paint", "layout", "strict", "content" ].some((value)=>(css.contain || "").includes(value)); } function $6855fcb605b0f44b$export$940d8225183e1404(element) { let currentNode = $6855fcb605b0f44b$export$4e12058fc4d51d56(element); while($6855fcb605b0f44b$export$1b3bfaa9684536aa(currentNode) && !$6855fcb605b0f44b$export$d1162fb0b6d4cd51(currentNode)){ if ($6855fcb605b0f44b$export$d6c4e8150c35fed1(currentNode)) return currentNode; else currentNode = $6855fcb605b0f44b$export$4e12058fc4d51d56(currentNode); } return null; } function $6855fcb605b0f44b$export$78551043582a6a98() { if (typeof CSS === "undefined" || !CSS.supports) return false; return CSS.supports("-webkit-backdrop-filter", "none"); } function $6855fcb605b0f44b$export$d1162fb0b6d4cd51(node) { return [ "html", "body", "#document" ].includes($6855fcb605b0f44b$export$651544f548703224(node)); } function $6855fcb605b0f44b$export$3735103072e4a80(element) { return $6855fcb605b0f44b$export$38b2d434cce3ea22(element).getComputedStyle(element); } function $6855fcb605b0f44b$export$dc8fc79fa2800137(element) { if ($6855fcb605b0f44b$export$45a5e7f76e0caa8d(element)) return { scrollLeft: element.scrollLeft, scrollTop: element.scrollTop }; return { scrollLeft: element.pageXOffset, scrollTop: element.pageYOffset }; } function $6855fcb605b0f44b$export$4e12058fc4d51d56(node) { if ($6855fcb605b0f44b$export$651544f548703224(node) === "html") return node; const result = // Step into the shadow DOM of the parent of a slotted node. node.assignedSlot || // DOM Element detected. node.parentNode || // ShadowRoot detected. $6855fcb605b0f44b$export$af51f0f06c0f328a(node) && node.host || // Fallback. $6855fcb605b0f44b$export$e495491855dc5418(node); return $6855fcb605b0f44b$export$af51f0f06c0f328a(result) ? result.host : result; } function $6855fcb605b0f44b$export$7cd01a57c8ca906c(node) { const parentNode = $6855fcb605b0f44b$export$4e12058fc4d51d56(node); if ($6855fcb605b0f44b$export$d1162fb0b6d4cd51(parentNode)) return node.ownerDocument ? node.ownerDocument.body : node.body; if ($6855fcb605b0f44b$export$1b3bfaa9684536aa(parentNode) && $6855fcb605b0f44b$export$989e911fa9af580a(parentNode)) return parentNode; return $6855fcb605b0f44b$export$7cd01a57c8ca906c(parentNode); } function $6855fcb605b0f44b$export$3b57c1601291186b(node, list, traverseIframes) { var _node$ownerDocument2; if (list === void 0) list = []; if (traverseIframes === void 0) traverseIframes = true; const scrollableAncestor = $6855fcb605b0f44b$export$7cd01a57c8ca906c(node); const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); const win = $6855fcb605b0f44b$export$38b2d434cce3ea22(scrollableAncestor); if (isBody) return list.concat(win, win.visualViewport || [], $6855fcb605b0f44b$export$989e911fa9af580a(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? $6855fcb605b0f44b$export$3b57c1601291186b(win.frameElement) : []); return list.concat(scrollableAncestor, $6855fcb605b0f44b$export$3b57c1601291186b(scrollableAncestor, [], traverseIframes)); } }); parcelRegister("fvpw6", function(module, exports) { $parcel$export(module.exports, "sides", () => $b49d8b63aada88c5$export$832b6fa47fa053d2); $parcel$export(module.exports, "placements", () => $b49d8b63aada88c5$export$803cd8101b6c182b); $parcel$export(module.exports, "min", () => $b49d8b63aada88c5$export$96ec731ed4dcb222); $parcel$export(module.exports, "max", () => $b49d8b63aada88c5$export$8960430cfd85939f); $parcel$export(module.exports, "round", () => $b49d8b63aada88c5$export$2077e0241d6afd3c); $parcel$export(module.exports, "floor", () => $b49d8b63aada88c5$export$a3fe094919f356fd); $parcel$export(module.exports, "createCoords", () => $b49d8b63aada88c5$export$a397704b5e280835); $parcel$export(module.exports, "clamp", () => $b49d8b63aada88c5$export$7d15b64cf5a3a4c4); $parcel$export(module.exports, "evaluate", () => $b49d8b63aada88c5$export$fef61f332f2c0afc); $parcel$export(module.exports, "getSide", () => $b49d8b63aada88c5$export$3c915306cb7fc97a); $parcel$export(module.exports, "getAlignment", () => $b49d8b63aada88c5$export$f0989780f32bfcda); $parcel$export(module.exports, "getOppositeAxis", () => $b49d8b63aada88c5$export$8a000a963141ac32); $parcel$export(module.exports, "getAxisLength", () => $b49d8b63aada88c5$export$320bd9d53520c68a); $parcel$export(module.exports, "getSideAxis", () => $b49d8b63aada88c5$export$f28e8f882010718a); $parcel$export(module.exports, "getAlignmentAxis", () => $b49d8b63aada88c5$export$2b57e0052a6d6d4c); $parcel$export(module.exports, "getAlignmentSides", () => $b49d8b63aada88c5$export$be42861551f17911); $parcel$export(module.exports, "getOppositePlacement", () => $b49d8b63aada88c5$export$9c5e28bad23365fa); $parcel$export(module.exports, "getExpandedPlacements", () => $b49d8b63aada88c5$export$496432a3699e50b1); $parcel$export(module.exports, "getOppositeAlignmentPlacement", () => $b49d8b63aada88c5$export$2b182c584985588b); $parcel$export(module.exports, "getOppositeAxisPlacements", () => $b49d8b63aada88c5$export$a9b6fb18fd92c3ec); $parcel$export(module.exports, "getPaddingObject", () => $b49d8b63aada88c5$export$598c291c29bc2e71); $parcel$export(module.exports, "rectToClientRect", () => $b49d8b63aada88c5$export$ee05aea0aeecbad4); const $b49d8b63aada88c5$export$832b6fa47fa053d2 = [ "top", "right", "bottom", "left" ]; const $b49d8b63aada88c5$export$27b07d8a310ed8b5 = [ "start", "end" ]; const $b49d8b63aada88c5$export$803cd8101b6c182b = /*#__PURE__*/ $b49d8b63aada88c5$export$832b6fa47fa053d2.reduce((acc, side)=>acc.concat(side, side + "-" + $b49d8b63aada88c5$export$27b07d8a310ed8b5[0], side + "-" + $b49d8b63aada88c5$export$27b07d8a310ed8b5[1]), []); const $b49d8b63aada88c5$export$96ec731ed4dcb222 = Math.min; const $b49d8b63aada88c5$export$8960430cfd85939f = Math.max; const $b49d8b63aada88c5$export$2077e0241d6afd3c = Math.round; const $b49d8b63aada88c5$export$a3fe094919f356fd = Math.floor; const $b49d8b63aada88c5$export$a397704b5e280835 = (v)=>({ x: v, y: v }); const $b49d8b63aada88c5$var$oppositeSideMap = { left: "right", right: "left", bottom: "top", top: "bottom" }; const $b49d8b63aada88c5$var$oppositeAlignmentMap = { start: "end", end: "start" }; function $b49d8b63aada88c5$export$7d15b64cf5a3a4c4(start, value, end) { return $b49d8b63aada88c5$export$8960430cfd85939f(start, $b49d8b63aada88c5$export$96ec731ed4dcb222(value, end)); } function $b49d8b63aada88c5$export$fef61f332f2c0afc(value, param) { return typeof value === "function" ? value(param) : value; } function $b49d8b63aada88c5$export$3c915306cb7fc97a(placement) { return placement.split("-")[0]; } function $b49d8b63aada88c5$export$f0989780f32bfcda(placement) { return placement.split("-")[1]; } function $b49d8b63aada88c5$export$8a000a963141ac32(axis) { return axis === "x" ? "y" : "x"; } function $b49d8b63aada88c5$export$320bd9d53520c68a(axis) { return axis === "y" ? "height" : "width"; } function $b49d8b63aada88c5$export$f28e8f882010718a(placement) { return [ "top", "bottom" ].includes($b49d8b63aada88c5$export$3c915306cb7fc97a(placement)) ? "y" : "x"; } function $b49d8b63aada88c5$export$2b57e0052a6d6d4c(placement) { return $b49d8b63aada88c5$export$8a000a963141ac32($b49d8b63aada88c5$export$f28e8f882010718a(placement)); } function $b49d8b63aada88c5$export$be42861551f17911(placement, rects, rtl) { if (rtl === void 0) rtl = false; const alignment = $b49d8b63aada88c5$export$f0989780f32bfcda(placement); const alignmentAxis = $b49d8b63aada88c5$export$2b57e0052a6d6d4c(placement); const length = $b49d8b63aada88c5$export$320bd9d53520c68a(alignmentAxis); let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; if (rects.reference[length] > rects.floating[length]) mainAlignmentSide = $b49d8b63aada88c5$export$9c5e28bad23365fa(mainAlignmentSide); return [ mainAlignmentSide, $b49d8b63aada88c5$export$9c5e28bad23365fa(mainAlignmentSide) ]; } function $b49d8b63aada88c5$export$496432a3699e50b1(placement) { const oppositePlacement = $b49d8b63aada88c5$export$9c5e28bad23365fa(placement); return [ $b49d8b63aada88c5$export$2b182c584985588b(placement), oppositePlacement, $b49d8b63aada88c5$export$2b182c584985588b(oppositePlacement) ]; } function $b49d8b63aada88c5$export$2b182c584985588b(placement) { return placement.replace(/start|end/g, (alignment)=>$b49d8b63aada88c5$var$oppositeAlignmentMap[alignment]); } function $b49d8b63aada88c5$var$getSideList(side, isStart, rtl) { const lr = [ "left", "right" ]; const rl = [ "right", "left" ]; const tb = [ "top", "bottom" ]; const bt = [ "bottom", "top" ]; switch(side){ case "top": case "bottom": if (rtl) return isStart ? rl : lr; return isStart ? lr : rl; case "left": case "right": return isStart ? tb : bt; default: return []; } } function $b49d8b63aada88c5$export$a9b6fb18fd92c3ec(placement, flipAlignment, direction, rtl) { const alignment = $b49d8b63aada88c5$export$f0989780f32bfcda(placement); let list = $b49d8b63aada88c5$var$getSideList($b49d8b63aada88c5$export$3c915306cb7fc97a(placement), direction === "start", rtl); if (alignment) { list = list.map((side)=>side + "-" + alignment); if (flipAlignment) list = list.concat(list.map($b49d8b63aada88c5$export$2b182c584985588b)); } return list; } function $b49d8b63aada88c5$export$9c5e28bad23365fa(placement) { return placement.replace(/left|right|bottom|top/g, (side)=>$b49d8b63aada88c5$var$oppositeSideMap[side]); } function $b49d8b63aada88c5$export$1c66dbf1a9e34223(padding) { return { top: 0, right: 0, bottom: 0, left: 0, ...padding }; } function $b49d8b63aada88c5$export$598c291c29bc2e71(padding) { return typeof padding !== "number" ? $b49d8b63aada88c5$export$1c66dbf1a9e34223(padding) : { top: padding, right: padding, bottom: padding, left: padding }; } function $b49d8b63aada88c5$export$ee05aea0aeecbad4(rect) { return { ...rect, top: rect.y, left: rect.x, right: rect.x + rect.width, bottom: rect.y + rect.height }; } }); parcelRegister("2Dcmu", function(module, exports) { $parcel$export(module.exports, "arrow", () => $1ea8d0139225f984$export$f2120bbfa5450bd2); $parcel$export(module.exports, "useFloating", () => $1ea8d0139225f984$export$4e02a5c1d08bac65); var $l2jTt = parcelRequire("l2jTt"); var $91fsP = parcelRequire("91fsP"); var $8Xnp2 = parcelRequire("8Xnp2"); var $63SH6 = parcelRequire("63SH6"); var $grDIR = parcelRequire("grDIR"); /** * Provides data to position an inner element of the floating element so that it * appears centered to the reference element. * This wraps the core `arrow` middleware to allow React refs as the element. * @see https://floating-ui.com/docs/arrow */ const $1ea8d0139225f984$export$f2120bbfa5450bd2 = (options)=>{ function isRef(value) { return ({}).hasOwnProperty.call(value, "current"); } return { name: "arrow", options: options, fn (state) { const { element: element, padding: padding } = typeof options === "function" ? options(state) : options; if (element && isRef(element)) { if (element.current != null) return (0, $l2jTt.arrow)({ element: element.current, padding: padding }).fn(state); return {}; } else if (element) return (0, $l2jTt.arrow)({ element: element, padding: padding }).fn(state); return {}; } }; }; var $1ea8d0139225f984$var$index = typeof document !== "undefined" ? (0, $63SH6.useLayoutEffect) : (0, $63SH6.useEffect); // Fork of `fast-deep-equal` that only does the comparisons we need and compares // functions function $1ea8d0139225f984$var$deepEqual(a, b) { if (a === b) return true; if (typeof a !== typeof b) return false; if (typeof a === "function" && a.toString() === b.toString()) return true; let length, i, keys; if (a && b && typeof a == "object") { if (Array.isArray(a)) { length = a.length; if (length != b.length) return false; for(i = length; i-- !== 0;){ if (!$1ea8d0139225f984$var$deepEqual(a[i], b[i])) return false; } return true; } keys = Object.keys(a); length = keys.length; if (length !== Object.keys(b).length) return false; for(i = length; i-- !== 0;){ if (!({}).hasOwnProperty.call(b, keys[i])) return false; } for(i = length; i-- !== 0;){ const key = keys[i]; if (key === "_owner" && a.$$typeof) continue; if (!$1ea8d0139225f984$var$deepEqual(a[key], b[key])) return false; } return true; } return a !== a && b !== b; } function $1ea8d0139225f984$var$getDPR(element) { if (typeof window === "undefined") return 1; const win = element.ownerDocument.defaultView || window; return win.devicePixelRatio || 1; } function $1ea8d0139225f984$var$roundByDPR(element, value) { const dpr = $1ea8d0139225f984$var$getDPR(element); return Math.round(value * dpr) / dpr; } function $1ea8d0139225f984$var$useLatestRef(value) { const ref = $63SH6.useRef(value); $1ea8d0139225f984$var$index(()=>{ ref.current = value; }); return ref; } /** * Provides data to position a floating element. * @see https://floating-ui.com/docs/react */ function $1ea8d0139225f984$export$4e02a5c1d08bac65(options) { if (options === void 0) options = {}; const { placement: placement = "bottom", strategy: strategy = "absolute", middleware: middleware = [], platform: platform, elements: { reference: externalReference, floating: externalFloating } = {}, transform: transform = true, whileElementsMounted: whileElementsMounted, open: open } = options; const [data, setData] = $63SH6.useState({ x: 0, y: 0, strategy: strategy, placement: placement, middlewareData: {}, isPositioned: false }); const [latestMiddleware, setLatestMiddleware] = $63SH6.useState(middleware); if (!$1ea8d0139225f984$var$deepEqual(latestMiddleware, middleware)) setLatestMiddleware(middleware); const [_reference, _setReference] = $63SH6.useState(null); const [_floating, _setFloating] = $63SH6.useState(null); const setReference = $63SH6.useCallback((node)=>{ if (node != referenceRef.current) { referenceRef.current = node; _setReference(node); } }, [ _setReference ]); const setFloating = $63SH6.useCallback((node)=>{ if (node !== floatingRef.current) { floatingRef.current = node; _setFloating(node); } }, [ _setFloating ]); const referenceEl = externalReference || _reference; const floatingEl = externalFloating || _floating; const referenceRef = $63SH6.useRef(null); const floatingRef = $63SH6.useRef(null); const dataRef = $63SH6.useRef(data); const whileElementsMountedRef = $1ea8d0139225f984$var$useLatestRef(whileElementsMounted); const platformRef = $1ea8d0139225f984$var$useLatestRef(platform); const update = $63SH6.useCallback(()=>{ if (!referenceRef.current || !floatingRef.current) return; const config = { placement: placement, strategy: strategy, middleware: latestMiddleware }; if (platformRef.current) config.platform = platformRef.current; (0, $91fsP.computePosition)(referenceRef.current, floatingRef.current, config).then((data)=>{ const fullData = { ...data, isPositioned: true }; if (isMountedRef.current && !$1ea8d0139225f984$var$deepEqual(dataRef.current, fullData)) { dataRef.current = fullData; $grDIR.flushSync(()=>{ setData(fullData); }); } }); }, [ latestMiddleware, placement, strategy, platformRef ]); $1ea8d0139225f984$var$index(()=>{ if (open === false && dataRef.current.isPositioned) { dataRef.current.isPositioned = false; setData((data)=>({ ...data, isPositioned: false })); } }, [ open ]); const isMountedRef = $63SH6.useRef(false); $1ea8d0139225f984$var$index(()=>{ isMountedRef.current = true; return ()=>{ isMountedRef.current = false; }; }, []); $1ea8d0139225f984$var$index(()=>{ if (referenceEl) referenceRef.current = referenceEl; if (floatingEl) floatingRef.current = floatingEl; if (referenceEl && floatingEl) { if (whileElementsMountedRef.current) return whileElementsMountedRef.current(referenceEl, floatingEl, update); else update(); } }, [ referenceEl, floatingEl, update, whileElementsMountedRef ]); const refs = $63SH6.useMemo(()=>({ reference: referenceRef, floating: floatingRef, setReference: setReference, setFloating: setFloating }), [ setReference, setFloating ]); const elements = $63SH6.useMemo(()=>({ reference: referenceEl, floating: floatingEl }), [ referenceEl, floatingEl ]); const floatingStyles = $63SH6.useMemo(()=>{ const initialStyles = { position: strategy, left: 0, top: 0 }; if (!elements.floating) return initialStyles; const x = $1ea8d0139225f984$var$roundByDPR(elements.floating, data.x); const y = $1ea8d0139225f984$var$roundByDPR(elements.floating, data.y); if (transform) return { ...initialStyles, transform: "translate(" + x + "px, " + y + "px)", ...$1ea8d0139225f984$var$getDPR(elements.floating) >= 1.5 && { willChange: "transform" } }; return { position: strategy, left: x, top: y }; }, [ strategy, transform, elements.floating, data.x, data.y ]); return $63SH6.useMemo(()=>({ ...data, update: update, refs: refs, elements: elements, floatingStyles: floatingStyles }), [ data, update, refs, elements, floatingStyles ]); } }); parcelRegister("l2jTt", function(module, exports) { $parcel$export(module.exports, "computePosition", () => $f50937607e0de9ef$export$48a53dcb22e581d0); $parcel$export(module.exports, "detectOverflow", () => $f50937607e0de9ef$export$37b6bde19b108ecc); $parcel$export(module.exports, "arrow", () => $f50937607e0de9ef$export$f2120bbfa5450bd2); $parcel$export(module.exports, "flip", () => $f50937607e0de9ef$export$8a83211c878a3f1f); $parcel$export(module.exports, "offset", () => $f50937607e0de9ef$export$cc800923e997bb8); $parcel$export(module.exports, "shift", () => $f50937607e0de9ef$export$fba63a578e423eb); $parcel$export(module.exports, "rectToClientRect", () => (parcelRequire("fvpw6")).rectToClientRect); var $fvpw6 = parcelRequire("fvpw6"); function $f50937607e0de9ef$var$computeCoordsFromPlacement(_ref, placement, rtl) { let { reference: reference, floating: floating } = _ref; const sideAxis = (0, $fvpw6.getSideAxis)(placement); const alignmentAxis = (0, $fvpw6.getAlignmentAxis)(placement); const alignLength = (0, $fvpw6.getAxisLength)(alignmentAxis); const side = (0, $fvpw6.getSide)(placement); const isVertical = sideAxis === "y"; const commonX = reference.x + reference.width / 2 - floating.width / 2; const commonY = reference.y + reference.height / 2 - floating.height / 2; const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; let coords; switch(side){ case "top": coords = { x: commonX, y: reference.y - floating.height }; break; case "bottom": coords = { x: commonX, y: reference.y + reference.height }; break; case "right": coords = { x: reference.x + reference.width, y: commonY }; break; case "left": coords = { x: reference.x - floating.width, y: commonY }; break; default: coords = { x: reference.x, y: reference.y }; } switch((0, $fvpw6.getAlignment)(placement)){ case "start": coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); break; case "end": coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); break; } return coords; } /** * Computes the `x` and `y` coordinates that will place the floating element * next to a reference element when it is given a certain positioning strategy. * * This export does not have any `platform` interface logic. You will need to * write one for the platform you are using Floating UI with. */ const $f50937607e0de9ef$export$48a53dcb22e581d0 = async (reference, floating, config)=>{ const { placement: placement = "bottom", strategy: strategy = "absolute", middleware: middleware = [], platform: platform } = config; const validMiddleware = middleware.filter(Boolean); const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating)); let rects = await platform.getElementRects({ reference: reference, floating: floating, strategy: strategy }); let { x: x, y: y } = $f50937607e0de9ef$var$computeCoordsFromPlacement(rects, placement, rtl); let statefulPlacement = placement; let middlewareData = {}; let resetCount = 0; for(let i = 0; i < validMiddleware.length; i++){ const { name: name, fn: fn } = validMiddleware[i]; const { x: nextX, y: nextY, data: data, reset: reset } = await fn({ x: x, y: y, initialPlacement: placement, placement: statefulPlacement, strategy: strategy, middlewareData: middlewareData, rects: rects, platform: platform, elements: { reference: reference, floating: floating } }); x = nextX != null ? nextX : x; y = nextY != null ? nextY : y; middlewareData = { ...middlewareData, [name]: { ...middlewareData[name], ...data } }; if (reset && resetCount <= 50) { resetCount++; if (typeof reset === "object") { if (reset.placement) statefulPlacement = reset.placement; if (reset.rects) rects = reset.rects === true ? await platform.getElementRects({ reference: reference, floating: floating, strategy: strategy }) : reset.rects; ({ x: x, y: y } = $f50937607e0de9ef$var$computeCoordsFromPlacement(rects, statefulPlacement, rtl)); } i = -1; continue; } } return { x: x, y: y, placement: statefulPlacement, strategy: strategy, middlewareData: middlewareData }; }; /** * Resolves with an object of overflow side offsets that determine how much the * element is overflowing a given clipping boundary on each side. * - positive = overflowing the boundary by that number of pixels * - negative = how many pixels left before it will overflow * - 0 = lies flush with the boundary * @see https://floating-ui.com/docs/detectOverflow */ async function $f50937607e0de9ef$export$37b6bde19b108ecc(state, options) { var _await$platform$isEle; if (options === void 0) options = {}; const { x: x, y: y, platform: platform, rects: rects, elements: elements, strategy: strategy } = state; const { boundary: boundary = "clippingAncestors", rootBoundary: rootBoundary = "viewport", elementContext: elementContext = "floating", altBoundary: altBoundary = false, padding: padding = 0 } = (0, $fvpw6.evaluate)(options, state); const paddingObject = (0, $fvpw6.getPaddingObject)(padding); const altContext = elementContext === "floating" ? "reference" : "floating"; const element = elements[altBoundary ? altContext : elementContext]; const clippingClientRect = (0, $fvpw6.rectToClientRect)(await platform.getClippingRect({ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating)), boundary: boundary, rootBoundary: rootBoundary, strategy: strategy })); const rect = elementContext === "floating" ? { ...rects.floating, x: x, y: y } : rects.reference; const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)); const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) ? await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || { x: 1, y: 1 } : { x: 1, y: 1 }; const elementClientRect = (0, $fvpw6.rectToClientRect)(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({ rect: rect, offsetParent: offsetParent, strategy: strategy }) : rect); return { top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x }; } /** * Provides data to position an inner element of the floating element so that it * appears centered to the reference element. * @see https://floating-ui.com/docs/arrow */ const $f50937607e0de9ef$export$f2120bbfa5450bd2 = (options)=>({ name: "arrow", options: options, async fn (state) { const { x: x, y: y, placement: placement, rects: rects, platform: platform, elements: elements, middlewareData: middlewareData } = state; // Since `element` is required, we don't Partial<> the type. const { element: element, padding: padding = 0 } = (0, $fvpw6.evaluate)(options, state) || {}; if (element == null) return {}; const paddingObject = (0, $fvpw6.getPaddingObject)(padding); const coords = { x: x, y: y }; const axis = (0, $fvpw6.getAlignmentAxis)(placement); const length = (0, $fvpw6.getAxisLength)(axis); const arrowDimensions = await platform.getDimensions(element); const isYAxis = axis === "y"; const minProp = isYAxis ? "top" : "left"; const maxProp = isYAxis ? "bottom" : "right"; const clientProp = isYAxis ? "clientHeight" : "clientWidth"; const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; const startDiff = coords[axis] - rects.reference[axis]; const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element)); let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0; // DOM platform can return `window` as the `offsetParent`. if (!clientSize || !await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent))) clientSize = elements.floating[clientProp] || rects.floating[length]; const centerToReference = endDiff / 2 - startDiff / 2; // If the padding is large enough that it causes the arrow to no longer be // centered, modify the padding so that it is centered. const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; const minPadding = (0, $fvpw6.min)(paddingObject[minProp], largestPossiblePadding); const maxPadding = (0, $fvpw6.min)(paddingObject[maxProp], largestPossiblePadding); // Make sure the arrow doesn't overflow the floating element if the center // point is outside the floating element's bounds. const min$1 = minPadding; const max = clientSize - arrowDimensions[length] - maxPadding; const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; const offset = (0, $fvpw6.clamp)(min$1, center, max); // If the reference is small enough that the arrow's padding causes it to // to point to nothing for an aligned placement, adjust the offset of the // floating element itself. To ensure `shift()` continues to take action, // a single reset is performed when this is true. const shouldAddOffset = !middlewareData.arrow && (0, $fvpw6.getAlignment)(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0; return { [axis]: coords[axis] + alignmentOffset, data: { [axis]: offset, centerOffset: center - offset - alignmentOffset, ...shouldAddOffset && { alignmentOffset: alignmentOffset } }, reset: shouldAddOffset }; } }); function $f50937607e0de9ef$var$getPlacementList(alignment, autoAlignment, allowedPlacements) { const allowedPlacementsSortedByAlignment = alignment ? [ ...allowedPlacements.filter((placement)=>(0, $fvpw6.getAlignment)(placement) === alignment), ...allowedPlacements.filter((placement)=>(0, $fvpw6.getAlignment)(placement) !== alignment) ] : allowedPlacements.filter((placement)=>(0, $fvpw6.getSide)(placement) === placement); return allowedPlacementsSortedByAlignment.filter((placement)=>{ if (alignment) return (0, $fvpw6.getAlignment)(placement) === alignment || (autoAlignment ? (0, $fvpw6.getOppositeAlignmentPlacement)(placement) !== placement : false); return true; }); } /** * Optimizes the visibility of the floating element by choosing the placement * that has the most space available automatically, without needing to specify a * preferred placement. Alternative to `flip`. * @see https://floating-ui.com/docs/autoPlacement */ const $f50937607e0de9ef$export$91fb6ecbd551914 = function(options) { if (options === void 0) options = {}; return { name: "autoPlacement", options: options, async fn (state) { var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE; const { rects: rects, middlewareData: middlewareData, placement: placement, platform: platform, elements: elements } = state; const { crossAxis: crossAxis = false, alignment: alignment, allowedPlacements: allowedPlacements = (0, $fvpw6.placements), autoAlignment: autoAlignment = true, ...detectOverflowOptions } = (0, $fvpw6.evaluate)(options, state); const placements$1 = alignment !== undefined || allowedPlacements === (0, $fvpw6.placements) ? $f50937607e0de9ef$var$getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements; const overflow = await $f50937607e0de9ef$export$37b6bde19b108ecc(state, detectOverflowOptions); const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0; const currentPlacement = placements$1[currentIndex]; if (currentPlacement == null) return {}; const alignmentSides = (0, $fvpw6.getAlignmentSides)(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); // Make `computeCoords` start from the right place. if (placement !== currentPlacement) return { reset: { placement: placements$1[0] } }; const currentOverflows = [ overflow[(0, $fvpw6.getSide)(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]] ]; const allOverflows = [ ...((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || [], { placement: currentPlacement, overflows: currentOverflows } ]; const nextPlacement = placements$1[currentIndex + 1]; // There are more placements to check. if (nextPlacement) return { data: { index: currentIndex + 1, overflows: allOverflows }, reset: { placement: nextPlacement } }; const placementsSortedByMostSpace = allOverflows.map((d)=>{ const alignment = (0, $fvpw6.getAlignment)(d.placement); return [ d.placement, alignment && crossAxis ? // Check along the mainAxis and main crossAxis side. d.overflows.slice(0, 2).reduce((acc, v)=>acc + v, 0) : // Check only the mainAxis. d.overflows[0], d.overflows ]; }).sort((a, b)=>a[1] - b[1]); const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter((d)=>d[2].slice(0, // Aligned placements should not check their opposite crossAxis // side. (0, $fvpw6.getAlignment)(d[0]) ? 2 : 3).every((v)=>v <= 0)); const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0]; if (resetPlacement !== placement) return { data: { index: currentIndex + 1, overflows: allOverflows }, reset: { placement: resetPlacement } }; return {}; } }; }; /** * Optimizes the visibility of the floating element by flipping the `placement` * in order to keep it in view when the preferred placement(s) will overflow the * clipping boundary. Alternative to `autoPlacement`. * @see https://floating-ui.com/docs/flip */ const $f50937607e0de9ef$export$8a83211c878a3f1f = function(options) { if (options === void 0) options = {}; return { name: "flip", options: options, async fn (state) { var _middlewareData$arrow, _middlewareData$flip; const { placement: placement, middlewareData: middlewareData, rects: rects, initialPlacement: initialPlacement, platform: platform, elements: elements } = state; const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true, fallbackPlacements: specifiedFallbackPlacements, fallbackStrategy: fallbackStrategy = "bestFit", fallbackAxisSideDirection: fallbackAxisSideDirection = "none", flipAlignment: flipAlignment = true, ...detectOverflowOptions } = (0, $fvpw6.evaluate)(options, state); // If a reset by the arrow was caused due to an alignment offset being // added, we should skip any logic now since `flip()` has already done its // work. // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) return {}; const side = (0, $fvpw6.getSide)(placement); const isBasePlacement = (0, $fvpw6.getSide)(initialPlacement) === initialPlacement; const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [ (0, $fvpw6.getOppositePlacement)(initialPlacement) ] : (0, $fvpw6.getExpandedPlacements)(initialPlacement)); if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") fallbackPlacements.push(...(0, $fvpw6.getOppositeAxisPlacements)(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); const placements = [ initialPlacement, ...fallbackPlacements ]; const overflow = await $f50937607e0de9ef$export$37b6bde19b108ecc(state, detectOverflowOptions); const overflows = []; let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; if (checkMainAxis) overflows.push(overflow[side]); if (checkCrossAxis) { const sides = (0, $fvpw6.getAlignmentSides)(placement, rects, rtl); overflows.push(overflow[sides[0]], overflow[sides[1]]); } overflowsData = [ ...overflowsData, { placement: placement, overflows: overflows } ]; // One or more sides is overflowing. if (!overflows.every((side)=>side <= 0)) { var _middlewareData$flip2, _overflowsData$filter; const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; const nextPlacement = placements[nextIndex]; if (nextPlacement) // Try next placement and re-run the lifecycle. return { data: { index: nextIndex, overflows: overflowsData }, reset: { placement: nextPlacement } }; // First, find the candidates that fit on the mainAxis side of overflow, // then find the placement that fits the best on the main crossAxis side. 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; // Otherwise fallback. if (!resetPlacement) switch(fallbackStrategy){ case "bestFit": { var _overflowsData$map$so; const placement = (_overflowsData$map$so = overflowsData.map((d)=>[ d.placement, d.overflows.filter((overflow)=>overflow > 0).reduce((acc, overflow)=>acc + overflow, 0) ]).sort((a, b)=>a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0]; if (placement) resetPlacement = placement; break; } case "initialPlacement": resetPlacement = initialPlacement; break; } if (placement !== resetPlacement) return { reset: { placement: resetPlacement } }; } return {}; } }; }; function $f50937607e0de9ef$var$getSideOffsets(overflow, rect) { return { top: overflow.top - rect.height, right: overflow.right - rect.width, bottom: overflow.bottom - rect.height, left: overflow.left - rect.width }; } function $f50937607e0de9ef$var$isAnySideFullyClipped(overflow) { return (0, $fvpw6.sides).some((side)=>overflow[side] >= 0); } /** * Provides data to hide the floating element in applicable situations, such as * when it is not in the same clipping context as the reference element. * @see https://floating-ui.com/docs/hide */ const $f50937607e0de9ef$export$fe8985bb6374093c = function(options) { if (options === void 0) options = {}; return { name: "hide", options: options, async fn (state) { const { rects: rects } = state; const { strategy: strategy = "referenceHidden", ...detectOverflowOptions } = (0, $fvpw6.evaluate)(options, state); switch(strategy){ case "referenceHidden": { const overflow = await $f50937607e0de9ef$export$37b6bde19b108ecc(state, { ...detectOverflowOptions, elementContext: "reference" }); const offsets = $f50937607e0de9ef$var$getSideOffsets(overflow, rects.reference); return { data: { referenceHiddenOffsets: offsets, referenceHidden: $f50937607e0de9ef$var$isAnySideFullyClipped(offsets) } }; } case "escaped": { const overflow = await $f50937607e0de9ef$export$37b6bde19b108ecc(state, { ...detectOverflowOptions, altBoundary: true }); const offsets = $f50937607e0de9ef$var$getSideOffsets(overflow, rects.floating); return { data: { escapedOffsets: offsets, escaped: $f50937607e0de9ef$var$isAnySideFullyClipped(offsets) } }; } default: return {}; } } }; }; function $f50937607e0de9ef$var$getBoundingRect(rects) { const minX = (0, $fvpw6.min)(...rects.map((rect)=>rect.left)); const minY = (0, $fvpw6.min)(...rects.map((rect)=>rect.top)); const maxX = (0, $fvpw6.max)(...rects.map((rect)=>rect.right)); const maxY = (0, $fvpw6.max)(...rects.map((rect)=>rect.bottom)); return { x: minX, y: minY, width: maxX - minX, height: maxY - minY }; } function $f50937607e0de9ef$var$getRectsByLine(rects) { const sortedRects = rects.slice().sort((a, b)=>a.y - b.y); const groups = []; let prevRect = null; for(let i = 0; i < sortedRects.length; i++){ const rect = sortedRects[i]; if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) groups.push([ rect ]); else groups[groups.length - 1].push(rect); prevRect = rect; } return groups.map((rect)=>(0, $fvpw6.rectToClientRect)($f50937607e0de9ef$var$getBoundingRect(rect))); } /** * Provides improved positioning for inline reference elements that can span * over multiple lines, such as hyperlinks or range selections. * @see https://floating-ui.com/docs/inline */ const $f50937607e0de9ef$export$18c8ad048e32c7d5 = function(options) { if (options === void 0) options = {}; return { name: "inline", options: options, async fn (state) { const { placement: placement, elements: elements, rects: rects, platform: platform, strategy: strategy } = state; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a // ClientRect's bounds, despite the event listener being triggered. A // padding of 2 seems to handle this issue. const { padding: padding = 2, x: x, y: y } = (0, $fvpw6.evaluate)(options, state); const nativeClientRects = Array.from(await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference)) || []); const clientRects = $f50937607e0de9ef$var$getRectsByLine(nativeClientRects); const fallback = (0, $fvpw6.rectToClientRect)($f50937607e0de9ef$var$getBoundingRect(nativeClientRects)); const paddingObject = (0, $fvpw6.getPaddingObject)(padding); function getBoundingClientRect() { // There are two rects and they are disjoined. if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) // Find the first rect in which the point is fully inside. return clientRects.find((rect)=>x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback; // There are 2 or more connected rects. if (clientRects.length >= 2) { if ((0, $fvpw6.getSideAxis)(placement) === "y") { const firstRect = clientRects[0]; const lastRect = clientRects[clientRects.length - 1]; const isTop = (0, $fvpw6.getSide)(placement) === "top"; const top = firstRect.top; const bottom = lastRect.bottom; const left = isTop ? firstRect.left : lastRect.left; const right = isTop ? firstRect.right : lastRect.right; const width = right - left; const height = bottom - top; return { top: top, bottom: bottom, left: left, right: right, width: width, height: height, x: left, y: top }; } const isLeftSide = (0, $fvpw6.getSide)(placement) === "left"; const maxRight = (0, $fvpw6.max)(...clientRects.map((rect)=>rect.right)); const minLeft = (0, $fvpw6.min)(...clientRects.map((rect)=>rect.left)); const measureRects = clientRects.filter((rect)=>isLeftSide ? rect.left === minLeft : rect.right === maxRight); const top = measureRects[0].top; const bottom = measureRects[measureRects.length - 1].bottom; const left = minLeft; const right = maxRight; const width = right - left; const height = bottom - top; return { top: top, bottom: bottom, left: left, right: right, width: width, height: height, x: left, y: top }; } return fallback; } const resetRects = await platform.getElementRects({ reference: { getBoundingClientRect: getBoundingClientRect }, floating: elements.floating, strategy: strategy }); if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) return { reset: { rects: resetRects } }; return {}; } }; }; // For type backwards-compatibility, the `OffsetOptions` type was also // Derivable. async function $f50937607e0de9ef$var$convertValueToCoords(state, options) { const { placement: placement, platform: platform, elements: elements } = state; const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); const side = (0, $fvpw6.getSide)(placement); const alignment = (0, $fvpw6.getAlignment)(placement); const isVertical = (0, $fvpw6.getSideAxis)(placement) === "y"; const mainAxisMulti = [ "left", "top" ].includes(side) ? -1 : 1; const crossAxisMulti = rtl && isVertical ? -1 : 1; const rawValue = (0, $fvpw6.evaluate)(options, state); // eslint-disable-next-line prefer-const let { mainAxis: mainAxis, crossAxis: crossAxis, alignmentAxis: alignmentAxis } = typeof rawValue === "number" ? { mainAxis: rawValue, crossAxis: 0, alignmentAxis: null } : { mainAxis: 0, crossAxis: 0, alignmentAxis: null, ...rawValue }; if (alignment && typeof alignmentAxis === "number") crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; return isVertical ? { x: crossAxis * crossAxisMulti, y: mainAxis * mainAxisMulti } : { x: mainAxis * mainAxisMulti, y: crossAxis * crossAxisMulti }; } /** * Modifies the placement by translating the floating element along the * specified axes. * A number (shorthand for `mainAxis` or distance), or an axes configuration * object may be passed. * @see https://floating-ui.com/docs/offset */ const $f50937607e0de9ef$export$cc800923e997bb8 = function(options) { if (options === void 0) options = 0; return { name: "offset", options: options, async fn (state) { const { x: x, y: y } = state; const diffCoords = await $f50937607e0de9ef$var$convertValueToCoords(state, options); return { x: x + diffCoords.x, y: y + diffCoords.y, data: diffCoords }; } }; }; /** * Optimizes the visibility of the floating element by shifting it in order to * keep it in view when it will overflow the clipping boundary. * @see https://floating-ui.com/docs/shift */ const $f50937607e0de9ef$export$fba63a578e423eb = function(options) { if (options === void 0) options = {}; return { name: "shift", options: options, async fn (state) { const { x: x, y: y, placement: placement } = state; const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = false, limiter: limiter = { fn: (_ref)=>{ let { x: x, y: y } = _ref; return { x: x, y: y }; } }, ...detectOverflowOptions } = (0, $fvpw6.evaluate)(options, state); const coords = { x: x, y: y }; const overflow = await $f50937607e0de9ef$export$37b6bde19b108ecc(state, detectOverflowOptions); const crossAxis = (0, $fvpw6.getSideAxis)((0, $fvpw6.getSide)(placement)); const mainAxis = (0, $fvpw6.getOppositeAxis)(crossAxis); let mainAxisCoord = coords[mainAxis]; let crossAxisCoord = coords[crossAxis]; if (checkMainAxis) { const minSide = mainAxis === "y" ? "top" : "left"; const maxSide = mainAxis === "y" ? "bottom" : "right"; const min = mainAxisCoord + overflow[minSide]; const max = mainAxisCoord - overflow[maxSide]; mainAxisCoord = (0, $fvpw6.clamp)(min, mainAxisCoord, max); } if (checkCrossAxis) { const minSide = crossAxis === "y" ? "top" : "left"; const maxSide = crossAxis === "y" ? "bottom" : "right"; const min = crossAxisCoord + overflow[minSide]; const max = crossAxisCoord - overflow[maxSide]; crossAxisCoord = (0, $fvpw6.clamp)(min, crossAxisCoord, max); } const limitedCoords = limiter.fn({ ...state, [mainAxis]: mainAxisCoord, [crossAxis]: crossAxisCoord }); return { ...limitedCoords, data: { x: limitedCoords.x - x, y: limitedCoords.y - y } }; } }; }; /** * Built-in `limiter` that will stop `shift()` at a certain point. */ const $f50937607e0de9ef$export$7bf07e38f3dc4b69 = function(options) { if (options === void 0) options = {}; return { options: options, fn (state) { const { x: x, y: y, placement: placement, rects: rects, middlewareData: middlewareData } = state; const { offset: offset = 0, mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true } = (0, $fvpw6.evaluate)(options, state); const coords = { x: x, y: y }; const crossAxis = (0, $fvpw6.getSideAxis)(placement); const mainAxis = (0, $fvpw6.getOppositeAxis)(crossAxis); let mainAxisCoord = coords[mainAxis]; let crossAxisCoord = coords[crossAxis]; const rawOffset = (0, $fvpw6.evaluate)(offset, state); const computedOffset = typeof rawOffset === "number" ? { mainAxis: rawOffset, crossAxis: 0 } : { mainAxis: 0, crossAxis: 0, ...rawOffset }; if (checkMainAxis) { const len = mainAxis === "y" ? "height" : "width"; const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; if (mainAxisCoord < limitMin) mainAxisCoord = limitMin; else if (mainAxisCoord > limitMax) mainAxisCoord = limitMax; } if (checkCrossAxis) { var _middlewareData$offse, _middlewareData$offse2; const len = mainAxis === "y" ? "width" : "height"; const isOriginSide = [ "top", "left" ].includes((0, $fvpw6.getSide)(placement)); 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); 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); if (crossAxisCoord < limitMin) crossAxisCoord = limitMin; else if (crossAxisCoord > limitMax) crossAxisCoord = limitMax; } return { [mainAxis]: mainAxisCoord, [crossAxis]: crossAxisCoord }; } }; }; /** * Provides data that allows you to change the size of the floating element — * for instance, prevent it from overflowing the clipping boundary or match the * width of the reference element. * @see https://floating-ui.com/docs/size */ const $f50937607e0de9ef$export$346677f925de839c = function(options) { if (options === void 0) options = {}; return { name: "size", options: options, async fn (state) { const { placement: placement, rects: rects, platform: platform, elements: elements } = state; const { apply: apply = ()=>{}, ...detectOverflowOptions } = (0, $fvpw6.evaluate)(options, state); const overflow = await $f50937607e0de9ef$export$37b6bde19b108ecc(state, detectOverflowOptions); const side = (0, $fvpw6.getSide)(placement); const alignment = (0, $fvpw6.getAlignment)(placement); const isYAxis = (0, $fvpw6.getSideAxis)(placement) === "y"; const { width: width, height: height } = rects.floating; let heightSide; let widthSide; if (side === "top" || side === "bottom") { heightSide = side; widthSide = alignment === (await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; } else { widthSide = side; heightSide = alignment === "end" ? "top" : "bottom"; } const overflowAvailableHeight = height - overflow[heightSide]; const overflowAvailableWidth = width - overflow[widthSide]; const noShift = !state.middlewareData.shift; let availableHeight = overflowAvailableHeight; let availableWidth = overflowAvailableWidth; if (isYAxis) { const maximumClippingWidth = width - overflow.left - overflow.right; availableWidth = alignment || noShift ? (0, $fvpw6.min)(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth; } else { const maximumClippingHeight = height - overflow.top - overflow.bottom; availableHeight = alignment || noShift ? (0, $fvpw6.min)(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight; } if (noShift && !alignment) { const xMin = (0, $fvpw6.max)(overflow.left, 0); const xMax = (0, $fvpw6.max)(overflow.right, 0); const yMin = (0, $fvpw6.max)(overflow.top, 0); const yMax = (0, $fvpw6.max)(overflow.bottom, 0); if (isYAxis) availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : (0, $fvpw6.max)(overflow.left, overflow.right)); else availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : (0, $fvpw6.max)(overflow.top, overflow.bottom)); } await apply({ ...state, availableWidth: availableWidth, availableHeight: availableHeight }); const nextDimensions = await platform.getDimensions(elements.floating); if (width !== nextDimensions.width || height !== nextDimensions.height) return { reset: { rects: true } }; return {}; } }; }; }); parcelRegister("91fsP", function(module, exports) { $parcel$export(module.exports, "platform", () => $691033dc47d95db1$export$722a64dea1b767dc); $parcel$export(module.exports, "autoUpdate", () => $691033dc47d95db1$export$deee3a793edee05f); $parcel$export(module.exports, "computePosition", () => $691033dc47d95db1$export$48a53dcb22e581d0); $parcel$export(module.exports, "getOverflowAncestors", () => (parcelRequire("8Xnp2")).getOverflowAncestors); parcelRequire("l2jTt"); var $fvpw6 = parcelRequire("fvpw6"); var $l2jTt = parcelRequire("l2jTt"); var $fvpw6 = parcelRequire("fvpw6"); var $8Xnp2 = parcelRequire("8Xnp2"); function $691033dc47d95db1$var$getCssDimensions(element) { const css = (0, $8Xnp2.getComputedStyle)(element); // In testing environments, the `width` and `height` properties are empty // strings for SVG elements, returning NaN. Fallback to `0` in this case. let width = parseFloat(css.width) || 0; let height = parseFloat(css.height) || 0; const hasOffset = (0, $8Xnp2.isHTMLElement)(element); const offsetWidth = hasOffset ? element.offsetWidth : width; const offsetHeight = hasOffset ? element.offsetHeight : height; const shouldFallback = (0, $fvpw6.round)(width) !== offsetWidth || (0, $fvpw6.round)(height) !== offsetHeight; if (shouldFallback) { width = offsetWidth; height = offsetHeight; } return { width: width, height: height, $: shouldFallback }; } function $691033dc47d95db1$var$unwrapElement(element) { return !(0, $8Xnp2.isElement)(element) ? element.contextElement : element; } function $691033dc47d95db1$var$getScale(element) { const domElement = $691033dc47d95db1$var$unwrapElement(element); if (!(0, $8Xnp2.isHTMLElement)(domElement)) return (0, $fvpw6.createCoords)(1); const rect = domElement.getBoundingClientRect(); const { width: width, height: height, $: $ } = $691033dc47d95db1$var$getCssDimensions(domElement); let x = ($ ? (0, $fvpw6.round)(rect.width) : rect.width) / width; let y = ($ ? (0, $fvpw6.round)(rect.height) : rect.height) / height; // 0, NaN, or Infinity should always fallback to 1. if (!x || !Number.isFinite(x)) x = 1; if (!y || !Number.isFinite(y)) y = 1; return { x: x, y: y }; } const $691033dc47d95db1$var$noOffsets = /*#__PURE__*/ (0, $fvpw6.createCoords)(0); function $691033dc47d95db1$var$getVisualOffsets(element) { const win = (0, $8Xnp2.getWindow)(element); if (!(0, $8Xnp2.isWebKit)() || !win.visualViewport) return $691033dc47d95db1$var$noOffsets; return { x: win.visualViewport.offsetLeft, y: win.visualViewport.offsetTop }; } function $691033dc47d95db1$var$shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { if (isFixed === void 0) isFixed = false; if (!floatingOffsetParent || isFixed && floatingOffsetParent !== (0, $8Xnp2.getWindow)(element)) return false; return isFixed; } function $691033dc47d95db1$var$getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { if (includeScale === void 0) includeScale = false; if (isFixedStrategy === void 0) isFixedStrategy = false; const clientRect = element.getBoundingClientRect(); const domElement = $691033dc47d95db1$var$unwrapElement(element); let scale = (0, $fvpw6.createCoords)(1); if (includeScale) { if (offsetParent) { if ((0, $8Xnp2.isElement)(offsetParent)) scale = $691033dc47d95db1$var$getScale(offsetParent); } else scale = $691033dc47d95db1$var$getScale(element); } const visualOffsets = $691033dc47d95db1$var$shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? $691033dc47d95db1$var$getVisualOffsets(domElement) : (0, $fvpw6.createCoords)(0); let x = (clientRect.left + visualOffsets.x) / scale.x; let y = (clientRect.top + visualOffsets.y) / scale.y; let width = clientRect.width / scale.x; let height = clientRect.height / scale.y; if (domElement) { const win = (0, $8Xnp2.getWindow)(domElement); const offsetWin = offsetParent && (0, $8Xnp2.isElement)(offsetParent) ? (0, $8Xnp2.getWindow)(offsetParent) : offsetParent; let currentIFrame = win.frameElement; while(currentIFrame && offsetParent && offsetWin !== win){ const iframeScale = $691033dc47d95db1$var$getScale(currentIFrame); const iframeRect = currentIFrame.getBoundingClientRect(); const css = (0, $8Xnp2.getComputedStyle)(currentIFrame); const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; x *= iframeScale.x; y *= iframeScale.y; width *= iframeScale.x; height *= iframeScale.y; x += left; y += top; currentIFrame = (0, $8Xnp2.getWindow)(currentIFrame).frameElement; } } return (0, $fvpw6.rectToClientRect)({ width: width, height: height, x: x, y: y }); } function $691033dc47d95db1$var$convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { let { rect: rect, offsetParent: offsetParent, strategy: strategy } = _ref; const isOffsetParentAnElement = (0, $8Xnp2.isHTMLElement)(offsetParent); const documentElement = (0, $8Xnp2.getDocumentElement)(offsetParent); if (offsetParent === documentElement) return rect; let scroll = { scrollLeft: 0, scrollTop: 0 }; let scale = (0, $fvpw6.createCoords)(1); const offsets = (0, $fvpw6.createCoords)(0); if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") { if ((0, $8Xnp2.getNodeName)(offsetParent) !== "body" || (0, $8Xnp2.isOverflowElement)(documentElement)) scroll = (0, $8Xnp2.getNodeScroll)(offsetParent); if ((0, $8Xnp2.isHTMLElement)(offsetParent)) { const offsetRect = $691033dc47d95db1$var$getBoundingClientRect(offsetParent); scale = $691033dc47d95db1$var$getScale(offsetParent); offsets.x = offsetRect.x + offsetParent.clientLeft; offsets.y = offsetRect.y + offsetParent.clientTop; } } return { width: rect.width * scale.x, height: rect.height * scale.y, x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x, y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y }; } function $691033dc47d95db1$var$getClientRects(element) { return Array.from(element.getClientRects()); } function $691033dc47d95db1$var$getWindowScrollBarX(element) { // If has a CSS width greater than the viewport, then this will be // incorrect for RTL. return $691033dc47d95db1$var$getBoundingClientRect((0, $8Xnp2.getDocumentElement)(element)).left + (0, $8Xnp2.getNodeScroll)(element).scrollLeft; } // Gets the entire size of the scrollable document area, even extending outside // of the `` and `` rect bounds if horizontally scrollable. function $691033dc47d95db1$var$getDocumentRect(element) { const html = (0, $8Xnp2.getDocumentElement)(element); const scroll = (0, $8Xnp2.getNodeScroll)(element); const body = element.ownerDocument.body; const width = (0, $fvpw6.max)(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); const height = (0, $fvpw6.max)(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); let x = -scroll.scrollLeft + $691033dc47d95db1$var$getWindowScrollBarX(element); const y = -scroll.scrollTop; if ((0, $8Xnp2.getComputedStyle)(body).direction === "rtl") x += (0, $fvpw6.max)(html.clientWidth, body.clientWidth) - width; return { width: width, height: height, x: x, y: y }; } function $691033dc47d95db1$var$getViewportRect(element, strategy) { const win = (0, $8Xnp2.getWindow)(element); const html = (0, $8Xnp2.getDocumentElement)(element); const visualViewport = win.visualViewport; let width = html.clientWidth; let height = html.clientHeight; let x = 0; let y = 0; if (visualViewport) { width = visualViewport.width; height = visualViewport.height; const visualViewportBased = (0, $8Xnp2.isWebKit)(); if (!visualViewportBased || visualViewportBased && strategy === "fixed") { x = visualViewport.offsetLeft; y = visualViewport.offsetTop; } } return { width: width, height: height, x: x, y: y }; } // Returns the inner client rect, subtracting scrollbars if present. function $691033dc47d95db1$var$getInnerBoundingClientRect(element, strategy) { const clientRect = $691033dc47d95db1$var$getBoundingClientRect(element, true, strategy === "fixed"); const top = clientRect.top + element.clientTop; const left = clientRect.left + element.clientLeft; const scale = (0, $8Xnp2.isHTMLElement)(element) ? $691033dc47d95db1$var$getScale(element) : (0, $fvpw6.createCoords)(1); const width = element.clientWidth * scale.x; const height = element.clientHeight * scale.y; const x = left * scale.x; const y = top * scale.y; return { width: width, height: height, x: x, y: y }; } function $691033dc47d95db1$var$getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { let rect; if (clippingAncestor === "viewport") rect = $691033dc47d95db1$var$getViewportRect(element, strategy); else if (clippingAncestor === "document") rect = $691033dc47d95db1$var$getDocumentRect((0, $8Xnp2.getDocumentElement)(element)); else if ((0, $8Xnp2.isElement)(clippingAncestor)) rect = $691033dc47d95db1$var$getInnerBoundingClientRect(clippingAncestor, strategy); else { const visualOffsets = $691033dc47d95db1$var$getVisualOffsets(element); rect = { ...clippingAncestor, x: clippingAncestor.x - visualOffsets.x, y: clippingAncestor.y - visualOffsets.y }; } return (0, $fvpw6.rectToClientRect)(rect); } function $691033dc47d95db1$var$hasFixedPositionAncestor(element, stopNode) { const parentNode = (0, $8Xnp2.getParentNode)(element); if (parentNode === stopNode || !(0, $8Xnp2.isElement)(parentNode) || (0, $8Xnp2.isLastTraversableNode)(parentNode)) return false; return (0, $8Xnp2.getComputedStyle)(parentNode).position === "fixed" || $691033dc47d95db1$var$hasFixedPositionAncestor(parentNode, stopNode); } // A "clipping ancestor" is an `overflow` element with the characteristic of // clipping (or hiding) child elements. This returns all clipping ancestors // of the given element up the tree. function $691033dc47d95db1$var$getClippingElementAncestors(element, cache) { const cachedResult = cache.get(element); if (cachedResult) return cachedResult; let result = (0, $8Xnp2.getOverflowAncestors)(element, [], false).filter((el)=>(0, $8Xnp2.isElement)(el) && (0, $8Xnp2.getNodeName)(el) !== "body"); let currentContainingBlockComputedStyle = null; const elementIsFixed = (0, $8Xnp2.getComputedStyle)(element).position === "fixed"; let currentNode = elementIsFixed ? (0, $8Xnp2.getParentNode)(element) : element; // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block while((0, $8Xnp2.isElement)(currentNode) && !(0, $8Xnp2.isLastTraversableNode)(currentNode)){ const computedStyle = (0, $8Xnp2.getComputedStyle)(currentNode); const currentNodeIsContaining = (0, $8Xnp2.isContainingBlock)(currentNode); if (!currentNodeIsContaining && computedStyle.position === "fixed") currentContainingBlockComputedStyle = null; const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && [ "absolute", "fixed" ].includes(currentContainingBlockComputedStyle.position) || (0, $8Xnp2.isOverflowElement)(currentNode) && !currentNodeIsContaining && $691033dc47d95db1$var$hasFixedPositionAncestor(element, currentNode); if (shouldDropCurrentNode) // Drop non-containing blocks. result = result.filter((ancestor)=>ancestor !== currentNode); else // Record last containing block for next iteration. currentContainingBlockComputedStyle = computedStyle; currentNode = (0, $8Xnp2.getParentNode)(currentNode); } cache.set(element, result); return result; } // Gets the maximum area that the element is visible in due to any number of // clipping ancestors. function $691033dc47d95db1$var$getClippingRect(_ref) { let { element: element, boundary: boundary, rootBoundary: rootBoundary, strategy: strategy } = _ref; const elementClippingAncestors = boundary === "clippingAncestors" ? $691033dc47d95db1$var$getClippingElementAncestors(element, this._c) : [].concat(boundary); const clippingAncestors = [ ...elementClippingAncestors, rootBoundary ]; const firstClippingAncestor = clippingAncestors[0]; const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor)=>{ const rect = $691033dc47d95db1$var$getClientRectFromClippingAncestor(element, clippingAncestor, strategy); accRect.top = (0, $fvpw6.max)(rect.top, accRect.top); accRect.right = (0, $fvpw6.min)(rect.right, accRect.right); accRect.bottom = (0, $fvpw6.min)(rect.bottom, accRect.bottom); accRect.left = (0, $fvpw6.max)(rect.left, accRect.left); return accRect; }, $691033dc47d95db1$var$getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy)); return { width: clippingRect.right - clippingRect.left, height: clippingRect.bottom - clippingRect.top, x: clippingRect.left, y: clippingRect.top }; } function $691033dc47d95db1$var$getDimensions(element) { return $691033dc47d95db1$var$getCssDimensions(element); } function $691033dc47d95db1$var$getRectRelativeToOffsetParent(element, offsetParent, strategy) { const isOffsetParentAnElement = (0, $8Xnp2.isHTMLElement)(offsetParent); const documentElement = (0, $8Xnp2.getDocumentElement)(offsetParent); const isFixed = strategy === "fixed"; const rect = $691033dc47d95db1$var$getBoundingClientRect(element, true, isFixed, offsetParent); let scroll = { scrollLeft: 0, scrollTop: 0 }; const offsets = (0, $fvpw6.createCoords)(0); if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { if ((0, $8Xnp2.getNodeName)(offsetParent) !== "body" || (0, $8Xnp2.isOverflowElement)(documentElement)) scroll = (0, $8Xnp2.getNodeScroll)(offsetParent); if (isOffsetParentAnElement) { const offsetRect = $691033dc47d95db1$var$getBoundingClientRect(offsetParent, true, isFixed, offsetParent); offsets.x = offsetRect.x + offsetParent.clientLeft; offsets.y = offsetRect.y + offsetParent.clientTop; } else if (documentElement) offsets.x = $691033dc47d95db1$var$getWindowScrollBarX(documentElement); } return { x: rect.left + scroll.scrollLeft - offsets.x, y: rect.top + scroll.scrollTop - offsets.y, width: rect.width, height: rect.height }; } function $691033dc47d95db1$var$getTrueOffsetParent(element, polyfill) { if (!(0, $8Xnp2.isHTMLElement)(element) || (0, $8Xnp2.getComputedStyle)(element).position === "fixed") return null; if (polyfill) return polyfill(element); return element.offsetParent; } // Gets the closest ancestor positioned element. Handles some edge cases, // such as table ancestors and cross browser bugs. function $691033dc47d95db1$var$getOffsetParent(element, polyfill) { const window = (0, $8Xnp2.getWindow)(element); if (!(0, $8Xnp2.isHTMLElement)(element)) return window; let offsetParent = $691033dc47d95db1$var$getTrueOffsetParent(element, polyfill); while(offsetParent && (0, $8Xnp2.isTableElement)(offsetParent) && (0, $8Xnp2.getComputedStyle)(offsetParent).position === "static")offsetParent = $691033dc47d95db1$var$getTrueOffsetParent(offsetParent, polyfill); if (offsetParent && ((0, $8Xnp2.getNodeName)(offsetParent) === "html" || (0, $8Xnp2.getNodeName)(offsetParent) === "body" && (0, $8Xnp2.getComputedStyle)(offsetParent).position === "static" && !(0, $8Xnp2.isContainingBlock)(offsetParent))) return window; return offsetParent || (0, $8Xnp2.getContainingBlock)(element) || window; } const $691033dc47d95db1$var$getElementRects = async function(_ref) { let { reference: reference, floating: floating, strategy: strategy } = _ref; const getOffsetParentFn = this.getOffsetParent || $691033dc47d95db1$var$getOffsetParent; const getDimensionsFn = this.getDimensions; return { reference: $691033dc47d95db1$var$getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy), floating: { x: 0, y: 0, ...await getDimensionsFn(floating) } }; }; function $691033dc47d95db1$var$isRTL(element) { return (0, $8Xnp2.getComputedStyle)(element).direction === "rtl"; } const $691033dc47d95db1$export$722a64dea1b767dc = { convertOffsetParentRelativeRectToViewportRelativeRect: $691033dc47d95db1$var$convertOffsetParentRelativeRectToViewportRelativeRect, getDocumentElement: $8Xnp2.getDocumentElement, getClippingRect: $691033dc47d95db1$var$getClippingRect, getOffsetParent: $691033dc47d95db1$var$getOffsetParent, getElementRects: $691033dc47d95db1$var$getElementRects, getClientRects: $691033dc47d95db1$var$getClientRects, getDimensions: $691033dc47d95db1$var$getDimensions, getScale: $691033dc47d95db1$var$getScale, isElement: $8Xnp2.isElement, isRTL: $691033dc47d95db1$var$isRTL }; // https://samthor.au/2021/observing-dom/ function $691033dc47d95db1$var$observeMove(element, onMove) { let io = null; let timeoutId; const root = (0, $8Xnp2.getDocumentElement)(element); function cleanup() { clearTimeout(timeoutId); io && io.disconnect(); io = null; } function refresh(skip, threshold) { if (skip === void 0) skip = false; if (threshold === void 0) threshold = 1; cleanup(); const { left: left, top: top, width: width, height: height } = element.getBoundingClientRect(); if (!skip) onMove(); if (!width || !height) return; const insetTop = (0, $fvpw6.floor)(top); const insetRight = (0, $fvpw6.floor)(root.clientWidth - (left + width)); const insetBottom = (0, $fvpw6.floor)(root.clientHeight - (top + height)); const insetLeft = (0, $fvpw6.floor)(left); const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; const options = { rootMargin: rootMargin, threshold: (0, $fvpw6.max)(0, (0, $fvpw6.min)(1, threshold)) || 1 }; let isFirstUpdate = true; function handleObserve(entries) { const ratio = entries[0].intersectionRatio; if (ratio !== threshold) { if (!isFirstUpdate) return refresh(); if (!ratio) timeoutId = setTimeout(()=>{ refresh(false, 1e-7); }, 100); else refresh(false, ratio); } isFirstUpdate = false; } // Older browsers don't support a `document` as the root and will throw an // error. try { io = new IntersectionObserver(handleObserve, { ...options, // Handle