"use strict";var o=require('./../../ext-esm/tslib/tslib.es6.js'),e=require("react/jsx-runtime"),r=require("react"),n=require("@material-ui/core"),i=require("chroma-js"),t=require("classnames"),s=require("./PaletteChromePicker/PaletteChromePicker.js"),c=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(i),d=l(t),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(i){var t,l,g,m=i.label,h=void 0===m?"Color":m,f=i.value,x=i.converter,j=void 0===x?"rgba_hex":x,q=i.onChange,I=i.buttonClassName,v=i.popoverAnchorOrigin,C=void 0===v?{vertical:"bottom",horizontal:"left"}:v,k=i.popoverTransformOrigin,P=void 0===k?{vertical:"top",horizontal:"left"}:k,_=i.labelPosition,S=void 0===_?"top":_,L=i.hideLabel,z=void 0!==L&&L,R=i.pickerComponent,B=void 0===R?s:R,F=i.lensColor,y=i.enableTransparencyPalette,T=void 0!==y&&y,D=i["data-testid"],O=void 0===D?"ColorPicker":D,w=i.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=F||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",o.__assign({className:d.default(N.root,(t={},t[N.topLabelRoot]="top"===S,t[N.rightLabelRoot]="right"===S,t)),ref:function(o){return K(a.findParentBackground(o))}},{children:[!z&&e.jsx(n.InputLabel,o.__assign({className:d.default((l={},l[N.topLabel]="top"===S,l[N.rightLabel]="right"===S,l)),shrink:!0},{children:h})),e.jsx(n.Tooltip,o.__assign({title:E.title},E,{children:e.jsx(n.IconButton,o.__assign({"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(c.PaletteIcon,{size:16,className:N.colorLensIcon})}))})),e.jsx(n.Popover,o.__assign({id:"colors-popper",action:W,open:Boolean(M),anchorEl:M,onClose:function(){V(null)},anchorOrigin:C,transformOrigin:P},{children:e.jsx(B,{color:H,onChange:function(o){var e=p[j](o);U(e),q(e)},onSizeChange:function(){W.current&&W.current.updatePosition()},enableTransparencyPalette:T})}))]}))};
