Socket
Socket
Sign inDemoInstall

@floating-ui/react-dom-interactions

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@floating-ui/react-dom-interactions - npm Package Compare versions

Comparing version 0.13.1 to 0.13.2

2

dist/floating-ui.react-dom-interactions.esm.min.js

@@ -1,1 +0,1 @@

import{useFloating as e,offset as t,detectOverflow as n,getOverflowAncestors as r}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import*as o from"react";import{useLayoutEffect as u,useEffect as c,useRef as l}from"react";import{createPortal as i,flushSync as s}from"react-dom";import{tabbable as a}from"tabbable";import{hideOthers as f}from"aria-hidden";var d="undefined"!=typeof document?u:c;function v(){const e=new Map;return{emit(t,n){var r;null==(r=e.get(t))||r.forEach((e=>e(n)))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){e.set(t,(e.get(t)||[]).filter((e=>e!==n)))}}}let m=!1,p=0;const g=()=>"floating-ui-"+p++;const b=o["useId".toString()],h=null!=b?b:function(){const[e,t]=o.useState((()=>m?g():void 0));return d((()=>{null==e&&t(g())}),[]),o.useEffect((()=>{m||(m=!0)}),[]),e},y=o.createContext(null),w=o.createContext(null),E=()=>{var e,t;return null!=(e=null==(t=o.useContext(y))?void 0:t.id)?e:null},R=()=>o.useContext(w),x=e=>{const t=h(),n=R(),r=E(),o=e||r;return d((()=>{const e={id:t,parentId:o};return null==n||n.addNode(e),()=>{null==n||n.removeNode(e)}}),[n,t,o]),t},k=e=>{let{children:t,id:n}=e;const r=E();return o.createElement(y.Provider,{value:o.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},I=e=>{let{children:t}=e;const n=o.useRef([]),r=o.useCallback((e=>{n.current=[...n.current,e]}),[]),u=o.useCallback((e=>{n.current=n.current.filter((t=>t!==e))}),[]),c=o.useState((()=>v()))[0];return o.createElement(w.Provider,{value:o.useMemo((()=>({nodesRef:n,addNode:r,removeNode:u,events:c})),[n,r,u,c])},t)};function T(e){var t;return null!=(t=null==e?void 0:e.ownerDocument)?t:document}function C(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}function L(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map((e=>{let{brand:t,version:n}=e;return t+"/"+n})).join(" "):navigator.userAgent}function M(e){var t;return null!=(t=T(e).defaultView)?t:window}function A(e){return!!e&&e instanceof M(e).Element}function O(e){return!!e&&e instanceof M(e).HTMLElement}function S(e){if(0===e.mozInputSource&&e.isTrusted)return!0;const t=/Android/i;return(t.test(C())||t.test(L()))&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType}function P(e){return 0===e.width&&0===e.height||1===e.width&&1===e.height&&0===e.pressure&&0===e.detail&&"mouse"!==e.pointerType||e.width<1&&e.height<1&&0===e.pressure&&0===e.detail}function D(){return/apple/i.test(navigator.vendor)}function F(){return C().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}const H=o["useInsertionEffect".toString()]||(e=>e());function N(e){const t=o.useRef((()=>{}));return H((()=>{t.current=e})),o.useCallback((function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return null==t.current?void 0:t.current(...n)}),[])}function K(t){let{open:n=!1,onOpenChange:r,whileElementsMounted:u,placement:c,middleware:l,strategy:i,nodeId:s}=void 0===t?{}:t;const[a,f]=o.useState(null),m=R(),p=o.useRef(null),g=o.useRef({}),b=o.useState((()=>v()))[0],h=e({placement:c,middleware:l,strategy:i,whileElementsMounted:u}),y=N(r),w=o.useMemo((()=>({...h.refs,domReference:p})),[h.refs]),E=o.useMemo((()=>({...h,refs:w,dataRef:g,nodeId:s,events:b,open:n,onOpenChange:y,_:{domReference:a}})),[h,s,b,n,y,w,a]);d((()=>{const e=null==m?void 0:m.nodesRef.current.find((e=>e.id===s));e&&(e.context=E)}));const{reference:x}=h,k=o.useCallback((e=>{(A(e)||null===e)&&(E.refs.domReference.current=e,f(e)),x(e)}),[x,E.refs]);return o.useMemo((()=>({...h,context:E,refs:w,reference:k})),[h,w,E,k])}function j(e,t,n){const r=new Map;return{..."floating"===n&&{tabIndex:-1},...e,...t.map((e=>e?e[n]:null)).concat(e).reduce(((e,t)=>t?(Object.entries(t).forEach((t=>{let[n,o]=t;var u;0===n.indexOf("on")?(r.has(n)||r.set(n,[]),"function"==typeof o&&(null==(u=r.get(n))||u.push(o),e[n]=function(){for(var e,t=arguments.length,o=new Array(t),u=0;u<t;u++)o[u]=arguments[u];null==(e=r.get(n))||e.forEach((e=>e(...o)))})):e[n]=o})),e):e),{})}}const B=function(e){void 0===e&&(e=[]);const t=e,n=o.useCallback((t=>j(t,e,"reference")),t),r=o.useCallback((t=>j(t,e,"floating")),t),u=o.useCallback((t=>j(t,e,"item")),t);return o.useMemo((()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:u})),[n,r,u])};function W(e,t){if(!e||!t)return!1;const n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&(r=n,"undefined"!=typeof ShadowRoot&&(r instanceof M(r).ShadowRoot||r instanceof ShadowRoot))){let n=t;do{if(n&&e===n)return!0;n=n.parentNode||n.host}while(n)}var r;return!1}function V(e,t){var n;let r=null!=(n=e.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})))?n:[],o=r;for(;o.length;){var u;o=null!=(u=e.filter((e=>{var t;return null==(t=o)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})))?u:[],r=r.concat(o)}return r}function _(e){return"composedPath"in e?e.composedPath()[0]:e.target}function X(e){let t,{restMs:n=0,buffer:r=.5,blockPointerEvents:o=!0,debug:u=null}=void 0===e?{}:e,c=!1;const l=e=>{let{x:o,y:u,placement:l,refs:i,onClose:s,nodeId:a,tree:f,leave:d=!1}=e;return function(e){function v(){clearTimeout(t),s()}clearTimeout(t);const{clientX:m,clientY:p}=e,g=_(e);if("mousemove"===e.type&&W(i.domReference.current,g))return;if("mouseleave"===e.type&&A(e.relatedTarget)&&W(i.floating.current,e.relatedTarget))return;if(f&&V(f.nodesRef.current,a).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if(W(i.floating.current,g)&&!d)return void(c=!0);if(!i.domReference.current||!i.floating.current||null==l||null==o||null==u)return;const b=i.domReference.current.getBoundingClientRect(),h=i.floating.current.getBoundingClientRect(),y=l.split("-")[0],w=o>h.right-h.width/2,E=u>h.bottom-h.height/2;if("top"===y&&u>=b.bottom-1||"bottom"===y&&u<=b.top+1||"left"===y&&o>=b.right-1||"right"===y&&o<=b.left+1)return v();switch(y){case"top":if(m>=h.left&&m<=h.right&&p>=h.top&&p<=b.top+1)return;break;case"bottom":if(m>=h.left&&m<=h.right&&p>=b.bottom-1&&p<=h.bottom)return;break;case"left":if(m>=h.left&&m<=b.left+1&&p>=h.top&&p<=h.bottom)return;break;case"right":if(m>=b.right-1&&m<=h.right&&p>=h.top&&p<=h.bottom)return}if(c)return v();const R=function(e){let[t,n]=e;const o=h.width>b.width,u=h.height>b.height;switch(y){case"top":return[[o?t+r/2:w?t+4*r:t-4*r,n+r+1],[o?t-r/2:w?t+4*r:t-4*r,n+r+1],...[[h.left,w||o?h.bottom-r:h.top],[h.right,w?o?h.bottom-r:h.top:h.bottom-r]]];case"bottom":return[[o?t+r/2:w?t+4*r:t-4*r,n-r],[o?t-r/2:w?t+4*r:t-4*r,n-r],...[[h.left,w||o?h.top+r:h.bottom],[h.right,w?o?h.top+r:h.bottom:h.top+r]]];case"left":{const e=[t+r+1,u?n+r/2:E?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:E?n+4*r:n-4*r];return[...[[E||u?h.right-r:h.left,h.top],[E?u?h.right-r:h.left:h.right-r,h.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:E?n+4*r:n-4*r],[t-r,u?n-r/2:E?n+4*r:n-4*r],...[[E||u?h.left+r:h.right,h.top],[E?u?h.left+r:h.right:h.left+r,h.bottom]]]}}([o,u]);!function(e,t){const[n,r]=e;let o=!1;const u=t.length;for(let e=0,c=u-1;e<u;c=e++){const[u,l]=t[e]||[0,0],[i,s]=t[c]||[0,0];l>=r!=s>=r&&n<=(i-u)*(r-l)/(s-l)+u&&(o=!o)}return o}([m,p],R)?v():n&&(t=setTimeout(s,n))}};return l.__options={blockPointerEvents:o},l}function Y(){return Y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Y.apply(this,arguments)}const q={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 U,z;function G(e){"Tab"===e.key&&(U=e.target,clearTimeout(z))}const J=o.forwardRef((function(e,t){const n=N(e.onFocus),[r,u]=o.useState();return d((()=>(D()&&u("button"),document.addEventListener("keydown",G),()=>{document.removeEventListener("keydown",G)})),[]),o.createElement("span",Y({},e,{ref:t,tabIndex:0,role:r,"aria-hidden":!r||void 0,"data-floating-ui-focus-guard":"",style:q,onFocus:e=>{D()&&F()&&!function(e){const t=U===e.relatedTarget;return U=e.relatedTarget,clearTimeout(z),t}(e)?(e.persist(),z=window.setTimeout((()=>{n(e)}),50)):n(e)}}))}));function Q(e){let t=e.activeElement;for(;null!=(null==(n=t)||null==(r=n.shadowRoot)?void 0:r.activeElement);){var n,r;t=t.shadowRoot.activeElement}return t}const Z=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function $(e,t){const n=a(e,Z());"prev"===t&&n.reverse();const r=n.indexOf(Q(T(e)));return n.slice(r+1)[0]}function ee(){return $(document.body,"next")}function te(){return $(document.body,"prev")}function ne(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!W(n,r)}function re(e){a(e,Z()).forEach((e=>{var t;e.dataset.tabindex=null!=(t=e.getAttribute("tabindex"))?t:"",e.setAttribute("tabindex","-1")}))}function oe(e){e.querySelectorAll("[data-tabindex]").forEach((e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")}))}const ue=o.createContext(null),ce=function(e){let{id:t,enabled:n=!0}=void 0===e?{}:e;const[r,u]=o.useState(null),c=h(),l=ie();return d((()=>{if(!n)return;const e=t?document.getElementById(t):null;if(!e){const e=document.createElement("div");e.id=t||c,e.setAttribute("data-floating-ui-portal",""),u(e);const n=(null==l?void 0:l.portalNode)||document.body;return n.appendChild(e),()=>{n.removeChild(e)}}e.setAttribute("data-floating-ui-portal",""),u(e)}),[t,l,c,n]),r},le=e=>{let{children:t,id:n,root:r=null,preserveTabOrder:u=!0}=e;const c=ce({id:n,enabled:!r}),[l,s]=o.useState(null),a=o.useRef(null),f=o.useRef(null),d=o.useRef(null),v=o.useRef(null),m=!!l&&!l.modal&&!(!r&&!c)&&u;return o.useEffect((()=>{if(c&&u&&(null==l||!l.modal))return c.addEventListener("focusin",e,!0),c.addEventListener("focusout",e,!0),()=>{c.removeEventListener("focusin",e,!0),c.removeEventListener("focusout",e,!0)};function e(e){if(c&&ne(e)){("focusin"===e.type?oe:re)(c)}}}),[c,u,null==l?void 0:l.modal]),o.createElement(ue.Provider,{value:o.useMemo((()=>({preserveTabOrder:u,beforeOutsideRef:a,afterOutsideRef:f,beforeInsideRef:d,afterInsideRef:v,portalNode:c,setFocusManagerState:s})),[u,c])},m&&c&&o.createElement(J,{ref:a,onFocus:e=>{if(ne(e,c)){var t;null==(t=d.current)||t.focus()}else{const e=te()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus()}}}),m&&c&&o.createElement("span",{"aria-owns":c.id,style:q}),r?i(t,r):c?i(t,c):null,m&&c&&o.createElement(J,{ref:f,onFocus:e=>{if(ne(e,c)){var t;null==(t=v.current)||t.focus()}else{const e=ee()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus(),null==l||l.onOpenChange(!1)}}}))},ie=()=>o.useContext(ue),se="data-floating-ui-scroll-lock",ae=o.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return d((()=>{var e,t,r,o;if(!n)return;if(document.body.hasAttribute(se))return;document.body.setAttribute(se,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(C()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(se),Object.assign(document.body.style,{overflow:"",[u]:""})};const l=null!=(e=null==(t=window.visualViewport)?void 0:t.offsetLeft)?e:0,i=null!=(r=null==(o=window.visualViewport)?void 0:o.offsetTop)?r:0,s=window.pageXOffset,a=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(a-Math.floor(i))+"px",left:-(s-Math.floor(l))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(se),window.scrollTo(s,a)}}),[n]),o.createElement("div",Y({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));function fe(e){return O(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function de(e){e.preventDefault(),e.stopPropagation()}function ve(e){const t=l(e);return d((()=>{t.current=e})),t}let me=0;function pe(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(me);const u=()=>null==e?void 0:e.focus({preventScroll:n});o?u():me=requestAnimationFrame(u)}const ge=o.forwardRef((function(e,t){return o.createElement("button",Y({},e,{ref:t,tabIndex:-1,style:q}))}));function be(e){let{context:t,children:n,order:r=["content"],guards:u=!0,initialFocus:c=0,returnFocus:l=!0,modal:i=!0,visuallyHiddenDismiss:s=!1}=e;const{refs:v,nodeId:m,onOpenChange:p,events:g,_:{domReference:b}}=t,h=ve(r),y=R(),w=ie(),[E,x]=o.useState(null),k="number"==typeof c&&c<0,I=o.useRef(null),C=o.useRef(null),L=o.useRef(!1),M=o.useRef(null),A=null!=w,S=b&&"combobox"===b.getAttribute("role")&&fe(b),P=o.useCallback((function(e){return void 0===e&&(e=v.floating.current),e?a(e,Z()):[]}),[v]),D=o.useCallback((e=>{const t=P(e);return h.current.map((e=>v.domReference.current&&"reference"===e?v.domReference.current:v.floating.current&&"floating"===e?v.floating.current:t)).filter(Boolean).flat()}),[h,v,P]);o.useEffect((()=>{if(!i)return;function e(e){if("Tab"===e.key){0!==P().length||S||de(e);const t=D(),n=_(e);"reference"===h.current[0]&&n===v.domReference.current&&(de(e),e.shiftKey?pe(t[t.length-1]):pe(t[1])),"floating"===h.current[1]&&n===v.floating.current&&e.shiftKey&&(de(e),pe(t[0]))}}const t=T(v.floating.current);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[i,h,v,S,P,D]),o.useEffect((()=>{var e,t;const n=v.floating.current,r=v.domReference.current,o=Array.from(null!=(e=null==w||null==(t=w.portalNode)?void 0:t.querySelectorAll("[data-floating-ui-portal]"))?e:[]);let u=!1;function c(){u=!0,setTimeout((()=>{u=!1}))}function l(e){const t=e.relatedTarget,o=!(W(r,t)||W(n,t)||W(t,n)||W(null==w?void 0:w.portalNode,t)||[null==w?void 0:w.beforeOutsideRef.current,null==w?void 0:w.afterOutsideRef.current].filter(Boolean).includes(t)||y&&(V(y.nodesRef.current,m).find((e=>{var n,r;return W(null==(n=e.context)?void 0:n.refs.floating.current,t)||W(null==(r=e.context)?void 0:r.refs.domReference.current,t)}))||function(e,t){var n;let r=[],o=null==(n=e.find((e=>e.id===t)))?void 0:n.parentId;for(;o;){const t=e.find((e=>e.id===o));o=null==t?void 0:t.parentId,t&&(r=r.concat(t))}return r}(y.nodesRef.current,m).find((e=>{var n,r;return(null==(n=e.context)?void 0:n.refs.floating.current)===t||(null==(r=e.context)?void 0:r.refs.domReference.current)===t}))));t&&o&&!u&&t!==M.current&&(L.current=!0,setTimeout((()=>p(!1))))}if(n&&O(r)){let e;if(i){const t=[n,...o,...[I.current,C.current].filter(Boolean)];e=f(h.current.includes("reference")||S?t.concat(r):t)}return r.addEventListener("focusout",l),r.addEventListener("pointerdown",c),!i&&n.addEventListener("focusout",l),()=>{r.removeEventListener("focusout",l),r.removeEventListener("pointerdown",c),!i&&n.removeEventListener("focusout",l),null==e||e()}}}),[i,c,m,y,h,v,w,S,k,p]),o.useEffect((()=>{const e=v.floating.current;if(i&&!u&&e){const t=[],n=Z(),r=a(T(e).body,n),o=D(),u=r.filter((e=>!o.includes(e)));return u.forEach(((e,n)=>{t[n]=e.getAttribute("tabindex"),e.setAttribute("tabindex","-1")})),()=>{u.forEach(((e,n)=>{const r=t[n];null==r?e.removeAttribute("tabindex"):e.setAttribute("tabindex",r)}))}}}),[i,u,v,D]),d((()=>{var e;const t=v.floating.current;if(!t)return;const n=T(t);let r=l,o=!1;const u=null!=(e=v.domReference.current)?e:Q(n);M.current=u;const i=D(t),s=("number"==typeof c?i[c]:c.current)||t;function a(e){if("outsidePress"!==e.type)return;const t=e.data.returnFocus;"object"==typeof t?(r=!0,o=t.preventScroll):r=t}return!k&&pe(s,{preventScroll:s===t}),g.on("dismiss",a),()=>{g.off("dismiss",a),r&&O(u)&&!L.current&&pe(u,{preventScroll:o,cancelPrevious:!1})}}),[D,c,l,v,g,k]),d((()=>{if(w)return w.setFocusManagerState({...t,modal:i}),()=>{w.setFocusManagerState(null)}}),[w,i,t]),d((()=>{0!==P().length||k||x(0)}),[P,v,k]);const F=u&&(A||i)&&!S;function H(e){return s&&i?o.createElement(ge,{ref:"start"===e?I:C,onClick:()=>p(!1)},"string"==typeof s?s:"Dismiss"):null}return o.createElement(o.Fragment,null,F&&o.createElement(J,{ref:null==w?void 0:w.beforeInsideRef,onFocus:e=>{if(i){const e=D();pe("reference"===r[0]?e[0]:e[e.length-1])}else if(null!=w&&w.preserveTabOrder&&w.portalNode)if(L.current=!1,ne(e,w.portalNode)){const e=ee()||b;null==e||e.focus()}else{var t;null==(t=w.beforeOutsideRef.current)||t.focus()}}}),S?null:H("start"),o.cloneElement(n,0===E||r.includes("floating")?{tabIndex:0}:{}),H("end"),F&&o.createElement(J,{ref:null==w?void 0:w.afterInsideRef,onFocus:e=>{if(i)pe(D()[0]);else if(null!=w&&w.preserveTabOrder&&w.portalNode)if(L.current=!0,ne(e,w.portalNode)){const e=te()||b;null==e||e.focus()}else{var t;null==(t=w.afterOutsideRef.current)||t.focus()}}}))}function he(e,t,n){return n&&"mouse"!==n?0:"number"==typeof e?e:null==e?void 0:e[t]}const ye=function(e,t){let{enabled:n=!0,delay:r=0,handleClose:u=null,mouseOnly:c=!1,restMs:l=0,move:i=!0}=void 0===t?{}:t;const{open:s,onOpenChange:a,dataRef:f,events:v,refs:m,_:p}=e,g=R(),b=E(),h=ve(u),y=ve(r),w=o.useRef(),x=o.useRef(),k=o.useRef(),I=o.useRef(),C=o.useRef(!0),L=o.useRef(!1),M=o.useCallback((()=>{var e;const t=null==(e=f.current.openEvent)?void 0:e.type;return(null==t?void 0:t.includes("mouse"))&&"mousedown"!==t}),[f]);o.useEffect((()=>{if(n)return v.on("dismiss",e),()=>{v.off("dismiss",e)};function e(){clearTimeout(x.current),clearTimeout(I.current),C.current=!0}}),[n,v,m]),o.useEffect((()=>{if(!n||!h.current||!s)return;function e(){M()&&a(!1)}const t=T(m.floating.current).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[m,s,a,n,h,f,M]);const O=o.useCallback((function(e){void 0===e&&(e=!0);const t=he(y.current,"close",w.current);t&&!k.current?(clearTimeout(x.current),x.current=setTimeout((()=>a(!1)),t)):e&&(clearTimeout(x.current),a(!1))}),[y,a]),S=o.useCallback((()=>{k.current&&(T(m.floating.current).removeEventListener("mousemove",k.current),k.current=void 0)}),[m]),P=o.useCallback((()=>{T(m.floating.current).body.style.pointerEvents="",L.current=!1}),[m]);return o.useEffect((()=>{if(!n)return;function t(){return!!f.current.openEvent&&["click","mousedown"].includes(f.current.openEvent.type)}function r(e){if(clearTimeout(x.current),C.current=!1,c&&"mouse"!==w.current||l>0&&0===he(y.current,"open"))return;f.current.openEvent=e;const t=he(y.current,"open",w.current);t?x.current=setTimeout((()=>{a(!0)}),t):a(!0)}function o(n){if(t())return;const r=T(m.floating.current);if(clearTimeout(I.current),h.current)return clearTimeout(x.current),k.current&&r.removeEventListener("mousemove",k.current),k.current=h.current({...e,tree:g,x:n.clientX,y:n.clientY,onClose(){P(),S(),O()}}),void r.addEventListener("mousemove",k.current);O()}function u(n){t()||null==h.current||h.current({...e,tree:g,x:n.clientX,y:n.clientY,leave:!0,onClose(){P(),S(),O()}})(n)}const d=m.floating.current,v=m.domReference.current;return A(v)?(s&&v.addEventListener("mouseleave",u),null==d||d.addEventListener("mouseleave",u),i&&v.addEventListener("mousemove",r,{once:!0}),v.addEventListener("mouseenter",r),v.addEventListener("mouseleave",o),()=>{s&&v.removeEventListener("mouseleave",u),null==d||d.removeEventListener("mouseleave",u),i&&v.removeEventListener("mousemove",r),v.removeEventListener("mouseenter",r),v.removeEventListener("mouseleave",o)}):void 0}),[p.domReference,n,e,c,l,i,O,S,P,a,s,g,m,y,h,f]),d((()=>{if(n&&s&&h.current&&h.current.__options.blockPointerEvents&&M()){T(m.floating.current).body.style.pointerEvents="none",L.current=!0;const n=m.domReference.current,r=m.floating.current;if(A(n)&&r){var e,t;const o=null==g||null==(e=g.nodesRef.current.find((e=>e.id===b)))||null==(t=e.context)?void 0:t.refs.floating.current;return o&&(o.style.pointerEvents=""),n.style.pointerEvents="auto",r.style.pointerEvents="auto",()=>{n.style.pointerEvents="",r.style.pointerEvents=""}}}}),[n,s,b,m,g,h,f,M]),d((()=>{s||(w.current=void 0,S(),L.current&&P())}),[s,S,P]),o.useEffect((()=>()=>{S(),clearTimeout(x.current),clearTimeout(I.current),L.current&&P()}),[n,S,P]),o.useMemo((()=>{if(!n)return{};function e(e){w.current=e.pointerType}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove(){s||0===l||(clearTimeout(I.current),I.current=setTimeout((()=>{C.current||a(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(x.current)},onMouseLeave(){O(!1)}}}}),[n,l,s,a,O])},we=o.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),Ee=()=>o.useContext(we),Re=e=>{let{children:t,delay:n}=e;const[r,u]=o.useState({delay:n,initialDelay:n,currentId:null}),c=o.useCallback((e=>{u((t=>({...t,currentId:e})))}),[]);return o.createElement(we.Provider,{value:o.useMemo((()=>({...r,setState:u,setCurrentId:c})),[r,u,c])},t)},xe=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:u}=t;const{currentId:c,initialDelay:l,setState:i}=Ee();o.useEffect((()=>{c&&(i((e=>({...e,delay:{open:1,close:he(l,"close")}}))),c!==u&&r(!1))}),[u,r,i,c,l]),o.useEffect((()=>{n||c!==u||(r(!1),i((e=>({...e,delay:l,currentId:null}))))}),[n,i,c,u,r,l])};function ke(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const Ie=e=>({name:"inner",options:e,async fn(r){var o;const{listRef:u,overflowRef:c,onFallbackChange:l,offset:i=0,index:a=0,minItemsVisible:f=4,referenceOverflowThreshold:d=0,scrollRef:v,...m}=e,{rects:p,elements:{floating:g}}=r,b=u.current[a];if(!b)return{};const h={...r,...await t(-b.offsetTop-p.reference.height/2-b.offsetHeight/2-i).fn(r)},y=null!=(o=null==v?void 0:v.current)?o:g,w=await n(ke(h,y.scrollHeight),m),E=await n(h,{...m,elementContext:"reference"}),R=Math.max(0,w.top),x=h.y+R,k=Math.max(0,y.scrollHeight-R-Math.max(0,w.bottom));return y.style.maxHeight=k+"px",y.scrollTop=R,l&&(y.offsetHeight<b.offsetHeight*Math.min(f,u.current.length-1)-1||E.top>=-d||E.bottom>=-d?s((()=>l(!0))):s((()=>l(!1)))),c&&(c.current=await n(ke({...h,y:x},y.offsetHeight),m)),{y:x}}}),Te=(e,t)=>{let{open:n,refs:r}=e,{enabled:u=!0,overflowRef:c,scrollRef:l,onChange:i}=t;const a=N(i),f=o.useRef(!1),d=o.useRef(null),v=o.useRef(null);return o.useEffect((()=>{var e;if(!u)return;function t(e){if(e.ctrlKey||!o||null==c.current)return;const t=e.deltaY,n=c.current.top>=-.5,r=c.current.bottom>=-.5,u=o.scrollHeight-o.clientHeight,l=t<0?-1:1,i=t<0?"max":"min";o.scrollHeight<=o.clientHeight||(!n&&t>0||!r&&t<0?(e.preventDefault(),s((()=>{a((e=>e+Math[i](t,u*l)))}))):/firefox/i.test(L())&&(o.scrollTop+=t))}const o=null!=(e=null==l?void 0:l.current)?e:r.floating.current;return n&&o?(o.addEventListener("wheel",t),requestAnimationFrame((()=>{d.current=o.scrollTop,null!=c.current&&(v.current={...c.current})})),()=>{d.current=null,v.current=null,o.removeEventListener("wheel",t)}):void 0}),[u,n,r,c,l,a]),o.useMemo((()=>u?{floating:{onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const e=(null==l?void 0:l.current)||r.floating.current;if(c.current&&e&&f.current){if(null!==d.current){const t=e.scrollTop-d.current;(c.current.bottom<-.5&&t<-1||c.current.top<-.5&&t>1)&&s((()=>a((e=>e+t))))}requestAnimationFrame((()=>{d.current=e.scrollTop}))}}}}:{}),[u,c,r,l,a])},Ce=function(e,t){let{open:n}=e,{enabled:r=!0,role:u="dialog"}=void 0===t?{}:t;const c=h(),l=h();return o.useMemo((()=>{const e={id:c,role:u};return r?"tooltip"===u?{reference:{"aria-describedby":n?c:void 0},floating:e}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":"alertdialog"===u?"dialog":u,"aria-controls":n?c:void 0,..."listbox"===u&&{role:"combobox"},..."menu"===u&&{id:l}},floating:{...e,..."menu"===u&&{"aria-labelledby":l}}}:{}}),[r,u,n,c,l])};function Le(e){return O(e.target)&&"BUTTON"===e.target.tagName}function Me(e){return fe(e)}const Ae=function(e,t){let{open:n,onOpenChange:r,dataRef:u,refs:c}=e,{enabled:l=!0,event:i="click",toggle:s=!0,ignoreMouse:a=!1,keyboardHandlers:f=!0}=void 0===t?{}:t;const d=o.useRef();return o.useMemo((()=>l?{reference:{onPointerDown(e){d.current=e.pointerType},onMouseDown(e){0===e.button&&("mouse"===d.current&&a||"click"!==i&&(n?!s||u.current.openEvent&&"mousedown"!==u.current.openEvent.type||r(!1):(e.preventDefault(),r(!0)),u.current.openEvent=e.nativeEvent))},onClick(e){"mousedown"===i&&d.current?d.current=void 0:"mouse"===d.current&&a||(n?!s||u.current.openEvent&&"click"!==u.current.openEvent.type||r(!1):r(!0),u.current.openEvent=e.nativeEvent)},onKeyDown(e){d.current=void 0,f&&(Le(e)||(" "!==e.key||Me(c.domReference.current)||e.preventDefault(),"Enter"===e.key&&(n?s&&r(!1):r(!0))))},onKeyUp(e){f&&(Le(e)||Me(c.domReference.current)||" "===e.key&&(n?s&&r(!1):r(!0)))}}}:{}),[l,u,i,a,f,c,s,n,r])};function Oe(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}const Se={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Pe={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},De=function(e,t){let{open:n,onOpenChange:u,refs:c,events:l,nodeId:i}=e,{enabled:s=!0,escapeKey:a=!0,outsidePress:f=!0,outsidePressEvent:d="pointerdown",referencePress:v=!1,referencePressEvent:m="pointerdown",ancestorScroll:p=!1,bubbles:g=!0}=void 0===t?{}:t;const b=R(),h=null!=E(),y=o.useRef(!1);return o.useEffect((()=>{if(!n||!s)return;function e(e){if("Escape"===e.key){if(!g&&b&&V(b.nodesRef.current,i).length>0)return;l.emit("dismiss",{type:"escapeKey",data:{returnFocus:{preventScroll:!1}}}),u(!1)}}function t(e){const t=y.current;if(y.current=!1,t)return;if("function"==typeof f&&!f(e))return;const n=_(e);if(A(n)&&c.floating.current){var r;const t=null!=(r=c.floating.current.ownerDocument.defaultView)?r:window,o=n.scrollWidth>n.clientWidth,u=n.scrollHeight>n.clientHeight;let l=u&&e.offsetX>n.clientWidth;if(u){"rtl"===t.getComputedStyle(n).direction&&(l=e.offsetX<=n.offsetWidth-n.clientWidth)}if(l||o&&e.offsetY>n.clientHeight)return}const o=b&&V(b.nodesRef.current,i).some((t=>{var n;return Oe(e,null==(n=t.context)?void 0:n.refs.floating.current)}));Oe(e,c.floating.current)||Oe(e,c.domReference.current)||o||!g&&b&&V(b.nodesRef.current,i).length>0||(l.emit("dismiss",{type:"outsidePress",data:{returnFocus:h?{preventScroll:!0}:S(e)||P(e)}}),u(!1))}function o(){u(!1)}const v=T(c.floating.current);a&&v.addEventListener("keydown",e),f&&v.addEventListener(d,t);let m=[];return p&&(A(c.domReference.current)&&(m=r(c.domReference.current)),A(c.floating.current)&&(m=m.concat(r(c.floating.current))),!A(c.reference.current)&&c.reference.current&&c.reference.current.contextElement&&(m=m.concat(r(c.reference.current.contextElement)))),m=m.filter((e=>{var t;return e!==(null==(t=v.defaultView)?void 0:t.visualViewport)})),m.forEach((e=>{e.addEventListener("scroll",o,{passive:!0})})),()=>{a&&v.removeEventListener("keydown",e),f&&v.removeEventListener(d,t),m.forEach((e=>{e.removeEventListener("scroll",o)}))}}),[a,f,d,l,b,i,n,u,p,s,g,c,h]),o.useEffect((()=>{y.current=!1}),[f,d]),o.useMemo((()=>s?{reference:{[Se[m]]:()=>{v&&(l.emit("dismiss",{type:"referencePress",data:{returnFocus:!1}}),u(!1))}},floating:{[Pe[d]]:()=>{y.current=!0}}}:{}),[s,l,v,d,m,u])},Fe=function(e,t){let{open:n,onOpenChange:r,dataRef:u,refs:c,events:l}=e,{enabled:i=!0,keyboardOnly:s=!0}=void 0===t?{}:t;const a=o.useRef(""),f=o.useRef(!1),d=o.useRef();return o.useEffect((()=>{var e;if(!i)return;const t=null!=(e=T(c.floating.current).defaultView)?e:window;function r(){!n&&O(c.domReference.current)&&c.domReference.current===Q(T(c.domReference.current))&&(f.current=!0)}return t.addEventListener("blur",r),()=>{t.removeEventListener("blur",r)}}),[c,n,i]),o.useEffect((()=>{if(i)return l.on("dismiss",e),()=>{l.off("dismiss",e)};function e(e){"referencePress"===e.type&&(f.current=!0)}}),[l,i]),o.useEffect((()=>()=>{clearTimeout(d.current)}),[]),o.useMemo((()=>i?{reference:{onPointerDown(e){let{pointerType:t}=e;a.current=t,f.current=!(!t||!s)},onPointerLeave(){f.current=!1},onFocus(e){var t;f.current||"focus"===e.type&&"mousedown"===(null==(t=u.current.openEvent)?void 0:t.type)&&u.current.openEvent&&Oe(u.current.openEvent,c.domReference.current)||(u.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){f.current=!1;const t=e.relatedTarget,n=A(t)&&t.hasAttribute("data-floating-ui-focus-guard");d.current=setTimeout((()=>{W(c.floating.current,t)||W(c.domReference.current,t)||n||r(!1)}))}}}:{}),[i,s,c,u,r])};let He=!1;function Ne(e,t,n){return Math.floor(e/t)!==n}function Ke(e,t){return t<0||t>=e.current.length}function je(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o,amount:u=1}=void 0===t?{}:t;const c=e.current;let l=n;do{var i,s;l+=r?-u:u}while(l>=0&&l<=c.length-1&&(o?o.includes(l):null==c[l]||(null==(i=c[l])?void 0:i.hasAttribute("disabled"))||"true"===(null==(s=c[l])?void 0:s.getAttribute("aria-disabled"))));return l}function Be(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function We(e,t){return Be(t,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function Ve(e,t,n){return Be(t,"ArrowDown"===e,n?"ArrowLeft"===e:"ArrowRight"===e)||"Enter"===e||" "==e||""===e}function _e(e,t){return je(e,{disabledIndices:t})}function Xe(e,t){return je(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}const Ye=function(e,t){let{open:n,onOpenChange:r,refs:u}=e,{listRef:c,activeIndex:l,onNavigate:i=(()=>{}),enabled:a=!0,selectedIndex:f=null,allowEscape:v=!1,loop:m=!1,nested:p=!1,rtl:g=!1,virtual:b=!1,focusItemOnOpen:h="auto",focusItemOnHover:y=!0,openOnArrowKeyDown:w=!0,disabledIndices:x,orientation:k="vertical",cols:I=1}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const C=E(),L=R(),M=N(i),A=o.useRef(h),H=o.useRef(null!=f?f:-1),K=o.useRef(null),j=o.useRef(!1),B=o.useRef(M),V=o.useRef(n),_=o.useRef(!1),X=ve(x),Y=ve(n),[q,U]=o.useState(),z=o.useCallback(((e,t)=>{if(b){var n;U(null==(n=e.current[t.current])?void 0:n.id)}else{pe(e.current[t.current],{preventScroll:!0,sync:!(!F()||!D())&&(He||_.current)})}}),[b]);return d((()=>{document.createElement("div").focus({get preventScroll(){return He=!0,!1}})}),[]),d((()=>{a&&(n?A.current&&null!=f&&M(f):V.current&&(H.current=-1,B.current(null)))}),[a,n,f,M]),d((()=>{if(a&&n)if(null==l){if(_.current=!1,null!=f)return;V.current&&(H.current=-1,z(c,H)),!V.current&&A.current&&(null!=K.current||!0===A.current&&null==K.current)&&(H.current=null==K.current||Ve(K.current,k,g)||p?_e(c,X.current):Xe(c,X.current),M(H.current))}else Ke(c,l)||(H.current=l,z(c,H))}),[a,n,l,f,p,c,k,g,M,z,X]),d((()=>{if(a&&V.current&&!n){var e,t;const n=null==L||null==(e=L.nodesRef.current.find((e=>e.id===C)))||null==(t=e.context)?void 0:t.refs.floating.current;n&&!W(n,Q(T(n)))&&n.focus({preventScroll:!0})}}),[a,n,L,C]),d((()=>{K.current=null,B.current=M,V.current=n})),o.useMemo((()=>{if(!a)return{};const e=X.current;function t(t){if(j.current=!0,_.current=!0,!Y.current&&t.currentTarget===u.floating.current)return;if(p&&function(e,t,n){return Be(t,n?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(t.key,k,g))return de(t),r(!1),void(O(u.domReference.current)&&u.domReference.current.focus());const o=H.current,l=_e(c,e),i=Xe(c,e);if("Home"===t.key&&(H.current=l,M(H.current)),"End"===t.key&&(H.current=i,M(H.current)),I>1){const n=H.current;if("ArrowUp"===t.key){if(de(t),-1===n)H.current=i;else if(H.current=je(c,{startingIndex:n,amount:I,decrement:!0,disabledIndices:e}),m&&(n-I<l||H.current<0)){const e=n%I,t=i%I,r=i-(t-e);H.current=t===e?i:t>e?r:r-I}Ke(c,H.current)&&(H.current=n),M(H.current)}if("ArrowDown"===t.key&&(de(t),-1===n?H.current=l:(H.current=je(c,{startingIndex:n,amount:I,disabledIndices:e}),m&&n+I>i&&(H.current=je(c,{startingIndex:n%I-I,amount:I,disabledIndices:e}))),Ke(c,H.current)&&(H.current=n),M(H.current)),"both"===k){const r=Math.floor(n/I);"ArrowRight"===t.key&&(de(t),n%I!=I-1?(H.current=je(c,{startingIndex:n,disabledIndices:e}),m&&Ne(H.current,I,r)&&(H.current=je(c,{startingIndex:n-n%I-1,disabledIndices:e}))):m&&(H.current=je(c,{startingIndex:n-n%I-1,disabledIndices:e})),Ne(H.current,I,r)&&(H.current=n)),"ArrowLeft"===t.key&&(de(t),n%I!=0?(H.current=je(c,{startingIndex:n,disabledIndices:e,decrement:!0}),m&&Ne(H.current,I,r)&&(H.current=je(c,{startingIndex:n+(I-n%I),decrement:!0,disabledIndices:e}))):m&&(H.current=je(c,{startingIndex:n+(I-n%I),decrement:!0,disabledIndices:e})),Ne(H.current,I,r)&&(H.current=n));const o=Math.floor(i/I)===r;return Ke(c,H.current)&&(H.current=m&&o?"ArrowLeft"===t.key?i:je(c,{startingIndex:n-n%I-1,disabledIndices:e}):n),void M(H.current)}}if(We(t.key,k)){if(de(t),n&&!b&&Q(t.currentTarget.ownerDocument)===t.currentTarget)return H.current=Ve(t.key,k,g)?l:i,void M(H.current);Ve(t.key,k,g)?H.current=m?o>=i?v&&o!==c.current.length?-1:l:je(c,{startingIndex:o,disabledIndices:e}):Math.min(i,je(c,{startingIndex:o,disabledIndices:e})):H.current=m?o<=l?v&&-1!==o?c.current.length:i:je(c,{startingIndex:o,decrement:!0,disabledIndices:e}):Math.max(l,je(c,{startingIndex:o,decrement:!0,disabledIndices:e})),Ke(c,H.current)?M(null):M(H.current)}}function o(e){"auto"===h&&S(e.nativeEvent)&&(A.current=!0)}return{reference:{...b&&n&&null!=l&&{"aria-activedescendant":q},onKeyDown(o){j.current=!0;const u=0===o.key.indexOf("Arrow");if(b&&n)return t(o);if(!n&&!w&&u)return;(u||"Enter"===o.key||" "===o.key||""===o.key)&&(K.current=o.key),p?function(e,t,n){return Be(t,n?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(o.key,k,g)&&(de(o),n?(H.current=_e(c,e),M(H.current)):r(!0)):We(o.key,k)&&(null!=f&&(H.current=f),de(o),!n&&w?r(!0):t(o),n&&M(H.current))},onFocus(){n&&M(null)},onPointerDown:function(e){A.current=h,"auto"===h&&P(e.nativeEvent)&&(A.current=!0)},onMouseDown:o,onClick:o},floating:{"aria-orientation":"both"===k?void 0:k,...b&&null!=l&&{"aria-activedescendant":q},onKeyDown:t,onPointerMove(){j.current=!1}},item:{onFocus(e){let{currentTarget:t}=e;const n=c.current.indexOf(t);-1!==n&&l!==n&&M(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...y&&{onMouseMove(e){let{currentTarget:t}=e;const n=t;if(n){const e=c.current.indexOf(n);-1!==e&&l!==e&&M(e)}},onPointerLeave(){var e;j.current||(H.current=-1,z(c,H),s((()=>M(null))),b||null==(e=u.floating.current)||e.focus({preventScroll:!0}))}}}}}),[q,X,Y,c,a,k,g,b,n,l,p,f,w,y,v,I,m,u,h,z,M,r])},qe=function(e,t){var n;let{open:r,dataRef:u}=e,{listRef:c,activeIndex:l,onMatch:i=(()=>{}),enabled:s=!0,findMatch:a=null,resetMs:f=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const p=o.useRef(),g=o.useRef(""),b=o.useRef(null!=(n=null!=m?m:l)?n:-1),h=o.useRef(null),y=N(i),w=ve(a),E=ve(v);return d((()=>{r&&(clearTimeout(p.current),h.current=null,g.current="")}),[r]),d((()=>{var e;r&&""===g.current&&(b.current=null!=(e=null!=m?m:l)?e:-1)}),[r,m,l]),o.useMemo((()=>{if(!s)return{};function e(e){const t=_(e.nativeEvent);if(A(t)&&Q(T(t))!==e.currentTarget&&t.closest('[role="dialog"],[role="menu"],[role="listbox"],[role="tree"],[role="grid"]')!==e.currentTarget)return;g.current.length>0&&" "!==g.current[0]&&(u.current.typing=!0," "===e.key&&de(e));const n=c.current;if(null==n||E.current.includes(e.key)||1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey)return;n.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&g.current===e.key&&(g.current="",b.current=h.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",b.current=h.current,u.current.typing=!1}),f);const r=b.current,o=[...n.slice((null!=r?r:0)+1),...n.slice(0,(null!=r?r:0)+1)],l=w.current?w.current(o,g.current):o.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current.toLocaleLowerCase())))),i=l?n.indexOf(l):-1;-1!==i&&(y(i),h.current=i)}return{reference:{onKeyDown:e},floating:{onKeyDown:e}}}),[s,u,c,f,E,w,y])};export{Re as FloatingDelayGroup,be as FloatingFocusManager,k as FloatingNode,ae as FloatingOverlay,le as FloatingPortal,I as FloatingTree,Ie as inner,X as safePolygon,Ae as useClick,xe as useDelayGroup,Ee as useDelayGroupContext,De as useDismiss,K as useFloating,x as useFloatingNodeId,E as useFloatingParentNodeId,ce as useFloatingPortalNode,R as useFloatingTree,Fe as useFocus,ye as useHover,h as useId,Te as useInnerOffset,B as useInteractions,Ye as useListNavigation,Ce as useRole,qe as useTypeahead};
import{useFloating as e,offset as t,detectOverflow as n,getOverflowAncestors as r}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import*as o from"react";import{useLayoutEffect as u,useEffect as c,useRef as l}from"react";import{createPortal as i,flushSync as s}from"react-dom";import{tabbable as a}from"tabbable";import{hideOthers as f}from"aria-hidden";var d="undefined"!=typeof document?u:c;function m(){const e=new Map;return{emit(t,n){var r;null==(r=e.get(t))||r.forEach((e=>e(n)))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){e.set(t,(e.get(t)||[]).filter((e=>e!==n)))}}}let v=!1,p=0;const g=()=>"floating-ui-"+p++;const b=o["useId".toString()],h=null!=b?b:function(){const[e,t]=o.useState((()=>v?g():void 0));return d((()=>{null==e&&t(g())}),[]),o.useEffect((()=>{v||(v=!0)}),[]),e},y=o.createContext(null),w=o.createContext(null),E=()=>{var e,t;return null!=(e=null==(t=o.useContext(y))?void 0:t.id)?e:null},R=()=>o.useContext(w),x=e=>{const t=h(),n=R(),r=E(),o=e||r;return d((()=>{const e={id:t,parentId:o};return null==n||n.addNode(e),()=>{null==n||n.removeNode(e)}}),[n,t,o]),t},k=e=>{let{children:t,id:n}=e;const r=E();return o.createElement(y.Provider,{value:o.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},I=e=>{let{children:t}=e;const n=o.useRef([]),r=o.useCallback((e=>{n.current=[...n.current,e]}),[]),u=o.useCallback((e=>{n.current=n.current.filter((t=>t!==e))}),[]),c=o.useState((()=>m()))[0];return o.createElement(w.Provider,{value:o.useMemo((()=>({nodesRef:n,addNode:r,removeNode:u,events:c})),[n,r,u,c])},t)};function T(e){var t;return null!=(t=null==e?void 0:e.ownerDocument)?t:document}function C(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}function L(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map((e=>{let{brand:t,version:n}=e;return t+"/"+n})).join(" "):navigator.userAgent}function M(e){var t;return null!=(t=T(e).defaultView)?t:window}function A(e){return!!e&&e instanceof M(e).Element}function O(e){return!!e&&e instanceof M(e).HTMLElement}function S(e){if(0===e.mozInputSource&&e.isTrusted)return!0;const t=/Android/i;return(t.test(C())||t.test(L()))&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType}function P(e){return 0===e.width&&0===e.height||1===e.width&&1===e.height&&0===e.pressure&&0===e.detail&&"mouse"!==e.pointerType||e.width<1&&e.height<1&&0===e.pressure&&0===e.detail}function D(){return/apple/i.test(navigator.vendor)}function F(){return C().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}const H=o["useInsertionEffect".toString()]||(e=>e());function K(e){const t=o.useRef((()=>{}));return H((()=>{t.current=e})),o.useCallback((function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return null==t.current?void 0:t.current(...n)}),[])}function N(t){let{open:n=!1,onOpenChange:r,whileElementsMounted:u,placement:c,middleware:l,strategy:i,nodeId:s}=void 0===t?{}:t;const[a,f]=o.useState(null),v=R(),p=o.useRef(null),g=o.useRef({}),b=o.useState((()=>m()))[0],h=e({placement:c,middleware:l,strategy:i,whileElementsMounted:u}),y=K(r),w=o.useMemo((()=>({...h.refs,domReference:p})),[h.refs]),E=o.useMemo((()=>({...h,refs:w,dataRef:g,nodeId:s,events:b,open:n,onOpenChange:y,_:{domReference:a}})),[h,s,b,n,y,w,a]);d((()=>{const e=null==v?void 0:v.nodesRef.current.find((e=>e.id===s));e&&(e.context=E)}));const{reference:x}=h,k=o.useCallback((e=>{(A(e)||null===e)&&(E.refs.domReference.current=e,f(e)),x(e)}),[x,E.refs]);return o.useMemo((()=>({...h,context:E,refs:w,reference:k})),[h,w,E,k])}function j(e,t,n){const r=new Map;return{..."floating"===n&&{tabIndex:-1},...e,...t.map((e=>e?e[n]:null)).concat(e).reduce(((e,t)=>t?(Object.entries(t).forEach((t=>{let[n,o]=t;var u;0===n.indexOf("on")?(r.has(n)||r.set(n,[]),"function"==typeof o&&(null==(u=r.get(n))||u.push(o),e[n]=function(){for(var e,t=arguments.length,o=new Array(t),u=0;u<t;u++)o[u]=arguments[u];null==(e=r.get(n))||e.forEach((e=>e(...o)))})):e[n]=o})),e):e),{})}}const B=function(e){void 0===e&&(e=[]);const t=e,n=o.useCallback((t=>j(t,e,"reference")),t),r=o.useCallback((t=>j(t,e,"floating")),t),u=o.useCallback((t=>j(t,e,"item")),t);return o.useMemo((()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:u})),[n,r,u])};function W(e,t){if(!e||!t)return!1;const n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&(r=n,"undefined"!=typeof ShadowRoot&&(r instanceof M(r).ShadowRoot||r instanceof ShadowRoot))){let n=t;do{if(n&&e===n)return!0;n=n.parentNode||n.host}while(n)}var r;return!1}function V(e,t){var n;let r=null!=(n=e.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})))?n:[],o=r;for(;o.length;){var u;o=null!=(u=e.filter((e=>{var t;return null==(t=o)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})))?u:[],r=r.concat(o)}return r}function _(e){return"composedPath"in e?e.composedPath()[0]:e.target}function X(e){let t,{restMs:n=0,buffer:r=.5,blockPointerEvents:o=!0,debug:u=null}=void 0===e?{}:e,c=!1;const l=e=>{let{x:o,y:u,placement:l,refs:i,onClose:s,nodeId:a,tree:f,leave:d=!1}=e;return function(e){function m(){clearTimeout(t),s()}clearTimeout(t);const{clientX:v,clientY:p}=e,g=_(e);if("mousemove"===e.type&&W(i.domReference.current,g))return;if("mouseleave"===e.type&&A(e.relatedTarget)&&W(i.floating.current,e.relatedTarget))return;if(f&&V(f.nodesRef.current,a).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if(W(i.floating.current,g)&&!d)return void(c=!0);if(!i.domReference.current||!i.floating.current||null==l||null==o||null==u)return;const b=i.domReference.current.getBoundingClientRect(),h=i.floating.current.getBoundingClientRect(),y=l.split("-")[0],w=o>h.right-h.width/2,E=u>h.bottom-h.height/2;if("top"===y&&u>=b.bottom-1||"bottom"===y&&u<=b.top+1||"left"===y&&o>=b.right-1||"right"===y&&o<=b.left+1)return m();switch(y){case"top":if(v>=h.left&&v<=h.right&&p>=h.top&&p<=b.top+1)return;break;case"bottom":if(v>=h.left&&v<=h.right&&p>=b.bottom-1&&p<=h.bottom)return;break;case"left":if(v>=h.left&&v<=b.left+1&&p>=h.top&&p<=h.bottom)return;break;case"right":if(v>=b.right-1&&v<=h.right&&p>=h.top&&p<=h.bottom)return}if(c)return m();const R=function(e){let[t,n]=e;const o=h.width>b.width,u=h.height>b.height;switch(y){case"top":return[[o?t+r/2:w?t+4*r:t-4*r,n+r+1],[o?t-r/2:w?t+4*r:t-4*r,n+r+1],...[[h.left,w||o?h.bottom-r:h.top],[h.right,w?o?h.bottom-r:h.top:h.bottom-r]]];case"bottom":return[[o?t+r/2:w?t+4*r:t-4*r,n-r],[o?t-r/2:w?t+4*r:t-4*r,n-r],...[[h.left,w||o?h.top+r:h.bottom],[h.right,w?o?h.top+r:h.bottom:h.top+r]]];case"left":{const e=[t+r+1,u?n+r/2:E?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:E?n+4*r:n-4*r];return[...[[E||u?h.right-r:h.left,h.top],[E?u?h.right-r:h.left:h.right-r,h.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:E?n+4*r:n-4*r],[t-r,u?n-r/2:E?n+4*r:n-4*r],...[[E||u?h.left+r:h.right,h.top],[E?u?h.left+r:h.right:h.left+r,h.bottom]]]}}([o,u]);!function(e,t){const[n,r]=e;let o=!1;const u=t.length;for(let e=0,c=u-1;e<u;c=e++){const[u,l]=t[e]||[0,0],[i,s]=t[c]||[0,0];l>=r!=s>=r&&n<=(i-u)*(r-l)/(s-l)+u&&(o=!o)}return o}([v,p],R)?m():n&&(t=setTimeout(s,n))}};return l.__options={blockPointerEvents:o},l}function Y(){return Y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Y.apply(this,arguments)}const q={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 U,z;function G(e){"Tab"===e.key&&(U=e.target,clearTimeout(z))}const J=o.forwardRef((function(e,t){const n=K(e.onFocus),[r,u]=o.useState();return d((()=>(D()&&u("button"),document.addEventListener("keydown",G),()=>{document.removeEventListener("keydown",G)})),[]),o.createElement("span",Y({},e,{ref:t,tabIndex:0,role:r,"aria-hidden":!r||void 0,"data-floating-ui-focus-guard":"",style:q,onFocus:e=>{D()&&F()&&!function(e){const t=U===e.relatedTarget;return U=e.relatedTarget,clearTimeout(z),t}(e)?(e.persist(),z=window.setTimeout((()=>{n(e)}),50)):n(e)}}))}));function Q(e){let t=e.activeElement;for(;null!=(null==(n=t)||null==(r=n.shadowRoot)?void 0:r.activeElement);){var n,r;t=t.shadowRoot.activeElement}return t}const Z=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function $(e,t){const n=a(e,Z());"prev"===t&&n.reverse();const r=n.indexOf(Q(T(e)));return n.slice(r+1)[0]}function ee(){return $(document.body,"next")}function te(){return $(document.body,"prev")}function ne(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!W(n,r)}function re(e){a(e,Z()).forEach((e=>{var t;e.dataset.tabindex=null!=(t=e.getAttribute("tabindex"))?t:"",e.setAttribute("tabindex","-1")}))}function oe(e){e.querySelectorAll("[data-tabindex]").forEach((e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")}))}const ue=o.createContext(null),ce=function(e){let{id:t,enabled:n=!0}=void 0===e?{}:e;const[r,u]=o.useState(null),c=h(),l=ie();return d((()=>{if(!n)return;const e=t?document.getElementById(t):null;if(!e){const e=document.createElement("div");e.id=t||c,e.setAttribute("data-floating-ui-portal",""),u(e);const n=(null==l?void 0:l.portalNode)||document.body;return n.appendChild(e),()=>{n.removeChild(e)}}e.setAttribute("data-floating-ui-portal",""),u(e)}),[t,l,c,n]),r},le=e=>{let{children:t,id:n,root:r=null,preserveTabOrder:u=!0}=e;const c=ce({id:n,enabled:!r}),[l,s]=o.useState(null),a=o.useRef(null),f=o.useRef(null),d=o.useRef(null),m=o.useRef(null),v=!!l&&!l.modal&&!(!r&&!c)&&u;return o.useEffect((()=>{if(c&&u&&(null==l||!l.modal))return c.addEventListener("focusin",e,!0),c.addEventListener("focusout",e,!0),()=>{c.removeEventListener("focusin",e,!0),c.removeEventListener("focusout",e,!0)};function e(e){if(c&&ne(e)){("focusin"===e.type?oe:re)(c)}}}),[c,u,null==l?void 0:l.modal]),o.createElement(ue.Provider,{value:o.useMemo((()=>({preserveTabOrder:u,beforeOutsideRef:a,afterOutsideRef:f,beforeInsideRef:d,afterInsideRef:m,portalNode:c,setFocusManagerState:s})),[u,c])},v&&c&&o.createElement(J,{ref:a,onFocus:e=>{if(ne(e,c)){var t;null==(t=d.current)||t.focus()}else{const e=te()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus()}}}),v&&c&&o.createElement("span",{"aria-owns":c.id,style:q}),r?i(t,r):c?i(t,c):null,v&&c&&o.createElement(J,{ref:f,onFocus:e=>{if(ne(e,c)){var t;null==(t=m.current)||t.focus()}else{const e=ee()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus(),null==l||l.onOpenChange(!1)}}}))},ie=()=>o.useContext(ue),se="data-floating-ui-scroll-lock",ae=o.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return d((()=>{var e,t,r,o;if(!n)return;if(document.body.hasAttribute(se))return;document.body.setAttribute(se,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(C()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(se),Object.assign(document.body.style,{overflow:"",[u]:""})};const l=null!=(e=null==(t=window.visualViewport)?void 0:t.offsetLeft)?e:0,i=null!=(r=null==(o=window.visualViewport)?void 0:o.offsetTop)?r:0,s=window.pageXOffset,a=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(a-Math.floor(i))+"px",left:-(s-Math.floor(l))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(se),window.scrollTo(s,a)}}),[n]),o.createElement("div",Y({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));function fe(e){return O(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function de(e){e.preventDefault(),e.stopPropagation()}function me(e){const t=l(e);return d((()=>{t.current=e})),t}let ve=0;function pe(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(ve);const u=()=>null==e?void 0:e.focus({preventScroll:n});o?u():ve=requestAnimationFrame(u)}const ge=o.forwardRef((function(e,t){return o.createElement("button",Y({},e,{ref:t,tabIndex:-1,style:q}))}));function be(e){let{context:t,children:n,order:r=["content"],guards:u=!0,initialFocus:c=0,returnFocus:l=!0,modal:i=!0,visuallyHiddenDismiss:s=!1}=e;const{refs:m,nodeId:v,onOpenChange:p,events:g,_:{domReference:b}}=t,h=me(r),y=R(),w=ie(),[E,x]=o.useState(null),k="number"==typeof c&&c<0,I=o.useRef(null),C=o.useRef(null),L=o.useRef(!1),M=o.useRef(null),A=null!=w,S=b&&"combobox"===b.getAttribute("role")&&fe(b),P=o.useCallback((function(e){return void 0===e&&(e=m.floating.current),e?a(e,Z()):[]}),[m]),D=o.useCallback((e=>{const t=P(e);return h.current.map((e=>m.domReference.current&&"reference"===e?m.domReference.current:m.floating.current&&"floating"===e?m.floating.current:t)).filter(Boolean).flat()}),[h,m,P]);o.useEffect((()=>{if(!i)return;function e(e){if("Tab"===e.key){0!==P().length||S||de(e);const t=D(),n=_(e);"reference"===h.current[0]&&n===m.domReference.current&&(de(e),e.shiftKey?pe(t[t.length-1]):pe(t[1])),"floating"===h.current[1]&&n===m.floating.current&&e.shiftKey&&(de(e),pe(t[0]))}}const t=T(m.floating.current);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[i,h,m,S,P,D]),o.useEffect((()=>{var e,t;const n=m.floating.current,r=m.domReference.current,o=Array.from(null!=(e=null==w||null==(t=w.portalNode)?void 0:t.querySelectorAll("[data-floating-ui-portal]"))?e:[]);let u=!1;function c(){u=!0,setTimeout((()=>{u=!1}))}function l(e){const t=e.relatedTarget,o=!(W(r,t)||W(n,t)||W(t,n)||W(null==w?void 0:w.portalNode,t)||[null==w?void 0:w.beforeOutsideRef.current,null==w?void 0:w.afterOutsideRef.current].filter(Boolean).includes(t)||y&&(V(y.nodesRef.current,v).find((e=>{var n,r;return W(null==(n=e.context)?void 0:n.refs.floating.current,t)||W(null==(r=e.context)?void 0:r.refs.domReference.current,t)}))||function(e,t){var n;let r=[],o=null==(n=e.find((e=>e.id===t)))?void 0:n.parentId;for(;o;){const t=e.find((e=>e.id===o));o=null==t?void 0:t.parentId,t&&(r=r.concat(t))}return r}(y.nodesRef.current,v).find((e=>{var n,r;return(null==(n=e.context)?void 0:n.refs.floating.current)===t||(null==(r=e.context)?void 0:r.refs.domReference.current)===t}))));t&&o&&!u&&t!==M.current&&(L.current=!0,setTimeout((()=>p(!1))))}if(n&&O(r)){let e;if(i){const t=[n,...o,...[I.current,C.current].filter(Boolean)];e=f(h.current.includes("reference")||S?t.concat(r):t)}return r.addEventListener("focusout",l),r.addEventListener("pointerdown",c),!i&&n.addEventListener("focusout",l),()=>{r.removeEventListener("focusout",l),r.removeEventListener("pointerdown",c),!i&&n.removeEventListener("focusout",l),null==e||e()}}}),[i,c,v,y,h,m,w,S,k,p]),o.useEffect((()=>{const e=m.floating.current;if(i&&!u&&e){const t=[],n=Z(),r=a(T(e).body,n),o=D(),u=r.filter((e=>!o.includes(e)));return u.forEach(((e,n)=>{t[n]=e.getAttribute("tabindex"),e.setAttribute("tabindex","-1")})),()=>{u.forEach(((e,n)=>{const r=t[n];null==r?e.removeAttribute("tabindex"):e.setAttribute("tabindex",r)}))}}}),[i,u,m,D]),d((()=>{const e=m.floating.current;if(!e)return;const t=T(e);let n=l,r=!1;const o=Q(t);M.current=o;const u=D(e),i=("number"==typeof c?u[c]:c.current)||e;function s(e){if("escapeKey"===e.type&&m.domReference.current&&(M.current=m.domReference.current),"outsidePress"!==e.type)return;const t=e.data.returnFocus;"object"==typeof t?(n=!0,r=t.preventScroll):n=t}return!k&&pe(i,{preventScroll:i===e}),g.on("dismiss",s),()=>{g.off("dismiss",s),W(e,Q(t))&&m.domReference.current&&(M.current=m.domReference.current),n&&O(M.current)&&!L.current&&pe(M.current,{preventScroll:r,cancelPrevious:!1})}}),[D,c,l,m,g,k]),d((()=>{if(w)return w.setFocusManagerState({...t,modal:i}),()=>{w.setFocusManagerState(null)}}),[w,i,t]),d((()=>{0!==P().length||k||x(0)}),[P,m,k]);const F=u&&(A||i)&&!S;function H(e){return s&&i?o.createElement(ge,{ref:"start"===e?I:C,onClick:()=>p(!1)},"string"==typeof s?s:"Dismiss"):null}return o.createElement(o.Fragment,null,F&&o.createElement(J,{ref:null==w?void 0:w.beforeInsideRef,onFocus:e=>{if(i){const e=D();pe("reference"===r[0]?e[0]:e[e.length-1])}else if(null!=w&&w.preserveTabOrder&&w.portalNode)if(L.current=!1,ne(e,w.portalNode)){const e=ee()||b;null==e||e.focus()}else{var t;null==(t=w.beforeOutsideRef.current)||t.focus()}}}),S?null:H("start"),o.cloneElement(n,0===E||r.includes("floating")?{tabIndex:0}:{}),H("end"),F&&o.createElement(J,{ref:null==w?void 0:w.afterInsideRef,onFocus:e=>{if(i)pe(D()[0]);else if(null!=w&&w.preserveTabOrder&&w.portalNode)if(L.current=!0,ne(e,w.portalNode)){const e=te()||b;null==e||e.focus()}else{var t;null==(t=w.afterOutsideRef.current)||t.focus()}}}))}function he(e,t,n){return n&&"mouse"!==n?0:"number"==typeof e?e:null==e?void 0:e[t]}const ye=function(e,t){let{enabled:n=!0,delay:r=0,handleClose:u=null,mouseOnly:c=!1,restMs:l=0,move:i=!0}=void 0===t?{}:t;const{open:s,onOpenChange:a,dataRef:f,events:m,refs:v,_:p}=e,g=R(),b=E(),h=me(u),y=me(r),w=o.useRef(),x=o.useRef(),k=o.useRef(),I=o.useRef(),C=o.useRef(!0),L=o.useRef(!1),M=o.useCallback((()=>{var e;const t=null==(e=f.current.openEvent)?void 0:e.type;return(null==t?void 0:t.includes("mouse"))&&"mousedown"!==t}),[f]);o.useEffect((()=>{if(n)return m.on("dismiss",e),()=>{m.off("dismiss",e)};function e(){clearTimeout(x.current),clearTimeout(I.current),C.current=!0}}),[n,m,v]),o.useEffect((()=>{if(!n||!h.current||!s)return;function e(){M()&&a(!1)}const t=T(v.floating.current).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[v,s,a,n,h,f,M]);const O=o.useCallback((function(e){void 0===e&&(e=!0);const t=he(y.current,"close",w.current);t&&!k.current?(clearTimeout(x.current),x.current=setTimeout((()=>a(!1)),t)):e&&(clearTimeout(x.current),a(!1))}),[y,a]),S=o.useCallback((()=>{k.current&&(T(v.floating.current).removeEventListener("mousemove",k.current),k.current=void 0)}),[v]),P=o.useCallback((()=>{T(v.floating.current).body.style.pointerEvents="",L.current=!1}),[v]);return o.useEffect((()=>{if(!n)return;function t(){return!!f.current.openEvent&&["click","mousedown"].includes(f.current.openEvent.type)}function r(e){if(clearTimeout(x.current),C.current=!1,c&&"mouse"!==w.current||l>0&&0===he(y.current,"open"))return;f.current.openEvent=e;const t=he(y.current,"open",w.current);t?x.current=setTimeout((()=>{a(!0)}),t):a(!0)}function o(n){if(t())return;const r=T(v.floating.current);if(clearTimeout(I.current),h.current)return clearTimeout(x.current),k.current&&r.removeEventListener("mousemove",k.current),k.current=h.current({...e,tree:g,x:n.clientX,y:n.clientY,onClose(){P(),S(),O()}}),void r.addEventListener("mousemove",k.current);O()}function u(n){t()||null==h.current||h.current({...e,tree:g,x:n.clientX,y:n.clientY,leave:!0,onClose(){P(),S(),O()}})(n)}const d=v.floating.current,m=v.domReference.current;return A(m)?(s&&m.addEventListener("mouseleave",u),null==d||d.addEventListener("mouseleave",u),i&&m.addEventListener("mousemove",r,{once:!0}),m.addEventListener("mouseenter",r),m.addEventListener("mouseleave",o),()=>{s&&m.removeEventListener("mouseleave",u),null==d||d.removeEventListener("mouseleave",u),i&&m.removeEventListener("mousemove",r),m.removeEventListener("mouseenter",r),m.removeEventListener("mouseleave",o)}):void 0}),[p.domReference,n,e,c,l,i,O,S,P,a,s,g,v,y,h,f]),d((()=>{if(n&&s&&h.current&&h.current.__options.blockPointerEvents&&M()){T(v.floating.current).body.style.pointerEvents="none",L.current=!0;const n=v.domReference.current,r=v.floating.current;if(A(n)&&r){var e,t;const o=null==g||null==(e=g.nodesRef.current.find((e=>e.id===b)))||null==(t=e.context)?void 0:t.refs.floating.current;return o&&(o.style.pointerEvents=""),n.style.pointerEvents="auto",r.style.pointerEvents="auto",()=>{n.style.pointerEvents="",r.style.pointerEvents=""}}}}),[n,s,b,v,g,h,f,M]),d((()=>{s||(w.current=void 0,S(),L.current&&P())}),[s,S,P]),o.useEffect((()=>()=>{S(),clearTimeout(x.current),clearTimeout(I.current),L.current&&P()}),[n,S,P]),o.useMemo((()=>{if(!n)return{};function e(e){w.current=e.pointerType}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove(){s||0===l||(clearTimeout(I.current),I.current=setTimeout((()=>{C.current||a(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(x.current)},onMouseLeave(){O(!1)}}}}),[n,l,s,a,O])},we=o.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),Ee=()=>o.useContext(we),Re=e=>{let{children:t,delay:n}=e;const[r,u]=o.useState({delay:n,initialDelay:n,currentId:null}),c=o.useCallback((e=>{u((t=>({...t,currentId:e})))}),[]);return o.createElement(we.Provider,{value:o.useMemo((()=>({...r,setState:u,setCurrentId:c})),[r,u,c])},t)},xe=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:u}=t;const{currentId:c,initialDelay:l,setState:i}=Ee();o.useEffect((()=>{c&&(i((e=>({...e,delay:{open:1,close:he(l,"close")}}))),c!==u&&r(!1))}),[u,r,i,c,l]),o.useEffect((()=>{n||c!==u||(r(!1),i((e=>({...e,delay:l,currentId:null}))))}),[n,i,c,u,r,l])};function ke(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const Ie=e=>({name:"inner",options:e,async fn(r){var o;const{listRef:u,overflowRef:c,onFallbackChange:l,offset:i=0,index:a=0,minItemsVisible:f=4,referenceOverflowThreshold:d=0,scrollRef:m,...v}=e,{rects:p,elements:{floating:g}}=r,b=u.current[a];if(!b)return{};const h={...r,...await t(-b.offsetTop-p.reference.height/2-b.offsetHeight/2-i).fn(r)},y=null!=(o=null==m?void 0:m.current)?o:g,w=await n(ke(h,y.scrollHeight),v),E=await n(h,{...v,elementContext:"reference"}),R=Math.max(0,w.top),x=h.y+R,k=Math.max(0,y.scrollHeight-R-Math.max(0,w.bottom));return y.style.maxHeight=k+"px",y.scrollTop=R,l&&(y.offsetHeight<b.offsetHeight*Math.min(f,u.current.length-1)-1||E.top>=-d||E.bottom>=-d?s((()=>l(!0))):s((()=>l(!1)))),c&&(c.current=await n(ke({...h,y:x},y.offsetHeight),v)),{y:x}}}),Te=(e,t)=>{let{open:n,refs:r}=e,{enabled:u=!0,overflowRef:c,scrollRef:l,onChange:i}=t;const a=K(i),f=o.useRef(!1),d=o.useRef(null),m=o.useRef(null);return o.useEffect((()=>{var e;if(!u)return;function t(e){if(e.ctrlKey||!o||null==c.current)return;const t=e.deltaY,n=c.current.top>=-.5,r=c.current.bottom>=-.5,u=o.scrollHeight-o.clientHeight,l=t<0?-1:1,i=t<0?"max":"min";o.scrollHeight<=o.clientHeight||(!n&&t>0||!r&&t<0?(e.preventDefault(),s((()=>{a((e=>e+Math[i](t,u*l)))}))):/firefox/i.test(L())&&(o.scrollTop+=t))}const o=null!=(e=null==l?void 0:l.current)?e:r.floating.current;return n&&o?(o.addEventListener("wheel",t),requestAnimationFrame((()=>{d.current=o.scrollTop,null!=c.current&&(m.current={...c.current})})),()=>{d.current=null,m.current=null,o.removeEventListener("wheel",t)}):void 0}),[u,n,r,c,l,a]),o.useMemo((()=>u?{floating:{onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const e=(null==l?void 0:l.current)||r.floating.current;if(c.current&&e&&f.current){if(null!==d.current){const t=e.scrollTop-d.current;(c.current.bottom<-.5&&t<-1||c.current.top<-.5&&t>1)&&s((()=>a((e=>e+t))))}requestAnimationFrame((()=>{d.current=e.scrollTop}))}}}}:{}),[u,c,r,l,a])},Ce=function(e,t){let{open:n}=e,{enabled:r=!0,role:u="dialog"}=void 0===t?{}:t;const c=h(),l=h();return o.useMemo((()=>{const e={id:c,role:u};return r?"tooltip"===u?{reference:{"aria-describedby":n?c:void 0},floating:e}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":"alertdialog"===u?"dialog":u,"aria-controls":n?c:void 0,..."listbox"===u&&{role:"combobox"},..."menu"===u&&{id:l}},floating:{...e,..."menu"===u&&{"aria-labelledby":l}}}:{}}),[r,u,n,c,l])};function Le(e){return O(e.target)&&"BUTTON"===e.target.tagName}function Me(e){return fe(e)}const Ae=function(e,t){let{open:n,onOpenChange:r,dataRef:u,refs:c}=e,{enabled:l=!0,event:i="click",toggle:s=!0,ignoreMouse:a=!1,keyboardHandlers:f=!0}=void 0===t?{}:t;const d=o.useRef();return o.useMemo((()=>l?{reference:{onPointerDown(e){d.current=e.pointerType},onMouseDown(e){0===e.button&&("mouse"===d.current&&a||"click"!==i&&(n?!s||u.current.openEvent&&"mousedown"!==u.current.openEvent.type||r(!1):(e.preventDefault(),r(!0)),u.current.openEvent=e.nativeEvent))},onClick(e){"mousedown"===i&&d.current?d.current=void 0:"mouse"===d.current&&a||(n?!s||u.current.openEvent&&"click"!==u.current.openEvent.type||r(!1):r(!0),u.current.openEvent=e.nativeEvent)},onKeyDown(e){d.current=void 0,f&&(Le(e)||(" "!==e.key||Me(c.domReference.current)||e.preventDefault(),"Enter"===e.key&&(n?s&&r(!1):r(!0))))},onKeyUp(e){f&&(Le(e)||Me(c.domReference.current)||" "===e.key&&(n?s&&r(!1):r(!0)))}}}:{}),[l,u,i,a,f,c,s,n,r])};function Oe(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}const Se={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Pe={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},De=function(e,t){let{open:n,onOpenChange:u,refs:c,events:l,nodeId:i}=e,{enabled:s=!0,escapeKey:a=!0,outsidePress:f=!0,outsidePressEvent:d="pointerdown",referencePress:m=!1,referencePressEvent:v="pointerdown",ancestorScroll:p=!1,bubbles:g=!0}=void 0===t?{}:t;const b=R(),h=null!=E(),y=me(f),w=o.useRef(!1);return o.useEffect((()=>{if(!n||!s)return;const e=y.current;function t(e){if("Escape"===e.key){if(!g&&b&&V(b.nodesRef.current,i).length>0)return;l.emit("dismiss",{type:"escapeKey",data:{returnFocus:{preventScroll:!1}}}),u(!1)}}function o(t){const n=w.current;if(w.current=!1,n)return;if("function"==typeof e&&!e(t))return;const r=_(t);if(A(r)&&c.floating.current){var o;const e=null!=(o=c.floating.current.ownerDocument.defaultView)?o:window,n=r.scrollWidth>r.clientWidth,u=r.scrollHeight>r.clientHeight;let l=u&&t.offsetX>r.clientWidth;if(u){"rtl"===e.getComputedStyle(r).direction&&(l=t.offsetX<=r.offsetWidth-r.clientWidth)}if(l||n&&t.offsetY>r.clientHeight)return}const s=b&&V(b.nodesRef.current,i).some((e=>{var n;return Oe(t,null==(n=e.context)?void 0:n.refs.floating.current)}));Oe(t,c.floating.current)||Oe(t,c.domReference.current)||s||!g&&b&&V(b.nodesRef.current,i).length>0||(l.emit("dismiss",{type:"outsidePress",data:{returnFocus:h?{preventScroll:!0}:S(t)||P(t)}}),u(!1))}function f(){u(!1)}const m=T(c.floating.current);a&&m.addEventListener("keydown",t),e&&m.addEventListener(d,o);let v=[];return p&&(A(c.domReference.current)&&(v=r(c.domReference.current)),A(c.floating.current)&&(v=v.concat(r(c.floating.current))),!A(c.reference.current)&&c.reference.current&&c.reference.current.contextElement&&(v=v.concat(r(c.reference.current.contextElement)))),v=v.filter((e=>{var t;return e!==(null==(t=m.defaultView)?void 0:t.visualViewport)})),v.forEach((e=>{e.addEventListener("scroll",f,{passive:!0})})),()=>{a&&m.removeEventListener("keydown",t),e&&m.removeEventListener(d,o),v.forEach((e=>{e.removeEventListener("scroll",f)}))}}),[a,y,d,l,b,i,n,u,p,s,g,c,h]),o.useEffect((()=>{w.current=!1}),[f,d]),o.useMemo((()=>s?{reference:{[Se[v]]:()=>{m&&(l.emit("dismiss",{type:"referencePress",data:{returnFocus:!1}}),u(!1))}},floating:{[Pe[d]]:()=>{w.current=!0}}}:{}),[s,l,m,d,v,u])},Fe=function(e,t){let{open:n,onOpenChange:r,dataRef:u,refs:c,events:l}=e,{enabled:i=!0,keyboardOnly:s=!0}=void 0===t?{}:t;const a=o.useRef(""),f=o.useRef(!1),d=o.useRef();return o.useEffect((()=>{var e;if(!i)return;const t=null!=(e=T(c.floating.current).defaultView)?e:window;function r(){!n&&O(c.domReference.current)&&c.domReference.current===Q(T(c.domReference.current))&&(f.current=!0)}return t.addEventListener("blur",r),()=>{t.removeEventListener("blur",r)}}),[c,n,i]),o.useEffect((()=>{if(i)return l.on("dismiss",e),()=>{l.off("dismiss",e)};function e(e){"referencePress"!==e.type&&"escapeKey"!==e.type||(f.current=!0)}}),[l,i]),o.useEffect((()=>()=>{clearTimeout(d.current)}),[]),o.useMemo((()=>i?{reference:{onPointerDown(e){let{pointerType:t}=e;a.current=t,f.current=!(!t||!s)},onPointerLeave(){f.current=!1},onFocus(e){var t;f.current||"focus"===e.type&&"mousedown"===(null==(t=u.current.openEvent)?void 0:t.type)&&u.current.openEvent&&Oe(u.current.openEvent,c.domReference.current)||(u.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){f.current=!1;const t=e.relatedTarget,n=A(t)&&t.hasAttribute("data-floating-ui-focus-guard");d.current=setTimeout((()=>{W(c.floating.current,t)||W(c.domReference.current,t)||n||r(!1)}))}}}:{}),[i,s,c,u,r])};let He=!1;function Ke(e,t,n){return Math.floor(e/t)!==n}function Ne(e,t){return t<0||t>=e.current.length}function je(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o,amount:u=1}=void 0===t?{}:t;const c=e.current;let l=n;do{var i,s;l+=r?-u:u}while(l>=0&&l<=c.length-1&&(o?o.includes(l):null==c[l]||(null==(i=c[l])?void 0:i.hasAttribute("disabled"))||"true"===(null==(s=c[l])?void 0:s.getAttribute("aria-disabled"))));return l}function Be(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function We(e,t){return Be(t,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function Ve(e,t,n){return Be(t,"ArrowDown"===e,n?"ArrowLeft"===e:"ArrowRight"===e)||"Enter"===e||" "==e||""===e}function _e(e,t){return je(e,{disabledIndices:t})}function Xe(e,t){return je(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}const Ye=function(e,t){let{open:n,onOpenChange:r,refs:u}=e,{listRef:c,activeIndex:l,onNavigate:i=(()=>{}),enabled:a=!0,selectedIndex:f=null,allowEscape:m=!1,loop:v=!1,nested:p=!1,rtl:g=!1,virtual:b=!1,focusItemOnOpen:h="auto",focusItemOnHover:y=!0,openOnArrowKeyDown:w=!0,disabledIndices:x,orientation:k="vertical",cols:I=1}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const C=E(),L=R(),M=K(i),A=o.useRef(h),H=o.useRef(null!=f?f:-1),N=o.useRef(null),j=o.useRef(!1),B=o.useRef(M),V=o.useRef(n),_=o.useRef(!1),X=me(x),Y=me(n),[q,U]=o.useState(),z=o.useCallback(((e,t)=>{if(b){var n;U(null==(n=e.current[t.current])?void 0:n.id)}else{pe(e.current[t.current],{preventScroll:!0,sync:!(!F()||!D())&&(He||_.current)})}}),[b]);return d((()=>{document.createElement("div").focus({get preventScroll(){return He=!0,!1}})}),[]),d((()=>{a&&(n?A.current&&null!=f&&M(f):V.current&&(H.current=-1,B.current(null)))}),[a,n,f,M]),d((()=>{if(a&&n)if(null==l){if(_.current=!1,null!=f)return;V.current&&(H.current=-1,z(c,H)),!V.current&&A.current&&(null!=N.current||!0===A.current&&null==N.current)&&(H.current=null==N.current||Ve(N.current,k,g)||p?_e(c,X.current):Xe(c,X.current),M(H.current))}else Ne(c,l)||(H.current=l,z(c,H))}),[a,n,l,f,p,c,k,g,M,z,X]),d((()=>{if(a&&V.current&&!n){var e,t;const n=null==L||null==(e=L.nodesRef.current.find((e=>e.id===C)))||null==(t=e.context)?void 0:t.refs.floating.current;n&&!W(n,Q(T(n)))&&n.focus({preventScroll:!0})}}),[a,n,L,C]),d((()=>{N.current=null,B.current=M,V.current=n})),o.useMemo((()=>{if(!a)return{};const e=X.current;function t(t){if(j.current=!0,_.current=!0,!Y.current&&t.currentTarget===u.floating.current)return;if(p&&function(e,t,n){return Be(t,n?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(t.key,k,g))return de(t),r(!1),void(O(u.domReference.current)&&u.domReference.current.focus());const o=H.current,l=_e(c,e),i=Xe(c,e);if("Home"===t.key&&(H.current=l,M(H.current)),"End"===t.key&&(H.current=i,M(H.current)),I>1){const n=H.current;if("ArrowUp"===t.key){if(de(t),-1===n)H.current=i;else if(H.current=je(c,{startingIndex:n,amount:I,decrement:!0,disabledIndices:e}),v&&(n-I<l||H.current<0)){const e=n%I,t=i%I,r=i-(t-e);H.current=t===e?i:t>e?r:r-I}Ne(c,H.current)&&(H.current=n),M(H.current)}if("ArrowDown"===t.key&&(de(t),-1===n?H.current=l:(H.current=je(c,{startingIndex:n,amount:I,disabledIndices:e}),v&&n+I>i&&(H.current=je(c,{startingIndex:n%I-I,amount:I,disabledIndices:e}))),Ne(c,H.current)&&(H.current=n),M(H.current)),"both"===k){const r=Math.floor(n/I);"ArrowRight"===t.key&&(de(t),n%I!=I-1?(H.current=je(c,{startingIndex:n,disabledIndices:e}),v&&Ke(H.current,I,r)&&(H.current=je(c,{startingIndex:n-n%I-1,disabledIndices:e}))):v&&(H.current=je(c,{startingIndex:n-n%I-1,disabledIndices:e})),Ke(H.current,I,r)&&(H.current=n)),"ArrowLeft"===t.key&&(de(t),n%I!=0?(H.current=je(c,{startingIndex:n,disabledIndices:e,decrement:!0}),v&&Ke(H.current,I,r)&&(H.current=je(c,{startingIndex:n+(I-n%I),decrement:!0,disabledIndices:e}))):v&&(H.current=je(c,{startingIndex:n+(I-n%I),decrement:!0,disabledIndices:e})),Ke(H.current,I,r)&&(H.current=n));const o=Math.floor(i/I)===r;return Ne(c,H.current)&&(H.current=v&&o?"ArrowLeft"===t.key?i:je(c,{startingIndex:n-n%I-1,disabledIndices:e}):n),void M(H.current)}}if(We(t.key,k)){if(de(t),n&&!b&&Q(t.currentTarget.ownerDocument)===t.currentTarget)return H.current=Ve(t.key,k,g)?l:i,void M(H.current);Ve(t.key,k,g)?H.current=v?o>=i?m&&o!==c.current.length?-1:l:je(c,{startingIndex:o,disabledIndices:e}):Math.min(i,je(c,{startingIndex:o,disabledIndices:e})):H.current=v?o<=l?m&&-1!==o?c.current.length:i:je(c,{startingIndex:o,decrement:!0,disabledIndices:e}):Math.max(l,je(c,{startingIndex:o,decrement:!0,disabledIndices:e})),Ne(c,H.current)?M(null):M(H.current)}}function o(e){"auto"===h&&S(e.nativeEvent)&&(A.current=!0)}return{reference:{...b&&n&&null!=l&&{"aria-activedescendant":q},onKeyDown(o){j.current=!0;const u=0===o.key.indexOf("Arrow");if(b&&n)return t(o);if(!n&&!w&&u)return;(u||"Enter"===o.key||" "===o.key||""===o.key)&&(N.current=o.key),p?function(e,t,n){return Be(t,n?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(o.key,k,g)&&(de(o),n?(H.current=_e(c,e),M(H.current)):r(!0)):We(o.key,k)&&(null!=f&&(H.current=f),de(o),!n&&w?r(!0):t(o),n&&M(H.current))},onFocus(){n&&M(null)},onPointerDown:function(e){A.current=h,"auto"===h&&P(e.nativeEvent)&&(A.current=!0)},onMouseDown:o,onClick:o},floating:{"aria-orientation":"both"===k?void 0:k,...b&&null!=l&&{"aria-activedescendant":q},onKeyDown:t,onPointerMove(){j.current=!1}},item:{onFocus(e){let{currentTarget:t}=e;const n=c.current.indexOf(t);-1!==n&&l!==n&&M(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...y&&{onMouseMove(e){let{currentTarget:t}=e;const n=t;if(n){const e=c.current.indexOf(n);-1!==e&&l!==e&&M(e)}},onPointerLeave(){var e;j.current||(H.current=-1,z(c,H),s((()=>M(null))),b||null==(e=u.floating.current)||e.focus({preventScroll:!0}))}}}}}),[q,X,Y,c,a,k,g,b,n,l,p,f,w,y,m,I,v,u,h,z,M,r])},qe=function(e,t){var n;let{open:r,dataRef:u}=e,{listRef:c,activeIndex:l,onMatch:i=(()=>{}),enabled:s=!0,findMatch:a=null,resetMs:f=1e3,ignoreKeys:m=[],selectedIndex:v=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const p=o.useRef(),g=o.useRef(""),b=o.useRef(null!=(n=null!=v?v:l)?n:-1),h=o.useRef(null),y=K(i),w=me(a),E=me(m);return d((()=>{r&&(clearTimeout(p.current),h.current=null,g.current="")}),[r]),d((()=>{var e;r&&""===g.current&&(b.current=null!=(e=null!=v?v:l)?e:-1)}),[r,v,l]),o.useMemo((()=>{if(!s)return{};function e(e){const t=_(e.nativeEvent);if(A(t)&&Q(T(t))!==e.currentTarget&&t.closest('[role="dialog"],[role="menu"],[role="listbox"],[role="tree"],[role="grid"]')!==e.currentTarget)return;g.current.length>0&&" "!==g.current[0]&&(u.current.typing=!0," "===e.key&&de(e));const n=c.current;if(null==n||E.current.includes(e.key)||1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey)return;n.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&g.current===e.key&&(g.current="",b.current=h.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",b.current=h.current,u.current.typing=!1}),f);const r=b.current,o=[...n.slice((null!=r?r:0)+1),...n.slice(0,(null!=r?r:0)+1)],l=w.current?w.current(o,g.current):o.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current.toLocaleLowerCase())))),i=l?n.indexOf(l):-1;-1!==i&&(y(i),h.current=i)}return{reference:{onKeyDown:e},floating:{onKeyDown:e}}}),[s,u,c,f,E,w,y])};export{Re as FloatingDelayGroup,be as FloatingFocusManager,k as FloatingNode,ae as FloatingOverlay,le as FloatingPortal,I as FloatingTree,Ie as inner,X as safePolygon,Ae as useClick,xe as useDelayGroup,Ee as useDelayGroupContext,De as useDismiss,N as useFloating,x as useFloatingNodeId,E as useFloatingParentNodeId,ce as useFloatingPortalNode,R as useFloatingTree,Fe as useFocus,ye as useHover,h as useId,Te as useInnerOffset,B as useInteractions,Ye as useListNavigation,Ce as useRole,qe as useTypeahead};

@@ -5,2 +5,2 @@ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@floating-ui/react-dom"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/react-dom","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.FloatingUIReactDOM,e.React,e.ReactDOM)}(this,(function(e,t,n,r){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var u=o(n),c="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;function i(){const e=new Map;return{emit(t,n){var r;null==(r=e.get(t))||r.forEach((e=>e(n)))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){e.set(t,(e.get(t)||[]).filter((e=>e!==n)))}}}let l=!1,a=0;const s=()=>"floating-ui-"+a++;const f=u["useId".toString()],d=null!=f?f:function(){const[e,t]=u.useState((()=>l?s():void 0));return c((()=>{null==e&&t(s())}),[]),u.useEffect((()=>{l||(l=!0)}),[]),e},v=u.createContext(null),m=u.createContext(null),p=()=>{var e,t;return null!=(e=null==(t=u.useContext(v))?void 0:t.id)?e:null},g=()=>u.useContext(m);function h(e){var t;return null!=(t=null==e?void 0:e.ownerDocument)?t:document}function y(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}function b(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map((e=>{let{brand:t,version:n}=e;return t+"/"+n})).join(" "):navigator.userAgent}function w(e){var t;return null!=(t=h(e).defaultView)?t:window}function E(e){return!!e&&e instanceof w(e).Element}function R(e){return!!e&&e instanceof w(e).HTMLElement}function x(e){if(0===e.mozInputSource&&e.isTrusted)return!0;const t=/Android/i;return(t.test(y())||t.test(b()))&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType}function I(e){return 0===e.width&&0===e.height||1===e.width&&1===e.height&&0===e.pressure&&0===e.detail&&"mouse"!==e.pointerType||e.width<1&&e.height<1&&0===e.pressure&&0===e.detail}function k(){return/apple/i.test(navigator.vendor)}function T(){return y().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}const S=u["useInsertionEffect".toString()]||(e=>e());function C(e){const t=u.useRef((()=>{}));return S((()=>{t.current=e})),u.useCallback((function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return null==t.current?void 0:t.current(...n)}),[])}function O(e,t,n){const r=new Map;return{..."floating"===n&&{tabIndex:-1},...e,...t.map((e=>e?e[n]:null)).concat(e).reduce(((e,t)=>t?(Object.entries(t).forEach((t=>{let[n,o]=t;var u;0===n.indexOf("on")?(r.has(n)||r.set(n,[]),"function"==typeof o&&(null==(u=r.get(n))||u.push(o),e[n]=function(){for(var e,t=arguments.length,o=new Array(t),u=0;u<t;u++)o[u]=arguments[u];null==(e=r.get(n))||e.forEach((e=>e(...o)))})):e[n]=o})),e):e),{})}}function M(e,t){if(!e||!t)return!1;const n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&(r=n,"undefined"!=typeof ShadowRoot&&(r instanceof w(r).ShadowRoot||r instanceof ShadowRoot))){let n=t;do{if(n&&e===n)return!0;n=n.parentNode||n.host}while(n)}var r;return!1}function A(e,t){var n;let r=null!=(n=e.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})))?n:[],o=r;for(;o.length;){var u;o=null!=(u=e.filter((e=>{var t;return null==(t=o)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})))?u:[],r=r.concat(o)}return r}function L(e){return"composedPath"in e?e.composedPath()[0]:e.target}function P(){return P=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},P.apply(this,arguments)}const D={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 F,N;function H(e){"Tab"===e.key&&(F=e.target,clearTimeout(N))}const j=u.forwardRef((function(e,t){const n=C(e.onFocus),[r,o]=u.useState();return c((()=>(k()&&o("button"),document.addEventListener("keydown",H),()=>{document.removeEventListener("keydown",H)})),[]),u.createElement("span",P({},e,{ref:t,tabIndex:0,role:r,"aria-hidden":!r||void 0,"data-floating-ui-focus-guard":"",style:D,onFocus:e=>{k()&&T()&&!function(e){const t=F===e.relatedTarget;return F=e.relatedTarget,clearTimeout(N),t}(e)?(e.persist(),N=window.setTimeout((()=>{n(e)}),50)):n(e)}}))}));

* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/var K=["input","select","textarea","a[href]","button","[tabindex]:not(slot)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"].join(","),W="undefined"==typeof Element,B=W?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,_=!W&&Element.prototype.getRootNode?function(e){return e.getRootNode()}:function(e){return e.ownerDocument},q=function e(t,n,r){for(var o=[],u=Array.from(t);u.length;){var c=u.shift();if("SLOT"===c.tagName){var i=c.assignedElements(),l=e(i.length?i:c.children,!0,r);r.flatten?o.push.apply(o,l):o.push({scopeParent:c,candidates:l})}else{B.call(c,K)&&r.filter(c)&&(n||!t.includes(c))&&o.push(c);var a=c.shadowRoot||"function"==typeof r.getShadowRoot&&r.getShadowRoot(c),s=!r.shadowRootFilter||r.shadowRootFilter(c);if(a&&s){var f=e(!0===a?c.children:a.children,!0,r);r.flatten?o.push.apply(o,f):o.push({scopeParent:c,candidates:f})}else u.unshift.apply(u,c.children)}}return o},U=function(e,t){return e.tabIndex<0&&(t||/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||e.isContentEditable)&&isNaN(parseInt(e.getAttribute("tabindex"),10))?0:e.tabIndex},V=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},X=function(e){return"INPUT"===e.tagName},Y=function(e){return function(e){return X(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||_(e),r=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=r(window.CSS.escape(e.name));else try{t=r(e.name)}catch(e){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",e.message),!1}var o=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!o||o===e}(e)},z=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return 0===n&&0===r},G=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var o=B.call(e,"details>summary:first-of-type")?e.parentElement:e;if(B.call(o,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return z(e)}else{if("function"==typeof r){for(var u=e;e;){var c=e.parentElement,i=_(e);if(c&&!c.shadowRoot&&!0===r(c))return z(e);e=e.assignedSlot?e.assignedSlot:c||i===e.ownerDocument?c:i.host}e=u}if(function(e){for(var t,n=_(e).host,r=!!(null!==(t=n)&&void 0!==t&&t.ownerDocument.contains(n)||e.ownerDocument.contains(e));!r&&n;){var o;r=!(null===(o=n=_(n).host)||void 0===o||!o.ownerDocument.contains(n))}return r}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},$=function(e,t){return!(t.disabled||function(e){return X(e)&&"hidden"===e.type}(t)||G(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!B.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},J=function(e,t){return!(Y(t)||U(t)<0||!$(e,t))},Q=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},Z=function e(t){var n=[],r=[];return t.forEach((function(t,o){var u=!!t.scopeParent,c=u?t.scopeParent:t,i=U(c,u),l=u?e(t.candidates):c;0===i?u?n.push.apply(n,l):n.push(c):r.push({documentOrder:o,tabIndex:i,item:t,isScope:u,content:l})})),r.sort(V).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)},ee=function(e,t){var n;return n=(t=t||{}).getShadowRoot?q([e],t.includeContainer,{filter:J.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:Q}):function(e,t,n){var r=Array.prototype.slice.apply(e.querySelectorAll(K));return t&&B.call(e,K)&&r.unshift(e),r.filter(n)}(e,t.includeContainer,J.bind(null,t)),Z(n)};function te(e){let t=e.activeElement;for(;null!=(null==(n=t)||null==(r=n.shadowRoot)?void 0:r.activeElement);){var n,r;t=t.shadowRoot.activeElement}return t}const ne=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function re(e,t){const n=ee(e,ne());"prev"===t&&n.reverse();const r=n.indexOf(te(h(e)));return n.slice(r+1)[0]}function oe(){return re(document.body,"next")}function ue(){return re(document.body,"prev")}function ce(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!M(n,r)}function ie(e){ee(e,ne()).forEach((e=>{var t;e.dataset.tabindex=null!=(t=e.getAttribute("tabindex"))?t:"",e.setAttribute("tabindex","-1")}))}function le(e){e.querySelectorAll("[data-tabindex]").forEach((e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")}))}const ae=u.createContext(null),se=function(e){let{id:t,enabled:n=!0}=void 0===e?{}:e;const[r,o]=u.useState(null),i=d(),l=fe();return c((()=>{if(!n)return;const e=t?document.getElementById(t):null;if(!e){const e=document.createElement("div");e.id=t||i,e.setAttribute("data-floating-ui-portal",""),o(e);const n=(null==l?void 0:l.portalNode)||document.body;return n.appendChild(e),()=>{n.removeChild(e)}}e.setAttribute("data-floating-ui-portal",""),o(e)}),[t,l,i,n]),r},fe=()=>u.useContext(ae),de="data-floating-ui-scroll-lock",ve=u.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return c((()=>{var e,t,r,o;if(!n)return;if(document.body.hasAttribute(de))return;document.body.setAttribute(de,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(y()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(de),Object.assign(document.body.style,{overflow:"",[u]:""})};const i=null!=(e=null==(t=window.visualViewport)?void 0:t.offsetLeft)?e:0,l=null!=(r=null==(o=window.visualViewport)?void 0:o.offsetTop)?r:0,a=window.pageXOffset,s=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(s-Math.floor(l))+"px",left:-(a-Math.floor(i))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(de),window.scrollTo(a,s)}}),[n]),u.createElement("div",P({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var me=new WeakMap,pe=new WeakMap,ge={},he=0,ye=function(e,t,n){void 0===t&&(t=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e)),void 0===n&&(n="data-aria-hidden");var r=Array.isArray(e)?e:[e];ge[n]||(ge[n]=new WeakMap);var o=ge[n],u=[],c=new Set,i=function(e){e&&!c.has(e)&&(c.add(e),i(e.parentNode))};r.forEach(i);var l=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(c.has(e))l(e);else{var t=e.getAttribute("aria-hidden"),r=null!==t&&"false"!==t,i=(me.get(e)||0)+1,a=(o.get(e)||0)+1;me.set(e,i),o.set(e,a),u.push(e),1===i&&r&&pe.set(e,!0),1===a&&e.setAttribute(n,"true"),r||e.setAttribute("aria-hidden","true")}}))};return l(t),c.clear(),he++,function(){u.forEach((function(e){var t=me.get(e)-1,r=o.get(e)-1;me.set(e,t),o.set(e,r),t||(pe.has(e)||e.removeAttribute("aria-hidden"),pe.delete(e)),r||e.removeAttribute(n)})),--he||(me=new WeakMap,me=new WeakMap,pe=new WeakMap,ge={})}};function be(e){return R(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function we(e){e.preventDefault(),e.stopPropagation()}function Ee(e){const t=n.useRef(e);return c((()=>{t.current=e})),t}let Re=0;function xe(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(Re);const u=()=>null==e?void 0:e.focus({preventScroll:n});o?u():Re=requestAnimationFrame(u)}const Ie=u.forwardRef((function(e,t){return u.createElement("button",P({},e,{ref:t,tabIndex:-1,style:D}))}));function ke(e,t,n){return n&&"mouse"!==n?0:"number"==typeof e?e:null==e?void 0:e[t]}const Te=u.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),Se=()=>u.useContext(Te);function Ce(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}function Oe(e){return R(e.target)&&"BUTTON"===e.target.tagName}function Me(e){return be(e)}function Ae(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}const Le={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Pe={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"};let De=!1;const Fe="ArrowUp",Ne="ArrowDown",He="ArrowLeft",je="ArrowRight";function Ke(e,t,n){return Math.floor(e/t)!==n}function We(e,t){return t<0||t>=e.current.length}function Be(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o,amount:u=1}=void 0===t?{}:t;const c=e.current;let i=n;do{var l,a;i+=r?-u:u}while(i>=0&&i<=c.length-1&&(o?o.includes(i):null==c[i]||(null==(l=c[i])?void 0:l.hasAttribute("disabled"))||"true"===(null==(a=c[i])?void 0:a.getAttribute("aria-disabled"))));return i}function _e(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function qe(e,t){return _e(t,e===Fe||e===Ne,e===He||e===je)}function Ue(e,t,n){return _e(t,e===Ne,n?e===He:e===je)||"Enter"===e||" "==e||""===e}function Ve(e,t){return Be(e,{disabledIndices:t})}function Xe(e,t){return Be(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}e.FloatingDelayGroup=e=>{let{children:t,delay:n}=e;const[r,o]=u.useState({delay:n,initialDelay:n,currentId:null}),c=u.useCallback((e=>{o((t=>({...t,currentId:e})))}),[]);return u.createElement(Te.Provider,{value:u.useMemo((()=>({...r,setState:o,setCurrentId:c})),[r,o,c])},t)},e.FloatingFocusManager=function(e){let{context:t,children:n,order:r=["content"],guards:o=!0,initialFocus:i=0,returnFocus:l=!0,modal:a=!0,visuallyHiddenDismiss:s=!1}=e;const{refs:f,nodeId:d,onOpenChange:v,events:m,_:{domReference:p}}=t,y=Ee(r),b=g(),w=fe(),[E,x]=u.useState(null),I="number"==typeof i&&i<0,k=u.useRef(null),T=u.useRef(null),S=u.useRef(!1),C=u.useRef(null),O=null!=w,P=p&&"combobox"===p.getAttribute("role")&&be(p),D=u.useCallback((function(e){return void 0===e&&(e=f.floating.current),e?ee(e,ne()):[]}),[f]),F=u.useCallback((e=>{const t=D(e);return y.current.map((e=>f.domReference.current&&"reference"===e?f.domReference.current:f.floating.current&&"floating"===e?f.floating.current:t)).filter(Boolean).flat()}),[y,f,D]);u.useEffect((()=>{if(!a)return;function e(e){if("Tab"===e.key){0!==D().length||P||we(e);const t=F(),n=L(e);"reference"===y.current[0]&&n===f.domReference.current&&(we(e),e.shiftKey?xe(t[t.length-1]):xe(t[1])),"floating"===y.current[1]&&n===f.floating.current&&e.shiftKey&&(we(e),xe(t[0]))}}const t=h(f.floating.current);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[a,y,f,P,D,F]),u.useEffect((()=>{var e,t;const n=f.floating.current,r=f.domReference.current,o=Array.from(null!=(e=null==w||null==(t=w.portalNode)?void 0:t.querySelectorAll("[data-floating-ui-portal]"))?e:[]);let u=!1;function c(){u=!0,setTimeout((()=>{u=!1}))}function i(e){const t=e.relatedTarget,o=!(M(r,t)||M(n,t)||M(t,n)||M(null==w?void 0:w.portalNode,t)||[null==w?void 0:w.beforeOutsideRef.current,null==w?void 0:w.afterOutsideRef.current].filter(Boolean).includes(t)||b&&(A(b.nodesRef.current,d).find((e=>{var n,r;return M(null==(n=e.context)?void 0:n.refs.floating.current,t)||M(null==(r=e.context)?void 0:r.refs.domReference.current,t)}))||function(e,t){var n;let r=[],o=null==(n=e.find((e=>e.id===t)))?void 0:n.parentId;for(;o;){const t=e.find((e=>e.id===o));o=null==t?void 0:t.parentId,t&&(r=r.concat(t))}return r}(b.nodesRef.current,d).find((e=>{var n,r;return(null==(n=e.context)?void 0:n.refs.floating.current)===t||(null==(r=e.context)?void 0:r.refs.domReference.current)===t}))));t&&o&&!u&&t!==C.current&&(S.current=!0,setTimeout((()=>v(!1))))}if(n&&R(r)){let e;if(a){const t=[n,...o,...[k.current,T.current].filter(Boolean)];e=ye(y.current.includes("reference")||P?t.concat(r):t)}return r.addEventListener("focusout",i),r.addEventListener("pointerdown",c),!a&&n.addEventListener("focusout",i),()=>{r.removeEventListener("focusout",i),r.removeEventListener("pointerdown",c),!a&&n.removeEventListener("focusout",i),null==e||e()}}}),[a,i,d,b,y,f,w,P,I,v]),u.useEffect((()=>{const e=f.floating.current;if(a&&!o&&e){const t=[],n=ne(),r=ee(h(e).body,n),o=F(),u=r.filter((e=>!o.includes(e)));return u.forEach(((e,n)=>{t[n]=e.getAttribute("tabindex"),e.setAttribute("tabindex","-1")})),()=>{u.forEach(((e,n)=>{const r=t[n];null==r?e.removeAttribute("tabindex"):e.setAttribute("tabindex",r)}))}}}),[a,o,f,F]),c((()=>{var e;const t=f.floating.current;if(!t)return;const n=h(t);let r=l,o=!1;const u=null!=(e=f.domReference.current)?e:te(n);C.current=u;const c=F(t),a=("number"==typeof i?c[i]:i.current)||t;function s(e){if("outsidePress"!==e.type)return;const t=e.data.returnFocus;"object"==typeof t?(r=!0,o=t.preventScroll):r=t}return!I&&xe(a,{preventScroll:a===t}),m.on("dismiss",s),()=>{m.off("dismiss",s),r&&R(u)&&!S.current&&xe(u,{preventScroll:o,cancelPrevious:!1})}}),[F,i,l,f,m,I]),c((()=>{if(w)return w.setFocusManagerState({...t,modal:a}),()=>{w.setFocusManagerState(null)}}),[w,a,t]),c((()=>{0!==D().length||I||x(0)}),[D,f,I]);const N=o&&(O||a)&&!P;function H(e){return s&&a?u.createElement(Ie,{ref:"start"===e?k:T,onClick:()=>v(!1)},"string"==typeof s?s:"Dismiss"):null}return u.createElement(u.Fragment,null,N&&u.createElement(j,{ref:null==w?void 0:w.beforeInsideRef,onFocus:e=>{if(a){const e=F();xe("reference"===r[0]?e[0]:e[e.length-1])}else if(null!=w&&w.preserveTabOrder&&w.portalNode)if(S.current=!1,ce(e,w.portalNode)){const e=oe()||p;null==e||e.focus()}else{var t;null==(t=w.beforeOutsideRef.current)||t.focus()}}}),P?null:H("start"),u.cloneElement(n,0===E||r.includes("floating")?{tabIndex:0}:{}),H("end"),N&&u.createElement(j,{ref:null==w?void 0:w.afterInsideRef,onFocus:e=>{if(a)xe(F()[0]);else if(null!=w&&w.preserveTabOrder&&w.portalNode)if(S.current=!0,ce(e,w.portalNode)){const e=ue()||p;null==e||e.focus()}else{var t;null==(t=w.afterOutsideRef.current)||t.focus()}}}))},e.FloatingNode=e=>{let{children:t,id:n}=e;const r=p();return u.createElement(v.Provider,{value:u.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},e.FloatingOverlay=ve,e.FloatingPortal=e=>{let{children:t,id:n,root:o=null,preserveTabOrder:c=!0}=e;const i=se({id:n,enabled:!o}),[l,a]=u.useState(null),s=u.useRef(null),f=u.useRef(null),d=u.useRef(null),v=u.useRef(null),m=!!l&&!l.modal&&!(!o&&!i)&&c;return u.useEffect((()=>{if(i&&c&&(null==l||!l.modal))return i.addEventListener("focusin",e,!0),i.addEventListener("focusout",e,!0),()=>{i.removeEventListener("focusin",e,!0),i.removeEventListener("focusout",e,!0)};function e(e){if(i&&ce(e)){("focusin"===e.type?le:ie)(i)}}}),[i,c,null==l?void 0:l.modal]),u.createElement(ae.Provider,{value:u.useMemo((()=>({preserveTabOrder:c,beforeOutsideRef:s,afterOutsideRef:f,beforeInsideRef:d,afterInsideRef:v,portalNode:i,setFocusManagerState:a})),[c,i])},m&&i&&u.createElement(j,{ref:s,onFocus:e=>{if(ce(e,i)){var t;null==(t=d.current)||t.focus()}else{const e=ue()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus()}}}),m&&i&&u.createElement("span",{"aria-owns":i.id,style:D}),o?r.createPortal(t,o):i?r.createPortal(t,i):null,m&&i&&u.createElement(j,{ref:f,onFocus:e=>{if(ce(e,i)){var t;null==(t=v.current)||t.focus()}else{const e=oe()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus(),null==l||l.onOpenChange(!1)}}}))},e.FloatingTree=e=>{let{children:t}=e;const n=u.useRef([]),r=u.useCallback((e=>{n.current=[...n.current,e]}),[]),o=u.useCallback((e=>{n.current=n.current.filter((t=>t!==e))}),[]),c=u.useState((()=>i()))[0];return u.createElement(m.Provider,{value:u.useMemo((()=>({nodesRef:n,addNode:r,removeNode:o,events:c})),[n,r,o,c])},t)},e.inner=e=>({name:"inner",options:e,async fn(n){var o;const{listRef:u,overflowRef:c,onFallbackChange:i,offset:l=0,index:a=0,minItemsVisible:s=4,referenceOverflowThreshold:f=0,scrollRef:d,...v}=e,{rects:m,elements:{floating:p}}=n,g=u.current[a];if(!g)return{};const h={...n,...await t.offset(-g.offsetTop-m.reference.height/2-g.offsetHeight/2-l).fn(n)},y=null!=(o=null==d?void 0:d.current)?o:p,b=await t.detectOverflow(Ce(h,y.scrollHeight),v),w=await t.detectOverflow(h,{...v,elementContext:"reference"}),E=Math.max(0,b.top),R=h.y+E,x=Math.max(0,y.scrollHeight-E-Math.max(0,b.bottom));return y.style.maxHeight=x+"px",y.scrollTop=E,i&&(y.offsetHeight<g.offsetHeight*Math.min(s,u.current.length-1)-1||w.top>=-f||w.bottom>=-f?r.flushSync((()=>i(!0))):r.flushSync((()=>i(!1)))),c&&(c.current=await t.detectOverflow(Ce({...h,y:R},y.offsetHeight),v)),{y:R}}}),e.safePolygon=function(e){let t,{restMs:n=0,buffer:r=.5,blockPointerEvents:o=!0,debug:u=null}=void 0===e?{}:e,c=!1;const i=e=>{let{x:o,y:u,placement:i,refs:l,onClose:a,nodeId:s,tree:f,leave:d=!1}=e;return function(e){function v(){clearTimeout(t),a()}clearTimeout(t);const{clientX:m,clientY:p}=e,g=L(e);if("mousemove"===e.type&&M(l.domReference.current,g))return;if("mouseleave"===e.type&&E(e.relatedTarget)&&M(l.floating.current,e.relatedTarget))return;if(f&&A(f.nodesRef.current,s).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if(M(l.floating.current,g)&&!d)return void(c=!0);if(!l.domReference.current||!l.floating.current||null==i||null==o||null==u)return;const h=l.domReference.current.getBoundingClientRect(),y=l.floating.current.getBoundingClientRect(),b=i.split("-")[0],w=o>y.right-y.width/2,R=u>y.bottom-y.height/2;if("top"===b&&u>=h.bottom-1||"bottom"===b&&u<=h.top+1||"left"===b&&o>=h.right-1||"right"===b&&o<=h.left+1)return v();switch(b){case"top":if(m>=y.left&&m<=y.right&&p>=y.top&&p<=h.top+1)return;break;case"bottom":if(m>=y.left&&m<=y.right&&p>=h.bottom-1&&p<=y.bottom)return;break;case"left":if(m>=y.left&&m<=h.left+1&&p>=y.top&&p<=y.bottom)return;break;case"right":if(m>=h.right-1&&m<=y.right&&p>=y.top&&p<=y.bottom)return}if(c)return v();const x=function(e){let[t,n]=e;const o=y.width>h.width,u=y.height>h.height;switch(b){case"top":return[[o?t+r/2:w?t+4*r:t-4*r,n+r+1],[o?t-r/2:w?t+4*r:t-4*r,n+r+1],...[[y.left,w||o?y.bottom-r:y.top],[y.right,w?o?y.bottom-r:y.top:y.bottom-r]]];case"bottom":return[[o?t+r/2:w?t+4*r:t-4*r,n-r],[o?t-r/2:w?t+4*r:t-4*r,n-r],...[[y.left,w||o?y.top+r:y.bottom],[y.right,w?o?y.top+r:y.bottom:y.top+r]]];case"left":{const e=[t+r+1,u?n+r/2:R?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:R?n+4*r:n-4*r];return[...[[R||u?y.right-r:y.left,y.top],[R?u?y.right-r:y.left:y.right-r,y.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:R?n+4*r:n-4*r],[t-r,u?n-r/2:R?n+4*r:n-4*r],...[[R||u?y.left+r:y.right,y.top],[R?u?y.left+r:y.right:y.left+r,y.bottom]]]}}([o,u]);!function(e,t){const[n,r]=e;let o=!1;const u=t.length;for(let e=0,c=u-1;e<u;c=e++){const[u,i]=t[e]||[0,0],[l,a]=t[c]||[0,0];i>=r!=a>=r&&n<=(l-u)*(r-i)/(a-i)+u&&(o=!o)}return o}([m,p],x)?v():n&&(t=setTimeout(a,n))}};return i.__options={blockPointerEvents:o},i},e.useClick=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c}=e,{enabled:i=!0,event:l="click",toggle:a=!0,ignoreMouse:s=!1,keyboardHandlers:f=!0}=void 0===t?{}:t;const d=u.useRef();return u.useMemo((()=>i?{reference:{onPointerDown(e){d.current=e.pointerType},onMouseDown(e){0===e.button&&("mouse"===d.current&&s||"click"!==l&&(n?!a||o.current.openEvent&&"mousedown"!==o.current.openEvent.type||r(!1):(e.preventDefault(),r(!0)),o.current.openEvent=e.nativeEvent))},onClick(e){"mousedown"===l&&d.current?d.current=void 0:"mouse"===d.current&&s||(n?!a||o.current.openEvent&&"click"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent)},onKeyDown(e){d.current=void 0,f&&(Oe(e)||(" "!==e.key||Me(c.domReference.current)||e.preventDefault(),"Enter"===e.key&&(n?a&&r(!1):r(!0))))},onKeyUp(e){f&&(Oe(e)||Me(c.domReference.current)||" "===e.key&&(n?a&&r(!1):r(!0)))}}}:{}),[i,o,l,s,f,c,a,n,r])},e.useDelayGroup=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:o}=t;const{currentId:c,initialDelay:i,setState:l}=Se();u.useEffect((()=>{c&&(l((e=>({...e,delay:{open:1,close:ke(i,"close")}}))),c!==o&&r(!1))}),[o,r,l,c,i]),u.useEffect((()=>{n||c!==o||(r(!1),l((e=>({...e,delay:i,currentId:null}))))}),[n,l,c,o,r,i])},e.useDelayGroupContext=Se,e.useDismiss=function(e,n){let{open:r,onOpenChange:o,refs:c,events:i,nodeId:l}=e,{enabled:a=!0,escapeKey:s=!0,outsidePress:f=!0,outsidePressEvent:d="pointerdown",referencePress:v=!1,referencePressEvent:m="pointerdown",ancestorScroll:y=!1,bubbles:b=!0}=void 0===n?{}:n;const w=g(),R=null!=p(),k=u.useRef(!1);return u.useEffect((()=>{if(!r||!a)return;function e(e){if("Escape"===e.key){if(!b&&w&&A(w.nodesRef.current,l).length>0)return;i.emit("dismiss",{type:"escapeKey",data:{returnFocus:{preventScroll:!1}}}),o(!1)}}function n(e){const t=k.current;if(k.current=!1,t)return;if("function"==typeof f&&!f(e))return;const n=L(e);if(E(n)&&c.floating.current){var r;const t=null!=(r=c.floating.current.ownerDocument.defaultView)?r:window,o=n.scrollWidth>n.clientWidth,u=n.scrollHeight>n.clientHeight;let i=u&&e.offsetX>n.clientWidth;if(u){"rtl"===t.getComputedStyle(n).direction&&(i=e.offsetX<=n.offsetWidth-n.clientWidth)}if(i||o&&e.offsetY>n.clientHeight)return}const u=w&&A(w.nodesRef.current,l).some((t=>{var n;return Ae(e,null==(n=t.context)?void 0:n.refs.floating.current)}));Ae(e,c.floating.current)||Ae(e,c.domReference.current)||u||!b&&w&&A(w.nodesRef.current,l).length>0||(i.emit("dismiss",{type:"outsidePress",data:{returnFocus:R?{preventScroll:!0}:x(e)||I(e)}}),o(!1))}function u(){o(!1)}const v=h(c.floating.current);s&&v.addEventListener("keydown",e),f&&v.addEventListener(d,n);let m=[];return y&&(E(c.domReference.current)&&(m=t.getOverflowAncestors(c.domReference.current)),E(c.floating.current)&&(m=m.concat(t.getOverflowAncestors(c.floating.current))),!E(c.reference.current)&&c.reference.current&&c.reference.current.contextElement&&(m=m.concat(t.getOverflowAncestors(c.reference.current.contextElement)))),m=m.filter((e=>{var t;return e!==(null==(t=v.defaultView)?void 0:t.visualViewport)})),m.forEach((e=>{e.addEventListener("scroll",u,{passive:!0})})),()=>{s&&v.removeEventListener("keydown",e),f&&v.removeEventListener(d,n),m.forEach((e=>{e.removeEventListener("scroll",u)}))}}),[s,f,d,i,w,l,r,o,y,a,b,c,R]),u.useEffect((()=>{k.current=!1}),[f,d]),u.useMemo((()=>a?{reference:{[Le[m]]:()=>{v&&(i.emit("dismiss",{type:"referencePress",data:{returnFocus:!1}}),o(!1))}},floating:{[Pe[d]]:()=>{k.current=!0}}}:{}),[a,i,v,d,m,o])},e.useFloating=function(e){let{open:n=!1,onOpenChange:r,whileElementsMounted:o,placement:l,middleware:a,strategy:s,nodeId:f}=void 0===e?{}:e;const[d,v]=u.useState(null),m=g(),p=u.useRef(null),h=u.useRef({}),y=u.useState((()=>i()))[0],b=t.useFloating({placement:l,middleware:a,strategy:s,whileElementsMounted:o}),w=C(r),R=u.useMemo((()=>({...b.refs,domReference:p})),[b.refs]),x=u.useMemo((()=>({...b,refs:R,dataRef:h,nodeId:f,events:y,open:n,onOpenChange:w,_:{domReference:d}})),[b,f,y,n,w,R,d]);c((()=>{const e=null==m?void 0:m.nodesRef.current.find((e=>e.id===f));e&&(e.context=x)}));const{reference:I}=b,k=u.useCallback((e=>{(E(e)||null===e)&&(x.refs.domReference.current=e,v(e)),I(e)}),[I,x.refs]);return u.useMemo((()=>({...b,context:x,refs:R,reference:k})),[b,R,x,k])},e.useFloatingNodeId=e=>{const t=d(),n=g(),r=p(),o=e||r;return c((()=>{const e={id:t,parentId:o};return null==n||n.addNode(e),()=>{null==n||n.removeNode(e)}}),[n,t,o]),t},e.useFloatingParentNodeId=p,e.useFloatingPortalNode=se,e.useFloatingTree=g,e.useFocus=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c,events:i}=e,{enabled:l=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const s=u.useRef(""),f=u.useRef(!1),d=u.useRef();return u.useEffect((()=>{var e;if(!l)return;const t=null!=(e=h(c.floating.current).defaultView)?e:window;function r(){!n&&R(c.domReference.current)&&c.domReference.current===te(h(c.domReference.current))&&(f.current=!0)}return t.addEventListener("blur",r),()=>{t.removeEventListener("blur",r)}}),[c,n,l]),u.useEffect((()=>{if(l)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(e){"referencePress"===e.type&&(f.current=!0)}}),[i,l]),u.useEffect((()=>()=>{clearTimeout(d.current)}),[]),u.useMemo((()=>l?{reference:{onPointerDown(e){let{pointerType:t}=e;s.current=t,f.current=!(!t||!a)},onPointerLeave(){f.current=!1},onFocus(e){var t;f.current||"focus"===e.type&&"mousedown"===(null==(t=o.current.openEvent)?void 0:t.type)&&o.current.openEvent&&Ae(o.current.openEvent,c.domReference.current)||(o.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){f.current=!1;const t=e.relatedTarget,n=E(t)&&t.hasAttribute("data-floating-ui-focus-guard");d.current=setTimeout((()=>{M(c.floating.current,t)||M(c.domReference.current,t)||n||r(!1)}))}}}:{}),[l,a,c,o,r])},e.useHover=function(e,t){let{enabled:n=!0,delay:r=0,handleClose:o=null,mouseOnly:i=!1,restMs:l=0,move:a=!0}=void 0===t?{}:t;const{open:s,onOpenChange:f,dataRef:d,events:v,refs:m,_:y}=e,b=g(),w=p(),R=Ee(o),x=Ee(r),I=u.useRef(),k=u.useRef(),T=u.useRef(),S=u.useRef(),C=u.useRef(!0),O=u.useRef(!1),M=u.useCallback((()=>{var e;const t=null==(e=d.current.openEvent)?void 0:e.type;return(null==t?void 0:t.includes("mouse"))&&"mousedown"!==t}),[d]);u.useEffect((()=>{if(n)return v.on("dismiss",e),()=>{v.off("dismiss",e)};function e(){clearTimeout(k.current),clearTimeout(S.current),C.current=!0}}),[n,v,m]),u.useEffect((()=>{if(!n||!R.current||!s)return;function e(){M()&&f(!1)}const t=h(m.floating.current).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[m,s,f,n,R,d,M]);const A=u.useCallback((function(e){void 0===e&&(e=!0);const t=ke(x.current,"close",I.current);t&&!T.current?(clearTimeout(k.current),k.current=setTimeout((()=>f(!1)),t)):e&&(clearTimeout(k.current),f(!1))}),[x,f]),L=u.useCallback((()=>{T.current&&(h(m.floating.current).removeEventListener("mousemove",T.current),T.current=void 0)}),[m]),P=u.useCallback((()=>{h(m.floating.current).body.style.pointerEvents="",O.current=!1}),[m]);return u.useEffect((()=>{if(!n)return;function t(){return!!d.current.openEvent&&["click","mousedown"].includes(d.current.openEvent.type)}function r(e){if(clearTimeout(k.current),C.current=!1,i&&"mouse"!==I.current||l>0&&0===ke(x.current,"open"))return;d.current.openEvent=e;const t=ke(x.current,"open",I.current);t?k.current=setTimeout((()=>{f(!0)}),t):f(!0)}function o(n){if(t())return;const r=h(m.floating.current);if(clearTimeout(S.current),R.current)return clearTimeout(k.current),T.current&&r.removeEventListener("mousemove",T.current),T.current=R.current({...e,tree:b,x:n.clientX,y:n.clientY,onClose(){P(),L(),A()}}),void r.addEventListener("mousemove",T.current);A()}function u(n){t()||null==R.current||R.current({...e,tree:b,x:n.clientX,y:n.clientY,leave:!0,onClose(){P(),L(),A()}})(n)}const c=m.floating.current,v=m.domReference.current;return E(v)?(s&&v.addEventListener("mouseleave",u),null==c||c.addEventListener("mouseleave",u),a&&v.addEventListener("mousemove",r,{once:!0}),v.addEventListener("mouseenter",r),v.addEventListener("mouseleave",o),()=>{s&&v.removeEventListener("mouseleave",u),null==c||c.removeEventListener("mouseleave",u),a&&v.removeEventListener("mousemove",r),v.removeEventListener("mouseenter",r),v.removeEventListener("mouseleave",o)}):void 0}),[y.domReference,n,e,i,l,a,A,L,P,f,s,b,m,x,R,d]),c((()=>{if(n&&s&&R.current&&R.current.__options.blockPointerEvents&&M()){h(m.floating.current).body.style.pointerEvents="none",O.current=!0;const n=m.domReference.current,r=m.floating.current;if(E(n)&&r){var e,t;const o=null==b||null==(e=b.nodesRef.current.find((e=>e.id===w)))||null==(t=e.context)?void 0:t.refs.floating.current;return o&&(o.style.pointerEvents=""),n.style.pointerEvents="auto",r.style.pointerEvents="auto",()=>{n.style.pointerEvents="",r.style.pointerEvents=""}}}}),[n,s,w,m,b,R,d,M]),c((()=>{s||(I.current=void 0,L(),O.current&&P())}),[s,L,P]),u.useEffect((()=>()=>{L(),clearTimeout(k.current),clearTimeout(S.current),O.current&&P()}),[n,L,P]),u.useMemo((()=>{if(!n)return{};function e(e){I.current=e.pointerType}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove(){s||0===l||(clearTimeout(S.current),S.current=setTimeout((()=>{C.current||f(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(k.current)},onMouseLeave(){A(!1)}}}}),[n,l,s,f,A])},e.useId=d,e.useInnerOffset=(e,t)=>{let{open:n,refs:o}=e,{enabled:c=!0,overflowRef:i,scrollRef:l,onChange:a}=t;const s=C(a),f=u.useRef(!1),d=u.useRef(null),v=u.useRef(null);return u.useEffect((()=>{var e;if(!c)return;function t(e){if(e.ctrlKey||!u||null==i.current)return;const t=e.deltaY,n=i.current.top>=-.5,o=i.current.bottom>=-.5,c=u.scrollHeight-u.clientHeight,l=t<0?-1:1,a=t<0?"max":"min";u.scrollHeight<=u.clientHeight||(!n&&t>0||!o&&t<0?(e.preventDefault(),r.flushSync((()=>{s((e=>e+Math[a](t,c*l)))}))):/firefox/i.test(b())&&(u.scrollTop+=t))}const u=null!=(e=null==l?void 0:l.current)?e:o.floating.current;return n&&u?(u.addEventListener("wheel",t),requestAnimationFrame((()=>{d.current=u.scrollTop,null!=i.current&&(v.current={...i.current})})),()=>{d.current=null,v.current=null,u.removeEventListener("wheel",t)}):void 0}),[c,n,o,i,l,s]),u.useMemo((()=>c?{floating:{onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const e=(null==l?void 0:l.current)||o.floating.current;if(i.current&&e&&f.current){if(null!==d.current){const t=e.scrollTop-d.current;(i.current.bottom<-.5&&t<-1||i.current.top<-.5&&t>1)&&r.flushSync((()=>s((e=>e+t))))}requestAnimationFrame((()=>{d.current=e.scrollTop}))}}}}:{}),[c,i,o,l,s])},e.useInteractions=function(e){void 0===e&&(e=[]);const t=e,n=u.useCallback((t=>O(t,e,"reference")),t),r=u.useCallback((t=>O(t,e,"floating")),t),o=u.useCallback((t=>O(t,e,"item")),t);return u.useMemo((()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:o})),[n,r,o])},e.useListNavigation=function(e,t){let{open:n,onOpenChange:o,refs:i}=e,{listRef:l,activeIndex:a,onNavigate:s=(()=>{}),enabled:f=!0,selectedIndex:d=null,allowEscape:v=!1,loop:m=!1,nested:y=!1,rtl:b=!1,virtual:w=!1,focusItemOnOpen:E="auto",focusItemOnHover:S=!0,openOnArrowKeyDown:O=!0,disabledIndices:A,orientation:L="vertical",cols:P=1}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const D=p(),F=g(),N=C(s),H=u.useRef(E),j=u.useRef(null!=d?d:-1),K=u.useRef(null),W=u.useRef(!1),B=u.useRef(N),_=u.useRef(n),q=u.useRef(!1),U=Ee(A),V=Ee(n),[X,Y]=u.useState(),z=u.useCallback(((e,t)=>{if(w){var n;Y(null==(n=e.current[t.current])?void 0:n.id)}else{xe(e.current[t.current],{preventScroll:!0,sync:!(!T()||!k())&&(De||q.current)})}}),[w]);return c((()=>{document.createElement("div").focus({get preventScroll(){return De=!0,!1}})}),[]),c((()=>{f&&(n?H.current&&null!=d&&N(d):_.current&&(j.current=-1,B.current(null)))}),[f,n,d,N]),c((()=>{if(f&&n)if(null==a){if(q.current=!1,null!=d)return;_.current&&(j.current=-1,z(l,j)),!_.current&&H.current&&(null!=K.current||!0===H.current&&null==K.current)&&(j.current=null==K.current||Ue(K.current,L,b)||y?Ve(l,U.current):Xe(l,U.current),N(j.current))}else We(l,a)||(j.current=a,z(l,j))}),[f,n,a,d,y,l,L,b,N,z,U]),c((()=>{if(f&&_.current&&!n){var e,t;const n=null==F||null==(e=F.nodesRef.current.find((e=>e.id===D)))||null==(t=e.context)?void 0:t.refs.floating.current;n&&!M(n,te(h(n)))&&n.focus({preventScroll:!0})}}),[f,n,F,D]),c((()=>{K.current=null,B.current=N,_.current=n})),u.useMemo((()=>{if(!f)return{};const e=U.current;function t(t){if(W.current=!0,q.current=!0,!V.current&&t.currentTarget===i.floating.current)return;if(y&&function(e,t,n){return _e(t,n?e===je:e===He,e===Fe)}(t.key,L,b))return we(t),o(!1),void(R(i.domReference.current)&&i.domReference.current.focus());const r=j.current,u=Ve(l,e),c=Xe(l,e);if("Home"===t.key&&(j.current=u,N(j.current)),"End"===t.key&&(j.current=c,N(j.current)),P>1){const n=j.current;if(t.key===Fe){if(we(t),-1===n)j.current=c;else if(j.current=Be(l,{startingIndex:n,amount:P,decrement:!0,disabledIndices:e}),m&&(n-P<u||j.current<0)){const e=n%P,t=c%P,r=c-(t-e);j.current=t===e?c:t>e?r:r-P}We(l,j.current)&&(j.current=n),N(j.current)}if(t.key===Ne&&(we(t),-1===n?j.current=u:(j.current=Be(l,{startingIndex:n,amount:P,disabledIndices:e}),m&&n+P>c&&(j.current=Be(l,{startingIndex:n%P-P,amount:P,disabledIndices:e}))),We(l,j.current)&&(j.current=n),N(j.current)),"both"===L){const r=Math.floor(n/P);t.key===je&&(we(t),n%P!=P-1?(j.current=Be(l,{startingIndex:n,disabledIndices:e}),m&&Ke(j.current,P,r)&&(j.current=Be(l,{startingIndex:n-n%P-1,disabledIndices:e}))):m&&(j.current=Be(l,{startingIndex:n-n%P-1,disabledIndices:e})),Ke(j.current,P,r)&&(j.current=n)),t.key===He&&(we(t),n%P!=0?(j.current=Be(l,{startingIndex:n,disabledIndices:e,decrement:!0}),m&&Ke(j.current,P,r)&&(j.current=Be(l,{startingIndex:n+(P-n%P),decrement:!0,disabledIndices:e}))):m&&(j.current=Be(l,{startingIndex:n+(P-n%P),decrement:!0,disabledIndices:e})),Ke(j.current,P,r)&&(j.current=n));const o=Math.floor(c/P)===r;return We(l,j.current)&&(j.current=m&&o?t.key===He?c:Be(l,{startingIndex:n-n%P-1,disabledIndices:e}):n),void N(j.current)}}if(qe(t.key,L)){if(we(t),n&&!w&&te(t.currentTarget.ownerDocument)===t.currentTarget)return j.current=Ue(t.key,L,b)?u:c,void N(j.current);Ue(t.key,L,b)?j.current=m?r>=c?v&&r!==l.current.length?-1:u:Be(l,{startingIndex:r,disabledIndices:e}):Math.min(c,Be(l,{startingIndex:r,disabledIndices:e})):j.current=m?r<=u?v&&-1!==r?l.current.length:c:Be(l,{startingIndex:r,decrement:!0,disabledIndices:e}):Math.max(u,Be(l,{startingIndex:r,decrement:!0,disabledIndices:e})),We(l,j.current)?N(null):N(j.current)}}function u(e){"auto"===E&&x(e.nativeEvent)&&(H.current=!0)}return{reference:{...w&&n&&null!=a&&{"aria-activedescendant":X},onKeyDown(r){W.current=!0;const u=0===r.key.indexOf("Arrow");if(w&&n)return t(r);if(!n&&!O&&u)return;(u||"Enter"===r.key||" "===r.key||""===r.key)&&(K.current=r.key),y?function(e,t,n){return _e(t,n?e===He:e===je,e===Ne)}(r.key,L,b)&&(we(r),n?(j.current=Ve(l,e),N(j.current)):o(!0)):qe(r.key,L)&&(null!=d&&(j.current=d),we(r),!n&&O?o(!0):t(r),n&&N(j.current))},onFocus(){n&&N(null)},onPointerDown:function(e){H.current=E,"auto"===E&&I(e.nativeEvent)&&(H.current=!0)},onMouseDown:u,onClick:u},floating:{"aria-orientation":"both"===L?void 0:L,...w&&null!=a&&{"aria-activedescendant":X},onKeyDown:t,onPointerMove(){W.current=!1}},item:{onFocus(e){let{currentTarget:t}=e;const n=l.current.indexOf(t);-1!==n&&a!==n&&N(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...S&&{onMouseMove(e){let{currentTarget:t}=e;const n=t;if(n){const e=l.current.indexOf(n);-1!==e&&a!==e&&N(e)}},onPointerLeave(){var e;W.current||(j.current=-1,z(l,j),r.flushSync((()=>N(null))),w||null==(e=i.floating.current)||e.focus({preventScroll:!0}))}}}}}),[X,U,V,l,f,L,b,w,n,a,y,d,O,S,v,P,m,i,E,z,N,o])},e.useRole=function(e,t){let{open:n}=e,{enabled:r=!0,role:o="dialog"}=void 0===t?{}:t;const c=d(),i=d();return u.useMemo((()=>{const e={id:c,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":n?c:void 0},floating:e}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":"alertdialog"===o?"dialog":o,"aria-controls":n?c:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:i}},floating:{...e,..."menu"===o&&{"aria-labelledby":i}}}:{}}),[r,o,n,c,i])},e.useTypeahead=function(e,t){var n;let{open:r,dataRef:o}=e,{listRef:i,activeIndex:l,onMatch:a=(()=>{}),enabled:s=!0,findMatch:f=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const p=u.useRef(),g=u.useRef(""),y=u.useRef(null!=(n=null!=m?m:l)?n:-1),b=u.useRef(null),w=C(a),R=Ee(f),x=Ee(v);return c((()=>{r&&(clearTimeout(p.current),b.current=null,g.current="")}),[r]),c((()=>{var e;r&&""===g.current&&(y.current=null!=(e=null!=m?m:l)?e:-1)}),[r,m,l]),u.useMemo((()=>{if(!s)return{};function e(e){const t=L(e.nativeEvent);if(E(t)&&te(h(t))!==e.currentTarget&&t.closest('[role="dialog"],[role="menu"],[role="listbox"],[role="tree"],[role="grid"]')!==e.currentTarget)return;g.current.length>0&&" "!==g.current[0]&&(o.current.typing=!0," "===e.key&&we(e));const n=i.current;if(null==n||x.current.includes(e.key)||1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey)return;n.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&g.current===e.key&&(g.current="",y.current=b.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",y.current=b.current,o.current.typing=!1}),d);const r=y.current,u=[...n.slice((null!=r?r:0)+1),...n.slice(0,(null!=r?r:0)+1)],c=R.current?R.current(u,g.current):u.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current.toLocaleLowerCase())))),l=c?n.indexOf(c):-1;-1!==l&&(w(l),b.current=l)}return{reference:{onKeyDown:e},floating:{onKeyDown:e}}}),[s,o,i,d,x,R,w])},Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})}));
*/var K=["input","select","textarea","a[href]","button","[tabindex]:not(slot)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"].join(","),W="undefined"==typeof Element,B=W?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,_=!W&&Element.prototype.getRootNode?function(e){return e.getRootNode()}:function(e){return e.ownerDocument},q=function e(t,n,r){for(var o=[],u=Array.from(t);u.length;){var c=u.shift();if("SLOT"===c.tagName){var i=c.assignedElements(),l=e(i.length?i:c.children,!0,r);r.flatten?o.push.apply(o,l):o.push({scopeParent:c,candidates:l})}else{B.call(c,K)&&r.filter(c)&&(n||!t.includes(c))&&o.push(c);var a=c.shadowRoot||"function"==typeof r.getShadowRoot&&r.getShadowRoot(c),s=!r.shadowRootFilter||r.shadowRootFilter(c);if(a&&s){var f=e(!0===a?c.children:a.children,!0,r);r.flatten?o.push.apply(o,f):o.push({scopeParent:c,candidates:f})}else u.unshift.apply(u,c.children)}}return o},U=function(e,t){return e.tabIndex<0&&(t||/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||e.isContentEditable)&&isNaN(parseInt(e.getAttribute("tabindex"),10))?0:e.tabIndex},V=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},X=function(e){return"INPUT"===e.tagName},Y=function(e){return function(e){return X(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||_(e),r=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=r(window.CSS.escape(e.name));else try{t=r(e.name)}catch(e){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",e.message),!1}var o=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!o||o===e}(e)},z=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return 0===n&&0===r},G=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var o=B.call(e,"details>summary:first-of-type")?e.parentElement:e;if(B.call(o,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return z(e)}else{if("function"==typeof r){for(var u=e;e;){var c=e.parentElement,i=_(e);if(c&&!c.shadowRoot&&!0===r(c))return z(e);e=e.assignedSlot?e.assignedSlot:c||i===e.ownerDocument?c:i.host}e=u}if(function(e){for(var t,n=_(e).host,r=!!(null!==(t=n)&&void 0!==t&&t.ownerDocument.contains(n)||e.ownerDocument.contains(e));!r&&n;){var o;r=!(null===(o=n=_(n).host)||void 0===o||!o.ownerDocument.contains(n))}return r}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},$=function(e,t){return!(t.disabled||function(e){return X(e)&&"hidden"===e.type}(t)||G(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!B.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},J=function(e,t){return!(Y(t)||U(t)<0||!$(e,t))},Q=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},Z=function e(t){var n=[],r=[];return t.forEach((function(t,o){var u=!!t.scopeParent,c=u?t.scopeParent:t,i=U(c,u),l=u?e(t.candidates):c;0===i?u?n.push.apply(n,l):n.push(c):r.push({documentOrder:o,tabIndex:i,item:t,isScope:u,content:l})})),r.sort(V).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)},ee=function(e,t){var n;return n=(t=t||{}).getShadowRoot?q([e],t.includeContainer,{filter:J.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:Q}):function(e,t,n){var r=Array.prototype.slice.apply(e.querySelectorAll(K));return t&&B.call(e,K)&&r.unshift(e),r.filter(n)}(e,t.includeContainer,J.bind(null,t)),Z(n)};function te(e){let t=e.activeElement;for(;null!=(null==(n=t)||null==(r=n.shadowRoot)?void 0:r.activeElement);){var n,r;t=t.shadowRoot.activeElement}return t}const ne=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function re(e,t){const n=ee(e,ne());"prev"===t&&n.reverse();const r=n.indexOf(te(h(e)));return n.slice(r+1)[0]}function oe(){return re(document.body,"next")}function ue(){return re(document.body,"prev")}function ce(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!M(n,r)}function ie(e){ee(e,ne()).forEach((e=>{var t;e.dataset.tabindex=null!=(t=e.getAttribute("tabindex"))?t:"",e.setAttribute("tabindex","-1")}))}function le(e){e.querySelectorAll("[data-tabindex]").forEach((e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")}))}const ae=u.createContext(null),se=function(e){let{id:t,enabled:n=!0}=void 0===e?{}:e;const[r,o]=u.useState(null),i=d(),l=fe();return c((()=>{if(!n)return;const e=t?document.getElementById(t):null;if(!e){const e=document.createElement("div");e.id=t||i,e.setAttribute("data-floating-ui-portal",""),o(e);const n=(null==l?void 0:l.portalNode)||document.body;return n.appendChild(e),()=>{n.removeChild(e)}}e.setAttribute("data-floating-ui-portal",""),o(e)}),[t,l,i,n]),r},fe=()=>u.useContext(ae),de="data-floating-ui-scroll-lock",ve=u.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return c((()=>{var e,t,r,o;if(!n)return;if(document.body.hasAttribute(de))return;document.body.setAttribute(de,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(y()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(de),Object.assign(document.body.style,{overflow:"",[u]:""})};const i=null!=(e=null==(t=window.visualViewport)?void 0:t.offsetLeft)?e:0,l=null!=(r=null==(o=window.visualViewport)?void 0:o.offsetTop)?r:0,a=window.pageXOffset,s=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(s-Math.floor(l))+"px",left:-(a-Math.floor(i))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(de),window.scrollTo(a,s)}}),[n]),u.createElement("div",P({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var me=new WeakMap,pe=new WeakMap,ge={},he=0,ye=function(e,t,n){void 0===t&&(t=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e)),void 0===n&&(n="data-aria-hidden");var r=Array.isArray(e)?e:[e];ge[n]||(ge[n]=new WeakMap);var o=ge[n],u=[],c=new Set,i=function(e){e&&!c.has(e)&&(c.add(e),i(e.parentNode))};r.forEach(i);var l=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(c.has(e))l(e);else{var t=e.getAttribute("aria-hidden"),r=null!==t&&"false"!==t,i=(me.get(e)||0)+1,a=(o.get(e)||0)+1;me.set(e,i),o.set(e,a),u.push(e),1===i&&r&&pe.set(e,!0),1===a&&e.setAttribute(n,"true"),r||e.setAttribute("aria-hidden","true")}}))};return l(t),c.clear(),he++,function(){u.forEach((function(e){var t=me.get(e)-1,r=o.get(e)-1;me.set(e,t),o.set(e,r),t||(pe.has(e)||e.removeAttribute("aria-hidden"),pe.delete(e)),r||e.removeAttribute(n)})),--he||(me=new WeakMap,me=new WeakMap,pe=new WeakMap,ge={})}};function be(e){return R(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function we(e){e.preventDefault(),e.stopPropagation()}function Ee(e){const t=n.useRef(e);return c((()=>{t.current=e})),t}let Re=0;function xe(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(Re);const u=()=>null==e?void 0:e.focus({preventScroll:n});o?u():Re=requestAnimationFrame(u)}const Ie=u.forwardRef((function(e,t){return u.createElement("button",P({},e,{ref:t,tabIndex:-1,style:D}))}));function ke(e,t,n){return n&&"mouse"!==n?0:"number"==typeof e?e:null==e?void 0:e[t]}const Te=u.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),Se=()=>u.useContext(Te);function Ce(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}function Oe(e){return R(e.target)&&"BUTTON"===e.target.tagName}function Me(e){return be(e)}function Ae(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}const Le={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Pe={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"};let De=!1;const Fe="ArrowUp",Ne="ArrowDown",He="ArrowLeft",je="ArrowRight";function Ke(e,t,n){return Math.floor(e/t)!==n}function We(e,t){return t<0||t>=e.current.length}function Be(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o,amount:u=1}=void 0===t?{}:t;const c=e.current;let i=n;do{var l,a;i+=r?-u:u}while(i>=0&&i<=c.length-1&&(o?o.includes(i):null==c[i]||(null==(l=c[i])?void 0:l.hasAttribute("disabled"))||"true"===(null==(a=c[i])?void 0:a.getAttribute("aria-disabled"))));return i}function _e(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function qe(e,t){return _e(t,e===Fe||e===Ne,e===He||e===je)}function Ue(e,t,n){return _e(t,e===Ne,n?e===He:e===je)||"Enter"===e||" "==e||""===e}function Ve(e,t){return Be(e,{disabledIndices:t})}function Xe(e,t){return Be(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}e.FloatingDelayGroup=e=>{let{children:t,delay:n}=e;const[r,o]=u.useState({delay:n,initialDelay:n,currentId:null}),c=u.useCallback((e=>{o((t=>({...t,currentId:e})))}),[]);return u.createElement(Te.Provider,{value:u.useMemo((()=>({...r,setState:o,setCurrentId:c})),[r,o,c])},t)},e.FloatingFocusManager=function(e){let{context:t,children:n,order:r=["content"],guards:o=!0,initialFocus:i=0,returnFocus:l=!0,modal:a=!0,visuallyHiddenDismiss:s=!1}=e;const{refs:f,nodeId:d,onOpenChange:v,events:m,_:{domReference:p}}=t,y=Ee(r),b=g(),w=fe(),[E,x]=u.useState(null),I="number"==typeof i&&i<0,k=u.useRef(null),T=u.useRef(null),S=u.useRef(!1),C=u.useRef(null),O=null!=w,P=p&&"combobox"===p.getAttribute("role")&&be(p),D=u.useCallback((function(e){return void 0===e&&(e=f.floating.current),e?ee(e,ne()):[]}),[f]),F=u.useCallback((e=>{const t=D(e);return y.current.map((e=>f.domReference.current&&"reference"===e?f.domReference.current:f.floating.current&&"floating"===e?f.floating.current:t)).filter(Boolean).flat()}),[y,f,D]);u.useEffect((()=>{if(!a)return;function e(e){if("Tab"===e.key){0!==D().length||P||we(e);const t=F(),n=L(e);"reference"===y.current[0]&&n===f.domReference.current&&(we(e),e.shiftKey?xe(t[t.length-1]):xe(t[1])),"floating"===y.current[1]&&n===f.floating.current&&e.shiftKey&&(we(e),xe(t[0]))}}const t=h(f.floating.current);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[a,y,f,P,D,F]),u.useEffect((()=>{var e,t;const n=f.floating.current,r=f.domReference.current,o=Array.from(null!=(e=null==w||null==(t=w.portalNode)?void 0:t.querySelectorAll("[data-floating-ui-portal]"))?e:[]);let u=!1;function c(){u=!0,setTimeout((()=>{u=!1}))}function i(e){const t=e.relatedTarget,o=!(M(r,t)||M(n,t)||M(t,n)||M(null==w?void 0:w.portalNode,t)||[null==w?void 0:w.beforeOutsideRef.current,null==w?void 0:w.afterOutsideRef.current].filter(Boolean).includes(t)||b&&(A(b.nodesRef.current,d).find((e=>{var n,r;return M(null==(n=e.context)?void 0:n.refs.floating.current,t)||M(null==(r=e.context)?void 0:r.refs.domReference.current,t)}))||function(e,t){var n;let r=[],o=null==(n=e.find((e=>e.id===t)))?void 0:n.parentId;for(;o;){const t=e.find((e=>e.id===o));o=null==t?void 0:t.parentId,t&&(r=r.concat(t))}return r}(b.nodesRef.current,d).find((e=>{var n,r;return(null==(n=e.context)?void 0:n.refs.floating.current)===t||(null==(r=e.context)?void 0:r.refs.domReference.current)===t}))));t&&o&&!u&&t!==C.current&&(S.current=!0,setTimeout((()=>v(!1))))}if(n&&R(r)){let e;if(a){const t=[n,...o,...[k.current,T.current].filter(Boolean)];e=ye(y.current.includes("reference")||P?t.concat(r):t)}return r.addEventListener("focusout",i),r.addEventListener("pointerdown",c),!a&&n.addEventListener("focusout",i),()=>{r.removeEventListener("focusout",i),r.removeEventListener("pointerdown",c),!a&&n.removeEventListener("focusout",i),null==e||e()}}}),[a,i,d,b,y,f,w,P,I,v]),u.useEffect((()=>{const e=f.floating.current;if(a&&!o&&e){const t=[],n=ne(),r=ee(h(e).body,n),o=F(),u=r.filter((e=>!o.includes(e)));return u.forEach(((e,n)=>{t[n]=e.getAttribute("tabindex"),e.setAttribute("tabindex","-1")})),()=>{u.forEach(((e,n)=>{const r=t[n];null==r?e.removeAttribute("tabindex"):e.setAttribute("tabindex",r)}))}}}),[a,o,f,F]),c((()=>{const e=f.floating.current;if(!e)return;const t=h(e);let n=l,r=!1;const o=te(t);C.current=o;const u=F(e),c=("number"==typeof i?u[i]:i.current)||e;function a(e){if("escapeKey"===e.type&&f.domReference.current&&(C.current=f.domReference.current),"outsidePress"!==e.type)return;const t=e.data.returnFocus;"object"==typeof t?(n=!0,r=t.preventScroll):n=t}return!I&&xe(c,{preventScroll:c===e}),m.on("dismiss",a),()=>{m.off("dismiss",a),M(e,te(t))&&f.domReference.current&&(C.current=f.domReference.current),n&&R(C.current)&&!S.current&&xe(C.current,{preventScroll:r,cancelPrevious:!1})}}),[F,i,l,f,m,I]),c((()=>{if(w)return w.setFocusManagerState({...t,modal:a}),()=>{w.setFocusManagerState(null)}}),[w,a,t]),c((()=>{0!==D().length||I||x(0)}),[D,f,I]);const N=o&&(O||a)&&!P;function H(e){return s&&a?u.createElement(Ie,{ref:"start"===e?k:T,onClick:()=>v(!1)},"string"==typeof s?s:"Dismiss"):null}return u.createElement(u.Fragment,null,N&&u.createElement(j,{ref:null==w?void 0:w.beforeInsideRef,onFocus:e=>{if(a){const e=F();xe("reference"===r[0]?e[0]:e[e.length-1])}else if(null!=w&&w.preserveTabOrder&&w.portalNode)if(S.current=!1,ce(e,w.portalNode)){const e=oe()||p;null==e||e.focus()}else{var t;null==(t=w.beforeOutsideRef.current)||t.focus()}}}),P?null:H("start"),u.cloneElement(n,0===E||r.includes("floating")?{tabIndex:0}:{}),H("end"),N&&u.createElement(j,{ref:null==w?void 0:w.afterInsideRef,onFocus:e=>{if(a)xe(F()[0]);else if(null!=w&&w.preserveTabOrder&&w.portalNode)if(S.current=!0,ce(e,w.portalNode)){const e=ue()||p;null==e||e.focus()}else{var t;null==(t=w.afterOutsideRef.current)||t.focus()}}}))},e.FloatingNode=e=>{let{children:t,id:n}=e;const r=p();return u.createElement(v.Provider,{value:u.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},e.FloatingOverlay=ve,e.FloatingPortal=e=>{let{children:t,id:n,root:o=null,preserveTabOrder:c=!0}=e;const i=se({id:n,enabled:!o}),[l,a]=u.useState(null),s=u.useRef(null),f=u.useRef(null),d=u.useRef(null),v=u.useRef(null),m=!!l&&!l.modal&&!(!o&&!i)&&c;return u.useEffect((()=>{if(i&&c&&(null==l||!l.modal))return i.addEventListener("focusin",e,!0),i.addEventListener("focusout",e,!0),()=>{i.removeEventListener("focusin",e,!0),i.removeEventListener("focusout",e,!0)};function e(e){if(i&&ce(e)){("focusin"===e.type?le:ie)(i)}}}),[i,c,null==l?void 0:l.modal]),u.createElement(ae.Provider,{value:u.useMemo((()=>({preserveTabOrder:c,beforeOutsideRef:s,afterOutsideRef:f,beforeInsideRef:d,afterInsideRef:v,portalNode:i,setFocusManagerState:a})),[c,i])},m&&i&&u.createElement(j,{ref:s,onFocus:e=>{if(ce(e,i)){var t;null==(t=d.current)||t.focus()}else{const e=ue()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus()}}}),m&&i&&u.createElement("span",{"aria-owns":i.id,style:D}),o?r.createPortal(t,o):i?r.createPortal(t,i):null,m&&i&&u.createElement(j,{ref:f,onFocus:e=>{if(ce(e,i)){var t;null==(t=v.current)||t.focus()}else{const e=oe()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus(),null==l||l.onOpenChange(!1)}}}))},e.FloatingTree=e=>{let{children:t}=e;const n=u.useRef([]),r=u.useCallback((e=>{n.current=[...n.current,e]}),[]),o=u.useCallback((e=>{n.current=n.current.filter((t=>t!==e))}),[]),c=u.useState((()=>i()))[0];return u.createElement(m.Provider,{value:u.useMemo((()=>({nodesRef:n,addNode:r,removeNode:o,events:c})),[n,r,o,c])},t)},e.inner=e=>({name:"inner",options:e,async fn(n){var o;const{listRef:u,overflowRef:c,onFallbackChange:i,offset:l=0,index:a=0,minItemsVisible:s=4,referenceOverflowThreshold:f=0,scrollRef:d,...v}=e,{rects:m,elements:{floating:p}}=n,g=u.current[a];if(!g)return{};const h={...n,...await t.offset(-g.offsetTop-m.reference.height/2-g.offsetHeight/2-l).fn(n)},y=null!=(o=null==d?void 0:d.current)?o:p,b=await t.detectOverflow(Ce(h,y.scrollHeight),v),w=await t.detectOverflow(h,{...v,elementContext:"reference"}),E=Math.max(0,b.top),R=h.y+E,x=Math.max(0,y.scrollHeight-E-Math.max(0,b.bottom));return y.style.maxHeight=x+"px",y.scrollTop=E,i&&(y.offsetHeight<g.offsetHeight*Math.min(s,u.current.length-1)-1||w.top>=-f||w.bottom>=-f?r.flushSync((()=>i(!0))):r.flushSync((()=>i(!1)))),c&&(c.current=await t.detectOverflow(Ce({...h,y:R},y.offsetHeight),v)),{y:R}}}),e.safePolygon=function(e){let t,{restMs:n=0,buffer:r=.5,blockPointerEvents:o=!0,debug:u=null}=void 0===e?{}:e,c=!1;const i=e=>{let{x:o,y:u,placement:i,refs:l,onClose:a,nodeId:s,tree:f,leave:d=!1}=e;return function(e){function v(){clearTimeout(t),a()}clearTimeout(t);const{clientX:m,clientY:p}=e,g=L(e);if("mousemove"===e.type&&M(l.domReference.current,g))return;if("mouseleave"===e.type&&E(e.relatedTarget)&&M(l.floating.current,e.relatedTarget))return;if(f&&A(f.nodesRef.current,s).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if(M(l.floating.current,g)&&!d)return void(c=!0);if(!l.domReference.current||!l.floating.current||null==i||null==o||null==u)return;const h=l.domReference.current.getBoundingClientRect(),y=l.floating.current.getBoundingClientRect(),b=i.split("-")[0],w=o>y.right-y.width/2,R=u>y.bottom-y.height/2;if("top"===b&&u>=h.bottom-1||"bottom"===b&&u<=h.top+1||"left"===b&&o>=h.right-1||"right"===b&&o<=h.left+1)return v();switch(b){case"top":if(m>=y.left&&m<=y.right&&p>=y.top&&p<=h.top+1)return;break;case"bottom":if(m>=y.left&&m<=y.right&&p>=h.bottom-1&&p<=y.bottom)return;break;case"left":if(m>=y.left&&m<=h.left+1&&p>=y.top&&p<=y.bottom)return;break;case"right":if(m>=h.right-1&&m<=y.right&&p>=y.top&&p<=y.bottom)return}if(c)return v();const x=function(e){let[t,n]=e;const o=y.width>h.width,u=y.height>h.height;switch(b){case"top":return[[o?t+r/2:w?t+4*r:t-4*r,n+r+1],[o?t-r/2:w?t+4*r:t-4*r,n+r+1],...[[y.left,w||o?y.bottom-r:y.top],[y.right,w?o?y.bottom-r:y.top:y.bottom-r]]];case"bottom":return[[o?t+r/2:w?t+4*r:t-4*r,n-r],[o?t-r/2:w?t+4*r:t-4*r,n-r],...[[y.left,w||o?y.top+r:y.bottom],[y.right,w?o?y.top+r:y.bottom:y.top+r]]];case"left":{const e=[t+r+1,u?n+r/2:R?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:R?n+4*r:n-4*r];return[...[[R||u?y.right-r:y.left,y.top],[R?u?y.right-r:y.left:y.right-r,y.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:R?n+4*r:n-4*r],[t-r,u?n-r/2:R?n+4*r:n-4*r],...[[R||u?y.left+r:y.right,y.top],[R?u?y.left+r:y.right:y.left+r,y.bottom]]]}}([o,u]);!function(e,t){const[n,r]=e;let o=!1;const u=t.length;for(let e=0,c=u-1;e<u;c=e++){const[u,i]=t[e]||[0,0],[l,a]=t[c]||[0,0];i>=r!=a>=r&&n<=(l-u)*(r-i)/(a-i)+u&&(o=!o)}return o}([m,p],x)?v():n&&(t=setTimeout(a,n))}};return i.__options={blockPointerEvents:o},i},e.useClick=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c}=e,{enabled:i=!0,event:l="click",toggle:a=!0,ignoreMouse:s=!1,keyboardHandlers:f=!0}=void 0===t?{}:t;const d=u.useRef();return u.useMemo((()=>i?{reference:{onPointerDown(e){d.current=e.pointerType},onMouseDown(e){0===e.button&&("mouse"===d.current&&s||"click"!==l&&(n?!a||o.current.openEvent&&"mousedown"!==o.current.openEvent.type||r(!1):(e.preventDefault(),r(!0)),o.current.openEvent=e.nativeEvent))},onClick(e){"mousedown"===l&&d.current?d.current=void 0:"mouse"===d.current&&s||(n?!a||o.current.openEvent&&"click"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent)},onKeyDown(e){d.current=void 0,f&&(Oe(e)||(" "!==e.key||Me(c.domReference.current)||e.preventDefault(),"Enter"===e.key&&(n?a&&r(!1):r(!0))))},onKeyUp(e){f&&(Oe(e)||Me(c.domReference.current)||" "===e.key&&(n?a&&r(!1):r(!0)))}}}:{}),[i,o,l,s,f,c,a,n,r])},e.useDelayGroup=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:o}=t;const{currentId:c,initialDelay:i,setState:l}=Se();u.useEffect((()=>{c&&(l((e=>({...e,delay:{open:1,close:ke(i,"close")}}))),c!==o&&r(!1))}),[o,r,l,c,i]),u.useEffect((()=>{n||c!==o||(r(!1),l((e=>({...e,delay:i,currentId:null}))))}),[n,l,c,o,r,i])},e.useDelayGroupContext=Se,e.useDismiss=function(e,n){let{open:r,onOpenChange:o,refs:c,events:i,nodeId:l}=e,{enabled:a=!0,escapeKey:s=!0,outsidePress:f=!0,outsidePressEvent:d="pointerdown",referencePress:v=!1,referencePressEvent:m="pointerdown",ancestorScroll:y=!1,bubbles:b=!0}=void 0===n?{}:n;const w=g(),R=null!=p(),k=Ee(f),T=u.useRef(!1);return u.useEffect((()=>{if(!r||!a)return;const e=k.current;function n(e){if("Escape"===e.key){if(!b&&w&&A(w.nodesRef.current,l).length>0)return;i.emit("dismiss",{type:"escapeKey",data:{returnFocus:{preventScroll:!1}}}),o(!1)}}function u(t){const n=T.current;if(T.current=!1,n)return;if("function"==typeof e&&!e(t))return;const r=L(t);if(E(r)&&c.floating.current){var u;const e=null!=(u=c.floating.current.ownerDocument.defaultView)?u:window,n=r.scrollWidth>r.clientWidth,o=r.scrollHeight>r.clientHeight;let i=o&&t.offsetX>r.clientWidth;if(o){"rtl"===e.getComputedStyle(r).direction&&(i=t.offsetX<=r.offsetWidth-r.clientWidth)}if(i||n&&t.offsetY>r.clientHeight)return}const a=w&&A(w.nodesRef.current,l).some((e=>{var n;return Ae(t,null==(n=e.context)?void 0:n.refs.floating.current)}));Ae(t,c.floating.current)||Ae(t,c.domReference.current)||a||!b&&w&&A(w.nodesRef.current,l).length>0||(i.emit("dismiss",{type:"outsidePress",data:{returnFocus:R?{preventScroll:!0}:x(t)||I(t)}}),o(!1))}function f(){o(!1)}const v=h(c.floating.current);s&&v.addEventListener("keydown",n),e&&v.addEventListener(d,u);let m=[];return y&&(E(c.domReference.current)&&(m=t.getOverflowAncestors(c.domReference.current)),E(c.floating.current)&&(m=m.concat(t.getOverflowAncestors(c.floating.current))),!E(c.reference.current)&&c.reference.current&&c.reference.current.contextElement&&(m=m.concat(t.getOverflowAncestors(c.reference.current.contextElement)))),m=m.filter((e=>{var t;return e!==(null==(t=v.defaultView)?void 0:t.visualViewport)})),m.forEach((e=>{e.addEventListener("scroll",f,{passive:!0})})),()=>{s&&v.removeEventListener("keydown",n),e&&v.removeEventListener(d,u),m.forEach((e=>{e.removeEventListener("scroll",f)}))}}),[s,k,d,i,w,l,r,o,y,a,b,c,R]),u.useEffect((()=>{T.current=!1}),[f,d]),u.useMemo((()=>a?{reference:{[Le[m]]:()=>{v&&(i.emit("dismiss",{type:"referencePress",data:{returnFocus:!1}}),o(!1))}},floating:{[Pe[d]]:()=>{T.current=!0}}}:{}),[a,i,v,d,m,o])},e.useFloating=function(e){let{open:n=!1,onOpenChange:r,whileElementsMounted:o,placement:l,middleware:a,strategy:s,nodeId:f}=void 0===e?{}:e;const[d,v]=u.useState(null),m=g(),p=u.useRef(null),h=u.useRef({}),y=u.useState((()=>i()))[0],b=t.useFloating({placement:l,middleware:a,strategy:s,whileElementsMounted:o}),w=C(r),R=u.useMemo((()=>({...b.refs,domReference:p})),[b.refs]),x=u.useMemo((()=>({...b,refs:R,dataRef:h,nodeId:f,events:y,open:n,onOpenChange:w,_:{domReference:d}})),[b,f,y,n,w,R,d]);c((()=>{const e=null==m?void 0:m.nodesRef.current.find((e=>e.id===f));e&&(e.context=x)}));const{reference:I}=b,k=u.useCallback((e=>{(E(e)||null===e)&&(x.refs.domReference.current=e,v(e)),I(e)}),[I,x.refs]);return u.useMemo((()=>({...b,context:x,refs:R,reference:k})),[b,R,x,k])},e.useFloatingNodeId=e=>{const t=d(),n=g(),r=p(),o=e||r;return c((()=>{const e={id:t,parentId:o};return null==n||n.addNode(e),()=>{null==n||n.removeNode(e)}}),[n,t,o]),t},e.useFloatingParentNodeId=p,e.useFloatingPortalNode=se,e.useFloatingTree=g,e.useFocus=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c,events:i}=e,{enabled:l=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const s=u.useRef(""),f=u.useRef(!1),d=u.useRef();return u.useEffect((()=>{var e;if(!l)return;const t=null!=(e=h(c.floating.current).defaultView)?e:window;function r(){!n&&R(c.domReference.current)&&c.domReference.current===te(h(c.domReference.current))&&(f.current=!0)}return t.addEventListener("blur",r),()=>{t.removeEventListener("blur",r)}}),[c,n,l]),u.useEffect((()=>{if(l)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(e){"referencePress"!==e.type&&"escapeKey"!==e.type||(f.current=!0)}}),[i,l]),u.useEffect((()=>()=>{clearTimeout(d.current)}),[]),u.useMemo((()=>l?{reference:{onPointerDown(e){let{pointerType:t}=e;s.current=t,f.current=!(!t||!a)},onPointerLeave(){f.current=!1},onFocus(e){var t;f.current||"focus"===e.type&&"mousedown"===(null==(t=o.current.openEvent)?void 0:t.type)&&o.current.openEvent&&Ae(o.current.openEvent,c.domReference.current)||(o.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){f.current=!1;const t=e.relatedTarget,n=E(t)&&t.hasAttribute("data-floating-ui-focus-guard");d.current=setTimeout((()=>{M(c.floating.current,t)||M(c.domReference.current,t)||n||r(!1)}))}}}:{}),[l,a,c,o,r])},e.useHover=function(e,t){let{enabled:n=!0,delay:r=0,handleClose:o=null,mouseOnly:i=!1,restMs:l=0,move:a=!0}=void 0===t?{}:t;const{open:s,onOpenChange:f,dataRef:d,events:v,refs:m,_:y}=e,b=g(),w=p(),R=Ee(o),x=Ee(r),I=u.useRef(),k=u.useRef(),T=u.useRef(),S=u.useRef(),C=u.useRef(!0),O=u.useRef(!1),M=u.useCallback((()=>{var e;const t=null==(e=d.current.openEvent)?void 0:e.type;return(null==t?void 0:t.includes("mouse"))&&"mousedown"!==t}),[d]);u.useEffect((()=>{if(n)return v.on("dismiss",e),()=>{v.off("dismiss",e)};function e(){clearTimeout(k.current),clearTimeout(S.current),C.current=!0}}),[n,v,m]),u.useEffect((()=>{if(!n||!R.current||!s)return;function e(){M()&&f(!1)}const t=h(m.floating.current).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[m,s,f,n,R,d,M]);const A=u.useCallback((function(e){void 0===e&&(e=!0);const t=ke(x.current,"close",I.current);t&&!T.current?(clearTimeout(k.current),k.current=setTimeout((()=>f(!1)),t)):e&&(clearTimeout(k.current),f(!1))}),[x,f]),L=u.useCallback((()=>{T.current&&(h(m.floating.current).removeEventListener("mousemove",T.current),T.current=void 0)}),[m]),P=u.useCallback((()=>{h(m.floating.current).body.style.pointerEvents="",O.current=!1}),[m]);return u.useEffect((()=>{if(!n)return;function t(){return!!d.current.openEvent&&["click","mousedown"].includes(d.current.openEvent.type)}function r(e){if(clearTimeout(k.current),C.current=!1,i&&"mouse"!==I.current||l>0&&0===ke(x.current,"open"))return;d.current.openEvent=e;const t=ke(x.current,"open",I.current);t?k.current=setTimeout((()=>{f(!0)}),t):f(!0)}function o(n){if(t())return;const r=h(m.floating.current);if(clearTimeout(S.current),R.current)return clearTimeout(k.current),T.current&&r.removeEventListener("mousemove",T.current),T.current=R.current({...e,tree:b,x:n.clientX,y:n.clientY,onClose(){P(),L(),A()}}),void r.addEventListener("mousemove",T.current);A()}function u(n){t()||null==R.current||R.current({...e,tree:b,x:n.clientX,y:n.clientY,leave:!0,onClose(){P(),L(),A()}})(n)}const c=m.floating.current,v=m.domReference.current;return E(v)?(s&&v.addEventListener("mouseleave",u),null==c||c.addEventListener("mouseleave",u),a&&v.addEventListener("mousemove",r,{once:!0}),v.addEventListener("mouseenter",r),v.addEventListener("mouseleave",o),()=>{s&&v.removeEventListener("mouseleave",u),null==c||c.removeEventListener("mouseleave",u),a&&v.removeEventListener("mousemove",r),v.removeEventListener("mouseenter",r),v.removeEventListener("mouseleave",o)}):void 0}),[y.domReference,n,e,i,l,a,A,L,P,f,s,b,m,x,R,d]),c((()=>{if(n&&s&&R.current&&R.current.__options.blockPointerEvents&&M()){h(m.floating.current).body.style.pointerEvents="none",O.current=!0;const n=m.domReference.current,r=m.floating.current;if(E(n)&&r){var e,t;const o=null==b||null==(e=b.nodesRef.current.find((e=>e.id===w)))||null==(t=e.context)?void 0:t.refs.floating.current;return o&&(o.style.pointerEvents=""),n.style.pointerEvents="auto",r.style.pointerEvents="auto",()=>{n.style.pointerEvents="",r.style.pointerEvents=""}}}}),[n,s,w,m,b,R,d,M]),c((()=>{s||(I.current=void 0,L(),O.current&&P())}),[s,L,P]),u.useEffect((()=>()=>{L(),clearTimeout(k.current),clearTimeout(S.current),O.current&&P()}),[n,L,P]),u.useMemo((()=>{if(!n)return{};function e(e){I.current=e.pointerType}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove(){s||0===l||(clearTimeout(S.current),S.current=setTimeout((()=>{C.current||f(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(k.current)},onMouseLeave(){A(!1)}}}}),[n,l,s,f,A])},e.useId=d,e.useInnerOffset=(e,t)=>{let{open:n,refs:o}=e,{enabled:c=!0,overflowRef:i,scrollRef:l,onChange:a}=t;const s=C(a),f=u.useRef(!1),d=u.useRef(null),v=u.useRef(null);return u.useEffect((()=>{var e;if(!c)return;function t(e){if(e.ctrlKey||!u||null==i.current)return;const t=e.deltaY,n=i.current.top>=-.5,o=i.current.bottom>=-.5,c=u.scrollHeight-u.clientHeight,l=t<0?-1:1,a=t<0?"max":"min";u.scrollHeight<=u.clientHeight||(!n&&t>0||!o&&t<0?(e.preventDefault(),r.flushSync((()=>{s((e=>e+Math[a](t,c*l)))}))):/firefox/i.test(b())&&(u.scrollTop+=t))}const u=null!=(e=null==l?void 0:l.current)?e:o.floating.current;return n&&u?(u.addEventListener("wheel",t),requestAnimationFrame((()=>{d.current=u.scrollTop,null!=i.current&&(v.current={...i.current})})),()=>{d.current=null,v.current=null,u.removeEventListener("wheel",t)}):void 0}),[c,n,o,i,l,s]),u.useMemo((()=>c?{floating:{onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const e=(null==l?void 0:l.current)||o.floating.current;if(i.current&&e&&f.current){if(null!==d.current){const t=e.scrollTop-d.current;(i.current.bottom<-.5&&t<-1||i.current.top<-.5&&t>1)&&r.flushSync((()=>s((e=>e+t))))}requestAnimationFrame((()=>{d.current=e.scrollTop}))}}}}:{}),[c,i,o,l,s])},e.useInteractions=function(e){void 0===e&&(e=[]);const t=e,n=u.useCallback((t=>O(t,e,"reference")),t),r=u.useCallback((t=>O(t,e,"floating")),t),o=u.useCallback((t=>O(t,e,"item")),t);return u.useMemo((()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:o})),[n,r,o])},e.useListNavigation=function(e,t){let{open:n,onOpenChange:o,refs:i}=e,{listRef:l,activeIndex:a,onNavigate:s=(()=>{}),enabled:f=!0,selectedIndex:d=null,allowEscape:v=!1,loop:m=!1,nested:y=!1,rtl:b=!1,virtual:w=!1,focusItemOnOpen:E="auto",focusItemOnHover:S=!0,openOnArrowKeyDown:O=!0,disabledIndices:A,orientation:L="vertical",cols:P=1}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const D=p(),F=g(),N=C(s),H=u.useRef(E),j=u.useRef(null!=d?d:-1),K=u.useRef(null),W=u.useRef(!1),B=u.useRef(N),_=u.useRef(n),q=u.useRef(!1),U=Ee(A),V=Ee(n),[X,Y]=u.useState(),z=u.useCallback(((e,t)=>{if(w){var n;Y(null==(n=e.current[t.current])?void 0:n.id)}else{xe(e.current[t.current],{preventScroll:!0,sync:!(!T()||!k())&&(De||q.current)})}}),[w]);return c((()=>{document.createElement("div").focus({get preventScroll(){return De=!0,!1}})}),[]),c((()=>{f&&(n?H.current&&null!=d&&N(d):_.current&&(j.current=-1,B.current(null)))}),[f,n,d,N]),c((()=>{if(f&&n)if(null==a){if(q.current=!1,null!=d)return;_.current&&(j.current=-1,z(l,j)),!_.current&&H.current&&(null!=K.current||!0===H.current&&null==K.current)&&(j.current=null==K.current||Ue(K.current,L,b)||y?Ve(l,U.current):Xe(l,U.current),N(j.current))}else We(l,a)||(j.current=a,z(l,j))}),[f,n,a,d,y,l,L,b,N,z,U]),c((()=>{if(f&&_.current&&!n){var e,t;const n=null==F||null==(e=F.nodesRef.current.find((e=>e.id===D)))||null==(t=e.context)?void 0:t.refs.floating.current;n&&!M(n,te(h(n)))&&n.focus({preventScroll:!0})}}),[f,n,F,D]),c((()=>{K.current=null,B.current=N,_.current=n})),u.useMemo((()=>{if(!f)return{};const e=U.current;function t(t){if(W.current=!0,q.current=!0,!V.current&&t.currentTarget===i.floating.current)return;if(y&&function(e,t,n){return _e(t,n?e===je:e===He,e===Fe)}(t.key,L,b))return we(t),o(!1),void(R(i.domReference.current)&&i.domReference.current.focus());const r=j.current,u=Ve(l,e),c=Xe(l,e);if("Home"===t.key&&(j.current=u,N(j.current)),"End"===t.key&&(j.current=c,N(j.current)),P>1){const n=j.current;if(t.key===Fe){if(we(t),-1===n)j.current=c;else if(j.current=Be(l,{startingIndex:n,amount:P,decrement:!0,disabledIndices:e}),m&&(n-P<u||j.current<0)){const e=n%P,t=c%P,r=c-(t-e);j.current=t===e?c:t>e?r:r-P}We(l,j.current)&&(j.current=n),N(j.current)}if(t.key===Ne&&(we(t),-1===n?j.current=u:(j.current=Be(l,{startingIndex:n,amount:P,disabledIndices:e}),m&&n+P>c&&(j.current=Be(l,{startingIndex:n%P-P,amount:P,disabledIndices:e}))),We(l,j.current)&&(j.current=n),N(j.current)),"both"===L){const r=Math.floor(n/P);t.key===je&&(we(t),n%P!=P-1?(j.current=Be(l,{startingIndex:n,disabledIndices:e}),m&&Ke(j.current,P,r)&&(j.current=Be(l,{startingIndex:n-n%P-1,disabledIndices:e}))):m&&(j.current=Be(l,{startingIndex:n-n%P-1,disabledIndices:e})),Ke(j.current,P,r)&&(j.current=n)),t.key===He&&(we(t),n%P!=0?(j.current=Be(l,{startingIndex:n,disabledIndices:e,decrement:!0}),m&&Ke(j.current,P,r)&&(j.current=Be(l,{startingIndex:n+(P-n%P),decrement:!0,disabledIndices:e}))):m&&(j.current=Be(l,{startingIndex:n+(P-n%P),decrement:!0,disabledIndices:e})),Ke(j.current,P,r)&&(j.current=n));const o=Math.floor(c/P)===r;return We(l,j.current)&&(j.current=m&&o?t.key===He?c:Be(l,{startingIndex:n-n%P-1,disabledIndices:e}):n),void N(j.current)}}if(qe(t.key,L)){if(we(t),n&&!w&&te(t.currentTarget.ownerDocument)===t.currentTarget)return j.current=Ue(t.key,L,b)?u:c,void N(j.current);Ue(t.key,L,b)?j.current=m?r>=c?v&&r!==l.current.length?-1:u:Be(l,{startingIndex:r,disabledIndices:e}):Math.min(c,Be(l,{startingIndex:r,disabledIndices:e})):j.current=m?r<=u?v&&-1!==r?l.current.length:c:Be(l,{startingIndex:r,decrement:!0,disabledIndices:e}):Math.max(u,Be(l,{startingIndex:r,decrement:!0,disabledIndices:e})),We(l,j.current)?N(null):N(j.current)}}function u(e){"auto"===E&&x(e.nativeEvent)&&(H.current=!0)}return{reference:{...w&&n&&null!=a&&{"aria-activedescendant":X},onKeyDown(r){W.current=!0;const u=0===r.key.indexOf("Arrow");if(w&&n)return t(r);if(!n&&!O&&u)return;(u||"Enter"===r.key||" "===r.key||""===r.key)&&(K.current=r.key),y?function(e,t,n){return _e(t,n?e===He:e===je,e===Ne)}(r.key,L,b)&&(we(r),n?(j.current=Ve(l,e),N(j.current)):o(!0)):qe(r.key,L)&&(null!=d&&(j.current=d),we(r),!n&&O?o(!0):t(r),n&&N(j.current))},onFocus(){n&&N(null)},onPointerDown:function(e){H.current=E,"auto"===E&&I(e.nativeEvent)&&(H.current=!0)},onMouseDown:u,onClick:u},floating:{"aria-orientation":"both"===L?void 0:L,...w&&null!=a&&{"aria-activedescendant":X},onKeyDown:t,onPointerMove(){W.current=!1}},item:{onFocus(e){let{currentTarget:t}=e;const n=l.current.indexOf(t);-1!==n&&a!==n&&N(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...S&&{onMouseMove(e){let{currentTarget:t}=e;const n=t;if(n){const e=l.current.indexOf(n);-1!==e&&a!==e&&N(e)}},onPointerLeave(){var e;W.current||(j.current=-1,z(l,j),r.flushSync((()=>N(null))),w||null==(e=i.floating.current)||e.focus({preventScroll:!0}))}}}}}),[X,U,V,l,f,L,b,w,n,a,y,d,O,S,v,P,m,i,E,z,N,o])},e.useRole=function(e,t){let{open:n}=e,{enabled:r=!0,role:o="dialog"}=void 0===t?{}:t;const c=d(),i=d();return u.useMemo((()=>{const e={id:c,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":n?c:void 0},floating:e}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":"alertdialog"===o?"dialog":o,"aria-controls":n?c:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:i}},floating:{...e,..."menu"===o&&{"aria-labelledby":i}}}:{}}),[r,o,n,c,i])},e.useTypeahead=function(e,t){var n;let{open:r,dataRef:o}=e,{listRef:i,activeIndex:l,onMatch:a=(()=>{}),enabled:s=!0,findMatch:f=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const p=u.useRef(),g=u.useRef(""),y=u.useRef(null!=(n=null!=m?m:l)?n:-1),b=u.useRef(null),w=C(a),R=Ee(f),x=Ee(v);return c((()=>{r&&(clearTimeout(p.current),b.current=null,g.current="")}),[r]),c((()=>{var e;r&&""===g.current&&(y.current=null!=(e=null!=m?m:l)?e:-1)}),[r,m,l]),u.useMemo((()=>{if(!s)return{};function e(e){const t=L(e.nativeEvent);if(E(t)&&te(h(t))!==e.currentTarget&&t.closest('[role="dialog"],[role="menu"],[role="listbox"],[role="tree"],[role="grid"]')!==e.currentTarget)return;g.current.length>0&&" "!==g.current[0]&&(o.current.typing=!0," "===e.key&&we(e));const n=i.current;if(null==n||x.current.includes(e.key)||1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey)return;n.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&g.current===e.key&&(g.current="",y.current=b.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",y.current=b.current,o.current.typing=!1}),d);const r=y.current,u=[...n.slice((null!=r?r:0)+1),...n.slice(0,(null!=r?r:0)+1)],c=R.current?R.current(u,g.current):u.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current.toLocaleLowerCase())))),l=c?n.indexOf(c):-1;-1!==l&&(w(l),b.current=l)}return{reference:{onKeyDown:e},floating:{onKeyDown:e}}}),[s,o,i,d,x,R,w])},Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@floating-ui/react-dom-interactions",
"version": "0.13.1",
"version": "0.13.2",
"@rollingversions": {

@@ -5,0 +5,0 @@ "baseVersion": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc