+
    .pÐj·  ã                  ó¼   € R t ^ RIHt ^ RIHtHt ^ RIHt ^ RIH	t	 ^ RI
Ht  ^ RItRt]	 ! R R	4      4       t ! R
 R4      t ! R R4      tR#   ] d    Rt L2i ; i)a  Keep Hermes's own auto-thread title rename out of the pinned session-context prompt.

``chat_name`` keys the pinned prompt, and the title lane renames a new auto-thread between its
first and second turns. While the thread carries Hermes's title, its chat name keeps the name the
title replaced. Any other observed name retires the record: equal text is not edit provenance, so
a moderator who later restores Hermes's title sees it as itself. Records live in memory; after a
restart each renamed thread re-renders once.
)Úannotations)ÚCallableÚIterator)Úcontextmanager)Ú	dataclass)ÚAnyNiÐ  c                  óD   € ] tR t^t$ R]R&   R]R&   R]R&   RtR]R&   RtR	# )
Ú_TitleRenameÚstrÚreplacedÚtitleÚlast_event_nameFÚboolÚ
title_seen© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__annotations__r   Ú__static_attributes__r   ó    Ú>/opt/hermes/plugins/platforms/discord/adapter_thread_titles.pyr	   r	      s   ‡ àƒMØƒJØÓØ€J�×r   r	   c                  óT   € ] tR t^ tRtR R lt]R R l4       tR R ltR R	 lt	R
t
R# )ÚSemanticThreadRenamesz3Hermes's latest guarded title rename per thread id.c               ó   € V ^8„  d   QhRR/# )é   ÚreturnÚNoner   )Úformats   "r   Ú__annotate__Ú"SemanticThreadRenames.__annotate__#   s   € ÷ 4ñ 4˜$ñ 4r   c                	ó   € / V n         R # )N©Ú_records)Úselfs   &r   Ú__init__ÚSemanticThreadRenames.__init__#   s	   € Ø13ˆŽr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Ú	thread_idr
   r   r   r   zIterator[None]r   )r   s   "r   r    r!   '   s(   € ÷ ñ  ð °ð ¸Cð ÀNñ r   c              #  ó�  "  € \        W#VR7      pV P                  P                  VR4       W@P                  V&   \        V P                  4      \        8”  d,   V P                  \        \        V P                  4      4       KI   Rx € R#   \         d/    T P                  P                  T4      TJ d   T P                  T h i ; i5i)zcRecord a rename before its REST edit, which gateway events can overtake; drop it if the edit fails.)r   N)	r	   r$   ÚpopÚlenÚ_MAX_RECORDSÚnextÚiterÚBaseExceptionÚget)r%   r)   r   r   Úrecords   &&&& r   ÚattemptÚSemanticThreadRenames.attempt&   sš   é € ô ˜h¸xÔHˆØ�‰×Ñ˜) TÔ*Ø#)�‰�iÑ Ü�$—-‘-Ó ¤<Ô/Ø—‘œd¤4¨¯©Ó#6Ó7Ò8ð	ÝøÜô 	à�}‰}× Ñ  Ó+¨vÓ5Ø—M‘M )Ð,Øð		üs   ‚BCÂB
 ÂCÂ
9CÃCc               ó$   € V ^8„  d   QhRRRRRR/# )r   r)   r
   Únamer   r   r   )r   s   "r   r    r!   6   s!   € ÷ )ñ ) sð )°#ð )¸$ñ )r   c                óä   € V P                   P                  V4      pVe   W#P                  8X  d   R# VP                  V3VP                  VP                  38X  d	   W#n        R# V P                   V R# )zZApply one gateway rename event; only Hermes's own replaced -> title step keeps the record.N)r$   r1   r   r   r   ©r%   r)   r6   r2   s   &&& r   Úobserve_eventÚ#SemanticThreadRenames.observe_event6   s[   € à—‘×"Ñ" 9Ó-ˆØŠ>˜T×%;Ñ%;Ô;ÙØ×"Ñ" DÐ)¨f¯o©o¸v¿|¹|Ð-LÔLØ%)Ö"à—‘˜iÒ(r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r)   r
   r6   r   r   )r   s   "r   r    r!   @   s!   € ÷ ñ  cð °ð ¸ñ r   c                óì   € V P                   P                  V4      pVf   V# W#P                  8X  d   RVn        VP                  # VP                  '       g   W#P                  8w  d   V P                   V V# )z8The name to render for a thread currently called *name*.T)r$   r1   r   r   r   r8   s   &&& r   Údisplay_nameÚ"SemanticThreadRenames.display_name@   sb   € à—‘×"Ñ" 9Ó-ˆØŠ>ØˆKØ—<‘<ÔØ $ˆFÔØ—?‘?Ð"à××Ð ¯©Ô 7Ø—‘˜iÐ(Øˆr   r#   N)r   r   r   r   Ú__doc__r&   r   r3   r9   r=   r   r   r   r   r   r       s-   † Ù=õ4ð ôó ðõ)÷ñ r   r   c                  óZ   € ] tR t^Nt$ R]R&   R]R&   R]R&   R R ltR	 R
 ltR R ltRtR# )ÚDiscordThreadTitlesMixinr   Ú_semantic_thread_renameszCallable[[Any], bool]Ú_is_forum_parentzCallable[..., str | None]Ú_get_effective_topicc               ó    € V ^8„  d   QhRRRR/# )r   Úpayloadr   r   r   r   )r   s   "r   r    Ú%DiscordThreadTitlesMixin.__annotate__S   s   € ÷ Vñ V¸Cð VÀDñ Vr   c              ƒ  	óÒ   "  € VP                   P                  R 4      p\        V\        4      '       d2   V P                  P                  \        VP                  4      V4       R# R# 5i)r6   N)Údatar1   Ú
isinstancer
   rB   r9   r)   )r%   rF   r6   s   && r   Ú_on_platform_raw_thread_updateÚ7DiscordThreadTitlesMixin._on_platform_raw_thread_updateS   sO   é € ð �|‰|×Ñ Ó'ˆÜ�dœC× Ò Ø×)Ñ)×7Ñ7¼¸G×<MÑ<MÓ8NÐPTÖUñ !ùs   ‚A%A'c               ó    € V ^8„  d   QhRRRR/# )r   Úthreadr   r   r
   r   )r   s   "r   r    rG   Z   s   € ÷ ñ ¨sð °sñ r   c           	     ó  € \        VRR4      ;'       g    \        \        VRR4      4      pV P                  P                  \        \        VRR4      4      V4      p\        VRR4      p\        VRR4      ;'       g    \        VRR4      p\        VRR4      p\        VRR4      pV P	                  V4      '       d   V'       d   V'       d   V RV RV 2# V'       d   V'       d   V R	V RV 2# V'       d   V RV 2# V# )
zdBuild a readable chat name for thread-like Discord channels, including forum context when available.r6   NÚidrN   Ú ÚparentÚguildz / ú / #)Úgetattrr
   rB   r=   rC   )r%   rN   Úthread_namerR   rS   Ú
guild_nameÚparent_names   &&     r   Ú_format_thread_chat_nameÚ1DiscordThreadTitlesMixin._format_thread_chat_nameZ   sû   € ä˜f f¨dÓ3×[Ð[´s¼7À6È4ÐQYÓ;ZÓ7[ˆØ×3Ñ3×@Ñ@ÄÄWÈVÐUYÐ[]ÓE^ÓA_ÐalÓmˆÜ˜ ¨4Ó0ˆÜ˜ ¨Ó.×PÐP´'¸&À'È4Ó2PˆÜ˜U F¨DÓ1ˆ
Ü˜f f¨dÓ3ˆØ× Ñ  ×(Ò(¯Z¿KØ �\  [ M°°[°MÐBÐBßŸ:Ø �\  k ]°#°k°]ÐCÐCßØ!�] # k ]Ð3Ð3ØÐr   c               ó    € V ^8„  d   QhRRRR/# )r   Úchannelr   r   ztuple[str, str | None]r   )r   s   "r   r    rG   j   s   € ÷ bñ b¨Sð bÐ5Kñ br   c                ó:  € \        V\        P                  4      '       d%   V P                  V4      V P	                  VRR7      3# \        VR\        VP                  4      4      \        VRR4      r2V'       d   VP                   RV 2MTV P	                  V4      3# )z_``(chat_name, chat_topic)`` for a guild channel or thread, as a message posted there gets them.T)Ú	is_threadr6   rS   NrT   )	rJ   ÚdiscordÚThreadrY   rD   rU   r
   rP   r6   )r%   r\   r6   rS   s   &&  r   Ú_guild_channel_labelsÚ.DiscordThreadTitlesMixin._guild_channel_labelsj   sˆ   € ä�gœwŸ~™~×.Ò.Ø×0Ñ0°Ó9¸4×;TÑ;TÐU\ÐhlÐ;TÓ;mÐmÐmÜ˜g v¬s°7·:±:«Ó?ÄÈÐRYÐ[_ÓA`ˆeß-2�5—:‘:�,˜d 4 &Ñ)¸¸t×?XÑ?XÐY`Ó?aÐaÐar   r   N)	r   r   r   r   r   rK   rY   ra   r   r   r   r   rA   rA   N   s+   ‡ Ø3Ó3Ø+Ó+Ø3Ó3õVõ÷ bñ br   rA   )r?   Ú
__future__r   Úcollections.abcr   r   Ú
contextlibr   Údataclassesr   Útypingr   r_   ÚImportErrorr-   r	   r   rA   r   r   r   Ú<module>ri      sq   ðñõ #ç .Ý %Ý !Ý ðÛð €ð ÷ð ó ð÷+ñ +÷\!bó !bøðy ô Ø‚Gðús   ¤A Á	AÁA