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.Z=a.category}function ca(){this.a={};this.H=[];this.version=0}
  3. ca.prototype.update=function(a,b){a.emoji_use&&(this.a=JSON.parse(a.emoji_use));a.highlight_words?this.H=(a.highlight_words||"").split(",").filter(function(a){return""!==a.trim()}):a.highlights&&(this.H=a.highlights);this.version=Math.max(this.version,b)};function da(){this.a=null;this.m={};this.j={};this.self=null;this.b={version:0,data:{}};this.h={version:0,data:{}};this.B={};this.Y={};this.s=0}function ea(a,b){return b.pv?new t(b.id,a.j[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,f=b.users.length;e<f;e++){var h=a.j[d+b.users[e].id];h||(h=a.j[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.m[d+b.channels[e].id])||(h=a.m[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.j[d+b.self.id]||null,a.self.W||(a.self.W=new ca),b.self.prefs&&a.self.W.update(b.self.prefs,c));b.capacities&&(a.Y={},b.capacities.forEach(function(a){this.Y[a]=!0},a));a.s=Math.max(a.s,c)}"undefined"!==typeof module&&(module.M.Qb=da,module.M.Rb=aa,module.M.Tb=ba);function v(a){this.id=a;this.D=!1;this.u=0;this.j={};this.version=0}function ha(a,b,c){if(!a.G||a.G<b)a.G=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.ka=a.is_archived);void 0!==a.is_member&&(this.ca=a.is_member);void 0!==a.last_read&&(this.u=Math.max(parseFloat(a.last_read),this.u));void 0!==a.last_msg&&(this.G=parseFloat(a.last_msg));this.G&&(this.u=Math.min(this.u,this.G));void 0!==a.is_private&&(this.h=a.is_private);void 0!==a.pins&&(this.b=a.pins);this.D=!!a.is_starred;if(a.members&&(this.j={},a.members))for(var e=0,f=a.members.length;e<
  7. f;e++){var h=b.j[d+a.members[e]];this.j[h.id]=h;h.m[this.id]=this}a.topic&&(this.ya=a.topic.value,this.A=b.j[d+a.topic.creator],this.fa=a.topic.last_set);a.purpose&&(this.ua=a.purpose.value,this.s=b.j[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.oa(b,a.name),ra:c.oa(b,Object.values(a.j),function(a){return a?a.getName():null}),ya:c.oa(b,a.ya),ua:c.oa(b,a.ua)}}
  8. function t(a,b){v.call(this,a);this.a=b;this.name=b.getName();this.h=!0;b.S=this}t.prototype=Object.create(v.prototype);t.prototype.constructor=t;"undefined"!==typeof module&&(module.M.Zb=v,module.M.Yb=t);function w(a,b){this.O=a.user;this.username=a.username;this.id=a.id||a.ts;this.l=parseFloat(a.ts);this.text="";this.w=[];this.D=a.is_starred||!1;this.h=this.J=!1;this.I={};this.version=b;this.update(a,b)}function y(a,b){w.call(this,a,b)}function A(a,b){w.call(this,a,b)}
  9. w.prototype.update=function(a,b){if(a){this.text=a.text||"";a.attachments&&(this.w=a.attachments);this.D=!!a.is_starred;this.J=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.I=c}a.pendingId&&(this.sa=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.i=[];this.b=c;this.sb=0;this.h=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.a=function(a,b){return!0===a.isMeMessage?new y(a,b):!0===a.isNotice?new A(a,b):new w(a,b)};
  11. ka.prototype.push=function(a,b){for(var c,d=!1,e,f=0,h=this.i.length;f<h;f++)if(c=this.i[f],c.id===a.id){e=c.update(a,b);d=!0;break}d||(c=this.a(a,b),this.i.push(c),e=c.l);for(;this.i.length>this.h;)this.i.shift();if(this.b)for(a=0;a<this.i.length;a++)this.i[a].version<b-this.b&&this.i.splice(a--,1);return e||0};function na(a){return a.i[a.i.length-1]}function oa(a,b){for(var c=0,d=a.i.length;c<d;c++)if(a.i[c].id==b)return a.i[c];return null}
  12. function ma(a){a.i.sort(function(a,c){return a.l-c.l})}y.prototype=Object.create(w.prototype);y.prototype.constructor=y;A.prototype=Object.create(w.prototype);A.prototype.constructor=A;"undefined"!==typeof module&&(module.M={Vb:w,Ub:y,Xb:A,$b:ka});function ga(a){this.id=a;this.m={};this.S=this.W=null;this.version=0}
  13. ga.prototype.update=function(a,b){void 0!==a.name&&(this.name=a.name);void 0!==a.deleted&&(this.bb=a.deleted);void 0!==a.status&&(this.status=a.status);void 0!==a.goal&&(this.Bb=a.goal);void 0!==a.phone&&(this.Kb=a.phone);void 0!==a.first_name&&(this.eb=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.R=a.isPresent);a.isBot&&(this.Fb=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.eb||this.hb};"undefined"!==typeof module&&(module.M.Sb=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],f;for(f in e.m)if(!0===b(e.m[f],f))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].m[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].m[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 f=b.a[d].m,h;for(h in f)a&&!a(f[h],b.a[d],h)||c.push(h)}return c}function E(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}qa.prototype.Ha=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.M.Wb=qa);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{oa:a}}();"undefined"!==typeof module&&(module.M.ac=ja);var G={},H,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")}H=G[c];console.log("Loading language pack: "+c);if(H.c)for(var d in H.c)if(c=document.getElementById(d))c.textContent=H.c[d];xa.forEach(function(a){a()})};G.fr={Pb:"Utilisateur inconnu",Ob:"Channel inconnu",Ja:"Nouveau message",message:"Message",jb:"Reseau",kb:"(visible seulement par vous)",D:"Favoris",m:"Discutions",ra:"Membres",ob:"Discutions priv\u00e9es",qb:"Partage sa position GPS",ok:"Ok",cb:"Annuler",U: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()},zb: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()},Fa: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.J=function(a){return"(edit&eacute; "+G.fr.U(a)+")"};G.fr.Na=function(a,b){return"par "+a.getName()+" le "+G.fr.U(b)};G.en={Pb:"Unknown member",Ob:"Unknown channel",Ja:"New message",message:"Message",jb:"Network",kb:"(only visible to you)",D:"Starred",m:"Channels",ra:"Members",ob:"Direct messages",qb:"Share your GPS location",ok:"Ok",cb:"Cancel",U: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()},zb: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()},Fa: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.J=function(a){return"(edited "+G.en.U(a)+")"};
  24. G.en.Na=function(a,b){return"by "+a.getName()+" on "+G.en.U(b)};var Aa=function(){function a(a){this.text="";this.g=a}function b(b,c,d){this.aa=c;this.f=null;this.o=[];this.a=d||"";this.Ba="<"===this.a;this.La="*"===this.a;this.Aa="_"===this.a;this.Ca="~"===this.a||"-"===this.a;this.h=">"===this.a||"&gt;"===this.a;this.A=":"===this.a;this.Oa="`"===this.a;this.Za="```"===this.a;this.Pa="\n"===this.a;this.za=void 0!==d&&-1!==p.H.indexOf(d);this.g=b;this.Da=null;this.b=this.Pa||this.za?c+d.length-1:!1;this.za&&(this.f=new a(this),this.o.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||m;for(var c=0,e=a.o.length;c<e;c++){var l=a.o[c];if(l instanceof b)if(l.b){if(l=
  26. d(l))return l}else return l}return null}function e(a,c){a.g instanceof b&&(a.g.o.splice(a.g.o.indexOf(a)+(c?1:0)),a.g.f=a.g.o[a.g.o.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,gb:!1}}var g,m,p={H:[],$:h,xa:h,qa:k};b.prototype.Ra=function(){return this.La&&!!this.b||this.g instanceof b&&this.g.Ra()};b.prototype.Ua=function(){return this.Aa&&!!this.b||this.g instanceof b&&this.g.Ua()};b.prototype.Va=function(){return this.Ca&&
  27. !!this.b||this.g instanceof b&&this.g.Va()};b.prototype.fa=function(){return this.A&&!!this.b||this.g instanceof b&&this.g.fa()};b.prototype.Ta=function(){return this.za&&!!this.b||this.g instanceof b&&this.g.Ta()};b.prototype.Sa=function(){return this.Oa&&!!this.b||this.g instanceof b&&this.g.Sa()};b.prototype.ea=function(){return this.Za&&!!this.b||this.g instanceof b&&this.g.ea()};b.prototype.Wa=function(){for(var a=0,c=this.o.length;a<c;a++)if(this.o[a]instanceof b&&(!this.o[a].b||this.o[a].Wa()))return!0;
  28. return!1};b.prototype.Xa=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.La||this.Aa||this.Ca))return!1;if(this.f&&this.Wa())return this.f.$a();if(this.tb())return!0}return"\n"===g[a]&&this.h?!0:!1};b.prototype.tb=function(){for(var a=this;a;){for(var c=0,d=a.o.length;c<d;c++)if(a.o[c]instanceof b||a.o[c].text.length)return!0;a=a.Da}return!1};b.prototype.$a=function(){var a=new b(this.g,this.aa,this.a);a.Da=this;this.f&&
  29. this.f instanceof b&&(a.f=this.f.$a(),a.o=[a.f]);return a};b.prototype.ub=function(a){return this.A&&(" "===g[a]||"\t"===g[a])||(this.A||this.Ba||this.La||this.Aa||this.Ca||this.Oa)&&"\n"===g[a]?!1:!0};b.prototype.vb=function(b){if(this.Oa||this.A||this.Za||this.Ba)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.Ka();if(void 0===f||f){if("&gt;"===g.substr(b,4))return"&gt;";if(">"===g[b])return g[b]}if("`"===g[b]&&!d||
  30. "\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.H.length;d<e;d++)if(f=p.H[d],g.substr(b,f.length)===f)return f}return null};a.prototype.Ka=function(){if(""!==this.text.trim())return!1};b.prototype.Ka=function(){for(var a=this.o.length-1;0<=a;a--){var b=this.o[a].Ka();if(void 0!==b)return b}if(this.Pa||
  31. this.h)return!0};a.prototype.s=function(a){this.text+=g[a];return 1};b.prototype.s=function(c){var d=this.f&&!this.f.b&&this.f.Xa?this.f.Xa(c):null;if(d){var e=this.f.a.length;this.f.Qa(c);d instanceof b&&(this.f=d,this.o.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.o.push(this.f),this.f.a.length;if(!this.f||this.f.b)this.f=new a(this),this.o.push(this.f);return this.f.s(c)}d=this.f.aa+1;m.ca(this.f.aa);this.f=new a(this);
  32. this.f.s(d-1);this.o.pop();this.o.push(this.f);return d-c};b.prototype.Qa=function(a){for(var b=this;b;)b.b=a,b=b.Da};b.prototype.ca=function(a){this.b&&this.b>=a&&(this.b=!1);this.o.forEach(function(c){c instanceof b&&c.ca(a)})};a.prototype.innerHTML=function(){if(this.g.fa()){for(var a=this.g;a&&!a.A;)a=a.g;if(a){var a=a.a+this.text+a.a,b=p.$(a);return b?b:a}return(a=p.$(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.xa(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.Sa()?(b.push("code"),d=this.innerHTML()):(this.g.Ba&&(d=p.qa(this.text))?
  34. (a="a",c=' href="'+d.link+'"',d.style&&(c+=' style="'+d.style+'"'),d.gb||(c+=' target="_blank"'),d.ab&&d.ab.forEach(function(a){b.push(a)}),d=p.xa(d.text)):d=this.innerHTML(),this.g.Ra()&&b.push("bold"),this.g.Ua()&&b.push("italic"),this.g.Va()&&b.push("strike"),this.g.fa()&&b.push("emoji"),this.g.Ta()&&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.Pa&&(a+="<br/>");this.o.forEach(function(b){a+=
  35. b.outerHTML()});this.h&&(a+="</span>");return a};b.prototype.Ya=function(a){this.h&&!this.b&&this.Qa(a);this.o.forEach(function(c){c instanceof b&&c.Ya(a)})};return function(c,n){n||(n={});p.H=n.H||[];p.$=n.$||h;p.xa=n.xa||f;p.qa=n.qa||k;g=c;m=new b(this,0);n=0;c=g.length;do{for(;n<c;)n+=m.s(n);m.Ya(g.length);if(n=d()){e(n,!1);m.ca(n.aa);var l=new a(n.g);l.s(n.aa);n.g.o.push(l);n.g.f=l;n=n.aa+1}else n=void 0}while(void 0!==n);return m.outerHTML()}}();"undefined"!==typeof module&&(module.M.C=Aa);function Ba(a,b){this.A=b||a;this.method=b?a:"GET"}function K(a,b,c,d){a&&a.forEach(function(a){a(b,c,d)})}function Ca(a,b){a.ha||(a.ha=[]);a.ha.push(b);return a}function Da(a,b){a.ja||(a.ja=[]);a.ja.push(b);return a}function Ea(a,b){a.ia||(a.ia=[]);a.ia.push(b);return a}
  36. function N(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)?K(this.ja,this.b.status,this.b.statusText,this.b.response):K(this.ia,this.b.status,this.b.statusText,this.b.response),K(this.ha,this.b.status,this.b.statusText,this.b.response))}.bind(this)}N.prototype=Object.create(Ba.prototype);N.prototype.constructor=N;N.prototype.s=function(a){this.b.timeout=a;return this};
  37. N.prototype.h=function(a){this.b.responseType=a;return this};N.prototype.a=function(a){this.b.open(this.method,this.A,!0);this.b.send(a);return this};function Fa(a,b){Ba.call(this,a,b);this.b=5E3;this.responseType="text"}Fa.prototype=Object.create(Ba.prototype);Fa.prototype.constructor=N;Fa.prototype.s=function(a){this.b=a;return this};Fa.prototype.h=function(a){this.responseType=a;return this};
  38. function Ga(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 Ha=function(){var a=document.createElement("a");return function(b){a.href=b;return a.href}}();
  39. Fa.prototype.a=function(a){__native.sendHttpRequest(this.method,Ha(this.A),this.b,this.responseType,Ga(a),Ia.ib(function(a,c,d){try{var b="text"===this.responseType?d:JSON.parse(d)}catch(f){b=d}__native.isDebug()&&console.log(this,{dc:a,statusText:c,cc:d});2===Math.floor(a/100)?K(this.ja,a,c,b):K(this.ia,a,c,b);K(this.ha,a,c,b)},this));return this};function O(a,b){return Ja()?new Fa(a,b):new N(a,b)};function Ka(a,b){this.title=a;this.content=b;this.c=La(this);this.b=Ma(this);this.a=[];this.h=[]}
  40. function La(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=Na;d.className=Oa;e.className=Pa;e.textContent="x";c.appendChild(d);c.appendChild(e);b.appendChild(c);f.className=
  41. Qa;b.appendChild(f);b.b.className=Ra;b.b.textContent=H.cb;b.b.addEventListener("click",function(){Sa(a,!1)});e.addEventListener("click",function(){Sa(a,!1)});b.a.addEventListener("click",function(){Sa(a,!0)});h.appendChild(b.b);b.a.className=Ra;b.a.textContent=H.ok;h.appendChild(b.a);h.className=Ta+" "+Ua;b.appendChild(h);b.className=Va;return b}function Sa(a,b){(b?a.a:a.h).forEach(function(a){a()});a.close()}
  42. function Ma(a){var b=document.createElement("div");b.className=Wa;b.addEventListener("click",function(){Sa(this,!1)}.bind(a));return b}function Xa(a,b,c){a.c.a.textContent=b;a.c.b.textContent=c;return a}Ka.prototype.va=function(a){a=a||document.body;a.appendChild(this.b);a.appendChild(this.c);return this};Ka.prototype.close=function(){this.c.remove();this.b.remove();return this};function Ya(a,b){a.a.push(b);return a};var Ra="button",Ta="button-container",Va="dialog",Wa="dialog-overlay",Na="dialog-title",Oa="dialog-title-label",Pa="dialog-title-close",Qa="dialog-body",Ua="dialog-footer";function Za(a){var b=document.createElement("lh");b.textContent=a;b.className="chat-command-header";return b}
  43. function $a(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 ab(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=P.m;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=Q instanceof t?P.j:Q.j,b=e.substr(f+1,
  46. 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+":",Ga:p,ta:bb.name})}for(g in P.b.data)g.length>=b.length&&g.substr(0,b.length)===b&&(k=document.createElement("span"),k.className="emoji-small",k.appendChild(cb(g)),d.push({name:":"+g+":",
  47. Ga:k,ta:"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=db.fb(b))&&d.push(a):(d=db.Ab(b),c.dataset.cursor=JSON.stringify([0,a.selectionEnd]));a=P?P.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.Z.localeCompare(b.Z)||a.name.localeCompare(b.name)})}c.textContent="";if(d.length){l=document.createDocumentFragment();g=0;for(a=
  48. d.length;g<a;g++)if(e=d[g],e instanceof ga){if(!n){var n=!0;l.appendChild(Za(H.ra))}b=document.createElement("span");b.className="chat-command-userIcon";b.style.backgroundImage='url("'+pa(e)+'")';l.appendChild($a("@"+e.getName(),b))}else e instanceof v?(n||(n=!0,l.appendChild(Za(H.m))),l.appendChild($a("#"+e.name))):e.Ga?(n!==e.ta&&(n=e.ta,l.appendChild(Za(e.ta))),l.appendChild($a(e.name,e.Ga))):(n!==e.Z&&(n=e.Z,l.appendChild(Za(e.Z))),l.appendChild($a(e)));c.appendChild(l)}}
  49. function eb(a){if(R)return O("PUT","api/msg?room="+encodeURIComponent(Q.id)+"&ts="+R.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=P,d=db.fb(c);if(d)return a=a.trim(),d.exec(b,Q,a),!0;if(b&&(c=b.h.data[c])){if("/me"===c.name)fb(Q,a,!0);else if("/msg"===c.name){a=a.trim();var b=/(\S+)\s+(.*)/.exec(a);a:{var e=b[1],d=P,f=e,h=[];"#"===f[0]&&(f=f.substr(1));for(var k in d.m)d.m[k].name===f&&h.push(d.m[k]);if(h.length)var g=
  50. h[0];else{k=[];"@"===e[0]&&(e=e.substr(1));for(g in d.j)d.j[g].getName()===e&&k.push(d.m[g]);if(k.length)for(g=0,d=k.length;g<d;g++)if(k[g].S){g=k[g].S;break a}g=null}}g&&fb(g,b[2],!1)}O("POST","api/cmd?room="+encodeURIComponent(Q.id)+"&cmd="+encodeURIComponent(c.name.substr(1))+"&args="+encodeURIComponent(a)).a();return!0}return!1}g=fb(Q,a,!1);gb(Q,a,g,S);return!0}function hb(){document.getElementById("msgInput").focus()}
  51. function ib(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 jb(){var a=0,b=document.getElementById("msgInput");b.addEventListener("input",function(){if(Q){var b=Date.now();a+3E3<b&&(P.self.R||Q instanceof t)&&(O("POST","api/typing?room="+encodeURIComponent(Q.id)).a(),a=b);ab(this);ib(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. ib(this),this.selectionStart=this.selectionEnd=a+1):kb(),!1});document.getElementById("slashList").addEventListener("click",function(a){if(Q){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;ab(c);c.focus();break}b=b.parentElement}}})};var T=[],lb=0;
  54. function mb(){var a=document.createDocumentFragment(),b=wa(function(a){return!a.ka&&!1!==a.ca}),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.m[a];b=d.m[b];return a.name===b.name?(h[a.id]=H.Fa(c.a.name,a.name),h[b.id]=H.Fa(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.bb){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.R||b.classList.add("presence-away");Q===a&&b.classList.add("selected");a.G!==a.u&&void 0!==a.G&&(b.classList.add("unread"),b.classList.add("unreadHi"));b=k=b}b&&(a.D?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",
  56. b.dataset.count=Object.keys(a.j||{}).length):b.className="chat-context-room chat-channel",Q===a&&b.classList.add("selected"),p.textContent=k||a.name,b.appendChild(nb()),b.appendChild(p),a.G!==a.u&&void 0!==a.G&&(b.classList.add("unread"),0<=U.indexOf(a)&&b.classList.add("unreadHi")),k=b)a.D?c.push(k):a.h?e.push(k):d.push(k)});c.length&&a.appendChild(ob(H.D));c.forEach(function(b){a.appendChild(b)});d.length&&a.appendChild(ob(H.m));d.forEach(function(b){a.appendChild(b)});e.forEach(function(b){a.appendChild(b)});
  57. f.length&&a.appendChild(ob(H.ob));f.forEach(function(b){a.appendChild(b)});document.getElementById("chanList").textContent="";document.getElementById("chanList").appendChild(a);pb.apply(document.getElementById("chanSearch"));qb()?rb(P.a.id,P.j,function(a){document.getElementById("chatCtx").style.backgroundImage="url("+a+")"}):Ja()&&(b=__native.getPreviousChannel())&&(document.location.hash=b)}
  58. function sb(){ua(function(a){var b=a.B,c;for(c in a.self.m)if(!a.self.m[c].ka){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.j)(c=a.j[e].S)&&!c.ka&&(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(P&&Q&&(a=P.B[Q.id])){var b=document.createDocumentFragment(),c=!1,d;for(d in a)(a=E(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=Q.name||(Q.a?Q.a.getName():void 0);if(!a){console.error("No name provided for ",Q);var a=[],b;for(b in Q.j)a.push(Q.j[b].getName());a=a.join(", ")}document.getElementById("currentRoomTitle").textContent=a;document.getElementById("chatWindow").textContent="";T=[];yb();hb();document.getElementById("fileUploadContainer").classList.add("hidden");zb();S&&(S=null,V());R&&(R=null,V());tb()}
  61. function V(){if(S){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){S=null;V()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(S.P())}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";hb()}
  62. function Ab(){if(R){document.body.classList.add("replyingTo");var a=document.getElementById("replyToContainer"),b=document.createElement("a");b.addEventListener("click",function(){R=null;Ab()});b.className="replyto-close";b.textContent="x";a.textContent="";a.appendChild(b);a.appendChild(R.P());document.getElementById("msgInput").value=R.text}else document.body.classList.remove("replyingTo"),document.getElementById("replyToContainer").textContent="";hb()}
  63. 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.I[c]&&-1!==e.I[c].indexOf(f.self.id)?O("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="!"+H.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.G>a.u&&c++});c&&(b="("+c+")");Cb(0,c)}!b.length&&Q&&(b=Q.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(H.Ja);lb=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
  66. function yb(){var a=document.getElementById("chatWindow"),b=Q.id,c=null,d=0;Q.D?document.getElementById("chatSystemContainer").classList.add("starred"):document.getElementById("chatSystemContainer").classList.remove("starred");if(C.a[b]){var e=0,f=0;C.a[b].i.forEach(function(b){if(T[e]){if(f>=T[e].i.length&&!b.h)if(b instanceof y||c&&c.O!==b.O||!b.O){for(;T[e].content.children[f];)T[e].content.children[f].remove();T[e].i.splice(f);e++;f=0;d=b.l}else{var h=b.F();30>Math.abs(d-b.l)&&!(b instanceof y)?
  67. c&&c.F().classList.add("chatmsg-same-ts"):d=b.l;(!c||c.l<=Q.u)&&b.l>Q.u?h.classList.add("chatmsg-first-unread"):h.classList.remove("chatmsg-first-unread");T[e].content.appendChild(h);T[e].i.push(b.id);++f;c=b;return}if(T[e]){if(T[e].i[f]===b.id)if(h=T[e].content.children[f],b.h)h.remove(),T[e].i.splice(f,1);else{if(b.T){var g=b.F();T[e].content.replaceChild(h,g);h=g}}else h=b.F(),T[e].content.insertBefore(h,T[e].content.children[f]),T[e].i.splice(f,0,b.id);(!c||c.l<=Q.u)&&b.l>Q.u?h.classList.add("chatmsg-first-unread"):
  68. h.classList.remove("chatmsg-first-unread");f++;c=b;return}}if(!T[e]){h=T;var g=e,m=E(b.O),p=b.username,l=document.createElement("div"),n=document.createElement("div"),u=document.createElement("a"),x=document.createElement("img");l.la=document.createElement("span");l.la.className="chatmsg-author-img-wrapper";x.className="chatmsg-author-img";u.className="chatmsg-author-name";u.href="#"+m.id;m?(u.textContent=m.getName(),u.style.backgroundColor=Fb(m.getName()),x.src=pa(m)):(u.textContent=p||"?",x.src=
  69. "");l.la.appendChild(x);n.appendChild(l.la);n.appendChild(u);n.className="chatmsg-author";l.className="chatmsg-authorGroup";l.appendChild(n);l.content=document.createElement("div");l.content.className="chatmsg-author-messages";l.i=[];l.appendChild(l.content);h[g]=l;h=b.F();d=b.l;(!c||c.l<=Q.u)&&b.l>Q.u?(h.classList.add("chatmsg-first-unread"),h.insertBefore(Gb,h.firstChild)):h.classList.remove("chatmsg-first-unread");T[e].content.appendChild(h);T[e].i.push(b.id);c=b;a.appendChild(T[e]);f=1;if(b instanceof
  70. y){for(;T[e].content.children[f];)T[e].content.children[f].remove();T[e].i.splice(f);e++;f=0;d=b.l}}});if(T[e]){for(;T[e].content.children[f];)T[e].content.children[f].remove();T[e].i.splice(f);for(b=e+1;T[b];b++)T[b].remove()}T.splice(e+1)}b=document.getElementById("chatWindow");b.scrollTop=b.scrollHeight-b.clientHeight;wb();window.hasFocus&&zb()}
  71. function Hb(a,b){if(a.classList.contains("chatmsg-hover-reply"))R&&(R=null,Ab()),S!==b&&(S=b,V());else if(a.classList.contains("chatmsg-hover-reaction")){var c=Q.id,d=b.id;Ib.va(document.body,P,function(a){a&&Bb(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(S&&(S=null,V()),R!==b&&(R=b,Ab())):a.classList.contains("chatmsg-hover-star")?b.D?O("DELETE","api/starMsg?room="+encodeURIComponent(Q.id)+"&msgId="+b.id).a():O("POST","api/starMsg?room="+encodeURIComponent(Q.id)+"&msgId="+b.id).a():
  72. a.classList.contains("chatmsg-hover-pin")?b.pinned?Jb(Q,b):O("POST","api/pinMsg?room="+encodeURIComponent(Q.id)+"&msgId="+b.id).a():a.classList.contains("chatmsg-hover-remove")&&(S&&(S=null,V()),R&&(R=null,Ab()),O("DELETE","api/msg?room="+encodeURIComponent(Q.id)+"&ts="+b.id).a())}function fb(a,b,c){b={channel:a.id,text:b.trim(),Ha:c,c:Kb(b,c)};Lb.push(b);a===Q&&yb();return b}
  73. function Mb(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[Q.id],d))&&a.w[e]&&a.w[e].actions&&a.w[e].actions[f]&&
  74. Nb(a,a.w[e],a.w[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[Q.id],d))&&Hb(c,a);break}c=c.parentElement}}
  75. function Nb(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 A,message_ts:a.id};O("POST","api/attachmentAction?serviceId="+encodeURIComponent(a.O)).a(JSON.stringify(d))}var e=Q.id;c.confirm?Ya(Xa(new Ka(c.confirm.title,c.confirm.text),c.confirm.ok_text,c.confirm.dismiss_text),d).va():d()}
  76. function Ob(){if(!1!==X.b&&!1!==X.h){var a=document.getElementById("chatWindow").getBoundingClientRect().top;T.forEach(function(b){var c=b.la,d=c.clientHeight;b=b.getBoundingClientRect();c.style.top=Math.max(0,Math.min(a-b.top,b.height-d-d/2))+"px"})}}function Pb(){var a=document.getElementById("chatCtx");a.classList.contains("opened")?a.classList.remove("opened"):a.classList.add("opened")}
  77. document.addEventListener("DOMContentLoaded",function(){za();Qb();jb();var a=document.getElementById("chanSearch");a.addEventListener("input",pb);a.addEventListener("blur",pb);document.getElementById("chatWindow").addEventListener("click",Mb);window.addEventListener("hashchange",function(){document.location.hash&&"#"===document.location.hash[0]&&qb()});document.addEventListener("mouseover",function(a){a=a.target;if(Rb.Gb(a))Rb.ba();else{for(;a&&a!==this;){if("A"===a.nodeName){var b=a.href,d=b.indexOf("#");
  78. if(0<=d){b=b.substr(d+1);if(d=D(C.context,b)){Rb.mb(d,d.m[b]).show(a);return}a:{for(var d=C.context,e=0,f=d.a.length;e<f;e++)if(d.a[e].j[b]){d=d.a[e];break a}d=null}if(d&&(b=d.j[b].S)){Rb.mb(d,b).show(a);return}}}a=a.parentElement}Rb.Db()}});document.getElementById("chatCtxButton").addEventListener("click",Pb);document.getElementById("currentRoomStar").addEventListener("click",function(a){a.preventDefault();Q&&(Q.D?Sb(Q):Tb(Q));return!1});document.getElementById("fileUploadCancel").addEventListener("click",
  79. 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",Ub);document.getElementById("ctxMenuSettings").addEventListener("click",function(a){a.preventDefault();Vb.display()});document.getElementById("fileUploadForm").addEventListener("submit",function(a){a.preventDefault();
  80. a=document.getElementById("fileUploadInput");var b=a.value;b&&(b=b.substr(b.lastIndexOf("\\")+1),Wb(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();Q&&document.getElementById("fileUploadContainer").classList.remove("hidden");
  81. return!1});document.getElementById("msgFormSubmit").addEventListener("click",function(a){a.preventDefault();kb();return!1});document.getElementById("msgForm").addEventListener("submit",function(a){a.preventDefault();kb();return!1});window.addEventListener("blur",function(){window.hasFocus=!1});window.addEventListener("focus",function(){window.hasFocus=!0;lb=0;Q&&zb();hb()});window.hasFocus=!0;document.getElementById("emojiButton").addEventListener("click",function(){P&&Ib.va(document.body,P,function(a){a&&
  82. (document.getElementById("msgInput").value+=":"+a+":");hb()})});Ja()&&(__native.readSmsPermission(Ia.ib(function(){var a=JSON.parse(__native.getStatic());a&&C.update(a)})),document.body.classList.add("native"));IS_LOCAL||Xb()});function kb(){var a=document.getElementById("msgInput");Q&&a.value&&eb(a.value)&&(a.value="",S&&(S=null,V()),R&&(R=null,V()),document.getElementById("slashList").textContent="",ib(a));hb()};var Vb=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={X:"services",
  83. display:"display",bc:"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");
  84. 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.A&&(b.emojiProvider=document.getElementById("settings-displayEmojiProvider").value);var c=!!document.getElementById("settings-displayDisplayAvatar").checked;
  85. c!==(!1!==X.b)&&(b.displayAvatar=c);c=!!document.getElementById("settings-displayColorfulNames").checked;c!==(!0===X.s)&&(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){Yb(c,b);Zb();O("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");
  86. var d=document.createDocumentFragment(),f=!1,g;for(g in X.X){var m=X.X[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"),
  87. m.appendChild(d)):document.getElementById("settings-serviceListEmpty").classList.add("hidden");d=document.createDocumentFragment();m=document.getElementById("settings-displayEmojiProvider");for(g in $b){var n=document.createElement("option");n.value=g;n.textContent=$b[g].name;$b[g]===bb&&(n.selected=!0);d.appendChild(n)}m.textContent="";m.appendChild(d);document.getElementById("settings-displayDisplayAvatar").checked=!1!==X.b;document.getElementById("settings-displayColorfulNames").checked=!0===X.s;
  88. document.getElementById("settings-displayScrollAvatars").checked=!1!==X.h;document.getElementById("settings-displayAttachmentContent").value=void 0!==X.a?X.a:ac;c=!0}b(a||e.X);return this},Mb:function(){return this},Jb:e}}();function bc(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.V=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");
  89. 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,l=(1-Math.log(Math.tan(d*Math.PI/180)+1/Math.cos(d*Math.PI/180))/Math.PI)/2*p,m=Math.floor(n),L=Math.floor(l),
  90. ya=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)))),m/p*360-180,(m+1)/p*360-180):0;d=b;for(e=0;3>e;e++)for(g=0;3>g;g++)c(a,m+e-1,L+g-1,{Eb:e,Hb:g,sb:d}).then(function(a){if(a.sb===b){h.drawImage(a.V,100*a.Eb,100*a.Hb,100,100);a=n-m;var c=l-L;a=100*a+100;c=100*c+100;f.putImageData(h.getImageData(0,0,300,300),0,0);void 0!==ya&&(f.beginPath(),f.arc(a,c,Math.max(ya,10),0,2*Math.PI,!1),f.lineWidth=2,f.fillStyle="rgba(244, 146, 66, 0.4)",f.strokeStyle=
  91. "rgba(244, 146, 66, 0.8)",f.stroke(),f.fill());if(void 0===ya||25<ya)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()}}).catch(function(){})},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");
  92. 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 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}}();
  93. function cc(a){var b={},c=a;if(P)for(var d=P;!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 cb(a){return"makeEmoji"in window?(a=cc(a),"string"===typeof a&&(a=window.makeEmoji(a)),"string"===typeof a?null:a):null}
  94. function dc(a,b){var c=b.context.Y;b=C.context.Ha(b.O);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&&
  95. (a.pa=document.createElement("li"),a.pa.className="chatmsg-hover-star",a.appendChild(a.pa));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)}
  96. function ec(a){var b=document.createElement("div"),c=document.createElement("div"),d=document.createElement("summary");b.da=document.createElement("ul");b.w=document.createElement("ul");b.I=document.createElement("ul");b.l=document.createElement("div");b.wa=document.createElement("div");b.ma=document.createElement("span");b.L=document.createElement("details");b.L.addEventListener("toggle",function(){this.Nb=!0});b.className="chatmsg-item";b.l.className="chatmsg-ts";b.wa.className="chatmsg-msg";b.ma.className=
  97. "chatmsg-author-name";a&&(b.id=a.b+"_"+a.id,dc(b.da,a),b.da.className="chatmsg-hover");c.appendChild(b.ma);c.appendChild(b.wa);c.appendChild(b.l);d.textContent="attachment";b.L.appendChild(d);b.L.appendChild(b.w);c.appendChild(b.L);b.J=document.createElement("div");b.J.className="chatmsg-edited";c.appendChild(b.J);c.appendChild(b.I);c.className="chatmsg-content";b.w.className="chatmsg-attachments";b.I.className="chatmsg-reactions";b.appendChild(c);b.appendChild(b.da);return b}
  98. function Fb(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 fc(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 gc(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"),x=document.createElement("div");d.className="chatmsg-attachment";e.style.borderColor=fc(b.color||"");e.className="chatmsg-attachment-block";
  100. f.className="chatmsg-attachment-pretext";b.pretext?f.innerHTML=a.C(b.pretext):f.classList.add("hidden");h.target="_blank";b.title?(h.innerHTML=a.C(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.C(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)),
  101. 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.C(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=bc(b.geo))&&p.appendChild(l);u.className="chatmsg-attachment-img";b.image_url?
  102. u.src=b.image_url:u.classList.add("hidden");x.className="chatmsg-attachment-footer";b.footer&&(l=document.createElement("span"),l.className="chatmsg-attachment-footer-text",l.innerHTML=a.C(b.footer),b.footer_icon&&(n=document.createElement("img"),n.src=b.footer_icon,n.className="chatmsg-attachment-footer-icon",x.appendChild(n)),x.appendChild(l));b.ts&&(l=document.createElement("span"),l.className="chatmsg-ts",l.innerHTML=H.U(b.ts),x.appendChild(l));e.appendChild(h);e.appendChild(k);e.appendChild(p);
  103. e.appendChild(u);if(b.fields&&b.fields.length){var z=document.createElement("ul");e.appendChild(z);z.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.C(d);e.appendChild(f);e.appendChild(g);e&&z.appendChild(e)})}if(b.actions&&
  104. b.actions.length)for(h=document.createElement("ul"),h.className="chatmsg-attachment-actions "+Ta,e.appendChild(h),k=0,p=b.actions.length;k<p;k++)(u=b.actions[k])&&(u=hc(c,k,u))&&h.appendChild(u);e.appendChild(x);d.appendChild(f);d.appendChild(e);return d}
  105. function hc(a,b,c){var d=document.createElement("li"),e=fc(c.style);d.textContent=c.text;e!==fc()&&(d.style.color=e);d.style.borderColor=e;d.dataset.attachmentIndex=a;d.dataset.actionIndex=b;d.className="chatmsg-attachment-actions-item "+Ra;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 Ib=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(){z={};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),
  106. !0):!1}function e(a){var b=0;a=void 0===a?x.value:a;if(g()){var c=0,d=window.searchEmojis(a),e=f(d,J?J.self.W.a:[]),p;for(k in z)z[k].visible&&(z[k].visible=!1,n.removeChild(z[k].c));var k=0;for(p=e.length;k<p;k++){var l=e[k].name,m=z[l];if(!m){var m=z,L=l;var r=l;var l=window.makeEmoji(d[l]),I=document.createElement("span");I.appendChild(l);I.className="emoji-medium";r=h(r,I);m=m[L]=r}m.visible||(m.visible=!0,n.appendChild(m.c));c++}b+=c}k=b;c=0;for(F in B)B[F].visible&&(B[F].visible=!1,u.removeChild(B[F].c));
  107. if(J){d=f(J.b.data,J?J.self.W.a:[]);var F=0;for(b=d.length;F<b;F++)L=d[F].name,""!==a&&L.substr(0,a.length)!==a||"alias:"===J.b.data[L].substr(0,6)||(e=B[L],e||(e=B,m=p=L,L=J.b.data[L],r=document.createElement("span"),l=document.createElement("span"),r.className="emoji emoji-custom",r.style.backgroundImage='url("'+L+'")',r.textContent=":"+m+":",r.title=m,l.appendChild(r),l.className="emoji-medium",m=h(m,l),e=e[p]=m),e.visible||(e.visible=!0,u.appendChild(e.c)),c++);F=c}else F=0;return k+F}function f(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 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"),x=document.createElement("input"),z={},B={},M=document.createElement("div"),I=document.createElement("span"),F=document.createElement("span"),r,J;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)&&
  110. c()});p.className="emojibar-overlay";m.className="emojibar";l.className="emojibar-emojis";n.className=u.className="emojibar-list";x.className="emojibar-search";M.className="emojibar-detail";I.className="emojibar-detail-img";F.className="emojibar-detail-name";M.appendChild(I);M.appendChild(F);b();m.appendChild(l);m.appendChild(M);m.appendChild(x);x.addEventListener("keyup",function(){e()});m.addEventListener("mousemove",function(b){a(b,function(a){var b=a?z[a]||B[a]:null;b?(I.innerHTML=b.c.outerHTML,
  111. F.textContent=":"+a+":"):(I.textContent="",F.textContent="")})});m.addEventListener("click",function(b){a(b,function(a){a&&d()&&r&&r(a)})});return{isSupported:g,va:function(a,b,c){return g()?(J=b,r=c,a.appendChild(p),a.appendChild(m),x.value="",e(),x.focus(),!0):!1},search:e,close:c,reset:function(){b();e()}}}();var C,U=[];function ic(){da.call(this)}ic.prototype=Object.create(da.prototype);ic.prototype.constructor=ic;function sa(a){return a.a?a.a.id:null}function jc(){this.b=0;this.context=new qa;this.a={}}
  112. jc.prototype.update=function(a){var b=Date.now();a.v&&(this.b=a.v);if(a["static"])for(g in a["static"]){var c=ra(this.context,g);c||(c=new ic,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.a(a,b))});c.m[e].b=f}}ta(this.context,function(a){a.G===a.u&&(a=U.indexOf(a),-1!==a&&U.splice(a,
  113. 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.m[k])?(this.a[k].i.length&&ha(c,na(this.a[k]).l,b),c.ka||(kc(g,c,a.live[k]),Q&&a.live[Q.id]&&yb())):C.b=0}}a["static"]&&mb();var m=!1;a.typing&&this.context.a.forEach(function(c){var d=m,e=a.typing,f=!1;if(c.B)for(var g in c.B)e&&!e[g]&&(delete c.B[g],f=!0);if(e)for(g in e)if(c.m[g]){c.B[g]||(c.B[g]={});for(var h in e[g])c.B[g][h]||(f=!0),c.B[g][h]=
  114. b}m=d|f},this);(a["static"]||m)&&sb();a.config&&(X=new lc(a.config),Zb());if(P&&Q&&a["static"]&&a["static"][P.a.id]&&a["static"][P.a.id].channels&&a["static"][P.a.id].channels)for(k=a["static"][P.a.id].channels,g=0,c=k.length;g<c;g++)if(k[g].id===Q.id){yb();break}};setInterval(function(){var a=!1,b=Date.now();ua(function(c){var d=!1,e;for(e in c.B){var f=!0,h;for(h in c.B[e])c.B[e][h]+6500<b?(delete c.B[e][h],d=!0):f=!1;f&&(delete c.B[e],d=!0)}d&&(a=!0)});a&&sb()},1E3);
  115. function kc(a,b,c){var d;if(b!==Q||!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.u)&&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.W.H;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===U.indexOf(b)&&(k=!0,U.push(b)),f=!0)}});if(h){wb();var g=document.getElementById("room_"+b.id);g&&(g.classList.add("unread"),f&&g.classList.add("unreadHi"));
  116. k&&!window.hasFocus&&Eb()}}c.forEach(function(a){if(!d||d===a.O)for(var c=0,e=Lb.length;c<e;c++){var f=Lb[c];if(f.channel===b.id&&!!a.isMeMessage===f.Ha&&(a.pendingId===f.sa&&f.sa||!f.sa&&a.text.trim()===f.text)){Lb.splice(c,1);break}}})}
  117. function zb(){var a=Q,b=U.indexOf(a);if(a.G>a.u){var c=C.a[a.id];c&&(c=na(c))&&(O("POST","api/markread?room="+encodeURIComponent(a.id)+"&id="+c.id+"&ts="+c.l).a(),a.u=c.l)}0<=b&&(U.splice(b,1),wb());a=document.getElementById("room_"+a.id);a.classList.remove("unread");a.classList.remove("unreadHi")}function mc(){for(var a in C.a)nc(C.a[a]);Q&&yb()}C=new jc;var rb=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.V?b.V?Math.random()-.5:-1:1}function c(a,b){for(var e=0,f=a.length;e<f;e++)if(void 0===a[e].V){d(a[e].src,function(d){a[e].V=d;c(a,b)});return}var g=[];a.forEach(function(a){a.V&&g.push(a.V)});b(g)}function d(a,b){Ea(Da(O(a),function(a,c,d){if(d){var e=new Image;e.onload=function(){var a=document.createElement("canvas");
  118. a.height=a.width=x;a=a.getContext("2d");a.drawImage(e,0,0,x,x);var a=a.getImageData(0,0,x,x),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=g.createLinearGradient(0,
  119. 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();
  120. 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),x=.5*u,z={},B={},M={};return function(b,d,f){if(z[b])f(z[b]);else if(M[b])B[b]?B[b].push(f):B[b]=[f];else{var g=e(),h=[];M[b]=!0;B[b]?B[b].push(f):B[b]=[f];for(var l in d)d[l].bb||d[l].Fb||h.push({src:pa(d[l])});
  121. c(h,function(c){a(g,c);z[b]=k.toDataURL();B[b].forEach(function(a){a(z[b])})})}}}();var W=0,Q=null,Gb=document.createElement("span"),P=null,S=null,R=null,Lb=[];function Qb(){Ea(Da(O("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")}).s(6E4).a()}
  122. function oc(){var a=Q;Ca(Da(O("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.i.length&&ha(a,na(b).l,e),kc(D(C.context,a.id),a,d),a===Q&&yb())}}),function(){}).a()}
  123. function Zb(){pc()&&Vb.Mb(!1).display(Vb.Jb.X);qc();!1!==X.h?(document.getElementById("chatWindow").addEventListener("scroll",Ob),Ob()):(mc(),document.getElementById("chatWindow").removeEventListener("scroll",Ob));for(var a in C.a)C.a[a].i.forEach(function(a){a.c&&a.N()});document.getElementById("customsheet").innerHTML=rc()}
  124. function Xb(){var a=sc;IS_LOCAL||Ca(O("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").s(6E4).a()}function sc(a,b){a?(b&&C.update(b),Xb()):setTimeout(tc,1E3*W)}function tc(){Xb()}function Db(a){if(Ja()){var b=!(!P||!P.Y.starChannel);__native.setTitle(a,b,b?Q.D:!1)}}
  125. function uc(a){Q&&(document.getElementById("room_"+Q.id).classList.remove("selected"),document.getElementById("chatSystemContainer").classList.add("no-room-selected"),Gb.remove());Gb.className="chatmsg-unread";Gb.textContent=H.Ja;document.getElementById("room_"+a.id).classList.add("selected");document.body.classList.remove("no-room-selected");Q=a;P=D(C.context,a.id);Ja()&&__native.setCurrentChannel(a.id);xb();Rb.Cb();rb(P.a.id,P.j,function(a){document.getElementById("chatCtx").style.backgroundImage=
  126. "url("+a+")"});(!C.a[Q.id]||100>C.a[Q.id].i.length)&&oc();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!==Q?(uc(b),!0):(a=E(a))&&a.S?(uc(a.S),!0):!1}function Tb(a){O("POST","api/starChannel?room="+encodeURIComponent(a.id)).a()}function Sb(a){O("POST","api/unstarChannel?room="+encodeURIComponent(a.id)).a()}
  127. function Wb(a,b,c){var d=Q;new FileReader;var e=new FormData;e.append("file",b);e.append("filename",a);Ea(Da(O("POST","api/file?room="+encodeURIComponent(d.id)),function(){c(null)}),function(a,b){c(b)}).a(e)}
  128. function gb(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:E(d.O).getName(),text:d.text,footer:a.h?H.message:a.name,ts:d.l}])));Gb.remove();Da(O("POST",b).h("json"),function(a,b,d){d&&void 0!==d.pendingId&&(c.sa=d.pendingId)}).a()}function Jb(a,b){O("DELETE","api/pinMsg?room="+encodeURIComponent(a.id)+"&msgId="+b.id).a()}
  129. function Bb(a,b,c){O("POST","api/reaction?room="+encodeURIComponent(a)+"&msg="+b+"&reaction="+encodeURIComponent(c)).a()}function Ub(){O("POST","api/logout").a();document.cookie="sessID=;Path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;";document.location.reload();Ja()&&__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].ra+a[d].ya+a[d].ua?(e.classList.remove("hidden"),b.push(d)):e.classList.add("hidden"))}};var $b={noemoji:{Ia:"noemoji.js",na:null,name:"None"},emojione_v2_3:{Ia:"emojione_v2.3.sprites.js",na:"emojione_v2.3.sprites.css",name:"Emojione v2.3"},emojione_v3:{Ia:"emojione_v3.sprites.js",na:"emojione_v3.sprites.css",name:"Emojione v3"}},vc=$b.emojione_v2_3,bb;
  131. function wc(a){bb!==a&&(console.log("Loading emoji pack "+a.name),Da(O(a.Ia),function(b,c,d){b=document.createElement("script");b.innerHTML=d;b.language="text/javascript";document.body.appendChild(b);a.na&&(d=document.createElement("link"),d.href=a.na,d.rel="stylesheet",document.head.appendChild(d));d=document.getElementById("emojiButton");mc();Ib.reset();"makeEmoji"in window?(d.style.backgroundImage='url("smile.svg")',d.classList.remove("hidden")):d.classList.add("hidden")}).s(6E4).a(),bb=a)}
  132. function qc(){var a=X.A;wc(a&&$b[a]?$b[a]:vc)};var Rb=function(){function a(){c();r instanceof t?(f.style.backgroundImage="url(api/avatar?size=l&user="+encodeURIComponent(r.a.id)+")",m.textContent=(r.a.pb||(r.a.eb||"")+" "+r.a.hb).trim(),h.classList.add("presence-indicator"),r.a.R?h.classList.remove("presence-away"):h.classList.add("presence-away"),g.classList.remove("hidden"),l.classList.remove("hidden"),l.textContent=r.a.Kb||"",u.textContent=r.a.Bb||"",n.classList.remove("hidden"),e.classList.remove("roominfo-channel"),e.classList.add("roominfo-user")):
  133. b()}function b(){var a=F;a.Y.topic?(g.classList.remove("hidden"),m.textContent=r.ya||"",p.textContent=r.A?H.Na(r.A,r.fa):""):g.classList.add("hidden");a.Y.purpose?(n.classList.remove("hidden"),u.textContent=r.ua||"",x.textContent=r.s?H.Na(r.s,r.ea):""):n.classList.add("hidden");f.style.backgroundImage="";h.classList.remove("presence-indicator");M.textContent=H.rb(r.j?Object.keys(r.j).length:0);a=[];if(r.j)for(var b in r.j)a.push(r.j[b]);a.sort(function(a,b){return a.R&&!b.R?-1:b.R&&!a.R?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.R||b.classList.add("presence-away");c.appendChild(b)});I.textContent="";I.appendChild(c);e.classList.add("roominfo-channel");e.classList.remove("roominfo-user")}function c(){h.textContent=r.name;if(r.b){z.textContent=H.lb(r.b.length);z.classList.remove("hidden");B.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=Ra+" roominfo-unpin";c.className="roominfo-pinlist-item";c.appendChild(b.P());c.appendChild(e);a.appendChild(c)});B.textContent="";B.appendChild(a)}else z.classList.add("hidden"),B.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){Jb(r,
  136. 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"),x=document.createElement("span"),z=document.createElement("div"),B=document.createElement("ul"),M=document.createElement("div"),I=document.createElement("ul"),
  137. F,r;e.className="chat-context-roominfo";f.className="roominfo-title";g.className="roominfo-topic";n.className="roominfo-purpose";l.className="roominfo-phone";z.className="roominfo-pincount";B.className="roominfo-pinlist";M.className="roominfo-usercount";I.className="roominfo-userlist";x.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(x);k.appendChild(g);k.appendChild(l);k.appendChild(n);k.appendChild(z);
  138. k.appendChild(B);k.appendChild(M);k.appendChild(I);var J=null;return{mb:function(b,c){this.ba();F=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},Cb:function(){this.ba();e.classList.add("hidden");return this},ba:function(){J&&clearTimeout(J);J=null;return this},Db:function(){J||(J=setTimeout(function(){e.classList.add("hidden");J=null},300));return this},Gb: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.a=function(a,b){return!0===a.isMeMessage?new xc(this.id,a,b):!0===a.isNotice?new yc(this.id,a,b):new zc(this.id,a,b)};function nc(a){a.i.forEach(function(a){a.K()})}
  140. var Z=function(){function a(a,d){return Aa(d,{H:a.context.self.W.H,$:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=cb(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null},qa: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=E(h))a=!0,h="#"+d.S.id,k="@"+d.getName(),d="background-color:"+
  141. Fb(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,ab:b,gb:a}}return{K:function(a){a.T=!0;return a},ga:function(a){a.c&&a.c.parentElement&&(a.c.remove(),delete a.c);return a},F:function(a){a.c?a.T&&(a.T=!1,a.N()):a.Ea().N();return a.c},
  142. N:function(b){var c=E(b.O);b.c.l.innerHTML=H.U(b.l);b.c.wa.innerHTML=a(b,b.text);b.c.ma.textContent=c?c.getName():b.username||"?";for(var e=document.createDocumentFragment(),f=c=!1,h=0,k=b.w.length;h<k;h++){var g=b.w[h];if(g){var m=gc(b,g,h);m&&(e.appendChild(m),c|=!!g.image_url,f=!0)}}b.c.w.textContent="";b.c.w.appendChild(e);f?(b.c.L.classList.remove("hidden"),b.c.L.Nb||(e=X,b.c.L.open=1!==e.a&&(e.a!==ac&&void 0!==e.a||c)?!1:!0)):b.c.L.classList.add("hidden");c=b.b;e=document.createDocumentFragment();
  143. if(b.I)for(var p in b.I){f=c;h=b.id;k=p;g=b.I[p];if(m=cb(k)){for(var l=document.createElement("li"),n=document.createElement("a"),u=document.createElement("span"),x=document.createElement("span"),z=[],B=0,M=g.length;B<M;B++){var I=E(g[B]);I&&z.push(I.getName())}z.sort();x.textContent=z.join(", ");u.appendChild(m);u.className="emoji-small";n.href="javascript:toggleReaction('"+f+"', '"+h+"', '"+k+"')";n.appendChild(u);n.appendChild(x);l.className="chatmsg-reaction-item";l.appendChild(n);f=l}else console.warn("Reaction id not found: "+
  144. k),f=null;f&&e.appendChild(f)}b.c.I.textContent="";b.c.I.appendChild(e);b.c.da.pa&&(b.c.da.pa.style.backgroundImage=b.D?'url("star_full.png")':'url("star_empty.png")');b.J&&(b.c.J.innerHTML=H.J(b.J),b.c.classList.add("edited"));return b},P:function(a){return a.F().cloneNode(!0)},C:function(b,d){return a(b,d)}}}();function xc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.c=Z.c;this.T=Z.T}xc.prototype=Object.create(y.prototype);q=xc.prototype;q.constructor=xc;q.K=function(){return Z.K(this)};
  145. q.C=function(a){return Z.C(this,a)};q.ga=function(){return Z.ga(this)};q.F=function(){return Z.F(this)};q.Ea=function(){this.c=ec(this);this.c.classList.add("chatmsg-me_message");return this};q.P=function(){return Z.P(this)};q.N=function(){Z.N(this);return this};q.update=function(a,b){y.prototype.update.call(this,a,b);this.K()};function zc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.c=Z.c;this.T=Z.T}zc.prototype=Object.create(w.prototype);q=zc.prototype;q.constructor=zc;
  146. q.K=function(){return Z.K(this)};q.C=function(a){return Z.C(this,a)};q.ga=function(){return Z.ga(this)};q.F=function(){return Z.F(this)};q.Ea=function(){this.c=ec(this);return this};q.P=function(){return Z.P(this)};q.N=function(){Z.N(this);return this};
  147. q.update=function(a,b){w.prototype.update.call(this,a,b);this.K();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.w.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 yc(a,b,c){w.call(this,b,c);this.context=D(C.context,a);this.b=a;this.a=null;this.T=!0}yc.prototype=Object.create(A.prototype);q=yc.prototype;q.constructor=yc;q.K=function(){return Z.K(this)};q.C=function(a){return Z.C(this,a)};q.ga=function(){this.a&&this.a.parentElement&&(this.a.remove(),delete this.a);this.c&&delete this.c;return this};q.F=function(){Z.F(this);return this.a};q.P=function(){return this.a.cloneNode(!0)};
  149. q.Ea=function(){this.c=ec(this);this.a=document.createElement("span");this.c.classList.add("chatmsg-notice");this.a.className="chatmsg-notice";this.a.textContent=H.kb;this.a.appendChild(this.c);return this};q.N=function(){Z.N(this);return this};q.update=function(a,b){A.prototype.update.call(this,a,b);this.K()};
  150. function Kb(a,b){var c=ec(null);c.classList.add("chatmsg-pending");b&&c.classList.add("chatmsg-me_message");c.wa.innerHTML=Aa(a,{$:function(a){":"===a[0]&&":"===a[a.length-1]&&(a=a.substr(1,a.length-2));if(a=cb(a)){var b=document.createElement("span");b.className="emoji-small";b.appendChild(a);return b.outerHTML}return null}});c.ma.textContent=P.self?P.self.getName():"";a=document.createElement("span");a.className="typing-dot1";a.textContent=".";c.l.appendChild(a);a=document.createElement("span");
  151. a.className="typing-dot2";a.textContent=".";c.l.appendChild(a);a=document.createElement("span");a.className="typing-dot3";a.textContent=".";c.l.appendChild(a);c.l.classList.add("typing-container");c.L.remove();return c};function pc(){var a=X.X,b;for(b in a)if(a.hasOwnProperty(b))return!1;return!0};var X,ac=2;function lc(a){this.X={};for(var b=0,c=a.length;b<c;b++)null===a[b].service&&null===a[b].device&&Yb(this,JSON.parse(a[b].config))}
  152. function Yb(a,b){if(b.services)for(var c in b.services)a.X[c]=b.services[c];void 0!==b.emojiProvider&&(a.A=b.emojiProvider);void 0!==b.displayAvatar&&(a.b=b.displayAvatar);void 0!==b.colorfulNames&&(a.s=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 rc(){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.s||(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 lc([]);function Ac(){}Ac.prototype.close=function(){};function Bc(a,b){Ac.apply(this);this.Ma=Cc++;this.wb=a;this.port=b}Bc.prototype=Object.create(Ac);Bc.prototype.constructor=Bc;Bc.prototype.connect=function(){return new Promise(function(){__native.TCPConnect(this.Ma,this.wb,this.port)})};Bc.prototype.write=function(a){__native.TCPWrite(this.Ma,a)};Bc.prototype.close=function(){__native.TCPClose(this.Ma)};var Cc=0;var Ia=function(){var a={},b=0;return{ib:function(c,d){var e=b++;d&&(c.xb=d);a[""+e]=c;return e},Ib:function(){var b=""+Array.prototype.shift.call(arguments);a[b]&&(a[b].apply(a[b].xb,arguments),delete a[b])}}}();window.__CALLBACK={onResult:Ia.Ib};function Ja(){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(){Pb()};window.setChannelFavorite=function(a,b){var c=va(a);c?b?Tb(c):Sb(c):console.error("Channel "+a+" not found")};window.onApplicationPaused=function(){window.hasFocus=!1};window.onApplicationResumed=function(){window.hasFocus=!0};var db=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},Ab: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},Lb:function(b){b.Z="client";b.exec=b.exec.bind(b);a.push(b)}}}();function Dc(){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(){db.Lb({name:"/sherlock",names:["/sherlock","/sharelock"],usage:"",description:H.qb,exec:function(a,b){Dc().then(function(a){var c=a.coords.latitude,e=a.coords.longitude;gb(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. })();