function analyzeEliminationDrawPositions(params) {
  const { unfilledPositions, chunkedDrawPositions } = params;
  const profiledPositions = getPositionProfiles(params);

  const checkedChunk = chunkedDrawPositions.map((chunkedGrouping) => {
    const unassigned = unfilledPositions.filter((unfilledPosition) =>
      chunkedGrouping.includes(unfilledPosition)
    );
    const unpaired = unpairedPositions(unassigned);
    const paired = unassigned.filter(
      (drawPosition) => !unpaired.includes(drawPosition)
    );
    const pairedNoConflict = paired.filter((drawPosition) => {
      const pairedPosition = getPairedPosition(drawPosition);
      return !profiledPositions[pairedPosition]?.includesGroupsToAvoid;
    });
    return { unassigned, unpaired, pairedNoConflict };
  });

  return checkedChunk;

  function unpairedPositions(unassigned) {
    return unassigned.filter((u) => !pairAssigned(u));

    function pairAssigned(drawPosition) {
      const pairedPosition = getPairedPosition(drawPosition);
      return !unassigned.includes(pairedPosition);
    }
  }
}
/**
 *
 * @param {string[]} allGroups - group names derived from participant attributes which match policyAttributes
 * @param {string[]} groupsToAvoid - names of groups which contain the participantId currently being placed
 * @param {number[]} unfilledPositions - drawPositions which have not been assigned a participantid
 * @param {object[]} positionAssignments - array of assignment objects { drawPosition, participantId }
 * @param {object[]} chunkedDrawPositions - array of arrays of drawPositions
 *
 * Returns different types of placement options.
 * 1. positions which are unassigned
 * 2. unassigned positions which are not paired with any other participantId
 * 3. unassigned positions which are paired and which have no conflicting groupings (groupings to avoid)
 *
 */


Returns different types of placement options.
1. positions which are unassigned
2. unassigned positions which are not paired with any other participantId
3. unassigned positions which are paired and which have no conflicting groupings (groupings to avoid)
Returns different types of placement options . 1 . positions which are unassigned 2 . unassigned positions which are not paired with any other participantId 3 . unassigned positions which are paired and which have no conflicting groupings ( groupings to avoid )
function analyzeEliminationDrawPositions(params) {
  const { unfilledPositions, chunkedDrawPositions } = params;
  const profiledPositions = getPositionProfiles(params);
  const checkedChunk = chunkedDrawPositions.map((chunkedGrouping) => {
    const unassigned = unfilledPositions.filter((unfilledPosition) =>
      chunkedGrouping.includes(unfilledPosition)
    );
    const unpaired = unpairedPositions(unassigned);
    const paired = unassigned.filter(
      (drawPosition) => !unpaired.includes(drawPosition)
    );
    const pairedNoConflict = paired.filter((drawPosition) => {
      const pairedPosition = getPairedPosition(drawPosition);
      return !profiledPositions[pairedPosition]?.includesGroupsToAvoid;
    });
    return { unassigned, unpaired, pairedNoConflict };
  });
  return checkedChunk;
  function unpairedPositions(unassigned) {
    return unassigned.filter((u) => !pairAssigned(u));
    function pairAssigned(drawPosition) {
      const pairedPosition = getPairedPosition(drawPosition);
      return !unassigned.includes(pairedPosition);
    }
  }
}
function analyzeEliminationDrawPositions ( params ) { const { unfilledPositions , chunkedDrawPositions } = params ; const profiledPositions = getPositionProfiles ( params ) ; const checkedChunk = chunkedDrawPositions . map ( ( chunkedGrouping ) => { const unassigned = unfilledPositions . filter ( ( unfilledPosition ) => chunkedGrouping . includes ( unfilledPosition ) ) ; const unpaired = unpairedPositions ( unassigned ) ; const paired = unassigned . filter ( ( drawPosition ) => ! unpaired . includes ( drawPosition ) ) ; const pairedNoConflict = paired . filter ( ( drawPosition ) => { const pairedPosition = getPairedPosition ( drawPosition ) ; return ! profiledPositions [ pairedPosition ] ?. includesGroupsToAvoid ; } ) ; return { unassigned , unpaired , pairedNoConflict } ; } ) ; return checkedChunk ; function unpairedPositions ( unassigned ) { return unassigned . filter ( ( u ) => ! pairAssigned ( u ) ) ; function pairAssigned ( drawPosition ) { const pairedPosition = getPairedPosition ( drawPosition ) ; return ! unassigned . includes ( pairedPosition ) ; } } }
@param {string[]} allGroups - group names derived from participant attributes which match policyAttributes
 @param {string[]} groupsToAvoid - names of groups which contain the participantId currently being placed
 @param {number[]} unfilledPositions - drawPositions which have not been assigned a participantid
 @param {object[]} positionAssignments - array of assignment objects { drawPosition, participantId }
 @param {object[]} chunkedDrawPositions - array of arrays of drawPositions
@param { string [] } allGroups - group names derived from participant attributes which match policyAttributes @param { string [] } groupsToAvoid - names of groups which contain the participantId currently being placed @param { number [] } unfilledPositions - drawPositions which have not been assigned a participantid @param { object [] } positionAssignments - array of assignment objects { drawPosition participantId } @param { object [] } chunkedDrawPositions - array of arrays of drawPositions