import{__assign as o}from'./../../ext-esm/tslib/tslib.es6.js';import{jsxs as n,jsx as t}from"react/jsx-runtime";import{useState as r,useRef as i,useEffect as c}from"react";import{makeStyles as e,InputLabel as s,Tooltip as a,IconButton as l,Popover as p}from"@material-ui/core";import m from"chroma-js";import u from"classnames";import d from"./PaletteChromePicker/PaletteChromePicker.js";import{PaletteIcon as b}from"../../icons/iconParkIcons.js";import"../../icons/customIcons/icons/AddMessage.js";import"../../icons/customIcons/icons/Attention.js";import"../../icons/customIcons/icons/Collapse.js";import"../../icons/customIcons/icons/Dashboard.js";import"../../icons/customIcons/icons/Expand.js";import"../../icons/customIcons/icons/FolderClosed.js";import"../../icons/customIcons/icons/FolderClosedFilled.js";import"../../icons/customIcons/icons/FolderOpened.js";import"../../icons/customIcons/icons/GreaterOrEqual.js";import"../../icons/customIcons/icons/LessOrEqual.js";import"../../icons/customIcons/icons/Search.js";import"../../icons/customIcons/icons/Wellhub.js";import"../../icons/customIcons/icons/MultiRuler.js";import"../../icons/customIcons/icons/Checkbox.js";import"../../icons/customIcons/icons/CheckboxChecked.js";import"../../icons/customIcons/icons/CheckboxIndeterminate.js";import"../../icons/customIcons/icons/Radio.js";import"../../icons/customIcons/icons/RadioChecked.js";import"../../icons/customIcons/icons/SimulFrac.js";import"../../icons/customIcons/icons/ZipperFrac.js";import"../../icons/customIcons/icons/CautionFilled.js";import"../../icons/customIcons/icons/MoreApp.js";import{getValidColor as g,getButtonStrokeColor as h,findParentBackground as f}from"./ColorPicketUtils.js";var x={rgba:function(o){return"rgba(".concat(o.rgb.r,", ").concat(o.rgb.g,", ").concat(o.rgb.b,", ").concat(o.rgb.a,")")},rgb:function(o){return"rgb(".concat(o.rgb.r,", ").concat(o.rgb.g,", ").concat(o.rgb.b,")")},hex:function(o){return o.hex},rgba_rgb:function(o){return 1===o.rgb.a?x.rgb(o):x.rgba(o)},rgba_hex:function(o){return 1===o.rgb.a?x.hex(o):x.rgba(o)}},I=e({root:{position:"relative",display:"flex"},topLabelRoot:{flexDirection:"column"},rightLabelRoot:{flexDirection:"row-reverse",justifyContent:"flex-end",alignItems:"center"},button:{width:"36px",height:"24px",boxShadow:"0px 3px 6px rgba(0, 0, 0, 0.161)",borderRadius:"5px",fontSize:"1rem"},buttonTransparent:{position:"relative",backgroundImage:"url(".concat("/static/media/39f55985e0da1489ad22264208b0493d.svg",")"),backgroundSize:"cover",backgroundPosition:"center","&::before":{content:'""',position:"absolute",display:"block",width:"100%",height:"3px",background:"#FF0000",transform:"rotate(148deg)",borderRadius:"2px"}},colorLensIcon:{position:"relative",zIndex:2},popper:{zIndex:1500},topLabel:{marginBottom:"8px",fontSize:"15px",lineHeight:"17px",letterSpacing:"0.4px",color:"#BDBDBD",whiteSpace:"nowrap"},rightLabel:{marginLeft:"8px",fontSize:"16px"}}),j=function(e){var j,v,C,k=e.label,L=void 0===k?"Color":k,P=e.value,z=e.converter,R=void 0===z?"rgba_hex":z,S=e.onChange,F=e.buttonClassName,D=e.popoverAnchorOrigin,O=void 0===D?{vertical:"bottom",horizontal:"left"}:D,T=e.popoverTransformOrigin,w=void 0===T?{vertical:"top",horizontal:"left"}:T,y=e.labelPosition,B=void 0===y?"top":y,_=e.hideLabel,N=void 0!==_&&_,A=e.pickerComponent,E=void 0===A?d:A,M=e.lensColor,q=e.enableTransparencyPalette,G=void 0!==q&&q,H=e["data-testid"],U=void 0===H?"ColorPicker":H,W=e.tooltipProps,Z=void 0===W?{title:"Change color",children:null}:W,J=I(),K=r(null),Q=K[0],V=K[1],X=r((function(){return g(P)||"#03BCD4"})),Y=X[0],$=X[1],oo=i(),no=r(null),to=no[0],ro=no[1],io=M||h(to,P);c((function(){var o=g(P);o?$(o):console.error("The color value(".concat(P,") is not valid, please check it."))}),[P]);return n("div",o({className:u(J.root,(j={},j[J.topLabelRoot]="top"===B,j[J.rightLabelRoot]="right"===B,j)),ref:function(o){return ro(f(o))}},{children:[!N&&t(s,o({className:u((v={},v[J.topLabel]="top"===B,v[J.rightLabel]="right"===B,v)),shrink:!0},{children:L})),t(a,o({title:Z.title},Z,{children:t(l,o({"data-testid":"".concat(U,"_icon_").concat(L),className:u(J.button,F,(C={},C[J.buttonTransparent]=0===m(Y).alpha(),C)),disableRipple:!0,style:{backgroundColor:Y,color:io},onClick:function(o){V(o.currentTarget)},size:"small"},{children:t(b,{size:16,className:J.colorLensIcon})}))})),t(p,o({id:"colors-popper",action:oo,open:Boolean(Q),anchorEl:Q,onClose:function(){V(null)},anchorOrigin:O,transformOrigin:w},{children:t(E,{color:Y,onChange:function(o){var n=x[R](o);$(n),S(n)},onSizeChange:function(){oo.current&&oo.current.updatePosition()},enableTransparencyPalette:G})}))]}))};export{j as default};
