// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import { Create as $Create } from "@wailsio/runtime";

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as time$0 from "../../../../../../time/models.js";

export class Artifact {
  kind: ArtifactKind;
  format: ArtifactFormat;
  url: string;
  sha256: string;
  size?: number;

  /** Creates a new Artifact instance. */
  constructor($$source: Partial<Artifact> = {}) {
    if (!("kind" in $$source)) {
      this["kind"] = ArtifactKind.$zero;
    }
    if (!("format" in $$source)) {
      this["format"] = ArtifactFormat.$zero;
    }
    if (!("url" in $$source)) {
      this["url"] = "";
    }
    if (!("sha256" in $$source)) {
      this["sha256"] = "";
    }

    Object.assign(this, $$source);
  }

  /**
   * Creates a new Artifact instance from a string or object.
   */
  static createFrom($$source: any = {}): Artifact {
    let $$parsedSource = typeof $$source === "string" ? JSON.parse($$source) : $$source;
    return new Artifact($$parsedSource as Partial<Artifact>);
  }
}

export enum ArtifactFormat {
  /**
   * The Go zero value for the underlying type of the enum.
   */
  $zero = "",

  ArtifactFormatZip = "zip",
  ArtifactFormatTarGz = "tar.gz",
}

export enum ArtifactKind {
  /**
   * The Go zero value for the underlying type of the enum.
   */
  $zero = "",

  ArtifactKindBundleArchive = "bundle-archive",
}

export class BundleFile {
  path: string;
  mode: string;

  /** Creates a new BundleFile instance. */
  constructor($$source: Partial<BundleFile> = {}) {
    if (!("path" in $$source)) {
      this["path"] = "";
    }
    if (!("mode" in $$source)) {
      this["mode"] = "";
    }

    Object.assign(this, $$source);
  }

  /**
   * Creates a new BundleFile instance from a string or object.
   */
  static createFrom($$source: any = {}): BundleFile {
    let $$parsedSource = typeof $$source === "string" ? JSON.parse($$source) : $$source;
    return new BundleFile($$parsedSource as Partial<BundleFile>);
  }
}

export class BundleManifest {
  schemaVersion: number;
  entrypoint: string;
  files: BundleFile[];

  /** Creates a new BundleManifest instance. */
  constructor($$source: Partial<BundleManifest> = {}) {
    if (!("schemaVersion" in $$source)) {
      this["schemaVersion"] = 0;
    }
    if (!("entrypoint" in $$source)) {
      this["entrypoint"] = "";
    }
    if (!("files" in $$source)) {
      this["files"] = [];
    }

    Object.assign(this, $$source);
  }

  /**
   * Creates a new BundleManifest instance from a string or object.
   */
  static createFrom($$source: any = {}): BundleManifest {
    const $$createField2_0 = $$createType1;
    let $$parsedSource = typeof $$source === "string" ? JSON.parse($$source) : $$source;
    if ("files" in $$parsedSource) {
      $$parsedSource["files"] = $$createField2_0($$parsedSource["files"]);
    }
    return new BundleManifest($$parsedSource as Partial<BundleManifest>);
  }
}

export enum Channel {
  /**
   * The Go zero value for the underlying type of the enum.
   */
  $zero = "",

  ChannelStable = "stable",
  ChannelBeta = "beta",
  ChannelAlpha = "alpha",
}

export class ErrorInfo {
  code: string;
  message: string;

  /** Creates a new ErrorInfo instance. */
  constructor($$source: Partial<ErrorInfo> = {}) {
    if (!("code" in $$source)) {
      this["code"] = "";
    }
    if (!("message" in $$source)) {
      this["message"] = "";
    }

    Object.assign(this, $$source);
  }

  /**
   * Creates a new ErrorInfo instance from a string or object.
   */
  static createFrom($$source: any = {}): ErrorInfo {
    let $$parsedSource = typeof $$source === "string" ? JSON.parse($$source) : $$source;
    return new ErrorInfo($$parsedSource as Partial<ErrorInfo>);
  }
}

export class InstallRoot {
  path: string;

  /** Creates a new InstallRoot instance. */
  constructor($$source: Partial<InstallRoot> = {}) {
    if (!("path" in $$source)) {
      this["path"] = "";
    }

    Object.assign(this, $$source);
  }

  /**
   * Creates a new InstallRoot instance from a string or object.
   */
  static createFrom($$source: any = {}): InstallRoot {
    let $$parsedSource = typeof $$source === "string" ? JSON.parse($$source) : $$source;
    return new InstallRoot($$parsedSource as Partial<InstallRoot>);
  }
}

export class Release {
  id: string;
  version: string;
  channel: Channel;
  notesMarkdown?: string;
  publishedAt: time$0.Time;
  artifact: Artifact;

  /** Creates a new Release instance. */
  constructor($$source: Partial<Release> = {}) {
    if (!("id" in $$source)) {
      this["id"] = "";
    }
    if (!("version" in $$source)) {
      this["version"] = "";
    }
    if (!("channel" in $$source)) {
      this["channel"] = Channel.$zero;
    }
    if (!("publishedAt" in $$source)) {
      this["publishedAt"] = null;
    }
    if (!("artifact" in $$source)) {
      this["artifact"] = new Artifact();
    }

    Object.assign(this, $$source);
  }

  /**
   * Creates a new Release instance from a string or object.
   */
  static createFrom($$source: any = {}): Release {
    const $$createField5_0 = $$createType2;
    let $$parsedSource = typeof $$source === "string" ? JSON.parse($$source) : $$source;
    if ("artifact" in $$parsedSource) {
      $$parsedSource["artifact"] = $$createField5_0($$parsedSource["artifact"]);
    }
    return new Release($$parsedSource as Partial<Release>);
  }
}

export class Snapshot {
  state: State;
  currentVersion: string;
  channel: Channel;
  lastCheckedAt?: time$0.Time | null;
  candidate?: Release | null;
  staged?: StagedArtifact | null;
  lastError?: ErrorInfo | null;

  /** Creates a new Snapshot instance. */
  constructor($$source: Partial<Snapshot> = {}) {
    if (!("state" in $$source)) {
      this["state"] = State.$zero;
    }
    if (!("currentVersion" in $$source)) {
      this["currentVersion"] = "";
    }
    if (!("channel" in $$source)) {
      this["channel"] = Channel.$zero;
    }

    Object.assign(this, $$source);
  }

  /**
   * Creates a new Snapshot instance from a string or object.
   */
  static createFrom($$source: any = {}): Snapshot {
    const $$createField4_0 = $$createType4;
    const $$createField5_0 = $$createType6;
    const $$createField6_0 = $$createType8;
    let $$parsedSource = typeof $$source === "string" ? JSON.parse($$source) : $$source;
    if ("candidate" in $$parsedSource) {
      $$parsedSource["candidate"] = $$createField4_0($$parsedSource["candidate"]);
    }
    if ("staged" in $$parsedSource) {
      $$parsedSource["staged"] = $$createField5_0($$parsedSource["staged"]);
    }
    if ("lastError" in $$parsedSource) {
      $$parsedSource["lastError"] = $$createField6_0($$parsedSource["lastError"]);
    }
    return new Snapshot($$parsedSource as Partial<Snapshot>);
  }
}

export class StagedArtifact {
  path: string;
  root: InstallRoot;
  release: Release;
  bundle: BundleManifest;

  /** Creates a new StagedArtifact instance. */
  constructor($$source: Partial<StagedArtifact> = {}) {
    if (!("path" in $$source)) {
      this["path"] = "";
    }
    if (!("root" in $$source)) {
      this["root"] = new InstallRoot();
    }
    if (!("release" in $$source)) {
      this["release"] = new Release();
    }
    if (!("bundle" in $$source)) {
      this["bundle"] = new BundleManifest();
    }

    Object.assign(this, $$source);
  }

  /**
   * Creates a new StagedArtifact instance from a string or object.
   */
  static createFrom($$source: any = {}): StagedArtifact {
    const $$createField1_0 = $$createType9;
    const $$createField2_0 = $$createType3;
    const $$createField3_0 = $$createType10;
    let $$parsedSource = typeof $$source === "string" ? JSON.parse($$source) : $$source;
    if ("root" in $$parsedSource) {
      $$parsedSource["root"] = $$createField1_0($$parsedSource["root"]);
    }
    if ("release" in $$parsedSource) {
      $$parsedSource["release"] = $$createField2_0($$parsedSource["release"]);
    }
    if ("bundle" in $$parsedSource) {
      $$parsedSource["bundle"] = $$createField3_0($$parsedSource["bundle"]);
    }
    return new StagedArtifact($$parsedSource as Partial<StagedArtifact>);
  }
}

export enum State {
  /**
   * The Go zero value for the underlying type of the enum.
   */
  $zero = "",

  StateIdle = "idle",
  StateChecking = "checking",
  StateUpToDate = "up_to_date",
  StateUpdateAvailable = "update_available",
  StateDownloading = "downloading",
  StateDownloaded = "downloaded",
  StateVerifying = "verifying",
  StateReadyToApply = "ready_to_apply",
  StateApplying = "applying",
  StateRestarting = "restarting",
  StateFailed = "failed",
}

// Private type creation functions
const $$createType0 = BundleFile.createFrom;
const $$createType1 = $Create.Array($$createType0);
const $$createType2 = Artifact.createFrom;
const $$createType3 = Release.createFrom;
const $$createType4 = $Create.Nullable($$createType3);
const $$createType5 = StagedArtifact.createFrom;
const $$createType6 = $Create.Nullable($$createType5);
const $$createType7 = ErrorInfo.createFrom;
const $$createType8 = $Create.Nullable($$createType7);
const $$createType9 = InstallRoot.createFrom;
const $$createType10 = BundleManifest.createFrom;
