"""Streamlit-friendly chart wrappers (delegate to core.notebook_helpers.charts).

Every wrapper takes a ``key`` — the same figure type renders on multiple
tabs (Summary, Benefits, Costs) within one script run, so Streamlit needs
explicit element IDs to avoid StreamlitDuplicateElementId errors.
"""

from __future__ import annotations

import streamlit as st

from core.notebook_helpers import charts as core_charts


def cashflow(yearly_breakdown, *, initial_cost: float = 0.0, key: str = "cashflow") -> None:
    fig = core_charts.cashflow_chart(yearly_breakdown, initial_cost=initial_cost)
    st.plotly_chart(fig, width="stretch", key=key)


def benefits_bar(items, *, key: str = "benefits_bar") -> None:
    fig = core_charts.benefits_bar(items)
    st.plotly_chart(fig, width="stretch", key=key)


def cost_pie(items, *, key: str = "cost_pie") -> None:
    fig = core_charts.cost_breakdown_pie(items)
    st.plotly_chart(fig, width="stretch", key=key)


def benefits_vs_costs_by_year(benefit_items, cost_items, *, key: str = "by_year") -> None:
    fig = core_charts.benefits_vs_costs_by_year(benefit_items, cost_items)
    st.plotly_chart(fig, width="stretch", key=key)


def scenario_bars(scenarios, *, key: str = "scenario_bars") -> None:
    fig = core_charts.scenario_comparison(scenarios)
    st.plotly_chart(fig, width="stretch", key=key)


def waterfall(values, *, key: str = "waterfall") -> None:
    fig = core_charts.waterfall(values)
    st.plotly_chart(fig, width="stretch", key=key)
