"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _propTypes = _interopRequireDefault(require("prop-types"));

var _react = _interopRequireDefault(require("react"));

var _Col = _interopRequireDefault(require("./Col"));

var _index = require("../../tokens/forimport/index.es");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

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; }

/**
 * @deprecated This component has been deprecated 2021-06-04. Use Grid or LayoutGrid instead.
 */
var ColWithNubbin = function ColWithNubbin(_ref) {
  var children = _ref.children,
      nubbinRef = _ref.nubbinRef,
      props = _objectWithoutProperties(_ref, ["children", "nubbinRef"]);

  var nubbinTopPosition = 0;

  if (nubbinRef && nubbinRef instanceof HTMLElement) {
    // 17 is half the distance of the diagonal of the nubbin
    // Actually used the pythagorean theorem:
    // Nubbin is 24 x 24, so 24 * √2 = 33.94 / 2 = 17
    var nubbinHypotenuse = parseInt(_index.nubbinSize) * Math.sqrt(2); // Adjust the top position to be halfway through the ref's height
    // minus half the nubbin's height (the hypotenuse)

    nubbinTopPosition = nubbinRef.offsetTop + nubbinRef.offsetHeight / 2 - nubbinHypotenuse / 2;
  }

  return _react["default"].createElement(_Col["default"], props, _react["default"].createElement("div", {
    className: "height--1-1 soft-double background--light border--left"
  }, _react["default"].createElement("div", {
    className: "oui-config-panel__nubbin",
    style: {
      top: nubbinTopPosition
    }
  }), children));
};

ColWithNubbin.propTypes = {
  children: _propTypes["default"].node.isRequired,
  nubbinRef: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].func, _propTypes["default"].object]).isRequired
};
ColWithNubbin.displayName = "ColWithNubbin";
ColWithNubbin.defaultProps = {};
var _default = ColWithNubbin;
exports["default"] = _default;