+
    kHàj:
  ã                  óF   € R t ^ RIHt ^ RIHt R R ltR R ltR R ltR	# )
zîTelegram ``text_link`` expansion, kept out of the adapter facade.

A rich-text hyperlink arrives as visible anchor text plus a ``text_link`` entity carrying the
URL; the model only ever sees the anchor unless the URL is inlined (#31071).
)Úannotations)ÚAnyc               ó    € V ^8„  d   QhRRRR/# )é   ÚtextÚstrÚreturnÚint© )Úformats   "ÚQ/home/ubuntu/.hermes/hermes-agent/plugins/platforms/telegram/telegram_entities.pyÚ__annotate__r      s   € ÷ .ñ .˜ð . ñ .ó    c                óD   € \        V P                  R 4      4      ^,          # )ú	utf-16-le)ÚlenÚencode)r   s   &r   Ú_utf16_lengthr      s   € Üˆt�{‰{˜;Ó'Ó(¨AÕ-Ð-r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   Úutf16_offsetr	   r   z
int | Noner
   )r   s   "r   r   r      s!   € ÷ ñ ˜Cð ¨sð °zñ r   c                óŽ   €  \        V P                  R4      RV^,           P                  R4      4      #   \         d     R# i ; i)zQPython index for a UTF-16 code-unit offset; None when it splits a surrogate pair.r   N)r   r   ÚdecodeÚUnicodeDecodeError)r   r   s   &&r   Ú_code_point_indexr      sE   € ðÜ�4—;‘;˜{Ó+Ð,>¨l¸QÕ.>Ð?×FÑFÀ{ÓSÓTÐTøÜô Úðús   ‚25 µAÁAc               ó    € V ^8„  d   QhRRRR/# )r   Úmessager   r   r   r
   )r   s   "r   r   r      s   € ÷ ,ñ , #ð ,¨#ñ ,r   c                ó  € \        V RR4      pV'       d   \        V RR4      ;'       g    . pM.\        V RR4      ;'       g    Rp\        V RR4      ;'       g    . pV'       d	   V'       g   V# \        V4      p. pV EF'  p\        \        VRR4      4      P                  R4      R,          P	                  4       p\        VR	R4      p\        V\        4      '       d   VP                  4       MRpVR
8w  g	   V'       g   K„   \        \        VRR4      4      p	\        \        VR^ 4      4      p
T	^ 8  g   T
^ 8:  g   Yš,           T8”  d   KÎ  \        Y4      \        YT
,           4      rËTe   Te   YË8:  d   Kú  YT P                  4       T8X  d   EK  TP                  Y¼T34       EK*  	  Tp\        VRR7       F4  w  rìpRV R2pWÜR P                  V4      '       d   K'  VRV  V WÜR  2pK6  	  V#   \        \        3 d     EKŠ  i ; i)ah  Message text (or caption) with every hidden ``text_link`` URL inlined after its anchor.

Entity offsets are UTF-16 code units (emoji before the anchor count twice), so they are mapped
to code-point indices before slicing. Malformed entities are skipped; an anchor that already
reads as its own URL, or text already carrying the inline form, is left untouched.
r   NÚentitiesÚcaptionÚ Úcaption_entitiesÚtypeÚ.ÚurlÚ	text_linkÚoffsetÚlengthT)Úreversez (Ú)éÿÿÿÿ)Úgetattrr   r   ÚsplitÚlowerÚ
isinstanceÚstripr	   Ú	TypeErrorÚ
ValueErrorr   ÚappendÚsortedÚ
startswith)r   r   r   Úutf16_lengthÚlinksÚentityÚentity_typeÚraw_urlr#   r%   r&   ÚstartÚendÚexpandedÚ_startÚinlines   &               r   Úexpand_link_entitiesr>      sñ  € ô �7˜F DÓ)€DßÜ˜7 J°Ó5×;Ð;¸‰ä�w 	¨4Ó0×6Ð6°BˆÜ˜7Ð$6¸Ó=×CÐCÀˆß—xØˆä  Ó&€LØ(*€EÜˆÜœ' &¨&°"Ó5Ó6×<Ñ<¸SÓAÀ"ÕE×KÑKÓMˆÜ˜& %¨Ó.ˆÜ!+¨G´S×!9Ò!9ˆg�m‰mŒo¸rˆØ˜+Ô%¯SÙð	Üœ ¨°2Ó6Ó7ˆFÜœ ¨°1Ó5Ó6ˆFð �AŒ:˜ 1œ¨­¸,Ô(FÙÜ& tÓ4Ô6GÈÐW]ÍoÓ6^ˆsØŠ=˜CšK¨3¬<ÙØ�cˆ?× Ñ Ó" cÔ)ÚØ�‰�e #Ð&×'ñ% ð( €HÜ" 5°$×7Ñˆ�SØ�c�U˜!�ˆØ�Dˆ>×$Ñ$ V×,Ò,ÙØ˜t �nÐ% f X¨h°t¨nÐ-=Ð>Šñ	 8ð
 €Oøô# œ:Ð&ô 	Ûð	ús   Ä,G2Ç2HÈHN)Ú__doc__Ú
__future__r   Útypingr   r   r   r>   r
   r   r   Ú<module>rB      s!   ðñõ #å õ.õ÷,r   