/*
 =======================================================================*\
|| ###################################################################### ||
|| # 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("cancel changed_extra_css_warning confirm_action css_reverted css_saved error_loading_css error_setting_theme loading_themes no_preview_available revert revert_extra_css_warning save_and_continue style_changed success there_are_no_themes_installed".split(" "),["styleid"]);vBulletin.ensureObj("sitebuilder");
$.extend(vBulletin.sitebuilder,function(c,U,x,p){function I(b){vBulletin.assertUserHasAdminPermission("canusesitebuilder",this,()=>{y.call(this)});return!1}function y(b,a){var d=c(this);c(document.body);var e=!d.hasClass("selected"),g=!0;"undefined"!=typeof b&&(e=!!b);"undefined"!=typeof a&&(g=!!a);e?(c(document.body).addClass("js-edit-mode-style"),J(),c(".js-style-panel").css("display","none").removeClass("h-hide").slideDown("400",z)):(K(!e,d),c(".js-style-panel").slideUp("fast",function(){c(document.body).removeClass("js-edit-mode-style");
var f=new URL(location.href);f.searchParams.delete("adminAction");g?location.replace(f.href):history.replaceState({},"",f.href)}))}function u(b){y(!1,b);return!1}function K(b,a){c(document).trigger("vb-toggle-sitebuilder-menu",{enableButtons:b,currentButton:a})}function A(b,a,d){var e=c(".js-theme-selector__list:visible .js-theme-selector__theme-radio:checked").val();vBulletin.AJAX({call:"/ajax/api/style/setDefaultStyle",data:{styleid:e},error_phrase:"error_setting_theme",success:function(){x.setCookie("userstyleid",
e,!0);("undefined"==typeof a||a)&&u(!0);"undefined"!=typeof d&&d&&vBulletin.flashMessage(vBulletin.phrase.get("style_changed"))}});return!1}function L(){B(null)}function M(b){p.openConfirmDialogSimple({title:"revert",message:"revert_extra_css_warning",iconType:"warning",onClickYes:()=>{vBulletin.AJAX({call:"/ajax/api/template/revertCssTemplateSbEditor",data:{styleid:q,templateName:n},success:function(){p.alert("success","css_reverted","",v)},error_phrase:"error_saving_css"})}});return!1}function N(b){r(t,
C)}function D(b,a,d){!a&&b&&b.target&&(a=c(b.target).closest(".js-theme-selector__theme").data("preview-url"));d||(d=c(b.target).closest(".js-theme-selector__list"));b=d.closest(".js-panel").find(".js-theme-selector__theme-preview");d=b.find("> img, > p");1==b.length&&(a=a?c("<img />").prop("src",a):c("<p />").addClass("b-theme-selector__theme-preview-message").text(vBulletin.phrase.get("no_preview_available")),d.is("p")&&a.is("p")?d.fadeTo(200,"0.5",function(){c(this).fadeTo(400,1)}):(d.css("zIndex",
"2"),a.css("zIndex","1").hide(),b.append(a),d.fadeOut({duration:300,queue:!1,complete:function(){c(this).remove()}}),a.fadeIn({duration:600,queue:!1})))}function O(b,a,d){d="js-theme-selector__theme b-theme-selector__theme h-margin-right-xl";var e=c('<input type="radio" name="styleid" value="'+this.styleid+'" />').addClass("js-theme-selector__theme-radio b-theme-selector__theme-radio h-margin-none h-margin-right-s"),g=c("<label />").prop("title",this.title),f=c("<div />").addClass("h-margin-s h-margin-bottom-none b-theme-selector__theme-title").text(30<
this.title.length?this.title.substr(0,20)+" ...":this.title),h=c("<img />").addClass("h-margin-s h-margin-bottom-m").prop("src",this.iconurl),m=c("<div />").addClass("b-theme-selector__theme-thumbnail"),l=this.iconurl;(new Image).src=l;l=this.previewurl;(new Image).src=l;a==this.styleid&&(e.prop("checked",!0),D({},this.previewurl,b),d+=" b-theme-selector__theme--selected js-theme-selector__theme--selected js-vbscroller-selected-item");m.append(h);f.prepend(e);g.append(m).append(f);c("<div />").addClass(d).data("preview-url",
this.previewurl||"").append(g).appendTo(b);w.call(h.get(0),2)}function w(b){var a=c(this);a.css({maxWidth:"none",maxHeight:"none"});var d=a.outerWidth()||0,e=a.outerHeight()||0,g=d>e?"height":"width",f=!1;if(0<d&&0<e){var h=!1;if("width"==g&&100<d){var m=100/d;h=!0}else"height"==g&&100<e&&(m=100/e,h=!0);h&&(a.removeClass("h-margin-s h-margin-bottom-m").css({maxWidth:d*m,maxHeight:e*m}),d=a.parent(),e=c("<div />").addClass("b-theme-selector__image-resize-wrapper h-margin-s h-margin-bottom-m").css({width:100,
height:100,overflow:"hidden"}),e.append(a),d.append(e),f=!0)}if(!f)if(a.css({maxWidth:"100px",maxHeight:"100px"}),0<b){var l=this;window.setTimeout(function(){w.call(l,--b)},100)}else l=this,a.off("load").on("load",function(){w.call(l,--b)})}function P(b,a){var d=0,e=vBulletin.options.get("styleid");a.html("");b&&b.themes&&c.each(b.themes,function(){O.apply(this,[a,e,d]);++d});d?Q(a):c("<div />").addClass("b-theme-selector__message").text(vBulletin.phrase.get("there_are_no_themes_installed")).appendTo(a)}
function Q(b){vBulletin.vBScroller&&vBulletin.vBScroller.initializeScroller&&(b=b.closest(".js-vbscroller-wrapper"),vBulletin.vBScroller.initializeScroller(b))}function E(b){function a(e){var g=b,f=c(this).closest(".js-theme-selector__theme"),h=f.find(".js-theme-selector__theme-radio");f.is(".js-theme-selector__theme--selected")||(h.prop("checked",!0),f=c(this),f.closest(".js-theme-selector__list").find(".js-theme-selector__theme").removeClass("b-theme-selector__theme--selected js-theme-selector__theme--selected js-vbscroller-selected-item"),
f.closest(".js-theme-selector__theme").addClass("b-theme-selector__theme--selected js-theme-selector__theme--selected js-vbscroller-selected-item"),D.call(this,e),g.liveUpdate&&A.call(this,e,!1,!0))}b=c.extend({},{liveUpdate:!1,container:document},b);var d=c(".js-theme-selector__list",b.containerSelector);d.off("change",".js-theme-selector__theme-radio").on("change",".js-theme-selector__theme-radio",a);d.off("click",".js-theme-selector__theme label img").on("click",".js-theme-selector__theme label img",
a);vBulletin.AJAX({call:"/ajax/api/style/getThemeInfo",success:function(e){P.apply(this,[e,d])},error:function(){var e=c("<div />").addClass("b-theme-selector__message").text(vBulletin.phrase.get("error_fetching_themes"));d.html(e)}})}function R(b){b=c(b.target);if(b.is(".js_stylepanel_selectStyle")&&isNaN(parseFloat(b.val()))||b.is(".js_stylepanel_selectTemplate")&&""==b.val())return!1;currentText=k.getValue();t!=k.getValue()?S():v()}function F(){var b=new Date,a=c(".js_stylepanel_selectStyle").val(),
d=c(".js-sb-sprite-icon-preview-img"),e=d.attr("src");e=e.replace(/styleid=\d+/,"styleid="+a);e=e.replace(/ts=\d+/,"ts="+b.getTime());d.attr("src",e)}function T(b){var a=c(".js-sb-sprite-icon-preview");a.data("preview-initialized")||(c(".js-sb-sprite-icon-preview-bg-btn").css("background-color",function(){return c(this).data("bgcolor")}).on("click",function(){var d=c(this);c(".js-sb-sprite-icon-preview-img-wrapper").css("background-color",d.data("bgcolor"));c(".js-sb-sprite-icon-preview-bg-btn").removeClass("sb-sprite-icon-preview-bg-btn--selected");
d.addClass("sb-sprite-icon-preview-bg-btn--selected");return!1}).eq(1).trigger("click"),a.data("preview-initialized","1"));b&&"css_sprite_icons_general.css"==b?(a.removeClass("h-hide"),F()):a.addClass("h-hide")}function r(b,a){let d=c(".js_stylepanel_selectStyle"),e=c(".js_stylepanel_selectTemplate"),g=c(".js_stylepanel_selecttype");k.setValue(b);t=k.getValue();q=d.val();n=e.val();C=a;g.selectBox("value",a);g.val()!=a&&(console.log("fred",c(".js-default-compiletype"),c(".js-default-compiletype").val()),
g.selectBox("value",c(".js-default-compiletype").val()));T(n)}function v(){let b=c(".js_stylepanel_selectStyle"),a=c(".js_stylepanel_selectTemplate");if(!G){let d=x.getCookie("userstyleid");d&&b.val(d);G=!0}vBulletin.AJAX({call:"/ajax/api/template/getCssTemplateSbEditor",data:{styleid:b.val(),templateName:a.val()},success:d=>{d=d.template;r(d.template,d.compiletype)},api_error:()=>{r("","full")},error_phrase:"error_loading_css"})}function S(){p.openConfirmDialogSimple({title:"confirm_action",message:"changed_extra_css_warning",
yesPhrase:"save_and_continue",noPhrase:"cancel",iconType:"warning",onClickYes:()=>{B(v)},onClickNo:()=>{c(".js_stylepanel_selectStyle").selectBox("value",q);c(".js_stylepanel_selectTemplate").selectBox("value",n)}})}function B(b){let a=k.getValue(),d=c(".js_stylepanel_selecttype").val();vBulletin.AJAX({call:"/ajax/api/template/saveCssTemplateSbEditor",data:{text:a,styleid:q,templateName:n,compiletype:d},success:()=>{r(a,d);F();p.alert("success","css_saved","",b)},error_phrase:"error_saving_css"})}
function z(){function b(){if("undefined"==typeof k){var e=c(".sb-style-panel_cssextraedit").get(0);k=CodeMirror.fromTextArea(e,{mode:"css",lineNumbers:!0});(e=c(e).attr("dir"))&&c(k.display.wrapper).attr("dir",e);t="";a.find(".js_stylepanel_selectStyle").change();d.off("click",b);c(".js-select-box",a).selectBox()}}var a=c(".js-style-panel .js-admin-stylepanel-csseditor"),d=c(".sb-style-panel .tab-item a");d.off("click",b).on("click",b);a.is(":visible")&&b()}function J(){if(!H){c(".js-style-panel .tabs").tabs();
var b=c(document);var a=".js-style-panel #admin-stylepanel-themes .js-button--save";b.off("click",a).on("click",a,A);a=".js-style-panel #admin-stylepanel-themes .js-button--cancel";b.off("click",a).on("click",a,u.bind(null,!1));a=c("#admin-stylepanel-csseditor");a.find(".js-button--revert").offon("click",M);a.find(".js-button--cancel").offon("click",N);a.find(".js-button--close").offon("click",u.bind(null,!0));a.find(".js-button--save").offon("click",L);a.find(".js_stylepanel_selectStyle, .js_stylepanel_selectTemplate").offon("change",
R);1==c(".js-style-panel .js-theme-selector__container").length&&E({liveUpdate:!1,containerSelector:".js-style-panel"});1==c(".js-style-panel .js-admin-stylepanel-csseditor").length&&z();H=!0}}let H=!1,k,t="",q=0,n="",C="",G=!1;c(function(){c(document).on("vb-sitebuilder-panel--style",I);vBulletin.ready("sb_page_style").resolve()});return{initThemesInQuickConfig:function(){E({liveUpdate:!0,containerSelector:".js-config-site-panel"})}}}(jQuery,vBulletin,vBulletin.storagetools,vBulletin.dialogtools));
