import{defineProperty as o}from"../../../../../_virtual/_rollupPluginBabelHelpers.js";import e from"classnames";import t,{useRef as n,useEffect as i,useCallback as r,useMemo as s}from"react";import l from"../../../Tooltip/Tooltip.js";import c from"../../../../hooks/useIsOverflowing/useIsOverflowing.js";import{keyCodes as a}from"../../../../constants/keyCodes.js";import"../../../../constants/sizes.js";import{getOptionId as p}from"../../helpers.js";import{withStaticPropsWithoutForwardRef as m}from"../../../../types/withStaticProps.js";import"../../../../utils/colors-vars-map.js";import{ComboboxOptionIconType as f}from"../ComboboxConstants.js";import{getTestId as u,ComponentDefaultTestId as d}from"../../../../tests/testIds.js";import v from"./ComboboxOption.module.scss.js";import b from"../../../../../components/icon/dist/Icon/Icon.js";var O=m((function(m){var f=m.index,O=m.option,h=m.className,y=m.isActive,j=m.visualFocus,I=m.scrollRef,g=m.scrollOffset,T=void 0===g?100:g,C=m.onOptionClick,E=m.onOptionLeave,k=m.onOptionHover,N=m.optionLineHeight,P=m.shouldScrollWhenActive,S=void 0===P||P,w=m.optionRenderer,x=void 0===w?null:w,L=O.id,H=O.leftIcon,R=O.leftIconType,z=O.rightIcon,A=O.rightIconType,B=O.label,F=O.iconSize,M=void 0===F?18:F,_=O.disabled,W=O.selected,D=O.ariaLabel,K=O.belongToCategory,V=void 0!==K&&K,X=O.tooltipContent,q=n(null),G=n(),J=c({ref:G});i((function(){var o,e=q.current;j&&e&&S&&((null==I?void 0:I.current)&&e?I.current.scrollTop=e.offsetTop-T:null===(o=null==e?void 0:e.scrollIntoView)||void 0===o||o.call(e,{behaviour:"smooth"}))}),[q,j,S,I,T,V]);var Q=function(o,n,i){return"renderer"===n?o(e(v.optionIcon,i)):t.createElement(b,{className:e(v.optionIcon,i),iconType:"font",icon:o,iconSize:M,ignoreFocusStyle:!0})},U=r((function(o){_||C(o,f,O,!0)}),[f,O,C,_]),Y=r((function(o){_||E(o,f,O,!0)}),[f,O,E,_]),Z=r((function(o){_||k(o,f,O,!0)}),[f,O,k,_]),$=r((function(o){o.key!==a.ENTER&&o.key!==a.SPACE||C(o,f,O,!1)}),[C,f,O]);X||(X=J?B:null);var oo=s((function(){return x&&x(O)}),[x,O]),eo=t.createElement(t.Fragment,null,H&&Q(H,R,v.left),t.createElement("div",{ref:G,className:e(v.optionLabel)},B),z&&Q(z,A,""));return t.createElement(l,Object.assign({},O.tooltipProps,{content:X,hideWhenReferenceHidden:!0}),t.createElement("div",{ref:q,key:L||B,"aria-level":V?2:1,"aria-selected":y,"aria-label":D||B,id:p(L,f),"data-testid":u(d.COMBOBOX_OPTION,f),onMouseEnter:Z,onClick:U,onKeyDown:$,onMouseLeave:Y,className:e(v.comboboxOption,h,o(o(o(o({},v.disabled,_),v.selected,W),v.active,y),v.activeOutline,j)),style:{height:N}},oo||eo))}),{iconTypes:f});export{O as default};
//# sourceMappingURL=ComboboxOption.js.map
