
    {i                       % S r SSKJr  SSKJrJr  SSKJr  SSK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  \	(       a  SSKr\" SSS9rS\S'    " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r  " S  S!\5      r! " S" S#\5      r" " S$ S\5      r# " S% S&\5      r$ " S' S(\#\5      r% " S) S*\#5      r& " S+ S,\#\5      r' " S- S.\#5      r( " S/ S0\#5      r) " S1 S2\#\5      r* " S3 S4\#\5      r+ " S5 S6\#\5      r, " S7 S8\#\5      r- " S9 S:\#\5      r. " S; S<\#5      r/ " S= S>5      r0 " S? S@5      r1g)Az#Provide classes related to widgets.    )annotations)JSONEncoderdumps)Path)TYPE_CHECKINGAnyTypeVar   )API_PATH)_deprecate_args)cachedproperty   )PRAWBase)BaseListN
WidgetTypeWidget)boundr	   c                      \ rS rSrSrSrg)Button   a  Class to represent a single button inside a :class:`.ButtonWidget`.

.. include:: ../../typical_attributes.rst

============== =====================================================================
Attribute      Description
============== =====================================================================
``color``      The hex color used to outline the button.
``fillColor``  The hex color for the background of the button.
``height``     Image height. Only present on image buttons.
``hoverState`` A ``dict`` describing the state of the button when hovered over.
               Optional.
``kind``       Either ``"text"`` or ``"image"``.
``linkUrl``    A link that can be visited by clicking the button. Only present on
               image buttons.
``text``       The text displayed on the button.
``textColor``  The hex color for the text of the button.
``url``        - If the button is a text button, a link that can be visited by
                 clicking the button.
               - If the button is an image button, the URL of a Reddit-hosted image.
``width``      Image width. Only present on image buttons.
============== =====================================================================

 N__name__
__module____qualname____firstlineno____doc____static_attributes__r       T/home/james-whalen/.local/lib/python3.13/site-packages/praw/models/reddit/widgets.pyr   r      s    r   r   c                      \ rS rSrSrSrg)CalendarConfiguration0   a  Class to represent the configuration of a :class:`.Calendar`.

.. include:: ../../typical_attributes.rst

=================== ================================================
Attribute           Description
=================== ================================================
``numEvents``       The number of events to display on the calendar.
``showDate``        Whether to show the dates of events.
``showDescription`` Whether to show the descriptions of events.
``showLocation``    Whether to show the locations of events.
``showTime``        Whether to show the times of events.
``showTitle``       Whether to show the titles of events.
=================== ================================================

r   Nr   r   r   r    r"   r"   0   s    r   r"   c                      \ rS rSrSrSrg)HoverC   aD  Class to represent the hover data for a :class:`.ButtonWidget`.

These values will take effect when the button is hovered over (the user moves their
cursor so it's on top of the button).

.. include:: ../../typical_attributes.rst

============= =====================================================================
Attribute     Description
============= =====================================================================
``color``     The hex color used to outline the button.
``fillColor`` The hex color for the background of the button.
``textColor`` The hex color for the text of the button.
``height``    Image height. Only present on image buttons.
``kind``      Either ``text`` or ``image``.
``text``      The text displayed on the button.
``url``       - If the button is a text button, a link that can be visited by
                clicking the button.
              - If the button is an image button, the URL of a Reddit-hosted image.
``width``     Image width. Only present on image buttons.
============= =====================================================================

r   Nr   r   r   r    r%   r%   C   s    r   r%   c                      \ rS rSrSrSrg)Image]   a  Class to represent an image that's part of a :class:`.ImageWidget`.

.. include:: ../../typical_attributes.rst

=========== =================================================
Attribute   Description
=========== =================================================
``height``  Image height.
``linkUrl`` A link that can be visited by clicking the image.
``url``     The URL of the (Reddit-hosted) image.
``width``   Image width.
=========== =================================================

r   Nr   r   r   r    r(   r(   ]       r   r(   c                      \ rS rSrSrSrg)	ImageDatan   a  Class for image data that's part of a :class:`.CustomWidget`.

.. include:: ../../typical_attributes.rst

========== =========================================
Attribute  Description
========== =========================================
``height`` The image height.
``name``   The image name.
``url``    The URL of the image on Reddit's servers.
``width``  The image width.
========== =========================================

r   Nr   r   r   r    r,   r,   n   r*   r   r,   c                      \ rS rSrSrSrg)MenuLink   as  Class to represent a single link inside a :class:`.Menu` or :class:`.Submenu`.

.. include:: ../../typical_attributes.rst

========= ====================================
Attribute Description
========= ====================================
``text``  The text of the menu link.
``url``   The URL that the menu item links to.
========= ====================================

r   Nr   r   r   r    r/   r/      s    r   r/   c                      \ rS rSrSrSrg)Styles   aH  Class to represent the style information of a widget.

.. include:: ../../typical_attributes.rst

=================== ========================================================
Attribute           Description
=================== ========================================================
``backgroundColor`` The background color of a widget, given as a hexadecimal
                    (``0x######``).
``headerColor``     The header color of a widget, given as a hexadecimal
                    (``0x######``).
=================== ========================================================

r   Nr   r   r   r    r2   r2      r*   r   r2   c                      \ rS rSrSrSrSrg)Submenu   af  Class to represent a submenu of links inside a :class:`.Menu`.

.. include:: ../../typical_attributes.rst

============ ======================================================================
Attribute    Description
============ ======================================================================
``children`` A list of the :class:`.MenuLink`\ s in this submenu. Can be iterated
             over by iterating over the :class:`.Submenu` (e.g., ``for menu_link in
             submenu``).
``text``     The name of the submenu.
============ ======================================================================

childrenr   Nr   r   r   r   r   CHILD_ATTRIBUTEr   r   r   r    r5   r5      s     !Or   r5   c                     ^  \ rS rSrSr\SS j5       r\SS j5       r\SS j5       r\SS j5       r	\SS j5       r
\SS j5       rSS	 jrSU 4S
 jjrSS jrU 4S jrS rSrU =r$ )SubredditWidgets   a  Class to represent a :class:`.Subreddit`'s widgets.

Create an instance like so:

.. code-block:: python

    widgets = reddit.subreddit("test").widgets

Data will be lazy-loaded. By default, PRAW will not request progressively loading
images from Reddit. To enable this, instantiate a :class:`.SubredditWidgets` object
via :meth:`~.Subreddit.widgets`, then set the attribute ``progressive_images`` to
``True`` before performing any action that would result in a network request.

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    widgets.progressive_images = True
    for widget in widgets.sidebar:
        # do something
        ...

Access a :class:`.Subreddit`'s widgets with the following attributes:

.. code-block:: python

    print(widgets.id_card)
    print(widgets.moderators_widget)
    print(widgets.sidebar)
    print(widgets.topbar)

The attribute :attr:`.id_card` contains the :class:`.Subreddit`'s ID card, which
displays information like the number of subscribers.

The attribute :attr:`.moderators_widget` contains the :class:`.Subreddit`'s
moderators widget, which lists the moderators of the subreddit.

The attribute :attr:`.sidebar` contains a list of widgets which make up the sidebar
of the subreddit.

The attribute :attr:`.topbar` contains a list of widgets which make up the top bar
of the subreddit.

To edit a :class:`.Subreddit`'s widgets, use :attr:`~.SubredditWidgets.mod`. For
example:

.. code-block:: python

    widgets.mod.add_text_area(
        short_name="My title",
        text="**bold text**",
        styles={"backgroundColor": "#FFFF66", "headerColor": "#3333EE"},
    )

For more information, see :class:`.SubredditWidgetsModeration`.

To edit a particular widget, use ``.mod`` on the widget. For example:

.. code-block:: python

    for widget in widgets.sidebar:
        widget.mod.update(shortName="Exciting new name")

For more information, see :class:`.WidgetModeration`.

**Currently available widgets**:

- :class:`.ButtonWidget`
- :class:`.Calendar`
- :class:`.CommunityList`
- :class:`.CustomWidget`
- :class:`.IDCard`
- :class:`.ImageWidget`
- :class:`.Menu`
- :class:`.ModeratorsWidget`
- :class:`.PostFlairWidget`
- :class:`.RulesWidget`
- :class:`.TextArea`

c                :    U R                   U R                  S      $ )z7Get this :class:`.Subreddit`'s :class:`.IDCard` widget.idCardWidgetitemslayoutselfs    r    id_cardSubredditWidgets.id_card  s     zz$++n566r   c                    0 nU R                   R                  5        H;  u  p#U R                  US'   U R                  R                  R                  U5      X'   M=     U$ )zCGet this :class:`.Subreddit`'s widgets as a dict from ID to widget.	subreddit)
_raw_itemsr@   rG   _reddit	_objector	objectify)rC   r@   	item_namedatas       r    r@   SubredditWidgets.items  sT     #446OI $D#||55??EE  7 r   c                B    [        U R                  U R                  5      $ )a  Get an instance of :class:`.SubredditWidgetsModeration`.

.. note::

    Using any of the methods of :class:`.SubredditWidgetsModeration` will likely
    result in the data of this :class:`.SubredditWidgets` being outdated. To
    re-sync, call :meth:`.refresh`.

)SubredditWidgetsModerationrG   rI   rB   s    r    modSubredditWidgets.mod  s     *$..$,,GGr   c                :    U R                   U R                  S      $ )z:Get this :class:`.Subreddit`'s :class:`.ModeratorsWidget`.moderatorWidgetr?   rB   s    r    moderators_widget"SubredditWidgets.moderators_widget  s     zz$++&7899r   c                j    U R                   S   S    Vs/ s H  oR                  U   PM     sn$ s  snf )z;Get a list of :class:`.Widget`\ s that make up the sidebar.sidebarorderrA   r@   rC   widget_names     r    rX   SubredditWidgets.sidebar#  s;     8<{{97Mg7V
7VJJ{#7V
 	
 
   0c                j    U R                   S   S    Vs/ s H  oR                  U   PM     sn$ s  snf )z;Get a list of :class:`.Widget`\ s that make up the top bar.topbarrY   rZ   r[   s     r    r`   SubredditWidgets.topbar*  s;     8<{{87LW7U
7UJJ{#7U
 	
 
r^   c                    UR                  S5      (       d,  U R                  (       d  U R                  5         [        X5      $ U R                  R
                  < SU< 3n[        U5      e)zReturn the value of ``attr``._z object has no attribute )
startswith_fetched_fetchgetattr	__class__r   AttributeError)rC   attrmsgs      r    __getattr__SubredditWidgets.__getattr__1  sR    s##DMMKKM4&&((++DTHMS!!r   c                p   > SU l         SU l        Xl        SU l        [        TU ]  UR                  0 5        g)zuInitialize a :class:`.SubredditWidgets` instance.

:param subreddit: The :class:`.Subreddit` the widgets belong to.

NF)rH   re   rG   progressive_imagessuper__init__rI   )rC   rG   rh   s     r    rq   SubredditWidgets.__init__9  s5     ""'**B/r   c                $    SU R                   < S3$ )z?Return an object initialization representation of the instance.zSubredditWidgets(subreddit=)rG   rB   s    r    __repr__SubredditWidgets.__repr__F  s    ,T^^,>a@@r   c                h  > U R                   R                  [        S   R                  U R                  S9SU R
                  0S9nUR                  S5      U l        [        TU ]%  U R                  R                   U5        / SQnU R                  R                  nU H  nU" US 5        M     SU l        g )Nwidgetsru   ro   )paramsr@   )rD   rU   rX   r`   r@   T)rI   getr   formatrG   ro   poprH   rp   rq   __dict__re   )rC   rM   cached_property_namesinst_dict_popnamerh   s        r    rf   SubredditWidgets._fetchJ  s    ||Y&&&@($*A*AB   

 ((7+//6!
 )))D$% * r   c                $    U R                  5         g)ab  Refresh the :class:`.Subreddit`'s widgets.

By default, PRAW will not request progressively loading images from Reddit. To
enable this, set the attribute ``progressive_images`` to ``True`` prior to
calling ``refresh()``.

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    widgets.progressive_images = True
    widgets.refresh()

N)rf   rB   s    r    refreshSubredditWidgets.refresh`  s     	r   )re   rH   ro   rG   )returnzpraw.models.IDCard)r   zdict[str, praw.models.Widget])r   z&praw.models.SubredditWidgetsModeration)r   zpraw.models.ModeratorsWidget)r   zlist[praw.models.Widget])r   zlist[praw.models.Menu])rj   strr   r   )rG   praw.models.Subreddit)r   r   )r   r   r   r   r   r   rD   r@   rQ   rU   rX   r`   rl   rq   rv   rf   r   r   __classcell__rh   s   @r    r;   r;      s    N` 7 7   
H 
H : : 
 
 
 
"0A, r   r;   c                  N   ^  \ rS rSrSr\SS j5       rSS jrS	U 4S jjrSr	U =r
$ )
r   iq  z+Base class to represent a :class:`.Widget`.c                B    [        X R                  U R                  5      $ )a*  Get an instance of :class:`.WidgetModeration` for this widget.

.. note::

    Using any of the methods of :class:`.WidgetModeration` will likely make the
    data in the :class:`.SubredditWidgets` that this widget belongs to outdated.
    To remedy this, call :meth:`~.SubredditWidgets.refresh`.

)WidgetModerationrG   rI   rB   s    r    rQ   
Widget.modt  s      nndllCCr   c                    [        U[        5      (       a5  U R                  R                  5       UR                  R                  5       :H  $ [	        U5      R                  5       U R                  R                  5       :H  $ )z&Check equality against another object.)
isinstancer   idlowerr   )rC   others     r    __eq__Widget.__eq__  sQ    eV$$77==?ehhnn&6665z!TWW]]_44r   c                J   > SU l         SU l        [        TU ]  XS9  SU l        g)z'Initialize a :class:`.Widget` instance. _dataN)rG   r   rp   rq   _modrC   redditr   rh   s      r    rq   Widget.__init__  s(    -	r   )r   r   rG   )r   zpraw.models.WidgetModeration)r   objectr   boolr   praw.Redditr   dict[str, Any])r   r   r   r   r   r   rQ   r   rq   r   r   r   s   @r    r   r   q  s)    5
D 
D5 r   c                  "    \ rS rSrSrSS jrSrg)WidgetEncoderi  z'Class to encode widget-related objects.c                :   [        XR                  5      (       a  [        U5      $ [        U[        5      (       aF  [	        U5      R                  5        VVs0 s H  u  p#UR                  S5      (       a  M  X#_M!     snn$ [        R                  " X5      $ s  snnf )zSerialize ``PRAWBase`` objects.rc   )	r   _subreddit_classr   r   varsr@   rd   r   default)rC   okeyvals       r    r   WidgetEncoder.default  sq    a..//q6Ma""-1!W]]_X_CNNSVDWHCH_XX""4++ Ys   B7Br   N)r   r   r   r   )r   r   r   r   r   r   r   r   r   r    r   r     s
    1,r   r   c                      \ rS rSrSrSrSrg)ButtonWidgeti  a
  Class to represent a widget containing one or more buttons.

Find an existing one:

.. code-block:: python

    button_widget = None
    widgets = reddit.subreddit("test").widgets
    for widget in widgets.sidebar:
        if isinstance(widget, praw.models.ButtonWidget):
            button_widget = widget
            break

    for button in button_widget:
        print(button.text, button.url)

Create one:

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    buttons = [
        {
            "kind": "text",
            "text": "View source",
            "url": "https://github.com/praw-dev/praw",
            "color": "#FF0000",
            "textColor": "#00FF00",
            "fillColor": "#0000FF",
            "hoverState": {
                "kind": "text",
                "text": "ecruos weiV",
                "color": "#000000",
                "textColor": "#FFFFFF",
                "fillColor": "#0000FF",
            },
        },
        {
            "kind": "text",
            "text": "View documentation",
            "url": "https://praw.readthedocs.io",
            "color": "#FFFFFF",
            "textColor": "#FFFF00",
            "fillColor": "#0000FF",
        },
    ]
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    button_widget = widgets.mod.add_button_widget(
        "Things to click", "Click some of these *cool* links!", buttons, styles
    )

For more information on creation, see :meth:`.add_button_widget`.

Update one:

.. code-block:: python

    new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
    button_widget = button_widget.mod.update(shortName="My fav buttons", styles=new_styles)

Delete one:

.. code-block:: python

    button_widget.mod.delete()

.. include:: ../../typical_attributes.rst

==================== ==============================================================
Attribute            Description
==================== ==============================================================
``buttons``          A list of :class:`.Button`\ s. These can also be accessed just
                     by iterating over the :class:`.ButtonWidget` (e.g., ``for
                     button in button_widget``).
``description``      The description, in Markdown.
``description_html`` The description, in HTML.
``id``               The widget ID.
``kind``             The widget kind (always ``"button"``).
``shortName``        The short name of the widget.
``styles``           A ``dict`` with the keys ``"backgroundColor"`` and
                     ``"headerColor"``.
``subreddit``        The :class:`.Subreddit` the button widget belongs to.
==================== ==============================================================

buttonsr   Nr8   r   r   r    r   r     s    Tl  Or   r   c                      \ rS rSrSrSrg)Calendari  a<  Class to represent a calendar widget.

Find an existing one:

.. code-block:: python

    calendar = None
    widgets = reddit.subreddit("test").widgets
    for widget in widgets.sidebar:
        if isinstance(widget, praw.models.Calendar):
            calendar = widget
            break

    print(calendar.googleCalendarId)

Create one:

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    config = {
        "numEvents": 10,
        "showDate": True,
        "showDescription": False,
        "showLocation": False,
        "showTime": True,
        "showTitle": True,
    }
    cal_id = "y6nm89jy427drk8l71w75w9wjn@group.calendar.google.com"
    calendar = widgets.mod.add_calendar(
        short_name="Upcoming Events",
        google_calendar_id=cal_id,
        requires_sync=True,
        configuration=config,
        styles=styles,
    )

For more information on creation, see :meth:`.add_calendar`.

Update one:

.. code-block:: python

    new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
    calendar = calendar.mod.update(shortName="My fav events", styles=new_styles)

Delete one:

.. code-block:: python

    calendar.mod.delete()

.. include:: ../../typical_attributes.rst

================= =====================================================
Attribute         Description
================= =====================================================
``configuration`` A ``dict`` describing the calendar configuration.
``data``          A list of dictionaries that represent events.
``id``            The widget ID.
``kind``          The widget kind (always ``"calendar"``).
``requiresSync``  A ``bool`` representing whether the calendar requires
                  synchronization.
``shortName``     The short name of the widget.
``styles``        A ``dict`` with the keys ``"backgroundColor"`` and
                  ``"headerColor"``.
``subreddit``     The :class:`.Subreddit` the button widget belongs to.
================= =====================================================

r   Nr   r   r   r    r   r     s    Fr   r   c                      \ rS rSrSrSrSrg)CommunityListi?  a\  Class to represent a Related Communities widget.

Find an existing one:

.. code-block:: python

    community_list = None
    widgets = reddit.subreddit("test").widgets
    for widget in widgets.sidebar:
        if isinstance(widget, praw.models.CommunityList):
            community_list = widget
            break

    print(community_list)

Create one:

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    subreddits = ["learnpython", reddit.subreddit("test")]
    community_list = widgets.mod.add_community_list(
        short_name="Related subreddits",
        data=subreddits,
        styles=styles,
        description="description",
    )

For more information on creation, see :meth:`.add_community_list`.

Update one:

.. code-block:: python

    new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
    community_list = community_list.mod.update(shortName="My fav subs", styles=new_styles)

Delete one:

.. code-block:: python

    community_list.mod.delete()

.. include:: ../../typical_attributes.rst

============= =====================================================================
Attribute     Description
============= =====================================================================
``data``      A list of :class:`.Subreddit`\ s. These can also be iterated over by
              iterating over the :class:`.CommunityList` (e.g., ``for sub in
              community_list``).
``id``        The widget ID.
``kind``      The widget kind (always ``"community-list"``).
``shortName`` The short name of the widget.
``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
``subreddit`` The :class:`.Subreddit` the button widget belongs to.
============= =====================================================================

rM   r   Nr8   r   r   r    r   r   ?  s    ;z Or   r   c                  0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )CustomWidgeti  a  Class to represent a custom widget.

Find an existing one:

.. code-block:: python

    custom = None
    widgets = reddit.subreddit("test").widgets
    for widget in widgets.sidebar:
        if isinstance(widget, praw.models.CustomWidget):
            custom = widget
            break

    print(custom.text)
    print(custom.css)

Create one:

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    custom = widgets.mod.add_custom_widget(
        short_name="My custom widget",
        text="# Hello world!",
        css="/**/",
        height=200,
        image_data=[],
        styles=styles,
    )

For more information on creation, see :meth:`.add_custom_widget`.

Update one:

.. code-block:: python

    new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
    custom = custom.mod.update(shortName="My fav customization", styles=new_styles)

Delete one:

.. code-block:: python

    custom.mod.delete()

.. include:: ../../typical_attributes.rst

================= ============================================================
Attribute         Description
================= ============================================================
``css``           The CSS of the widget, as a ``str``.
``height``        The height of the widget, as an ``int``.
``id``            The widget ID.
``imageData``     A ``list`` of :class:`.ImageData` that belong to the widget.
``kind``          The widget kind (always ``"custom"``).
``shortName``     The short name of the widget.
``styles``        A ``dict`` with the keys ``"backgroundColor"`` and
                  ``"headerColor"``.
``stylesheetUrl`` A link to the widget's stylesheet.
``subreddit``     The :class:`.Subreddit` the button widget belongs to.
``text``          The text contents, as Markdown.
``textHtml``      The text contents, as HTML.
================= ============================================================

c                   > UR                  S5       Vs/ s H  n[        X5      PM     snUS'   [        TU ]  XS9  gs  snf )z-Initialize a :class:`.CustomWidget` instance.	imageDatar   N)r}   r,   rp   rq   )rC   r   r   rM   rh   s       r    rq   CustomWidget.__init__  sI     16		+0F
0FIf#0F
k 	-
s   >r   r   )r   r   r   r   r   rq   r   r   r   s   @r    r   r     s    AF. .r   r   c                      \ rS rSrSrSrg)IDCardi  a  Class to represent an ID card widget.

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    id_card = widgets.id_card
    print(id_card.subscribersText)

Update one:

.. code-block:: python

    widgets.id_card.mod.update(currentlyViewingText="Bots")

.. include:: ../../typical_attributes.rst

========================= =======================================================
Attribute                 Description
========================= =======================================================
``currentlyViewingCount`` The number of redditors viewing the subreddit.
``currentlyViewingText``  The text displayed next to the view count. For example,
                          ``"users online"``.
``description``           The subreddit description.
``id``                    The widget ID.
``kind``                  The widget kind (always ``"id-card"``).
``shortName``             The short name of the widget.
``styles``                A ``dict`` with the keys ``"backgroundColor"`` and
                          ``"headerColor"``.
``subreddit``             The :class:`.Subreddit` the button widget belongs to.
``subscribersCount``      The number of subscribers to the subreddit.
``subscribersText``       The text displayed next to the subscriber count. For
                          example, "users subscribed".
========================= =======================================================

r   Nr   r   r   r    r   r     s    "r   r   c                      \ rS rSrSrSrSrg)ImageWidgeti  a  Class to represent an image widget.

Find an existing one:

.. code-block:: python

    image_widget = None
    widgets = reddit.subreddit("test").widgets
    for widget in widgets.sidebar:
        if isinstance(widget, praw.models.ImageWidget):
            image_widget = widget
            break

    for image in image_widget:
        print(image.url)

Create one:

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    image_paths = ["/path/to/image1.jpg", "/path/to/image2.png"]
    image_data = [
        {
            "width": 600,
            "height": 450,
            "linkUrl": "",
            "url": widgets.mod.upload_image(img_path),
        }
        for img_path in image_paths
    ]
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    image_widget = widgets.mod.add_image_widget(
        short_name="My cool pictures", data=image_data, styles=styles
    )

For more information on creation, see :meth:`.add_image_widget`.

Update one:

.. code-block:: python

    new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
    image_widget = image_widget.mod.update(shortName="My fav images", styles=new_styles)

Delete one:

.. code-block:: python

    image_widget.mod.delete()

.. include:: ../../typical_attributes.rst

============= =====================================================================
Attribute     Description
============= =====================================================================
``data``      A list of the :class:`.Image`\ s in this widget. Can be iterated over
              by iterating over the :class:`.ImageWidget` (e.g., ``for img in
              image_widget``).
``id``        The widget ID.
``kind``      The widget kind (always ``"image"``).
``shortName`` The short name of the widget.
``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
``subreddit`` The :class:`.Subreddit` the button widget belongs to.
============= =====================================================================

rM   r   Nr8   r   r   r    r   r     s    BH Or   r   c                      \ rS rSrSrSrSrg)Menui:  a4  Class to represent the top menu widget of a :class:`.Subreddit`.

Menus can generally be found as the first item in a :class:`.Subreddit`'s top bar.

.. code-block:: python

    topbar = reddit.subreddit("test").widgets.topbar
    if len(topbar) > 0:
        probably_menu = topbar[0]
        assert isinstance(probably_menu, praw.models.Menu)
        for item in probably_menu:
            if isinstance(item, praw.models.Submenu):
                print(item.text)
                for child in item:
                    print("\t", child.text, child.url)
            else:  # MenuLink
                print(item.text, item.url)

Create one:

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    menu_contents = [
        {"text": "My homepage", "url": "https://example.com"},
        {
            "text": "Python packages",
            "children": [
                {"text": "PRAW", "url": "https://praw.readthedocs.io/"},
                {"text": "requests", "url": "http://python-requests.org"},
            ],
        },
        {"text": "Reddit homepage", "url": "https://reddit.com"},
    ]
    menu = widgets.mod.add_menu(data=menu_contents)

For more information on creation, see :meth:`.add_menu`.

Update one:

.. code-block:: python

    menu_items = list(menu)
    menu_items.reverse()
    menu = menu.mod.update(data=menu_items)

Delete one:

.. code-block:: python

    menu.mod.delete()

.. include:: ../../typical_attributes.rst

============= ====================================================================
Attribute     Description
============= ====================================================================
``data``      A list of the :class:`.MenuLink`\ s and :class:`.Submenu`\ s in this
              widget. Can be iterated over by iterating over the :class:`.Menu`
              (e.g., ``for item in menu``).
``id``        The widget ID.
``kind``      The widget kind (always ``"menu"``).
``subreddit`` The :class:`.Subreddit` the button widget belongs to.
============= ====================================================================

rM   r   Nr8   r   r   r    r   r   :  s    AF Or   r   c                  4   ^  \ rS rSrSrSrSU 4S jjrSrU =r$ )ModeratorsWidgeti  a  Class to represent a moderators widget.

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    print(widgets.moderators_widget)

Update one:

.. code-block:: python

    new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
    widgets.moderators_widget.mod.update(styles=new_styles)

.. include:: ../../typical_attributes.rst

============= =====================================================================
Attribute     Description
============= =====================================================================
``id``        The widget ID.
``kind``      The widget kind (always ``"moderators"``).
``mods``      A list of the :class:`.Redditor`\ s that moderate the subreddit. Can
              be iterated over by iterating over the :class:`.ModeratorsWidget`
              (e.g., ``for mod in widgets.moderators_widget``).
``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
``subreddit`` The :class:`.Subreddit` the button widget belongs to.
``totalMods`` The total number of moderators in the subreddit.
============= =====================================================================

modsc                \   > U R                   U;  a  / X R                   '   [        TU ]	  XS9  g)z1Initialize a :class:`.ModeratorsWidget` instance.r   Nr9   rp   rq   r   s      r    rq   ModeratorsWidget.__init__  /    u,*,E&&'-r   r   r   	r   r   r   r   r   r9   rq   r   r   r   s   @r    r   r     s    > O. .r   r   c                      \ rS rSrSrSrSrg)PostFlairWidgeti  a2  Class to represent a post flair widget.

Find an existing one:

.. code-block:: python

    post_flair_widget = None
    widgets = reddit.subreddit("test").widgets
    for widget in widgets.sidebar:
        if isinstance(widget, praw.models.PostFlairWidget):
            post_flair_widget = widget
            break

    for flair in post_flair_widget:
        print(flair)
        print(post_flair_widget.templates[flair])

Create one:

.. code-block:: python

    subreddit = reddit.subreddit("test")
    widgets = subreddit.widgets
    flairs = [f["id"] for f in subreddit.flair.link_templates]
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    post_flair = widgets.mod.add_post_flair_widget(
        short_name="Some flairs", display="list", order=flairs, styles=styles
    )

For more information on creation, see :meth:`.add_post_flair_widget`.

Update one:

.. code-block:: python

    new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
    post_flair = post_flair.mod.update(shortName="My fav flairs", styles=new_styles)

Delete one:

.. code-block:: python

    post_flair.mod.delete()

.. include:: ../../typical_attributes.rst

============= =====================================================================
Attribute     Description
============= =====================================================================
``display``   The display style of the widget, either ``"cloud"`` or ``"list"``.
``id``        The widget ID.
``kind``      The widget kind (always ``"post-flair"``).
``order``     A list of the flair IDs in this widget. Can be iterated over by
              iterating over the :class:`.PostFlairWidget` (e.g., ``for flair_id in
              post_flair``).
``shortName`` The short name of the widget.
``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
``subreddit`` The :class:`.Subreddit` the button widget belongs to.
``templates`` A ``dict`` that maps flair IDs to dictionaries that describe flairs.
============= =====================================================================

rY   r   Nr8   r   r   r    r   r     s    =~ Or   r   c                  4   ^  \ rS rSrSrSrSU 4S jjrSrU =r$ )RulesWidgeti  an  Class to represent a rules widget.

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    rules_widget = None
    for widget in widgets.sidebar:
        if isinstance(widget, praw.models.RulesWidget):
            rules_widget = widget
            break
    from pprint import pprint

    pprint(rules_widget.data)

Update one:

.. code-block:: python

    new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
    rules_widget.mod.update(display="compact", shortName="The LAWS", styles=new_styles)

.. include:: ../../typical_attributes.rst

============= =====================================================================
Attribute     Description
============= =====================================================================
``data``      A list of the subreddit rules. Can be iterated over by iterating over
              the :class:`.RulesWidget` (e.g., ``for rule in rules_widget``).
``display``   The display style of the widget, either ``"full"`` or ``"compact"``.
``id``        The widget ID.
``kind``      The widget kind (always ``"subreddit-rules"``).
``shortName`` The short name of the widget.
``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
``subreddit`` The :class:`.Subreddit` the button widget belongs to.
============= =====================================================================

rM   c                \   > U R                   U;  a  / X R                   '   [        TU ]	  XS9  g)z,Initialize a :class:`.RulesWidget` instance.r   Nr   r   s      r    rq   RulesWidget.__init__  r   r   r   r   r   r   s   @r    r   r     s    $L O. .r   r   c                      \ rS rSrSrSrg)TextAreai  aV  Class to represent a text area widget.

Find a text area in a subreddit:

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    text_area = None
    for widget in widgets.sidebar:
        if isinstance(widget, praw.models.TextArea):
            text_area = widget
            break
    print(text_area.text)

Create one:

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    text_area = widgets.mod.add_text_area(
        short_name="My cool title", text="*Hello* **world**!", styles=styles
    )

For more information on creation, see :meth:`.add_text_area`.

Update one:

.. code-block:: python

    new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
    text_area = text_area.mod.update(shortName="My fav text", styles=new_styles)

Delete one:

.. code-block:: python

    text_area.mod.delete()

.. include:: ../../typical_attributes.rst

============= =====================================================================
Attribute     Description
============= =====================================================================
``id``        The widget ID.
``kind``      The widget kind (always ``"textarea"``).
``shortName`` The short name of the widget.
``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
``subreddit`` The :class:`.Subreddit` the button widget belongs to.
``text``      The widget's text, as Markdown.
``textHtml``  The widget's text, as HTML.
============= =====================================================================

r   Nr   r   r   r    r   r     s    5r   r   c                  >    \ rS rSrSr      SS jrS rS	S jrSrg)
r   iX  zClass for moderating a particular widget.

Example usage:

.. code-block:: python

    widget = reddit.subreddit("test").widgets.sidebar[0]
    widget.mod.update(shortName="My new title")
    widget.mod.delete()

c                (    Xl         X0l        X l        g)z1Initialize a :class:`.WidgetModeration` instance.N)widgetrI   
_subreddit)rC   r   rG   r   s       r    rq   WidgetModeration.__init__e  s     #r   c                    [         S   R                  U R                  R                  U R                  S9nU R
                  R                  U5        g)zUDelete the widget.

Example usage:

.. code-block:: python

    widget.mod.delete()

widget_modify	widget_idrG   N)r   r|   r   r   r   rI   delete)rC   paths     r    r   WidgetModeration.deletep  sC     (//kknn 0 
 	D!r   c           	        [         S   R                  U R                  R                  U R                  S9n[        U R                  5      R                  5        VVs0 s H  u  p4UR                  S5      (       a  M  X4_M!     nnnUS	 SU;   a  US	 UR                  U5        U R                  R                  US[        U[        S90S9nU R                  Ul        U$ s  snnf )	a'  Update the widget. Returns the updated widget.

Parameters differ based on the type of widget. See `Reddit documentation
<https://www.reddit.com/dev/api#PUT_api_widget_{widget_id}>`_ or the document of
the particular type of widget.

:returns: The updated :class:`.Widget`.

For example, update a text widget like so:

.. code-block:: python

    text_widget.mod.update(shortName="New text area", text="Hello!")

.. note::

    Most parameters follow the ``lowerCamelCase`` convention. When in doubt,
    check the Reddit documentation linked above.

r   r   rc   rG   rQ   jsonclsrM   )r   r|   r   r   r   r   r@   rd   updaterI   putr   r   rG   )rC   kwargsr   r   valuepayloadr   s          r    r   WidgetModeration.update  s    * (//kknn 0 

 #4;;/557
7
>>#& CJ7 	 

 K Gv!!g= AB " 
  ??
s   C<C)rI   r   r   N)r   r   rG   zpraw.models.Subreddit | strr   r   )r   r   r   r   )	r   r   r   r   r   rq   r   r   r   r   r   r    r   r   X  s2    
	$	$ /	$ 		$"%r   r   c                  J   \ rS rSrSrS%S jrS&S jr\" SSSS5                  S'S	 j5       r\" SS
SSS5                    S(S j5       r	\" SSSS5      SS.           S)S jj5       r
\" SSSSSS5                      S*S j5       r\" SSS5                S+S j5       r\" S5            S,S j5       r\" SSSS5                  S-S j5       r\" SSS5                S.S j5       r\" SS5      SS .S/S! jj5       rS0S" jrS#rg$)1rP   i  a  Class for moderating a :class:`.Subreddit`'s widgets.

Get an instance of this class from :attr:`.SubredditWidgets.mod`.

Example usage:

.. code-block:: python

    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    reddit.subreddit("test").widgets.mod.add_text_area(
        short_name="My title", text="**bold text**", styles=styles
    )

.. note::

    To use this class's methods, the authenticated user must be a moderator with
    appropriate permissions.

c                    Xl         X l        g)z;Initialize a :class:`.SubredditWidgetsModeration` instance.N)r   rI   )rC   rG   r   s      r    rq   #SubredditWidgetsModeration.__init__  s    #r   c           	         [         S   R                  U R                  S9nU R                  R	                  US[        U[        S90S9nU R                  Ul        U$ )Nwidget_createru   r   r   r   )r   r|   r   rI   postr   r   rG   )rC   r   r   r   s       r    _create_widget)SubredditWidgetsModeration._create_widget  s[    (//$///J""g= AB # 
  ??r   
short_namedescriptionr   stylesc               V    UUSUUS.nUR                  U5        U R                  U5      $ )a   Add and return a :class:`.ButtonWidget`.

:param buttons: A list of dictionaries describing buttons, as specified in
    `Reddit docs`_. As of this writing, the format is:

    Each button is either a text button or an image button. A text button looks
    like this:

    .. code-block:: text

        {
            "kind": "text",
            "text": a string no longer than 30 characters,
            "url": a valid URL,
            "color": a 6-digit rgb hex color, e.g., `#AABBCC`,
            "textColor": a 6-digit rgb hex color, e.g., `#AABBCC`,
            "fillColor": a 6-digit rgb hex color, e.g., `#AABBCC`,
            "hoverState": {...}
        }

    An image button looks like this:

    .. code-block:: text

        {
            "kind": "image",
            "text": a string no longer than 30 characters,
            "linkUrl": a valid URL,
            "url": a valid URL of a Reddit-hosted image,
            "height": an integer,
            "width": an integer,
            "hoverState": {...}
        }

    Both types of buttons have the field ``hoverState``. The field does not have
    to be included (it is optional). If it is included, it can be one of two
    types: ``"text"`` or ``"image"``. A text ``hoverState`` looks like this:

    .. code-block:: text

        {
            "kind": "text",
            "text": a string no longer than 30 characters,
            "color": a 6-digit rgb hex color, e.g., `#AABBCC`,
            "textColor": a 6-digit rgb hex color, e.g., `#AABBCC`,
            "fillColor": a 6-digit rgb hex color, e.g., `#AABBCC`
        }

    An image ``hoverState`` looks like this:

    .. code-block:: text

        {
            "kind": "image",
            "url": a valid URL of a Reddit-hosted image,
            "height": an integer,
            "width": an integer
        }

    .. note::

        The method :meth:`.upload_image` can be used to upload images to Reddit
        for a ``url`` field that holds a Reddit-hosted image.

    .. note::

        An image ``hoverState`` may be paired with a text widget, and a text
        ``hoverState`` may be paired with an image widget.

:param description: Markdown text to describe the widget.
:param short_name: A name for the widget, no longer than 30 characters.
:param styles: A dictionary with keys ``"backgroundColor"`` and
    ``"headerColor"``, and values of hex colors. For example,
    ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.

:returns: The created :class:`.ButtonWidget`.

.. _reddit docs: https://www.reddit.com/dev/api#POST_api_widget

Example usage:

.. code-block:: python

    widget_moderation = reddit.subreddit("test").widgets.mod
    my_image = widget_moderation.upload_image("/path/to/pic.jpg")
    buttons = [
        {
            "kind": "text",
            "text": "View source",
            "url": "https://github.com/praw-dev/praw",
            "color": "#FF0000",
            "textColor": "#00FF00",
            "fillColor": "#0000FF",
            "hoverState": {
                "kind": "text",
                "text": "ecruos weiV",
                "color": "#FFFFFF",
                "textColor": "#000000",
                "fillColor": "#0000FF",
            },
        },
        {
            "kind": "image",
            "text": "View documentation",
            "linkUrl": "https://praw.readthedocs.io",
            "url": my_image,
            "height": 200,
            "width": 200,
            "hoverState": {"kind": "image", "url": my_image, "height": 200, "width": 200},
        },
    ]
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    new_widget = widget_moderation.add_button_widget(
        short_name="Things to click",
        description="Click some of these *cool* links!",
        buttons=buttons,
        styles=styles,
    )

button)r   r   kind	shortNamer   r   r   )rC   r   r   r   r   other_settingsbutton_widgets          r    add_button_widget,SubredditWidgetsModeration.add_button_widget  s<    F &#
 	^,""=11r   google_calendar_idrequires_syncconfigurationc               X    UUUUUSS.nUR                  U5        U R                  U5      $ )a4  Add and return a :class:`.Calendar` widget.

:param configuration: A dictionary as specified in `Reddit docs`_. For example:

    .. code-block:: python

        {
            "numEvents": 10,
            "showDate": True,
            "showDescription": False,
            "showLocation": False,
            "showTime": True,
            "showTitle": True,
        }

:param google_calendar_id: An email-style calendar ID. To share a Google
    Calendar, make it public, then find the "Calendar ID".
:param requires_sync: Whether the calendar needs synchronization.
:param short_name: A name for the widget, no longer than 30 characters.
:param styles: A dictionary with keys ``"backgroundColor"`` and
    ``"headerColor"``, and values of hex colors. For example,
    ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.

:returns: The created :class:`.Calendar`.

.. _reddit docs: https://www.reddit.com/dev/api#POST_api_widget

Example usage:

.. code-block:: python

    widget_moderation = reddit.subreddit("test").widgets.mod
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    config = {
        "numEvents": 10,
        "showDate": True,
        "showDescription": False,
        "showLocation": False,
        "showTime": True,
        "showTitle": True,
    }
    calendar_id = "y6nm89jy427drk8l71w75w9wjn@group.calendar.google.com"
    new_widget = widget_moderation.add_calendar(
        short_name="Upcoming Events",
        google_calendar_id=calendar_id,
        requires_sync=True,
        configuration=config,
        styles=styles,
    )

calendar)r   googleCalendarIdrequiresSyncr   r   r   r   )rC   r   r   r   r   r   r   r   s           r    add_calendar'SubredditWidgetsModeration.add_calendarU  s=    B $ 2)*
 	'""8,,r   rM   r   )r   c               V    USUUUS.nUR                  U5        U R                  U5      $ )a  Add and return a :class:`.CommunityList` widget.

:param data: A list of subreddits. Subreddits can be represented as ``str`` or
    as :class:`.Subreddit`. These types may be mixed within the list.
:param description: A string containing Markdown (default: ``""``).
:param short_name: A name for the widget, no longer than 30 characters.
:param styles: A dictionary with keys ``"backgroundColor"`` and
    ``"headerColor"``, and values of hex colors. For example,
    ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.

:returns: The created :class:`.CommunityList`.

Example usage:

.. code-block:: python

    widget_moderation = reddit.subreddit("test").widgets.mod
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    subreddits = ["learnpython", reddit.subreddit("redditdev")]
    new_widget = widget_moderation.add_community_list(
        short_name="My fav subs", data=subreddits, styles=styles, description="description"
    )

zcommunity-list)rM   r   r   r   r   r   )rC   rM   r   r   r   r   community_lists          r    add_community_list-SubredditWidgetsModeration.add_community_list  s<    F $#&
 	n-"">22r   textcssheight
image_datac               Z    UUUSUUUS.nUR                  U5        U R                  U5      $ )a  Add and return a :class:`.CustomWidget`.

:param css: The CSS for the widget, no longer than 100000 characters.

    .. note::

        As of this writing, Reddit will not accept empty CSS. If you wish to
        create a custom widget without CSS, consider using ``"/**/"`` (an empty
        comment) as your CSS.

:param height: The height of the widget, between 50 and 500.
:param image_data: A list of dictionaries as specified in `Reddit docs`_. Each
    dictionary represents an image and has the key ``"url"`` which maps to the
    URL of an image hosted on Reddit's servers. Images should be uploaded using
    :meth:`.upload_image`.

    For example:

    .. code-block:: python

        [
            {
                "url": "https://some.link",  # from upload_image()
                "width": 600,
                "height": 450,
                "name": "logo",
            },
            {
                "url": "https://other.link",  # from upload_image()
                "width": 450,
                "height": 600,
                "name": "icon",
            },
        ]

:param short_name: A name for the widget, no longer than 30 characters.
:param styles: A dictionary with keys ``"backgroundColor"`` and
    ``"headerColor"``, and values of hex colors. For example,
    ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.
:param text: The Markdown text displayed in the widget.

:returns: The created :class:`.CustomWidget`.

.. _reddit docs: https://www.reddit.com/dev/api#POST_api_widget

Example usage:

.. code-block:: python

    widget_moderation = reddit.subreddit("test").widgets.mod
    image_paths = ["/path/to/image1.jpg", "/path/to/image2.png"]
    image_urls = [widget_moderation.upload_image(img_path) for img_path in image_paths]
    image_data = [
        {"width": 600, "height": 450, "name": "logo", "url": image_urls[0]},
        {"width": 450, "height": 600, "name": "icon", "url": image_urls[1]},
    ]
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    new_widget = widget_moderation.add_custom_widget(
        image_short_name="My widget",
        text="# Hello world!",
        css="/**/",
        height=200,
        image_data=image_data,
        styles=styles,
    )

custom)r  r	  r   r   r   r   r  r   )	rC   r  r	  r
  r   r   r  r   custom_widgets	            r    add_custom_widget,SubredditWidgetsModeration.add_custom_widget  sB    ` ##
 	^,""=11r   c               T    USUUS.nUR                  U5        U R                  U5      $ )a  Add and return an :class:`.ImageWidget`.

:param data: A list of dictionaries as specified in `Reddit docs`_. Each
    dictionary has the key ``"url"`` which maps to the URL of an image hosted on
    Reddit's servers. Images should be uploaded using :meth:`.upload_image`.

    For example:

    .. code-block:: python

        [
            {
                "url": "https://some.link",  # from upload_image()
                "width": 600,
                "height": 450,
                "linkUrl": "https://github.com/praw-dev/praw",
            },
            {
                "url": "https://other.link",  # from upload_image()
                "width": 450,
                "height": 600,
                "linkUrl": "https://praw.readthedocs.io",
            },
        ]

:param short_name: A name for the widget, no longer than 30 characters.
:param styles: A dictionary with keys ``"backgroundColor"`` and
    ``"headerColor"``, and values of hex colors. For example,
    ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.

:returns: The created :class:`.ImageWidget`.

.. _reddit docs: https://www.reddit.com/dev/api#POST_api_widget

Example usage:

.. code-block:: python

    widget_moderation = reddit.subreddit("test").widgets.mod
    image_paths = ["/path/to/image1.jpg", "/path/to/image2.png"]
    image_data = [
        {
            "width": 600,
            "height": 450,
            "linkUrl": "",
            "url": widget_moderation.upload_image(img_path),
        }
        for img_path in image_paths
    ]
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    new_widget = widget_moderation.add_image_widget(
        short_name="My cool pictures", data=image_data, styles=styles
    )

image)rM   r   r   r   r   )rC   rM   r   r   r   image_widgets         r    add_image_widget+SubredditWidgetsModeration.add_image_widget'  s9    B #	
 	N+""<00r   c               P    USS.nUR                  U5        U R                  U5      $ )ao  Add and return a :class:`.Menu` widget.

:param data: A list of dictionaries describing menu contents, as specified in
    `Reddit docs`_. As of this writing, the format is:

    .. code-block:: text

        [
            {
                "text": a string no longer than 20 characters,
                "url": a valid URL
            },

            OR

            {
                "children": [
                    {
                        "text": a string no longer than 20 characters,
                        "url": a valid URL,
                    },
                    ...
                ],
                "text": a string no longer than 20 characters,
            },
            ...
        ]


:returns: The created :class:`.Menu`.

.. _reddit docs: https://www.reddit.com/dev/api#POST_api_widget

Example usage:

.. code-block:: python

    widget_moderation = reddit.subreddit("test").widgets.mod
    menu_contents = [
        {"text": "My homepage", "url": "https://example.com"},
        {
            "text": "Python packages",
            "children": [
                {"text": "PRAW", "url": "https://praw.readthedocs.io/"},
                {"text": "requests", "url": "https://docs.python-requests.org/"},
            ],
        },
        {"text": "Reddit homepage", "url": "https://reddit.com"},
    ]
    new_widget = widget_moderation.add_menu(data=menu_contents)

menu)rM   r   r   )rC   rM   r   r  s       r    add_menu#SubredditWidgetsModeration.add_menup  s,    v f-N#""4((r   displayrY   c               V    SUUUUS.nUR                  U5        U R                  U5      $ )a  Add and return a :class:`.PostFlairWidget`.

:param display: Display style. Either ``"cloud"`` or ``"list"``.
:param order: A list of flair template IDs. You can get all flair template IDs
    in a subreddit with:

    .. code-block:: python

        flairs = [f["id"] for f in subreddit.flair.link_templates]

:param short_name: A name for the widget, no longer than 30 characters.
:param styles: A dictionary with keys ``"backgroundColor"`` and
    ``"headerColor"``, and values of hex colors. For example,
    ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.

:returns: The created :class:`.PostFlairWidget`.

Example usage:

.. code-block:: python

    subreddit = reddit.subreddit("test")
    widget_moderation = subreddit.widgets.mod
    flairs = [f["id"] for f in subreddit.flair.link_templates]
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    new_widget = widget_moderation.add_post_flair_widget(
        short_name="Some flairs", display="list", order=flairs, styles=styles
    )

z
post-flair)r   r  r   rY   r   r   )rC   r  rY   r   r   r   
post_flairs          r    add_post_flair_widget0SubredditWidgetsModeration.add_post_flair_widget  s<    R !#

 	.)"":..r   c               T    UUUSS.nUR                  U5        U R                  U5      $ )a  Add and return a :class:`.TextArea` widget.

:param short_name: A name for the widget, no longer than 30 characters.
:param styles: A dictionary with keys ``"backgroundColor"`` and
    ``"headerColor"``, and values of hex colors. For example,
    ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.
:param text: The Markdown text displayed in the widget.

:returns: The created :class:`.TextArea`.

Example usage:

.. code-block:: python

    widget_moderation = reddit.subreddit("test").widgets.mod
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    new_widget = widget_moderation.add_text_area(
        short_name="My cool title", text="*Hello* **world**!", styles=styles
    )

textarea)r   r  r   r   r   )rC   r   r   r  r   	text_areas         r    add_text_area(SubredditWidgetsModeration.add_text_area  s8    > $	
	 	(""9--r   	new_ordersectionrX   )r$  c                  U Vs/ s H/  n[        U[        5      (       a  UR                  O
[        U5      PM1     nn[        S   R                  U R                  US9nU R                  R                  U[        U5      US.S9  gs  snf )a  Reorder the widgets.

:param new_order: A list of widgets. Represented as a list that contains
    :class:`.Widget` objects, or widget IDs as strings. These types may be
    mixed.
:param section: The section to reorder (default: ``"sidebar"``).

Example usage:

.. code-block:: python

    widgets = reddit.subreddit("test").widgets
    order = list(widgets.sidebar)
    order.reverse()
    widgets.mod.reorder(order)

widget_order)rG   r$  )r   r$  r   N)
r   r   r   r   r   r|   r   rI   patchr   )rC   r#  r$  thingrY   r   s         r    reorder"SubredditWidgetsModeration.reorder  s    ( PY
OXe
5&11EHHs5zAy 	 
 '..oow / 
 	4uU|&PQ
s   6Bc                N   [        U5      nUR                  SS.nUR                  5       R                  S5      (       a  SUS'   [        S   R                  U R                  S9nU R                  R                  XCS9S	   nUS
    Vs0 s H  ofS   US   _M     nnSUS    3nUR                  S5       n	U R                  R                  R                  R                  R                  XSU	0S9n
SSS5        W
R                  5         U SUS    3$ s  snf ! , (       d  f       N-= f)a  Upload an image to Reddit and get the URL.

:param file_path: The path to the local file.

:returns: The URL of the uploaded image as a ``str``.

This method is used to upload images for widgets. For example, it can be used in
conjunction with :meth:`.add_image_widget`, :meth:`.add_custom_widget`, and
:meth:`.add_button_widget`.

Example usage:

.. code-block:: python

    my_sub = reddit.subreddit("test")
    image_url = my_sub.widgets.mod.upload_image("/path/to/image.jpg")
    image_data = [{"width": 300, "height": 300, "url": image_url, "linkUrl": ""}]
    styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
    my_sub.widgets.mod.add_image_widget(
        short_name="My cool pictures", data=image_data, styles=styles
    )

z
image/jpeg)filepathmimetypez.pngz	image/pngr-  widget_leaseru   r   s3UploadLeasefieldsr   r   zhttps:actionrbfile)rM   filesN/r   )r   r   r   endswithr   r|   r   rI   r   open_core
_requestor_httpraise_for_status)rC   	file_pathr3  img_dataurlupload_leaseitemupload_data
upload_urlr  responses              r    upload_image'SubredditWidgetsModeration.upload_image#  s,   0 I		$
 ??%%f--#.HZ ~&---H||(((<_M?KH?UV?UtF|T']2?UVl8456
YYt_||))44::??VUO @ H  	!!#Q{51233 W _s   D4;D
D$)rI   r   N)rG   r   r   r   )r   r   r   r   )r   z1list[dict[str, dict[str, str | int] | str | int]]r   r   r   r   r   dict[str, str]r   r   r   zpraw.models.ButtonWidget)r   zdict[str, bool | int]r   r   r   r   r   r   r   rF  r   r   r   zpraw.models.Calendar)rM   z!list[str | praw.models.Subreddit]r   r   r   r   r   rF  r   r   r   zpraw.models.CommunityList)r  r   r	  intr
  list[dict[str, str | int]]r   r   r   rF  r  r   r   r   r   zpraw.models.CustomWidget)
rM   rH  r   r   r   rF  r   r   r   zpraw.models.ImageWidget)rM   z+list[dict[str, list[dict[str, str]] | str]]r   r   r   zpraw.models.Menu | Widget)r  r   rY   z	list[str]r   r   r   rF  r   r   r   z$praw.models.PostFlairWidget | Widget)
r   r   r   rF  r  r   r   r   r   zpraw.models.TextArea)r#  zlist[Widget | str]r$  r   )r<  r   r   r   )r   r   r   r   r   rq   r   r   r   r  r  r  r  r  r  r!  r)  rD  r   r   r   r    rP   rP     s.   (
 \=)XFI2 CI2 	I2
 I2 I2 I2 
"I2 GI2V *O_hF- -F-  	F-
 F- F- F- F- 
F-F-P \68]C
 	)3 0)3 	)3
 )3 )3 )3 
#)3 D)3V \65(L(SX2 X2 	X2
 /X2 X2 X2 X2 X2 
"X2 TX2t \684F1 )F1 	F1
 F1 F1 
!F1 5F1P V<) :<) 	<)
 
#<) <)| \9gx@// // 	//
 // // // 
.// A//b \684$. $. 	$.
 $. $. 
$. 5$.L [),GP R -R4,4r   rP   )2r   
__future__r   r   r   r   pathlibr   typingr   r   r	   constr   utilr   
util.cacher   baser   	list.baser   praw.modelsprawr   __annotations__r   r"   r%   r(   r,   r/   r2   r5   r;   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rP   r   r   r    <module>rT     s   ) " #  . .  # (   l(;
G ;X 6H &H 4H " "x X "!h !&|x |~X <	,K 	,W 68 W tGv GT>FH >BI.6 I.X#V #LE&( EPD68 DN'.vx '.T@fh @F..&( ..b6v 6rL L^h
4 h
4r   