"""Reusable pipeline helpers for legacy workflow migration."""

from __future__ import annotations

from femic.pipeline.io import (
    DEFAULT_DEV_CONFIG_PATH,
    DEFAULT_RUN_CONFIG_PATH,
    EffectiveRunOptions,
    FALLBACK_DEFAULT_TSA_LIST,
    LegacyDataArtifactPaths,
    LegacyExternalDataPaths,
    LegacyExecutionPlan,
    PipelineRunProfile,
    build_legacy_data_artifact_paths,
    PipelineRunConfig,
    build_ria_vri_checkpoint_paths,
    build_legacy_execution_plan,
    build_pipeline_run_config,
    file_sha256,
    load_pipeline_run_profile,
    load_default_tsa_list,
    normalize_tsa_list,
    resolve_effective_run_options,
    resolve_legacy_external_data_paths,
)
from femic.pipeline.manifest import (
    build_run_manifest_payload,
    collect_runtime_versions,
    write_manifest,
)
from femic.pipeline.pre_vdyp import (
    load_vdyp_prep_checkpoint,
    pre_vdyp_checkpoint_path,
    save_vdyp_prep_checkpoint,
    serialize_vdyp_prep_payload,
)
from femic.pipeline.vdyp_logging import (
    append_jsonl,
    append_text,
    build_tsa_vdyp_log_paths,
    resolve_run_id,
    vdyp_log_base,
)
from femic.pipeline.vdyp_curves import (
    fill_curve_left,
    legacy_fit_func1,
    legacy_fit_func1_bounds_func,
    legacy_fit_func2,
    legacy_fit_func2_bounds_func,
    prepend_quasi_origin_point,
    process_vdyp_out,
)
from femic.pipeline.vdyp_overrides import (
    DEFAULT_VDYP_KWARG_OVERRIDES,
    vdyp_kwarg_overrides_for_tsa,
)
from femic.pipeline.stages import (
    execute_legacy_tsa_stage,
    LegacyTSAStageState,
    ParallelExecutionBackend,
    StageResult,
    initialize_parallel_execution_backend,
    initialize_legacy_tsa_stage_state,
    load_legacy_module,
    prepare_tsa_index,
    run_legacy_subprocess,
    run_legacy_tsa_loop,
    should_skip_if_outputs_exist,
)
from femic.pipeline.legacy_runtime import (
    Legacy01ARuntimeConfig,
    Legacy01BRuntimeConfig,
    build_legacy_01a_runtime_config,
    build_legacy_01b_runtime_config,
)
from femic.pipeline.bundle import (
    BundleAssemblyResult,
    BundlePaths,
    assign_curve_ids_from_au_table,
    build_bundle_tables_from_curves,
    bundle_tables_ready,
    emit_missing_au_curve_mapping_warning,
    ensure_au_table_index,
    ensure_scsi_au_from_table,
    load_bundle_tables,
    resolve_bundle_paths,
    write_bundle_tables,
)
from femic.pipeline.vdyp_sampling import nsamples_from_curves
from femic.pipeline.vdyp_io import import_vdyp_tables, write_vdyp_infiles_plylyr
from femic.pipeline.tipsy import (
    TIPSYCandidateEvaluation,
    build_tipsy_params_for_tsa,
    build_tipsy_input_table,
    tipsy_params_excel_path,
    build_tipsy_warning_event,
    compute_vdyp_oaf1,
    compute_vdyp_site_index,
    evaluate_tipsy_candidate,
    tipsy_stage_output_paths,
    write_tipsy_input_exports,
)
from femic.pipeline.tsa import (
    assign_au_ids_from_scsi,
    assign_thlb_raw_from_raster,
    assign_thlb_area_and_flag,
    assign_si_levels_from_stratum_quantiles,
    assign_stratum_matches_from_au_table,
    build_au_assignment_null_summary,
    mean_thlb_for_geometry,
    emit_missing_au_mapping_warning,
    lookup_scsi_au_base,
    summarize_missing_au_mappings,
    validate_nonempty_au_assignment,
)
from femic.pipeline.tipsy_config import (
    build_tipsy_params_from_config,
    discover_tipsy_config_tsas,
    load_tipsy_tsa_config,
    resolve_tipsy_runtime_options,
    resolve_tipsy_param_builder,
    tipsy_config_path_for_tsa,
    validate_tipsy_tsa_config,
)
from femic.pipeline.tipsy_legacy import (
    build_tipsy_exclusion,
    get_legacy_tipsy_builders,
)
from femic.pipeline.vdyp import build_vdyp_cache_paths, build_vdyp_log_paths
from femic.pipeline.vri import (
    assign_stratum_codes_with_lexmatch,
    assign_forest_type_from_species_pct,
    classify_stand_cdm,
    classify_stand_forest_type,
    derive_species_list_from_slots,
    filter_post_thlb_stands,
    is_conifer_species_code,
    is_deciduous_species_code,
    normalize_and_filter_checkpoint2_records,
    pconif,
    pdecid,
    stratify_stand,
)
from femic.pipeline.species_volume import (
    compile_species_volume_columns,
    compile_species_volume_series,
    species_volume_input_columns,
)
from femic.pipeline.siteprod import (
    DEFAULT_SITEPROD_SPECIES_LOOKUP,
    assign_siteprod_from_raster,
    build_siteprod_layer_tif_path,
    enumerate_siteprod_layer_tif_paths,
    export_and_stack_siteprod_layers,
    list_siteprod_layers,
    mean_siteprod_for_row,
    parse_arc_raster_rescue_layer_mappings,
    siteprod_species_lookup,
)
from femic.pipeline.stands import (
    DEFAULT_STANDS_PROP_NAMES,
    DEFAULT_STANDS_PROP_TYPES,
    build_stands_column_map,
    export_stands_shapefiles,
    extract_stand_features_for_tsa,
    prepare_stands_export_frame,
    should_skip_stands_export,
)
from femic.pipeline.vdyp_stage import (
    CurveSmoothingPlotConfig,
    StratumFitRunConfig,
    SmoothedCurveResult,
    build_bootstrap_vdyp_results_runner,
    build_curve_fit_adapter,
    build_curve_smoothing_plot_config,
    build_stratum_fit_run_config,
    build_fit_stratum_curves_runner,
    build_run_vdyp_for_stratum_runner,
    build_smoothed_curve_table,
    compile_strata_fit_results,
    execute_bootstrap_vdyp_runs,
    execute_curve_smoothing_runs,
    execute_vdyp_batch,
    fit_stratum_curves,
    load_vdyp_input_tables,
    load_or_build_vdyp_results_tsa,
    plot_curve_overlays,
    run_vdyp_for_stratum,
    run_vdyp_sampling,
)

__all__ = [
    "DEFAULT_DEV_CONFIG_PATH",
    "DEFAULT_RUN_CONFIG_PATH",
    "EffectiveRunOptions",
    "FALLBACK_DEFAULT_TSA_LIST",
    "LegacyDataArtifactPaths",
    "LegacyExternalDataPaths",
    "LegacyExecutionPlan",
    "PipelineRunProfile",
    "PipelineRunConfig",
    "build_legacy_data_artifact_paths",
    "build_ria_vri_checkpoint_paths",
    "resolve_legacy_external_data_paths",
    "StageResult",
    "Legacy01ARuntimeConfig",
    "Legacy01BRuntimeConfig",
    "LegacyTSAStageState",
    "ParallelExecutionBackend",
    "BundlePaths",
    "BundleAssemblyResult",
    "assign_curve_ids_from_au_table",
    "build_legacy_execution_plan",
    "build_legacy_01a_runtime_config",
    "build_legacy_01b_runtime_config",
    "execute_legacy_tsa_stage",
    "initialize_parallel_execution_backend",
    "initialize_legacy_tsa_stage_state",
    "load_legacy_module",
    "prepare_tsa_index",
    "run_legacy_subprocess",
    "run_legacy_tsa_loop",
    "should_skip_if_outputs_exist",
    "resolve_bundle_paths",
    "build_bundle_tables_from_curves",
    "bundle_tables_ready",
    "emit_missing_au_curve_mapping_warning",
    "ensure_au_table_index",
    "load_bundle_tables",
    "write_bundle_tables",
    "ensure_scsi_au_from_table",
    "build_run_manifest_payload",
    "collect_runtime_versions",
    "load_vdyp_prep_checkpoint",
    "pre_vdyp_checkpoint_path",
    "save_vdyp_prep_checkpoint",
    "serialize_vdyp_prep_payload",
    "append_jsonl",
    "append_text",
    "build_tsa_vdyp_log_paths",
    "resolve_run_id",
    "vdyp_log_base",
    "fill_curve_left",
    "legacy_fit_func1",
    "legacy_fit_func1_bounds_func",
    "legacy_fit_func2",
    "legacy_fit_func2_bounds_func",
    "prepend_quasi_origin_point",
    "process_vdyp_out",
    "DEFAULT_VDYP_KWARG_OVERRIDES",
    "vdyp_kwarg_overrides_for_tsa",
    "import_vdyp_tables",
    "write_vdyp_infiles_plylyr",
    "nsamples_from_curves",
    "compute_vdyp_oaf1",
    "compute_vdyp_site_index",
    "build_tipsy_input_table",
    "tipsy_params_excel_path",
    "tipsy_stage_output_paths",
    "write_tipsy_input_exports",
    "assign_stratum_matches_from_au_table",
    "assign_si_levels_from_stratum_quantiles",
    "lookup_scsi_au_base",
    "assign_au_ids_from_scsi",
    "mean_thlb_for_geometry",
    "assign_thlb_raw_from_raster",
    "assign_thlb_area_and_flag",
    "summarize_missing_au_mappings",
    "emit_missing_au_mapping_warning",
    "build_au_assignment_null_summary",
    "validate_nonempty_au_assignment",
    "build_tipsy_params_for_tsa",
    "build_tipsy_warning_event",
    "evaluate_tipsy_candidate",
    "TIPSYCandidateEvaluation",
    "tipsy_config_path_for_tsa",
    "discover_tipsy_config_tsas",
    "load_tipsy_tsa_config",
    "resolve_tipsy_runtime_options",
    "resolve_tipsy_param_builder",
    "validate_tipsy_tsa_config",
    "build_tipsy_params_from_config",
    "build_tipsy_exclusion",
    "get_legacy_tipsy_builders",
    "write_manifest",
    "build_vdyp_cache_paths",
    "build_vdyp_log_paths",
    "is_conifer_species_code",
    "is_deciduous_species_code",
    "stratify_stand",
    "assign_stratum_codes_with_lexmatch",
    "pconif",
    "pdecid",
    "classify_stand_cdm",
    "classify_stand_forest_type",
    "derive_species_list_from_slots",
    "assign_forest_type_from_species_pct",
    "filter_post_thlb_stands",
    "normalize_and_filter_checkpoint2_records",
    "species_volume_input_columns",
    "compile_species_volume_series",
    "compile_species_volume_columns",
    "DEFAULT_SITEPROD_SPECIES_LOOKUP",
    "parse_arc_raster_rescue_layer_mappings",
    "list_siteprod_layers",
    "build_siteprod_layer_tif_path",
    "enumerate_siteprod_layer_tif_paths",
    "export_and_stack_siteprod_layers",
    "siteprod_species_lookup",
    "mean_siteprod_for_row",
    "assign_siteprod_from_raster",
    "DEFAULT_STANDS_PROP_NAMES",
    "DEFAULT_STANDS_PROP_TYPES",
    "build_stands_column_map",
    "export_stands_shapefiles",
    "extract_stand_features_for_tsa",
    "prepare_stands_export_frame",
    "should_skip_stands_export",
    "build_pipeline_run_config",
    "file_sha256",
    "load_pipeline_run_profile",
    "load_default_tsa_list",
    "normalize_tsa_list",
    "resolve_effective_run_options",
    "execute_vdyp_batch",
    "execute_bootstrap_vdyp_runs",
    "build_bootstrap_vdyp_results_runner",
    "execute_curve_smoothing_runs",
    "CurveSmoothingPlotConfig",
    "StratumFitRunConfig",
    "SmoothedCurveResult",
    "build_curve_smoothing_plot_config",
    "build_stratum_fit_run_config",
    "plot_curve_overlays",
    "fit_stratum_curves",
    "build_fit_stratum_curves_runner",
    "build_run_vdyp_for_stratum_runner",
    "run_vdyp_for_stratum",
    "run_vdyp_sampling",
    "build_curve_fit_adapter",
    "build_smoothed_curve_table",
    "compile_strata_fit_results",
    "load_vdyp_input_tables",
    "load_or_build_vdyp_results_tsa",
]
