# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs
# Based on "crates/store/re_sdk_types/definitions/rerun/blueprint/views/text_log.fbs".

from __future__ import annotations

from typing import TYPE_CHECKING

__all__ = ["TextLogView"]


from .. import archetypes as blueprint_archetypes
from ..api import View, ViewContentsLike, VisualizerLike

if TYPE_CHECKING:
    from collections.abc import Iterable, Mapping

    from ... import datatypes
    from ..._baseclasses import (
        AsComponents,
        DescribedComponentBatch,
    )
    from ...datatypes import EntityPathLike, Utf8Like


class TextLogView(View):
    """
    **View**: A view of a text log, for use with [`archetypes.TextLog`][rerun.archetypes.TextLog].

    ⚠️ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**

    Example
    -------
    ### Use a blueprint to show a TextLogView.:
    ```python
    import rerun as rr
    import rerun.blueprint as rrb

    rr.init("rerun_example_text_log", spawn=True)

    rr.set_time("time", sequence=0)
    rr.log(
        "log/status", rr.TextLog("Application started.", level=rr.TextLogLevel.INFO)
    )
    rr.set_time("time", sequence=5)
    rr.log("log/other", rr.TextLog("A warning.", level=rr.TextLogLevel.WARN))
    for i in range(10):
        rr.set_time("time", sequence=i)
        rr.log(
            "log/status",
            rr.TextLog(f"Processing item {i}.", level=rr.TextLogLevel.INFO),
        )

    # Create a text view that displays all logs.
    blueprint = rrb.Blueprint(
        rrb.TextLogView(
            origin="/log",
            name="Text Logs",
            columns=rrb.TextLogColumns(
                timeline_columns=["time"],
                text_log_columns=["loglevel", "entitypath", "body"],
            ),
            rows=rrb.TextLogRows(
                filter_by_log_level=["INFO", "WARN", "ERROR"],
            ),
            format_options=rrb.TextLogFormat(
                monospace_body=False,
            ),
        ),
        collapse_panels=True,
    )

    rr.send_blueprint(blueprint)
    ```
    <center>
    <picture>
      <source media="(max-width: 480px)" srcset="https://static.rerun.io/text_log/457ab91ec42a481bacae4146c0fc01eee397bb86/480w.png">
      <source media="(max-width: 768px)" srcset="https://static.rerun.io/text_log/457ab91ec42a481bacae4146c0fc01eee397bb86/768w.png">
      <source media="(max-width: 1024px)" srcset="https://static.rerun.io/text_log/457ab91ec42a481bacae4146c0fc01eee397bb86/1024w.png">
      <source media="(max-width: 1200px)" srcset="https://static.rerun.io/text_log/457ab91ec42a481bacae4146c0fc01eee397bb86/1200w.png">
      <img src="https://static.rerun.io/text_log/457ab91ec42a481bacae4146c0fc01eee397bb86/full.png" width="640">
    </picture>
    </center>

    """

    def __init__(
        self,
        *,
        origin: EntityPathLike = "/",
        contents: ViewContentsLike = "$origin/**",
        name: Utf8Like | None = None,
        visible: datatypes.BoolLike | None = None,
        defaults: Iterable[AsComponents | Iterable[DescribedComponentBatch]] | None = None,
        overrides: Mapping[EntityPathLike, VisualizerLike | Iterable[VisualizerLike]] | None = None,
        columns: blueprint_archetypes.TextLogColumns | None = None,
        rows: blueprint_archetypes.TextLogRows | None = None,
        format_options: blueprint_archetypes.TextLogFormat | None = None,
    ) -> None:
        """
        Construct a blueprint for a new TextLogView view.

        Parameters
        ----------
        origin:
            The `EntityPath` to use as the origin of this view.
            All other entities will be transformed to be displayed relative to this origin.
        contents:
            The contents of the view specified as a query expression.
            This is either a single expression, or a list of multiple expressions.
            See [rerun.blueprint.archetypes.ViewContents][].
        name:
            The display name of the view.
        visible:
            Whether this view is visible.

            Defaults to true if not specified.
        defaults:
            List of archetypes or (described) component batches to add to the view.
            When an archetype in the view is missing a component included in this set,
            the value of default will be used instead of the normal fallback for the visualizer.

            Note that an archetype's required components typically don't have any effect.
            It is recommended to use the archetype's `from_fields` method instead and only specify the fields that you need.
        overrides:
            Dictionary of visualizer overrides to apply to the view. The key is the path to the entity where the override
            should be applied. The value is a list of visualizers which should be enabled for that entity, or a single visualizer.

            Each visualizer can be configured with arbitrary overrides and mappings.

            For any entity mentioned in this map, visualizers are no longer added automatically based on the entity's components.

            Important note: the path must be a fully qualified entity path starting at the root. The override paths
            do not yet support `$origin` relative paths or glob expressions.
            This will be addressed in <https://github.com/rerun-io/rerun/issues/6673>.

        columns:
            The columns to display in the view.
        rows:
            Filter for rows to display in the view.
        format_options:
            Formatting options for the text log view.

        """

        properties: dict[str, AsComponents] = {}
        if columns is not None:
            if not isinstance(columns, blueprint_archetypes.TextLogColumns):
                columns = blueprint_archetypes.TextLogColumns(columns)
            properties["TextLogColumns"] = columns

        if rows is not None:
            if not isinstance(rows, blueprint_archetypes.TextLogRows):
                rows = blueprint_archetypes.TextLogRows(rows)
            properties["TextLogRows"] = rows

        if format_options is not None:
            if not isinstance(format_options, blueprint_archetypes.TextLogFormat):
                format_options = blueprint_archetypes.TextLogFormat(format_options)
            properties["TextLogFormat"] = format_options

        super().__init__(
            class_identifier="TextLog",
            origin=origin,
            contents=contents,
            name=name,
            visible=visible,
            properties=properties,
            defaults=defaults,
            overrides=overrides,
        )
