
    #h@                         S SK r S SKJrJr  S SKJrJrJrJrJrJ	r	J
r
Jr  S SKJr  SSKJr  SSKJrJr  SSKJr  S S	KJr  SS
KJr  SSKJrJr  S SKJr  S SKJr   " S S\5      r  " S S\5      r!g)    N)datetime	timedelta)DictIterableList
NamedTupleOptionalSetTupleUnion)Arrow   )	BaseAlarm)Attendee	Organizer)	Component)	Container)	ArrowLike)	get_arrowuid_gen)EventParser)EventSerializerc                   *    \ rS rSr% \\S'   \\S'   Srg)Geo   latitude	longitude N)__name__
__module____qualname____firstlineno__float__annotations____static_attributes__r       I/Users/user/Downloads/htwk/venv/lib/python3.13/site-packages/ics/event.pyr   r      s    Or&   r   c            %          \ rS rSrSr " S S5      r                  S<S\S\S\S	\S
\S\S\S\S\S\S\	S\
\   S\
\   S\
\   S\S\S\SS4$S jjrS\	4S jrS\4S jr\S\4S j5       r\R(                  S\4S j5       r\S\4S j5       r\R(                  S\4S  j5       r\S\\   4S! j5       r\R(                  S\4S" j5       r\S\\   4S# j5       r\R(                  S\\\\4   \\\4   \S4   4S$ j5       r\S% 5       rS=S& jr\S\\   4S' j5       r \ R(                  S\\   4S( j5       r \S) 5       r!\!R(                  S* 5       r!S\4S+ jr"S\	4S, jr#S\	4S- jr$S\	4S. jr%\%r&S\	4S/ jr'S\	4S0 jr(\(r)S\	4S1 jr*S\	4S2 jr+S\	4S3 jr,S\	4S4 jr-S5\.S\	4S6 jr/S\	4S7 jr0S8 r1\1r2S9 r3S\44S: jr5S;r6g)>Event   a+  A calendar event.

Can be full-day or between two instants.
Can be defined by a beginning instant and
a duration *or* end instant.

Unsupported event attributes can be found in `event.extra`,
a :class:`ics.parse.Container`. You may add some by appending a
:class:`ics.parse.ContentLine` to `.extra`
c                        \ rS rSrSr\r\rSr	g)
Event.Meta$   VEVENTr   N)
r   r    r!   r"   namer   parserr   
serializerr%   r   r&   r'   Metar,   $   s    $
r&   r2   Nr/   beginenddurationuiddescriptioncreatedlast_modifiedlocationurltransparentalarms	attendees
categoriesstatus	organizerclassificationreturnc                    SU l         SU l        SU l        SU l        SU l        SU l        UU l        U(       d
  [        5       OUU l        X`l	        [        U5      U l        [        U5      U l        Xl        Xl        Xl        [!        5       U l        [%        5       U l        [%        5       U l        UU l        [-        SS9U l        Xl        X l        U(       a  U(       a  [5        S5      eU(       a  X0l        OU(       a  X@l        Ub  [!        U5      U l        Xl        UU l        Ub$  U R(                  R?                  [%        U5      5        Ub%  U R&                  R?                  [%        U5      5        gg)a  Instantiates a new :class:`ics.event.Event`.

Args:
    name: rfc5545 SUMMARY property
    begin (Arrow-compatible)
    end (Arrow-compatible)
    duration
    uid: must be unique
    description
    created (Arrow-compatible)
    last_modified (Arrow-compatible)
    location
    url
    transparent
    alarms
    attendees
    categories
    status
    organizer
    classification

Raises:
    ValueError: if `end` and `duration` are specified at the same time
Nr.   )r/   zNEvent() may not specify an end and a duration                 at the same time) 	_duration	_end_time_begin_begin_precision_status_classificationrA   r   r6   r7   r   r8   r9   r:   r;   r<   listr=   setr>   r?   geor   extrar/   r3   
ValueErrorr4   r5   r@   rB   update)selfr/   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rM   rB   s                      r'   __init__Event.__init__)   s0   Z /3.2+/ $&*.2.7),	#*5,5g,>2;M2J'/"%+6'+v(+$'EH-
	
"# # H$Mv,DK,!OO""3z?3 NN!!#i.1 !r&   c                 R    [        U R                  =(       d    U R                  5      $ )z#
Return:
    bool: self has an end
)boolrF   rE   rQ   s    r'   has_endEvent.has_end   s    
 DNN4dnn55r&   attendeec                 :    U R                   R                  U5        g)z-Add an attendee to the attendees set
        N)r>   add)rQ   rY   s     r'   add_attendeeEvent.add_attendee   s     	8$r&   c                     U R                   $ )zGet or set the beginning of the event.

|  Will return an :class:`Arrow` object.
|  May be set to anything that :func:`Arrow.get` understands.
|  If an end is defined (not a duration), .begin must not
    be set to a superior value.
)rG   rV   s    r'   r3   Event.begin   s     {{r&   valuec                     [        U5      nU(       a+  U R                  (       a  XR                  :  a  [        S5      eXl        SU l        g )NzBegin must be before endsecond)r   rF   rO   rG   rH   rQ   r`   s     r'   r3   r_      s7    % T^^(>788 (r&   c                 T   U R                   (       a  U R                  U R                   -   $ U R                  (       a)  U R                  (       a  U R                  $ U R                  $ U R                  (       a3  U R                  (       a  U R                  [        SS9-   $ U R                  $ g)aW  Get or set the end of the event.

|  Will return an :class:`Arrow` object.
|  May be set to anything that :func:`Arrow.get` understands.
|  If set to a non null value, removes any already
    existing duration.
|  Setting to None will have unexpected behavior if
    begin is not None.
|  Must not be set to an inferior value than self.begin.
r   daysN)rE   r3   rF   all_dayrG   r   rV   s    r'   r4   	Event.end   sq     >>::..^^||~~%~~%[[||{{YA%666 {{"r&   c                     [        U5      nU(       a+  U R                  (       a  XR                  :  a  [        S5      eXl        U(       a  S U l        g g )NzEnd must be after begin)r   rG   rO   rF   rE   rc   s     r'   r4   rh      s>    % T[[U[[%8677!DN r&   c                     U R                   (       a  U R                   $ U R                  (       a  U R                  U R                  -
  $ g)zGet or set the duration of the event.

|  Will return a timedelta object.
|  May be set to anything that timedelta() understands.
|  May be set with a dict ({"days":2, "hours":6}).
|  If set to a non null value, removes any already
    existing end time.
N)rE   r4   r3   rV   s    r'   r5   Event.duration   s4     >>>>!XX88djj(( r&   c                     [        U[        5      (       a  [        S0 UD6nO&[        U[        5      (       a  UnOUb  [        U5      nU(       a  S U l        Xl        g )Nr   )
isinstancedictr   rF   rE   rc   s     r'   r5   rk      sM    eT""&&Ey))Ee$E!DNr&   c                     U R                   $ )zGet or set the geo position of the event.

|  Will return a namedtuple object.
|  May be set to any Geo, tuple or dict with latitude and longitude keys.
|  If set to a non null value, removes any already
    existing geo.
)_georV   s    r'   rM   	Event.geo   s     yyr&   c                     [        U[        5      (       a  US   US   p2[        X#5      nOUb  Uu  p#[        X#5      nXl        g )Nr   r   )rm   rn   r   rp   )rQ   r`   r   r   s       r'   rM   rq      sG    eT"""'
"3U;5Gi,E"'H,E	r&   c                      U R                   S:H  $ )z,
Return:
    bool: self is an all-day event
day)rH   rV   s    r'   rg   Event.all_day   s     $$--r&   c                     U R                   (       a  gU R                  R                  S5      nU R                  R                  S5      nXl        X:X  a  SU l        OU[        SS9-   U l        SU l        SU l        g)zfTransforms self to an all-day event.

The event will span all the days from the begin to the end day.
Nrt   r   re   )	rg   r3   floorr4   rG   rF   r   rE   rH   )rQ   	begin_dayend_days      r'   make_all_dayEvent.make_all_day  sh    
 <<JJ$$U+	((..' !DN$ya'88DN %r&   c                     U R                   $ N)rI   rV   s    r'   r@   Event.status  s    ||r&   c                     [        U[        5      (       a  UR                  5       nSnX;  a7  [        SSR	                  U Vs/ s H  n[        U5      PM     sn5      -  5      eXl        g s  snf )N)N	TENTATIVE	CONFIRMED	CANCELLEDzstatus must be one of %sz, )rm   strupperrO   joinreprrI   )rQ   r`   statusesxs       r'   r@   r~   #  sb    eS!!KKME@ 7$))V^D_V^QRT!WV^D_:``aa E`s   A+c                     U R                   $ r}   )rJ   rV   s    r'   rB   Event.classification,  s    ###r&   c                 f    Ub'  [        U[        5      (       d  [        S5      eXl        g S U l        g )Nzclassification must be a str)rm   r   rO   rJ   rc   s     r'   rB   r   0  s/    eS)) !?@@#( #'D r&   c                    U R                   (       a  SR                  U R                   5      OSnU R                  (       a  U R                  (       d   eU R                  (       a  U R                  U R                  :X  a*  SR                  XR
                  R                  S5      5      $ SR                  XR                  R                  S5      U R                  R                  S5      5      $ U R
                  c.  U R                   (       a  SR                  U R                   5      $ S$ SR                  XR
                  U R                  5      $ )	Nz'{}'  z<all-day Event {}{}>z%Y-%m-%dz!<all-day Event {}begin:{} end:{}>z<Event '{}'>z<Event>z<Event {}begin:{} end:{}>)r/   formatrg   rG   rF   r3   strftimer4   )rQ   r/   s     r'   __repr__Event.__repr__9  s    ,0IIw~~dii(2<<;;;>>T[[DNN%B-44T::;N;Nz;Z[[:AA$H\H\]gHhjnjxjx  kB  kB  CM  kN  O  OZZ7;yy>((3OiO.55dJJQQr&   c                     [        U[        5      (       d#  [        SR                  [	        U5      5      5      eU R
                  UR
                  :  =(       a    U R
                  UR                  :*  $ NCannot compare Event and {})rm   r)   NotImplementedErrorr   typer3   r4   rQ   others     r'   starts_withinEvent.starts_withinF  sU    %''%-44T%[AC CzzU[[(DTZZ599-DDr&   c                     [        U[        5      (       d#  [        SR                  [	        U5      5      5      eU R
                  UR                  :  =(       a    U R
                  UR
                  :*  $ r   )rm   r)   r   r   r   r4   r3   r   s     r'   ends_withinEvent.ends_withinL  sU    %''%-44T%[AC Cxx5;;&@488uyy+@@r&   c                 $   [        U[        5      (       d#  [        SR                  [	        U5      5      5      eU R                  U5      =(       dA    U R                  U5      =(       d)    UR                  U 5      =(       d    UR                  U 5      $ r   )rm   r)   r   r   r   r   r   r   s     r'   
intersectsEvent.intersectsR  s~    %''%-44T%[AC C""5) +##E*+&&t,+ $$T*	,r&   c                 8   [        U[        5      (       a)  UR                  U 5      =(       a    UR                  U 5      $ [        U[        5      (       a%  U R
                  U:*  =(       a    U R                  U:  $ [        SR                  [        U5      5      5      er   )
rm   r)   r   r   r   r3   r4   r   r   r   r   s     r'   includesEvent.includes]  sy    eU##&&t,H1B1B41HHeX&&::&<488u+<<!)00e=? 	?r&   c                     [        U[        5      (       a  UR                  U 5      $ [        SR	                  [        U5      5      5      er   )rm   r)   r   r   r   r   r   s     r'   is_included_inEvent.is_included_ine  s=    eU##>>$''!)00e=? 	?r&   c                 ^   [        U[        5      (       a  U R                  c]  UR                  cP  U R                  c  UR                  c  gU R                  c  gUR                  c  gU R                  UR                  :  $ U R                  UR                  :X  a5  U R                  c  gUR                  c  gU R                  UR                  :  $ U R                  UR                  :  $ [        U[
        5      (       a  U R                  U:  $ [        SR                  [        U5      5      5      e)NFTr   	rm   r)   r3   r/   r4   r   r   r   r   r   s     r'   __lt__Event.__lt__m  s    eU##zz!ekk&999$); YY&ZZ' 99uzz11 u{{*88#YY& 88eii//zzEKK//eX&&::%%!)00e=? 	?r&   c                 ^   [        U[        5      (       a  U R                  c]  UR                  cP  U R                  c  UR                  c  gU R                  c  gUR                  c  gU R                  UR                  :*  $ U R                  UR                  :X  a5  U R                  c  gUR                  c  gU R                  UR                  :*  $ U R                  UR                  :*  $ [        U[
        5      (       a  U R                  U:*  $ [        SR                  [        U5      5      5      e)NTFr   r   r   s     r'   __le__Event.__le__  s    eU##zz!ekk&999$);YY&ZZ' 99

22u{{*88#YY& 88uyy00zzU[[00eX&&::&&!)00e=? 	?r&   c                 .    U R                  U5      (       + $ r}   )r   r   s     r'   __gt__Event.__gt__      ;;u%%%r&   c                 .    U R                  U5      (       + $ r}   )r   r   s     r'   __ge__Event.__ge__  r   r&   r   c                 2   [        U[        5      (       Ga  U R                  UR                  :H  =(       Ga    U R                  UR                  :H  =(       Ga    U R                  UR                  :H  =(       Ga|    U R
                  UR
                  :H  =(       Ga[    U R                  UR                  :H  =(       Ga:    U R                  UR                  :H  =(       Ga    U R                  UR                  :H  =(       a    U R                  UR                  :H  =(       a    U R                  UR                  :H  =(       a    U R                  UR                  :H  =(       a    U R                  UR                  :H  =(       ay    U R                  UR                  :H  =(       aY    U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R                   UR                   :H  $ [#        SR%                  ['        U5      5      5      er   )rm   r)   r/   r3   r4   r5   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   r   r   r   r   s     r'   __eq__Event.__eq__  s   eU##II+ 2 2

ekk)2 2EII%2 2 /2 2   E$5$55	2 2
 -2 2 ""e&9&992 /2 EII%2   E$5$552 u||+2 %//12 5#3#332 u||+2 %//13 ")00e=? 	?r&   c                 t    U R                   UR                   :H  =(       a    U R                  UR                  :H  $ r}   )r3   r4   r   s     r'   time_equalsEvent.time_equals  s'    

ekk)FEII0EFr&   c                 b   [        U0 UD6nU R                  U5      (       au  U R                  U5      (       a  UR                  Ul        OU R                  Ul        U R	                  U5      (       a  UR
                  Ul        U$ U R
                  Ul        U$ [        SR                  X5      5      e)zCreate a new event which covers the time range of two intersecting events

All extra parameters are passed to the Event constructor.

Args:
    other: the other event

Returns:
    a new Event instance
z-Cannot join {} with {}: they don't intersect.)r)   r   r   r3   r   r4   rO   r   )rQ   r   argskwargevents        r'   r   
Event.join  s     t%u%??5!!!!%((#kk"jj&&!II	 L !HH	LIPPQU]^^r&   c                    [         R                   " U 5      nUR                  R                  5       Ul        [         R                   " U R                  5      Ul        [         R                   " U R                  5      Ul        U$ )z*
Returns:
    Event: an exact copy of self)copyrN   cloner=   r?   )rQ   r   s     r'   r   Event.clone  sS     		$kk'')yy-99T__5r&   c                 `    [        SR                  [        S U R                  5      5      5      $ )z3
Returns:
    int: hash of self. Based on self.uid.r   c                     S[        U 5      -  $ )Nz%.3d)ord)r   s    r'   <lambda> Event.__hash__.<locals>.<lambda>  s    #a&r&   )intr   mapr6   rV   s    r'   __hash__Event.__hash__  s$     27738$((CDEEr&   )rG   rH   rJ   rE   rF   rp   rI   r=   r>   r3   r?   rB   r8   r7   r5   r4   rN   rM   r9   r:   r/   rA   r@   r<   r6   r;   )NNNNNNNNNNNNNNNNNN)rC   N)7r   r    r!   r"   __doc__r2   r   r   r   rU   r   r   r   r   rR   rW   r\   propertyr   r3   setterr4   r	   r5   r   rM   r   r   r#   r   rg   rz   r@   rB   r   r   r   r   __xor__r   r   __in__r   r   r   r   objectr   r   r   __and__r   r   r   r%   r   r&   r'   r)   r)      s   	% % "$("&'+ $(&*,0!% %)/315-1#(,'+%W2W2!W2  W2 %	W2
 W2 "W2 $W2 !*W2 W2 W2 #W2 "),W2 %X.W2 &c]W2 W2  &!W2$ "%%W2& 'W2r6 6%X %
 u   \\)9 ) ) U  : 	ZZ" " " (9-  $ __i   Xc]   	ZZtCJ/ue|1Dc4OP   . .&.    ]]HSM   $ $ ( (R# REd EAD A,4 , G? ??t ? F?t ?8?t ?2&t &&t &?F ?t ?(GD G_4 GF# Fr&   r)   )"r   r   r   typingr   r   r   r   r	   r
   r   r   arrowr   
alarm.baser   rY   r   r   	componentr   ics.grammar.parser   typesr   utilsr   r   ics.parsers.event_parserr    ics.serializers.event_serializerr   r   r)   r   r&   r'   <module>r      sS     (" " "  ! )   '  ' 0 <* 
RFI RFr&   