namespace SpaceGame.Api.Geopolitics.Contracts;

public sealed record SystemRouteLinkSnapshot(
  string Id,
  string SourceSystemId,
  string DestinationSystemId,
  float Distance,
  bool IsPrimaryLane);

public sealed record DiplomaticRelationSnapshot(
  string Id,
  string FactionAId,
  string FactionBId,
  string Status,
  string Posture,
  float TrustScore,
  float TensionScore,
  float GrievanceScore,
  string TradeAccessPolicy,
  string MilitaryAccessPolicy,
  string? WarStateId,
  DateTimeOffset? CeasefireUntilUtc,
  DateTimeOffset UpdatedAtUtc,
  IReadOnlyList<string> ActiveTreatyIds,
  IReadOnlyList<string> ActiveIncidentIds);

public sealed record TreatySnapshot(
  string Id,
  string Kind,
  string Status,
  string TradeAccessPolicy,
  string MilitaryAccessPolicy,
  string? Summary,
  DateTimeOffset CreatedAtUtc,
  DateTimeOffset UpdatedAtUtc,
  IReadOnlyList<string> FactionIds);

public sealed record DiplomaticIncidentSnapshot(
  string Id,
  string Kind,
  string Status,
  string SourceFactionId,
  string TargetFactionId,
  string? SystemId,
  string? BorderEdgeId,
  string Summary,
  float Severity,
  float EscalationScore,
  DateTimeOffset CreatedAtUtc,
  DateTimeOffset LastObservedAtUtc);

public sealed record BorderTensionSnapshot(
  string Id,
  string RelationId,
  string BorderEdgeId,
  string FactionAId,
  string FactionBId,
  string Status,
  float TensionScore,
  float IncidentScore,
  float MilitaryPressure,
  float AccessFriction,
  DateTimeOffset UpdatedAtUtc,
  IReadOnlyList<string> SystemIds);

public sealed record WarStateSnapshot(
  string Id,
  string RelationId,
  string FactionAId,
  string FactionBId,
  string Status,
  string WarGoal,
  float EscalationScore,
  DateTimeOffset StartedAtUtc,
  DateTimeOffset? CeasefireUntilUtc,
  DateTimeOffset UpdatedAtUtc,
  IReadOnlyList<string> ActiveFrontLineIds);

public sealed record DiplomaticStateSnapshot(
  IReadOnlyList<DiplomaticRelationSnapshot> Relations,
  IReadOnlyList<TreatySnapshot> Treaties,
  IReadOnlyList<DiplomaticIncidentSnapshot> Incidents,
  IReadOnlyList<BorderTensionSnapshot> BorderTensions,
  IReadOnlyList<WarStateSnapshot> Wars);

public sealed record TerritoryClaimSnapshot(
  string Id,
  string? SourceClaimId,
  string FactionId,
  string SystemId,
  string CelestialId,
  string Status,
  string ClaimKind,
  float ClaimStrength,
  DateTimeOffset UpdatedAtUtc);

public sealed record TerritoryInfluenceSnapshot(
  string Id,
  string SystemId,
  string FactionId,
  float ClaimStrength,
  float AssetStrength,
  float LogisticsStrength,
  float TotalInfluence,
  bool IsContesting,
  DateTimeOffset UpdatedAtUtc);

public sealed record TerritoryControlStateSnapshot(
  string SystemId,
  string? ControllerFactionId,
  string? PrimaryClaimantFactionId,
  string ControlKind,
  bool IsContested,
  float ControlScore,
  float StrategicValue,
  IReadOnlyList<string> ClaimantFactionIds,
  IReadOnlyList<string> InfluencingFactionIds,
  DateTimeOffset UpdatedAtUtc);

public sealed record SectorStrategicProfileSnapshot(
  string SystemId,
  string? ControllerFactionId,
  string ZoneKind,
  bool IsContested,
  float StrategicValue,
  float SecurityRating,
  float TerritorialPressure,
  float LogisticsValue,
  string? EconomicRegionId,
  string? FrontLineId,
  DateTimeOffset UpdatedAtUtc);

public sealed record BorderEdgeSnapshot(
  string Id,
  string SourceSystemId,
  string DestinationSystemId,
  string? SourceFactionId,
  string? DestinationFactionId,
  bool IsContested,
  string? RelationId,
  float TensionScore,
  float CorridorImportance,
  DateTimeOffset UpdatedAtUtc);

public sealed record FrontLineSnapshot(
  string Id,
  string Kind,
  string Status,
  string? AnchorSystemId,
  float PressureScore,
  float SupplyRisk,
  DateTimeOffset UpdatedAtUtc,
  IReadOnlyList<string> FactionIds,
  IReadOnlyList<string> SystemIds,
  IReadOnlyList<string> BorderEdgeIds);

public sealed record TerritoryZoneSnapshot(
  string Id,
  string SystemId,
  string? FactionId,
  string Kind,
  string Status,
  string? Reason,
  DateTimeOffset UpdatedAtUtc);

public sealed record TerritoryPressureSnapshot(
  string Id,
  string SystemId,
  string? FactionId,
  string Kind,
  float PressureScore,
  float SecurityScore,
  float HostileInfluence,
  float CorridorRisk,
  DateTimeOffset UpdatedAtUtc);

public sealed record TerritoryStateSnapshot(
  IReadOnlyList<TerritoryClaimSnapshot> Claims,
  IReadOnlyList<TerritoryInfluenceSnapshot> Influences,
  IReadOnlyList<TerritoryControlStateSnapshot> ControlStates,
  IReadOnlyList<SectorStrategicProfileSnapshot> StrategicProfiles,
  IReadOnlyList<BorderEdgeSnapshot> BorderEdges,
  IReadOnlyList<FrontLineSnapshot> FrontLines,
  IReadOnlyList<TerritoryZoneSnapshot> Zones,
  IReadOnlyList<TerritoryPressureSnapshot> Pressures);

public sealed record EconomicRegionSnapshot(
  string Id,
  string? FactionId,
  string Label,
  string Kind,
  string Status,
  string CoreSystemId,
  DateTimeOffset UpdatedAtUtc,
  IReadOnlyList<string> SystemIds,
  IReadOnlyList<string> StationIds,
  IReadOnlyList<string> FrontLineIds,
  IReadOnlyList<string> CorridorIds);

public sealed record SupplyNetworkSnapshot(
  string Id,
  string RegionId,
  float ThroughputScore,
  float RiskScore,
  DateTimeOffset UpdatedAtUtc,
  IReadOnlyList<string> StationIds,
  IReadOnlyList<string> ProducerItemIds,
  IReadOnlyList<string> ConsumerItemIds,
  IReadOnlyList<string> ConstructionItemIds);

public sealed record LogisticsCorridorSnapshot(
  string Id,
  string? FactionId,
  string Kind,
  string Status,
  float RiskScore,
  float ThroughputScore,
  string AccessState,
  DateTimeOffset UpdatedAtUtc,
  IReadOnlyList<string> SystemPathIds,
  IReadOnlyList<string> RegionIds,
  IReadOnlyList<string> BorderEdgeIds);

public sealed record RegionalProductionProfileSnapshot(
  string RegionId,
  string PrimaryIndustry,
  int ShipyardCount,
  int StationCount,
  DateTimeOffset UpdatedAtUtc,
  IReadOnlyList<string> ProducedItemIds,
  IReadOnlyList<string> ScarceItemIds);

public sealed record RegionalTradeBalanceSnapshot(
  string RegionId,
  int ImportsRequiredCount,
  int ExportsSurplusCount,
  int CriticalShortageCount,
  float NetTradeScore,
  DateTimeOffset UpdatedAtUtc);

public sealed record RegionalBottleneckSnapshot(
  string Id,
  string RegionId,
  string ItemId,
  string Cause,
  string Status,
  float Severity,
  DateTimeOffset UpdatedAtUtc);

public sealed record RegionalSecurityAssessmentSnapshot(
  string RegionId,
  float SupplyRisk,
  float BorderPressure,
  int ActiveWarCount,
  int HostileRelationCount,
  float AccessFriction,
  DateTimeOffset UpdatedAtUtc);

public sealed record RegionalEconomicAssessmentSnapshot(
  string RegionId,
  float SustainmentScore,
  float ProductionDepth,
  float ConstructionPressure,
  float CorridorDependency,
  DateTimeOffset UpdatedAtUtc);

public sealed record EconomyRegionStateSnapshot(
  IReadOnlyList<EconomicRegionSnapshot> Regions,
  IReadOnlyList<SupplyNetworkSnapshot> SupplyNetworks,
  IReadOnlyList<LogisticsCorridorSnapshot> Corridors,
  IReadOnlyList<RegionalProductionProfileSnapshot> ProductionProfiles,
  IReadOnlyList<RegionalTradeBalanceSnapshot> TradeBalances,
  IReadOnlyList<RegionalBottleneckSnapshot> Bottlenecks,
  IReadOnlyList<RegionalSecurityAssessmentSnapshot> SecurityAssessments,
  IReadOnlyList<RegionalEconomicAssessmentSnapshot> EconomicAssessments);

public sealed record GeopoliticalStateSnapshot(
  int Cycle,
  DateTimeOffset UpdatedAtUtc,
  IReadOnlyList<SystemRouteLinkSnapshot> Routes,
  DiplomaticStateSnapshot Diplomacy,
  TerritoryStateSnapshot Territory,
  EconomyRegionStateSnapshot EconomyRegions);
