"use strict";var o=require('./../../ext-esm/tslib/tslib.es6.js'),e=require("react/jsx-runtime"),r=require("react"),n=require("@material-ui/core"),t=require("chroma-js"),i=require("classnames"),c=require("./PaletteChromePicker/PaletteChromePicker.js"),s=require("../../icons/iconParkIcons.js");require("../../icons/customIcons/icons/AddMessage.js"),require("../../icons/customIcons/icons/Attention.js"),require("../../icons/customIcons/icons/Collapse.js"),require("../../icons/customIcons/icons/Dashboard.js"),require("../../icons/customIcons/icons/Expand.js"),require("../../icons/customIcons/icons/FolderClosed.js"),require("../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../icons/customIcons/icons/FolderOpened.js"),require("../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../icons/customIcons/icons/LessOrEqual.js"),require("../../icons/customIcons/icons/Search.js"),require("../../icons/customIcons/icons/Wellhub.js"),require("../../icons/customIcons/icons/MultiRuler.js"),require("../../icons/customIcons/icons/Checkbox.js"),require("../../icons/customIcons/icons/CheckboxChecked.js"),require("../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../icons/customIcons/icons/Radio.js"),require("../../icons/customIcons/icons/RadioChecked.js"),require("../../icons/customIcons/icons/SimulFrac.js"),require("../../icons/customIcons/icons/ZipperFrac.js"),require("../../icons/customIcons/icons/CautionFilled.js"),require("../../icons/customIcons/icons/MoreApp.js");var a=require("./ColorPicketUtils.js");function l(o){return o&&"object"==typeof o&&"default"in o?o:{default:o}}var u=l(t),d=l(i),p={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?p.rgb(o):p.rgba(o)},rgba_hex:function(o){return 1===o.rgb.a?p.hex(o):p.rgba(o)}},b=n.makeStyles({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:"16px",letterSpacing:"0.4px",color:"#BDBDBD",whiteSpace:"nowrap"},rightLabel:{marginLeft:"8px",fontSize:"16px"}});module.exports=function(t){var i,l,g,m=t.label,h=void 0===m?"Color":m,f=t.value,x=t.converter,j=void 0===x?"rgba_hex":x,q=t.onChange,I=t.buttonClassName,v=t.popoverAnchorOrigin,C=void 0===v?{vertical:"bottom",horizontal:"left"}:v,k=t.popoverTransformOrigin,P=void 0===k?{vertical:"top",horizontal:"left"}:k,S=t.labelPosition,L=void 0===S?"top":S,z=t.hideLabel,R=void 0!==z&&z,B=t.pickerComponent,F=void 0===B?c:B,y=t.lensColor,T=t.enableTransparencyPalette,_=void 0!==T&&T,D=t["data-testid"],O=void 0===D?"ColorPicker":D,w=t.tooltipProps,E=void 0===w?{title:"Change color",children:null}:w,N=b(),A=r.useState(null),M=A[0],V=A[1],G=r.useState((function(){return a.getValidColor(f)||"#03BCD4"})),H=G[0],U=G[1],W=r.useRef(),Z=r.useState(null),J=Z[0],K=Z[1],Q=y||a.getButtonStrokeColor(J,f);r.useEffect((function(){var o=a.getValidColor(f);o?U(o):console.error("The color value(".concat(f,") is not valid, please check it."))}),[f]);return e.jsxs("div",{className:d.default(N.root,(i={},i[N.topLabelRoot]="top"===L,i[N.rightLabelRoot]="right"===L,i)),ref:function(o){return K(a.findParentBackground(o))},children:[!R&&e.jsx(n.InputLabel,{className:d.default((l={},l[N.topLabel]="top"===L,l[N.rightLabel]="right"===L,l)),shrink:!0,children:h}),e.jsx(n.Tooltip,o.__assign({title:E.title},E,{children:e.jsx(n.IconButton,{"data-testid":"".concat(O,"_icon_").concat(h),className:d.default(N.button,I,(g={},g[N.buttonTransparent]=0===u.default(H).alpha(),g)),disableRipple:!0,style:{backgroundColor:H,color:Q},onClick:function(o){V(o.currentTarget)},size:"small",children:e.jsx(s.PaletteIcon,{size:16,className:N.colorLensIcon})})})),e.jsx(n.Popover,{id:"colors-popper",action:W,open:Boolean(M),anchorEl:M,onClose:function(){V(null)},anchorOrigin:C,transformOrigin:P,children:e.jsx(F,{color:H,onChange:function(o){var e=p[j](o);U(e),q(e)},onSizeChange:function(){W.current&&W.current.updatePosition()},enableTransparencyPalette:_})})]})};
