from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

from ..models.renderer_config_hl_engine import RendererConfigHlEngine
from ..models.renderer_config_md_engine import RendererConfigMdEngine
from ..types import UNSET, Unset






T = TypeVar("T", bound="RendererConfig")



@_attrs_define
class RendererConfig:
    """ Renderer configuration for Markdown-to-HTML conversion. Both engines are
    optional; partial overrides are allowed (set only `md_engine` or only
    `hl_engine`). When neither context nor source sets a value, the service
    default applies (`md_engine: "pandoc"`, `hl_engine: "pygments"`).

        Example:
            {'md_engine': 'pandoc', 'hl_engine': 'pygments'}

        Attributes:
            md_engine (RendererConfigMdEngine | Unset): Markdown engine: `pandoc` (default, with automatic fallback to
                `python-markdown`) or `python-markdown`.
            hl_engine (RendererConfigHlEngine | Unset): Syntax-highlighting engine: `pygments` (default) or `none`.
     """

    md_engine: RendererConfigMdEngine | Unset = UNSET
    hl_engine: RendererConfigHlEngine | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)





    def to_dict(self) -> dict[str, Any]:
        md_engine: str | Unset = UNSET
        if not isinstance(self.md_engine, Unset):
            md_engine = self.md_engine.value


        hl_engine: str | Unset = UNSET
        if not isinstance(self.hl_engine, Unset):
            hl_engine = self.hl_engine.value



        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({
        })
        if md_engine is not UNSET:
            field_dict["md_engine"] = md_engine
        if hl_engine is not UNSET:
            field_dict["hl_engine"] = hl_engine

        return field_dict



    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        _md_engine = d.pop("md_engine", UNSET)
        md_engine: RendererConfigMdEngine | Unset
        if isinstance(_md_engine,  Unset):
            md_engine = UNSET
        else:
            md_engine = RendererConfigMdEngine(_md_engine)




        _hl_engine = d.pop("hl_engine", UNSET)
        hl_engine: RendererConfigHlEngine | Unset
        if isinstance(_hl_engine,  Unset):
            hl_engine = UNSET
        else:
            hl_engine = RendererConfigHlEngine(_hl_engine)




        renderer_config = cls(
            md_engine=md_engine,
            hl_engine=hl_engine,
        )


        renderer_config.additional_properties = d
        return renderer_config

    @property
    def additional_keys(self) -> list[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties[key]

    def __setitem__(self, key: str, value: Any) -> None:
        self.additional_properties[key] = value

    def __delitem__(self, key: str) -> None:
        del self.additional_properties[key]

    def __contains__(self, key: str) -> bool:
        return key in self.additional_properties
