# Path: cbus/common.py
# class ExtendedCALType(IntEnum):
#     BINARY = 0x00
#     LEVEL = 0x07
# 
# class GroupState(IntEnum):
#     MISSING = 0x00
#     ON = 0x01
#     OFF = 0x02
#     ERROR = 0x03


import abc
from dataclasses import dataclass
from typing import Iterator, Optional, Sequence
from cbus.common import ExtendedCALType, GroupState
def manchester_encode(value: Optional[int],
                      buf: Optional[bytearray] = None,
                      off: int = 0):
    if buf is None:
        buf = bytearray(2)
    if len(buf) < off + 2:
        raise IndexError(f'buf too small, need {off+2} bytes')
    if value is None:
        return buf

    value = int(value) & 0xff
    buf[off] = (_MANCHESTER_NIBBLES[value & 0x3] |
                _MANCHESTER_NIBBLES[value >> 2 & 0x3] << 4)
    buf[off + 1] = (_MANCHESTER_NIBBLES[value >> 4 & 0x3] |
                    _MANCHESTER_NIBBLES[value >> 6 & 0x3] << 4)
    return buf


class StatusReport(abc.ABC):
    @classmethod
    @abc.abstractmethod
    def decode(cls, data: bytes) -> StatusReport:
        raise NotImplementedError('decode')

    @property
    @abc.abstractmethod
    def block_type(self) -> ExtendedCALType:
        raise NotImplementedError('block_type')

    @abc.abstractmethod

# Path: cbus/common.py
# class ExtendedCALType(IntEnum):
#     BINARY = 0x00
#     LEVEL = 0x07
# 
# class GroupState(IntEnum):
#     MISSING = 0x00
#     ON = 0x01
#     OFF = 0x02
#     ERROR = 0x03


# Path: cbus/protocol/cal/report.py
import abc
from dataclasses import dataclass
from typing import Iterator, Optional, Sequence
from cbus.common import ExtendedCALType, GroupState

def manchester_encode(value: Optional[int],
                      buf: Optional[bytearray] = None,
                      off: int = 0):
    if buf is None:
        buf = bytearray(2)
    if len(buf) < off + 2:
        raise IndexError(f'buf too small, need {off+2} bytes')
    if value is None:
        return buf

    value = int(value) & 0xff
    buf[off] = (_MANCHESTER_NIBBLES[value & 0x3] |
                _MANCHESTER_NIBBLES[value >> 2 & 0x3] << 4)
    buf[off + 1] = (_MANCHESTER_NIBBLES[value >> 4 & 0x3] |
                    _MANCHESTER_NIBBLES[value >> 6 & 0x3] << 4)
    return buf


class StatusReport(abc.ABC):
    @classmethod
    @abc.abstractmethod
    def decode(cls, data: bytes) -> StatusReport:
        raise NotImplementedError('decode')

    @property
    @abc.abstractmethod
    def block_type(self) -> ExtendedCALType:
        raise NotImplementedError('block_type')

    @abc.abstractmethod

    def encode(self) -> bytes: