"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4219],{15741:function(e,t,n){n.r(t),n.d(t,{default:function(){return Dropdown_DropdownMenu}});var r=n(44194),o=n(56321),u=n(55494);let useDropdownPosition=(e="left")=>{let{dropdownTriggerRef:t,isOpen:n}=(0,u.x)(),[o,d]=(0,r.useState)({top:0,left:0,right:"auto",transform:"none",loading:!0});return(0,r.useEffect)(()=>{let updateMenuPosition=()=>{let n="undefined"!=typeof window;if(!t?.current)return;let r=t.current.getBoundingClientRect(),o=r?.top??0,u=r?.height??0,s=r?.left??0,a=r?.width??0,l=n?document?.documentElement?.scrollTop:0,c=n?document?.documentElement?.scrollLeft:0,i=s+c,p="auto",f="none";"right"===e?(p=`${document.documentElement.clientWidth-s-a}px`,i="auto"):"center"===e&&(i=s+a/2+c,f="translateX(-50%)"),d({top:o+u+l,left:i,right:p,transform:f,loading:!1})};return n&&(updateMenuPosition(),window.addEventListener("resize",updateMenuPosition)),()=>{window.removeEventListener("resize",updateMenuPosition)}},[t,n,e]),{...o,position:"absolute"}};var Dropdown_DropdownMenu=({children:e,testId:t="fs-dropdown-menu",size:n="regular",align:d="left",style:s,...a})=>{let{isOpen:l,close:c,dropdownItemsRef:i,selectedDropdownItemIndexRef:p,dropdownTriggerRef:f,id:w}=(0,u.x)(),{loading:h,...m}=useDropdownPosition(d),P=r.Children.toArray(e).length,handleDownPress=()=>{p.current<P-1?p.current++:p.current=0,i?.current[p.current]?.focus()},handleUpPress=()=>{p.current>0?p.current--:p.current=P-1,i?.current[p.current]?.focus()},handleHomePress=()=>{p.current=0,i?.current[p.current]?.focus()},handleEndPress=()=>{p.current=P-1,i?.current[p.current]?.focus()},handleEscapePress=()=>{c?.(),f?.current?.focus()},handleKeyNavigatePress=e=>{let t=i?.current??[],n=p.current,r=[...t.slice(n+1),...t.slice(0,n+1)],o=r.find(t=>t.textContent?.[0]?.toLowerCase()===e.toLowerCase());o&&(p.current=t.indexOf(o),o.focus())};return l&&!h?(0,o.createPortal)(r.createElement("div",{role:"presentation","data-fs-dropdown-overlay":!0,onKeyDown:e=>{if(!e.defaultPrevented&&"Enter"!==e.key&&" "!==e.key){switch(e.preventDefault(),e.key){case"Escape":handleEscapePress();break;case"ArrowDown":handleDownPress();break;case"ArrowUp":handleUpPress();break;case"Home":handleHomePress();break;case"End":handleEndPress();break;default:handleKeyNavigatePress(e.key)}e.stopPropagation()}},"data-testid":`${t}-overlay`},r.createElement("div",{role:"menu","aria-orientation":"vertical","data-fs-dropdown-menu":!0,"data-fs-dropdown-menu-size":n,"data-testid":t,style:{...m,...s},id:w,...a},e)),document.body):(i.current=[],null)}},49642:function(e,t,n){var r=n(44194);let o=(0,r.createContext)({isOpen:!1,dropdownTriggerRef:null,selectedDropdownItemIndexRef:null,dropdownItemsRef:null,id:"fs-dropdown"});t.Z=o},55494:function(e,t,n){n.d(t,{x:function(){return useDropdown}});var r=n(44194),o=n(49642);let useDropdown=()=>{let e=(0,r.useContext)(o.Z);if(void 0===e)throw Error("Do not use useDropdown hook outside the Dropdown context.");return e}}}]);