import { _ as __assign } from '../tslib.es6-20a2a300.js';
import { jsx, jsxs } from 'react/jsx-runtime';
import colors from '../theme/colors.js';
import Typography from './Typography.js';
import { m as makeStyles } from '../makeStyles-c9a99c7a.js';
import { b as _extends, d as _objectWithoutProperties, P as PropTypes } from '../defaultTheme-49a26576.js';
import * as React from 'react';
import { c as clsx } from '../clsx.m-6243b874.js';
import { f as formControlState } from '../formControlState-da4d15f8.js';
import { u as useFormControl } from '../useFormControl-dc7cf5d6.js';
import { a as withStyles } from '../withStyles-99aeb25b.js';
import { B as Box } from '../Box-581dc061.js';
import '../_commonjsHelpers-57e89916.js';
import '../theme/fontSize.js';
import '../theme/fontWeight.js';
import '../theme/fontFamily.js';
import '../theme/lineHeight.js';
import '../Typography-649a8eff.js';
import '../capitalize-5d3e9aac.js';
import '../hoist-non-react-statics.cjs-b718ab87.js';
import '../FormControlContext-64eed5c2.js';
import '../styled-339d0187.js';

var styles = function styles(theme) {
  return {
    /* Styles applied to the root element. */
    root: _extends({
      color: theme.palette.text.secondary
    }, theme.typography.caption, {
      textAlign: 'left',
      marginTop: 3,
      margin: 0,
      '&$disabled': {
        color: theme.palette.text.disabled
      },
      '&$error': {
        color: theme.palette.error.main
      }
    }),

    /* Pseudo-class applied to the root element if `error={true}`. */
    error: {},

    /* Pseudo-class applied to the root element if `disabled={true}`. */
    disabled: {},

    /* Styles applied to the root element if `margin="dense"`. */
    marginDense: {
      marginTop: 4
    },

    /* Styles applied to the root element if `variant="filled"` or `variant="outlined"`. */
    contained: {
      marginLeft: 14,
      marginRight: 14
    },

    /* Pseudo-class applied to the root element if `focused={true}`. */
    focused: {},

    /* Pseudo-class applied to the root element if `filled={true}`. */
    filled: {},

    /* Pseudo-class applied to the root element if `required={true}`. */
    required: {}
  };
};
var FormHelperText$1 = /*#__PURE__*/React.forwardRef(function FormHelperText(props, ref) {
  var children = props.children,
      classes = props.classes,
      className = props.className,
      _props$component = props.component,
      Component = _props$component === void 0 ? 'p' : _props$component;
      props.disabled;
      props.error;
      props.filled;
      props.focused;
      props.margin;
      props.required;
      props.variant;
      var other = _objectWithoutProperties(props, ["children", "classes", "className", "component", "disabled", "error", "filled", "focused", "margin", "required", "variant"]);

  var muiFormControl = useFormControl();
  var fcs = formControlState({
    props: props,
    muiFormControl: muiFormControl,
    states: ['variant', 'margin', 'disabled', 'error', 'filled', 'focused', 'required']
  });
  return /*#__PURE__*/React.createElement(Component, _extends({
    className: clsx(classes.root, (fcs.variant === 'filled' || fcs.variant === 'outlined') && classes.contained, className, fcs.disabled && classes.disabled, fcs.error && classes.error, fcs.filled && classes.filled, fcs.focused && classes.focused, fcs.required && classes.required, fcs.margin === 'dense' && classes.marginDense),
    ref: ref
  }, other), children === ' ' ?
  /*#__PURE__*/
  // eslint-disable-next-line react/no-danger
  React.createElement("span", {
    dangerouslySetInnerHTML: {
      __html: '&#8203;'
    }
  }) : children);
});
process.env.NODE_ENV !== "production" ? FormHelperText$1.propTypes = {
  // ----------------------------- Warning --------------------------------
  // | These PropTypes are generated from the TypeScript type definitions |
  // |     To update them edit the d.ts file and run "yarn proptypes"     |
  // ----------------------------------------------------------------------

  /**
   * The content of the component.
   *
   * If `' '` is provided, the component reserves one line height for displaying a future message.
   */
  children: PropTypes.node,

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

  /**
   * @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,

  /**
   * If `true`, the helper text should be displayed in a disabled state.
   */
  disabled: PropTypes.bool,

  /**
   * If `true`, helper text should be displayed in an error state.
   */
  error: PropTypes.bool,

  /**
   * If `true`, the helper text should use filled classes key.
   */
  filled: PropTypes.bool,

  /**
   * If `true`, the helper text should use focused classes key.
   */
  focused: PropTypes.bool,

  /**
   * If `dense`, will adjust vertical spacing. This is normally obtained via context from
   * FormControl.
   */
  margin: PropTypes.oneOf(['dense']),

  /**
   * If `true`, the helper text should use required classes key.
   */
  required: PropTypes.bool,

  /**
   * The variant to use.
   */
  variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
} : void 0;
var MuiFormHelperText = withStyles(styles, {
  name: 'MuiFormHelperText'
})(FormHelperText$1);

var useStyles = makeStyles(function (theme) { return ({
    box: {
        "& span": {
            lineHeight: 1
        }
    }
}); });
var FormHelperText = function (_a) {
    var text = _a.text, startAdornment = _a.startAdornment;
    var classes = useStyles();
    return (jsx(MuiFormHelperText, __assign({ component: "div" }, { children: jsxs(Box, __assign({ display: "inline-flex", alignItems: "center", alignSelf: "start", lineHeight: 0, px: 3, pt: 0.8, pb: 1, bgcolor: colors.button.secondary, className: classes.box }, { children: [startAdornment && jsx(Box, __assign({ mr: 1 }, { children: startAdornment }), void 0), jsx(Typography, __assign({ variant: "callout", color: "inversePrimary" }, { children: text }), void 0)] }), void 0) }), void 0));
};

export { FormHelperText as default };
