import find from 'lodash/find'

import type { MatchInfo } from 'requests/getMatchInfo'

import { FULL_MATCH_BOUNDARY } from 'features/MatchPage/components/LiveMatch/helpers'

export const calculateDuration = (profile: MatchInfo) => {
  const bound = find(profile?.video_bounds, { h: FULL_MATCH_BOUNDARY })
  if (!bound) return 0
  return Number(bound.e) - Number(bound.s)
}
