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

#include "py.Windows.System.Power.h"

namespace py::cpp::Windows::System::Power
{
    // ----- BackgroundEnergyManager class --------------------

    static PyObject* _new_BackgroundEnergyManager(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::System::Power::BackgroundEnergyManager>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::System::Power::BackgroundEnergyManager>::type_name);
        return nullptr;
    }

    static PyObject* BackgroundEnergyManager_get_ExcessiveUsageLevel(PyObject* /*unused*/, 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.System.Power.BackgroundEnergyManager", L"ExcessiveUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::BackgroundEnergyManager::ExcessiveUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyManager_get_LowUsageLevel(PyObject* /*unused*/, 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.System.Power.BackgroundEnergyManager", L"LowUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::BackgroundEnergyManager::LowUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyManager_get_MaxAcceptableUsageLevel(PyObject* /*unused*/, 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.System.Power.BackgroundEnergyManager", L"MaxAcceptableUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::BackgroundEnergyManager::MaxAcceptableUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyManager_get_NearMaxAcceptableUsageLevel(PyObject* /*unused*/, 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.System.Power.BackgroundEnergyManager", L"NearMaxAcceptableUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::BackgroundEnergyManager::NearMaxAcceptableUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyManager_get_NearTerminationUsageLevel(PyObject* /*unused*/, 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.System.Power.BackgroundEnergyManager", L"NearTerminationUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::BackgroundEnergyManager::NearTerminationUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyManager_get_RecentEnergyUsage(PyObject* /*unused*/, 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.System.Power.BackgroundEnergyManager", L"RecentEnergyUsage");
            }

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

            return py::convert(winrt::Windows::System::Power::BackgroundEnergyManager::RecentEnergyUsage());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyManager_get_RecentEnergyUsageLevel(PyObject* /*unused*/, 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.System.Power.BackgroundEnergyManager", L"RecentEnergyUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::BackgroundEnergyManager::RecentEnergyUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyManager_get_TerminationUsageLevel(PyObject* /*unused*/, 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.System.Power.BackgroundEnergyManager", L"TerminationUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::BackgroundEnergyManager::TerminationUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyManager_add_RecentEnergyUsageIncreased(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.BackgroundEnergyManager", L"RecentEnergyUsageIncreased");
            }

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

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

            return py::convert(winrt::Windows::System::Power::BackgroundEnergyManager::RecentEnergyUsageIncreased(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyManager_remove_RecentEnergyUsageIncreased(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.BackgroundEnergyManager", L"RecentEnergyUsageIncreased");
            }

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

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

            winrt::Windows::System::Power::BackgroundEnergyManager::RecentEnergyUsageIncreased(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyManager_add_RecentEnergyUsageReturnedToLow(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.BackgroundEnergyManager", L"RecentEnergyUsageReturnedToLow");
            }

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

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

            return py::convert(winrt::Windows::System::Power::BackgroundEnergyManager::RecentEnergyUsageReturnedToLow(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BackgroundEnergyManager_remove_RecentEnergyUsageReturnedToLow(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.BackgroundEnergyManager", L"RecentEnergyUsageReturnedToLow");
            }

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

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

            winrt::Windows::System::Power::BackgroundEnergyManager::RecentEnergyUsageReturnedToLow(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_BackgroundEnergyManager[] = {
        { }
    };

    static PyGetSetDef _getset_BackgroundEnergyManager[] = {
        { }
    };

    static PyType_Slot _type_slots_BackgroundEnergyManager[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_BackgroundEnergyManager) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_BackgroundEnergyManager) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_BackgroundEnergyManager) },
        { }
    };

    static PyType_Spec type_spec_BackgroundEnergyManager = {
        "winrt._winrt_windows_system_power.BackgroundEnergyManager",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_BackgroundEnergyManager};

    static PyGetSetDef getset_BackgroundEnergyManager_Static[] = {
        { "excessive_usage_level", reinterpret_cast<getter>(BackgroundEnergyManager_get_ExcessiveUsageLevel), nullptr, nullptr, nullptr },
        { "low_usage_level", reinterpret_cast<getter>(BackgroundEnergyManager_get_LowUsageLevel), nullptr, nullptr, nullptr },
        { "max_acceptable_usage_level", reinterpret_cast<getter>(BackgroundEnergyManager_get_MaxAcceptableUsageLevel), nullptr, nullptr, nullptr },
        { "near_max_acceptable_usage_level", reinterpret_cast<getter>(BackgroundEnergyManager_get_NearMaxAcceptableUsageLevel), nullptr, nullptr, nullptr },
        { "near_termination_usage_level", reinterpret_cast<getter>(BackgroundEnergyManager_get_NearTerminationUsageLevel), nullptr, nullptr, nullptr },
        { "recent_energy_usage", reinterpret_cast<getter>(BackgroundEnergyManager_get_RecentEnergyUsage), nullptr, nullptr, nullptr },
        { "recent_energy_usage_level", reinterpret_cast<getter>(BackgroundEnergyManager_get_RecentEnergyUsageLevel), nullptr, nullptr, nullptr },
        { "termination_usage_level", reinterpret_cast<getter>(BackgroundEnergyManager_get_TerminationUsageLevel), nullptr, nullptr, nullptr },
        { }
    };

    static PyMethodDef methods_BackgroundEnergyManager_Static[] = {
        { "add_recent_energy_usage_increased", reinterpret_cast<PyCFunction>(BackgroundEnergyManager_add_RecentEnergyUsageIncreased), METH_O, nullptr },
        { "remove_recent_energy_usage_increased", reinterpret_cast<PyCFunction>(BackgroundEnergyManager_remove_RecentEnergyUsageIncreased), METH_O, nullptr },
        { "add_recent_energy_usage_returned_to_low", reinterpret_cast<PyCFunction>(BackgroundEnergyManager_add_RecentEnergyUsageReturnedToLow), METH_O, nullptr },
        { "remove_recent_energy_usage_returned_to_low", reinterpret_cast<PyCFunction>(BackgroundEnergyManager_remove_RecentEnergyUsageReturnedToLow), METH_O, nullptr },
        { }
    };

    static PyType_Slot type_slots_BackgroundEnergyManager_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_BackgroundEnergyManager_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_BackgroundEnergyManager_Static) },
        { }
    };

    static PyType_Spec type_spec_BackgroundEnergyManager_Static =
    {
        "winrt._winrt_windows_system_power.BackgroundEnergyManager_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_BackgroundEnergyManager_Static
    };

    // ----- ForegroundEnergyManager class --------------------

    static PyObject* _new_ForegroundEnergyManager(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::System::Power::ForegroundEnergyManager>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::System::Power::ForegroundEnergyManager>::type_name);
        return nullptr;
    }

    static PyObject* ForegroundEnergyManager_get_ExcessiveUsageLevel(PyObject* /*unused*/, 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.System.Power.ForegroundEnergyManager", L"ExcessiveUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::ForegroundEnergyManager::ExcessiveUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ForegroundEnergyManager_get_LowUsageLevel(PyObject* /*unused*/, 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.System.Power.ForegroundEnergyManager", L"LowUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::ForegroundEnergyManager::LowUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ForegroundEnergyManager_get_MaxAcceptableUsageLevel(PyObject* /*unused*/, 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.System.Power.ForegroundEnergyManager", L"MaxAcceptableUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::ForegroundEnergyManager::MaxAcceptableUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ForegroundEnergyManager_get_NearMaxAcceptableUsageLevel(PyObject* /*unused*/, 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.System.Power.ForegroundEnergyManager", L"NearMaxAcceptableUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::ForegroundEnergyManager::NearMaxAcceptableUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ForegroundEnergyManager_get_RecentEnergyUsage(PyObject* /*unused*/, 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.System.Power.ForegroundEnergyManager", L"RecentEnergyUsage");
            }

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

            return py::convert(winrt::Windows::System::Power::ForegroundEnergyManager::RecentEnergyUsage());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ForegroundEnergyManager_get_RecentEnergyUsageLevel(PyObject* /*unused*/, 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.System.Power.ForegroundEnergyManager", L"RecentEnergyUsageLevel");
            }

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

            return py::convert(winrt::Windows::System::Power::ForegroundEnergyManager::RecentEnergyUsageLevel());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ForegroundEnergyManager_add_RecentEnergyUsageIncreased(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.ForegroundEnergyManager", L"RecentEnergyUsageIncreased");
            }

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

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

            return py::convert(winrt::Windows::System::Power::ForegroundEnergyManager::RecentEnergyUsageIncreased(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ForegroundEnergyManager_remove_RecentEnergyUsageIncreased(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.ForegroundEnergyManager", L"RecentEnergyUsageIncreased");
            }

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

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

            winrt::Windows::System::Power::ForegroundEnergyManager::RecentEnergyUsageIncreased(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ForegroundEnergyManager_add_RecentEnergyUsageReturnedToLow(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.ForegroundEnergyManager", L"RecentEnergyUsageReturnedToLow");
            }

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

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

            return py::convert(winrt::Windows::System::Power::ForegroundEnergyManager::RecentEnergyUsageReturnedToLow(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* ForegroundEnergyManager_remove_RecentEnergyUsageReturnedToLow(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.ForegroundEnergyManager", L"RecentEnergyUsageReturnedToLow");
            }

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

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

            winrt::Windows::System::Power::ForegroundEnergyManager::RecentEnergyUsageReturnedToLow(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_ForegroundEnergyManager[] = {
        { }
    };

    static PyGetSetDef _getset_ForegroundEnergyManager[] = {
        { }
    };

    static PyType_Slot _type_slots_ForegroundEnergyManager[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_ForegroundEnergyManager) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_ForegroundEnergyManager) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_ForegroundEnergyManager) },
        { }
    };

    static PyType_Spec type_spec_ForegroundEnergyManager = {
        "winrt._winrt_windows_system_power.ForegroundEnergyManager",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_ForegroundEnergyManager};

    static PyGetSetDef getset_ForegroundEnergyManager_Static[] = {
        { "excessive_usage_level", reinterpret_cast<getter>(ForegroundEnergyManager_get_ExcessiveUsageLevel), nullptr, nullptr, nullptr },
        { "low_usage_level", reinterpret_cast<getter>(ForegroundEnergyManager_get_LowUsageLevel), nullptr, nullptr, nullptr },
        { "max_acceptable_usage_level", reinterpret_cast<getter>(ForegroundEnergyManager_get_MaxAcceptableUsageLevel), nullptr, nullptr, nullptr },
        { "near_max_acceptable_usage_level", reinterpret_cast<getter>(ForegroundEnergyManager_get_NearMaxAcceptableUsageLevel), nullptr, nullptr, nullptr },
        { "recent_energy_usage", reinterpret_cast<getter>(ForegroundEnergyManager_get_RecentEnergyUsage), nullptr, nullptr, nullptr },
        { "recent_energy_usage_level", reinterpret_cast<getter>(ForegroundEnergyManager_get_RecentEnergyUsageLevel), nullptr, nullptr, nullptr },
        { }
    };

    static PyMethodDef methods_ForegroundEnergyManager_Static[] = {
        { "add_recent_energy_usage_increased", reinterpret_cast<PyCFunction>(ForegroundEnergyManager_add_RecentEnergyUsageIncreased), METH_O, nullptr },
        { "remove_recent_energy_usage_increased", reinterpret_cast<PyCFunction>(ForegroundEnergyManager_remove_RecentEnergyUsageIncreased), METH_O, nullptr },
        { "add_recent_energy_usage_returned_to_low", reinterpret_cast<PyCFunction>(ForegroundEnergyManager_add_RecentEnergyUsageReturnedToLow), METH_O, nullptr },
        { "remove_recent_energy_usage_returned_to_low", reinterpret_cast<PyCFunction>(ForegroundEnergyManager_remove_RecentEnergyUsageReturnedToLow), METH_O, nullptr },
        { }
    };

    static PyType_Slot type_slots_ForegroundEnergyManager_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_ForegroundEnergyManager_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_ForegroundEnergyManager_Static) },
        { }
    };

    static PyType_Spec type_spec_ForegroundEnergyManager_Static =
    {
        "winrt._winrt_windows_system_power.ForegroundEnergyManager_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_ForegroundEnergyManager_Static
    };

    // ----- PowerManager class --------------------

    static PyObject* _new_PowerManager(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::System::Power::PowerManager>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::System::Power::PowerManager>::type_name);
        return nullptr;
    }

    static PyObject* PowerManager_get_BatteryStatus(PyObject* /*unused*/, 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.System.Power.PowerManager", L"BatteryStatus");
            }

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

            return py::convert(winrt::Windows::System::Power::PowerManager::BatteryStatus());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_get_EnergySaverStatus(PyObject* /*unused*/, 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.System.Power.PowerManager", L"EnergySaverStatus");
            }

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

            return py::convert(winrt::Windows::System::Power::PowerManager::EnergySaverStatus());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_get_PowerSupplyStatus(PyObject* /*unused*/, 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.System.Power.PowerManager", L"PowerSupplyStatus");
            }

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

            return py::convert(winrt::Windows::System::Power::PowerManager::PowerSupplyStatus());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_get_RemainingChargePercent(PyObject* /*unused*/, 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.System.Power.PowerManager", L"RemainingChargePercent");
            }

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

            return py::convert(winrt::Windows::System::Power::PowerManager::RemainingChargePercent());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_get_RemainingDischargeTime(PyObject* /*unused*/, 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.System.Power.PowerManager", L"RemainingDischargeTime");
            }

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

            return py::convert(winrt::Windows::System::Power::PowerManager::RemainingDischargeTime());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_add_BatteryStatusChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.PowerManager", L"BatteryStatusChanged");
            }

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

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

            return py::convert(winrt::Windows::System::Power::PowerManager::BatteryStatusChanged(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_remove_BatteryStatusChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.PowerManager", L"BatteryStatusChanged");
            }

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

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

            winrt::Windows::System::Power::PowerManager::BatteryStatusChanged(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_add_EnergySaverStatusChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.PowerManager", L"EnergySaverStatusChanged");
            }

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

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

            return py::convert(winrt::Windows::System::Power::PowerManager::EnergySaverStatusChanged(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_remove_EnergySaverStatusChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.PowerManager", L"EnergySaverStatusChanged");
            }

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

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

            winrt::Windows::System::Power::PowerManager::EnergySaverStatusChanged(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_add_PowerSupplyStatusChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.PowerManager", L"PowerSupplyStatusChanged");
            }

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

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

            return py::convert(winrt::Windows::System::Power::PowerManager::PowerSupplyStatusChanged(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_remove_PowerSupplyStatusChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.PowerManager", L"PowerSupplyStatusChanged");
            }

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

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

            winrt::Windows::System::Power::PowerManager::PowerSupplyStatusChanged(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_add_RemainingChargePercentChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.PowerManager", L"RemainingChargePercentChanged");
            }

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

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

            return py::convert(winrt::Windows::System::Power::PowerManager::RemainingChargePercentChanged(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_remove_RemainingChargePercentChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.PowerManager", L"RemainingChargePercentChanged");
            }

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

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

            winrt::Windows::System::Power::PowerManager::RemainingChargePercentChanged(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_add_RemainingDischargeTimeChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.PowerManager", L"RemainingDischargeTimeChanged");
            }

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

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

            return py::convert(winrt::Windows::System::Power::PowerManager::RemainingDischargeTimeChanged(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerManager_remove_RemainingDischargeTimeChanged(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Power.PowerManager", L"RemainingDischargeTimeChanged");
            }

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

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

            winrt::Windows::System::Power::PowerManager::RemainingDischargeTimeChanged(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_PowerManager[] = {
        { }
    };

    static PyGetSetDef _getset_PowerManager[] = {
        { }
    };

    static PyType_Slot _type_slots_PowerManager[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_PowerManager) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_PowerManager) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_PowerManager) },
        { }
    };

    static PyType_Spec type_spec_PowerManager = {
        "winrt._winrt_windows_system_power.PowerManager",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_PowerManager};

    static PyGetSetDef getset_PowerManager_Static[] = {
        { "battery_status", reinterpret_cast<getter>(PowerManager_get_BatteryStatus), nullptr, nullptr, nullptr },
        { "energy_saver_status", reinterpret_cast<getter>(PowerManager_get_EnergySaverStatus), nullptr, nullptr, nullptr },
        { "power_supply_status", reinterpret_cast<getter>(PowerManager_get_PowerSupplyStatus), nullptr, nullptr, nullptr },
        { "remaining_charge_percent", reinterpret_cast<getter>(PowerManager_get_RemainingChargePercent), nullptr, nullptr, nullptr },
        { "remaining_discharge_time", reinterpret_cast<getter>(PowerManager_get_RemainingDischargeTime), nullptr, nullptr, nullptr },
        { }
    };

    static PyMethodDef methods_PowerManager_Static[] = {
        { "add_battery_status_changed", reinterpret_cast<PyCFunction>(PowerManager_add_BatteryStatusChanged), METH_O, nullptr },
        { "remove_battery_status_changed", reinterpret_cast<PyCFunction>(PowerManager_remove_BatteryStatusChanged), METH_O, nullptr },
        { "add_energy_saver_status_changed", reinterpret_cast<PyCFunction>(PowerManager_add_EnergySaverStatusChanged), METH_O, nullptr },
        { "remove_energy_saver_status_changed", reinterpret_cast<PyCFunction>(PowerManager_remove_EnergySaverStatusChanged), METH_O, nullptr },
        { "add_power_supply_status_changed", reinterpret_cast<PyCFunction>(PowerManager_add_PowerSupplyStatusChanged), METH_O, nullptr },
        { "remove_power_supply_status_changed", reinterpret_cast<PyCFunction>(PowerManager_remove_PowerSupplyStatusChanged), METH_O, nullptr },
        { "add_remaining_charge_percent_changed", reinterpret_cast<PyCFunction>(PowerManager_add_RemainingChargePercentChanged), METH_O, nullptr },
        { "remove_remaining_charge_percent_changed", reinterpret_cast<PyCFunction>(PowerManager_remove_RemainingChargePercentChanged), METH_O, nullptr },
        { "add_remaining_discharge_time_changed", reinterpret_cast<PyCFunction>(PowerManager_add_RemainingDischargeTimeChanged), METH_O, nullptr },
        { "remove_remaining_discharge_time_changed", reinterpret_cast<PyCFunction>(PowerManager_remove_RemainingDischargeTimeChanged), METH_O, nullptr },
        { }
    };

    static PyType_Slot type_slots_PowerManager_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_PowerManager_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_PowerManager_Static) },
        { }
    };

    static PyType_Spec type_spec_PowerManager_Static =
    {
        "winrt._winrt_windows_system_power.PowerManager_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_PowerManager_Static
    };

    // ----- Windows.System.Power Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.System.Power");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_system_power",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::System::Power

PyMODINIT_FUNC PyInit__winrt_windows_system_power(void) noexcept
{
    using namespace py::cpp::Windows::System::Power;

    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::pyobj_handle type_BackgroundEnergyManager_Static{PyType_FromSpec(&type_spec_BackgroundEnergyManager_Static)};
    if (!type_BackgroundEnergyManager_Static)
    {
        return nullptr;
    }

    py::pytype_handle BackgroundEnergyManager_type{py::register_python_type(module.get(), &type_spec_BackgroundEnergyManager, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_BackgroundEnergyManager_Static.get()))};
    if (!BackgroundEnergyManager_type)
    {
        return nullptr;
    }

    py::pyobj_handle type_ForegroundEnergyManager_Static{PyType_FromSpec(&type_spec_ForegroundEnergyManager_Static)};
    if (!type_ForegroundEnergyManager_Static)
    {
        return nullptr;
    }

    py::pytype_handle ForegroundEnergyManager_type{py::register_python_type(module.get(), &type_spec_ForegroundEnergyManager, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_ForegroundEnergyManager_Static.get()))};
    if (!ForegroundEnergyManager_type)
    {
        return nullptr;
    }

    py::pyobj_handle type_PowerManager_Static{PyType_FromSpec(&type_spec_PowerManager_Static)};
    if (!type_PowerManager_Static)
    {
        return nullptr;
    }

    py::pytype_handle PowerManager_type{py::register_python_type(module.get(), &type_spec_PowerManager, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_PowerManager_Static.get()))};
    if (!PowerManager_type)
    {
        return nullptr;
    }


    return module.detach();
}
