
    AHj                         d dl Z  e j                  d      j                  Z G d de      Z G d de      Zdedefd	Z	y)
    Nz^(-?\d+\.?\d*)(s|ms)$c                       e Zd ZdZy)DurationErrorzC
    Exception indicating a general issue with a CSS duration.
    N__name__
__module____qualname____doc__     I/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/_duration.pyr   r          r   r   c                       e Zd ZdZy)DurationParseErrorzI
    Indicates a malformed duration string that could not be parsed.
    Nr   r
   r   r   r   r      r   r   r   durationreturnc                     t        |       }|r.|j                         \  }}t        |      }|dk(  r|dz  }|S |}|S 	 t        |       }|S # t        $ r t	        | d      dw xY w)a  
    Args:
        duration: A string of the form `"2s"` or `"300ms"`, representing 2 seconds and
            300 milliseconds respectively. If no unit is supplied, e.g. `"2"`, then the duration is
            assumed to be in seconds.
    Raises:
        DurationParseError: If the argument `duration` is not a valid duration string.
    Returns:
        The duration in seconds.
    msi  z is not a valid duration.N)_match_durationgroupsfloat
ValueErrorr   )r   matchvalue	unit_nameduration_secss        r   _duration_as_secondsr      s     H%E <<>ye!DLM  "M 	Y!(OM   	Y$|3L%MNTXX	Ys   A
 
A#)
recompiler   r   	Exceptionr   r   strr   r   r
   r   r   <module>r!      sJ    	"**56<<I  3 5 r   