"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.AlignTargetContainer = void 0;
var _react = _interopRequireWildcard(require("react"));
var _styles = require("@material-ui/core/styles");
var _AlignTargetProvider = require("redhotmagma-visualization/AlignTargetProvider");
var _clsx = _interopRequireDefault(require("clsx"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var style = {
  root: {
    flex: 'inherit',
    display: 'inherit',
    flexDirection: 'inherit',
    width: 'inherit',
    height: 'inherit',
    // the pointer events should be passed through to the visualization component
    pointerEvents: 'inherit' // important: don't remove this
  }
};

var AlignTargetContainer = exports.AlignTargetContainer = (0, _styles.withStyles)(style, {
  name: 'AlignTargetContainer'
})((0, _AlignTargetProvider.withAlignTarget)(function (_ref) {
  var alignTarget = _ref.alignTarget,
    children = _ref.children,
    classes = _ref.classes,
    className = _ref.className;
  var ref = (0, _react.useRef)();
  (0, _react.useEffect)(function () {
    if (ref.current) {
      alignTarget.add(ref.current);
    }
    return function () {
      return alignTarget.remove(ref.current);
    };
  }, [alignTarget]);
  return /*#__PURE__*/_react["default"].createElement("div", {
    ref: ref,
    className: (0, _clsx["default"])(classes.root, className)
  }, children);
}));