"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.isNodeTypeValidChildOf = isNodeTypeValidChildOf;
var _model = require("@atlaskit/editor-prosemirror/model");
/**
 * Checks if a node type is a valid child of a parent node by creating a minimal valid
 * instance and validating it against the parent's content expression. Unlike ProseMirror's
 * canReplaceWith, this checks general type compatibility without requiring a specific insertion index.
 */
function isNodeTypeValidChildOf(childTypeName, parentNode, schema) {
  var childType = schema.nodes[childTypeName];
  if (!childType) {
    return false;
  }
  var candidate = childType.createAndFill();
  if (!candidate) {
    return false;
  }
  return parentNode.type.validContent(_model.Fragment.from(candidate));
}