!function(D,u,t){"use strict";ips.controller.register("bim.chatbox.free",{lmn1:!1,lmn2:!1,lmn3:!1,lmn4:!1,lmn5:!1,lmn6:!0,lmn7:0,lmn8:/\bhttps?:\/\/\S+/gi,lmn9:/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;\(\)]*[-A-Z0-9+&@#\/%=~_|])(\.jpg|\.png|\.gif|\.webp)/ig,lmn10:/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/,lmn11:/\uD83C\uDFF4(?:\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74)\uDB40\uDC7F|\u200D\u2620\uFE0F)|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC68(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3]))|\uD83D\uDC69\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\uD83D\uDC68(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83D\uDC69\u200D[\u2695\u2696\u2708])\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC68(?:\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD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]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDD1-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDD1-\uDDDD])/g,lmn12:["‘"],lmn13:"",lmn14:null,lmn15:null,initialize:function(){this.on("click",'[data-action="toggleSound"]',this.toggleSound),this.on("click",'[data-action="mention"]',this.mention),this.on("click",'[data-action="connect"]',this.connect),this.on("click",'[data-action="chat"]',this.chat),this.on("submit",'[data-action="chatform"]',this.chat),this.on("keypress",'[data-action="saveMSG"]',this.saveMSG),this.on("click",'[data-action="remove"]',this.remove),this.on("dblclick",'[data-action="editMSG"]',this.editMSG),this.on("click",'[data-action="editMSGButton"]',this.editMSG),this.on("click",'[data-action="loadMore"]',this.loadMore),this.on("click",'[data-action="playVideoInPopup"]',this.playVideoInPopup),this.on("click",'[data-action="playVideoInIframe"]',this.playVideoInIframe),this.on("click",'[data-action="bimGiphy"]',this.bimGiphy),this.on("focus",".bimcb_chatInput",this.focusChatInput),this.on("blur",".bimcb_chatInput",this.blurChatInput),this.setup()},setup:function(){var u=this;1!=ips.getSetting("chatbox_topStyle")&&D("#chatcontent img").imagesLoaded(function(u){D("#chatboxWrap").scrollTop(D("#chatboxWrap").prop("scrollHeight"))}),this.scope.find('[data-action="toggleSound"] .fa').replaceWith(D("<i/>").addClass("fa").addClass(ips.getSetting("chatbox_soundEnabled")?"fa-volume-up":"fa-volume-off")),ips.loader.get(["core/interface/howler/howler.core.min.js"]).then(function(){u.lmn15=new Howl({src:ips.getSetting("baseURL")+"applications/bimchatbox/interface/sounds/message.mp3",autoplay:!1})}),this.scope.find("#elChatbox").prepend(ips.templates.render("core.editor.emoticons",{id:"elEmoticons_chatbox",editor:"chatboxForm"})),this.scope.find("#elEmoticons_chatbox").click(function(){u.scope.find("#elChatbox").trigger("contentChange",[D("#elChatbox")]),D(".ipsNavBar_primary").css("zIndex",1e3)}),"ltr"==document.dir?this.scope.find(".bimcb_chatInput").css({"padding-right":D(".cbItems").width()+15+"px"}):this.scope.find(".bimcb_chatInput").css({"padding-left":D(".cbItems").width()+15+"px"}),this.loop(!0)},loop:function(D){var u=this;!0==D&&clearTimeout(u.lmn4);var t=ips.getSetting("chatbox_conf_interval")>1e4?ips.getSetting("chatbox_conf_interval"):1e4;u.getMessages(function(){u.lmn4=setTimeout(function(){u.loop(!0)},t)})},getMessages:function(u){if(this.lmn3||this.lmn1)return!1;if(this.lmn1=!0,1!=ips.getSetting("chatbox_topStyle"))var t=this.lmn7>0?this.lmn7:D("#chatcontent").children().last().attr("id");else var t=this.lmn7>0?this.lmn7:D("#chatcontent").children().first().attr("id");var e=this;ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=getmsg",{dataType:"json",data:{lastID:t||0,loadMoreMode:0}}).done(function(a){if("error"==a.type)ips.ui.alert.show({message:a.message});else if(D("#chatcontent").hasClass("ipsLoading")&&D("#chatcontent").removeClass("ipsLoading"),a.content&&t!=a.lastID){if(1!=ips.getSetting("chatbox_topStyle")){if(D("#chatboxWrap").scrollTop()+D("#chatboxWrap").innerHeight()-D("#chatboxWrap").prop("scrollHeight")>=-30)var i=1;D("#chatcontent").append(e._chatRow(a.content)),"1"==i&&D("#chatcontent img").imagesLoaded(function(u){D("#chatboxWrap").scrollTop(D("#chatboxWrap").prop("scrollHeight"))})}else D("#chatcontent").prepend(e._chatRow(a.content));var n=D("#chatcontent .chat_row").length-ips.getSetting("chatbox_maxMSG");n>0&&D("#chatcontent .chat_row:nth"+(1!=ips.getSetting("chatbox_topStyle")?"":"-last")+"-child(-n+"+n+")").remove(),!ips.getSetting("chatbox_soundEnabled")||e.lmn6||e.lmn2||e.lmn15.play(),e.lmn7=a.lastID,e.lmn6=!1,e.lmn2=!1}e.lmn1=!1,"function"==typeof u&&u()}).fail(function(){e.disconnect()})},loadMore:function(u){if(this.lmn1)return!1;if(this.lmn1=!0,1==ips.getSetting("chatbox_topStyle"))var t=D("#chatcontent").children().last().attr("id");else var t=D("#chatcontent").children().first().attr("id");var e=this;ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=getmsg",{type:"post",dataType:"json",data:{lastID:t||0,loadMoreMode:1}}).done(function(u){if("error"==u.type)ips.ui.alert.show({message:u.message});else if(!0==e.lmn5&&e.connected(),u.content){if(1==ips.getSetting("chatbox_topStyle"))D("#chatcontent").append(e._chatRow(u.content)),D("#chatboxWrap").animate({scrollTop:D("#"+u.lastID).position().top},1e3);else{var t=D("#chatcontent").height()+D("#chatboxWrap").height()-90;D("#chatcontent").prepend(e._chatRow(u.content)),D("#chatcontent img").imagesLoaded(function(u){var e=D("#chatcontent").height();D("#chatboxWrap").animate({scrollTop:e-t},1e3)})}}else ips.ui.alert.show({message:ips.getString("chatbox_error_noolder")});e.lmn1=!1}).fail(function(){e.disconnect()})},disconnect:function(){clearTimeout(self.lmn4);var u=ips.getString("chatbox_disconnect");return this.lmn5=!0,D("#btnConnect").attr("disabled",!1),D("#btnConnect").html(ips.getString("chatbox_reconnect")),D(".cbDisconnect").length||(D(".bimcb_chatArea").hide(),D("#chatcontent").prepend(ips.templates.render("chatbox._disconnected")),D("#chatBoxForm").prepend(ips.templates.render("chatbox._disconnectedMSG",{msg:u,btn:ips.getString("chatbox_reconnect")}))),!1},connect:function(){return D("#btnConnect").attr("disabled",!0),D("#btnConnect").html('<i class="fa fa-refresh fa-spin"></i> '+ips.getString("chatbox_connecting")),this.lmn1=!1,this.loop("true"),!1},connected:function(){return this.lmn5=!1,D(".bimcb_chatArea").show(),D(".cbDisconnect").remove(),D(".cbDisconnectMSG").remove(),!1},chat:function(u){if(this.lmn3)return!1;this.lmn2=!0;var t=this,e=t._escapeHTML(D('[name="txt"]').val());return ips.getSetting("chatbox_maxEmoticons")>0&&t._countEmoticons()>ips.getSetting("chatbox_maxEmoticons")?(ips.ui.alert.show({message:ips.getString("chatbox_error_toomanyemo",{num:ips.getSetting("chatbox_maxEmoticons")})}),!1):(t._toggleForm("off"),ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=chat",{type:"post",dataType:"json",data:{txt:e,csrfKey:ips.getSetting("csrfKey")}}).done(function(u){"error"==u.type?ips.ui.alert.show({message:u.message}):(D('[name="txt"]').val(""),t.loop(!0))}).always(function(){t._toggleForm("on")}),!1)},_chatRow:function(D){for(var u=D.split("~~||~~"),t="",e=0;e<u.length;e++)t+=this._chatDetail(u[e]);return t},_chatDetail:function(D){var u=D.split("~~#~~");if(u[0])var t=ips.templates.render("chatbox.row",{id:u[0],memberID:u[1],memberName:u[2],memberNameFormat:u[3],memberPhoto:u[4],memberUrl:u[5],message:this._parseEmoticonsAndBbcode(u[6]),time:this._getChatTime(u[7]),canEdit:u[8],canDelete:u[9],callme:-1!=u[6].indexOf("@"+ips.getSetting("chatbox_myname"))?1:0});return t},_countEmoticons:function(){var u,t=D('[name="txt"]').val().split(" "),e=0;for(u=0;u<t.length;++u)t[u]in ips.getSetting("chatbox_Emoticons")&&e++;return e},_parseEmoticonsAndBbcode:function(D){var t=this;D=D.replace(/(\r\n|\n|\r)/gm,""),D=(D=(D=t._parseForContent(D)).replace(this.lmn11,function(D){return 0>t.lmn12.indexOf(D)?"twemoji"!=ips.getSetting("emoji_style")?"<span class='chatboxEmoji'>"+D+"</span>":"<img class='chatboxEmoji' src='https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/"+t._emojiUnicode(D)+".png'>":D})).replace("!","&#33;"),u.each(ips.getSetting("chatbox_Emoticons"),function(u,e){for(var a="$1<img src='"+u+"'>$2",i=t._escapeRegex(e),n=RegExp("(^|\\s)"+(i=i.replace("<","&lt;").replace(">","&gt;"))+"(\\s|$)","gi");D.match(n);)D=D.replace(n,a)});var e={},a=0;return u.each(ips.getSetting("badwords"),function(i,n){var o=null,c=null;for(u.isUndefined(i.swop)&&(i.swop="#####"),o=i.m_exact?RegExp("(^|\\b|\\s)"+t._escapeRegex(n)+"(\\b|!|\\?|\\.|,|$)","gi"):RegExp(t._escapeRegex(n),"gi");c=o.exec(D);)null!==c&&(i.m_exact?e["__BW"+a+"__"]=c[1]+i.swop+c[2]:e["__BW"+a+"__"]=i.swop,D=D.replace(c[0],"__BW"+a+"__"),a++)}),u.each(e,function(u,t){D=D.replace(t,u)}),D},_emojiUnicode:function(D){var u;return 1===D.length&&(u=D.charCodeAt(0)),(u=(D.charCodeAt(0)-55296)*1024+(D.charCodeAt(1)-56320)+65536)<0&&(u=D.charCodeAt(0)),u.toString("16")},_escapeRegex:function(D){return this._sRE||(this._sRE=RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\|\\$|\\^)","g")),D.replace(this._sRE,"\\$1")},_escapeHTML:function(D){var u=document.createElement("div");return u.appendChild(document.createTextNode(D)),encodeURIComponent(u.innerHTML)},_parseForContent:function(u){1==ips.getSetting("chatbox_imgPost")&&D.trim(u).match(this.lmn9)&&(u=u.replace(this.lmn9,function(D){return ips.templates.render("chatbox.parsedImage",{url:D})})),1==ips.getSetting("chatbox_videoPost")&&D.trim(u).match(this.lmn10)&&(u=u.replace(this.lmn10,function(D){var u=/embed\//i.test(D)?D.split(/embed\//)[1].split('"')[0]:D.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];return ips.templates.render("chatbox.parsedVideo",{source:"youtube",id:u,img:"https://img.youtube.com/vi/"+u+"/mqdefault.jpg"})}));var t=0,e=this;return u=u.replace(this.lmn8,function(D){var a=u.indexOf(D,t),i=D;return"src='"!==u.substring(a,a-5)&&'srcset="'!==u.substring(a,a-8)&&(i='<a href="'+(D=D.replace(/&amp;/g,"&"))+'" target="_blank" class="chatboxLink" rel="noopener noreferrer">'+e.truncateURL(D,60)+"</a>"),t=a+D.length,i})},truncateURL:function(D,u,t){if(D.length<=u)return D;var e=u-(t=t||"...").length;return D.substr(0,Math.ceil(e/2))+t+D.substr(D.length-Math.floor(e/2))},_toggleForm:function(u){"off"==u?(D('[name="txt"]').prop("disabled",!0),D('[id="chat_button"]').prop("disabled",!0)):(D('[name="txt"]').prop("disabled",!1),D('[id="chat_button"]').prop("disabled",!1),D('[name="txt"]').focus())},_getChatTime:function(D){var u=new Date,t=parseInt(D)?parseInt(D):parseInt(new Date().getTime());u.setTime(1e3*t);var e=u.getHours(),a=u.getMinutes()+"",i=u.getDate(),n=u.getYear(),o=ips.getString("chatbox_month_"+u.getMonth()),c=new Date,s=c.getDate(),r=c.getYear(),l=ips.getString("chatbox_month_"+u.getMonth());return 1==a.length&&(a="0"+a),u=ips.getSetting("chatbox_24h")?e+":"+a:e>12?e-12+":"+a+" "+ips.getString("chatbox_time_pm"):0==e?"12:"+a+" "+ips.getString("chatbox_time_am"):12==e?e+":"+a+" "+ips.getString("chatbox_time_pm"):e+":"+a+" "+ips.getString("chatbox_time_am"),u=i==s&&o==l&&n==r?ips.getString("chatbox_today")+" "+u:i+" "+o+" "+u},editMSG:function(u){u.preventDefault();var t=this,e=D(u.currentTarget).attr("data-id");return this.lmn3?(D("#chatraw_"+e).html(this._parseEmoticonsAndBbcode(D("#editmsg_"+e).val())),D('[data-action="editMSGButton"][data-id="'+e+'"]').html('<i class="fa fa-pencil-square"></i>'),this.lmn3=!1,this._toggleForm("on"),!1):(ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=edit&id="+e,{type:"post",dataType:"json",data:{id:e,csrfKey:ips.getSetting("csrfKey")}}).done(function(u){if("error"==u.type)ips.ui.alert.show({message:u.message});else{var a=ips.templates.render("chatbox.editForm",{id:e,content:u.content});D("#chatraw_"+e).html(a),D('[data-action="editMSGButton"][data-id="'+e+'"]').html(ips.getString("chatbox_cancel")).attr("_title",ips.getString("chatbox_cancel")),t.lmn3=!0,t._toggleForm("off")}}),!1)},saveMSG:function(u,t){if(13==u.which){var e=this,t=t>0?t:D(u.currentTarget).attr("data-id");return ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=saveMSG",{type:"post",dataType:"json",data:{id:t,txt:e._escapeHTML(D("#editmsg_"+t).val()),csrfKey:ips.getSetting("csrfKey")}}).done(function(u){"error"==u.type?ips.ui.alert.show({message:u.message}):(ips.ui.flashMsg.show(u.message),D("#chatraw_"+t).html(e._parseEmoticonsAndBbcode(u.txt)),D('[data-action="editMSGButton"][data-id="'+t+'"]').html('<i class="fa fa-pencil-square"></i>'),e.lmn3=!1,e._toggleForm("on"),e.loop(!0))}),!1}},remove:function(u){if(u.preventDefault(),!confirm(ips.getString("confirmDelete")))return!1;var t=ips.getSetting("baseURL")+"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=delete",e=D(u.currentTarget).attr("data-id");return ips.getAjax()(t,{type:"post",dataType:"json",data:{id:e,csrfKey:ips.getSetting("csrfKey")}}).done(function(u){"error"==u.type?ips.ui.alert.show({message:u.message}):(ips.ui.flashMsg.show(u.message),D("#"+e).remove())}),!1},mention:function(u){u.preventDefault();var t=D(u.currentTarget).attr("data-member"),e=D('[name="txt"]').val()+" @"+t+" ";return D('[name="txt"]').val(e),D('[name="txt"]').focus(),!1},toggleSound:function(u){u.preventDefault(),this.scope.find('[data-action="toggleSound"] .fa').replaceWith(D("<i/>").addClass("fa").addClass(ips.getSetting("chatbox_soundEnabled")?"fa-volume-off":"fa-volume-up").removeClass(ips.getSetting("chatbox_soundEnabled")?"fa-volume-up":"fa-volume-off")),ips.setSetting("chatbox_soundEnabled",!ips.getSetting("chatbox_soundEnabled")),ips.utils.db.set("chatbox","sounds",ips.getSetting("chatbox_soundEnabled"))},playVideoInPopup:function(u){u.preventDefault(),this.stopPlayingVideos();var t=D(u.currentTarget).attr("data-videoSource"),e=D(u.currentTarget).attr("data-videoId");return ips.ui.dialog.create({fixed:!1,size:"medium",url:"index.php?app=bimchatbox&module=chatbox&controller=chatbox&do=playvideo",forceReload:!0,ajax:{type:"post",data:{source:t,id:e}}}).show(),!1},playVideoInIframe:function(u){u.preventDefault(),this.stopPlayingVideos();var t=D(u.currentTarget).closest(".cbVideo"),e="//www.youtube.com/embed/"+D(u.currentTarget).attr("data-videoId")+"?autoplay=1";return t.html(ips.templates.render("chatbox.videoIframe",{play:e})),!1},stopPlayingVideos:function(){D(".cbVideoContainer").each(function(){var u=D(this).find(".cbPlayer");if(0!==u.length){var t=u.attr("src"),e=/embed\//i.test(t)?t.split(/embed\//)[1].split('"')[0]:t.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0],a="//img.youtube.com/vi/"+(e=e.replace("?autoplay=1",""))+"/mqdefault.jpg";D(this).html(ips.templates.render("chatbox.parsedVideo",{source:"youtube",id:e,img:a}))}})},focusChatInput:function(){("cmd"==ips.getSetting("chatbox_giphy")||"both"==ips.getSetting("chatbox_giphy"))&&(this.lmn14=setInterval(u.bind(this.checkTyping,this),700))},blurChatInput:function(){clearInterval(this.lmn14)},checkTyping:function(){var u=D('[name="txt"]').val();if(u!=this.lmn13){if(0!=u.indexOf("/giphy ")){D(".chatboxMedia").is(":visible")&&(D(".chatboxMedia").empty(),D(".chatboxMedia").hide());return}if(this.lmn13=u,0==u.indexOf("/giphy ")&&("cmd"==ips.getSetting("chatbox_giphy")||"both"==ips.getSetting("chatbox_giphy"))){this.cmdMedia("giphy");return}}},cmdMedia:function(u){var t=this,e=t.lmn13.substring(u.length+2);this._ajax&&this._ajax.abort&&this._ajax.abort(),D(".chatboxMedia").is(":visible")||D(".chatboxMedia").show(),D(".chatboxMedia").empty(),D(".chatboxMedia").addClass("ipsLoading"),this._ajax=ips.getAjax()(ips.getSetting("baseURL")+"index.php?app=core&module=system&controller=plugins&do=bimGiphy&editorId=giphyCMD",{data:{q:e},type:"post"}).done(function(u){D(".chatboxMedia").html(u),D(document).trigger("contentChange",[t.scope.find(".chatboxMedia")])}).always(function(){D(".chatboxMedia").removeClass("ipsLoading")})},bimGiphy:function(){var D=ips.getSetting("baseURL")+"index.php?app=core&module=system&controller=plugins&do=bimGiphy&editorId=chatbox",t=ips.utils.db.get("bimgiphy_gif","recent"),e=null;return u.isArray(t)&&(e=JSON.stringify(t)),ips.ui.dialog.create({fixed:!1,size:"medium",title:ips.getString("bim_giphy"),url:D,forceReload:!0,ajax:{type:"post",data:{recent:e}}}).show(),!1}})}(jQuery,_),function(D,u,t){"use strict";ips.controller.mixin("bim.chatbox.free.emoji","core.global.editor.emoticons",!0,function(){this.before("insertEmoji",function(u){if("chatboxForm"==this.editorID){var t=D(u.currentTarget).attr("data-emoji"),e=null;if(t.indexOf("custom-")>=0)e=D(u.currentTarget).find("img").attr("title");else{var a=D(u.currentTarget).find(".ipsEmoji");e=a.attr("src")&&void 0!=a.attr("src")?a.attr("alt"):D(u.currentTarget).find(".ipsEmoji").html()}var i=D('[data-controller="bim.chatbox.free"]').find('[name="txt"]'),n=i.val()+" "+e;i.val(n).focus(),ips.utils.emoji.logUse(t)}}),this.after("setup",function(){if(["ipsappzone.com"].indexOf(document.domain)>-1)return!1;var u="<div id='cbCopyright' class='ipsType ipsType_center ipsType_small ipsType_light ipsPad_half'>";u+="Chatbox "+ips.getSetting("chatbox_version")+" by <a href='https://ipsappzone.com' target=_blank>IpsAppZone</a>",u+="</div>",D('[data-controller="bim.chatbox.manage"]').length&&D('[data-controller="bim.chatbox.manage"]').find("#cbCopyright").length<=0&&D('[data-controller="bim.chatbox.manage"]').append(u),D("#elEmoticons_chatbox_menu").find("#cbCopyright").length<=0&&D("#elEmoticons_chatbox_menu .ipsMenu_footerBar").append(u),D("#cbCopyright").css({display:"block","font-size":"10px",visibility:"visible"})})})}(jQuery,_),ips.templates.set("chatbox.row"," <li class='ipsDataItem chat_row {{#callme}}ipsDataItem_new{{/callme}}' id='{{id}}'>	<div class='ipsPad_half {{#memberPhoto}}ipsPhotoPanel ipsPhotoPanel_tiny{{/memberPhoto}} ipsClearfix'>		{{#memberPhoto}}			<a href='{{memberUrl}}' class='ipsUserPhoto ipsUserPhoto_tiny' id='ips_uid_{{memberID}}'>				<img src='{{memberPhoto}}' alt=''>			</a>		{{/memberPhoto}}		<div>			<a href='#!' data-action='mention' data-member='{{memberName}}'>{{{memberNameFormat}}}</a>			<span class='ipsPos_right'>				<span class='ipsType_small ipsType_light'>{{time}}</span>				{{#canEdit}}<a href='#!' data-action='editMSGButton' data-id='{{id}}'><i class='fa fa-pencil-square'></i></a>{{/canEdit}}				{{#canDelete}}<a href='#!' data-action='remove' data-id='{{id}}'><i class='fa fa-minus-square'></i></a>{{/canDelete}}			</span>			<div class='ipsList_inline' id='chatraw_{{id}}' data-id='{{id}}' {{#canEdit}}data-action='editMSG'{{/canEdit}}>{{{message}}}</div>		</div>	</div></li>"),ips.templates.set("chatbox.parsedImage"," <a href='{{url}}' class='ipsImage ipsThumb_small' data-ipslightbox>	<img src='{{url}}' class='cbImg'></a>"),ips.templates.set("chatbox.parsedVideo"," <div class='cbVideoContainer'>	<div class='cbVideo ipsSpacer_both ipsSpacer_half'>		<img src='{{img}}'>		<a href='#!' data-action='playVideoInIframe' data-videoId='{{id}}'></a>	</div>	<a class='cbVideoPopupOpen' title='{{#lang}}cb_expandPlayer{{/lang}}' data-action='playVideoInPopup' data-videoSource='{{source}}' data-videoId='{{id}}'>		<i class='fa fa-window-maximize' aria-hidden='true'></i>&nbsp;&nbsp;{{#lang}}cb_expandPlayer{{/lang}}	</a></div>"),ips.templates.set("chatbox.videoIframe"," <iframe class='cbPlayer' width='200' height='113' src='{{play}}' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe>"),ips.templates.set("chatbox._disconnected"," <div class='cbDisconnect'></div>"),ips.templates.set("chatbox._disconnectedMSG"," <div class='ipsPad_half ipsType_warning cbDisconnectMSG'><i class='fa fa-exclamation-triangle'></i> {{msg}} <a href='#!' class='ipsButton ipsButton_primary ipsButton_verySmall' id='btnConnect' data-action='connect'>{{btn}}</a></div>"),ips.templates.set("chatbox.editForm"," <textarea type='text' class='bimcb_editform' id='editmsg_{{id}}' data-action='saveMSG' data-id='{{id}}' autocomplete='off'>{{content}}</textarea>");;