f93_system_has_ancient_relay = {
	OR = {
		has_megastructure = dandelion_relay
		has_megastructure = dandelion_relay_star
		AND = {
			OR ={
				has_global_flag = f82_button_2_1_off
				has_overlord_dlc = no
			}
			has_star_flag = f93_ancient_relay_system
		}
	}
}

safe_highway_start_end = {
	NOR = {
		exists = owner
		any_fleet_in_system = { exists = this }
		has_star_flag = chosen_cluster
		has_star_flag = empire_cluster
		# any_neighbor_system = { exists = owner }
		closest_system = {
			exists = owner
			max_steps = 3
		}
	}
}

is_union_state = {
	# or = {
	# 	is_country_type = fallen_empire
	# 	is_country_type = awakened_fallen_empire
	# }
	is_same_value = event_target:galactic_union_state
}

is_shrouded_ai = {
	is_ai = yes
	is_country_type = default
	NOR = {
		has_country_flag = chosen_empire
	}
	capital_scope = {
		f93_system_winthin_20_steps_of_galcro = no
		has_star_flag = f93_isolated_capital_system
	}
}
is_shrouded_player = {
	is_ai = no
	capital_scope = {
		# f93_system_winthin_20_steps_of_galcro = no
		# NEW ISOLATION DETECTION
		any_system = {
			distance = {
				source = prev
				type = hyperlane
				max_jumps = 30
			}
			OR = {
				has_star_flag = normal_region
				f93_system_has_ancient_relay = yes
			}
			exists = this
		}
	}
}
f93_is_close_to_highway = {
	OR = {
		any_system_within_border = { f93_system_has_ancient_relay = yes }
		any_system_within_border = {
			any_neighbor_system = { f93_system_has_ancient_relay = yes }
		}
	}
}
f93_system_winthin_20_steps_of_galcro = {
	closest_system = {
		f93_system_has_ancient_relay = yes
		max_steps = 20
		exists = this
	}
}
f93_has_zro_cartel = {
	OR = {
		has_modifier = f93_zro_cartel
		has_modifier = f93_zro_drone_cartel
	}
}

f93_is_zro_cartel_lord = {
	any_owned_planet = { is_same_value = event_target:f93_ralis_planet }
}

f93_country_is_connected_to_gal_crossing = {
	any_system_within_border = {
		OR = {
			f93_system_has_ancient_relay = yes
			AND = {
				has_megastructure = hyper_relay
				closest_system = {
					f93_system_has_ancient_relay = yes
					max_steps = 1
					use_bypasses = yes
				}
			}
		}
		is_system_connected_to_relay_network = yes
	}
}

invalid_shrouded_system = {
	OR = {
		has_star_flag = chosen_cluster
		has_star_flag = lcluster
		has_star_flag = surveillance_supercomputer_system
		has_star_flag = empire_cluster
		#Away on an Island Origin in Giga
		has_star_flag = cohesive_system	
	}
}
is_shrouded_region_system = {
	has_star_flag = f93_new_shrouded_region
	has_star_flag = f93_shroud_region_flag
}
f93_is_in_a_cluster = {
	OR = {
		has_star_flag = f93_shrouded_cluster
		has_star_flag = f93_ralisgate_cluster
		has_star_flag = f93_ralisgate
		has_star_flag = f93_ralis_empire_cluster
		has_star_flag = sealed_entry_system # avoid connecting this system
		any_neighbor_system = { has_hyperlane_to = prev }
	}
}
