@floating-ui/react
Advanced tools
Comparing version 0.22.3 to 0.23.0
@@ -1,1 +0,1 @@ | ||
import{platform as e,getOverflowAncestors as t,offset as n,detectOverflow as r,useFloating as o}from"@floating-ui/react-dom";export{arrow,autoPlacement,autoUpdate,computePosition,detectOverflow,flip,getOverflowAncestors,hide,inline,limitShift,offset,platform,shift,size}from"@floating-ui/react-dom";import*as u from"react";import{useLayoutEffect as i,useEffect as c,useRef as l}from"react";import{hideOthers as s}from"aria-hidden";import{tabbable as a}from"tabbable";import{createPortal as f,flushSync as d}from"react-dom";function m(){return m=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},m.apply(this,arguments)}var v="undefined"!=typeof document?i:c;let p=!1,g=0;const h=()=>"floating-ui-"+g++;const b=u["useId".toString()]||function(){const[e,t]=u.useState((()=>p?h():void 0));return v((()=>{null==e&&t(h())}),[]),u.useEffect((()=>{p||(p=!0)}),[]),e},y=u.forwardRef((function(t,n){var r;let{context:{placement:o,elements:{floating:i},middlewareData:{arrow:c}},width:l=14,height:s=7,tipRadius:a=0,strokeWidth:f=0,staticOffset:d,stroke:v,d:p,...g}=t;f*=2;const h=f/2,y=l/2*(a/-8+1),E=s/2*a/4,[w,R]=o.split("-"),x=!!i&&e.isRTL(i),k=!!p,I="top"===w||"bottom"===w,M=d&&"end"===R?"bottom":"top";let T=d&&"end"===R?"right":"left";d&&x&&(T="end"===R?"left":"right");const C=k?0:h,L=null!=(null==c?void 0:c.x)?d||c.x:"",A=null!=(null==c?void 0:c.y)?d||c.y+C:"",P=p||"M0,0 H"+l+" L"+(l-y)+","+(s-E)+" Q"+l/2+","+s+" "+y+","+(s-E)+" Z",O={top:k?"rotate(180deg)":"",left:k?"rotate(90deg)":"rotate(-90deg)",bottom:k?"":"rotate(180deg)",right:k?"rotate(-90deg)":"rotate(90deg)"}[w],S=b();return u.createElement("svg",m({},g,{suppressHydrationWarning:!0,"aria-hidden":!0,ref:n,width:k?l:l+f,height:l,viewBox:"0 0 "+l+" "+(s>l?s:l),style:{...g.style,position:"absolute",pointerEvents:"none",[T]:L,[M]:A,[w]:I||k?"100%":"calc(100% - "+f/2+"px)",transform:O+(null!=(r=g.style)&&r.transform?" "+g.style.transform:"")}}),f>0&&u.createElement("path",{clipPath:"url(#"+S+")",fill:"none",stroke:v,strokeWidth:f+(p?0:1),d:P}),u.createElement("path",{stroke:f&&!p?g.fill:"none",d:P}),u.createElement("clipPath",{id:S},u.createElement("rect",{x:-h,y:h*(k?-1:1),width:l+f,height:l})))}));function E(){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){var r;e.set(t,(null==(r=e.get(t))?void 0:r.filter((e=>e!==n)))||[])}}}const w=u.createContext(null),R=u.createContext(null),x=()=>{var e;return(null==(e=u.useContext(w))?void 0:e.id)||null},k=()=>u.useContext(R),I=e=>{const t=b(),n=k(),r=x(),o=e||r;return v((()=>{const e={id:t,parentId:o};return null==n||n.addNode(e),()=>{null==n||n.removeNode(e)}}),[n,t,o]),t},M=e=>{let{children:t,id:n}=e;const r=x();return u.createElement(w.Provider,{value:u.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},T=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))}),[]),i=u.useState((()=>E()))[0];return u.createElement(R.Provider,{value:u.useMemo((()=>({nodesRef:n,addNode:r,removeNode:o,events:i})),[n,r,o,i])},t)};function C(e){return(null==e?void 0:e.ownerDocument)||document}function L(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}function A(){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 P(e){return C(e).defaultView||window}function O(e){return!!e&&e instanceof P(e).Element}function S(e){return!!e&&e instanceof P(e).HTMLElement}function D(e){if(0===e.mozInputSource&&e.isTrusted)return!0;const t=/Android/i;return(t.test(L())||t.test(A()))&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType}function F(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 H(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function B(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 P(r).ShadowRoot||r instanceof ShadowRoot))){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}var r;return!1}function N(e){const t=l(e);return v((()=>{t.current=e})),t}function j(e,t,n){return n&&!H(n)?0:"number"==typeof e?e:null==e?void 0:e[t]}const W=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,events:i,elements:{domReference:c,floating:l},refs:s}=e,{enabled:a=!0,delay:f=0,handleClose:d=null,mouseOnly:m=!1,restMs:p=0,move:g=!0}=t,h=k(),b=x(),y=N(d),E=N(f),w=u.useRef(),R=u.useRef(),I=u.useRef(),M=u.useRef(),T=u.useRef(!0),L=u.useRef(!1),A=u.useRef((()=>{})),P=u.useCallback((()=>{var e;const t=null==(e=o.current.openEvent)?void 0:e.type;return(null==t?void 0:t.includes("mouse"))&&"mousedown"!==t}),[o]);u.useEffect((()=>{if(a)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){clearTimeout(R.current),clearTimeout(M.current),T.current=!0}}),[a,i]),u.useEffect((()=>{if(!a||!y.current||!n)return;function e(){P()&&r(!1)}const t=C(l).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[l,n,r,a,y,o,P]);const S=u.useCallback((function(e){void 0===e&&(e=!0);const t=j(E.current,"close",w.current);t&&!I.current?(clearTimeout(R.current),R.current=setTimeout((()=>r(!1)),t)):e&&(clearTimeout(R.current),r(!1))}),[E,r]),D=u.useCallback((()=>{A.current(),I.current=void 0}),[]),F=u.useCallback((()=>{if(L.current){const e=C(s.floating.current).body;e.style.pointerEvents="",e.removeAttribute("data-floating-ui-safe-polygon"),L.current=!1}}),[s]);return u.useEffect((()=>{if(a&&O(c)){const e=c;return n&&e.addEventListener("mouseleave",s),null==l||l.addEventListener("mouseleave",s),g&&e.addEventListener("mousemove",u,{once:!0}),e.addEventListener("mouseenter",u),e.addEventListener("mouseleave",i),()=>{n&&e.removeEventListener("mouseleave",s),null==l||l.removeEventListener("mouseleave",s),g&&e.removeEventListener("mousemove",u),e.removeEventListener("mouseenter",u),e.removeEventListener("mouseleave",i)}}function t(){return!!o.current.openEvent&&["click","mousedown"].includes(o.current.openEvent.type)}function u(e){if(clearTimeout(R.current),T.current=!1,m&&!H(w.current)||p>0&&0===j(E.current,"open"))return;o.current.openEvent=e;const t=j(E.current,"open",w.current);t?R.current=setTimeout((()=>{r(!0)}),t):r(!0)}function i(r){if(t())return;A.current();const o=C(l);if(clearTimeout(M.current),y.current){n||clearTimeout(R.current),I.current=y.current({...e,tree:h,x:r.clientX,y:r.clientY,onClose(){F(),D(),S()}});const t=I.current;return o.addEventListener("mousemove",t),void(A.current=()=>{o.removeEventListener("mousemove",t)})}("touch"!==w.current||!B(l,r.relatedTarget))&&S()}function s(n){t()||null==y.current||y.current({...e,tree:h,x:n.clientX,y:n.clientY,onClose(){F(),D(),S()}})(n)}}),[c,l,a,e,m,p,g,S,D,F,r,n,h,E,y,o]),v((()=>{var e;if(a&&n&&null!=(e=y.current)&&e.__options.blockPointerEvents&&P()){const e=C(l).body;if(e.setAttribute("data-floating-ui-safe-polygon",""),e.style.pointerEvents="none",L.current=!0,O(c)&&l){var t,r;const e=c,n=null==h||null==(t=h.nodesRef.current.find((e=>e.id===b)))||null==(r=t.context)?void 0:r.elements.floating;return n&&(n.style.pointerEvents=""),e.style.pointerEvents="auto",l.style.pointerEvents="auto",()=>{e.style.pointerEvents="",l.style.pointerEvents=""}}}}),[a,n,b,l,c,h,y,o,P]),v((()=>{n||(w.current=void 0,D(),F())}),[n,D,F]),u.useEffect((()=>()=>{D(),clearTimeout(R.current),clearTimeout(M.current),F()}),[a,D,F]),u.useMemo((()=>{if(!a)return{};function e(e){w.current=e.pointerType}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove(){n||0===p||(clearTimeout(M.current),M.current=setTimeout((()=>{T.current||r(!0)}),p))}},floating:{onMouseEnter(){clearTimeout(R.current)},onMouseLeave(){i.emit("dismiss",{type:"mouseLeave",data:{returnFocus:!1}}),S(!1)}}}}),[i,a,p,n,r,S])},_=u.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:()=>{},setState:()=>{},isInstantPhase:!1}),q=()=>u.useContext(_),V=e=>{let{children:t,delay:n,timeoutMs:r=0}=e;const[o,i]=u.useReducer(((e,t)=>({...e,...t})),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),c=u.useRef(null),l=u.useCallback((e=>{i({currentId:e})}),[]);return v((()=>{o.currentId?null===c.current?c.current=o.currentId:i({isInstantPhase:!0}):(i({isInstantPhase:!1}),c.current=null)}),[o.currentId]),u.createElement(_.Provider,{value:u.useMemo((()=>({...o,setState:i,setCurrentId:l})),[o,i,l])},t)},X=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:o}=t;const{currentId:i,setCurrentId:c,initialDelay:l,setState:s,timeoutMs:a}=q();u.useEffect((()=>{i&&(s({delay:{open:1,close:j(l,"close")}}),i!==o&&r(!1))}),[o,r,s,i,l]),u.useEffect((()=>{function e(){r(!1),s({delay:l,currentId:null})}if(!n&&i===o){if(a){const t=window.setTimeout(e,a);return()=>{clearTimeout(t)}}e()}}),[n,s,i,o,r,l,a]),u.useEffect((()=>{n&&c(o)}),[n,c,o])};function Y(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}let z=0;function U(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(z);const u=()=>null==e?void 0:e.focus({preventScroll:n});o?u():z=requestAnimationFrame(u)}function Z(e,t){let n=e.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})),r=n;for(;r.length;)r=e.filter((e=>{var t;return null==(t=r)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})),n=n.concat(r);return n}function Q(e){return"composedPath"in e?e.composedPath()[0]:e.target}function G(e){return S(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function J(e){e.preventDefault(),e.stopPropagation()}const $=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function ee(e,t){const n=a(e,$());"prev"===t&&n.reverse();const r=n.indexOf(Y(C(e)));return n.slice(r+1)[0]}function te(){return ee(document.body,"next")}function ne(){return ee(document.body,"prev")}function re(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!B(n,r)}function oe(e){a(e,$()).forEach((e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")}))}function ue(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 ie={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};function ce(e){"Tab"===e.key&&(e.target,clearTimeout(undefined))}const le=u.forwardRef((function(e,t){const[n,r]=u.useState();return v((()=>(K()&&r("button"),document.addEventListener("keydown",ce),()=>{document.removeEventListener("keydown",ce)})),[]),u.createElement("span",m({},e,{ref:t,tabIndex:0,role:n,"aria-hidden":!n||void 0,"data-floating-ui-focus-guard":"",style:ie}))})),se=u.createContext(null),ae=function(e){let{id:t,root:n}=void 0===e?{}:e;const[r,o]=u.useState(null),i=b(),c=de();return v((()=>{const e=t?document.getElementById(t):null,r="data-floating-ui-portal";if(e){const t=document.createElement("div");return t.id=i,t.setAttribute(r,""),e.appendChild(t),o(t),()=>{t.remove()}}{let e=(null==c?void 0:c.portalNode)||n||document.body,u=null;t&&(u=document.createElement("div"),u.id=t,e.appendChild(u));const l=document.createElement("div");return l.id=i,l.setAttribute(r,""),o(l),e=u||e,e.appendChild(l),()=>{var e;l.remove(),null==(e=u)||e.remove()}}}),[t,n,c,i]),r},fe=e=>{let{children:t,id:n,root:r=null,preserveTabOrder:o=!0}=e;const i=ae({id:n,root:r}),[c,l]=u.useState(null),s=u.useRef(null),a=u.useRef(null),d=u.useRef(null),m=u.useRef(null),v=!!c&&!c.modal&&!(!r&&!i)&&o;return u.useEffect((()=>{if(i&&o&&(null==c||!c.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&&re(e)){("focusin"===e.type?ue:oe)(i)}}}),[i,o,null==c?void 0:c.modal]),u.createElement(se.Provider,{value:u.useMemo((()=>({preserveTabOrder:o,beforeOutsideRef:s,afterOutsideRef:a,beforeInsideRef:d,afterInsideRef:m,portalNode:i,setFocusManagerState:l})),[o,i])},v&&i&&u.createElement(le,{"data-type":"outside",ref:s,onFocus:e=>{if(re(e,i)){var t;null==(t=d.current)||t.focus()}else{const e=ne()||(null==c?void 0:c.refs.domReference.current);null==e||e.focus()}}}),v&&i&&u.createElement("span",{"aria-owns":i.id,style:ie}),i&&f(t,i),v&&i&&u.createElement(le,{"data-type":"outside",ref:a,onFocus:e=>{if(re(e,i)){var t;null==(t=m.current)||t.focus()}else{const e=te()||(null==c?void 0:c.refs.domReference.current);null==e||e.focus(),(null==c?void 0:c.closeOnFocusOut)&&(null==c||c.onOpenChange(!1))}}}))},de=()=>u.useContext(se),me=u.forwardRef((function(e,t){return u.createElement("button",m({},e,{type:"button",ref:t,tabIndex:-1,style:ie}))}));function ve(e){let{context:t,children:n,order:r=["content"],guards:o=!0,initialFocus:i=0,returnFocus:c=!0,modal:l=!0,visuallyHiddenDismiss:f=!1,closeOnFocusOut:d=!0}=e;const{open:m,refs:p,nodeId:g,onOpenChange:h,events:b,dataRef:y,elements:{domReference:E,floating:w}}=t,R=N(r),x=N(i),I=N(c),M=k(),T=de(),[L,A]=u.useState(null),P="number"==typeof i&&i<0,O=u.useRef(null),D=u.useRef(null),F=u.useRef(!1),K=u.useRef(null),H=u.useRef(!1),j=null!=T,W=E&&"combobox"===E.getAttribute("role")&&G(E),_=u.useCallback((function(e){return void 0===e&&(e=w),e?a(e,$()):[]}),[w]),q=u.useCallback((e=>{const t=_(e);return R.current.map((e=>E&&"reference"===e?E:w&&"floating"===e?w:t)).filter(Boolean).flat()}),[E,w,R,_]);u.useEffect((()=>{if(!l)return;function e(e){if("Tab"===e.key){0!==_().length||W||J(e);const t=q(),n=Q(e);"reference"===R.current[0]&&n===E&&(J(e),e.shiftKey?U(t[t.length-1]):U(t[1])),"floating"===R.current[1]&&n===w&&e.shiftKey&&(J(e),U(t[0]))}}const t=C(w);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[E,w,l,R,p,W,_,q]),u.useEffect((()=>{if(d)return w&&S(E)?(E.addEventListener("focusout",t),E.addEventListener("pointerdown",e),!l&&w.addEventListener("focusout",t),()=>{E.removeEventListener("focusout",t),E.removeEventListener("pointerdown",e),!l&&w.removeEventListener("focusout",t)}):void 0;function e(){H.current=!0,setTimeout((()=>{H.current=!1}))}function t(e){const t=e.relatedTarget;queueMicrotask((()=>{const e=!(B(E,t)||B(w,t)||B(t,w)||B(null==T?void 0:T.portalNode,t)||null!=t&&t.hasAttribute("data-floating-ui-focus-guard")||M&&(Z(M.nodesRef.current,g).find((e=>{var n,r;return B(null==(n=e.context)?void 0:n.elements.floating,t)||B(null==(r=e.context)?void 0:r.elements.domReference,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}(M.nodesRef.current,g).find((e=>{var n,r;return(null==(n=e.context)?void 0:n.elements.floating)===t||(null==(r=e.context)?void 0:r.elements.domReference)===t}))));t&&e&&!H.current&&t!==K.current&&(F.current=!0,h(!1))}))}}),[E,w,l,g,M,T,h,d]),u.useEffect((()=>{var e;const t=Array.from((null==T||null==(e=T.portalNode)?void 0:e.querySelectorAll("[data-floating-ui-portal]"))||[]);if(w&&l){const e=[w,...t,...[O.current,D.current].filter(Boolean)],n=s(R.current.includes("reference")||W?e.concat(E||[]):e);return()=>{n()}}}),[E,w,l,R,T,W]),u.useEffect((()=>{if(l&&!o&&w){const e=[],t=$(),n=a(C(w).body,t),r=q(),o=n.filter((e=>!r.includes(e)));return o.forEach(((t,n)=>{e[n]=t.getAttribute("tabindex"),t.setAttribute("tabindex","-1")})),()=>{o.forEach(((t,n)=>{const r=e[n];null==r?t.removeAttribute("tabindex"):t.setAttribute("tabindex",r)}))}}}),[w,l,o,q]),v((()=>{if(!w)return;let e=!1;const t=C(w),n=Y(t),r=y.current;function o(t){if("escapeKey"===t.type&&p.domReference.current&&(K.current=p.domReference.current),["referencePress","escapeKey"].includes(t.type))return;const n=t.data.returnFocus;"object"==typeof n?(F.current=!1,e=n.preventScroll):F.current=!n}return K.current=n,queueMicrotask((()=>{const e=q(w),t=x.current,r=("number"==typeof t?e[t]:t.current)||w,o=B(w,n);P||o||!m||U(r,{preventScroll:r===w})})),b.on("dismiss",o),()=>{b.off("dismiss",o);const n=Y(t);(B(w,n)||M&&Z(M.nodesRef.current,g).some((e=>{var t;return B(null==(t=e.context)?void 0:t.elements.floating,n)}))||r.openEvent&&["click","mousedown"].includes(r.openEvent.type))&&p.domReference.current&&(K.current=p.domReference.current),I.current&&S(K.current)&&!F.current&&U(K.current,{cancelPrevious:!1,preventScroll:e})}}),[m,w,q,I,x,y,p,b,P,M,g]),v((()=>{if(T)return T.setFocusManagerState({...t,modal:l,closeOnFocusOut:d}),()=>{T.setFocusManagerState(null)}}),[T,l,d,t]),v((()=>{if(!P&&w&&(e(),"function"==typeof MutationObserver)){const t=new MutationObserver(e);return t.observe(w,{childList:!0,subtree:!0}),()=>{t.disconnect()}}function e(){Y(C(w))!==p.domReference.current&&A(_().length)}}),[w,_,P,p]);const V=o&&(j||l)&&!W;function X(e){return f&&l?u.createElement(me,{ref:"start"===e?O:D,onClick:()=>h(!1)},"string"==typeof f?f:"Dismiss"):null}return u.createElement(u.Fragment,null,V&&u.createElement(le,{"data-type":"inside",ref:null==T?void 0:T.beforeInsideRef,onFocus:e=>{if(l){const e=q();U("reference"===r[0]?e[0]:e[e.length-1])}else if(null!=T&&T.preserveTabOrder&&T.portalNode)if(F.current=!1,re(e,T.portalNode)){const e=te()||E;null==e||e.focus()}else{var t;null==(t=T.beforeOutsideRef.current)||t.focus()}}}),W?null:X("start"),u.cloneElement(n,0===L||r.includes("floating")?{tabIndex:0}:{}),X("end"),V&&u.createElement(le,{"data-type":"inside",ref:null==T?void 0:T.afterInsideRef,onFocus:e=>{if(l)U(q()[0]);else if(null!=T&&T.preserveTabOrder&&T.portalNode)if(d&&(F.current=!0),re(e,T.portalNode)){const e=ne()||E;null==e||e.focus()}else{var t;null==(t=T.afterOutsideRef.current)||t.focus()}}}))}const pe="data-floating-ui-scroll-lock",ge=u.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return v((()=>{var e,t;if(!n)return;if(document.body.hasAttribute(pe))return;document.body.setAttribute(pe,"");const r=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(L()))return Object.assign(document.body.style,{overflow:"hidden",[r]:o+"px"}),()=>{document.body.removeAttribute(pe),Object.assign(document.body.style,{overflow:"",[r]:""})};const u=(null==(e=window.visualViewport)?void 0:e.offsetLeft)||0,i=(null==(t=window.visualViewport)?void 0:t.offsetTop)||0,c=window.pageXOffset,l=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(l-Math.floor(i))+"px",left:-(c-Math.floor(u))+"px",right:"0",[r]:o+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[r]:""}),document.body.removeAttribute(pe),window.scrollTo(c,l)}}),[n]),u.createElement("div",m({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));function he(e){return S(e.target)&&"BUTTON"===e.target.tagName}function be(e){return G(e)}const ye=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,elements:{domReference:i}}=e,{enabled:c=!0,event:l="click",toggle:s=!0,ignoreMouse:a=!1,keyboardHandlers:f=!0}=t,d=u.useRef();return u.useMemo((()=>c?{reference:{onPointerDown(e){d.current=e.pointerType},onMouseDown(e){0===e.button&&(H(d.current,!0)&&a||"click"!==l&&(n?!s||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:H(d.current,!0)&&a||(n?!s||o.current.openEvent&&"click"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent)},onKeyDown(e){d.current=void 0,f&&(he(e)||(" "!==e.key||be(i)||e.preventDefault(),"Enter"===e.key&&(n?s&&r(!1):r(!0))))},onKeyUp(e){f&&(he(e)||be(i)||" "===e.key&&(n?s&&r(!1):r(!0)))}}}:{}),[c,o,l,a,f,i,s,n,r])},Ee=u["useInsertionEffect".toString()]||(e=>e());function we(e){const t=u.useRef((()=>{}));return Ee((()=>{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 Re(e){return null!=e&&null!=e.clientX}const xe=function(e,t){let{open:n,refs:r,dataRef:o,elements:{floating:i}}=e,{enabled:c=!0,axis:l="both",x:s=null,y:a=null}=void 0===t?{}:t;const f=u.useRef(!1),d=u.useRef(null),[m,p]=u.useState(),[g,h]=u.useState([]),b=we(((e,t)=>{f.current||o.current.openEvent&&!Re(o.current.openEvent)||r.setPositionReference(function(e,t){let n=null,r=null,o=!1;return{contextElement:e.current||void 0,getBoundingClientRect(){var u,i;const c=(null==(u=e.current)?void 0:u.getBoundingClientRect())||{width:0,height:0,x:0,y:0},l="x"===t.axis||"both"===t.axis,s="y"===t.axis||"both"===t.axis,a=["mouseenter","mousemove"].includes((null==(i=t.dataRef.current.openEvent)?void 0:i.type)||"")&&"touch"!==t.pointerType;let f=c.width,d=c.height,m=c.x,v=c.y;return null==n&&t.x&&l&&(n=c.x-t.x),null==r&&t.y&&s&&(r=c.y-t.y),m-=n||0,v-=r||0,f=0,d=0,!o||a?(f="y"===t.axis?c.width:0,d="x"===t.axis?c.height:0,m=l&&null!=t.x?t.x:m,v=s&&null!=t.y?t.y:v):o&&!a&&(d="x"===t.axis?c.height:d,f="y"===t.axis?c.width:f),o=!0,{width:f,height:d,x:m,y:v,top:v,right:m+f,bottom:v+d,left:m}}}}(r.domReference,{x:e,y:t,axis:l,dataRef:o,pointerType:m}))})),y=we((e=>{null==s&&null==a&&(n?d.current||h([]):b(e.clientX,e.clientY))})),E=H(m)?i:n,w=u.useCallback((()=>{if(!E||!c||null!=s||null!=a)return;const e=P(r.floating.current);function t(n){const o=Q(n);B(r.floating.current,o)?(e.removeEventListener("mousemove",t),d.current=null):b(n.clientX,n.clientY)}if(!o.current.openEvent||Re(o.current.openEvent)){e.addEventListener("mousemove",t);const n=()=>{e.removeEventListener("mousemove",t),d.current=null};return d.current=n,n}r.setPositionReference(r.domReference.current)}),[o,c,E,r,b,s,a]);return u.useEffect((()=>w()),[w,g]),u.useEffect((()=>{c&&!i&&(f.current=!1)}),[c,i]),u.useEffect((()=>{!c&&n&&(f.current=!0)}),[c,n]),v((()=>{!c||null==s&&null==a||(f.current=!1,b(s,a))}),[c,s,a,b]),u.useMemo((()=>{if(!c)return{};function e(e){let{pointerType:t}=e;p(t)}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove:y,onMouseEnter:y}}}),[c,y])};function ke(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 Ie={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Me={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Te=function(e,n){void 0===n&&(n={});const{open:r,onOpenChange:o,events:i,nodeId:c,elements:{reference:l,domReference:s,floating:a},dataRef:f}=e,{enabled:d=!0,escapeKey:m=!0,outsidePress:v=!0,outsidePressEvent:p="pointerdown",referencePress:g=!1,referencePressEvent:h="pointerdown",ancestorScroll:b=!1,bubbles:y}=n,E=k(),w=null!=x(),R=we("function"==typeof v?v:()=>!1),I="function"==typeof v?R:v,M=u.useRef(!1),{escapeKeyBubbles:T,outsidePressBubbles:L}=(e=>{var t,n;return{escapeKeyBubbles:"boolean"==typeof e?e:null!=(t=null==e?void 0:e.escapeKey)&&t,outsidePressBubbles:"boolean"==typeof e?e:null==(n=null==e?void 0:e.outsidePress)||n}})(y),A=we((e=>{if(!r||!d||!m||"Escape"!==e.key)return;const t=E?Z(E.nodesRef.current,c):[];if(!T&&(e.stopPropagation(),t.length>0)){let e=!0;if(t.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__escapeKeyBubbles||(e=!1)})),!e)return}i.emit("dismiss",{type:"escapeKey",data:{returnFocus:{preventScroll:!1}}}),o(!1)})),K=we((e=>{const t=M.current;if(M.current=!1,t)return;if("function"==typeof I&&!I(e))return;const n=Q(e);if(S(n)&&a){const t=n.clientWidth>0&&n.scrollWidth>n.clientWidth,r=n.clientHeight>0&&n.scrollHeight>n.clientHeight;let o=r&&e.offsetX>n.clientWidth;if(r){"rtl"===P(a).getComputedStyle(n).direction&&(o=e.offsetX<=n.offsetWidth-n.clientWidth)}if(o||t&&e.offsetY>n.clientHeight)return}const r=E&&Z(E.nodesRef.current,c).some((t=>{var n;return ke(e,null==(n=t.context)?void 0:n.elements.floating)}));if(ke(e,a)||ke(e,s)||r)return;const u=E?Z(E.nodesRef.current,c):[];if(u.length>0){let e=!0;if(u.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__outsidePressBubbles||(e=!1)})),!e)return}i.emit("dismiss",{type:"outsidePress",data:{returnFocus:w?{preventScroll:!0}:D(e)||F(e)}}),o(!1)}));return u.useEffect((()=>{if(!r||!d)return;function e(){o(!1)}f.current.__escapeKeyBubbles=T,f.current.__outsidePressBubbles=L;const n=C(a);m&&n.addEventListener("keydown",A),I&&n.addEventListener(p,K);let u=[];return b&&(O(s)&&(u=t(s)),O(a)&&(u=u.concat(t(a))),!O(l)&&l&&l.contextElement&&(u=u.concat(t(l.contextElement)))),u=u.filter((e=>{var t;return e!==(null==(t=n.defaultView)?void 0:t.visualViewport)})),u.forEach((t=>{t.addEventListener("scroll",e,{passive:!0})})),()=>{m&&n.removeEventListener("keydown",A),I&&n.removeEventListener(p,K),u.forEach((t=>{t.removeEventListener("scroll",e)}))}}),[f,a,s,l,m,I,p,r,o,b,d,T,L,A,K]),u.useEffect((()=>{M.current=!1}),[I,p]),u.useMemo((()=>d?{reference:{onKeyDown:A,[Ie[h]]:()=>{g&&(i.emit("dismiss",{type:"referencePress",data:{returnFocus:!1}}),o(!1))}},floating:{onKeyDown:A,[Me[p]]:()=>{M.current=!0}}}:{}),[d,i,g,p,h,o,A])},Ce=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,events:i,refs:c,elements:{floating:l,domReference:s}}=e,{enabled:a=!0,keyboardOnly:f=!0}=t,d=u.useRef(""),m=u.useRef(!1),v=u.useRef();return u.useEffect((()=>{if(!a)return;const e=C(l).defaultView||window;function t(){!n&&S(s)&&s===Y(C(s))&&(m.current=!0)}return e.addEventListener("blur",t),()=>{e.removeEventListener("blur",t)}}),[l,s,n,a]),u.useEffect((()=>{if(a)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(e){"referencePress"!==e.type&&"escapeKey"!==e.type||(m.current=!0)}}),[i,a]),u.useEffect((()=>()=>{clearTimeout(v.current)}),[]),u.useMemo((()=>a?{reference:{onPointerDown(e){let{pointerType:t}=e;d.current=t,m.current=!(!t||!f)},onMouseLeave(){m.current=!1},onFocus(e){var t;m.current||"focus"===e.type&&"mousedown"===(null==(t=o.current.openEvent)?void 0:t.type)&&o.current.openEvent&&ke(o.current.openEvent,s)||(o.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){m.current=!1;const t=e.relatedTarget,n=O(t)&&t.hasAttribute("data-floating-ui-focus-guard")&&"outside"===t.getAttribute("data-type");v.current=setTimeout((()=>{B(c.floating.current,t)||B(s,t)||n||r(!1)}))}}}:{}),[a,f,s,c,o,r])};let Le=!1;function Ae(e,t,n){return Math.floor(e/t)!==n}function Pe(e,t){return t<0||t>=e.current.length}function Oe(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o,amount:u=1}=void 0===t?{}:t;const i=e.current;let c=n;do{var l,s;c+=r?-u:u}while(c>=0&&c<=i.length-1&&(o?o.includes(c):null==i[c]||(null==(l=i[c])?void 0:l.hasAttribute("disabled"))||"true"===(null==(s=i[c])?void 0:s.getAttribute("aria-disabled"))));return c}function Se(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function De(e,t){return Se(t,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function Fe(e,t,n){return Se(t,"ArrowDown"===e,n?"ArrowLeft"===e:"ArrowRight"===e)||"Enter"===e||" "==e||""===e}function Ke(e,t){return Oe(e,{disabledIndices:t})}function He(e,t){return Oe(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}const Be=(e,t)=>{const{open:n,onOpenChange:r,refs:o,elements:{domReference:i,floating:c}}=e,{listRef:l,activeIndex:s,onNavigate:a=(()=>{}),enabled:f=!0,selectedIndex:d=null,allowEscape:m=!1,loop:p=!1,nested:g=!1,rtl:h=!1,virtual:b=!1,focusItemOnOpen:y="auto",focusItemOnHover:E=!0,openOnArrowKeyDown:w=!0,disabledIndices:R,orientation:I="vertical",cols:M=1,scrollItemIntoView:T=!0}=t,A=x(),P=k(),O=we(a),H=u.useRef(y),j=u.useRef(null!=d?d:-1),W=u.useRef(null),_=u.useRef(!0),q=u.useRef(O),V=u.useRef(!!c),X=u.useRef(!1),z=u.useRef(!1),Z=N(R),Q=N(n),G=N(T),[$,ee]=u.useState(),te=we((function(e,t,n){void 0===n&&(n=!1);const r=e.current[t.current];r&&(b?ee(null==r?void 0:r.id):U(r,{preventScroll:!0,sync:!(!L().toLowerCase().startsWith("mac")||navigator.maxTouchPoints||!K())&&(Le||X.current)}),requestAnimationFrame((()=>{const e=G.current;e&&r&&(n||!_.current)&&(null==r.scrollIntoView||r.scrollIntoView("boolean"==typeof e?{block:"nearest",inline:"nearest"}:e))})))}));v((()=>{document.createElement("div").focus({get preventScroll(){return Le=!0,!1}})}),[]),v((()=>{f&&(n&&c?H.current&&null!=d&&(z.current=!0,O(d)):V.current&&(j.current=-1,q.current(null)))}),[f,n,c,d,O]),v((()=>{if(f&&n&&c)if(null==s){if(X.current=!1,null!=d)return;if(V.current&&(j.current=-1,te(l,j)),!V.current&&H.current&&(null!=W.current||!0===H.current&&null==W.current)){let e=0;const t=()=>{if(null==l.current[0]){if(e<2){(e?requestAnimationFrame:queueMicrotask)(t)}e++}else j.current=null==W.current||Fe(W.current,I,h)||g?Ke(l,Z.current):He(l,Z.current),W.current=null,O(j.current)};t()}}else Pe(l,s)||(j.current=s,te(l,j,z.current),z.current=!1)}),[f,n,c,s,d,g,l,I,h,O,te,Z]),v((()=>{if(f&&V.current&&!c&&P){var e,t;const n=P.nodesRef.current,r=null==(e=n.find((e=>e.id===A)))||null==(t=e.context)?void 0:t.elements.floating,o=Y(C(c)),u=n.some((e=>e.context&&B(e.context.elements.floating,o)));r&&!u&&r.focus({preventScroll:!0})}}),[f,c,P,A]),v((()=>{q.current=O,V.current=!!c})),v((()=>{n||(W.current=null)}),[n]);const ne=null!=s,re=u.useMemo((()=>{function e(e){if(!n)return;const t=l.current.indexOf(e);-1!==t&&O(t)}return{onFocus(t){let{currentTarget:n}=t;e(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...E&&{onMouseMove(t){let{currentTarget:n}=t;e(n)},onPointerLeave(e){let{pointerType:t}=e;_.current&&"touch"!==t&&(j.current=-1,te(l,j),O(null),b||U(o.floating.current,{preventScroll:!0}))}}}}),[n,o,te,E,l,O,b]);return u.useMemo((()=>{if(!f)return{};const e=Z.current;function t(t){if(_.current=!1,X.current=!0,!Q.current&&t.currentTarget===o.floating.current)return;if(g&&function(e,t,n){return Se(t,n?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(t.key,I,h))return J(t),r(!1),void(S(i)&&i.focus());const u=j.current,c=Ke(l,e),s=He(l,e);if("Home"===t.key&&(J(t),j.current=c,O(j.current)),"End"===t.key&&(J(t),j.current=s,O(j.current)),M>1){const n=j.current;if("ArrowUp"===t.key){if(J(t),-1===n)j.current=s;else if(j.current=Oe(l,{startingIndex:n,amount:M,decrement:!0,disabledIndices:e}),p&&(n-M<c||j.current<0)){const e=n%M,t=s%M,r=s-(t-e);j.current=t===e?s:t>e?r:r-M}Pe(l,j.current)&&(j.current=n),O(j.current)}if("ArrowDown"===t.key&&(J(t),-1===n?j.current=c:(j.current=Oe(l,{startingIndex:n,amount:M,disabledIndices:e}),p&&n+M>s&&(j.current=Oe(l,{startingIndex:n%M-M,amount:M,disabledIndices:e}))),Pe(l,j.current)&&(j.current=n),O(j.current)),"both"===I){const r=Math.floor(n/M);"ArrowRight"===t.key&&(J(t),n%M!=M-1?(j.current=Oe(l,{startingIndex:n,disabledIndices:e}),p&&Ae(j.current,M,r)&&(j.current=Oe(l,{startingIndex:n-n%M-1,disabledIndices:e}))):p&&(j.current=Oe(l,{startingIndex:n-n%M-1,disabledIndices:e})),Ae(j.current,M,r)&&(j.current=n)),"ArrowLeft"===t.key&&(J(t),n%M!=0?(j.current=Oe(l,{startingIndex:n,disabledIndices:e,decrement:!0}),p&&Ae(j.current,M,r)&&(j.current=Oe(l,{startingIndex:n+(M-n%M),decrement:!0,disabledIndices:e}))):p&&(j.current=Oe(l,{startingIndex:n+(M-n%M),decrement:!0,disabledIndices:e})),Ae(j.current,M,r)&&(j.current=n));const o=Math.floor(s/M)===r;return Pe(l,j.current)&&(j.current=p&&o?"ArrowLeft"===t.key?s:Oe(l,{startingIndex:n-n%M-1,disabledIndices:e}):n),void O(j.current)}}if(De(t.key,I)){if(J(t),n&&!b&&Y(t.currentTarget.ownerDocument)===t.currentTarget)return j.current=Fe(t.key,I,h)?c:s,void O(j.current);Fe(t.key,I,h)?j.current=p?u>=s?m&&u!==l.current.length?-1:c:Oe(l,{startingIndex:u,disabledIndices:e}):Math.min(s,Oe(l,{startingIndex:u,disabledIndices:e})):j.current=p?u<=c?m&&-1!==u?l.current.length:s:Oe(l,{startingIndex:u,decrement:!0,disabledIndices:e}):Math.max(c,Oe(l,{startingIndex:u,decrement:!0,disabledIndices:e})),Pe(l,j.current)?O(null):O(j.current)}}function u(e){"auto"===y&&D(e.nativeEvent)&&(H.current=!0)}const c=b&&n&&ne&&{"aria-activedescendant":$};return{reference:{...c,onKeyDown(o){_.current=!1;const u=0===o.key.indexOf("Arrow");if(b&&n)return t(o);if(!n&&!w&&u)return;const i=u||"Enter"===o.key||""===o.key.trim(),c=De(o.key,I),s=function(e,t,n){return Se(t,n?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(o.key,I,h);i&&(W.current=g&&c?null:o.key),g?s&&(J(o),n?(j.current=Ke(l,e),O(j.current)):r(!0)):c&&(null!=d&&(j.current=d),J(o),!n&&w?r(!0):t(o),n&&O(j.current))},onFocus(){n&&O(null)},onPointerDown:function(e){H.current=y,"auto"===y&&F(e.nativeEvent)&&(H.current=!0)},onMouseDown:u,onClick:u},floating:{"aria-orientation":"both"===I?void 0:I,...c,onKeyDown:t,onPointerMove(){_.current=!0}},item:re}}),[i,o,$,Z,Q,l,f,I,h,b,n,ne,g,d,w,m,M,p,y,O,r,re])};function Ne(e){return u.useMemo((()=>e.every((e=>null==e))?null:t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}),e)}const je=function(e,t){void 0===t&&(t={});const{open:n,floatingId:r}=e,{enabled:o=!0,role:i="dialog"}=t,c=b();return u.useMemo((()=>{const e={id:r,role:i};return o?"tooltip"===i?{reference:{"aria-describedby":n?r:void 0},floating:e}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":"alertdialog"===i?"dialog":i,"aria-controls":n?r:void 0,..."listbox"===i&&{role:"combobox"},..."menu"===i&&{id:c}},floating:{...e,..."menu"===i&&{"aria-labelledby":c}}}:{}}),[o,i,n,r,c])},We=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,((e,t)=>(t?"-":"")+e.toLowerCase()));function _e(e,t){return"function"==typeof e?e(t):e}function qe(e,t){void 0===t&&(t={});const{open:n,elements:{floating:r}}=e,{duration:o=250}=t,i=("number"==typeof o?o:o.close)||0,[c,l]=u.useState(!1),[s,a]=u.useState("unmounted"),f=function(e,t){const[n,r]=u.useState(e);return e&&!n&&r(!0),u.useEffect((()=>{if(!e){const e=setTimeout((()=>r(!1)),t);return()=>clearTimeout(e)}}),[e,t]),n}(n,i);return v((()=>{c&&!f&&a("unmounted")}),[c,f]),v((()=>{if(r){if(n){a("initial");const e=requestAnimationFrame((()=>{a("open")}));return()=>{cancelAnimationFrame(e)}}l(!0),a("close")}}),[n,r]),{isMounted:f,status:s}}function Ve(e,t){void 0===t&&(t={});const{initial:n={opacity:0},open:r,close:o,common:i,duration:c=250}=t,l=e.placement,s=l.split("-")[0],a=u.useMemo((()=>({side:s,placement:l})),[s,l]),f="number"==typeof c,d=(f?c:c.open)||0,m=(f?c:c.close)||0,[p,g]=u.useState((()=>({..._e(i,a),..._e(n,a)}))),{isMounted:h,status:b}=qe(e,{duration:c}),y=N(n),E=N(r),w=N(o),R=N(i);return v((()=>{const e=_e(y.current,a),t=_e(w.current,a),n=_e(R.current,a),r=_e(E.current,a)||Object.keys(e).reduce(((e,t)=>(e[t]="",e)),{});if("initial"===b&&g((t=>({transitionProperty:t.transitionProperty,...n,...e}))),"open"===b&&g({transitionProperty:Object.keys(r).map(We).join(","),transitionDuration:d+"ms",...n,...r}),"close"===b){const r=t||e;g({transitionProperty:Object.keys(r).map(We).join(","),transitionDuration:m+"ms",...n,...r})}}),[m,w,y,E,R,d,b,a]),{isMounted:h,styles:p}}const Xe=(e,t)=>{var n;const{open:r,dataRef:o}=e,{listRef:i,activeIndex:c,onMatch:l,onTypingChange:s,enabled:a=!0,findMatch:f=null,resetMs:d=750,ignoreKeys:m=[],selectedIndex:p=null}=t,g=u.useRef(),h=u.useRef(""),b=u.useRef(null!=(n=null!=p?p:c)?n:-1),y=u.useRef(null),E=we(l),w=we(s),R=N(f),x=N(m);return v((()=>{r&&(clearTimeout(g.current),y.current=null,h.current="")}),[r]),v((()=>{var e;r&&""===h.current&&(b.current=null!=(e=null!=p?p:c)?e:-1)}),[r,p,c]),u.useMemo((()=>{if(!a)return{};function e(e){e?o.current.typing||(o.current.typing=e,w(e)):o.current.typing&&(o.current.typing=e,w(e))}function t(e,t,n){const r=R.current?R.current(t,n):t.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(n.toLocaleLowerCase()))));return r?e.indexOf(r):-1}function n(n){const o=i.current;if(h.current.length>0&&" "!==h.current[0]&&(-1===t(o,o,h.current)?e(!1):" "===n.key&&J(n)),null==o||x.current.includes(n.key)||1!==n.key.length||n.ctrlKey||n.metaKey||n.altKey)return;r&&" "!==n.key&&(J(n),e(!0));o.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&h.current===n.key&&(h.current="",b.current=y.current),h.current+=n.key,clearTimeout(g.current),g.current=setTimeout((()=>{h.current="",b.current=y.current,e(!1)}),d);const u=b.current,c=t(o,[...o.slice((u||0)+1),...o.slice(0,(u||0)+1)],h.current);-1!==c?(E(c),y.current=c):(h.current="",e(!1))}return{reference:{onKeyDown:n},floating:{onKeyDown:n}}}),[a,r,o,i,d,x,R,E,w])};function Ye(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const ze=e=>({name:"inner",options:e,async fn(t){const{listRef:o,overflowRef:u,onFallbackChange:i,offset:c=0,index:l=0,minItemsVisible:s=4,referenceOverflowThreshold:a=0,scrollRef:f,...m}=e,{rects:v,elements:{floating:p}}=t,g=o.current[l];if(!g)return{};const h={...t,...await n(-g.offsetTop-v.reference.height/2-g.offsetHeight/2-c).fn(t)},b=(null==f?void 0:f.current)||p,y=await r(Ye(h,b.scrollHeight),m),E=await r(h,{...m,elementContext:"reference"}),w=Math.max(0,y.top),R=h.y+w,x=Math.max(0,b.scrollHeight-w-Math.max(0,y.bottom));return b.style.maxHeight=x+"px",b.scrollTop=w,i&&(b.offsetHeight<g.offsetHeight*Math.min(s,o.current.length-1)-1||E.top>=-a||E.bottom>=-a?d((()=>i(!0))):d((()=>i(!1)))),u&&(u.current=await r(Ye({...h,y:R},b.offsetHeight),m)),{y:R}}}),Ue=(e,t)=>{let{open:n,elements:r}=e,{enabled:o=!0,overflowRef:i,scrollRef:c,onChange:l}=t;const s=we(l),a=u.useRef(!1),f=u.useRef(null),m=u.useRef(null);return u.useEffect((()=>{if(!o)return;function e(e){if(e.ctrlKey||!t||null==i.current)return;const n=e.deltaY,r=i.current.top>=-.5,o=i.current.bottom>=-.5,u=t.scrollHeight-t.clientHeight,c=n<0?-1:1,l=n<0?"max":"min";t.scrollHeight<=t.clientHeight||(!r&&n>0||!o&&n<0?(e.preventDefault(),d((()=>{s((e=>e+Math[l](n,u*c)))}))):/firefox/i.test(A())&&(t.scrollTop+=n))}const t=(null==c?void 0:c.current)||r.floating;return n&&t?(t.addEventListener("wheel",e),requestAnimationFrame((()=>{f.current=t.scrollTop,null!=i.current&&(m.current={...i.current})})),()=>{f.current=null,m.current=null,t.removeEventListener("wheel",e)}):void 0}),[o,n,r.floating,i,c,s]),u.useMemo((()=>o?{floating:{onKeyDown(){a.current=!0},onWheel(){a.current=!1},onPointerMove(){a.current=!1},onScroll(){const e=(null==c?void 0:c.current)||r.floating;if(i.current&&e&&a.current){if(null!==f.current){const t=e.scrollTop-f.current;(i.current.bottom<-.5&&t<-1||i.current.top<-.5&&t>1)&&d((()=>s((e=>e+t))))}requestAnimationFrame((()=>{f.current=e.scrollTop}))}}}}:{}),[o,i,r.floating,c,s])};function Ze(e){let t,{restMs:n=0,buffer:r=.5,blockPointerEvents:o=!1}=void 0===e?{}:e,u=!1,i=!1;const c=e=>{let{x:o,y:c,placement:l,elements:s,onClose:a,nodeId:f,tree:d}=e;return function(e){function m(){clearTimeout(t),a()}if(clearTimeout(t),!s.domReference||!s.floating||null==l||null==o||null==c)return;const{clientX:v,clientY:p}=e,g=[v,p],h=Q(e),b="mouseleave"===e.type,y=B(s.floating,h),E=B(s.domReference,h),w=s.domReference.getBoundingClientRect(),R=s.floating.getBoundingClientRect(),x=l.split("-")[0],k=o>R.right-R.width/2,I=c>R.bottom-R.height/2,M=function(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}(g,w);if(y&&(i=!0,!b))return;if(E&&(i=!1),E&&!b)return void(i=!0);if(b&&O(e.relatedTarget)&&B(s.floating,e.relatedTarget))return;if(d&&Z(d.nodesRef.current,f).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if("top"===x&&c>=w.bottom-1||"bottom"===x&&c<=w.top+1||"left"===x&&o>=w.right-1||"right"===x&&o<=w.left+1)return m();let T=[];switch(x){case"top":T=[[R.left,w.top+1],[R.left,R.bottom-1],[R.right,R.bottom-1],[R.right,w.top+1]],u=v>=R.left&&v<=R.right&&p>=R.top&&p<=w.top+1;break;case"bottom":T=[[R.left,R.top+1],[R.left,w.bottom-1],[R.right,w.bottom-1],[R.right,R.top+1]],u=v>=R.left&&v<=R.right&&p>=w.bottom-1&&p<=R.bottom;break;case"left":T=[[R.right-1,R.bottom],[R.right-1,R.top],[w.left+1,R.top],[w.left+1,R.bottom]],u=v>=R.left&&v<=w.left+1&&p>=R.top&&p<=R.bottom;break;case"right":T=[[w.right-1,R.bottom],[w.right-1,R.top],[R.left+1,R.top],[R.left+1,R.bottom]],u=v>=w.right-1&&v<=R.right&&p>=R.top&&p<=R.bottom}const C=u?T:function(e){let[t,n]=e;const o=R.width>w.width,u=R.height>w.height;switch(x){case"top":return[[o?t+r/2:k?t+4*r:t-4*r,n+r+1],[o?t-r/2:k?t+4*r:t-4*r,n+r+1],...[[R.left,k||o?R.bottom-r:R.top],[R.right,k?o?R.bottom-r:R.top:R.bottom-r]]];case"bottom":return[[o?t+r/2:k?t+4*r:t-4*r,n-r],[o?t-r/2:k?t+4*r:t-4*r,n-r],...[[R.left,k||o?R.top+r:R.bottom],[R.right,k?o?R.top+r:R.bottom:R.top+r]]];case"left":{const e=[t+r+1,u?n+r/2:I?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:I?n+4*r:n-4*r];return[...[[I||u?R.right-r:R.left,R.top],[I?u?R.right-r:R.left:R.right-r,R.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:I?n+4*r:n-4*r],[t-r,u?n-r/2:I?n+4*r:n-4*r],...[[I||u?R.left+r:R.right,R.top],[I?u?R.left+r:R.right:R.left+r,R.bottom]]]}}([o,c]);return u?void 0:i&&!M?m():void(!function(e,t){const[n,r]=e;let o=!1;const u=t.length;for(let e=0,i=u-1;e<u;i=e++){const[u,c]=t[e]||[0,0],[l,s]=t[i]||[0,0];c>=r!=s>=r&&n<=(l-u)*(r-c)/(s-c)+u&&(o=!o)}return o}([v,p],C)?m():n&&!i&&(t=setTimeout(m,n)))}};return c.__options={blockPointerEvents:o},c}function Qe(e){void 0===e&&(e={});const{open:t=!1,onOpenChange:n,nodeId:r}=e,i=o(e),c=k(),l=u.useRef(null),s=u.useRef({}),a=u.useState((()=>E()))[0],f=b(),[d,m]=u.useState(null),p=u.useCallback((e=>{const t=O(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),contextElement:e}:e;i.refs.setReference(t)}),[i.refs]),g=u.useCallback((e=>{(O(e)||null===e)&&(l.current=e,m(e)),(O(i.refs.reference.current)||null===i.refs.reference.current||null!==e&&!O(e))&&i.refs.setReference(e)}),[i.refs]),h=u.useMemo((()=>({...i.refs,setReference:g,setPositionReference:p,domReference:l})),[i.refs,g,p]),y=u.useMemo((()=>({...i.elements,domReference:d})),[i.elements,d]),w=we(n),R=u.useMemo((()=>({...i,refs:h,elements:y,dataRef:s,nodeId:r,floatingId:f,events:a,open:t,onOpenChange:w})),[i,r,f,a,t,w,h,y]);return v((()=>{const e=null==c?void 0:c.nodesRef.current.find((e=>e.id===r));e&&(e.context=R)})),u.useMemo((()=>({...i,context:R,refs:h,elements:y,reference:g,positionReference:p})),[i,h,y,R,g,p])}function Ge(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];return null==(e=r.get(n))?void 0:e.map((e=>e(...o))).find((e=>void 0!==e))})):e[n]=o})),e):e),{})}}const Je=function(e){void 0===e&&(e=[]);const t=e,n=u.useCallback((t=>Ge(t,e,"reference")),t),r=u.useCallback((t=>Ge(t,e,"floating")),t),o=u.useCallback((t=>Ge(t,e,"item")),e.map((e=>null==e?void 0:e.item)));return u.useMemo((()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:o})),[n,r,o])};export{y as FloatingArrow,V as FloatingDelayGroup,ve as FloatingFocusManager,M as FloatingNode,ge as FloatingOverlay,fe as FloatingPortal,T as FloatingTree,ze as inner,Ze as safePolygon,ye as useClick,xe as useClientPoint,X as useDelayGroup,q as useDelayGroupContext,Te as useDismiss,Qe as useFloating,I as useFloatingNodeId,x as useFloatingParentNodeId,ae as useFloatingPortalNode,k as useFloatingTree,Ce as useFocus,W as useHover,b as useId,Ue as useInnerOffset,Je as useInteractions,Be as useListNavigation,Ne as useMergeRefs,je as useRole,qe as useTransitionStatus,Ve as useTransitionStyles,Xe as useTypeahead}; | ||
import{platform as e,getOverflowAncestors as t,offset as n,detectOverflow as r,useFloating as o}from"@floating-ui/react-dom";export{arrow,autoPlacement,autoUpdate,computePosition,detectOverflow,flip,getOverflowAncestors,hide,inline,limitShift,offset,platform,shift,size}from"@floating-ui/react-dom";import*as u from"react";import{useLayoutEffect as i,useEffect as c,useRef as l}from"react";import{hideOthers as s}from"aria-hidden";import{tabbable as a}from"tabbable";import{createPortal as f,flushSync as d}from"react-dom";function m(){return m=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},m.apply(this,arguments)}var p="undefined"!=typeof document?i:c;let v=!1,g=0;const h=()=>"floating-ui-"+g++;const b=u["useId".toString()]||function(){const[e,t]=u.useState((()=>v?h():void 0));return p((()=>{null==e&&t(h())}),[]),u.useEffect((()=>{v||(v=!0)}),[]),e},y=u.forwardRef((function(t,n){var r;let{context:{placement:o,elements:{floating:i},middlewareData:{arrow:c}},width:l=14,height:s=7,tipRadius:a=0,strokeWidth:f=0,staticOffset:d,stroke:p,d:v,...g}=t;f*=2;const h=f/2,y=l/2*(a/-8+1),w=s/2*a/4,[E,R]=o.split("-"),x=!!i&&e.isRTL(i),I=!!v,k="top"===E||"bottom"===E,C=d&&"end"===R?"bottom":"top";let M=d&&"end"===R?"right":"left";d&&x&&(M="end"===R?"left":"right");const T=I?0:h,O=null!=(null==c?void 0:c.x)?d||c.x:"",L=null!=(null==c?void 0:c.y)?d||c.y+T:"",P=v||"M0,0 H"+l+" L"+(l-y)+","+(s-w)+" Q"+l/2+","+s+" "+y+","+(s-w)+" Z",A={top:I?"rotate(180deg)":"",left:I?"rotate(90deg)":"rotate(-90deg)",bottom:I?"":"rotate(180deg)",right:I?"rotate(-90deg)":"rotate(90deg)"}[E],S=b();return u.createElement("svg",m({},g,{suppressHydrationWarning:!0,"aria-hidden":!0,ref:n,width:I?l:l+f,height:l,viewBox:"0 0 "+l+" "+(s>l?s:l),style:{...g.style,position:"absolute",pointerEvents:"none",[M]:O,[C]:L,[E]:k||I?"100%":"calc(100% - "+f/2+"px)",transform:A+(null!=(r=g.style)&&r.transform?" "+g.style.transform:"")}}),f>0&&u.createElement("path",{clipPath:"url(#"+S+")",fill:"none",stroke:p,strokeWidth:f+(v?0:1),d:P}),u.createElement("path",{stroke:f&&!v?g.fill:"none",d:P}),u.createElement("clipPath",{id:S},u.createElement("rect",{x:-h,y:h*(I?-1:1),width:l+f,height:l})))}));function w(){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){var r;e.set(t,(null==(r=e.get(t))?void 0:r.filter((e=>e!==n)))||[])}}}const E=u.createContext(null),R=u.createContext(null),x=()=>{var e;return(null==(e=u.useContext(E))?void 0:e.id)||null},I=()=>u.useContext(R),k=e=>{const t=b(),n=I(),r=x(),o=e||r;return p((()=>{const e={id:t,parentId:o};return null==n||n.addNode(e),()=>{null==n||n.removeNode(e)}}),[n,t,o]),t},C=e=>{let{children:t,id:n}=e;const r=x();return u.createElement(E.Provider,{value:u.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},M=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))}),[]),i=u.useState((()=>w()))[0];return u.createElement(R.Provider,{value:u.useMemo((()=>({nodesRef:n,addNode:r,removeNode:o,events:i})),[n,r,o,i])},t)};function T(e){return(null==e?void 0:e.ownerDocument)||document}function O(){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 P(e){return T(e).defaultView||window}function A(e){return!!e&&e instanceof P(e).Element}function S(e){return!!e&&e instanceof P(e).HTMLElement}function D(e){if(0===e.mozInputSource&&e.isTrusted)return!0;const t=/Android/i;return(t.test(O())||t.test(L()))&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType}function N(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 F(){return/apple/i.test(navigator.vendor)}function K(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function B(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 P(r).ShadowRoot||r instanceof ShadowRoot))){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}var r;return!1}function H(e){const t=l(e);return p((()=>{t.current=e})),t}function _(e,t,n){return n&&!K(n)?0:"number"==typeof e?e:null==e?void 0:e[t]}const q=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,events:i,elements:{domReference:c,floating:l},refs:s}=e,{enabled:a=!0,delay:f=0,handleClose:d=null,mouseOnly:m=!1,restMs:v=0,move:g=!0}=t,h=I(),b=x(),y=H(d),w=H(f),E=u.useRef(),R=u.useRef(),k=u.useRef(),C=u.useRef(),M=u.useRef(!0),O=u.useRef(!1),L=u.useRef((()=>{})),P=u.useCallback((()=>{var e;const t=null==(e=o.current.openEvent)?void 0:e.type;return(null==t?void 0:t.includes("mouse"))&&"mousedown"!==t}),[o]);u.useEffect((()=>{if(a)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){clearTimeout(R.current),clearTimeout(C.current),M.current=!0}}),[a,i]),u.useEffect((()=>{if(!a||!y.current||!n)return;function e(){P()&&r(!1)}const t=T(l).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[l,n,r,a,y,o,P]);const S=u.useCallback((function(e){void 0===e&&(e=!0);const t=_(w.current,"close",E.current);t&&!k.current?(clearTimeout(R.current),R.current=setTimeout((()=>r(!1)),t)):e&&(clearTimeout(R.current),r(!1))}),[w,r]),D=u.useCallback((()=>{L.current(),k.current=void 0}),[]),N=u.useCallback((()=>{if(O.current){const e=T(s.floating.current).body;e.style.pointerEvents="",e.removeAttribute("data-floating-ui-safe-polygon"),O.current=!1}}),[s]);return u.useEffect((()=>{if(a&&A(c)){const e=c;return n&&e.addEventListener("mouseleave",s),null==l||l.addEventListener("mouseleave",s),g&&e.addEventListener("mousemove",u,{once:!0}),e.addEventListener("mouseenter",u),e.addEventListener("mouseleave",i),()=>{n&&e.removeEventListener("mouseleave",s),null==l||l.removeEventListener("mouseleave",s),g&&e.removeEventListener("mousemove",u),e.removeEventListener("mouseenter",u),e.removeEventListener("mouseleave",i)}}function t(){return!!o.current.openEvent&&["click","mousedown"].includes(o.current.openEvent.type)}function u(e){if(clearTimeout(R.current),M.current=!1,m&&!K(E.current)||v>0&&0===_(w.current,"open"))return;o.current.openEvent=e;const t=_(w.current,"open",E.current);t?R.current=setTimeout((()=>{r(!0)}),t):r(!0)}function i(r){if(t())return;L.current();const o=T(l);if(clearTimeout(C.current),y.current){n||clearTimeout(R.current),k.current=y.current({...e,tree:h,x:r.clientX,y:r.clientY,onClose(){N(),D(),S()}});const t=k.current;return o.addEventListener("mousemove",t),void(L.current=()=>{o.removeEventListener("mousemove",t)})}("touch"!==E.current||!B(l,r.relatedTarget))&&S()}function s(n){t()||null==y.current||y.current({...e,tree:h,x:n.clientX,y:n.clientY,onClose(){N(),D(),S()}})(n)}}),[c,l,a,e,m,v,g,S,D,N,r,n,h,w,y,o]),p((()=>{var e;if(a&&n&&null!=(e=y.current)&&e.__options.blockPointerEvents&&P()){const e=T(l).body;if(e.setAttribute("data-floating-ui-safe-polygon",""),e.style.pointerEvents="none",O.current=!0,A(c)&&l){var t,r;const e=c,n=null==h||null==(t=h.nodesRef.current.find((e=>e.id===b)))||null==(r=t.context)?void 0:r.elements.floating;return n&&(n.style.pointerEvents=""),e.style.pointerEvents="auto",l.style.pointerEvents="auto",()=>{e.style.pointerEvents="",l.style.pointerEvents=""}}}}),[a,n,b,l,c,h,y,o,P]),p((()=>{n||(E.current=void 0,D(),N())}),[n,D,N]),u.useEffect((()=>()=>{D(),clearTimeout(R.current),clearTimeout(C.current),N()}),[a,D,N]),u.useMemo((()=>{if(!a)return{};function e(e){E.current=e.pointerType}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove(){n||0===v||(clearTimeout(C.current),C.current=setTimeout((()=>{M.current||r(!0)}),v))}},floating:{onMouseEnter(){clearTimeout(R.current)},onMouseLeave(){i.emit("dismiss",{type:"mouseLeave",data:{returnFocus:!1}}),S(!1)}}}}),[i,a,v,n,r,S])},j=u.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:()=>{},setState:()=>{},isInstantPhase:!1}),W=()=>u.useContext(j),U=e=>{let{children:t,delay:n,timeoutMs:r=0}=e;const[o,i]=u.useReducer(((e,t)=>({...e,...t})),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),c=u.useRef(null),l=u.useCallback((e=>{i({currentId:e})}),[]);return p((()=>{o.currentId?null===c.current?c.current=o.currentId:i({isInstantPhase:!0}):(i({isInstantPhase:!1}),c.current=null)}),[o.currentId]),u.createElement(j.Provider,{value:u.useMemo((()=>({...o,setState:i,setCurrentId:l})),[o,i,l])},t)},V=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:o}=t;const{currentId:u,setCurrentId:i,initialDelay:c,setState:l,timeoutMs:s}=W();p((()=>{u&&(l({delay:{open:1,close:_(c,"close")}}),u!==o&&r(!1))}),[o,r,l,u,c]),p((()=>{function e(){r(!1),l({delay:c,currentId:null})}if(!n&&u===o){if(s){const t=window.setTimeout(e,s);return()=>{clearTimeout(t)}}e()}}),[n,l,u,o,r,c,s]),p((()=>{n&&i(o)}),[n,i,o])};function X(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}let Y=0;function z(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(Y);const u=()=>null==e?void 0:e.focus({preventScroll:n});o?u():Y=requestAnimationFrame(u)}function Z(e,t){let n=e.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})),r=n;for(;r.length;)r=e.filter((e=>{var t;return null==(t=r)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})),n=n.concat(r);return n}function G(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Q(e){return S(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function J(e){e.preventDefault(),e.stopPropagation()}const $=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function ee(e,t){const n=a(e,$());"prev"===t&&n.reverse();const r=n.indexOf(X(T(e)));return n.slice(r+1)[0]}function te(){return ee(document.body,"next")}function ne(){return ee(document.body,"prev")}function re(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!B(n,r)}function oe(e){a(e,$()).forEach((e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")}))}function ue(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 ie={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};function ce(e){"Tab"===e.key&&(e.target,clearTimeout(undefined))}const le=u.forwardRef((function(e,t){const[n,r]=u.useState();return p((()=>(F()&&r("button"),document.addEventListener("keydown",ce),()=>{document.removeEventListener("keydown",ce)})),[]),u.createElement("span",m({},e,{ref:t,tabIndex:0,role:n,"aria-hidden":!n||void 0,"data-floating-ui-focus-guard":"",style:ie}))})),se=u.createContext(null),ae=function(e){let{id:t,root:n}=void 0===e?{}:e;const[r,o]=u.useState(null),i=u.useRef(null),c=b(),l=de(),s=u.useMemo((()=>({id:t,root:n,portalContext:l,uniqueId:c})),[t,n,l,c]),a=u.useRef();return p((()=>{const e=i.current;return()=>{null==r||r.remove(),null==e||e.remove()}}),[r,s]),p((()=>{if(a.current===s)return;a.current=s;const{id:e,root:t,portalContext:n,uniqueId:r}=s,u=e?document.getElementById(e):null,i="data-floating-ui-portal";if(u){const e=document.createElement("div");e.id=r,e.setAttribute(i,""),u.appendChild(e),o(e)}else{let u=(null==n?void 0:n.portalNode)||t||document.body,c=null;e&&(c=document.createElement("div"),c.id=e,u.appendChild(c));const l=document.createElement("div");l.id=r,l.setAttribute(i,""),u=c||u,u.appendChild(l),o(l)}}),[s]),r},fe=e=>{let{children:t,id:n,root:r=null,preserveTabOrder:o=!0}=e;const i=ae({id:n,root:r}),[c,l]=u.useState(null),s=u.useRef(null),a=u.useRef(null),d=u.useRef(null),m=u.useRef(null),p=!!c&&!c.modal&&!(!r&&!i)&&o;return u.useEffect((()=>{if(i&&o&&(null==c||!c.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&&re(e)){("focusin"===e.type?ue:oe)(i)}}}),[i,o,null==c?void 0:c.modal]),u.createElement(se.Provider,{value:u.useMemo((()=>({preserveTabOrder:o,beforeOutsideRef:s,afterOutsideRef:a,beforeInsideRef:d,afterInsideRef:m,portalNode:i,setFocusManagerState:l})),[o,i])},p&&i&&u.createElement(le,{"data-type":"outside",ref:s,onFocus:e=>{if(re(e,i)){var t;null==(t=d.current)||t.focus()}else{const e=ne()||(null==c?void 0:c.refs.domReference.current);null==e||e.focus()}}}),p&&i&&u.createElement("span",{"aria-owns":i.id,style:ie}),i&&f(t,i),p&&i&&u.createElement(le,{"data-type":"outside",ref:a,onFocus:e=>{if(re(e,i)){var t;null==(t=m.current)||t.focus()}else{const e=te()||(null==c?void 0:c.refs.domReference.current);null==e||e.focus(),(null==c?void 0:c.closeOnFocusOut)&&(null==c||c.onOpenChange(!1))}}}))},de=()=>u.useContext(se),me=u.forwardRef((function(e,t){return u.createElement("button",m({},e,{type:"button",ref:t,tabIndex:-1,style:ie}))}));function pe(e){let{context:t,children:n,order:r=["content"],guards:o=!0,initialFocus:i=0,returnFocus:c=!0,modal:l=!0,visuallyHiddenDismiss:f=!1,closeOnFocusOut:d=!0}=e;const{open:m,refs:v,nodeId:g,onOpenChange:h,events:b,dataRef:y,elements:{domReference:w,floating:E}}=t,R=H(r),x=H(i),k=H(c),C=I(),M=de(),[O,L]=u.useState(null),P="number"==typeof i&&i<0,A=u.useRef(null),D=u.useRef(null),N=u.useRef(!1),F=u.useRef(null),K=u.useRef(!1),_=null!=M,q=w&&"combobox"===w.getAttribute("role")&&Q(w),j=u.useCallback((function(e){return void 0===e&&(e=E),e?a(e,$()):[]}),[E]),W=u.useCallback((e=>{const t=j(e);return R.current.map((e=>w&&"reference"===e?w:E&&"floating"===e?E:t)).filter(Boolean).flat()}),[w,E,R,j]);u.useEffect((()=>{if(!l)return;function e(e){if("Tab"===e.key){0!==j().length||q||J(e);const t=W(),n=G(e);"reference"===R.current[0]&&n===w&&(J(e),e.shiftKey?z(t[t.length-1]):z(t[1])),"floating"===R.current[1]&&n===E&&e.shiftKey&&(J(e),z(t[0]))}}const t=T(E);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[w,E,l,R,v,q,j,W]),u.useEffect((()=>{if(d)return E&&S(w)?(w.addEventListener("focusout",t),w.addEventListener("pointerdown",e),!l&&E.addEventListener("focusout",t),()=>{w.removeEventListener("focusout",t),w.removeEventListener("pointerdown",e),!l&&E.removeEventListener("focusout",t)}):void 0;function e(){K.current=!0,setTimeout((()=>{K.current=!1}))}function t(e){const t=e.relatedTarget;queueMicrotask((()=>{const e=!(B(w,t)||B(E,t)||B(t,E)||B(null==M?void 0:M.portalNode,t)||null!=t&&t.hasAttribute("data-floating-ui-focus-guard")||C&&(Z(C.nodesRef.current,g).find((e=>{var n,r;return B(null==(n=e.context)?void 0:n.elements.floating,t)||B(null==(r=e.context)?void 0:r.elements.domReference,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}(C.nodesRef.current,g).find((e=>{var n,r;return(null==(n=e.context)?void 0:n.elements.floating)===t||(null==(r=e.context)?void 0:r.elements.domReference)===t}))));t&&e&&!K.current&&t!==F.current&&(N.current=!0,h(!1))}))}}),[w,E,l,g,C,M,h,d]),u.useEffect((()=>{var e;const t=Array.from((null==M||null==(e=M.portalNode)?void 0:e.querySelectorAll("[data-floating-ui-portal]"))||[]);if(E&&l){const e=[E,...t,...[A.current,D.current].filter(Boolean)],n=s(R.current.includes("reference")||q?e.concat(w||[]):e);return()=>{n()}}}),[w,E,l,R,M,q]),u.useEffect((()=>{if(l&&!o&&E){const e=[],t=$(),n=a(T(E).body,t),r=W(),o=n.filter((e=>!r.includes(e)));return o.forEach(((t,n)=>{e[n]=t.getAttribute("tabindex"),t.setAttribute("tabindex","-1")})),()=>{o.forEach(((t,n)=>{const r=e[n];null==r?t.removeAttribute("tabindex"):t.setAttribute("tabindex",r)}))}}}),[E,l,o,W]),p((()=>{if(!E)return;let e=!1;const t=T(E),n=X(t),r=y.current;function o(t){if("escapeKey"===t.type&&v.domReference.current&&(F.current=v.domReference.current),["referencePress","escapeKey"].includes(t.type))return;const n=t.data.returnFocus;"object"==typeof n?(N.current=!1,e=n.preventScroll):N.current=!n}return F.current=n,queueMicrotask((()=>{const e=W(E),t=x.current,r=("number"==typeof t?e[t]:t.current)||E,o=B(E,n);P||o||!m||z(r,{preventScroll:r===E})})),b.on("dismiss",o),()=>{b.off("dismiss",o);const n=X(t);(B(E,n)||C&&Z(C.nodesRef.current,g).some((e=>{var t;return B(null==(t=e.context)?void 0:t.elements.floating,n)}))||r.openEvent&&["click","mousedown"].includes(r.openEvent.type))&&v.domReference.current&&(F.current=v.domReference.current),k.current&&S(F.current)&&!N.current&&z(F.current,{cancelPrevious:!1,preventScroll:e})}}),[m,E,W,k,x,y,v,b,P,C,g]),p((()=>{if(M)return M.setFocusManagerState({...t,modal:l,closeOnFocusOut:d}),()=>{M.setFocusManagerState(null)}}),[M,l,d,t]),p((()=>{if(!P&&E&&(e(),"function"==typeof MutationObserver)){const t=new MutationObserver(e);return t.observe(E,{childList:!0,subtree:!0}),()=>{t.disconnect()}}function e(){X(T(E))!==v.domReference.current&&L(j().length)}}),[E,j,P,v]);const U=o&&(_||l)&&!q;function V(e){return f&&l?u.createElement(me,{ref:"start"===e?A:D,onClick:()=>h(!1)},"string"==typeof f?f:"Dismiss"):null}return u.createElement(u.Fragment,null,U&&u.createElement(le,{"data-type":"inside",ref:null==M?void 0:M.beforeInsideRef,onFocus:e=>{if(l){const e=W();z("reference"===r[0]?e[0]:e[e.length-1])}else if(null!=M&&M.preserveTabOrder&&M.portalNode)if(N.current=!1,re(e,M.portalNode)){const e=te()||w;null==e||e.focus()}else{var t;null==(t=M.beforeOutsideRef.current)||t.focus()}}}),q?null:V("start"),u.cloneElement(n,0===O||r.includes("floating")?{tabIndex:0}:{}),V("end"),U&&u.createElement(le,{"data-type":"inside",ref:null==M?void 0:M.afterInsideRef,onFocus:e=>{if(l)z(W()[0]);else if(null!=M&&M.preserveTabOrder&&M.portalNode)if(d&&(N.current=!0),re(e,M.portalNode)){const e=ne()||w;null==e||e.focus()}else{var t;null==(t=M.afterOutsideRef.current)||t.focus()}}}))}function ve(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const ge=u.createContext({register:()=>{},unregister:()=>{},map:new Map,elementsRef:{current:[]}});function he(e){let{children:t,elementsRef:n,labelsRef:r}=e;const[o,i]=u.useState((()=>new Map)),c=u.useCallback((e=>{i((t=>new Map(t).set(e,null)))}),[]),l=u.useCallback((e=>{i((t=>{const n=new Map(t);return n.delete(e),n}))}),[]);return p((()=>{if(o.size<2)return;const e=new Map(o);Array.from(e.keys()).sort(ve).forEach(((t,n)=>{e.set(t,n)})),function(e,t){if(e.size!==t.size)return!1;for(const[n,r]of e.entries())if(r!==t.get(n))return!1;return!0}(o,e)||i(e)}),[o]),u.createElement(ge.Provider,{value:{register:c,unregister:l,map:o,elementsRef:n,labelsRef:r}},t)}function be(e){let{label:t}=void 0===e?{}:e;const[n,r]=u.useState(null),o=u.useRef(null),{register:i,unregister:c,map:l,elementsRef:s,labelsRef:a}=u.useContext(ge),f=u.useCallback((e=>{if(o.current=e,null!==n&&(s.current[n]=e,a)){var r;const o=void 0!==t;a.current[n]=o?t:null!=(r=null==e?void 0:e.textContent)?r:null}}),[n,s,a,t]);return p((()=>{const e=o.current;if(e)return i(e),()=>{c(e)}}),[i,c]),p((()=>{const e=o.current?l.get(o.current):null;null!=e&&r(e)}),[l]),u.useMemo((()=>({ref:f,index:null==n?-1:n})),[n,f])}const ye="data-floating-ui-scroll-lock",we=u.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return p((()=>{var e,t;if(!n)return;if(document.body.hasAttribute(ye))return;document.body.setAttribute(ye,"");const r=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(O()))return Object.assign(document.body.style,{overflow:"hidden",[r]:o+"px"}),()=>{document.body.removeAttribute(ye),Object.assign(document.body.style,{overflow:"",[r]:""})};const u=(null==(e=window.visualViewport)?void 0:e.offsetLeft)||0,i=(null==(t=window.visualViewport)?void 0:t.offsetTop)||0,c=window.pageXOffset,l=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(l-Math.floor(i))+"px",left:-(c-Math.floor(u))+"px",right:"0",[r]:o+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[r]:""}),document.body.removeAttribute(ye),window.scrollTo(c,l)}}),[n]),u.createElement("div",m({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));function Ee(e){return S(e.target)&&"BUTTON"===e.target.tagName}function Re(e){return Q(e)}const xe=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,elements:{domReference:i}}=e,{enabled:c=!0,event:l="click",toggle:s=!0,ignoreMouse:a=!1,keyboardHandlers:f=!0}=t,d=u.useRef(),m=u.useRef(!1);return u.useMemo((()=>c?{reference:{onPointerDown(e){d.current=e.pointerType},onMouseDown(e){0===e.button&&(K(d.current,!0)&&a||"click"!==l&&(n?!s||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:K(d.current,!0)&&a||(n?!s||o.current.openEvent&&"click"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent)},onKeyDown(e){d.current=void 0,f&&!Ee(e)&&(" "!==e.key||Re(i)||(e.preventDefault(),m.current=!0),"Enter"===e.key&&(n?s&&r(!1):r(!0)))},onKeyUp(e){!f||Ee(e)||Re(i)||" "===e.key&&m.current&&(m.current=!1,n?s&&r(!1):r(!0))}}}:{}),[c,o,l,a,f,i,s,n,r])},Ie=u["useInsertionEffect".toString()]||(e=>e());function ke(e){const t=u.useRef((()=>{}));return Ie((()=>{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 Ce(e){return null!=e&&null!=e.clientX}const Me=function(e,t){let{open:n,refs:r,dataRef:o,elements:{floating:i}}=e,{enabled:c=!0,axis:l="both",x:s=null,y:a=null}=void 0===t?{}:t;const f=u.useRef(!1),d=u.useRef(null),[m,v]=u.useState(),[g,h]=u.useState([]),b=ke(((e,t)=>{f.current||o.current.openEvent&&!Ce(o.current.openEvent)||r.setPositionReference(function(e,t){let n=null,r=null,o=!1;return{contextElement:e.current||void 0,getBoundingClientRect(){var u,i;const c=(null==(u=e.current)?void 0:u.getBoundingClientRect())||{width:0,height:0,x:0,y:0},l="x"===t.axis||"both"===t.axis,s="y"===t.axis||"both"===t.axis,a=["mouseenter","mousemove"].includes((null==(i=t.dataRef.current.openEvent)?void 0:i.type)||"")&&"touch"!==t.pointerType;let f=c.width,d=c.height,m=c.x,p=c.y;return null==n&&t.x&&l&&(n=c.x-t.x),null==r&&t.y&&s&&(r=c.y-t.y),m-=n||0,p-=r||0,f=0,d=0,!o||a?(f="y"===t.axis?c.width:0,d="x"===t.axis?c.height:0,m=l&&null!=t.x?t.x:m,p=s&&null!=t.y?t.y:p):o&&!a&&(d="x"===t.axis?c.height:d,f="y"===t.axis?c.width:f),o=!0,{width:f,height:d,x:m,y:p,top:p,right:m+f,bottom:p+d,left:m}}}}(r.domReference,{x:e,y:t,axis:l,dataRef:o,pointerType:m}))})),y=ke((e=>{null==s&&null==a&&(n?d.current||h([]):b(e.clientX,e.clientY))})),w=K(m)?i:n,E=u.useCallback((()=>{if(!w||!c||null!=s||null!=a)return;const e=P(r.floating.current);function t(n){const o=G(n);B(r.floating.current,o)?(e.removeEventListener("mousemove",t),d.current=null):b(n.clientX,n.clientY)}if(!o.current.openEvent||Ce(o.current.openEvent)){e.addEventListener("mousemove",t);const n=()=>{e.removeEventListener("mousemove",t),d.current=null};return d.current=n,n}r.setPositionReference(r.domReference.current)}),[o,c,w,r,b,s,a]);return u.useEffect((()=>E()),[E,g]),u.useEffect((()=>{c&&!i&&(f.current=!1)}),[c,i]),u.useEffect((()=>{!c&&n&&(f.current=!0)}),[c,n]),p((()=>{!c||null==s&&null==a||(f.current=!1,b(s,a))}),[c,s,a,b]),u.useMemo((()=>{if(!c)return{};function e(e){let{pointerType:t}=e;v(t)}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove:y,onMouseEnter:y}}}),[c,y])};function Te(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 Oe={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Le={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Pe=function(e,n){void 0===n&&(n={});const{open:r,onOpenChange:o,events:i,nodeId:c,elements:{reference:l,domReference:s,floating:a},dataRef:f}=e,{enabled:d=!0,escapeKey:m=!0,outsidePress:p=!0,outsidePressEvent:v="pointerdown",referencePress:g=!1,referencePressEvent:h="pointerdown",ancestorScroll:b=!1,bubbles:y}=n,w=I(),E=null!=x(),R=ke("function"==typeof p?p:()=>!1),k="function"==typeof p?R:p,C=u.useRef(!1),{escapeKeyBubbles:M,outsidePressBubbles:O}=(e=>{var t,n;return{escapeKeyBubbles:"boolean"==typeof e?e:null!=(t=null==e?void 0:e.escapeKey)&&t,outsidePressBubbles:"boolean"==typeof e?e:null==(n=null==e?void 0:e.outsidePress)||n}})(y),L=ke((e=>{if(!r||!d||!m||"Escape"!==e.key)return;const t=w?Z(w.nodesRef.current,c):[];if(!M&&(e.stopPropagation(),t.length>0)){let e=!0;if(t.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__escapeKeyBubbles||(e=!1)})),!e)return}i.emit("dismiss",{type:"escapeKey",data:{returnFocus:{preventScroll:!1}}}),o(!1)})),F=ke((e=>{const t=C.current;if(C.current=!1,t)return;if("function"==typeof k&&!k(e))return;const n=G(e);if(S(n)&&a){const t=n.clientWidth>0&&n.scrollWidth>n.clientWidth,r=n.clientHeight>0&&n.scrollHeight>n.clientHeight;let o=r&&e.offsetX>n.clientWidth;if(r){"rtl"===P(a).getComputedStyle(n).direction&&(o=e.offsetX<=n.offsetWidth-n.clientWidth)}if(o||t&&e.offsetY>n.clientHeight)return}const r=w&&Z(w.nodesRef.current,c).some((t=>{var n;return Te(e,null==(n=t.context)?void 0:n.elements.floating)}));if(Te(e,a)||Te(e,s)||r)return;const u=w?Z(w.nodesRef.current,c):[];if(u.length>0){let e=!0;if(u.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__outsidePressBubbles||(e=!1)})),!e)return}i.emit("dismiss",{type:"outsidePress",data:{returnFocus:E?{preventScroll:!0}:D(e)||N(e)}}),o(!1)}));return u.useEffect((()=>{if(!r||!d)return;function e(){o(!1)}f.current.__escapeKeyBubbles=M,f.current.__outsidePressBubbles=O;const n=T(a);m&&n.addEventListener("keydown",L),k&&n.addEventListener(v,F);let u=[];return b&&(A(s)&&(u=t(s)),A(a)&&(u=u.concat(t(a))),!A(l)&&l&&l.contextElement&&(u=u.concat(t(l.contextElement)))),u=u.filter((e=>{var t;return e!==(null==(t=n.defaultView)?void 0:t.visualViewport)})),u.forEach((t=>{t.addEventListener("scroll",e,{passive:!0})})),()=>{m&&n.removeEventListener("keydown",L),k&&n.removeEventListener(v,F),u.forEach((t=>{t.removeEventListener("scroll",e)}))}}),[f,a,s,l,m,k,v,r,o,b,d,M,O,L,F]),u.useEffect((()=>{C.current=!1}),[k,v]),u.useMemo((()=>d?{reference:{onKeyDown:L,[Oe[h]]:()=>{g&&(i.emit("dismiss",{type:"referencePress",data:{returnFocus:!1}}),o(!1))}},floating:{onKeyDown:L,[Le[v]]:()=>{C.current=!0}}}:{}),[d,i,g,v,h,o,L])},Ae=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,events:i,refs:c,elements:{floating:l,domReference:s}}=e,{enabled:a=!0,keyboardOnly:f=!0}=t,d=u.useRef(""),m=u.useRef(!1),p=u.useRef();return u.useEffect((()=>{if(!a)return;const e=T(l).defaultView||window;function t(){!n&&S(s)&&s===X(T(s))&&(m.current=!0)}return e.addEventListener("blur",t),()=>{e.removeEventListener("blur",t)}}),[l,s,n,a]),u.useEffect((()=>{if(a)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(e){"referencePress"!==e.type&&"escapeKey"!==e.type||(m.current=!0)}}),[i,a]),u.useEffect((()=>()=>{clearTimeout(p.current)}),[]),u.useMemo((()=>a?{reference:{onPointerDown(e){let{pointerType:t}=e;d.current=t,m.current=!(!t||!f)},onMouseLeave(){m.current=!1},onFocus(e){var t;m.current||"focus"===e.type&&"mousedown"===(null==(t=o.current.openEvent)?void 0:t.type)&&o.current.openEvent&&Te(o.current.openEvent,s)||(o.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){m.current=!1;const t=e.relatedTarget,n=A(t)&&t.hasAttribute("data-floating-ui-focus-guard")&&"outside"===t.getAttribute("data-type");p.current=setTimeout((()=>{B(c.floating.current,t)||B(s,t)||n||r(!1)}))}}}:{}),[a,f,s,c,o,r])};let Se=!1;function De(e,t,n){return Math.floor(e/t)!==n}function Ne(e,t){return t<0||t>=e.current.length}function Fe(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o,amount:u=1}=void 0===t?{}:t;const i=e.current;let c=n;do{var l,s;c+=r?-u:u}while(c>=0&&c<=i.length-1&&(o?o.includes(c):null==i[c]||(null==(l=i[c])?void 0:l.hasAttribute("disabled"))||"true"===(null==(s=i[c])?void 0:s.getAttribute("aria-disabled"))));return c}function Ke(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Be(e,t){return Ke(t,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function He(e,t,n){return Ke(t,"ArrowDown"===e,n?"ArrowLeft"===e:"ArrowRight"===e)||"Enter"===e||" "==e||""===e}function _e(e,t){return Fe(e,{disabledIndices:t})}function qe(e,t){return Fe(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}const je=(e,t)=>{const{open:n,onOpenChange:r,refs:o,elements:{domReference:i,floating:c}}=e,{listRef:l,activeIndex:s,onNavigate:a=(()=>{}),enabled:f=!0,selectedIndex:d=null,allowEscape:m=!1,loop:v=!1,nested:g=!1,rtl:h=!1,virtual:b=!1,focusItemOnOpen:y="auto",focusItemOnHover:w=!0,openOnArrowKeyDown:E=!0,disabledIndices:R,orientation:k="vertical",cols:C=1,scrollItemIntoView:M=!0}=t,L=x(),P=I(),A=ke(a),K=u.useRef(y),_=u.useRef(null!=d?d:-1),q=u.useRef(null),j=u.useRef(!0),W=u.useRef(A),U=u.useRef(!!c),V=u.useRef(!1),Y=u.useRef(!1),Z=H(R),G=H(n),Q=H(M),[$,ee]=u.useState(),te=ke((function(e,t,n){void 0===n&&(n=!1);const r=e.current[t.current];r&&(b?ee(r.id):z(r,{preventScroll:!0,sync:!(!O().toLowerCase().startsWith("mac")||navigator.maxTouchPoints||!F())&&(Se||V.current)}),requestAnimationFrame((()=>{const e=Q.current;e&&r&&(n||!j.current)&&(null==r.scrollIntoView||r.scrollIntoView("boolean"==typeof e?{block:"nearest",inline:"nearest"}:e))})))}));p((()=>{document.createElement("div").focus({get preventScroll(){return Se=!0,!1}})}),[]),p((()=>{f&&(n&&c?K.current&&null!=d&&(Y.current=!0,A(d)):U.current&&(_.current=-1,W.current(null)))}),[f,n,c,d,A]),p((()=>{if(f&&n&&c)if(null==s){if(V.current=!1,null!=d)return;if(U.current&&(_.current=-1,te(l,_)),!U.current&&K.current&&(null!=q.current||!0===K.current&&null==q.current)){let e=0;const t=()=>{if(null==l.current[0]){if(e<2){(e?requestAnimationFrame:queueMicrotask)(t)}e++}else _.current=null==q.current||He(q.current,k,h)||g?_e(l,Z.current):qe(l,Z.current),q.current=null,A(_.current)};t()}}else Ne(l,s)||(_.current=s,te(l,_,Y.current),Y.current=!1)}),[f,n,c,s,d,g,l,k,h,A,te,Z]),p((()=>{if(f&&U.current&&!c&&P){var e,t;const n=P.nodesRef.current,r=null==(e=n.find((e=>e.id===L)))||null==(t=e.context)?void 0:t.elements.floating,o=X(T(c)),u=n.some((e=>e.context&&B(e.context.elements.floating,o)));r&&!u&&r.focus({preventScroll:!0})}}),[f,c,P,L]),p((()=>{W.current=A,U.current=!!c})),p((()=>{n||(q.current=null)}),[n]);const ne=null!=s,re=u.useMemo((()=>{function e(e){if(!n)return;const t=l.current.indexOf(e);-1!==t&&A(t)}return{onFocus(t){let{currentTarget:n}=t;e(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...w&&{onMouseMove(t){let{currentTarget:n}=t;e(n)},onPointerLeave(e){let{pointerType:t}=e;j.current&&"touch"!==t&&(_.current=-1,te(l,_),A(null),b||z(o.floating.current,{preventScroll:!0}))}}}}),[n,o,te,w,l,A,b]);return u.useMemo((()=>{if(!f)return{};const e=Z.current;function t(t){if(j.current=!1,V.current=!0,!G.current&&t.currentTarget===o.floating.current)return;if(g&&function(e,t,n){return Ke(t,n?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(t.key,k,h))return J(t),r(!1),void(S(i)&&i.focus());const u=_.current,c=_e(l,e),s=qe(l,e);if("Home"===t.key&&(J(t),_.current=c,A(_.current)),"End"===t.key&&(J(t),_.current=s,A(_.current)),C>1){const n=_.current;if("ArrowUp"===t.key){if(J(t),-1===n)_.current=s;else if(_.current=Fe(l,{startingIndex:n,amount:C,decrement:!0,disabledIndices:e}),v&&(n-C<c||_.current<0)){const e=n%C,t=s%C,r=s-(t-e);_.current=t===e?s:t>e?r:r-C}Ne(l,_.current)&&(_.current=n),A(_.current)}if("ArrowDown"===t.key&&(J(t),-1===n?_.current=c:(_.current=Fe(l,{startingIndex:n,amount:C,disabledIndices:e}),v&&n+C>s&&(_.current=Fe(l,{startingIndex:n%C-C,amount:C,disabledIndices:e}))),Ne(l,_.current)&&(_.current=n),A(_.current)),"both"===k){const r=Math.floor(n/C);"ArrowRight"===t.key&&(J(t),n%C!=C-1?(_.current=Fe(l,{startingIndex:n,disabledIndices:e}),v&&De(_.current,C,r)&&(_.current=Fe(l,{startingIndex:n-n%C-1,disabledIndices:e}))):v&&(_.current=Fe(l,{startingIndex:n-n%C-1,disabledIndices:e})),De(_.current,C,r)&&(_.current=n)),"ArrowLeft"===t.key&&(J(t),n%C!=0?(_.current=Fe(l,{startingIndex:n,disabledIndices:e,decrement:!0}),v&&De(_.current,C,r)&&(_.current=Fe(l,{startingIndex:n+(C-n%C),decrement:!0,disabledIndices:e}))):v&&(_.current=Fe(l,{startingIndex:n+(C-n%C),decrement:!0,disabledIndices:e})),De(_.current,C,r)&&(_.current=n));const o=Math.floor(s/C)===r;return Ne(l,_.current)&&(_.current=v&&o?"ArrowLeft"===t.key?s:Fe(l,{startingIndex:n-n%C-1,disabledIndices:e}):n),void A(_.current)}}if(Be(t.key,k)){if(J(t),n&&!b&&X(t.currentTarget.ownerDocument)===t.currentTarget)return _.current=He(t.key,k,h)?c:s,void A(_.current);He(t.key,k,h)?_.current=v?u>=s?m&&u!==l.current.length?-1:c:Fe(l,{startingIndex:u,disabledIndices:e}):Math.min(s,Fe(l,{startingIndex:u,disabledIndices:e})):_.current=v?u<=c?m&&-1!==u?l.current.length:s:Fe(l,{startingIndex:u,decrement:!0,disabledIndices:e}):Math.max(c,Fe(l,{startingIndex:u,decrement:!0,disabledIndices:e})),Ne(l,_.current)?A(null):A(_.current)}}function u(e){"auto"===y&&D(e.nativeEvent)&&(K.current=!0)}const c=b&&n&&ne&&{"aria-activedescendant":$};return{reference:{...c,onKeyDown(o){j.current=!1;const u=0===o.key.indexOf("Arrow");if(b&&n)return t(o);if(!n&&!E&&u)return;const i=u||"Enter"===o.key||""===o.key.trim(),c=Be(o.key,k),s=function(e,t,n){return Ke(t,n?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(o.key,k,h);i&&(q.current=g&&c?null:o.key),g?s&&(J(o),n?(_.current=_e(l,e),A(_.current)):r(!0)):c&&(null!=d&&(_.current=d),J(o),!n&&E?r(!0):t(o),n&&A(_.current))},onFocus(){n&&A(null)},onPointerDown:function(e){K.current=y,"auto"===y&&N(e.nativeEvent)&&(K.current=!0)},onMouseDown:u,onClick:u},floating:{"aria-orientation":"both"===k?void 0:k,...c,onKeyDown:t,onPointerMove(){j.current=!0}},item:re}}),[i,o,$,Z,G,l,f,k,h,b,n,ne,g,d,E,m,C,v,y,A,r,re])};function We(e){return u.useMemo((()=>e.every((e=>null==e))?null:t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}),e)}const Ue=function(e,t){void 0===t&&(t={});const{open:n,floatingId:r}=e,{enabled:o=!0,role:i="dialog"}=t,c=b();return u.useMemo((()=>{const e={id:r,role:i};return o?"tooltip"===i?{reference:{"aria-describedby":n?r:void 0},floating:e}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":"alertdialog"===i?"dialog":i,"aria-controls":n?r:void 0,..."listbox"===i&&{role:"combobox"},..."menu"===i&&{id:c}},floating:{...e,..."menu"===i&&{"aria-labelledby":c}}}:{}}),[o,i,n,r,c])},Ve=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,((e,t)=>(t?"-":"")+e.toLowerCase()));function Xe(e,t){return"function"==typeof e?e(t):e}function Ye(e,t){void 0===t&&(t={});const{open:n,elements:{floating:r}}=e,{duration:o=250}=t,i=("number"==typeof o?o:o.close)||0,[c,l]=u.useState(!1),[s,a]=u.useState("unmounted"),f=function(e,t){const[n,r]=u.useState(e);return e&&!n&&r(!0),u.useEffect((()=>{if(!e){const e=setTimeout((()=>r(!1)),t);return()=>clearTimeout(e)}}),[e,t]),n}(n,i);return p((()=>{c&&!f&&a("unmounted")}),[c,f]),p((()=>{if(r){if(n){a("initial");const e=requestAnimationFrame((()=>{a("open")}));return()=>{cancelAnimationFrame(e)}}l(!0),a("close")}}),[n,r]),{isMounted:f,status:s}}function ze(e,t){void 0===t&&(t={});const{initial:n={opacity:0},open:r,close:o,common:i,duration:c=250}=t,l=e.placement,s=l.split("-")[0],a=u.useMemo((()=>({side:s,placement:l})),[s,l]),f="number"==typeof c,d=(f?c:c.open)||0,m=(f?c:c.close)||0,[v,g]=u.useState((()=>({...Xe(i,a),...Xe(n,a)}))),{isMounted:h,status:b}=Ye(e,{duration:c}),y=H(n),w=H(r),E=H(o),R=H(i);return p((()=>{const e=Xe(y.current,a),t=Xe(E.current,a),n=Xe(R.current,a),r=Xe(w.current,a)||Object.keys(e).reduce(((e,t)=>(e[t]="",e)),{});if("initial"===b&&g((t=>({transitionProperty:t.transitionProperty,...n,...e}))),"open"===b&&g({transitionProperty:Object.keys(r).map(Ve).join(","),transitionDuration:d+"ms",...n,...r}),"close"===b){const r=t||e;g({transitionProperty:Object.keys(r).map(Ve).join(","),transitionDuration:m+"ms",...n,...r})}}),[m,E,y,w,R,d,b,a]),{isMounted:h,styles:v}}const Ze=(e,t)=>{var n;const{open:r,dataRef:o}=e,{listRef:i,activeIndex:c,onMatch:l,onTypingChange:s,enabled:a=!0,findMatch:f=null,resetMs:d=750,ignoreKeys:m=[],selectedIndex:v=null}=t,g=u.useRef(),h=u.useRef(""),b=u.useRef(null!=(n=null!=v?v:c)?n:-1),y=u.useRef(null),w=ke(l),E=ke(s),R=H(f),x=H(m);return p((()=>{r&&(clearTimeout(g.current),y.current=null,h.current="")}),[r]),p((()=>{var e;r&&""===h.current&&(b.current=null!=(e=null!=v?v:c)?e:-1)}),[r,v,c]),u.useMemo((()=>{if(!a)return{};function e(e){e?o.current.typing||(o.current.typing=e,E(e)):o.current.typing&&(o.current.typing=e,E(e))}function t(e,t,n){const r=R.current?R.current(t,n):t.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(n.toLocaleLowerCase()))));return r?e.indexOf(r):-1}function n(n){const o=i.current;if(h.current.length>0&&" "!==h.current[0]&&(-1===t(o,o,h.current)?e(!1):" "===n.key&&J(n)),null==o||x.current.includes(n.key)||1!==n.key.length||n.ctrlKey||n.metaKey||n.altKey)return;r&&" "!==n.key&&(J(n),e(!0));o.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&h.current===n.key&&(h.current="",b.current=y.current),h.current+=n.key,clearTimeout(g.current),g.current=setTimeout((()=>{h.current="",b.current=y.current,e(!1)}),d);const u=b.current,c=t(o,[...o.slice((u||0)+1),...o.slice(0,(u||0)+1)],h.current);-1!==c?(w(c),y.current=c):(h.current="",e(!1))}return{reference:{onKeyDown:n},floating:{onKeyDown:n}}}),[a,r,o,i,d,x,R,w,E])};function Ge(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const Qe=e=>({name:"inner",options:e,async fn(t){const{listRef:o,overflowRef:u,onFallbackChange:i,offset:c=0,index:l=0,minItemsVisible:s=4,referenceOverflowThreshold:a=0,scrollRef:f,...m}=e,{rects:p,elements:{floating:v}}=t,g=o.current[l];if(!g)return{};const h={...t,...await n(-g.offsetTop-p.reference.height/2-g.offsetHeight/2-c).fn(t)},b=(null==f?void 0:f.current)||v,y=await r(Ge(h,b.scrollHeight),m),w=await r(h,{...m,elementContext:"reference"}),E=Math.max(0,y.top),R=h.y+E,x=Math.max(0,b.scrollHeight-E-Math.max(0,y.bottom));return b.style.maxHeight=x+"px",b.scrollTop=E,i&&(b.offsetHeight<g.offsetHeight*Math.min(s,o.current.length-1)-1||w.top>=-a||w.bottom>=-a?d((()=>i(!0))):d((()=>i(!1)))),u&&(u.current=await r(Ge({...h,y:R},b.offsetHeight),m)),{y:R}}}),Je=(e,t)=>{let{open:n,elements:r}=e,{enabled:o=!0,overflowRef:i,scrollRef:c,onChange:l}=t;const s=ke(l),a=u.useRef(!1),f=u.useRef(null),m=u.useRef(null);return u.useEffect((()=>{if(!o)return;function e(e){if(e.ctrlKey||!t||null==i.current)return;const n=e.deltaY,r=i.current.top>=-.5,o=i.current.bottom>=-.5,u=t.scrollHeight-t.clientHeight,c=n<0?-1:1,l=n<0?"max":"min";t.scrollHeight<=t.clientHeight||(!r&&n>0||!o&&n<0?(e.preventDefault(),d((()=>{s((e=>e+Math[l](n,u*c)))}))):/firefox/i.test(L())&&(t.scrollTop+=n))}const t=(null==c?void 0:c.current)||r.floating;return n&&t?(t.addEventListener("wheel",e),requestAnimationFrame((()=>{f.current=t.scrollTop,null!=i.current&&(m.current={...i.current})})),()=>{f.current=null,m.current=null,t.removeEventListener("wheel",e)}):void 0}),[o,n,r.floating,i,c,s]),u.useMemo((()=>o?{floating:{onKeyDown(){a.current=!0},onWheel(){a.current=!1},onPointerMove(){a.current=!1},onScroll(){const e=(null==c?void 0:c.current)||r.floating;if(i.current&&e&&a.current){if(null!==f.current){const t=e.scrollTop-f.current;(i.current.bottom<-.5&&t<-1||i.current.top<-.5&&t>1)&&d((()=>s((e=>e+t))))}requestAnimationFrame((()=>{f.current=e.scrollTop}))}}}}:{}),[o,i,r.floating,c,s])};function $e(e){let t,{buffer:n=.5,blockPointerEvents:r=!1,requireIntent:o=!0}=void 0===e?{}:e,u=!1,i=!1,c=null,l=null,s=performance.now();const a=e=>{let{x:r,y:a,placement:f,elements:d,onClose:m,nodeId:p,tree:v}=e;return function(e){function g(){clearTimeout(t),m()}if(clearTimeout(t),!d.domReference||!d.floating||null==f||null==r||null==a)return;const{clientX:h,clientY:b}=e,y=[h,b],w=G(e),E="mouseleave"===e.type,R=B(d.floating,w),x=B(d.domReference,w),I=d.domReference.getBoundingClientRect(),k=d.floating.getBoundingClientRect(),C=f.split("-")[0],M=r>k.right-k.width/2,T=a>k.bottom-k.height/2,O=function(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}(y,I);if(R&&(i=!0,!E))return;if(x&&(i=!1),x&&!E)return void(i=!0);if(E&&A(e.relatedTarget)&&B(d.floating,e.relatedTarget))return;if(v&&Z(v.nodesRef.current,p).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if("top"===C&&a>=I.bottom-1||"bottom"===C&&a<=I.top+1||"left"===C&&r>=I.right-1||"right"===C&&r<=I.left+1)return g();let L=[];switch(C){case"top":L=[[k.left,I.top+1],[k.left,k.bottom-1],[k.right,k.bottom-1],[k.right,I.top+1]],u=h>=k.left&&h<=k.right&&b>=k.top&&b<=I.top+1;break;case"bottom":L=[[k.left,k.top+1],[k.left,I.bottom-1],[k.right,I.bottom-1],[k.right,k.top+1]],u=h>=k.left&&h<=k.right&&b>=I.bottom-1&&b<=k.bottom;break;case"left":L=[[k.right-1,k.bottom],[k.right-1,k.top],[I.left+1,k.top],[I.left+1,k.bottom]],u=h>=k.left&&h<=I.left+1&&b>=k.top&&b<=k.bottom;break;case"right":L=[[I.right-1,k.bottom],[I.right-1,k.top],[k.left+1,k.top],[k.left+1,k.bottom]],u=h>=I.right-1&&h<=k.right&&b>=k.top&&b<=k.bottom}const P=u?L:function(e){let[t,r]=e;const o=k.width>I.width,u=k.height>I.height;switch(C){case"top":return[[o?t+n/2:M?t+4*n:t-4*n,r+n+1],[o?t-n/2:M?t+4*n:t-4*n,r+n+1],...[[k.left,M||o?k.bottom-n:k.top],[k.right,M?o?k.bottom-n:k.top:k.bottom-n]]];case"bottom":return[[o?t+n/2:M?t+4*n:t-4*n,r-n],[o?t-n/2:M?t+4*n:t-4*n,r-n],...[[k.left,M||o?k.top+n:k.bottom],[k.right,M?o?k.top+n:k.bottom:k.top+n]]];case"left":{const e=[t+n+1,u?r+n/2:T?r+4*n:r-4*n],o=[t+n+1,u?r-n/2:T?r+4*n:r-4*n];return[...[[T||u?k.right-n:k.left,k.top],[T?u?k.right-n:k.left:k.right-n,k.bottom]],e,o]}case"right":return[[t-n,u?r+n/2:T?r+4*n:r-4*n],[t-n,u?r-n/2:T?r+4*n:r-4*n],...[[T||u?k.left+n:k.right,k.top],[T?u?k.left+n:k.right:k.left+n,k.bottom]]]}}([r,a]);if(!u){if(i&&!O)return g();if(!E&&o){const t=function(e,t){const n=performance.now(),r=n-s;if(null===c||null===l||0===r)return c=e,l=t,s=n,null;const o=e-c,u=t-l,i=Math.sqrt(o*o+u*u);return c=e,l=t,s=n,i/r}(e.clientX,e.clientY),n=.1;if(null!==t&&t<n)return g()}!function(e,t){const[n,r]=e;let o=!1;const u=t.length;for(let e=0,i=u-1;e<u;i=e++){const[u,c]=t[e]||[0,0],[l,s]=t[i]||[0,0];c>=r!=s>=r&&n<=(l-u)*(r-c)/(s-c)+u&&(o=!o)}return o}([h,b],P)?g():!i&&o&&(t=window.setTimeout(g,40))}}};return a.__options={blockPointerEvents:r},a}function et(e){void 0===e&&(e={});const{open:t=!1,onOpenChange:n,nodeId:r}=e,i=o(e),c=I(),l=u.useRef(null),s=u.useRef({}),a=u.useState((()=>w()))[0],f=b(),[d,m]=u.useState(null),v=u.useCallback((e=>{const t=A(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),contextElement:e}:e;i.refs.setReference(t)}),[i.refs]),g=u.useCallback((e=>{(A(e)||null===e)&&(l.current=e,m(e)),(A(i.refs.reference.current)||null===i.refs.reference.current||null!==e&&!A(e))&&i.refs.setReference(e)}),[i.refs]),h=u.useMemo((()=>({...i.refs,setReference:g,setPositionReference:v,domReference:l})),[i.refs,g,v]),y=u.useMemo((()=>({...i.elements,domReference:d})),[i.elements,d]),E=ke(n),R=u.useMemo((()=>({...i,refs:h,elements:y,dataRef:s,nodeId:r,floatingId:f,events:a,open:t,onOpenChange:E})),[i,r,f,a,t,E,h,y]);return p((()=>{const e=null==c?void 0:c.nodesRef.current.find((e=>e.id===r));e&&(e.context=R)})),u.useMemo((()=>({...i,context:R,refs:h,elements:y,reference:g,positionReference:v})),[i,h,y,R,g,v])}function tt(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];return null==(e=r.get(n))?void 0:e.map((e=>e(...o))).find((e=>void 0!==e))})):e[n]=o})),e):e),{})}}const nt=function(e){void 0===e&&(e=[]);const t=e,n=u.useCallback((t=>tt(t,e,"reference")),t),r=u.useCallback((t=>tt(t,e,"floating")),t),o=u.useCallback((t=>tt(t,e,"item")),e.map((e=>null==e?void 0:e.item)));return u.useMemo((()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:o})),[n,r,o])};export{y as FloatingArrow,U as FloatingDelayGroup,pe as FloatingFocusManager,he as FloatingList,C as FloatingNode,we as FloatingOverlay,fe as FloatingPortal,M as FloatingTree,Qe as inner,$e as safePolygon,xe as useClick,Me as useClientPoint,V as useDelayGroup,W as useDelayGroupContext,Pe as useDismiss,et as useFloating,k as useFloatingNodeId,x as useFloatingParentNodeId,ae as useFloatingPortalNode,I as useFloatingTree,Ae as useFocus,q as useHover,b as useId,Je as useInnerOffset,nt as useInteractions,be as useListItem,je as useListNavigation,We as useMergeRefs,Ue as useRole,Ye as useTransitionStatus,ze as useTransitionStyles,Ze as useTypeahead}; |
@@ -1,1 +0,1 @@ | ||
!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);function i(){return i=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},i.apply(this,arguments)}var c="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;let l=!1,s=0;const a=()=>"floating-ui-"+s++;const f=u["useId".toString()]||function(){const[e,t]=u.useState((()=>l?a():void 0));return c((()=>{null==e&&t(a())}),[]),u.useEffect((()=>{l||(l=!0)}),[]),e},d=u.forwardRef((function(e,n){var r;let{context:{placement:o,elements:{floating:c},middlewareData:{arrow:l}},width:s=14,height:a=7,tipRadius:d=0,strokeWidth:m=0,staticOffset:p,stroke:v,d:g,...h}=e;m*=2;const y=m/2,b=s/2*(d/-8+1),E=a/2*d/4,[w,R]=o.split("-"),x=!!c&&t.platform.isRTL(c),I=!!g,k="top"===w||"bottom"===w,O=p&&"end"===R?"bottom":"top";let M=p&&"end"===R?"right":"left";p&&x&&(M="end"===R?"left":"right");const P=I?0:y,T=null!=(null==l?void 0:l.x)?p||l.x:"",S=null!=(null==l?void 0:l.y)?p||l.y+P:"",C=g||"M0,0 H"+s+" L"+(s-b)+","+(a-E)+" Q"+s/2+","+a+" "+b+","+(a-E)+" Z",A={top:I?"rotate(180deg)":"",left:I?"rotate(90deg)":"rotate(-90deg)",bottom:I?"":"rotate(180deg)",right:I?"rotate(-90deg)":"rotate(90deg)"}[w],L=f();return u.createElement("svg",i({},h,{suppressHydrationWarning:!0,"aria-hidden":!0,ref:n,width:I?s:s+m,height:s,viewBox:"0 0 "+s+" "+(a>s?a:s),style:{...h.style,position:"absolute",pointerEvents:"none",[M]:T,[O]:S,[w]:k||I?"100%":"calc(100% - "+m/2+"px)",transform:A+(null!=(r=h.style)&&r.transform?" "+h.style.transform:"")}}),m>0&&u.createElement("path",{clipPath:"url(#"+L+")",fill:"none",stroke:v,strokeWidth:m+(g?0:1),d:C}),u.createElement("path",{stroke:m&&!g?h.fill:"none",d:C}),u.createElement("clipPath",{id:L},u.createElement("rect",{x:-y,y:y*(I?-1:1),width:s+m,height:s})))}));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){var r;e.set(t,(null==(r=e.get(t))?void 0:r.filter((e=>e!==n)))||[])}}}const p=u.createContext(null),v=u.createContext(null),g=()=>{var e;return(null==(e=u.useContext(p))?void 0:e.id)||null},h=()=>u.useContext(v);function y(e){return(null==e?void 0:e.ownerDocument)||document}function b(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}function E(){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){return y(e).defaultView||window}function R(e){return!!e&&e instanceof w(e).Element}function x(e){return!!e&&e instanceof w(e).HTMLElement}function I(e){if(0===e.mozInputSource&&e.isTrusted)return!0;const t=/Android/i;return(t.test(b())||t.test(E()))&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType}function k(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 O(){return/apple/i.test(navigator.vendor)}function M(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function P(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;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}var r;return!1}function T(e){const t=n.useRef(e);return c((()=>{t.current=e})),t}const S="data-floating-ui-safe-polygon";function C(e,t,n){return n&&!M(n)?0:"number"==typeof e?e:null==e?void 0:e[t]}const A=u.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:()=>{},setState:()=>{},isInstantPhase:!1}),L=()=>u.useContext(A);var D=new WeakMap,F=new WeakMap,N={},j=0,K=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];N[n]||(N[n]=new WeakMap);var o=N[n],u=[],i=new Set,c=function(e){e&&!i.has(e)&&(i.add(e),c(e.parentNode))};r.forEach(c);var l=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(i.has(e))l(e);else{var t=e.getAttribute("aria-hidden"),r=null!==t&&"false"!==t,c=(D.get(e)||0)+1,s=(o.get(e)||0)+1;D.set(e,c),o.set(e,s),u.push(e),1===c&&r&&F.set(e,!0),1===s&&e.setAttribute(n,"true"),r||e.setAttribute("aria-hidden","true")}}))};return l(t),i.clear(),j++,function(){u.forEach((function(e){var t=D.get(e)-1,r=o.get(e)-1;D.set(e,t),o.set(e,r),t||(F.has(e)||e.removeAttribute("aria-hidden"),F.delete(e)),r||e.removeAttribute(n)})),--j||(D=new WeakMap,D=new WeakMap,F=new WeakMap,N={})}},B=["input","select","textarea","a[href]","button","[tabindex]:not(slot)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"].join(","),H="undefined"==typeof Element,W=H?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,q=!H&&Element.prototype.getRootNode?function(e){return e.getRootNode()}:function(e){return e.ownerDocument},_=function e(t,n,r){for(var o=[],u=Array.from(t);u.length;){var i=u.shift();if("SLOT"===i.tagName){var c=i.assignedElements(),l=e(c.length?c:i.children,!0,r);r.flatten?o.push.apply(o,l):o.push({scopeParent:i,candidates:l})}else{W.call(i,B)&&r.filter(i)&&(n||!t.includes(i))&&o.push(i);var s=i.shadowRoot||"function"==typeof r.getShadowRoot&&r.getShadowRoot(i),a=!r.shadowRootFilter||r.shadowRootFilter(i);if(s&&a){var f=e(!0===s?i.children:s.children,!0,r);r.flatten?o.push.apply(o,f):o.push({scopeParent:i,candidates:f})}else u.unshift.apply(u,i.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},z=function(e){return function(e){return X(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||q(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)},Y=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=W.call(e,"details>summary:first-of-type")?e.parentElement:e;if(W.call(o,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return Y(e)}else{if("function"==typeof r){for(var u=e;e;){var i=e.parentElement,c=q(e);if(i&&!i.shadowRoot&&!0===r(i))return Y(e);e=e.assignedSlot?e.assignedSlot:i||c===e.ownerDocument?i:c.host}e=u}if(function(e){for(var t,n=q(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=q(n).host)||void 0===o||!o.ownerDocument.contains(n))}return r}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},Z=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!!W.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},$=function(e,t){return!(z(t)||U(t)<0||!Z(e,t))},Q=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},J=function e(t){var n=[],r=[];return t.forEach((function(t,o){var u=!!t.scopeParent,i=u?t.scopeParent:t,c=U(i,u),l=u?e(t.candidates):i;0===c?u?n.push.apply(n,l):n.push(i):r.push({documentOrder:o,tabIndex:c,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?_([e],t.includeContainer,{filter:$.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:Q}):function(e,t,n){var r=Array.prototype.slice.apply(e.querySelectorAll(B));return t&&W.call(e,B)&&r.unshift(e),r.filter(n)}(e,t.includeContainer,$.bind(null,t)),J(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}let ne=0;function re(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(ne);const u=()=>null==e?void 0:e.focus({preventScroll:n});o?u():ne=requestAnimationFrame(u)}function oe(e,t){let n=e.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})),r=n;for(;r.length;)r=e.filter((e=>{var t;return null==(t=r)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})),n=n.concat(r);return n}function ue(e){return"composedPath"in e?e.composedPath()[0]:e.target}function ie(e){return x(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function ce(e){e.preventDefault(),e.stopPropagation()}const le=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function se(e,t){const n=ee(e,le());"prev"===t&&n.reverse();const r=n.indexOf(te(y(e)));return n.slice(r+1)[0]}function ae(){return se(document.body,"next")}function fe(){return se(document.body,"prev")}function de(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!P(n,r)}function me(e){ee(e,le()).forEach((e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")}))}function pe(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 ve={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};function ge(e){"Tab"===e.key&&(e.target,clearTimeout(undefined))}const he=u.forwardRef((function(e,t){const[n,r]=u.useState();return c((()=>(O()&&r("button"),document.addEventListener("keydown",ge),()=>{document.removeEventListener("keydown",ge)})),[]),u.createElement("span",i({},e,{ref:t,tabIndex:0,role:n,"aria-hidden":!n||void 0,"data-floating-ui-focus-guard":"",style:ve}))})),ye=u.createContext(null),be=function(e){let{id:t,root:n}=void 0===e?{}:e;const[r,o]=u.useState(null),i=f(),l=Ee();return c((()=>{const e=t?document.getElementById(t):null,r="data-floating-ui-portal";if(e){const t=document.createElement("div");return t.id=i,t.setAttribute(r,""),e.appendChild(t),o(t),()=>{t.remove()}}{let e=(null==l?void 0:l.portalNode)||n||document.body,u=null;t&&(u=document.createElement("div"),u.id=t,e.appendChild(u));const c=document.createElement("div");return c.id=i,c.setAttribute(r,""),o(c),e=u||e,e.appendChild(c),()=>{var e;c.remove(),null==(e=u)||e.remove()}}}),[t,n,l,i]),r},Ee=()=>u.useContext(ye),we=u.forwardRef((function(e,t){return u.createElement("button",i({},e,{type:"button",ref:t,tabIndex:-1,style:ve}))}));const Re="data-floating-ui-scroll-lock",xe=u.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return c((()=>{var e,t;if(!n)return;if(document.body.hasAttribute(Re))return;document.body.setAttribute(Re,"");const r=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(b()))return Object.assign(document.body.style,{overflow:"hidden",[r]:o+"px"}),()=>{document.body.removeAttribute(Re),Object.assign(document.body.style,{overflow:"",[r]:""})};const u=(null==(e=window.visualViewport)?void 0:e.offsetLeft)||0,i=(null==(t=window.visualViewport)?void 0:t.offsetTop)||0,c=window.pageXOffset,l=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(l-Math.floor(i))+"px",left:-(c-Math.floor(u))+"px",right:"0",[r]:o+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[r]:""}),document.body.removeAttribute(Re),window.scrollTo(c,l)}}),[n]),u.createElement("div",i({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));function Ie(e){return x(e.target)&&"BUTTON"===e.target.tagName}function ke(e){return ie(e)}const Oe=u["useInsertionEffect".toString()]||(e=>e());function Me(e){const t=u.useRef((()=>{}));return Oe((()=>{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 Pe(e){return null!=e&&null!=e.clientX}function Te(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"},Ce={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"};let Ae=!1;const Le="ArrowUp",De="ArrowDown",Fe="ArrowLeft",Ne="ArrowRight";function je(e,t,n){return Math.floor(e/t)!==n}function Ke(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 i=e.current;let c=n;do{var l,s;c+=r?-u:u}while(c>=0&&c<=i.length-1&&(o?o.includes(c):null==i[c]||(null==(l=i[c])?void 0:l.hasAttribute("disabled"))||"true"===(null==(s=i[c])?void 0:s.getAttribute("aria-disabled"))));return c}function He(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function We(e,t){return He(t,e===Le||e===De,e===Fe||e===Ne)}function qe(e,t,n){return He(t,e===De,n?e===Fe:e===Ne)||"Enter"===e||" "==e||""===e}function _e(e,t){return Be(e,{disabledIndices:t})}function Ue(e,t){return Be(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}const Ve=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,((e,t)=>(t?"-":"")+e.toLowerCase()));function Xe(e,t){return"function"==typeof e?e(t):e}function ze(e,t){void 0===t&&(t={});const{open:n,elements:{floating:r}}=e,{duration:o=250}=t,i=("number"==typeof o?o:o.close)||0,[l,s]=u.useState(!1),[a,f]=u.useState("unmounted"),d=function(e,t){const[n,r]=u.useState(e);return e&&!n&&r(!0),u.useEffect((()=>{if(!e){const e=setTimeout((()=>r(!1)),t);return()=>clearTimeout(e)}}),[e,t]),n}(n,i);return c((()=>{l&&!d&&f("unmounted")}),[l,d]),c((()=>{if(r){if(n){f("initial");const e=requestAnimationFrame((()=>{f("open")}));return()=>{cancelAnimationFrame(e)}}s(!0),f("close")}}),[n,r]),{isMounted:d,status:a}}function Ye(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}function Ge(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];return null==(e=r.get(n))?void 0:e.map((e=>e(...o))).find((e=>void 0!==e))})):e[n]=o})),e):e),{})}}Object.defineProperty(e,"arrow",{enumerable:!0,get:function(){return t.arrow}}),Object.defineProperty(e,"autoPlacement",{enumerable:!0,get:function(){return t.autoPlacement}}),Object.defineProperty(e,"autoUpdate",{enumerable:!0,get:function(){return t.autoUpdate}}),Object.defineProperty(e,"computePosition",{enumerable:!0,get:function(){return t.computePosition}}),Object.defineProperty(e,"detectOverflow",{enumerable:!0,get:function(){return t.detectOverflow}}),Object.defineProperty(e,"flip",{enumerable:!0,get:function(){return t.flip}}),Object.defineProperty(e,"getOverflowAncestors",{enumerable:!0,get:function(){return t.getOverflowAncestors}}),Object.defineProperty(e,"hide",{enumerable:!0,get:function(){return t.hide}}),Object.defineProperty(e,"inline",{enumerable:!0,get:function(){return t.inline}}),Object.defineProperty(e,"limitShift",{enumerable:!0,get:function(){return t.limitShift}}),Object.defineProperty(e,"offset",{enumerable:!0,get:function(){return t.offset}}),Object.defineProperty(e,"platform",{enumerable:!0,get:function(){return t.platform}}),Object.defineProperty(e,"shift",{enumerable:!0,get:function(){return t.shift}}),Object.defineProperty(e,"size",{enumerable:!0,get:function(){return t.size}}),e.FloatingArrow=d,e.FloatingDelayGroup=e=>{let{children:t,delay:n,timeoutMs:r=0}=e;const[o,i]=u.useReducer(((e,t)=>({...e,...t})),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),l=u.useRef(null),s=u.useCallback((e=>{i({currentId:e})}),[]);return c((()=>{o.currentId?null===l.current?l.current=o.currentId:i({isInstantPhase:!0}):(i({isInstantPhase:!1}),l.current=null)}),[o.currentId]),u.createElement(A.Provider,{value:u.useMemo((()=>({...o,setState:i,setCurrentId:s})),[o,i,s])},t)},e.FloatingFocusManager=function(e){let{context:t,children:n,order:r=["content"],guards:o=!0,initialFocus:i=0,returnFocus:l=!0,modal:s=!0,visuallyHiddenDismiss:a=!1,closeOnFocusOut:f=!0}=e;const{open:d,refs:m,nodeId:p,onOpenChange:v,events:g,dataRef:b,elements:{domReference:E,floating:w}}=t,R=T(r),I=T(i),k=T(l),O=h(),M=Ee(),[S,C]=u.useState(null),A="number"==typeof i&&i<0,L=u.useRef(null),D=u.useRef(null),F=u.useRef(!1),N=u.useRef(null),j=u.useRef(!1),B=null!=M,H=E&&"combobox"===E.getAttribute("role")&&ie(E),W=u.useCallback((function(e){return void 0===e&&(e=w),e?ee(e,le()):[]}),[w]),q=u.useCallback((e=>{const t=W(e);return R.current.map((e=>E&&"reference"===e?E:w&&"floating"===e?w:t)).filter(Boolean).flat()}),[E,w,R,W]);u.useEffect((()=>{if(!s)return;function e(e){if("Tab"===e.key){0!==W().length||H||ce(e);const t=q(),n=ue(e);"reference"===R.current[0]&&n===E&&(ce(e),e.shiftKey?re(t[t.length-1]):re(t[1])),"floating"===R.current[1]&&n===w&&e.shiftKey&&(ce(e),re(t[0]))}}const t=y(w);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[E,w,s,R,m,H,W,q]),u.useEffect((()=>{if(f)return w&&x(E)?(E.addEventListener("focusout",t),E.addEventListener("pointerdown",e),!s&&w.addEventListener("focusout",t),()=>{E.removeEventListener("focusout",t),E.removeEventListener("pointerdown",e),!s&&w.removeEventListener("focusout",t)}):void 0;function e(){j.current=!0,setTimeout((()=>{j.current=!1}))}function t(e){const t=e.relatedTarget;queueMicrotask((()=>{const e=!(P(E,t)||P(w,t)||P(t,w)||P(null==M?void 0:M.portalNode,t)||null!=t&&t.hasAttribute("data-floating-ui-focus-guard")||O&&(oe(O.nodesRef.current,p).find((e=>{var n,r;return P(null==(n=e.context)?void 0:n.elements.floating,t)||P(null==(r=e.context)?void 0:r.elements.domReference,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}(O.nodesRef.current,p).find((e=>{var n,r;return(null==(n=e.context)?void 0:n.elements.floating)===t||(null==(r=e.context)?void 0:r.elements.domReference)===t}))));t&&e&&!j.current&&t!==N.current&&(F.current=!0,v(!1))}))}}),[E,w,s,p,O,M,v,f]),u.useEffect((()=>{var e;const t=Array.from((null==M||null==(e=M.portalNode)?void 0:e.querySelectorAll("[data-floating-ui-portal]"))||[]);if(w&&s){const e=[w,...t,...[L.current,D.current].filter(Boolean)],n=K(R.current.includes("reference")||H?e.concat(E||[]):e);return()=>{n()}}}),[E,w,s,R,M,H]),u.useEffect((()=>{if(s&&!o&&w){const e=[],t=le(),n=ee(y(w).body,t),r=q(),o=n.filter((e=>!r.includes(e)));return o.forEach(((t,n)=>{e[n]=t.getAttribute("tabindex"),t.setAttribute("tabindex","-1")})),()=>{o.forEach(((t,n)=>{const r=e[n];null==r?t.removeAttribute("tabindex"):t.setAttribute("tabindex",r)}))}}}),[w,s,o,q]),c((()=>{if(!w)return;let e=!1;const t=y(w),n=te(t),r=b.current;function o(t){if("escapeKey"===t.type&&m.domReference.current&&(N.current=m.domReference.current),["referencePress","escapeKey"].includes(t.type))return;const n=t.data.returnFocus;"object"==typeof n?(F.current=!1,e=n.preventScroll):F.current=!n}return N.current=n,queueMicrotask((()=>{const e=q(w),t=I.current,r=("number"==typeof t?e[t]:t.current)||w,o=P(w,n);A||o||!d||re(r,{preventScroll:r===w})})),g.on("dismiss",o),()=>{g.off("dismiss",o);const n=te(t);(P(w,n)||O&&oe(O.nodesRef.current,p).some((e=>{var t;return P(null==(t=e.context)?void 0:t.elements.floating,n)}))||r.openEvent&&["click","mousedown"].includes(r.openEvent.type))&&m.domReference.current&&(N.current=m.domReference.current),k.current&&x(N.current)&&!F.current&&re(N.current,{cancelPrevious:!1,preventScroll:e})}}),[d,w,q,k,I,b,m,g,A,O,p]),c((()=>{if(M)return M.setFocusManagerState({...t,modal:s,closeOnFocusOut:f}),()=>{M.setFocusManagerState(null)}}),[M,s,f,t]),c((()=>{if(!A&&w&&(e(),"function"==typeof MutationObserver)){const t=new MutationObserver(e);return t.observe(w,{childList:!0,subtree:!0}),()=>{t.disconnect()}}function e(){te(y(w))!==m.domReference.current&&C(W().length)}}),[w,W,A,m]);const _=o&&(B||s)&&!H;function U(e){return a&&s?u.createElement(we,{ref:"start"===e?L:D,onClick:()=>v(!1)},"string"==typeof a?a:"Dismiss"):null}return u.createElement(u.Fragment,null,_&&u.createElement(he,{"data-type":"inside",ref:null==M?void 0:M.beforeInsideRef,onFocus:e=>{if(s){const e=q();re("reference"===r[0]?e[0]:e[e.length-1])}else if(null!=M&&M.preserveTabOrder&&M.portalNode)if(F.current=!1,de(e,M.portalNode)){const e=ae()||E;null==e||e.focus()}else{var t;null==(t=M.beforeOutsideRef.current)||t.focus()}}}),H?null:U("start"),u.cloneElement(n,0===S||r.includes("floating")?{tabIndex:0}:{}),U("end"),_&&u.createElement(he,{"data-type":"inside",ref:null==M?void 0:M.afterInsideRef,onFocus:e=>{if(s)re(q()[0]);else if(null!=M&&M.preserveTabOrder&&M.portalNode)if(f&&(F.current=!0),de(e,M.portalNode)){const e=fe()||E;null==e||e.focus()}else{var t;null==(t=M.afterOutsideRef.current)||t.focus()}}}))},e.FloatingNode=e=>{let{children:t,id:n}=e;const r=g();return u.createElement(p.Provider,{value:u.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},e.FloatingOverlay=xe,e.FloatingPortal=e=>{let{children:t,id:n,root:o=null,preserveTabOrder:i=!0}=e;const c=be({id:n,root:o}),[l,s]=u.useState(null),a=u.useRef(null),f=u.useRef(null),d=u.useRef(null),m=u.useRef(null),p=!!l&&!l.modal&&!(!o&&!c)&&i;return u.useEffect((()=>{if(c&&i&&(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&&de(e)){("focusin"===e.type?pe:me)(c)}}}),[c,i,null==l?void 0:l.modal]),u.createElement(ye.Provider,{value:u.useMemo((()=>({preserveTabOrder:i,beforeOutsideRef:a,afterOutsideRef:f,beforeInsideRef:d,afterInsideRef:m,portalNode:c,setFocusManagerState:s})),[i,c])},p&&c&&u.createElement(he,{"data-type":"outside",ref:a,onFocus:e=>{if(de(e,c)){var t;null==(t=d.current)||t.focus()}else{const e=fe()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus()}}}),p&&c&&u.createElement("span",{"aria-owns":c.id,style:ve}),c&&r.createPortal(t,c),p&&c&&u.createElement(he,{"data-type":"outside",ref:f,onFocus:e=>{if(de(e,c)){var t;null==(t=m.current)||t.focus()}else{const e=ae()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus(),(null==l?void 0:l.closeOnFocusOut)&&(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))}),[]),i=u.useState((()=>m()))[0];return u.createElement(v.Provider,{value:u.useMemo((()=>({nodesRef:n,addNode:r,removeNode:o,events:i})),[n,r,o,i])},t)},e.inner=e=>({name:"inner",options:e,async fn(n){const{listRef:o,overflowRef:u,onFallbackChange:i,offset:c=0,index:l=0,minItemsVisible:s=4,referenceOverflowThreshold:a=0,scrollRef:f,...d}=e,{rects:m,elements:{floating:p}}=n,v=o.current[l];if(!v)return{};const g={...n,...await t.offset(-v.offsetTop-m.reference.height/2-v.offsetHeight/2-c).fn(n)},h=(null==f?void 0:f.current)||p,y=await t.detectOverflow(Ye(g,h.scrollHeight),d),b=await t.detectOverflow(g,{...d,elementContext:"reference"}),E=Math.max(0,y.top),w=g.y+E,R=Math.max(0,h.scrollHeight-E-Math.max(0,y.bottom));return h.style.maxHeight=R+"px",h.scrollTop=E,i&&(h.offsetHeight<v.offsetHeight*Math.min(s,o.current.length-1)-1||b.top>=-a||b.bottom>=-a?r.flushSync((()=>i(!0))):r.flushSync((()=>i(!1)))),u&&(u.current=await t.detectOverflow(Ye({...g,y:w},h.offsetHeight),d)),{y:w}}}),e.safePolygon=function(e){let t,{restMs:n=0,buffer:r=.5,blockPointerEvents:o=!1}=void 0===e?{}:e,u=!1,i=!1;const c=e=>{let{x:o,y:c,placement:l,elements:s,onClose:a,nodeId:f,tree:d}=e;return function(e){function m(){clearTimeout(t),a()}if(clearTimeout(t),!s.domReference||!s.floating||null==l||null==o||null==c)return;const{clientX:p,clientY:v}=e,g=[p,v],h=ue(e),y="mouseleave"===e.type,b=P(s.floating,h),E=P(s.domReference,h),w=s.domReference.getBoundingClientRect(),x=s.floating.getBoundingClientRect(),I=l.split("-")[0],k=o>x.right-x.width/2,O=c>x.bottom-x.height/2,M=function(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}(g,w);if(b&&(i=!0,!y))return;if(E&&(i=!1),E&&!y)return void(i=!0);if(y&&R(e.relatedTarget)&&P(s.floating,e.relatedTarget))return;if(d&&oe(d.nodesRef.current,f).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if("top"===I&&c>=w.bottom-1||"bottom"===I&&c<=w.top+1||"left"===I&&o>=w.right-1||"right"===I&&o<=w.left+1)return m();let T=[];switch(I){case"top":T=[[x.left,w.top+1],[x.left,x.bottom-1],[x.right,x.bottom-1],[x.right,w.top+1]],u=p>=x.left&&p<=x.right&&v>=x.top&&v<=w.top+1;break;case"bottom":T=[[x.left,x.top+1],[x.left,w.bottom-1],[x.right,w.bottom-1],[x.right,x.top+1]],u=p>=x.left&&p<=x.right&&v>=w.bottom-1&&v<=x.bottom;break;case"left":T=[[x.right-1,x.bottom],[x.right-1,x.top],[w.left+1,x.top],[w.left+1,x.bottom]],u=p>=x.left&&p<=w.left+1&&v>=x.top&&v<=x.bottom;break;case"right":T=[[w.right-1,x.bottom],[w.right-1,x.top],[x.left+1,x.top],[x.left+1,x.bottom]],u=p>=w.right-1&&p<=x.right&&v>=x.top&&v<=x.bottom}const S=u?T:function(e){let[t,n]=e;const o=x.width>w.width,u=x.height>w.height;switch(I){case"top":return[[o?t+r/2:k?t+4*r:t-4*r,n+r+1],[o?t-r/2:k?t+4*r:t-4*r,n+r+1],...[[x.left,k||o?x.bottom-r:x.top],[x.right,k?o?x.bottom-r:x.top:x.bottom-r]]];case"bottom":return[[o?t+r/2:k?t+4*r:t-4*r,n-r],[o?t-r/2:k?t+4*r:t-4*r,n-r],...[[x.left,k||o?x.top+r:x.bottom],[x.right,k?o?x.top+r:x.bottom:x.top+r]]];case"left":{const e=[t+r+1,u?n+r/2:O?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:O?n+4*r:n-4*r];return[...[[O||u?x.right-r:x.left,x.top],[O?u?x.right-r:x.left:x.right-r,x.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:O?n+4*r:n-4*r],[t-r,u?n-r/2:O?n+4*r:n-4*r],...[[O||u?x.left+r:x.right,x.top],[O?u?x.left+r:x.right:x.left+r,x.bottom]]]}}([o,c]);return u?void 0:i&&!M?m():void(!function(e,t){const[n,r]=e;let o=!1;const u=t.length;for(let e=0,i=u-1;e<u;i=e++){const[u,c]=t[e]||[0,0],[l,s]=t[i]||[0,0];c>=r!=s>=r&&n<=(l-u)*(r-c)/(s-c)+u&&(o=!o)}return o}([p,v],S)?m():n&&!i&&(t=setTimeout(m,n)))}};return c.__options={blockPointerEvents:o},c},e.useClick=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,elements:{domReference:i}}=e,{enabled:c=!0,event:l="click",toggle:s=!0,ignoreMouse:a=!1,keyboardHandlers:f=!0}=t,d=u.useRef();return u.useMemo((()=>c?{reference:{onPointerDown(e){d.current=e.pointerType},onMouseDown(e){0===e.button&&(M(d.current,!0)&&a||"click"!==l&&(n?!s||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:M(d.current,!0)&&a||(n?!s||o.current.openEvent&&"click"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent)},onKeyDown(e){d.current=void 0,f&&(Ie(e)||(" "!==e.key||ke(i)||e.preventDefault(),"Enter"===e.key&&(n?s&&r(!1):r(!0))))},onKeyUp(e){f&&(Ie(e)||ke(i)||" "===e.key&&(n?s&&r(!1):r(!0)))}}}:{}),[c,o,l,a,f,i,s,n,r])},e.useClientPoint=function(e,t){let{open:n,refs:r,dataRef:o,elements:{floating:i}}=e,{enabled:l=!0,axis:s="both",x:a=null,y:f=null}=void 0===t?{}:t;const d=u.useRef(!1),m=u.useRef(null),[p,v]=u.useState(),[g,h]=u.useState([]),y=Me(((e,t)=>{d.current||o.current.openEvent&&!Pe(o.current.openEvent)||r.setPositionReference(function(e,t){let n=null,r=null,o=!1;return{contextElement:e.current||void 0,getBoundingClientRect(){var u,i;const c=(null==(u=e.current)?void 0:u.getBoundingClientRect())||{width:0,height:0,x:0,y:0},l="x"===t.axis||"both"===t.axis,s="y"===t.axis||"both"===t.axis,a=["mouseenter","mousemove"].includes((null==(i=t.dataRef.current.openEvent)?void 0:i.type)||"")&&"touch"!==t.pointerType;let f=c.width,d=c.height,m=c.x,p=c.y;return null==n&&t.x&&l&&(n=c.x-t.x),null==r&&t.y&&s&&(r=c.y-t.y),m-=n||0,p-=r||0,f=0,d=0,!o||a?(f="y"===t.axis?c.width:0,d="x"===t.axis?c.height:0,m=l&&null!=t.x?t.x:m,p=s&&null!=t.y?t.y:p):o&&!a&&(d="x"===t.axis?c.height:d,f="y"===t.axis?c.width:f),o=!0,{width:f,height:d,x:m,y:p,top:p,right:m+f,bottom:p+d,left:m}}}}(r.domReference,{x:e,y:t,axis:s,dataRef:o,pointerType:p}))})),b=Me((e=>{null==a&&null==f&&(n?m.current||h([]):y(e.clientX,e.clientY))})),E=M(p)?i:n,R=u.useCallback((()=>{if(!E||!l||null!=a||null!=f)return;const e=w(r.floating.current);function t(n){const o=ue(n);P(r.floating.current,o)?(e.removeEventListener("mousemove",t),m.current=null):y(n.clientX,n.clientY)}if(!o.current.openEvent||Pe(o.current.openEvent)){e.addEventListener("mousemove",t);const n=()=>{e.removeEventListener("mousemove",t),m.current=null};return m.current=n,n}r.setPositionReference(r.domReference.current)}),[o,l,E,r,y,a,f]);return u.useEffect((()=>R()),[R,g]),u.useEffect((()=>{l&&!i&&(d.current=!1)}),[l,i]),u.useEffect((()=>{!l&&n&&(d.current=!0)}),[l,n]),c((()=>{!l||null==a&&null==f||(d.current=!1,y(a,f))}),[l,a,f,y]),u.useMemo((()=>{if(!l)return{};function e(e){let{pointerType:t}=e;v(t)}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove:b,onMouseEnter:b}}}),[l,b])},e.useDelayGroup=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:o}=t;const{currentId:i,setCurrentId:c,initialDelay:l,setState:s,timeoutMs:a}=L();u.useEffect((()=>{i&&(s({delay:{open:1,close:C(l,"close")}}),i!==o&&r(!1))}),[o,r,s,i,l]),u.useEffect((()=>{function e(){r(!1),s({delay:l,currentId:null})}if(!n&&i===o){if(a){const t=window.setTimeout(e,a);return()=>{clearTimeout(t)}}e()}}),[n,s,i,o,r,l,a]),u.useEffect((()=>{n&&c(o)}),[n,c,o])},e.useDelayGroupContext=L,e.useDismiss=function(e,n){void 0===n&&(n={});const{open:r,onOpenChange:o,events:i,nodeId:c,elements:{reference:l,domReference:s,floating:a},dataRef:f}=e,{enabled:d=!0,escapeKey:m=!0,outsidePress:p=!0,outsidePressEvent:v="pointerdown",referencePress:b=!1,referencePressEvent:E="pointerdown",ancestorScroll:O=!1,bubbles:M}=n,P=h(),T=null!=g(),S=Me("function"==typeof p?p:()=>!1),C="function"==typeof p?S:p,A=u.useRef(!1),{escapeKeyBubbles:L,outsidePressBubbles:D}=(e=>{var t,n;return{escapeKeyBubbles:"boolean"==typeof e?e:null!=(t=null==e?void 0:e.escapeKey)&&t,outsidePressBubbles:"boolean"==typeof e?e:null==(n=null==e?void 0:e.outsidePress)||n}})(M),F=Me((e=>{if(!r||!d||!m||"Escape"!==e.key)return;const t=P?oe(P.nodesRef.current,c):[];if(!L&&(e.stopPropagation(),t.length>0)){let e=!0;if(t.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__escapeKeyBubbles||(e=!1)})),!e)return}i.emit("dismiss",{type:"escapeKey",data:{returnFocus:{preventScroll:!1}}}),o(!1)})),N=Me((e=>{const t=A.current;if(A.current=!1,t)return;if("function"==typeof C&&!C(e))return;const n=ue(e);if(x(n)&&a){const t=n.clientWidth>0&&n.scrollWidth>n.clientWidth,r=n.clientHeight>0&&n.scrollHeight>n.clientHeight;let o=r&&e.offsetX>n.clientWidth;if(r){"rtl"===w(a).getComputedStyle(n).direction&&(o=e.offsetX<=n.offsetWidth-n.clientWidth)}if(o||t&&e.offsetY>n.clientHeight)return}const r=P&&oe(P.nodesRef.current,c).some((t=>{var n;return Te(e,null==(n=t.context)?void 0:n.elements.floating)}));if(Te(e,a)||Te(e,s)||r)return;const u=P?oe(P.nodesRef.current,c):[];if(u.length>0){let e=!0;if(u.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__outsidePressBubbles||(e=!1)})),!e)return}i.emit("dismiss",{type:"outsidePress",data:{returnFocus:T?{preventScroll:!0}:I(e)||k(e)}}),o(!1)}));return u.useEffect((()=>{if(!r||!d)return;function e(){o(!1)}f.current.__escapeKeyBubbles=L,f.current.__outsidePressBubbles=D;const n=y(a);m&&n.addEventListener("keydown",F),C&&n.addEventListener(v,N);let u=[];return O&&(R(s)&&(u=t.getOverflowAncestors(s)),R(a)&&(u=u.concat(t.getOverflowAncestors(a))),!R(l)&&l&&l.contextElement&&(u=u.concat(t.getOverflowAncestors(l.contextElement)))),u=u.filter((e=>{var t;return e!==(null==(t=n.defaultView)?void 0:t.visualViewport)})),u.forEach((t=>{t.addEventListener("scroll",e,{passive:!0})})),()=>{m&&n.removeEventListener("keydown",F),C&&n.removeEventListener(v,N),u.forEach((t=>{t.removeEventListener("scroll",e)}))}}),[f,a,s,l,m,C,v,r,o,O,d,L,D,F,N]),u.useEffect((()=>{A.current=!1}),[C,v]),u.useMemo((()=>d?{reference:{onKeyDown:F,[Se[E]]:()=>{b&&(i.emit("dismiss",{type:"referencePress",data:{returnFocus:!1}}),o(!1))}},floating:{onKeyDown:F,[Ce[v]]:()=>{A.current=!0}}}:{}),[d,i,b,v,E,o,F])},e.useFloating=function(e){void 0===e&&(e={});const{open:n=!1,onOpenChange:r,nodeId:o}=e,i=t.useFloating(e),l=h(),s=u.useRef(null),a=u.useRef({}),d=u.useState((()=>m()))[0],p=f(),[v,g]=u.useState(null),y=u.useCallback((e=>{const t=R(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),contextElement:e}:e;i.refs.setReference(t)}),[i.refs]),b=u.useCallback((e=>{(R(e)||null===e)&&(s.current=e,g(e)),(R(i.refs.reference.current)||null===i.refs.reference.current||null!==e&&!R(e))&&i.refs.setReference(e)}),[i.refs]),E=u.useMemo((()=>({...i.refs,setReference:b,setPositionReference:y,domReference:s})),[i.refs,b,y]),w=u.useMemo((()=>({...i.elements,domReference:v})),[i.elements,v]),x=Me(r),I=u.useMemo((()=>({...i,refs:E,elements:w,dataRef:a,nodeId:o,floatingId:p,events:d,open:n,onOpenChange:x})),[i,o,p,d,n,x,E,w]);return c((()=>{const e=null==l?void 0:l.nodesRef.current.find((e=>e.id===o));e&&(e.context=I)})),u.useMemo((()=>({...i,context:I,refs:E,elements:w,reference:b,positionReference:y})),[i,E,w,I,b,y])},e.useFloatingNodeId=e=>{const t=f(),n=h(),r=g(),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=g,e.useFloatingPortalNode=be,e.useFloatingTree=h,e.useFocus=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,events:i,refs:c,elements:{floating:l,domReference:s}}=e,{enabled:a=!0,keyboardOnly:f=!0}=t,d=u.useRef(""),m=u.useRef(!1),p=u.useRef();return u.useEffect((()=>{if(!a)return;const e=y(l).defaultView||window;function t(){!n&&x(s)&&s===te(y(s))&&(m.current=!0)}return e.addEventListener("blur",t),()=>{e.removeEventListener("blur",t)}}),[l,s,n,a]),u.useEffect((()=>{if(a)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(e){"referencePress"!==e.type&&"escapeKey"!==e.type||(m.current=!0)}}),[i,a]),u.useEffect((()=>()=>{clearTimeout(p.current)}),[]),u.useMemo((()=>a?{reference:{onPointerDown(e){let{pointerType:t}=e;d.current=t,m.current=!(!t||!f)},onMouseLeave(){m.current=!1},onFocus(e){var t;m.current||"focus"===e.type&&"mousedown"===(null==(t=o.current.openEvent)?void 0:t.type)&&o.current.openEvent&&Te(o.current.openEvent,s)||(o.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){m.current=!1;const t=e.relatedTarget,n=R(t)&&t.hasAttribute("data-floating-ui-focus-guard")&&"outside"===t.getAttribute("data-type");p.current=setTimeout((()=>{P(c.floating.current,t)||P(s,t)||n||r(!1)}))}}}:{}),[a,f,s,c,o,r])},e.useHover=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,events:i,elements:{domReference:l,floating:s},refs:a}=e,{enabled:f=!0,delay:d=0,handleClose:m=null,mouseOnly:p=!1,restMs:v=0,move:b=!0}=t,E=h(),w=g(),x=T(m),I=T(d),k=u.useRef(),O=u.useRef(),A=u.useRef(),L=u.useRef(),D=u.useRef(!0),F=u.useRef(!1),N=u.useRef((()=>{})),j=u.useCallback((()=>{var e;const t=null==(e=o.current.openEvent)?void 0:e.type;return(null==t?void 0:t.includes("mouse"))&&"mousedown"!==t}),[o]);u.useEffect((()=>{if(f)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){clearTimeout(O.current),clearTimeout(L.current),D.current=!0}}),[f,i]),u.useEffect((()=>{if(!f||!x.current||!n)return;function e(){j()&&r(!1)}const t=y(s).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[s,n,r,f,x,o,j]);const K=u.useCallback((function(e){void 0===e&&(e=!0);const t=C(I.current,"close",k.current);t&&!A.current?(clearTimeout(O.current),O.current=setTimeout((()=>r(!1)),t)):e&&(clearTimeout(O.current),r(!1))}),[I,r]),B=u.useCallback((()=>{N.current(),A.current=void 0}),[]),H=u.useCallback((()=>{if(F.current){const e=y(a.floating.current).body;e.style.pointerEvents="",e.removeAttribute(S),F.current=!1}}),[a]);return u.useEffect((()=>{if(f&&R(l)){const e=l;return n&&e.addEventListener("mouseleave",c),null==s||s.addEventListener("mouseleave",c),b&&e.addEventListener("mousemove",u,{once:!0}),e.addEventListener("mouseenter",u),e.addEventListener("mouseleave",i),()=>{n&&e.removeEventListener("mouseleave",c),null==s||s.removeEventListener("mouseleave",c),b&&e.removeEventListener("mousemove",u),e.removeEventListener("mouseenter",u),e.removeEventListener("mouseleave",i)}}function t(){return!!o.current.openEvent&&["click","mousedown"].includes(o.current.openEvent.type)}function u(e){if(clearTimeout(O.current),D.current=!1,p&&!M(k.current)||v>0&&0===C(I.current,"open"))return;o.current.openEvent=e;const t=C(I.current,"open",k.current);t?O.current=setTimeout((()=>{r(!0)}),t):r(!0)}function i(r){if(t())return;N.current();const o=y(s);if(clearTimeout(L.current),x.current){n||clearTimeout(O.current),A.current=x.current({...e,tree:E,x:r.clientX,y:r.clientY,onClose(){H(),B(),K()}});const t=A.current;return o.addEventListener("mousemove",t),void(N.current=()=>{o.removeEventListener("mousemove",t)})}("touch"!==k.current||!P(s,r.relatedTarget))&&K()}function c(n){t()||null==x.current||x.current({...e,tree:E,x:n.clientX,y:n.clientY,onClose(){H(),B(),K()}})(n)}}),[l,s,f,e,p,v,b,K,B,H,r,n,E,I,x,o]),c((()=>{var e;if(f&&n&&null!=(e=x.current)&&e.__options.blockPointerEvents&&j()){const e=y(s).body;if(e.setAttribute(S,""),e.style.pointerEvents="none",F.current=!0,R(l)&&s){var t,r;const e=l,n=null==E||null==(t=E.nodesRef.current.find((e=>e.id===w)))||null==(r=t.context)?void 0:r.elements.floating;return n&&(n.style.pointerEvents=""),e.style.pointerEvents="auto",s.style.pointerEvents="auto",()=>{e.style.pointerEvents="",s.style.pointerEvents=""}}}}),[f,n,w,s,l,E,x,o,j]),c((()=>{n||(k.current=void 0,B(),H())}),[n,B,H]),u.useEffect((()=>()=>{B(),clearTimeout(O.current),clearTimeout(L.current),H()}),[f,B,H]),u.useMemo((()=>{if(!f)return{};function e(e){k.current=e.pointerType}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove(){n||0===v||(clearTimeout(L.current),L.current=setTimeout((()=>{D.current||r(!0)}),v))}},floating:{onMouseEnter(){clearTimeout(O.current)},onMouseLeave(){i.emit("dismiss",{type:"mouseLeave",data:{returnFocus:!1}}),K(!1)}}}}),[i,f,v,n,r,K])},e.useId=f,e.useInnerOffset=(e,t)=>{let{open:n,elements:o}=e,{enabled:i=!0,overflowRef:c,scrollRef:l,onChange:s}=t;const a=Me(s),f=u.useRef(!1),d=u.useRef(null),m=u.useRef(null);return u.useEffect((()=>{if(!i)return;function e(e){if(e.ctrlKey||!t||null==c.current)return;const n=e.deltaY,o=c.current.top>=-.5,u=c.current.bottom>=-.5,i=t.scrollHeight-t.clientHeight,l=n<0?-1:1,s=n<0?"max":"min";t.scrollHeight<=t.clientHeight||(!o&&n>0||!u&&n<0?(e.preventDefault(),r.flushSync((()=>{a((e=>e+Math[s](n,i*l)))}))):/firefox/i.test(E())&&(t.scrollTop+=n))}const t=(null==l?void 0:l.current)||o.floating;return n&&t?(t.addEventListener("wheel",e),requestAnimationFrame((()=>{d.current=t.scrollTop,null!=c.current&&(m.current={...c.current})})),()=>{d.current=null,m.current=null,t.removeEventListener("wheel",e)}):void 0}),[i,n,o.floating,c,l,a]),u.useMemo((()=>i?{floating:{onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const e=(null==l?void 0:l.current)||o.floating;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)&&r.flushSync((()=>a((e=>e+t))))}requestAnimationFrame((()=>{d.current=e.scrollTop}))}}}}:{}),[i,c,o.floating,l,a])},e.useInteractions=function(e){void 0===e&&(e=[]);const t=e,n=u.useCallback((t=>Ge(t,e,"reference")),t),r=u.useCallback((t=>Ge(t,e,"floating")),t),o=u.useCallback((t=>Ge(t,e,"item")),e.map((e=>null==e?void 0:e.item)));return u.useMemo((()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:o})),[n,r,o])},e.useListNavigation=(e,t)=>{const{open:n,onOpenChange:r,refs:o,elements:{domReference:i,floating:l}}=e,{listRef:s,activeIndex:a,onNavigate:f=(()=>{}),enabled:d=!0,selectedIndex:m=null,allowEscape:p=!1,loop:v=!1,nested:E=!1,rtl:w=!1,virtual:R=!1,focusItemOnOpen:M="auto",focusItemOnHover:S=!0,openOnArrowKeyDown:C=!0,disabledIndices:A,orientation:L="vertical",cols:D=1,scrollItemIntoView:F=!0}=t,N=g(),j=h(),K=Me(f),B=u.useRef(M),H=u.useRef(null!=m?m:-1),W=u.useRef(null),q=u.useRef(!0),_=u.useRef(K),U=u.useRef(!!l),V=u.useRef(!1),X=u.useRef(!1),z=T(A),Y=T(n),G=T(F),[Z,$]=u.useState(),Q=Me((function(e,t,n){void 0===n&&(n=!1);const r=e.current[t.current];r&&(R?$(null==r?void 0:r.id):re(r,{preventScroll:!0,sync:!(!b().toLowerCase().startsWith("mac")||navigator.maxTouchPoints||!O())&&(Ae||V.current)}),requestAnimationFrame((()=>{const e=G.current;e&&r&&(n||!q.current)&&(null==r.scrollIntoView||r.scrollIntoView("boolean"==typeof e?{block:"nearest",inline:"nearest"}:e))})))}));c((()=>{document.createElement("div").focus({get preventScroll(){return Ae=!0,!1}})}),[]),c((()=>{d&&(n&&l?B.current&&null!=m&&(X.current=!0,K(m)):U.current&&(H.current=-1,_.current(null)))}),[d,n,l,m,K]),c((()=>{if(d&&n&&l)if(null==a){if(V.current=!1,null!=m)return;if(U.current&&(H.current=-1,Q(s,H)),!U.current&&B.current&&(null!=W.current||!0===B.current&&null==W.current)){let e=0;const t=()=>{if(null==s.current[0]){if(e<2){(e?requestAnimationFrame:queueMicrotask)(t)}e++}else H.current=null==W.current||qe(W.current,L,w)||E?_e(s,z.current):Ue(s,z.current),W.current=null,K(H.current)};t()}}else Ke(s,a)||(H.current=a,Q(s,H,X.current),X.current=!1)}),[d,n,l,a,m,E,s,L,w,K,Q,z]),c((()=>{if(d&&U.current&&!l&&j){var e,t;const n=j.nodesRef.current,r=null==(e=n.find((e=>e.id===N)))||null==(t=e.context)?void 0:t.elements.floating,o=te(y(l)),u=n.some((e=>e.context&&P(e.context.elements.floating,o)));r&&!u&&r.focus({preventScroll:!0})}}),[d,l,j,N]),c((()=>{_.current=K,U.current=!!l})),c((()=>{n||(W.current=null)}),[n]);const J=null!=a,ee=u.useMemo((()=>{function e(e){if(!n)return;const t=s.current.indexOf(e);-1!==t&&K(t)}return{onFocus(t){let{currentTarget:n}=t;e(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...S&&{onMouseMove(t){let{currentTarget:n}=t;e(n)},onPointerLeave(e){let{pointerType:t}=e;q.current&&"touch"!==t&&(H.current=-1,Q(s,H),K(null),R||re(o.floating.current,{preventScroll:!0}))}}}}),[n,o,Q,S,s,K,R]);return u.useMemo((()=>{if(!d)return{};const e=z.current;function t(t){if(q.current=!1,V.current=!0,!Y.current&&t.currentTarget===o.floating.current)return;if(E&&function(e,t,n){return He(t,n?e===Ne:e===Fe,e===Le)}(t.key,L,w))return ce(t),r(!1),void(x(i)&&i.focus());const u=H.current,c=_e(s,e),l=Ue(s,e);if("Home"===t.key&&(ce(t),H.current=c,K(H.current)),"End"===t.key&&(ce(t),H.current=l,K(H.current)),D>1){const n=H.current;if(t.key===Le){if(ce(t),-1===n)H.current=l;else if(H.current=Be(s,{startingIndex:n,amount:D,decrement:!0,disabledIndices:e}),v&&(n-D<c||H.current<0)){const e=n%D,t=l%D,r=l-(t-e);H.current=t===e?l:t>e?r:r-D}Ke(s,H.current)&&(H.current=n),K(H.current)}if(t.key===De&&(ce(t),-1===n?H.current=c:(H.current=Be(s,{startingIndex:n,amount:D,disabledIndices:e}),v&&n+D>l&&(H.current=Be(s,{startingIndex:n%D-D,amount:D,disabledIndices:e}))),Ke(s,H.current)&&(H.current=n),K(H.current)),"both"===L){const r=Math.floor(n/D);t.key===Ne&&(ce(t),n%D!=D-1?(H.current=Be(s,{startingIndex:n,disabledIndices:e}),v&&je(H.current,D,r)&&(H.current=Be(s,{startingIndex:n-n%D-1,disabledIndices:e}))):v&&(H.current=Be(s,{startingIndex:n-n%D-1,disabledIndices:e})),je(H.current,D,r)&&(H.current=n)),t.key===Fe&&(ce(t),n%D!=0?(H.current=Be(s,{startingIndex:n,disabledIndices:e,decrement:!0}),v&&je(H.current,D,r)&&(H.current=Be(s,{startingIndex:n+(D-n%D),decrement:!0,disabledIndices:e}))):v&&(H.current=Be(s,{startingIndex:n+(D-n%D),decrement:!0,disabledIndices:e})),je(H.current,D,r)&&(H.current=n));const o=Math.floor(l/D)===r;return Ke(s,H.current)&&(H.current=v&&o?t.key===Fe?l:Be(s,{startingIndex:n-n%D-1,disabledIndices:e}):n),void K(H.current)}}if(We(t.key,L)){if(ce(t),n&&!R&&te(t.currentTarget.ownerDocument)===t.currentTarget)return H.current=qe(t.key,L,w)?c:l,void K(H.current);qe(t.key,L,w)?H.current=v?u>=l?p&&u!==s.current.length?-1:c:Be(s,{startingIndex:u,disabledIndices:e}):Math.min(l,Be(s,{startingIndex:u,disabledIndices:e})):H.current=v?u<=c?p&&-1!==u?s.current.length:l:Be(s,{startingIndex:u,decrement:!0,disabledIndices:e}):Math.max(c,Be(s,{startingIndex:u,decrement:!0,disabledIndices:e})),Ke(s,H.current)?K(null):K(H.current)}}function u(e){"auto"===M&&I(e.nativeEvent)&&(B.current=!0)}const c=R&&n&&J&&{"aria-activedescendant":Z};return{reference:{...c,onKeyDown(o){q.current=!1;const u=0===o.key.indexOf("Arrow");if(R&&n)return t(o);if(!n&&!C&&u)return;const i=u||"Enter"===o.key||""===o.key.trim(),c=We(o.key,L),l=function(e,t,n){return He(t,n?e===Fe:e===Ne,e===De)}(o.key,L,w);i&&(W.current=E&&c?null:o.key),E?l&&(ce(o),n?(H.current=_e(s,e),K(H.current)):r(!0)):c&&(null!=m&&(H.current=m),ce(o),!n&&C?r(!0):t(o),n&&K(H.current))},onFocus(){n&&K(null)},onPointerDown:function(e){B.current=M,"auto"===M&&k(e.nativeEvent)&&(B.current=!0)},onMouseDown:u,onClick:u},floating:{"aria-orientation":"both"===L?void 0:L,...c,onKeyDown:t,onPointerMove(){q.current=!0}},item:ee}}),[i,o,Z,z,Y,s,d,L,w,R,n,J,E,m,C,p,D,v,M,K,r,ee])},e.useMergeRefs=function(e){return u.useMemo((()=>e.every((e=>null==e))?null:t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}),e)},e.useRole=function(e,t){void 0===t&&(t={});const{open:n,floatingId:r}=e,{enabled:o=!0,role:i="dialog"}=t,c=f();return u.useMemo((()=>{const e={id:r,role:i};return o?"tooltip"===i?{reference:{"aria-describedby":n?r:void 0},floating:e}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":"alertdialog"===i?"dialog":i,"aria-controls":n?r:void 0,..."listbox"===i&&{role:"combobox"},..."menu"===i&&{id:c}},floating:{...e,..."menu"===i&&{"aria-labelledby":c}}}:{}}),[o,i,n,r,c])},e.useTransitionStatus=ze,e.useTransitionStyles=function(e,t){void 0===t&&(t={});const{initial:n={opacity:0},open:r,close:o,common:i,duration:l=250}=t,s=e.placement,a=s.split("-")[0],f=u.useMemo((()=>({side:a,placement:s})),[a,s]),d="number"==typeof l,m=(d?l:l.open)||0,p=(d?l:l.close)||0,[v,g]=u.useState((()=>({...Xe(i,f),...Xe(n,f)}))),{isMounted:h,status:y}=ze(e,{duration:l}),b=T(n),E=T(r),w=T(o),R=T(i);return c((()=>{const e=Xe(b.current,f),t=Xe(w.current,f),n=Xe(R.current,f),r=Xe(E.current,f)||Object.keys(e).reduce(((e,t)=>(e[t]="",e)),{});if("initial"===y&&g((t=>({transitionProperty:t.transitionProperty,...n,...e}))),"open"===y&&g({transitionProperty:Object.keys(r).map(Ve).join(","),transitionDuration:m+"ms",...n,...r}),"close"===y){const r=t||e;g({transitionProperty:Object.keys(r).map(Ve).join(","),transitionDuration:p+"ms",...n,...r})}}),[p,w,b,E,R,m,y,f]),{isMounted:h,styles:v}},e.useTypeahead=(e,t)=>{var n;const{open:r,dataRef:o}=e,{listRef:i,activeIndex:l,onMatch:s,onTypingChange:a,enabled:f=!0,findMatch:d=null,resetMs:m=750,ignoreKeys:p=[],selectedIndex:v=null}=t,g=u.useRef(),h=u.useRef(""),y=u.useRef(null!=(n=null!=v?v:l)?n:-1),b=u.useRef(null),E=Me(s),w=Me(a),R=T(d),x=T(p);return c((()=>{r&&(clearTimeout(g.current),b.current=null,h.current="")}),[r]),c((()=>{var e;r&&""===h.current&&(y.current=null!=(e=null!=v?v:l)?e:-1)}),[r,v,l]),u.useMemo((()=>{if(!f)return{};function e(e){e?o.current.typing||(o.current.typing=e,w(e)):o.current.typing&&(o.current.typing=e,w(e))}function t(e,t,n){const r=R.current?R.current(t,n):t.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(n.toLocaleLowerCase()))));return r?e.indexOf(r):-1}function n(n){const o=i.current;if(h.current.length>0&&" "!==h.current[0]&&(-1===t(o,o,h.current)?e(!1):" "===n.key&&ce(n)),null==o||x.current.includes(n.key)||1!==n.key.length||n.ctrlKey||n.metaKey||n.altKey)return;r&&" "!==n.key&&(ce(n),e(!0));o.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&h.current===n.key&&(h.current="",y.current=b.current),h.current+=n.key,clearTimeout(g.current),g.current=setTimeout((()=>{h.current="",y.current=b.current,e(!1)}),m);const u=y.current,c=t(o,[...o.slice((u||0)+1),...o.slice(0,(u||0)+1)],h.current);-1!==c?(E(c),b.current=c):(h.current="",e(!1))}return{reference:{onKeyDown:n},floating:{onKeyDown:n}}}),[f,r,o,i,m,x,R,E,w])},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!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);function i(){return i=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},i.apply(this,arguments)}var c="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;let l=!1,s=0;const a=()=>"floating-ui-"+s++;const f=u["useId".toString()]||function(){const[e,t]=u.useState((()=>l?a():void 0));return c((()=>{null==e&&t(a())}),[]),u.useEffect((()=>{l||(l=!0)}),[]),e},d=u.forwardRef((function(e,n){var r;let{context:{placement:o,elements:{floating:c},middlewareData:{arrow:l}},width:s=14,height:a=7,tipRadius:d=0,strokeWidth:m=0,staticOffset:p,stroke:v,d:g,...h}=e;m*=2;const y=m/2,b=s/2*(d/-8+1),w=a/2*d/4,[E,R]=o.split("-"),x=!!c&&t.platform.isRTL(c),I=!!g,O="top"===E||"bottom"===E,k=p&&"end"===R?"bottom":"top";let C=p&&"end"===R?"right":"left";p&&x&&(C="end"===R?"left":"right");const M=I?0:y,T=null!=(null==l?void 0:l.x)?p||l.x:"",P=null!=(null==l?void 0:l.y)?p||l.y+M:"",S=g||"M0,0 H"+s+" L"+(s-b)+","+(a-w)+" Q"+s/2+","+a+" "+b+","+(a-w)+" Z",A={top:I?"rotate(180deg)":"",left:I?"rotate(90deg)":"rotate(-90deg)",bottom:I?"":"rotate(180deg)",right:I?"rotate(-90deg)":"rotate(90deg)"}[E],L=f();return u.createElement("svg",i({},h,{suppressHydrationWarning:!0,"aria-hidden":!0,ref:n,width:I?s:s+m,height:s,viewBox:"0 0 "+s+" "+(a>s?a:s),style:{...h.style,position:"absolute",pointerEvents:"none",[C]:T,[k]:P,[E]:O||I?"100%":"calc(100% - "+m/2+"px)",transform:A+(null!=(r=h.style)&&r.transform?" "+h.style.transform:"")}}),m>0&&u.createElement("path",{clipPath:"url(#"+L+")",fill:"none",stroke:v,strokeWidth:m+(g?0:1),d:S}),u.createElement("path",{stroke:m&&!g?h.fill:"none",d:S}),u.createElement("clipPath",{id:L},u.createElement("rect",{x:-y,y:y*(I?-1:1),width:s+m,height:s})))}));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){var r;e.set(t,(null==(r=e.get(t))?void 0:r.filter((e=>e!==n)))||[])}}}const p=u.createContext(null),v=u.createContext(null),g=()=>{var e;return(null==(e=u.useContext(p))?void 0:e.id)||null},h=()=>u.useContext(v);function y(e){return(null==e?void 0:e.ownerDocument)||document}function b(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}function w(){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 E(e){return y(e).defaultView||window}function R(e){return!!e&&e instanceof E(e).Element}function x(e){return!!e&&e instanceof E(e).HTMLElement}function I(e){if(0===e.mozInputSource&&e.isTrusted)return!0;const t=/Android/i;return(t.test(b())||t.test(w()))&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType}function O(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 C(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(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 E(r).ShadowRoot||r instanceof ShadowRoot))){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}var r;return!1}function T(e){const t=n.useRef(e);return c((()=>{t.current=e})),t}const P="data-floating-ui-safe-polygon";function S(e,t,n){return n&&!C(n)?0:"number"==typeof e?e:null==e?void 0:e[t]}const A=u.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:()=>{},setState:()=>{},isInstantPhase:!1}),L=()=>u.useContext(A);var D=new WeakMap,N=new WeakMap,F={},j=0,K=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];F[n]||(F[n]=new WeakMap);var o=F[n],u=[],i=new Set,c=function(e){e&&!i.has(e)&&(i.add(e),c(e.parentNode))};r.forEach(c);var l=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(i.has(e))l(e);else{var t=e.getAttribute("aria-hidden"),r=null!==t&&"false"!==t,c=(D.get(e)||0)+1,s=(o.get(e)||0)+1;D.set(e,c),o.set(e,s),u.push(e),1===c&&r&&N.set(e,!0),1===s&&e.setAttribute(n,"true"),r||e.setAttribute("aria-hidden","true")}}))};return l(t),i.clear(),j++,function(){u.forEach((function(e){var t=D.get(e)-1,r=o.get(e)-1;D.set(e,t),o.set(e,r),t||(N.has(e)||e.removeAttribute("aria-hidden"),N.delete(e)),r||e.removeAttribute(n)})),--j||(D=new WeakMap,D=new WeakMap,N=new WeakMap,F={})}},_=["input","select","textarea","a[href]","button","[tabindex]:not(slot)","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"].join(","),B="undefined"==typeof Element,H=B?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,q=!B&&Element.prototype.getRootNode?function(e){return e.getRootNode()}:function(e){return e.ownerDocument},W=function e(t,n,r){for(var o=[],u=Array.from(t);u.length;){var i=u.shift();if("SLOT"===i.tagName){var c=i.assignedElements(),l=e(c.length?c:i.children,!0,r);r.flatten?o.push.apply(o,l):o.push({scopeParent:i,candidates:l})}else{H.call(i,_)&&r.filter(i)&&(n||!t.includes(i))&&o.push(i);var s=i.shadowRoot||"function"==typeof r.getShadowRoot&&r.getShadowRoot(i),a=!r.shadowRootFilter||r.shadowRootFilter(i);if(s&&a){var f=e(!0===s?i.children:s.children,!0,r);r.flatten?o.push.apply(o,f):o.push({scopeParent:i,candidates:f})}else u.unshift.apply(u,i.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},z=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},V=function(e){return"INPUT"===e.tagName},X=function(e){return function(e){return V(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||q(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)},Y=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=H.call(e,"details>summary:first-of-type")?e.parentElement:e;if(H.call(o,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return Y(e)}else{if("function"==typeof r){for(var u=e;e;){var i=e.parentElement,c=q(e);if(i&&!i.shadowRoot&&!0===r(i))return Y(e);e=e.assignedSlot?e.assignedSlot:i||c===e.ownerDocument?i:c.host}e=u}if(function(e){for(var t,n=q(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=q(n).host)||void 0===o||!o.ownerDocument.contains(n))}return r}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},Z=function(e,t){return!(t.disabled||function(e){return V(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!!H.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},$=function(e,t){return!(X(t)||U(t)<0||!Z(e,t))},Q=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},J=function e(t){var n=[],r=[];return t.forEach((function(t,o){var u=!!t.scopeParent,i=u?t.scopeParent:t,c=U(i,u),l=u?e(t.candidates):i;0===c?u?n.push.apply(n,l):n.push(i):r.push({documentOrder:o,tabIndex:c,item:t,isScope:u,content:l})})),r.sort(z).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?W([e],t.includeContainer,{filter:$.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:Q}):function(e,t,n){var r=Array.prototype.slice.apply(e.querySelectorAll(_));return t&&H.call(e,_)&&r.unshift(e),r.filter(n)}(e,t.includeContainer,$.bind(null,t)),J(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}let ne=0;function re(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(ne);const u=()=>null==e?void 0:e.focus({preventScroll:n});o?u():ne=requestAnimationFrame(u)}function oe(e,t){let n=e.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})),r=n;for(;r.length;)r=e.filter((e=>{var t;return null==(t=r)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})),n=n.concat(r);return n}function ue(e){return"composedPath"in e?e.composedPath()[0]:e.target}function ie(e){return x(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function ce(e){e.preventDefault(),e.stopPropagation()}const le=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function se(e,t){const n=ee(e,le());"prev"===t&&n.reverse();const r=n.indexOf(te(y(e)));return n.slice(r+1)[0]}function ae(){return se(document.body,"next")}function fe(){return se(document.body,"prev")}function de(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!M(n,r)}function me(e){ee(e,le()).forEach((e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")}))}function pe(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 ve={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};function ge(e){"Tab"===e.key&&(e.target,clearTimeout(undefined))}const he=u.forwardRef((function(e,t){const[n,r]=u.useState();return c((()=>(k()&&r("button"),document.addEventListener("keydown",ge),()=>{document.removeEventListener("keydown",ge)})),[]),u.createElement("span",i({},e,{ref:t,tabIndex:0,role:n,"aria-hidden":!n||void 0,"data-floating-ui-focus-guard":"",style:ve}))})),ye=u.createContext(null),be=function(e){let{id:t,root:n}=void 0===e?{}:e;const[r,o]=u.useState(null),i=u.useRef(null),l=f(),s=we(),a=u.useMemo((()=>({id:t,root:n,portalContext:s,uniqueId:l})),[t,n,s,l]),d=u.useRef();return c((()=>{const e=i.current;return()=>{null==r||r.remove(),null==e||e.remove()}}),[r,a]),c((()=>{if(d.current===a)return;d.current=a;const{id:e,root:t,portalContext:n,uniqueId:r}=a,u=e?document.getElementById(e):null,i="data-floating-ui-portal";if(u){const e=document.createElement("div");e.id=r,e.setAttribute(i,""),u.appendChild(e),o(e)}else{let u=(null==n?void 0:n.portalNode)||t||document.body,c=null;e&&(c=document.createElement("div"),c.id=e,u.appendChild(c));const l=document.createElement("div");l.id=r,l.setAttribute(i,""),u=c||u,u.appendChild(l),o(l)}}),[a]),r},we=()=>u.useContext(ye),Ee=u.forwardRef((function(e,t){return u.createElement("button",i({},e,{type:"button",ref:t,tabIndex:-1,style:ve}))}));function Re(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const xe=u.createContext({register:()=>{},unregister:()=>{},map:new Map,elementsRef:{current:[]}});const Ie="data-floating-ui-scroll-lock",Oe=u.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return c((()=>{var e,t;if(!n)return;if(document.body.hasAttribute(Ie))return;document.body.setAttribute(Ie,"");const r=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(b()))return Object.assign(document.body.style,{overflow:"hidden",[r]:o+"px"}),()=>{document.body.removeAttribute(Ie),Object.assign(document.body.style,{overflow:"",[r]:""})};const u=(null==(e=window.visualViewport)?void 0:e.offsetLeft)||0,i=(null==(t=window.visualViewport)?void 0:t.offsetTop)||0,c=window.pageXOffset,l=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(l-Math.floor(i))+"px",left:-(c-Math.floor(u))+"px",right:"0",[r]:o+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[r]:""}),document.body.removeAttribute(Ie),window.scrollTo(c,l)}}),[n]),u.createElement("div",i({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));function ke(e){return x(e.target)&&"BUTTON"===e.target.tagName}function Ce(e){return ie(e)}const Me=u["useInsertionEffect".toString()]||(e=>e());function Te(e){const t=u.useRef((()=>{}));return Me((()=>{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 Pe(e){return null!=e&&null!=e.clientX}function Se(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 Ae={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Le={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"};let De=!1;const Ne="ArrowUp",Fe="ArrowDown",je="ArrowLeft",Ke="ArrowRight";function _e(e,t,n){return Math.floor(e/t)!==n}function Be(e,t){return t<0||t>=e.current.length}function He(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o,amount:u=1}=void 0===t?{}:t;const i=e.current;let c=n;do{var l,s;c+=r?-u:u}while(c>=0&&c<=i.length-1&&(o?o.includes(c):null==i[c]||(null==(l=i[c])?void 0:l.hasAttribute("disabled"))||"true"===(null==(s=i[c])?void 0:s.getAttribute("aria-disabled"))));return c}function qe(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function We(e,t){return qe(t,e===Ne||e===Fe,e===je||e===Ke)}function Ue(e,t,n){return qe(t,e===Fe,n?e===je:e===Ke)||"Enter"===e||" "==e||""===e}function ze(e,t){return He(e,{disabledIndices:t})}function Ve(e,t){return He(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}const Xe=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,((e,t)=>(t?"-":"")+e.toLowerCase()));function Ye(e,t){return"function"==typeof e?e(t):e}function Ge(e,t){void 0===t&&(t={});const{open:n,elements:{floating:r}}=e,{duration:o=250}=t,i=("number"==typeof o?o:o.close)||0,[l,s]=u.useState(!1),[a,f]=u.useState("unmounted"),d=function(e,t){const[n,r]=u.useState(e);return e&&!n&&r(!0),u.useEffect((()=>{if(!e){const e=setTimeout((()=>r(!1)),t);return()=>clearTimeout(e)}}),[e,t]),n}(n,i);return c((()=>{l&&!d&&f("unmounted")}),[l,d]),c((()=>{if(r){if(n){f("initial");const e=requestAnimationFrame((()=>{f("open")}));return()=>{cancelAnimationFrame(e)}}s(!0),f("close")}}),[n,r]),{isMounted:d,status:a}}function Ze(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}function $e(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];return null==(e=r.get(n))?void 0:e.map((e=>e(...o))).find((e=>void 0!==e))})):e[n]=o})),e):e),{})}}Object.defineProperty(e,"arrow",{enumerable:!0,get:function(){return t.arrow}}),Object.defineProperty(e,"autoPlacement",{enumerable:!0,get:function(){return t.autoPlacement}}),Object.defineProperty(e,"autoUpdate",{enumerable:!0,get:function(){return t.autoUpdate}}),Object.defineProperty(e,"computePosition",{enumerable:!0,get:function(){return t.computePosition}}),Object.defineProperty(e,"detectOverflow",{enumerable:!0,get:function(){return t.detectOverflow}}),Object.defineProperty(e,"flip",{enumerable:!0,get:function(){return t.flip}}),Object.defineProperty(e,"getOverflowAncestors",{enumerable:!0,get:function(){return t.getOverflowAncestors}}),Object.defineProperty(e,"hide",{enumerable:!0,get:function(){return t.hide}}),Object.defineProperty(e,"inline",{enumerable:!0,get:function(){return t.inline}}),Object.defineProperty(e,"limitShift",{enumerable:!0,get:function(){return t.limitShift}}),Object.defineProperty(e,"offset",{enumerable:!0,get:function(){return t.offset}}),Object.defineProperty(e,"platform",{enumerable:!0,get:function(){return t.platform}}),Object.defineProperty(e,"shift",{enumerable:!0,get:function(){return t.shift}}),Object.defineProperty(e,"size",{enumerable:!0,get:function(){return t.size}}),e.FloatingArrow=d,e.FloatingDelayGroup=e=>{let{children:t,delay:n,timeoutMs:r=0}=e;const[o,i]=u.useReducer(((e,t)=>({...e,...t})),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),l=u.useRef(null),s=u.useCallback((e=>{i({currentId:e})}),[]);return c((()=>{o.currentId?null===l.current?l.current=o.currentId:i({isInstantPhase:!0}):(i({isInstantPhase:!1}),l.current=null)}),[o.currentId]),u.createElement(A.Provider,{value:u.useMemo((()=>({...o,setState:i,setCurrentId:s})),[o,i,s])},t)},e.FloatingFocusManager=function(e){let{context:t,children:n,order:r=["content"],guards:o=!0,initialFocus:i=0,returnFocus:l=!0,modal:s=!0,visuallyHiddenDismiss:a=!1,closeOnFocusOut:f=!0}=e;const{open:d,refs:m,nodeId:p,onOpenChange:v,events:g,dataRef:b,elements:{domReference:w,floating:E}}=t,R=T(r),I=T(i),O=T(l),k=h(),C=we(),[P,S]=u.useState(null),A="number"==typeof i&&i<0,L=u.useRef(null),D=u.useRef(null),N=u.useRef(!1),F=u.useRef(null),j=u.useRef(!1),_=null!=C,B=w&&"combobox"===w.getAttribute("role")&&ie(w),H=u.useCallback((function(e){return void 0===e&&(e=E),e?ee(e,le()):[]}),[E]),q=u.useCallback((e=>{const t=H(e);return R.current.map((e=>w&&"reference"===e?w:E&&"floating"===e?E:t)).filter(Boolean).flat()}),[w,E,R,H]);u.useEffect((()=>{if(!s)return;function e(e){if("Tab"===e.key){0!==H().length||B||ce(e);const t=q(),n=ue(e);"reference"===R.current[0]&&n===w&&(ce(e),e.shiftKey?re(t[t.length-1]):re(t[1])),"floating"===R.current[1]&&n===E&&e.shiftKey&&(ce(e),re(t[0]))}}const t=y(E);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[w,E,s,R,m,B,H,q]),u.useEffect((()=>{if(f)return E&&x(w)?(w.addEventListener("focusout",t),w.addEventListener("pointerdown",e),!s&&E.addEventListener("focusout",t),()=>{w.removeEventListener("focusout",t),w.removeEventListener("pointerdown",e),!s&&E.removeEventListener("focusout",t)}):void 0;function e(){j.current=!0,setTimeout((()=>{j.current=!1}))}function t(e){const t=e.relatedTarget;queueMicrotask((()=>{const e=!(M(w,t)||M(E,t)||M(t,E)||M(null==C?void 0:C.portalNode,t)||null!=t&&t.hasAttribute("data-floating-ui-focus-guard")||k&&(oe(k.nodesRef.current,p).find((e=>{var n,r;return M(null==(n=e.context)?void 0:n.elements.floating,t)||M(null==(r=e.context)?void 0:r.elements.domReference,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}(k.nodesRef.current,p).find((e=>{var n,r;return(null==(n=e.context)?void 0:n.elements.floating)===t||(null==(r=e.context)?void 0:r.elements.domReference)===t}))));t&&e&&!j.current&&t!==F.current&&(N.current=!0,v(!1))}))}}),[w,E,s,p,k,C,v,f]),u.useEffect((()=>{var e;const t=Array.from((null==C||null==(e=C.portalNode)?void 0:e.querySelectorAll("[data-floating-ui-portal]"))||[]);if(E&&s){const e=[E,...t,...[L.current,D.current].filter(Boolean)],n=K(R.current.includes("reference")||B?e.concat(w||[]):e);return()=>{n()}}}),[w,E,s,R,C,B]),u.useEffect((()=>{if(s&&!o&&E){const e=[],t=le(),n=ee(y(E).body,t),r=q(),o=n.filter((e=>!r.includes(e)));return o.forEach(((t,n)=>{e[n]=t.getAttribute("tabindex"),t.setAttribute("tabindex","-1")})),()=>{o.forEach(((t,n)=>{const r=e[n];null==r?t.removeAttribute("tabindex"):t.setAttribute("tabindex",r)}))}}}),[E,s,o,q]),c((()=>{if(!E)return;let e=!1;const t=y(E),n=te(t),r=b.current;function o(t){if("escapeKey"===t.type&&m.domReference.current&&(F.current=m.domReference.current),["referencePress","escapeKey"].includes(t.type))return;const n=t.data.returnFocus;"object"==typeof n?(N.current=!1,e=n.preventScroll):N.current=!n}return F.current=n,queueMicrotask((()=>{const e=q(E),t=I.current,r=("number"==typeof t?e[t]:t.current)||E,o=M(E,n);A||o||!d||re(r,{preventScroll:r===E})})),g.on("dismiss",o),()=>{g.off("dismiss",o);const n=te(t);(M(E,n)||k&&oe(k.nodesRef.current,p).some((e=>{var t;return M(null==(t=e.context)?void 0:t.elements.floating,n)}))||r.openEvent&&["click","mousedown"].includes(r.openEvent.type))&&m.domReference.current&&(F.current=m.domReference.current),O.current&&x(F.current)&&!N.current&&re(F.current,{cancelPrevious:!1,preventScroll:e})}}),[d,E,q,O,I,b,m,g,A,k,p]),c((()=>{if(C)return C.setFocusManagerState({...t,modal:s,closeOnFocusOut:f}),()=>{C.setFocusManagerState(null)}}),[C,s,f,t]),c((()=>{if(!A&&E&&(e(),"function"==typeof MutationObserver)){const t=new MutationObserver(e);return t.observe(E,{childList:!0,subtree:!0}),()=>{t.disconnect()}}function e(){te(y(E))!==m.domReference.current&&S(H().length)}}),[E,H,A,m]);const W=o&&(_||s)&&!B;function U(e){return a&&s?u.createElement(Ee,{ref:"start"===e?L:D,onClick:()=>v(!1)},"string"==typeof a?a:"Dismiss"):null}return u.createElement(u.Fragment,null,W&&u.createElement(he,{"data-type":"inside",ref:null==C?void 0:C.beforeInsideRef,onFocus:e=>{if(s){const e=q();re("reference"===r[0]?e[0]:e[e.length-1])}else if(null!=C&&C.preserveTabOrder&&C.portalNode)if(N.current=!1,de(e,C.portalNode)){const e=ae()||w;null==e||e.focus()}else{var t;null==(t=C.beforeOutsideRef.current)||t.focus()}}}),B?null:U("start"),u.cloneElement(n,0===P||r.includes("floating")?{tabIndex:0}:{}),U("end"),W&&u.createElement(he,{"data-type":"inside",ref:null==C?void 0:C.afterInsideRef,onFocus:e=>{if(s)re(q()[0]);else if(null!=C&&C.preserveTabOrder&&C.portalNode)if(f&&(N.current=!0),de(e,C.portalNode)){const e=fe()||w;null==e||e.focus()}else{var t;null==(t=C.afterOutsideRef.current)||t.focus()}}}))},e.FloatingList=function(e){let{children:t,elementsRef:n,labelsRef:r}=e;const[o,i]=u.useState((()=>new Map)),l=u.useCallback((e=>{i((t=>new Map(t).set(e,null)))}),[]),s=u.useCallback((e=>{i((t=>{const n=new Map(t);return n.delete(e),n}))}),[]);return c((()=>{if(o.size<2)return;const e=new Map(o);Array.from(e.keys()).sort(Re).forEach(((t,n)=>{e.set(t,n)})),function(e,t){if(e.size!==t.size)return!1;for(const[n,r]of e.entries())if(r!==t.get(n))return!1;return!0}(o,e)||i(e)}),[o]),u.createElement(xe.Provider,{value:{register:l,unregister:s,map:o,elementsRef:n,labelsRef:r}},t)},e.FloatingNode=e=>{let{children:t,id:n}=e;const r=g();return u.createElement(p.Provider,{value:u.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},e.FloatingOverlay=Oe,e.FloatingPortal=e=>{let{children:t,id:n,root:o=null,preserveTabOrder:i=!0}=e;const c=be({id:n,root:o}),[l,s]=u.useState(null),a=u.useRef(null),f=u.useRef(null),d=u.useRef(null),m=u.useRef(null),p=!!l&&!l.modal&&!(!o&&!c)&&i;return u.useEffect((()=>{if(c&&i&&(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&&de(e)){("focusin"===e.type?pe:me)(c)}}}),[c,i,null==l?void 0:l.modal]),u.createElement(ye.Provider,{value:u.useMemo((()=>({preserveTabOrder:i,beforeOutsideRef:a,afterOutsideRef:f,beforeInsideRef:d,afterInsideRef:m,portalNode:c,setFocusManagerState:s})),[i,c])},p&&c&&u.createElement(he,{"data-type":"outside",ref:a,onFocus:e=>{if(de(e,c)){var t;null==(t=d.current)||t.focus()}else{const e=fe()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus()}}}),p&&c&&u.createElement("span",{"aria-owns":c.id,style:ve}),c&&r.createPortal(t,c),p&&c&&u.createElement(he,{"data-type":"outside",ref:f,onFocus:e=>{if(de(e,c)){var t;null==(t=m.current)||t.focus()}else{const e=ae()||(null==l?void 0:l.refs.domReference.current);null==e||e.focus(),(null==l?void 0:l.closeOnFocusOut)&&(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))}),[]),i=u.useState((()=>m()))[0];return u.createElement(v.Provider,{value:u.useMemo((()=>({nodesRef:n,addNode:r,removeNode:o,events:i})),[n,r,o,i])},t)},e.inner=e=>({name:"inner",options:e,async fn(n){const{listRef:o,overflowRef:u,onFallbackChange:i,offset:c=0,index:l=0,minItemsVisible:s=4,referenceOverflowThreshold:a=0,scrollRef:f,...d}=e,{rects:m,elements:{floating:p}}=n,v=o.current[l];if(!v)return{};const g={...n,...await t.offset(-v.offsetTop-m.reference.height/2-v.offsetHeight/2-c).fn(n)},h=(null==f?void 0:f.current)||p,y=await t.detectOverflow(Ze(g,h.scrollHeight),d),b=await t.detectOverflow(g,{...d,elementContext:"reference"}),w=Math.max(0,y.top),E=g.y+w,R=Math.max(0,h.scrollHeight-w-Math.max(0,y.bottom));return h.style.maxHeight=R+"px",h.scrollTop=w,i&&(h.offsetHeight<v.offsetHeight*Math.min(s,o.current.length-1)-1||b.top>=-a||b.bottom>=-a?r.flushSync((()=>i(!0))):r.flushSync((()=>i(!1)))),u&&(u.current=await t.detectOverflow(Ze({...g,y:E},h.offsetHeight),d)),{y:E}}}),e.safePolygon=function(e){let t,{buffer:n=.5,blockPointerEvents:r=!1,requireIntent:o=!0}=void 0===e?{}:e,u=!1,i=!1,c=null,l=null,s=performance.now();const a=e=>{let{x:r,y:a,placement:f,elements:d,onClose:m,nodeId:p,tree:v}=e;return function(e){function g(){clearTimeout(t),m()}if(clearTimeout(t),!d.domReference||!d.floating||null==f||null==r||null==a)return;const{clientX:h,clientY:y}=e,b=[h,y],w=ue(e),E="mouseleave"===e.type,x=M(d.floating,w),I=M(d.domReference,w),O=d.domReference.getBoundingClientRect(),k=d.floating.getBoundingClientRect(),C=f.split("-")[0],T=r>k.right-k.width/2,P=a>k.bottom-k.height/2,S=function(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}(b,O);if(x&&(i=!0,!E))return;if(I&&(i=!1),I&&!E)return void(i=!0);if(E&&R(e.relatedTarget)&&M(d.floating,e.relatedTarget))return;if(v&&oe(v.nodesRef.current,p).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if("top"===C&&a>=O.bottom-1||"bottom"===C&&a<=O.top+1||"left"===C&&r>=O.right-1||"right"===C&&r<=O.left+1)return g();let A=[];switch(C){case"top":A=[[k.left,O.top+1],[k.left,k.bottom-1],[k.right,k.bottom-1],[k.right,O.top+1]],u=h>=k.left&&h<=k.right&&y>=k.top&&y<=O.top+1;break;case"bottom":A=[[k.left,k.top+1],[k.left,O.bottom-1],[k.right,O.bottom-1],[k.right,k.top+1]],u=h>=k.left&&h<=k.right&&y>=O.bottom-1&&y<=k.bottom;break;case"left":A=[[k.right-1,k.bottom],[k.right-1,k.top],[O.left+1,k.top],[O.left+1,k.bottom]],u=h>=k.left&&h<=O.left+1&&y>=k.top&&y<=k.bottom;break;case"right":A=[[O.right-1,k.bottom],[O.right-1,k.top],[k.left+1,k.top],[k.left+1,k.bottom]],u=h>=O.right-1&&h<=k.right&&y>=k.top&&y<=k.bottom}const L=u?A:function(e){let[t,r]=e;const o=k.width>O.width,u=k.height>O.height;switch(C){case"top":return[[o?t+n/2:T?t+4*n:t-4*n,r+n+1],[o?t-n/2:T?t+4*n:t-4*n,r+n+1],...[[k.left,T||o?k.bottom-n:k.top],[k.right,T?o?k.bottom-n:k.top:k.bottom-n]]];case"bottom":return[[o?t+n/2:T?t+4*n:t-4*n,r-n],[o?t-n/2:T?t+4*n:t-4*n,r-n],...[[k.left,T||o?k.top+n:k.bottom],[k.right,T?o?k.top+n:k.bottom:k.top+n]]];case"left":{const e=[t+n+1,u?r+n/2:P?r+4*n:r-4*n],o=[t+n+1,u?r-n/2:P?r+4*n:r-4*n];return[...[[P||u?k.right-n:k.left,k.top],[P?u?k.right-n:k.left:k.right-n,k.bottom]],e,o]}case"right":return[[t-n,u?r+n/2:P?r+4*n:r-4*n],[t-n,u?r-n/2:P?r+4*n:r-4*n],...[[P||u?k.left+n:k.right,k.top],[P?u?k.left+n:k.right:k.left+n,k.bottom]]]}}([r,a]);if(!u){if(i&&!S)return g();if(!E&&o){const t=function(e,t){const n=performance.now(),r=n-s;if(null===c||null===l||0===r)return c=e,l=t,s=n,null;const o=e-c,u=t-l,i=Math.sqrt(o*o+u*u);return c=e,l=t,s=n,i/r}(e.clientX,e.clientY),n=.1;if(null!==t&&t<n)return g()}!function(e,t){const[n,r]=e;let o=!1;const u=t.length;for(let e=0,i=u-1;e<u;i=e++){const[u,c]=t[e]||[0,0],[l,s]=t[i]||[0,0];c>=r!=s>=r&&n<=(l-u)*(r-c)/(s-c)+u&&(o=!o)}return o}([h,y],L)?g():!i&&o&&(t=window.setTimeout(g,40))}}};return a.__options={blockPointerEvents:r},a},e.useClick=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,elements:{domReference:i}}=e,{enabled:c=!0,event:l="click",toggle:s=!0,ignoreMouse:a=!1,keyboardHandlers:f=!0}=t,d=u.useRef(),m=u.useRef(!1);return u.useMemo((()=>c?{reference:{onPointerDown(e){d.current=e.pointerType},onMouseDown(e){0===e.button&&(C(d.current,!0)&&a||"click"!==l&&(n?!s||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:C(d.current,!0)&&a||(n?!s||o.current.openEvent&&"click"!==o.current.openEvent.type||r(!1):r(!0),o.current.openEvent=e.nativeEvent)},onKeyDown(e){d.current=void 0,f&&!ke(e)&&(" "!==e.key||Ce(i)||(e.preventDefault(),m.current=!0),"Enter"===e.key&&(n?s&&r(!1):r(!0)))},onKeyUp(e){!f||ke(e)||Ce(i)||" "===e.key&&m.current&&(m.current=!1,n?s&&r(!1):r(!0))}}}:{}),[c,o,l,a,f,i,s,n,r])},e.useClientPoint=function(e,t){let{open:n,refs:r,dataRef:o,elements:{floating:i}}=e,{enabled:l=!0,axis:s="both",x:a=null,y:f=null}=void 0===t?{}:t;const d=u.useRef(!1),m=u.useRef(null),[p,v]=u.useState(),[g,h]=u.useState([]),y=Te(((e,t)=>{d.current||o.current.openEvent&&!Pe(o.current.openEvent)||r.setPositionReference(function(e,t){let n=null,r=null,o=!1;return{contextElement:e.current||void 0,getBoundingClientRect(){var u,i;const c=(null==(u=e.current)?void 0:u.getBoundingClientRect())||{width:0,height:0,x:0,y:0},l="x"===t.axis||"both"===t.axis,s="y"===t.axis||"both"===t.axis,a=["mouseenter","mousemove"].includes((null==(i=t.dataRef.current.openEvent)?void 0:i.type)||"")&&"touch"!==t.pointerType;let f=c.width,d=c.height,m=c.x,p=c.y;return null==n&&t.x&&l&&(n=c.x-t.x),null==r&&t.y&&s&&(r=c.y-t.y),m-=n||0,p-=r||0,f=0,d=0,!o||a?(f="y"===t.axis?c.width:0,d="x"===t.axis?c.height:0,m=l&&null!=t.x?t.x:m,p=s&&null!=t.y?t.y:p):o&&!a&&(d="x"===t.axis?c.height:d,f="y"===t.axis?c.width:f),o=!0,{width:f,height:d,x:m,y:p,top:p,right:m+f,bottom:p+d,left:m}}}}(r.domReference,{x:e,y:t,axis:s,dataRef:o,pointerType:p}))})),b=Te((e=>{null==a&&null==f&&(n?m.current||h([]):y(e.clientX,e.clientY))})),w=C(p)?i:n,R=u.useCallback((()=>{if(!w||!l||null!=a||null!=f)return;const e=E(r.floating.current);function t(n){const o=ue(n);M(r.floating.current,o)?(e.removeEventListener("mousemove",t),m.current=null):y(n.clientX,n.clientY)}if(!o.current.openEvent||Pe(o.current.openEvent)){e.addEventListener("mousemove",t);const n=()=>{e.removeEventListener("mousemove",t),m.current=null};return m.current=n,n}r.setPositionReference(r.domReference.current)}),[o,l,w,r,y,a,f]);return u.useEffect((()=>R()),[R,g]),u.useEffect((()=>{l&&!i&&(d.current=!1)}),[l,i]),u.useEffect((()=>{!l&&n&&(d.current=!0)}),[l,n]),c((()=>{!l||null==a&&null==f||(d.current=!1,y(a,f))}),[l,a,f,y]),u.useMemo((()=>{if(!l)return{};function e(e){let{pointerType:t}=e;v(t)}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove:b,onMouseEnter:b}}}),[l,b])},e.useDelayGroup=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:o}=t;const{currentId:u,setCurrentId:i,initialDelay:l,setState:s,timeoutMs:a}=L();c((()=>{u&&(s({delay:{open:1,close:S(l,"close")}}),u!==o&&r(!1))}),[o,r,s,u,l]),c((()=>{function e(){r(!1),s({delay:l,currentId:null})}if(!n&&u===o){if(a){const t=window.setTimeout(e,a);return()=>{clearTimeout(t)}}e()}}),[n,s,u,o,r,l,a]),c((()=>{n&&i(o)}),[n,i,o])},e.useDelayGroupContext=L,e.useDismiss=function(e,n){void 0===n&&(n={});const{open:r,onOpenChange:o,events:i,nodeId:c,elements:{reference:l,domReference:s,floating:a},dataRef:f}=e,{enabled:d=!0,escapeKey:m=!0,outsidePress:p=!0,outsidePressEvent:v="pointerdown",referencePress:b=!1,referencePressEvent:w="pointerdown",ancestorScroll:k=!1,bubbles:C}=n,M=h(),T=null!=g(),P=Te("function"==typeof p?p:()=>!1),S="function"==typeof p?P:p,A=u.useRef(!1),{escapeKeyBubbles:L,outsidePressBubbles:D}=(e=>{var t,n;return{escapeKeyBubbles:"boolean"==typeof e?e:null!=(t=null==e?void 0:e.escapeKey)&&t,outsidePressBubbles:"boolean"==typeof e?e:null==(n=null==e?void 0:e.outsidePress)||n}})(C),N=Te((e=>{if(!r||!d||!m||"Escape"!==e.key)return;const t=M?oe(M.nodesRef.current,c):[];if(!L&&(e.stopPropagation(),t.length>0)){let e=!0;if(t.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__escapeKeyBubbles||(e=!1)})),!e)return}i.emit("dismiss",{type:"escapeKey",data:{returnFocus:{preventScroll:!1}}}),o(!1)})),F=Te((e=>{const t=A.current;if(A.current=!1,t)return;if("function"==typeof S&&!S(e))return;const n=ue(e);if(x(n)&&a){const t=n.clientWidth>0&&n.scrollWidth>n.clientWidth,r=n.clientHeight>0&&n.scrollHeight>n.clientHeight;let o=r&&e.offsetX>n.clientWidth;if(r){"rtl"===E(a).getComputedStyle(n).direction&&(o=e.offsetX<=n.offsetWidth-n.clientWidth)}if(o||t&&e.offsetY>n.clientHeight)return}const r=M&&oe(M.nodesRef.current,c).some((t=>{var n;return Se(e,null==(n=t.context)?void 0:n.elements.floating)}));if(Se(e,a)||Se(e,s)||r)return;const u=M?oe(M.nodesRef.current,c):[];if(u.length>0){let e=!0;if(u.forEach((t=>{var n;null==(n=t.context)||!n.open||t.context.dataRef.current.__outsidePressBubbles||(e=!1)})),!e)return}i.emit("dismiss",{type:"outsidePress",data:{returnFocus:T?{preventScroll:!0}:I(e)||O(e)}}),o(!1)}));return u.useEffect((()=>{if(!r||!d)return;function e(){o(!1)}f.current.__escapeKeyBubbles=L,f.current.__outsidePressBubbles=D;const n=y(a);m&&n.addEventListener("keydown",N),S&&n.addEventListener(v,F);let u=[];return k&&(R(s)&&(u=t.getOverflowAncestors(s)),R(a)&&(u=u.concat(t.getOverflowAncestors(a))),!R(l)&&l&&l.contextElement&&(u=u.concat(t.getOverflowAncestors(l.contextElement)))),u=u.filter((e=>{var t;return e!==(null==(t=n.defaultView)?void 0:t.visualViewport)})),u.forEach((t=>{t.addEventListener("scroll",e,{passive:!0})})),()=>{m&&n.removeEventListener("keydown",N),S&&n.removeEventListener(v,F),u.forEach((t=>{t.removeEventListener("scroll",e)}))}}),[f,a,s,l,m,S,v,r,o,k,d,L,D,N,F]),u.useEffect((()=>{A.current=!1}),[S,v]),u.useMemo((()=>d?{reference:{onKeyDown:N,[Ae[w]]:()=>{b&&(i.emit("dismiss",{type:"referencePress",data:{returnFocus:!1}}),o(!1))}},floating:{onKeyDown:N,[Le[v]]:()=>{A.current=!0}}}:{}),[d,i,b,v,w,o,N])},e.useFloating=function(e){void 0===e&&(e={});const{open:n=!1,onOpenChange:r,nodeId:o}=e,i=t.useFloating(e),l=h(),s=u.useRef(null),a=u.useRef({}),d=u.useState((()=>m()))[0],p=f(),[v,g]=u.useState(null),y=u.useCallback((e=>{const t=R(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),contextElement:e}:e;i.refs.setReference(t)}),[i.refs]),b=u.useCallback((e=>{(R(e)||null===e)&&(s.current=e,g(e)),(R(i.refs.reference.current)||null===i.refs.reference.current||null!==e&&!R(e))&&i.refs.setReference(e)}),[i.refs]),w=u.useMemo((()=>({...i.refs,setReference:b,setPositionReference:y,domReference:s})),[i.refs,b,y]),E=u.useMemo((()=>({...i.elements,domReference:v})),[i.elements,v]),x=Te(r),I=u.useMemo((()=>({...i,refs:w,elements:E,dataRef:a,nodeId:o,floatingId:p,events:d,open:n,onOpenChange:x})),[i,o,p,d,n,x,w,E]);return c((()=>{const e=null==l?void 0:l.nodesRef.current.find((e=>e.id===o));e&&(e.context=I)})),u.useMemo((()=>({...i,context:I,refs:w,elements:E,reference:b,positionReference:y})),[i,w,E,I,b,y])},e.useFloatingNodeId=e=>{const t=f(),n=h(),r=g(),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=g,e.useFloatingPortalNode=be,e.useFloatingTree=h,e.useFocus=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,events:i,refs:c,elements:{floating:l,domReference:s}}=e,{enabled:a=!0,keyboardOnly:f=!0}=t,d=u.useRef(""),m=u.useRef(!1),p=u.useRef();return u.useEffect((()=>{if(!a)return;const e=y(l).defaultView||window;function t(){!n&&x(s)&&s===te(y(s))&&(m.current=!0)}return e.addEventListener("blur",t),()=>{e.removeEventListener("blur",t)}}),[l,s,n,a]),u.useEffect((()=>{if(a)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(e){"referencePress"!==e.type&&"escapeKey"!==e.type||(m.current=!0)}}),[i,a]),u.useEffect((()=>()=>{clearTimeout(p.current)}),[]),u.useMemo((()=>a?{reference:{onPointerDown(e){let{pointerType:t}=e;d.current=t,m.current=!(!t||!f)},onMouseLeave(){m.current=!1},onFocus(e){var t;m.current||"focus"===e.type&&"mousedown"===(null==(t=o.current.openEvent)?void 0:t.type)&&o.current.openEvent&&Se(o.current.openEvent,s)||(o.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){m.current=!1;const t=e.relatedTarget,n=R(t)&&t.hasAttribute("data-floating-ui-focus-guard")&&"outside"===t.getAttribute("data-type");p.current=setTimeout((()=>{M(c.floating.current,t)||M(s,t)||n||r(!1)}))}}}:{}),[a,f,s,c,o,r])},e.useHover=function(e,t){void 0===t&&(t={});const{open:n,onOpenChange:r,dataRef:o,events:i,elements:{domReference:l,floating:s},refs:a}=e,{enabled:f=!0,delay:d=0,handleClose:m=null,mouseOnly:p=!1,restMs:v=0,move:b=!0}=t,w=h(),E=g(),x=T(m),I=T(d),O=u.useRef(),k=u.useRef(),A=u.useRef(),L=u.useRef(),D=u.useRef(!0),N=u.useRef(!1),F=u.useRef((()=>{})),j=u.useCallback((()=>{var e;const t=null==(e=o.current.openEvent)?void 0:e.type;return(null==t?void 0:t.includes("mouse"))&&"mousedown"!==t}),[o]);u.useEffect((()=>{if(f)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){clearTimeout(k.current),clearTimeout(L.current),D.current=!0}}),[f,i]),u.useEffect((()=>{if(!f||!x.current||!n)return;function e(){j()&&r(!1)}const t=y(s).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[s,n,r,f,x,o,j]);const K=u.useCallback((function(e){void 0===e&&(e=!0);const t=S(I.current,"close",O.current);t&&!A.current?(clearTimeout(k.current),k.current=setTimeout((()=>r(!1)),t)):e&&(clearTimeout(k.current),r(!1))}),[I,r]),_=u.useCallback((()=>{F.current(),A.current=void 0}),[]),B=u.useCallback((()=>{if(N.current){const e=y(a.floating.current).body;e.style.pointerEvents="",e.removeAttribute(P),N.current=!1}}),[a]);return u.useEffect((()=>{if(f&&R(l)){const e=l;return n&&e.addEventListener("mouseleave",c),null==s||s.addEventListener("mouseleave",c),b&&e.addEventListener("mousemove",u,{once:!0}),e.addEventListener("mouseenter",u),e.addEventListener("mouseleave",i),()=>{n&&e.removeEventListener("mouseleave",c),null==s||s.removeEventListener("mouseleave",c),b&&e.removeEventListener("mousemove",u),e.removeEventListener("mouseenter",u),e.removeEventListener("mouseleave",i)}}function t(){return!!o.current.openEvent&&["click","mousedown"].includes(o.current.openEvent.type)}function u(e){if(clearTimeout(k.current),D.current=!1,p&&!C(O.current)||v>0&&0===S(I.current,"open"))return;o.current.openEvent=e;const t=S(I.current,"open",O.current);t?k.current=setTimeout((()=>{r(!0)}),t):r(!0)}function i(r){if(t())return;F.current();const o=y(s);if(clearTimeout(L.current),x.current){n||clearTimeout(k.current),A.current=x.current({...e,tree:w,x:r.clientX,y:r.clientY,onClose(){B(),_(),K()}});const t=A.current;return o.addEventListener("mousemove",t),void(F.current=()=>{o.removeEventListener("mousemove",t)})}("touch"!==O.current||!M(s,r.relatedTarget))&&K()}function c(n){t()||null==x.current||x.current({...e,tree:w,x:n.clientX,y:n.clientY,onClose(){B(),_(),K()}})(n)}}),[l,s,f,e,p,v,b,K,_,B,r,n,w,I,x,o]),c((()=>{var e;if(f&&n&&null!=(e=x.current)&&e.__options.blockPointerEvents&&j()){const e=y(s).body;if(e.setAttribute(P,""),e.style.pointerEvents="none",N.current=!0,R(l)&&s){var t,r;const e=l,n=null==w||null==(t=w.nodesRef.current.find((e=>e.id===E)))||null==(r=t.context)?void 0:r.elements.floating;return n&&(n.style.pointerEvents=""),e.style.pointerEvents="auto",s.style.pointerEvents="auto",()=>{e.style.pointerEvents="",s.style.pointerEvents=""}}}}),[f,n,E,s,l,w,x,o,j]),c((()=>{n||(O.current=void 0,_(),B())}),[n,_,B]),u.useEffect((()=>()=>{_(),clearTimeout(k.current),clearTimeout(L.current),B()}),[f,_,B]),u.useMemo((()=>{if(!f)return{};function e(e){O.current=e.pointerType}return{reference:{onPointerDown:e,onPointerEnter:e,onMouseMove(){n||0===v||(clearTimeout(L.current),L.current=setTimeout((()=>{D.current||r(!0)}),v))}},floating:{onMouseEnter(){clearTimeout(k.current)},onMouseLeave(){i.emit("dismiss",{type:"mouseLeave",data:{returnFocus:!1}}),K(!1)}}}}),[i,f,v,n,r,K])},e.useId=f,e.useInnerOffset=(e,t)=>{let{open:n,elements:o}=e,{enabled:i=!0,overflowRef:c,scrollRef:l,onChange:s}=t;const a=Te(s),f=u.useRef(!1),d=u.useRef(null),m=u.useRef(null);return u.useEffect((()=>{if(!i)return;function e(e){if(e.ctrlKey||!t||null==c.current)return;const n=e.deltaY,o=c.current.top>=-.5,u=c.current.bottom>=-.5,i=t.scrollHeight-t.clientHeight,l=n<0?-1:1,s=n<0?"max":"min";t.scrollHeight<=t.clientHeight||(!o&&n>0||!u&&n<0?(e.preventDefault(),r.flushSync((()=>{a((e=>e+Math[s](n,i*l)))}))):/firefox/i.test(w())&&(t.scrollTop+=n))}const t=(null==l?void 0:l.current)||o.floating;return n&&t?(t.addEventListener("wheel",e),requestAnimationFrame((()=>{d.current=t.scrollTop,null!=c.current&&(m.current={...c.current})})),()=>{d.current=null,m.current=null,t.removeEventListener("wheel",e)}):void 0}),[i,n,o.floating,c,l,a]),u.useMemo((()=>i?{floating:{onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const e=(null==l?void 0:l.current)||o.floating;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)&&r.flushSync((()=>a((e=>e+t))))}requestAnimationFrame((()=>{d.current=e.scrollTop}))}}}}:{}),[i,c,o.floating,l,a])},e.useInteractions=function(e){void 0===e&&(e=[]);const t=e,n=u.useCallback((t=>$e(t,e,"reference")),t),r=u.useCallback((t=>$e(t,e,"floating")),t),o=u.useCallback((t=>$e(t,e,"item")),e.map((e=>null==e?void 0:e.item)));return u.useMemo((()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:o})),[n,r,o])},e.useListItem=function(e){let{label:t}=void 0===e?{}:e;const[n,r]=u.useState(null),o=u.useRef(null),{register:i,unregister:l,map:s,elementsRef:a,labelsRef:f}=u.useContext(xe),d=u.useCallback((e=>{if(o.current=e,null!==n&&(a.current[n]=e,f)){var r;const o=void 0!==t;f.current[n]=o?t:null!=(r=null==e?void 0:e.textContent)?r:null}}),[n,a,f,t]);return c((()=>{const e=o.current;if(e)return i(e),()=>{l(e)}}),[i,l]),c((()=>{const e=o.current?s.get(o.current):null;null!=e&&r(e)}),[s]),u.useMemo((()=>({ref:d,index:null==n?-1:n})),[n,d])},e.useListNavigation=(e,t)=>{const{open:n,onOpenChange:r,refs:o,elements:{domReference:i,floating:l}}=e,{listRef:s,activeIndex:a,onNavigate:f=(()=>{}),enabled:d=!0,selectedIndex:m=null,allowEscape:p=!1,loop:v=!1,nested:w=!1,rtl:E=!1,virtual:R=!1,focusItemOnOpen:C="auto",focusItemOnHover:P=!0,openOnArrowKeyDown:S=!0,disabledIndices:A,orientation:L="vertical",cols:D=1,scrollItemIntoView:N=!0}=t,F=g(),j=h(),K=Te(f),_=u.useRef(C),B=u.useRef(null!=m?m:-1),H=u.useRef(null),q=u.useRef(!0),W=u.useRef(K),U=u.useRef(!!l),z=u.useRef(!1),V=u.useRef(!1),X=T(A),Y=T(n),G=T(N),[Z,$]=u.useState(),Q=Te((function(e,t,n){void 0===n&&(n=!1);const r=e.current[t.current];r&&(R?$(r.id):re(r,{preventScroll:!0,sync:!(!b().toLowerCase().startsWith("mac")||navigator.maxTouchPoints||!k())&&(De||z.current)}),requestAnimationFrame((()=>{const e=G.current;e&&r&&(n||!q.current)&&(null==r.scrollIntoView||r.scrollIntoView("boolean"==typeof e?{block:"nearest",inline:"nearest"}:e))})))}));c((()=>{document.createElement("div").focus({get preventScroll(){return De=!0,!1}})}),[]),c((()=>{d&&(n&&l?_.current&&null!=m&&(V.current=!0,K(m)):U.current&&(B.current=-1,W.current(null)))}),[d,n,l,m,K]),c((()=>{if(d&&n&&l)if(null==a){if(z.current=!1,null!=m)return;if(U.current&&(B.current=-1,Q(s,B)),!U.current&&_.current&&(null!=H.current||!0===_.current&&null==H.current)){let e=0;const t=()=>{if(null==s.current[0]){if(e<2){(e?requestAnimationFrame:queueMicrotask)(t)}e++}else B.current=null==H.current||Ue(H.current,L,E)||w?ze(s,X.current):Ve(s,X.current),H.current=null,K(B.current)};t()}}else Be(s,a)||(B.current=a,Q(s,B,V.current),V.current=!1)}),[d,n,l,a,m,w,s,L,E,K,Q,X]),c((()=>{if(d&&U.current&&!l&&j){var e,t;const n=j.nodesRef.current,r=null==(e=n.find((e=>e.id===F)))||null==(t=e.context)?void 0:t.elements.floating,o=te(y(l)),u=n.some((e=>e.context&&M(e.context.elements.floating,o)));r&&!u&&r.focus({preventScroll:!0})}}),[d,l,j,F]),c((()=>{W.current=K,U.current=!!l})),c((()=>{n||(H.current=null)}),[n]);const J=null!=a,ee=u.useMemo((()=>{function e(e){if(!n)return;const t=s.current.indexOf(e);-1!==t&&K(t)}return{onFocus(t){let{currentTarget:n}=t;e(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...P&&{onMouseMove(t){let{currentTarget:n}=t;e(n)},onPointerLeave(e){let{pointerType:t}=e;q.current&&"touch"!==t&&(B.current=-1,Q(s,B),K(null),R||re(o.floating.current,{preventScroll:!0}))}}}}),[n,o,Q,P,s,K,R]);return u.useMemo((()=>{if(!d)return{};const e=X.current;function t(t){if(q.current=!1,z.current=!0,!Y.current&&t.currentTarget===o.floating.current)return;if(w&&function(e,t,n){return qe(t,n?e===Ke:e===je,e===Ne)}(t.key,L,E))return ce(t),r(!1),void(x(i)&&i.focus());const u=B.current,c=ze(s,e),l=Ve(s,e);if("Home"===t.key&&(ce(t),B.current=c,K(B.current)),"End"===t.key&&(ce(t),B.current=l,K(B.current)),D>1){const n=B.current;if(t.key===Ne){if(ce(t),-1===n)B.current=l;else if(B.current=He(s,{startingIndex:n,amount:D,decrement:!0,disabledIndices:e}),v&&(n-D<c||B.current<0)){const e=n%D,t=l%D,r=l-(t-e);B.current=t===e?l:t>e?r:r-D}Be(s,B.current)&&(B.current=n),K(B.current)}if(t.key===Fe&&(ce(t),-1===n?B.current=c:(B.current=He(s,{startingIndex:n,amount:D,disabledIndices:e}),v&&n+D>l&&(B.current=He(s,{startingIndex:n%D-D,amount:D,disabledIndices:e}))),Be(s,B.current)&&(B.current=n),K(B.current)),"both"===L){const r=Math.floor(n/D);t.key===Ke&&(ce(t),n%D!=D-1?(B.current=He(s,{startingIndex:n,disabledIndices:e}),v&&_e(B.current,D,r)&&(B.current=He(s,{startingIndex:n-n%D-1,disabledIndices:e}))):v&&(B.current=He(s,{startingIndex:n-n%D-1,disabledIndices:e})),_e(B.current,D,r)&&(B.current=n)),t.key===je&&(ce(t),n%D!=0?(B.current=He(s,{startingIndex:n,disabledIndices:e,decrement:!0}),v&&_e(B.current,D,r)&&(B.current=He(s,{startingIndex:n+(D-n%D),decrement:!0,disabledIndices:e}))):v&&(B.current=He(s,{startingIndex:n+(D-n%D),decrement:!0,disabledIndices:e})),_e(B.current,D,r)&&(B.current=n));const o=Math.floor(l/D)===r;return Be(s,B.current)&&(B.current=v&&o?t.key===je?l:He(s,{startingIndex:n-n%D-1,disabledIndices:e}):n),void K(B.current)}}if(We(t.key,L)){if(ce(t),n&&!R&&te(t.currentTarget.ownerDocument)===t.currentTarget)return B.current=Ue(t.key,L,E)?c:l,void K(B.current);Ue(t.key,L,E)?B.current=v?u>=l?p&&u!==s.current.length?-1:c:He(s,{startingIndex:u,disabledIndices:e}):Math.min(l,He(s,{startingIndex:u,disabledIndices:e})):B.current=v?u<=c?p&&-1!==u?s.current.length:l:He(s,{startingIndex:u,decrement:!0,disabledIndices:e}):Math.max(c,He(s,{startingIndex:u,decrement:!0,disabledIndices:e})),Be(s,B.current)?K(null):K(B.current)}}function u(e){"auto"===C&&I(e.nativeEvent)&&(_.current=!0)}const c=R&&n&&J&&{"aria-activedescendant":Z};return{reference:{...c,onKeyDown(o){q.current=!1;const u=0===o.key.indexOf("Arrow");if(R&&n)return t(o);if(!n&&!S&&u)return;const i=u||"Enter"===o.key||""===o.key.trim(),c=We(o.key,L),l=function(e,t,n){return qe(t,n?e===je:e===Ke,e===Fe)}(o.key,L,E);i&&(H.current=w&&c?null:o.key),w?l&&(ce(o),n?(B.current=ze(s,e),K(B.current)):r(!0)):c&&(null!=m&&(B.current=m),ce(o),!n&&S?r(!0):t(o),n&&K(B.current))},onFocus(){n&&K(null)},onPointerDown:function(e){_.current=C,"auto"===C&&O(e.nativeEvent)&&(_.current=!0)},onMouseDown:u,onClick:u},floating:{"aria-orientation":"both"===L?void 0:L,...c,onKeyDown:t,onPointerMove(){q.current=!0}},item:ee}}),[i,o,Z,X,Y,s,d,L,E,R,n,J,w,m,S,p,D,v,C,K,r,ee])},e.useMergeRefs=function(e){return u.useMemo((()=>e.every((e=>null==e))?null:t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}),e)},e.useRole=function(e,t){void 0===t&&(t={});const{open:n,floatingId:r}=e,{enabled:o=!0,role:i="dialog"}=t,c=f();return u.useMemo((()=>{const e={id:r,role:i};return o?"tooltip"===i?{reference:{"aria-describedby":n?r:void 0},floating:e}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":"alertdialog"===i?"dialog":i,"aria-controls":n?r:void 0,..."listbox"===i&&{role:"combobox"},..."menu"===i&&{id:c}},floating:{...e,..."menu"===i&&{"aria-labelledby":c}}}:{}}),[o,i,n,r,c])},e.useTransitionStatus=Ge,e.useTransitionStyles=function(e,t){void 0===t&&(t={});const{initial:n={opacity:0},open:r,close:o,common:i,duration:l=250}=t,s=e.placement,a=s.split("-")[0],f=u.useMemo((()=>({side:a,placement:s})),[a,s]),d="number"==typeof l,m=(d?l:l.open)||0,p=(d?l:l.close)||0,[v,g]=u.useState((()=>({...Ye(i,f),...Ye(n,f)}))),{isMounted:h,status:y}=Ge(e,{duration:l}),b=T(n),w=T(r),E=T(o),R=T(i);return c((()=>{const e=Ye(b.current,f),t=Ye(E.current,f),n=Ye(R.current,f),r=Ye(w.current,f)||Object.keys(e).reduce(((e,t)=>(e[t]="",e)),{});if("initial"===y&&g((t=>({transitionProperty:t.transitionProperty,...n,...e}))),"open"===y&&g({transitionProperty:Object.keys(r).map(Xe).join(","),transitionDuration:m+"ms",...n,...r}),"close"===y){const r=t||e;g({transitionProperty:Object.keys(r).map(Xe).join(","),transitionDuration:p+"ms",...n,...r})}}),[p,E,b,w,R,m,y,f]),{isMounted:h,styles:v}},e.useTypeahead=(e,t)=>{var n;const{open:r,dataRef:o}=e,{listRef:i,activeIndex:l,onMatch:s,onTypingChange:a,enabled:f=!0,findMatch:d=null,resetMs:m=750,ignoreKeys:p=[],selectedIndex:v=null}=t,g=u.useRef(),h=u.useRef(""),y=u.useRef(null!=(n=null!=v?v:l)?n:-1),b=u.useRef(null),w=Te(s),E=Te(a),R=T(d),x=T(p);return c((()=>{r&&(clearTimeout(g.current),b.current=null,h.current="")}),[r]),c((()=>{var e;r&&""===h.current&&(y.current=null!=(e=null!=v?v:l)?e:-1)}),[r,v,l]),u.useMemo((()=>{if(!f)return{};function e(e){e?o.current.typing||(o.current.typing=e,E(e)):o.current.typing&&(o.current.typing=e,E(e))}function t(e,t,n){const r=R.current?R.current(t,n):t.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(n.toLocaleLowerCase()))));return r?e.indexOf(r):-1}function n(n){const o=i.current;if(h.current.length>0&&" "!==h.current[0]&&(-1===t(o,o,h.current)?e(!1):" "===n.key&&ce(n)),null==o||x.current.includes(n.key)||1!==n.key.length||n.ctrlKey||n.metaKey||n.altKey)return;r&&" "!==n.key&&(ce(n),e(!0));o.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&h.current===n.key&&(h.current="",y.current=b.current),h.current+=n.key,clearTimeout(g.current),g.current=setTimeout((()=>{h.current="",y.current=b.current,e(!1)}),m);const u=y.current,c=t(o,[...o.slice((u||0)+1),...o.slice(0,(u||0)+1)],h.current);-1!==c?(w(c),b.current=c):(h.current="",e(!1))}return{reference:{onKeyDown:n},floating:{onKeyDown:n}}}),[f,r,o,i,m,x,R,w,E])},Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@floating-ui/react", | ||
"version": "0.22.3", | ||
"version": "0.23.0", | ||
"@rollingversions": { | ||
@@ -5,0 +5,0 @@ "baseVersion": [ |
export { FloatingArrow } from './components/FloatingArrow'; | ||
export { FloatingDelayGroup, useDelayGroup, useDelayGroupContext, } from './components/FloatingDelayGroup'; | ||
export { FloatingFocusManager } from './components/FloatingFocusManager'; | ||
export { FloatingList, useListItem } from './components/FloatingList'; | ||
export { FloatingOverlay } from './components/FloatingOverlay'; | ||
@@ -5,0 +6,0 @@ export { FloatingPortal, useFloatingPortalNode, } from './components/FloatingPortal'; |
import type { HandleCloseFn } from './hooks/useHover'; | ||
import type { ReferenceType } from './types'; | ||
export declare function safePolygon<RT extends ReferenceType = ReferenceType>({ restMs, buffer, blockPointerEvents, }?: Partial<{ | ||
restMs: number; | ||
export declare function safePolygon<RT extends ReferenceType = ReferenceType>({ buffer, blockPointerEvents, requireIntent, }?: Partial<{ | ||
buffer: number; | ||
blockPointerEvents: boolean; | ||
requireIntent: boolean; | ||
}>): HandleCloseFn<RT>; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
572513
50
12960
61
2
3
1
25