# Path: telethon/_misc/tlobject.py
# _EPOCH_NAIVE = datetime(*time.gmtime(0)[:6])
# _EPOCH_NAIVE_LOCAL = datetime(*time.localtime(0)[:6])
# _EPOCH = _EPOCH_NAIVE.replace(tzinfo=timezone.utc)
#     CONSTRUCTOR_ID = None
#     SUBCLASS_OF_ID = None
# def _datetime_to_timestamp(dt):
# def _json_default(value):
#     def _serialize_bytes(data):
#     def _serialize_datetime(dt):
#     def __eq__(self, o):
#     def __ne__(self, o):
#     def __repr__(self):
#     def __str__(self):
#     def stringify(self):
#     def to_dict(self):
#     def __bytes__(self):
#     def _bytes(self):
#     def _from_reader(cls, reader):
#     def _read_result(reader):
#     async def _resolve(self, client, utils):
# class TLObject:
# class TLRequest(TLObject):


import gzip
import struct
from ..._misc import tlobject



class GzipPacked(tlobject.TLObject):
    CONSTRUCTOR_ID = 0x3072cfa1

    def __init__(self, data):
        self.data = data

    @staticmethod
    def gzip_if_smaller(content_related, data):
        """Calls bytes(request), and based on a certain threshold,
           optionally gzips the resulting data. If the gzipped data is
           smaller than the original byte array, this is returned instead.

           Note that this only applies to content related requests.
        """
        if content_related and len(data) > 512:
            gzipped = bytes(GzipPacked(data))
            return gzipped if len(gzipped) < len(data) else data
        else:
            return data

    def __bytes__(self):
        return struct.pack('<I', GzipPacked.CONSTRUCTOR_ID) + \

# Path: telethon/_misc/tlobject.py
# _EPOCH_NAIVE = datetime(*time.gmtime(0)[:6])
# _EPOCH_NAIVE_LOCAL = datetime(*time.localtime(0)[:6])
# _EPOCH = _EPOCH_NAIVE.replace(tzinfo=timezone.utc)
#     CONSTRUCTOR_ID = None
#     SUBCLASS_OF_ID = None
# def _datetime_to_timestamp(dt):
# def _json_default(value):
#     def _serialize_bytes(data):
#     def _serialize_datetime(dt):
#     def __eq__(self, o):
#     def __ne__(self, o):
#     def __repr__(self):
#     def __str__(self):
#     def stringify(self):
#     def to_dict(self):
#     def __bytes__(self):
#     def _bytes(self):
#     def _from_reader(cls, reader):
#     def _read_result(reader):
#     async def _resolve(self, client, utils):
# class TLObject:
# class TLRequest(TLObject):


# Path: telethon/types/_core/gzippacked.py
import gzip
import struct
from ..._misc import tlobject




class GzipPacked(tlobject.TLObject):
    CONSTRUCTOR_ID = 0x3072cfa1

    def __init__(self, data):
        self.data = data

    @staticmethod
    def gzip_if_smaller(content_related, data):
        """Calls bytes(request), and based on a certain threshold,
           optionally gzips the resulting data. If the gzipped data is
           smaller than the original byte array, this is returned instead.

           Note that this only applies to content related requests.
        """
        if content_related and len(data) > 512:
            gzipped = bytes(GzipPacked(data))
            return gzipped if len(gzipped) < len(data) else data
        else:
            return data

    def __bytes__(self):
        return struct.pack('<I', GzipPacked.CONSTRUCTOR_ID) + \

               tlobject.TLObject._serialize_bytes(gzip.compress(self.data))