)L i$dZddlmZddlmZmZmZmZgdZerddl m Z GddZ d dZ d d Z ed ee egeffZdd Zdd Ze Ze Zy )zo Layout dimensions are used to give the minimum, maximum and preferred dimensions for containers and controls. ) annotations) TYPE_CHECKINGAnyCallableUnion) DimensionDsum_layout_dimensionsmax_layout_dimensions AnyDimension to_dimension is_dimension) TypeGuardc`eZdZdZ d ddZed dZed dZd dZy) ra Specified dimension (width/height) of a user control or window. The layout engine tries to honor the preferred size. If that is not possible, because the terminal is larger or smaller, it tries to keep in between min and max. :param min: Minimum size. :param max: Maximum size. :param weight: For a VSplit/HSplit, the actual size will be determined by taking the proportion of weights from all the children. E.g. When there are two children, one with a weight of 1, and the other with a weight of 2, the second will always be twice as big as the first, if the min/max values allow it. :param preferred: Preferred size. Nc||dk\sJ||dk\sJ||dk\sJ||dk\sJ|du|_|du|_|du|_|du|_|d}|d}||}|d}||_||_||_||_||kr td|j |jkr|j|_|j |j kDr|j |_yy)Nrl73Me'zInvalid Dimension: max < min.) min_specified max_specifiedpreferred_specifiedweight_specifiedminmax preferredweight ValueError)selfrrrrs e/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/prompt_toolkit/layout/dimension.py__init__zDimension.__init__*s  Q; ;{cQh&&{cQh&& IN22 _ _#,D#8 &d 2 ;C ;C  I >F"  9<= = >>DHH $!XXDN >>DHH $!XXDN %c||||S)zv Return a :class:`.Dimension` with an exact size. (min, max and preferred set to ``amount``). rrr)clsamounts rexactzDimension.exactVs v6V<z(sum_layout_dimensions..x (aee (c34K|]}|jywr:rr<s rr?z(sum_layout_dimensions..yr@rAc34K|]}|jywr:rr<s rr?z(sum_layout_dimensions..zs4AAKK4rAr!)sumr) dimensionsrrrs rr r tsC  (Z ( (C (Z ( (C444I # ;;rct|stjStd|DrtjS|Dcgc]$}|jdk7s|j dk7s#|&}}|rgt d|D}t d|D}t |t d|D}||kDr|}t d|D}t|||StScc}w)z Take the maximum of a list of :class:`.Dimension` instances. Used when we have a HSplit/VSplit, and we want to get the best width/height.) c3\K|]$}|jdk(xr|jdk(&yw)rN)rrr<s rr?z(max_layout_dimensions..s) ?q1;;!  * * ?s*,rc34K|]}|jywr:r;r<s rr?z(max_layout_dimensions..-Q155-rAc34K|]}|jywr:rCr<s rr?z(max_layout_dimensions..rKrAc34K|]}|jywr:rEr<s rr?z(max_layout_dimensions..s=QQ[[=rAc34K|]}|jywr:rEr<s rr?z(max_layout_dimensions..s8 8rAr!)lenrr'allrrr)rGr>min_max_rs rr r s z?~~  ?J ??~~(K1;;!+; !KJK-*---*--4=*==> $;D8Z88 TtyAA{7Ls C(C(/C(Nc| tSt|trtj|St|tr|St |rt |St d)z: Turn the given object into a `Dimension` object. z#Not an integer or Dimension object.)r isinstancer1r%callabler rvalues rr r sY }{%u%%%# EG$$ : ;;rcP|yt|ryt|ttfryy)z Test whether the given value could be a valid dimension. (For usage in an assertion. It's not guaranteed in case of a callable.) TF)rUrTr1rrVs rrrs+  }%#y)* r)rGzlist[Dimension]r/r)rWr r/r)rWobjectr/zTypeGuard[AnyDimension])r6 __future__rtypingrrrr__all__typing_extensionsrrr r r1r r rr LayoutDimensionr"rrr_sz #66 +Y9Y9x<*\  RW   < r