# Path: pyhindsight/lib/ccl_chrome_indexeddb/ccl_simplesnappy.py
# DEBUG = False
# def log(msg):
# def _read_le_varint(stream: typing.BinaryIO) -> typing.Optional[typing.Tuple[int, bytes]]:
# def read_le_varint(stream: typing.BinaryIO) -> typing.Optional[int]:
# def read_uint16(stream: typing.BinaryIO) -> int:
# def read_uint24(stream: typing.BinaryIO) -> int:
# def read_uint32(stream: typing.BinaryIO) -> int:
# def read_byte(stream: typing.BinaryIO) -> typing.Optional[int]:
# def decompress(data: typing.BinaryIO) -> bytes:
# def main(path):
# class ElementType(enum.IntEnum):


import typing
import struct
import re
import os
import io
import pathlib
import dataclasses
import enum
from collections import namedtuple
from types import MappingProxyType
from pyhindsight.lib.ccl_chrome_indexeddb import ccl_simplesnappy

def read_le_varint(stream: typing.BinaryIO, *, is_google_32bit=False) -> typing.Optional[int]:
    """Convenience version of _read_le_varint that only returns the value or None"""
    x = _read_le_varint(stream, is_google_32bit=is_google_32bit)
    if x is None:
        return None
    else:
        return x[0]


def read_length_prefixed_blob(stream: typing.BinaryIO):
    length = read_le_varint(stream)
    data = stream.read(length)
    if len(data) != length:
        raise ValueError(f"Could not read all data (expected {length}, got {len(data)}")
    return data


@dataclasses.dataclass(frozen=True)
class BlockHandle:
    """See: https://github.com/google/leveldb/blob/master/doc/table_format.md
    A BlockHandle contains an offset and length of a block in an ldb table file"""
    offset: int
    length: int

    @classmethod
    def from_stream(cls, stream: typing.BinaryIO):
        return cls(read_le_varint(stream), read_le_varint(stream))

    @classmethod

# Path: pyhindsight/lib/ccl_chrome_indexeddb/ccl_simplesnappy.py
# DEBUG = False
# def log(msg):
# def _read_le_varint(stream: typing.BinaryIO) -> typing.Optional[typing.Tuple[int, bytes]]:
# def read_le_varint(stream: typing.BinaryIO) -> typing.Optional[int]:
# def read_uint16(stream: typing.BinaryIO) -> int:
# def read_uint24(stream: typing.BinaryIO) -> int:
# def read_uint32(stream: typing.BinaryIO) -> int:
# def read_byte(stream: typing.BinaryIO) -> typing.Optional[int]:
# def decompress(data: typing.BinaryIO) -> bytes:
# def main(path):
# class ElementType(enum.IntEnum):


# Path: pyhindsight/lib/ccl_chrome_indexeddb/ccl_leveldb.py
import typing
import struct
import re
import os
import io
import pathlib
import dataclasses
import enum
from collections import namedtuple
from types import MappingProxyType
from pyhindsight.lib.ccl_chrome_indexeddb import ccl_simplesnappy


def read_le_varint(stream: typing.BinaryIO, *, is_google_32bit=False) -> typing.Optional[int]:
    """Convenience version of _read_le_varint that only returns the value or None"""
    x = _read_le_varint(stream, is_google_32bit=is_google_32bit)
    if x is None:
        return None
    else:
        return x[0]


def read_length_prefixed_blob(stream: typing.BinaryIO):
    length = read_le_varint(stream)
    data = stream.read(length)
    if len(data) != length:
        raise ValueError(f"Could not read all data (expected {length}, got {len(data)}")
    return data


@dataclasses.dataclass(frozen=True)
class BlockHandle:
    """See: https://github.com/google/leveldb/blob/master/doc/table_format.md
    A BlockHandle contains an offset and length of a block in an ldb table file"""
    offset: int
    length: int

    @classmethod
    def from_stream(cls, stream: typing.BinaryIO):
        return cls(read_le_varint(stream), read_le_varint(stream))

    @classmethod

    def from_bytes(cls, data: bytes):