import { fadeInClassName, fadeOutClassName } from '../Modal/Modal.styles';
import { closingPhasesInOrder, openingPhasesInOrder } from './Tearsheet.constants';
export var wait = function wait(ms) {
  return new Promise(function (res) {
    return setTimeout(res, ms);
  });
};
function getIsPhaseInProgressOrComplete(targetPhase, currentPhase, status) {
  if (currentPhase === 'disabled') {
    return false;
  }
  if (status === 'opening') {
    return openingPhasesInOrder.indexOf(targetPhase) <= openingPhasesInOrder.indexOf(currentPhase);
  }
  if (status === 'closing') {
    return closingPhasesInOrder.indexOf(targetPhase) <= closingPhasesInOrder.indexOf(currentPhase);
  }
  return false;
}
export function getScrimClassName(status, phase) {
  if (status === 'open') {
    return fadeInClassName;
  }
  if (status === 'closed') {
    return fadeOutClassName;
  }
  if (status === 'closing') {
    return getIsPhaseInProgressOrComplete('scrim', phase, status) ? fadeOutClassName : fadeInClassName;
  }
  if (status === 'opening') {
    return getIsPhaseInProgressOrComplete('scrim', phase, status) ? fadeInClassName : fadeOutClassName;
  }
}
export function getAnimationState(targetPhase, currentPhase, status) {
  if (status === 'open') {
    return {
      $open: true
    };
  }
  if (status === 'closed') {
    return {
      $open: false
    };
  }
  var inProgressOrComplete = getIsPhaseInProgressOrComplete(targetPhase, currentPhase, status);
  if (status === 'closing') {
    return {
      $open: !inProgressOrComplete,
      $closing: targetPhase === currentPhase
    };
  }
  if (status === 'opening') {
    return {
      $open: inProgressOrComplete,
      $opening: targetPhase === currentPhase
    };
  }
  return {
    $open: false
  };
}
//# sourceMappingURL=Tearsheet.util.js.map