mimouchat.min.js 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. "use strict";(function(){
  2. 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.yb=a.desc;this.name=a.name;this.type=a.type;this.usage=a.usage;this.Y=a.category}function ca(){this.a={};this.F=[];this.version=0}
  3. ca.prototype.update=function(a,b){a.emoji_use&&(this.a=JSON.parse(a.emoji_use));a.highlight_words?this.F=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.F=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.w={};this.X={};this.o=0}function ea(a,b){return b.pv?new t(b.id,a.i[b.user]):new v(b.id)}
  4. 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,g=b.users.length;e<g;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,g=b.channels.length;e<g;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]=
  5. new ba(b.commands[e]);a.h.version=c}b.self&&(a.self=a.i[d+b.self.id]||null,a.self.U||(a.self.U=new ca),b.self.prefs&&a.self.U.update(b.self.prefs,c));b.capacities&&(a.X={},b.capacities.forEach(function(a){this.X[a]=!0},a));a.o=Math.max(a.o,c)}"undefined"!==typeof module&&(module.K.Pb=da,module.K.Qb=aa,module.K.Sb=ba);function v(a){this.id=a;this.B=!1;this.D=0;this.i={};this.version=0}function ha(a,b,c){if(!a.C||a.C<b)a.C=b,a.version=c}
  6. v.prototype.update=function(a,b,c,d){d=d||"";void 0!==a.name&&(this.name=a.name);void 0!==a.is_archived&&(this.ja=a.is_archived);void 0!==a.is_member&&(this.ca=a.is_member);void 0!==a.last_read&&(this.D=Math.max(parseFloat(a.last_read),this.D));void 0!==a.last_msg&&(this.C=parseFloat(a.last_msg));this.C&&(this.D=Math.min(this.D,this.C));void 0!==a.is_private&&(this.h=a.is_private);void 0!==a.pins&&(this.b=a.pins);this.B=!!a.is_starred;if(a.members&&(this.i={},a.members))for(var e=0,g=a.members.length;e<
  7. g;e++){var h=b.i[d+a.members[e]];this.i[h.id]=h;h.j[this.id]=this}a.topic&&(this.xa=a.topic.value,this.u=b.i[d+a.topic.creator],this.fa=a.topic.last_set);a.purpose&&(this.ta=a.purpose.value,this.o=b.i[d+a.purpose.creator],this.ea=a.purpose.last_set);this.version=Math.max(this.version,c)};function ia(a,b){var c=ja;return{name:c.na(b,a.name),qa:c.na(b,Object.values(a.i),function(a){return a?a.getName():null}),xa:c.na(b,a.xa),ta:c.na(b,a.ta)}}
  8. function t(a,b){v.call(this,a);this.a=b;this.name=b.getName();this.h=!0;b.R=this}t.prototype=Object.create(v.prototype);t.prototype.constructor=t;"undefined"!==typeof module&&(module.K.Yb=v,module.K.Xb=t);function w(a,b){this.M=a.user;this.username=a.username;this.id=a.id||a.ts;this.m=parseFloat(a.ts);this.text="";this.s=[];this.B=a.is_starred||!1;this.h=this.H=!1;this.G={};this.version=b;this.update(a,b)}function x(a,b){w.call(this,a,b)}function B(a,b){w.call(this,a,b)}
  9. w.prototype.update=function(a,b){if(a){this.text=a.text||"";a.attachments&&(this.s=a.attachments);this.B=!!a.is_starred;this.H=void 0===a.edited?!1:a.edited;this.h=!!a.removed;if(a.reactions){var c={};a.reactions.forEach(function(a){c[a.name]=[];a.users.forEach(function(b){c[a.name].push(b)})});this.G=c}a.pendingId&&(this.ra=a.pendingId)}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.sb=0;this.o=b;d&&la(this,d,e)}
  10. 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 x(a,b):!0===a.isNotice?new B(a,b):new w(a,b)};
  11. ka.prototype.push=function(a,b){for(var c,d=!1,e,g=0,h=this.a.length;g<h;g++)if(c=this.a[g],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}
  12. function ma(a){a.a.sort(function(a,c){return a.m-c.m})}x.prototype=Object.create(w.prototype);x.prototype.constructor=x;B.prototype=Object.create(w.prototype);B.prototype.constructor=B;"undefined"!==typeof module&&(module.K={Ub:w,Tb:x,Wb:B,Zb:ka});function ga(a){this.id=a;this.j={};this.R=this.U=null;this.version=0}
  13. ga.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.ab=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.goal&&(this.Ab=a.goal);void 0!==a.phone&&(this.Jb=a.phone);void 0!==a.first_name&&(this.cb=a.first_name);void 0!==a.last_name&&(this.hb=a.last_name);void 0!==a.real_name&&(this.pb=a.real_name);void 0!==a.isPresent&&(this.P=a.isPresent);a.isBot&&(this.Eb=a.isBot);this.version=Math.max(this.version,b)};
  14. function pa(a){return"api/avatar?user="+encodeURIComponent(a.id)}ga.prototype.getName=function(){return this.name||this.pb||this.cb||this.hb};"undefined"!==typeof module&&(module.K.Rb=ga);function qa(){this.a=[]}qa.prototype.push=function(a){this.a.push(a)};function ra(a,b){for(var c=0,d=a.a.length;c<d;c++)if(b===sa(a.a[c]))return a.a[c];return null}function ta(a,b){for(var c=0,d=a.a.length;c<d;c++){var e=a.a[c],g;for(g in e.j)if(!0===b(e.j[g],g))return}}function ua(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}
  15. function va(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 wa(a){for(var b=C.context,c=[],d=0,e=b.a.length;d<e;d++){var g=b.a[d].j,h;for(h in g)a&&!a(g[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}qa.prototype.Ga=function(a){for(var b=0,c=this.a.length;b<c;b++){var d=this.a[b];if(d.self&&d.self.id===a)return!0}return!1};
  16. "undefined"!==typeof module&&(module.K.Vb=qa);var ja=function(){function a(b,c,d){if(Array.isArray(c)){for(var e=0,g=0,h=c.length;g<h;g++){var k=a(b,c[g],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{na:a}}();"undefined"!==typeof module&&(module.K.$b=ja);var G={},J,xa=[];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];xa.forEach(function(a){a()})};G.fr={Ob:"Utilisateur inconnu",Nb:"Channel inconnu",Ia:"Nouveau message",message:"Message",jb:"Reseau",kb:"(visible seulement par vous)",B:"Favoris",j:"Discutions",qa:"Membres",ob:"Discutions priv\u00e9es",qb:"Partage sa position GPS",ok:"Ok",bb:"Annuler",S: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, "+
  17. a.toLocaleTimeString():a.toLocaleString()},eb:function(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()?"aujourd'hui":a.getTime()>c.getTime()?"hier":a.toLocaleDateString()},Ea: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",
  18. "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",
  19. "settings-displayColorfulNamesLbl":"Afficher les nomes en couleur","settings-displayScrollAvatarsLbl":"Faire d\u00e9filer les avatars lors de la lecture","settings-displayAttachmentContentLbl":"Afficher les pieces jointes ?","settings-displayAttachmentContent-never":"Jamais","settings-displayAttachmentContent-always":"Toujours","settings-displayAttachmentContent-notimg":"Si elles ne contiennent pas d'images"}};
  20. G.fr.lb=function(a){return 0===a?"Pas de message \u00e9pingl\u00e9":a+(1===a?" message \u00e9pingl\u00e9":" messages \u00e9pingl\u00e9s")};G.fr.rb=function(a){return 0===a?"Pas de chatteur":a+(1===a?" chatteur":" chatteurs")};G.fr.H=function(a){return"(edit&eacute; "+G.fr.S(a)+")"};G.fr.Ma=function(a,b){return"par "+a.getName()+" le "+G.fr.S(b)};G.en={Ob:"Unknown member",Nb:"Unknown channel",Ia:"New message",message:"Message",jb:"Network",kb:"(only visible to you)",B:"Starred",j:"Channels",qa:"Members",ob:"Direct messages",qb:"Share your GPS location",ok:"Ok",bb:"Cancel",S: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():
  21. a.toLocaleString()},eb:function(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()?"today":a.getTime()>c.getTime()?"yesterday":a.toLocaleDateString()},Ea: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",
  22. "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","settings-displayScrollAvatarsLbl":"Scroll avatars",
  23. "settings-displayAttachmentContentLbl":"Automaticcaly unwrap attachments ?","settings-displayAttachmentContent-never":"Never","settings-displayAttachmentContent-always":"Always","settings-displayAttachmentContent-notimg":"If they don't contain image"}};G.en.lb=function(a){return 0===a?"No pinned messages":a+(1===a?" pinned message":" pinned messages")};G.en.rb=function(a){return 0===a?"No users in this room":a+(1===a?" user":" users")};G.en.H=function(a){return"(edited "+G.en.S(a)+")"};
  24. G.en.Ma=function(a,b){return"by "+a.getName()+" on "+G.en.S(b)};var Aa=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.aa=c;this.f=null;this.l=[];this.a=d||"";this.Aa="<"===this.a;this.Ka="*"===this.a;this.za="_"===this.a;this.Ba="~"===this.a||"-"===this.a;this.h=">"===this.a||"&gt;"===this.a;this.u=":"===this.a;this.Na="`"===this.a;this.Ya="```"===this.a;this.Oa="\n"===this.a;this.ya=void 0!==d&&-1!==p.F.indexOf(d);this.g=b;this.Ca=null;this.b=this.Oa||this.ya?c+d.length-1:!1;this.ya&&(this.f=new a(this),this.l.push(this.f),this.f.text=
  25. d)}function c(a){return/[A-Za-z0-9\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+]/.test(a)}function d(a){a=a||n;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=
  26. 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 g(a){return a.replace("<","&lt;")}function h(a){return a}function k(a){return{link:a,text:a,gb:!1}}var f,n,p={F:[],Z:h,wa:h,pa:k};b.prototype.Qa=function(){return this.Ka&&!!this.b||this.g instanceof b&&this.g.Qa()};b.prototype.Ta=function(){return this.za&&!!this.b||this.g instanceof b&&this.g.Ta()};b.prototype.Ua=function(){return this.Ba&&
  27. !!this.b||this.g instanceof b&&this.g.Ua()};b.prototype.fa=function(){return this.u&&!!this.b||this.g instanceof b&&this.g.fa()};b.prototype.Sa=function(){return this.ya&&!!this.b||this.g instanceof b&&this.g.Sa()};b.prototype.Ra=function(){return this.Na&&!!this.b||this.g instanceof b&&this.g.Ra()};b.prototype.ea=function(){return this.Ya&&!!this.b||this.g instanceof b&&this.g.ea()};b.prototype.Va=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].Va()))return!0;
  28. return!1};b.prototype.Wa=function(a){if("<"===this.a&&">"===f[a])return!0;var b=c(f[a-1]);if(!this.h&&f.substr(a,this.a.length)===this.a){if(!b&&(this.Ka||this.za||this.Ba))return!1;if(this.f&&this.Va())return this.f.Za();if(this.tb())return!0}return"\n"===f[a]&&this.h?!0:!1};b.prototype.tb=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.Ca}return!1};b.prototype.Za=function(){var a=new b(this.g,this.aa,this.a);a.Ca=this;this.f&&
  29. this.f instanceof b&&(a.f=this.f.Za(),a.l=[a.f]);return a};b.prototype.ub=function(a){return this.u&&(" "===f[a]||"\t"===f[a])||(this.u||this.Aa||this.Ka||this.za||this.Ba||this.Na)&&"\n"===f[a]?!1:!0};b.prototype.vb=function(b){if(this.Na||this.u||this.Ya||this.Aa)return null;if(!this.f||this.f.b||this.f instanceof a){var d=c(f[b-1]),e=c(f[b+1]);if("```"===f.substr(b,3))return"```";var g=n.Ja();if(void 0===g||g){if("&gt;"===f.substr(b,4))return"&gt;";if(">"===f[b])return f[b]}if("`"===f[b]&&!d||
  30. "\n"===f[b]||!(-1===["*","~","-","_"].indexOf(f[b])||!e&&void 0!==f[b+1]&&-1==="*~-_<&".split("").indexOf(f[b+1])||d&&void 0!==f[b-1]&&-1==="*~-_<&".split("").indexOf(f[b-1]))||-1!==[":"].indexOf(f[b])&&e||-1!==["<"].indexOf(f[b]))return f[b];d=0;for(e=p.F.length;d<e;d++)if(g=p.F[d],f.substr(b,g.length)===g)return g}return null};a.prototype.Ja=function(){if(""!==this.text.trim())return!1};b.prototype.Ja=function(){for(var a=this.l.length-1;0<=a;a--){var b=this.l[a].Ja();if(void 0!==b)return b}if(this.Oa||
  31. this.h)return!0};a.prototype.o=function(a){this.text+=f[a];return 1};b.prototype.o=function(c){var d=this.f&&!this.f.b&&this.f.Wa?this.f.Wa(c):null;if(d){var e=this.f.a.length;this.f.Pa(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.ub(c)){if(d=this.vb(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.aa+1;n.ca(this.f.aa);this.f=new a(this);
  32. this.f.o(d-1);this.l.pop();this.l.push(this.f);return d-c};b.prototype.Pa=function(a){for(var b=this;b;)b.b=a,b=b.Ca};b.prototype.ca=function(a){this.b&&this.b>=a&&(this.b=!1);this.l.forEach(function(c){c instanceof b&&c.ca(a)})};a.prototype.innerHTML=function(){if(this.g.fa()){for(var a=this.g;a&&!a.u;)a=a.g;if(a){var a=a.a+this.text+a.a,b=p.Z(a);return b?b:a}return(a=p.Z(this.text))?a:this.text}if(this.g.ea()){if("undefined"!==typeof hljs)try{return a=this.text.match(/^\w+/),hljs.configure({useBR:!0,
  33. 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.wa(this.text)};a.prototype.outerHTML=function(){var a="span",b=[],c="";if(this.g.ea()){a="pre";b.push("codeblock");var d=this.innerHTML()}else this.g.Ra()?(b.push("code"),d=this.innerHTML()):(this.g.Aa&&(d=p.pa(this.text))?
  34. (a="a",c=' href="'+d.link+'"',d.style&&(c+=' style="'+d.style+'"'),d.gb||(c+=' target="_blank"'),d.$a&&d.$a.forEach(function(a){b.push(a)}),d=p.wa(d.text)):d=this.innerHTML(),this.g.Qa()&&b.push("bold"),this.g.Ta()&&b.push("italic"),this.g.Ua()&&b.push("strike"),this.g.fa()&&b.push("emoji"),this.g.Sa()&&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.Oa&&(a+="<br/>");this.l.forEach(function(b){a+=
  35. b.outerHTML()});this.h&&(a+="</span>");return a};b.prototype.Xa=function(a){this.h&&!this.b&&this.Pa(a);this.l.forEach(function(c){c instanceof b&&c.Xa(a)})};return function(c,l){l||(l={});p.F=l.F||[];p.Z=l.Z||h;p.wa=l.wa||g;p.pa=l.pa||k;f=c;n=new b(this,0);l=0;c=f.length;do{for(;l<c;)l+=n.o(l);n.Xa(f.length);if(l=d()){e(l,!1);n.ca(l.aa);var m=new a(l.g);m.o(l.aa);l.g.l.push(m);l.g.f=m;l=l.aa+1}else l=void 0}while(void 0!==l);return n.outerHTML()}}();"undefined"!==typeof module&&(module.K.A=Aa);function Ba(a,b){this.u=b||a;this.method=b?a:"GET"}function M(a,b,c,d){a&&a.forEach(function(a){a(b,c,d)})}function Ca(a,b){a.ga||(a.ga=[]);a.ga.push(b);return a}function N(a,b){a.ia||(a.ia=[]);a.ia.push(b);return a}function Da(a,b){a.ha||(a.ha=[]);a.ha.push(b);return a}
  36. function O(a,b){Ba.call(this,a,b);this.b=new XMLHttpRequest;this.b.onreadystatechange=function(){4===this.b.readyState&&(2===Math.floor(this.b.status/100)?M(this.ia,this.b.status,this.b.statusText,this.b.response):M(this.ha,this.b.status,this.b.statusText,this.b.response),M(this.ga,this.b.status,this.b.statusText,this.b.response))}.bind(this)}O.prototype=Object.create(Ba.prototype);O.prototype.constructor=O;O.prototype.o=function(a){this.b.timeout=a;return this};
  37. O.prototype.h=function(a){this.b.responseType=a;return this};O.prototype.a=function(a){this.b.open(this.method,this.u,!0);this.b.send(a);return this};function Ea(a,b){Ba.call(this,a,b);this.b=5E3;this.responseType="text"}Ea.prototype=Object.create(Ba.prototype);Ea.prototype.constructor=O;Ea.prototype.o=function(a){this.b=a;return this};Ea.prototype.h=function(a){this.responseType=a;return this};
  38. function Fa(a){if(!a)return null;if("string"===typeof a)return a;var b={},c;for(c in a)b[c]=a[c];return JSON.stringify(b)}var Ga=function(){var a=document.createElement("a");return function(b){a.href=b;return a.href}}();
  39. Ea.prototype.a=function(a){__native.sendHttpRequest(this.method,Ga(this.u),this.b,this.responseType,Fa(a),Ha.ib(function(a,c,d){try{var b="text"===this.responseType?d:JSON.parse(d)}catch(g){b=d}__native.isDebug()&&console.log(this,{cc:a,statusText:c,bc:d});2===Math.floor(a/100)?M(this.ia,a,c,b):M(this.ha,a,c,b);M(this.ga,a,c,b)},this));return this};function P(a,b){return Ia()?new Ea(a,b):new O(a,b)};function Ja(a,b){this.title=a;this.content=b;this.c=Ka(this);this.b=La(this);this.a=[];this.h=[]}
  40. function Ka(a){var b=document.createElement("div"),c=document.createElement("header"),d=document.createElement("span"),e=document.createElement("span"),g=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?g.innerHTML=a.content:g.appendChild(a.content);c.className=Ma;d.className=Na;e.className=Oa;e.textContent="x";c.appendChild(d);c.appendChild(e);b.appendChild(c);g.className=
  41. Pa;b.appendChild(g);b.b.className=Qa;b.b.textContent=J.bb;b.b.addEventListener("click",function(){Ra(a,!1)});e.addEventListener("click",function(){Ra(a,!1)});b.a.addEventListener("click",function(){Ra(a,!0)});h.appendChild(b.b);b.a.className=Qa;b.a.textContent=J.ok;h.appendChild(b.a);h.className=Sa+" "+Ta;b.appendChild(h);b.className=Ua;return b}function Ra(a,b){(b?a.a:a.h).forEach(function(a){a()});a.close()}
  42. function La(a){var b=document.createElement("div");b.className=Va;b.addEventListener("click",function(){Ra(this,!1)}.bind(a));return b}function Wa(a,b,c){a.c.a.textContent=b;a.c.b.textContent=c;return a}Ja.prototype.ua=function(a){a=a||document.body;a.appendChild(this.b);a.appendChild(this.c);return this};Ja.prototype.close=function(){this.c.remove();this.b.remove();return this};function Xa(a,b){a.a.push(b);return a};var Qa="button",Sa="button-container",Ua="dialog",Va="dialog-overlay",Ma="dialog-title",Na="dialog-title-label",Oa="dialog-title-close",Pa="dialog-body",Ta="dialog-footer";function Ya(a){var b=document.createElement("lh");b.textContent=a;b.className="chat-command-header";return b}
  43. function Za(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.yb;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";
  44. return c}
  45. function $a(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 g=a.selectionStart,h=a.selectionEnd;g&&" "!==e[g-1];g--);for(b=e.length;h<b&&" "!==e[h];h++);if(g!==h&&0<h-g-1){if("#"===e[g]){var k=Q.j;b=e.substr(g+1,h-g-1);for(var f in k)k[f].name.length>=b.length&&k[f].name.substr(0,b.length)===b&&d.push(k[f])}else if("@"===e[g])for(f in k=R instanceof t?Q.i:R.i,b=e.substr(g+1,
  46. h-g-1),k){var n=k[f].getName();n.length>=b.length&&n.substr(0,b.length)===b&&d.push(k[f])}else if(":"===e[g]&&window.searchEmojis){b=e.substr(g+1,h-g-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+":",Fa:p,sa:ab.name})}for(f in Q.b.data)f.length>=b.length&&f.substr(0,b.length)===b&&(k=document.createElement("span"),k.className="emoji-small",k.appendChild(bb(f)),d.push({name:":"+f+":",
  47. Fa:k,sa:"custom"}))}d.length&&(c.dataset.cursor=JSON.stringify([g,h]))}}if(!d.length&&"/"===e[0]){f=e.indexOf(" ");g=-1!==f;f=-1===f?e.length:f;b=e.substr(0,f);g?(a=cb.fb(b))&&d.push(a):(d=cb.zb(b),c.dataset.cursor=JSON.stringify([0,a.selectionEnd]));a=Q?Q.h.data:{};for(var m in a)e=a[m],(!g&&e.name.substr(0,f)===b||g&&e.name===b)&&d.push(e);d.sort(function(a,b){return a.Y.localeCompare(b.Y)||a.name.localeCompare(b.name)})}c.textContent="";if(d.length){m=document.createDocumentFragment();f=0;for(a=
  48. d.length;f<a;f++)if(e=d[f],e instanceof ga){if(!l){var l=!0;m.appendChild(Ya(J.qa))}b=document.createElement("span");b.className="chat-command-userIcon";b.style.backgroundImage='url("'+pa(e)+'")';m.appendChild(Za("@"+e.getName(),b))}else e instanceof v?(l||(l=!0,m.appendChild(Ya(J.j))),m.appendChild(Za("#"+e.name))):e.Fa?(l!==e.sa&&(l=e.sa,m.appendChild(Ya(e.sa))),m.appendChild(Za(e.name,e.Fa))):(l!==e.Y&&(l=e.Y,m.appendChild(Ya(e.Y))),m.appendChild(Za(e)));c.appendChild(m)}}
  49. function db(a){if(S)return P("PUT","api/msg?room="+encodeURIComponent(R.id)+"&ts="+S.id+"&text="+encodeURIComponent(a)).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=Q,d=cb.fb(c);if(d)return a=a.trim(),d.exec(b,R,a),!0;if(b&&(c=b.h.data[c])){if("/me"===c.name)eb(R,a,!0);else if("/msg"===c.name){a=a.trim();var b=/(\S+)\s+(.*)/.exec(a);a:{var e=b[1],d=Q,g=e,h=[];"#"===g[0]&&(g=g.substr(1));for(var k in d.j)d.j[k].name===g&&h.push(d.j[k]);if(h.length)var f=
  50. h[0];else{k=[];"@"===e[0]&&(e=e.substr(1));for(f in d.i)d.i[f].getName()===e&&k.push(d.j[f]);if(k.length)for(f=0,d=k.length;f<d;f++)if(k[f].R){f=k[f].R;break a}f=null}}f&&eb(f,b[2],!1)}P("POST","api/cmd?room="+encodeURIComponent(R.id)+"&cmd="+encodeURIComponent(c.name.substr(1))+"&args="+encodeURIComponent(a)).a();return!0}return!1}f=eb(R,a,!1);fb(R,a,f,T);return!0}function gb(){document.getElementById("msgInput").focus()}
  51. function hb(a){for(var b=1,c=0,d=a.value.length;c<d;c++)"\n"===a.value[c]&&b++;for(a.rows=Math.min(5,b);5>a.rows&&a.scrollHeight>a.clientHeight;)a.rows++}
  52. function ib(){var a=0,b=document.getElementById("msgInput");b.addEventListener("input",function(){if(R){var b=Date.now();a+3E3<b&&(Q.self.P||R instanceof t)&&(P("POST","api/typing?room="+encodeURIComponent(R.id)).a(),a=b);$a(this);hb(this)}});b.addEventListener("keydown",function(a){if(9===a.keyCode)return a.preventDefault(),!1;if(13===a.keyCode)return a.preventDefault(),a.shiftKey||a.altKey||a.ctrlKey?(a=this.selectionStart,this.value=this.value.substr(0,a)+"\n"+this.value.substr(this.selectionEnd),
  53. hb(this),this.selectionStart=this.selectionEnd=a+1):jb(),!1});document.getElementById("slashList").addEventListener("click",function(a){if(R){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;$a(c);c.focus();break}b=b.parentElement}}})};var kb=[],lb=0;
  54. function mb(){var a=document.createDocumentFragment(),b=wa(function(a){return!a.ja&&!1!==a.ca}),c=[],d=[],e=[],g=[],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.Ea(c.a.name,a.name),h[b.id]=J.Ea(d.a.name,b.name),c.a.name.localeCompare(d.a.name)):a.name.localeCompare(b.name)});b.forEach(function(a){a=va(a);if(a instanceof t){var b;if(b=!a.a.ab){var k=h[a.id];b=document.createElement("li");var p=document.createElement("a");
  55. 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(nb());b.appendChild(p);a.a.P||b.classList.add("presence-away");R===a&&b.classList.add("selected");a.C!==a.D&&void 0!==a.C&&(b.classList.add("unread"),b.classList.add("unreadHi"));b=k=b}b&&(a.B?c.push(k):g.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",
  56. b.dataset.count=Object.keys(a.i||{}).length):b.className="chat-context-room chat-channel",R===a&&b.classList.add("selected"),p.textContent=k||a.name,b.appendChild(nb()),b.appendChild(p),a.C!==a.D&&void 0!==a.C&&(b.classList.add("unread"),0<=U.indexOf(a)&&b.classList.add("unreadHi")),k=b)a.B?c.push(k):a.h?e.push(k):d.push(k)});c.length&&a.appendChild(ob(J.B));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(ob(J.j));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});
  57. g.length&&a.appendChild(ob(J.ob));g.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);pb.apply(document.getElementById("chanSearch"));qb()?rb(Q.a.id,Q.i,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"}):Ia()&&(b=__native.getPreviousChannel())&&(document.location.hash=b)}
  58. function sb(){ua(function(a){var b=a.w,c;for(c in a.self.j)if(!a.self.j[c].ja){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].R)&&!c.ja&&(d=document.getElementById("room_"+c.id))&&(b[c.id]?d.classList.add("chat-context-typing"):d.classList.remove("chat-context-typing"))});tb()}
  59. function tb(){var a;document.getElementById("whoistyping").textContent="";if(Q&&R&&(a=Q.w[R.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=F(d))?b.appendChild(ub(a)):c=!0;c&&(C.b=0);document.getElementById("whoistyping").appendChild(b)}}function vb(a){a?document.body.classList.remove("no-network"):document.body.classList.add("no-network");wb()}
  60. function xb(){var a=R.name||(R.a?R.a.getName():void 0);if(!a){console.error("No name provided for ",R);var a=[],b;for(b in R.i)a.push(R.i[b].getName());a=a.join(", ")}document.getElementById("currentRoomTitle").textContent=a;yb();gb();document.getElementById("fileUploadContainer").classList.add("hidden");zb();T&&(T=null,V());S&&(S=null,V());tb()}
  61. function V(){if(T){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){T=null;V()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(T.N())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";gb()}
  62. function Ab(){if(S){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){S=null;Ab()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(S.N());document.getElementById("msgInput").value=S.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";gb()}
  63. window.toggleReaction=function(a,b,c){var d=C.a[a],e,g;(d=C.a[a])&&(e=oa(d,b))&&(g=D(C.context,a))&&(e.G[c]&&-1!==e.G[c].indexOf(g.self.id)?P("DELETE","api/reaction?room="+encodeURIComponent(a)+"&msg="+b+"&reaction="+encodeURIComponent(c)).a():Bb(a,b,c))};function Cb(a,b){document.getElementById("linkFavicon").href=a||b?"favicon.png?h="+a+"&m="+b:"favicon_ok.png"}
  64. function wb(){var a=U.length,b="";if(W)b="!"+J.jb+" - Mimouchat",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+")",Cb(a,a);else{var c=0;ta(C.context,function(a){a.C>a.D&&c++});c&&(b="("+c+")");Cb(0,c)}!b.length&&R&&(b=R.name);b=b.length?b:"Mimouchat";document.title=b;Db(b)}
  65. function Eb(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(lb+3E4<a){var b=new Notification(J.Ia);lb=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
  66. function yb(){var a=document.createDocumentFragment(),b=R.id,c=null,d=0,e=null,g=0,h;R.B?document.getElementById("chatSystemContainer").classList.add("starred"):document.getElementById("chatSystemContainer").classList.remove("starred");kb=[];C.a[b]&&C.a[b].a.forEach(function(b){if(b.h)b.$();else{var f=b.O(),k=!1;var m=new Date(b.m);var l=new Date(g);m.setHours(0);m.setMinutes(0);m.setSeconds(0);m.setMilliseconds(0);l.setHours(0);l.setMinutes(0);l.setSeconds(0);l.setMilliseconds(0);m=m.getTime()===
  67. l.getTime();c&&c.M===b.M&&b.M&&m?30>Math.abs(d-b.m)&&!(b instanceof x)?e.classList.add("chatmsg-same-ts"):d=b.m:(d=b.m,k=!0);-1<Fb&&(!c||c.m<=Fb)&&b.m>Fb?(f.classList.add("chatmsg-first-unread"),f.insertBefore(Gb,f.firstChild)):f.classList.remove("chatmsg-first-unread");if(b instanceof x)e=c=null,d=0,a.appendChild(f),h=null;else{if(k||!h)h=Hb(F(b.M),b.username),kb.push(h),a.appendChild(h);c=b;e=f;h.content.appendChild(f)}h&&h.content.firstChild!==f||(m?(h||f).classList.remove("chatmsg-first-daily"):
  68. ((h||f).classList.add("chatmsg-first-daily"),(h||f).dataset.date=J.eb(b.m)));g=b.m}});var k=!0;Ib.forEach(function(b){b.channel===R.id&&(k&&(h=Hb(Q.self,""),a.appendChild(h),k=!1),h.content.appendChild(b.c))});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;wb();window.hasFocus&&zb()}
  69. function Jb(a,b){if(a.classList.contains("chatmsg-hover-reply"))S&&(S=null,Ab()),T!==b&&(T=b,V());else if(a.classList.contains("chatmsg-hover-reaction")){var c=R.id,d=b.id;Kb.ua(document.body,Q,function(a){a&&Bb(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(T&&(T=null,V()),S!==b&&(S=b,Ab())):a.classList.contains("chatmsg-hover-star")?b.B?P("DELETE","api/starMsg?room="+encodeURIComponent(R.id)+"&msgId="+b.id).a():P("POST","api/starMsg?room="+encodeURIComponent(R.id)+"&msgId="+b.id).a():
  70. a.classList.contains("chatmsg-hover-pin")?b.pinned?Lb(R,b):P("POST","api/pinMsg?room="+encodeURIComponent(R.id)+"&msgId="+b.id).a():a.classList.contains("chatmsg-hover-remove")&&(T&&(T=null,V()),S&&(S=null,Ab()),P("DELETE","api/msg?room="+encodeURIComponent(R.id)+"&ts="+b.id).a())}function eb(a,b,c){b={channel:a.id,text:b.trim(),Ga:c,c:Mb(b,c)};Ib.push(b);a===R&&yb();return b}
  71. function Nb(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,g=c.dataset.actionIndex;if((d=b(a,c))&&void 0!==e&&void 0!==g){d=d.substr(d.lastIndexOf("_")+1);(a=oa(C.a[R.id],d))&&a.s[e]&&a.s[e].actions&&a.s[e].actions[g]&&
  72. Ob(a,a.s[e],a.s[e].actions[g]);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[R.id],d))&&Jb(c,a);break}c=c.parentElement}}
  73. function Ob(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};P("POST","api/attachmentAction?serviceId="+encodeURIComponent(a.M)).a(JSON.stringify(d))}var e=R.id;c.confirm?Xa(Wa(new Ja(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).ua():d()}
  74. function Pb(){if(!1!==X.b&&!1!==X.h){var a=document.getElementById("chatWindow").getBoundingClientRect().top;kb.forEach(function(b){var c=b.ka,d=c.clientHeight;b=b.getBoundingClientRect();c.style.top=Math.max(0,Math.min(a-b.top,b.height-d-d/2))+"px"})}}function Qb(){var a=document.getElementById("chatCtx");a.classList.contains("opened")?a.classList.remove("opened"):a.classList.add("opened")}
  75. document.addEventListener("DOMContentLoaded",function(){za();Rb();ib();var a=document.getElementById("chanSearch");a.addEventListener("input",pb);a.addEventListener("blur",pb);document.getElementById("chatWindow").addEventListener("click",Nb);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&qb()});document.addEventListener("mouseover",function(a){a=a.target;if(Sb.Fb(a))Sb.ba();else{for(;a&&a!==this;){if("A"===a.nodeName){var b=a.href,d=b.indexOf("#");
  76. if(0<=d){b=b.substr(d+1);if(d=D(C.context,b)){Sb.mb(d,d.j[b]).show(a);return}a:{for(var d=C.context,e=0,g=d.a.length;e<g;e++)if(d.a[e].i[b]){d=d.a[e];break a}d=null}if(d&&(b=d.i[b].R)){Sb.mb(d,b).show(a);return}}}a=a.parentElement}Sb.Cb()}});document.getElementById("chatCtxButton").addEventListener("click",Qb);document.getElementById("currentRoomStar").addEventListener("click",function(a){a.preventDefault();R&&(R.B?Tb(R):Ub(R));return!1});document.getElementById("fileUploadCancel").addEventListener("click",
  77. 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",Vb);document.getElementById("ctxMenuSettings").addEventListener("click",function(a){a.preventDefault();Wb.display()});document.getElementById("fileUploadForm").addEventListener("submit",function(a){a.preventDefault();
  78. a=document.getElementById("fileUploadInput");var b=a.value;b&&(b=b.substr(b.lastIndexOf("\\")+1),Xb(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();R&&document.getElementById("fileUploadContainer").classList.remove("hidden");
  79. return!1});document.getElementById("msgFormSubmit").addEventListener("click",function(a){a.preventDefault();jb();return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();jb();return!1});window.addEventListener("blur",function(){window.hasFocus=!1});window.addEventListener("focus",function(){window.hasFocus=!0;lb=0;R&&zb();gb()});window.hasFocus=!0;document.getElementById("emojiButton").addEventListener("click",function(){Q&&Kb.ua(document.body,Q,function(a){a&&
  80. (document.getElementById("msgInput").value+=":"+a+":");gb()})});Ia()&&(__native.readSmsPermission(Ha.ib(function(){var a=JSON.parse(__native.getStatic());a&&C.update(a)})),document.body.classList.add("native"));IS_LOCAL||Yb()});function jb(){var a=document.getElementById("msgInput");R&&a.value&&db(a.value)&&(a.value="",T&&(T=null,V()),S&&(S=null,V()),document.getElementById("slashList").textContent="",hb(a));gb()};var Wb=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={V:"services",
  81. display:"display",ac:"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");
  82. 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.u&&(b.emojiProvider=document.getElementById("settings-displayEmojiProvider").value);var c=!!document.getElementById("settings-displayDisplayAvatar").checked;
  83. c!==(!1!==X.b)&&(b.displayAvatar=c);c=!!document.getElementById("settings-displayColorfulNames").checked;c!==(!0===X.o)&&(b.colorfulNames=c);c=!!document.getElementById("settings-displayScrollAvatars").checked;c!==(!1!==X.h)&&(b.scrollAvatars=c);c=document.getElementById("settings-displayAttachmentContent").value;c!==X.a&&(b.autoExpandAttachments=c);var c=X,d;for(d in b){Zb(c,b);$b();P("POST","api/settings?service=null&device=null").a(JSON.stringify(b));break}a()});return{display:function(a){if(!c){document.getElementById("settings").classList.remove("hidden");
  84. var d=document.createDocumentFragment(),g=!1,f;for(f in X.V){var n=X.V[f];for(l in n){var g=document.createElement("li"),p=document.createElement("span"),m=document.createElement("span");p.textContent=f;m.textContent=n[l];g.className="settings-service-list-item";p.className="settings-service-list-item-provider";m.className="settings-service-list-item-service";g.appendChild(p);g.appendChild(m);d.appendChild(g);g=!0}}n=document.getElementById("settings-serviceList");n.textContent="";g?(document.getElementById("settings-serviceListEmpty").classList.remove("hidden"),
  85. n.appendChild(d)):document.getElementById("settings-serviceListEmpty").classList.add("hidden");d=document.createDocumentFragment();n=document.getElementById("settings-displayEmojiProvider");for(f in ac){var l=document.createElement("option");l.value=f;l.textContent=ac[f].name;ac[f]===ab&&(l.selected=!0);d.appendChild(l)}n.textContent="";n.appendChild(d);document.getElementById("settings-displayDisplayAvatar").checked=!1!==X.b;document.getElementById("settings-displayColorfulNames").checked=!0===X.o;
  86. document.getElementById("settings-displayScrollAvatars").checked=!1!==X.h;document.getElementById("settings-displayAttachmentContent").value=void 0!==X.a?X.a:bc;c=!0}b(a||e.V);return this},Lb:function(){return this},Ib:e}}();function cc(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,g){var f=new Image;f.addEventListener("load",function(){d.T=f;e(d)});f.addEventListener("error",function(){console.warn("Error loading tile ",{zoom:a,x:b,y:c});g(f)});f.crossOrigin="anonymous";f.src="https://c.tile.openstreetmap.org/"+a+"/"+b+"/"+c+".png"})},d=document.createElement("canvas"),e=document.createElement("canvas");
  87. d.height=d.width=e.height=e.width=300;var g=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)))},f=function(a,d,e,f){h.fillStyle="#808080";h.fillRect(0,0,300,300);g.fillStyle="#808080";g.fillRect(0,0,300,300);var l=Math.pow(2,a),p=(e+180)/360*l,m=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*l,n=Math.floor(p),K=Math.floor(m),
  88. ya=f?100*f/k(180/Math.PI*Math.atan(.5*(Math.exp(Math.PI-2*Math.PI*K/l)-Math.exp(-(Math.PI-2*Math.PI*K/l)))),n/l*360-180,(n+1)/l*360-180):0;d=b;for(e=0;3>e;e++)for(f=0;3>f;f++)c(a,n+e-1,K+f-1,{Db:e,Gb:f,sb:d}).then(function(a){if(a.sb===b){h.drawImage(a.T,100*a.Db,100*a.Gb,100,100);a=p-n;var c=m-K;a=100*a+100;c=100*c+100;g.putImageData(h.getImageData(0,0,300,300),0,0);void 0!==ya&&(g.beginPath(),g.arc(a,c,Math.max(ya,10),0,2*Math.PI,!1),g.lineWidth=2,g.fillStyle="rgba(244, 146, 66, 0.4)",g.strokeStyle=
  89. "rgba(244, 146, 66, 0.8)",g.stroke(),g.fill());if(void 0===ya||25<ya)g.strokeStyle="rgba(244, 146, 66, 1)",g.beginPath(),g.moveTo(a-5,c-5),g.lineTo(a+5,c+5),g.stroke(),g.moveTo(a+5,c-5),g.lineTo(a-5,c+5),g.stroke()}})},n,p=function(c){c=Math.max(4,Math.min(19,c));n!==c&&(b++,n=c,f(n,Number(a.latitude),Number(a.longitude),Number(a.accuracy)))};p(12);var e=document.createElement("div"),m=document.createElement("div"),l=document.createElement("button"),u=document.createElement("button");e.className=
  90. "OSM-wrapper";d.className="OSM-canvas";m.className="OSM-controls";u.className="OSM-controls-zoomMin";l.className="OSM-controls-zoomPlus";u.addEventListener("click",function(){p(n-1)});l.addEventListener("click",function(){p(n+1)});m.appendChild(u);m.appendChild(l);e.appendChild(d);e.appendChild(m);return e}};function nb(){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 ob=function(){var a={};return function(b){var c=a[b];c||(c=a[b]=document.createElement("header"),c.textContent=b);return c}}();
  91. function dc(a){var b={},c=a;if(Q)for(var d=Q;!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 bb(a){return"makeEmoji"in window?(a=dc(a),"string"===typeof a&&(a=window.makeEmoji(a)),"string"===typeof a?null:a):null}
  92. function ec(a,b){var c=b.context.X;b=C.context.Ga(b.M);if(c.replyToMsg){var d=document.createElement("li");d.className="chatmsg-hover-reply";d.style.backgroundImage='url("repl.svg")';a.appendChild(d)}c.reactMsg&&(d=document.createElement("li"),d.className="chatmsg-hover-reaction",d.style.backgroundImage='url("smile.svg")',a.appendChild(d));if(b&&c.editMsg||c.editOtherMsg)d=document.createElement("li"),d.className="chatmsg-hover-edit",d.style.backgroundImage='url("edit.svg")',a.appendChild(d);c.starMsg&&
  93. (a.oa=document.createElement("li"),a.oa.className="chatmsg-hover-star",a.appendChild(a.oa));c.pinMsg&&(d=document.createElement("li"),d.className="chatmsg-hover-pin",a.appendChild(d),d.style.backgroundImage='url("pin.svg")');if(b&&c.removeMsg||c.moderate)c=document.createElement("li"),c.className="chatmsg-hover-remove",c.style.backgroundImage='url("remove.svg")',a.appendChild(c)}
  94. function fc(a){var b=document.createElement("div"),c=document.createElement("div"),d=document.createElement("summary");b.da=document.createElement("ul");b.s=document.createElement("ul");b.G=document.createElement("ul");b.m=document.createElement("div");b.va=document.createElement("div");b.la=document.createElement("span");b.J=document.createElement("details");b.J.addEventListener("toggle",function(){this.Mb=!0});b.className="chatmsg-item";b.m.className="chatmsg-ts";b.va.className="chatmsg-msg";b.la.className=
  95. "chatmsg-author-name";a&&(b.id=a.b+"_"+a.id,ec(b.da,a),b.da.className="chatmsg-hover");c.appendChild(b.la);c.appendChild(b.va);c.appendChild(b.m);d.textContent="attachment";b.J.appendChild(d);b.J.appendChild(b.s);c.appendChild(b.J);b.H=document.createElement("div");b.H.className="chatmsg-edited";c.appendChild(b.H);c.appendChild(b.G);c.className="chatmsg-content";b.s.className="chatmsg-attachments";b.G.className="chatmsg-reactions";b.appendChild(c);b.appendChild(b.da);return b}
  96. function gc(a){if(!a.length)return"black";for(var b=0,c=0,c=[],d=0,e=0,g=0,h,k=0,f=a.length;k<f;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;g=Math.max(c,g);b=a+((b<<5)-b)});e/=a.length;b=Math.abs(b-60)%199*360/199;c=g?Math.round(Math.min(100,Math.max(75,e/g*25+75))):100;return"hsl("+b+", 100%, "+c+"%)"}
  97. function Hb(a,b){var c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("a"),g=document.createElement("img");c.ka=document.createElement("span");c.ka.className="chatmsg-author-img-wrapper";g.className="chatmsg-author-img";e.className="chatmsg-author-name";e.href="#"+a.id;a?(e.textContent=a.getName(),e.style.backgroundColor=gc(a.getName()),g.src=pa(a)):(e.textContent=b||"?",g.src="");c.ka.appendChild(g);d.appendChild(c.ka);d.appendChild(e);d.className="chatmsg-author";
  98. 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 hc(a){var b={good:"#2fa44f",warning:"#de9e31",danger:"#d50200"};if(a){if("#"===a[0])return a;if(b[a])return b[a]}return"#e3e4e6"}
  99. function ic(a,b,c){var d=document.createElement("li"),e=document.createElement("div"),g=document.createElement("div"),h=document.createElement("a"),k=document.createElement("div"),f=document.createElement("img"),n=document.createElement("a"),p=document.createElement("div"),m=document.createElement("div"),l=document.createElement("div"),u=document.createElement("img"),A=document.createElement("div");d.className="chatmsg-attachment";e.style.borderColor=hc(b.color||"");e.className="chatmsg-attachment-block";
  100. g.className="chatmsg-attachment-pretext";b.pretext?g.innerHTML=a.A(b.pretext):g.classList.add("hidden");h.target="_blank";b.title?(h.innerHTML=a.A(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.A(b.author_name),n.href=b.author_link||"",n.className="chatmsg-author-name",f.className="chatmsg-author-img",b.author_icon&&(f.src=b.author_icon,k.appendChild(f)),
  101. k.appendChild(n));l.className="chatmsg-attachment-thumb";b.thumb_url?(f=document.createElement("img"),f.src=b.thumb_url,l.appendChild(f),e.classList.add("has-thumb"),b.video_html&&(l.dataset.video=b.video_html)):l.classList.add("hidden");p.className="chatmsg-attachment-content";f=a.A(b.text||"");m.className="chatmsg-attachment-text";f&&""!=f?m.innerHTML=f:m.classList.add("hidden");p.appendChild(l);p.appendChild(m);b.geo&&(m=cc(b.geo))&&p.appendChild(m);u.className="chatmsg-attachment-img";b.image_url?
  102. u.src=b.image_url:u.classList.add("hidden");A.className="chatmsg-attachment-footer";b.footer&&(m=document.createElement("span"),m.className="chatmsg-attachment-footer-text",m.innerHTML=a.A(b.footer),b.footer_icon&&(l=document.createElement("img"),l.src=b.footer_icon,l.className="chatmsg-attachment-footer-icon",A.appendChild(l)),A.appendChild(m));b.ts&&(m=document.createElement("span"),m.className="chatmsg-ts",m.innerHTML=J.S(b.ts),A.appendChild(m));e.appendChild(h);e.appendChild(k);e.appendChild(p);
  103. e.appendChild(u);if(b.fields&&b.fields.length){var y=document.createElement("ul");e.appendChild(y);y.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.A(d);e.appendChild(f);e.appendChild(g);e&&y.appendChild(e)})}if(b.actions&&
  104. b.actions.length)for(h=document.createElement("ul"),h.className="chatmsg-attachment-actions "+Sa,e.appendChild(h),k=0,p=b.actions.length;k<p;k++)(u=b.actions[k])&&(u=jc(c,k,u))&&h.appendChild(u);e.appendChild(A);d.appendChild(g);d.appendChild(e);return d}
  105. function jc(a,b,c){var d=document.createElement("li"),e=hc(c.style);d.textContent=c.text;e!==hc()&&(d.style.color=e);d.style.borderColor=e;d.dataset.attachmentIndex=a;d.dataset.actionIndex=b;d.className="chatmsg-attachment-actions-item "+Qa;return d}function ub(a){var b=document.createElement("li"),c=document.createElement("span");c.textContent=a.getName();b.appendChild(nb());b.appendChild(c);return b};var Kb=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(){y={};m.textContent="";window.emojiProviderHeader&&(m.appendChild(k(window.emojiProviderHeader)),l.textContent="",m.appendChild(l));m.appendChild(k("emojicustom.png"));m.appendChild(u)}function c(){if(!d())return!1;r&&r(null);return!0}function d(){return n.parentElement?(n.parentElement.removeChild(p),n.parentElement.removeChild(n),
  106. !0):!1}function e(a){var b=0;a=void 0===a?A.value:a;if(f()){var c=0,d=window.searchEmojis(a),e=g(d,I?I.self.U.a:[]),k;for(p in y)y[p].visible&&(y[p].visible=!1,l.removeChild(y[p].c));var p=0;for(k=e.length;p<k;p++){var m=e[p].name,n=y[m];if(!n){var n=y,K=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);n=n[K]=r}n.visible||(n.visible=!0,l.appendChild(n.c));c++}b+=c}p=b;c=0;for(E in z)z[E].visible&&(z[E].visible=!1,u.removeChild(z[E].c));
  107. if(I){d=g(I.b.data,I?I.self.U.a:[]);var E=0;for(b=d.length;E<b;E++)K=d[E].name,""!==a&&K.substr(0,a.length)!==a||"alias:"===I.b.data[K].substr(0,6)||(e=z[K],e||(e=z,n=k=K,K=I.b.data[K],r=document.createElement("span"),m=document.createElement("span"),r.className="emoji emoji-custom",r.style.backgroundImage='url("'+K+'")',r.textContent=":"+n+":",r.title=n,m.appendChild(r),m.className="emoji-medium",n=h(n,m),e=e[k]=n),e.visible||(e.visible=!0,u.appendChild(e.c)),c++);E=c}else E=0;return p+E}function g(a,
  108. b){var c=[],d;for(d in a){var e={name:d,nb: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.nb-b.nb})}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";
  109. return c}function f(){return"searchEmojis"in window}var n=document.createElement("div"),p=document.createElement("div"),m=document.createElement("div"),l=document.createElement("ul"),u=document.createElement("ul"),A=document.createElement("input"),y={},z={},L=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)&&
  110. c()});p.className="emojibar-overlay";n.className="emojibar";m.className="emojibar-emojis";l.className=u.className="emojibar-list";A.className="emojibar-search";L.className="emojibar-detail";H.className="emojibar-detail-img";E.className="emojibar-detail-name";L.appendChild(H);L.appendChild(E);b();n.appendChild(m);n.appendChild(L);n.appendChild(A);A.addEventListener("keyup",function(){e()});n.addEventListener("mousemove",function(b){a(b,function(a){var b=a?y[a]||z[a]:null;b?(H.innerHTML=b.c.outerHTML,
  111. E.textContent=":"+a+":"):(H.textContent="",E.textContent="")})});n.addEventListener("click",function(b){a(b,function(a){a&&d()&&r&&r(a)})});return{isSupported:f,ua:function(a,b,c){return f()?(I=b,r=c,a.appendChild(p),a.appendChild(n),A.value="",e(),A.focus(),!0):!1},search:e,close:c,reset:function(){b();e()}}}();var C,U=[];function kc(){da.call(this)}kc.prototype=Object.create(da.prototype);kc.prototype.constructor=kc;function sa(a){return a.a?a.a.id:null}function lc(){this.b=0;this.context=new qa;this.a={}}
  112. lc.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(f in a["static"]){var c=ra(this.context,f);c||(c=new kc,this.context.push(c));var d={};a["static"][f].channels&&a["static"][f].channels.forEach(function(a){a.pins&&(d[a.id]=a.pins,a.pins=void 0)});fa(c,a["static"][f],b);for(var e in d){var g=[],h=this.a[e];h||(h=this.a[e]=new Y(e,250,null,b));d[e].forEach(function(a){g.push(h.b(a,b))});c.j[e].b=g}}ta(this.context,function(a){a.C===a.D&&(a=U.indexOf(a),-1!==a&&U.splice(a,
  113. 1))});if(a.live){for(f in a.live)(c=this.a[f])?la(c,a.live[f],b):c=this.a[f]=new Y(f,250,a.live[f],b);for(var k in a.live){var f=D(this.context,k);(c=f.j[k])?(this.a[k].a.length&&ha(c,na(this.a[k]).m,b),c.ja||(mc(f,c,a.live[k]),R&&a.live[R.id]&&yb())):C.b=0}}a["static"]&&mb();var n=!1;a.typing&&this.context.a.forEach(function(c){var d=n,e=a.typing,f=!1;if(c.w)for(var g in c.w)e&&!e[g]&&(delete c.w[g],f=!0);if(e)for(g in e)if(c.j[g]){c.w[g]||(c.w[g]={});for(var h in e[g])c.w[g][h]||(f=!0),c.w[g][h]=
  114. b}n=d|f},this);(a["static"]||n)&&sb();a.config&&(X=new nc(a.config),$b());if(Q&&R&&a["static"]&&a["static"][Q.a.id]&&a["static"][Q.a.id].channels&&a["static"][Q.a.id].channels)for(k=a["static"][Q.a.id].channels,f=0,c=k.length;f<c;f++)if(k[f].id===R.id){yb();break}};setInterval(function(){var a=!1,b=Date.now();ua(function(c){var d=!1,e;for(e in c.w){var g=!0,h;for(h in c.w[e])c.w[e][h]+6500<b?(delete c.w[e][h],d=!0):g=!1;g&&(delete c.w[e],d=!0)}d&&(a=!0)});a&&sb()},1E3);
  115. function mc(a,b,c){var d;if(b!==R||!window.hasFocus){var e=(d=a.self?a.self.id:null)?new RegExp("<@"+d):null,g=!1,h=!1,k=!1;c.forEach(function(c){if(!(parseFloat(c.ts)<=b.D)&&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.U.F;for(var f=0,l=d.length;f<l;f++)if(-1!==c.text.indexOf(d[f])){d=!0;break a}d=!1}d&&(-1===U.indexOf(b)&&(k=!0,U.push(b)),g=!0)}});if(h){wb();var f=document.getElementById("room_"+b.id);f&&(f.classList.add("unread"),g&&f.classList.add("unreadHi"));
  116. k&&!window.hasFocus&&Eb()}}c.forEach(function(a){if(!d||d===a.M)for(var c=0,e=Ib.length;c<e;c++){var f=Ib[c];if(f.channel===b.id&&!!a.isMeMessage===f.Ga&&(a.pendingId===f.ra&&f.ra||!f.ra&&a.text.trim()===f.text)){Ib.splice(c,1);break}}})}
  117. function zb(){var a=R,b=U.indexOf(a);if(a.C>a.D){var c=C.a[a.id];c&&(c=na(c))&&(P("POST","api/markread?room="+encodeURIComponent(a.id)+"&id="+c.id+"&ts="+c.m).a(),a.D=c.m)}0<=b&&(U.splice(b,1),wb());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}function oc(){for(var a in C.a)pc(C.a[a]);R&&yb()}C=new lc;var rb=function(){function a(a,c){c.sort(function(){return Math.random()-.5});for(var d=0,e=20;e<n-40;e+=m)for(var f=0;f+m<=p;f+=m)h(a,c[d],e,f),d++,d===c.length&&(c.sort(b),d=0)}function b(a,b){return a.T?b.T?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].T){d(a[e].src,function(d){a[e].T=d;c(a,b)});return}var g=[];a.forEach(function(a){a.T&&g.push(a.T)});b(g)}function d(a,b){Da(N(P(a),function(a,c,d){if(d){var e=new Image;e.onload=function(){var a=document.createElement("canvas");
  118. 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)}).h("blob").a()}function e(){var a=f.createLinearGradient(0,
  119. 0,0,p);a.addColorStop(0,"#4D394B");a.addColorStop(1,"#201820");f.fillStyle=a;f.fillRect(0,0,n,p);return f.getImageData(0,0,n,p)}function g(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]];f.fillStyle="#"+(1.1*a[0]<<16|1.1*a[1]<<8|1.1*a[2]).toString(16);f.beginPath();
  120. f.moveTo(c+m/2,d+l);f.lineTo(c-l+m,d+m/2);f.lineTo(c+m/2,d-l+m);f.lineTo(c+l,d+m/2);f.closePath();f.fill();f.putImageData(g(f.getImageData(c+l,d+l,u,u),b),c+l,d+l)}var k=document.createElement("canvas"),f=k.getContext("2d"),n=k.width=250,p=k.height=290,m=(n-40)/3,l=.1*m,u=Math.floor(m-2*l),A=.5*u,y={},z={},L={};return function(b,d,f){if(y[b])f(y[b]);else if(L[b])z[b]?z[b].push(f):z[b]=[f];else{var g=e(),h=[];L[b]=!0;z[b]?z[b].push(f):z[b]=[f];for(var l in d)d[l].ab||d[l].Eb||h.push({src:pa(d[l])});
  121. c(h,function(c){a(g,c);y[b]=k.toDataURL();z[b].forEach(function(a){a(y[b])})})}}}();var W=0,R=null,Fb=-1,Gb=document.createElement("span"),Q=null,T=null,S=null,Ib=[];function Rb(){Da(N(P("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")}).o(6E4).a()}
  122. function qc(){var a=R;Ca(N(P("api/hist?room="+encodeURIComponent(a.id)).h("json"),function(b,c,d){if(d){b=C.a[a.id];var e=Date.now();b?c=!!la(b,d,e):(b=C.a[a.id]=new Y(a,100,d,e),c=!0);c&&(b.a.length&&ha(a,na(b).m,e),mc(D(C.context,a.id),a,d),a===R&&yb())}}),function(){}).a()}
  123. function $b(){rc()&&Wb.Lb(!1).display(Wb.Ib.V);sc();!1!==X.h?(document.getElementById("chatWindow").addEventListener("scroll",Pb),Pb()):(oc(),document.getElementById("chatWindow").removeEventListener("scroll",Pb));for(var a in C.a)C.a[a].a.forEach(function(a){a.c&&a.L()});document.getElementById("customsheet").innerHTML=tc()}
  124. function Yb(){var a=uc;IS_LOCAL||Ca(P("api?v="+C.b),function(b,c,d){(b=2===Math.floor(b/100))?W&&(W=0,vb(!0)):W?(W+=Math.floor((W||5)/2),W=Math.min(60,W)):(W=5,vb(!1));a(b,d)}).h("json").o(6E4).a()}function uc(a,b){a?(b&&C.update(b),Yb()):setTimeout(vc,1E3*W)}function vc(){Yb()}function Db(a){if(Ia()){var b=!(!Q||!Q.X.starChannel);__native.setTitle(a,b,b?R.B:!1)}}
  125. function wc(a){R&&(document.getElementById("room_"+R.id).classList.remove("selected"),document.getElementById("chatSystemContainer").classList.add("no-room-selected"),Gb.remove());Gb.className="chatmsg-unread";Gb.textContent=J.Ia;document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");R=a;Q=D(C.context,a.id);Fb=a.D;Ia()&&__native.setCurrentChannel(a.id);xb();Sb.Bb();rb(Q.a.id,Q.i,function(a){document.getElementById("chatCtx").style.backgroundImage=
  126. "url("+a+")"});(!C.a[R.id]||100>C.a[R.id].a.length)&&qc();document.getElementById("chatSystemContainer").classList.remove("no-room-selected");document.getElementById("chatCtx").classList.remove("opened")}function qb(){var a=document.location.hash.substr(1),b=va(a);return b&&b!==R?(wc(b),!0):(a=F(a))&&a.R?(wc(a.R),!0):!1}function Ub(a){P("POST","api/starChannel?room="+encodeURIComponent(a.id)).a()}function Tb(a){P("POST","api/unstarChannel?room="+encodeURIComponent(a.id)).a()}
  127. function Xb(a,b,c){var d=R;new FileReader;var e=new FormData;e.append("file",b);e.append("filename",a);Da(N(P("POST","api/file?room="+encodeURIComponent(d.id)),function(){c(null)}),function(a,b){c(b)}).a(e)}
  128. function fb(a,b,c,d){b="api/msg?room="+encodeURIComponent(a.id)+"&text="+encodeURIComponent(b);d&&(b+="&attachments="+encodeURIComponent(JSON.stringify([{fallback:d.text,author_name:F(d.M).getName(),text:d.text,footer:a.h?J.message:a.name,ts:d.m}])));Fb=-1;Gb.remove();N(P("POST",b).h("json"),function(a,b,d){d&&void 0!==d.pendingId&&(c.ra=d.pendingId)}).a()}function Lb(a,b){P("DELETE","api/pinMsg?room="+encodeURIComponent(a.id)+"&msgId="+b.id).a()}
  129. function Bb(a,b,c){P("POST","api/reaction?room="+encodeURIComponent(a)+"&msg="+b+"&reaction="+encodeURIComponent(c)).a()}function Vb(){P("POST","api/logout").a();document.cookie="sessID=;Path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;";document.location.reload();Ia()&&__native.logout()}
  130. function pb(){var a={},b=[],c=this.value;ta(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].qa+a[d].xa+a[d].ta?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var ac={noemoji:{Ha:"noemoji.js",ma:null,name:"None"},emojione_v2_3:{Ha:"emojione_v2.3.sprites.js",ma:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Ha:"emojione_v3.sprites.js",ma:"emojione_v3.sprites.css",name:"Emojione v3"}},xc=ac.emojione_v2_3,ab;
  131. function yc(a){ab!==a&&(console.log("Loading emoji pack "+a.name),N(P(a.Ha),function(b,c,d){b=document.createElement("script");b.innerHTML=d;b.language="text/javascript";document.body.appendChild(b);a.ma&&(d=document.createElement("link"),d.href=a.ma,d.rel="stylesheet",document.head.appendChild(d));d=document.getElementById("emojiButton");oc();Kb.reset();"makeEmoji"in window?(d.style.backgroundImage='url("smile.svg")',d.classList.remove("hidden")):d.classList.add("hidden")}).o(6E4).a(),ab=a)}
  132. function sc(){var a=X.u;yc(a&&ac[a]?ac[a]:xc)};var Sb=function(){function a(){c();r instanceof t?(g.style.backgroundImage="url(api/avatar?size=l&user="+encodeURIComponent(r.a.id)+")",n.textContent=(r.a.pb||(r.a.cb||"")+" "+r.a.hb).trim(),h.classList.add("presence-indicator"),r.a.P?h.classList.remove("presence-away"):h.classList.add("presence-away"),f.classList.remove("hidden"),m.classList.remove("hidden"),m.textContent=r.a.Jb||"",u.textContent=r.a.Ab||"",l.classList.remove("hidden"),e.classList.remove("roominfo-channel"),e.classList.add("roominfo-user")):
  133. b()}function b(){var a=E;a.X.topic?(f.classList.remove("hidden"),n.textContent=r.xa||"",p.textContent=r.u?J.Ma(r.u,r.fa):""):f.classList.add("hidden");a.X.purpose?(l.classList.remove("hidden"),u.textContent=r.ta||"",A.textContent=r.o?J.Ma(r.o,r.ea):""):l.classList.add("hidden");g.style.backgroundImage="";h.classList.remove("presence-indicator");L.textContent=J.rb(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.P&&!b.P?-1:b.P&&!a.P?1:a.getName().localeCompare(b.getName())});
  134. 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.P||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){y.textContent=J.lb(r.b.length);y.classList.remove("hidden");z.classList.remove("hidden");
  135. 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=Qa+" roominfo-unpin";c.className="roominfo-pinlist-item";c.appendChild(b.N());c.appendChild(e);a.appendChild(c)});z.textContent="";z.appendChild(a)}else y.classList.add("hidden"),z.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){Lb(r,
  136. r.b[a]);break}}var e=document.createElement("div"),g=document.createElement("header"),h=document.createElement("h3"),k=document.createElement("div"),f=document.createElement("div"),n=document.createElement("span"),p=document.createElement("span"),m=document.createElement("div"),l=document.createElement("div"),u=document.createElement("span"),A=document.createElement("span"),y=document.createElement("div"),z=document.createElement("ul"),L=document.createElement("div"),H=document.createElement("ul"),
  137. E,r;e.className="chat-context-roominfo";g.className="roominfo-title";f.className="roominfo-topic";l.className="roominfo-purpose";m.className="roominfo-phone";y.className="roominfo-pincount";z.className="roominfo-pinlist";L.className="roominfo-usercount";H.className="roominfo-userlist";A.className=p.className="roominfo-author";g.appendChild(h);e.appendChild(g);e.appendChild(k);f.appendChild(n);f.appendChild(p);l.appendChild(u);l.appendChild(A);k.appendChild(f);k.appendChild(m);k.appendChild(l);k.appendChild(y);
  138. k.appendChild(z);k.appendChild(L);k.appendChild(H);var I=null;return{mb:function(b,c){this.ba();E=b;r=c;a();return this},update:function(){this.ba();a();return this},show:function(a){this.ba();a.appendChild(e);e.classList.remove("hidden");return this},Bb:function(){this.ba();e.classList.add("hidden");return this},ba:function(){I&&clearTimeout(I);I=null;return this},Cb:function(){I||(I=setTimeout(function(){e.classList.add("hidden");I=null},300));return this},Fb:function(a){for(;a;){if(a===e)return!0;
  139. 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 zc(this.id,a,b):!0===a.isNotice?new Ac(this.id,a,b):new Bc(this.id,a,b)};function pc(a){a.a.forEach(function(a){a.I()})}
  140. var Z=function(){function a(a,d){return Aa(d,{F:a.context.self.U.F,Z:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=bb(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null},pa: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=sa(a.context)+"|"+h.substr(1),d=F(h))a=!0,h="#"+d.R.id,k="@"+d.getName(),d="background-color:"+
  141. gc(d.getName()),b=["chatmsg-link-user","chatmsg-link"];else return null;else if("#"===h[0])if(h=sa(a.context)+"|"+h.substr(1),k=va(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,$a:b,gb:a}}return{I:function(a){a.W=!0;return a},$:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},O:function(a){a.c?a.W&&(a.W=!1,a.L()):a.Da().L();return a.c},
  142. L:function(b){var c=F(b.M);b.c.m.innerHTML=J.S(b.m);b.c.va.innerHTML=a(b,b.text);b.c.la.textContent=c?c.getName():b.username||"?";for(var e=document.createDocumentFragment(),g=c=!1,h=0,k=b.s.length;h<k;h++){var f=b.s[h];if(f){var n=ic(b,f,h);n&&(e.appendChild(n),c|=!!f.image_url,g=!0)}}b.c.s.textContent="";b.c.s.appendChild(e);g?(b.c.J.classList.remove("hidden"),b.c.J.Mb||(e=X,b.c.J.open=1!==e.a&&(e.a!==bc&&void 0!==e.a||c)?!1:!0)):b.c.J.classList.add("hidden");c=b.b;e=document.createDocumentFragment();
  143. if(b.G)for(var p in b.G){g=c;h=b.id;k=p;f=b.G[p];if(n=bb(k)){for(var m=document.createElement("li"),l=document.createElement("a"),u=document.createElement("span"),A=document.createElement("span"),y=[],z=0,L=f.length;z<L;z++){var H=F(f[z]);H&&y.push(H.getName())}y.sort();A.textContent=y.join(", ");u.appendChild(n);u.className="emoji-small";l.href="javascript:toggleReaction('"+g+"', '"+h+"', '"+k+"')";l.appendChild(u);l.appendChild(A);m.className="chatmsg-reaction-item";m.appendChild(l);g=m}else console.warn("Reaction id not found: "+
  144. k),g=null;g&&e.appendChild(g)}b.c.G.textContent="";b.c.G.appendChild(e);b.c.da.oa&&(b.c.da.oa.style.backgroundImage=b.B?'url("star_full.png")':'url("star_empty.png")');b.H&&(b.c.H.innerHTML=J.H(b.H),b.c.classList.add("edited"));return b},N:function(a){return a.O().cloneNode(!0)},A:function(b,d){return a(b,d)}}}();function zc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.c=Z.c;this.W=Z.W}zc.prototype=Object.create(x.prototype);q=zc.prototype;q.constructor=zc;q.I=function(){return Z.I(this)};
  145. q.A=function(a){return Z.A(this,a)};q.$=function(){return Z.$(this)};q.O=function(){return Z.O(this)};q.Da=function(){this.c=fc(this);this.c.classList.add("chatmsg-me_message");return this};q.N=function(){return Z.N(this)};q.L=function(){Z.L(this);return this};q.update=function(a,b){x.prototype.update.call(this,a,b);this.I()};function Bc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.c=Z.c;this.W=Z.W}Bc.prototype=Object.create(w.prototype);q=Bc.prototype;q.constructor=Bc;q.I=function(){return Z.I(this)};
  146. q.A=function(a){return Z.A(this,a)};q.$=function(){return Z.$(this)};q.O=function(){return Z.O(this)};q.Da=function(){this.c=fc(this);return this};q.N=function(){return Z.N(this)};q.L=function(){Z.L(this);return this};
  147. q.update=function(a,b){w.prototype.update.call(this,a,b);this.I();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],
  148. longitude:a[3],accuracy:a[5]}})};function Ac(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.a=null;this.W=!0}Ac.prototype=Object.create(B.prototype);q=Ac.prototype;q.constructor=Ac;q.I=function(){return Z.I(this)};q.A=function(a){return Z.A(this,a)};q.$=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};q.O=function(){Z.O(this);return this.a};q.N=function(){return this.a.cloneNode(!0)};
  149. q.Da=function(){this.c=fc(this);this.a=document.createElement("span");this.c.classList.add("chatmsg-notice");this.a.className="chatmsg-notice";this.a.textContent=J.kb;this.a.appendChild(this.c);return this};q.L=function(){Z.L(this);return this};q.update=function(a,b){B.prototype.update.call(this,a,b);this.I()};
  150. function Mb(a,b){var c=fc(null);c.classList.add("chatmsg-pending");b&&c.classList.add("chatmsg-me_message");c.va.innerHTML=Aa(a,{Z:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=bb(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null}});c.la.textContent=Q.self?Q.self.getName():"";a=document.createElement("span");a.className="typing-dot1";a.textContent=".";c.m.appendChild(a);a=document.createElement("span");
  151. 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");c.J.remove();return c};function rc(){var a=X.V,b;for(b in a)if(a.hasOwnProperty(b))return!1;return!0};var X,bc=2;function nc(a){this.V={};for(var b=0,c=a.length;b<c;b++)null===a[b].service&&null===a[b].device&&Zb(this,JSON.parse(a[b].config))}
  152. function Zb(a,b){if(b.services)for(var c in b.services)a.V[c]=b.services[c];void 0!==b.emojiProvider&&(a.u=b.emojiProvider);void 0!==b.displayAvatar&&(a.b=b.displayAvatar);void 0!==b.colorfulNames&&(a.o=b.colorfulNames);void 0!==b.scrollAvatars&&(a.h=b.scrollAvatars);void 0!==b.autoExpandAttachments&&(a.a=b.autoExpandAttachments);"string"===typeof a.a&&(a.a=parseInt(a.a,10))}
  153. function tc(){var a=X,b={},c="";!1===a.b&&(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"]=
  154. ["content:'<'"],b[".chatmsg-author-name::after"]=["content:'>'"]);!0===a.o||(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 nc([]);function Cc(){}Cc.prototype.close=function(){};function Dc(a,b){Cc.apply(this);this.La=Ec++;this.wb=a;this.port=b}Dc.prototype=Object.create(Cc);Dc.prototype.constructor=Dc;Dc.prototype.connect=function(){return new Promise(function(){__native.TCPConnect(this.La,this.wb,this.port)})};Dc.prototype.write=function(a){__native.TCPWrite(this.La,a)};Dc.prototype.close=function(){__native.TCPClose(this.La)};var Ec=0;var Ha=function(){var a={},b=0;return{ib:function(c,d){var e=b++;d&&(c.xb=d);a[""+e]=c;return e},Hb:function(){var b=""+Array.prototype.shift.call(arguments);a[b]&&(a[b].apply(a[b].xb,arguments),delete a[b])}}}();window.__CALLBACK={onResult:Ha.Hb};function Ia(){return!!("__native"in window)};window.displayMenu=function(){document.getElementById("chatCtx").classList.add("opened")};window.hideMenu=function(){document.getElementById("chatCtx").classList.remove("opened")};window.toggleMenu=function(){Qb()};window.setChannelFavorite=function(a,b){var c=va(a);c?b?Ub(c):Tb(c):console.error("Channel "+a+" not found")};window.onApplicationPaused=function(){window.hasFocus=!1};window.onApplicationResumed=function(){window.hasFocus=!0};var cb=function(){var a=[];return{fb:function(b){for(var c=0,d=a.length;c<d;c++)if(-1!==a[c].names.indexOf(b))return a[c];return null},zb:function(b){var c=[];a.forEach(function(a){for(var d=0,g=a.names.length;d<g;d++)if(a.names[d].substr(0,b.length)===b){c.push(a);break}});return c},Kb:function(b){b.Y="client";b.exec=b.exec.bind(b);a.push(b)}}}();function Fc(){return new Promise(function(a,b){"geolocation"in window.navigator?navigator.geolocation.getCurrentPosition(function(c){c?a(c):b("denied")}):b("geolocation not available")})}
  155. xa.push(function(){cb.Kb({name:"/sherlock",names:["/sherlock","/sharelock"],usage:"",description:J.qb,exec:function(a,b){Fc().then(function(a){var c=a.coords.latitude,e=a.coords.longitude;fb(b,"https://www.openstreetmap.org/?mlat="+c+"&mlon="+e+"&macc="+a.coords.accuracy+"#map=17/"+c+"/"+e)}).catch(function(a){console.error("Error: ",a)})}})});
  156. })();