"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.closest = closest;
exports.closestElement = closestElement;
Object.defineProperty(exports, "containsClassName", {
  enumerable: true,
  get: function get() {
    return _containsClassName.containsClassName;
  }
});
exports.mapElem = mapElem;
exports.maphElem = maphElem;
Object.defineProperty(exports, "parsePx", {
  enumerable: true,
  get: function get() {
    return _parsePx.parsePx;
  }
});
Object.defineProperty(exports, "removeNestedEmptyEls", {
  enumerable: true,
  get: function get() {
    return _removeNestedEmptyEls.removeNestedEmptyEls;
  }
});
Object.defineProperty(exports, "unwrap", {
  enumerable: true,
  get: function get() {
    return _unwrap.unwrap;
  }
});
Object.defineProperty(exports, "walkUpTreeUntil", {
  enumerable: true,
  get: function get() {
    return _walkUpTreeUntil.walkUpTreeUntil;
  }
});
var _walkUpTreeUntil = require("./walkUpTreeUntil");
var _unwrap = require("./unwrap");
var _removeNestedEmptyEls = require("./removeNestedEmptyEls");
var _containsClassName = require("./containsClassName");
var _parsePx = require("./parsePx");
function closest(node, s) {
  if (!node) {
    return null;
  }
  var el = node;
  if (!document.documentElement || !document.documentElement.contains(el)) {
    return null;
  }
  if (el.closest) {
    return el.closest(s);
  }
  do {
    var matchfn = el.matches ? el.matches : el.msMatchesSelector;
    if (matchfn && matchfn.call(el, s)) {
      // Ignored via go/ees005
      // eslint-disable-next-line @atlaskit/editor/no-as-casting
      return el;
    }
    el = el.parentElement || el.parentNode;
  } while (el !== null && el.nodeType === 1);
  return null;
}

// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
/*
 * @deprecated - Use HTMLElement.protoype.closest instead
 */
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
function closestElement(node, s) {
  return closest(node, s);
}
// does typescript have function templates yet?

// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
function mapElem(elem, callback) {
  var array = [];
  for (var i = 0; i < elem.childElementCount; i++) {
    array.push(callback(elem.children[i], i, elem));
  }
  return array;
}

// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
function maphElem(elem, callback) {
  return mapElem(elem, callback);
}
// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export