# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401, F403, F405
r"""
Gravity optimization for nesting layouts.

Provides binary-search gravity sliding to tighten packing by sliding
parts down and left as far as possible without overlapping.
"""

import collections.abc
from raygeo.geo import types
__all__ = [
    "apply_gravity",
    "find_max_slide",
]

def apply_gravity(placement_groups: collections.abc.Sequence[collections.abc.Sequence[types.Polygon]], sheet_poly: types.Polygon, spacing: float) -> list[tuple[float, float]]:
    r"""
    Apply gravity sliding to tighten a nesting layout.
    
    Iterates Y and X passes until no movement occurs (max 10 passes).
    Returns a ``(dx, dy)`` adjustment for each input group in order.
    
    :param placement_groups: List of placed parts (each a list of polygons).
    :param sheet_poly: Sheet polygon.
    :param spacing: Minimum spacing between parts.
    :returns: List of ``(dx, dy)`` adjustments, one per group.
    :complexity: O(passes * n * m) where passes ≤ 10.
    """

def find_max_slide(polys: collections.abc.Sequence[types.Polygon], other_polys_list: collections.abc.Sequence[collections.abc.Sequence[types.Polygon]], sheet_bounds: tuple[float, float, float, float], sheet_poly: types.Polygon, axis: str, spacing: float) -> float:
    r"""
    Find the maximum distance a part can slide in the negative axis direction.
    
    Uses binary search with polygon overlap and containment checks.
    
    :param polys: Polygons of the part to slide.
    :param other_polys_list: Polygons of all other placed parts (grouped).
    :param sheet_bounds: Sheet bounding box (min_x, min_y, max_x, max_y).
    :param sheet_poly: Sheet polygon.
    :param axis: ``"x"`` or ``"y"`` — axis to slide along.
    :param spacing: Minimum spacing between parts.
    :returns: Maximum slide distance.
    :complexity: O(log range * n * m) for binary search with overlap checks.
    """

