§
    §MºfÄ-  ã                   ó(  — d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlZddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ  e¦   «         Z e j        ¦   «         Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d„ Z!d„ Z"d„ Z#	 	 	 	 	 	 	 	 	 	 dd„Z$dS )é    N)Úfnmatch)ÚPath©ÚisfileÚjoin)Úparse_qsé   )Ú	_validate)ÚAttributeDict)Úget_relative_path)Úcontext_value)Úget_appc                 óÀ  ‡
— t           j        Š
g d¢}|                      d¦  «        d         }g }t          j                             ‰
¦  «        r ˆ
fd„t          j        ‰
¦  «        D ¦   «         }d}d}|D ]e}|                     d¦  «        \  }}}	|	                     ¦   «         |v r4||k    s|| 	                    dd¦  «        k    r|c S |dk    r|}|d	k    r|}Œf|r|S |S )
zØ
    Return:
    - A page specific image: `assets/<module>.<extension>` is used, e.g. `assets/weekly_analytics.png`
    - A generic app image at `assets/app.<extension>`
    - A logo at `assets/logo.<extension>`
    )ÚapngÚavifÚgifÚjpegÚjpgÚpngÚsvgÚwebpú.éÿÿÿÿc                 óN   •— g | ]!}t          t          ‰|¦  «        ¦  «        ¯|‘Œ"S © r   )Ú.0ÚfÚassets_folders     €úJ/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/dash/_pages.pyú
<listcomp>z _infer_image.<locals>.<listcomp>$   s@   ø€ ð 
ð 
ð 
ØµF½4ÀÈqÑ;QÔ;QÑ4RÔ4Rð
Øð
ð 
ð 
ó    NÚ_ú-ÚappÚlogo)
ÚCONFIGr   ÚsplitÚosÚpathÚexistsÚlistdirÚ	partitionÚlowerÚreplace)ÚmoduleÚvalid_extensionsÚpage_idÚfiles_in_assetsÚapp_fileÚ	logo_fileÚfnÚfn_without_extensionr"   Ú	extensionr   s             @r   Ú_infer_imager8      s'  ø€ õ Ô(€MØSÐSÐSÐØ�lŠl˜3ÑÔ Ô#€GØ€Oå	„w‡~‚~�mÑ$Ô$ð 
ð
ð 
ð 
ð 
Ý”z -Ñ0Ô0ð
ñ 
ô 
ˆð €HØ€IØð ð ˆØ-/¯\ª\¸#Ñ->Ô->Ñ*Ð˜a Ø�?Š?ÑÔÐ 0Ð0Ð0à$¨Ò/Ð/Ø'¨7¯?ª?¸3ÀÑ+DÔ+DÒDÐDà�	�	�	à# uÒ,Ð,Ø�à# vÒ-Ð-Ø�	øàð ØˆàÐr!   c                 ó„   — |                       d¦  «        d                              dd¦  «                             ¦   «         S )Nr   r   r"   ú )r'   r.   Ú
capitalize©Úmodule_names    r   Ú_module_name_to_page_namer>   >   s7   € Ø×Ò˜SÑ!Ô! "Ô%×-Ò-¨c°3Ñ7Ô7×BÒBÑDÔDÐDr!   c                 ó  — |€Êt           j        r�t          t          t           j        ¦  «        j        ¦  «        }|                      |¦  «        d                              dd¦  «                             dd¦  «                             ¦   «         }nS|                      dd¦  «                             dd¦  «                             ¦   «         }nt          j	        dd|¦  «        }| 
                    d¦  «        sd|z   n|}|S )Nr   r"   r#   r   ú/ú<.*?>Únone)r&   Úpages_folderÚstrr   Únamer'   r.   r-   ÚreÚsubÚ
startswith)r=   ÚtemplateÚpages_moduler)   s       r   Ú_infer_pathrK   B   sà   € ØÐÝÔð 		KÝ�t¥FÔ$7Ñ8Ô8Ô=Ñ>Ô>ˆLà×!Ò! ,Ñ/Ô/°Ô3ß’˜˜cÑ"Ô"ß’˜˜cÑ"Ô"ß’‘”ð	 ˆDð ×&Ò& s¨CÑ0Ô0×8Ò8¸¸cÑBÔB×HÒHÑJÔJˆDˆDõ Œv�g˜v xÑ0Ô0ˆØ!Ÿ_š_¨SÑ1Ô1Ð;ˆ3�‰:ˆ:°t€DØ€Kr!   c                 óx   — | t           j        v o,t          t           j        |          j        ¦  «        j        dk    S )Nz__init__.py)ÚsysÚmodulesr   Ú__file__rE   r<   s    r   Ú_module_name_is_packagerP   V   s4   € à•s”{Ð"ð 	JÝ•”˜[Ô)Ô2Ñ3Ô3Ô8¸MÒIðr!   c                 ó¾   — t          | ¦  «                             dd¦  «                             t          j        ¦  «                             t          j        d¦  «        S )Nz.pyÚ r   )rD   r.   Ústripr(   Úsep)r)   s    r   Ú_path_to_module_namerU   ]   s@   € Ýˆt‰9Œ9×Ò˜U BÑ'Ô'×-Ò-­b¬fÑ5Ô5×=Ò=½b¼fÀcÑJÔJÐJr!   c                 óÚ  — |                       t          j        ¦  «        d         }t          |¦  «        }t          j                             t          j        ¦  «        }t          j                             |¦  «        r"t          j        t          |¦  «        d …         }nt          j        }t          |¦  «        }|› d|› �}t          t          j        ¦  «        rt          j        › d|› �}|S )Nr   r   )r'   r&   rC   rU   ÚflaskÚhelpersÚget_root_pathrE   rH   ÚlenrP   )Ú	page_pathÚrelative_pathr/   Ú	proj_rootÚparent_pathÚparent_moduler=   s          r   Ú_infer_module_namer`   a   sÈ   € Ø—O’O¥FÔ$7Ñ8Ô8¸Ô<€MÝ! -Ñ0Ô0€FÝ”×+Ò+­F¬KÑ8Ô8€IÝÔ×%Ò% iÑ0Ô0ð *ÝÔ)­#¨i©.¬.Ð*:Ð*:Ô;ˆˆåÔ)ˆÝ(¨Ñ5Ô5€Mà"Ð-Ð- VÐ-Ð-€KÝ�vœ{Ñ+Ô+ð 5åœÐ4Ð4 {Ð4Ð4ˆØÐr!   c                 óø   — | r*t          | ¦  «        dk    r| d         dk    r| dd …         } ni S i }t          | ¦  «                             ¦   «         D ]'\  }}t          |¦  «        dk    r|d         n|}|||<   Œ(|S )Nr   ú?r	   )rZ   r   Úitems)ÚsearchÚ	parsed_qsÚkÚvs       r   Ú_parse_query_stringrh   r   s’   € Øð •#�f‘+”+ ’/�/ f¨Q¤i°3Ò&6Ð&6Ø˜˜˜”ˆˆàˆ	à€IÝ˜6Ñ"Ô"×(Ò(Ñ*Ô*ð ð ‰ˆˆAÝ˜‘F”F˜a’K�KˆAˆaŒDˆD QˆØˆ	�!‰ˆØÐr!   c                 óV  — t          j        dd|¦  «        }t          j        dd|¦  «        }t          | |¦  «        sdS t          j        d|¦  «        }t          j        || ¦  «        }t	          |d         t
          ¦  «        r|d         n|}t          t          ||¦  «        ¦  «        S )zÔ
    creates the dict of path variables passed to the layout
    e.g. path_template= "/asset/<asset_id>"
         if pathname provided by the browser is "/assets/a100"
         returns **{"asset_id": "a100"}
    rA   Ú*z(.*)Nz<(.*?)>r   )rF   rG   r   ÚfindallÚ
isinstanceÚtupleÚdictÚzip)ÚpathnameÚpath_templateÚwildcard_patternÚvar_patternÚ	var_namesÚ	variabless         r   Ú_parse_path_variablesrv      s£   € õ ”v˜g s¨MÑ:Ô:ÐÝ”&˜ &¨-Ñ8Ô8€Kõ �8Ð-Ñ.Ô.ð Øˆtõ ”
˜9 mÑ4Ô4€Iõ ”
˜;¨Ñ1Ô1€IÝ *¨9°Q¬<½Ñ ?Ô ?ÐN�	˜!”�ÀY€Iå•�I˜yÑ)Ô)Ñ*Ô*Ð*r!   c                 ó   ‡ — ˆ fd„}|S )Nc                  ó0   •— t          j        ‰ d¬¦  «        S )Ni-  )Úcode)rW   Úredirect)Úredirect_tos   €r   rz   z+_create_redirect_function.<locals>.redirect›   s   ø€ ÝŒ~˜k°Ð4Ñ4Ô4Ð4r!   r   )r{   rz   s   ` r   Ú_create_redirect_functionr|   š   s#   ø€ ð5ð 5ð 5ð 5ð 5ð €Or!   c           
      óø   — t          ¦   «         }| ret          | ¦  «        rX| D ]W}|                     |¦  «        }|j                             ||t          |                     |¦  «        ¦  «        ¦  «         ŒTd S d S d S )N)r   rZ   r   ÚserverÚadd_url_ruler|   )Úredirect_fromr)   r$   rz   Úfullnames        r   Ú_set_redirectr‚   ¡   s    € Ý
‰)Œ)€CØð �˜]Ñ+Ô+ð Ø%ð 	ð 	ˆHØ×,Ò,¨XÑ6Ô6ˆHØŒJ×#Ò#ØØÝ)¨#×*?Ò*?ÀÑ*EÔ*EÑFÔFñô ð ð ðð ð ð ð	ð 	r!   c           
      óB  — t          j        ¦   «                              d¦  «        rdS t          j        t          ¦  «         t          t          j        | ¦  «        |||�|nt          | |¦  «        ||�|nt          | ¦  «        ¬¦  «        }| 	                    ||�|n|d         ¬¦  «          |j	        d|r|nd|||
dœ|¤Ž | 	                    ||�|nt          | ¦  «        |¬¦  «         | 	                    t          |	|d	         ¦  «        ¬
¦  «         |t          | <   |d         rt          j        |d         ¦  «         |
�|
t          |          d<   t          d„ t                               ¦   «         D ¦   «         ¦  «        }t                               ¦   «         D ]5}|d	         dk    r|sdn|d         |d<   t!          |d	         ¦  «        |d<   Œ6t#          t                               ¦   «         d„ ¬¦  «        D ]"}t                               |d         ¦  «         Œ#dS )aÍ  
    Assigns the variables to `dash.page_registry` as an `OrderedDict`
    (ordered by `order`).

    `dash.page_registry` is used by `pages_plugin` to set up the layouts as
    a multi-page Dash app. This includes the URL routing callbacks
    (using `dcc.Location`) and the HTML templates to include title,
    meta description, and the meta description image.

    `dash.page_registry` can also be used by Dash developers to create the
    page navigation links or by template authors.

    - `module`:
       The module path where this page's `layout` is defined. Often `__name__`.

    - `path`:
       URL Path, e.g. `/` or `/home-page`.
       If not supplied, will be inferred from the `path_template` or `module`,
       e.g. based on path_template: `/asset/<asset_id` to `/asset/none`
       e.g. based on module: `pages.weekly_analytics` to `/weekly-analytics`

    - `relative_path`:
        The path with `requests_pathname_prefix` prefixed before it.
        Use this path when specifying local URL paths that will work
        in environments regardless of what `requests_pathname_prefix` is.
        In some deployment environments, like Dash Enterprise,
        `requests_pathname_prefix` is set to the application name,
        e.g. `my-dash-app`.
        When working locally, `requests_pathname_prefix` might be unset and
        so a relative URL like `/page-2` can just be `/page-2`.
        However, when the app is deployed to a URL like `/my-dash-app`, then
        `relative_path` will be `/my-dash-app/page-2`.

    - `path_template`:
       Add variables to a URL by marking sections with <variable_name>. The layout function
       then receives the <variable_name> as a keyword argument.
       e.g. path_template= "/asset/<asset_id>"
            then if pathname in browser is "/assets/a100" then layout will receive **{"asset_id":"a100"}

    - `name`:
       The name of the link.
       If not supplied, will be inferred from `module`,
       e.g. `pages.weekly_analytics` to `Weekly analytics`

    - `order`:
       The order of the pages in `page_registry`.
       If not supplied, then the filename is used and the page with path `/` has
       order `0`

    - `title`:
       (string or function) The name of the page <title>. That is, what appears in the browser title.
       If not supplied, will use the supplied `name` or will be inferred by module,
       e.g. `pages.weekly_analytics` to `Weekly analytics`

    - `description`:
       (string or function) The <meta type="description"></meta>.
       If not supplied, then nothing is supplied.

    - `image`:
       The meta description image used by social media platforms.
       If not supplied, then it looks for the following images in `assets/`:
        - A page specific image: `assets/<module>.<extension>` is used, e.g. `assets/weekly_analytics.png`
        - A generic app image at `assets/app.<extension>`
        - A logo at `assets/logo.<extension>`
        When inferring the image file, it will look for the following extensions:
        APNG, AVIF, GIF, JPEG, JPG, PNG, SVG, WebP.

    -  `image_url`:
       Overrides the image property and sets the `<image>` meta tag to the provided image URL.

    - `redirect_from`:
       A list of paths that should redirect to this page.
       For example: `redirect_from=['/v2', '/v3']`

    - `layout`:
       The layout function or component for this page.
       If not supplied, then looks for `layout` from within the supplied `module`.

    - `**kwargs`:
       Arbitrary keyword arguments that can be stored

    ***

    `page_registry` stores the original property that was passed in under
    `supplied_<property>` and the coerced property under `<property>`.
    For example, if this was called:
    ```
    register_page(
        'pages.historical_outlook',
        name='Our historical view',
        custom_key='custom value'
    )
    ```
    Then this will appear in `page_registry`:
    ```
    OrderedDict([
        (
            'pages.historical_outlook',
            dict(
                module='pages.historical_outlook',

                supplied_path=None,
                path='/historical-outlook',

                supplied_name='Our historical view',
                name='Our historical view',

                supplied_title=None,
                title='Our historical view'

                supplied_layout=None,
                layout=<function pages.historical_outlook.layout>,

                custom_key='custom value'
            )
        ),
    ])
    ```
    Úignore_register_pageN)r/   Úsupplied_pathrq   r)   Úsupplied_namerE   rE   )Úsupplied_titleÚtitlerR   )ÚdescriptionÚorderÚsupplied_orderÚsupplied_layout)Úsupplied_imageÚimageÚ	image_urlr)   )r€   rq   Úlayoutc              3   ó*   K  — | ]}|d          duV — ŒdS )r‹   Nr   )r   Úps     r   ú	<genexpr>z register_page.<locals>.<genexpr>[  s>   è è € ð ð Ø,-ˆÐ
Ô 4Ð'ðð ð ð ð ð r!   r@   r   r‹   rŠ   r\   c                 ód   — t          |                      d| d         ¦  «        ¦  «        | d         fS )NrŠ   r/   )rD   Úget)Úis    r   ú<lambda>zregister_page.<locals>.<lambda>h  s)   € •s˜1Ÿ5š5 ¨!¨H¬+Ñ6Ô6Ñ7Ô7¸¸8¼ÐE€ r!   )Úkeyr/   r   )r   r•   r
   Úvalidate_use_pagesr&   rn   Úvalidate_module_namerK   r>   Úupdater8   r‚   ÚPAGE_REGISTRYÚvalidate_templateÚanyÚvaluesr   ÚsortedÚmove_to_end)r/   r)   rq   rE   rŠ   rˆ   r‰   rŽ   r�   r€   r�   ÚkwargsÚpageÚorder_suppliedr’   s                  r   Úregister_pager¥   ­   s•  € õJ ÔÑÔ×ÒÐ5Ñ6Ô6ð ØˆåÔ ¥Ñ(Ô(Ð(åÝÔ-¨fÑ5Ô5ØØ#ØÐ%ˆTˆT­;°v¸}Ñ+MÔ+MØØÐ%ˆTˆTÕ+DÀVÑ+LÔ+Lðñ ô €Dð 	‡K‚KØØÐ)ˆuˆu¨t°F¬|ð ñ ô ð ð €D„Kð Ø#.Ð6�K�K°BØØØð	ð ð
 ðð ð ð 	‡K‚KØØÐ)ˆuˆu­|¸FÑ/CÔ/CØð ñ ô ð ð
 	‡K‚K�m¨M¸4À¼<ÑHÔH€KÑIÔIÐIà …M�&ÑàˆOÔð ;ÝÔ# D¨Ô$9Ñ:Ô:Ð:àÐà*0��fÔ˜hÑ'õ ð ð Ý1>×1EÒ1EÑ1GÔ1Gðñ ô ñ ô €Nõ ×!Ò!Ñ#Ô#ð :ð :ˆà�6”˜cÒ!Ð!¨.Ð!ˆAˆA¸aÐ@PÔ>Qð 	
ˆ'‰
õ /¨q°¬yÑ9Ô9ˆˆ/ÑÐõ Ý×ÒÑÔØEÐEðñ ô ð 2ð 2ˆõ 	×!Ò! $ x¤.Ñ1Ô1Ð1Ð1ð	2ð 2r!   )
NNNNNNNNNN)%Úcollectionsr(   rF   rM   r   Úpathlibr   Úos.pathr   r   Úurllib.parser   rW   rR   r
   Ú_utilsr   Ú
_get_pathsr   Ú_callback_contextr   Ú_get_appr   r&   ÚOrderedDictrœ   r8   r>   rK   rP   rU   r`   rh   rv   r|   r‚   r¥   r   r!   r   ú<module>r¯      sÛ  ðØ Ð Ð Ð Ø 	€	€	€	Ø 	€	€	€	Ø 
€
€
€
Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ð  Ð  Ø !Ð !Ð !Ð !Ð !Ð !à €€€à Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !Ø )Ð )Ð )Ð )Ð )Ð )Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø Ð Ð Ð Ð Ð ð 
ˆ‰Œ€Ø'�Ô'Ñ)Ô)€ð$ð $ð $ðNEð Eð Eðð ð ð(ð ð ðKð Kð Kðð ð ð"
ð 
ð 
ð+ð +ð +ð6ð ð ð	ð 	ð 	ð 
ØØ	Ø
Ø
ØØ
ØØØð}2ð }2ð }2ð }2ð }2ð }2r!   