/*
 =======================================================================*\
|| ###################################################################### ||
|| # 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(["login","cancel","error_information_x"],[]);
vBulletin.createAjaxTools=(u,l,k,v)=>{function n(a,c){if(Array.isArray(a))a.unshift(c);else{var b=a;a=function(...d){c.apply(this,d);"function"==typeof b&&b.apply(this,d)}}return a}function A(a){return'<textarea style="border:1px solid #999;margin-top:10px;height:120px;width:100%;">'+a+"</textarea>"}function B(a){for(var c=[],b=0;b<a.length;b++){var d=$.isArray(a[b])?a[b][0]:a[b],e=k.get(a[b]);1==$("#debug-information").length&&d!=e&&(e+=" ("+d+")");c.push(e)}return c}function C(a,c){return(b,d,e)=>
{var f="";"undefined"!=typeof b.status&&(f+=" "+b.status);null!=d&&(f+=" "+d);"undefined"!=typeof e&&(f+=" "+e);console.log(c+" Error callback: "+a.url);D(b,d,e);b=k.get(a.error_phrase)+"<br /><br />"+k.get("error_information_x",f);v.openAlertDialog({title:k.get(a.title_phrase),message:b,iconType:"error",onAfterClose:a.after_error})}}function E(a,c,b,d,e){(b=a.errors)||(b=[a.error]);if(!c.api_error||c.api_error.apply(d,[b,a,c])){var f=g=>{e.data=e.data.replace(/securitytoken=[^&]*(&|$)/,"securitytoken="+
g.newtoken+"$1");$.ajax(e)};if(0!=l){if(w(b,["inlinemodauth_required"])){x("inlinemod_auth",f,l,"cplogin");return}if(0==a.userid&&w(b,[/^humanverify_/,/^no_permission(?:_|$)/,"no_create_permissions","session_timed_out_login","not_logged_no_permission","no_delete_permissions","no_featured_permissions"])){a=()=>{x("login",f,l,c.cpaction?"cplogin":"")};L(f,a,l)||a();return}}y(b,a,c)}}function w(a,c){if(!$.isArray(a))return!1;var b=c;$.isArray(b)||(b=[c]);for(c=0;c<a.length;c++){var d=a[c];$.isArray(d)&&
(d=d[0]);for(var e=0;e<b.length;e++){var f=b[e];if("regexp"==$.type(f)){if(f.test(d))return!0}else if(f==d)return!0}}return!1}function y(a,c,b){var d={title_phrase:"error",after_error:null};$.extend(!0,d,b);a:{for(b=0;b<a.length;b++){var e=a[b];if($.isArray(e)&&"exception_trace"==e[0]){a.splice(b,1);b=e[1];break a}}b=""}a=B(a);1==$("#debug-information").length&&(b&&a.push(A(b)),a.push(A(JSON.stringify(c))));a="<ul>\n<li>"+a.join("</li>\n<li>")+"</li>\n</ul>";return v.openAlertDialog({title:k.get(d.title_phrase),
message:a,iconType:"error",onAfterClose:d.after_error})}function D(a,c,b){console.dir({textStatus:c,jqXHRStatus:a.status,jqXHRResponseText:a.responseText,errorThrown:b});console.trace()}function m(a){var c={type:"POST",dataType:"json",title_phrase:"error",error_phrase:"error",api_error:!1,after_error:null,silent:!1};a.data instanceof FormData&&(c.processData=!1,c.contentType=!1);$.extend(!0,c,a);c.call&&(c.url=u+c.call,c.call="");c.silent&&(c.error=$.noop,c.api_error=$.noop);c.error||(c.error=C(c,
"ajax"));var b=this;c.success=function(d,e,f){d||c.allowEmptyResponse||(d={errors:[["invalid_server_response_please_try_again"]]});d&&(d.errors||d.error)?E(d,c,a,b,this):a.success&&a.success.apply(this,arguments)};return $.ajax(c)}function F(a,c){let b={dataType:"json",title_phrase:"error",error_phrase:"error",api_error:!1,after_error:null,iframe:!1,silent:!1};$.extend(b,c);b.silent&&(b.error=$.noop,b.api_error=$.noop);b.error||(b.error=C(b,"ajaxForm"));b.beforeSubmit=function(d,e,f){if(c.beforeSubmit&&
!1===c.beforeSubmit.apply(this,arguments))return!1;var g=$("button, .b-button",e);g.prop("disabled",!0);$(document).one("ajaxComplete",()=>{g.prop("disabled",!1)});return!0};b.success=function(d,e,f,g){d||b.allowEmptyResponse||(d={errors:[["invalid_server_response_please_try_again"]]});d&&(d.errors||d.error)?E(d,b,c,g,this):c.success&&c.success.apply(this,arguments)};return b}function L(a,c,b){return"undefined"!=typeof vBfb&&vBfb.isFbLogin()?(vBfb.makeAuthEvent(d=>{m({call:"/auth/login-external",
data:{provider:"facebook",auth:d.accessToken,userid:b},success:e=>{vBulletin.doReplaceSecurityToken(e.newtoken);return a(e)},api_error:c})})(),!0):!1}function x(a,c,b,d){let e,f;v.openTemplateConfirmDialog(G,{title:a,width:400,yesPhrase:"login",noPhrase:"cancel",handleEnter:!0,onClickYes:g=>{f.text("").addClass("h-hide");m({call:"/auth/ajax-login",data:e.serializeArray(),success:h=>{g.trigger("vb-login",h)},api_error:h=>{f.html(k.get(h[0])).removeClass("h-hide");f.find("a").attr("target","_blank")},
title_phrase:a});return!1}},{call:"/auth/login-dialog",data:{logintype:d,userid:b},api_error:y}).then(g=>{e=g.find(".js-login-form");f=$(".js-error-box",e);$('[type="text"], [type="password"]',g).filter(":visible").first().trigger("focus");g.on("vb-login",(h,p)=>{h.stopPropagation();vBulletin.doReplaceSecurityToken(p.newtoken);g.dialog("close");return c(p)})})}$.ajaxSetup({contentType:"application/x-www-form-urlencoded; charset=UTF-8"});let z,H=!1,I=!0,q,r,t=[];$(()=>{z=$("#debug-information");(H=
0<z.length)?(q=z.find("#debug-ajax-request-count"),r=$("<ol />").attr("id","debug-ajax-request-list").hide().css({height:"150px",overflow:"auto",padding:"4px",border:"1px solid #CCC",background:"#EEE","margin-top":"2px","margin-bottom":"4px"}).appendTo(q.closest("li")),q.css("cursor","pointer").on("click",()=>{r.toggle()})):(I=!1,t=[])});$.ajaxPrefilter((a,c,b)=>{if(I){var d={url:a.url,startTimeStamp:Date.now(),endTimeStamp:0,finalTimeStamp:0,status:"UNKNOWN",errorThrown:""};t.push(d);a.success=n(a.success,
(e,f,g)=>{d.endTimeStamp=Date.now()});a.error=n(a.error,(e,f,g)=>{d.endTimeStamp=Date.now();d.errorThrown=g});a.complete=n(a.complete,(e,f)=>{d.finalTimeStamp=Date.now();d.status=f;if(H)for(e=t.length,q.text(e),f=0;f<e;f++){var g=t[f];let h="js-request-counter-"+f;if(0==r.find("."+h).length){let p=0==g.url.indexOf(u)?g.url.substring(u.length):g.url,J=g.endTimeStamp-g.startTimeStamp,K=g.finalTimeStamp-g.startTimeStamp;g='{0} <span style="font-size:x-small;">({1}, <span title="Request Time: {2}ms, Processing Time: {3}ms, Total Time: {4}ms" style="text-decoration:underline;">{2}ms, {3}ms</span>){5}</span>'.format(p,
g.status,J,K-J,K,g.errorThrown?" Error: "+g.errorThrown:"");$("<li />").addClass(h).html(g).appendTo(r)}}})}});var G={hasError:w,ajax:m,ajaxSilent:function(a){vBulletin.loadingIndicator.suppressNextAjaxIndicator();return m(a)},render:function(a){a.template&&(a.call="/ajax/render/"+a.template,a.template="");a.data.isAjaxTemplateRender=!0;a.data.isAjaxTemplateRenderWithData=!0;return m(a)},ajaxForm:function(a){this.ajaxForm(F(this,a))},initForm:function(a,c){a.ajaxForm(F(a,c))},logApiError:function(a){console.dir(B(a))},
logAjaxError:D,showApiError:y,runBeforeCallback:n,library:{inlineMod(a){x("inlinemod_auth",a,l,"cplogin")}}};return G};
