# Path: google/cloud/firestore_v1/_helpers.py
# def decode_value(
#     value, client
# ) -> Union[None, bool, int, float, list, datetime.datetime, str, bytes, dict, GeoPoint]:
#     """Converts a Firestore protobuf ``Value`` to a native Python value.
# 
#     Args:
#         value (google.cloud.firestore_v1.types.Value): A
#             Firestore protobuf to be decoded / parsed / converted.
#         client (:class:`~google.cloud.firestore_v1.client.Client`):
#             A client that has a document factory.
# 
#     Returns:
#         Union[NoneType, bool, int, float, datetime.datetime, \
#             str, bytes, dict, ~google.cloud.Firestore.GeoPoint]: A native
#         Python value converted from the ``value``.
# 
#     Raises:
#         NotImplementedError: If the ``value_type`` is ``reference_value``.
#         ValueError: If the ``value_type`` is unknown.
#     """
#     value_pb = getattr(value, "_pb", value)
#     value_type = value_pb.WhichOneof("value_type")
# 
#     if value_type == "null_value":
#         return None
#     elif value_type == "boolean_value":
#         return value_pb.boolean_value
#     elif value_type == "integer_value":
#         return value_pb.integer_value
#     elif value_type == "double_value":
#         return value_pb.double_value
#     elif value_type == "timestamp_value":
#         return DatetimeWithNanoseconds.from_timestamp_pb(value_pb.timestamp_value)
#     elif value_type == "string_value":
#         return value_pb.string_value
#     elif value_type == "bytes_value":
#         return value_pb.bytes_value
#     elif value_type == "reference_value":
#         return reference_value_to_document(value_pb.reference_value, client)
#     elif value_type == "geo_point_value":
#         return GeoPoint(
#             value_pb.geo_point_value.latitude, value_pb.geo_point_value.longitude
#         )
#     elif value_type == "array_value":
#         return [
#             decode_value(element, client) for element in value_pb.array_value.values
#         ]
#     elif value_type == "map_value":
#         return decode_dict(value_pb.map_value.fields, client)
#     else:
#         raise ValueError("Unknown ``value_type``", value_type)


from enum import Enum
from google.cloud.firestore_v1._helpers import decode_value
from typing import Any
import math
        elif value_type == "geo_point_value":
            return cls.compare_geo_points(left, right)
        elif value_type == "array_value":
            return cls.compare_arrays(left, right)
        elif value_type == "map_value":
            return cls.compare_objects(left, right)
        else:
            raise ValueError(f"Unknown ``value_type`` {value_type}")

    @staticmethod
    def compare_blobs(left, right) -> int:
        left_bytes = left.bytes_value
        right_bytes = right.bytes_value

        return Order._compare_to(left_bytes, right_bytes)

    @staticmethod
    def compare_timestamps(left, right) -> Any:
        left = left._pb.timestamp_value
        right = right._pb.timestamp_value

        seconds = Order._compare_to(left.seconds or 0, right.seconds or 0)
        if seconds != 0:
            return seconds

        return Order._compare_to(left.nanos or 0, right.nanos or 0)

    @staticmethod
    def compare_geo_points(left, right) -> Any:
        left_value = decode_value(left, None)

# Path: google/cloud/firestore_v1/_helpers.py
# def decode_value(
#     value, client
# ) -> Union[None, bool, int, float, list, datetime.datetime, str, bytes, dict, GeoPoint]:
#     """Converts a Firestore protobuf ``Value`` to a native Python value.
# 
#     Args:
#         value (google.cloud.firestore_v1.types.Value): A
#             Firestore protobuf to be decoded / parsed / converted.
#         client (:class:`~google.cloud.firestore_v1.client.Client`):
#             A client that has a document factory.
# 
#     Returns:
#         Union[NoneType, bool, int, float, datetime.datetime, \
#             str, bytes, dict, ~google.cloud.Firestore.GeoPoint]: A native
#         Python value converted from the ``value``.
# 
#     Raises:
#         NotImplementedError: If the ``value_type`` is ``reference_value``.
#         ValueError: If the ``value_type`` is unknown.
#     """
#     value_pb = getattr(value, "_pb", value)
#     value_type = value_pb.WhichOneof("value_type")
# 
#     if value_type == "null_value":
#         return None
#     elif value_type == "boolean_value":
#         return value_pb.boolean_value
#     elif value_type == "integer_value":
#         return value_pb.integer_value
#     elif value_type == "double_value":
#         return value_pb.double_value
#     elif value_type == "timestamp_value":
#         return DatetimeWithNanoseconds.from_timestamp_pb(value_pb.timestamp_value)
#     elif value_type == "string_value":
#         return value_pb.string_value
#     elif value_type == "bytes_value":
#         return value_pb.bytes_value
#     elif value_type == "reference_value":
#         return reference_value_to_document(value_pb.reference_value, client)
#     elif value_type == "geo_point_value":
#         return GeoPoint(
#             value_pb.geo_point_value.latitude, value_pb.geo_point_value.longitude
#         )
#     elif value_type == "array_value":
#         return [
#             decode_value(element, client) for element in value_pb.array_value.values
#         ]
#     elif value_type == "map_value":
#         return decode_dict(value_pb.map_value.fields, client)
#     else:
#         raise ValueError("Unknown ``value_type``", value_type)


# Path: google/cloud/firestore_v1/order.py
from enum import Enum
from google.cloud.firestore_v1._helpers import decode_value
from typing import Any
import math

        elif value_type == "geo_point_value":
            return cls.compare_geo_points(left, right)
        elif value_type == "array_value":
            return cls.compare_arrays(left, right)
        elif value_type == "map_value":
            return cls.compare_objects(left, right)
        else:
            raise ValueError(f"Unknown ``value_type`` {value_type}")

    @staticmethod
    def compare_blobs(left, right) -> int:
        left_bytes = left.bytes_value
        right_bytes = right.bytes_value

        return Order._compare_to(left_bytes, right_bytes)

    @staticmethod
    def compare_timestamps(left, right) -> Any:
        left = left._pb.timestamp_value
        right = right._pb.timestamp_value

        seconds = Order._compare_to(left.seconds or 0, right.seconds or 0)
        if seconds != 0:
            return seconds

        return Order._compare_to(left.nanos or 0, right.nanos or 0)

    @staticmethod
    def compare_geo_points(left, right) -> Any:
        left_value = decode_value(left, None)

        right_value = decode_value(right, None)