import { __exports as N } from "../../../../../../_virtual/helpers.js";
import { __require as S } from "../../../../domhandler@5.0.3/node_modules/domhandler/lib/index.js";
var I;
function b() {
  if (I) return N;
  I = 1, Object.defineProperty(N, "__esModule", { value: !0 }), N.DocumentPosition = void 0, N.removeSubsets = h, N.compareDocumentPosition = O, N.uniqueSort = C;
  var l = /* @__PURE__ */ S();
  function h(r) {
    for (var e = r.length; --e >= 0; ) {
      var t = r[e];
      if (e > 0 && r.lastIndexOf(t, e - 1) >= 0) {
        r.splice(e, 1);
        continue;
      }
      for (var i = t.parent; i; i = i.parent)
        if (r.includes(i)) {
          r.splice(e, 1);
          break;
        }
    }
    return r;
  }
  var a;
  (function(r) {
    r[r.DISCONNECTED = 1] = "DISCONNECTED", r[r.PRECEDING = 2] = "PRECEDING", r[r.FOLLOWING = 4] = "FOLLOWING", r[r.CONTAINS = 8] = "CONTAINS", r[r.CONTAINED_BY = 16] = "CONTAINED_BY";
  })(a || (N.DocumentPosition = a = {}));
  function O(r, e) {
    var t = [], i = [];
    if (r === e)
      return 0;
    for (var u = (0, l.hasChildren)(r) ? r : r.parent; u; )
      t.unshift(u), u = u.parent;
    for (u = (0, l.hasChildren)(e) ? e : e.parent; u; )
      i.unshift(u), u = u.parent;
    for (var E = Math.min(t.length, i.length), n = 0; n < E && t[n] === i[n]; )
      n++;
    if (n === 0)
      return a.DISCONNECTED;
    var f = t[n - 1], v = f.children, p = t[n], s = i[n];
    return v.indexOf(p) > v.indexOf(s) ? f === e ? a.FOLLOWING | a.CONTAINED_BY : a.FOLLOWING : f === r ? a.PRECEDING | a.CONTAINS : a.PRECEDING;
  }
  function C(r) {
    return r = r.filter(function(e, t, i) {
      return !i.includes(e, t + 1);
    }), r.sort(function(e, t) {
      var i = O(e, t);
      return i & a.PRECEDING ? -1 : i & a.FOLLOWING ? 1 : 0;
    }), r;
  }
  return N;
}
export {
  b as __require
};
//# sourceMappingURL=helpers.js.map
