import { withPluginApi } from "discourse/lib/plugin-api";
const TABS = [
{
id: "settings",
label: "Settings",
settings: new Set([
"community_landing_enabled",
"logo_dark_url", "logo_light_url", "logo_height", "footer_logo_url",
"accent_color", "accent_hover_color", "dark_bg_color", "light_bg_color",
"scroll_animation", "staggered_reveal_enabled", "dynamic_background_enabled",
"mouse_parallax_enabled", "scroll_progress_enabled"
])
},
{
id: "navbar",
label: "Navbar",
settings: new Set([
"navbar_signin_label", "navbar_signin_enabled", "navbar_signin_color",
"navbar_join_label", "navbar_join_enabled", "navbar_join_color",
"navbar_bg_color", "navbar_border_style"
])
},
{
id: "hero",
label: "Hero",
settings: new Set([
"hero_title", "hero_accent_word", "hero_subtitle",
"hero_card_enabled", "hero_image_first", "hero_content_width",
"hero_background_image_url", "hero_image_urls", "hero_image_max_height",
"hero_primary_button_enabled", "hero_primary_button_label", "hero_primary_button_url",
"hero_secondary_button_enabled", "hero_secondary_button_label", "hero_secondary_button_url",
"hero_video_url", "hero_video_button_color", "hero_video_blur_on_hover",
"hero_bg_dark", "hero_bg_light", "hero_min_height", "hero_border_style",
"hero_card_bg_dark", "hero_card_bg_light", "hero_card_opacity",
"contributors_enabled", "contributors_title", "contributors_title_enabled",
"contributors_count_label", "contributors_count_label_enabled",
"contributors_alignment", "contributors_pill_max_width", "contributors_pill_bg_color",
"contributors_days", "contributors_count"
])
},
{
id: "stats",
label: "Stats",
settings: new Set([
"stats_enabled", "stat_labels_enabled", "stats_title_enabled",
"stats_title", "stat_card_style",
"stat_icon_color", "stat_icon_bg_color", "stat_icon_shape", "stat_counter_color",
"stat_members_label", "stat_topics_label", "stat_posts_label",
"stat_likes_label", "stat_chats_label", "stat_round_numbers",
"stats_bg_dark", "stats_bg_light", "stats_min_height", "stats_border_style"
])
},
{
id: "about",
label: "About",
settings: new Set([
"about_enabled", "about_heading_enabled", "about_heading",
"about_title", "about_role", "about_body", "about_image_url",
"about_card_color", "about_background_image_url",
"about_bg_dark", "about_bg_light", "about_min_height", "about_border_style"
])
},
{
id: "topics",
label: "Trending",
settings: new Set([
"topics_enabled", "topics_title_enabled", "topics_title", "topics_count",
"topics_card_bg_color",
"topics_bg_dark", "topics_bg_light", "topics_min_height", "topics_border_style"
])
},
{
id: "groups",
label: "Spaces",
settings: new Set([
"groups_enabled", "groups_title_enabled", "groups_title", "groups_count",
"groups_selected", "groups_card_bg_color",
"groups_bg_dark", "groups_bg_light", "groups_min_height", "groups_border_style"
])
},
{
id: "appcta",
label: "App CTA",
settings: new Set([
"show_app_ctas", "ios_app_url", "android_app_url",
"ios_app_badge_image_url", "android_app_badge_image_url",
"app_badge_height", "app_badge_style",
"app_cta_headline", "app_cta_subtext",
"app_cta_gradient_start", "app_cta_gradient_mid", "app_cta_gradient_end",
"app_cta_image_url",
"app_cta_bg_dark", "app_cta_bg_light", "app_cta_min_height", "app_cta_border_style"
])
},
{
id: "footer",
label: "Footer",
settings: new Set([
"footer_description", "footer_text", "footer_links",
"footer_bg_dark", "footer_bg_light", "footer_border_style"
])
}
];
// Dark/light background pairs — light row gets merged into dark row
const BG_PAIRS = [
["hero_bg_dark", "hero_bg_light"],
["hero_card_bg_dark", "hero_card_bg_light"],
["stats_bg_dark", "stats_bg_light"],
["about_bg_dark", "about_bg_light"],
["topics_bg_dark", "topics_bg_light"],
["groups_bg_dark", "groups_bg_light"],
["app_cta_bg_dark", "app_cta_bg_light"],
["footer_bg_dark", "footer_bg_light"],
];
let currentTab = "settings";
let filterActive = false;
let isActive = false;
let recheckTimer = null;
function getContainer() {
return (
document.querySelector(".admin-plugin-config-area") ||
document.querySelector(".admin-detail")
);
}
function applyTabFilter() {
const container = getContainer();
if (!container) return;
const tab = TABS.find((t) => t.id === currentTab);
if (!tab) return;
container.querySelectorAll(".row.setting[data-setting]").forEach((row) => {
// Keep merged light rows permanently hidden
if (row.classList.contains("cl-merged-hidden")) return;
const name = row.getAttribute("data-setting");
row.classList.toggle(
"cl-tab-hidden",
!filterActive && !tab.settings.has(name)
);
});
// Update filter-active dimming on native nav or standalone tab bar
const nativeNav = document.querySelector(".d-nav-submenu__tabs");
if (nativeNav) {
nativeNav.classList.toggle("cl-filter-active", filterActive);
}
const standaloneBar = document.querySelector(".cl-admin-tabs");
if (standaloneBar) {
standaloneBar.classList.toggle("filter-active", filterActive);
}
}
function updateActiveStates(activeId) {
// Native nav: our injected
tabs
document.querySelectorAll("li.cl-admin-tab").forEach((li) => {
li.classList.toggle("active", li.dataset.tab === activeId);
});
// Native nav: the original Settings
const nativeItem = document.querySelector(".cl-native-settings-item");
if (nativeItem) {
nativeItem.classList.toggle("active", activeId === "settings");
}
// Standalone fallback: