/*
 =======================================================================*\
|| ###################################################################### ||
|| # vBulletin 6.2.3
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2026 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
vBulletin.precache("channel_deleted_confirmation confirm_delete confirm_delete_channel_has_x_posts_y_forums emails_sent_successfully enter_email_message_and_recipients forum_created forum_deleted forum_description_updated forum_title_updated home_page_changed logo_changed no_permission unable_to_update_home_page_route channel_selections_updated channel_updated sitename_updated".split(" "),[]);
(function(b,g,m,y,l){function z(){if(!v){A();var a=b(document);a.offon("click",".js-site-config__edit-title__button",B);a.offon("click",".js-site-config__upload_file, .js-site-config__upload_url",C);a.offon("click",".js-site-config__btn-url",D);a.offon("click",".js-site-config__save-channel-select",E);a.offon("click",".js-config-site__delete-forum",F);a.offon("click",".js-config-site__toggle-forum",G);a.offon("click",".js-site-config__more-forums",w);a.offon("change",".b-config-site__forum-title",
H);a.offon("change",".b-config-site__forum-desc",I);a.offon("click",".js-site-config__send-btn",J);a.offon("click",".js-site-config__close-btn",K);b(".js-config-site-panel .autogrow").autogrow().trigger("input");w();1==b(".js-config-site-panel .js-theme-selector__container").length&&g.sitebuilder.initThemesInQuickConfig();L();v=!0}}let v=!1,t=y.ajax,h=g.flashPhrase,u=g.clearFlashMessage,M=function(a){var c=this;g.assertUserHasAdminPermission("canusesitebuilder",c,function(){var d=b(".js-top-menu-tab--quicksetup").get(0);
g.sitebuilder.activateSB.apply(d);x.call(c,a)});return!1},x=function(a){var c=b(this),d=b(document.body),f=!c.hasClass("b-top-menu__item-link--selected");f?(d.addClass("js-edit-mode-style"),b(".js-site-config__upload_file").trigger("click"),b(".js-config-site-panel").css("display","none").removeClass("h-hide").slideDown(400,z)):b(".js-config-site-panel").slideUp(function(){var e=!f;b(document).trigger("vb-toggle-sitebuilder-menu",{enableButtons:e,currentButton:c});d.removeClass("js-edit-mode-style");
e=new URL(location.href);e.searchParams.delete("adminAction");location.replace(e.href)})},B=function(a){var c=b(a.currentTarget),d=b(".js-site-config__toggle-wrapper--title"),f=d.is(".toggle");if(f){let e=b(".js-site-config__sitename--input"),k=b(".js-site-config__sitename--label"),n=e.data("originalValue");a={};e.val()!=n&&(a.sitename=e.val());e.prop("disabled",!0);c.prop("disabled",!0);u();t({call:"/ajax/api/site/saveSiteNameAndUrl",data:a,success(p){if(n!=p.bbtitle){k.text(p.bbtitle);e.data("originalValue",
p.bbtitle);let q=document.title;q=q.substring(0,q.length-n.length)+p.bbtitle;document.title=q}h("sitename_updated",3)}}).always(()=>{e.prop("disabled",!1);c.prop("disabled",!1);d.toggleClass("toggle",!f)})}else d.toggleClass("toggle",!f)},C=function(a){a=b(a.target).is(".js-site-config__upload_file");b(".js-site-config__urlForm").toggleClass("h-hide",a);b(".js-site-config__fileForm").toggleClass("h-hide",!a);b(".js-site-config__upload_"+(a?"url":"file")).prop("checked",!1)},K=function(){x.call(b(".js-top-menu-tab--quicksetup").get(0))},
A=function(){b(".js-config-site-panel").fileupload({dropZone:b(".js-site-config__upload-logo"),dataType:"json",add:function(a,c){b("body").css("cursor","wait");b(".js-config-site-panel").find(".js-upload-progress:first").removeClass("h-hide");c.submit()},done:function(a,c){c.result&&c.result.filedataid?(b("#header .site-logo img").attr({src:c.result.imageUrl,"data-fileid":c.result.filedataid,"data-styleselection":b("#edit-site-logo-dialog .styleselection:checked").val()}),h("logo_changed")):l.error("error",
"error_uploading_logo")},fail:function(a,c){l.error("error","error_uploading_logo")},always:function(a,c){b("body").css("cursor","auto");b(".js-config-site-panel").find(".js-upload-progress:first").addClass("h-hide")}})},D=function(){var a=b(".js-site-config__url_form .js-site-config__url"),c=b.trim(a.val()),d=b('.js-site-config__setlogo__url_styleselection input[name="styleselection"]:checked'),f=d.length&&d.val()||"current";if(c){b("body").css("cursor","wait");var e=b(this).closest(".dialog-content").find(".js-upload-progress:last").removeClass("h-hide");
g.AJAX({call:"/uploader/upload-logo-url",data:{urlupload:c,styleselection:f},complete:function(){b("body").css("cursor","auto");e.addClass("h-hide")},success:function(k){b("#header .site-logo img").attr({src:k.imageUrl,"data-fileid":k.filedataid,"data-styleselection":f});h("logo_changed")},error_phrase:"error_processing_site_logo"})}else a.trigger("focus")},L=function(){var a=b(".js-site-config__homepage-container");g.AJAX({call:"/ajax/render/admin_configuresite_homepage_list",data:{isAjaxTemplateRenderWithData:!0},
error:function(){var c=b("<div />").addClass("b-config-site__message").text(m.get("error_fetching_home_page_options"));a.html(c)},success:function(c){a.html(c.template);b(document).off("click",".js-site-config__homepage-opt").on("click",".js-site-config__homepage-opt",N);b(document).off("click",".js-site-config__revert-to-custom").on("click",".js-site-config__revert-to-custom",O);g.vBScroller&&g.vBScroller.initializeScroller&&(c=a.find(".js-vbscroller-wrapper"),g.vBScroller.initializeScroller(c))}})},
N=function(a){var c=b(a.target).closest(".js-site-config__homepage-opt"),d=c.data("routeid");c.is(".b-config-site__homepage-opt--selected")||g.AJAX({call:"/ajax/api/route/setAsHomeRoute",data:{routeid:d},error_phrase:"unable_to_update_home_page_route",success:function(f){f.success&&f.routeid==d?(b(".js-site-config__homepage-opt").removeClass("b-config-site__homepage-opt--selected"),c.addClass("b-config-site__homepage-opt--selected"),b(".js-site-config__homepage-custom-current").addClass("h-hide"),
b(".js-site-config__homepage-custom-prev").removeClass("h-hide"),h("home_page_changed")):l.error("error","unable_to_update_home_page_route")}})},O=function(a){var c=b(a.target).data("routeid");g.AJAX({call:"/ajax/api/route/setAsHomeRoute",data:{routeid:c},error_phrase:"unable_to_update_home_page_route",success:function(d){d.success&&d.routeid==c?(b(".js-site-config__homepage-opt").removeClass("b-config-site__homepage-opt--selected"),b(".js-site-config__homepage-custom-current").removeClass("h-hide"),
b(".js-site-config__homepage-custom-prev").addClass("h-hide")):l.error("error","unable_to_update_home_page_route")}});return!1},E=function(a){var c=b(a.currentTarget),d=b(".js-site-config__channel-select"),f={};d.each((e,k)=>{f[k.value]=k.checked?1:0});c.prop("disabled",!0);u();t({call:"/ajax/api/content_channel/quickToggleChannel",data:{activeChannelsMap:f},success(e){for(const k in e.state){let n=e.state[k].active;d.filter(`[value="${k}"]`).prop("checked",n)}h("channel_selections_updated")}}).always(()=>
{c.prop("disabled",!1)})},J=function(){var a=b(".b-config-site__email-list").val(),c=b(".b-config-site__email-title").val(),d=b(".b-config-site__email-content").val();4>a.length||4>d.length?l.error("error","enter_message_and_recipients"):g.AJAX({call:"/ajax/api/mail/send",error_phrase:"error_sending_email",data:{to:a,subject:c,message:d},success:function(f){if(f.success)h("emails_sent_successfully");else{let e="";m.register(["sent_to_x","send_failed_to_x"]);f.sent&&(e+=m.get(["sent_to_x",f.sent.join(", ")]));
f.failed&&(e+=m.get(["send_failed_to_x",f.failed.join(", ")]));l.error("error",["phrase_passthrough",e])}}})},r=a=>a.closest(".js-site-config__forum-record");var F=function(a){a=b(a.currentTarget);var c=r(a),d=c.data("nodeid"),f=a.data("postcount")||0;g.AJAX({call:"/ajax/api/search/getInitialResults",data:{search_json:{channel:d,type:"vBForum_Channel"},perpage:100},error_phrase:"error_deleting_forum",success:function(e){subforums=e.totalRecords?e.totalRecords:0;l.openConfirmDialogSimple({title:"confirm_delete",
message:["confirm_delete_channel_has_x_posts_y_forums",f,subforums],iconType:"warning",onClickYes:function(){g.AJAX({call:"/ajax/api/content_channel/delete",data:{nodeid:d},error_phrase:"error_deleting_forum",success:function(k){c.html(m.get("channel_deleted_confirmation")).addClass("h-margin-bottom-xxl");h("forum_deleted")}})}})}})},G=function(a){let c=b(a.currentTarget);a=r(c);let d=a.data("nodeid"),f=c.data("action"),e=b(".js-config-site__toggle-forum",a);e.prop("disabled",!0);u();t({call:"/ajax/api/content_channel/toggleChannelPublic",
data:{action:f,channelid:d},success(){h("channel_updated");e.removeClass("vbactive");c.addClass("vbactive")}}).always(()=>{e.prop("disabled",!1)})},w=function(){var a=b(".js-site-config__more-forums-sample").find(".js-site-config__forum-record").clone();b(".js-site-config__forum-div").append(a);a.find(".autogrow").autogrow()},H=function(a){var c=b(a.currentTarget);a=c.val();var d=r(c);c=d.data("nodeid");""!=a&&(c?g.AJAX({call:"/ajax/api/content_channel/update",data:{nodeid:c,data:{title:a}},success:function(f){h("forum_title_updated")},
error_phrase:"error_updating_forum"}):g.AJAX({call:"/createcontent/channel",data:{title:a,description:b(".b-config-site__forum-desc",d).val()},success:function(f){d.data("nodeid",f.nodeid);let e=".js-config-site__controls-forum";f.candelete&&(e+=", .js-config-site__delete-forum");b(e,d).removeClass("h-hide-imp");h("forum_created")},error_phrase:"error_updating_forum"}))},I=function(a){a=b(a.currentTarget);let c=r(a).data("nodeid");c&&g.AJAX({call:"/ajax/api/content_channel/update",error_phrase:"error_updating_forum",
data:{nodeid:c,data:{description:a.val()}},success:function(d){h("forum_description_updated")}})};b(function(){b(document).on("vb-sitebuilder-panel--quicksetup",M)})})(jQuery,vBulletin,vBulletin.phrase,vBulletin.ajaxtools,vBulletin.dialogtools);
