§
    €î§i  ã                  ó˜   — d 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 e	rdd	lmZ e G d
„ d¦  «        ¦   «         ZdS )a(  
JMAP calendar resource object.

Wraps a raw JSCalendar CalendarEvent dict with the same minimal interface
as :class:`caldav.calendarobjectresource.CalendarObjectResource`:
``.id``, ``.parent``, :meth:`get_data`, :meth:`get_icalendar_instance`,
:meth:`edit_icalendar_instance`, and :meth:`save`.
é    )Úannotations)Úcontextmanager)Ú	dataclassÚfield)ÚTYPE_CHECKINGN)Újscal_to_ical)ÚJMAPMethodError)ÚJMAPCalendarc                  ó–   — e Zd ZU dZded<   ded<    edddd¬¦  «        Zd	ed
<   edd„¦   «         Zdd„Z	dd„Z
ed„ ¦   «         Zdd„ZdS )ÚJMAPCalendarObjectuq  Thin wrapper around a raw JSCalendar CalendarEvent dict.

    Stores the server's JSON response as-is.  No JMAP field names are mapped
    to typed attributes â€” callers work with the dict directly via
    :meth:`get_data`, or convert to iCalendar via :meth:`get_icalendar_instance`.

    Attributes:
        data: Raw JSCalendar CalendarEvent dict as returned by ``CalendarEvent/get``.
        parent: The :class:`~caldav.jmap.objects.calendar.JMAPCalendar` this object
            belongs to, or ``None`` when fetched without a calendar context
            (e.g. via :meth:`~caldav.jmap.client.JMAPClient.get_event`).
    ÚdictÚdatazJMAPCalendar | NoneÚparentNF)ÚdefaultÚinitÚreprÚcomparezicalendar.Calendar | NoneÚ_ical_cacheÚreturnÚstrc                ó   — | j         d         S )zServer-assigned JMAP event ID.Úid©r   ©Úselfs    ú^/root/projects/butler/venv/lib/python3.11/site-packages/caldav/jmap/objects/calendar_object.pyr   zJMAPCalendarObject.id/   s   € ð Œy˜ŒÐó    c                ó   — | j         S )zDReturn the raw JSCalendar dict as returned by ``CalendarEvent/get``.r   r   s    r   Úget_datazJMAPCalendarObject.get_data4   s
   € àŒyÐr   úicalendar.Calendarc                óŠ   — | j         €6t          j                             t	          | j        ¦  «        ¦  «        | _         | j         S )zâReturn an :class:`icalendar.Calendar` for this object.

        The result is cached after the first conversion.  Treat it as
        read-only; use :meth:`edit_icalendar_instance` to make and persist
        changes.
        )r   Ú	icalendarÚCalendarÚ	from_icalr   r   r   s    r   Úget_icalendar_instancez)JMAPCalendarObject.get_icalendar_instance8   s9   € ð ÔÐ#Ý(Ô1×;Ò;½MÈ$Ì)Ñ<TÔ<TÑUÔUˆDÔØÔÐr   c              #  ó:   K  — |                       ¦   «         }|V — dS )aõ  Borrow an editable :class:`icalendar.Calendar` for this object.

        Yields the cached :class:`icalendar.Calendar` for in-place editing.
        Call :meth:`save` after the ``with`` block to persist changes to the server.

        Note: :meth:`save` is sync-only.  Async-backed calendars cannot use
        this path yet.

        Example::

            with obj.edit_icalendar_instance() as cal:
                cal.subcomponents[0]["SUMMARY"] = vText("New title")
            obj.save()
        N)r%   )r   Úcals     r   Úedit_icalendar_instancez*JMAPCalendarObject.edit_icalendar_instanceC   s&   è è € ð  ×)Ò)Ñ+Ô+ˆØˆ	ˆ	ˆ	ˆ	ˆ	r   ÚNonec                óB  — | j         €t          dd¬¦  «        ‚| j         j        rt          d¦  «        ‚| j        +| j                             ¦   «                              ¦   «         nt          | j        ¦  «        }| j         j	         
                    | j        |¦  «         dS )a“  Persist changes made via :meth:`edit_icalendar_instance` to the server.

        Serialises the (possibly edited) icalendar object back to an iCalendar
        string and calls ``update_event()`` on the parent calendar's client.

        Raises:
            JMAPMethodError: If no parent calendar is set (``parent`` is ``None``).
            RuntimeError: If called on an async-backed calendar.
        NzN/Az&Cannot save: no parent calendar is set)ÚurlÚreasonzesave() is not supported for async-backed calendars. Use await parent._client.update_event() directly.)r   r	   Ú	_is_asyncÚRuntimeErrorr   Úto_icalÚdecoder   r   Ú_clientÚupdate_eventr   )r   Úical_strs     r   ÚsavezJMAPCalendarObject.saveV   sª   € ð Œ;ÐÝ! eÐ4\Ð]Ñ]Ô]Ð]ØŒ;Ô ð 	ÝðDñô ð ð ÔÐ+ð Ô×$Ò$Ñ&Ô&×-Ò-Ñ/Ô/Ð/å˜tœyÑ)Ô)ð 	ð
 	ŒÔ×(Ò(¨¬°(Ñ;Ô;Ð;Ð;Ð;r   )r   r   )r   r   )r   r    )r   r)   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   Úpropertyr   r   r%   r   r(   r4   © r   r   r   r      sá   € € € € € € ðð ð €J€JJØÐÐÑà-2¨UØ˜5 u°eð.ñ .ô .€Kð ð ð ñ ð ðð ð ñ „Xððð ð ð ð	 ð 	 ð 	 ð 	 ð ðð ñ „^ðð$<ð <ð <ð <ð <ð <r   r   )r8   Ú
__future__r   Ú
contextlibr   Údataclassesr   r   Útypingr   r"   Úcaldav.jmap.convertr   Úcaldav.jmap.errorr	   Úcaldav.jmap.objects.calendarr
   r   r;   r   r   ú<module>rC      sñ   ððð ð #Ð "Ð "Ð "Ð "Ð "à %Ð %Ð %Ð %Ð %Ð %Ø (Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ø  Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð à -Ð -Ð -Ð -Ð -Ð -Ø -Ð -Ð -Ð -Ð -Ð -àð :Ø9Ð9Ð9Ð9Ð9Ð9ð ðR<ð R<ð R<ð R<ð R<ñ R<ô R<ñ „ðR<ð R<ð R<r   