from __future__ import annotations


class StorageAdapter:
    _bucket: str

    def __init__(self, bucket: str) -> None:
        self._bucket = bucket

    @property
    def bucket(self) -> str:
        return self._bucket

    def build_object_path(
        self,
        *,
        user_id: str,
        session_id: str,
        message_seq: int,
        checksum_sha256: str,
        extension: str,
    ) -> str:
        normalized_ext = extension.strip(".").lower()
        return (
            f"agent-chat/{user_id}/{session_id}/{message_seq}/"
            f"{checksum_sha256}.{normalized_ext}"
        )

    def build_attachment_metadata(
        self,
        *,
        object_path: str,
        mime_type: str,
        size: int,
        checksum_sha256: str,
        origin: str,
        preview_text: str | None = None,
    ) -> dict[str, object]:
        return {
            "object_path": object_path,
            "mime_type": mime_type,
            "size": size,
            "checksum_sha256": checksum_sha256,
            "origin": origin,
            "preview_text": preview_text,
        }
