from __future__ import annotations

from typing import Callable

from .downloader import Downloader
from .models import DownloadConfig, DownloadProgress, DownloadResult, DownloadTask


async def download_file_async(
    task: DownloadTask,
    config: DownloadConfig | None = None,
    progress_callback: Callable[[DownloadProgress], None] | None = None,
    headers: dict[str, str] | None = None,
) -> DownloadResult:
    downloader = Downloader(config=config)
    return await downloader.download(task, progress_callback=progress_callback, headers=headers)
