% period = params[:period] ? Period.from_key(params[:period]) : Period.last_30_days %>
<% series = @account.balance_series(period: period) %>
<% trend = series.trend %>
<%= turbo_frame_tag dom_id(@account, :chart_details) do %>
<% if trend.direction.flat? %>
<%= tag.span t(".no_change"), class: "text-secondary" %>
<% else %>
<%= tag.span "#{trend.value.positive? ? "+" : ""}#{format_money(trend.value)}", style: "color: #{trend.color}" %>
<% unless trend.percent.infinite? %>
<%= tag.span "(#{trend.percent}%)", style: "color: #{trend.color}" %>
<% end %>
<% end %>
<%= tag.span period.comparison_label, class: "text-secondary" %>
<% if series.any? %>
<% else %>
No data available for the selected period.
<% end %>
<% end %>