
    AHj              	       \    d dl mZmZ d dlmZ d dlmZ d dlmZ dee   dede	dee   fd	Z
y
)    )Iterablecast)Segment)Style)Colorsegmentsbase_backgroundopacityreturnc              #     K   t         }t        j                  }t        j                  }|j
                  }t        d|       }|D ]  \  }}	}
|	}|	j                  1 ||	j                        } |||      }| ||j                        z  }|	j                  1 ||	j                        } |||      }| ||j                        z  } |||        yw)a  Takes an iterable of foreground Segments and blends them into the supplied
    background color, yielding copies of the Segments with blended foreground and
    background colors applied.

    Args:
        segments: The segments in the foreground.
        base_background: The background color to blend foreground into.
        opacity: The blending factor. A value of 1.0 means output segments will
            have identical foreground and background colors to input segments.
    z#Iterable[tuple[str, Style, object]]N)color)bgcolor)
r   r   from_rich_colorr   
from_colorblendr   r   
rich_colorr   )r   r	   r
   _Segmentr   r   r   styled_segmentstextstyle_blended_styler   blended_foregroundr   blended_backgrounds                   H/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/_opacity.py_apply_opacityr   	   s      H++O!!J!!E@(KO) ,eQ;;"#EKK0E!&ug!6Z.@.K.KLLM==$%emm4G!&w!8Z0B0M0MNNMt]++,s   CCN)typingr   r   rich.segmentr   
rich.styler   textual.colorr   floatr        r   <module>r$      sD    !    !,w!,!, !, g	!,r#   