
    ii                    6   d Z ddlmZ ddlZddlmZmZ ddlmZ erddl	m
Z
 ddlmZ ddlmZ erdd	lmZ dfdZdgdZ ed          ZeddfdhdZ edd          Z edde          Zdid Zdjd$Z ed%d&e eej                  '          Zdkd(Z ed)d*          Z ed+d,          Z ed-d.          Zdld0Z ed1d2e eej                  '          Z ed3d4          Z  ed5d6          Z!dmd8Z" ed9d:e" eej#                  '          Z#dnd<Z$ ed=d>e$ eej%                  '          Z%dod@Z& edAdBe& eej'                  '          Z'dpdDZ( edEdFe( eej)                  '          Z)dqdHZ* e*dIdJdK          Z+ edLdM          Z, edNdO          Z-drdQZ. edRdSe. eej/                  '          Z/dsdVZ0dtdXZ1dudYZ2 e3e0e1e2          Z4 edZd[          Z5 ed\d]          Z6 ed^d_          Z7dvdaZ8dwdcZ9dd Z: e3e8e9e:          Z;g deZ<dS )xzParameter access for icalendar.

Related:

- :rfc:`5545`, Section 3.2. Property Parameters
- :rfc:`7986`, Section 6. Property Parameters
- :rfc:`9253`
- https://github.com/collective/icalendar/issues/798
    )annotationsN)TYPE_CHECKINGTypeVar)enums)Callable)	timedelta)Enum)	VPROPERTYreturn
str | Nonec                     dS )Return None by default.N r       J/root/projects/butler/venv/lib/python3.11/site-packages/icalendar/param.py_default_return_noner      s    4r   strc                     dS )r    r   r   r   r   _default_return_stringr   !   s    2r   Tnamedocdefaultr   convertCallable[[str], T] | None
convert_toCallable[[T], str] | Nonepropertyc                     t          j                  d fd            }d fd}d fd	t          |||
          S )z8Return a parameter with a quoted value (case sensitive).Nselfr
   r   r   c                n    | j                                       }|
             S r |          n|S N)paramsget)r!   valuer   r   r   s     r   fgetzstring_parameter.<locals>.fget5   s>    %%=799!(3wwu~~~e3r   r&   c                T    | |            d S r |          n|| j         <   d S r#   )r$   )r!   r&   r   fdelr   s     r   fsetzstring_parameter.<locals>.fset<   s?    =DJJJJJ5? J

5 1 1 1UDKr   c                >    | j                             d            d S r#   r$   popr!   r   s    r   r)   zstring_parameter.<locals>.fdelB       d#####r   r   )r!   r
   r   r   r!   r
   r&   r   r!   r
   )	functoolswrapsr   )r   r   r   r   r   r'   r*   r)   s   ` ```  @r   string_parameterr5   )   s     
_W4 4 4 4 4 4 4 4K K K K K K K K$ $ $ $ $ $ D$#....r   ALTREPa  ALTREP - Specify an alternate text representation for the property value.

Description:
    This parameter specifies a URI that points to an
    alternate representation for a textual property value.  A property
    specifying this parameter MUST also include a value that reflects
    the default representation of the text value.  The URI parameter
    value MUST be specified in a quoted-string.

.. note::

    While there is no restriction imposed on the URI schemes
    allowed for this parameter, Content Identifier (CID) :rfc:`2392`,
    HTTP :rfc:`2616`, and HTTPS :rfc:`2818` are the URI schemes most
    commonly used by current implementations.
CNa  Specify the common name to be associated with the calendar user specified.

Description:
    This parameter can be specified on properties with a
    CAL-ADDRESS value type.  The parameter specifies the common name
    to be associated with the calendar user specified by the property.
    The parameter value is text.  The parameter value can be used for
    display text to be associated with the calendar address specified
    by the property.
r   enums.CUTYPE | strc                 $    t           j        j        S zDefault value.)r   CUTYPE
INDIVIDUALr   r   r   _default_return_individualr>   l   s    <""r   enum
type[Enum]Callable[[str], Enum]c                     d fd}|S )Nr&   r   r   c                d    	  |                                            S # t          $ r | cY S w xY w)zConvert if possible.)upper
ValueError)r&   r?   s    r   r   z_convert_enum.<locals>.convertr   sD    	4&&& 	 	 	LLL	s     //)r&   r   r   r   r   )r?   r   s   ` r   _convert_enumrF   q   s(          Nr   r<   a  Identify the type of calendar user specified by the property.

Description:
    This parameter can be specified on properties with a
    CAL-ADDRESS value type.  The parameter identifies the type of
    calendar user specified by the property.  If not specified on a
    property that allows this parameter, the default is INDIVIDUAL.
    Applications MUST treat x-name and iana-token values they don't
    recognize the same way as they would the UNKNOWN value.
)r   r   c                R     d fd}d fd}d fd	t          |||
          S )z/Return a parameter that contains a quoted list.r!   r
   r   
tuple[str]c                    | j                                       }|dS t          |t                    r"t	          |                    d                    S |S )Nr   ,)r$   r%   
isinstancer   tuplesplit)r!   r&   r   s     r   r'   z#quoted_list_parameter.<locals>.fget   sQ    %%=2eS!! 	+S))***r   r&   str | tuple[str]c                r    |dk    r |            d S t          |t                    r|fn|| j        <   d S )Nr   )rK   r   r$   )r!   r&   r)   r   s     r   r*   z#quoted_list_parameter.<locals>.fset   sD    B;;DJJJJJ,6uc,B,B MDKr   c                >    | j                             d            d S r#   r,   r.   s    r   r)   z#quoted_list_parameter.<locals>.fdel   r/   r   r0   )r!   r
   r   rH   )r!   r
   r&   rN   r2   )r   )r   r   r'   r*   r)   s   `   @r   quoted_list_parameterrQ      s         N N N N N N N$ $ $ $ $ $ D$#....r   zDELEGATED-FROMa  Specify the calendar users that have delegated their participation to the calendar user specified by the property.

Description:
    This parameter can be specified on properties with a
    CAL-ADDRESS value type.  This parameter specifies those calendar
    users that have delegated their participation in a group-scheduled
    event or to-do to the calendar user specified by the property.
    The individual calendar address parameter values MUST each be
    specified in a quoted-string.
zDELEGATED-TOa  Specify the calendar users to whom the calendar user specified by the property has delegated participation.

Description:
    This parameter can be specified on properties with a
    CAL-ADDRESS value type.  This parameter specifies those calendar
    users whom have been delegated participation in a group-scheduled
    event or to-do by the calendar user specified by the property.
    The individual calendar address parameter values MUST each be
    specified in a quoted-string.
    DIRa  Specify reference to a directory entry associated with the calendar user specified by the property.

Description:
    This parameter can be specified on properties with a
    CAL-ADDRESS value type.  The parameter specifies a reference to
    the directory entry associated with the calendar user specified by
    the property.  The parameter value is a URI.  The URI parameter
    value MUST be specified in a quoted-string.

.. note::

    While there is no restriction imposed on the URI schemes
    allowed for this parameter, CID :rfc:`2392`, DATA :rfc:`2397`, FILE
    :rfc:`1738`, FTP :rfc:`1738`, HTTP :rfc:`2616`, HTTPS :rfc:`2818`, LDAP
    :rfc:`4516`, and MID :rfc:`2392` are the URI schemes most commonly
    used by current implementations.
enums.FBTYPE | strc                 $    t           j        j        S r;   )r   FBTYPEBUSYr   r   r   _default_return_busyrW      s    <r   rU   a#  Specify the free or busy time type.

Description:
    This parameter specifies the free or busy time type.
    The value FREE indicates that the time interval is free for
    scheduling.  The value BUSY indicates that the time interval is
    busy because one or more events have been scheduled for that
    interval.  The value BUSY-UNAVAILABLE indicates that the time
    interval is busy and that the interval can not be scheduled.  The
    value BUSY-TENTATIVE indicates that the time interval is busy
    because one or more events have been tentatively scheduled for
    that interval.  If not specified on a property that allows this
    parameter, the default is BUSY.  Applications MUST treat x-name
    and iana-token values they don't recognize the same way as they
    would the BUSY value.
LANGUAGEa  Specify the language for text values in a property or property parameter.

Description:
    This parameter identifies the language of the text in
    the property value and of all property parameter values of the
    property.  The value of the "LANGUAGE" property parameter is that
    defined in :rfc:`5646`.

    For transport in a MIME entity, the Content-Language header field
    can be used to set the default language for the entire body part.
    Otherwise, no default language is assumed.
MEMBERa'  Specify the group or list membership of the calendar user specified by the property.

Description:
    This parameter can be specified on properties with a
    CAL-ADDRESS value type.  The parameter identifies the groups or
    list membership for the calendar user specified by the property.
    The parameter value is either a single calendar address in a
    quoted-string or a COMMA-separated list of calendar addresses,
    each in a quoted-string.  The individual calendar address
    parameter values MUST each be specified in a quoted-string.
enums.PARTSTAT | strc                 $    t           j        j        S r;   )r   PARTSTATNEEDS_ACTIONr   r   r   _default_return_needs_actionr^     s    >&&r   r\   a  Specify the participation status for the calendar user specified by the property.

Description:
    This parameter can be specified on properties with a
    CAL-ADDRESS value type.  The parameter identifies the
    participation status for the calendar user specified by the
    property value.  The parameter values differ depending on whether
    they are associated with a group-scheduled "VEVENT", "VTODO", or
    "VJOURNAL".  The values MUST match one of the values allowed for
    the given calendar component.  If not specified on a property that
    allows this parameter, the default value is NEEDS-ACTION.
    Applications MUST treat x-name and iana-token values they don't
    recognize the same way as they would the NEEDS-ACTION value.
enums.RANGE | str | Nonec                     d S r#   r   r   r   r   _default_range_nonera   +  s    4r   RANGEar  Specify the effective range of recurrence instances from the instance specified by the recurrence identifier specified by the property.

Description:
    This parameter can be specified on a property that
    specifies a recurrence identifier.  The parameter specifies the
    effective range of recurrence instances that is specified by the
    property.  The effective range is from the recurrence identifier
    specified by the property.  If this parameter is not specified on
    an allowed property, then the default range is the single instance
    specified by the recurrence identifier value of the property.  The
    parameter value can only be "THISANDFUTURE" to indicate a range
    defined by the recurrence identifier and all subsequent instances.
    The value "THISANDPRIOR" is deprecated by this revision of
    iCalendar and MUST NOT be generated by applications.
enums.RELATED | strc                 $    t           j        j        S r#   )r   RELATEDSTARTr   r   r   _default_relatedrg   E  s    =r   re   a  Specify the relationship of the alarm trigger with respect to the start or end of the calendar component.

Description:
    This parameter can be specified on properties that
    specify an alarm trigger with a "DURATION" value type.  The
    parameter specifies whether the alarm will trigger relative to the
    start or end of the calendar component.  The parameter value START
    will set the alarm to trigger off the start of the calendar
    component; the parameter value END will set the alarm to trigger
    off the end of the calendar component.  If the parameter is not
    specified on an allowable property, then the default is START.

enums.ROLE | strc                 $    t           j        j        S r#   )r   ROLEREQ_PARTICIPANTr   r   r   _default_req_participantrl   ]  s    :%%r   rj   a3  Specify the participation role for the calendar user specified by the property.

Description:
    This parameter can be specified on properties with a
    CAL-ADDRESS value type.  The parameter specifies the participation
    role for the calendar user specified by the property in the group
    schedule calendar component.  If not specified on a property that
    allows this parameter, the default value is REQ-PARTICIPANT.
    Applications MUST treat x-name and iana-token values they don't
    recognize the same way as they would the REQ-PARTICIPANT value.
boolc                <    dfd}t          | ||d d           S )Nr   rm   c                      S r#   r   r8   s   r   _defaultz#boolean_parameter.<locals>._defaultt  s    r   c                2    |                                  dk    S )NTRUE)rD   xs    r   <lambda>z#boolean_parameter.<locals>.<lambda>{  s    !''))v- r   c                    | rdndS )Nrr   FALSEr   rs   s    r   ru   z#boolean_parameter.<locals>.<lambda>|  s    q5VVg r   )r   r   r   )r   rm   )r5   )r   r   r   rp   s    `  r   boolean_parameterrx   s  sO          --55   r   RSVPFa@  Specify whether there is an expectation of a favor of anreply from the calendar user specified by the property value.

Description:
    This parameter can be specified on properties with a
    CAL-ADDRESS value type.  The parameter identifies the expectation
    of a reply from the calendar user specified by the property value.
    This parameter is used by the "Organizer" to request a
    participation status reply from an "Attendee" of a group-scheduled
    event or to-do.  If not specified on a property that allows this
    parameter, the default value is ``False``.
zSENT-BYa  Specify the calendar user that is acting on behalf of the calendar user specified by the property.

Description:
    This parameter can be specified on properties with a
    CAL-ADDRESS value type.  The parameter specifies the calendar user
    that is acting on behalf of the calendar user specified by the
    property.  The parameter value MUST be a mailto URI as defined in
    :rfc:`2368`.  The individual calendar address parameter values MUST
    each be specified in a quoted-string.
TZIDa  Specify the identifier for the time zone definition for a time component in the property value.

Description:
    This parameter MUST be specified on the "DTSTART",
    "DTEND", "DUE", "EXDATE", and "RDATE" properties when either a
    DATE-TIME or TIME value type is specified and when the value is
    neither a UTC or a "floating" time.  Refer to the DATE-TIME or
    TIME value type definition for a description of UTC and "floating
    time" formats.  This property parameter specifies a text value
    that uniquely identifies the "VTIMEZONE" calendar component to be
    used when evaluating the time portion of the property.  The value
    of the "TZID" property parameter will be equal to the value of the
    "TZID" property for the matching time zone definition.  An
    individual "VTIMEZONE" calendar component MUST be specified for
    each unique "TZID" parameter value specified in the iCalendar
    object.

    The parameter MUST be specified on properties with a DATE-TIME
    value if the DATE-TIME is not either a UTC or a "floating" time.
    Failure to include and follow VTIMEZONE definitions in iCalendar
    objects may lead to inconsistent understanding of the local time
    at any given location.

    The presence of the SOLIDUS character as a prefix, indicates that
    this "TZID" represents a unique ID in a globally defined time zone
    registry (when such registry is defined).

.. note::

    This document does not define a naming convention for
    time zone identifiers.  Implementers may want to use the naming
    conventions defined in existing time zone specifications such
    as the public-domain TZ database (TZDB). The specification of
    globally unique time zone identifiers is not addressed by this
    document and is left for future study.
enums.RELTYPEc                 $    t           j        j        S r#   )r   RELTYPEPARENTr   r   r   _default_return_parentr     s    =r   r}   a  Specify the type of hierarchical relationship associated with a component.

Conformance:
    :rfc:`5545` introduces the RELTYPE property parameter.
    :rfc:`9253` adds new values.

Description:
    This parameter can be specified on a property that
    references another related calendar.  The parameter specifies the
    hierarchical relationship type of the calendar component
    referenced by the property.  The parameter value can be PARENT, to
    indicate that the referenced calendar component is a superior of
    calendar component; CHILD to indicate that the referenced calendar
    component is a subordinate of the calendar component; or SIBLING
    to indicate that the referenced calendar component is a peer of
    the calendar component.  If this parameter is not specified on an
    allowable property, the default relationship type is PARENT.
    Applications MUST treat x-name and iana-token values they don't
    recognize the same way as they would the PARENT value.
r!   r
   c                n    | j         j        }|t          | dd          }|
 |            }|| j        n|S )ay  The VALUE parameter or the default.

    Purpose:
        VALUE explicitly specify the value type format for a property value.

    Description:
        This parameter specifies the value type and format of
        the property value.  The property values MUST be of a single value
        type.  For example, a "RDATE" property cannot have a combination
        of DATE-TIME and TIME value types.

        If the property's value is the default value type, then this
        parameter need not be specified.  However, if the property's
        default value type is overridden by some other allowable value
        type, then this parameter MUST be specified.

        Applications MUST preserve the value data for ``x-name`` and
        ``iana-token`` values that they don't recognize without attempting
        to interpret or parse the value data.

    Returns:
        The VALUE parameter or the default.

    Examples:
        The VALUE defaults to the name of the property.
        Note that it is case-insensitive but always uppercase.

        .. code-block:: pycon

            >>> from icalendar import vBoolean
            >>> b = vBoolean(True)
            >>> b.VALUE
            'BOOLEAN'

        Setting the VALUE parameter of a typed property usually does not make sense.
        For convenience, using this property, the value will be converted to
        an uppercase string.
        If you have some custom property, you might use it like this:

        .. code-block:: pycon

            >>> from icalendar import vUnknown, Event
            >>> v = vUnknown("Some property text.")
            >>> v.VALUE = "x-type"  # lower case
            >>> v.VALUE
            'X-TYPE'
            >>> event = Event()
            >>> event.add("x-prop", v)
            >>> print(event.to_ical())
            BEGIN:VEVENT
            X-PROP;VALUE=X-TYPE:Some property text.
            END:VEVENT

    N
_get_value)r$   r&   getattrdefault_value)r!   r&   _get_default_values      r   r   r     sL    n KE}$T<>>)&&((E!&4E9r   r&   c                    || j         _        dS )zSet the VALUE parameter.Nr$   r&   )r!   r&   s     r   
_set_valuer   %  s    DKr   c                    | j         `dS )zDelete the VALUE parameter.Nr   )r!   s    r   
_del_valuer   *  s    r   LABELa&  LABEL provides a human-readable label.

Conformance:
    This property parameter is specified in :rfc:`7986`,
    iCalendar Property Extensions.

    :rfc:`9253` makes use of this for the LINK property.
    This parameter maps to the "title"
    attribute defined in Section 3.4.1 of :rfc:`8288`.
    LABEL is used to label the destination
    of a link such that it can be used as a human-readable identifier
    (e.g., a menu entry) in the language indicated by the LANGUAGE
    (if present). The LABEL MUST NOT
    appear more than once in a given link; occurrences after the first
    MUST be ignored by parsers.

Description:
    This property parameter MAY be specified on the
    "CONFERENCE" property.  It is anticipated that other extensions to
    iCalendar will reuse this property parameter on new properties
    that they define.  As a result, clients MUST expect to find this
    property parameter present on many different properties.  It
    provides a human-readable label that can be presented to calendar
    users to allow them to discriminate between properties that might
    be similar or provide additional information for properties that
    are not self-describing.  The "LANGUAGE" property parameter can be
    used to specify the language of the text in the parameter value
    (as per Section 3.2.10 of :rfc:`5545`).

Examples:
    This is a label of a chat.

    .. code-block:: ics

        CONFERENCE;VALUE=URI;FEATURE=VIDEO;
            LABEL="Web video chat, access code=76543";
            :https://video-chat.example.com/;group-id=1234

FMTTYPEa  FMTTYPE specfies the content type of a referenced object.

Conformance:
    :rfc:`5545` specifies the FMTTYPE.
    :rfc:`9253` adds FMTTYPE to LINK properties. In a LINK,
    FMTTYPE maps to the "type"
    attribute defined in Section 3.4.1 of :rfc:`8288`.
    See :rfc:`6838`.

Description:
    This parameter can be specified on properties that are
    used to reference an object.  The parameter specifies the media
    type :rfc:`4288` of the referenced object. For example, on the
    "ATTACH" property, an FTP type URI value does not, by itself,
    necessarily convey the type of content associated with the
    resource.  The parameter value MUST be the text for either an
    IANA-registered media type or a non-standard media type.

Example:
    A Microsoft Word document:

    .. code-block:: ics

        ATTACH;FMTTYPE=application/msword:ftp://example.com/pub/docs/
         agenda.doc

    A website:

    .. code-block:: ics

        LINK;FMTTYPE=text/html;LINKREL=SOURCE;LABEL=Venue;VALUE=URI:
         https://example.com/venue

    LINKRELa  LINKREL

Purpose:
    LINKREL specifies the relationship of data referenced
    by a LINK property.

Conformance:
    LINKREL is specified in :rfc:`9253`.
    This parameter maps to the link relation type defined in
    Section 2.1 of :rfc:`8288`.
    It is always quoted.

Description:
    This parameter MUST be specified on all LINK properties and define
    the type of reference.
    This allows programs consuming this data to automatically scan
    for references they support.
    There is no default relation type. Any link relation in the
    link registry established by :rfc:`8288`, or new link relations,
    may be used.
    It is expected that link relation types seeing significant usage
    in calendaring will have the calendaring usage described in an RFC.

    In the simplest case, a link relation type identifies the semantics
    of a link.  For example, a link with the relation type "copyright"
    indicates that the current link context has a copyright resource at
    the link target.

    Link relation types can also be used to indicate that the target
    resource has particular attributes, or exhibits particular
    behaviours; for example, a "service" link implies that the link
    target can be used as part of a defined protocol (in this case, a
    service description).

Registration:
    There are two kinds of relation types: registered and extension.
    These relation types are registered in :rfc:`8288`.

.. seealso::

    `Registered Link Relation Types
    <https://www.iana.org/assignments/link-relations/link-relations.xhtml>`_.


Examples:
    This identifies the latest version of the event information.

    .. code-block:: ics

        LINKREL=latest-version

timedelta | Nonec                    | j                             d          }|dS ddlm} t	          |t
                    r|                    |          S t	          ||          st          d          |j        S )a  GAP

    Purpose:
        GAP specifies the length of the gap, positive or negative,
        between two components with a temporal relationship.

    Format Definition:
        Same as the DURATION value type defined in :rfc:`5545`, Section 3.3.6.

    Description:
        This parameter MAY be specified on the RELATED-TO property and defines
        the duration of time between the predecessor and successor in an interval.
        When positive, it defines the lag time between a task and its logical successor.
        When negative, it defines the lead time.

    Examples:
        An example of lag time might be if Task-A is "paint the room" and Task-B is
        "lay the carpets". Then, Task-A may be related to Task-B with
        RELTYPE=FINISHTOSTART with a gap of 1 day -- long enough for the paint to dry.

        .. code-block:: text

            ====================
            |  paint the room  |--+
            ====================  |
                                  |(lag of one day)
                                  |
                                  |  ===================
                                  +->| lay the carpet  |
                                     ===================

        For an example of lead time, in constructing a two-story building,
        the electrical work must be done before painting. However,
        the painter can move in to the first floor as the electricians move upstairs.

        .. code-block:: text

            =====================
            |  electrical work  |--+
            =====================  |
                     +-------------+
                     |(lead of estimated time)
                     |  ==================
                     +->|    painting    |
                        ==================
    GAPNr   	vDurationz"Value MUST be a vDuration instance)	r$   r%   icalendar.propr   rK   r   	from_ical	TypeErrortdpropr&   r   s      r   _get_GAPr     s    ^ KOOE""E}t((((((% *""5)))eY'' ><===8Or   timedelta | str | Nonec                v    || j                             dd           dS ddlm}  ||          | j         d<   dS )z%Set the GAP parameter as a timedelta.Nr   r   r   )r$   r-   r   r   r   s      r   _set_GAPr     sP    }t$$$(((((("5))DKr   c                <    | j                             dd           dS )zDelete the GAP parameter.r   Nr,   )r   s    r   _del_GAPr      s    KOOE4     r   )r6   r7   r<   DELEGATED_FROMDELEGATED_TOrR   rU   r   r   r   rX   r   rY   r\   rb   re   rj   ry   SENT_BYrz   VALUErQ   r5   )r   r   )r   r   )r   r   r   r   r   r   r   r   r   r   r   r   )r   r9   )r?   r@   r   rA   )r   r   r   r   r   r   )r   rS   )r   rZ   )r   r_   )r   rc   )r   rh   )r   r   r   rm   r   r   r   r   )r   r{   )r!   r
   r   r   r1   r2   )r   r   )r&   r   )=__doc__
__future__r   r3   typingr   r   	icalendarr   collections.abcr   datetimer   r?   r	   r   r
   r   r   r   r5   r6   r7   r>   rF   r<   rQ   r   r   rR   rW   rU   rX   rY   r^   r\   ra   rb   rg   re   rl   rj   rx   ry   r   rz   r   r}   r   r   r   r   r   r   r   r   r   r   r   r   __all__r   r   r   <module>r      sx    # " " " " "     ) ) ) ) ) ) ) )       ((((((""""""  )((((((   
   
 GCLL -)-,0/ / / / /> 
	
 
( 	 #   # # # #
    
		 'M%,''
 
 
"/ / / /. '&	  %$	  	 ,   
 
	  !M%,'''
 
 
,    
	

 
 ' ' ' '
  )M%.))#  *    	  M%+&&%	 	 	,    
 M%-((!  (& & & & 

 %M%*%%  $
 
 
 
 
	
   
	  
#& &R        
( #M%-((/  6<: <: <: <:~   
   
 	Z44&)	 )	V 
!$ $L 
36 6r8 8 8 8v* * * *! ! !
 hx8,,  r   