"""
AUTO-GENERATED by scripts/a2ui/generator.py from a2ui_seed.toml
Do not edit manually. Regenerate with: just a2ui-generate
"""

from __future__ import annotations

from typing import Any

from adk_fluent._ui import (
    UIAction,
    UIBinding,
    UICheck,
    UIComponent,
    _component,
)


class _GeneratedFactories:
    """Generated A2UI component and function factories.

    Mixed into the UI class via inheritance in _ui.py.
    """

    # === Component factories ===

    @staticmethod
    def text(text: str | UIBinding, *, variant: str = "body", id: str | None = None) -> UIComponent:
        """

        Args:
            text: Required.
            variant: One of ['h1', 'h2', 'h3', 'h4', 'h5', 'caption', 'body']. Default: 'body'.
        """
        return _component("Text", id=id, text=text, variant=variant)

    @staticmethod
    def image(
        url: str | UIBinding, *, fit: str = "fill", variant: str = "mediumFeature", id: str | None = None
    ) -> UIComponent:
        """

        Args:
            url: Required.
            fit: One of ['contain', 'cover', 'fill', 'none', 'scaleDown']. Default: 'fill'.
            variant: One of ['icon', 'avatar', 'smallFeature', 'mediumFeature', 'largeFeature', 'header']. Default: 'mediumFeature'.
        """
        return _component("Image", id=id, url=url, fit=fit, variant=variant)

    @staticmethod
    def icon(name: Any, *, id: str | None = None) -> UIComponent:
        """

        Args:
            name: Required.
        """
        return _component("Icon", id=id, name=name)

    @staticmethod
    def video(url: str | UIBinding, *, id: str | None = None) -> UIComponent:
        """

        Args:
            url: Required.
        """
        return _component("Video", id=id, url=url)

    @staticmethod
    def audio(
        url: str | UIBinding, *, description: str | UIBinding | None = None, id: str | None = None
    ) -> UIComponent:
        """

        Args:
            url: Required.
        """
        return _component("AudioPlayer", id=id, url=url, description=description)

    @staticmethod
    def row(
        *children: UIComponent, justify: str = "start", align: str = "stretch", id: str | None = None
    ) -> UIComponent:
        """A layout component that arranges its children horizontally. To create a grid layout, nest Columns within this Row.

        Args:
            *children: Child components.
            justify: One of ['center', 'end', 'spaceAround', 'spaceBetween', 'spaceEvenly', 'start', 'stretch']. Default: 'start'.
            align: One of ['start', 'center', 'end', 'stretch']. Default: 'stretch'.
        """
        _children = children
        return _component("Row", id=id, justify=justify, align=align, _children=_children)

    @staticmethod
    def column(
        *children: UIComponent, justify: str = "start", align: str = "stretch", id: str | None = None
    ) -> UIComponent:
        """A layout component that arranges its children vertically. To create a grid layout, nest Rows within this Column.

        Args:
            *children: Child components.
            justify: One of ['start', 'center', 'end', 'spaceBetween', 'spaceAround', 'spaceEvenly', 'stretch']. Default: 'start'.
            align: One of ['center', 'end', 'start', 'stretch']. Default: 'stretch'.
        """
        _children = children
        return _component("Column", id=id, justify=justify, align=align, _children=_children)

    @staticmethod
    def list_(
        *children: UIComponent, direction: str = "vertical", align: str = "stretch", id: str | None = None
    ) -> UIComponent:
        """

        Args:
            *children: Child components.
            direction: One of ['vertical', 'horizontal']. Default: 'vertical'.
            align: One of ['start', 'center', 'end', 'stretch']. Default: 'stretch'.
        """
        _children = children
        return _component("List", id=id, direction=direction, align=align, _children=_children)

    @staticmethod
    def card(child: UIComponent | None = None, id: str | None = None) -> UIComponent:
        """

        Args:
            child: Single child component.
        """
        _children = (child,) if child else ()
        return _component("Card", id=id, _children=_children)

    @staticmethod
    def tabs(tabs: list[tuple[str, UIComponent]] | None = None, id: str | None = None) -> UIComponent:
        """

        Args:
            tabs: List of (title, child_component) tuples.
        """
        _children = tuple(c for _, c in (tabs or []))
        _tabs_meta = [(t, "") for t, _ in (tabs or [])]
        return _component("Tabs", id=id, _children=_children)

    @staticmethod
    def modal(child: UIComponent | None = None, id: str | None = None) -> UIComponent:
        """

        Args:
            child: Single child component.
        """
        _children = (child,) if child else ()
        return _component("Modal", id=id, _children=_children)

    @staticmethod
    def divider(axis: str = "horizontal", id: str | None = None) -> UIComponent:
        """

        Args:
            axis: One of ['horizontal', 'vertical']. Default: 'horizontal'.
        """
        return _component("Divider", id=id, axis=axis)

    @staticmethod
    def button(
        variant: str = "default",
        checks: list[UICheck] | None = None,
        action: str | None = None,
        child: UIComponent | None = None,
        id: str | None = None,
    ) -> UIComponent:
        """

        Args:
            variant: One of ['default', 'primary', 'borderless']. Default: 'default'.
            checks: Validation rules.
            action: Server event name to dispatch on click.
            child: Single child component.
        """
        _checks = tuple(checks) if checks else ()
        _action = UIAction(event=action) if action else None
        _children = (child,) if child else ()
        return _component("Button", id=id, variant=variant, _children=_children, _checks=_checks, _action=_action)

    @staticmethod
    def text_field(
        label: str | UIBinding,
        *,
        value: str | UIBinding | None = None,
        variant: str = "shortText",
        bind: str | None = None,
        checks: list[UICheck] | None = None,
        id: str | None = None,
    ) -> UIComponent:
        """

        Args:
            label: Required.
            variant: One of ['longText', 'number', 'shortText', 'obscured']. Default: 'shortText'.
            bind: JSON Pointer path for two-way data binding.
            checks: Validation rules.
        """
        _bindings = (UIBinding(path=bind),) if bind else ()
        _checks = tuple(checks) if checks else ()
        return _component(
            "TextField", id=id, label=label, value=value, variant=variant, _bindings=_bindings, _checks=_checks
        )

    @staticmethod
    def checkbox(
        label: str | UIBinding,
        value: bool | UIBinding,
        *,
        bind: str | None = None,
        checks: list[UICheck] | None = None,
        id: str | None = None,
    ) -> UIComponent:
        """

        Args:
            label: Required.
            value: Required.
            bind: JSON Pointer path for two-way data binding.
            checks: Validation rules.
        """
        _bindings = (UIBinding(path=bind),) if bind else ()
        _checks = tuple(checks) if checks else ()
        return _component("CheckBox", id=id, label=label, value=value, _bindings=_bindings, _checks=_checks)

    @staticmethod
    def choice(
        options: list[dict[str, Any]],
        value: str | UIBinding,
        *,
        label: str | UIBinding | None = None,
        variant: str = "mutuallyExclusive",
        displayStyle: str = "checkbox",
        filterable: bool = False,
        bind: str | None = None,
        checks: list[UICheck] | None = None,
        id: str | None = None,
    ) -> UIComponent:
        """A component that allows selecting one or more options from a list.

        Args:
            options: Required.
            value: Required.
            variant: One of ['multipleSelection', 'mutuallyExclusive']. Default: 'mutuallyExclusive'.
            displayStyle: One of ['checkbox', 'chips']. Default: 'checkbox'.
            bind: JSON Pointer path for two-way data binding.
            checks: Validation rules.
        """
        _bindings = (UIBinding(path=bind),) if bind else ()
        _checks = tuple(checks) if checks else ()
        return _component(
            "ChoicePicker",
            id=id,
            options=options,
            value=value,
            label=label,
            variant=variant,
            displayStyle=displayStyle,
            filterable=filterable,
            _bindings=_bindings,
            _checks=_checks,
        )

    @staticmethod
    def slider(
        max: int | float,
        value: int | float | UIBinding,
        *,
        label: str | UIBinding | None = None,
        min: int | float = 0,
        bind: str | None = None,
        checks: list[UICheck] | None = None,
        id: str | None = None,
    ) -> UIComponent:
        """

        Args:
            max: Required.
            value: Required.
            bind: JSON Pointer path for two-way data binding.
            checks: Validation rules.
        """
        _bindings = (UIBinding(path=bind),) if bind else ()
        _checks = tuple(checks) if checks else ()
        return _component(
            "Slider", id=id, max=max, value=value, label=label, min=min, _bindings=_bindings, _checks=_checks
        )

    @staticmethod
    def date_time(
        value: str | UIBinding,
        *,
        enableDate: bool = False,
        enableTime: bool = False,
        min: str | UIBinding | None = None,
        max: str | UIBinding | None = None,
        label: str | UIBinding | None = None,
        bind: str | None = None,
        checks: list[UICheck] | None = None,
        id: str | None = None,
    ) -> UIComponent:
        """

        Args:
            value: Required.
            bind: JSON Pointer path for two-way data binding.
            checks: Validation rules.
        """
        _bindings = (UIBinding(path=bind),) if bind else ()
        _checks = tuple(checks) if checks else ()
        return _component(
            "DateTimeInput",
            id=id,
            value=value,
            enableDate=enableDate,
            enableTime=enableTime,
            min=min,
            max=max,
            label=label,
            _bindings=_bindings,
            _checks=_checks,
        )

    # === Function factories (validation, formatting, logic) ===

    @staticmethod
    def required(msg: str = "Required check failed") -> UICheck:
        """Checks that the value is not null, undefined, or empty."""
        return UICheck(fn="required", message=msg)

    @staticmethod
    def regex(pattern: str, *, msg: str = "Regex check failed") -> UICheck:
        """Checks that the value matches a regular expression string."""
        return UICheck(fn="regex", args=tuple((k, v) for k, v in (("pattern", pattern),) if v is not None), message=msg)

    @staticmethod
    def length(min: int | None = None, max: int | None = None, msg: str = "Length check failed") -> UICheck:
        """Checks string length constraints."""
        return UICheck(
            fn="length",
            args=tuple(
                (k, v)
                for k, v in (
                    ("min", min),
                    ("max", max),
                )
                if v is not None
            ),
            message=msg,
        )

    @staticmethod
    def numeric(
        min: int | float | None = None, max: int | float | None = None, msg: str = "Numeric check failed"
    ) -> UICheck:
        """Checks numeric range constraints."""
        return UICheck(
            fn="numeric",
            args=tuple(
                (k, v)
                for k, v in (
                    ("min", min),
                    ("max", max),
                )
                if v is not None
            ),
            message=msg,
        )

    @staticmethod
    def email(msg: str = "Email check failed") -> UICheck:
        """Checks that the value is a valid email address."""
        return UICheck(fn="email", message=msg)

    @staticmethod
    def formatString() -> dict[str, Any]:
        """Performs string interpolation of data model values and other functions in the catalog functions list and returns the resulting string."""
        return {"call": "formatString", "returnType": "string"}

    @staticmethod
    def formatNumber(
        decimals: int | float | UIBinding | None = None, grouping: bool | UIBinding | None = None
    ) -> dict[str, Any]:
        """Formats a number with the specified grouping and decimal precision."""
        return {"call": "formatNumber", "args": {"decimals": decimals, "grouping": grouping}, "returnType": "string"}

    @staticmethod
    def formatCurrency(
        currency: str | UIBinding,
        *,
        decimals: int | float | UIBinding | None = None,
        grouping: bool | UIBinding | None = None,
    ) -> dict[str, Any]:
        """Formats a number as a currency string."""
        return {
            "call": "formatCurrency",
            "args": {"currency": currency, "decimals": decimals, "grouping": grouping},
            "returnType": "string",
        }

    @staticmethod
    def formatDate(format: str | UIBinding) -> dict[str, Any]:
        """Formats a timestamp into a string using a pattern."""
        return {"call": "formatDate", "args": {"format": format}, "returnType": "string"}

    @staticmethod
    def pluralize(
        other: str | UIBinding,
        *,
        zero: str | UIBinding | None = None,
        one: str | UIBinding | None = None,
        two: str | UIBinding | None = None,
        few: str | UIBinding | None = None,
        many: str | UIBinding | None = None,
    ) -> dict[str, Any]:
        """Returns a localized string based on the Common Locale Data Repository (CLDR) plural category of the count (zero, one, two, few, many, other)."""
        return {
            "call": "pluralize",
            "args": {"zero": zero, "one": one, "two": two, "few": few, "many": many, "other": other},
            "returnType": "string",
        }

    @staticmethod
    def openUrl(url: str) -> dict[str, Any]:
        """Opens the specified URL in a browser or handler."""
        return {"call": "openUrl", "args": {"url": url}, "returnType": "void"}

    @staticmethod
    def and_(values: Any) -> dict[str, Any]:
        """Performs a logical AND operation on a list of boolean values."""
        return {"call": "and", "args": {"values": values}, "returnType": "boolean"}

    @staticmethod
    def or_(values: Any) -> dict[str, Any]:
        """Performs a logical OR operation on a list of boolean values."""
        return {"call": "or", "args": {"values": values}, "returnType": "boolean"}

    @staticmethod
    def not_() -> dict[str, Any]:
        """Performs a logical NOT operation on a boolean value."""
        return {"call": "not", "returnType": "boolean"}

    # === Aliases (DX sugar) ===

    @staticmethod
    def heading(content: str, *, id: str | None = None) -> UIComponent:
        """Sugar for UI.text(x, variant='h1')"""
        return _component("Text", id=id, text=content, variant="h1")

    @staticmethod
    def h1(content: str, *, id: str | None = None) -> UIComponent:
        """Heading level 1"""
        return _component("Text", id=id, text=content, variant="h1")

    @staticmethod
    def h2(content: str, *, id: str | None = None) -> UIComponent:
        """Heading level 2"""
        return _component("Text", id=id, text=content, variant="h2")

    @staticmethod
    def h3(content: str, *, id: str | None = None) -> UIComponent:
        """Heading level 3"""
        return _component("Text", id=id, text=content, variant="h3")

    @staticmethod
    def h4(content: str, *, id: str | None = None) -> UIComponent:
        """Heading level 4"""
        return _component("Text", id=id, text=content, variant="h4")

    @staticmethod
    def h5(content: str, *, id: str | None = None) -> UIComponent:
        """Heading level 5"""
        return _component("Text", id=id, text=content, variant="h5")

    @staticmethod
    def caption(content: str, *, id: str | None = None) -> UIComponent:
        """Caption text"""
        return _component("Text", id=id, text=content, variant="caption")

    @staticmethod
    def paragraph(content: str, *, id: str | None = None) -> UIComponent:
        """Body paragraph"""
        return _component("Text", id=id, text=content, variant="body")

    @staticmethod
    def primary_button(label: str, *, action: str | None = None, id: str | None = None) -> UIComponent:
        """Primary action button"""
        _action = UIAction(event=action) if action else None
        _label = _component("Text", text=label)
        return _component("Button", id=id, variant="primary", _children=(_label,), _action=_action)

    @staticmethod
    def link_button(label: str, *, action: str | None = None, id: str | None = None) -> UIComponent:
        """Borderless link-style button"""
        _action = UIAction(event=action) if action else None
        _label = _component("Text", text=label)
        return _component("Button", id=id, variant="borderless", _children=(_label,), _action=_action)

    @staticmethod
    def long_text(
        label: str, *, bind: str | None = None, checks: list[UICheck] | None = None, id: str | None = None
    ) -> UIComponent:
        """Multi-line text input"""
        _bindings = (UIBinding(path=bind),) if bind else ()
        _checks = tuple(checks) if checks else ()
        return _component("TextField", id=id, label=label, variant="longText", _bindings=_bindings, _checks=_checks)

    @staticmethod
    def password(
        label: str, *, bind: str | None = None, checks: list[UICheck] | None = None, id: str | None = None
    ) -> UIComponent:
        """Password input"""
        _bindings = (UIBinding(path=bind),) if bind else ()
        _checks = tuple(checks) if checks else ()
        return _component("TextField", id=id, label=label, variant="obscured", _bindings=_bindings, _checks=_checks)

    @staticmethod
    def number_input(
        label: str, *, bind: str | None = None, checks: list[UICheck] | None = None, id: str | None = None
    ) -> UIComponent:
        """Numeric text input"""
        _bindings = (UIBinding(path=bind),) if bind else ()
        _checks = tuple(checks) if checks else ()
        return _component("TextField", id=id, label=label, variant="number", _bindings=_bindings, _checks=_checks)
