# Path: weasyprint/formatting_structure/boxes.py
# class Box:
# class ParentBox(Box):
# class BlockLevelBox(Box):
# class BlockContainerBox(ParentBox):
# class BlockBox(BlockContainerBox, BlockLevelBox):
# class LineBox(ParentBox):
# class InlineLevelBox(Box):
# class InlineBox(InlineLevelBox, ParentBox):
# class TextBox(InlineLevelBox):
# class AtomicInlineLevelBox(InlineLevelBox):
# class InlineBlockBox(AtomicInlineLevelBox, BlockContainerBox):
# class ReplacedBox(Box):
# class BlockReplacedBox(ReplacedBox, BlockLevelBox):
# class InlineReplacedBox(ReplacedBox, AtomicInlineLevelBox):
# class TableBox(BlockLevelBox, ParentBox):
# class InlineTableBox(TableBox):
# class TableRowGroupBox(ParentBox):
# class TableRowBox(ParentBox):
# class TableColumnGroupBox(ParentBox):
# class TableColumnBox(ParentBox):
# class TableCellBox(BlockContainerBox):
# class TableCaptionBox(BlockBox):
# class PageBox(ParentBox):
# class MarginBox(BlockContainerBox):
# class FootnoteAreaBox(BlockBox):
# class FlexContainerBox(ParentBox):
# class FlexBox(FlexContainerBox, BlockLevelBox):
# class InlineFlexBox(FlexContainerBox, InlineLevelBox):
#     def all_children(self):
#     def __init__(self, element_tag, style, element):
#     def __repr__(self):
#     def anonymous_from(cls, parent, *args, **kwargs):
#     def copy(self):
#     def deepcopy(self):
#     def translate(self, dx=0, dy=0, ignore_floats=False):
#     def padding_width(self):
#     def padding_height(self):
#     def border_width(self):
#     def border_height(self):
#     def margin_width(self):
#     def margin_height(self):
#     def content_box_x(self):
#     def content_box_y(self):
#     def padding_box_x(self):
#     def padding_box_y(self):
#     def border_box_x(self):
#     def border_box_y(self):
#     def hit_area(self):
#     def rounded_box(self, bt, br, bb, bl):
#     def rounded_box_ratio(self, ratio):
#     def rounded_padding_box(self):
#     def rounded_border_box(self):
#     def rounded_content_box(self):
#     def is_floated(self):
#     def is_footnote(self):
#     def is_absolutely_positioned(self):
#     def is_running(self):
#     def is_in_normal_flow(self):
#     def page_values(self):
#     def __init__(self, element_tag, style, element, children):
#     def all_children(self):
#     def _reset_spacing(self, side):
#     def remove_decoration(self, start, end):
#     def copy_with_children(self, new_children):
#     def deepcopy(self):
#     def descendants(self):
#     def get_wrapped_table(self):
#     def page_values(self):
#     def anonymous_from(cls, parent, *args, **kwargs):
#     def remove_decoration(self, start, end):
#     def hit_area(self):
#     def __init__(self, element_tag, style, element, text):
#     def copy_with_text(self, text):
#     def __init__(self, element_tag, style, element, replacement):
#     def all_children(self):
#     def translate(self, dx=0, dy=0, ignore_floats=False):
#     def page_values(self):
#     def get_cells(self):
#     def get_cells(self):
#     def __init__(self, page_type, style):
#     def __repr__(self):
#     def __init__(self, at_keyword, style):
#     def __repr__(self):
#     def __init__(self, page, style):
#     def __repr__(self):


from math import inf
from ..formatting_structure import boxes
    just replaces percentages.

    """
    # box.style has computed values
    value = box.style[property_name]
    # box attributes are used values
    percent = percentage(value, refer_to)
    setattr(box, property_name, percent)
    if property_name in ('min_width', 'min_height') and percent == 'auto':
        if (main_flex_direction is None or
                property_name != (f'min_{main_flex_direction}')):
            setattr(box, property_name, 0)


def resolve_position_percentages(box, containing_block):
    cb_width, cb_height = containing_block
    resolve_one_percentage(box, 'left', cb_width)
    resolve_one_percentage(box, 'right', cb_width)
    resolve_one_percentage(box, 'top', cb_height)
    resolve_one_percentage(box, 'bottom', cb_height)


def resolve_percentages(box, containing_block, main_flex_direction=None):
    """Set used values as attributes of the box object."""
    if isinstance(containing_block, boxes.Box):
        # cb is short for containing block
        cb_width = containing_block.width
        cb_height = containing_block.height
    else:
        cb_width, cb_height = containing_block

# Path: weasyprint/formatting_structure/boxes.py
# class Box:
# class ParentBox(Box):
# class BlockLevelBox(Box):
# class BlockContainerBox(ParentBox):
# class BlockBox(BlockContainerBox, BlockLevelBox):
# class LineBox(ParentBox):
# class InlineLevelBox(Box):
# class InlineBox(InlineLevelBox, ParentBox):
# class TextBox(InlineLevelBox):
# class AtomicInlineLevelBox(InlineLevelBox):
# class InlineBlockBox(AtomicInlineLevelBox, BlockContainerBox):
# class ReplacedBox(Box):
# class BlockReplacedBox(ReplacedBox, BlockLevelBox):
# class InlineReplacedBox(ReplacedBox, AtomicInlineLevelBox):
# class TableBox(BlockLevelBox, ParentBox):
# class InlineTableBox(TableBox):
# class TableRowGroupBox(ParentBox):
# class TableRowBox(ParentBox):
# class TableColumnGroupBox(ParentBox):
# class TableColumnBox(ParentBox):
# class TableCellBox(BlockContainerBox):
# class TableCaptionBox(BlockBox):
# class PageBox(ParentBox):
# class MarginBox(BlockContainerBox):
# class FootnoteAreaBox(BlockBox):
# class FlexContainerBox(ParentBox):
# class FlexBox(FlexContainerBox, BlockLevelBox):
# class InlineFlexBox(FlexContainerBox, InlineLevelBox):
#     def all_children(self):
#     def __init__(self, element_tag, style, element):
#     def __repr__(self):
#     def anonymous_from(cls, parent, *args, **kwargs):
#     def copy(self):
#     def deepcopy(self):
#     def translate(self, dx=0, dy=0, ignore_floats=False):
#     def padding_width(self):
#     def padding_height(self):
#     def border_width(self):
#     def border_height(self):
#     def margin_width(self):
#     def margin_height(self):
#     def content_box_x(self):
#     def content_box_y(self):
#     def padding_box_x(self):
#     def padding_box_y(self):
#     def border_box_x(self):
#     def border_box_y(self):
#     def hit_area(self):
#     def rounded_box(self, bt, br, bb, bl):
#     def rounded_box_ratio(self, ratio):
#     def rounded_padding_box(self):
#     def rounded_border_box(self):
#     def rounded_content_box(self):
#     def is_floated(self):
#     def is_footnote(self):
#     def is_absolutely_positioned(self):
#     def is_running(self):
#     def is_in_normal_flow(self):
#     def page_values(self):
#     def __init__(self, element_tag, style, element, children):
#     def all_children(self):
#     def _reset_spacing(self, side):
#     def remove_decoration(self, start, end):
#     def copy_with_children(self, new_children):
#     def deepcopy(self):
#     def descendants(self):
#     def get_wrapped_table(self):
#     def page_values(self):
#     def anonymous_from(cls, parent, *args, **kwargs):
#     def remove_decoration(self, start, end):
#     def hit_area(self):
#     def __init__(self, element_tag, style, element, text):
#     def copy_with_text(self, text):
#     def __init__(self, element_tag, style, element, replacement):
#     def all_children(self):
#     def translate(self, dx=0, dy=0, ignore_floats=False):
#     def page_values(self):
#     def get_cells(self):
#     def get_cells(self):
#     def __init__(self, page_type, style):
#     def __repr__(self):
#     def __init__(self, at_keyword, style):
#     def __repr__(self):
#     def __init__(self, page, style):
#     def __repr__(self):


# Path: weasyprint/layout/percent.py
from math import inf
from ..formatting_structure import boxes

    just replaces percentages.

    """
    # box.style has computed values
    value = box.style[property_name]
    # box attributes are used values
    percent = percentage(value, refer_to)
    setattr(box, property_name, percent)
    if property_name in ('min_width', 'min_height') and percent == 'auto':
        if (main_flex_direction is None or
                property_name != (f'min_{main_flex_direction}')):
            setattr(box, property_name, 0)


def resolve_position_percentages(box, containing_block):
    cb_width, cb_height = containing_block
    resolve_one_percentage(box, 'left', cb_width)
    resolve_one_percentage(box, 'right', cb_width)
    resolve_one_percentage(box, 'top', cb_height)
    resolve_one_percentage(box, 'bottom', cb_height)


def resolve_percentages(box, containing_block, main_flex_direction=None):
    """Set used values as attributes of the box object."""
    if isinstance(containing_block, boxes.Box):
        # cb is short for containing block
        cb_width = containing_block.width
        cb_height = containing_block.height
    else:
        cb_width, cb_height = containing_block

    if isinstance(box, boxes.PageBox):