# This file was auto generated by Styx.
# Do not edit this file directly.

import typing
import pathlib
from styxdefs import *

SURFACE_FLIP_LR_METADATA = Metadata(
    id="bdd0276d22f7add2db023bdd235def55dde8330f.workbench",
    name="surface-flip-lr",
    package="workbench",
    container_image_tag="nx10x/workbench:2.1.0",
)


_SurfaceFlipLrParamsDictNoTag = typing.TypedDict('_SurfaceFlipLrParamsDictNoTag', {
    "surface": InputPathType,
    "surface-out": str,
})
SurfaceFlipLrParamsDictTagged = typing.TypedDict('SurfaceFlipLrParamsDictTagged', {
    "@type": typing.Literal["workbench/surface-flip-lr"],
    "surface": InputPathType,
    "surface-out": str,
})
SurfaceFlipLrParamsDict = _SurfaceFlipLrParamsDictNoTag | SurfaceFlipLrParamsDictTagged


class SurfaceFlipLrOutputs(typing.NamedTuple):
    """
    Output object returned when calling `SurfaceFlipLrParamsDict(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    surface_out: OutputPathType
    """the output flipped surface"""


def surface_flip_lr_params(
    surface: InputPathType,
    surface_out: str,
) -> SurfaceFlipLrParamsDictTagged:
    """
    Build parameters.
    
    Args:
        surface: the surface to flip.
        surface_out: the output flipped surface.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/surface-flip-lr",
        "surface": surface,
        "surface-out": surface_out,
    }
    return params


def surface_flip_lr_validate(
    params: typing.Any,
) -> None:
    """
    Validate parameters. Throws an error if `params` is not a valid
    `SurfaceFlipLrParamsDict` object.
    
    Args:
        params: The parameters object to validate.
    """
    if params is None or not isinstance(params, dict):
        raise StyxValidationError(f'Params object has the wrong type \'{type(params)}\'')
    if params.get("surface", None) is None:
        raise StyxValidationError("`surface` must not be None")
    if not isinstance(params["surface"], (pathlib.Path, str)):
        raise StyxValidationError(f'`surface` has the wrong type: Received `{type(params.get("surface", None))}` expected `InputPathType`')
    if params.get("surface-out", None) is None:
        raise StyxValidationError("`surface-out` must not be None")
    if not isinstance(params["surface-out"], str):
        raise StyxValidationError(f'`surface-out` has the wrong type: Received `{type(params.get("surface-out", None))}` expected `str`')


def surface_flip_lr_cargs(
    params: SurfaceFlipLrParamsDict,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.extend([
        "wb_command",
        "-surface-flip-lr"
    ])
    cargs.append(execution.input_file(params.get("surface", None)))
    cargs.append(params.get("surface-out", None))
    return cargs


def surface_flip_lr_outputs(
    params: SurfaceFlipLrParamsDict,
    execution: Execution,
) -> SurfaceFlipLrOutputs:
    """
    Build outputs object containing output file paths and possibly stdout/stderr.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Outputs object.
    """
    ret = SurfaceFlipLrOutputs(
        root=execution.output_file("."),
        surface_out=execution.output_file(params.get("surface-out", None)),
    )
    return ret


def surface_flip_lr_execute(
    params: SurfaceFlipLrParamsDict,
    runner: Runner | None = None,
) -> SurfaceFlipLrOutputs:
    """
    MIRROR A SURFACE THROUGH THE YZ PLANE.
    
    This command negates the x coordinate of each vertex, and flips the surface
    normals, so that you have a surface of opposite handedness with the same
    features and vertex correspondence, with normals consistent with the
    original surface. That is, if the input surface has normals facing outward,
    the output surface will also have normals facing outward.
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceFlipLrOutputs`).
    """
    surface_flip_lr_validate(params)
    runner = runner or get_global_runner()
    execution = runner.start_execution(SURFACE_FLIP_LR_METADATA)
    params = execution.params(params)
    cargs = surface_flip_lr_cargs(params, execution)
    ret = surface_flip_lr_outputs(params, execution)
    execution.run(cargs)
    return ret


def surface_flip_lr(
    surface: InputPathType,
    surface_out: str,
    runner: Runner | None = None,
) -> SurfaceFlipLrOutputs:
    """
    MIRROR A SURFACE THROUGH THE YZ PLANE.
    
    This command negates the x coordinate of each vertex, and flips the surface
    normals, so that you have a surface of opposite handedness with the same
    features and vertex correspondence, with normals consistent with the
    original surface. That is, if the input surface has normals facing outward,
    the output surface will also have normals facing outward.
    
    Args:
        surface: the surface to flip.
        surface_out: the output flipped surface.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SurfaceFlipLrOutputs`).
    """
    params = surface_flip_lr_params(
        surface=surface,
        surface_out=surface_out,
    )
    return surface_flip_lr_execute(params, runner)


__all__ = [
    "SURFACE_FLIP_LR_METADATA",
    "SurfaceFlipLrOutputs",
    "SurfaceFlipLrParamsDict",
    "SurfaceFlipLrParamsDictTagged",
    "surface_flip_lr",
    "surface_flip_lr_execute",
    "surface_flip_lr_params",
]
