from __future__ import annotations

from typing import Literal, TypedDict

from . import schemathesis
from ._events import CoverageEvent, parse_event_label  # noqa: F401
from ._version import VERSION
from .http import HttpInteraction, HttpRequest, HttpResponse  # noqa: F401


class ThresholdViolation(TypedDict):
    dimension: Literal["operations", "parameters", "keywords", "examples", "responses"]
    actual: float
    minimum: float

__version__ = VERSION

try:
    # Try professional first, fall back to community
    from tracecov_professional import CoverageMap  # noqa: F401

    __edition__ = "professional"  # pragma: no cover
except ImportError:  # pragma: no cover
    try:
        from tracecov_community import CoverageMap  # noqa: F401

        __edition__ = "community"
    except ModuleNotFoundError as exc:
        raise ImportError(
            "No TraceCov backend found. Try reinstalling 'tracecov'."
        ) from exc


__all__ = [
    "__version__",
    "__edition__",
    "CoverageEvent",
    "CoverageMap",
    "HttpInteraction",
    "HttpRequest",
    "HttpResponse",
    "ThresholdViolation",
    "parse_event_label",
    "schemathesis",
]
