Ë
    ¼vëjé  ã                  ór   — d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	 ddl
mZ ddlmZ d	Zdd
„Zdd„Zddd„Zy)a"  Templates from files. A file is the Template model as JSON, with blocks written as {"type": ..., "optional":
[...], "required": [...], ...options}; the block's contract fills in the values. A file that does not validate is
refused with the reason, which is what an owner's upload will hear.é    )ÚannotationsN)ÚPath)ÚDictÚListÚUnioné   )Úblock)ÚTemplate)ÚsecondÚthirdÚfourthÚfifthÚsixthc                ó�  — g }i }| j                  d«      xs g D ]š  }t        |t        «      rd|in
t        |«      }|j	                  d«      }d|vrI|dvrE|j                  |d«      }|r)t
        t        |dz
  t        t
        «      dz
  «         |d<   |dz   ||<   |j                  t        |fi |¤Ž«       Œœ t        di i | ¥d|i¥¤ŽS )zÐA repeated block the design did not name is named here (second, third ...), so two text sections or two
    products are two sets of values instead of a refusal: the model asked for two sections and meant it.ÚblocksÚtypeÚname)ÚdividerÚheaderÚfooterr   r   © )ÚgetÚ
isinstanceÚstrÚdictÚpopÚORDINALSÚminÚlenÚappendr	   r
   )Údatar   ÚseenÚbÚspecÚtype_Úns          ú]/var/www/html/strategist-ai/venv/lib/python3.12/site-packages/galaxiq_utils/templates/load.pyÚtemplate_from_dictr(      sÖ   € ð €FØ€DØ�X‰X�hÓÒ% 2ò ,ˆÜ(¨¬CÔ0�˜‰{´d¸1³gˆØ—‘˜Ó ˆØ˜Ñ %Ð/NÑ"NØ—‘˜ Ó"ˆAÙÜ'¬¨A°©E´3´x³=À1Ñ3DÓ(EÑF��V‘Ø˜a™%ˆD�‰KØ�‰”e˜EÑ* TÑ*Õ+ð,ô Ñ1Ð0˜Ð0˜x¨Ñ0Ñ1Ð1ó    c                óÎ   — t        | «      } 	 t        t        j                  | j	                  d¬«      «      «      S # t
        $ r }t        | j                  › d|› �«      |‚d }~ww xY w)Nzutf-8)Úencodingz: )r   r(   ÚjsonÚloadsÚ	read_textÚ	ExceptionÚ
ValueErrorr   )ÚpathÚexcs     r'   Útemplate_from_filer3   "   s[   € Ü�‹:€Dð9Ü!¤$§*¡*¨T¯^©^ÀW¨^Ó-MÓ"NÓOÐOøÜò 9Ü˜DŸI™I˜; b¨¨Ð.Ó/°SÐ8ûð9ús   �-; »	A$ÁAÁA$c                ó²   — i }t        t        | «      j                  d«      «      D ].  }t        |«      }|r|j                  |k7  rŒ |||j
                  <   Œ0 |S )zGEvery *.template.json in a folder, by name, for one channel when given.z*.template.json)Úsortedr   Úglobr3   Úchannelr   )Úfolderr7   Úoutr1   Úts        r'   Úload_templatesr;   *   sZ   € à!€CÜ”t˜F“|×(Ñ(Ð):Ó;Ó<ò ˆÜ˜tÓ$ˆÙ�q—y‘y GÒ+ØØˆˆA�F‰FŠð	ð
 €Jr)   )r!   r   Úreturnr
   )r1   úUnion[str, Path]r<   r
   )Ú )r8   r=   r7   r   r<   zDict[str, Template])Ú__doc__Ú
__future__r   r,   Úpathlibr   Útypingr   r   r   r   r	   r$   r
   r   r(   r3   r;   r   r)   r'   ú<module>rC      s8   ðñGõ #ã Ý ß $Ñ $å Ý ð ;€ó2ó"9õr)   