--	print(p2)
	local v2 = u1.Directory.Eggs[p2];
	
	local l__isGolden__3 = v2.isGolden;
	local v4 = p2 == "Exclusive Egg";
	local v5 = v2.drops;
	if type(v5) == "string" then
		v5 = u1.Directory.Eggs[v5].drops;
	end;
	local u6 = u1.Functions.CloneTable(v5);
	local v6 = u1.Gamepasses.Owns(p1, l__ID__3);
	--local v7 = u1.Gamepasses.Owns(p1, l__ID__4);
	--local v8 = u1.Upgrades.Get(p1, "Halloween Legendary Pets");
	--local v9 = u1.Upgrades.Get(p1, "Halloween Mythical Pets");
	local v10
	if l__isGolden__3 then
		v10 = "Golden Eggs";
	else
		v10 = "Eggs";
	end;
	local u7 = (u1.Boosts.Has(p1, "Super Lucky") and u1.Settings.SuperLuckyMult or 0) + (u1.Boosts.Has(p1, "Ultra Lucky") and u1.Settings.UltraLuckyMult or 0) + (u1.Gamepasses.Owns(p1, l__ID__2) and u1.Settings.LuckyPassMult or 0) + ( u1.Settings.LuckyMult or 0)
	local function u8(p4)
		local v11 = 0;
		for v12, v13 in pairs(u6) do
			local v14, v15 = unpack(v13);
			v11 = v11 + v15;
		end;
		for v16, v17 in pairs(u6) do
			local v18, v19 = unpack(v17);
			if v19 / v11 <= 0.05 then
				local v20 = u6[v16];
				v20[2] = v20[2] * p4;
			end;
		end;
	end;
	local function u9(p5, p6)
		for v21, v22 in pairs(u6) do
			local v23, v24 = unpack(v22);
			if u1.Directory.Pets[v23].rarity == p5 then
				local v25 = u6[v21];
				v25[2] = v25[2] * p6;
			end;
		end;
	end;
	if not v4 then
		(function()
			if u7 > 0 then
				u8(u7);
			end;
			if v6 then
				u9("Mythical", u1.Settings.MythicalHunterMult);
			end;
			--if v8 > 0 then
			--	u9("Legendary", 1 + v8 * 0.2);
			--end;
			--if v9 > 0 then
			--	u9("Mythical", 1 + v9 * 0.2);
			--end;
			--if u1.Mastery.HasPerk(p1, v10, 3) then
			--	u8(2);
			--	return;
		---	end;
			--if u1.Mastery.HasPerk(p1, v10, 1) then
			--	u8(1.33);
			--end;
		end)();
	end;
	local function v26()
		local v27 = u1.Functions.Lottery(unpack(u6));
		local v28 = u1.Directory.Pets[v27];
		if not v28 then
			print("Pet does not exist (" .. v27 .. " from egg " .. p2 .. ")", true);
			return false;
		end;
		local v29 = false;
		local v30 = false;
		local v31 = false;
		local v32 = false;
		local v33 = u1.Settings.MagicEggsChances.Golden;
		local v34 = u1.Settings.MagicEggsChances.Rainbow;
		--if u1.Mastery.HasPerk(p1, v10, 5) then
			--if l__isGolden__3 then
			--	v32 = true;
			--	v34 = v34 * 1.2;
			--else
			--	v31 = true;
			---	v33 = v33 * 1.2;
			--end;
		--end;
		--if v7 then
		--	v32 = true;
	--		v31 = true;
	--	end;
		if v31 or v32 then
			local v35 = u5:NextNumber() * 100;
			if v35 <= v34 and v32 then
				v30 = true;
			elseif v35 <= v33 and v31 then
				v29 = true;
			end;
		end;
		if not v30 and l__isGolden__3 and u5:NextNumber(0, 100) <= u1.Settings.GoldenEggChance then
			v29 = true;
		end;
		if v4 then
			v29 = false;
			v30 = false;
		end;
		local v36 = {};
		if v30 then
			v36.r = true;
			v36.s = v28.strengthMax * u1.Settings.RainbowPetsMult;
		elseif v29 then
			v36.g = true;
			v36.s = v28.strengthMax * u1.Settings.GoldPetsMult;
		end;
		local v37, v38 = u1.Pets.Create(p1, v27, v36);
		if not v37 then
			return false;
		end;
		u1.Signal.Fire("Hatched Pet", p1, p2, v38);
		local l__rarity__10 = v28.rarity;

		coroutine.wrap(function()
			u1.Functions.Wait(3);
			if u1.Shared.PetRarityNumbers[l__rarity__10] >= 3 then
				RareHatchChatMessage(v37, v36);
			end;
			if l__rarity__10 == "Rare" then
				u1.Achievements.Add(p1, "Rare Pets", 1);
				return;
			end;
			if l__rarity__10 == "Epic" then
				u1.Achievements.Add(p1, "Epic Pets", 1);
				return;
			end;
			if l__rarity__10 == "Legendary" then
				u1.Achievements.Add(p1, "Legendary Pets", 1);
				return;
			end;
			if l__rarity__10 == "Mythical" then
				u1.Achievements.Add(p1, "Mythical Pets", 1);
				return;
			end;
			if l__rarity__10 == "Exclusive" then

			end;
		end)();
		return v38;
	end;
	local v39 = {};
	for v40 = 1, p3 do
		local v41 = v26();
		if v41 then
			table.insert(v39, v41);
		end;
	end;
	u1.Network.Fire("Open Egg", p1, p2, v39);
	return true;
end;
local l__ID__11 = u1.Directory.Gamepasses["Triple Egg"].ID;
local u12 = {};
function v1.Buy(p7, p8, p9)
	local v42 = u1.Saving.Get(p7);
	local v43 = u1.Directory.Eggs[p8];
	if not v42 or not v43 then
		return false;
	end;
	local v44
	if p9 then
		v44 = 3;
	else
		v44 = 1;
	end;
	local v45 = v43.cost * v44;
	local l__currency__46 = v43.currency;
	local l__area__47 = v43.area;
	local l__areaRequired__48 = v43.areaRequired;
	local l__areaEggsRequired__49 = v43.areaEggsRequired;
	if not v43.hatchable or v43.disabled then
		return false;
	end;
	local v50 
	if v43.isGolden then
		v50 = "Golden Eggs";
	else
		v50 = "Eggs";
	end;
	--if u1.Mastery.HasPerk(p7, v50, 4) then
	--	local v51
	--	if v43.isGolden then
		--	v51 = 0.85;
	--	else
	--		v51 = 0.8;
	--	end;
	--	v45 = v45 * v51;
	--elseif u1.Mastery.HasPerk(p7, v50, 2) then
		--local v52
		--if v43.isGolden then
		--	v52 = 0.95;
		--else
		--	v52 = 0.9;
	---	end;
	--	v45 = v45 * v52;