'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var cls = require('classnames');
var base$1 = require('./variations/_view/base.js');
var base = require('./variations/_size/base.js');
var base$3 = require('./variations/_disabled/base.js');
var base$2 = require('./variations/_read-only/base.js');
var base$4 = require('./variations/_hint-view/base.js');
var base$5 = require('./variations/_hint-size/base.js');
var InformationWrapper_styles = require('./InformationWrapper.styles.js');
var InformationWrapper_tokens = require('./InformationWrapper.tokens.js');
var Label = require('./ui/Label/Label.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);
var cls__default = /*#__PURE__*/_interopDefault(cls);

var _excluded = ["size", "view", "children", "label", "labelHtmlFor", "labelPlacement", "hasRequiredIndicator", "requiredIndicatorPlacement", "optional", "optionalText", "hintText", "hintTrigger", "hintView", "hintSize", "hintTargetIcon", "hintPlacement", "hintHasArrow", "hintOffset", "hintWidth", "hintContentLeft", "titleCaption", "leftHelper", "rightHelper", "readOnly", "disabled"];
var informationWrapperRoot = function informationWrapperRoot(Root) {
  return /*#__PURE__*/React.forwardRef(function (_ref, ref) {
    var size = _ref.size,
      view = _ref.view,
      children = _ref.children,
      label = _ref.label,
      labelHtmlFor = _ref.labelHtmlFor,
      _ref$labelPlacement = _ref.labelPlacement,
      labelPlacement = _ref$labelPlacement === void 0 ? 'top' : _ref$labelPlacement,
      hasRequiredIndicator = _ref.hasRequiredIndicator,
      _ref$requiredIndicato = _ref.requiredIndicatorPlacement,
      requiredIndicatorPlacement = _ref$requiredIndicato === void 0 ? 'right' : _ref$requiredIndicato,
      optional = _ref.optional,
      optionalText = _ref.optionalText,
      hintText = _ref.hintText,
      _ref$hintTrigger = _ref.hintTrigger,
      hintTrigger = _ref$hintTrigger === void 0 ? 'hover' : _ref$hintTrigger,
      _ref$hintView = _ref.hintView,
      hintView = _ref$hintView === void 0 ? 'default' : _ref$hintView,
      _ref$hintSize = _ref.hintSize,
      hintSize = _ref$hintSize === void 0 ? 'm' : _ref$hintSize,
      hintTargetIcon = _ref.hintTargetIcon,
      _ref$hintPlacement = _ref.hintPlacement,
      hintPlacement = _ref$hintPlacement === void 0 ? 'auto' : _ref$hintPlacement,
      hintHasArrow = _ref.hintHasArrow,
      hintOffset = _ref.hintOffset,
      hintWidth = _ref.hintWidth,
      hintContentLeft = _ref.hintContentLeft,
      titleCaption = _ref.titleCaption,
      leftHelper = _ref.leftHelper,
      rightHelper = _ref.rightHelper,
      readOnly = _ref.readOnly,
      disabled = _ref.disabled,
      rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
    var hasHelpers = leftHelper || rightHelper;
    return /*#__PURE__*/React__default.default.createElement(Root, _rollupPluginBabelHelpers.extends({
      ref: ref,
      size: size,
      view: view,
      disabled: disabled,
      readOnly: readOnly
    }, hintText && {
      hintView: hintView,
      hintSize: hintSize
    }, rest), /*#__PURE__*/React__default.default.createElement(InformationWrapper_styles.LabelWrapper, {
      className: cls__default.default(_rollupPluginBabelHelpers.defineProperty({}, InformationWrapper_tokens.classes.withoutLabel, !label)),
      hasLabel: Boolean(label),
      hasCaption: Boolean(titleCaption)
    }, (labelPlacement === 'top' || !label) && /*#__PURE__*/React__default.default.createElement(Label.LabelComponent, {
      size: size,
      hasRequiredIndicator: hasRequiredIndicator,
      requiredIndicatorPlacement: requiredIndicatorPlacement,
      optional: optional,
      optionalText: optionalText,
      label: label,
      labelHtmlFor: labelHtmlFor,
      titleCaption: titleCaption,
      hintText: hintText,
      hintTrigger: hintTrigger,
      hintTargetIcon: hintTargetIcon,
      hintPlacement: hintPlacement,
      hintHasArrow: hintHasArrow,
      hintOffset: hintOffset,
      hintWidth: hintWidth,
      hintContentLeft: hintContentLeft,
      disabled: disabled
    }), titleCaption && /*#__PURE__*/React__default.default.createElement(InformationWrapper_styles.TitleCaption, {
      hasLabel: Boolean(label)
    }, titleCaption)), /*#__PURE__*/React__default.default.createElement(InformationWrapper_styles.ContentWrapper, null, Boolean(label) && labelPlacement === 'left' && /*#__PURE__*/React__default.default.createElement(Label.LabelComponent, {
      hasRequiredIndicator: hasRequiredIndicator,
      requiredIndicatorPlacement: requiredIndicatorPlacement,
      optional: optional,
      optionalText: optionalText,
      label: label,
      labelHtmlFor: labelHtmlFor,
      titleCaption: titleCaption,
      hintText: hintText,
      hintTrigger: hintTrigger,
      hintTargetIcon: hintTargetIcon,
      hintPlacement: hintPlacement,
      hintHasArrow: hintHasArrow,
      hintOffset: hintOffset,
      hintWidth: hintWidth,
      hintContentLeft: hintContentLeft
    }), /*#__PURE__*/React__default.default.createElement(InformationWrapper_styles.ContentChildrenWrapper, null, children, hasHelpers && /*#__PURE__*/React__default.default.createElement(InformationWrapper_styles.Helpers, null, leftHelper && /*#__PURE__*/React__default.default.createElement(InformationWrapper_styles.LeftHelper, {
      className: InformationWrapper_tokens.classes.leftHelper
    }, leftHelper), rightHelper && /*#__PURE__*/React__default.default.createElement(InformationWrapper_styles.RightHelper, null, rightHelper)))));
  });
};
var informationWrapperConfig = {
  name: 'InformationWrapper',
  tag: 'div',
  layout: informationWrapperRoot,
  base: InformationWrapper_styles.base,
  variations: {
    size: {
      css: base.base
    },
    view: {
      css: base$1.base
    },
    readOnly: {
      css: base$2.base,
      attrs: true
    },
    disabled: {
      css: base$3.base,
      attrs: true
    },
    hintView: {
      css: base$4.base
    },
    hintSize: {
      css: base$5.base
    }
  },
  defaults: {
    size: 's',
    view: 'default'
  }
};

exports.informationWrapperConfig = informationWrapperConfig;
exports.informationWrapperRoot = informationWrapperRoot;
