import{defineProperty as e}from"../../../../../_virtual/_rollupPluginBabelHelpers.js";import{camelCase as o}from"es-toolkit";import{getStyle as t}from"../../../../helpers/typesciptCssModulesHelper.js";import r from"classnames";import n,{forwardRef as l,useMemo as s,useRef as c,useCallback as i,useEffect as a}from"react";import{contentColors as m}from"../../../../utils/colors-vars-map.js";import u from"../../../../utils/colors-utils.js";import d from"../../../Tooltip/Tooltip.js";import p from"../../../Clickable/Clickable.js";import{getTestId as f}from"../../../../tests/testIds.js";import{ComponentDefaultTestId as v}from"../../../../tests/constants.js";import I from"./ColorPickerItemComponent.module.scss.js";import C from"../../../../../components/icon/dist/Icon/Icon.js";var g=l((function(l,g){var y=l.color,E=l.onColorClicked,k=l.colorStyle,j=void 0===k?"regular":k,b=l.shouldRenderIndicatorWithoutBackground,S=l.ColorIndicatorIcon,h=l.SelectedIndicatorIcon,L=void 0===h?S:h,M=l.isSelected,N=l.colorSize,P=l.tooltipContent,T=l.isActive,W=l.colorShape,_=l["data-testid"],x=s((function(){return m.includes(y)}),[y]),A=x?u.getMondayColorAsStyle(y,j):y,R=c(null),z=i((function(){return E(y)}),[E,y]);a((function(){if((null==R?void 0:R.current)&&!b&&x){var e=R.current,o=function(e){e.target.style.background=u.getMondayColorAsStyle(y,"selected"===j?"regular":"hover")},t=function(e){e.target.style.background=A};return e.addEventListener("mouseenter",o,!1),e.addEventListener("mouseleave",t,!1),function(){e.removeEventListener("mouseenter",o,!1),e.removeEventListener("mouseleave",t,!1)}}}),[y,A,j,x,R,b]);var B=M||S,D=b?{color:A}:{};return n.createElement(d,{content:P},n.createElement("li",{className:r(I.itemWrapper,e(e(e({},I.selectedColor,M),I.active,T),I.circle,"circle"===W)),"data-testid":_||f(v.COLOR_PICKER_ITEM,y)},n.createElement("div",{className:r(I.feedbackIndicator)}),n.createElement(p,{ref:R,ariaLabel:y,className:r(I.colorItem,t(I,o("color-item-size-"+N)),e({},I.colorItemTextMode,b)),style:{background:b?"transparent":A},onClick:z,tabIndex:"-1",onMouseDown:function(e){return e.preventDefault()}},n.createElement("div",{className:r(I.colorIndicatorWrapper),style:D},B&&n.createElement(C,{icon:M?L:S,className:r(e({},I.colorIconWhite,!b)),ignoreFocusStyle:!0})))))}));export{g as default};
//# sourceMappingURL=ColorPickerItemComponent.js.map
