"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.IntersectionContainer = exports.IntersectionGuard = exports.default = exports.SubMenu = exports.PopupItem = exports.Group = exports.Item = void 0;

var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _consoleComponents = require("@alicloud/console-components");

function _templateObject7() {
  var data = (0, _taggedTemplateLiteral2.default)(["\n  height: 100%;\n  ", ";\n\n  .next-menu {\n    height: 100%;\n  }\n"]);

  _templateObject7 = function _templateObject7() {
    return data;
  };

  return data;
}

function _templateObject6() {
  var data = (0, _taggedTemplateLiteral2.default)(["\n  position: absolute;\n  height: 12px;\n  top: -20px;\n"]);

  _templateObject6 = function _templateObject6() {
    return data;
  };

  return data;
}

function _templateObject5() {
  var data = (0, _taggedTemplateLiteral2.default)(["\n  &&& {\n    ", " {\n      padding: 0 16px 0 0;\n    }\n  }\n"]);

  _templateObject5 = function _templateObject5() {
    return data;
  };

  return data;
}

function _templateObject4() {
  var data = (0, _taggedTemplateLiteral2.default)([""]);

  _templateObject4 = function _templateObject4() {
    return data;
  };

  return data;
}

function _templateObject3() {
  var data = (0, _taggedTemplateLiteral2.default)([""]);

  _templateObject3 = function _templateObject3() {
    return data;
  };

  return data;
}

function _templateObject2() {
  var data = (0, _taggedTemplateLiteral2.default)([""]);

  _templateObject2 = function _templateObject2() {
    return data;
  };

  return data;
}

function _templateObject() {
  var data = (0, _taggedTemplateLiteral2.default)([""]);

  _templateObject = function _templateObject() {
    return data;
  };

  return data;
}

var Item = (0, _styledComponents.default)(_consoleComponents.Nav.Item)(_templateObject());
exports.Item = Item;
var Group = (0, _styledComponents.default)(_consoleComponents.Nav.Group)(_templateObject2());
exports.Group = Group;
var PopupItem = (0, _styledComponents.default)(_consoleComponents.Nav.PopupItem)(_templateObject3());
exports.PopupItem = PopupItem;
var SubMenu = (0, _styledComponents.default)(_consoleComponents.Nav.SubNav)(_templateObject4());
exports.SubMenu = SubMenu;
var Menu = (0, _styledComponents.default)(_consoleComponents.Nav)(_templateObject5(), Item);
var _default = Menu;
exports.default = _default;

var IntersectionGuard = _styledComponents.default.div(_templateObject6());

exports.IntersectionGuard = IntersectionGuard;

var getAdjustedHeight = function getAdjustedHeight(value) {
  if (typeof value === 'number') {
    return value;
  }

  if (typeof window === 'undefined' || typeof document === 'undefined') {
    // this is executed in SSR
    // document is not defined
    return 0;
  }

  if (typeof value === 'string') {
    var elem = document.getElementById(value) || document.querySelector(value);

    if (elem && elem.offsetHeight) {
      return elem.offsetHeight;
    }
  }

  return 0;
};

var stickyIfNonIntersecting = function stickyIfNonIntersecting(props) {
  return props.isIntersecting ? '' : "\n    position: sticky;\n    top: 0;\n    overflow-y: scroll;\n    height: calc(100vh - ".concat(getAdjustedHeight(props.adjustHeight), "px);\n  ");
};

var IntersectionContainer = _styledComponents.default.div(_templateObject7(), stickyIfNonIntersecting);

exports.IntersectionContainer = IntersectionContainer;