"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4983],{7169:function(e,t,n){n.r(t);var r=n(4194),u=n(9642);t.default=({children:e,isOpen:t,onDismiss:n,id:c="fs-dropdown"})=>{let[s,l]=(0,r.useState)(!1),o=(0,r.useRef)([]),f=(0,r.useRef)(0),a=(0,r.useRef)(null),d=t??s,i=(0,r.useCallback)(()=>{l(!1),n?.()},[n]),open=()=>{l(!0)},v=(0,r.useCallback)(()=>{l(e=>(e&&(n?.(),a.current?.focus()),!e))},[n]),p=(0,r.useCallback)(e=>{a.current=e},[]);(0,r.useEffect)(()=>{l(t??!1)},[t]),(0,r.useEffect)(()=>{d&&o?.current[0]?.focus()},[d]),(0,r.useEffect)(()=>{let e=!0,event=t=>{let n=o?.current.some(e=>t.target===e||e.contains(t.target));if(e){e=!1;return}n||i()};return d?document.addEventListener("click",event):document.removeEventListener("click",event),()=>{document.removeEventListener("click",event)}},[i,d]);let k=(0,r.useMemo)(()=>({isOpen:d,close:i,open,toggle:v,dropdownTriggerRef:a,addDropdownTriggerRef:p,selectedDropdownItemIndexRef:f,dropdownItemsRef:o,id:c}),[d,i,v,p,c]);return r.createElement(u.Z.Provider,{value:k},e)}},9642:function(e,t,n){var r=n(4194);let u=(0,r.createContext)({isOpen:!1,dropdownTriggerRef:null,selectedDropdownItemIndexRef:null,dropdownItemsRef:null,id:"fs-dropdown"});t.Z=u}}]);