{
  name: "Cosmo Shift",
  rating: 5,
  num: -21007,
  flags: { failroleplay: 1, noreceiver: 1, noentrain: 1, notrace: 1, failskillswap: 1, cantsuppress: 1, notransform: 1 },
  onPreStart(pokemon) {
    if (!pokemon || !pokemon.baseSpecies) return;
    const baseSpecies = (pokemon.baseSpecies.baseSpecies || pokemon.baseSpecies.name || pokemon.baseSpecies.id || "").toString().toLowerCase().replace(/[^a-z0-9]/g, "");
    if (baseSpecies !== "terapagosatom") return;
    if (pokemon.species && pokemon.species.forme === "Cosmic") return;
    this.add("-activate", pokemon, "ability: Cosmo Shift");
    const oldMaxHP = pokemon.maxhp;
    const oldHP = pokemon.hp;
    const changed = pokemon.formeChange("Terapagosatom-Cosmic", this.effect, true) || pokemon.formeChange("terapagosatomcosmic", this.effect, true) || pokemon.formeChange("Cosmic", this.effect, true);
    if (!changed) return;
    pokemon.baseMaxhp = Math.floor(Math.floor(2 * pokemon.species.baseStats.hp + pokemon.set.ivs.hp + Math.floor(pokemon.set.evs.hp / 4) + 100) * pokemon.level / 100 + 10);
    const newMaxHP = pokemon.baseMaxhp;
    pokemon.hp = newMaxHP - (oldMaxHP - oldHP);
    if (pokemon.hp <= 0) pokemon.hp = 1;
    pokemon.maxhp = newMaxHP;
    this.add("-heal", pokemon, pokemon.getHealth, "[silent]");
    this.add("-formechange", pokemon, "Terapagosatom-Cosmic", "[from] ability: Cosmo Shift");
  }
}
