// WARNING: Please don't edit this file. It was generated by Python/WinRT v2.2.0

#include "py.Windows.UI.Popups.h"

namespace py::cpp::Windows::UI::Popups
{
    // ----- MessageDialog class --------------------

    static PyObject* _new_MessageDialog(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds != nullptr)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        auto arg_count = PyTuple_Size(args);
        if (arg_count == 1)
        {
            try
            {
                auto param0 = py::convert_to<winrt::hstring>(args, 0);

                winrt::Windows::UI::Popups::MessageDialog instance{param0};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else if (arg_count == 2)
        {
            try
            {
                auto param0 = py::convert_to<winrt::hstring>(args, 0);
                auto param1 = py::convert_to<winrt::hstring>(args, 1);

                winrt::Windows::UI::Popups::MessageDialog instance{param0, param1};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_MessageDialog(py::wrapper::Windows::UI::Popups::MessageDialog* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* MessageDialog_ShowAsync(py::wrapper::Windows::UI::Popups::MessageDialog* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Popups.MessageDialog", L"ShowAsync", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert(self->obj.ShowAsync());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MessageDialog_get_Title(py::wrapper::Windows::UI::Popups::MessageDialog* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.MessageDialog", L"Title");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Title());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int MessageDialog_put_Title(py::wrapper::Windows::UI::Popups::MessageDialog* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.MessageDialog", L"Title");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::hstring>(arg);

            self->obj.Title(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* MessageDialog_get_Options(py::wrapper::Windows::UI::Popups::MessageDialog* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.MessageDialog", L"Options");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Options());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int MessageDialog_put_Options(py::wrapper::Windows::UI::Popups::MessageDialog* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.MessageDialog", L"Options");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::UI::Popups::MessageDialogOptions>(arg);

            self->obj.Options(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* MessageDialog_get_DefaultCommandIndex(py::wrapper::Windows::UI::Popups::MessageDialog* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.MessageDialog", L"DefaultCommandIndex");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.DefaultCommandIndex());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int MessageDialog_put_DefaultCommandIndex(py::wrapper::Windows::UI::Popups::MessageDialog* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.MessageDialog", L"DefaultCommandIndex");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<uint32_t>(arg);

            self->obj.DefaultCommandIndex(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* MessageDialog_get_Content(py::wrapper::Windows::UI::Popups::MessageDialog* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.MessageDialog", L"Content");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Content());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int MessageDialog_put_Content(py::wrapper::Windows::UI::Popups::MessageDialog* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.MessageDialog", L"Content");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::hstring>(arg);

            self->obj.Content(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* MessageDialog_get_CancelCommandIndex(py::wrapper::Windows::UI::Popups::MessageDialog* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.MessageDialog", L"CancelCommandIndex");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.CancelCommandIndex());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int MessageDialog_put_CancelCommandIndex(py::wrapper::Windows::UI::Popups::MessageDialog* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.MessageDialog", L"CancelCommandIndex");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<uint32_t>(arg);

            self->obj.CancelCommandIndex(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* MessageDialog_get_Commands(py::wrapper::Windows::UI::Popups::MessageDialog* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.MessageDialog", L"Commands");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Commands());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_MessageDialog(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::UI::Popups::MessageDialog>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_MessageDialog(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::UI::Popups::MessageDialog>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_MessageDialog[] = {
        { "show_async", reinterpret_cast<PyCFunction>(MessageDialog_ShowAsync), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_MessageDialog, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_MessageDialog), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_MessageDialog[] = {
        { "title", reinterpret_cast<getter>(MessageDialog_get_Title), reinterpret_cast<setter>(MessageDialog_put_Title), nullptr, nullptr },
        { "options", reinterpret_cast<getter>(MessageDialog_get_Options), reinterpret_cast<setter>(MessageDialog_put_Options), nullptr, nullptr },
        { "default_command_index", reinterpret_cast<getter>(MessageDialog_get_DefaultCommandIndex), reinterpret_cast<setter>(MessageDialog_put_DefaultCommandIndex), nullptr, nullptr },
        { "content", reinterpret_cast<getter>(MessageDialog_get_Content), reinterpret_cast<setter>(MessageDialog_put_Content), nullptr, nullptr },
        { "cancel_command_index", reinterpret_cast<getter>(MessageDialog_get_CancelCommandIndex), reinterpret_cast<setter>(MessageDialog_put_CancelCommandIndex), nullptr, nullptr },
        { "commands", reinterpret_cast<getter>(MessageDialog_get_Commands), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_MessageDialog[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_MessageDialog) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_MessageDialog) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_MessageDialog) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_MessageDialog) },
        { }
    };

    static PyType_Spec type_spec_MessageDialog = {
        "winrt._winrt_windows_ui_popups.MessageDialog",
        sizeof(py::wrapper::Windows::UI::Popups::MessageDialog),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_MessageDialog};

    // ----- PopupMenu class --------------------

    static PyObject* _new_PopupMenu(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds != nullptr)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        auto arg_count = PyTuple_Size(args);
        if (arg_count == 0)
        {
            try
            {
                winrt::Windows::UI::Popups::PopupMenu instance{};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_PopupMenu(py::wrapper::Windows::UI::Popups::PopupMenu* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* PopupMenu_ShowAsync(py::wrapper::Windows::UI::Popups::PopupMenu* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Popups.PopupMenu", L"ShowAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Foundation::Point>(args, 0);

                return py::convert(self->obj.ShowAsync(param0));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PopupMenu_ShowForSelectionAsync(py::wrapper::Windows::UI::Popups::PopupMenu* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Popups.PopupMenu", L"ShowForSelectionAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Foundation::Rect>(args, 0);

                return py::convert(self->obj.ShowForSelectionAsync(param0));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else if (arg_count == 2)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.UI.Popups.PopupMenu", L"ShowForSelectionAsync", 2);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(2);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Foundation::Rect>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::UI::Popups::Placement>(args, 1);

                return py::convert(self->obj.ShowForSelectionAsync(param0, param1));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PopupMenu_get_Commands(py::wrapper::Windows::UI::Popups::PopupMenu* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.PopupMenu", L"Commands");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Commands());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_PopupMenu(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::UI::Popups::PopupMenu>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_PopupMenu(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::UI::Popups::PopupMenu>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_PopupMenu[] = {
        { "show_async", reinterpret_cast<PyCFunction>(PopupMenu_ShowAsync), METH_VARARGS, nullptr },
        { "show_for_selection_async", reinterpret_cast<PyCFunction>(PopupMenu_ShowForSelectionAsync), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_PopupMenu, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_PopupMenu), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_PopupMenu[] = {
        { "commands", reinterpret_cast<getter>(PopupMenu_get_Commands), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_PopupMenu[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_PopupMenu) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_PopupMenu) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_PopupMenu) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_PopupMenu) },
        { }
    };

    static PyType_Spec type_spec_PopupMenu = {
        "winrt._winrt_windows_ui_popups.PopupMenu",
        sizeof(py::wrapper::Windows::UI::Popups::PopupMenu),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_PopupMenu};

    // ----- UICommand class --------------------

    static PyObject* _new_UICommand(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds != nullptr)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        auto arg_count = PyTuple_Size(args);
        if (arg_count == 1)
        {
            try
            {
                auto param0 = py::convert_to<winrt::hstring>(args, 0);

                winrt::Windows::UI::Popups::UICommand instance{param0};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else if (arg_count == 2)
        {
            try
            {
                auto param0 = py::convert_to<winrt::hstring>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::UI::Popups::UICommandInvokedHandler>(args, 1);

                winrt::Windows::UI::Popups::UICommand instance{param0, param1};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else if (arg_count == 3)
        {
            try
            {
                auto param0 = py::convert_to<winrt::hstring>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::UI::Popups::UICommandInvokedHandler>(args, 1);
                auto param2 = py::convert_to<winrt::Windows::Foundation::IInspectable>(args, 2);

                winrt::Windows::UI::Popups::UICommand instance{param0, param1, param2};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else if (arg_count == 0)
        {
            try
            {
                winrt::Windows::UI::Popups::UICommand instance{};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_UICommand(py::wrapper::Windows::UI::Popups::UICommand* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* UICommand_get_Label(py::wrapper::Windows::UI::Popups::UICommand* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommand", L"Label");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Label());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int UICommand_put_Label(py::wrapper::Windows::UI::Popups::UICommand* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommand", L"Label");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::hstring>(arg);

            self->obj.Label(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* UICommand_get_Invoked(py::wrapper::Windows::UI::Popups::UICommand* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommand", L"Invoked");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Invoked());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int UICommand_put_Invoked(py::wrapper::Windows::UI::Popups::UICommand* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommand", L"Invoked");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::UI::Popups::UICommandInvokedHandler>(arg);

            self->obj.Invoked(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* UICommand_get_Id(py::wrapper::Windows::UI::Popups::UICommand* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommand", L"Id");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Id());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int UICommand_put_Id(py::wrapper::Windows::UI::Popups::UICommand* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommand", L"Id");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);

            self->obj.Id(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* _assign_array_UICommand(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::UI::Popups::UICommand>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_UICommand(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::UI::Popups::UICommand>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_UICommand[] = {
        { "_assign_array_", _assign_array_UICommand, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_UICommand), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_UICommand[] = {
        { "label", reinterpret_cast<getter>(UICommand_get_Label), reinterpret_cast<setter>(UICommand_put_Label), nullptr, nullptr },
        { "invoked", reinterpret_cast<getter>(UICommand_get_Invoked), reinterpret_cast<setter>(UICommand_put_Invoked), nullptr, nullptr },
        { "id", reinterpret_cast<getter>(UICommand_get_Id), reinterpret_cast<setter>(UICommand_put_Id), nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_UICommand[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_UICommand) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_UICommand) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_UICommand) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_UICommand) },
        { }
    };

    static PyType_Spec type_spec_UICommand = {
        "winrt._winrt_windows_ui_popups.UICommand",
        sizeof(py::wrapper::Windows::UI::Popups::UICommand),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_UICommand};

    // ----- UICommandSeparator class --------------------

    static PyObject* _new_UICommandSeparator(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds != nullptr)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        auto arg_count = PyTuple_Size(args);
        if (arg_count == 0)
        {
            try
            {
                winrt::Windows::UI::Popups::UICommandSeparator instance{};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_UICommandSeparator(py::wrapper::Windows::UI::Popups::UICommandSeparator* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* UICommandSeparator_get_Label(py::wrapper::Windows::UI::Popups::UICommandSeparator* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommandSeparator", L"Label");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Label());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int UICommandSeparator_put_Label(py::wrapper::Windows::UI::Popups::UICommandSeparator* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommandSeparator", L"Label");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::hstring>(arg);

            self->obj.Label(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* UICommandSeparator_get_Invoked(py::wrapper::Windows::UI::Popups::UICommandSeparator* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommandSeparator", L"Invoked");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Invoked());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int UICommandSeparator_put_Invoked(py::wrapper::Windows::UI::Popups::UICommandSeparator* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommandSeparator", L"Invoked");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::UI::Popups::UICommandInvokedHandler>(arg);

            self->obj.Invoked(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* UICommandSeparator_get_Id(py::wrapper::Windows::UI::Popups::UICommandSeparator* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommandSeparator", L"Id");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Id());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int UICommandSeparator_put_Id(py::wrapper::Windows::UI::Popups::UICommandSeparator* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.UICommandSeparator", L"Id");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);

            self->obj.Id(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* _assign_array_UICommandSeparator(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::UI::Popups::UICommandSeparator>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_UICommandSeparator(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::UI::Popups::UICommandSeparator>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_UICommandSeparator[] = {
        { "_assign_array_", _assign_array_UICommandSeparator, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_UICommandSeparator), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_UICommandSeparator[] = {
        { "label", reinterpret_cast<getter>(UICommandSeparator_get_Label), reinterpret_cast<setter>(UICommandSeparator_put_Label), nullptr, nullptr },
        { "invoked", reinterpret_cast<getter>(UICommandSeparator_get_Invoked), reinterpret_cast<setter>(UICommandSeparator_put_Invoked), nullptr, nullptr },
        { "id", reinterpret_cast<getter>(UICommandSeparator_get_Id), reinterpret_cast<setter>(UICommandSeparator_put_Id), nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_UICommandSeparator[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_UICommandSeparator) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_UICommandSeparator) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_UICommandSeparator) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_UICommandSeparator) },
        { }
    };

    static PyType_Spec type_spec_UICommandSeparator = {
        "winrt._winrt_windows_ui_popups.UICommandSeparator",
        sizeof(py::wrapper::Windows::UI::Popups::UICommandSeparator),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_UICommandSeparator};

    // ----- IUICommand interface --------------------

    static PyObject* _new_IUICommand(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::UI::Popups::IUICommand>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::UI::Popups::IUICommand>::type_name);
        return nullptr;
    }

    static void _dealloc_IUICommand(py::wrapper::Windows::UI::Popups::IUICommand* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* IUICommand_get_Id(py::wrapper::Windows::UI::Popups::IUICommand* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.IUICommand", L"Id");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Id());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int IUICommand_put_Id(py::wrapper::Windows::UI::Popups::IUICommand* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.IUICommand", L"Id");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);

            self->obj.Id(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* IUICommand_get_Invoked(py::wrapper::Windows::UI::Popups::IUICommand* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.IUICommand", L"Invoked");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Invoked());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int IUICommand_put_Invoked(py::wrapper::Windows::UI::Popups::IUICommand* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.IUICommand", L"Invoked");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::UI::Popups::UICommandInvokedHandler>(arg);

            self->obj.Invoked(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* IUICommand_get_Label(py::wrapper::Windows::UI::Popups::IUICommand* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.IUICommand", L"Label");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Label());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int IUICommand_put_Label(py::wrapper::Windows::UI::Popups::IUICommand* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (arg == nullptr)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.UI.Popups.IUICommand", L"Label");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::hstring>(arg);

            self->obj.Label(param0);
            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* _assign_array_IUICommand(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::UI::Popups::IUICommand>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_IUICommand(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::UI::Popups::IUICommand>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_IUICommand[] = {
        { "_assign_array_", _assign_array_IUICommand, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_IUICommand), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_IUICommand[] = {
        { "id", reinterpret_cast<getter>(IUICommand_get_Id), reinterpret_cast<setter>(IUICommand_put_Id), nullptr, nullptr },
        { "invoked", reinterpret_cast<getter>(IUICommand_get_Invoked), reinterpret_cast<setter>(IUICommand_put_Invoked), nullptr, nullptr },
        { "label", reinterpret_cast<getter>(IUICommand_get_Label), reinterpret_cast<setter>(IUICommand_put_Label), nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_IUICommand[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_IUICommand) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_IUICommand) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_IUICommand) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_IUICommand) },
        { }
    };

    static PyType_Spec type_spec_IUICommand = {
        "winrt._winrt_windows_ui_popups.IUICommand",
        sizeof(py::wrapper::Windows::UI::Popups::IUICommand),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_IUICommand};

    // ----- Windows.UI.Popups Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.UI.Popups");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_ui_popups",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::UI::Popups

PyMODINIT_FUNC PyInit__winrt_windows_ui_popups(void) noexcept
{
    using namespace py::cpp::Windows::UI::Popups;

    if (py::import_winrt_runtime() == -1)
    {
        return nullptr;
    }

    py::pyobj_handle module{PyModule_Create(&module_def)};

    if (!module)
    {
        return nullptr;
    }

    auto object_type = py::get_object_type();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle object_bases{PyTuple_Pack(1, object_type)};

    if (!object_bases)
    {
        return nullptr;
    }

    py::pytype_handle MessageDialog_type{py::register_python_type(module.get(), &type_spec_MessageDialog, object_bases.get(), nullptr)};
    if (!MessageDialog_type)
    {
        return nullptr;
    }

    py::pytype_handle PopupMenu_type{py::register_python_type(module.get(), &type_spec_PopupMenu, object_bases.get(), nullptr)};
    if (!PopupMenu_type)
    {
        return nullptr;
    }

    py::pytype_handle UICommand_type{py::register_python_type(module.get(), &type_spec_UICommand, object_bases.get(), nullptr)};
    if (!UICommand_type)
    {
        return nullptr;
    }

    py::pytype_handle UICommandSeparator_type{py::register_python_type(module.get(), &type_spec_UICommandSeparator, object_bases.get(), nullptr)};
    if (!UICommandSeparator_type)
    {
        return nullptr;
    }

    py::pytype_handle IUICommand_type{py::register_python_type(module.get(), &type_spec_IUICommand, object_bases.get(), nullptr)};
    if (!IUICommand_type)
    {
        return nullptr;
    }


    return module.detach();
}
