import { z as e } from "zod";
import { RawImageCodec as d, RawImageTypeInvalidError as s } from "./accelbyte-widgets536.mjs";
import { ImageMediumCodec as c, toRaw as m, fromRaw as l } from "./accelbyte-widgets397.mjs";
import { YoutubeVideoMediumCodec as w, toRaw as f, fromRaw as R } from "./accelbyte-widgets396.mjs";
import { ErrorModel as p } from "./accelbyte-widgets537.mjs";
class M extends Error {
}
class a extends Error {
}
const t = e.union([w, c]), F = e.array(t);
e.union([e.null(), t, p]);
const g = [R, l], x = {
  fromRaw: (r) => {
    const n = d.safeParse(r);
    if (!n.success)
      return [
        null,
        {
          kind: "error",
          error: new s()
        }
      ];
    for (const u of g) {
      const i = n.data, o = u(i);
      if (o && (o == null ? void 0 : o.kind) !== "error")
        return [o, null];
    }
    return [
      null,
      {
        kind: "error",
        error: new M()
      }
    ];
  },
  toRaw: (r) => {
    try {
      switch (r.kind) {
        case "youtubeVideo":
          return [f(r), null];
        case "image":
          return [m(r), null];
        default:
          return [null, new a()];
      }
    } catch {
      return [null, new a()];
    }
  }
};
export {
  c as ImageMediumCodec,
  t as MediumCodec,
  F as MediumCodecArray,
  M as MediumDeserializerNotFound,
  x as MediumHelper,
  a as MediumSerializerNotFound,
  d as RawImageCodec,
  s as RawImageTypeInvalidError,
  w as YoutubeVideoMediumCodec
};
