function sensaNormalizeText(value) {
  return String(value || "").replace(/\s+/g, " ").trim();
}

function sensaIsElementVisible(element) {
  if (!(element instanceof Element)) {
    return false;
  }

  const style = window.getComputedStyle(element);
  if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0") {
    return false;
  }

  const rect = element.getBoundingClientRect();
  return rect.width > 0 && rect.height > 0;
}

function sensaShouldSkipTextNode(element) {
  if (!sensaIsElementVisible(element)) {
    return true;
  }

  const tagName = element.tagName.toLowerCase();
  return ["script", "style", "noscript", "template"].includes(tagName);
}
