/*!
 * 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={5592:(e,t,o)=>{t.useNumberInput=void 0;const n=o(9497),l=o(4793);t.useNumberInput=({min:e=Number.NEGATIVE_INFINITY,max:t=Number.POSITIVE_INFINITY,value:o,defaultValue:r,onValueChange:a=l.noop})=>{const[u,i]=(0,n.useState)(o),s=(0,n.useRef)(!1),d=(0,n.useCallback)(((e,t)=>{null==t&&i(null!=r?r:o),a(e,t)}),[r,a,o]),c=(0,n.useMemo)((()=>(0,l.debounce)(((e,t)=>d(e,t.value)),250)),[d]);(0,n.useLayoutEffect)((()=>{i(o)}),[o]);return{handleChange:(0,n.useCallback)(((e,t)=>{i(t.value),s.current||c(e,t)}),[c]),handleBlur:(0,n.useCallback)((e=>{s.current=!1,o!==u&&d(e,u)}),[u,d,o]),handleFocus:(0,n.useCallback)((()=>{s.current=!0}),[]),handleKeyPress:(0,n.useCallback)((n=>{var r;if("string"==typeof n.key&&"enter"===n.key.toLowerCase()){const a=null===(r=n.target)||void 0===r?void 0:r.value,u=a?Number(a):void 0,i="number"==typeof u?(0,l.clamp)(u,e,t):void 0;o!==i&&d(n,i)}"string"==typeof n.key&&"escape"===n.key.toLowerCase()&&i(o)}),[d,o,e,t]),currentValue:u}}},4008:function(e,t,o){var n=this&&this.__createBinding||(Object.create?function(e,t,o,n){void 0===n&&(n=o);var l=Object.getOwnPropertyDescriptor(t,o);l&&!("get"in l?!t.__esModule:l.writable||l.configurable)||(l={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,n,l)}:function(e,t,o,n){void 0===n&&(n=o),e[n]=t[o]}),l=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=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)&&n(t,e,o);return l(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 u=r(o(9497)),i=r(o(23)),s=a(o(232)),d=o(6649),c=a(o(6643)),p=o(3563),f=a(o(6379)),b=a(o(7020)),m=a(o(9250)),v=(0,s.default)(m.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;
    }
`,h=(0,s.default)(f.default)`
    display: flex;
    > span {
        display: flex;
        width: 35px;
    }
`,g=(0,s.default)(b.default)`
    color: ${p.variables.contentColorActive} !important;
    &:hover {
        background-color: ${p.variables.interactiveColorOverlayDrag} !important;
    }
`;t.AdvancedConfigButton=({label:e="",onClick:t})=>u.default.createElement(h,{"data-test":`${e}-advanced-config-button-tooltip`,content:(0,d._)("Advanced configurations")},u.default.createElement(g,{"data-test":`${e}-advanced-config-button`,icon:u.default.createElement(c.default,{"data-test":`${e}-advanced-config-button-icon`}),appearance:"subtle",onClick:t}));const y=({"data-test":e,children:o,isAdvanced:n=!1,label:l,hideLabel:r,labelPosition:a,labelWidth:i,tooltip:s,help:d,style:c,error:p,controlsLayout:f,onClick:b,onAdvancedConfigButtonClick:m})=>u.default.createElement(v,{"data-test":null!=e?e:"control-group",label:l,hideLabel:r,labelPosition:a,labelWidth:i,tooltip:s,help:d,error:p,style:c,onClick:b,controlsLayout:f},n?u.Children.toArray(o).filter(Boolean).map((e=>(0,u.cloneElement)(e,{style:{flex:1}}))):o,n?u.default.createElement(t.AdvancedConfigButton,{label:l,onClick:m}):null);y.propTypes={style:i.object,isAdvanced:i.bool,onClick:i.func,onAdvancedConfigButtonClick:i.func},t.default=y},6643:e=>{e.exports=require("@splunk/react-icons/SlidersDoubleHorizontal")},7020:e=>{e.exports=require("@splunk/react-ui/Button")},9250:e=>{e.exports=require("@splunk/react-ui/ControlGroup")},2782:e=>{e.exports=require("@splunk/react-ui/Number")},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")},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(n){var l=t[n];if(void 0!==l)return l.exports;var r=t[n]={exports:{}};return e[n].call(r.exports,r,r.exports,o),r.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 n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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 n={};(()=>{o.r(n),o.d(n,{default:()=>p});var e=o(9497),t=o.n(e),l=o(23),r=o.n(l),a=o(2782),u=o.n(a),i=o(4008),s=o.n(i),d=o(5592);const c=({onChange:o,name:n,value:l=null,labelPosition:r="top",labelWidth:a,label:i,min:c,max:p,step:f,isDisabled:b,help:m,helpFormat:v="under",defaultValue:h})=>{const g=(0,e.useCallback)(((e,t)=>{if(void 0===h&&null==t)return void o(e,n,t);const l=parseFloat(null!=t?t:h);Number.isFinite(l)&&o(e,n,l)}),[h,o,n]),{currentValue:y,handleChange:C,handleBlur:x,handleFocus:k,handleKeyPress:_}=(0,d.useNumberInput)({value:l,min:c,max:p,defaultValue:h,onValueChange:g});return t().createElement(s(),{label:i,labelPosition:r,labelWidth:a,help:"under"===v?m:void 0,tooltip:"tooltip"===v?m:void 0,tooltipDefaultPlacement:"top"},t().createElement(u(),{"data-test":n,min:c,max:p,step:f,onChange:C,onBlur:x,onFocus:k,onKeyDown:_,value:y,disabled:b}))};c.propTypes={onChange:r().func.isRequired,name:r().string.isRequired,label:r().string.isRequired,value:r().number,defaultValue:r().number,labelPosition:r().oneOf(["top","left"]),labelWidth:r().number,min:r().number,max:r().number,step:r().number,isDisabled:r().bool,help:r().string,helpFormat:r().oneOf(["text","under"])};const p=c})(),module.exports=n})();
//# sourceMappingURL=NumberEditor.js.map