"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.hasVisibleContent = hasVisibleContent;
/**
 * Returns false if node contains only empty inline nodes and hardBreaks.
 */
function hasVisibleContent(node) {
  var isInlineNodeHasVisibleContent = function isInlineNodeHasVisibleContent(inlineNode) {
    return inlineNode.isText ? !!inlineNode.textContent.trim() : inlineNode.type.name !== 'hardBreak';
  };
  if (node.isInline) {
    return isInlineNodeHasVisibleContent(node);
  } else if (node.isBlock && (node.isLeaf || node.isAtom)) {
    return true;
  } else if (!node.childCount) {
    return false;
  }
  for (var index = 0; index < node.childCount; index++) {
    var child = node.child(index);
    var invisibleNodeTypes = ['paragraph', 'text', 'hardBreak'];
    if (!invisibleNodeTypes.includes(child.type.name) || hasVisibleContent(child)) {
      return true;
    }
  }
  return false;
}