"use strict";(function(){ var p;function aa(a){this.id=a;this.version=0}aa.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);this.version=Math.max(this.version,b)};function ba(a){this.mb=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.V=a.category}function ca(){this.a={};this.B=[];this.version=0} ca.prototype.update=function(a,b){a.emoji_use&&(this.a=JSON.parse(a.emoji_use));a.highlight_words?this.B=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.B=a.highlights);this.version=Math.max(this.version,b)};function da(){this.a=null;this.l={};this.h={};this.self=null;this.b={version:0,data:{}};this.i={version:0,data:{}};this.u={};this.$={};this.o=0}function ea(a,b){return b.pv?new t(b.id,a.h[b.user]):new v(b.id)} function fa(a,b,c){var d=d||"";b.team&&(a.a||(a.a=new aa(b.team.id)),a.a.update(b.team,c));if(b.users)for(var e=0,f=b.users.length;ethis.o;)this.a.shift();if(this.i)for(a=0;ab.getTime()?a.toLocaleTimeString():a.getTime()>c.getTime()?"hier, "+ a.toLocaleTimeString():a.toLocaleString()},ya:function(a,b){return a+"/"+b},c:{fileUploadCancel:"Annuler",neterror:"Impossible de se connecter au chat !",ctxMenuSettings:"Configuration",settingTitle:"Configuration","setting-menu-services":"Services","settings-services-title":"Services","setting-menu-display":"Affichage","settings-display-title":"Affichage","setting-menu-privacy":"Vie priv\u00e9e","settings-privacy-title":"Vie priv\u00e9e",settingCommit:"Appliquer","settings-serviceAddButton":"Ajouter un service", "settings-serviceListEmpty":"Vous n'avez pas encore ajout\u00e9 de service. Ajouter un service pour continuer.","settings-serviceAddConfirm":"Suivant"}};M.fr.ab=function(a){return 0===a?"Pas de message \u00e9pingl\u00e9":a+(1===a?" message \u00e9pingl\u00e9":" messages \u00e9pingl\u00e9s")};M.fr.hb=function(a){return 0===a?"Pas de chatteur":a+(1===a?" chatteur":" chatteurs")};M.fr.F=function(a){return"(edité "+M.fr.O(a)+")"};M.fr.Ca=function(a,b){return"par "+a.getName()+" le "+M.fr.O(b)};M.en={Ab:"Unknown member",zb:"Unknown channel",Za:"New message",message:"Message",Ya:"Network",$a:"(only visible to you)",A:"Starred",l:"Channels",la:"Members",eb:"Direct messages",gb:"Share your GPS location",ok:"Ok",Sa:"Cancel",O:function(a){"string"!==typeof a&&(a=parseFloat(a));var b=new Date,c=new Date;a=new Date(a);b.setHours(0,0,0,0);c.setTime(b.getTime());c.setDate(c.getDate()-1);return a.getTime()>b.getTime()?a.toLocaleTimeString():a.getTime()>c.getTime()?"yesterday, "+a.toLocaleTimeString(): a.toLocaleString()},ya:function(a,b){return a+"/"+b},c:{fileUploadCancel:"Cancel",neterror:"Cannot connect to chat !",ctxMenuSettings:"Settings",settingTitle:"Settings","setting-menu-services":"Services","settings-services-title":"Services","setting-menu-display":"Display","settings-display-title":"Display","setting-menu-privacy":"Privacy","settings-privacy-title":"Privacy",settingCommit:"Apply","settings-serviceAddButton":"Add a service","settings-serviceListEmpty":"You don't have any service yet. Please add a service to continue.", "settings-serviceAddConfirm":"Next"}};M.en.ab=function(a){return 0===a?"No pinned messages":a+(1===a?" pinned message":" pinned messages")};M.en.hb=function(a){return 0===a?"No users in this room":a+(1===a?" user":" users")};M.en.F=function(a){return"(edited "+M.en.O(a)+")"};M.en.Ca=function(a,b){return"by "+a.getName()+" on "+M.en.O(b)};var wa=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.Y=c;this.f=null;this.j=[];this.a=d||"";this.ta="<"===this.a;this.Aa="*"===this.a;this.sa="_"===this.a;this.ua="~"===this.a||"-"===this.a;this.i=">"===this.a||">"===this.a;this.J=":"===this.a;this.Da="`"===this.a;this.Oa="```"===this.a;this.Ea="\n"===this.a;this.ra=void 0!==d&&-1!==m.B.indexOf(d);this.g=b;this.va=null;this.b=this.Ea||this.ra?c+d.length-1:!1;this.ra&&(this.f=new a(this),this.j.push(this.f),this.f.text=d)} function c(a){return"A"<=a&&"Z">=a||"a"<=a&&"z">=a||"0"<=a&&"9">=a||-1!=="\u00e0\u00e8\u00ec\u00f2\u00f9\u00c0\u00c8\u00cc\u00d2\u00d9\u00e1\u00e9\u00ed\u00f3\u00fa\u00fd\u00c1\u00c9\u00cd\u00d3\u00da\u00dd\u00e2\u00ea\u00ee\u00f4\u00fb\u00c2\u00ca\u00ce\u00d4\u00db\u00e3\u00f1\u00f5\u00c3\u00d1\u00d5\u00e4\u00eb\u00ef\u00f6\u00fc\u00ff\u00c4\u00cb\u00cf\u00d6\u00dc\u0178\u00e7\u00c7\u00df\u00d8\u00f8\u00c5\u00e5\u00c6\u00e6\u0153".indexOf(a)}function d(a){a=a||h;for(var c=0,e=a.j.length;c"===k[a])return!0;var b=c(k[a-1]);if(!this.i&&k.substr(a,this.a.length)===this.a){if(!b&&(this.Aa||this.sa||this.ua))return!1;if(this.f&&this.La())return this.f.Pa();if(this.jb())return!0}return"\n"===k[a]&&this.i?!0:!1};b.prototype.jb=function(){for(var a=this;a;){for(var c=0,d=a.j.length;c"===k[b])return k[b]}if("`"===k[b]&&!d|| "\n"===k[b]||!(-1===["*","~","-","_"].indexOf(k[b])||!e&&void 0!==k[b+1]&&-1==="*~-_<&".split("").indexOf(k[b+1])||d&&void 0!==k[b-1]&&-1==="*~-_<&".split("").indexOf(k[b-1]))||-1!==[":"].indexOf(k[b])&&e||-1!==["<"].indexOf(k[b]))return k[b];d=0;for(e=m.B.length;d=a&&(this.b=!1);this.j.forEach(function(c){c instanceof b&&c.ba(a)})};a.prototype.innerHTML=function(){if(this.g.ea()){for(var a=this.g;a&&!a.J;)a=a.g;if(a){var a=a.a+this.text+a.a,b=m.aa(a);return b?b:a}return(a=m.aa(this.text))?a:this.text}if(this.g.da()){if("undefined"!==typeof hljs)try{return a=this.text.match(/^\w+/),hljs.configure({useBR:!0, tabReplace:"      "}),a&&hljs.getLanguage(a[0])?hljs.fixMarkup(hljs.highlight(a[0],this.text.substr(a[0].length)).value):hljs.fixMarkup(hljs.highlightAuto(this.text).value)}catch(q){console.error(q)}return this.text.replace(/\n/g,"
")}return m.pa(this.text)};a.prototype.outerHTML=function(){var a="span",b=[],c="";if(this.g.da()){a="pre";b.push("codeblock");var d=this.innerHTML()}else this.g.Ha()?(b.push("code"),d=this.innerHTML()):(this.g.ta&&(d=m.ka(this.text))? (a="a",c=' href="'+d.link+'"',d.Va||(c+=' target="_blank"'),d=m.pa(d.text)):d=this.innerHTML(),this.g.Ga()&&b.push("bold"),this.g.Ja()&&b.push("italic"),this.g.Ka()&&b.push("strike"),this.g.ea()&&b.push("emoji"),this.g.Ia()&&b.push("highlight"));return"<"+a+c+(b.length?' class="'+b.join(" ")+'"':"")+">"+d+""};b.prototype.outerHTML=function(){var a="";this.i&&(a+='');this.Ea&&(a+="
");this.j.forEach(function(b){a+=b.outerHTML()});this.i&&(a+="
");return a};b.prototype.Na= function(a){this.i&&!this.b&&this.Fa(a);this.j.forEach(function(c){c instanceof b&&c.Na(a)})};return function(c,l){l||(l={});m.B=l.B||[];m.aa=l.aa||f;m.pa=l.pa||f;m.ka=l.ka||g;k=c;h=new b(this,0);l=0;c=k.length;do{for(;la.C&&(b.classList.add("unread"),b.classList.add("unreadHi"));b=k=b}b&&(a.A?c.push(k):f.push(k))}else if(k=g[a.id],b=document.createElement("li"),n=document.createElement("a"),b.id="room_"+a.id,n.href="#"+a.id,a.i?(b.className="chat-context-room chat-group",b.dataset.count= Object.keys(a.h||{}).length):b.className="chat-context-room chat-channel",O===a&&b.classList.add("selected"),n.textContent=k||a.name,b.appendChild(Pa()),b.appendChild(n),a.R>a.C&&(b.classList.add("unread"),0<=P.indexOf(a)&&b.classList.add("unreadHi")),k=b)a.A?c.push(k):a.i?e.push(k):d.push(k)});c.length&&a.appendChild(Qa(N.A));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(Qa(N.l));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});f.length&&a.appendChild(Qa(N.eb)); f.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);Ra.apply(document.getElementById("chanSearch"));Sa();Ta();Q&&Ua(Q.a.id,Q.h,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"})} function Va(){ra(function(a){var b=a.u,c;for(c in a.self.l)if(!a.self.l[c].fa){var d=document.getElementById("room_"+c);b[c]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing")}for(var e in a.h)(c=a.h[e].W)&&!c.fa&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing"))});Wa()} function Wa(){var a;document.getElementById("whoistyping").textContent="";if(Q&&O&&(a=Q.u[O.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=L(d))?b.appendChild(Xa(a)):c=!0;c&&(I.b=0);document.getElementById("whoistyping").appendChild(b)}}function Ya(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");Ta()} function Za(){var a=O.name||(O.a?O.a.getName():void 0);if(!a){console.error("No name provided for ",O);var a=[],b;for(b in O.h)a.push(O.h[b].getName());a=a.join(", ")}document.getElementById("currentRoomTitle").textContent=a;$a();R();document.getElementById("fileUploadContainer").classList.add("hidden");ab();S&&(S=null,T());U&&(U=null,T());Ta();Wa()} function T(){if(S){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){S=null;T()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(S.I())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";R()} function bb(){if(U){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){U=null;bb()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(U.I());document.getElementById("msgInput").value=U.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";R()} window.toggleReaction=function(a,b,c){var d=I.a[a],e,f;(d=I.a[a])&&(e=ma(d,b))&&(f=K(I.context,a))&&(e.D[c]&&-1!==e.D[c].indexOf(f.self.id)?(d=new XMLHttpRequest,d.open("DELETE","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0),d.send(null)):cb(a,b,c))}; function db(a){a:{var b={};if(Q)for(var c=Q;!b[a];){if(c=c.b.data[a])if("alias:"==c.substr(0,6))b[a]=!0,a=c.substr(6);else{a=document.createElement("span");a.className="emoji-custom emoji";a.style.backgroundImage="url('"+c+"')";break a}break}}"string"===typeof a&&"makeEmoji"in window&&(a=window.makeEmoji(a));return"string"===typeof a?null:a}function eb(a,b){document.getElementById("linkFavicon").href=a||b?"favicon.png?h="+a+"&m="+b:"favicon_ok.png"} function Ta(){var a=P.length,b="";if(V)b="!"+N.Ya+" - Mimouchat",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+")",eb(a,a);else{var c=0;qa(I.context,function(a){a.R>a.C&&c++});c&&(b="("+c+")");eb(0,c)}!b.length&&O&&(b=O.name);document.title=b.length?b:"Mimouchat"} function fb(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(Na+3E4Math.abs(d-b.m)&&!(b instanceof B)?e.classList.add("chatmsg-same-ts"):d=b.m:(d=b.m,g=!0);(!c||c.m<=O.C)&&b.m>O.C?k.classList.add("chatmsg-first-unread"):k.classList.remove("chatmsg-first-unread"); if(b instanceof B)e=c=null,d=0,a.appendChild(k),f=null;else{if(g||!f){var g=L(b.N),m=b.username,n=document.createElement("div"),l=document.createElement("div"),q=document.createElement("a"),u=document.createElement("img");n.ga=document.createElement("span");n.ga.className="chatmsg-author-img-wrapper";u.className="chatmsg-author-img";q.className="chatmsg-author-name";q.href="#"+g.id;g?(q.textContent=g.getName(),u.src="api/avatar?user="+g.id):(q.textContent=m||"?",u.src="");n.ga.appendChild(u);l.appendChild(n.ga); l.appendChild(q);l.className="chatmsg-author";n.className="chatmsg-authorGroup";n.appendChild(l);n.content=document.createElement("div");n.content.className="chatmsg-author-messages";n.appendChild(n.content);f=n;Ma.push(f);a.appendChild(f)}c=b;e=k;f.content.appendChild(k)}}});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;gb();window.hasFocus&&ab()} function hb(a,b){if(a.classList.contains("chatmsg-hover-reply"))U&&(U=null,bb()),S!==b&&(S=b,T());else if(a.classList.contains("chatmsg-hover-reaction")){var c=O.id,d=b.id;ib.oa(document.body,Q,function(a){a&&cb(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(S&&(S=null,T()),U!==b&&(U=b,bb())):a.classList.contains("chatmsg-hover-star")?b.A?jb(b):kb(b):a.classList.contains("chatmsg-hover-pin")?b.pinned?lb(O,b):mb(b):a.classList.contains("chatmsg-hover-remove")&&(S&&(S=null,T()),U&&(U=null, bb()),nb(b))} function ob(a){function b(a,b){for(b=b||a.target;b!==a.currentTarget&&b;){if(b.id&&b.classList.contains("chatmsg-item"))return b.id;b=b.parentElement}}for(var c=a.target;c!==a.currentTarget&&c&&!c.classList.contains("chatmsg-hover");){var d;if(c.parentElement&&c.classList.contains("chatmsg-attachment-actions-item")){var e=c.dataset.attachmentIndex,f=c.dataset.actionIndex;if((d=b(a,c))&&void 0!==e&&void 0!==f){d=d.substr(d.lastIndexOf("_")+1);(a=ma(I.a[O.id],d))&&a.s[e]&&a.s[e].actions&&a.s[e].actions[f]&& pb(a,a.s[e],a.s[e].actions[f]);break}}if(c.parentElement&&c.parentElement.classList.contains("chatmsg-hover")){if(d=b(a,c))d=d.substr(d.lastIndexOf("_")+1),(a=ma(I.a[O.id],d))&&hb(c,a);break}c=c.parentElement}} function pb(a,b,c){function d(){var d={actions:[c],attachment_id:b.id,callback_id:b.callback_id,channel_id:e,is_ephemeral:a instanceof D,message_ts:a.id},g=new XMLHttpRequest;g.open("POST","api/attachmentAction?serviceId="+a.N);g.send(JSON.stringify(d))}var e=O.id;c.confirm?La(Ka(new xa(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).oa():d()}function R(){document.getElementById("msgInput").focus()} function gb(){var a=document.getElementById("chatWindow").getBoundingClientRect().top;Ma.forEach(function(b){var c=b.ga,d=c.clientHeight;b=b.getBoundingClientRect();c.style.top=Math.max(0,Math.min(a-b.top,b.height-d-d/2))+"px"})} function qb(a){var b=document.getElementById("slashList");b.dataset.cursor&&delete b.dataset.cursor;var c=[];var d=a.value;if("/"===a.value[0]){var e=d.indexOf(" "),f=-1!==e,e=-1===e?d.length:e;d=d.substr(0,e);if(f){var g=rb.Ua(d);g&&c.push(g)}else c=rb.nb(d),b.dataset.cursor=JSON.stringify([0,a.selectionEnd]);var g=Q?Q.i.data:{};for(n in g){var k=g[n];(!f&&k.name.substr(0,e)===d||f&&k.name===d)&&c.push(k)}}c.sort(function(a,b){return a.V.localeCompare(b.V)||a.name.localeCompare(b.name)});if(!c.length&& a.selectionStart===a.selectionEnd&&a.selectionStart){e=a.selectionStart;for(f=a.selectionEnd;e&&" "!==a.value[e-1];e--);for(d=a.value.length;f=d.length&&h[m].name.substr(0,d.length)===d&&c.push(h[m])}else if("@"===a.value[e])for(m in h=O instanceof t?Q.h:O.h,d=a.value.substr(e+1,f-e-1),h)a=h[m].getName(),a.length>=d.length&&a.substr(0,d.length)===d&&c.push(h[m]);else if(":"=== a.value[e]&&0=d.length&&m.substr(0,d.length)===d&&(h=document.createElement("span"),a=document.createElement("span"),h.className="emoji-small",a.className="emoji emoji-small emoji-custom",a.style.backgroundImage='url("'+Q.b.data[m]+'")', h.appendChild(a),c.push({name:":"+m+":",ha:h,ma:"custom"}))}c.length&&(b.dataset.cursor=JSON.stringify([e,f]))}}b.textContent="";if(c.length){d=document.createDocumentFragment();m=0;for(h=c.length;m=a.latitude&&-180<=a.longitude&&180>=a.longitude){var b=0,c=function(a,b,c,d){return new Promise(function(e,f){var g=new Image;g.addEventListener("load",function(){d.P=g;e(d)});g.addEventListener("error",function(){console.warn("Error loading tile ",{zoom:a,x:b,y:c});f(g)});g.crossOrigin="anonymous";g.src="https://c.tile.openstreetmap.org/"+a+"/"+b+"/"+c+".png"})},d=document.createElement("canvas"),e=document.createElement("canvas"); d.height=d.width=e.height=e.width=300;var f=d.getContext("2d"),g=e.getContext("2d"),k=function(a,b,c){a=a*Math.PI/180;b=b*Math.PI/180;c=c*Math.PI/180;return Math.abs(6371E3*Math.acos(Math.pow(Math.sin(a),2)+Math.pow(Math.cos(a),2)*Math.cos(c-b)))},h=function(a,d,e,h){g.fillStyle="#808080";g.fillRect(0,0,300,300);f.fillStyle="#808080";f.fillRect(0,0,300,300);var n=Math.pow(2,a),l=(e+180)/360*n,m=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*n,q=Math.floor(l),H=Math.floor(m), ia=h?100*h/k(180/Math.PI*Math.atan(.5*(Math.exp(Math.PI-2*Math.PI*H/n)-Math.exp(-(Math.PI-2*Math.PI*H/n)))),q/n*360-180,(q+1)/n*360-180):0;d=b;for(e=0;3>e;e++)for(h=0;3>h;h++)c(a,q+e-1,H+h-1,{rb:e,ub:h,ib:d}).then(function(a){if(a.ib===b){g.drawImage(a.P,100*a.rb,100*a.ub,100,100);a=l-q;var c=m-H;a=100*a+100;c=100*c+100;f.putImageData(g.getImageData(0,0,300,300),0,0);void 0!==ia&&(f.beginPath(),f.arc(a,c,Math.max(ia,10),0,2*Math.PI,!1),f.lineWidth=2,f.fillStyle="rgba(244, 146, 66, 0.4)",f.strokeStyle= "rgba(244, 146, 66, 0.8)",f.stroke(),f.fill());if(void 0===ia||25b.bottom||a.screenXb.right)&&c()});n.className="emojibar-overlay";m.className= "emojibar";l.className="emojibar-emojis";q.className=u.className="emojibar-list";A.className="emojibar-search";J.className="emojibar-detail";F.className="emojibar-detail-img";C.className="emojibar-detail-name";J.appendChild(F);J.appendChild(C);b();m.appendChild(l);m.appendChild(J);m.appendChild(A);A.addEventListener("keyup",function(){e()});m.addEventListener("mousemove",function(b){a(b,function(a){var b=a?w[a]||y[a]:null;b?(F.innerHTML=b.c.outerHTML,C.textContent=":"+a+":"):(F.textContent="",C.textContent= "")})});m.addEventListener("click",function(b){a(b,function(a){a&&d()&&r&&r(a)})});return{isSupported:h,oa:function(a,b,c){return h()?(G=b,r=c,a.appendChild(n),a.appendChild(m),A.value="",e(),A.focus(),!0):!1},search:e,close:c,reset:function(){b();e()}}}();var I,P=[];function Gb(){da.call(this)}Gb.prototype=Object.create(da.prototype);Gb.prototype.constructor=Gb;function pa(a){return a.a?a.a.id:null}function Hb(){this.b=0;this.context=new na;this.a={}} Hb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(h in a["static"]){var c=oa(this.context,h);c||(c=new Gb,this.context.push(c));var d={};a["static"][h].channels&&a["static"][h].channels.forEach(function(a){a.pins&&(d[a.id]=a.pins,a.pins=void 0)});fa(c,a["static"][h],b);for(var e in d){var f=[],g=this.a[e];g||(g=this.a[e]=new Y(e,250,null,b));d[e].forEach(function(a){f.push(g.b(a,b))});c.l[e].b=f}}qa(this.context,function(a){a.R===a.C&&(a=P.indexOf(a),-1!==a&&P.splice(a, 1))});if(a.live){for(h in a.live)(c=this.a[h])?ja(c,a.live[h],b):c=this.a[h]=new Y(h,250,a.live[h],b);for(var k in a.live){var h=K(this.context,k);(c=h.l[k])?(this.a[k].a.length&&(c.R=Math.max(c.R,la(this.a[k]).m)),c.fa||(Ib(h,c,a.live[k]),O&&a.live[O.id]&&$a())):I.b=0}}a["static"]&&Oa();var m=!1;a.typing&&this.context.a.forEach(function(c){var d=m,e=a.typing,f=!1;if(c.u)for(var g in c.u)e[g]||(delete c.u[g],f=!0);if(e)for(g in e)if(c.l[g]){c.u[g]||(c.u[g]={});for(var h in e[g])c.u[g][h]||(f=!0), c.u[g][h]=b}m=d|f},this);(a["static"]||m)&&Va();a.config&&(Jb=new Kb(a.config),Lb()&&wb.yb(!1).display(wb.vb.T),Ab(Mb()));if(Q&&O&&a["static"]&&a["static"][Q.a.id]&&a["static"][Q.a.id].channels&&a["static"][Q.a.id].channels)for(k=a["static"][Q.a.id].channels,h=0,c=k.length;ha.C){var c=I.a[a.id];if(c&&(c=c.a[c.a.length-1])){var d=new XMLHttpRequest;d.open("POST","api/markread?room="+a.id+"&id="+c.id+"&ts="+c.m,!0);d.send(null);a.C=c.m}}0<=b&&(P.splice(b,1),Ta());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}I=new Hb;var Ua=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;ed/(c.height*c.width))for(e=0;eI.a[O.id].a.length)&&Nb();document.getElementById("chatSystemContainer").classList.remove("no-room-selected")} function Sa(){var a=document.location.hash.substr(1),b=sa(a);b&&b!==O?Qb(b):(a=L(a))&&a.W&&Qb(a.W)}function xb(a,b,c){var d=O;new FileReader;var e=new FormData,f=new XMLHttpRequest;e.append("file",b);e.append("filename",a);f.onreadystatechange=function(){4===f.readyState&&(204===f.status?c(null):c(f.statusText))};f.open("POST","api/file?room="+d.id);f.send(e)} function Rb(a,b,c){var d=new XMLHttpRequest;b="api/msg?room="+a.id+"&text="+encodeURIComponent(b);c&&(b+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:c.text,author_name:L(c.N).getName(),text:c.text,footer:a.i?N.message:a.name,ts:c.m}])));d.open("POST",b,!0);d.send(null)} function yb(a){if(U){var b=new XMLHttpRequest;b.open("PUT","api/msg?room="+O.id+"&ts="+U.id+"&text="+encodeURIComponent(a),!0);b.send(null);return!0}if("/"===a[0]){var c=a.indexOf(" "),b=a.substr(0,-1===c?void 0:c);a=-1===c?"":a.substr(c);var c=Q,d=rb.Ua(b);return d?(d.exec(c,O,a.trim()),!0):c&&(b=c.i.data[b])?(c=new XMLHttpRequest,c.open("POST","api/cmd?room="+O.id+"&cmd="+encodeURIComponent(b.name.substr(1))+"&args="+encodeURIComponent(a.trim()),!0),c.send(null),!0):!1}Rb(O,a,S);return!0} function nb(a){var b=new XMLHttpRequest;b.open("DELETE","api/msg?room="+O.id+"&ts="+a.id,!0);b.send(null)}function mb(a){var b=new XMLHttpRequest;b.open("POST","api/pinMsg?room="+O.id+"&msgId="+a.id,!0);b.send(null)}function kb(a){var b=new XMLHttpRequest;b.open("POST","api/starMsg?room="+O.id+"&msgId="+a.id,!0);b.send(null)}function lb(a,b){var c=new XMLHttpRequest;c.open("DELETE","api/pinMsg?room="+a.id+"&msgId="+b.id,!0);c.send(null)} function jb(a){var b=new XMLHttpRequest;b.open("DELETE","api/starMsg?room="+O.id+"&msgId="+a.id,!0);b.send(null)}function cb(a,b,c){var d=new XMLHttpRequest;d.open("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c),!0);d.send(null)} function Ra(){var a={},b=[],c=this.value;qa(I.context,function(b){a[b.id]=ga(b,c)});for(var d in a){var e=document.getElementById("room_"+d);e&&(a[d].name+a[d].la+a[d].qa+a[d].na?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var X={emojione_v2_3:{Wa:"emojione_v2.3.sprites.js",Qa:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Wa:"emojione_v3.sprites.js",Qa:"emojione_v3.sprites.css",name:"Emojione v3"}},Sb=X.emojione_v2_3,sb; function Tb(a){if(sb!==a){console.log("Loading emoji pack "+a.name);var b=new XMLHttpRequest;b.timeout=6E4;b.onreadystatechange=function(){if(4===b.readyState){var c=document.createElement("script"),d=document.createElement("link");c.innerHTML=b.response;c.language="text/javascript";d.href=a.Qa;d.rel="stylesheet";document.head.appendChild(d);document.body.appendChild(c);var c=document.getElementById("emojiButton"),e;for(e in I.a)Ub(I.a[e]);O&&$a();ib.reset();"makeEmoji"in window?(e=window.makeEmoji("smile"))? c.innerHTML=""+e.outerHTML+"":c.style.backgroundImage='url("smile.svg")':c.classList.add("hidden")}};b.open("GET",a.Wa,!0);b.send(null);sb=a}}function Ab(a){Tb(a&&X[a]?X[a]:Sb)};var W=function(){function a(){c();r instanceof t?(f.style.backgroundImage="url(api/avatar?size=l&user="+r.a.id+")",m.textContent=(r.a.fb||(r.a.Ta||"")+" "+r.a.Xa).trim(),g.classList.add("presence-indicator"),r.a.L?g.classList.remove("presence-away"):g.classList.add("presence-away"),h.classList.remove("hidden"),l.classList.remove("hidden"),l.textContent=r.a.wb||"",u.textContent=r.a.ob||"",q.classList.remove("hidden"),e.classList.remove("roominfo-channel"),e.classList.add("roominfo-user")):b()}function b(){var a= C;a.$.topic?(h.classList.remove("hidden"),m.textContent=r.qa||"",n.textContent=r.J?N.Ca(r.J,r.ea):""):h.classList.add("hidden");a.$.purpose?(q.classList.remove("hidden"),u.textContent=r.na||"",A.textContent=r.o?N.Ca(r.o,r.da):""):q.classList.add("hidden");f.style.backgroundImage="";g.classList.remove("presence-indicator");J.textContent=N.hb(r.h?Object.keys(r.h).length:0);a=[];if(r.h)for(var b in r.h)a.push(r.h[b]);a.sort(function(a,b){return a.L&&!b.L?-1:b.L&&!a.L?1:a.getName().localeCompare(b.getName())}); var c=document.createDocumentFragment();a.forEach(function(a){var b=document.createElement("li"),d=document.createElement("a");d.href="#"+a.id;d.textContent=a.getName();b.appendChild(d);b.classList.add("presence-indicator");a.L||b.classList.add("presence-away");c.appendChild(b)});F.textContent="";F.appendChild(c);e.classList.add("roominfo-channel");e.classList.remove("roominfo-user")}function c(){g.textContent=r.name;if(r.b){w.textContent=N.ab(r.b.length);w.classList.remove("hidden");y.classList.remove("hidden"); var a=document.createDocumentFragment();r.b.forEach(function(b){var c=document.createElement("li"),e=document.createElement("a");e.href="javascript:void(0)";e.dataset.msgId=b.id;e.addEventListener("click",d);e.className=Ea+" roominfo-unpin";c.className="roominfo-pinlist-item";c.appendChild(b.I());c.appendChild(e);a.appendChild(c)});y.textContent="";y.appendChild(a)}else w.classList.add("hidden"),y.classList.add("hidden")}function d(){if(r.b)for(var a=0,b=r.b.length;a