/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var utils_dom = require('../../utils/dom.js');
require('../../_chunks/dep-f4db2590.js');
require('lodash/isString');
require('lodash/isFunction');
require('lodash/isArray');
require('../../utils/easing.js');

function getRelativePosition(elm) {
  var relativeElm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.body;
  var _getWindowScroll = utils_dom.getWindowScroll(),
    scrollTop = _getWindowScroll.scrollTop,
    scrollLeft = _getWindowScroll.scrollLeft;
  var _elm$getBoundingClien = elm.getBoundingClientRect(),
    elmTop = _elm$getBoundingClien.top,
    elmLeft = _elm$getBoundingClien.left;
  var _relativeElm$getBound = relativeElm.getBoundingClientRect(),
    relElmTop = _relativeElm$getBound.top,
    relElmLeft = _relativeElm$getBound.left;
  var relativeElmPosition = utils_dom.getElmCssPropValue(relativeElm, "position");
  if (relativeElm.tagName.toLowerCase() !== "body" && relativeElmPosition === "relative" || relativeElmPosition === "sticky") {
    return {
      top: elmTop - relElmTop,
      left: elmLeft - relElmLeft
    };
  }
  if (utils_dom.isFixed(elm)) {
    return {
      top: elmTop,
      left: elmLeft
    };
  }
  return {
    top: elmTop + scrollTop,
    left: elmLeft + scrollLeft
  };
}

exports["default"] = getRelativePosition;
//# sourceMappingURL=getRelativePosition.js.map
