/*
 =======================================================================*\
|| ###################################################################### ||
|| # 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("all_changes_made_will_be_lost_would_you_like_to_continue attach_link attach_video close_preview enter_link_title enter_photo_gallery_title enter_poll_question enter_title error_while_saving_content event_invalid_enddate follow following following_pending html_off html_on invalid_user_filedata loading max_attachments_reached no_photos_or_albums no_post_content_to_preview please_enter_message_x_chars please_enter_a_valid_url_and_click_attach preview preview_map saving select_from_photo_album unexpected_error write_something_here write_something_here_optional x_selected your_post_is_now_being_reviewed_and_waiting_for_moderators_approval".split(" "),
["commentminchars","threadpreview","suggesttags"]);vBulletin.ensureObj("contentEntryBox");
$.extend(vBulletin.contentEntryBox,((t,x,P,V,H,Z,K,E)=>{function Aa(a){let b=$(this),c=b.closest("form");a=c.data("content-type")||"";var e=c.find(".js-editor").attr("id");e=x.getEditorContent(e);if("text"==a&&""==e)t.error("preview","no_post_content_to_preview");else{var f=t.getFormData(c,0),d=$.extend({conversationtype:a,posttags:f.tags,rawtext:e,disable_bbcode:W,isAjaxTemplateRender:!0,isAjaxTemplateRenderWithData:!0},t.objSubset(f,["parentid","channelid","nodeid","htmlstate"]));if("gallery"==
a){var g=[];$('.js-photo-postdata input[name="filedataid[]"]',c).each(function(){g.push(this.value);d["title_"+this.value]=$('.js-photo-postdata input[name="title_'+this.value+'"]',c).val()||""});d.filedataid=g}"link"==a&&(d.link=t.objSubset(f,["title","meta","url","url_image"]));"poll"==a&&(d.poll={options:[],mutliple:$('input[name="multiple"]',c).is(":checked")?1:0},$(".js-poll-option",c).each(function(){d.poll.options.push(this.value)}));"video"==a&&(d.video=t.objSubset(f,["title","meta","url"]),
d.video.items=$(".js-video-url",c).toArray().map(h=>h.value));"event"==a&&($.each(["eventstartdate","eventenddate","location"],function(h,k){h=$('input[name="'+k+'"]',c);h.length&&(d[k]=h.val())}),$.each(["is_all_day","ignoredst"],function(h,k){h=$('input[name="'+k+'"]:checked',c);h.length&&(d[k]=h.val())}));b.prop("disabled",!0);E.ajax({call:"/create-content/load-preview",data:d,success:function(h){var k=$("<div />").attr("id","preview-overlay").addClass("h-hide").append($("<div />").addClass("dialog-content")).append($("<div />").addClass("b-button-group h-margin-bottom-m")).appendTo("body");
$("<ul />").addClass("conversation-list list-container stream-view activity-view h-clearfix b-post--preview").appendTo($(".dialog-content",k));$("<button />").addClass("js-content-entry-preview-submit b-button b-button--primary").text($(".js-content-entry-submit",c).text()).on("click",()=>{c.trigger("submit");k.dialog("close")}).appendTo($(".b-button-group",k));$("<button />").addClass("js-content-entry-preview-close b-button").text(H.get("close")).on("click",()=>{k.dialog("close")}).appendTo($(".b-button-group",
k));$(h.template).appendTo($("ul",k));$(".js-post .js-post__content-text",k).html(h.parsedText);h=k.find(".dialog-content");$("a",h).addClass("h-disabled").on("click",()=>!1);$(".js-button, .b-button,  button",h).prop("disabled",!0);k.removeClass("h-hide");K.openModalDialog(k,{title:"preview",width:800,dialogClass:"preview-dialog-container",onOpen:()=>{k.dialog("option",{minHeight:0,closeOnEscape:!0});$(".b-button--primary",k).trigger("focus")},onAfterClose:()=>{k.dialog("destroy").remove()}})},title_phrase:"preview",
error_phrase:"error_loading_preview",complete:()=>{b.prop("disabled",!1)}})}}function Ba(a){var b=$(this).closest("form");0==b.find('input[name="save_draft"]').length&&Q("save_draft",1).appendTo(b);setTimeout(function(){b.find('input[name="save_draft"]').remove()},100)}function Ca(a){a=$(this);var b=a.closest("form");la(b,a)}function la(a,b,c){var e=a.find('input[name="parentid"]').val();let f=a.find('input[name="channelid"]').val(),d=pageData.lastloadtime||pageData.current_server_datetime,g=pageData.past_page_limit||
!1;var h=a.closest(".conversation-content-widget")||a.closest("#activities-tab");let k=$(".conversation-list",h),n="stream",m={"activity-view":"activity-stream","full-activity-view":"full-activity-stream","thread-view":"thread"},r=$(".list-container",h);h=$(".list-container>li.b-post",h);let y=h.length,p=parseInt($('form.toolbar-filter-overlay input[name="pagenum"]').val())||1,B=Number($("form.pagenav-form span.pagetotal").text())||0,v=a.data("initial-page-total")||0,D=parseInt($('form.toolbar-filter-overlay input[name="hookcontext"]').val())||
"",F=[];v||(v=B,a.data("initial-page-total",B));for(const u in m)k.hasClass(u)&&(n=m[u]);h.each((u,l)=>{(u=$(l).data("node-id"))&&F.push(u)});e={parentid:e,channelid:f,newreplyid:c,loadednodes:F,lastloadtime:d,view:n,currentpage:p,pagetotal:B,initialpagetotal:v,postcount:y,postsperpage:P.POSTS_PER_PAGE,past_page_limit_aware:g,hookcontext:D};t.loadingIndicator.show();b&&b.prop("disabled",!0);E.ajax({call:"/create-content/loadnewposts",data:e,success:function(u){if(u.redirect)location.href=u.redirect;
else{pageData.lastloadtime=u.timenow;u.past_page_limit&&(pageData.past_page_limit=u.past_page_limit);var l=u.pageinfo;newcurrentpage=l.currentpage||l.pagenumber;l.currentpage=newcurrentpage;l.pagenumber=newcurrentpage;$(document).trigger("vb-postpagination",{ajaxResult:u});P.pagination&&B!=l.totalpages&&P.pagination.updatePageInfo(l,!0);u.template&&(1<r.length&&(l=a.closest(".tab"),r=0<l.length?$(".list-container",l):$(".list-container",$(".tab.media-tab"))),u=$(u.template),r.hasClass("ajax-order-newest-first")&&
0<$("li.list-item:first",r).length?$("li.list-item:first",r).before(u):(r.append(u),l=u.closest(".ui-tabs-panel").find(".conversation-toolbar-wrapper"),l.hasClass("scrolltofixed-floating")&&(l=l.data("object-instance"))&&l.addLimit(u.filter((q,z)=>z.nodeType==Node.ELEMENT_NODE).outerHeight(!0)),c&&t.scrollToAnchor("#post"+c)),$(document).trigger("vb-loadnewposts",{insertedHtml:u}))}},complete:function(){b&&b.prop("disabled",!1);t.loadingIndicator.hide()}})}function Da(a){var b=$(this),c=$(this.form).data("content-type"),
e=b.closest(".js-content-entry");a=b.closest(".js-post");var f=a.data("node-id");f||(f=a.data("nodeid"));"comment"!=c&&"media"!=c&&(1==b.closest('.list-item-body-wrapper[data-node-type="visitorMessage"], .js-post__content-wrapper[data-node-type="visitorMessage"]').length?c="visitorMessage":1==b.closest(".js-conversation-starter").length?(c=1==b.closest(".conversation-list.blog-list").length?"blog":"topic",c=1==b.closest(".conversation-list.article-list").length?"article":"topic"):c="reply");H.register["delete_x",
"posttype_"+c];a=H.get("delete_x",H.get("posttype_"+c));K.openTemplateConfirmDialog(E,{title:a,width:500,dialogClass:"no-buttons-while-loading",yesPhrase:a,noPhrase:"cancel",onClickYes:function(d){let g=e.find("form");var h=$.Event("beforeDelete");g.trigger(h);if(!h.isDefaultPrevented()){d=d.find(".delete-posts-form");var k=d.find("input:radio[name=deletetype]:checked").val()||1;h={hard:2==k?1:0,reason:d.find(":input[name=deletereason]").val(),nodeids:f};E.ajax({url:t.normalizeAjaxUrl(d.attr("action")),
data:h,error_phrase:"error_deleting_posts",success:function(n){$(window).off("beforeunload.editPost");aa(e);2==k?"topic"==c||"blog"==c?location.replace($("#breadcrumbs .crumb a:last").attr("href")||pageData.baseurl):$('.js-post[data-node-id="'+f+'"]').remove():(n=$(".filter-wrapper",b.closest(".conversation-view, .ui-tabs-panel, .widget-content").find(".conversation-toolbar")).data("object-instance"))&&"function"==typeof n.applyFilters?n.forceApplyFilters():"visitorMessage"==c?history.back():location.reload();
g.trigger("afterDelete")}})}}},{name:"delete_post_form",data:{postType:c,nodeid:f,authorid:b.data("userid")}})}function Ea(a,b){var c=this.form,e=$(c),f=$(this);a=f.closest(".edit-conversation-container");if(!b){let g=$.Event("beforeCancel");e.trigger(g);if(g.isDefaultPrevented())return!1}if(1==a.length){if(!b)return R(function(){f.trigger("click",[!0])},"cancel_edit");b=e.data("content-type");b=f.closest("comment"==b?".js-comment":".js-post__content-wrapper");0==b.length&&(b=f.closest(".js-post__content-wrapper"));
b.removeClass("b-post--edit");b.find(".b-post__content--edit").removeClass("b-post__content--edit");b.find(".b-post__footer--edit").removeClass("b-post__footer--edit");$(window).off("beforeunload.editPost");e.trigger("afterCancel");aa(b);a.empty().hide()}else if(1==f.closest(".sb-dialog").length)M(e,!0,()=>{e.trigger("afterCancel");f.closest(".sb-dialog").dialog("close")});else if("vm"==e.data("message-type")||"pm-reply"==e.data("message-type")||"reply"==e.data("message-type"))M(e,!0,()=>{e.trigger("afterCancel")});
else{var d="";d=c.ret&&c.ret.value?c.ret.value:"pm-new"==e.data("message-type")?pageData.baseurl+"/messagecenter/index":"pm-forward"==e.data("message-type")?pageData.baseurl+"/messagecenter/index":c.parentid&&c.parentid.value?pageData.baseurl+"/node/"+c.parentid.value:pageData.baseurl;ma(e.closest(".js-content-entry"))?(e.trigger("afterCancel"),location.href=d):R(()=>{e.trigger("afterCancel");location.href=d})}}function na(){var a=$(this),b=Z.get("commentminchars"),c=$(".js-editor",a);c.attr("id");
var e=$.trim(c.val()),f=0<a.closest(".js-comments").length,d=a.data("content-type"),g=t.contentEntryBox.ATTACHLIMIT||0,h=$(".b-content-entry-panel__content--"+d,a);"video"==d&&0==h.length&&(h=$(".b-content-entry-panel__content--link",a));var k=function(r){return function(){setTimeout(function(){r.trigger("focus")},10)}};if("comment"==d||f)return e.length<b?(t.warning("error",["please_enter_message_x_chars",b],k(c)),!1):!0;if($(".js-content-entry-title",a).is(":visible")&&""==$.trim($(".js-content-entry-title",
a).val()))return t.warning("error","please_enter_title_of_topic",k($(".js-content-entry-title",a))),!1;if("gallery"==d){if(0==$(".js-photo-postdata input",h).length)return t.warning("error","please_upload_at_least_one_photo"),!1;if(0<g&&$('.js-photo-postdata input[name^="filedataid"]',h).length>g)return t.warning("error",["you_may_only_attach_x_files_per_post",g]),!1}if(("link"==d||"video"==d)&&!$.trim(h.find(".js-panel-content").html()))return t.warning("error","please_enter_a_valid_url_and_click_attach",
k($(".b-link-input__url",h))),!1;if("poll"==d){var n=0,m;$(".js-poll-option:visible",a).each(function(){""!=$.trim($(this).val())?n++:m||(m=$(this));if(2<=n)return!1});if(2>n)return t.warning("error",["please_enter_at_least_x_poll_answers",2],k(m)),!1}return!0}function Fa(a,b,c,e){e.closest(".js-dialog-body").dialog("close");b=e.data("content-type")||"";var f=e.data("current-channeltype")||"";M(e);c=$.Event("afterSave");e.trigger(c,a);if(!c.isDefaultPrevented()){c=pageData;var d=a.nodeId;var g=e.closest(".conversation-content-widget");
0==g.length&&(g=e.closest("#activities-tab"));var h=$(".conversation-list",g),k=$(".list-container",g);1==e.closest(".private-message-widget").length?1==e.closest(".private-message-widget").find(".conversation-list").length?location.reload():location.href=pageData.baseurl+"/messagecenter/index":a.retUrl&&0==k.length?location.href=a.retUrl:(g=h.hasClass("thread-view")?"thread":h.hasClass("full-activity-view")?"full-activity-stream":h.hasClass("activity-view")?"activity-stream":"stream","forum"===f&&
"thread"===g?(la(e,null,a.nodeId),V.reset()):(f=$(".js-post:not(.js-comment):last .js-show-post-link:first",h).text()||"1",f=Number(f.replace("#","")),c["posts-perpage"]=P.POSTS_PER_PAGE,"thread"==g&&(c["comments-perpage"]=P.COMMENTS_PER_PAGE),E.hasError(a.warnings,"warning_spam_post")?E.showApiError(a.warnings,a,{title_phrase:"warning",after_error:function(){a.warningReturnUrl?location.href=a.warningReturnUrl:location.reload(!0)}}):(E.ajax({call:"/create-content/loadnode",data:{nodeid:d,view:g,index:f,
page:c,type:b,isAjaxTemplateRender:!0,isAjaxTemplateRenderWithData:!0},success:function(n){e.find("textarea").val("");a.moderateNode&&K.showStatusMessage("your_post_is_now_being_reviewed_and_waiting_for_moderators_approval","moderate");var m=$(n.template);1<k.length&&($tab=e.closest(".tab"),k=0<$tab.length?$(".list-container",$tab):$(".list-container",$(".tab.media-tab")));if(k.hasClass("ajax-order-newest-first")&&0<$("li.list-item:first",k).length)$("li.list-item:first",k).before(m);else{k.append(m);
var r=m.closest(".ui-tabs-panel").find(".conversation-toolbar-wrapper");r.hasClass("scrolltofixed-floating")&&(r=r.data("object-instance"))&&r.addLimit(m.filter("*").outerHeight(!0));k.removeClass("h-hide");t.scrollToAnchor("#post"+d)}0<k.children(".list-item").length&&k.parent().find(".conversation-empty").addClass("h-hide");$(document).trigger("vb-loadnode",{insertedHtml:m,context:"content_entry_box"});t.Responsive.checkForVideoSignature();t.subscribe.updateSubscribeButton(n.topic_subscribed)},
title_phrase:"conversation",error_phrase:"error_loading_post"}),V.reset())))}}function Ga(a){var b=[],c=[],e=null,f=null,d=null,g=function(n){function m(w,C,A){var S=w.first();"undefined"==typeof S.data("css-prop-restore-value_"+C)&&S.data("css-prop-restore-value_"+C,S.css(C));"undefined"!=typeof A&&w.css(C,A)}function r(w,C){var A=w.first().data("css-prop-restore-value_"+C);"undefined"!=typeof A&&w.css(C,A)}function y(w,C){n.css({width:w});p.css({width:C})}var p=f.parent();d||(d={originalPanelWidth:n.width(),
originalDialogWidth:p.width(),scrollbarWidth:t.getScrollbarWidth(),originalPanelHeight:n.height(),originalDialogHeight:p.height()});var B="margin"+pageData.textDirLeft.charAt(0).toUpperCase()+pageData.textDirLeft.slice(1);m(p,"height");m(n,"height");m(p.find(".photoSelectorTabs"),"height");m(p.find(".js-dialog-body"),"padding");m(p.find(".photoSelectorTabs ul"),"width");m(p.find(".photoSelectorTabs ul li"),"width");m(p.find(".photoSelectorTabs .tabPanel"),"width");m(p.find(".photo-item-wrapper"),
"width");m(p.find(".js-photo-counter"),B);var v=$(window).width(),D=d.originalDialogWidth+d.scrollbarWidth>v,F=d.originalPanelWidth,u=d.originalDialogWidth;D&&(F-=200,u-=200);y(F,u);var l=p.outerWidth()>v;l||(r(p,"height"),r(n,"height"),r(p.find(".photoSelectorTabs"),"height"),r(p.find(".js-dialog-body"),"padding"),r(p.find(".photoSelectorTabs ul"),"width"),r(p.find(".photoSelectorTabs ul li"),"width"),r(p.find(".photoSelectorTabs .tabPanel"),"width"),r(p.find(".photo-item-wrapper"),"width"),r(p.find(".js-photo-counter"),
B),p.find(".photo-checkbox input").css(pageData.textDirLeft,""),p.find(".photo-checkbox input").css(pageData.textDirRight,"5px"),p.find(".js-photo-counter").removeClass("h-margin-top-s"));y(F,u);var q=n.find(".photo-item-wrapper"),z=q.first().outerHeight();D?(D=q.length,q.addClass("last-in-row")):(D=Math.ceil(q.length/2),q.filter(":even").removeClass("last-in-row"));q=D*z;d.originalPanelHeight<q&&(F+=d.scrollbarWidth,u+=d.scrollbarWidth,y(F,u));l&&(p.css({width:v+"px",left:0,top:0,marginLeft:0,marginTop:0}),
m(p,"height","auto"),m(n,"height",q+"px"),m(p.find(".photoSelectorTabs"),"height",q+"px"),m(p.find(".js-dialog-body"),"padding",0),m(p.find(".photoSelectorTabs ul"),"width","30%"),m(p.find(".photoSelectorTabs ul li"),"width","100%"),m(p.find(".photoSelectorTabs .tabPanel"),"width","70%"),m(p.find(".photo-item-wrapper"),"width","auto"),m(p.find(".js-photo-counter"),B,"12px"),p.find(".photo-checkbox input").css(pageData.textDirRight,""),p.find(".photo-checkbox input").css(pageData.textDirLeft,"5px"),
p.find(".js-photo-counter").addClass("h-margin-top-s"));$("body").is(".l-xsmall")&&m(p,"height","auto")},h=function(n){var m=$(".photo-item-wrapper .photo-item .filedataid",n),r=$(".js-photo-counter",n.parent());g(n);m.offon("click",function(y){y.stopPropagation();var p=$(this);y=p.data("nodeid");var B=p.val();const v=p.closest(".photo-item-wrapper"),D=$.trim(v.find(".photo-title").text());p=v.closest(".js-photo-selector-container");this.checked?(b.push(y),c[y]={filedataid:B,title:D},v.addClass("selected")):
(v.removeClass("selected"),B=$.inArray(y,b),-1!=B&&(b.splice(B,1),delete c[y]));r.html(H.get("x_selected",b.length));$(".js-photo-selector-continue",f).prop("disabled",0==b.length);p.data("selected-nodes",b);p.data("selected-nodes-meta",c)});$(".photo-item-wrapper",n).offon("click",function(){var y=$(".photo-checkbox .filedataid",this);y.prop("checked",!y.prop("checked")).triggerHandler("click")});0<b.length?(m.each(function(){-1!=$.inArray($(this).data("nodeid"),b)&&(this.checked=!0,$(this).closest(".photo-item-wrapper").addClass("selected"))}),
$(".js-photo-selector-continue",f).prop("disabled",!1)):(m.prop("checked",!1),$(".photo-item-wrapper",this).removeClass("selected"),$(".js-photo-selector-continue",f).prop("disabled",!0));r.html(H.get("x_selected",b.length))},k=function(n,m){function r(l){const q=$(l.currentTarget);l=$(l.delegateTarget);const z=B(l),[w,C]=p(l),A=q.is(".js-prev-arrow")?w-1:w+1;q.is(".h-disabled")||1>A||A>C||A==w||v(l,z,A)}function y(l){const q=$(l.currentTarget),z=parseInt(q.val(),10)||0;l=$(l.delegateTarget);const w=
B(l),[C,A]=p(l);1>z||z>A||z==C?q.val(C):v(l,w,z)}function p(l){var q=l.find(".js-current-page");l=parseInt(q.data("currentpage"),10)||1;q=parseInt(q.data("totalpages"),10)||1;return[l,q]}function B(l){l=l.attr("id");return l.substring(l.lastIndexOf("-")+1)}function v(l,q,z){E.ajax({call:"/profile/get-photo-tab-content",data:{nodeid:q,page:z,ppr:2,isAjaxTemplateRender:!0,isAjaxTemplateRenderWithData:!0},success:function(w){l.html(w.template);h(l)}})}function D(l){l.offon("click",".js-album-source-pagination .js-page-arrow",
r);l.offon("change",".js-album-source-pagination .js-current-page",y);l.offon("keypress",".js-album-source-pagination .js-current-page",q=>{if(32==q.which||13==q.which)q.preventDefault(),q.currentTarget.blur()})}n=n.nodes;e=$(".photo-selector-galleries",m);var F=e.find(".photo-selector-tabs");F.empty();e.children(".tabPanel").remove();$.each(n,function(l,q){-1!=q.nodeid&&(l="tab-gallery-"+(-2==q.nodeid?0:q.nodeid),F.append('<li class="tab-item"><a href="{0}"><span>{1}</span></a></li>'.format("#"+
l,q.title)),e.append('<div id="{0}" class="tabPanel photo-display h-left"></div>'.format(l)))});var u=function(l){const q=B(l);l.html()?g(l):v(l,q,1)};f=m.dialog({modal:!0,width:597,autoOpen:!1,showCloseButton:!1,closeOnEscape:!0,resizable:!1,showTitleBar:!0,title:H.get("select_from_photo_album"),dialogClass:"js-photo-selector-wrapper photo-selector-wrapper dialog-container dialog-box"});e.tabs({create:function(l,q){l=q.panel;u(l);D(l)},activate:function(l,q){l=q.newPanel;u(l);D(l)}});f.addClass("js-no-responsive-resize");
f.off("vbulletin:dialogresize").on("vbulletin:dialogresize",function(){var l=f.find(".ui-tabs-panel");g(l)});f.dialog("open")};a.offon("click",".js-photo-selector-button",function(){a.data("gallery-container",$(this).closest(".b-content-entry-panel__content--gallery"));var n=$(".js-photo-selector-wrapper .js-photo-selector-container");0==n.length&&(n=$(this).closest(".b-content-entry").find(".js-photo-selector-container"));b=[];c=[];n.data("selected-nodes",[]);n.data("selected-nodes-meta",[]);E.ajax({call:"/profile/get-photo-tabs",
success:m=>k(m,n)})})}function M(a,b,c){var e=a.closest(".js-content-entry"),f=e.find(".js-editor");if(b&&!ma(e))return R(()=>{M(a,!1,c)});a.trigger("reset");$(".linkcontainer, .js-photo-postdata, .js-attach-postdata",a).html("");$(".edit-photo-link",a).addClass("h-hide");$(".upload-photo-dialog-container .photo-display-container .photo-display").html("");a.attr("default-action")&&a.attr("action",a.attr("default-action"));t.upload&&t.upload.setUploadButtonText&&t.upload.setUploadButtonText(a);x.resetEditor(f,
function(){e.find(".b-content-entry-panel__content").each(function(d,g){N($(g))});ba(e);f.attr("id")&&x.editorExists(f.attr("id"))&&x.toggleToolbar(f,!1);e.data("prev-selected-panel","");e.find(".b-toolbar__item").removeClass("b-toolbar__item--active");oa(e,e.find(".js-contententry-form"));e.find(".js-content-entry-title").val("");e.find(".js-contententry-buttons").data("hide-buttons-until-click")&&(e.find(".js-contententry-buttons").addClass("h-hide"),e.find(".js-human-verification").addClass("h-hide"));
pa(f.attr("id"));t.ensureFun(c).apply(a)})}function qa(a){if(a.hasClass("b-content-entry-panel__content--gallery"))return!$.trim(a.find(".js-panel-content").html());if(a.hasClass("b-content-entry-panel__content--link")||a.hasClass("b-content-entry-panel__content--video"))return!$.trim(a.find(".js-panel-content").html())&&!a.find(".b-link-input__url").val();if(a.hasClass("b-content-entry-panel__content--poll")){var b=!1;$(".b-poll-fieldset .b-form-input__input",a).each((d,g)=>{if($(g).val())return b=
!0,!1});b||$(".b-poll-fieldset .b-form-control__control",a).each((d,g)=>{if(g.defaultChecked!=g.checked)return b=!0,!1});return!b}if(a.hasClass("b-content-entry-panel__content--attachment"))return!(1<a.find(".js-attach-list .js-attach-item").length);if(a.hasClass("b-content-entry-panel__content--event")){b=!1;var c=$('input[name="eventstartdate"]',a),e=$(".js-toggle-slider[data-name='is_all_day']",a);a=$('input[name="eventenddate"]',a);var f=$("input[name='location']");c.length&&c.val()!=c.data("initial-value")&&
(b=!0);e.length&&e.hasClass("b-toggle-slider--no")&&(b=!0);a.length&&a.val()!=a.data("initial-value")&&(b=!0);f.length&&""!=f.val()&&(b=!0);return!b}return!0}function ca(a){var b=$();a.is(".js-content-entry")&&(b=a);b.length||(b=a.find(".js-content-entry"));b.length||(b=a.closest(".js-content-entry"));a=1==b.find(".b-content-entry-panel__content--event:visible").length;b=b.find(".js-content-entry-event-highlights-container");var c=b.find(".js-content-entry-event-highlights");b.toggleClass("h-hide-imp",
!a);b.is(":visible")&&c.is(".selectBox")&&c.val()&&c.val("").selectBox("value","")}function N(a){a.addClass("h-hide");if(a.hasClass("b-content-entry-panel__content--gallery"))a.find(".js-panel-content").empty(),a.find(".b-button--upload .js-upload-label").text(H.get("upload")),a.find(".b-form-input__file--hidden").prop("disabled",!0),a.find(".js-photo-postdata").empty(),a=t.upload.getUploadedPhotosDlg(!1,a),$(".photo-display",a).empty();else if(a.hasClass("b-content-entry-panel__content--link")||
a.hasClass("b-content-entry-panel__content--video"))a.find(".js-panel-content").empty(),a.find(".b-link-input__url").val("").prop("disabled",!0).parent().removeClass("h-hide");else if(a.hasClass("b-content-entry-panel__content--poll")){var b=a.find(".b-poll-fieldset__poll-answers li");3<b.length&&b.filter(function(d){return 3<=d}).remove();a.find(".b-poll-fieldset input").each((d,g)=>{"text"==g.type?(g.value="",g.disabled=!0):"checkbox"==g.type&&(d=$(g),d.prop("checked",g.defaultChecked),d.hasClass("js-poll-timeout")&&
d.triggerHandler("click"))})}else if(a.hasClass("b-content-entry-panel__content--attachment"))a.find('.js-attach-list .js-attach-item:not(.h-hide) .js-attach-ctrl[data-action="remove"]').trigger("click");else if(a.hasClass("b-content-entry-panel__content--advanced-options"))a.removeClass("h-hide"),a.find(".js-htmlstate").selectBox("value","off"),b=a.find(".js-collapse__icon:not(.js-collapse--collapsed)"),0==a.find(".b-content-entry-panel__section--lite").length?b.trigger("click"):b.first().trigger("click");
else if(a.hasClass("b-content-entry-panel__content--event")){b=$('input[name="eventstartdate"]',a);var c=$(".js-toggle-slider[data-name='is_all_day']",a),e=$('input[name="eventenddate"]',a),f=$("input[name='location']");b.length&&b.val(b.data("initial-value"));c.length&&c.hasClass("b-toggle-slider--no")&&c.trigger("click");e.length&&e.val(e.data("initial-value"));f.length&&f.val("");ca(a)}}function Ha(a){a.hasClass("b-content-entry-panel__content--gallery")?a.find(".b-form-input__file--hidden").prop("disabled",
!1):a.hasClass("b-content-entry-panel__content--link")||a.hasClass("b-content-entry-panel__content--video")?a.find(".b-link-input__url").prop("disabled",!1):a.hasClass("b-content-entry-panel__content--poll")&&a.find(".b-poll-fieldset .b-form-input__input").prop("disabled",!1)}function Ia(a){let b=a.closest("form");var c=a.data("panel"),e=$(".js-content-entry-title",b);let f=$(".js-editor",b);if(!(b.attr("action")||"").match(RegExp("private-message/?$"))){a=a.hasClass("b-toolbar__item--active")?c.replace(/^b-content-entry-panel__content--/,
""):b.closest(".js-content-entry").data("default-content-type").toLowerCase()||"text";b.attr("action",t.getAjaxBaseurl()+"/create-content/"+a);b.data("content-type",a);c={text:"enter_title",gallery:"enter_photo_gallery_title",poll:"enter_poll_question","default":"enter_"+a+"_title"};var d={text:"write_something_here",event:"enter_event_details_here","default":"write_something_here_optional"};e.attr("placeholder",H.get(c[a in c?a:"default"]));e=H.get(d[a in d?a:"default"]);f.attr("placeholder",e);
$(".b-editor__placeholder",b).text(e)}}function Ja(a,b){var c=null,e=null,f=0,d=0,g=(h,k,n,m,r)=>{h.find(k).slice(n,m?m:void 0).height(r)};a.find(b).each((h,k)=>{k=$(k);e=k.position().top;e!==c&&(d&&g(a,b,f,h,d),f=h,d=0,c=k.position().top);h=k.outerHeight(!0);d=d>h?d:h});g(a,b,f,0,d)}function Ka(){var a=$(this),b=a.closest(".js-smilie-container"),c=d=>{$(".js-smilie-category",d).add(".js-toggle-more-smilies",d).add(".js-smilie-category-preview",d).toggleClass("h-hide");d.toggleClass("b-smilie__container--big")};
if(b.data("all-smilies-loaded"))c(b);else{var e=$("<span />").addClass("h-left h-margin-top-xs").text(H.get("loading")+"...");a.after(e).addClass("h-hide");var f=d=>{d.find(".js-smilie-category").each((g,h)=>{var k=$(h);g=k.find("img");var n=g.length,m=0;g.offon("load",r=>{++m;m>=n-1&&Ja(k,".js-smilie-button")})})};E.ajax({call:"/ajax/render/contententry_panel_smilies",data:{previewOnly:0,isAjaxTemplateRenderWithData:1},success:d=>{a.removeClass("h-hide");e.remove();d=$(d.template).find(".js-smilie-container");
b.replaceWith(d);d.data("all-smilies-loaded","1");c(d);f(d)}})}return!1}function La(a){var b=function(d,g){var h=$(d);d=h.attr("src");var k=h.attr("title");h=h.data("smilieid");d=g.document.createElement("img",{attributes:{src:d,"data-cke-saved-src":d,title:k,alt:k,smilieid:h}});g.insertElement(d)};a=$(this);var c=a.closest(".js-content-entry").find(".js-editor"),e=a.find("img").get(0),f=c.attr("id");if(a.hasClass("b-smilie__button--disabled"))return!1;f&&x.editorExists(f)?b(e,x.getEditor(f)):x.initEditor(c,
{showToolbar:!0,success:(d,g)=>{b(e,g)}});return!1}function Ma(a){a=$(a.target).closest(".js-content-entry-panel__content--event").find(".js-event-dateinput");var b=a.filter("[name=eventstartdate]");a=a.filter("[name=eventenddate]");var c=b.val(),e=a.val(),f=!1;"undefined"==typeof X&&(X=36E5,da=b.data("initial-value"),ea=a.data("initial-value"));if(c!=da){b=new Date(Date.parse(c));b=b.getTime()+X;b=new Date(b);function d(g){return 10>g?"0"+g:g}e=d(b.getMonth()+1)+"/"+d(b.getDate())+"/"+b.getFullYear()+
" "+d(b.getHours())+":"+d(b.getMinutes());f=!0}else e!=ea&&(b=new Date(Date.parse(c)),X=(new Date(Date.parse(e))).getTime()-b.getTime());da=c;ea=e;f&&t.flatpickr.getInstance(a).setDate(e)}function Na(a){var b="1"==$(this).find("input[name=is_all_day]:checked").val(),c=$(a.target).closest(".js-content-entry-panel__content--event").find(".js-event-dateinput");a=c.filter("[name=eventstartdate]");var e=a.data("initial-value");e=a.val()||e;c=c.filter("[name=eventenddate]");var f=c.data("initial-value");
f=c.val()||f;var d="datetime";if(b)d="date",a.data("temp-saved-date",e),c.data("temp-saved-date",f);else{-1===a.val().indexOf(":")&&a.val(e);-1===c.val().indexOf(":")&&c.val(f);b=a.data("temp-saved-date");var g=c.data("temp-saved-date");b&&0<=b.indexOf(e)&&a.val(b);g&&0<=g.indexOf(f)&&c.val(g)}t.flatpickr.changePickerType(a,d);t.flatpickr.changePickerType(c,d)}function Oa(a){a=$(this);var b=a.closest(".b-content-entry-panel__content").data("class");a.is(".js-ckeditor-toolbar-close")&&(b="b-content-entry-panel__content--toggle-editor");
a.closest(".b-content-entry").find('.b-toolbar__item[data-panel="'+b+'"]').trigger("click")}function ba(a){var b=a.find(".js-content-entry-panel"),c=b.find(".b-content-entry-panel__content").not(".h-hide");b.toggleClass("h-hide",!c.length);c.removeClass("b-content-entry-panel__content--first").first().addClass("b-content-entry-panel__content--first");b.closest(".js-content-entry").toggleClass("b-content-entry--all-panels-hidden",0==c.length);ca(a);t.ensureFun(b.data("callback")).call(b)}function R(a,
b){K.openConfirmDialogSimple({title:b||"content_entry",message:"all_changes_made_will_be_lost_would_you_like_to_continue",iconType:"warning",onClickYes:a});return!1}function Pa(a){var b=!0;a.find(".b-content-entry-panel__content").each(function(c,e){if(!qa($(e)))return b=!1});return b}function ma(a){var b=a.find(".js-content-entry-title").val();return("string"!=typeof b||""==b)&&x.isEditorEmpty(a.find(".js-editor"))&&Pa(a)}function fa(a,b,c,e,f){a.find('input[type="hidden"]').filter((d,g)=>{d=$(g).attr("name");
for(key of["",b])for(field of["filedataids[{0}]","filenames[{0}]","setting[{0}][size]"])if(d==field.format(key))return!0}).remove();a.append([Q("filedataids[{0}]".format(b),c),Q("filenames[{0}]".format(b),e)]);f&&a.append(Q("setting[{0}][size]".format(b),f))}function ra(a){a.find('.b-toolbar__item[data-panel="b-content-entry-panel__content--attachment"]:not(.b-toolbar__item--active)').trigger("click")}function sa(a,b,c){if(!a)return console.warn("addAttachmentItemPanel failed because $closestElement was not provided"),
!1;a=a.closest(".js-content-entry");var e=a.find(".js-attach-list"),f=e.find(".js-attach-item-sample").first().clone(!0),d=$("<img />").attr("src",pageData.baseurl+"/filedata/fetch?type=thumb&filedataid="+c.filedataid).addClass("b-attach-item__image");f.removeClass("js-attach-item-sample");f.find(".js-attach-item-image").append(d);f.find(".js-attach-item-filename").text(c.filename);d="";var g=c.filename.match(/\.([a-z]+)$/i);g&&(d=g[1]);f.data({fileext:d,filename:c.filename,filedataid:c.filedataid,
attachnodeid:0,"first-insert-id":b});fa(f,b,c.filedataid,c.filename,c.imagesize);f.appendTo(e).removeClass("h-hide");e.removeClass("h-hide");ra(a);return!0}function Qa(a){var b=$(this);a=b.closest("form");var c=b.closest(".js-attach-item"),e=b.data("action"),f=b.data("imagesize"),d=c.data("filedataid"),g=x.generateTempAttachmentId(d),h=c.data("attachnodeid")||0,k=c.data("fileext"),n=c.data("filename"),m=a.find(".js-editor"),r=c.data("first-insert-id"),y="icon thumb small medium large full".split(" "),
p=function(l,q,z,w,C,A,S){var G="",J="";G=pageData.baseurl+"/filedata/fetch?filedataid="+l;J=G+"&thumb=1";var T="",L=null!==q.match(/^(gif|jpg|jpeg|jpe|png|bmp|webp)$/i),ta=!1;q=!1;var ha="data-tempid",U=g;if(r||0!=h)if(!r&&0<h){var I=!1;"wysiwyg"==w.mode?(temp=document.createElement("div"),temp.innerHTML=w.getData(),I=L?"img":"a",I=0<$(temp).find(I+'[data-attachmentid="'+h+'"]').length):(regex=new RegExp("\\[ATTACH(=[^\\]]+)?\\]n"+h+"\\[/ATTACH\\]","i"),sourceText=$(w.container.$).find("textarea.cke_source").val(),
(matches=regex.exec(sourceText))&&(I=!0));I?q=!0:(G=pageData.baseurl+"/filedata/fetch?id="+h,J=G+"&thumb=1",ha="data-attachmentid",U=h,g="n"+h,c.data("first-insert-id",g),"insert_image"==C||"insert_sigpic"==C||A||(A="thumb"),A&&(I={},I.attachmentid=h,I.size=A,E.ajax({call:"/uploader/saveattachmentsetting",data:I})))}else r&&(q=L);else z=(z=c.find('input[type="hidden"][name="filenames[]"]'))&&z.val(),c.data("first-insert-id",g),ta=!0;L||(0<h?U=g=h:c.data("tempid")&&(U=g=c.data("tempid")));I=!1;L?("insert_sigpic"==
C?J=G=" [SIGPIC][/SIGPIC] ":(L="","insert_image"==C?(S.includes(A)&&(G+="&amp;type="+A),T=G):(A="thumb",L=" thumbnail",T=J),G=' <img class="bbcode-attachment'+L+'" src="{0}" {1}="{2}" /> '.format(T,ha,U),J=" [ATTACH=CONFIG]{0}[/ATTACH] ".format(g)),I=A):"video"==c.data("filebasetype")?G=J="[VIDEO=videofile;{0}{1}]{0}[/VIDEO]".format(G,0==h?";"+g:""):"insert_sigpic"==C?J=G="":(G=' <a class="bbcode-attachment" href="{0}" {1}="{2}" />'.format(G,ha,U)+z+"</a> ",J=" [ATTACH]{0}[/ATTACH] ".format(g));ta&&
(fa(c,g,l,z,I),c.attr("data-tempid",g));q&&(filedataObj={filedataid:l,filename:z,imagesize:A},sa(b,g,filedataObj));if(l=w.document&&w.document.getBody())l.setAttribute("contentEditable",!1),l.setAttribute("contentEditable",!0);"wysiwyg"==w.mode?(w.insertHtml(G),""!=T&&x.autogrowEditorOnImageLoad(T,w)):($sourceTextArea=$(w.container.$).find("textarea.cke_source"),cursorStart=$sourceTextArea[0].selectionStart,cursorEnd=$sourceTextArea[0].selectionEnd,text=$sourceTextArea.val(),newtext=text.substring(0,
cursorStart)+J+text.substring(cursorEnd),$sourceTextArea.val(newtext));setTimeout(()=>{w.focus();w.execCommand("autogrow")},10)};switch(e){case "remove":var B=function(){0<h&&Q("removeattachnodeids[]",h).appendTo(c.closest("form"));c.remove()};if(x.editorExists(m.attr("id"))){a=x.getEditor(m.attr("id"));var v=a.getData(),D=pageData.baseurl+"/filedata/fetch?filedataid="+d;v=v.replace("[ATTACH]{0}[/ATTACH]".format(r),"");v=v.replace("[ATTACH=CONFIG]{0}[/ATTACH]".format(r),"");v=v.replace("[IMG]{0}[/IMG]".format(D),
"");for(var F of y)v=v.replace("[IMG]{0}&amp;type={1}[/IMG]".format(D,F),"");v=v.replace("[VIDEO=videofile;{0}]{0}[/VIDEO]".format(pageData.baseurl+"/filedata/fetch?id="+h),"");F=c.find('input[type="hidden"]');var u=(l,q,z)=>{l=l.replace(new RegExp("\\[ATTACH(=[^\\]]+)?\\]"+q+"\\[/ATTACH\\]","i"),"");q=document.createElement("div");q.innerHTML=l;$(q).find("img["+z+"], a["+z+"]").remove();return q.innerHTML};for(D=0;D<F.length;D++)regex=/filedataids\[([^\]]+)]/,(tempid=(matches=regex.exec(F[D].name))&&
matches[1])&&(v=u(v,tempid,'data-tempid="'+tempid+'"'));0<h&&(v=u(v,"n"+h,'data-attachmentid="'+h+'"'));a.setData(v,function(){B()})}else B();break;case "insert":case "insert_image":case "insert_sigpic":x.editorExists(m.attr("id"))?p(d,k,n,x.getEditor(m.attr("id")),e,f,y):x.initEditor(m,{success:()=>{setTimeout(()=>{p(d,k,n,x.getEditor(m.attr("id")),e,f,y)},0)}})}return!1}function Ra(a,b){var c=$(this);a=c.closest(".js-content-entry");var e=a.find("."+c.data("panel")),f=1==c.closest(".js-toolbar-primary").length,
d=a.data("prev-selected-panel")||"",g=k=>k.is(":visible")&&!qa(k);if(f){if("0"==a.data("allow-type-text")&&(c.addClass("b-toolbar__item--unselectable"),c.hasClass("b-toolbar__item--active")))return!1;if(!b&&(d.length&&g(d)||g(e)))return R(function(){d.length?(N(d),d=""):N(e);c.trigger("click",[!0])});$(".js-toolbar-primary .b-toolbar__item",a).removeClass(function(){return this==c.get(0)?($(this).toggleClass("b-toolbar__item--active"),""):"b-toolbar__item--active b-toolbar__item--unselectable"});
d.length&&d.is(":visible")&&(N(d),d="");c.hasClass("b-toolbar__item--active")?(Ha(e),d=e,e.removeClass("h-hide"),ca(e)):(N(e),d="");Ia(c);a.data("prev-selected-panel",d)}else{if(!b&&"b-content-entry-panel__content--attachment"==c.data("panel")&&g(e))return R(()=>{N(e);c.trigger("click",[!0])});c.toggleClass("b-toolbar__item--active");g=c.hasClass("b-toolbar__item--active");b=parseInt(pageData.user_editorstate,10);var h=c.data("panel");f=ua(h);"b-content-entry-panel__content--toggle-editor"==h?toggleAdvancedEditor(c):
e.toggleClass("h-hide",!g);g?(b|=f,g="add"):(b-=b&f,g="remove");b!=pageData.user_editorstate&&(t.loadingIndicator.suppressNextAjaxIndicator(),E.ajax({call:"/ajax/api/user/saveEditorState",data:{action:g,value:f},success:function(k){k.success&&"undefined"!=typeof k.editorstate&&(pageData.user_editorstate=parseInt(k.editorstate,10))}}))}ba(a);ia(a)}function ia(a){a.find(".js-contententry-buttons, .js-human-verification").removeClass("h-hide")}function ua(a){var b={"b-content-entry-panel__content--toggle-editor":1,
"b-content-entry-panel__content--attachment":2,"b-content-entry-panel__content--smiley":4};return a in b?b[a]:0}function pa(a){$("#"+a).closest(".js-content-entry").find(".b-toolbar__item--secondary").each(function(){var b=$(this),c=b.data("panel");c=ua(c);pageData.user_editorstate&c&&!b.hasClass("b-toolbar__item--active")&&b.trigger("click")})}function aa(a){a=a.find(".js-editor");if(0<a.length){let b=a.attr("id");x.editorExists(b)&&x.destroyEditor(b)}a.closest("form").remove()}function ja(a,b){$(".js-attach-button",
a).offon("click",function(e){e.preventDefault();e=$(this);Sa(e,e.closest(O(b)),b)});$(".b-link-content__urlinfo .js-link-edit",a).on("click",function(e){e.preventDefault();var f=$(this).parent().parent();f.addClass("b-link-content__urlinfo-meta--edit-mode");$(".js-link-textbox",f).val($.trim($(".b-link-content__urlinfo-text",f).text())).trigger("focus");$(".js-link-save",f).on("click",function(d){d.preventDefault();$(".b-link-content__urlinfo-text",f).text($(".js-link-textbox",f).val());f.removeClass("b-link-content__urlinfo-meta--edit-mode")})});
$(".js-link-remove",a).on("click",function(e){e.preventDefault();$(this).closest(".b-content-entry-panel__content").find(".b-link-input").removeClass("h-hide");$(this).closest(".js-panel-content").empty();$(".b-link-input",a).removeClass("h-hide")});if("link"==b){$(".js-link-preview-checkbox",a).offon("click",function(){$(".b-link-content__thumbnail",a)[this.checked?"addClass":"removeClass"]("h-hide")});var c=$(".b-link-thumbnail-list__item",a).length;function e(f,d){const g=f.add(d);g.offon("jcarouselcontrol:inactive",
(h,k)=>{$(h.currentTarget).addClass("b-icon--disabled")});g.offon("jcarouselcontrol:active",(h,k)=>{$(h.currentTarget).removeClass("b-icon--disabled")});d.jcarouselControl({target:"-=1"});f.jcarouselControl({target:"+=1"})}(function(){var f=a.find(".b-link-thumbnail-list"),d=f.parent();f.css("position","relative");d.on("jcarousel:create",(n,m)=>{$(".b-thumbnail-nav .b-thumbnail-nav__counter",a).html("1/"+c)});f.on("jcarousel:targetin","li",n=>{n=$(n.currentTarget);const m=n.index()+1;$(".b-thumbnail-nav .b-thumbnail-nav__counter",
a).html(m+"/"+c);$('input[type="radio"]',n).prop("checked",!0)});f.on("jcarousel:targetout","li",n=>{n=$(n.currentTarget);$('input[type="radio"]',n).prop("checked",!1)});let g,h;const k=(null==(g=$(".js-link-url-image:checked",f))?void 0:null==(h=g.parent())?void 0:h.index())||0;d.on("jcarousel:createend",n=>{setTimeout(()=>{$(n.currentTarget).jcarousel("scroll",k,!1)},50)});d.jcarousel({list:".b-link-thumbnail-list",items:".b-link-thumbnail-list__item",vertical:!1,center:!0,wrap:null,scroll:1,rtl:vBulletin.isRtl()});
f=d.find(".b-thumbnail-nav__prev-arrow");d=d.find(".b-thumbnail-nav__next-arrow");e(d,f,!1)})()}}function Sa(a,b,c){let e=$(".b-link-input__url",b),f=$.trim(e.val());c="attach_"+c;f?(f.match(/^https?:\/\//)||(f="http://"+f,e.val(f)),a.prop("disabled",!0),E.ajax({call:"/createcontent/getlinkdata",data:{url:f,isAjaxTemplateRender:!0,isAjaxTemplateRenderWithData:!0},success:d=>{let g=$(d.template);b.closest("form").data("content-type",d.contenttype);g.find("img").on("error",function(){$(this).closest("li").remove()});
b.find(".js-panel-content").append(g);ja(b,d.contenttype);g.fadeIn("slow",()=>{e.val("");$(".b-link-input",b).addClass("h-hide")})},after_error:()=>e.trigger("focus"),complete:()=>{a.prop("disabled",!1)},title_phrase:c})):K.warning(c,"please_enter_a_valid_url_and_click_attach",e)}function Ta(a){if(0<a.find(O("poll")).length){var b=a.find(".b-poll-fieldset__poll-answers");b.find(".js-remove-button").prop("disabled",2>=b.find("li").length);a.find(".js-poll-timeout").offon("click",c=>{c=!c.currentTarget.checked;
let e=a.find(".b-poll-fieldset__datepicker-container");e.toggleClass("h-hide",c);c&&e.find(".b-datepicker__input").val("")})}0<a.find(O("video")).length&&(b=O("video"),ja(a.find(b),"video"));0<a.find(O("link")).length&&(b=O("link"),ja(a.find(b),"link"))}function Ua(a,b,c,e){a.data("initAjaxFormSubmitDone")||(V.initAjaxForm(b,{success:e||Fa,error_phrase:"error_while_saving_content",api_error:V.resetOnError,beforeSerialize:f=>{var d=f.find("[name=text]");d.val(d.val().replace(String.fromCharCode(8203),
""));d=$.Event("beforeSave");f.trigger(d);return!d.isDefaultPrevented()},beforeSubmit:(f,d,g)=>{if(!1===na.apply(d,[g]))return!1;c||$(window).off("beforeunload.editPost");return c&&Z.get("suggesttags")&&!d.data("tagsdone")?(f=f.find(h=>"tags"==h.name))&&f.value?!0:!t.tagEditor.promptForTags(d):!0}}),a.data("initAjaxFormSubmitDone",!0))}function Va(a){function b(g){var h=g.val();return""==h||g.data("last-autofill-value")==h}function c(g,h,k,n){var m=!1;b(g)&&(g.data("last-autofill-value",h),g.val(h),
m=!0);b(k)&&(k.data("last-autofill-value",n),k.val(n),m=!0);!m||k.is(":visible")&&g.is(":visible")||(g=$('.js-collapse__icon.js-collapse--collapsed[data-collapse-id="{0}"]'.format("collapse_advoptionspanel_meta_new")),$('.js-collapse__icon.js-collapse--collapsed[data-collapse-id="{0}"]'.format("collapse_advoptionspanel_new")).trigger("click"),g.trigger("click"))}let e=a.find(".js-content-entry-title").first(),f=a.find(".js-content-entry-url-alias").first(),d=a.find(".js-content-entry-html-title").first();
e.offon("change.urlident",function(g){g=e.val();""!=g&&f.length&&b(f)?E.ajax({call:"/create-content/get-url-ident",data:{text:g},silent:!0,success:h=>{c(f,h.urlident,d,e.val())}}):c(f,"",d,e.val())})}function Wa(a){function b(d,g,h=!1){d=d.data("collapse-id");var k='data-collapse-id="'+d+'"',n=$(".js-collapse__link["+k+"]",a),m=$(".js-collapse__icon["+k+"]",a),r=$(".js-collapse__body["+k+"]",a),y=m.add(r);"toggle"==g&&(g=n.add(m).is(".js-collapse--collapsed"));k=p=>{m.toggleClass("b-icon__plus-circle",
!p).toggleClass("b-icon__minus-circle",p);y.toggleClass("js-collapse--collapsed",!p)};g?(r.show(),n=r.find(".js-toggle-slider__dependent.h-hide").removeClass("h-hide"),r.find(".js-select-box").selectBox(),n.addClass("h-hide"),r.hide(),r.slideDown("fast"),k(g)):r.is(".b-content-entry-panel__section--lite")||(r.slideUp("fast",()=>r.hide()),k(g));h&&e(d,!g)}let c=t.storagetools.createStorage("editor"),e=(d,g)=>c.set(d.replace(/(^collapse_|_edit$|_new$)/g,""),g?"1":"0"),f=$(".js-collapse__icon",a);$(".js-collapse__link",
a).add(f).addClass("b-link js-link").offon("click",function(d){b($(this),"toggle",!0)});f.addClass("b-icon");(function(){$(".js-content-entry .js-collapse__icon").each((d,g)=>{d=$(g);g=c.get(d.data("collapse-id").replace(/(^collapse_|_edit$|_new$)/g,""));g=null==g?!(!d.is(".js-collapse--collapsed")||d.is(".js-content-entry-edit-post .js-collapse__icon")):"1"==g;b(d,!g)})})()}function oa(a,b){b=b.data("content-type");let c=$('.b-toolbar__item[data-panel="b-content-entry-panel__content--{0}"]'.format(b),
a);0==c.length&&"video"==b&&(c=$('.b-toolbar__item[data-panel="b-content-entry-panel__content--{0}"]'.format("link"),a));c.hasClass("b-toolbar__item--active")||c.trigger("click")}function Xa(){if(!va){let a=$(document);Ga(a);a.offon("click",".js-content-entry-save-draft",Ba);a.offon("click",".js-content-entry-preview",Aa);a.offon("click",".js-content-entry-loadnewposts",Ca);a.offon("click",".b-content-entry .b-toolbar__item",Ra);a.offon("keydown",".js-content-entry .b-link-input__url",function(b){(b=
13==b.keyCode)&&$(this).next(".js-attach-button").trigger("click");return!b});a.offon("focus",".js-content-entry .js-editor",function(){ia($(this).closest(".js-content-entry"))});W=$('.js-content-entry .js-toggle-slider[data-name="disable_bbcode"]').data("value");a.offon("change",'.js-content-entry .js-toggle-slider[data-name="disable_bbcode"]',(b,c)=>{W=c});a.offon("change",".js-content-entry .js-content-entry-panel__content--event .js-event-dateinput",Ma).offon("change",".js-content-entry .js-content-entry-panel__content--event .js-toggle-slider[data-name='is_all_day']",
Na);a.offon("keyup",".js-event-location",b=>{b=$(b.target);b.closest("form").find(".js-event-previewmap").prop("disabled",""==b.val())});a.offon("click",".js-event-previewmap",b=>{b=$(b.target).closest("form").find(".js-event-location").val();E.ajax({call:"/ajax/render/display_event_map",data:{location:b,isAjaxTemplateRenderWithData:1},success:c=>{K.openAlertDialog({title:H.get("preview_map"),message:c.template})}})})}va=!0}function ka(a,b=!0,c=null){let e=a.is("#newTextForm"),f=!e&&!a.is(".js-content-entry-basic"),
d=e?a:a.find(".js-contententry-form"),g=d.find(".js-editor");Xa();if(f){let h=x.getEditorContent(g);d.trigger("reset");h&&(x.editorExists(g)?x.getEditor(g).setData(h):g.val(h))}e||t.upload.initializePhotoUpload(a);Ua(a,d,b,c);e||(Ta(a),Wa(a));f&&(Va(a),oa(a,d))}function Ya(a,b){var c="iconid prefixid title text tags htmlstate".split(" ");let e=[/^filedataids/,/^filenames/,/^setting/];"poll"==b?c.push("polloptions[new][]","timeout","ignoredst","canchangevotes","public","multiple"):"event"==b?c.push("eventstartdate",
"eventenddate","is_all_day","location","showmap","eventhighlightid","ignoredst"):"link"==b||"video"==b?c.push("url_title","url","url_meta","url_image","url_nopreview","videoitems[new][][url]"):"gallery"==b&&e.push(/^filedataid/,/^title_/,/^caption_/,/^displayorder_/);a=t.getFormData(a,0);c=t.objSubset(a,c);for(let f of Object.keys(a))for(let d of e)d.test(f)&&(c[f]=a[f]);c.contenttype=b;return c}function wa(a){return a.find('*[name^="customfield"]')||$()}function Za(a){wa(a).each((b,c)=>{b=$(c);Y.hasOwnProperty(c.name)&&
b.val(Y[c.name])})}function $a(a){a=wa(a).serializeArray().reduce((b,c)=>{b[c.name]=c.value;return b},{});Y={...Y,...a}}async function xa(a,b){if(!(0>=b)){var c=a.find(".js-contententry-form"),e=c.data("content-type")||"text",f=Ya(c,e);$a(c);E.render({call:"/create-content/LoadContentEntryForChannel",data:{...f,channelid:b},success(d){var g=a.find(".js-contententry-newentry-wrapper");g.html(d.template||"");a.find(".js-contententry-cancel-wrapper").toggleClass("h-hide",!!d.template);vBulletin.conversation.bindEditFormEventHandlers("all");
g.find(".b-content-entry-panel__content--edit-reason").hide();g.find(".js-editor").val(f.text);d=g.find(".js-contententry-form");let h=d.data("content-type");ka(g.find(".js-content-entry"),!0);d.data("content-type",h);x.initEditorComponents(g);Za(g.find(".js-contententry-form"));d=`.${"js-contententry-container"}[data-tageditor-contextid="${a.data("tageditor-contextid")}"] .js-content-entry-tag-editor`;g.find(".add-tag-link").data("node-id",b);let k;null==(k=t.tagEditor)||k.initEditTagsContent(d);
t.flatpickr&&t.flatpickr.initPickers();(g=a.dialog("instance"))&&g.option({position:{my:"center",at:"center",of:window}})}})}}function ya(a,b){const c=()=>{b&&(b.option("beforeClose",null),b.close())};if(!a||!a.length)return c(),!1;M(a,!0,()=>{a.trigger("afterCancel");c()});return!1}function ab(a){var b=$(a.target);a=b.closest(".js-contententry-container");b=Number.parseInt(b.val(),10);xa(a,b)}function bb(a){a=$(a.target).data("contententry-contextid");const b=$('.js-contententry-container[data-contententry-contextid="'+
a+'"]');a=b.find(".js-contententry-channel");a=Number.parseInt(a.val());b.offon("change",".js-contententry-channel",ab);a&&xa(b,a);b.length&&(b.removeClass("h-hide"),K.openModalDialog(b,{title:"start_a_topic",width:800,dialogClass:"contententry-dialog-container",onOpen:()=>{const c=b.find(".js-contententry-form"),e=b.dialog("instance");b.dialog("option",{closeOnEscape:!0,beforeClose:f=>{ya(c,e);return!1}});b.offon("click",".js-content-entry-cancel",f=>{f.stopImmediatePropagation();f.preventDefault();
f=b.find("form");ya(f,e)});e._allowInteraction=f=>{const d=$.ui.dialog.prototype._allowInteraction.call(e,f);return!d&&$(f.target).closest(".flatpickr-calendar").length?!0:d}}}))}function za(a){a.find(".js-start-new-topic").offon("click",bb)}let Q=(a,b)=>$("<input />").attr({type:"hidden",name:a}).val(b),O=a=>".b-content-entry-panel__content--"+a,W=!1;toggleAdvancedEditor=function(a){var b=a.closest(".js-content-entry").find(".js-editor");b.attr("id")&&x.editorExists(b.attr("id"))?x.toggleToolbar(b):
x.initEditor(b,{showToolbar:!0,success:(c,e)=>{e.focus();t.ensureFun(b.data("callback")).call(b)}})};var X,da,ea;let va=!1,Y={};(function(){let a=$(document);$(".js-content-entry").each((b,c)=>{b=$(c);0==b.closest(".edit-conversation-container").length&&ka(b)});a.offon("click",".js-content-entry-delete",Da);a.offon("click",".js-content-entry-cancel",Ea);a.offon("click",".js-content-entry .js-contententry-panel-x",Oa);a.offon("click",".js-smilie-container .js-toggle-more-smilies",Ka);a.offon("click",
".js-smilie-container .js-smilie-button",La);a.offon("click",".js-content-entry .js-attach-ctrl",Qa);a.on("vb-instrument",b=>{za($(b.target))});za(a)})();return{showButtons:ia,initEntryBox:ka,addAttachmentItemPanel:sa,updatePanelItemData:fa,openAttachmentPanel:ra,entryBoxEvent:function(a,b,c){a.find(".js-contententry-form").on(b,c)},resetForm:M,validateForm:na,afterPanelChange:ba,restoreEditorState:pa,destroyEditor:aa,populateMetaDescription:function(a,b){var c=b.find(".js-meta-description").first();
if(1==c.length){var e=c.val(),f="";b=b.is(".js-content-entry-edit-post");var d=Z.get("threadpreview");0>=d&&(d=150);a=$("<div />").html(a).text();a=a.replace(/[\s\v\0]+/g," ").replace(/^ | $/g,"");if(a.length>d+10){a=a.substr(0,d+10);d=a.length-1;for(var g=20<a.length?20:a.length,h;0<g;){h=a.substr(d,1);if(h.match(/[\s\v\0\.\?\n-]/)){a=a.substr(0,a.length-(a.length-d));break}--g;--d}}b&&(f=a);if(""==e&&""!=a||f==e&&""!=e||0===e.indexOf(f)&&""!=e)prevHtmlTitle=a,c.val(prevHtmlTitle),c.is(":visible")||
(c=c.closest(".js-collapse__body"),a=$(".js-collapse__icon, .js-collapse__body"),c=a.index(c),a.eq(c-1).trigger("click"))}},allowBbcode:()=>!W}})(vBulletin,vBulletin.ckeditor,vBulletin.conversation,vBulletin.hv,vBulletin.phrase,vBulletin.options,vBulletin.dialogtools,vBulletin.ajaxtools));
