Ver Fonte

[bugfix] self may not be initialized
[add] show instantaneously your message (displaying ... next to the message you are trying to send)
[bugfix] type=file messages do not contains message section and caused problems
[bugfix] keep a typing version

B Thibault há 8 anos atrás
pai
commit
18532c8a79

+ 14 - 2
cli/data.js

@@ -187,7 +187,8 @@ function isHighlighted(ctx, text) {
 **/
 function onMsgReceived(ctx, chan, msg) {
     if (chan !== SELECTED_ROOM || !window.hasFocus) {
-        var selfReg = new RegExp("<@" +ctx.self.id), // FIXME remove context id
+        var selfId = ctx.self ? ctx.self.id : null,
+            selfReg = selfId ? new RegExp("<@" +selfId) : null, // FIXME remove context id
             highligted = false,
             areNew = false,
             newHighlited = false;
@@ -198,7 +199,7 @@ function onMsgReceived(ctx, chan, msg) {
             }
             if (i["user"] !== ctx.self.id) {
                 areNew = true;
-                if (chan instanceof PrivateMessageRoom || (i["text"] && (i["text"].match(selfReg) || isHighlighted(ctx, i["text"])))) {
+                if (chan instanceof PrivateMessageRoom || (i["text"] && ((selfReg && i["text"].match(selfReg)) || isHighlighted(ctx, i["text"])))) {
                     if (HIGHLIGHTED_CHANS.indexOf(chan) === -1) {
                         newHighlited = true;
                         HIGHLIGHTED_CHANS.push(chan);
@@ -221,6 +222,17 @@ function onMsgReceived(ctx, chan, msg) {
             }
         }
     }
+    msg.forEach(function(m) {
+        if (!selfId || selfId === m.userId) {
+            for (var i =0, nbPending = PENDING_MESSAGES.length; i < nbPending; i++) {
+                var current = PENDING_MESSAGES[i];
+                if (current.channel === chan.id && m["text"] && m["text"].trim() === current.text && !!m["isMeMessage"] === current.isMe) {
+                    PENDING_MESSAGES.splice(i, 1);
+                    return;
+                }
+            }
+        }
+    });
 }
 
 /**

+ 6 - 5
cli/dom.js

@@ -227,11 +227,10 @@ function addHoverButtons(hover, msg) {
 }
 
 /**
- * @param {UiMessage|UiMeMessage|UiNoticeMessage} msg
+ * @param {UiMessage|UiMeMessage|UiNoticeMessage|null} msg
  * @return {Element}
 **/
 function doCreateMessageDom(msg) {
-    var channelId = msg.channelId;
     var dom = document.createElement("div")
         ,msgBlock = document.createElement("div")
         ,hoverReaction = document.createElement("li");
@@ -243,14 +242,16 @@ function doCreateMessageDom(msg) {
     dom.textDom = document.createElement("div");
     dom.authorName = document.createElement("span");
 
-    dom.id = channelId +"_" +msg.id;
     dom.className = R.klass.msg.item;
     dom.ts.className = R.klass.msg.ts;
     dom.textDom.className = R.klass.msg.msg;
     dom.authorName.className = R.klass.msg.authorname;
 
-    addHoverButtons(dom.hover, msg);
-    dom.hover.className = R.klass.msg.hover.container;
+    if (msg) {
+        dom.id = msg.channelId +"_" +msg.id;
+        addHoverButtons(dom.hover, msg);
+        dom.hover.className = R.klass.msg.hover.container;
+    }
 
     msgBlock.appendChild(dom.authorName);
     msgBlock.appendChild(dom.textDom);

+ 13 - 2
cli/msgInput.js

@@ -194,18 +194,29 @@ function onTextEntered(input, skipCommand) {
             cliCmdObject = CLIENT_COMMANDS.getCommand(cmd);
 
         if (cliCmdObject) {
-            cliCmdObject.exec(ctx, SELECTED_ROOM, args.trim());
+            args = args.trim();
+            cliCmdObject.exec(ctx, SELECTED_ROOM, args);
             return true;
         } else if (ctx) {
             var cmdObject = ctx.getChatContext().commands.data[cmd];
 
             if (cmdObject) {
-                doCommand(SELECTED_ROOM, cmdObject, args.trim());
+                if (cmdObject.name === "/me") {
+                    displayTmpMessage(SELECTED_ROOM, args, true);
+                } else if (cmdObject.name === "/msg") {
+                    args = args.trim();
+                    var argParts = (/(\S+)\s+(.*)/).exec(args),
+                        chan = SELECTED_CONTEXT.getRoom(argParts[1]);
+                    if (chan)
+                        displayTmpMessage(chan, argParts[2], false);
+                }
+                doCommand(SELECTED_ROOM, cmdObject, args);
                 return true;
             }
         }
         return false;
     }
+    displayTmpMessage(SELECTED_ROOM, input, false);
     sendMsg(SELECTED_ROOM, input, REPLYING_TO);
     return true;
 }

+ 1 - 0
cli/resources.js

@@ -134,6 +134,7 @@ var R = {
         },
         msg: {
             item: "chatmsg-item",
+            pending: "chatmsg-pending",
             notice: "chatmsg-notice",
             firstUnread: "chatmsg-first-unread",
             content: "chatmsg-content",

+ 27 - 1
cli/ui.js

@@ -56,7 +56,6 @@ function onContextUpdated() {
                         priv.push(chanListItem);
                 }
             }
-            //FIXME else remove
         } else {
             if ((chanListItem = createChanListItem(chan, chanNames[chan.id]))) {
                 if (chan.starred)
@@ -357,6 +356,17 @@ function onRoomUpdated() {
                 msg.removeDom();
             }
         });
+    var isFirstPending = true;
+    PENDING_MESSAGES.forEach(function(msg) {
+        if (msg.channel === SELECTED_ROOM.id) {
+            if (isFirstPending) {
+                currentMsgGroupDom = createMessageGroupDom(SELECTED_CONTEXT.self, "");
+                chatFrag.appendChild(currentMsgGroupDom);
+                isFirstPending = false;
+            }
+            currentMsgGroupDom.content.appendChild(msg.dom);
+        }
+    });
     var content = document.getElementById(R.id.currentRoom.content);
     //TODO lazy add dom if needed
     content.textContent = "";
@@ -418,6 +428,22 @@ function onMsgClicked(target, msg) {
     }
 }
 
+/**
+ * @param {Room} channel
+ * @param {string} input
+ * @param {boolean} isMeMessage
+**/
+function displayTmpMessage(channel, input, isMeMessage) {
+    PENDING_MESSAGES.push({
+        channel: channel.id,
+        text: input.trim(),
+        isMe: isMeMessage,
+        dom: createTmpMsgDom(input, isMeMessage)
+    });
+    if (channel === SELECTED_ROOM)
+        onRoomUpdated();
+}
+
 function chatClickDelegate(e) {
     var target = e.target,
         getMessageId = function(e, target) {

+ 44 - 0
cli/uiMessage.js

@@ -452,3 +452,47 @@ UiNoticeMessage.prototype.update = function(ev, ts) {
     this.invalidate();
 };
 
+/**
+ * @param {string} input
+ * @param {boolean} isMe
+ * @return {Element}
+**/
+function createTmpMsgDom(input, isMe) {
+    var dom = doCreateMessageDom(null),
+        sender = SELECTED_CONTEXT.self;
+
+    dom.classList.add(R.klass.msg.pending);
+    if (isMe)
+        dom.classList.add(R.klass.msg.meMessage);
+    dom.textDom.innerHTML = formatText(input, {
+        emojiFormatFunction: function(emoji) {
+            if (emoji[0] === ':' && emoji[emoji.length -1] === ':')
+                emoji = emoji.substr(1, emoji.length -2);
+            var emojiDom = makeEmojiDom(emoji);
+            if (emojiDom) {
+                var domParent = document.createElement("span");
+                domParent.className = R.klass.emoji.small;
+                domParent.appendChild(emojiDom);
+                return domParent.outerHTML;
+            }
+            return null;
+        }
+    });
+    dom.authorName.textContent = SELECTED_CONTEXT.self ? SELECTED_CONTEXT.self.getName() : "";
+
+    var dot = document.createElement("span");
+    dot.className = R.klass.typing.dot1;
+    dot.textContent = '.';
+    dom.ts.appendChild(dot);
+    dot = document.createElement("span");
+    dot.className = R.klass.typing.dot2;
+    dot.textContent = '.';
+    dom.ts.appendChild(dot);
+    dot = document.createElement("span");
+    dot.className = R.klass.typing.dot3;
+    dot.textContent = '.';
+    dom.ts.appendChild(dot);
+    dom.ts.classList.add(R.klass.typing.container);
+    return dom;
+}
+

+ 4 - 1
cli/workflow.js

@@ -23,7 +23,10 @@ var
     EDITING = null,
 
     /** @const @type {number} */
-    KEEP_MESSAGES = 100
+    KEEP_MESSAGES = 100,
+
+    /** @type {Array<{channel: string, text: string, isMe: boolean, dom: Element}>} */
+    PENDING_MESSAGES = []
 ;
 
 function initHljs() {

+ 137 - 132
srv/public/mimouchat.min.js

@@ -1,137 +1,142 @@
 "use strict";(function(){
-var q;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.nb=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.i={};this.self=null;this.b={version:0,data:{}};this.h={version:0,data:{}};this.u={};this.$={};this.m=0}function ea(a,b){return b.pv?new u(b.id,a.i[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;e<f;e++){var h=a.i[d+b.users[e].id];h||(h=a.i[d+b.users[e].id]=new ga(b.users[e].id));h.update(b.users[e],c)}if(b.channels)for(e=0,f=b.channels.length;e<f;e++)(h=a.l[d+b.channels[e].id])||(h=a.l[d+b.channels[e].id]=ea(a,b.channels[e])),h.update(b.channels[e],a,c,d);b.emojis&&(a.b.data=b.emojis,a.b.version=c);if(void 0!==b.commands){a.h.data={};for(e in b.commands)a.h.data[e]=
-new ba(b.commands[e]);a.h.version=c}b.self&&(a.self=a.i[d+b.self.id]||null,a.self.S||(a.self.S=new ca),b.self.prefs&&a.self.S.update(b.self.prefs,c));b.capacities&&(a.$={},b.capacities.forEach(function(a){this.$[a]=!0},a));a.m=Math.max(a.m,c)}"undefined"!==typeof module&&(module.J.Cb=da,module.J.Db=aa,module.J.Fb=ba);function v(a){this.id=a;this.A=!1;this.C=0;this.i={};this.version=0}function ha(a,b,c){if(!a.I||a.I<b)a.I=b,a.version=c}
+var q;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.ob=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.W=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.j={};this.i={};this.self=null;this.b={version:0,data:{}};this.h={version:0,data:{}};this.u={};this.aa={};this.o=0}function ea(a,b){return b.pv?new t(b.id,a.i[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;e<f;e++){var h=a.i[d+b.users[e].id];h||(h=a.i[d+b.users[e].id]=new ga(b.users[e].id));h.update(b.users[e],c)}if(b.channels)for(e=0,f=b.channels.length;e<f;e++)(h=a.j[d+b.channels[e].id])||(h=a.j[d+b.channels[e].id]=ea(a,b.channels[e])),h.update(b.channels[e],a,c,d);b.emojis&&(a.b.data=b.emojis,a.b.version=c);if(void 0!==b.commands){a.h.data={};for(e in b.commands)a.h.data[e]=
+new ba(b.commands[e]);a.h.version=c}b.self&&(a.self=a.i[d+b.self.id]||null,a.self.T||(a.self.T=new ca),b.self.prefs&&a.self.T.update(b.self.prefs,c));b.capacities&&(a.aa={},b.capacities.forEach(function(a){this.aa[a]=!0},a));a.o=Math.max(a.o,c)}"undefined"!==typeof module&&(module.J.Db=da,module.J.Eb=aa,module.J.Gb=ba);function v(a){this.id=a;this.A=!1;this.C=0;this.i={};this.version=0}function ha(a,b,c){if(!a.I||a.I<b)a.I=b,a.version=c}
 v.prototype.update=function(a,b,c,d){d=d||"";void 0!==a.name&&(this.name=a.name);void 0!==a.is_archived&&(this.fa=a.is_archived);void 0!==a.is_member&&(this.ba=a.is_member);void 0!==a.last_read&&(this.C=Math.max(parseFloat(a.last_read),this.C));void 0!==a.last_msg&&(this.I=parseFloat(a.last_msg));void 0!==a.is_private&&(this.h=a.is_private);void 0!==a.pins&&(this.b=a.pins);this.A=!!a.is_starred;if(a.members&&(this.i={},a.members))for(var e=0,f=a.members.length;e<f;e++){var h=b.i[d+a.members[e]];this.i[h.id]=
-h;h.l[this.id]=this}a.topic&&(this.qa=a.topic.value,this.G=b.i[d+a.topic.creator],this.ea=a.topic.last_set);a.purpose&&(this.na=a.purpose.value,this.m=b.i[d+a.purpose.creator],this.da=a.purpose.last_set);this.version=Math.max(this.version,c)};function ia(a,b){var c=ja;return{name:c.ia(b,a.name),la:c.ia(b,Object.values(a.i),function(a){return a?a.getName():null}),qa:c.ia(b,a.qa),na:c.ia(b,a.na)}}function u(a,b){v.call(this,a);this.a=b;this.name=b.getName();this.h=!0;b.W=this}u.prototype=Object.create(v.prototype);
-u.prototype.constructor=u;"undefined"!==typeof module&&(module.J.Lb=v,module.J.Kb=u);function y(a,b){this.O=a.user;this.username=a.username;this.id=a.id||a.ts;this.o=parseFloat(a.ts);this.text="";this.s=[];this.A=a.is_starred||!1;this.h=this.F=!1;this.D={};this.version=b;this.update(a,b)}function A(a,b){y.call(this,a,b)}function B(a,b){y.call(this,a,b)}
-y.prototype.update=function(a,b){if(a){if(this.text=a.text||"",a.attachments&&(this.s=a.attachments),this.A=!!a.is_starred,this.F=void 0===a.edited?!1:a.edited,this.h=!!a.removed,a.reactions){var c={};a.reactions.forEach(function(a){c[a.name]=[];a.users.forEach(function(b){c[a.name].push(b)})});this.D=c}}else this.h=!0;this.version=b};function ka(a,b,c,d,e){this.id="string"===typeof a?a:a.id;this.a=[];this.h=c;this.jb=0;this.m=b;d&&la(this,d,e)}
-function la(a,b,c){var d=0;b.forEach(function(a){d=Math.max(this.push(a,c),d)}.bind(a));ma(a);return d}ka.prototype.b=function(a,b){return!0===a.isMeMessage?new A(a,b):!0===a.isNotice?new B(a,b):new y(a,b)};
-ka.prototype.push=function(a,b){for(var c,d=!1,e,f=0,h=this.a.length;f<h;f++)if(c=this.a[f],c.id===a.id){e=c.update(a,b);d=!0;break}d||(c=this.b(a,b),this.a.push(c),e=c.o);for(;this.a.length>this.m;)this.a.shift();if(this.h)for(a=0;a<this.a.length;a++)this.a[a].version<b-this.h&&this.a.splice(a--,1);return e||0};function oa(a){return a.a[a.a.length-1]}function pa(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].id==b)return a.a[c];return null}
-function ma(a){a.a.sort(function(a,c){return a.o-c.o})}A.prototype=Object.create(y.prototype);A.prototype.constructor=A;B.prototype=Object.create(y.prototype);B.prototype.constructor=B;"undefined"!==typeof module&&(module.J={Hb:y,Gb:A,Jb:B,Mb:ka});function ga(a){this.id=a;this.l={};this.W=this.S=null;this.version=0}
-ga.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.Ta=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.goal&&(this.pb=a.goal);void 0!==a.phone&&(this.xb=a.phone);void 0!==a.first_name&&(this.Va=a.first_name);void 0!==a.last_name&&(this.Ya=a.last_name);void 0!==a.real_name&&(this.gb=a.real_name);void 0!==a.isPresent&&(this.M=a.isPresent);a.isBot&&(this.tb=a.isBot);this.version=Math.max(this.version,b)};
-function qa(a){return"api/avatar?user="+a.id}ga.prototype.getName=function(){return this.name||this.gb||this.Va||this.Ya};"undefined"!==typeof module&&(module.J.Eb=ga);function ra(){this.a=[]}ra.prototype.push=function(a){this.a.push(a)};function sa(a,b){for(var c=0,d=a.a.length;c<d;c++)if(b===ta(a.a[c]))return a.a[c];return null}function ua(a,b){for(var c=0,d=a.a.length;c<d;c++){var e=a.a[c],f;for(f in e.l)if(!0===b(e.l[f],f))return}}function va(a){for(var b=C.context,c=0,d=b.a.length;c<d&&!0!==a(b.a[c]);c++);}function D(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].l[b])return a.a[c];return null}
-function wa(a){for(var b=C.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].l[a];if(e)return e}return null}function xa(a){for(var b=C.context,c=[],d=0,e=b.a.length;d<e;d++){var f=b.a[d].l,h;for(h in f)a&&!a(f[h],b.a[d],h)||c.push(h)}return c}function F(a){for(var b=C.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].i[a];if(e)return e}return null}"undefined"!==typeof module&&(module.J.Ib=ra);var ja=function(){function a(b,c,d){if(Array.isArray(c)){for(var e=0,f=0,h=c.length;f<h;f++){var k=a(b,c[f],d);if(1===k)return 1;e=Math.max(k,e)}return e}return(c=d?d(c):c)&&void 0!==b&&null!==b?b.length?-1===c.indexOf(b)?0:b.length/c.length:1:0}return{ia:a}}();"undefined"!==typeof module&&(module.J.Nb=ja);var G={},J,ya=[];function za(){if(!c){for(var a=0,b=navigator.languages.length;a<b;a++)if(G.hasOwnProperty(navigator.languages[a])){var c=navigator.languages[a];break}c||(c="en")}J=G[c];console.log("Loading language pack: "+c);if(J.c)for(var d in J.c)if(c=document.getElementById(d))c.textContent=J.c[d];ya.forEach(function(a){a()})};G.fr={Bb:"Utilisateur inconnu",Ab:"Channel inconnu",$a:"Nouveau message",message:"Message",Za:"Reseau",ab:"(visible seulement par vous)",A:"Favoris",l:"Discutions",la:"Membres",fb:"Discutions priv\u00e9es",hb:"Partage sa position GPS",ok:"Ok",Ua:"Annuler",P: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()?"hier, "+
-a.toLocaleTimeString():a.toLocaleString()},ya:function(a,b){return a+"/"+b},c:{fileUploadCancel:"Annuler",neterror:"Impossible de se connecter au chat !",ctxMenuSettings:"Configuration",ctxMenuLogout:"D\u00e9connexion",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","settings-displayEmojiProviderLbl":"Gestionnaire d'emojis","settings-displayDisplayAvatarLbl":"Afficher les avatars","settings-displayColorfulNamesLbl":"Afficher les nomes en couleur"}};G.fr.bb=function(a){return 0===a?"Pas de message \u00e9pingl\u00e9":a+(1===a?" message \u00e9pingl\u00e9":" messages \u00e9pingl\u00e9s")};
-G.fr.ib=function(a){return 0===a?"Pas de chatteur":a+(1===a?" chatteur":" chatteurs")};G.fr.F=function(a){return"(edit&eacute; "+G.fr.P(a)+")"};G.fr.Ea=function(a,b){return"par "+a.getName()+" le "+G.fr.P(b)};G.en={Bb:"Unknown member",Ab:"Unknown channel",$a:"New message",message:"Message",Za:"Network",ab:"(only visible to you)",A:"Starred",l:"Channels",la:"Members",fb:"Direct messages",hb:"Share your GPS location",ok:"Ok",Ua:"Cancel",P: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",ctxMenuLogout:"Logout",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","settings-displayEmojiProviderLbl":"Emoji provider","settings-displayDisplayAvatarLbl":"Display avatars","settings-displayColorfulNamesLbl":"Colorful names"}};G.en.bb=function(a){return 0===a?"No pinned messages":a+(1===a?" pinned message":" pinned messages")};G.en.ib=function(a){return 0===a?"No users in this room":a+(1===a?" user":" users")};G.en.F=function(a){return"(edited "+G.en.P(a)+")"};G.en.Ea=function(a,b){return"by "+a.getName()+" on "+G.en.P(b)};var Aa=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.Ca="*"===this.a;this.sa="_"===this.a;this.ua="~"===this.a||"-"===this.a;this.h=">"===this.a||"&gt;"===this.a;this.G=":"===this.a;this.Fa="`"===this.a;this.Qa="```"===this.a;this.Ga="\n"===this.a;this.ra=void 0!==d&&-1!==p.B.indexOf(d);this.g=b;this.va=null;this.b=this.Ga||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||n;for(var c=0,e=a.j.length;c<e;c++){var f=
-a.j[c];if(f instanceof b)if(f.b){if(f=d(f))return f}else return f}return null}function e(a,c){a.g instanceof b&&(a.g.j.splice(a.g.j.indexOf(a)+(c?1:0)),a.g.f=a.g.j[a.g.j.length-1],e(a.g,!0))}function f(a){return a.replace("<","&lt;")}function h(a){return a}function k(a){return{link:a,text:a,Xa:!1}}var g,n,p={B:[],aa:h,pa:h,ka:k};b.prototype.Ia=function(){return this.Ca&&!!this.b||this.g instanceof b&&this.g.Ia()};b.prototype.La=function(){return this.sa&&!!this.b||this.g instanceof b&&this.g.La()};
-b.prototype.Ma=function(){return this.ua&&!!this.b||this.g instanceof b&&this.g.Ma()};b.prototype.ea=function(){return this.G&&!!this.b||this.g instanceof b&&this.g.ea()};b.prototype.Ka=function(){return this.ra&&!!this.b||this.g instanceof b&&this.g.Ka()};b.prototype.Ja=function(){return this.Fa&&!!this.b||this.g instanceof b&&this.g.Ja()};b.prototype.da=function(){return this.Qa&&!!this.b||this.g instanceof b&&this.g.da()};b.prototype.Na=function(){for(var a=0,c=this.j.length;a<c;a++)if(this.j[a]instanceof
-b&&(!this.j[a].b||this.j[a].Na()))return!0;return!1};b.prototype.Oa=function(a){if("<"===this.a&&">"===g[a])return!0;var b=c(g[a-1]);if(!this.h&&g.substr(a,this.a.length)===this.a){if(!b&&(this.Ca||this.sa||this.ua))return!1;if(this.f&&this.Na())return this.f.Ra();if(this.kb())return!0}return"\n"===g[a]&&this.h?!0:!1};b.prototype.kb=function(){for(var a=this;a;){for(var c=0,d=a.j.length;c<d;c++)if(a.j[c]instanceof b||a.j[c].text.length)return!0;a=a.va}return!1};b.prototype.Ra=function(){var a=new b(this.g,
-this.Y,this.a);a.va=this;this.f&&this.f instanceof b&&(a.f=this.f.Ra(),a.j=[a.f]);return a};b.prototype.lb=function(a){return this.G&&(" "===g[a]||"\t"===g[a])||(this.G||this.ta||this.Ca||this.sa||this.ua||this.Fa)&&"\n"===g[a]?!1:!0};b.prototype.mb=function(b){if(this.Fa||this.G||this.Qa||this.ta)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(g[b-1]),e=c(g[b+1]);if("```"===g.substr(b,3))return"```";var f=n.Ba();if(void 0===f||f){if("&gt;"===g.substr(b,4))return"&gt;";if(">"===g[b])return g[b]}if("`"===
-g[b]&&!d||"\n"===g[b]||!(-1===["*","~","-","_"].indexOf(g[b])||!e&&void 0!==g[b+1]&&-1==="*~-_<&".split("").indexOf(g[b+1])||d&&void 0!==g[b-1]&&-1==="*~-_<&".split("").indexOf(g[b-1]))||-1!==[":"].indexOf(g[b])&&e||-1!==["<"].indexOf(g[b]))return g[b];d=0;for(e=p.B.length;d<e;d++)if(f=p.B[d],g.substr(b,f.length)===f)return f}return null};a.prototype.Ba=function(){if(""!==this.text.trim())return!1};b.prototype.Ba=function(){for(var a=this.j.length-1;0<=a;a--){var b=this.j[a].Ba();if(void 0!==b)return b}if(this.Ga||
-this.h)return!0};a.prototype.m=function(a){this.text+=g[a];return 1};b.prototype.m=function(c){var d=this.f&&!this.f.b&&this.f.Oa?this.f.Oa(c):null;if(d){var e=this.f.a.length;this.f.Ha(c);d instanceof b&&(this.f=d,this.j.push(d));return e}if(!this.f||this.f.b||this.f instanceof a||this.f.lb(c)){if(d=this.mb(c))return this.f=new b(this,c,d),this.j.push(this.f),this.f.a.length;if(!this.f||this.f.b)this.f=new a(this),this.j.push(this.f);return this.f.m(c)}d=this.f.Y+1;n.ba(this.f.Y);this.f=new a(this);
-this.f.m(d-1);this.j.pop();this.j.push(this.f);return d-c};b.prototype.Ha=function(a){for(var b=this;b;)b.b=a,b=b.va};b.prototype.ba=function(a){this.b&&this.b>=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.G;)a=a.g;if(a){var a=a.a+this.text+a.a,b=p.aa(a);return b?b:a}return(a=p.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:"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"}),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(t){console.error(t)}return this.text.replace(/\n/g,"<br/>")}return p.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.Ja()?(b.push("code"),d=this.innerHTML()):(this.g.ta&&(d=p.ka(this.text))?
-(a="a",c=' href="'+d.link+'"',d.style&&(c+=' style="'+d.style+'"'),d.Xa||(c+=' target="_blank"'),d.Sa&&d.Sa.forEach(function(a){b.push(a)}),d=p.pa(d.text)):d=this.innerHTML(),this.g.Ia()&&b.push("bold"),this.g.La()&&b.push("italic"),this.g.Ma()&&b.push("strike"),this.g.ea()&&b.push("emoji"),this.g.Ka()&&b.push("highlight"));return"<"+a+c+(b.length?' class="'+b.join(" ")+'"':"")+">"+d+"</"+a+">"};b.prototype.outerHTML=function(){var a="";this.h&&(a+='<span class="quote">');this.Ga&&(a+="<br/>");this.j.forEach(function(b){a+=
-b.outerHTML()});this.h&&(a+="</span>");return a};b.prototype.Pa=function(a){this.h&&!this.b&&this.Ha(a);this.j.forEach(function(c){c instanceof b&&c.Pa(a)})};return function(c,m){m||(m={});p.B=m.B||[];p.aa=m.aa||h;p.pa=m.pa||f;p.ka=m.ka||k;g=c;n=new b(this,0);m=0;c=g.length;do{for(;m<c;)m+=n.m(m);n.Pa(g.length);if(m=d()){e(m,!1);n.ba(m.Y);var l=new a(m.g);l.m(m.Y);m.g.j.push(l);m.g.f=l;m=m.Y+1}else m=void 0}while(void 0!==m);return n.outerHTML()}}();"undefined"!==typeof module&&(module.J.w=Aa);function K(a,b){this.a=new XMLHttpRequest;this.G=b||a;this.method=b?a:"GET";this.a.onreadystatechange=function(){4===this.a.readyState&&(2===Math.floor(this.a.status/100)?Ba(this.m,this.a.status,this.a.statusText,this.a.response):Ba(this.h,this.a.status,this.a.statusText,this.a.response),Ba(this.b,this.a.status,this.a.statusText,this.a.response))}.bind(this)}function Ba(a,b,c,d){a&&a.forEach(function(a){a(b,c,d)})}function Ca(a,b){a.b||(a.b=[]);a.b.push(b);return a}
-function Da(a,b){a.m||(a.m=[]);a.m.push(b);return a}function Ea(a,b){a.h||(a.h=[]);a.h.push(b);return a}function Fa(a){a.a.timeout=6E4;return a}function Ga(a,b){a.a.responseType=b;return a}function N(a,b){a.a.open(a.method,a.G,!0);a.a.send(b)};function Ha(a,b){this.title=a;this.content=b;this.c=Ia(this);this.b=Ja(this);this.a=[];this.h=[]}
+h;h.j[this.id]=this}a.topic&&(this.sa=a.topic.value,this.G=b.i[d+a.topic.creator],this.ea=a.topic.last_set);a.purpose&&(this.oa=a.purpose.value,this.o=b.i[d+a.purpose.creator],this.da=a.purpose.last_set);this.version=Math.max(this.version,c)};function ia(a,b){var c=ja;return{name:c.ja(b,a.name),ma:c.ja(b,Object.values(a.i),function(a){return a?a.getName():null}),sa:c.ja(b,a.sa),oa:c.ja(b,a.oa)}}function t(a,b){v.call(this,a);this.a=b;this.name=b.getName();this.h=!0;b.O=this}t.prototype=Object.create(v.prototype);
+t.prototype.constructor=t;"undefined"!==typeof module&&(module.J.Mb=v,module.J.Lb=t);function w(a,b){this.K=a.user;this.username=a.username;this.id=a.id||a.ts;this.m=parseFloat(a.ts);this.text="";this.s=[];this.A=a.is_starred||!1;this.h=this.F=!1;this.D={};this.version=b;this.update(a,b)}function z(a,b){w.call(this,a,b)}function B(a,b){w.call(this,a,b)}
+w.prototype.update=function(a,b){if(a){if(this.text=a.text||"",a.attachments&&(this.s=a.attachments),this.A=!!a.is_starred,this.F=void 0===a.edited?!1:a.edited,this.h=!!a.removed,a.reactions){var c={};a.reactions.forEach(function(a){c[a.name]=[];a.users.forEach(function(b){c[a.name].push(b)})});this.D=c}}else this.h=!0;this.version=b};function ka(a,b,c,d,e){this.id="string"===typeof a?a:a.id;this.a=[];this.h=c;this.kb=0;this.o=b;d&&la(this,d,e)}
+function la(a,b,c){var d=0;b.forEach(function(a){d=Math.max(this.push(a,c),d)}.bind(a));ma(a);return d}ka.prototype.b=function(a,b){return!0===a.isMeMessage?new z(a,b):!0===a.isNotice?new B(a,b):new w(a,b)};
+ka.prototype.push=function(a,b){for(var c,d=!1,e,f=0,h=this.a.length;f<h;f++)if(c=this.a[f],c.id===a.id){e=c.update(a,b);d=!0;break}d||(c=this.b(a,b),this.a.push(c),e=c.m);for(;this.a.length>this.o;)this.a.shift();if(this.h)for(a=0;a<this.a.length;a++)this.a[a].version<b-this.h&&this.a.splice(a--,1);return e||0};function na(a){return a.a[a.a.length-1]}function oa(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].id==b)return a.a[c];return null}
+function ma(a){a.a.sort(function(a,c){return a.m-c.m})}z.prototype=Object.create(w.prototype);z.prototype.constructor=z;B.prototype=Object.create(w.prototype);B.prototype.constructor=B;"undefined"!==typeof module&&(module.J={Ib:w,Hb:z,Kb:B,Nb:ka});function ga(a){this.id=a;this.j={};this.O=this.T=null;this.version=0}
+ga.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.Ua=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.goal&&(this.qb=a.goal);void 0!==a.phone&&(this.yb=a.phone);void 0!==a.first_name&&(this.Wa=a.first_name);void 0!==a.last_name&&(this.Za=a.last_name);void 0!==a.real_name&&(this.hb=a.real_name);void 0!==a.isPresent&&(this.N=a.isPresent);a.isBot&&(this.ub=a.isBot);this.version=Math.max(this.version,b)};
+function pa(a){return"api/avatar?user="+a.id}ga.prototype.getName=function(){return this.name||this.hb||this.Wa||this.Za};"undefined"!==typeof module&&(module.J.Fb=ga);function ra(){this.a=[]}ra.prototype.push=function(a){this.a.push(a)};function sa(a,b){for(var c=0,d=a.a.length;c<d;c++)if(b===ta(a.a[c]))return a.a[c];return null}function ua(a,b){for(var c=0,d=a.a.length;c<d;c++){var e=a.a[c],f;for(f in e.j)if(!0===b(e.j[f],f))return}}function va(a){for(var b=C.context,c=0,d=b.a.length;c<d&&!0!==a(b.a[c]);c++);}function D(a,b){for(var c=0,d=a.a.length;c<d;c++)if(a.a[c].j[b])return a.a[c];return null}
+function wa(a){for(var b=C.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].j[a];if(e)return e}return null}function xa(a){for(var b=C.context,c=[],d=0,e=b.a.length;d<e;d++){var f=b.a[d].j,h;for(h in f)a&&!a(f[h],b.a[d],h)||c.push(h)}return c}function F(a){for(var b=C.context,c=0,d=b.a.length;c<d;c++){var e=b.a[c].i[a];if(e)return e}return null}ra.prototype.Ba=function(a){for(var b=0,c=this.a.length;b<c;b++)if(this.a[b].self.id===a)return!0;return!1};"undefined"!==typeof module&&(module.J.Jb=ra);var ja=function(){function a(b,c,d){if(Array.isArray(c)){for(var e=0,f=0,h=c.length;f<h;f++){var k=a(b,c[f],d);if(1===k)return 1;e=Math.max(k,e)}return e}return(c=d?d(c):c)&&void 0!==b&&null!==b?b.length?-1===c.indexOf(b)?0:b.length/c.length:1:0}return{ja:a}}();"undefined"!==typeof module&&(module.J.Ob=ja);var G={},J,ya=[];function za(){if(!c){for(var a=0,b=navigator.languages.length;a<b;a++)if(G.hasOwnProperty(navigator.languages[a])){var c=navigator.languages[a];break}c||(c="en")}J=G[c];console.log("Loading language pack: "+c);if(J.c)for(var d in J.c)if(c=document.getElementById(d))c.textContent=J.c[d];ya.forEach(function(a){a()})};G.fr={Cb:"Utilisateur inconnu",Bb:"Channel inconnu",ab:"Nouveau message",message:"Message",$a:"Reseau",bb:"(visible seulement par vous)",A:"Favoris",j:"Discutions",ma:"Membres",gb:"Discutions priv\u00e9es",ib:"Partage sa position GPS",ok:"Ok",Va:"Annuler",R: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()?"hier, "+
+a.toLocaleTimeString():a.toLocaleString()},za:function(a,b){return a+"/"+b},c:{fileUploadCancel:"Annuler",neterror:"Impossible de se connecter au chat !",ctxMenuSettings:"Configuration",ctxMenuLogout:"D\u00e9connexion",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","settings-displayEmojiProviderLbl":"Gestionnaire d'emojis","settings-displayDisplayAvatarLbl":"Afficher les avatars","settings-displayColorfulNamesLbl":"Afficher les nomes en couleur"}};G.fr.cb=function(a){return 0===a?"Pas de message \u00e9pingl\u00e9":a+(1===a?" message \u00e9pingl\u00e9":" messages \u00e9pingl\u00e9s")};
+G.fr.jb=function(a){return 0===a?"Pas de chatteur":a+(1===a?" chatteur":" chatteurs")};G.fr.F=function(a){return"(edit&eacute; "+G.fr.R(a)+")"};G.fr.Fa=function(a,b){return"par "+a.getName()+" le "+G.fr.R(b)};G.en={Cb:"Unknown member",Bb:"Unknown channel",ab:"New message",message:"Message",$a:"Network",bb:"(only visible to you)",A:"Starred",j:"Channels",ma:"Members",gb:"Direct messages",ib:"Share your GPS location",ok:"Ok",Va:"Cancel",R: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()},za:function(a,b){return a+"/"+b},c:{fileUploadCancel:"Cancel",neterror:"Cannot connect to chat !",ctxMenuSettings:"Settings",ctxMenuLogout:"Logout",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","settings-displayEmojiProviderLbl":"Emoji provider","settings-displayDisplayAvatarLbl":"Display avatars","settings-displayColorfulNamesLbl":"Colorful names"}};G.en.cb=function(a){return 0===a?"No pinned messages":a+(1===a?" pinned message":" pinned messages")};G.en.jb=function(a){return 0===a?"No users in this room":a+(1===a?" user":" users")};G.en.F=function(a){return"(edited "+G.en.R(a)+")"};G.en.Fa=function(a,b){return"by "+a.getName()+" on "+G.en.R(b)};var Aa=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.Z=c;this.f=null;this.l=[];this.a=d||"";this.va="<"===this.a;this.Ea="*"===this.a;this.ua="_"===this.a;this.wa="~"===this.a||"-"===this.a;this.h=">"===this.a||"&gt;"===this.a;this.G=":"===this.a;this.Ga="`"===this.a;this.Ra="```"===this.a;this.Ha="\n"===this.a;this.ta=void 0!==d&&-1!==p.B.indexOf(d);this.g=b;this.xa=null;this.b=this.Ha||this.ta?c+d.length-1:!1;this.ta&&(this.f=new a(this),this.l.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||m;for(var c=0,e=a.l.length;c<e;c++){var f=
+a.l[c];if(f instanceof b)if(f.b){if(f=d(f))return f}else return f}return null}function e(a,c){a.g instanceof b&&(a.g.l.splice(a.g.l.indexOf(a)+(c?1:0)),a.g.f=a.g.l[a.g.l.length-1],e(a.g,!0))}function f(a){return a.replace("<","&lt;")}function h(a){return a}function k(a){return{link:a,text:a,Ya:!1}}var g,m,p={B:[],X:h,ra:h,la:k};b.prototype.Ja=function(){return this.Ea&&!!this.b||this.g instanceof b&&this.g.Ja()};b.prototype.Ma=function(){return this.ua&&!!this.b||this.g instanceof b&&this.g.Ma()};
+b.prototype.Na=function(){return this.wa&&!!this.b||this.g instanceof b&&this.g.Na()};b.prototype.ea=function(){return this.G&&!!this.b||this.g instanceof b&&this.g.ea()};b.prototype.La=function(){return this.ta&&!!this.b||this.g instanceof b&&this.g.La()};b.prototype.Ka=function(){return this.Ga&&!!this.b||this.g instanceof b&&this.g.Ka()};b.prototype.da=function(){return this.Ra&&!!this.b||this.g instanceof b&&this.g.da()};b.prototype.Oa=function(){for(var a=0,c=this.l.length;a<c;a++)if(this.l[a]instanceof
+b&&(!this.l[a].b||this.l[a].Oa()))return!0;return!1};b.prototype.Pa=function(a){if("<"===this.a&&">"===g[a])return!0;var b=c(g[a-1]);if(!this.h&&g.substr(a,this.a.length)===this.a){if(!b&&(this.Ea||this.ua||this.wa))return!1;if(this.f&&this.Oa())return this.f.Sa();if(this.lb())return!0}return"\n"===g[a]&&this.h?!0:!1};b.prototype.lb=function(){for(var a=this;a;){for(var c=0,d=a.l.length;c<d;c++)if(a.l[c]instanceof b||a.l[c].text.length)return!0;a=a.xa}return!1};b.prototype.Sa=function(){var a=new b(this.g,
+this.Z,this.a);a.xa=this;this.f&&this.f instanceof b&&(a.f=this.f.Sa(),a.l=[a.f]);return a};b.prototype.mb=function(a){return this.G&&(" "===g[a]||"\t"===g[a])||(this.G||this.va||this.Ea||this.ua||this.wa||this.Ga)&&"\n"===g[a]?!1:!0};b.prototype.nb=function(b){if(this.Ga||this.G||this.Ra||this.va)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(g[b-1]),e=c(g[b+1]);if("```"===g.substr(b,3))return"```";var f=m.Da();if(void 0===f||f){if("&gt;"===g.substr(b,4))return"&gt;";if(">"===g[b])return g[b]}if("`"===
+g[b]&&!d||"\n"===g[b]||!(-1===["*","~","-","_"].indexOf(g[b])||!e&&void 0!==g[b+1]&&-1==="*~-_<&".split("").indexOf(g[b+1])||d&&void 0!==g[b-1]&&-1==="*~-_<&".split("").indexOf(g[b-1]))||-1!==[":"].indexOf(g[b])&&e||-1!==["<"].indexOf(g[b]))return g[b];d=0;for(e=p.B.length;d<e;d++)if(f=p.B[d],g.substr(b,f.length)===f)return f}return null};a.prototype.Da=function(){if(""!==this.text.trim())return!1};b.prototype.Da=function(){for(var a=this.l.length-1;0<=a;a--){var b=this.l[a].Da();if(void 0!==b)return b}if(this.Ha||
+this.h)return!0};a.prototype.o=function(a){this.text+=g[a];return 1};b.prototype.o=function(c){var d=this.f&&!this.f.b&&this.f.Pa?this.f.Pa(c):null;if(d){var e=this.f.a.length;this.f.Ia(c);d instanceof b&&(this.f=d,this.l.push(d));return e}if(!this.f||this.f.b||this.f instanceof a||this.f.mb(c)){if(d=this.nb(c))return this.f=new b(this,c,d),this.l.push(this.f),this.f.a.length;if(!this.f||this.f.b)this.f=new a(this),this.l.push(this.f);return this.f.o(c)}d=this.f.Z+1;m.ba(this.f.Z);this.f=new a(this);
+this.f.o(d-1);this.l.pop();this.l.push(this.f);return d-c};b.prototype.Ia=function(a){for(var b=this;b;)b.b=a,b=b.xa};b.prototype.ba=function(a){this.b&&this.b>=a&&(this.b=!1);this.l.forEach(function(c){c instanceof b&&c.ba(a)})};a.prototype.innerHTML=function(){if(this.g.ea()){for(var a=this.g;a&&!a.G;)a=a.g;if(a){var a=a.a+this.text+a.a,b=p.X(a);return b?b:a}return(a=p.X(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:"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"}),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(u){console.error(u)}return this.text.replace(/\n/g,"<br/>")}return p.ra(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.Ka()?(b.push("code"),d=this.innerHTML()):(this.g.va&&(d=p.la(this.text))?
+(a="a",c=' href="'+d.link+'"',d.style&&(c+=' style="'+d.style+'"'),d.Ya||(c+=' target="_blank"'),d.Ta&&d.Ta.forEach(function(a){b.push(a)}),d=p.ra(d.text)):d=this.innerHTML(),this.g.Ja()&&b.push("bold"),this.g.Ma()&&b.push("italic"),this.g.Na()&&b.push("strike"),this.g.ea()&&b.push("emoji"),this.g.La()&&b.push("highlight"));return"<"+a+c+(b.length?' class="'+b.join(" ")+'"':"")+">"+d+"</"+a+">"};b.prototype.outerHTML=function(){var a="";this.h&&(a+='<span class="quote">');this.Ha&&(a+="<br/>");this.l.forEach(function(b){a+=
+b.outerHTML()});this.h&&(a+="</span>");return a};b.prototype.Qa=function(a){this.h&&!this.b&&this.Ia(a);this.l.forEach(function(c){c instanceof b&&c.Qa(a)})};return function(c,n){n||(n={});p.B=n.B||[];p.X=n.X||h;p.ra=n.ra||f;p.la=n.la||k;g=c;m=new b(this,0);n=0;c=g.length;do{for(;n<c;)n+=m.o(n);m.Qa(g.length);if(n=d()){e(n,!1);m.ba(n.Z);var l=new a(n.g);l.o(n.Z);n.g.l.push(l);n.g.f=l;n=n.Z+1}else n=void 0}while(void 0!==n);return m.outerHTML()}}();"undefined"!==typeof module&&(module.J.w=Aa);function K(a,b){this.a=new XMLHttpRequest;this.G=b||a;this.method=b?a:"GET";this.a.onreadystatechange=function(){4===this.a.readyState&&(2===Math.floor(this.a.status/100)?Ba(this.o,this.a.status,this.a.statusText,this.a.response):Ba(this.h,this.a.status,this.a.statusText,this.a.response),Ba(this.b,this.a.status,this.a.statusText,this.a.response))}.bind(this)}function Ba(a,b,c,d){a&&a.forEach(function(a){a(b,c,d)})}function Ca(a,b){a.b||(a.b=[]);a.b.push(b);return a}
+function Da(a,b){a.o||(a.o=[]);a.o.push(b);return a}function Ea(a,b){a.h||(a.h=[]);a.h.push(b);return a}function Fa(a){a.a.timeout=6E4;return a}function Ga(a,b){a.a.responseType=b;return a}function N(a,b){a.a.open(a.method,a.G,!0);a.a.send(b)};function Ha(a,b){this.title=a;this.content=b;this.c=Ia(this);this.b=Ja(this);this.a=[];this.h=[]}
 function Ia(a){var b=document.createElement("div"),c=document.createElement("header"),d=document.createElement("span"),e=document.createElement("span"),f=document.createElement("div"),h=document.createElement("footer");b.a=document.createElement("span");b.b=document.createElement("span");d.textContent=a.title;"string"==typeof a.content?f.innerHTML=a.content:f.appendChild(a.content);c.className=Ka;d.className=La;e.className=Ma;e.textContent="x";c.appendChild(d);c.appendChild(e);b.appendChild(c);f.className=
-Na;b.appendChild(f);b.b.className=Oa;b.b.textContent=J.Ua;b.b.addEventListener("click",function(){Pa(a,!1)});e.addEventListener("click",function(){Pa(a,!1)});b.a.addEventListener("click",function(){Pa(a,!0)});h.appendChild(b.b);b.a.className=Oa;b.a.textContent=J.ok;h.appendChild(b.a);h.className=Qa+" "+Ra;b.appendChild(h);b.className=Sa;return b}function Pa(a,b){(b?a.a:a.h).forEach(function(a){a()});a.close()}
-function Ja(a){var b=document.createElement("div");b.className=Ta;b.addEventListener("click",function(){Pa(this,!1)}.bind(a));return b}function Ua(a,b,c){a.c.a.textContent=b;a.c.b.textContent=c;return a}Ha.prototype.oa=function(a){a=a||document.body;a.appendChild(this.b);a.appendChild(this.c);return this};Ha.prototype.close=function(){this.c.remove();this.b.remove();return this};function Va(a,b){a.a.push(b);return a};var Oa="button",Qa="button-container",Sa="dialog",Ta="dialog-overlay",Ka="dialog-title",La="dialog-title-label",Ma="dialog-title-close",Na="dialog-body",Ra="dialog-footer";function Wa(a){var b=document.createElement("lh");b.textContent=a;b.className="chat-command-header";return b}
-function Xa(a,b){var c=document.createElement("li"),d=document.createElement("span");d.className="chat-command-name";if("string"===typeof a)b&&c.appendChild(b),d.textContent=a,c.appendChild(d);else{b=document.createElement("span");var e=document.createElement("span");d.textContent=a.name;b.textContent=a.usage;e.textContent=a.nb;b.className="chat-command-usage";e.className="chat-command-desc";c.appendChild(d);c.appendChild(b);c.appendChild(e)}c.dataset.input=d.textContent;c.className="chat-command-item";
+Na;b.appendChild(f);b.b.className=Oa;b.b.textContent=J.Va;b.b.addEventListener("click",function(){Pa(a,!1)});e.addEventListener("click",function(){Pa(a,!1)});b.a.addEventListener("click",function(){Pa(a,!0)});h.appendChild(b.b);b.a.className=Oa;b.a.textContent=J.ok;h.appendChild(b.a);h.className=Qa+" "+Ra;b.appendChild(h);b.className=Sa;return b}function Pa(a,b){(b?a.a:a.h).forEach(function(a){a()});a.close()}
+function Ja(a){var b=document.createElement("div");b.className=Ta;b.addEventListener("click",function(){Pa(this,!1)}.bind(a));return b}function Ua(a,b,c){a.c.a.textContent=b;a.c.b.textContent=c;return a}Ha.prototype.pa=function(a){a=a||document.body;a.appendChild(this.b);a.appendChild(this.c);return this};Ha.prototype.close=function(){this.c.remove();this.b.remove();return this};function Va(a,b){a.a.push(b);return a};var Oa="button",Qa="button-container",Sa="dialog",Ta="dialog-overlay",Ka="dialog-title",La="dialog-title-label",Ma="dialog-title-close",Na="dialog-body",Ra="dialog-footer";function Wa(a){var b=document.createElement("lh");b.textContent=a;b.className="chat-command-header";return b}
+function Xa(a,b){var c=document.createElement("li"),d=document.createElement("span");d.className="chat-command-name";if("string"===typeof a)b&&c.appendChild(b),d.textContent=a,c.appendChild(d);else{b=document.createElement("span");var e=document.createElement("span");d.textContent=a.name;b.textContent=a.usage;e.textContent=a.ob;b.className="chat-command-usage";e.className="chat-command-desc";c.appendChild(d);c.appendChild(b);c.appendChild(e)}c.dataset.input=d.textContent;c.className="chat-command-item";
 return c}
-function Ya(a){var b,c=document.getElementById("slashList");c.dataset.cursor&&delete c.dataset.cursor;var d=[],e=a.value;if(a.selectionStart===a.selectionEnd&&a.selectionStart){for(var f=a.selectionStart,h=a.selectionEnd;f&&" "!==e[f-1];f--);for(b=e.length;h<b&&" "!==e[h];h++);if(f!==h&&0<h-f-1){if("#"===e[f]){var k=O.l;b=e.substr(f+1,h-f-1);for(var g in k)k[g].name.length>=b.length&&k[g].name.substr(0,b.length)===b&&d.push(k[g])}else if("@"===e[f])for(g in k=P instanceof u?O.i:P.i,b=e.substr(f+1,
-h-f-1),k){var n=k[g].getName();n.length>=b.length&&n.substr(0,b.length)===b&&d.push(k[g])}else if(":"===e[f]&&window.searchEmojis){b=e.substr(f+1,h-f-1);n=window.searchEmojis(b);for(k in n){var n=window.makeEmoji(k,!1),p=document.createElement("span");p.appendChild(n);p.className="emoji-small";d.push({name:":"+k+":",za:p,ma:Za.name})}for(g in O.b.data)g.length>=b.length&&g.substr(0,b.length)===b&&(k=document.createElement("span"),k.className="emoji-small",k.appendChild($a(g)),d.push({name:":"+g+":",
-za:k,ma:"custom"}))}d.length&&(c.dataset.cursor=JSON.stringify([f,h]))}}if(!d.length&&"/"===e[0]){g=e.indexOf(" ");f=-1!==g;g=-1===g?e.length:g;b=e.substr(0,g);f?(a=ab.Wa(b))&&d.push(a):(d=ab.ob(b),c.dataset.cursor=JSON.stringify([0,a.selectionEnd]));a=O?O.h.data:{};for(var l in a)e=a[l],(!f&&e.name.substr(0,g)===b||f&&e.name===b)&&d.push(e);d.sort(function(a,b){return a.V.localeCompare(b.V)||a.name.localeCompare(b.name)})}c.textContent="";if(d.length){l=document.createDocumentFragment();g=0;for(a=
-d.length;g<a;g++)if(e=d[g],e instanceof ga){if(!m){var m=!0;l.appendChild(Wa(J.la))}b=document.createElement("span");b.className="chat-command-userIcon";b.style.backgroundImage='url("'+qa(e)+'")';l.appendChild(Xa("@"+e.getName(),b))}else e instanceof v?(m||(m=!0,l.appendChild(Wa(J.l))),l.appendChild(Xa("#"+e.name))):e.za?(m!==e.ma&&(m=e.ma,l.appendChild(Wa(e.ma))),l.appendChild(Xa(e.name,e.za))):(m!==e.V&&(m=e.V,l.appendChild(Wa(e.V))),l.appendChild(Xa(e)));c.appendChild(l)}}
-function bb(a){if(Q)return N(new K("PUT","api/msg?room="+P.id+"&ts="+Q.id+"&text="+encodeURIComponent(a))),!0;if("/"===a[0]){var b=a.indexOf(" "),c=a.substr(0,-1===b?void 0:b);a=-1===b?"":a.substr(b);var b=O,d=ab.Wa(c);return d?(d.exec(b,P,a.trim()),!0):b&&(c=b.h.data[c])?(N(new K("POST","api/cmd?room="+P.id+"&cmd="+encodeURIComponent(c.name.substr(1))+"&args="+encodeURIComponent(a.trim()))),!0):!1}cb(P,a,R);return!0}function S(){document.getElementById("msgInput").focus()}
-function db(){function a(a){for(var b=1,c=0,d=a.value.length;c<d;c++)"\n"===a.value[c]&&b++;a.rows=Math.min(5,b)}var b=0,c=document.getElementById("msgInput");c.addEventListener("input",function(){if(P){var c=Date.now();b+3E3<c&&(O.self.M||P instanceof u)&&(N(new K("POST","api/typing?room="+P.id)),b=c);Ya(this);a(this)}});c.addEventListener("keydown",function(b){if(9===b.keyCode)return b.preventDefault(),!1;if(13===b.keyCode)return b.preventDefault(),b.shiftKey||b.altKey||b.ctrlKey?(this.value+="\n",
-a(this)):eb(),!1});document.getElementById("slashList").addEventListener("click",function(a){if(P){var b=a.target;if(a=this.dataset.cursor)for(a=JSON.parse(a);b&&b!==this;){if(b.dataset.input){var c=document.getElementById("msgInput"),b=b.dataset.input;c.value.length<=a[1]&&(b+=" ");c.value=c.value.substr(0,a[0])+b+c.value.substr(a[1]);c.selectionStart=c.selectionEnd=a[0]+b.length;Ya(c);c.focus();break}b=b.parentElement}}})};var fb=[],gb=0;
-function hb(){var a=document.createDocumentFragment(),b=xa(function(a){return!a.fa&&!1!==a.ba}),c=[],d=[],e=[],f=[],h={};b.sort(function(a,b){if(a[0]!==b[0])return a[0]-b[0];var c=D(C.context,a),d=D(C.context,b);a=c.l[a];b=d.l[b];return a.name===b.name?(h[a.id]=J.ya(c.a.name,a.name),h[b.id]=J.ya(d.a.name,b.name),c.a.name.localeCompare(d.a.name)):a.name.localeCompare(b.name)});b.forEach(function(a){a=wa(a);if(a instanceof u){var b;if(b=!a.a.Ta){var k=h[a.id];b=document.createElement("li");var p=document.createElement("a");
-b.id="room_"+a.id;p.href="#"+a.id;b.className="chat-context-room chat-ims presence-indicator";p.textContent=k||a.a.getName();b.appendChild(ib());b.appendChild(p);a.a.M||b.classList.add("presence-away");P===a&&b.classList.add("selected");a.I!==a.C&&void 0!==a.I&&(b.classList.add("unread"),b.classList.add("unreadHi"));b=k=b}b&&(a.A?c.push(k):f.push(k))}else if(k=h[a.id],b=document.createElement("li"),p=document.createElement("a"),b.id="room_"+a.id,p.href="#"+a.id,a.h?(b.className="chat-context-room chat-group",
-b.dataset.count=Object.keys(a.i||{}).length):b.className="chat-context-room chat-channel",P===a&&b.classList.add("selected"),p.textContent=k||a.name,b.appendChild(ib()),b.appendChild(p),a.I!==a.C&&void 0!==a.I&&(b.classList.add("unread"),0<=T.indexOf(a)&&b.classList.add("unreadHi")),k=b)a.A?c.push(k):a.h?e.push(k):d.push(k)});c.length&&a.appendChild(jb(J.A));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(jb(J.l));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});
-f.length&&a.appendChild(jb(J.fb));f.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);kb.apply(document.getElementById("chanSearch"));lb();mb();O&&nb(O.a.id,O.i,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"})}
-function ob(){va(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.i)(c=a.i[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"))});pb()}
-function pb(){var a;document.getElementById("whoistyping").textContent="";if(O&&P&&(a=O.u[P.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=F(d))?b.appendChild(qb(a)):c=!0;c&&(C.b=0);document.getElementById("whoistyping").appendChild(b)}}function rb(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");mb()}
-function sb(){var a=P.name||(P.a?P.a.getName():void 0);if(!a){console.error("No name provided for ",P);var a=[],b;for(b in P.i)a.push(P.i[b].getName());a=a.join(", ")}document.getElementById("currentRoomTitle").textContent=a;tb();S();document.getElementById("fileUploadContainer").classList.add("hidden");ub();R&&(R=null,U());Q&&(Q=null,U());mb();pb()}
-function U(){if(R){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){R=null;U()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(R.K())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";S()}
-function vb(){if(Q){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){Q=null;vb()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(Q.K());document.getElementById("msgInput").value=Q.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";S()}
-window.toggleReaction=function(a,b,c){var d=C.a[a],e,f;(d=C.a[a])&&(e=pa(d,b))&&(f=D(C.context,a))&&(e.D[c]&&-1!==e.D[c].indexOf(f.self.id)?N(new K("DELETE","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c))):wb(a,b,c))};function xb(a,b){document.getElementById("linkFavicon").href=a||b?"favicon.png?h="+a+"&m="+b:"favicon_ok.png"}
-function mb(){var a=T.length,b="";if(V)b="!"+J.Za+" - Mimouchat",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+")",xb(a,a);else{var c=0;ua(C.context,function(a){a.I>a.C&&c++});c&&(b="("+c+")");xb(0,c)}!b.length&&P&&(b=P.name);document.title=b.length?b:"Mimouchat"}
-function yb(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(gb+3E4<a){var b=new Notification(J.$a);gb=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
-function tb(){var a=document.createDocumentFragment(),b=P.id,c=null,d=0,e=null,f;P.A?document.getElementById("chatSystemContainer").classList.add("starred"):document.getElementById("chatSystemContainer").classList.remove("starred");fb=[];C.a[b]&&C.a[b].a.forEach(function(b){if(b.h)b.X();else{var h=b.L(),g=!1;c&&c.O===b.O&&b.O?30>Math.abs(d-b.o)&&!(b instanceof A)?e.classList.add("chatmsg-same-ts"):d=b.o:(d=b.o,g=!0);(!c||c.o<=P.C)&&b.o>P.C?h.classList.add("chatmsg-first-unread"):h.classList.remove("chatmsg-first-unread");
-if(b instanceof A)e=c=null,d=0,a.appendChild(h),f=null;else{if(g||!f){var g=F(b.O),n=b.username,p=document.createElement("div"),l=document.createElement("div"),m=document.createElement("a"),t=document.createElement("img");p.ga=document.createElement("span");p.ga.className="chatmsg-author-img-wrapper";t.className="chatmsg-author-img";m.className="chatmsg-author-name";m.href="#"+g.id;g?(m.textContent=g.getName(),m.style.backgroundColor=zb(g.getName()),t.src=qa(g)):(m.textContent=n||"?",t.src="");p.ga.appendChild(t);
-l.appendChild(p.ga);l.appendChild(m);l.className="chatmsg-author";p.className="chatmsg-authorGroup";p.appendChild(l);p.content=document.createElement("div");p.content.className="chatmsg-author-messages";p.appendChild(p.content);f=p;fb.push(f);a.appendChild(f)}c=b;e=h;f.content.appendChild(h)}}});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;Ab();window.hasFocus&&ub()}
-function Bb(a,b){if(a.classList.contains("chatmsg-hover-reply"))Q&&(Q=null,vb()),R!==b&&(R=b,U());else if(a.classList.contains("chatmsg-hover-reaction")){var c=P.id,d=b.id;Cb.oa(document.body,O,function(a){a&&wb(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(R&&(R=null,U()),Q!==b&&(Q=b,vb())):a.classList.contains("chatmsg-hover-star")?b.A?N(new K("DELETE","api/starMsg?room="+P.id+"&msgId="+b.id)):N(new K("POST","api/starMsg?room="+P.id+"&msgId="+b.id)):a.classList.contains("chatmsg-hover-pin")?
-b.pinned?Db(P,b):N(new K("POST","api/pinMsg?room="+P.id+"&msgId="+b.id)):a.classList.contains("chatmsg-hover-remove")&&(R&&(R=null,U()),Q&&(Q=null,vb()),N(new K("DELETE","api/msg?room="+P.id+"&ts="+b.id)))}
-function Eb(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=pa(C.a[P.id],d))&&a.s[e]&&a.s[e].actions&&a.s[e].actions[f]&&
-Fb(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=pa(C.a[P.id],d))&&Bb(c,a);break}c=c.parentElement}}
-function Fb(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 B,message_ts:a.id},h=new K("POST","api/attachmentAction?serviceId="+a.O);N(h,JSON.stringify(d))}var e=P.id;c.confirm?Va(Ua(new Ha(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).oa():d()}
-function Ab(){if(!1!==W.a){var a=document.getElementById("chatWindow").getBoundingClientRect().top;fb.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"})}}
-document.addEventListener("DOMContentLoaded",function(){za();Gb();db();var a=document.getElementById("chanSearch");a.addEventListener("input",kb);a.addEventListener("blur",kb);document.getElementById("chatWindow").addEventListener("click",Eb);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&lb()});document.addEventListener("mouseover",function(a){a=a.target;if(X.ub(a))X.Z();else{for(;a&&a!==this;){if("A"===a.nodeName){var b=a.href,d=b.indexOf("#");
-if(0<=d){b=b.substr(d+1);if(d=D(C.context,b)){X.cb(d,d.l[b]).show(a);return}a:{for(var d=C.context,e=0,f=d.a.length;e<f;e++)if(d.a[e].i[b]){d=d.a[e];break a}d=null}if(d&&(b=d.i[b].W)){X.cb(d,b).show(a);return}}}a=a.parentElement}X.rb()}});document.getElementById("currentRoomStar").addEventListener("click",function(a){a.preventDefault();P&&(P.A?N(new K("POST","api/unstarChannel?room="+P.id)):N(new K("POST","api/starChannel?room="+P.id)));return!1});document.getElementById("fileUploadCancel").addEventListener("click",
-function(a){a.preventDefault();document.getElementById("fileUploadError").classList.add("hidden");document.getElementById("fileUploadContainer").classList.add("hidden");document.getElementById("fileUploadInput").value="";return!1});document.getElementById("ctxMenuLogout").addEventListener("click",Hb);document.getElementById("ctxMenuSettings").addEventListener("click",function(a){a.preventDefault();Ib.display()});document.getElementById("fileUploadForm").addEventListener("submit",function(a){a.preventDefault();
-a=document.getElementById("fileUploadInput");var b=a.value;b&&(b=b.substr(b.lastIndexOf("\\")+1),Jb(b,a.files[0],function(a){var b=document.getElementById("fileUploadError");a?(b.textContent=a,b.classList.remove("hidden")):(b.classList.add("hidden"),document.getElementById("fileUploadInput").value="",document.getElementById("fileUploadContainer").classList.add("hidden"))}));return!1});document.getElementById("attachFile").addEventListener("click",function(a){a.preventDefault();P&&document.getElementById("fileUploadContainer").classList.remove("hidden");
-return!1});document.getElementById("msgFormSubmit").addEventListener("click",function(a){a.preventDefault();eb();return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();eb();return!1});window.addEventListener("blur",function(){window.hasFocus=!1});window.addEventListener("focus",function(){window.hasFocus=!0;gb=0;P&&ub();S()});document.getElementById("chatWindow").addEventListener("scroll",Ab);window.hasFocus=!0;document.getElementById("emojiButton").addEventListener("click",
-function(){O&&Cb.oa(document.body,O,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");S()})});Kb()});function eb(){var a=document.getElementById("msgInput");P&&a.value&&bb(a.value)&&(a.value="",R&&(R=null,U()),Q&&(Q=null,U()),document.getElementById("slashList").textContent="");S()};var Ib=function(){function a(){document.getElementById("settings").classList.add("hidden");c=!1}function b(a){d&&(document.getElementById("settings").classList.remove("display-"+d),document.getElementById("setting-menu-"+d).classList.remove("selected"),document.getElementById("settings-serviceAddSection").classList.add("hidden"));document.getElementById("settings").classList.add("display-"+a);document.getElementById("setting-menu-"+a).classList.add("selected");d=a}var c=!1,d=null,e={T:"services",
-display:"display",Ob:"privacy"};document.getElementById("settingMenuItems").addEventListener("click",function(a){for(var c=a.target;a.currentTarget!==c&&c;c=c.parentNode)if(c.dataset&&c.dataset.target)for(var d in e)if(e[d]===c.dataset.target){b(e[d]);return}});document.getElementById("settingDiscardClose").addEventListener("click",a);document.getElementById("settings-serviceAddButton").addEventListener("click",function(a){a.preventDefault();document.getElementById("settings-serviceAddSection").classList.remove("hidden");
-return!1});document.getElementById("settings-serviceAddConfirm").addEventListener("click",function(a){a.preventDefault();document.location.href=document.getElementById("settings-serviceAddServiceList").value;return!1});document.getElementById("settingCommit").addEventListener("click",function(){var b={};document.getElementById("settings-displayEmojiProvider").value!==W.h&&(b.emojiProvider=document.getElementById("settings-displayEmojiProvider").value);var c=!!document.getElementById("settings-displayDisplayAvatar").checked;
-c!==(!1!==W.a)&&(b.displayAvatar=c);c=!!document.getElementById("settings-displayColorfulNames").checked;c!==(!0===W.b)&&(b.colorfulNames=c);var c=W,d;for(d in b){Lb(c,b);Mb();N(new K("POST","api/settings?service=null&device=null"),JSON.stringify(b));break}a()});return{display:function(a){if(!c){document.getElementById("settings").classList.remove("hidden");var d=document.createDocumentFragment(),f=!1,g;for(g in W.T){var n=W.T[g];for(m in n){var f=document.createElement("li"),p=document.createElement("span"),
-l=document.createElement("span");p.textContent=g;l.textContent=n[m];f.className="settings-service-list-item";p.className="settings-service-list-item-provider";l.className="settings-service-list-item-service";f.appendChild(p);f.appendChild(l);d.appendChild(f);f=!0}}n=document.getElementById("settings-serviceList");n.textContent="";f?(document.getElementById("settings-serviceListEmpty").classList.remove("hidden"),n.appendChild(d)):document.getElementById("settings-serviceListEmpty").classList.add("hidden");
-d=document.createDocumentFragment();n=document.getElementById("settings-displayEmojiProvider");for(g in Nb){var m=document.createElement("option");m.value=g;m.textContent=Nb[g].name;Nb[g]===Za&&(m.selected=!0);d.appendChild(m)}n.textContent="";n.appendChild(d);document.getElementById("settings-displayDisplayAvatar").checked=!1!==W.a;document.getElementById("settings-displayColorfulNames").checked=!0===W.b;c=!0}b(a||e.T);return this},zb:function(){return this},wb:e}}();function Ob(a){if(void 0!==a.latitude&&void 0!==a.longitude&&-90<=a.latitude&&90>=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.R=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"),h=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)))},g=function(a,d,e,g){h.fillStyle="#808080";h.fillRect(0,0,300,300);f.fillStyle="#808080";f.fillRect(0,0,300,300);var p=Math.pow(2,a),m=(e+180)/360*p,n=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*p,l=Math.floor(m),L=Math.floor(n),
-na=g?100*g/k(180/Math.PI*Math.atan(.5*(Math.exp(Math.PI-2*Math.PI*L/p)-Math.exp(-(Math.PI-2*Math.PI*L/p)))),l/p*360-180,(l+1)/p*360-180):0;d=b;for(e=0;3>e;e++)for(g=0;3>g;g++)c(a,l+e-1,L+g-1,{sb:e,vb:g,jb:d}).then(function(a){if(a.jb===b){h.drawImage(a.R,100*a.sb,100*a.vb,100,100);a=m-l;var c=n-L;a=100*a+100;c=100*c+100;f.putImageData(h.getImageData(0,0,300,300),0,0);void 0!==na&&(f.beginPath(),f.arc(a,c,Math.max(na,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===na||25<na)f.strokeStyle="rgba(244, 146, 66, 1)",f.beginPath(),f.moveTo(a-5,c-5),f.lineTo(a+5,c+5),f.stroke(),f.moveTo(a+5,c-5),f.lineTo(a-5,c+5),f.stroke()}})},n,p=function(c){c=Math.max(4,Math.min(19,c));n!==c&&(b++,n=c,g(n,Number(a.latitude),Number(a.longitude),Number(a.accuracy)))};p(12);var e=document.createElement("div"),l=document.createElement("div"),m=document.createElement("button"),t=document.createElement("button");e.className=
-"OSM-wrapper";d.className="OSM-canvas";l.className="OSM-controls";t.className="OSM-controls-zoomMin";m.className="OSM-controls-zoomPlus";t.addEventListener("click",function(){p(n-1)});m.addEventListener("click",function(){p(n+1)});l.appendChild(t);l.appendChild(m);e.appendChild(d);e.appendChild(l);return e}};function ib(){var a=document.createElement("span"),b=document.createElement("span"),c=document.createElement("span"),d=document.createElement("span");a.className="typing-container";b.className="typing-dot1";c.className="typing-dot2";d.className="typing-dot3";b.textContent=c.textContent=d.textContent=".";a.appendChild(b);a.appendChild(c);a.appendChild(d);return a}var jb=function(){var a={};return function(b){var c=a[b];c||(c=a[b]=document.createElement("header"),c.textContent=b);return c}}();
-function Pb(a){var b={},c=a;if(O)for(var d=O;!b[a];){var e=d.b.data[a];if(e)if("alias:"==e.substr(0,6))b[a]=!0,a=e.substr(6);else return a=document.createElement("span"),a.className="emoji-custom emoji",a.style.backgroundImage="url('"+e+"')",a.textContent=":"+c+":",a.title=c,a;else return a}return c}function $a(a){return"makeEmoji"in window?(a=Pb(a),"string"===typeof a&&(a=window.makeEmoji(a)),"string"===typeof a?null:a):null}
-function Qb(a){var b=a.b,c=document.createElement("div"),d=document.createElement("div");c.ca=document.createElement("ul");c.s=document.createElement("ul");c.D=document.createElement("ul");c.o=document.createElement("div");c.Da=document.createElement("div");c.xa=document.createElement("span");c.id=b+"_"+a.id;c.className="chatmsg-item";c.o.className="chatmsg-ts";c.Da.className="chatmsg-msg";c.xa.className="chatmsg-author-name";var b=c.ca,e=a.context.$;a:{for(var f=C.context,h=0,k=f.a.length;h<k;h++)if(f.a[h].self.id===
-a.O){a=!0;break a}a=!1}e.replyToMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-reply",f.style.backgroundImage='url("repl.svg")',b.appendChild(f));e.reactMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-reaction",f.style.backgroundImage='url("smile.svg")',b.appendChild(f));if(a&&e.editMsg||e.editOtherMsg)f=document.createElement("li"),f.className="chatmsg-hover-edit",f.style.backgroundImage='url("edit.svg")',b.appendChild(f);e.starMsg&&(b.ja=document.createElement("li"),
-b.ja.className="chatmsg-hover-star",b.appendChild(b.ja));e.pinMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-pin",b.appendChild(f),f.style.backgroundImage='url("pin.svg")');if(a&&e.removeMsg||e.moderate)e=document.createElement("li"),e.className="chatmsg-hover-remove",e.style.backgroundImage='url("remove.svg")',b.appendChild(e);c.ca.className="chatmsg-hover";d.appendChild(c.xa);d.appendChild(c.Da);d.appendChild(c.o);d.appendChild(c.s);c.F=document.createElement("div");c.F.className=
-"chatmsg-edited";d.appendChild(c.F);d.appendChild(c.D);d.className="chatmsg-content";c.s.className="chatmsg-attachments";c.D.className="chatmsg-reactions";c.appendChild(d);c.appendChild(c.ca);return c}
-function zb(a){if(!a.length)return"black";for(var b=0,c=0,c=[],d=0,e=0,f=0,h,k=0,g=a.length;k<g;k++)c[k]=a.charCodeAt(k),d+=c[k];h=d/a.length;c.forEach(function(a){var c=Math.abs(h-a);e+=c;f=Math.max(c,f);b=a+((b<<5)-b)});e/=a.length;b=Math.abs(b-60)%199*360/199;c=f?Math.round(Math.min(100,Math.max(75,e/f*25+75))):100;return"hsl("+b+", 100%, "+c+"%)"}function Rb(a){var b={good:"#2fa44f",warning:"#de9e31",danger:"#d50200"};if(a){if("#"===a[0])return a;if(b[a])return b[a]}return"#e3e4e6"}
-function Sb(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),f=document.createElement("div"),h=document.createElement("a"),k=document.createElement("div"),g=document.createElement("img"),n=document.createElement("a"),p=document.createElement("div"),l=document.createElement("div"),m=document.createElement("div"),t=document.createElement("img"),z=document.createElement("div");d.className="chatmsg-attachment";e.style.borderColor=Rb(b.color||"");e.className="chatmsg-attachment-block";
-f.className="chatmsg-attachment-pretext";b.pretext?f.innerHTML=a.w(b.pretext):f.classList.add("hidden");h.target="_blank";b.title?(h.innerHTML=a.w(b.title),b.title_link&&(h.href=b.title_link),h.className="chatmsg-attachment-title"):h.className="hidden chatmsg-attachment-title";n.target="_blank";k.className="chatmsg-author";b.author_name&&(n.innerHTML=a.w(b.author_name),n.href=b.author_link||"",n.className="chatmsg-author-name",g.className="chatmsg-author-img",b.author_icon&&(g.src=b.author_icon,k.appendChild(g)),
-k.appendChild(n));m.className="chatmsg-attachment-thumb";b.thumb_url?(g=document.createElement("img"),g.src=b.thumb_url,m.appendChild(g),e.classList.add("has-thumb"),b.video_html&&(m.dataset.video=b.video_html)):m.classList.add("hidden");p.className="chatmsg-attachment-content";g=a.w(b.text||"");l.className="chatmsg-attachment-text";g&&""!=g?l.innerHTML=g:l.classList.add("hidden");p.appendChild(m);p.appendChild(l);b.geo&&(l=Ob(b.geo))&&p.appendChild(l);t.className="chatmsg-attachment-img";b.image_url?
-t.src=b.image_url:t.classList.add("hidden");z.className="chatmsg-attachment-footer";b.footer&&(l=document.createElement("span"),l.className="chatmsg-attachment-footer-text",l.innerHTML=a.w(b.footer),b.footer_icon&&(m=document.createElement("img"),m.src=b.footer_icon,m.className="chatmsg-attachment-footer-icon",z.appendChild(m)),z.appendChild(l));b.ts&&(l=document.createElement("span"),l.className="chatmsg-ts",l.innerHTML=J.P(b.ts),z.appendChild(l));e.appendChild(h);e.appendChild(k);e.appendChild(p);
-e.appendChild(t);if(b.fields&&b.fields.length){var w=document.createElement("ul");e.appendChild(w);w.className="chatmsg-attachment-fields";b.fields.forEach(function(b){var c=b.title||"",d=b.value||"";b=!!b["short"];var e=document.createElement("li"),f=document.createElement("div"),g=document.createElement("div");e.className="field";b||e.classList.add("field-long");f.className="field-title";f.textContent=c;g.className="field-text";g.innerHTML=a.w(d);e.appendChild(f);e.appendChild(g);e&&w.appendChild(e)})}if(b.actions&&
-b.actions.length)for(h=document.createElement("ul"),h.className="chatmsg-attachment-actions "+Qa,e.appendChild(h),k=0,p=b.actions.length;k<p;k++)(t=b.actions[k])&&(t=Tb(c,k,t))&&h.appendChild(t);e.appendChild(z);d.appendChild(f);d.appendChild(e);return d}
-function Tb(a,b,c){var d=document.createElement("li"),e=Rb(c.style);d.textContent=c.text;e!==Rb()&&(d.style.color=e);d.style.borderColor=e;d.dataset.attachmentIndex=a;d.dataset.actionIndex=b;d.className="chatmsg-attachment-actions-item "+Oa;return d}function qb(a){var b=document.createElement("li"),c=document.createElement("span");c.textContent=a.getName();b.appendChild(ib());b.appendChild(c);return b};var Cb=function(){function a(a,b){for(a=a.target;a!==n&&a&&"LI"!==a.nodeName;)a=a.parentElement;a&&"LI"===a.nodeName&&a.id&&"emojibar-"===a.id.substr(0,9)?b(a.id.substr(9)):b(null)}function b(){w={};l.textContent="";window.emojiProviderHeader&&(l.appendChild(k(window.emojiProviderHeader)),m.textContent="",l.appendChild(m));l.appendChild(k("emojicustom.png"));l.appendChild(t)}function c(){if(!d())return!1;r&&r(null);return!0}function d(){return n.parentElement?(n.parentElement.removeChild(p),n.parentElement.removeChild(n),
-!0):!1}function e(a){var b=0;a=void 0===a?z.value:a;if(g()){var c=0,d=window.searchEmojis(a),e=f(d,I?I.self.S.a:[]),p;for(k in w)w[k].visible&&(w[k].visible=!1,m.removeChild(w[k].c));var k=0;for(p=e.length;k<p;k++){var l=e[k].name,n=w[l];if(!n){var n=w,L=l;var r=l;var l=window.makeEmoji(d[l]),H=document.createElement("span");H.appendChild(l);H.className="emoji-medium";r=h(r,H);n=n[L]=r}n.visible||(n.visible=!0,m.appendChild(n.c));c++}b+=c}k=b;c=0;for(E in x)x[E].visible&&(x[E].visible=!1,t.removeChild(x[E].c));
-if(I){d=f(I.b.data,I?I.self.S.a:[]);var E=0;for(b=d.length;E<b;E++)L=d[E].name,""!==a&&L.substr(0,a.length)!==a||"alias:"===I.b.data[L].substr(0,6)||(e=x[L],e||(e=x,n=p=L,L=I.b.data[L],r=document.createElement("span"),l=document.createElement("span"),r.className="emoji emoji-custom",r.style.backgroundImage='url("'+L+'")',r.textContent=":"+n+":",r.title=n,l.appendChild(r),l.className="emoji-medium",n=h(n,l),e=e[p]=n),e.visible||(e.visible=!0,t.appendChild(e.c)),c++);E=c}else E=0;return k+E}function f(a,
-b){var c=[],d;for(d in a){var e={name:d,eb:0,count:0};if(a[d].names)for(var f=0,g=a[d].names.length;f<g;f++)e.count+=b[a[d].names[f]]||0;c.push(e)}return c=c.sort(function(a,b){var c=b.count-a.count;return c?c:a.eb-b.eb})}function h(a,b){var c=document.createElement("li");c.appendChild(b);c.className="emojibar-list-item";c.id="emojibar-"+a;return{visible:!1,c:c}}function k(a){var b=document.createElement("img"),c=document.createElement("div");b.src=a;c.appendChild(b);c.className="emojibar-header";
-return c}function g(){return"searchEmojis"in window}var n=document.createElement("div"),p=document.createElement("div"),l=document.createElement("div"),m=document.createElement("ul"),t=document.createElement("ul"),z=document.createElement("input"),w={},x={},M=document.createElement("div"),H=document.createElement("span"),E=document.createElement("span"),r,I;p.addEventListener("click",function(a){var b=n.getBoundingClientRect();(a.screenY<b.top||a.screenY>b.bottom||a.screenX<b.left||a.screenX>b.right)&&
-c()});p.className="emojibar-overlay";n.className="emojibar";l.className="emojibar-emojis";m.className=t.className="emojibar-list";z.className="emojibar-search";M.className="emojibar-detail";H.className="emojibar-detail-img";E.className="emojibar-detail-name";M.appendChild(H);M.appendChild(E);b();n.appendChild(l);n.appendChild(M);n.appendChild(z);z.addEventListener("keyup",function(){e()});n.addEventListener("mousemove",function(b){a(b,function(a){var b=a?w[a]||x[a]:null;b?(H.innerHTML=b.c.outerHTML,
-E.textContent=":"+a+":"):(H.textContent="",E.textContent="")})});n.addEventListener("click",function(b){a(b,function(a){a&&d()&&r&&r(a)})});return{isSupported:g,oa:function(a,b,c){return g()?(I=b,r=c,a.appendChild(p),a.appendChild(n),z.value="",e(),z.focus(),!0):!1},search:e,close:c,reset:function(){b();e()}}}();var C,T=[];function Ub(){da.call(this)}Ub.prototype=Object.create(da.prototype);Ub.prototype.constructor=Ub;function ta(a){return a.a?a.a.id:null}function Vb(){this.b=0;this.context=new ra;this.a={}}
-Vb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(g in a["static"]){var c=sa(this.context,g);c||(c=new Ub,this.context.push(c));var d={};a["static"][g].channels&&a["static"][g].channels.forEach(function(a){a.pins&&(d[a.id]=a.pins,a.pins=void 0)});fa(c,a["static"][g],b);for(var e in d){var f=[],h=this.a[e];h||(h=this.a[e]=new Y(e,250,null,b));d[e].forEach(function(a){f.push(h.b(a,b))});c.l[e].b=f}}ua(this.context,function(a){a.I===a.C&&(a=T.indexOf(a),-1!==a&&T.splice(a,
-1))});if(a.live){for(g in a.live)(c=this.a[g])?la(c,a.live[g],b):c=this.a[g]=new Y(g,250,a.live[g],b);for(var k in a.live){var g=D(this.context,k);(c=g.l[k])?(this.a[k].a.length&&ha(c,oa(this.a[k]).o,b),c.fa||(Wb(g,c,a.live[k]),P&&a.live[P.id]&&tb())):C.b=0}}a["static"]&&hb();var n=!1;a.typing&&this.context.a.forEach(function(c){var d=n,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}n=
-d|f},this);(a["static"]||n)&&ob();a.config&&(W=new Xb(a.config),Mb());if(O&&P&&a["static"]&&a["static"][O.a.id]&&a["static"][O.a.id].channels&&a["static"][O.a.id].channels)for(k=a["static"][O.a.id].channels,g=0,c=k.length;g<c;g++)if(k[g].id===P.id){tb();break}};setInterval(function(){var a=!1,b=Date.now();va(function(c){var d=!1,e;for(e in c.u){var f=!0,h;for(h in c.u[e])c.u[e][h]+3E3<b?(delete c.u[e][h],d=!0):f=!1;f&&(delete c.u[e],d=!0)}d&&(a=!0)});a&&ob()},1E3);
-function Wb(a,b,c){if(b!==P||!window.hasFocus){var d=new RegExp("<@"+a.self.id),e=!1,f=!1,h=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.C)&&c.user!==a.self.id){f=!0;var g;if(!(g=b instanceof u)&&(g=c.text)&&!(g=c.text.match(d)))a:{g=a.self.S.B;for(var k=0,p=g.length;k<p;k++)if(-1!==c.text.indexOf(g[k])){g=!0;break a}g=!1}g&&(-1===T.indexOf(b)&&(h=!0,T.push(b)),e=!0)}});if(f){mb();if(c=document.getElementById("room_"+b.id))c.classList.add("unread"),e&&c.classList.add("unreadHi");h&&!window.hasFocus&&
-yb()}}}function ub(){var a=P,b=T.indexOf(a);if(a.I>a.C){var c=C.a[a.id];c&&(c=c.a[c.a.length-1])&&(N(new K("POST","api/markread?room="+a.id+"&id="+c.id+"&ts="+c.o)),a.C=c.o)}0<=b&&(T.splice(b,1),mb());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}C=new Vb;var nb=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;e<n-40;e+=l)for(var f=0;f+l<=p;f+=l)h(a,c[d],e,f),d++,d===c.length&&(c.sort(b),d=0)}function b(a,b){return a.R?b.R?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].R){d(a[e].src,function(d){a[e].R=d;c(a,b)});return}var g=[];a.forEach(function(a){a.R&&g.push(a.R)});b(g)}function d(a,b){N(Ga(Ea(Da(new K(a),function(a,c,d){if(d){var e=new Image;e.onload=function(){var a=
-document.createElement("canvas");a.height=a.width=z;a=a.getContext("2d");a.drawImage(e,0,0,z,z);var a=a.getImageData(0,0,z,z),c=0,d;for(d=0;d<a.width*a.height*4;d+=4)a.data[d]=a.data[d+1]=a.data[d+2]=(a.data[d]+a.data[d+1]+a.data[d+2])/3,a.data[d+3]=50,c+=a.data[d];if(50>c/(a.height*a.width))for(d=0;d<a.width*a.height*4;d+=4)a.data[d]=a.data[d+1]=a.data[d+2]=255-a.data[d];b(a)};e.onerror=function(){b(null)};e.src=window.URL.createObjectURL(d)}else b(null)}),function(){b(null)}),"blob"))}function e(){var a=
-g.createLinearGradient(0,0,0,p);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");g.fillStyle=a;g.fillRect(0,0,n,p);return g.getImageData(0,0,n,p)}function f(a,b){for(var c=(a.height-b.height)/2,d=0;d<b.height;d++)for(var e=0;e<b.width;e++){var f=b.data[4*(d*b.width+e)]/255,g=4*((d+c)*a.width+e+c);a.data[g]*=f;a.data[g+1]*=f;a.data[g+2]*=f}return a}function h(a,b,c,d){var e=Math.floor(d);a=[a.data[e*n*4+0],a.data[e*n*4+1],a.data[e*n*4+2]];g.fillStyle="#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);
-g.beginPath();g.moveTo(c+l/2,d+m);g.lineTo(c-m+l,d+l/2);g.lineTo(c+l/2,d-m+l);g.lineTo(c+m,d+l/2);g.closePath();g.fill();g.putImageData(f(g.getImageData(c+m,d+m,t,t),b),c+m,d+m)}var k=document.createElement("canvas"),g=k.getContext("2d"),n=k.width=250,p=k.height=290,l=(n-40)/3,m=.1*l,t=Math.floor(l-2*m),z=.5*t,w={},x={},M={};return function(b,d,f){if(w[b])f(w[b]);else if(M[b])x[b]?x[b].push(f):x[b]=[f];else{var g=e(),h=[];M[b]=!0;x[b]?x[b].push(f):x[b]=[f];for(var l in d)d[l].Ta||d[l].tb||h.push({src:qa(d[l])});
-c(h,function(c){a(g,c);w[b]=k.toDataURL();x[b].forEach(function(a){a(w[b])})})}}}();var V=0,P=null,O=null,R=null,Q=null;function Gb(){N(Fa(Ea(Da(new K("highlight.pack.js"),function(a,b,c){a=document.createElement("script");b=document.createElement("link");a.innerHTML=c;a.language="text/javascript";b.href="hljs-androidstudio.css";b.rel="stylesheet";document.head.appendChild(b);document.body.appendChild(a)}),function(){console.error("Failure loading hljs required files")})))}
-function Yb(){var a=P;N(Ca(Da(Ga(new K("api/hist?room="+a.id),"json"),function(b,c,d){d&&((b=C.a[a.id])?b=!!la(b,d,Date.now()):(C.a[a.id]=new Y(a,100,d,Date.now()),b=!0),b&&(Wb(D(C.context,a.id),a,d),a===P&&tb()))}),function(){}))}function Mb(){a:{var a=W.T;for(var b in a)if(a.hasOwnProperty(b)){a=!1;break a}a=!0}a&&Ib.zb(!1).display(Ib.wb.T);a=W.h;Zb(a&&Nb[a]?Nb[a]:$b);document.getElementById("customsheet").innerHTML=ac()}
-function Kb(){var a=bc;N(Fa(Ga(Ca(new K("api?v="+C.b),function(b,c,d){(b=2===Math.floor(b/100))?V&&(V=0,rb(!0)):V?(V+=Math.floor((V||5)/2),V=Math.min(60,V)):(V=5,rb(!1));a(b,d)}),"json")))}function bc(a,b){a?(b&&C.update(b),Kb()):setTimeout(cc,1E3*V)}function cc(){Kb()}
-function dc(a){P&&(document.getElementById("room_"+P.id).classList.remove("selected"),document.getElementById("chatSystemContainer").classList.add("no-room-selected"));document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");P=a;O=D(C.context,a.id);sb();X.qb();nb(O.a.id,O.i,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"});(!C.a[P.id]||100>C.a[P.id].a.length)&&Yb();document.getElementById("chatSystemContainer").classList.remove("no-room-selected")}
-function lb(){var a=document.location.hash.substr(1),b=wa(a);b&&b!==P?dc(b):(a=F(a))&&a.W&&dc(a.W)}function Jb(a,b,c){var d=P;new FileReader;var e=new FormData;e.append("file",b);e.append("filename",a);N(Ea(Da(new K("POST","api/file?room="+d.id),function(){c(null)}),function(a,b){c(b)}),e)}
-function cb(a,b,c){b="api/msg?room="+a.id+"&text="+encodeURIComponent(b);c&&(b+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:c.text,author_name:F(c.O).getName(),text:c.text,footer:a.h?J.message:a.name,ts:c.o}])));N(new K("POST",b))}function Db(a,b){N(new K("DELETE","api/pinMsg?room="+a.id+"&msgId="+b.id))}function wb(a,b,c){N(new K("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c)))}
-function Hb(){N(new K("POST","api/logout"));document.cookie="sessID=;Path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;";document.location.reload()}function kb(){var a={},b=[],c=this.value;ua(C.context,function(b){a[b.id]=ia(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 Nb={noemoji:{Aa:"noemoji.js",ha:null,name:"None"},emojione_v2_3:{Aa:"emojione_v2.3.sprites.js",ha:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Aa:"emojione_v3.sprites.js",ha:"emojione_v3.sprites.css",name:"Emojione v3"}},$b=Nb.emojione_v2_3,Za;
-function Zb(a){Za!==a&&(console.log("Loading emoji pack "+a.name),N(Fa(Da(new K(a.Aa),function(b,c,d){b=document.createElement("script");b.innerHTML=d;b.language="text/javascript";document.body.appendChild(b);a.ha&&(d=document.createElement("link"),d.href=a.ha,d.rel="stylesheet",document.head.appendChild(d));d=document.getElementById("emojiButton");for(var e in C.a)ec(C.a[e]);P&&tb();Cb.reset();"makeEmoji"in window?(d.style.backgroundImage='url("smile.svg")',d.classList.remove("hidden")):d.classList.add("hidden")}))),
-Za=a)};var X=function(){function a(){c();r instanceof u?(f.style.backgroundImage="url(api/avatar?size=l&user="+r.a.id+")",n.textContent=(r.a.gb||(r.a.Va||"")+" "+r.a.Ya).trim(),h.classList.add("presence-indicator"),r.a.M?h.classList.remove("presence-away"):h.classList.add("presence-away"),g.classList.remove("hidden"),l.classList.remove("hidden"),l.textContent=r.a.xb||"",t.textContent=r.a.pb||"",m.classList.remove("hidden"),e.classList.remove("roominfo-channel"),e.classList.add("roominfo-user")):b()}function b(){var a=
-E;a.$.topic?(g.classList.remove("hidden"),n.textContent=r.qa||"",p.textContent=r.G?J.Ea(r.G,r.ea):""):g.classList.add("hidden");a.$.purpose?(m.classList.remove("hidden"),t.textContent=r.na||"",z.textContent=r.m?J.Ea(r.m,r.da):""):m.classList.add("hidden");f.style.backgroundImage="";h.classList.remove("presence-indicator");M.textContent=J.ib(r.i?Object.keys(r.i).length:0);a=[];if(r.i)for(var b in r.i)a.push(r.i[b]);a.sort(function(a,b){return a.M&&!b.M?-1:b.M&&!a.M?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.M||b.classList.add("presence-away");c.appendChild(b)});H.textContent="";H.appendChild(c);e.classList.add("roominfo-channel");e.classList.remove("roominfo-user")}function c(){h.textContent=r.name;if(r.b){w.textContent=J.bb(r.b.length);w.classList.remove("hidden");x.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=Oa+" roominfo-unpin";c.className="roominfo-pinlist-item";c.appendChild(b.K());c.appendChild(e);a.appendChild(c)});x.textContent="";x.appendChild(a)}else w.classList.add("hidden"),x.classList.add("hidden")}function d(){if(r.b)for(var a=0,b=r.b.length;a<b;a++)if(r.b[a].id===this.dataset.msgId){Db(r,
-r.b[a]);break}}var e=document.createElement("div"),f=document.createElement("header"),h=document.createElement("h3"),k=document.createElement("div"),g=document.createElement("div"),n=document.createElement("span"),p=document.createElement("span"),l=document.createElement("div"),m=document.createElement("div"),t=document.createElement("span"),z=document.createElement("span"),w=document.createElement("div"),x=document.createElement("ul"),M=document.createElement("div"),H=document.createElement("ul"),
-E,r;e.className="chat-context-roominfo";f.className="roominfo-title";g.className="roominfo-topic";m.className="roominfo-purpose";l.className="roominfo-phone";w.className="roominfo-pincount";x.className="roominfo-pinlist";M.className="roominfo-usercount";H.className="roominfo-userlist";z.className=p.className="roominfo-author";f.appendChild(h);e.appendChild(f);e.appendChild(k);g.appendChild(n);g.appendChild(p);m.appendChild(t);m.appendChild(z);k.appendChild(g);k.appendChild(l);k.appendChild(m);k.appendChild(w);
-k.appendChild(x);k.appendChild(M);k.appendChild(H);var I=null;return{cb:function(b,c){this.Z();E=b;r=c;a();return this},update:function(){this.Z();a();return this},show:function(a){this.Z();a.appendChild(e);e.classList.remove("hidden");return this},qb:function(){this.Z();e.classList.add("hidden");return this},Z:function(){I&&clearTimeout(I);I=null;return this},rb:function(){I||(I=setTimeout(function(){e.classList.add("hidden");I=null},300));return this},ub:function(a){for(;a;){if(a===e)return!0;a=
-a.parentNode}return!1}}}();function Y(a,b,c,d){ka.call(this,a,b,0,c,d)}Y.prototype=Object.create(ka.prototype);Y.prototype.constructor=Y;Y.prototype.b=function(a,b){return!0===a.isMeMessage?new fc(this.id,a,b):!0===a.isNotice?new gc(this.id,a,b):new hc(this.id,a,b)};function ec(a){a.a.forEach(function(a){a.H()})}
-var Z=function(){function a(a,d){return Aa(d,{B:a.context.self.S.B,aa:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=$a(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null},ka:function(c){return b(a,c)}})}function b(a,b){var c=b.indexOf("|"),d;if(-1===c)var h=b;else{h=b.substr(0,c);var k=b.substr(c+1)}if("@"===h[0])if(h=ta(a.context)+"|"+h.substr(1),d=F(h))a=!0,h="#"+d.W.id,k="@"+d.getName(),d="background-color:"+
-zb(d.getName()),b=["chatmsg-link-user","chatmsg-link"];else return null;else if("#"===h[0])if(h=ta(a.context)+"|"+h.substr(1),k=wa(h))a=!0,h="#"+h,k="#"+k.name,b=["chatmsg-link-chan","chatmsg-link"];else return null;else{if(!h.match(/^(https?|mailto):\/\//i))return null;b=["chatmsg-link"];a=!1}return{link:h,text:k||h,style:d,Sa:b,Xa:a}}return{H:function(a){a.U=!0;return a},X:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},L:function(a){a.c?a.U&&(a.U=!1,a.N()):a.wa().N();return a.c},
-N:function(b){var c=F(b.O);b.c.o.innerHTML=J.P(b.o);b.c.Da.innerHTML=a(b,b.text);b.c.xa.textContent=c?c.getName():b.username||"?";for(var c=document.createDocumentFragment(),e=0,f=b.s.length;e<f;e++){var h=b.s[e];h&&(h=Sb(b,h,e))&&c.appendChild(h)}b.c.s.textContent="";b.c.s.appendChild(c);c=b.b;e=document.createDocumentFragment();if(b.D)for(var k in b.D){var f=c,h=b.id,g=k,n=b.D[k],p=$a(g);if(p){for(var l=document.createElement("li"),m=document.createElement("a"),t=document.createElement("span"),
-z=document.createElement("span"),w=[],x=0,M=n.length;x<M;x++){var H=F(n[x]);H&&w.push(H.getName())}w.sort();z.textContent=w.join(", ");t.appendChild(p);t.className="emoji-small";m.href="javascript:toggleReaction('"+f+"', '"+h+"', '"+g+"')";m.appendChild(t);m.appendChild(z);l.className="chatmsg-reaction-item";l.appendChild(m);f=l}else console.warn("Reaction id not found: "+g),f=null;f&&e.appendChild(f)}b.c.D.textContent="";b.c.D.appendChild(e);b.c.ca.ja&&(b.c.ca.ja.style.backgroundImage=b.A?'url("star_full.png")':
-'url("star_empty.png")');b.F&&(b.c.F.innerHTML=J.F(b.F),b.c.classList.add("edited"));return b},K:function(a){return a.L().cloneNode(!0)},w:function(b,d){return a(b,d)}}}();function fc(a,b,c){y.call(this,b,c);this.context=D(C.context,a);this.b=a;this.c=Z.c;this.U=Z.U}fc.prototype=Object.create(A.prototype);q=fc.prototype;q.constructor=fc;q.H=function(){return Z.H(this)};q.w=function(a){return Z.w(this,a)};q.X=function(){return Z.X(this)};q.L=function(){return Z.L(this)};
-q.wa=function(){this.c=Qb(this);this.c.classList.add("chatmsg-me_message");return this};q.K=function(){return Z.K(this)};q.N=function(){Z.N(this);return this};q.update=function(a,b){A.prototype.update.call(this,a,b);this.H()};function hc(a,b,c){y.call(this,b,c);this.context=D(C.context,a);this.b=a;this.c=Z.c;this.U=Z.U}hc.prototype=Object.create(y.prototype);q=hc.prototype;q.constructor=hc;q.H=function(){return Z.H(this)};q.w=function(a){return Z.w(this,a)};q.X=function(){return Z.X(this)};q.L=function(){return Z.L(this)};
-q.wa=function(){this.c=Qb(this);return this};q.K=function(){return Z.K(this)};q.N=function(){Z.N(this);return this};
-q.update=function(a,b){y.prototype.update.call(this,a,b);this.H();if(a=this.text.match(/^<?https:\/\/www\.openstreetmap\.org\/\?mlat=(-?[0-9\.]+)(&amp;|&)mlon=(-?[0-9\.]+)(&amp;|&)macc=([0-9\.]+)[^\s]*/))this.text=this.text.substr(0,a.index)+this.text.substr(a.index+a[0].length).trim(),this.s.unshift({color:"#008000",text:a[0],footer:"Open Street Map",footer_icon:"https://www.openstreetmap.org/assets/favicon-32x32-36d06d8a01933075bc7093c9631cffd02d49b03b659f767340f256bb6839d990.png",geo:{latitude:a[1],
-longitude:a[3],accuracy:a[5]}})};function gc(a,b,c){y.call(this,b,c);this.context=D(C.context,a);this.b=a;this.a=null;this.U=!0}gc.prototype=Object.create(B.prototype);q=gc.prototype;q.constructor=gc;q.H=function(){return Z.H(this)};q.w=function(a){return Z.w(this,a)};q.X=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};q.L=function(){Z.L(this);return this.a};q.K=function(){return this.a.cloneNode(!0)};
-q.wa=function(){this.c=Qb(this);this.a=document.createElement("span");this.c.classList.add("chatmsg-notice");this.a.className="chatmsg-notice";this.a.textContent=J.ab;this.a.appendChild(this.c);return this};q.N=function(){Z.N(this);return this};q.update=function(a,b){B.prototype.update.call(this,a,b);this.H()};var W;function Xb(a){this.T={};for(var b=0,c=a.length;b<c;b++)null===a[b].service&&null===a[b].device&&Lb(this,JSON.parse(a[b].config))}function Lb(a,b){if(b.services)for(var c in b.services)a.T[c]=b.services[c];void 0!==b.emojiProvider&&(a.h=b.emojiProvider);void 0!==b.displayAvatar&&(a.a=b.displayAvatar);void 0!==b.colorfulNames&&(a.b=b.colorfulNames)}
-function ac(){var a=W,b={},c="";!1===a.a&&(b[".chatsystem-content .chatmsg-authorGroup .chatmsg-author-img-wrapper"]=["display: none"],b[".chatsystem-content .chatmsg-authorGroup"]=["display: flex"],b[".chatsystem-content .chatmsg-authorGroup .chatmsg-author"]=["position:initial","vertical-align:top","min-width:75px"],b[".chatsystem-content .chatmsg-authorGroup .chatmsg-author-messages"]=["padding-top:0","padding-left:0","display:inline-block","margin-top:-4px","flex:1"],b[".chatmsg-author-name::before"]=
-["content:'<'"],b[".chatmsg-author-name::after"]=["content:'>'"]);!0===a.b||(b[".chatmsg-authorGroup .chatmsg-item .chatmsg-link-user, .chatsystem-content a.chatmsg-author-name, .chatmsg-author-name"]=["background-color: transparent !important;"]);for(var d in b)c+=d+"{",b[d].forEach(function(a){c+=a+";"}),c+="}";return c}W=new Xb([]);var ab=function(){var a=[];return{Wa:function(b){for(var c=0,d=a.length;c<d;c++)if(-1!==a[c].names.indexOf(b))return a[c];return null},ob:function(b){var c=[];a.forEach(function(a){for(var d=0,f=a.names.length;d<f;d++)if(a.names[d].substr(0,b.length)===b){c.push(a);break}});return c},yb:function(b){b.V="client";b.exec=b.exec.bind(b);a.push(b)}}}();function ic(){return new Promise(function(a,b){"geolocation"in window.navigator?navigator.geolocation.getCurrentPosition(function(c){c?a(c):b("denied")}):b("geolocation not available")})}
-ya.push(function(){ab.yb({name:"/sherlock",names:["/sherlock","/sharelock"],usage:"",description:J.hb,exec:function(a,b){ic().then(function(a){var c=a.coords.latitude,e=a.coords.longitude;cb(b,"https://www.openstreetmap.org/?mlat="+c+"&mlon="+e+"&macc="+a.coords.accuracy+"#map=17/"+c+"/"+e)}).catch(function(a){console.error("Error: ",a)})}})});
+function Ya(a){var b,c=document.getElementById("slashList");c.dataset.cursor&&delete c.dataset.cursor;var d=[],e=a.value;if(a.selectionStart===a.selectionEnd&&a.selectionStart){for(var f=a.selectionStart,h=a.selectionEnd;f&&" "!==e[f-1];f--);for(b=e.length;h<b&&" "!==e[h];h++);if(f!==h&&0<h-f-1){if("#"===e[f]){var k=O.j;b=e.substr(f+1,h-f-1);for(var g in k)k[g].name.length>=b.length&&k[g].name.substr(0,b.length)===b&&d.push(k[g])}else if("@"===e[f])for(g in k=P instanceof t?O.i:P.i,b=e.substr(f+1,
+h-f-1),k){var m=k[g].getName();m.length>=b.length&&m.substr(0,b.length)===b&&d.push(k[g])}else if(":"===e[f]&&window.searchEmojis){b=e.substr(f+1,h-f-1);m=window.searchEmojis(b);for(k in m){var m=window.makeEmoji(k,!1),p=document.createElement("span");p.appendChild(m);p.className="emoji-small";d.push({name:":"+k+":",Aa:p,na:Za.name})}for(g in O.b.data)g.length>=b.length&&g.substr(0,b.length)===b&&(k=document.createElement("span"),k.className="emoji-small",k.appendChild($a(g)),d.push({name:":"+g+":",
+Aa:k,na:"custom"}))}d.length&&(c.dataset.cursor=JSON.stringify([f,h]))}}if(!d.length&&"/"===e[0]){g=e.indexOf(" ");f=-1!==g;g=-1===g?e.length:g;b=e.substr(0,g);f?(a=ab.Xa(b))&&d.push(a):(d=ab.pb(b),c.dataset.cursor=JSON.stringify([0,a.selectionEnd]));a=O?O.h.data:{};for(var l in a)e=a[l],(!f&&e.name.substr(0,g)===b||f&&e.name===b)&&d.push(e);d.sort(function(a,b){return a.W.localeCompare(b.W)||a.name.localeCompare(b.name)})}c.textContent="";if(d.length){l=document.createDocumentFragment();g=0;for(a=
+d.length;g<a;g++)if(e=d[g],e instanceof ga){if(!n){var n=!0;l.appendChild(Wa(J.ma))}b=document.createElement("span");b.className="chat-command-userIcon";b.style.backgroundImage='url("'+pa(e)+'")';l.appendChild(Xa("@"+e.getName(),b))}else e instanceof v?(n||(n=!0,l.appendChild(Wa(J.j))),l.appendChild(Xa("#"+e.name))):e.Aa?(n!==e.na&&(n=e.na,l.appendChild(Wa(e.na))),l.appendChild(Xa(e.name,e.Aa))):(n!==e.W&&(n=e.W,l.appendChild(Wa(e.W))),l.appendChild(Xa(e)));c.appendChild(l)}}
+function bb(a){if(Q)return N(new K("PUT","api/msg?room="+P.id+"&ts="+Q.id+"&text="+encodeURIComponent(a))),!0;if("/"===a[0]){var b=a.indexOf(" "),c=a.substr(0,-1===b?void 0:b);a=-1===b?"":a.substr(b);var b=O,d=ab.Xa(c);if(d)return a=a.trim(),d.exec(b,P,a),!0;if(b&&(c=b.h.data[c])){if("/me"===c.name)cb(P,a,!0);else if("/msg"===c.name){a=a.trim();var b=/(\S+)\s+(.*)/.exec(a);a:{var e=b[1],d=O,f=e,h=[];"#"===f[0]&&(f=f.substr(1));for(var k in d.j)d.j[k].name===f&&h.push(d.j[k]);if(h.length)var g=h[0];
+else{k=[];"@"===e[0]&&(e=e.substr(1));for(g in d.i)d.i[g].getName()===e&&k.push(d.j[g]);if(k.length)for(g=0,d=k.length;g<d;g++)if(k[g].O){g=k[g].O;break a}g=null}}g&&cb(g,b[2],!1)}N(new K("POST","api/cmd?room="+P.id+"&cmd="+encodeURIComponent(c.name.substr(1))+"&args="+encodeURIComponent(a)));return!0}return!1}cb(P,a,!1);db(P,a,R);return!0}function S(){document.getElementById("msgInput").focus()}
+function eb(){function a(a){for(var b=1,c=0,d=a.value.length;c<d;c++)"\n"===a.value[c]&&b++;a.rows=Math.min(5,b)}var b=0,c=document.getElementById("msgInput");c.addEventListener("input",function(){if(P){var c=Date.now();b+3E3<c&&(O.self.N||P instanceof t)&&(N(new K("POST","api/typing?room="+P.id)),b=c);Ya(this);a(this)}});c.addEventListener("keydown",function(b){if(9===b.keyCode)return b.preventDefault(),!1;if(13===b.keyCode)return b.preventDefault(),b.shiftKey||b.altKey||b.ctrlKey?(this.value+="\n",
+a(this)):fb(),!1});document.getElementById("slashList").addEventListener("click",function(a){if(P){var b=a.target;if(a=this.dataset.cursor)for(a=JSON.parse(a);b&&b!==this;){if(b.dataset.input){var c=document.getElementById("msgInput"),b=b.dataset.input;c.value.length<=a[1]&&(b+=" ");c.value=c.value.substr(0,a[0])+b+c.value.substr(a[1]);c.selectionStart=c.selectionEnd=a[0]+b.length;Ya(c);c.focus();break}b=b.parentElement}}})};var gb=[],hb=0;
+function ib(){var a=document.createDocumentFragment(),b=xa(function(a){return!a.fa&&!1!==a.ba}),c=[],d=[],e=[],f=[],h={};b.sort(function(a,b){if(a[0]!==b[0])return a[0]-b[0];var c=D(C.context,a),d=D(C.context,b);a=c.j[a];b=d.j[b];return a.name===b.name?(h[a.id]=J.za(c.a.name,a.name),h[b.id]=J.za(d.a.name,b.name),c.a.name.localeCompare(d.a.name)):a.name.localeCompare(b.name)});b.forEach(function(a){a=wa(a);if(a instanceof t){var b;if(b=!a.a.Ua){var k=h[a.id];b=document.createElement("li");var p=document.createElement("a");
+b.id="room_"+a.id;p.href="#"+a.id;b.className="chat-context-room chat-ims presence-indicator";p.textContent=k||a.a.getName();b.appendChild(jb());b.appendChild(p);a.a.N||b.classList.add("presence-away");P===a&&b.classList.add("selected");a.I!==a.C&&void 0!==a.I&&(b.classList.add("unread"),b.classList.add("unreadHi"));b=k=b}b&&(a.A?c.push(k):f.push(k))}else if(k=h[a.id],b=document.createElement("li"),p=document.createElement("a"),b.id="room_"+a.id,p.href="#"+a.id,a.h?(b.className="chat-context-room chat-group",
+b.dataset.count=Object.keys(a.i||{}).length):b.className="chat-context-room chat-channel",P===a&&b.classList.add("selected"),p.textContent=k||a.name,b.appendChild(jb()),b.appendChild(p),a.I!==a.C&&void 0!==a.I&&(b.classList.add("unread"),0<=T.indexOf(a)&&b.classList.add("unreadHi")),k=b)a.A?c.push(k):a.h?e.push(k):d.push(k)});c.length&&a.appendChild(kb(J.A));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(kb(J.j));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});
+f.length&&a.appendChild(kb(J.gb));f.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);lb.apply(document.getElementById("chanSearch"));mb();nb();O&&ob(O.a.id,O.i,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"})}
+function pb(){va(function(a){var b=a.u,c;for(c in a.self.j)if(!a.self.j[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.i)(c=a.i[e].O)&&!c.fa&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing"))});qb()}
+function qb(){var a;document.getElementById("whoistyping").textContent="";if(O&&P&&(a=O.u[P.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=F(d))?b.appendChild(rb(a)):c=!0;c&&(C.b=0);document.getElementById("whoistyping").appendChild(b)}}function sb(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");nb()}
+function tb(){var a=P.name||(P.a?P.a.getName():void 0);if(!a){console.error("No name provided for ",P);var a=[],b;for(b in P.i)a.push(P.i[b].getName());a=a.join(", ")}document.getElementById("currentRoomTitle").textContent=a;U();S();document.getElementById("fileUploadContainer").classList.add("hidden");ub();R&&(R=null,V());Q&&(Q=null,V());nb();qb()}
+function V(){if(R){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){R=null;V()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(R.L())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";S()}
+function vb(){if(Q){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){Q=null;vb()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(Q.L());document.getElementById("msgInput").value=Q.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";S()}
+window.toggleReaction=function(a,b,c){var d=C.a[a],e,f;(d=C.a[a])&&(e=oa(d,b))&&(f=D(C.context,a))&&(e.D[c]&&-1!==e.D[c].indexOf(f.self.id)?N(new K("DELETE","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c))):wb(a,b,c))};function xb(a,b){document.getElementById("linkFavicon").href=a||b?"favicon.png?h="+a+"&m="+b:"favicon_ok.png"}
+function nb(){var a=T.length,b="";if(W)b="!"+J.$a+" - Mimouchat",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+")",xb(a,a);else{var c=0;ua(C.context,function(a){a.I>a.C&&c++});c&&(b="("+c+")");xb(0,c)}!b.length&&P&&(b=P.name);document.title=b.length?b:"Mimouchat"}
+function yb(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(hb+3E4<a){var b=new Notification(J.ab);hb=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
+function U(){var a=document.createDocumentFragment(),b=P.id,c=null,d=0,e=null,f;P.A?document.getElementById("chatSystemContainer").classList.add("starred"):document.getElementById("chatSystemContainer").classList.remove("starred");gb=[];C.a[b]&&C.a[b].a.forEach(function(b){if(b.h)b.Y();else{var g=b.M(),h=!1;c&&c.K===b.K&&b.K?30>Math.abs(d-b.m)&&!(b instanceof z)?e.classList.add("chatmsg-same-ts"):d=b.m:(d=b.m,h=!0);(!c||c.m<=P.C)&&b.m>P.C?g.classList.add("chatmsg-first-unread"):g.classList.remove("chatmsg-first-unread");
+if(b instanceof z)e=c=null,d=0,a.appendChild(g),f=null;else{if(h||!f)f=zb(F(b.K),b.username),gb.push(f),a.appendChild(f);c=b;e=g;f.content.appendChild(g)}}});var h=!0;Ab.forEach(function(b){b.channel===P.id&&(h&&(f=zb(O.self,""),a.appendChild(f),h=!1),f.content.appendChild(b.c))});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;Bb();window.hasFocus&&ub()}
+function Cb(a,b){if(a.classList.contains("chatmsg-hover-reply"))Q&&(Q=null,vb()),R!==b&&(R=b,V());else if(a.classList.contains("chatmsg-hover-reaction")){var c=P.id,d=b.id;Db.pa(document.body,O,function(a){a&&wb(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(R&&(R=null,V()),Q!==b&&(Q=b,vb())):a.classList.contains("chatmsg-hover-star")?b.A?N(new K("DELETE","api/starMsg?room="+P.id+"&msgId="+b.id)):N(new K("POST","api/starMsg?room="+P.id+"&msgId="+b.id)):a.classList.contains("chatmsg-hover-pin")?
+b.pinned?Eb(P,b):N(new K("POST","api/pinMsg?room="+P.id+"&msgId="+b.id)):a.classList.contains("chatmsg-hover-remove")&&(R&&(R=null,V()),Q&&(Q=null,vb()),N(new K("DELETE","api/msg?room="+P.id+"&ts="+b.id)))}function cb(a,b,c){Ab.push({channel:a.id,text:b.trim(),Ba:c,c:Fb(b,c)});a===P&&U()}
+function Gb(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=oa(C.a[P.id],d))&&a.s[e]&&a.s[e].actions&&a.s[e].actions[f]&&
+Hb(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=oa(C.a[P.id],d))&&Cb(c,a);break}c=c.parentElement}}
+function Hb(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 B,message_ts:a.id},h=new K("POST","api/attachmentAction?serviceId="+a.K);N(h,JSON.stringify(d))}var e=P.id;c.confirm?Va(Ua(new Ha(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).pa():d()}
+function Bb(){if(!1!==X.a){var a=document.getElementById("chatWindow").getBoundingClientRect().top;gb.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"})}}
+document.addEventListener("DOMContentLoaded",function(){za();Ib();eb();var a=document.getElementById("chanSearch");a.addEventListener("input",lb);a.addEventListener("blur",lb);document.getElementById("chatWindow").addEventListener("click",Gb);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&mb()});document.addEventListener("mouseover",function(a){a=a.target;if(Jb.vb(a))Jb.$();else{for(;a&&a!==this;){if("A"===a.nodeName){var b=a.href,d=b.indexOf("#");
+if(0<=d){b=b.substr(d+1);if(d=D(C.context,b)){Jb.eb(d,d.j[b]).show(a);return}a:{for(var d=C.context,e=0,f=d.a.length;e<f;e++)if(d.a[e].i[b]){d=d.a[e];break a}d=null}if(d&&(b=d.i[b].O)){Jb.eb(d,b).show(a);return}}}a=a.parentElement}Jb.sb()}});document.getElementById("currentRoomStar").addEventListener("click",function(a){a.preventDefault();P&&(P.A?N(new K("POST","api/unstarChannel?room="+P.id)):N(new K("POST","api/starChannel?room="+P.id)));return!1});document.getElementById("fileUploadCancel").addEventListener("click",
+function(a){a.preventDefault();document.getElementById("fileUploadError").classList.add("hidden");document.getElementById("fileUploadContainer").classList.add("hidden");document.getElementById("fileUploadInput").value="";return!1});document.getElementById("ctxMenuLogout").addEventListener("click",Kb);document.getElementById("ctxMenuSettings").addEventListener("click",function(a){a.preventDefault();Lb.display()});document.getElementById("fileUploadForm").addEventListener("submit",function(a){a.preventDefault();
+a=document.getElementById("fileUploadInput");var b=a.value;b&&(b=b.substr(b.lastIndexOf("\\")+1),Mb(b,a.files[0],function(a){var b=document.getElementById("fileUploadError");a?(b.textContent=a,b.classList.remove("hidden")):(b.classList.add("hidden"),document.getElementById("fileUploadInput").value="",document.getElementById("fileUploadContainer").classList.add("hidden"))}));return!1});document.getElementById("attachFile").addEventListener("click",function(a){a.preventDefault();P&&document.getElementById("fileUploadContainer").classList.remove("hidden");
+return!1});document.getElementById("msgFormSubmit").addEventListener("click",function(a){a.preventDefault();fb();return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();fb();return!1});window.addEventListener("blur",function(){window.hasFocus=!1});window.addEventListener("focus",function(){window.hasFocus=!0;hb=0;P&&ub();S()});document.getElementById("chatWindow").addEventListener("scroll",Bb);window.hasFocus=!0;document.getElementById("emojiButton").addEventListener("click",
+function(){O&&Db.pa(document.body,O,function(a){a&&(document.getElementById("msgInput").value+=":"+a+":");S()})});Nb()});function fb(){var a=document.getElementById("msgInput");P&&a.value&&bb(a.value)&&(a.value="",R&&(R=null,V()),Q&&(Q=null,V()),document.getElementById("slashList").textContent="");S()};var Lb=function(){function a(){document.getElementById("settings").classList.add("hidden");c=!1}function b(a){d&&(document.getElementById("settings").classList.remove("display-"+d),document.getElementById("setting-menu-"+d).classList.remove("selected"),document.getElementById("settings-serviceAddSection").classList.add("hidden"));document.getElementById("settings").classList.add("display-"+a);document.getElementById("setting-menu-"+a).classList.add("selected");d=a}var c=!1,d=null,e={U:"services",
+display:"display",Pb:"privacy"};document.getElementById("settingMenuItems").addEventListener("click",function(a){for(var c=a.target;a.currentTarget!==c&&c;c=c.parentNode)if(c.dataset&&c.dataset.target)for(var d in e)if(e[d]===c.dataset.target){b(e[d]);return}});document.getElementById("settingDiscardClose").addEventListener("click",a);document.getElementById("settings-serviceAddButton").addEventListener("click",function(a){a.preventDefault();document.getElementById("settings-serviceAddSection").classList.remove("hidden");
+return!1});document.getElementById("settings-serviceAddConfirm").addEventListener("click",function(a){a.preventDefault();document.location.href=document.getElementById("settings-serviceAddServiceList").value;return!1});document.getElementById("settingCommit").addEventListener("click",function(){var b={};document.getElementById("settings-displayEmojiProvider").value!==X.h&&(b.emojiProvider=document.getElementById("settings-displayEmojiProvider").value);var c=!!document.getElementById("settings-displayDisplayAvatar").checked;
+c!==(!1!==X.a)&&(b.displayAvatar=c);c=!!document.getElementById("settings-displayColorfulNames").checked;c!==(!0===X.b)&&(b.colorfulNames=c);var c=X,d;for(d in b){Ob(c,b);Pb();N(new K("POST","api/settings?service=null&device=null"),JSON.stringify(b));break}a()});return{display:function(a){if(!c){document.getElementById("settings").classList.remove("hidden");var d=document.createDocumentFragment(),f=!1,g;for(g in X.U){var m=X.U[g];for(n in m){var f=document.createElement("li"),p=document.createElement("span"),
+l=document.createElement("span");p.textContent=g;l.textContent=m[n];f.className="settings-service-list-item";p.className="settings-service-list-item-provider";l.className="settings-service-list-item-service";f.appendChild(p);f.appendChild(l);d.appendChild(f);f=!0}}m=document.getElementById("settings-serviceList");m.textContent="";f?(document.getElementById("settings-serviceListEmpty").classList.remove("hidden"),m.appendChild(d)):document.getElementById("settings-serviceListEmpty").classList.add("hidden");
+d=document.createDocumentFragment();m=document.getElementById("settings-displayEmojiProvider");for(g in Qb){var n=document.createElement("option");n.value=g;n.textContent=Qb[g].name;Qb[g]===Za&&(n.selected=!0);d.appendChild(n)}m.textContent="";m.appendChild(d);document.getElementById("settings-displayDisplayAvatar").checked=!1!==X.a;document.getElementById("settings-displayColorfulNames").checked=!0===X.b;c=!0}b(a||e.U);return this},Ab:function(){return this},xb:e}}();function Rb(a){if(void 0!==a.latitude&&void 0!==a.longitude&&-90<=a.latitude&&90>=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.S=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"),h=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)))},g=function(a,d,e,g){h.fillStyle="#808080";h.fillRect(0,0,300,300);f.fillStyle="#808080";f.fillRect(0,0,300,300);var p=Math.pow(2,a),n=(e+180)/360*p,m=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*p,l=Math.floor(n),L=Math.floor(m),
+qa=g?100*g/k(180/Math.PI*Math.atan(.5*(Math.exp(Math.PI-2*Math.PI*L/p)-Math.exp(-(Math.PI-2*Math.PI*L/p)))),l/p*360-180,(l+1)/p*360-180):0;d=b;for(e=0;3>e;e++)for(g=0;3>g;g++)c(a,l+e-1,L+g-1,{tb:e,wb:g,kb:d}).then(function(a){if(a.kb===b){h.drawImage(a.S,100*a.tb,100*a.wb,100,100);a=n-l;var c=m-L;a=100*a+100;c=100*c+100;f.putImageData(h.getImageData(0,0,300,300),0,0);void 0!==qa&&(f.beginPath(),f.arc(a,c,Math.max(qa,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===qa||25<qa)f.strokeStyle="rgba(244, 146, 66, 1)",f.beginPath(),f.moveTo(a-5,c-5),f.lineTo(a+5,c+5),f.stroke(),f.moveTo(a+5,c-5),f.lineTo(a-5,c+5),f.stroke()}})},m,p=function(c){c=Math.max(4,Math.min(19,c));m!==c&&(b++,m=c,g(m,Number(a.latitude),Number(a.longitude),Number(a.accuracy)))};p(12);var e=document.createElement("div"),l=document.createElement("div"),n=document.createElement("button"),u=document.createElement("button");e.className=
+"OSM-wrapper";d.className="OSM-canvas";l.className="OSM-controls";u.className="OSM-controls-zoomMin";n.className="OSM-controls-zoomPlus";u.addEventListener("click",function(){p(m-1)});n.addEventListener("click",function(){p(m+1)});l.appendChild(u);l.appendChild(n);e.appendChild(d);e.appendChild(l);return e}};function jb(){var a=document.createElement("span"),b=document.createElement("span"),c=document.createElement("span"),d=document.createElement("span");a.className="typing-container";b.className="typing-dot1";c.className="typing-dot2";d.className="typing-dot3";b.textContent=c.textContent=d.textContent=".";a.appendChild(b);a.appendChild(c);a.appendChild(d);return a}var kb=function(){var a={};return function(b){var c=a[b];c||(c=a[b]=document.createElement("header"),c.textContent=b);return c}}();
+function Sb(a){var b={},c=a;if(O)for(var d=O;!b[a];){var e=d.b.data[a];if(e)if("alias:"==e.substr(0,6))b[a]=!0,a=e.substr(6);else return a=document.createElement("span"),a.className="emoji-custom emoji",a.style.backgroundImage="url('"+e+"')",a.textContent=":"+c+":",a.title=c,a;else return a}return c}function $a(a){return"makeEmoji"in window?(a=Sb(a),"string"===typeof a&&(a=window.makeEmoji(a)),"string"===typeof a?null:a):null}
+function Tb(a){var b=document.createElement("div"),c=document.createElement("div");b.ca=document.createElement("ul");b.s=document.createElement("ul");b.D=document.createElement("ul");b.m=document.createElement("div");b.qa=document.createElement("div");b.ha=document.createElement("span");b.className="chatmsg-item";b.m.className="chatmsg-ts";b.qa.className="chatmsg-msg";b.ha.className="chatmsg-author-name";if(a){b.id=a.b+"_"+a.id;var d=b.ca,e=a.context.aa;a=C.context.Ba(a.K);if(e.replyToMsg){var f=
+document.createElement("li");f.className="chatmsg-hover-reply";f.style.backgroundImage='url("repl.svg")';d.appendChild(f)}e.reactMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-reaction",f.style.backgroundImage='url("smile.svg")',d.appendChild(f));if(a&&e.editMsg||e.editOtherMsg)f=document.createElement("li"),f.className="chatmsg-hover-edit",f.style.backgroundImage='url("edit.svg")',d.appendChild(f);e.starMsg&&(d.ka=document.createElement("li"),d.ka.className="chatmsg-hover-star",
+d.appendChild(d.ka));e.pinMsg&&(f=document.createElement("li"),f.className="chatmsg-hover-pin",d.appendChild(f),f.style.backgroundImage='url("pin.svg")');if(a&&e.removeMsg||e.moderate)e=document.createElement("li"),e.className="chatmsg-hover-remove",e.style.backgroundImage='url("remove.svg")',d.appendChild(e);b.ca.className="chatmsg-hover"}c.appendChild(b.ha);c.appendChild(b.qa);c.appendChild(b.m);c.appendChild(b.s);b.F=document.createElement("div");b.F.className="chatmsg-edited";c.appendChild(b.F);
+c.appendChild(b.D);c.className="chatmsg-content";b.s.className="chatmsg-attachments";b.D.className="chatmsg-reactions";b.appendChild(c);b.appendChild(b.ca);return b}
+function Ub(a){if(!a.length)return"black";for(var b=0,c=0,c=[],d=0,e=0,f=0,h,k=0,g=a.length;k<g;k++)c[k]=a.charCodeAt(k),d+=c[k];h=d/a.length;c.forEach(function(a){var c=Math.abs(h-a);e+=c;f=Math.max(c,f);b=a+((b<<5)-b)});e/=a.length;b=Math.abs(b-60)%199*360/199;c=f?Math.round(Math.min(100,Math.max(75,e/f*25+75))):100;return"hsl("+b+", 100%, "+c+"%)"}
+function zb(a,b){var c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("a"),f=document.createElement("img");c.ga=document.createElement("span");c.ga.className="chatmsg-author-img-wrapper";f.className="chatmsg-author-img";e.className="chatmsg-author-name";e.href="#"+a.id;a?(e.textContent=a.getName(),e.style.backgroundColor=Ub(a.getName()),f.src=pa(a)):(e.textContent=b||"?",f.src="");c.ga.appendChild(f);d.appendChild(c.ga);d.appendChild(e);d.className="chatmsg-author";
+c.className="chatmsg-authorGroup";c.appendChild(d);c.content=document.createElement("div");c.content.className="chatmsg-author-messages";c.appendChild(c.content);return c}function Vb(a){var b={good:"#2fa44f",warning:"#de9e31",danger:"#d50200"};if(a){if("#"===a[0])return a;if(b[a])return b[a]}return"#e3e4e6"}
+function Wb(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),f=document.createElement("div"),h=document.createElement("a"),k=document.createElement("div"),g=document.createElement("img"),m=document.createElement("a"),p=document.createElement("div"),l=document.createElement("div"),n=document.createElement("div"),u=document.createElement("img"),A=document.createElement("div");d.className="chatmsg-attachment";e.style.borderColor=Vb(b.color||"");e.className="chatmsg-attachment-block";
+f.className="chatmsg-attachment-pretext";b.pretext?f.innerHTML=a.w(b.pretext):f.classList.add("hidden");h.target="_blank";b.title?(h.innerHTML=a.w(b.title),b.title_link&&(h.href=b.title_link),h.className="chatmsg-attachment-title"):h.className="hidden chatmsg-attachment-title";m.target="_blank";k.className="chatmsg-author";b.author_name&&(m.innerHTML=a.w(b.author_name),m.href=b.author_link||"",m.className="chatmsg-author-name",g.className="chatmsg-author-img",b.author_icon&&(g.src=b.author_icon,k.appendChild(g)),
+k.appendChild(m));n.className="chatmsg-attachment-thumb";b.thumb_url?(g=document.createElement("img"),g.src=b.thumb_url,n.appendChild(g),e.classList.add("has-thumb"),b.video_html&&(n.dataset.video=b.video_html)):n.classList.add("hidden");p.className="chatmsg-attachment-content";g=a.w(b.text||"");l.className="chatmsg-attachment-text";g&&""!=g?l.innerHTML=g:l.classList.add("hidden");p.appendChild(n);p.appendChild(l);b.geo&&(l=Rb(b.geo))&&p.appendChild(l);u.className="chatmsg-attachment-img";b.image_url?
+u.src=b.image_url:u.classList.add("hidden");A.className="chatmsg-attachment-footer";b.footer&&(l=document.createElement("span"),l.className="chatmsg-attachment-footer-text",l.innerHTML=a.w(b.footer),b.footer_icon&&(n=document.createElement("img"),n.src=b.footer_icon,n.className="chatmsg-attachment-footer-icon",A.appendChild(n)),A.appendChild(l));b.ts&&(l=document.createElement("span"),l.className="chatmsg-ts",l.innerHTML=J.R(b.ts),A.appendChild(l));e.appendChild(h);e.appendChild(k);e.appendChild(p);
+e.appendChild(u);if(b.fields&&b.fields.length){var x=document.createElement("ul");e.appendChild(x);x.className="chatmsg-attachment-fields";b.fields.forEach(function(b){var c=b.title||"",d=b.value||"";b=!!b["short"];var e=document.createElement("li"),f=document.createElement("div"),g=document.createElement("div");e.className="field";b||e.classList.add("field-long");f.className="field-title";f.textContent=c;g.className="field-text";g.innerHTML=a.w(d);e.appendChild(f);e.appendChild(g);e&&x.appendChild(e)})}if(b.actions&&
+b.actions.length)for(h=document.createElement("ul"),h.className="chatmsg-attachment-actions "+Qa,e.appendChild(h),k=0,p=b.actions.length;k<p;k++)(u=b.actions[k])&&(u=Xb(c,k,u))&&h.appendChild(u);e.appendChild(A);d.appendChild(f);d.appendChild(e);return d}
+function Xb(a,b,c){var d=document.createElement("li"),e=Vb(c.style);d.textContent=c.text;e!==Vb()&&(d.style.color=e);d.style.borderColor=e;d.dataset.attachmentIndex=a;d.dataset.actionIndex=b;d.className="chatmsg-attachment-actions-item "+Oa;return d}function rb(a){var b=document.createElement("li"),c=document.createElement("span");c.textContent=a.getName();b.appendChild(jb());b.appendChild(c);return b};var Db=function(){function a(a,b){for(a=a.target;a!==m&&a&&"LI"!==a.nodeName;)a=a.parentElement;a&&"LI"===a.nodeName&&a.id&&"emojibar-"===a.id.substr(0,9)?b(a.id.substr(9)):b(null)}function b(){x={};l.textContent="";window.emojiProviderHeader&&(l.appendChild(k(window.emojiProviderHeader)),n.textContent="",l.appendChild(n));l.appendChild(k("emojicustom.png"));l.appendChild(u)}function c(){if(!d())return!1;r&&r(null);return!0}function d(){return m.parentElement?(m.parentElement.removeChild(p),m.parentElement.removeChild(m),
+!0):!1}function e(a){var b=0;a=void 0===a?A.value:a;if(g()){var c=0,d=window.searchEmojis(a),e=f(d,I?I.self.T.a:[]),p;for(k in x)x[k].visible&&(x[k].visible=!1,n.removeChild(x[k].c));var k=0;for(p=e.length;k<p;k++){var m=e[k].name,l=x[m];if(!l){var l=x,L=m;var r=m;var m=window.makeEmoji(d[m]),H=document.createElement("span");H.appendChild(m);H.className="emoji-medium";r=h(r,H);l=l[L]=r}l.visible||(l.visible=!0,n.appendChild(l.c));c++}b+=c}k=b;c=0;for(E in y)y[E].visible&&(y[E].visible=!1,u.removeChild(y[E].c));
+if(I){d=f(I.b.data,I?I.self.T.a:[]);var E=0;for(b=d.length;E<b;E++)L=d[E].name,""!==a&&L.substr(0,a.length)!==a||"alias:"===I.b.data[L].substr(0,6)||(e=y[L],e||(e=y,l=p=L,L=I.b.data[L],r=document.createElement("span"),m=document.createElement("span"),r.className="emoji emoji-custom",r.style.backgroundImage='url("'+L+'")',r.textContent=":"+l+":",r.title=l,m.appendChild(r),m.className="emoji-medium",l=h(l,m),e=e[p]=l),e.visible||(e.visible=!0,u.appendChild(e.c)),c++);E=c}else E=0;return k+E}function f(a,
+b){var c=[],d;for(d in a){var e={name:d,fb:0,count:0};if(a[d].names)for(var f=0,g=a[d].names.length;f<g;f++)e.count+=b[a[d].names[f]]||0;c.push(e)}return c=c.sort(function(a,b){var c=b.count-a.count;return c?c:a.fb-b.fb})}function h(a,b){var c=document.createElement("li");c.appendChild(b);c.className="emojibar-list-item";c.id="emojibar-"+a;return{visible:!1,c:c}}function k(a){var b=document.createElement("img"),c=document.createElement("div");b.src=a;c.appendChild(b);c.className="emojibar-header";
+return c}function g(){return"searchEmojis"in window}var m=document.createElement("div"),p=document.createElement("div"),l=document.createElement("div"),n=document.createElement("ul"),u=document.createElement("ul"),A=document.createElement("input"),x={},y={},M=document.createElement("div"),H=document.createElement("span"),E=document.createElement("span"),r,I;p.addEventListener("click",function(a){var b=m.getBoundingClientRect();(a.screenY<b.top||a.screenY>b.bottom||a.screenX<b.left||a.screenX>b.right)&&
+c()});p.className="emojibar-overlay";m.className="emojibar";l.className="emojibar-emojis";n.className=u.className="emojibar-list";A.className="emojibar-search";M.className="emojibar-detail";H.className="emojibar-detail-img";E.className="emojibar-detail-name";M.appendChild(H);M.appendChild(E);b();m.appendChild(l);m.appendChild(M);m.appendChild(A);A.addEventListener("keyup",function(){e()});m.addEventListener("mousemove",function(b){a(b,function(a){var b=a?x[a]||y[a]:null;b?(H.innerHTML=b.c.outerHTML,
+E.textContent=":"+a+":"):(H.textContent="",E.textContent="")})});m.addEventListener("click",function(b){a(b,function(a){a&&d()&&r&&r(a)})});return{isSupported:g,pa:function(a,b,c){return g()?(I=b,r=c,a.appendChild(p),a.appendChild(m),A.value="",e(),A.focus(),!0):!1},search:e,close:c,reset:function(){b();e()}}}();var C,T=[];function Yb(){da.call(this)}Yb.prototype=Object.create(da.prototype);Yb.prototype.constructor=Yb;function ta(a){return a.a?a.a.id:null}function Zb(){this.b=0;this.context=new ra;this.a={}}
+Zb.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(g in a["static"]){var c=sa(this.context,g);c||(c=new Yb,this.context.push(c));var d={};a["static"][g].channels&&a["static"][g].channels.forEach(function(a){a.pins&&(d[a.id]=a.pins,a.pins=void 0)});fa(c,a["static"][g],b);for(var e in d){var f=[],h=this.a[e];h||(h=this.a[e]=new Y(e,250,null,b));d[e].forEach(function(a){f.push(h.b(a,b))});c.j[e].b=f}}ua(this.context,function(a){a.I===a.C&&(a=T.indexOf(a),-1!==a&&T.splice(a,
+1))});if(a.live){for(g in a.live)(c=this.a[g])?la(c,a.live[g],b):c=this.a[g]=new Y(g,250,a.live[g],b);for(var k in a.live){var g=D(this.context,k);(c=g.j[k])?(this.a[k].a.length&&ha(c,na(this.a[k]).m,b),c.fa||($b(g,c,a.live[k]),P&&a.live[P.id]&&U())):C.b=0}}a["static"]&&ib();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&&!e[g]&&(delete c.u[g],f=!0);if(e)for(g in e)if(c.j[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)&&pb();a.config&&(X=new ac(a.config),Pb());if(O&&P&&a["static"]&&a["static"][O.a.id]&&a["static"][O.a.id].channels&&a["static"][O.a.id].channels)for(k=a["static"][O.a.id].channels,g=0,c=k.length;g<c;g++)if(k[g].id===P.id){U();break}};setInterval(function(){var a=!1,b=Date.now();va(function(c){var d=!1,e;for(e in c.u){var f=!0,h;for(h in c.u[e])c.u[e][h]+5E3<b?(delete c.u[e][h],d=!0):f=!1;f&&(delete c.u[e],d=!0)}d&&(a=!0)});a&&pb()},1E3);
+function $b(a,b,c){var d;if(b!==P||!window.hasFocus){var e=(d=a.self?a.self.id:null)?new RegExp("<@"+d):null,f=!1,h=!1,k=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.C)&&c.user!==a.self.id){h=!0;var d;if(!(d=b instanceof t)&&(d=c.text)&&!(d=e&&c.text.match(e)))a:{d=a.self.T.B;for(var g=0,m=d.length;g<m;g++)if(-1!==c.text.indexOf(d[g])){d=!0;break a}d=!1}d&&(-1===T.indexOf(b)&&(k=!0,T.push(b)),f=!0)}});if(h){nb();var g=document.getElementById("room_"+b.id);g&&(g.classList.add("unread"),f&&g.classList.add("unreadHi"));
+k&&!window.hasFocus&&yb()}}c.forEach(function(a){if(!d||d===a.K)for(var c=0,e=Ab.length;c<e;c++){var f=Ab[c];if(f.channel===b.id&&a.text&&a.text.trim()===f.text&&!!a.isMeMessage===f.Ba){Ab.splice(c,1);break}}})}
+function ub(){var a=P,b=T.indexOf(a);if(a.I>a.C){var c=C.a[a.id];c&&(c=c.a[c.a.length-1])&&(N(new K("POST","api/markread?room="+a.id+"&id="+c.id+"&ts="+c.m)),a.C=c.m)}0<=b&&(T.splice(b,1),nb());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}C=new Zb;var ob=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;e<m-40;e+=l)for(var f=0;f+l<=p;f+=l)h(a,c[d],e,f),d++,d===c.length&&(c.sort(b),d=0)}function b(a,b){return a.S?b.S?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].S){d(a[e].src,function(d){a[e].S=d;c(a,b)});return}var g=[];a.forEach(function(a){a.S&&g.push(a.S)});b(g)}function d(a,b){N(Ga(Ea(Da(new K(a),function(a,c,d){if(d){var e=new Image;e.onload=function(){var a=
+document.createElement("canvas");a.height=a.width=A;a=a.getContext("2d");a.drawImage(e,0,0,A,A);var a=a.getImageData(0,0,A,A),c=0,d;for(d=0;d<a.width*a.height*4;d+=4)a.data[d]=a.data[d+1]=a.data[d+2]=(a.data[d]+a.data[d+1]+a.data[d+2])/3,a.data[d+3]=50,c+=a.data[d];if(50>c/(a.height*a.width))for(d=0;d<a.width*a.height*4;d+=4)a.data[d]=a.data[d+1]=a.data[d+2]=255-a.data[d];b(a)};e.onerror=function(){b(null)};e.src=window.URL.createObjectURL(d)}else b(null)}),function(){b(null)}),"blob"))}function e(){var a=
+g.createLinearGradient(0,0,0,p);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");g.fillStyle=a;g.fillRect(0,0,m,p);return g.getImageData(0,0,m,p)}function f(a,b){for(var c=(a.height-b.height)/2,d=0;d<b.height;d++)for(var e=0;e<b.width;e++){var f=b.data[4*(d*b.width+e)]/255,g=4*((d+c)*a.width+e+c);a.data[g]*=f;a.data[g+1]*=f;a.data[g+2]*=f}return a}function h(a,b,c,d){var e=Math.floor(d);a=[a.data[e*m*4+0],a.data[e*m*4+1],a.data[e*m*4+2]];g.fillStyle="#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);
+g.beginPath();g.moveTo(c+l/2,d+n);g.lineTo(c-n+l,d+l/2);g.lineTo(c+l/2,d-n+l);g.lineTo(c+n,d+l/2);g.closePath();g.fill();g.putImageData(f(g.getImageData(c+n,d+n,u,u),b),c+n,d+n)}var k=document.createElement("canvas"),g=k.getContext("2d"),m=k.width=250,p=k.height=290,l=(m-40)/3,n=.1*l,u=Math.floor(l-2*n),A=.5*u,x={},y={},M={};return function(b,d,f){if(x[b])f(x[b]);else if(M[b])y[b]?y[b].push(f):y[b]=[f];else{var g=e(),h=[];M[b]=!0;y[b]?y[b].push(f):y[b]=[f];for(var l in d)d[l].Ua||d[l].ub||h.push({src:pa(d[l])});
+c(h,function(c){a(g,c);x[b]=k.toDataURL();y[b].forEach(function(a){a(x[b])})})}}}();var W=0,P=null,O=null,R=null,Q=null,Ab=[];function Ib(){N(Fa(Ea(Da(new K("highlight.pack.js"),function(a,b,c){a=document.createElement("script");b=document.createElement("link");a.innerHTML=c;a.language="text/javascript";b.href="hljs-androidstudio.css";b.rel="stylesheet";document.head.appendChild(b);document.body.appendChild(a)}),function(){console.error("Failure loading hljs required files")})))}
+function bc(){var a=P;N(Ca(Da(Ga(new K("api/hist?room="+a.id),"json"),function(b,c,d){d&&((b=C.a[a.id])?b=!!la(b,d,Date.now()):(C.a[a.id]=new Y(a,100,d,Date.now()),b=!0),b&&($b(D(C.context,a.id),a,d),a===P&&U()))}),function(){}))}function Pb(){a:{var a=X.U;for(var b in a)if(a.hasOwnProperty(b)){a=!1;break a}a=!0}a&&Lb.Ab(!1).display(Lb.xb.U);a=X.h;cc(a&&Qb[a]?Qb[a]:dc);document.getElementById("customsheet").innerHTML=ec()}
+function Nb(){var a=fc;N(Fa(Ga(Ca(new K("api?v="+C.b),function(b,c,d){(b=2===Math.floor(b/100))?W&&(W=0,sb(!0)):W?(W+=Math.floor((W||5)/2),W=Math.min(60,W)):(W=5,sb(!1));a(b,d)}),"json")))}function fc(a,b){a?(b&&C.update(b),Nb()):setTimeout(gc,1E3*W)}function gc(){Nb()}
+function hc(a){P&&(document.getElementById("room_"+P.id).classList.remove("selected"),document.getElementById("chatSystemContainer").classList.add("no-room-selected"));document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");P=a;O=D(C.context,a.id);tb();Jb.rb();ob(O.a.id,O.i,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"});(!C.a[P.id]||100>C.a[P.id].a.length)&&bc();document.getElementById("chatSystemContainer").classList.remove("no-room-selected")}
+function mb(){var a=document.location.hash.substr(1),b=wa(a);b&&b!==P?hc(b):(a=F(a))&&a.O&&hc(a.O)}function Mb(a,b,c){var d=P;new FileReader;var e=new FormData;e.append("file",b);e.append("filename",a);N(Ea(Da(new K("POST","api/file?room="+d.id),function(){c(null)}),function(a,b){c(b)}),e)}
+function db(a,b,c){b="api/msg?room="+a.id+"&text="+encodeURIComponent(b);c&&(b+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:c.text,author_name:F(c.K).getName(),text:c.text,footer:a.h?J.message:a.name,ts:c.m}])));N(new K("POST",b))}function Eb(a,b){N(new K("DELETE","api/pinMsg?room="+a.id+"&msgId="+b.id))}function wb(a,b,c){N(new K("POST","api/reaction?room="+a+"&msg="+b+"&reaction="+encodeURIComponent(c)))}
+function Kb(){N(new K("POST","api/logout"));document.cookie="sessID=;Path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;";document.location.reload()}function lb(){var a={},b=[],c=this.value;ua(C.context,function(b){a[b.id]=ia(b,c)});for(var d in a){var e=document.getElementById("room_"+d);e&&(a[d].name+a[d].ma+a[d].sa+a[d].oa?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var Qb={noemoji:{Ca:"noemoji.js",ia:null,name:"None"},emojione_v2_3:{Ca:"emojione_v2.3.sprites.js",ia:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Ca:"emojione_v3.sprites.js",ia:"emojione_v3.sprites.css",name:"Emojione v3"}},dc=Qb.emojione_v2_3,Za;
+function cc(a){Za!==a&&(console.log("Loading emoji pack "+a.name),N(Fa(Da(new K(a.Ca),function(b,c,d){b=document.createElement("script");b.innerHTML=d;b.language="text/javascript";document.body.appendChild(b);a.ia&&(d=document.createElement("link"),d.href=a.ia,d.rel="stylesheet",document.head.appendChild(d));d=document.getElementById("emojiButton");for(var e in C.a)ic(C.a[e]);P&&U();Db.reset();"makeEmoji"in window?(d.style.backgroundImage='url("smile.svg")',d.classList.remove("hidden")):d.classList.add("hidden")}))),
+Za=a)};var Jb=function(){function a(){c();r instanceof t?(f.style.backgroundImage="url(api/avatar?size=l&user="+r.a.id+")",m.textContent=(r.a.hb||(r.a.Wa||"")+" "+r.a.Za).trim(),h.classList.add("presence-indicator"),r.a.N?h.classList.remove("presence-away"):h.classList.add("presence-away"),g.classList.remove("hidden"),l.classList.remove("hidden"),l.textContent=r.a.yb||"",u.textContent=r.a.qb||"",n.classList.remove("hidden"),e.classList.remove("roominfo-channel"),e.classList.add("roominfo-user")):b()}function b(){var a=
+E;a.aa.topic?(g.classList.remove("hidden"),m.textContent=r.sa||"",p.textContent=r.G?J.Fa(r.G,r.ea):""):g.classList.add("hidden");a.aa.purpose?(n.classList.remove("hidden"),u.textContent=r.oa||"",A.textContent=r.o?J.Fa(r.o,r.da):""):n.classList.add("hidden");f.style.backgroundImage="";h.classList.remove("presence-indicator");M.textContent=J.jb(r.i?Object.keys(r.i).length:0);a=[];if(r.i)for(var b in r.i)a.push(r.i[b]);a.sort(function(a,b){return a.N&&!b.N?-1:b.N&&!a.N?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.N||b.classList.add("presence-away");c.appendChild(b)});H.textContent="";H.appendChild(c);e.classList.add("roominfo-channel");e.classList.remove("roominfo-user")}function c(){h.textContent=r.name;if(r.b){x.textContent=J.cb(r.b.length);x.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=Oa+" roominfo-unpin";c.className="roominfo-pinlist-item";c.appendChild(b.L());c.appendChild(e);a.appendChild(c)});y.textContent="";y.appendChild(a)}else x.classList.add("hidden"),y.classList.add("hidden")}function d(){if(r.b)for(var a=0,b=r.b.length;a<b;a++)if(r.b[a].id===this.dataset.msgId){Eb(r,
+r.b[a]);break}}var e=document.createElement("div"),f=document.createElement("header"),h=document.createElement("h3"),k=document.createElement("div"),g=document.createElement("div"),m=document.createElement("span"),p=document.createElement("span"),l=document.createElement("div"),n=document.createElement("div"),u=document.createElement("span"),A=document.createElement("span"),x=document.createElement("div"),y=document.createElement("ul"),M=document.createElement("div"),H=document.createElement("ul"),
+E,r;e.className="chat-context-roominfo";f.className="roominfo-title";g.className="roominfo-topic";n.className="roominfo-purpose";l.className="roominfo-phone";x.className="roominfo-pincount";y.className="roominfo-pinlist";M.className="roominfo-usercount";H.className="roominfo-userlist";A.className=p.className="roominfo-author";f.appendChild(h);e.appendChild(f);e.appendChild(k);g.appendChild(m);g.appendChild(p);n.appendChild(u);n.appendChild(A);k.appendChild(g);k.appendChild(l);k.appendChild(n);k.appendChild(x);
+k.appendChild(y);k.appendChild(M);k.appendChild(H);var I=null;return{eb:function(b,c){this.$();E=b;r=c;a();return this},update:function(){this.$();a();return this},show:function(a){this.$();a.appendChild(e);e.classList.remove("hidden");return this},rb:function(){this.$();e.classList.add("hidden");return this},$:function(){I&&clearTimeout(I);I=null;return this},sb:function(){I||(I=setTimeout(function(){e.classList.add("hidden");I=null},300));return this},vb:function(a){for(;a;){if(a===e)return!0;a=
+a.parentNode}return!1}}}();function Y(a,b,c,d){ka.call(this,a,b,0,c,d)}Y.prototype=Object.create(ka.prototype);Y.prototype.constructor=Y;Y.prototype.b=function(a,b){return!0===a.isMeMessage?new jc(this.id,a,b):!0===a.isNotice?new kc(this.id,a,b):new lc(this.id,a,b)};function ic(a){a.a.forEach(function(a){a.H()})}
+var Z=function(){function a(a,d){return Aa(d,{B:a.context.self.T.B,X:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=$a(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null},la:function(c){return b(a,c)}})}function b(a,b){var c=b.indexOf("|"),d;if(-1===c)var h=b;else{h=b.substr(0,c);var k=b.substr(c+1)}if("@"===h[0])if(h=ta(a.context)+"|"+h.substr(1),d=F(h))a=!0,h="#"+d.O.id,k="@"+d.getName(),d="background-color:"+
+Ub(d.getName()),b=["chatmsg-link-user","chatmsg-link"];else return null;else if("#"===h[0])if(h=ta(a.context)+"|"+h.substr(1),k=wa(h))a=!0,h="#"+h,k="#"+k.name,b=["chatmsg-link-chan","chatmsg-link"];else return null;else{if(!h.match(/^(https?|mailto):\/\//i))return null;b=["chatmsg-link"];a=!1}return{link:h,text:k||h,style:d,Ta:b,Ya:a}}return{H:function(a){a.V=!0;return a},Y:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},M:function(a){a.c?a.V&&(a.V=!1,a.P()):a.ya().P();return a.c},
+P:function(b){var c=F(b.K);b.c.m.innerHTML=J.R(b.m);b.c.qa.innerHTML=a(b,b.text);b.c.ha.textContent=c?c.getName():b.username||"?";for(var c=document.createDocumentFragment(),e=0,f=b.s.length;e<f;e++){var h=b.s[e];h&&(h=Wb(b,h,e))&&c.appendChild(h)}b.c.s.textContent="";b.c.s.appendChild(c);c=b.b;e=document.createDocumentFragment();if(b.D)for(var k in b.D){var f=c,h=b.id,g=k,m=b.D[k],p=$a(g);if(p){for(var l=document.createElement("li"),n=document.createElement("a"),u=document.createElement("span"),
+A=document.createElement("span"),x=[],y=0,M=m.length;y<M;y++){var H=F(m[y]);H&&x.push(H.getName())}x.sort();A.textContent=x.join(", ");u.appendChild(p);u.className="emoji-small";n.href="javascript:toggleReaction('"+f+"', '"+h+"', '"+g+"')";n.appendChild(u);n.appendChild(A);l.className="chatmsg-reaction-item";l.appendChild(n);f=l}else console.warn("Reaction id not found: "+g),f=null;f&&e.appendChild(f)}b.c.D.textContent="";b.c.D.appendChild(e);b.c.ca.ka&&(b.c.ca.ka.style.backgroundImage=b.A?'url("star_full.png")':
+'url("star_empty.png")');b.F&&(b.c.F.innerHTML=J.F(b.F),b.c.classList.add("edited"));return b},L:function(a){return a.M().cloneNode(!0)},w:function(b,d){return a(b,d)}}}();function jc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.c=Z.c;this.V=Z.V}jc.prototype=Object.create(z.prototype);q=jc.prototype;q.constructor=jc;q.H=function(){return Z.H(this)};q.w=function(a){return Z.w(this,a)};q.Y=function(){return Z.Y(this)};q.M=function(){return Z.M(this)};
+q.ya=function(){this.c=Tb(this);this.c.classList.add("chatmsg-me_message");return this};q.L=function(){return Z.L(this)};q.P=function(){Z.P(this);return this};q.update=function(a,b){z.prototype.update.call(this,a,b);this.H()};function lc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.c=Z.c;this.V=Z.V}lc.prototype=Object.create(w.prototype);q=lc.prototype;q.constructor=lc;q.H=function(){return Z.H(this)};q.w=function(a){return Z.w(this,a)};q.Y=function(){return Z.Y(this)};q.M=function(){return Z.M(this)};
+q.ya=function(){this.c=Tb(this);return this};q.L=function(){return Z.L(this)};q.P=function(){Z.P(this);return this};
+q.update=function(a,b){w.prototype.update.call(this,a,b);this.H();if(a=this.text.match(/^<?https:\/\/www\.openstreetmap\.org\/\?mlat=(-?[0-9\.]+)(&amp;|&)mlon=(-?[0-9\.]+)(&amp;|&)macc=([0-9\.]+)[^\s]*/))this.text=this.text.substr(0,a.index)+this.text.substr(a.index+a[0].length).trim(),this.s.unshift({color:"#008000",text:a[0],footer:"Open Street Map",footer_icon:"https://www.openstreetmap.org/assets/favicon-32x32-36d06d8a01933075bc7093c9631cffd02d49b03b659f767340f256bb6839d990.png",geo:{latitude:a[1],
+longitude:a[3],accuracy:a[5]}})};function kc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.a=null;this.V=!0}kc.prototype=Object.create(B.prototype);q=kc.prototype;q.constructor=kc;q.H=function(){return Z.H(this)};q.w=function(a){return Z.w(this,a)};q.Y=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};q.M=function(){Z.M(this);return this.a};q.L=function(){return this.a.cloneNode(!0)};
+q.ya=function(){this.c=Tb(this);this.a=document.createElement("span");this.c.classList.add("chatmsg-notice");this.a.className="chatmsg-notice";this.a.textContent=J.bb;this.a.appendChild(this.c);return this};q.P=function(){Z.P(this);return this};q.update=function(a,b){B.prototype.update.call(this,a,b);this.H()};
+function Fb(a,b){var c=Tb(null);c.classList.add("chatmsg-pending");b&&c.classList.add("chatmsg-me_message");c.qa.innerHTML=Aa(a,{X:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=$a(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null}});c.ha.textContent=O.self?O.self.getName():"";a=document.createElement("span");a.className="typing-dot1";a.textContent=".";c.m.appendChild(a);a=document.createElement("span");
+a.className="typing-dot2";a.textContent=".";c.m.appendChild(a);a=document.createElement("span");a.className="typing-dot3";a.textContent=".";c.m.appendChild(a);c.m.classList.add("typing-container");return c};var X;function ac(a){this.U={};for(var b=0,c=a.length;b<c;b++)null===a[b].service&&null===a[b].device&&Ob(this,JSON.parse(a[b].config))}function Ob(a,b){if(b.services)for(var c in b.services)a.U[c]=b.services[c];void 0!==b.emojiProvider&&(a.h=b.emojiProvider);void 0!==b.displayAvatar&&(a.a=b.displayAvatar);void 0!==b.colorfulNames&&(a.b=b.colorfulNames)}
+function ec(){var a=X,b={},c="";!1===a.a&&(b[".chatsystem-content .chatmsg-authorGroup .chatmsg-author-img-wrapper"]=["display: none"],b[".chatsystem-content .chatmsg-authorGroup"]=["display: flex"],b[".chatsystem-content .chatmsg-authorGroup .chatmsg-author"]=["position:initial","vertical-align:top","min-width:75px"],b[".chatsystem-content .chatmsg-authorGroup .chatmsg-author-messages"]=["padding-top:0","padding-left:0","display:inline-block","margin-top:-4px","flex:1"],b[".chatmsg-author-name::before"]=
+["content:'<'"],b[".chatmsg-author-name::after"]=["content:'>'"]);!0===a.b||(b[".chatmsg-authorGroup .chatmsg-item .chatmsg-link-user, .chatsystem-content a.chatmsg-author-name, .chatmsg-author-name"]=["background-color: transparent !important;"]);for(var d in b)c+=d+"{",b[d].forEach(function(a){c+=a+";"}),c+="}";return c}X=new ac([]);var ab=function(){var a=[];return{Xa:function(b){for(var c=0,d=a.length;c<d;c++)if(-1!==a[c].names.indexOf(b))return a[c];return null},pb:function(b){var c=[];a.forEach(function(a){for(var d=0,f=a.names.length;d<f;d++)if(a.names[d].substr(0,b.length)===b){c.push(a);break}});return c},zb:function(b){b.W="client";b.exec=b.exec.bind(b);a.push(b)}}}();function mc(){return new Promise(function(a,b){"geolocation"in window.navigator?navigator.geolocation.getCurrentPosition(function(c){c?a(c):b("denied")}):b("geolocation not available")})}
+ya.push(function(){ab.zb({name:"/sherlock",names:["/sherlock","/sharelock"],usage:"",description:J.ib,exec:function(a,b){mc().then(function(a){var c=a.coords.latitude,e=a.coords.longitude;db(b,"https://www.openstreetmap.org/?mlat="+c+"&mlon="+e+"&macc="+a.coords.accuracy+"#map=17/"+c+"/"+e)}).catch(function(a){console.error("Error: ",a)})}})});
 })();

+ 69 - 21
srv/src/context.js

@@ -1,4 +1,8 @@
 
+
+/** @const */
+var TYPING_DELAY = 5000;
+
 /**
  * @constructor
 **/
@@ -123,6 +127,9 @@ function ChatContext() {
 
     /** @type {number} */
     this.liveV = 0;
+
+    /** @type {number} */
+    this.typingVersion = 0;
 };
 
 ChatContext.prototype.userFactory = function(userData) {
@@ -199,7 +206,7 @@ ChatContext.prototype.updateTyping = function(typing, now) {
 
     if (this.typing)
         for (var i in this.typing)
-            if (!typing[i]) {
+            if (typing && !typing[i]) {
                 delete (this.typing[i]);
                 updated = true;
             }
@@ -216,6 +223,8 @@ ChatContext.prototype.updateTyping = function(typing, now) {
             }
         }
     }
+    if (updated)
+        this.typingVersion = now;
     return updated;
 };
 
@@ -233,7 +242,7 @@ ChatContext.prototype.toStatic = function(t) {
         }
         ,"emojis": this.emojis.version > t ? this.emojis.data : undefined
     };
-    if (this.staticV > t) {
+    if (t) {
         res["capacities"] = Object.keys(this.capacities);
     }
     if (this.commands.version > t) {
@@ -259,38 +268,61 @@ ChatContext.prototype.toStatic = function(t) {
     return res;
 };
 
-ChatContext.prototype.getWhoIsTyping = function(now) {
+/**
+ * @param {number} version
+ * @return {Object<Object<string, number>>|undefined}
+**/
+ChatContext.prototype.getWhoIsTyping = function(version, now) {
     var res;
-    for (var typingChan in this.typing) {
-        var tChan = null;
-        for (var typingUser in this.typing[typingChan]) {
-            if (this.typing[typingChan][typingUser] >= now) {
-                if (!tChan)
-                    tChan = {};
-                tChan[typingUser] = 1;
-            } else {
-                delete this.typing[typingChan][typingUser];
-            }
-        }
-        if (tChan) {
-            if (!res)
-                res = {};
-            res[typingChan] = tChan;
-        } else {
-            delete this.typing[typingChan];
+
+    this.cleanTyping(now);
+    if (this.typingVersion > version) {
+        res = {};
+        for (var typingChan in this.typing) {
+            res[typingChan] = {};
+            for (var typingUser in this.typing[typingChan])
+                res[typingChan][typingUser] = 1;
         }
     }
     return res;
 };
 
+/**
+ * @param {string} chanNameOrUserName
+ * @return {Room|null}
+**/
+ChatContext.prototype.getRoom = function(chanNameOrUserName) {
+    var chans = this.getChannelsWithName(chanNameOrUserName);
+    if (chans.length)
+        return chans[0];
+    var users = this.getUsersWithName(chanNameOrUserName);
+    if (users.length)
+        for (var i =0, nbUsers = users.length; i < nbUsers; i++)
+            if (users[i].privateRoom)
+                return users[i].privateRoom;
+    return null;
+};
+
 ChatContext.prototype.getChannelsWithName = function(name) {
     var chans = [];
+    if (name[0] === '#')
+        name = name.substr(1);
     for (var i in this.channels)
         if (this.channels[i].name === name)
             chans.push(this.channels[i]);
     return chans;
 };
 
+ChatContext.prototype.getUsersWithName = function(name) {
+    var users = [];
+    if (name[0] === '@')
+        name = name.substr(1);
+    for (var i in this.users)
+        if (this.users[i].getName() === name)
+            users.push(this.channels[i]);
+    return users;
+};
+
 /**
  * @param {number} now
 **/
@@ -299,7 +331,7 @@ ChatContext.prototype.cleanTyping = function(now) {
     for (var typingChan in this.typing) {
         var chanEmpty = true;
         for (var typingUser in this.typing[typingChan]) {
-            if (this.typing[typingChan][typingUser] +3000 < now) {
+            if (this.typing[typingChan][typingUser] +TYPING_DELAY < now) {
                 delete this.typing[typingChan][typingUser];
                 updated = true;
             } else {
@@ -311,9 +343,25 @@ ChatContext.prototype.cleanTyping = function(now) {
             updated = true;
         }
     }
+    if (updated)
+        this.typingVersion = now;
     return updated;
 };
 
+ChatContext.prototype.stopTyping = function(chanId, userId, t) {
+    if (this.typing[chanId] && this.typing[chanId][userId]) {
+        delete this.typing[chanId][userId];
+        var empty = true;
+        for (var i in this.typing[chanId]) {
+            empty = false;
+            break;
+        }
+        if (empty)
+            delete this.typing[chanId];
+        this.typingVersion = t;
+    }
+};
+
 /** @suppress {undefinedVars,checkTypes} */
 (function() {
     if (typeof module !== "undefined") {

+ 1 - 1
srv/src/database.js

@@ -3,7 +3,7 @@ const sqlite3 = require('sqlite3'),
     updateAccountConfigTable = require('./models/accountConfig.js').updateTable;
 
 const DB_PATH = __dirname +"/../database.sqlite",
-    DB_VERSION = 1;
+    DB_VERSION = 3;
 
 function updateMetaTable(dbObj, currentVersion, cb) {
     if (!currentVersion) {

+ 0 - 1
srv/src/models/accountConfig.js

@@ -231,7 +231,6 @@ module.exports.updateTable = function(dbObject, currentVersion, cb) {
             +"`config` STRING NOT NULL,"
             +"`modified` INT NOT NULL"
             +');CREATE INDEX accconfigbyaccount ON ' +TABLE_NAME +'(accountId); CREATE UNIQUE INDEX accconfigUniq ON ' +TABLE_NAME +'(accountId, serviceId, deviceId)', cb);
-        //TODO permanent login token array
     } else {
         cb(null);
     }

+ 7 - 4
srv/src/models/accounts.js

@@ -51,7 +51,6 @@ function Account(dbResult) {
     this.services;
     this.dirty;
 
-    //TODO permanent login token array
     if (dbResult) {
         this.id = dbResult.id;
 
@@ -62,6 +61,7 @@ function Account(dbResult) {
         this.certificates = dbResult.certificates;
         this.cguReadAndAccepted = !!dbResult.cguReadAndAccepted;
         this.services = JSON.parse(dbResult.services);
+        this.permanentPhoneAccess = dbResult.permanentPhoneAccess.split(',').filter(token => token.length);
         this.dirty = false;
     } else {
         this.id = null;
@@ -72,6 +72,7 @@ function Account(dbResult) {
 
         this.createCertificate();
         this.cguReadAndAccepted = false;
+        this.permanentPhoneAccess = [];
         this.services = [];
         this.dirty = true;
     }
@@ -85,12 +86,12 @@ Account.prototype.toDb = function() {
         ,certificates: this.certificates
         ,cguReadAndAccepted: this.cguReadAndAccepted ? 1 : 0
         ,services: JSON.stringify(this.services)
-        //TODO permanent login token array
+        ,permanentPhoneAccess: ',' +this.permanentPhoneAccess.join(',') +','
     };
 };
 
 Account.prototype.createCertificate = function() {
-    //TODO
+    //TODO create certificate
     this.certificates = null;
 };
 
@@ -154,7 +155,9 @@ module.exports.updateTable = function(dbObject, currentVersion, cb) {
             +"`cguReadAndAccepted` BOOLEAN NOT NULL DEFAULT FALSE,"
             +"`services` STRING NOT NULL"
             +')', cb);
-        //TODO permanent login token array
+    } else if (currentVersion === 2) {
+        console.info("Updating table " +TABLE_NAME);
+        dbObject.run('ALTER TABLE `' +TABLE_NAME +'` ADD COLUMN `permanentPhoneAccess` STRING NOT NULL DEFAULT "";', cb);
     } else {
         cb(null);
     }

+ 2 - 6
srv/src/multichatManager.js

@@ -338,15 +338,11 @@ MultiChatManager.prototype.poll = function(knownVersion, reqT, callback, checkCo
                     });
                 }
             } else {
-                // FIXME start Polling now (actually some loop appens because of typing conception)
-                //_this.startPolling(knownVersion, reqT, callback);
-                setTimeout(function() { _this.startPolling(knownVersion, reqT, callback); }, 1000);
+                _this.startPolling(knownVersion, reqT, callback);
             }
         });
     } else {
-        // FIXME start Polling now (actually some loop appens because of typing conception)
-        //_this.startPolling(knownVersion, reqT, callback);
-        setTimeout(function() { _this.startPolling(knownVersion, reqT, callback); }, 1000);
+        _this.startPolling(knownVersion, reqT, callback);
     }
 };
 

+ 11 - 5
srv/src/slack.js

@@ -193,7 +193,7 @@ Slack.prototype.getEmojis = function(cb) {
 Slack.prototype.poll = function(knownVersion, now) {
     if (this.connected) {
         var updatedCtx = this.data.getUpdates(knownVersion)
-            ,updatedTyping = this.data.getWhoIsTyping(now)
+            ,updatedTyping = this.data.getWhoIsTyping(knownVersion, now)
             ,updatedLive = this.getLiveUpdates(knownVersion);
 
         if (updatedCtx || updatedLive || updatedTyping) {
@@ -201,7 +201,7 @@ Slack.prototype.poll = function(knownVersion, now) {
                 "static": updatedCtx,
                 "live": updatedLive,
                 "typing": updatedTyping,
-                "v": Math.max(this.data.liveV, this.data.staticV)
+                "v": Math.max(this.data.liveV, this.data.staticV, this.data.typingVersion)
             };
         }
     }
@@ -281,10 +281,14 @@ Slack.prototype.onMessage = function(msg, t) {
             var channelId = this.data.team.id +'|' +(msg["channel"] || msg["channel_id"] || msg["item"]["channel"])
                 ,channel = this.data.channels[channelId]
                 ,histo = this.lazyHistory(channel);
-            // FIXME remove typing for user
             var lastMsg = histo.push(msg, t);
-            if (lastMsg)
+            if (lastMsg) {
                 this.data.liveV = t;
+                // FIXME not true (edit, etc..)
+                var messageObject = histo.lastMessage();
+                if (messageObject && messageObject.userId)
+                    this.data.stopTyping(channelId, messageObject.userId, t);
+            }
             histo.resort();
             if (channel)
                 channel.setLastMsg(lastMsg, t);
@@ -774,7 +778,9 @@ Slack.prototype.fetchPinned = function(target) {
                 now = Date.now();
 
             resp.items.forEach(function(msg) {
-                msgs.push(histo.messageFactory(msg.message, now));
+                if (msg.message)
+                    msgs.push(histo.messageFactory(msg.message, now));
+                // Else file
             });
             target.pins = msgs;
             target.version = Math.max(target.version, now);

+ 2 - 4
srv/src/slackData.js

@@ -6,8 +6,6 @@ const ChatContext = require('./context.js').ChatContext
     ,Chatter = require('./chatter.js').Chatter
     ,PrivateMessageRoom = require('./room.js').PrivateMessageRoom;
 
-const SLACK_TYPING_DELAY = 6000;
-
 /**
  * @constructor
  * @extends {ChatInfo}
@@ -342,8 +340,8 @@ SlackData.prototype.onMessage = function(msg, t) {
         var chanId = this.team.id +'|' +msg["channel"];
         if (!this.typing[chanId])
             this.typing[chanId] = {};
-        this.typing[chanId][this.team.id +'|' +msg["user"]] = t +SLACK_TYPING_DELAY;
-        this.staticV = Math.max(this.staticV, t);
+        this.typing[chanId][this.team.id +'|' +msg["user"]] = t;
+        this.typingVersion = t;
     } else if (msg["type"] === "im_marked" || msg["type"] === "channel_marked" || msg["type"] === "group_marked") {
         var channel = this.channels[this.team.id +'|' +msg["channel"]];
         if (channel) {