var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
  getContainingBlock: () => getContainingBlock,
  getElementTop: () => getElementTop,
  getRootScrollTop: () => getRootScrollTop,
  getScrollTop: () => getScrollTop,
  isHidden: () => isHidden,
  preventDefault: () => preventDefault,
  resetScroll: () => resetScroll,
  setRootScrollTop: () => setRootScrollTop,
  setScrollTop: () => setScrollTop,
  stopPropagation: () => stopPropagation,
  windowHeight: () => windowHeight,
  windowWidth: () => windowWidth
});
module.exports = __toCommonJS(stdin_exports);
var import_use = require("@vant/use");
var import_vue = require("vue");
var import_basic = require("./basic");
function getScrollTop(el) {
  const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
  return Math.max(top, 0);
}
function setScrollTop(el, value) {
  if ("scrollTop" in el) {
    el.scrollTop = value;
  } else {
    el.scrollTo(el.scrollX, value);
  }
}
function getRootScrollTop() {
  return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
}
function setRootScrollTop(value) {
  setScrollTop(window, value);
  setScrollTop(document.body, value);
}
function getElementTop(el, scroller) {
  if (el === window) {
    return 0;
  }
  const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
  return (0, import_use.useRect)(el).top + scrollTop;
}
const isIOS = (0, import_basic.isIOS)();
function resetScroll() {
  if (isIOS) {
    setRootScrollTop(getRootScrollTop());
  }
}
const stopPropagation = (event) => event.stopPropagation();
function preventDefault(event, isStopPropagation) {
  if (typeof event.cancelable !== "boolean" || event.cancelable) {
    event.preventDefault();
  }
  if (isStopPropagation) {
    stopPropagation(event);
  }
}
function isHidden(elementRef) {
  const el = (0, import_vue.unref)(elementRef);
  if (!el) {
    return false;
  }
  const style = window.getComputedStyle(el);
  const hidden = style.display === "none";
  const parentHidden = el.offsetParent === null && style.position !== "fixed";
  return hidden || parentHidden;
}
const { width: windowWidth, height: windowHeight } = (0, import_use.useWindowSize)();
function isContainingBlock(el) {
  const css = window.getComputedStyle(el);
  return css.transform !== "none" || css.perspective !== "none" || ["transform", "perspective", "filter"].some(
    (value) => (css.willChange || "").includes(value)
  );
}
function getContainingBlock(el) {
  let node = el.parentElement;
  while (node) {
    if (node && node.tagName !== "HTML" && node.tagName !== "BODY" && isContainingBlock(node)) {
      return node;
    }
    node = node.parentElement;
  }
  return null;
}
