import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useMemo as n,useRef as o,useEffect as i,useCallback as r}from"react";import{useMultiSelectDraftValue as l}from"../../hooks/useMultiSelectDraftValue.js";import{VirtualizedListBox as a}from"../VirtualizedListBox/VirtualizedListBox.js";import s from"../../Filter.module.css.js";import{AutocompleteNext as u}from"../../../../../../componentsV2/Autocomplete/Autocomplete.js";import{Chip as p}from"../../../../../../componentsV2/Chip/Chip.js";import{TextMiddleTruncated as c}from"../../../../../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.js";import"../../../../../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.constants.js";import d from"../../../../../../effects/useOutsideClick.js";var m=function(m){var f=m.label,C=m.options,h=m.value,v=m.onChange,x=m.renderOptionPrefix,T=m.testId,j=m.dropdownClassName,b=m.loading,g=m.disabled,M=n((function(){return C.map((function(e){return{id:e.id,title:e.title,prefix:null==x?void 0:x(e)}}))}),[C,x]),N=n((function(){return M.map((function(e){return e.id}))}),[M]),V=o(null),y=l({value:h,optionIds:N,onChange:v}),I=y.value,k=y.onChange,A=y.startInteraction,O=y.endInteraction;d(V,(function(){return O()}),[".MuiAutocomplete-popper"]),i((function(){g&&O()}),[g,O]);var w=r((function(){g||A()}),[g,A]),z=r((function(e){var t=e.map((function(e){return e.id}));k(t)}),[k]),B=r((function(e){return function(t){t.stopPropagation(),k([e])}}),[k]),F=r((function(n){return e("div",{className:s.optionRow,children:[t(c,{className:s.optionTitle,children:n.title}),t(p,{state:"neutral",size:"small",shape:"square",className:s.onlyButton,onClick:B(n.id),children:"Only"})]})}),[B]),D=r((function(e){"Escape"!==e.key&&"Tab"!==e.key||O()}),[O]);return t("div",{ref:V,onFocusCapture:w,onKeyDownCapture:D,children:t(u,{label:f,options:M,value:g?[]:I,onChange:z,renderOption:F,multiple:!0,useAllOption:!0,clearable:!1,testId:T,dropdownClassName:j,listboxComponent:a,elementsClassNames:{input:s.filterInput},loading:b,disabled:g,placeholder:g?"All":void 0})})};m.displayName="MultiFilterSelect";export{m as MultiFilterSelect};
//# sourceMappingURL=MultiFilterSelect.js.map
