scripted_gui = {
	eu4_like_ideas_custom_national_ideas_window = {
		context_type = player_context

		window_name = "eu4_like_ideas_custom_national_ideas_window"

		dirty = show_eu4_like_ideas_custom_national_ideas_window

		visible = {
			is_ai = no
			has_variable = show_eu4_like_ideas_custom_national_ideas_window
			NOT = { has_country_flag = selected_custom_national_idea_group }
		}

		effects = {
			close_button_click = {
				clear_variable = show_eu4_like_ideas_custom_national_ideas_group_list_window
				clear_variable = show_eu4_like_ideas_custom_national_ideas_window
				set_country_flag = selected_custom_national_idea_group
			}
			select_national_idea_group_button_click = {
				if = {
					limit = {
						has_variable = show_eu4_like_ideas_custom_national_ideas_group_list_window
					}
					clear_variable = show_eu4_like_ideas_custom_national_ideas_group_list_window
				}
				else = {
					set_variable = { show_eu4_like_ideas_custom_national_ideas_group_list_window = 1 }
				}
				update_custom_national_ideas_window = yes
			}
			select_national_idea_group_button_right_click = {
				if = {
					limit = {
						can_change_national_idea_group = yes
					}
					swap_national_ideas_effect = yes
				}
				update_custom_national_ideas_window = yes
			}
		}
	}

	eu4_like_ideas_custom_national_ideas_group_side_panel = {
		context_type = player_context

		window_name = "eu4_like_ideas_custom_national_ideas_group_side_panel"
		parent_window_name = "eu4_like_ideas_custom_national_ideas_window"

		visible = {
			always = yes
		}
	}

	eu4_like_ideas_custom_national_ideas_group_list_window = {
		context_type = player_context

		window_name = "eu4_like_ideas_custom_national_ideas_group_list_window"
		parent_window_name = "eu4_like_ideas_custom_national_ideas_group_side_panel_instance"

		dirty = show_eu4_like_ideas_custom_national_ideas_window

		visible = {
			has_variable = show_eu4_like_ideas_custom_national_ideas_group_list_window
		}

		effects = {
			close_button_click = {
				clear_variable = show_eu4_like_ideas_custom_national_ideas_group_list_window
				update_custom_national_ideas_window = yes
			}
			select_national_idea_group_list_button_click = {
				swap_national_ideas_effect = yes
				set_temp_variable = { swap_to_custom_national_ideas = 1 }
				set_variable = { selected_custom_national_ideas_id = v }
				swap_national_ideas_effect = yes
				clear_variable = show_eu4_like_ideas_custom_national_ideas_group_list_window
				update_custom_national_ideas_window = yes
			}
		}

		triggers = {
			select_national_idea_group_list_button_visible = {
				set_temp_variable = { national_ideas_id_other_context = v }
			}
			select_national_idea_group_list_glow_icon_visible = {
				check_variable = { national_ideas_id = v }
			}
		}

		dynamic_lists = {
			national_idea_group_selection_gridbox = {
				array = global.national_idea_group_selection_array
				entry_container = national_idea_group_selection_entry
			}
		}
	}
}