from typing import Union
from typing import Tuple
from typing import List
import math


def parse_box(box: Union[Tuple, List]) -> Tuple[float, float, float, float]:
    """Parses the `box` value from Newspaper Navigator data to prepre for IIIF request"""
    box_x1, box_x2, box_y1, box_y2 = box
    x = math.floor(box_x1 * 10000) / 100.0
    y = math.ceil(box_x2 * 10000) / 100.0
    w = math.ceil((box_y1 - box_x1) * 10000) / 100.0
    h = math.ceil((box_y2 - box_x2) * 10000) / 100.0
    return x, y, w, h