/*!
 * Copyright © 2018 Splunk Inc.
 * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
 * in part without a valid written license from Splunk Inc. is PROHIBITED.
 */(()=>{"use strict";var e={4008:function(e,t,o){var l=this&&this.__createBinding||(Object.create?function(e,t,o,l){void 0===l&&(l=o);var r=Object.getOwnPropertyDescriptor(t,o);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,l,r)}:function(e,t,o,l){void 0===l&&(l=o),e[l]=t[o]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&l(t,e,o);return r(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AdvancedConfigButton=void 0;const i=n(o(9497)),u=n(o(23)),s=a(o(232)),d=o(6649),c=a(o(6643)),p=o(3563),f=a(o(6379)),b=a(o(7020)),h=a(o(9250)),g=(0,s.default)(h.default)`
    margin-top: 0;
    padding: 0;
    // adjust bottom margin according to theme
    margin-bottom: ${p.variables.spacingMedium};
    width: 100%;

    // remove top margin of the first component in control group
    &:first-child {
        margin-top: 0;
    }

    // remove bottom margin of the last component in control group
    &:last-child {
        margin-bottom: 0;
    }
    // remove top padding on label of the first control group
    [data-test='label']:first-of-type {
        padding-top: 0;
    }
`,m=(0,s.default)(f.default)`
    display: flex;
    > span {
        display: flex;
        width: 35px;
    }
`,v=(0,s.default)(b.default)`
    color: ${p.variables.contentColorActive} !important;
    &:hover {
        background-color: ${p.variables.interactiveColorOverlayDrag} !important;
    }
`;t.AdvancedConfigButton=({label:e="",onClick:t})=>i.default.createElement(m,{"data-test":`${e}-advanced-config-button-tooltip`,content:(0,d._)("Advanced configurations")},i.default.createElement(v,{"data-test":`${e}-advanced-config-button`,icon:i.default.createElement(c.default,{"data-test":`${e}-advanced-config-button-icon`}),appearance:"subtle",onClick:t}));const y=({"data-test":e,children:o,isAdvanced:l=!1,label:r,hideLabel:n,labelPosition:a,labelWidth:u,tooltip:s,help:d,style:c,error:p,controlsLayout:f,onClick:b,onAdvancedConfigButtonClick:h})=>i.default.createElement(g,{"data-test":null!=e?e:"control-group",label:r,hideLabel:n,labelPosition:a,labelWidth:u,tooltip:s,help:d,error:p,style:c,onClick:b,controlsLayout:f},l?i.Children.toArray(o).filter(Boolean).map((e=>(0,i.cloneElement)(e,{style:{flex:1}}))):o,l?i.default.createElement(t.AdvancedConfigButton,{label:r,onClick:h}):null);y.propTypes={style:u.object,isAdvanced:u.bool,onClick:u.func,onAdvancedConfigButtonClick:u.func},t.default=y},6643:e=>{e.exports=require("@splunk/react-icons/SlidersDoubleHorizontal")},7020:e=>{e.exports=require("@splunk/react-ui/Button")},7408:e=>{e.exports=require("@splunk/react-ui/Color")},9250:e=>{e.exports=require("@splunk/react-ui/ControlGroup")},2621:e=>{e.exports=require("@splunk/react-ui/ScreenReaderContent")},4082:e=>{e.exports=require("@splunk/react-ui/Text")},6379:e=>{e.exports=require("@splunk/react-ui/Tooltip")},3563:e=>{e.exports=require("@splunk/themes")},6649:e=>{e.exports=require("@splunk/ui-utils/i18n")},8987:e=>{e.exports=require("@splunk/ui-utils/id")},3283:e=>{e.exports=require("@splunk/visualizations-shared/colorUtils")},4793:e=>{e.exports=require("lodash")},23:e=>{e.exports=require("prop-types")},9497:e=>{e.exports=require("react")},232:e=>{e.exports=require("styled-components")}},t={};function o(l){var r=t[l];if(void 0!==r)return r.exports;var n=t[l]={exports:{}};return e[l].call(n.exports,n,n.exports,o),n.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var l in t)o.o(t,l)&&!o.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};(()=>{o.r(l),o.d(l,{default:()=>B});var e=o(9497),t=o.n(e),r=o(23),n=o.n(r),a=o(232),i=o.n(a),u=o(4793),s=o(3563),d=o(7408),c=o.n(d),p=o(4082),f=o.n(p),b=o(8987),h=o(6649),g=o(2621),m=o.n(g);const v=require("@splunk/visualizations-shared/colorConstants");var y=o(3283),C=o(4008),x=o.n(C);const k=i().div`
    max-height: ${s.variables.inputHeight};
    width: 100%;
    min-width: 0;
`,O=i()(f())`
    max-height: ${s.variables.inputHeight};
`,_=({color:e,defaultColor:t,prevColor:o})=>{const l="string"==typeof e?e.trim():e;return(0,y.isColor)(l)||null===l?l:(0,y.isColor)(t)?t:(0,y.isColor)(o)||null===o?o:"transparent"},q=({id:o,showTextInput:l,color:r,palette:n,handleColorChange:a,labelledBy:i,textWidth:u,value:s,name:d,handleTextColorChange:p,handleKeyPress:f,handleBlur:g,isDisabled:v})=>{const y=(0,e.useMemo)((()=>(0,b.createDOMID)("color-code")),[]);return t().createElement(t().Fragment,null,t().createElement("div",null,t().createElement(c(),{key:"color-editor",append:l,value:_({color:r}),palette:n,onChange:a,"data-test":`color-picker-${d}`,disabled:v,hideInput:!0,labelledBy:i})),l&&t().createElement(k,{"data-test":"text-container",textWidth:u},t().createElement(m(),{id:y},(0,h._)("Color code input")),t().createElement(O,{key:s,"data-test":d,prepend:!0,value:null===r?"N/A":r,onChange:p,onKeyDown:f,onBlur:g,disabled:v,style:{height:"32px"},labelledBy:`${i} ${y}`,inputId:o})))};q.propTypes={id:n().string,showTextInput:n().bool,color:n().string,palette:n().arrayOf(n().string),handleColorChange:n().func,labelledBy:n().string,textWidth:n().oneOfType([n().string,n().number]),value:n().string,name:n().string.isRequired,handleTextColorChange:n().func,handleKeyPress:n().func,handleBlur:n().func,isDisabled:n().bool};const E={default:"transparent"},T={},P=({name:o="color",value:l="transparent",label:r="",labelPosition:n="top",labelWidth:a,palette:i=v.COLOR_EDITOR_PALETTE,onChange:s=u.noop,itemSchema:d=E,isDisabled:c=!1,textWidth:p="auto",hideLabel:f=!1,showTextInput:b=!0,style:h=T})=>{const[g,m]=(0,e.useState)(l);(0,e.useEffect)((()=>{m(l)}),[l]);const y=(0,e.useMemo)((()=>(0,u.debounce)(s,250)),[s]),C=(0,e.useCallback)((({value:e})=>{const t=_({color:e,defaultColor:d.default,prevColor:l});m(t),l!==t&&y(null,o,t)}),[y,d.default,o,l]),k=(0,e.useCallback)(((e,{value:t})=>{const o="n/a"===(0,u.toLower)(t).trim()?null:t;m(o)}),[]),O=(0,e.useCallback)((e=>{if("Escape"!==e.key){if("Enter"===e.key&&l!==g){const t=_({color:g,defaultColor:d.default,prevColor:l});m(t),t!==l&&s(e,o,t)}}else m(l)}),[o,g,l,s,d.default]),P=(0,e.useCallback)((e=>{if(g!==l){const t=_({color:g,defaultColor:d.default,prevColor:l});m(t),t!==l&&s(e,o,t)}}),[o,g,l,s,d.default]);return t().createElement(x(),{label:r,labelPosition:n,labelWidth:a,style:h,hideLabel:f,controlsLayout:"fillJoin"},t().createElement(q,{showTextInput:b,color:g,palette:i,handleColorChange:C,name:o,isDisabled:c,textWidth:p,value:l,handleTextColorChange:k,handleKeyPress:O,handleBlur:P}))};P.propTypes={name:n().string.isRequired,value:n().string,itemSchema:n().object,label:n().string.isRequired,hideLabel:n().bool,showTextInput:n().bool,style:n().object,labelPosition:n().oneOf(["top","left"]),labelWidth:n().number,palette:n().arrayOf(n().string),onChange:n().func.isRequired,isDisabled:n().bool,textWidth:n().oneOfType([n().string,n().number])};const B=P})(),module.exports=l})();
//# sourceMappingURL=ColorEditor.js.map