# This file was auto-generated by Fern from our API Definition.

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.response_display_record_result import ResponseDisplayRecordResult
from .raw_client import AsyncRawDisplayClient, RawDisplayClient
from .types.record_action import RecordAction

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class DisplayClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawDisplayClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawDisplayClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawDisplayClient
        """
        return self._raw_client

    def record(
        self,
        *,
        action: RecordAction,
        save_path: typing.Optional[str] = OMIT,
        fps: typing.Optional[int] = OMIT,
        crf: typing.Optional[int] = OMIT,
        max_duration: typing.Optional[float] = OMIT,
        width: typing.Optional[int] = OMIT,
        height: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ResponseDisplayRecordResult:
        """
        Control display screen recording (start/stop/status).

        Records the entire X11 desktop using ffmpeg x11grab,
        including browser UI, multiple tabs, popups, terminal, etc.

        Parameters
        ----------
        action : RecordAction
            Recording action: start, stop, or status

        save_path : typing.Optional[str]
            Output file path (default: /tmp/recordings/recording_{timestamp}.mp4)

        fps : typing.Optional[int]
            Frames per second

        crf : typing.Optional[int]
            H.264 CRF quality (0=lossless, 51=worst)

        max_duration : typing.Optional[float]
            Max recording duration in seconds

        width : typing.Optional[int]
            Video width in pixels (auto-detected from X11 if omitted)

        height : typing.Optional[int]
            Video height in pixels (auto-detected from X11 if omitted)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ResponseDisplayRecordResult
            Successful Response

        Examples
        --------
        from agent_sandbox import Sandbox

        client = Sandbox(
            base_url="https://yourhost.com/path/to/api",
        )
        client.display.record(
            action="start",
        )
        """
        _response = self._raw_client.record(
            action=action,
            save_path=save_path,
            fps=fps,
            crf=crf,
            max_duration=max_duration,
            width=width,
            height=height,
            request_options=request_options,
        )
        return _response.data


class AsyncDisplayClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawDisplayClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawDisplayClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawDisplayClient
        """
        return self._raw_client

    async def record(
        self,
        *,
        action: RecordAction,
        save_path: typing.Optional[str] = OMIT,
        fps: typing.Optional[int] = OMIT,
        crf: typing.Optional[int] = OMIT,
        max_duration: typing.Optional[float] = OMIT,
        width: typing.Optional[int] = OMIT,
        height: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ResponseDisplayRecordResult:
        """
        Control display screen recording (start/stop/status).

        Records the entire X11 desktop using ffmpeg x11grab,
        including browser UI, multiple tabs, popups, terminal, etc.

        Parameters
        ----------
        action : RecordAction
            Recording action: start, stop, or status

        save_path : typing.Optional[str]
            Output file path (default: /tmp/recordings/recording_{timestamp}.mp4)

        fps : typing.Optional[int]
            Frames per second

        crf : typing.Optional[int]
            H.264 CRF quality (0=lossless, 51=worst)

        max_duration : typing.Optional[float]
            Max recording duration in seconds

        width : typing.Optional[int]
            Video width in pixels (auto-detected from X11 if omitted)

        height : typing.Optional[int]
            Video height in pixels (auto-detected from X11 if omitted)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ResponseDisplayRecordResult
            Successful Response

        Examples
        --------
        import asyncio

        from agent_sandbox import AsyncSandbox

        client = AsyncSandbox(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.display.record(
                action="start",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.record(
            action=action,
            save_path=save_path,
            fps=fps,
            crf=crf,
            max_duration=max_duration,
            width=width,
            height=height,
            request_options=request_options,
        )
        return _response.data
