1import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-C21x__mS.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{Nt as r,Xt as i,Yt as a}from"./store-BKpYtGn4.js";import{k as o}from"./accounts-5t7gWyVC.js";import{o as s,s as c}from"./typed_functions-Whap35TF.js";import{y as l}from"./filters-Br4s8K7f.js";import{t as u}from"./react-router-dom-C1dtKQUg.js";import{n as d,t as f}from"./modal-CMPL9eyP.js";import{t as p}from"./classnames-CfLRLWYq.js";import{n as m}from"./loading_indicator-eceYQNAM.js";import{t as h}from"./icon_button-DfNtv8BJ.js";import{t as g}from"./icon-BNrUFRb_.js";import{t as _}from"./popover-CMoU7E4P.js";var v=e(t()),y=e(p()),b=e=>e===null||typeof e==`object`&&`text`in e,x=e=>!e||!b(e)?!1:`action`in e,S=e=>!e||!b(e)?!1:`href`in e,C=n(),w=0,T=({item:e})=>{if(e===null)return null;let{text:t,description:n,icon:r,iconId:i}=e;return(0,C.jsxs)(C.Fragment,{children:[r&&(0,C.jsx)(g,{icon:r,id:i??t.toLowerCase().replaceAll(/[^a-z]+/g,`-`)}),(0,C.jsxs)(`span`,{className:`dropdown-menu__item-content`,children:[t,!!n&&(0,C.jsx)(`span`,{className:`dropdown-menu__item-subtitle`,children:n})]})]})},E=({items:e,loading:t,scrollable:n,onClose:r,openedViaKeyboard:i,renderItem:a,renderHeader:o,onItemClick:s})=>{let c=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=e=>{e.target instanceof Node&&c.current&&!c.current.contains(e.target)&&(r(),e.stopPropagation(),e.preventDefault())},t=e=>{if(!c.current)return;let t=Array.from(c.current.querySelectorAll(`a, button`)),n=document.activeElement?t.indexOf(document.activeElement):-1,i;switch(e.key){case`ArrowDown`:i=t[n+1]??t[0];break;case`ArrowUp`:i=t[n-1]??t[t.length-1];break;case`Tab`:i=e.shiftKey?t[n-1]??t[t.length-1]:t[n+1]??t[0];break;case`Home`:i=t[0];break;case`End`:i=t[t.length-1];break;case`Escape`:r()}i&&i instanceof HTMLElement&&(i.focus(),e.preventDefault(),e.stopPropagation())};return document.addEventListener(`click`,e,{capture:!0}),document.addEventListener(`keydown`,t,{capture:!0}),i&&(c.current?.querySelector(`li:first-child > :is(a, button)`))?.focus({preventScroll:!0}),()=>{document.removeEventListener(`click`,e,{capture:!0}),document.removeEventListener(`keydown`,t,{capture:!0})}},[r,i]);let l=(0,v.useCallback)(t=>{let n=Number(t.currentTarget.getAttribute(`data-index`)),i=e?.[n],a=!!(i&&typeof i==`object`&&`disabled`in i&&i.disabled);!i||a||(r(),typeof s==`function`?(t.preventDefault(),s(i,n)):x(i)&&(t.preventDefault(),i.action(t)))},[r,s,e]),d=a??((e,t)=>{if(!b(e))return null;if(e===null)return(0,C.jsx)(`li`,{className:`dropdown-menu__separator`},`sep-${t}`);let{text:n,highlighted:r,disabled:i,dangerous:a}=e,o;return o=x(e)?(0,C.jsx)(`button`,{onClick:l,"data-index":t,"aria-disabled":i,type:`button`,children:(0,C.jsx)(T,{item:e})}):S(e)?(0,C.jsx)(`a`,{href:e.href,target:e.target??`_target`,"data-method":e.method,rel:`noopener`,onClick:l,"data-index":t,children:(0,C.jsx)(T,{item:e})}):(0,C.jsx)(u,{to:e.to,onClick:l,"data-index":t,children:(0,C.jsx)(T,{item:e})}),(0,C.jsx)(`li`,{className:(0,y.default)(`dropdown-menu__item`,{"dropdown-menu__item--highlighted":r,"dropdown-menu__item--dangerous":a}),children:o},`${n}-${t}`)});return(0,C.jsxs)(`div`,{className:(0,y.default)(`dropdown-menu__container`,{"dropdown-menu__container--loading":t}),ref:c,children:[(t||!e)&&(0,C.jsx)(m,{size:30,strokeWidth:3.5}),!t&&o&&e&&(0,C.jsx)(`div`,{className:`dropdown-menu__container__header`,children:o(e)}),!t&&e&&(0,C.jsx)(`ul`,{className:(0,y.default)(`dropdown-menu__container__list`,{"dropdown-menu__container__list--scrollable":n}),children:e.map((e,t)=>d(e,t,l))})]})},D=({children:e,icon:t,iconComponent:n,iconClassName:u,items:p,loading:m,title:g=`Menu`,disabled:y,scrollable:b,placement:S=`bottom`,offset:T=5,status:D,needsStatusRefresh:O,forceDropdown:k=!1,className:A,renderItem:j,renderHeader:M,onOpen:N,onItemClick:P,scrollKey:F})=>{let I=s(),L=c(e=>e.dropdownMenu.openId),R=c(e=>e.dropdownMenu.keyboard),[z]=(0,v.useState)(w++),B=z===L,[V,H]=(0,v.useState)(null),U=(0,v.useId)(),W=D?D.getIn([`account`,`id`]):void 0,G=D?.get(`id`),K=(0,v.useCallback)(()=>{V&&V.focus({preventScroll:!0}),I(f({modalType:`ACTIONS`,ignoreFocus:!1})),I(a({id:z}))},[V,I,z]),q=(0,v.useCallback)(e=>{let t=Number(e.currentTarget.getAttribute(`data-index`)),n=p?.[t];K(),n&&(typeof P==`function`?(e.preventDefault(),P(n,t)):x(n)&&(e.preventDefault(),n.action(e)))},[K,P,p]),J=(0,v.useRef)(!1),Y=(0,v.useCallback)(e=>{(e.key===` `||e.key===`Enter`)&&(J.current=!0)},[]),X=(0,v.useCallback)(()=>{J.current=!1},[]),Z=(0,v.useCallback)(e=>{if(B)K();else{if(N?.(e)===!1)return;W&&I(o([W])),O&&G&&I(l(G,{forceFetch:!0,alsoFetchContext:!1})),r()&&!k?I(d({modalType:`ACTIONS`,modalProps:{actions:p,onClick:q,className:A}})):(I(i({id:z,keyboard:J.current,scrollKey:F})),J.current=!1)}},[I,z,W,F,N,q,B,p,k,K,G,O,A]);(0,v.useEffect)(()=>()=>{z===L&&K()},[z,L,K]);let Q,$={disabled:y,onClick:Z,onKeyDown:Y,onKeyUp:X,onBlur:X,"aria-expanded":B,"aria-controls":U,ref:H};if(e)Q=(0,v.cloneElement)(v.Children.only(e),$);else if(t&&n)Q=(0,C.jsx)(h,{icon:B?`close`:t,iconComponent:n,title:g,active:B,className:u,...$});else return null;return(0,C.jsxs)(C.Fragment,{children:[Q,(0,C.jsx)(_,{isOpen:B,onClose:K,offset:T,placement:S,reference:V,children:({props:e,placement:t})=>(0,C.jsx)(`div`,{...e,className:A,id:U,children:(0,C.jsx)(`div`,{className:`dropdown-animation dropdown-menu ${t}`,children:(0,C.jsx)(E,{items:p,loading:m,scrollable:b,onClose:K,openedViaKeyboard:R,renderItem:j,renderHeader:M,onItemClick:P})})})})]})};export{S as a,x as i,E as n,T as r,D as t}; 2//# sourceMappingURL=dropdown_menu-U6SI6ReI.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.