
    DhV!                         S SK JrJrJrJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJr  S SKJrJrJr   " S S	\
5      r " S
 S\\5      rg)    )ListOptionalTextIOUnion)MacroElement)
JSCSSMixin)GeoJson)Map)Template)JsCode
get_boundsremove_emptyc                   n   ^  \ rS rSrSr\" S5      rSS/r SS\\	\
\4   S\\   4U 4S jjjrS	 rS
rU =r$ )Timeline   aG	  
Create a layer from GeoJSON with time data to add to a map.

To add time data, you need to do one of the following:

* Add a 'start' and 'end' property to each feature. The start and end
  can be any comparable item.

Alternatively, you can provide a `get_interval` function.

* This function should be a JsCode object and take as parameter
  a GeoJson feature and return a dict containing values for
  'start', 'end', 'startExclusive' and 'endExcusive' (or false if no
  data could be extracted from the feature).
* 'start' and 'end' can be any comparable items
* 'startExclusive' and 'endExclusive' should be boolean values.

Parameters
----------
data: file, dict or str.
    The geojson data you want to plot.

get_interval: JsCode, optional
    Called for each feature, and should return either a time range for the
    feature or `false`, indicating that it should not be included in the
    timeline. The time range object should have 'start' and 'end' properties.
    Optionally, the boolean keys 'startExclusive' and 'endExclusive' allow the
    interval to be considered exclusive.

    If `get_interval` is not provided, 'start' and 'end' properties are
    assumed to be present on each feature.

Examples
--------
>>> from folium.plugins import Timeline, TimelineSlider
>>> m = folium.Map()

>>> data = requests.get(
...     "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson"
... ).json()

>>> timeline = Timeline(
...     data,
...     get_interval=JsCode(
...         '''
...         function (quake) {
...            // earthquake data only has a time, so we'll use that as a "start"
...            // and the "end" will be that + some value based on magnitude
...            // 18000000 = 30 minutes, so a quake of magnitude 5 would show on the
...            // map for 150 minutes or 2.5 hours
...            return {
...                start: quake.properties.time,
...                end: quake.properties.time + quake.properties.mag * 1800000,
...            };
...         };
...     '''
...     ),
... ).add_to(m)
>>> TimelineSlider(
...     auto_play=False,
...     show_ticks=True,
...     enable_keyboard_controls=True,
...     playback_duration=30000,
... ).add_timelines(timeline).add_to(m)

Other keyword arguments are passed to the GeoJson layer, so you can pass
  `style`, `point_to_layer` and/or `on_each_feature`.

al  
        {% macro script(this, kwargs) %}
          var {{ this.get_name() }}_options = {{ this.options|tojavascript }};

          var {{ this.get_name() }} = L.timeline(
              {{ this.data|tojson }},
              {{ this.get_name() }}_options
          );
          {{ this.get_name() }}.addTo({{ this._parent.get_name() }});
        {% endmacro %}
    timelinezPhttps://cdn.jsdelivr.net/npm/leaflet.timeline@1.6.0/dist/leaflet.timeline.min.jsmomentzEhttps://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.jsdataget_intervalc                 `   > [         TU ]  U5        SU l        Ub  X#S'   [        S0 UD6U l        g )Nr   r    )super__init___namer   options)selfr   r   kwargs	__class__s       jC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\folium/plugins/timeline.pyr   Timeline.__init__l   s6     	
#%1>"#-f-    c                 *    [        U R                  SS9$ )z
Computes the bounds of the object itself (not including it's children)
in the form [[lat_min, lon_min], [lat_max, lon_max]].

T)lonlat)r   r   )r   s    r!   _get_self_boundsTimeline._get_self_boundsz   s     $))D11r#   )r   r   )N)__name__
__module____qualname____firstlineno____doc__r   	_template
default_jsr   dictstrr   r   r   r   r&   __static_attributes____classcell__r    s   @r!   r   r      sh    DL 
	I	
	
	J *..D#v%&. v&. .2 2r#   r   c                      ^  \ rS rSrSr\" S5      rSS/r         SS\S\	S\
\\	\\4      S	\
\\	\\4      S
\S\S\S\S\4U 4S jjjrS rU 4S jrSrU =r$ )TimelineSlider   a  
Creates a timeline slider for timeline layers.

Parameters
----------
auto_play: bool, default True
    Whether the animation shall start automatically at startup.
start: str, int or float, default earliest 'start' in GeoJson
    The beginning/minimum value of the timeline.
end: str, int or float, default latest 'end' in GeoJSON
    The end/maximum value of the timeline.
date_options: str, default "YYYY-MM-DD HH:mm:ss"
    A format string to render the currently active time in the control.
enable_playback: bool, default True
    Show playback controls (i.e. prev/play/pause/next).
enable_keyboard_controls: bool, default False
    Allow playback to be controlled using the spacebar (play/pause) and
    right/left arrow keys (next/previous).
show_ticks: bool, default True
    Show tick marks on the slider
steps: int, default 1000
    How many steps to break the timeline into.
    Each step will then be (end-start) / steps. Only affects playback.
playback_duration: int, default 10000
    Minimum time, in ms, for the playback to take. Will almost certainly
    actually take at least a bit longer -- after each frame, the next
    one displays in playback_duration/steps ms, so each frame really
    takes frame processing time PLUS step time.

Examples
--------
See the documentation for Timeline

aT  
        {% macro header(this,kwargs) %}
            <style>
                .leaflet-bottom.leaflet-left {
                    width: 100%;
                }
                .leaflet-control-container .leaflet-timeline-controls {
                    box-sizing: border-box;
                    width: 100%;
                    margin: 0;
                    margin-bottom: 15px;
                }
            </style>
        {% endmacro %}

        {% macro script(this, kwargs) %}
          var {{ this.get_name() }} = L.timelineSliderControl(
              {{ this.options|tojavascript }}
          );
          {{ this.get_name() }}.addTo({{ this._parent.get_name() }});

          {% for timeline in this.timelines %}
              {{ this.get_name() }}.addTimelines({{ timeline.get_name() }});
          {% endfor %}

        {% endmacro %}
    r   r   	auto_playdate_optionsstartendenable_playbackenable_keyboard_controls
show_ticksstepsplayback_durationc
                    > [         TU ]  5         SU l        XS'   X:S'   XJS'   XZS'   XjS'   XzS'   XS'   XS	'   [        S
U-   S-   5      U
S'   / U l        [        S0 U
D6U l        g )Nr5   r7   r9   r:   r;   r<   r=   r>   durationzu
            function(date) {
                var newdate = new moment(date);
                return newdate.format("z");
            }
        format_outputr   )r   r   r   r   	timelinesr   r   )r   r7   r8   r9   r:   r;   r<   r=   r>   r?   r   r    s              r!   r   TimelineSlider.__init__   s     	%
'{wu$3 !-E)*)|w.z"(, 	
	#
 *,#-f-r#   c                 0    U =R                   U-  sl         U $ )zAdd timelines to the control)rC   )r   argss     r!   add_timelinesTimelineSlider.add_timelines   s    $r#   c                 r   > [        U R                  [        5      (       d   S5       e[        TU ]  " S0 UD6  g )Nz1TimelineSlider can only be added to a Map object.r   )
isinstance_parentr
   r   render)r   r   r    s     r!   rL   TimelineSlider.render   s<    LL#
 
 	?>	? 
 	  r#   )r   r   rC   )	TzYYYY-MM-DD HH:mm:ssNNTFTi  i'  )r(   r)   r*   r+   r,   r   r-   r.   boolr0   r   r   intfloatr   rG   rL   r1   r2   r3   s   @r!   r5   r5      s    !F 	I>	
	
	J 12604 $).!&&. &. 	&.
 c3o./&. eCeO,-&. &. #'&. &. &. &. &.P
! !r#   r5   N)typingr   r   r   r   branca.elementr   folium.elementsr   folium.featuresr	   folium.foliumr
   folium.templater   folium.utilitiesr   r   r   r   r5   r   r#   r!   <module>rX      s?    0 0 ' & #  $ = =t2w t2n~!Z ~!r#   