from typing import Tuple


def _pos_from_offset(col: int, msg: bytes, offset: int) -> Tuple[int, int]:
    """Calculate the line and column of a given offset."""
    msg = msg[:offset]
    lines = msg.split(b"\n")

    line = len(lines) - 1
    col = len(lines[-1]) + (col if line == 0 else 0)

    return (line, col)