import { a as __rest, _ as __assign } from '../tslib.es6-20a2a300.js';
import { jsxs, jsx } from 'react/jsx-runtime';
import Icon from './Icon.js';
import IconButton from './IconButton.js';
import { m as makeStyles } from '../makeStyles-c9a99c7a.js';
import { d as _objectWithoutProperties, b as _extends, P as PropTypes } from '../defaultTheme-49a26576.js';
import * as React from 'react';
import { c as clsx } from '../clsx.m-6243b874.js';
import { a as withStyles } from '../withStyles-99aeb25b.js';
import { u as useFormControl, F as FormControlContext } from '../FormControlContext-64eed5c2.js';
import { M as MuiTypography } from '../Typography-649a8eff.js';
import '../icons/ArrowRight.js';
import '../icons/ArrowRightCircle.js';
import '../icons/Check.js';
import '../icons/CheckCircle.js';
import '../icons/ChevronRight.js';
import '../icons/CrossCircle.js';
import '../icons/DollarSign.js';
import '../icons/InfoCircle.js';
import '../icons/Link.js';
import '../icons/TriangleUp.js';
import '../icons/TriangleDown.js';
import '../icons/TriangleLeft.js';
import '../icons/Copy.js';
import '../icons/SortUp.js';
import '../icons/Cross.js';
import '../icons/Search.js';
import '../icons/Range.js';
import '../theme/colors.js';
import '../IconButton-7563dc0d.js';
import '../capitalize-5d3e9aac.js';
import '../ButtonBase-11d3cdb5.js';
import 'react-dom';
import '../useForkRef-4ff8cc89.js';
import '../useEventCallback-8817ed1c.js';
import '../deprecatedPropType-0232df1e.js';
import '../useIsFocusVisible-c048447c.js';
import '../TransitionGroupContext-2ba64e99.js';
import '../refType-5cc24a92.js';
import '../elementTypeAcceptingRef-7677eeee.js';
import '../hoist-non-react-statics.cjs-b718ab87.js';

var styles = {
  /* Styles applied to the root element. */
  root: {
    display: 'flex',
    height: '0.01em',
    // Fix IE 11 flexbox alignment. To remove at some point.
    maxHeight: '2em',
    alignItems: 'center',
    whiteSpace: 'nowrap'
  },

  /* Styles applied to the root element if `variant="filled"`. */
  filled: {
    '&$positionStart:not($hiddenLabel)': {
      marginTop: 16
    }
  },

  /* Styles applied to the root element if `position="start"`. */
  positionStart: {
    marginRight: 8
  },

  /* Styles applied to the root element if `position="end"`. */
  positionEnd: {
    marginLeft: 8
  },

  /* Styles applied to the root element if `disablePointerEvents=true`. */
  disablePointerEvents: {
    pointerEvents: 'none'
  },

  /* Styles applied if the adornment is used inside <FormControl hiddenLabel />. */
  hiddenLabel: {},

  /* Styles applied if the adornment is used inside <FormControl margin="dense" />. */
  marginDense: {}
};
var InputAdornment$1 = /*#__PURE__*/React.forwardRef(function InputAdornment(props, ref) {
  var children = props.children,
      classes = props.classes,
      className = props.className,
      _props$component = props.component,
      Component = _props$component === void 0 ? 'div' : _props$component,
      _props$disablePointer = props.disablePointerEvents,
      disablePointerEvents = _props$disablePointer === void 0 ? false : _props$disablePointer,
      _props$disableTypogra = props.disableTypography,
      disableTypography = _props$disableTypogra === void 0 ? false : _props$disableTypogra,
      position = props.position,
      variantProp = props.variant,
      other = _objectWithoutProperties(props, ["children", "classes", "className", "component", "disablePointerEvents", "disableTypography", "position", "variant"]);

  var muiFormControl = useFormControl() || {};
  var variant = variantProp;

  if (variantProp && muiFormControl.variant) {
    if (process.env.NODE_ENV !== 'production') {
      if (variantProp === muiFormControl.variant) {
        console.error('Material-UI: The `InputAdornment` variant infers the variant prop ' + 'you do not have to provide one.');
      }
    }
  }

  if (muiFormControl && !variant) {
    variant = muiFormControl.variant;
  }

  return /*#__PURE__*/React.createElement(FormControlContext.Provider, {
    value: null
  }, /*#__PURE__*/React.createElement(Component, _extends({
    className: clsx(classes.root, className, position === 'end' ? classes.positionEnd : classes.positionStart, disablePointerEvents && classes.disablePointerEvents, muiFormControl.hiddenLabel && classes.hiddenLabel, variant === 'filled' && classes.filled, muiFormControl.margin === 'dense' && classes.marginDense),
    ref: ref
  }, other), typeof children === 'string' && !disableTypography ? /*#__PURE__*/React.createElement(MuiTypography, {
    color: "textSecondary"
  }, children) : children));
});
process.env.NODE_ENV !== "production" ? InputAdornment$1.propTypes = {
  /**
   * The content of the component, normally an `IconButton` or string.
   */
  children: PropTypes.node.isRequired,

  /**
   * Override or extend the styles applied to the component.
   * See [CSS API](#css) below for more details.
   */
  classes: PropTypes.object.isRequired,

  /**
   * @ignore
   */
  className: PropTypes.string,

  /**
   * The component used for the root node.
   * Either a string to use a HTML element or a component.
   */
  component: PropTypes
  /* @typescript-to-proptypes-ignore */
  .elementType,

  /**
   * Disable pointer events on the root.
   * This allows for the content of the adornment to focus the input on click.
   */
  disablePointerEvents: PropTypes.bool,

  /**
   * If children is a string then disable wrapping in a Typography component.
   */
  disableTypography: PropTypes.bool,

  /**
   * @ignore
   */
  muiFormControl: PropTypes.object,

  /**
   * The position this adornment should appear relative to the `Input`.
   */
  position: PropTypes.oneOf(['start', 'end']).isRequired,

  /**
   * The variant to use.
   * Note: If you are using the `TextField` component or the `FormControl` component
   * you do not have to set this manually.
   */
  variant: PropTypes.oneOf(['standard', 'outlined', 'filled'])
} : void 0;
var MuiInputAdornment = withStyles(styles, {
  name: 'MuiInputAdornment'
})(InputAdornment$1);

var useStyles = makeStyles(function (theme) { return ({
    positionEnd: {
        marginLeft: 0,
        "& .MuiIconButton-root": {
            paddingRight: theme.spacing(2.5)
        }
    }
}); });
var InputAdornment = function (_a) {
    var _b = _a.position, position = _b === void 0 ? "start" : _b, iconButtonProps = _a.iconButtonProps, children = _a.children; __rest(_a, ["position", "iconButtonProps", "children"]);
    var classes = useStyles();
    return (jsxs(MuiInputAdornment, __assign({ position: position, classes: classes }, { children: [children && children, !children && (iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) && jsx(IconButton, __assign({}, iconButtonProps), void 0), !children && !(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) && (iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.iconProps) && jsx(Icon, __assign({}, iconButtonProps.iconProps), void 0)] }), void 0));
};

export { InputAdornment as default };
