{
  num: -21026,
  accuracy: true,
  basePower: 195,
  category: "Special",
  isNonstandard: "Past",
  name: "Rebirth",
  pp: 1,
  priority: 0,
  flags: { protect: 1, mirror: 1 },
  isZ: "ancientgeniumz",
  slotCondition: "revivalblessing",
  selfSwitch: true,

  onTryHit(target, source, move) {
    if (!source?.side?.pokemon?.some((ally) => ally.fainted)) {
      move.slotCondition = undefined;
      move.selfSwitch = false;
    }
  },

  self: {
    onHit(source) {
      if (!source?.side?.pokemon?.some((ally) => ally.fainted)) return;
      source.side.addSlotCondition(source, "revivalblessing");
      source.switchFlag = true;
    }
  },

  condition: {
    duration: 1
  },

  onAfterMoveSecondarySelf(source, target, move) {
    if (!source || source.fainted) return;

    const types = [];
    for (const slot of source.moveSlots || []) {
      if (types.length >= 2) break;
      const moveid = slot.id || slot.move || slot.moveid;
      if (!moveid) continue;
      const baseMove = this.dex.moves.get(moveid);
      if (!baseMove?.exists || !baseMove.type) continue;
      if (!types.includes(baseMove.type)) types.push(baseMove.type);
    }

    if (!types.length) return;
    source.setType(types);
    this.add("-start", source, "typechange", types.join("/"), "[from] move: Rebirth");
  },

  secondary: null,
  target: "normal",
  type: "Psychic",
  contestType: "Clever"
}