@LAST_POLICY_ID = 79

scripted_gui = {
	show_their_ideas_window = {
		context_type = selected_country_context

		window_name = "show_their_ideas_window"
		parent_window_token = selected_country_view_diplomacy

		visible = {
			ROOT = {
				is_ai = no
			}
		}
	}

	open_ideas_window = {
		context_type = player_context

		window_name = "open_ideas_window"
		parent_window_token = politics_tab

		visible = {
			always = yes
		}

		effects = {
			open_button_click = {
				if = {
					limit = {
						has_variable = show_ideas_window
					}
					clear_variable = show_ideas_window
				}
				else = {
					set_ideas_up_at_start_effect = yes
					clear_variable = show_selectable_idea_groups_window
					clear_variable = show_ideas_window_confirm_alert
					clear_variable = confirm_idea_group
					clear_variable = confirm_idea
					clear_variable = show_policies_window
					remove_flags_for_available_dismissed_alerts = yes
					refresh_eu4_like_alerts = yes
					set_variable = { show_ideas_window = 1 }
				}
			}
		}

		triggers = {
			open_button_glow_visible = {
				OR = {
					can_select_any_idea_group = yes
					can_select_any_idea = yes
				}
			}
		}

		properties = {
			open_button_glow = {
				x = eu4_style_ideas_open_button_x
			}
			open_button = {
				x = eu4_style_ideas_open_button_x
			}
		}

		ai_enabled = {
			always = yes
		}

		ai_test_interval = 168
		ai_test_variance = 1

		ai_check = {
			NOT = { has_variable = show_ideas_window }
			NOT = { has_variable = show_selectable_idea_groups_window }
			OR = {
				AND = {
					can_select_any_idea_group = yes
					OR = {
						NOT = { has_country_flag = does_not_want_to_choose_idea_group }
						has_country_flag = {
							flag = does_not_want_to_choose_idea_group
							days > 50
						}
					}
				}
				can_select_any_idea = yes
				AI_can_remove_any_idea_group = yes
				can_select_any_policy = yes
				AI_might_want_to_remove_any_policy = yes
				# Never opened the GUI & has never set up ideas:
				NOT = { has_country_flag = selected_idea_groups_array_set }
				check_variable = { national_ideas_id = 0 }
			}
		}

		ai_weights = {
			open_button_click = {
				ai_will_do = {
					base = 1

					modifier = {
						factor = 0
						has_variable = show_ideas_window
					}
					modifier = {
						factor = 0
						has_global_flag = eu4_like_ideas_ai_disabled
					}
					modifier = {
						factor = 0
						NOT = {
							OR = {
								AND = {
									NOT = { has_global_flag = eu4_like_ideas_ai_only_majors }
									NOT = { has_global_flag = eu4_like_ideas_ai_only_minors }
									OR = {
										NOT = { has_global_flag = eu4_like_ideas_ai_idea_usage_delayed }
										AND = {
											has_global_flag = eu4_like_ideas_ai_idea_usage_delayed
											meta_trigger = {
												text = {
													date > [DATE]
												}
												DATE = "[?global.eu4_like_ideas_AI_idea_usage_delay.GetDateStringNoHour]"
											}
										}
									}
								}
								AND = {
									is_major = yes
									has_global_flag = eu4_like_ideas_ai_only_majors
									OR = {
										NOT = { has_global_flag = eu4_like_ideas_ai_idea_usage_delayed }
										AND = {
											has_global_flag = eu4_like_ideas_ai_idea_usage_delayed
											meta_trigger = {
												text = {
													date > [DATE]
												}
												DATE = "[?global.eu4_like_ideas_AI_idea_usage_delay.GetDateStringNoHour]"
											}
										}
									}
								}
								AND = {
									is_major = no
									has_global_flag = eu4_like_ideas_ai_only_minors
									OR = {
										NOT = { has_global_flag = eu4_like_ideas_ai_idea_usage_delayed }
										AND = {
											has_global_flag = eu4_like_ideas_ai_idea_usage_delayed
											meta_trigger = {
												text = {
													date > [DATE]
												}
												DATE = "[?global.eu4_like_ideas_AI_idea_usage_delay.GetDateStringNoHour]"
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	ideas_window = {
		context_type = player_context

		window_name = "ideas_window"

		dirty = show_ideas_window

		visible = {
			has_variable = show_ideas_window
		}

		effects = {
			close_button_click = {
				clear_variable = show_ideas_window
			}
			flag_click = {
				capital_scope = {
					ROOT = {
						goto_state = PREV
					}
				}
				update_main_ideas_window = yes
			}
			add_policy_button_click = {
				set_variable = { show_policies_window = 1 }
				update_policies_effect = yes
				clear_variable = show_ideas_window
			}
			show_remaining_idea_groups_button_click = {
				set_variable = { show_selectable_idea_groups_window = 1 }
				clear_variable = show_ideas_window
			}

			remove_policy_button_click = {
				if = {
					limit = {
						meta_trigger = {
							text = {
								set_temp_variable = { required_date_to_remove_policy = eu4_like_policy_[POLICY]_date }
							}
							POLICY = "[?v]"
						}
						meta_trigger = {
							text = {
								date > [DATE]
							}
							DATE = "[?required_date_to_remove_policy.GetDateStringNoHour]"
						}
					}
					if = {
						limit = {
							is_ai = no
						}
						set_variable = { show_ideas_window_confirm_alert = 5 }
						set_variable = { confirm_policy = v }
					}
					else = {
						remove_policy = yes
					}
				}
				update_main_ideas_window = yes
			}

			open_selectable_ideas_button_click = {
				set_variable = { show_selectable_idea_groups_window = 1 }
				clear_variable = show_ideas_window
			}
			remove_idea_group_button_click = {
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 3 }
					set_variable = { confirm_idea_group = v }
				}
				else = {
					remove_idea_group_effect = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_1_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 1 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_1_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_2_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 2 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_2_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_3_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 3 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_3_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_4_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 4 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_4_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_5_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 5 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_5_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_6_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 6 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_6_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_7_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 7 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_7_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
		}

		triggers = {
			close_button_click_enabled = {
				NOT = { has_variable = show_ideas_window_confirm_alert }
			}
			add_policy_button_click_enabled = {
				OR = {
					has_not_selected_max_amount_of_policies = yes
					is_ai = no
				}
			}
			show_remaining_idea_groups_button_visible = {
				NOT = { is_in_array = { selected_idea_groups = 0 } }
			}
			traditions_icon_1_visible = {
				is_ai = no
				meta_trigger = {
					text = {
						has_idea = national_ideas_[GROUP]_0
					}
					GROUP = "[?national_ideas_id]"
				}
			}
			traditions_icon_2_visible = {
				is_ai = no
				meta_trigger = {
					text = {
						has_idea = national_ideas_[GROUP]_0
					}
					GROUP = "[?national_ideas_id]"
				}
			}
			traditions_text_visible = {
				is_ai = no
				meta_trigger = {
					text = {
						has_idea = national_ideas_[GROUP]_0
					}
					GROUP = "[?national_ideas_id]"
				}
			}
			ambitions_icon_visible = {
				is_ai = no
				meta_trigger = {
					text = {
						has_idea = national_ideas_[GROUP]_8
					}
					GROUP = "[?national_ideas_id]"
				}
			}
			ambitions_text_visible = {
				is_ai = no
				meta_trigger = {
					text = {
						has_idea = national_ideas_[GROUP]_8
					}
					GROUP = "[?national_ideas_id]"
				}
			}
			national_idea_progress_green_visible = {
				check_variable = { completed_national_ideas < 7 }
				check_variable = { national_ideas_progress > 0 }
			}
			national_idea_progress_black_visible = {
				check_variable = { completed_national_ideas < 7 }
			}
			national_idea_progress_frame_visible = {
				check_variable = { completed_national_ideas < 7 }
			}
			national_idea_1_click_enabled = {
				check_variable = { completed_national_ideas > 0 }
			}
			national_idea_2_click_enabled = {
				check_variable = { completed_national_ideas > 1 }
			}
			national_idea_3_click_enabled = {
				check_variable = { completed_national_ideas > 2 }
			}
			national_idea_4_click_enabled = {
				check_variable = { completed_national_ideas > 3 }
			}
			national_idea_5_click_enabled = {
				check_variable = { completed_national_ideas > 4 }
			}
			national_idea_6_click_enabled = {
				check_variable = { completed_national_ideas > 5 }
			}
			national_idea_7_click_enabled = {
				check_variable = { completed_national_ideas > 6 }
			}

			open_selectable_ideas_button_visible = {
				check_variable = { v = 0 }
			}
			open_selectable_ideas_button_click_enabled = {
				OR = {
					has_global_flag = eu4_like_ideas_test_flag
					check_variable = { i = 0 }
					AND = {
						check_variable = { i = 1 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_2.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^0 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 2 }
						check_variable = { i = 2 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_3.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^1 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 2 }
						check_variable = { i = 3 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_4.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^2 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 4 }
						check_variable = { i = 4 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_5.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^3 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 4 }
						check_variable = { i = 5 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_6.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^4 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 6 }
						check_variable = { i = 6 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_7.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^5 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 6 }
						check_variable = { i = 7 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_8.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^6 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 8 }
						check_variable = { i = 8 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_9.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^7 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 8 }
						check_variable = { i = 9 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_10.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^8 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 10 }
						check_variable = { i = 10 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_11.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^9 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 10 }
						check_variable = { i = 11 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_12.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^10 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 12 }
						check_variable = { i = 12 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_13.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^11 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 12 }
						check_variable = { i = 13 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_14.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^12 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 14 }
						check_variable = { i = 14 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_15.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^13 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 14 }
						check_variable = { i = 15 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_16.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^14 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 16 }
						check_variable = { i = 16 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_17.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^15 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 16 }
						check_variable = { i = 17 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_18.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^16 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 18 }
						check_variable = { i = 18 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_19.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^17 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 18 }
						check_variable = { i = 19 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_20.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^18 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 20 }
						check_variable = { i = 20 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_21.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^19 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 20 }
						check_variable = { i = 21 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_22.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^20 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 22 }
						check_variable = { i = 22 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_23.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^21 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 22 }
						check_variable = { i = 23 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_24.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^22 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 24 }
						check_variable = { i = 24 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_25.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^23 = 0 } }
						}
					}
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > 24 }
						check_variable = { i = 25 }
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?global.unlock_date_for_idea_group_26.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^24 = 0 } }
						}
					}
				}
			}
			free_slot_glow_visible = {
				is_ai = no
				check_variable = { v = 0 }
				specific_idea_group_slot_is_unlocked = yes
			}
			text_unlocked_at_visible = {
				check_variable = { v = 0 }
			}
			selected_idea_groups_bg_visible = {
				check_variable = { v > 0 }
			}
			selected_idea_resource_icon_visible = {
				check_variable = { v > 0 }
			}
			selected_idea_icon_visible = {
				check_variable = { v > 0 }
			}
			selected_idea_name_visible = {
				check_variable = { v > 0 }
			}
			remove_idea_group_button_visible = {
				check_variable = { v > 0 }
			}
			selected_idea_uncompleted_icon_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 7 }
					}
					GROUP = "[?v]"
				}
			}
			selected_idea_completed_icon_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 6 }
					}
					GROUP = "[?v]"
				}
			}

			cannot_select_idea_1_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 0 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_1_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 0 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_1_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 0 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_1_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 1 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_1_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 0 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_2_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 1 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_2_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 1 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_2_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 1 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_2_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 2 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_2_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 1 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_3_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 2 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_3_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 2 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_3_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 2 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_3_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 3 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_3_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 2 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_4_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 3 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_4_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 3 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_4_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 3 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_4_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 4 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_4_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 3 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_5_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 4 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_5_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 4 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_5_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 4 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_5_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 5 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_5_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 4 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_6_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 5 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_6_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 5 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_6_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 5 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_6_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 6 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_6_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 5 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_7_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 6 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_7_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 6 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_7_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 6 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_7_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 7 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_7_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 6 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			next_idea_progress_frame_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 7 }
					}
					GROUP = "[?v]"
				}
			}
			next_idea_progress_green_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 7 }
					}
					GROUP = "[?v]"
				}
				set_temp_variable = { idea_group_progress = political_power }
				divide_temp_variable = { idea_group_progress = idea_cost_var }
				multiply_temp_variable = { idea_group_progress = 100 }
				round_temp_variable = idea_group_progress
				clamp_temp_variable = {
					var = idea_group_progress
					min = 0
					max = 100
				}
				check_variable = { idea_group_progress > 0 }
			}
			next_idea_progress_red_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 7 }
					}
					GROUP = "[?v]"
				}
			}
		}

		dynamic_lists = {
			selected_idea_groups_gridbox = {
				array = selected_idea_groups
				entry_container = selected_idea_groups_entry

				ai_weights = {
					open_selectable_ideas_button_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 10

								check_variable = { v = 0 }
								specific_idea_group_slot_is_unlocked = yes
							}
							modifier = {
								factor = 0
								has_country_flag = does_not_want_to_choose_idea_group
								has_country_flag = {
									flag = does_not_want_to_choose_idea_group
									days < 50
								}
							}
						}
					}
					select_idea_button_1_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_2_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_3_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_4_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_5_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_6_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_7_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					remove_idea_group_button_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 2
								NOT = { has_global_flag = eu4_like_ideas_rule_AI_ability_to_remove_idea_groups_disabled }
								OR = {
									AND = {
										check_variable = { v = 4 }
										OR = {
											AND = {
												NOT = { has_government = communism }
												NOT = { AI_is_set_to_become_communist = yes }
												communism < 0.2
											}
											OR = {
												AI_is_set_to_become_democratic = yes
												democratic > 0.5
											}
											OR = {
												AI_is_set_to_become_fascist = yes
												fascism > 0.5
											}
											OR = {
												AI_is_set_to_become_neutral = yes
												AND = {
													is_neutral_monarchy = yes
													neutrality > 0.5
												}
											}
										}
									}
									AND = {
										check_variable = { v = 5 }
										OR = {
											AND = {
												NOT = { has_government = democratic }
												NOT = { AI_is_set_to_become_democratic = yes }
												democratic < 0.2
											}
											OR = {
												AI_is_set_to_become_communist = yes
												communism > 0.5
											}
											OR = {
												AI_is_set_to_become_fascist = yes
												fascism > 0.5
											}
											OR = {
												AI_is_set_to_become_neutral = yes
												AND = {
													is_neutral_monarchy = yes
													neutrality > 0.5
												}
											}
										}
									}
									AND = {
										check_variable = { v = 6 }
										OR = {
											AND = {
												NOT = { has_government = fascism }
												NOT = { AI_is_set_to_become_fascist = yes }
												fascism < 0.2
											}
											OR = {
												AI_is_set_to_become_communist = yes
												communism > 0.5
											}
											OR = {
												AI_is_set_to_become_democratic = yes
												democratic > 0.5
											}
											OR = {
												AI_is_set_to_become_neutral = yes
												AND = {
													is_neutral_monarchy = yes
													neutrality > 0.5
												}
											}
										}
									}
									AND = {
										check_variable = { v = 19 }
										OR = {
											AND = {
												NOT = { has_government = neutrality }
												NOT = { is_neutral_monarchy = yes }
												NOT = { AI_is_set_to_become_neutral = yes }
												neutrality < 0.2
											}
											OR = {
												AI_is_set_to_become_communist = yes
												communism > 0.5
											}
											OR = {
												AI_is_set_to_become_democratic = yes
												democratic > 0.5
											}
											OR = {
												AI_is_set_to_become_fascist = yes
												fascism > 0.5
											}
										}
									}
								}
							}
						}
					}
				}
			}
			selected_policies_gridbox = {
				array = selected_policies_array
				entry_container = selected_policies_entry

				ai_weights = {
					remove_policy_button_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 3
								AI_might_want_to_remove_any_policy = yes
								meta_trigger = {
									text = {
										set_temp_variable = { required_date_to_remove_policy = eu4_like_policy_[POLICY]_date }
									}
									POLICY = "[?v]"
								}
								meta_trigger = {
									text = {
										date > [DATE]
									}
									DATE = "[?required_date_to_remove_policy.GetDateStringNoHour]"
								}
							}
						}
					}
				}
			}
		}

		properties = {
			flag = {
				image = "[This.GetFlag]"
			}
			national_idea_progress_green = {
				frame = national_ideas_progress
			}
			selected_idea_icon = {
				image = "[This.GetIdeaGroupIcon]"
			}
			next_idea_progress_green = {
				frame = idea_group_progress
			}

			traditions_icon_1 = {
				image = "[This.GetNationalIdeaFirstPicture0]"
			}
			traditions_icon_2 = {
				image = "[This.GetNationalIdeaSecondPicture0]"
			}
			ambitions_icon = {
				image = "[This.GetNationalIdeaPicture8]"
			}
			national_idea_1 = {
				image = "[This.GetNationalIdeaPicture1]"
			}
			national_idea_2 = {
				image = "[This.GetNationalIdeaPicture2]"
			}
			national_idea_3 = {
				image = "[This.GetNationalIdeaPicture3]"
			}
			national_idea_4 = {
				image = "[This.GetNationalIdeaPicture4]"
			}
			national_idea_5 = {
				image = "[This.GetNationalIdeaPicture5]"
			}
			national_idea_6 = {
				image = "[This.GetNationalIdeaPicture6]"
			}
			national_idea_7 = {
				image = "[This.GetNationalIdeaPicture7]"
			}

			selected_idea_resource_icon = {
				image = "[This.GetIdeaGroupResourceIcon]"
			}
			select_idea_button_1 = {
				image = "[This.GetIdeaPicture1]"
			}
			selected_idea_icon_1 = {
				image = "[This.GetIdeaPicture1]"
			}
			select_idea_button_2 = {
				image = "[This.GetIdeaPicture2]"
			}
			selected_idea_icon_2 = {
				image = "[This.GetIdeaPicture2]"
			}
			select_idea_button_3 = {
				image = "[This.GetIdeaPicture3]"
			}
			selected_idea_icon_3 = {
				image = "[This.GetIdeaPicture3]"
			}
			select_idea_button_4 = {
				image = "[This.GetIdeaPicture4]"
			}
			selected_idea_icon_4 = {
				image = "[This.GetIdeaPicture4]"
			}
			select_idea_button_5 = {
				image = "[This.GetIdeaPicture5]"
			}
			selected_idea_icon_5 = {
				image = "[This.GetIdeaPicture5]"
			}
			select_idea_button_6 = {
				image = "[This.GetIdeaPicture6]"
			}
			selected_idea_icon_6 = {
				image = "[This.GetIdeaPicture6]"
			}
			select_idea_button_7 = {
				image = "[This.GetIdeaPicture7]"
			}
			selected_idea_icon_7 = {
				image = "[This.GetIdeaPicture7]"
			}

			remove_policy_button = {
				image = "[This.GetPolicyPicture]"
			}
		}

		ai_enabled = {
			always = yes
		}

		ai_test_interval = 48
		ai_test_variance = 1

		ai_check = {
			has_variable = show_ideas_window
			NOT = { has_variable = show_ideas_window_confirm_alert }
		}

		ai_max_weight_taken_per_test = 5
		ai_weights = {
			close_button_click = {
				ai_will_do = {
					base = 0

					modifier = {
						add = 1
						NOT = { can_select_any_idea_group = yes }
						NOT = { can_select_any_idea = yes }
						NOT = { AI_can_remove_any_idea_group = yes }
						NOT = { can_select_any_policy = yes }
						NOT = { AI_might_want_to_remove_any_policy = yes }
					}
					modifier = {
						add = 1000
						NOT = { can_select_any_idea = yes }
						NOT = { AI_can_remove_any_idea_group = yes }
						NOT = { can_select_any_policy = yes }
						NOT = { AI_might_want_to_remove_any_policy = yes }
						has_country_flag = does_not_want_to_choose_idea_group
						has_country_flag = {
							flag = does_not_want_to_choose_idea_group
							days < 50
						}
					}
				}
			}
			flag_click = {
				ai_will_do = {
					factor = 0
				}
			}
			add_policy_button_click = {
				ai_will_do = {
					base = 0

					modifier = {
						add = 3
						can_select_any_policy = yes
					}
				}
			}
		}
	}

	selectable_idea_groups_window = {
		context_type = player_context

		window_name = "selectable_idea_groups_window"

		dirty = show_selectable_idea_groups_window

		visible = {
			has_variable = show_selectable_idea_groups_window
		}

		effects = {
			close_button_click = {
				set_variable = { show_ideas_window = 1 }
				clear_variable = show_selectable_idea_groups_window
				if = {
					limit = {
						is_ai = yes
					}
					clr_country_flag = does_not_want_to_choose_idea_group
					set_country_flag = does_not_want_to_choose_idea_group
				}
			}
			select_idea_group_button_click = {
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 1 }
					set_variable = { confirm_idea_group = v }
				}
				else = {
					select_idea_group_effect = yes
				}
				update_selectable_idea_groups_window = yes
			}
		}

		triggers = {
			close_button_click_enabled = {
				NOT = { has_variable = show_ideas_window_confirm_alert }
			}
			adm_idea_groups_empty_info_visible = {
				check_variable = { adm_idea_groups^num < 1 }
			}
			dip_idea_groups_empty_info_visible = {
				check_variable = { dip_idea_groups^num < 1 }
			}
			mil_idea_groups_empty_info_visible = {
				check_variable = { mil_idea_groups^num < 1 }
			}

			select_idea_group_button_click_enabled = {
				can_select_any_idea_group = yes
				set_temp_variable = { num_of_selected_adm = 9 }
				subtract_from_temp_variable = { num_of_selected_adm = adm_idea_groups^num }
				set_temp_variable = { num_of_selected_dip = 9 }
				subtract_from_temp_variable = { num_of_selected_dip = dip_idea_groups^num }
				set_temp_variable = { num_of_selected_mil = 9 }
				subtract_from_temp_variable = { num_of_selected_mil = mil_idea_groups^num }
				set_temp_variable = { total_num_of_selected_ideas = num_of_selected_adm }
				add_to_temp_variable = { total_num_of_selected_ideas = num_of_selected_dip }
				add_to_temp_variable = { total_num_of_selected_ideas = num_of_selected_mil }
				divide_temp_variable = { total_num_of_selected_ideas = 2 }
				OR = {
					has_global_flag = eu4_like_ideas_test_flag
					has_global_flag = eu4_like_ideas_limit_for_idea_groups_from_same_type_disabled
					AND = {
						OR = {
							check_variable = { v = 1 }
							check_variable = { v = 2 }
							check_variable = { v = 3 }
							check_variable = { v = 4 }
							check_variable = { v = 5 }
							check_variable = { v = 6 }
							check_variable = { v = 19 }
							check_variable = { v = 22 }
							check_variable = { v = 25 }
						}
						OR = {
							check_variable = { num_of_selected_adm = 0 }
							check_variable = { var = total_num_of_selected_ideas value = num_of_selected_adm compare = greater_than_or_equals }
						}
					}
					AND = {
						OR = {
							check_variable = { v = 7 }
							check_variable = { v = 8 }
							check_variable = { v = 9 }
							check_variable = { v = 10 }
							check_variable = { v = 11 }
							check_variable = { v = 12 }
							check_variable = { v = 20 }
							check_variable = { v = 23 }
							check_variable = { v = 26 }
						}
						OR = {
							check_variable = { num_of_selected_dip = 0 }
							check_variable = { var = total_num_of_selected_ideas value = num_of_selected_dip compare = greater_than_or_equals }
						}
					}
					AND = {
						OR = {
							check_variable = { v = 13 }
							check_variable = { v = 14 }
							check_variable = { v = 15 }
							check_variable = { v = 16 }
							check_variable = { v = 17 }
							check_variable = { v = 18 }
							check_variable = { v = 21 }
							check_variable = { v = 24 }
							check_variable = { v = 27 }
						}
						OR = {
							check_variable = { num_of_selected_mil = 0 }
							check_variable = { var = total_num_of_selected_ideas value = num_of_selected_mil compare = greater_than_or_equals }
						}
					}
				}
			}
		}

		dynamic_lists = {
			adm_idea_groups_gridbox = {
				array = adm_idea_groups
				entry_container = selectable_idea_groups_entry

				ai_weights = {
					select_idea_group_button_click = {
						ai_will_do = {
							base = 1

							modifier = {
								add = 2
								check_variable = { v = 1 }
								OR = {
									check_variable = { selected_idea_groups^0 = 0 }
									check_variable = { selected_idea_groups^1 = 0 }
									check_variable = { selected_idea_groups^2 = 0 }
									check_variable = { selected_idea_groups^3 = 0 }
								}
								OR = {
									has_stability < 0.6
									amount_taken_ideas = {
										amount < 2
										slots = {
											political_advisor
										}
									}
								}
							}
							modifier = {
								add = 100
								check_variable = { v = 1 }
								tag = USA
								check_variable = { selected_idea_groups^0 = 0 }
							}
							modifier = {
								add = 2
								check_variable = { v = 2 }
								OR = {
									num_of_military_factories < 50
									num_of_naval_factories < 15
									num_of_civilian_factories < 10
								}
							}
							modifier = {
								add = 150
								check_variable = { v = 2 }
								tag = GER
							}
							modifier = {
								add = 2
								check_variable = { v = 3 }
								OR = {
									check_variable = { selected_idea_groups^0 = 0 }
									check_variable = { selected_idea_groups^1 = 0 }
									check_variable = { selected_idea_groups^2 = 0 }
									check_variable = { selected_idea_groups^3 = 0 }
									check_variable = { selected_idea_groups^4 = 0 }
								}
								OR = {
									amount_research_slots < 4
									num_of_military_factories < 20
								}
							}
							modifier = {
								factor = 0.01
								check_variable = { v = 3 }
								tag = GER
								has_country_leader = {
									name = "Adolf Hitler"
									ruling_only = yes
								}
							}
							modifier = {
								factor = 0
								OR = {
									check_variable = { v = 4 }
									check_variable = { v = 5 }
									check_variable = { v = 6 }
									check_variable = { v = 19 }
								}
								OR = {
									AND = {
										set_temp_variable = { idea_group_out_of_context = 4 }
										has_selected_idea_group = yes
									}
									AND = {
										set_temp_variable = { idea_group_out_of_context = 5 }
										has_selected_idea_group = yes
									}
									AND = {
										set_temp_variable = { idea_group_out_of_context = 6 }
										has_selected_idea_group = yes
									}
									AND = {
										set_temp_variable = { idea_group_out_of_context = 19 }
										has_selected_idea_group = yes
									}
								}
							}
							modifier = {
								add = 50
								check_variable = { v = 4 }
								set_temp_variable = { idea_group_out_of_context = 5 }
								NOT = { has_selected_idea_group = yes }
								set_temp_variable = { idea_group_out_of_context = 6 }
								NOT = { has_selected_idea_group = yes }
								set_temp_variable = { idea_group_out_of_context = 19 }
								NOT = { has_selected_idea_group = yes }
								NOT = { AI_is_set_to_become_democratic = yes }
								NOT = { AI_is_set_to_become_fascist = yes }
								NOT = { AI_is_set_to_become_neutral = yes }
								OR = {
									AND = {
										communism > 0.25
										democratic < 0.25
										fascism < 0.25
										neutrality < 0.25
									}
									has_government = communism
									AI_is_set_to_become_communist = yes
								}
							}
							modifier = {
								add = 50
								check_variable = { v = 5 }
								set_temp_variable = { idea_group_out_of_context = 4 }
								NOT = { has_selected_idea_group = yes }
								set_temp_variable = { idea_group_out_of_context = 6 }
								NOT = { has_selected_idea_group = yes }
								set_temp_variable = { idea_group_out_of_context = 19 }
								NOT = { has_selected_idea_group = yes }
								NOT = { AI_is_set_to_become_communist = yes }
								NOT = { AI_is_set_to_become_fascist = yes }
								NOT = { AI_is_set_to_become_neutral = yes }
								OR = {
									AND = {
										democratic > 0.25
										communism < 0.25
										fascism < 0.25
										neutrality < 0.25
									}
									has_government = democratic
									AI_is_set_to_become_democratic = yes
								}
							}
							modifier = {
								add = 50
								check_variable = { v = 6 }
								set_temp_variable = { idea_group_out_of_context = 4 }
								NOT = { has_selected_idea_group = yes }
								set_temp_variable = { idea_group_out_of_context = 5 }
								NOT = { has_selected_idea_group = yes }
								set_temp_variable = { idea_group_out_of_context = 19 }
								NOT = { has_selected_idea_group = yes }
								NOT = { AI_is_set_to_become_communist = yes }
								NOT = { AI_is_set_to_become_democratic = yes }
								NOT = { AI_is_set_to_become_neutral = yes }
								OR = {
									AND = {
										fascism > 0.25
										communism < 0.25
										democratic < 0.25
										neutrality < 0.25
									}
									has_government = fascism
									AI_is_set_to_become_fascist = yes
								}
							}
							modifier = {
								add = 50
								check_variable = { v = 19 }
								set_temp_variable = { idea_group_out_of_context = 4 }
								NOT = { has_selected_idea_group = yes }
								set_temp_variable = { idea_group_out_of_context = 5 }
								NOT = { has_selected_idea_group = yes }
								set_temp_variable = { idea_group_out_of_context = 19 }
								NOT = { has_selected_idea_group = yes }
								NOT = { AI_is_set_to_become_communist = yes }
								NOT = { AI_is_set_to_become_democratic = yes }
								NOT = { AI_is_set_to_become_fascist = yes }
								OR = {
									is_neutral_monarchy = yes
									AI_is_set_to_become_neutral = yes
								}
								OR = {
									AND = {
										neutrality > 0.25
										fascism < 0.25
										democratic < 0.25
										communism < 0.25
									}
									has_government = neutrality
									AI_is_set_to_become_neutral = yes
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 22 }
								OR = {
									check_variable = { selected_idea_groups^0 = 0 }
									check_variable = { selected_idea_groups^1 = 0 }
									check_variable = { selected_idea_groups^2 = 0 }
									check_variable = { selected_idea_groups^3 = 0 }
								}
								political_power_daily < 1
								OR = {
									amount_taken_ideas = {
										amount < 2
										slots = {
											political_advisor
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											tank_manufacturer
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											naval_manufacturer
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											aircraft_manufacturer
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											materiel_manufacturer
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											industrial_concern
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											theorist
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											army_chief
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											navy_chief
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											air_chief
										}
									}
									amount_taken_ideas = {
										amount < 3
										slots = {
											high_command
										}
									}
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 25 }
								OR = {
									amount_taken_ideas = {
										amount < 2
										slots = {
											political_advisor
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											tank_manufacturer
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											naval_manufacturer
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											aircraft_manufacturer
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											materiel_manufacturer
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											industrial_concern
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											theorist
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											army_chief
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											navy_chief
										}
									}
									amount_taken_ideas = {
										amount < 1
										slots = {
											air_chief
										}
									}
									amount_taken_ideas = {
										amount < 3
										slots = {
											high_command
										}
									}
									can_select_any_policy = yes
								}
							}
							modifier = {
								factor = 0.01
								check_variable = { v = 25 }
								tag = GER
								has_country_leader = {
									name = "Adolf Hitler"
									ruling_only = yes
								}
							}
						}
					}
				}
			}
			dip_idea_groups_gridbox = {
				array = dip_idea_groups
				entry_container = selectable_idea_groups_entry

				ai_weights = {
					select_idea_group_button_click = {
						ai_will_do = {
							base = 1

							modifier = {
								add = 2
								check_variable = { v = 7 }
								NOT = { has_idea = limited_exports }
								NOT = { has_idea = closed_economy }
								set_temp_variable = { oil_produced_temp = resource_produced@oil }
								set_temp_variable = { rubber_produced_temp = resource_produced@rubber }
								set_temp_variable = { steel_produced_temp = resource_produced@steel }
								set_temp_variable = { chromium_produced_temp = resource_produced@chromium }
								OR = {
									has_government = democratic
									has_idea = free_trade
									check_variable = { oil_produced_temp > 150 }
									check_variable = { rubber_produced_temp > 75 }
									check_variable = { steel_produced_temp > 100 }
									check_variable = { chromium_produced_temp > 100 }
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 8 }
								OR = {
									has_government = democratic
									AND = {
										is_in_faction = yes
										num_faction_members > 9
										OR = {
											is_major = yes
											is_faction_leader = yes
										}
									}
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 9 }
								is_major = yes
								threat > 0.5
								has_added_tension_amount < 0.25
							}
							modifier = {
								add = 20
								check_variable = { v = 9 }
								OR = {
									tag = USA
									AND = {
										tag = ENG
										has_country_leader = {
											name = "Winston Churchill"
											ruling_only = yes
										}
									}
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 10 }
								OR = {
									num_subjects > 1
									AND = {
										NOT = { is_literally_china = yes }
										surrender_progress > 0.8
									}
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 11 }
								OR = {
									has_navy_size = {
										size > 30
										type = capital_ship
									}
									tag = ITA
									tag = ENG
								}
							}
							modifier = {
								add = 100
								check_variable = { v = 11 }
								OR = {
									tag = ENG
									tag = JAP
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 12 }
								OR = {
									has_navy_size = {
										size > 70
										type = submarine
									}
									has_completed_subdoctrine = wolfpacks
									has_completed_subdoctrine = submarine_fleet_operations
									has_completed_subdoctrine = capital_hunters
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 20 }
								has_navy_size = {
									size > 4
									type = carrier
								}
							}
							modifier = {
								add = 100
								check_variable = { v = 20 }
								OR = {
									tag = JAP
									tag = USA
								}
							}
							modifier = {
								add = 1.5
								check_variable = { v = 23 }
								has_government = communism
							}
							modifier = {
								add = 0.5
								check_variable = { v = 23 }
								NOT = { has_dlc = "La Resistance" }
							}
							modifier = {
								add = 3
								check_variable = { v = 23 }
								is_staging_coup = yes
							}
							modifier = {
								add = 2
								check_variable = { v = 26 }
								set_temp_variable = { idea_group_out_of_context = 27 }
								NOT = { has_selected_idea_group = yes }
								OR = {
									has_defensive_war = yes
									has_capitulated = yes
									any_other_country = {
										meta_trigger = {
											text = {
												strength_ratio = {
													tag = [COUNTRY]
													ratio > 1
												}
											}
											COUNTRY = "[Root.GetTag]"
										}
										OR = {
											is_justifying_wargoal_against = ROOT
											has_wargoal_against = ROOT
										}
									}
									any_owned_state = {
										NOT = { is_controlled_by = ROOT }
									}
								}
							}
							modifier = {
								add = 100
								check_variable = { v = 26 }
								set_temp_variable = { idea_group_out_of_context = 27 }
								NOT = { has_selected_idea_group = yes }
								tag = FRA
								has_government = democratic
							}
						}
					}
				}
			}
			mil_idea_groups_gridbox = {
				array = mil_idea_groups
				entry_container = selectable_idea_groups_entry

				ai_weights = {
					select_idea_group_button_click = {
						ai_will_do = {
							base = 1

							modifier = {
								add = 2
								check_variable = { v = 13 }
								NOT = { original_tag = ITA }
								OR = {
									any_unit_leader = {
										is_assigned = yes
										num_units > 10
										average_stats > 3
									}
									any_army_leader = {
										is_assigned = yes
										num_units > 10
										average_stats > 3
									}
								}
							}
							modifier = {
								factor = 0.5
								check_variable = { v = 13 }
								OR = {
									check_variable = { selected_idea_groups^0 = 0 }
									check_variable = { selected_idea_groups^1 = 0 }
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 14 }
								OR = {
									has_doctrine = new_mobile_warfare
									has_doctrine = superior_firepower
								}
								OR = {
									threat > 0.5
									has_government = communism
									has_government = fascism
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 15 }
								OR = {
									has_doctrine = mass_assault
									AND = {
										has_idea = scraping_the_barrel
										has_manpower < 50000
									}
									has_army_manpower = {
										size > 999999
									}
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 16 }
								set_temp_variable = { idea_group_out_of_context = 17 }
								NOT = { has_selected_idea_group = yes }
								OR = {
									has_offensive_war = yes
									has_completed_subdoctrine = mobile_defense
									any_other_country = {
										ROOT = {
											OR = {
												is_justifying_wargoal_against = PREV
												has_wargoal_against = PREV
											}
										}
									}
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 17 }
								set_temp_variable = { idea_group_out_of_context = 16 }
								NOT = { has_selected_idea_group = yes }
								OR = {
									has_defensive_war = yes
									has_doctrine = grand_battleplan
									bunker > 49
									any_other_country = {
										meta_trigger = {
											text = {
												strength_ratio = {
													tag = [COUNTRY]
													ratio > 1
												}
											}
											COUNTRY = "[Root.GetTag]"
										}
										OR = {
											is_justifying_wargoal_against = ROOT
											has_wargoal_against = ROOT
										}
									}
								}
							}
							modifier = {
								add = 100
								check_variable = { v = 17 }
								set_temp_variable = { idea_group_out_of_context = 16 }
								NOT = { has_selected_idea_group = yes }
								tag = FRA
								has_government = democratic
							}
							modifier = {
								add = 2
								check_variable = { v = 18 }
								has_deployed_air_force_size = {
									size > 1999
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 21 }
								has_army_size = {
									size > 14
									type = armor
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 24 }
								OR = {
									has_deployed_air_force_size = {
										size > 499
										type = cas
									}
									has_deployed_air_force_size = {
										size > 499
										type = tactical_bomber
									}
									has_deployed_air_force_size = {
										size > 499
										type = strategic_bomber
									}
								}
							}
							modifier = {
								add = 2
								check_variable = { v = 27 }
								set_temp_variable = { idea_group_out_of_context = 26 }
								NOT = { has_selected_idea_group = yes }
								OR = {
									has_offensive_war = yes
									num_occupied_states > 14
									any_other_country = {
										ROOT = {
											OR = {
												is_justifying_wargoal_against = PREV
												has_wargoal_against = PREV
											}
										}
									}
								}
							}
							modifier = {
								factor = 0
								check_variable = { v = 27 }
								has_global_flag = eu4_like_ideas_ai_disabled_collab_govs
							}
						}
					}
				}
			}
		}

		properties = {
			icon = {
				image = "[This.GetIdeaGroupIcon]"
			}
			resource_icon = {
				image = "[This.GetIdeaGroupResourceIcon]"
			}
			idea_icon_1 = {
				image = "[This.GetIdeaPicture1]"
			}
			idea_icon_2 = {
				image = "[This.GetIdeaPicture2]"
			}
			idea_icon_3 = {
				image = "[This.GetIdeaPicture3]"
			}
			idea_icon_4 = {
				image = "[This.GetIdeaPicture4]"
			}
			idea_icon_5 = {
				image = "[This.GetIdeaPicture5]"
			}
			idea_icon_6 = {
				image = "[This.GetIdeaPicture6]"
			}
			idea_icon_7 = {
				image = "[This.GetIdeaPicture7]"
			}
		}

		ai_enabled = {
			always = yes
		}

		ai_test_interval = 84
		ai_test_variance = 1

		ai_check = {
			has_variable = show_selectable_idea_groups_window
			NOT = { has_variable = show_ideas_window_confirm_alert }
		}

		ai_weights = {
			close_button_click = {
				ai_will_do = {
					factor = 0.01
				}
			}
		}
	}

	ideas_window_confirm_alert = {
		context_type = player_context

		window_name = "ideas_window_confirm_alert"

		visible = {
			is_ai = no
			has_variable = show_ideas_window_confirm_alert
		}

		effects = {
			cancel_button_click = {
				clear_variable = show_ideas_window_confirm_alert
				clear_variable = confirm_idea_group
				clear_variable = confirm_idea
				clear_variable = confirm_policy
				update_selectable_idea_groups_window = yes
				update_policy_window = yes
				update_main_ideas_window = yes
			}
			accept_button_click = {
				if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert < 4 }
					}
					set_temp_variable = { v = confirm_idea_group }
				}
				else = {
					set_temp_variable = { v = confirm_policy }
				}
				if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert = 1 }
					}
					select_idea_group_effect = yes
					scoped_sound_effect = "new_eu4_like_national_idea_unlocked"
				}
				else_if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert = 2 }
					}
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					meta_effect = {
						text = {
							complete_[IDEA]_idea_of_group = yes
						}
						IDEA = "[?confirm_idea]"
					}
					scoped_sound_effect = "click_accept_select_eu4_like_idea"
				}
				else_if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert = 3 }
					}
					remove_idea_group_effect = yes
					scoped_sound_effect = "disband"
				}
				else_if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert = 4 }
					}
					add_policy = yes
					set_variable = { show_ideas_window = 1 }
					clear_variable = show_policies_window
					clear_array = selectable_policies_array
					scoped_sound_effect = "click_select_eu4_like_idea"
				}
				else_if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert = 5 }
					}
					remove_policy = yes
					scoped_sound_effect = "disband"
				}
				clear_variable = show_ideas_window_confirm_alert
				clear_variable = confirm_idea_group
				clear_variable = confirm_idea
				clear_variable = confirm_policy
				update_selectable_idea_groups_window = yes
				update_policy_window = yes
				update_main_ideas_window = yes
			}
		}
	}

	ideas_window_national_idea_unlocked_alert = {
		context_type = player_context

		window_name = "ideas_window_national_idea_unlocked_alert"

		dirty = show_ideas_window_national_idea_unlocked_alert

		visible = {
			is_ai = no
			has_variable = show_ideas_window_national_idea_unlocked_alert
			NOT = { has_country_flag = disabled_ideas_window_national_idea_unlocked_alert }
		}

		effects = {
			ok_button_click = {
				clear_variable = show_ideas_window_national_idea_unlocked_alert
			}
			message_settings_button_click = {
				clear_variable = show_ideas_window_national_idea_unlocked_alert
				set_country_flag = disabled_ideas_window_national_idea_unlocked_alert
			}
			left_flag_click = {
				capital_scope = {
					ROOT = {
						goto_state = PREV
					}
				}
			}
			right_flag_click = {
				capital_scope = {
					ROOT = {
						goto_state = PREV
					}
				}
			}
		}

		properties = {
			left_flag = {
				image = "[This.GetFlag]"
			}
			right_flag = {
				image = "[This.GetFlag]"
			}
		}
	}

	# With La Resistance
	eu4_like_ideas_alerts_window_lar = {
		context_type = player_context

		window_name = "eu4_like_ideas_alerts_window_lar"
		parent_window_token = top_bar

		visible = {
			is_ai = no
			has_dlc = "La Resistance"
			OR = {
				NOT = { check_variable = { eu4_like_ideas_alerts^0 = 0 } }
				can_remove_flags_for_available_dismissed_alerts = yes
			}
		}

		effects = {
			eu4_like_ideas_alerts_dismissed_alerts_button_click = {
				remove_flags_for_available_dismissed_alerts = yes
				refresh_eu4_like_alerts = yes
			}

			alert_button_click = {
				clear_variable = show_ideas_window
				clear_variable = show_selectable_idea_groups_window
				clear_variable = show_policies_window
				clear_array = selectable_policies_array
				if = {
					limit = {
						OR = {
							check_variable = { v = 1 }
							check_variable = { v = 2 }
						}
					}
					set_variable = { show_ideas_window = 1 }
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					set_variable = { show_policies_window = 1 }
					update_policies_effect = yes
				}
				remove_flags_for_available_dismissed_alerts = yes
				refresh_eu4_like_alerts = yes
				update_main_ideas_window = yes
			}
			alert_button_right_click = {
				meta_effect = {
					text = {
						if = {
							limit = {
								has_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
							}
							clr_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
						}
						set_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				remove_from_array = { eu4_like_ideas_alerts = v }
			}
			alert_button_control_right_click = {
				meta_effect = {
					text = {
						set_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				remove_from_array = { eu4_like_ideas_alerts = v }
			}
			alert_button_control_shift_right_click = {
				if = {
					limit = {
						check_variable = { v = 3 }
					}
					clear_array = eu4_like_ideas_alerts_policies_options_array
					for_loop_effect = {
						start = 1
						end = 80
						value = j
						add_to_array = { eu4_like_ideas_alerts_policies_options_array = j }
					}
					set_variable = { show_eu4_like_ideas_alerts_policies_options_window = 1 }
				}
				update_alerts_policies_options_window = yes
			}
		}

		triggers = {
			eu4_like_ideas_alerts_dismissed_alerts_button_visible = {
				can_remove_flags_for_available_dismissed_alerts = yes
			}

			alert_button_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
			alert_icon_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
			yellow_alert_glow_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
		}

		dynamic_lists = {
			eu4_like_ideas_alerts_gridbox = {
				array = eu4_like_ideas_alerts
				entry_container = eu4_like_ideas_alerts_entry
			}
		}

		properties = {
			alert_icon = {
				frame = v
			}
		}
	}

	# Without La Resistance
	eu4_like_ideas_alerts_window = {
		context_type = player_context

		window_name = "eu4_like_ideas_alerts_window"
		parent_window_token = top_bar

		visible = {
			is_ai = no
			NOT = { has_dlc = "La Resistance" }
			OR = {
				NOT = { check_variable = { eu4_like_ideas_alerts^0 = 0 } }
				can_remove_flags_for_available_dismissed_alerts = yes
			}
		}

		effects = {
			eu4_like_ideas_alerts_dismissed_alerts_button_click = {
				remove_flags_for_available_dismissed_alerts = yes
				refresh_eu4_like_alerts = yes
			}

			alert_button_click = {
				clear_variable = show_ideas_window
				clear_variable = show_selectable_idea_groups_window
				clear_variable = show_policies_window
				clear_array = selectable_policies_array
				if = {
					limit = {
						OR = {
							check_variable = { v = 1 }
							check_variable = { v = 2 }
						}
					}
					set_variable = { show_ideas_window = 1 }
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					set_variable = { show_policies_window = 1 }
					update_policies_effect = yes
				}
				remove_flags_for_available_dismissed_alerts = yes
				refresh_eu4_like_alerts = yes
				update_main_ideas_window = yes
			}
			alert_button_right_click = {
				meta_effect = {
					text = {
						if = {
							limit = {
								has_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
							}
							clr_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
						}
						set_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				remove_from_array = { eu4_like_ideas_alerts = v }
			}
			alert_button_control_right_click = {
				meta_effect = {
					text = {
						set_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				remove_from_array = { eu4_like_ideas_alerts = v }
			}
			alert_button_control_shift_right_click = {
				if = {
					limit = {
						check_variable = { v = 3 }
					}
					clear_array = eu4_like_ideas_alerts_policies_options_array
					for_loop_effect = {
						start = 0
						end = @LAST_POLICY_ID
						value = j
						set_temp_variable = { j_temp = j }
						add_to_temp_variable = { j_temp = 1 }
						add_to_array = { eu4_like_ideas_alerts_policies_options_array = j_temp }
					}
					set_variable = { show_eu4_like_ideas_alerts_policies_options_window = 1 }
				}
				update_alerts_policies_options_window = yes
			}
		}

		triggers = {
			eu4_like_ideas_alerts_dismissed_alerts_button_visible = {
				can_remove_flags_for_available_dismissed_alerts = yes
			}

			alert_button_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
			alert_icon_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
			yellow_alert_glow_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
		}

		dynamic_lists = {
			eu4_like_ideas_alerts_gridbox = {
				array = eu4_like_ideas_alerts
				entry_container = eu4_like_ideas_alerts_entry
			}
		}

		properties = {
			alert_icon = {
				frame = v
			}
		}
	}

	eu4_like_ideas_alerts_policies_options_window = {
		context_type = player_context

		window_name = "eu4_like_ideas_alerts_policies_options_window"

		dirty = show_eu4_like_ideas_alerts_policies_options_window

		visible = {
			is_ai = no
			has_variable = show_eu4_like_ideas_alerts_policies_options_window
		}

		effects = {
			close_button_click = {
				clear_array = eu4_like_ideas_deactivated_alerts_options_array
				clear_variable = show_eu4_like_ideas_alerts_policies_options_side_menu_window
				clear_array = eu4_like_ideas_alerts_policies_options_array
				clear_variable = show_eu4_like_ideas_alerts_policies_options_window
			}
			open_side_menu_button_click = {
				clear_array = eu4_like_ideas_deactivated_alerts_options_array
				for_loop_effect = {
					start = 0
					end = 3
					value = j
					set_temp_variable = { j_temp = j }
					add_to_temp_variable = { j_temp = 1 }
					add_to_array = { eu4_like_ideas_deactivated_alerts_options_array = j_temp }
				}
				set_variable = { show_eu4_like_ideas_alerts_policies_options_side_menu_window = 1 }
				update_alerts_policies_options_window = yes
			}
			close_side_menu_button_click = {
				clear_array = eu4_like_ideas_deactivated_alerts_options_array
				clear_variable = show_eu4_like_ideas_alerts_policies_options_side_menu_window
				update_alerts_policies_options_window = yes
			}

			select_button_click = {
				remove_from_array = { deactivated_policies_for_alert = v }
				refresh_eu4_like_alerts = yes
				update_alerts_policies_options_window = yes
			}
			select_button_shift_click = {
				clear_array = deactivated_policies_for_alert
				refresh_eu4_like_alerts = yes
				update_alerts_policies_options_window = yes
			}
			deselect_button_click = {
				add_to_array = { deactivated_policies_for_alert = v }
				refresh_eu4_like_alerts = yes
				update_alerts_policies_options_window = yes
			}
			deselect_button_shift_click = {
				clear_array = deactivated_policies_for_alert
				for_each_loop = {
					array = eu4_like_ideas_alerts_policies_options_array
					value = j
					add_to_array = { deactivated_policies_for_alert = j }
				}
				refresh_eu4_like_alerts = yes
				update_alerts_policies_options_window = yes
			}
		}

		triggers = {
			open_side_menu_button_visible = {
				NOT = { has_variable = show_eu4_like_ideas_alerts_policies_options_side_menu_window }
			}
			close_side_menu_button_visible = {
				has_variable = show_eu4_like_ideas_alerts_policies_options_side_menu_window
			}

			select_button_visible = {
				is_in_array = { deactivated_policies_for_alert = v }
			}
			deselect_button_visible = {
				NOT = { is_in_array = { deactivated_policies_for_alert = v } }
			}
			icon_to_get_required_policies_tt_visible = {
				has_completed_required_idea_groups_for_policy = yes
				hidden_trigger = {
					always = no
				}
			}
		}

		dynamic_lists = {
			eu4_like_ideas_alerts_policies_options_gridbox = {
				array = eu4_like_ideas_alerts_policies_options_array
				entry_container = eu4_like_ideas_alerts_policies_options_entry
			}
		}
	}

	eu4_like_ideas_alerts_policies_options_side_menu_panel = {
		context_type = player_context

		window_name = "eu4_like_ideas_alerts_policies_options_side_menu_panel"
		parent_window_name = "eu4_like_ideas_alerts_policies_options_window"

		visible = {
			always = yes
		}
	}

	eu4_like_ideas_alerts_policies_options_side_menu_window = {
		context_type = player_context

		window_name = "eu4_like_ideas_alerts_policies_options_side_menu_window"
		parent_window_name = "eu4_like_ideas_alerts_policies_options_side_menu_panel_instance"

		visible = {
			is_ai = no
			has_variable = show_eu4_like_ideas_alerts_policies_options_side_menu_window
		}

		effects = {
			select_button_click = {
				meta_effect = {
					text = {
						set_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				clear_array = eu4_like_ideas_alerts
				refresh_eu4_like_alerts = yes
			}
			select_button_shift_click = {
				for_each_loop = {
					array = eu4_like_ideas_deactivated_alerts_options_array
					value = j
					meta_effect = {
						text = {
							set_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
						}
						ALERT = "[?j]"
					}
				}
				clear_array = eu4_like_ideas_alerts
				refresh_eu4_like_alerts = yes
			}
			deselect_button_click = {
				meta_effect = {
					text = {
						clr_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				clear_array = eu4_like_ideas_alerts
				refresh_eu4_like_alerts = yes
			}
			deselect_button_shift_click = {
				for_each_loop = {
					array = eu4_like_ideas_deactivated_alerts_options_array
					value = j
					meta_effect = {
						text = {
							clr_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
						}
						ALERT = "[?j]"
					}
				}
				clear_array = eu4_like_ideas_alerts
				refresh_eu4_like_alerts = yes
			}
		}

		triggers = {
			select_button_visible = {
				meta_trigger = {
					text = {
						NOT = { has_country_flag = disabled_eu4_like_ideas_alerts_[ALERT] }
					}
					ALERT = "[?v]"
				}
			}
			deselect_button_visible = {
				meta_trigger = {
					text = {
						has_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
			}
		}

		dynamic_lists = {
			eu4_like_ideas_deactivated_alerts_options_gridbox = {
				array = eu4_like_ideas_deactivated_alerts_options_array
				entry_container = eu4_like_ideas_deactivated_alerts_options_entry
			}
		}
	}

	policies_window = {
		context_type = player_context

		window_name = "policies_window"

		dirty = show_policies_window

		visible = {
			has_variable = show_policies_window
		}

		effects = {
			close_button_click = {
				set_variable = { show_ideas_window = 1 }
				clear_variable = show_policies_window
				clear_array = selectable_policies_array
			}
			alert_settings_button_click = {
				if = {
					limit = {
						NOT = { has_variable = show_eu4_like_ideas_alerts_policies_options_window }
					}
					clear_array = eu4_like_ideas_alerts_policies_options_array
					for_loop_effect = {
						start = 1
						end = 80
						value = j
						add_to_array = { eu4_like_ideas_alerts_policies_options_array = j }
					}
					set_variable = { show_eu4_like_ideas_alerts_policies_options_window = 1 }
				}
				else = {
					clear_array = eu4_like_ideas_alerts_policies_options_array
					clear_variable = show_eu4_like_ideas_alerts_policies_options_window
				}
			}

			select_policy_button_click = {
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 4 }
					set_variable = { confirm_policy = v }
				}
				else = {
					add_policy = yes
					set_variable = { show_ideas_window = 1 }
					clear_variable = show_policies_window
					clear_array = selectable_policies_array
				}
			}
			activate_policy_for_alert_button_click = {
				remove_from_array = { deactivated_policies_for_alert = v }
				refresh_eu4_like_alerts = yes
				update_policy_window = yes
				update_alerts_policies_options_window = yes
			}
			deactivate_policy_for_alert_button_click = {
				add_to_array = { deactivated_policies_for_alert = v }
				refresh_eu4_like_alerts = yes
				update_policy_window = yes
				update_alerts_policies_options_window = yes
			}
		}

		triggers = {
			close_button_click_enabled = {
				NOT = { has_variable = show_ideas_window_confirm_alert }
			}
			no_policies_available_info_visible = {
				check_variable = { selectable_policies_array^num < 1 }
			}
			alert_settings_button_visible = {
				is_ai = no
			}

			select_policy_button_click_enabled = {
				has_not_selected_max_amount_of_policies = yes
				has_completed_required_idea_groups_for_policy = yes
			}
			activate_policy_for_alert_button_visible = {
				is_in_array = { deactivated_policies_for_alert = v }
			}
			deactivate_policy_for_alert_button_visible = {
				NOT = { is_in_array = { deactivated_policies_for_alert = v } }
			}
		}

		dynamic_lists = {
			selectable_policies_gridbox = {
				array = selectable_policies_array
				entry_container = selectable_policies_entry

				ai_weights = {
					select_policy_button_click = {
						ai_will_do = {
							factor = 2
						}
					}
				}
			}
		}

		properties = {
			policy_icon = {
				image = "[This.GetPolicyPicture]"
			}
		}

		ai_enabled = {
			always = yes
		}

		ai_test_interval = 48
		ai_test_variance = 1

		ai_check = {
			has_variable = show_policies_window
			NOT = { has_variable = show_ideas_window_confirm_alert }
		}

		ai_weights = {
			close_button_click = {
				ai_will_do = {
					factor = 1
				}
			}
		}
	}
}