
    ei                         d dl Z d dlmZmZmZ d dlmZ 	 ej                  Zd dl	m
Z ddZd Zd Zy# e$ r	 d dlmZ Y w xY w)	    N)HHtmlElementstyles)unit)spanc                    i }|r||d<   |r|}nqt        d |D              }t        j                  |t        t        j                        z     }t        j                  |t        t        j                        z     }||z   }d}	|rd}
t        j
                  r(t        t        ddt        j                  d            f}
|
 t        t        t        j                  t        j                  t        j                  	            t        j                  |            f}	 t        t        dd
dd|t        j                  t        j                  ddd||      t        j                  |       |	      S )ar  Build an HtmlElement span object with the given body and annotation label.

    The end result will look something like this:

        [body | label]

    Parameters
    ----------
    body : string
        The string to put in the "body" part of the annotation.
    label : string
        The string to put in the "label" part of the annotation.
    background : string or None
        The color to use for the background "chip" containing this annotation.
        If None, will use a random color based on the label.
    color : string or None
        The color to use for the body and label text.
        If None, will use the document's default text color.
    style : dict
        Any CSS you want to apply to the containing "chip". This is useful for things like


    Examples
    --------

    Produce a simple annotation with default colors:

    >>> annotation("apple", "fruit")

    Produce an annotation with custom colors:

    >>> annotation("apple", "fruit", background="#FF0", color="black")

    Produce an annotation with crazy CSS:

    >>> annotation("apple", "fruit", background="#FF0", border="1px dashed red")

    colorc              3   2   K   | ]  }t        |        y w)N)ord).0cs     U/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/annotated_text/util.py	<genexpr>zannotation.<locals>.<genexpr>A   s     .1A.s    z	1px solidg?stretch)border_leftopacitymargin_left
align_self)style)r   	font_sizer   zinline-flexrowcenterhidden   )displayflex_directionalign_items
backgroundborder_radiuspaddingoverflowline_height )sumpPALETTElen	OPACITIESSHOW_LABEL_SEPARATORr   r   LABEL_SPACINGLABEL_FONT_SIZELABEL_OPACITYhtmlescapeBORDER_RADIUSPADDING)bodylabelr   r	   r   color_stylebackground_color	label_sumbackground_opacitylabel_element	separators              r   
annotationr:      sc   P K$G%...	99YQYY%?@[[S5E)EF%(::
M	!!"+ !(	 I D !//OO E"
	
 
%$$%oo		!
 
 
	
 KK	
    c                  $    t        t        |        S )zWrites text with annotations into an HTML string.

    Parameters
    ----------
    *args : see annotated_text()

    Returns
    -------
    str
        An HTML string.
    )strget_annotated_element)argss    r   get_annotated_htmlr@   v   s     $d+,,r;   c                  B   t               }| D ]  }t        |t              r |t        j                  |             /t        |t
              r	 ||       Ht        |t              r |t        |        gt        |t              r |t        |        t        d       |S )zWrites text with annotations into an HTBuilder HtmlElement object.

    Parameters
    ----------
    *args : see annotated_text()

    Returns
    -------
    HtmlElement
        An HTBuilder HtmlElement object.
    zOh noes!)r   
isinstancer=   r.   r/   r   tupler:   listr>   	Exception)r?   outargs      r   r>   r>      s     &C (c3C ![)HU#
C !T"%s+, J''(  Jr;   )r   NN)r.   	htbuilderr   r   r   htbuilder.unitsr   r   AttributeErrorannotated_text.parameters
parametersr&   r:   r@   r>   r$   r;   r   <module>rM      sJ     , ,  66D &bJ- u  s   3 A A