1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (c) 2025-present FERS Contributors (see AUTHORS.md).
4import { z } from 'zod';
7 AssetTemplateInsertionResult,
8} from '../assetTemplates';
12 GlobalParametersSchema,
15 PlatformComponentSchema,
17 PositionWaypointSchema,
19 RotationWaypointSchema,
24} from '../scenarioSchema';
26// --- Zod Inferred Types ---
27export type GlobalParameters = z.infer<typeof GlobalParametersSchema>;
28export type Waveform = z.infer<typeof WaveformSchema>;
29export type NoiseEntry = z.infer<typeof NoiseEntrySchema>;
30export type Timing = z.infer<typeof TimingSchema>;
31export type Antenna = z.infer<typeof AntennaSchema>;
32export type PositionWaypoint = z.infer<typeof PositionWaypointSchema>;
33export type MotionPath = z.infer<typeof MotionPathSchema>;
34export type FixedRotation = z.infer<typeof FixedRotationSchema>;
35export type RotationWaypoint = z.infer<typeof RotationWaypointSchema>;
36export type RotationPath = z.infer<typeof RotationPathSchema>;
37export type PlatformComponent = z.infer<typeof PlatformComponentSchema>;
38export type SchedulePeriod = z.infer<typeof SchedulePeriodSchema>;
39export type Platform = z.infer<typeof PlatformSchema> & {
48 rotationPathPoints?: { azimuth: number; elevation: number }[];
51// --- Visibility Type Definitions ---
52export type VisualizationLayers = {
54 showPatterns: boolean;
55 showBoresights: boolean;
57 showLinkLabels: boolean;
58 showLinkMonostatic: boolean;
59 showLinkIlluminator: boolean;
60 showLinkScattered: boolean;
61 showLinkDirect: boolean;
62 showVelocities: boolean;
63 showPlatforms: boolean;
64 showPlatformLabels: boolean;
65 showMotionPaths: boolean;
68// --- Component Type Definitions ---
69export type MonostaticComponent = Extract<
71 { type: 'monostatic' }
73export type TransmitterComponent = Extract<
75 { type: 'transmitter' }
77export type ReceiverComponent = Extract<
81export type TargetComponent = Extract<PlatformComponent, { type: 'target' }>;
83export type ScenarioData = Omit<
84 z.infer<typeof ScenarioDataSchema>,
87 platforms: Platform[];
90export type ScenarioItem =
98export type ViewControlAction = {
99 type: 'frame' | 'focus' | 'follow' | null;
104export type NotificationSeverity = 'success' | 'warning' | 'error';
106export type NotificationState = {
109 severity: NotificationSeverity;
112export type ScenarioState = ScenarioData & {
113 selectedItemId: string | null;
114 selectedComponentId: string | null;
118 targetPlaybackDuration: number | null;
119 isBackendSyncing: boolean;
120 backendVersion: number;
121 scenarioFilePath: string | null;
122 outputDirectory: string | null;
123 antennaPreviewErrors: Record<string, string>;
124 notificationSnackbar: NotificationState;
125 notificationQueue: NotificationState[];
126 viewControlAction: ViewControlAction;
127 visibility: VisualizationLayers;
130// --- Action Slice Types ---
131export type AssetActions = {
132 addWaveform: () => void;
133 addTiming: () => void;
134 addAntenna: () => void;
135 addNoiseEntry: (timingId: string) => void;
136 removeNoiseEntry: (timingId: string, entryId: string) => void;
139 newPattern: Antenna['pattern']
143export type PlatformActions = {
144 addPlatform: () => void;
145 addPositionWaypoint: (platformId: string) => void;
146 removePositionWaypoint: (platformId: string, waypointId: string) => void;
147 addRotationWaypoint: (platformId: string) => void;
148 removeRotationWaypoint: (platformId: string, waypointId: string) => void;
149 addPlatformComponent: (
151 componentType: PlatformComponent['type']
153 removePlatformComponent: (platformId: string, componentId: string) => void;
154 setPlatformRcsModel: (
157 newModel: TargetComponent['rcs_model']
159 fetchPlatformPath: (platformId: string) => Promise<void>;
162export type ScenarioActions = {
163 selectItem: (itemId: string | null) => void;
164 updateItem: (itemId: string, propertyPath: string, value: unknown) => void;
165 setRotationAngleUnit: (
166 unit: GlobalParameters['rotationAngleUnit'],
167 convertExisting: boolean
169 removeItem: (itemId: string) => void;
170 loadScenario: (backendData: unknown) => void;
171 resetScenario: () => void;
172 setScenarioFilePath: (path: string | null) => void;
173 setOutputDirectory: (dir: string | null) => void;
174 insertAssetTemplate: (
175 template: AssetLibraryTemplate
176 ) => AssetTemplateInsertionResult;
179export type BackendActions = {
180 syncBackend: () => Promise<void>;
181 fetchFromBackend: () => Promise<void>;
184export type PlaybackActions = {
185 togglePlayPause: () => void;
186 setCurrentTime: (time: number | ((prevTime: number) => number)) => void;
187 setTargetPlaybackDuration: (duration: number | null) => void;
190export type ErrorActions = {
191 showError: (message: string) => void;
192 showSuccess: (message: string) => void;
193 showWarning: (message: string) => void;
194 hideNotification: () => void;
195 advanceNotification: () => void;
196 setAntennaPreviewError: (antennaId: string, message: string) => void;
197 clearAntennaPreviewError: (antennaId: string) => void;
200export type ViewControlActions = {
201 frameScene: () => void;
202 focusOnItem: (itemId: string) => void;
203 toggleFollowItem: (itemId: string) => void;
204 clearViewControlAction: () => void;
205 toggleLayer: (layer: keyof VisualizationLayers) => void;
208// --- Full Store Type ---
209export type FullScenarioActions = AssetActions &
217export type ScenarioStore = ScenarioState & FullScenarioActions;