function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

/*
Copyright (c) 2018-2019 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import * as React from 'react';
import InputMask from 'react-input-mask';
import Input from './input.js';
import { Input as StyledInput } from './styled-components.js';
const MaskOverride = React.forwardRef(({
  startEnhancer,
  endEnhancer,
  error,
  onChange,
  onFocus,
  onBlur,
  value,
  disabled,
  ...restProps
}, ref) => {
  return React.createElement(InputMask, _extends({
    onChange: onChange,
    onFocus: onFocus,
    onBlur: onBlur,
    value: value,
    disabled: disabled
  }, restProps), props => React.createElement(StyledInput, _extends({
    ref: ref,
    onChange: onChange,
    onFocus: onFocus,
    onBlur: onBlur,
    value: value,
    disabled: disabled
  }, props)));
});
export default function MaskedInput(props) {
  const {
    overrides: {
      Input: inputOverride,
      ...restOverrides
    } = {},
    ...restProps
  } = props;
  const nextOverrides = {
    Input: {
      component: MaskOverride,
      props: restProps,
      ...(typeof inputOverride === 'object' ? inputOverride : {})
    },
    ...restOverrides
  };
  const {
    mask,
    maskChar,
    ...restInputProps
  } = props;
  return React.createElement(Input, _extends({}, restInputProps, {
    overrides: nextOverrides
  }));
}
MaskedInput.defaultProps = {
  maskChar: ' '
};