§
    ®	Êj‰  ã                  óz   — d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	 ddl
mZ ddlmZmZmZ dd„Zdd„Zdd„ZdS )aa  Every route from a chosen path to a spawned Firefox goes through here.

``binary_path=`` (and ``INVPW_BINARY_PATH``, which the test suite and the e2e
scripts turn into ``binary_path=``) never reaches ``ensure_binary()``, so none
of the download-side checks run on that route. The guard therefore sits on the
resolved executable, not inside the fetcher.
é    )ÚannotationsN)ÚPath)ÚOptionalÚUnion)Úensure_binary)ÚEngineMismatchÚactive_sealÚverify_engineÚbinary_pathúOptional[Union[str, Path]]Úreturnr   c                ó†   — t          ¦   «         }| r"t          t          | ¦  «        |d| › �¬¦  «        S t          |¬¦  «        S )us  ``binary_path=`` skips the download path entirely, so the guard sits on the
    resolved executable rather than inside the fetcher.

    â›” This used to say "binary_path= and INVPW_BINARY_PATH", and the second half
    was false: nothing here reads that variable. It is translated into
    ``binary_path=`` by the test scripts and by ``run_e2e.py``, so it is a
    convention of this repo's harness and not a feature of the library. Corrected
    2026-08-14 - a docstring that promises an env var the code never reads sends
    the reader looking for a bug in the wrong function.

    Driving an engine the packaged seal does not describe is done with
    ``binary_path=`` plus ``INVISIBLE_SEAL_FILE`` pointing at a seal generated for
    it; without that, ``verify_engine`` refuses, and refusing is correct - the
    prefs and the spoofed User-Agent describe the sealed build.
    zbinary_path=)Úsource)Úseal)r	   r
   r   r   )r   r   s     úLC:\Projects\Muse2API\.venv\Lib\site-packages\invisible_playwright/_engine.pyÚresolve_executabler      sM   € õ  ‰=Œ=€DØð [Ý�T +Ñ.Ô.°Ð=YÈKÐ=YÐ=YÐZÑZÔZÐZÝ˜dÐ#Ñ#Ô#Ð#ó    ÚNonec                óH  — | €dS t          ¦   «         }t          | dd¦  «        }t          |t          ¦  «        sdS |                     d¦  «        d                              ¦   «         }|r6||j        k    r-t          d|› d|j        › d|j        › d	|j	        › d
�	¦  «        ‚dS dS )a§  Compare what the engine reports over the protocol with the seal.

    browser.version is a cached property from the connection initializer
    (Juggler Browser.getInfo -> MOZ_APP_VERSION_DISPLAY), so this costs zero
    round trips and no pref can spoof it. It is the only check that also
    catches a hand-edited application.ini. Not available on the persistent
    context path, where Playwright exposes no Browser.
    NÚversionÚ ú/éÿÿÿÿziengine/seal mismatch after launch - the running browser is not the sealed build
  protocol says: Firefox z
  seal says    : Firefox z (tag z, build z˜)
  why          : application.ini can be edited; this value comes from the running engine itself.
  fix          : python -m invisible_playwright fetch)
r	   ÚgetattrÚ
isinstanceÚstrÚsplitÚstripÚupstream_versionr   ÚtagÚbuild_id)Úbrowserr   ÚrawÚreporteds       r   Úassert_wire_versionr%   )   sï   € ð €ØˆÝ‰=Œ=€DÝ
�'˜9 bÑ
)Ô
)€Cõ �c�3ÑÔð ØˆØ�yŠy˜‰~Œ~˜bÔ!×'Ò'Ñ)Ô)€HØð E�H Ô 5Ò5Ð5ÝðDØ(0ðDð Dà(,Ô(=ðDð DàEIÄXðDð Dð ”]ðDð Dð DñEô Eð 	EðEð EÐ5Ð5r   c                 ó¬  — t          ¦   «         } | j        r| j        sdS ddlm} dd„} || j        ¦  «         ||¦  «        cxk    r || j        ¦  «        k    rn ndS d|› d| j        › d	| j        › d
| j        › d| j        › d�}t          j                             d¦  «        dk    rt          j
        |t          d¬¦  «         dS t          |¦  «        ‚)zôThe Juggler protocol schema is closed-world: a client outside the range
    the binary was tested with dies at context creation, or silently loses a
    feature. The range travels in the seal, so widening it does not need a
    wrapper release.Nr   )r   Úvr   c                ó  — g }|                       d¦  «        d d…         D ]E}d                     d„ |D ¦   «         ¦  «        }|                     t          |pd¦  «        ¦  «         ŒFt	          |dgdt          |¦  «        z
  z  z   ¦  «        S )Nú.é   r   c              3  óB   K  — | ]}|                      ¦   «         ¯|V — Œd S )N)Úisdigit)Ú.0Úcs     r   ú	<genexpr>z5assert_playwright_range.<locals>.t.<locals>.<genexpr>_   s/   è è € Ð<Ð< 1°·	²	±´Ð<˜QÐ<Ð<Ð<Ð<Ð<Ð<r   r   )r   ÚjoinÚappendÚintÚtupleÚlen)r'   ÚoutÚpartÚdigitss       r   Útz"assert_playwright_range.<locals>.t\   sŽ   € ØˆØ—G’G˜C‘L”L  ! Ô$ð 	)ð 	)ˆDØ—W’WÐ<Ð<¨Ð<Ñ<Ô<Ñ<Ô<ˆFØ�JŠJ•s˜6˜; QÑ'Ô'Ñ(Ô(Ð(Ð(Ý�S˜A˜3 !¥c¨#¡h¤h¡,Ñ/Ñ/Ñ0Ô0Ð0r   zplaywright z3 is outside the range this engine was tested with (z .. z, from the seal for z�).
The Juggler protocol schema is closed-world: an untested client can kill every session at context creation.
Run: pip install "playwright==z>"   (or set INVISIBLE_PLAYWRIGHT_SKEW=allow to proceed anyway)ÚINVISIBLE_PLAYWRIGHT_SKEWÚallowé   )Ú
stacklevel)r'   r   )r	   Úplaywright_minÚplaywright_maxÚ&invisible_playwright._pw._repo_versionr   r    ÚosÚenvironÚgetÚwarningsÚwarnÚRuntimeWarningÚRuntimeError)r   Úhaver8   Úmsgs       r   Úassert_playwright_rangerI   G   sH  € õ
 ‰=Œ=€DØÔð  dÔ&9ð Øˆð GÐFÐFÐFÐFÐFð1ð 1ð 1ð 1ð 	€qˆÔ	ÑÔ   4¡¤ÐBÐBÒBÐB¨A¨A¨dÔ.AÑ,BÔ,BÒBÐBÐBÐBÐBØˆðI˜ð Ið IØÔ"ðIð IØ(,Ô(;ðIð IØQUÔQYðIð Ið -1Ô,?ð	Ið Ið I€Cõ 
„z‡~‚~Ð1Ñ2Ô2°gÒ=Ð=ÝŒ�c�>°aÐ8Ñ8Ô8Ð8Ð8Ð8å˜3ÑÔÐr   )r   r   r   r   )r   r   )Ú__doc__Ú
__future__r   r@   rC   Úpathlibr   Útypingr   r   Úinvisible_corer   Úinvisible_core.sealr   r	   r
   r   r%   rI   © r   r   ú<module>rQ      sÙ   ððð ð #Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø €€€Ø Ð Ð Ð Ð Ð Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "à (Ð (Ð (Ð (Ð (Ð (Ø JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ Jð$ð $ð $ð $ð,Eð Eð Eð Eð<' ð ' ð ' ð ' ð ' ð ' r   