/*
 =======================================================================*\
|| ###################################################################### ||
|| # 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.CompMenuDropdown=function(c){function C(a){c(a.target).closest(".js-comp-menu-dropdown").length||y(c(".js-comp-menu-dropdown"))}function L(){function a(f){e=new Date;h=f.originalEvent.touches[0].pageX;m=f.originalEvent.touches[0].pageY;g=l=0}function b(f){l=h-f.originalEvent.touches[0].pageX;g=m-f.originalEvent.touches[0].pageY}function d(f){400>=new Date-e&&!l&&!g&&C.call(this,f)}var e=!1,h,m,l,g;c(document).off("touchstart",a).on("touchstart",a).off("touchmove",b).on("touchmove",b).off("touchend",
d).on("touchend",d)}function M(a){var b=c(a.target).closest(".js-comp-menu-dropdown");b.is(".b-comp-menu-dropdown--open")?y(b):N(b);a=c(".js-comp-menu-dropdown").filter(function(){return c(this).get(0)!=b.get(0)});y(a);vBulletin.conversation.closeFilterMenus();return!1}function D(a){a=c(a.target).closest(".js-comp-menu-dropdown");a.length&&a.is(".b-comp-menu-dropdown--open")&&y(a)}function E(a){a=c(a.target);a.closest(".js-comp-menu-dropdown").find(".js-comp-menu-dropdown__trigger-text").text(a.text())}
function z(a,b,d){var e=b.find(".b-comp-menu-dropdown__content-item");d=Math.min(d,4);if(1<d){b.addClass("b-comp-menu-dropdown__content--"+d+"-column");b=!a.is(".b-comp-menu-dropdown--open");var h="",m="";e.removeClass("b-comp-menu-dropdown__content-item--column-first b-comp-menu-dropdown__content-item--column-trailing");b&&a.addClass("b-comp-menu-dropdown--open");e.each(function(){var l=c(this).position();l=parseInt(l.top,10);""===h&&(h=l);""===m&&(m=l);h=Math.min(h,l);m=Math.max(m,l)});e.each(function(){var l=
c(this),g=l.position();parseInt(g.top,10)<=h&&l.addClass("b-comp-menu-dropdown__content-item--column-first")});e=e.last();e.position().top<m&&e.addClass("b-comp-menu-dropdown__content-item--column-trailing");b&&a.removeClass("b-comp-menu-dropdown--open")}else{for(a=4;1<a;)b.removeClass("b-comp-menu-dropdown__content--"+a+"-column"),--a;e.removeClass("b-comp-menu-dropdown__content-item--column-first b-comp-menu-dropdown__content-item--column-trailing")}}function F(a,b){if(a.is(".b-comp-menu-dropdown--open")){var d=
b.outerHeight();b=b.outerWidth()}else a.addClass("b-comp-menu-dropdown--open"),d=b.outerHeight(),b=b.outerWidth(),a.removeClass("b-comp-menu-dropdown--open");return{width:b,height:d}}function G(a){var b=c(window),d=b.width(),e=b.height(),h=b.scrollLeft(),m=c(document).height();a.each(function(l,g){var f=c(g),r=f.offset(),u=f.find(".js-comp-menu-dropdown__trigger").outerHeight();l=f.find(".js-comp-menu-dropdown__trigger").outerWidth();g=f.find(".js-comp-menu-dropdown__content");var k=g.find(".b-comp-menu-dropdown__content-item");
g.css("width","auto");z(f,g,1);var n=F(f,g),p=n.height;n=n.width;k=Math.max(Math.min(Math.floor(k.length/15),4),1);p=Math.ceil(p/(e-100));n=Math.floor((d-0)/n);n=Math.max(n,1);k=Math.max(k,p);k=Math.min(k,4);k=Math.min(k,n);z(f,g,k);n=F(f,g);p=n.height;n=n.width;k=g.css("margin-top");var v=parseInt(k,10),q=r.top;k=q>=p;var t=m-q>=u+p+v;r=r.left-h+l;u=d-r+l;p=r>=n;v=u>=n;q=[];k&&!t?(f.addClass("b-comp-menu-dropdown--direction-up"),q.push("Forced up")):t&&!k&&(f.removeClass("b-comp-menu-dropdown--direction-up"),
q.push("Forced down"));k=f="";var w=t=0,x=0;p&&!v?(g.removeClass("b-comp-menu-dropdown__content--left").addClass("b-comp-menu-dropdown__content--right"),f="right",k="left",q.push("Forced right alignment (opens left)")):v&&!p?(g.removeClass("b-comp-menu-dropdown__content--right").addClass("b-comp-menu-dropdown__content--left"),f="left",k="right",q.push("Forced left alignment (opens right)")):v||p||(r>=u?(g.removeClass("b-comp-menu-dropdown__content--left").addClass("b-comp-menu-dropdown__content--right"),
f="right",k="left",w=n-r,x=u-l,t=Math.min(w,x),q.push("Forced right alignment (opens left) (More space on left)")):(g.removeClass("b-comp-menu-dropdown__content--right").addClass("b-comp-menu-dropdown__content--left"),f="left",k="right",w=n-u,x=r-l,t=Math.min(w,x),q.push("Forced left alignment (opens right) (More space on right)")));f&&k&&(0<t?g.css(f,"-"+t+"px"):g.css(f,"0"),g.css(k,"auto"));x<w&&g.css("width",d).find(".b-comp-menu-dropdown__content-item").addClass("ellipsis").find("> a").addClass("ellipsis")})}
function H(){var a=c(".js-comp-menu-dropdown").filter(function(){return c(this).is(".b-comp-menu-dropdown--open")});G(a)}function A(){var a=c(".js-select-on-xsmall, .js-select-on-small, .js-select-when-dropdown"),b=c("body").is(".l-small"),d=c("body").is(".l-xsmall");a.each(function(){var e=c(this),h=0<e.next(".vb-select-el").length,m=e.is(".js-select-when-dropdown")||e.is(".js-select-on-xsmall")&&d||e.is(".js-select-on-small")&&b;m&&!h?(I(e).removeClass("h-hide-imp").selectBox(),e.addClass("h-hide-imp")):
!m&&h&&(I(e).selectBox("destroy").addClass("h-hide-imp"),e.removeClass("h-hide-imp"))})}function I(a){var b=a.next(".vb-select-el");b.length||(b=c('<select class="vb-select-el"></select>'),1!=a.find(".b-comp-menu-dropdown__content-item.b-comp-menu-dropdown__content-item--current").length&&c("<option></option>").addClass("js-noop-label").text(a.find(".js-comp-menu-dropdown__trigger").text()).appendTo(b),a.find(".js-comp-menu-dropdown__content .b-comp-menu-dropdown__content-item").each(function(d,e){var h=
c(this);e=h.is(".b-comp-menu-dropdown__content-item--current");var m=h.find("> a");h=m.html()||h.html();c("<option></option>").html(h).data("vb-option-link",m).appendTo(b);e&&(b.get(0).selectedIndex=d)}),b.addClass("b-comp-menu-dropdown__select").on("change",function(d){d=d.target;idx=d.selectedIndex;opt=d.options[idx];(linkHref=($link=c(opt).data("vb-option-link"))?$link.attr("href"):null)&&"#"!=linkHref.substr(0,1)?window.location.href=linkHref:($link.one("click",function(e){var h=$link.data("href");
h&&(window.location.href=h,e.preventDefault())}),$link.trigger("click"))}).insertAfter(a),(a=a.data("add-classes-to-select-el"))&&b.addClass(a));return b}function J(){c(".js-select-on-xsmall, .js-select-on-small").each(function(){var a=c(this).data("vb-select-el");a&&(a=a.nextAll(".selectBox"),a=a.not(a.first()),a.remove())})}function N(a){a.each(function(b,d){b=c(this).closest(".conversation-toolbar");1==b.length&&b.height(b.height())});a.addClass("b-comp-menu-dropdown--open");G(a);a.find(".js-comp-menu-dropdown__trigger-arrow").removeClass("b-icon--disabled");
c(".js-expanded-indicator",a).removeClass("fa-caret-down").addClass("fa-caret-up")}function y(a){a.removeClass("b-comp-menu-dropdown--open");a.find(".js-comp-menu-dropdown__trigger-arrow").addClass("b-icon--disabled");c(".js-expanded-indicator",a).removeClass("fa-caret-up").addClass("fa-caret-down")}function K(){var a=c(".js-comp-menu-dropdown__trigger").filter((d,e)=>"1"!=c(e).data("comp-menu-dropdown-initialized"));a.offon("click",M).attr("tabindex","0").addClass("js-button").data("comp-menu-dropdown-initialized",
"1");c(document).offon("click.menu",C);L();var b=c();a.each(function(d,e){d=c(e);d.is(".b-comp-menu-dropdown__trigger--arrow")&&1>d.find(".js-comp-menu-dropdown__trigger-arrow").length&&c('<span class="b-icon-fa b-icon-fa--12 fa-solid fa-caret-down b-icon--disabled js-comp-menu-dropdown__trigger-arrow h-align-middle"></span>').appendTo(d);d=d.parents(".js-shrink-event-parent");d.length&&(b=b.add(d))});b.length&&vBulletin.Responsive.Debounce.checkShrinkEvent(b);c(".js-comp-menu-dropdown").removeClass("b-comp-menu-dropdown--open-on-hover");
A();c(document).off("vb-filterposts",J).on("vb-filterposts",J);c(".b-comp-menu-dropdown__content-item:not(.js-comp-menu-dropdown__content-maintain-menu)").filter(function(){return"1"!=c(this).data("comp-menu-dropdown__content-close-menu-initialized")}).off("click",D).on("click",D).attr("data-comp-menu-dropdown__content-close-menu-initialized","1");c(".js-comp-menu-dropdown--display-current").off("click",".b-comp-menu-dropdown__content-item",E).on("click",".b-comp-menu-dropdown__content-item",E);1>
B.init&&(vBulletin.Responsive.Debounce.registerCallback(H),vBulletin.Responsive.Debounce.registerCallback(A));B.init++}var B=vBulletin.ensureObj("jsexec.css_b_comp_menu_dropdown",{exec:0,init:0});B.exec++;c(K);return{init:K,updateMenuFormat:H,updateMenuAsSelectElement:A,setMenuColumnCount:z}}(jQuery);
