var _excluded = ["forwardedRef", "aspectRatio", "overrides"];

function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

/*
Copyright (c) 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 { Block } from '../block';
import { mergeOverrides } from '../helpers/overrides';

var aspectRatioBoxStyle = function aspectRatioBoxStyle(_ref) {
  var $aspectRatio = _ref.$aspectRatio;
  return {
    position: 'relative',
    '::before': {
      content: '""',
      width: '1px',
      marginLeft: '-1px',
      float: 'left',
      height: 0,
      paddingTop: "".concat(100 / $aspectRatio, "%"),
      pointerEvents: 'none'
    },
    '::after': {
      content: '""',
      display: 'table',
      clear: 'both'
    }
  };
};

var AspectRatioBox = function AspectRatioBox(_ref2) {
  var forwardedRef = _ref2.forwardedRef,
      _ref2$aspectRatio = _ref2.aspectRatio,
      aspectRatio = _ref2$aspectRatio === void 0 ? 1 : _ref2$aspectRatio,
      _ref2$overrides = _ref2.overrides,
      overrides = _ref2$overrides === void 0 ? {} : _ref2$overrides,
      restProps = _objectWithoutProperties(_ref2, _excluded);

  var aspectRatioBoxOverrides = {
    Block: {
      style: aspectRatioBoxStyle
    }
  };
  var blockOverrides = mergeOverrides(aspectRatioBoxOverrides, overrides);
  return /*#__PURE__*/React.createElement(Block // coerced to any because of how react components are typed.
  // cannot guarantee an html element
  , _extends({
    ref: forwardedRef,
    overrides: blockOverrides,
    $aspectRatio: aspectRatio,
    "data-baseweb": "aspect-ratio-box"
  }, restProps));
};

var AspectRatioBoxComponent = /*#__PURE__*/React.forwardRef(function (props, ref) {
  return /*#__PURE__*/React.createElement(AspectRatioBox, _extends({}, props, {
    forwardedRef: ref
  }));
});
AspectRatioBoxComponent.displayName = 'AspectRatioBox';
export default AspectRatioBoxComponent;