using FinalToken.Core; namespace FinalToken.App; public sealed partial class DataTooltip { public static DataTooltip Reset(ResetInstance row, TimeProvider clock) { var rows = new List { new("Start", Display.Projection(row.Start, clock)), new(row.Running ? "As of" : "End", Display.Projection(row.End, clock)), new("Nominal reset", Display.Projection(row.Reset, clock)), new("Lasted", Display.ResetDuration(row.Duration)), new("Final use", Display.ResetPercent(row.Final.Used, row.Final.Origin)), new("Peak", row.Peak is { } peak ? Display.ResetPercent(peak, row.PeakOrigin) : "Collecting history"), new("100 % reached", row.ReachedLimit is { } reached ? (row.BurnUp.ReachedOrigin == UseOrigin.Estimated ? "≈ " : "") + Display.Projection(reached, clock) : "Not reached"), new("Time at 100 %", Display.ResetDuration(row.TimeAtLimit)), new("Total tokens", Count(row.Tokens.Total)), new("Input", Count(row.Tokens.Input)), new("Cache read", Count(row.Tokens.CacheRead)), new("Cache write", Count(row.Tokens.CacheWrite)), new("Output", Count(row.Tokens.Output)), new("Reasoning (in output)", Count(row.Tokens.ReasoningOutput)), new("API list value", Display.Money(row.ApiValue)), new("Unpriced tokens", Count(row.UnpricedTokens)) }; if (row.Models.Count > 0) rows.Add(new("Models", row.Models.Count.ToString())); foreach (var model in row.Models) rows.Add(new(model.Model ?? "Unknown model", Count(model.Tokens.Total) + " · " + Display.Money(model.ApiValue))); rows.Add(new("Tokens per percent", row.ValuePerPercent is { } rate ? "≈ " + Display.Compact(rate.Tokens) + " · " + rate.Tokens.ToString("N2") : "No qualifying instance")); rows.Add(new("API value per percent", Display.Money(row.ValuePerPercent?.ApiValue))); rows.Add(new("Value basis", row.ValuePerPercent?.Basis switch { PercentBasis.OwnInstance => "Own instance (final ≥ 5 %)", PercentBasis.SeriesMedian => "Median of qualifying listed instances", _ => "No instance with final ≥ 5 %" })); if (row.Unused is { } unused) AddValue("Unused", unused); if (row.Gift is { } gift) { AddValue("Gift", gift); rows.Add(new("Skipped", Display.ResetDuration(row.Skipped))); } var estimates = new List(); if (row.Final.Origin == UseOrigin.Estimated) estimates.Add("final"); if (row.PeakOrigin == UseOrigin.Estimated) estimates.Add("peak"); if (row.BurnUp.ReachedOrigin == UseOrigin.Estimated) estimates.Add("100 % time"); if (row.Unused is not null) estimates.Add("unused value"); if (row.Gift is not null) estimates.Add("gift value"); rows.Add(new("Estimated figures", estimates.Count == 0 ? "API list value" : string.Join(", ", estimates) + ", API list value")); rows.Add(new("Prices checked", ApiPrices.CheckedOn.ToString("yyyy-MM-dd") + " · hourly boundary tokens")); return new(row.Running ? "Running instance" : row.Early ? "Early reset" : "On-time reset", rows.ToArray()); void AddValue(string label, ResetValue value) => rows.Add(new(label, Display.ResetPercent(value.Percent, UseOrigin.Estimated) + " · " + (value.Tokens is { } count ? "≈ " + Display.Compact(count) + " tokens · " : "") + Display.Money(value.ApiValue))); } }