
    <g                         d dl Z d dlmZmZmZ d dlmZ d dlmZ  ee       ed      k  r e	dez         G d de      Z
y)	    N)BytesIOKaitaiStreamKaitaiStruct)__version__)parse_versionz0.7zPIncompatible Kaitai Struct Python API: 0.7 or later is required, but you have %sc                   4    e Zd ZdZddZd Z G d de      Zy)IcoaD  Microsoft Windows uses specific file format to store applications
    icons - ICO. This is a container that contains one or more image
    files (effectively, DIB parts of BMP files or full PNG files are
    contained inside).
    
    .. seealso::
       Source - https://msdn.microsoft.com/en-us/library/ms997538.aspx
    Nc                 V    || _         || _        |r|n| | _        | j                          y N_io_parent_root_readselfr   r   r   s       n/var/www/html/myenv/lib/python3.12/site-packages/seleniumwire/thirdparty/mitmproxy/contrib/kaitaistruct/ico.py__init__zIco.__init__   s$    #U


    c           	         | j                   j                  t        j                  ddddd            | _        | j                   j                         | _        d g| j                  z  | _        t        | j                        D ]@  }| j                  j                  | j                   | | j                        | j                  |<   B y )N4br      )r   ensure_fixed_contentsstructpackmagic	read_u2le
num_imagesimagesranger   IconDirEntry)r   is     r   r   z	Ico._read   s    XX33FKKaAq4QR
((,,.f0t' 	QA!ZZ44TXXtTZZPDKKN	Qr   c                   J    e Zd ZddZd Zed        Zed        Zed        Zy)Ico.IconDirEntryNc                 V    || _         || _        |r|n| | _        | j                          y r   r   r   s       r   r   zIco.IconDirEntry.__init__$   s$    DH"DL"'TDJJJLr   c                    | j                   j                         | _        | j                   j                         | _        | j                   j                         | _        | j                   j                  t        j                  dd            | _        | j                   j                         | _
        | j                   j                         | _        | j                   j                         | _        | j                   j                         | _        y )N1br   )r   read_u1widthheight
num_colorsr   r   r   reservedr   
num_planesbpp	read_u4lelen_imgofs_imgr   s    r   r   zIco.IconDirEntry._read*   s    ))+DJ((**,DK"hh..0DO HH::6;;tQ;OPDM"hh002DOxx))+DH88--/DL88--/DLr   c                    t        | d      rt        | d      r| j                  S dS | j                  j                         }| j                  j	                  | j
                         | j                  j                  | j                        | _        | j                  j	                  |       t        | d      r| j                  S dS )zRaw image data. Use `is_png` to determine whether this is an
            embedded PNG file (true) or a DIB bitmap (false) and call a
            relevant parser, if needed to parse image data further.
            _m_imgN)hasattrr4   r   posseekr1   
read_bytesr0   r   _poss     r   imgzIco.IconDirEntry.img4   s     tX&&-dH&=t{{G4G88<<>DHHMM$,,'((--dll;DKHHMM$")$"94;;CtCr   c                 v   t        | d      rt        | d      r| j                  S dS | j                  j                         }| j                  j	                  | j
                         | j                  j                  d      | _        | j                  j	                  |       t        | d      r| j                  S dS )zhPre-reads first 8 bytes of the image to determine if it's an
            embedded PNG file.
            _m_png_headerN   )r5   r=   r   r6   r7   r1   r8   r9   s     r   
png_headerzIco.IconDirEntry.png_headerC   s    
 t_--4T?-Kt))UQUU88<<>DHHMM$,,'!%!4!4Q!7DHHMM$)0)G4%%QTQr   c                     t        | d      rt        | d      r| j                  S dS | j                  t        j                  ddddddd	d
d		      k(  | _        t        | d      r| j                  S dS )z$True if this image is in PNG format.	_m_is_pngN8biP   N   G      
      )r5   rA   r?   r   r   r2   s    r   is_pngzIco.IconDirEntry.is_pngQ   sl     t[))0{)Ct~~MM!__D$BPRTVXZ\^`b0ccDN%,T;%?4>>ITIr   NN)	__name__
__module____qualname__r   r   propertyr;   r?   rI    r   r   r!   r$   #   sN    		0 
	D 
	D 
	R 
	R 
	J 
	Jr   r!   rJ   )rK   rL   rM   __doc__r   r   r   r!   rO   r   r   r	   r	      s     Q5J| 5Jr   r	   )r   kaitaistructr   r   r   r   
ks_versionpkg_resourcesr   	Exceptionr	   rO   r   r   <module>rU      sJ     < < 2 '}U33
fjtu
vvLJ, LJr   