"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;exports.__esModule = true;exports.ResizeDetector = void 0;var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _react = _interopRequireDefault(require("react"));

var _Emotion = require("../../lib/theming/Emotion");

var _ResizeDetector2 = require("./ResizeDetector.styles");var







ResizeDetector = exports.ResizeDetector = /*#__PURE__*/function (_React$Component) {function ResizeDetector() {var _this;for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;_this.



    iframeWindow = null;_this.
























    handleResize = function (event) {
      if (_this.props.onResize) {
        _this.props.onResize(event);
      }
    };_this.

    iframeRef = function (iframe) {
      if (iframe && iframe.contentWindow) {
        _this.iframeWindow = iframe.contentWindow;
      }
    };return _this;}(0, _inheritsLoose2.default)(ResizeDetector, _React$Component);var _proto = ResizeDetector.prototype;_proto.componentDidMount = function componentDidMount() {if (this.iframeWindow) {this.iframeWindow.addEventListener('resize', this.handleResize);}};_proto.render = function render() {var _cx;return /*#__PURE__*/_react.default.createElement("div", { className: _ResizeDetector2.styles.root() }, /*#__PURE__*/_react.default.createElement("iframe", { title: "resizeDetector", ref: this.iframeRef, className: _ResizeDetector2.styles.iframe(), tabIndex: -1 }), /*#__PURE__*/_react.default.createElement("div", { className: (0, _Emotion.cx)((_cx = {}, _cx[_ResizeDetector2.styles.content()] = true, _cx[_ResizeDetector2.styles.fullHeight()] = this.props.fullHeight, _cx[_ResizeDetector2.styles.flex()] = this.props.alignBaseline, _cx)) }, this.props.children));};return ResizeDetector;}(_react.default.Component);ResizeDetector.__KONTUR_REACT_UI__ = 'ResizeDetector';ResizeDetector.displayName = 'ResizeDetector';