'use strict';

var index = require('../../../../../../hast-util-whitespace@2.0.1/node_modules/hast-util-whitespace/index.js');

/**
 * @typedef {import('../../types.js').Parent} Parent
 * @typedef {import('../../types.js').Content} Content
 */


const siblingAfter = siblings(1);
const siblingBefore = siblings(-1);

/**
 * Factory to check siblings in a direction.
 *
 * @param {number} increment
 */
function siblings(increment) {
  return sibling

  /**
   * Find applicable siblings in a direction.
   *
   * @param {Parent | null | undefined} parent
   * @param {number | null | undefined} index
   * @param {boolean | null | undefined} [includeWhitespace=false]
   * @returns {Content}
   */
  function sibling(parent, index$1, includeWhitespace) {
    const siblings = parent ? parent.children : [];
    let offset = (index$1 || 0) + increment;
    let next = siblings && siblings[offset];

    if (!includeWhitespace) {
      while (next && index.whitespace(next)) {
        offset += increment;
        next = siblings[offset];
      }
    }

    return next
  }
}

exports.siblingAfter = siblingAfter;
exports.siblingBefore = siblingBefore;
//# sourceMappingURL=siblings.js.map
