Ë
    §‘ˆjg  ã                   óº   — d Z ddlZddlZ ej                  e«      Z ej                  d«      Z ej                  d«      Z G d„ de	«      Z
defd„Zded	ed
efd„Zy)zÓExecutes a declarative field map against a source record.

The syntax is deliberately tiny: $.a.b and $.a[0]. Anything richer would make
the maps harder for a human to review, and C's LLM authors these configs.
é    Nz*\A([A-Za-z_][A-Za-z0-9_]*)((?:\[\d+\])*)\Zz	\[(\d+)\]c                   ó   — e Zd ZdZy)ÚFieldMapErrorzGThe field map itself is malformed, as opposed to the data being sparse.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    ú</var/www/html/strategist-ai/app/services/catalog/fieldmap.pyr   r      s   „ ÚQr
   r   Úrecordc                 ó  — t        |t        «      r|j                  d«      r|dk(  rt        d|›�«      ‚| }|dd  j	                  d«      D ]¼  }t
        j                  |«      }|st        d|›d|›�«      ‚|j                  d«      t        j                  |j                  d«      «      }}t        |t        «      s y |j                  |«      }|D ]5  }t        |t        «      s  y t        |«      }|t        |«      k  r||   nd }Œ7 Œ¾ |S )Nz$.zmalformed path: é   ú.zmalformed path segment z in é   )Ú
isinstanceÚstrÚ
startswithr   ÚsplitÚ_SEGMENTÚmatchÚgroupÚ_INDEXÚfindallÚdictÚgetÚlistÚintÚlen)	r   ÚpathÚcurrentÚrawÚmÚkeyÚindexesÚiÚidxs	            r   Úresolve_pathr'      s   € Ü�dœCÔ ¨¯©¸Ô(=ÀÈÂÜÐ.¨t¨hÐ7Ó8Ð8à€GØ�A�Bˆx�~‰~˜cÓ"ò CˆÜ�N‰N˜3ÓˆÙÜÐ"9¸#¸ÀÀTÀHÐ MÓNÐNà—w‘w˜q“z¤6§>¡>°!·'±'¸!³*Ó#=ˆWˆÜ˜'¤4Ô(ÙØ—+‘+˜cÓ"ˆàò 	CˆAÜ˜g¤tÔ,ÚÜ�a“&ˆCØ&)¬C°«LÒ&8�g˜c’l¸d‰Gñ		CðCð  €Nr
   ÚfieldsÚreturnc           	      ój   — |j                  «       D ��ci c]  \  }}|t        | |«      “Œ c}}S c c}}w )N)Úitemsr'   )r   r(   Útargetr   s       r   Úapply_field_mapr-   +   s,   € ØCIÇ<Á<Ã>×R±<°6¸4ˆF”L ¨Ó.Ñ.ÓRÐRùÓRs   ”/)r   ÚloggingÚreÚ	getLoggerr   ÚloggerÚcompiler   r   Ú	Exceptionr   r   r'   r-   r	   r
   r   ú<module>r4      s}   ðñó
 Û 	à	ˆ×	Ñ	˜8Ó	$€àˆ2�:‰:ÐCÓD€Ø	ˆ�‰�LÓ	!€ôR�Iô Rð˜ó ð0S˜Dð S¨$ð S°4ô Sr
   