import * as VScript from "http://172.16.0.12/bladerunner_sdk/vscript@2.5.2/deno/release/mod.ts";
import * as VAPI from "./mod.ts";
export const lift = {
  AFVRef: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new AFVRef(_raw),
  AllocationMode: (
    _raw: [0, [number]] | [1, [number]],
    _socket: VScript.VSocket,
  ): AllocationMode => {
    switch (_raw[0]) {
      case 0:
        return {
          variant: "Samples",
          value: VAPI.AudioRePlay.lift.SamplesSettings(_raw[1], _socket),
        };
      case 1:
        return {
          variant: "Time",
          value: VAPI.AudioRePlay.lift.TimeSettings(_raw[1], _socket),
        };
    }
  },
  BufferInput: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new BufferInput(_raw),
  Control: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new Control(_raw),
  DolbyE: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new DolbyE(_raw),
  DolbyEDebug: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new DolbyEDebug(_raw),
  DolbyERef: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new DolbyERef(_raw),
  DolbyEWriter: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new DolbyEWriter(_raw),
  DolbyLine: (
    _raw: [
      null | number,
      null | number,
      null | number,
      null | number,
      null | number,
      null | number,
    ],
    _socket: VScript.VSocket,
  ): DolbyLine => {
    return {
      earliest: _raw[0],
      earliest_ideal: _raw[1],
      ideal: _raw[2],
      latest_ideal: _raw[3],
      latest: _raw[4],
      calculated: _raw[5],
    };
  },
  InputDebug: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new InputDebug(_raw),
  OutputDebug: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new OutputDebug(_raw),
  Reader: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new Reader(_raw),
  SampleTime: (
    _raw: [number, number],
    _socket: VScript.VSocket,
  ): SampleTime => {
    return {
      samples: _raw[0],
      time: VScript.VAPIHelpers.liftNanoseconds(_raw[1], _socket),
    };
  },
  SamplesSettings: (
    _raw: [number],
    _socket: VScript.VSocket,
  ): SamplesSettings => {
    return {
      samples: _raw[0],
    };
  },
  TimeSettings: (_raw: [number], _socket: VScript.VSocket): TimeSettings => {
    return {
      time: VScript.VAPIHelpers.liftNanoseconds(_raw[0], _socket),
    };
  },
  UploadHeader: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new UploadHeader(_raw),
  Writer: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new Writer(_raw),
  BufferCurrentDelay: (
    _raw: [number, number, number, number, number],
    _socket: VScript.VSocket,
  ): BufferCurrentDelay => {
    return {
      manual_fraction: VScript.VAPIHelpers.liftNanoseconds(_raw[0], _socket),
      afv_fraction: VScript.VAPIHelpers.liftNanoseconds(_raw[1], _socket),
      dolby_e_fraction: VScript.VAPIHelpers.liftNanoseconds(_raw[2], _socket),
      as_samples: _raw[3],
      as_time: VScript.VAPIHelpers.liftNanoseconds(_raw[4], _socket),
    };
  },
  UploadHeaderDate: (
    _raw: [number, number, number],
    _socket: VScript.VSocket,
  ): UploadHeaderDate => {
    return {
      year: _raw[0],
      month: _raw[1],
      day: _raw[2],
    };
  },
  UploadHeaderTimeOfDay: (
    _raw: [number, number, number],
    _socket: VScript.VSocket,
  ): UploadHeaderTimeOfDay => {
    return {
      hours: _raw[0],
      minutes: _raw[1],
      seconds: _raw[2],
    };
  },
} as const;
export const lower = {
  AFVRef: (_x: AFVRef) => _x.raw.kwl,
  AllocationMode: (
    _x:
      | { variant: "Samples"; value: VAPI.AudioRePlay.SamplesSettings }
      | { variant: "Time"; value: VAPI.AudioRePlay.TimeSettings },
    _socket: VScript.VSocket,
  ): [0, [number]] | [1, [number]] => {
    switch (_x.variant) {
      case "Samples":
        return [0, VAPI.AudioRePlay.lower.SamplesSettings(_x.value, _socket)];
      case "Time":
        return [1, VAPI.AudioRePlay.lower.TimeSettings(_x.value, _socket)];
    }
  },
  BufferInput: (_x: BufferInput) => _x.raw.kwl,
  Control: (_x: Control) => _x.raw.kwl,
  DolbyE: (_x: DolbyE) => _x.raw.kwl,
  DolbyEDebug: (_x: DolbyEDebug) => _x.raw.kwl,
  DolbyERef: (_x: DolbyERef) => _x.raw.kwl,
  DolbyEWriter: (_x: DolbyEWriter) => _x.raw.kwl,
  DolbyLine: (
    _x: {
      earliest: null | VAPI.Primitives.Unsigned8;
      earliest_ideal: null | VAPI.Primitives.Unsigned8;
      ideal: null | VAPI.Primitives.Unsigned8;
      latest_ideal: null | VAPI.Primitives.Unsigned8;
      latest: null | VAPI.Primitives.Unsigned8;
      calculated: null | VAPI.Primitives.Unsigned16;
    },
    _socket: VScript.VSocket,
  ): [
    null | number,
    null | number,
    null | number,
    null | number,
    null | number,
    null | number,
  ] => [
    _x.earliest,
    _x.earliest_ideal,
    _x.ideal,
    _x.latest_ideal,
    _x.latest,
    _x.calculated,
  ],
  InputDebug: (_x: InputDebug) => _x.raw.kwl,
  OutputDebug: (_x: OutputDebug) => _x.raw.kwl,
  Reader: (_x: Reader) => _x.raw.kwl,
  SampleTime: (
    _x: { samples: number; time: VScript.Duration },
    _socket: VScript.VSocket,
  ): [number, number] => [
    _x.samples,
    VScript.VAPIHelpers.lowerNanoseconds(_x.time, _socket),
  ],
  SamplesSettings: (
    _x: { samples: number },
    _socket: VScript.VSocket,
  ): [number] => [_x.samples],
  TimeSettings: (
    _x: { time: VScript.Duration },
    _socket: VScript.VSocket,
  ): [number] => [VScript.VAPIHelpers.lowerNanoseconds(_x.time, _socket)],
  UploadHeader: (_x: UploadHeader) => _x.raw.kwl,
  Writer: (_x: Writer) => _x.raw.kwl,
  BufferCurrentDelay: (
    _x: {
      manual_fraction: VScript.Duration;
      afv_fraction: VScript.Duration;
      dolby_e_fraction: VScript.Duration;
      as_samples: number;
      as_time: VScript.Duration;
    },
    _socket: VScript.VSocket,
  ): [number, number, number, number, number] => [
    VScript.VAPIHelpers.lowerNanoseconds(_x.manual_fraction, _socket),
    VScript.VAPIHelpers.lowerNanoseconds(_x.afv_fraction, _socket),
    VScript.VAPIHelpers.lowerNanoseconds(_x.dolby_e_fraction, _socket),
    _x.as_samples,
    VScript.VAPIHelpers.lowerNanoseconds(_x.as_time, _socket),
  ],
  UploadHeaderDate: (
    _x: { year: number; month: number; day: number },
    _socket: VScript.VSocket,
  ): [number, number, number] => [_x.year, _x.month, _x.day],
  UploadHeaderTimeOfDay: (
    _x: { hours: number; minutes: number; seconds: number },
    _socket: VScript.VSocket,
  ): [number, number, number] => [_x.hours, _x.minutes, _x.seconds],
} as const;
export class AFVRef
  implements VScript.Referenceable<"AudioRePlay::Data::AFVRef">
{
  readonly type_identifier = "AudioRePlay::Data::AFVRef" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get transition_mode(): VScript.rwKeyword<
    VScript.VSocket,
    VAPI.AudioRePlay.TransitionMode,
    VAPI.AudioRePlay.TransitionMode,
    VAPI.AudioRePlay.TransitionMode,
    VAPI.AudioRePlay.TransitionMode,
    VAPI.AudioRePlay.AFVRef
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      VAPI.AudioRePlay.TransitionMode,
      VAPI.AudioRePlay.TransitionMode,
      VAPI.AudioRePlay.TransitionMode,
      VAPI.AudioRePlay.TransitionMode,
      VAPI.AudioRePlay.AFVRef
    >(
      this,
      "transition_mode" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get audio_late(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    VScript.Duration,
    VScript.Duration,
    VAPI.AudioRePlay.AFVRef
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      VScript.Duration,
      VScript.Duration,
      VAPI.AudioRePlay.AFVRef
    >(
      this,
      "audio_late" as VScript.SysName,
      {
        lift: VScript.VAPIHelpers.liftNanoseconds,
        lower: VScript.VAPIHelpers.lowerNanoseconds,
      },
      {
        lift: VScript.VAPIHelpers.liftNanoseconds,
        lower: VScript.VAPIHelpers.lowerNanoseconds,
      },
      null,
    );
  }
  get audio_early(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    VScript.Duration,
    VScript.Duration,
    VAPI.AudioRePlay.AFVRef
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      VScript.Duration,
      VScript.Duration,
      VAPI.AudioRePlay.AFVRef
    >(
      this,
      "audio_early" as VScript.SysName,
      {
        lift: VScript.VAPIHelpers.liftNanoseconds,
        lower: VScript.VAPIHelpers.lowerNanoseconds,
      },
      {
        lift: VScript.VAPIHelpers.liftNanoseconds,
        lower: VScript.VAPIHelpers.lowerNanoseconds,
      },
      null,
    );
  }
}
export type AllocationMode =
  | { variant: "Samples"; value: VAPI.AudioRePlay.SamplesSettings }
  | { variant: "Time"; value: VAPI.AudioRePlay.TimeSettings };
export class BufferInput
  implements VScript.Referenceable<"AudioRePlay::Data::BufferInput">
{
  readonly type_identifier = "AudioRePlay::Data::BufferInput" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get memory_usage(): VScript.rKeyword<
    VScript.VSocket,
    [number, number],
    VAPI.DataRePlay.MemoryCapacity,
    VAPI.AudioRePlay.BufferInput
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [number, number],
      VAPI.DataRePlay.MemoryCapacity,
      VAPI.AudioRePlay.BufferInput
    >(this, "memory_usage" as VScript.SysName, {
      lift: VAPI.DataRePlay.lift.MemoryCapacity,
      lower: VAPI.DataRePlay.lower.MemoryCapacity,
    });
  }
  get capacity(): VScript.dKeyword<
    VScript.VSocket,
    null | ([0, [number]] | [1, [number]]),
    null | ([0, [number]] | [1, [number]]),
    null | VAPI.AudioRePlay.AllocationMode,
    null | VAPI.AudioRePlay.AllocationMode,
    VAPI.AudioRePlay.BufferInput
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      null | ([0, [number]] | [1, [number]]),
      null | ([0, [number]] | [1, [number]]),
      null | VAPI.AudioRePlay.AllocationMode,
      null | VAPI.AudioRePlay.AllocationMode,
      VAPI.AudioRePlay.BufferInput
    >(
      this,
      "capacity" as VScript.SysName,
      {
        lift: VScript.VAPIHelpers.liftOrLowerNullable(
          VAPI.AudioRePlay.lift.AllocationMode,
        ),
        lower: VScript.VAPIHelpers.liftOrLowerNullable(
          VAPI.AudioRePlay.lower.AllocationMode,
        ),
      },
      {
        lift: VScript.VAPIHelpers.liftOrLowerNullable(
          VAPI.AudioRePlay.lift.AllocationMode,
        ),
        lower: VScript.VAPIHelpers.liftOrLowerNullable(
          VAPI.AudioRePlay.lower.AllocationMode,
        ),
      },
      (
        parent: VAPI.AudioRePlay.BufferInput,
        command: null | VAPI.AudioRePlay.AllocationMode,
      ) => (
        void parent,
        void command,
        {
          criterion: "status",
          validator: (status: null | VAPI.AudioRePlay.AllocationMode) =>
            (command === null && status === null) ||
            (command !== null &&
              status !== null &&
              ((command.variant === "Samples" &&
                status.variant === "Samples" &&
                status.value.samples >= command.value.samples) ||
                (command.variant === "Time" &&
                  status.variant === "Time" &&
                  status.value.time.s() >= command.value.time.s()))),
        }
      ),
    );
  }
  get setting(): VScript.rKeyword<
    VScript.VSocket,
    null | [number, number],
    null | VAPI.AudioRePlay.SampleTime,
    VAPI.AudioRePlay.BufferInput
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | [number, number],
      null | VAPI.AudioRePlay.SampleTime,
      VAPI.AudioRePlay.BufferInput
    >(this, "setting" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.AudioRePlay.lift.SampleTime,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.AudioRePlay.lower.SampleTime,
      ),
    });
  }
  get frequency(): VScript.dKeyword<
    VScript.VSocket,
    VAPI.Audio.Frequency,
    VAPI.Audio.Frequency,
    VAPI.Audio.Frequency,
    VAPI.Audio.Frequency,
    VAPI.AudioRePlay.BufferInput
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      VAPI.Audio.Frequency,
      VAPI.Audio.Frequency,
      VAPI.Audio.Frequency,
      VAPI.Audio.Frequency,
      VAPI.AudioRePlay.BufferInput
    >(
      this,
      "frequency" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get num_channels(): VScript.dKeyword<
    VScript.VSocket,
    number,
    number,
    VAPI.Audio.Channelcount,
    VAPI.Audio.Channelcount,
    VAPI.AudioRePlay.BufferInput
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      number,
      number,
      VAPI.Audio.Channelcount,
      VAPI.Audio.Channelcount,
      VAPI.AudioRePlay.BufferInput
    >(
      this,
      "num_channels" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      (
        parent: VAPI.AudioRePlay.BufferInput,
        command: VAPI.Audio.Channelcount,
      ) => (
        void parent,
        void command,
        {
          criterion: "status",
          validator: (status: VAPI.Audio.Channelcount) => status >= command,
        }
      ),
    );
  }
}
export type BufferMode = "Samples" | "Time";
export class Control
  implements VScript.Referenceable<"AudioRePlay::Data::Control">
{
  readonly type_identifier = "AudioRePlay::Data::Control" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}

  /**
    Stop
  */
  get stop(): VScript.wKeyword<
    VScript.VSocket,
    VAPI.Primitives.Button,
    VAPI.Primitives.Button,
    VAPI.AudioRePlay.Control
  > {
    return new VScript.wKeyword<
      VScript.VSocket,
      VAPI.Primitives.Button,
      VAPI.Primitives.Button,
      VAPI.AudioRePlay.Control
    >(
      this,
      "stop" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }

  /**
    @brief Play
    @desc Depending on the status of play mode. This command starts a Loop or
    Play
  */
  get play(): VScript.wKeyword<
    VScript.VSocket,
    VAPI.Primitives.Button,
    VAPI.Primitives.Button,
    VAPI.AudioRePlay.Control
  > {
    return new VScript.wKeyword<
      VScript.VSocket,
      VAPI.Primitives.Button,
      VAPI.Primitives.Button,
      VAPI.AudioRePlay.Control
    >(
      this,
      "play" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }

  /**
    @brief PlayMode
    @desc Play: Plays once from start_sample till end_sample Loop: start
    playing from start_sample. Reaching the end_sample rewinds the clip and
    plays from now on in a loop from clip_start to end_sample
  */
  get play_mode(): VScript.dKeyword<
    VScript.VSocket,
    VAPI.AudioRePlay.Motion,
    VAPI.AudioRePlay.Motion,
    VAPI.AudioRePlay.Motion,
    VAPI.AudioRePlay.Motion,
    VAPI.AudioRePlay.Control
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      VAPI.AudioRePlay.Motion,
      VAPI.AudioRePlay.Motion,
      VAPI.AudioRePlay.Motion,
      VAPI.AudioRePlay.Motion,
      VAPI.AudioRePlay.Control
    >(
      this,
      "play_mode" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get start_sample(): VScript.dKeyword<
    VScript.VSocket,
    null | number,
    null | number,
    null | number,
    null | number,
    VAPI.AudioRePlay.Control
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      null | number,
      null | number,
      null | number,
      null | number,
      VAPI.AudioRePlay.Control
    >(
      this,
      "start_sample" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get end_sample(): VScript.dKeyword<
    VScript.VSocket,
    null | number,
    null | number,
    null | number,
    null | number,
    VAPI.AudioRePlay.Control
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      null | number,
      null | number,
      null | number,
      null | number,
      VAPI.AudioRePlay.Control
    >(
      this,
      "end_sample" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get time(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VScript.Duration,
    VAPI.AudioRePlay.Control
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VScript.Duration,
      VAPI.AudioRePlay.Control
    >(this, "time" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.liftNanoseconds,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.lowerNanoseconds,
      ),
    });
  }
  get motion_status(): VScript.rKeyword<
    VScript.VSocket,
    VAPI.AudioRePlay.MotionStatus,
    VAPI.AudioRePlay.MotionStatus,
    VAPI.AudioRePlay.Control
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      VAPI.AudioRePlay.MotionStatus,
      VAPI.AudioRePlay.MotionStatus,
      VAPI.AudioRePlay.Control
    >(this, "motion_status" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
}
export class DolbyE
  implements VScript.Referenceable<"AudioRePlay::Data::DolbyE">
{
  readonly type_identifier = "AudioRePlay::Data::DolbyE" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get run_dolby_e_detector(): VScript.rwKeyword<
    VScript.VSocket,
    boolean,
    boolean,
    boolean,
    boolean,
    VAPI.AudioRePlay.DolbyE
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      boolean,
      boolean,
      boolean,
      boolean,
      VAPI.AudioRePlay.DolbyE
    >(
      this,
      "run_dolby_e_detector" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get measurement_duration(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    VScript.Duration,
    VScript.Duration,
    VAPI.AudioRePlay.DolbyE
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      VScript.Duration,
      VScript.Duration,
      VAPI.AudioRePlay.DolbyE
    >(
      this,
      "measurement_duration" as VScript.SysName,
      {
        lift: VScript.VAPIHelpers.liftNanoseconds,
        lower: VScript.VAPIHelpers.lowerNanoseconds,
      },
      {
        lift: VScript.VAPIHelpers.liftNanoseconds,
        lower: VScript.VAPIHelpers.lowerNanoseconds,
      },
      null,
    );
  }
}
export class DolbyEDebug
  implements VScript.Referenceable<"AudioRePlay::Data::DolbyEDebug">
{
  readonly type_identifier = "AudioRePlay::Data::DolbyEDebug" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get zero_samples_before_header(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.DolbyEDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.DolbyEDebug
    >(this, "zero_samples_before_header" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get free_running_counter_header_detected(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.DolbyEDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.DolbyEDebug
    >(this, "free_running_counter_header_detected" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
}
export class DolbyERef
  implements VScript.Referenceable<"AudioRePlay::Data::DolbyERef">
{
  readonly type_identifier = "AudioRePlay::Data::DolbyERef" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get channel_pair(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.DolbyERef
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.DolbyERef
    >(
      this,
      "channel_pair" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get samples(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | number,
    VAPI.AudioRePlay.DolbyERef
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | number,
      VAPI.AudioRePlay.DolbyERef
    >(this, "samples" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get time(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VScript.Duration,
    VAPI.AudioRePlay.DolbyERef
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VScript.Duration,
      VAPI.AudioRePlay.DolbyERef
    >(this, "time" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.liftNanoseconds,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.lowerNanoseconds,
      ),
    });
  }
  get dolby_e_line(): VScript.rKeyword<
    VScript.VSocket,
    [
      null | number,
      null | number,
      null | number,
      null | number,
      null | number,
      null | number,
    ],
    VAPI.AudioRePlay.DolbyLine,
    VAPI.AudioRePlay.DolbyERef
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [
        null | number,
        null | number,
        null | number,
        null | number,
        null | number,
        null | number,
      ],
      VAPI.AudioRePlay.DolbyLine,
      VAPI.AudioRePlay.DolbyERef
    >(this, "dolby_e_line" as VScript.SysName, {
      lift: VAPI.AudioRePlay.lift.DolbyLine,
      lower: VAPI.AudioRePlay.lower.DolbyLine,
    });
  }
}
export class DolbyEWriter
  implements VScript.Referenceable<"AudioRePlay::Data::DolbyEWriter">
{
  readonly type_identifier = "AudioRePlay::Data::DolbyEWriter" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get free_running_counter_irq(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.DolbyEWriter
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.DolbyEWriter
    >(this, "free_running_counter_irq" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get bits_irq(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.DolbyEWriter
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.DolbyEWriter
    >(this, "bits_irq" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get debug() {
    return new VScript.StronglyTypedArray<
      VScript.VSocket,
      "AudioRePlay::Data::DolbyEDebug",
      VAPI.AudioRePlay.DolbyEDebug
    >(
      VScript.VAPIHelpers.subtree_array_child_checked(this.raw, 2, "debug"),
      (st: VScript.DataViews.Subtree<VScript.VSocket>, _: VScript.VSocket) =>
        VAPI.AudioRePlay.lift.DolbyEDebug(st),
    );
  }
}
export interface DolbyLine {
  earliest: null | VAPI.Primitives.Unsigned8;
  earliest_ideal: null | VAPI.Primitives.Unsigned8;
  ideal: null | VAPI.Primitives.Unsigned8;
  latest_ideal: null | VAPI.Primitives.Unsigned8;
  latest: null | VAPI.Primitives.Unsigned8;
  calculated: null | VAPI.Primitives.Unsigned16;
}
export class InputDebug
  implements VScript.Referenceable<"AudioRePlay::Data::InputDebug">
{
  readonly type_identifier = "AudioRePlay::Data::InputDebug" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get writer_id(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.InputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.InputDebug
    >(this, "writer_id" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get writer_v_idx(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.InputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.InputDebug
    >(this, "writer_v_idx" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get start_address(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.InputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.InputDebug
    >(this, "start_address" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get end_address(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.InputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.InputDebug
    >(this, "end_address" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get enable(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.InputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.InputDebug
    >(this, "enable" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
}
export type Motion = "Play" | "Loop";
export type MotionStatus = "Stop" | "Play" | "Loop";
export class OutputDebug
  implements VScript.Referenceable<"AudioRePlay::Data::OutputDebug">
{
  readonly type_identifier = "AudioRePlay::Data::OutputDebug" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get reader_id(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.OutputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.OutputDebug
    >(this, "reader_id" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get reader_v_idx(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.OutputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.OutputDebug
    >(this, "reader_v_idx" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get loop_start_address(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.OutputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.OutputDebug
    >(this, "loop_start_address" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get loop_end_address(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.OutputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.OutputDebug
    >(this, "loop_end_address" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get enable(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.OutputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.OutputDebug
    >(this, "enable" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get start_address(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.OutputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.OutputDebug
    >(this, "start_address" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get start_timestamp(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.AudioRePlay.OutputDebug
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.AudioRePlay.OutputDebug
    >(this, "start_timestamp" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
}
export class Reader
  implements VScript.Referenceable<"AudioRePlay::Data::Reader">
{
  readonly type_identifier = "AudioRePlay::Data::Reader" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get active(): VScript.rKeyword<
    VScript.VSocket,
    boolean,
    boolean,
    VAPI.AudioRePlay.Reader
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      boolean,
      boolean,
      VAPI.AudioRePlay.Reader
    >(this, "active" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get debug() {
    return VAPI.AudioRePlay.lift.OutputDebug(
      VScript.VAPIHelpers.subtree_child_checked(this.raw, 1, "debug"),
    );
  }
}
export interface SampleTime {
  samples: number;
  time: VScript.Duration;
}
export interface SamplesSettings {
  samples: number;
}
export interface TimeSettings {
  time: VScript.Duration;
}
export type TransitionMode = "Jump" | "V_Fade";
export class UploadHeader
  implements VScript.Referenceable<"AudioRePlay::Data::UploadHeader">
{
  readonly type_identifier = "AudioRePlay::Data::UploadHeader" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get date(): VScript.rKeyword<
    VScript.VSocket,
    null | [number, number, number],
    null | VAPI.AudioRePlay.UploadHeaderDate,
    VAPI.AudioRePlay.UploadHeader
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | [number, number, number],
      null | VAPI.AudioRePlay.UploadHeaderDate,
      VAPI.AudioRePlay.UploadHeader
    >(this, "date" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.AudioRePlay.lift.UploadHeaderDate,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.AudioRePlay.lower.UploadHeaderDate,
      ),
    });
  }
  get time_of_day(): VScript.rKeyword<
    VScript.VSocket,
    null | [number, number, number],
    null | VAPI.AudioRePlay.UploadHeaderTimeOfDay,
    VAPI.AudioRePlay.UploadHeader
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | [number, number, number],
      null | VAPI.AudioRePlay.UploadHeaderTimeOfDay,
      VAPI.AudioRePlay.UploadHeader
    >(this, "time_of_day" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.AudioRePlay.lift.UploadHeaderTimeOfDay,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.AudioRePlay.lower.UploadHeaderTimeOfDay,
      ),
    });
  }
  get channels(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | number,
    VAPI.AudioRePlay.UploadHeader
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | number,
      VAPI.AudioRePlay.UploadHeader
    >(this, "channels" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get sample_rate(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | number,
    VAPI.AudioRePlay.UploadHeader
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | number,
      VAPI.AudioRePlay.UploadHeader
    >(this, "sample_rate" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get bits_per_sample(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | number,
    VAPI.AudioRePlay.UploadHeader
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | number,
      VAPI.AudioRePlay.UploadHeader
    >(this, "bits_per_sample" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get samples(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | number,
    VAPI.AudioRePlay.UploadHeader
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | number,
      VAPI.AudioRePlay.UploadHeader
    >(this, "samples" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get time(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VScript.Duration,
    VAPI.AudioRePlay.UploadHeader
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VScript.Duration,
      VAPI.AudioRePlay.UploadHeader
    >(this, "time" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.liftNanoseconds,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.lowerNanoseconds,
      ),
    });
  }
}
export class Writer
  implements VScript.Referenceable<"AudioRePlay::Data::Writer">
{
  readonly type_identifier = "AudioRePlay::Data::Writer" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get active(): VScript.rKeyword<
    VScript.VSocket,
    boolean,
    boolean,
    VAPI.AudioRePlay.Writer
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      boolean,
      boolean,
      VAPI.AudioRePlay.Writer
    >(this, "active" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get debug() {
    return VAPI.AudioRePlay.lift.InputDebug(
      VScript.VAPIHelpers.subtree_child_checked(this.raw, 1, "debug"),
    );
  }
  get dolby_e_debug() {
    return VAPI.AudioRePlay.lift.DolbyEWriter(
      VScript.VAPIHelpers.subtree_child_checked(this.raw, 2, "dolby_e_debug"),
    );
  }
}
export interface BufferCurrentDelay {
  manual_fraction: VScript.Duration;
  afv_fraction: VScript.Duration;
  dolby_e_fraction: VScript.Duration;
  as_samples: number;
  as_time: VScript.Duration;
}
export interface UploadHeaderDate {
  year: number;
  month: number;
  day: number;
}
export type DelayIssues = {
  missing_buffer_allocation: boolean;
  missing_sample_setting: boolean;
  missing_time_setting: boolean;
  missing_timesource: boolean;
  out_of_bounds: boolean;
  out_of_memory: boolean;
  out_of_readers: boolean;
  out_of_writers: boolean;
  too_small_for_dolby_e_alignment: boolean;
};
export type PlayerIssues = {
  missing_timesource: boolean;
  out_of_memory: boolean;
  out_of_readers: boolean;
};
export interface UploadHeaderTimeOfDay {
  hours: number;
  minutes: number;
  seconds: number;
}
export const Enums = {
  TransitionMode: ["Jump", "V_Fade"] as TransitionMode[],
  MotionStatus: ["Stop", "Play", "Loop"] as MotionStatus[],
  Motion: ["Play", "Loop"] as Motion[],
  BufferMode: ["Samples", "Time"] as BufferMode[],
} as const;
