using System.Text.Json.Serialization;
namespace AIStudio.Assistants.VisualBriefing;
///
/// The data of a briefing which AI Studio writes itself and no model may change, under the key _mwai.
///
/// The version of the schema of the briefing data.
/// The version of the runtime script of the briefing.
/// The version of AI Studio which created the briefing.
/// The embedded pictures, by their asset IDs.
/// What the briefing tells about each picture, or null where the data only gets validated.
/// The texts of the footer, by their keys.
internal sealed record VisualBriefingProtectedData(
int SchemaVersion,
int RuntimeVersion,
string AIStudioVersion,
IReadOnlyDictionary Assets,
[property: JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] Dictionary? AssetMetadata,
Dictionary Footer)
{
private const string VALIDATION_VALUE = "validation";
private const string VALIDATION_ASSET = "data:image/png;base64,AA==";
///
/// Creates stand-in protected data for validating a compiled briefing before it gets assembled.
///
/// The planned pictures of the briefing.
/// The stand-in protected data.
internal static VisualBriefingProtectedData ForValidation(IEnumerable assetPlan) => new(
VisualBriefingVersions.SCHEMA,
VisualBriefingVersions.RUNTIME,
VALIDATION_VALUE,
assetPlan.ToDictionary(asset => asset.AssetId, _ => VALIDATION_ASSET, StringComparer.Ordinal),
null,
new Dictionary(StringComparer.Ordinal)
{
["createdWith"] = VALIDATION_VALUE,
["models"] = VALIDATION_VALUE,
["createdAt"] = VALIDATION_VALUE,
["authors"] = VALIDATION_VALUE,
["protection"] = VALIDATION_VALUE,
});
}