import type {
  ContentExpectations,
  RawContentExpectations,
  RawValueExpectation,
  ValueExpectation,
} from "../../expect/types";
import type { ResolvedTargetBase } from "../../types";

export interface RawUdpExpectConfig {
  durationMs?: RawValueExpectation;
  responded?: boolean;
  response?: RawContentExpectations;
  responseSize?: RawValueExpectation;
  sourceHost?: RawValueExpectation;
  sourcePort?: RawValueExpectation;
}

export interface ResolvedUdpConfig {
  encoding: UdpEncoding;
  host: string;
  maxResponseBytes: number;
  payload: string;
  port: number;
  responseEncoding: UdpEncoding;
}

export interface ResolvedUdpExpectConfig {
  durationMs?: ValueExpectation;
  responded: boolean;
  response?: ContentExpectations;
  responseSize?: ValueExpectation;
  sourceHost?: ValueExpectation;
  sourcePort?: ValueExpectation;
}

export interface ResolvedUdpTarget extends ResolvedTargetBase {
  expect?: ResolvedUdpExpectConfig;
  group: string;
  intervalMs: number;
  name: null | string;
  rawExpect?: RawUdpExpectConfig;
  timeoutMs: number;
  type: "udp";
  udp: ResolvedUdpConfig;
}

export interface UdpDefaultsConfig {
  encoding?: UdpEncoding;
  maxResponseBytes?: number | string;
  responseEncoding?: UdpEncoding;
}

export type UdpEncoding = "base64" | "hex" | "text";

export interface UdpTargetConfig {
  encoding?: UdpEncoding;
  host: string;
  maxResponseBytes?: number | string;
  payload?: string;
  port: number;
  responseEncoding?: UdpEncoding;
}
