"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index = require("../unist-util-is/lib-index.cjs");
const findAfter = (
  // Note: overloads like this are needed to support optional generics.
  /**
   * @type {(
   *   (<Kind extends UnistParent, Check extends Test>(parent: Kind, index: Child<Kind> | number, test: Check) => Matches<Child<Kind>, Check> | undefined) &
   *   (<Kind extends UnistParent>(parent: Kind, index: Child<Kind> | number, test?: null | undefined) => Child<Kind> | undefined)
   * )}
   */
  /**
   * @param {UnistParent} parent
   * @param {UnistNode | number} index
   * @param {Test} [test]
   * @returns {UnistNode | undefined}
   */
  (function(parent, index$1, test) {
    const is = index.convert(test);
    if (!parent || !parent.type || !parent.children) {
      throw new Error("Expected parent node");
    }
    if (typeof index$1 === "number") {
      if (index$1 < 0 || index$1 === Number.POSITIVE_INFINITY) {
        throw new Error("Expected positive finite number as index");
      }
    } else {
      index$1 = parent.children.indexOf(index$1);
      if (index$1 < 0) {
        throw new Error("Expected child node or index");
      }
    }
    while (++index$1 < parent.children.length) {
      if (is(parent.children[index$1], index$1, parent)) {
        return parent.children[index$1];
      }
    }
    return void 0;
  })
);
exports.findAfter = findAfter;
//# sourceMappingURL=lib-index.cjs.map
