"""Provider factory for Scout checks."""

from __future__ import annotations

from typing import Dict

from ..crm_provider import CRMProvider
from .sfdc_provider import SFDCProvider
from .hubspot_provider import HubSpotProvider
from .dynamics_provider import DynamicsProvider


def create_provider(
    crm: str,
    *,
    org_alias: str | None = None,
    hubspot_profile: str | None = None,
    dynamics_profile: str | None = None,
    field_overrides: Dict[str, Dict[str, str]] | None = None,
) -> CRMProvider:
    crm_key = (crm or "salesforce").lower()
    if crm_key in ("salesforce", "sfdc"):
        return SFDCProvider(org_alias=org_alias, field_overrides=field_overrides)
    if crm_key == "hubspot":
        return HubSpotProvider(profile=hubspot_profile, field_overrides=field_overrides)
    if crm_key == "dynamics":
        return DynamicsProvider(profile=dynamics_profile, field_overrides=field_overrides)
    raise ValueError(f"Unsupported CRM provider: {crm}")


__all__ = ["create_provider", "SFDCProvider", "HubSpotProvider", "DynamicsProvider"]
