# generated by datamodel-codegen:
#   filename:  tyx-settings.schema.json
#   timestamp: 2025-10-22T13:26:48+00:00

from __future__ import annotations

from typing import Dict, List, Optional

from pydantic import BaseModel, ConfigDict, Field


class NamedItem(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    type: str = Field(..., description="The TyX type of this parameter.")
    required: Optional[bool] = Field(
        None, description="Whether this parameter is required."
    )
    label: Optional[str] = Field(
        None, description="Optional label (usually name) of this parameter."
    )
    documentation: Optional[str] = Field(
        None, description="Optional documentation for this parameter to show on hover."
    )
    name: str


class ParameterDescription(BaseModel):
    """
    TyX specification for a function parameter.
    """

    model_config = ConfigDict(
        extra="forbid",
    )
    type: str = Field(..., description="The TyX type of this parameter.")
    required: Optional[bool] = Field(
        None, description="Whether this parameter is required."
    )
    label: Optional[str] = Field(
        None, description="Optional label (usually name) of this parameter."
    )
    documentation: Optional[str] = Field(
        None, description="Optional documentation for this parameter to show on hover."
    )


class FunctionDefinition(BaseModel):
    """
    TyX specification for a Typst function.
    """

    model_config = ConfigDict(
        extra="forbid",
    )
    positional: Optional[List[ParameterDescription]] = Field(
        None, description="Positional arguments to the function."
    )
    named: Optional[List[NamedItem]] = Field(
        None, description="Named arguments to the function."
    )
    inline: Optional[bool] = Field(
        None, description="Whether TyX should display the function as inline."
    )


class TyXSettings(BaseModel):
    """
    App-wide customization for TyX.
    """

    model_config = ConfigDict(
        extra="forbid",
    )
    field_schema: Optional[str] = Field(None, alias="$schema")
    language: Optional[str] = Field(None, description="The UI Language for the app.")
    keyboardShortcuts: Optional[List[List[str]]] = Field(
        None,
        description="An array of pairs of [shortcut, command] of keyboard shortcuts.",
    )
    unbindKeyboardShortcuts: Optional[List[str]] = Field(
        None, description='An array of default shortcuts to unbind, e.g. "mod+b"'
    )
    keyboardMap: Optional[str] = Field(
        None, description="The keyboard map for the app."
    )
    mathInlineShortcuts: Optional[List[List[str]]] = Field(
        None,
        description="An array of pairs of [shortcut, command] of LaTeX inline math replacements.",
    )
    format: Optional[bool] = Field(
        None, description="Whether to format the output Typst documents."
    )
    autoStartServer: Optional[bool] = Field(
        None,
        description="Whether to automatically start a server that updates the PDF when the document changes.",
    )
    serverDebounce: Optional[float] = Field(
        None,
        description="The amount in milliseconds to debounce before updating the PDF.",
    )
    functions: Optional[Dict[str, FunctionDefinition]] = Field(
        None, description="Additional TyX function definitions."
    )
