"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const siblings = require("./lib-omission-util-siblings.cjs");
const closing = require("./lib-omission-closing.cjs");
const omission = require("./lib-omission-omission.cjs");
const index = require("../hast-util-whitespace/lib-index.cjs");
const opening = omission.omission({
  body,
  colgroup,
  head,
  html,
  tbody
});
function html(node) {
  const head2 = siblings.siblingAfter(node, -1);
  return !head2 || head2.type !== "comment";
}
function head(node) {
  const seen = /* @__PURE__ */ new Set();
  for (const child2 of node.children) {
    if (child2.type === "element" && (child2.tagName === "base" || child2.tagName === "title")) {
      if (seen.has(child2.tagName)) return false;
      seen.add(child2.tagName);
    }
  }
  const child = node.children[0];
  return !child || child.type === "element";
}
function body(node) {
  const head2 = siblings.siblingAfter(node, -1, true);
  return !head2 || head2.type !== "comment" && !(head2.type === "text" && index.whitespace(head2.value.charAt(0))) && !(head2.type === "element" && (head2.tagName === "meta" || head2.tagName === "link" || head2.tagName === "script" || head2.tagName === "style" || head2.tagName === "template"));
}
function colgroup(node, index2, parent) {
  const previous = siblings.siblingBefore(parent, index2);
  const head2 = siblings.siblingAfter(node, -1, true);
  if (parent && previous && previous.type === "element" && previous.tagName === "colgroup" && closing.closing(previous, parent.children.indexOf(previous), parent)) {
    return false;
  }
  return Boolean(head2 && head2.type === "element" && head2.tagName === "col");
}
function tbody(node, index2, parent) {
  const previous = siblings.siblingBefore(parent, index2);
  const head2 = siblings.siblingAfter(node, -1);
  if (parent && previous && previous.type === "element" && (previous.tagName === "thead" || previous.tagName === "tbody") && closing.closing(previous, parent.children.indexOf(previous), parent)) {
    return false;
  }
  return Boolean(head2 && head2.type === "element" && head2.tagName === "tr");
}
exports.opening = opening;
//# sourceMappingURL=lib-omission-opening.cjs.map
