var weechat;!function(){"use strict";var e=angular.module("localStorage",[]);function t(){this.storage=Object.create(null),this.keyIndex=[],Object.defineProperty(this,"length",{enumerable:!0,get:function(){return this.keyIndex.length}})}t.prototype.key=function(e){return this.keyIndex[e]},t.prototype.getItem=function(e){return e in this.storage?this.storage[e]:null},t.prototype.setItem=function(e,t){e in this.storage||this.keyIndex.push(e),this.storage[e]=t},t.prototype.clear=function(){this.storage=Object.create(null),this.keyIndex=[]},t.prototype.removeItem=function(e){if(e in storage){var t=this.keyIndex.indexOf(e);this.keyIndex.splice(t,1),delete this.storage[e]}},e.factory("$store",["$parse",function(i){var r=void 0===window.localStorage?void 0:window.localStorage,o=!(void 0===r||void 0===window.JSON);try{var e="eaf23ffe-6a8f-40a7-892b-4baf22d3ec75";r.setItem(e,1),r.removeItem(e)}catch(e){console.log("Warning: MobileSafari private mode detected. Switching to in-memory storage."),r=new t}o||console.log("Warning: localStorage is not supported");var a=function(t){var n;try{void 0===(n=JSON.parse(t))&&(n=t),"true"===n&&(n=!0),"false"===n&&(n=!1),parseFloat(n)!=n||angular.isObject(n)||(n=parseFloat(n))}catch(e){n=t}return n},s={set:function(e,t){o||console.log("Local Storage not supported");var n=JSON.stringify(t);return r.setItem(e,n),a(n)},get:function(e){if(!o)return null;var t=r.getItem(e);return a(t)},remove:function(e){return o&&(r.removeItem(e),!0)},enumerateKeys:function(){for(var e=[],t=0,n=r.length;t=m._colorsOptionsNames.length)return{fgColor:null,bgColor:null,attrs:null};var i=m._colorsOptionsNames[n];return t.fgColor={type:"option",name:i},t.bgColor=m._cloneColor(t.fgColor),t.attrs={name:i,override:{}},t}},{regex:/^@(\d{5})/,fn:function(e){return{fgColor:null,bgColor:null,attrs:null}}},{regex:/^F(?:([*!\/_|]*)(\d{2})|@([\x01\x02\x03\x04*!\/_|]*)(\d{5}))/,fn:function(e){var t={bgColor:null};return e[2]?(t.attrs=m._attrsFromStr(e[1]),t.fgColor=m._getColorObj(e[2])):(t.attrs=m._attrsFromStr(e[3]),t.fgColor=m._getColorObj(e[4])),t}},{regex:/^B(\d{2}|@\d{5})/,fn:function(e){return{fgColor:null,bgColor:m._getColorObj(e[1]),attrs:null}}},{regex:/^\*(?:([\x01\x02\x03\x04*!\/_|]*)(\d{2})|@([\x01\x02\x03\x04*!\/_|]*)(\d{5}))[,~](\d{2}|@\d{5})/,fn:function(e){var t={};return e[2]?(t.attrs=m._attrsFromStr(e[1]),t.fgColor=m._getColorObj(e[2])):(t.attrs=m._attrsFromStr(e[3]),t.fgColor=m._getColorObj(e[4])),t.bgColor=m._getColorObj(e[5]),t}},{regex:/^\*([\x01\x02\x03\x04*!\/_|]*)(\d{2}|@\d{5})/,fn:function(e){return{fgColor:m._getColorObj(e[2]),bgColor:null,attrs:m._attrsFromStr(e[1])}}},{regex:/^E/,fn:function(e){var t={fgColor:{type:"option",name:"emphasis"}};return t.bgColor=m._cloneColor(t.fgColor),t.attrs={name:"emphasis",override:{}},t}}].some(function(e){var t=n.match(e.regex);return!!t&&((i=e.fn(t)).text=n.substring(t[0].length),!0)}),i},m.rawText2Rich=function(e){var t=e.split(/(\x19|\x1a|\x1b|\x1c)/);if(1===t.length)return[{attrs:m._getDefaultAttributes(),fgColor:m._getDefaultColor(),bgColor:m._getDefaultColor(),text:t[0]}];var u=m._getDefaultColor(),l=m._getDefaultColor(),f=m._getDefaultAttributes(),d=null,h=!0;return t.map(function(e){if(0===e.length)return null;var t=e.charCodeAt(0),n=e.charAt(0);if(25<=t&&t<=28)return 28===t&&(u=m._getDefaultColor(),l=m._getDefaultColor(),25!==d&&(f=m._getDefaultAttributes())),d=t,null;var i=e;if(25===d){var r=m._getStyle(e);null!==r.fgColor&&(u=r.fgColor),null!==r.bgColor&&(l=r.bgColor),null!==r.attrs&&(f=r.attrs),i=r.text}else if(26===d||27===d){var o=26===d;if("|"!==n){var a=m._attrNameFromChar(n);a&&(f.override[a]=o,i=e.substring(1))}}if(d=null,0===i.length)return null;if(h&&null===f.name){var s=!0;for(var c in f.override)if(f.override[c]){s=!1;break}s?f.override={}:h=!1}return{fgColor:m._cloneColor(u),bgColor:m._cloneColor(l),attrs:m._cloneAttrs(f),text:i}}).filter(function(e){return null!==e})},m._uia2s=function(t){if(!t.length||0===t[0])return"";try{var e=String.fromCharCode.apply(null,t);return decodeURIComponent(escape(e))}catch(e){for(var n="",i=0,r=t.length;ithis._data.byteLength)return null;var t=this._data.slice(this._dataAt,this._dataAt+e);return this._dataAt+=e,t},_setData:function(e){this._data=e},setId:function(e,t){return"("+e+") "+t},parse:function(e,t){this._setData(e),this._dataAt=0;var n=this._getHeader();if(n.compression){var i=new Uint8Array(e,5),r=new Zlib.Inflate(i).decompress();this._setData(r.buffer),this._dataAt=0}for(var o=this._getId(),a=[],s=this._getObject();s;)a.push(s),s=this._getObject();return{header:n,id:o,objects:a}}},e.Protocol=m}("undefined"==typeof exports?this.weeChat={}:exports),function(){"use strict";angular.module("IrcUtils",[]).service("IrcUtils",[function(){function g(t,e){var n=null;return e.some(function(e){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&(n=e,!0)}),n}function p(e,t,n){for(var i=[],r=null,o=e.toLowerCase(),a=t.toLowerCase(),s=0;s "+t.text}if(function(e,t,n){if(h)navigator.serviceWorker.ready.then(function(e){e.showNotification(t,{body:n,icon:"assets/img/glowing_bear_128x128.png",vibrate:[200,100],tag:"gb-highlight-vib"})});else if("undefined"!=typeof Windows&&void 0!==Windows.UI&&void 0!==Windows.UI.Notifications){var i=Windows.UI.Notifications,r=i.ToastNotificationManager.createToastNotifier(),o=i.ToastTemplateType.toastText02,a=i.ToastNotificationManager.getTemplateContent(o),s=a.getElementsByTagName("text");s[0].appendChild(a.createTextNode(t)),s[1].appendChild(a.createTextNode(n));var c=new i.ToastNotification(a);c.onactivated=function(){f.setActiveBuffer(e.id),window.focus()},r.show(c)}else if("undefined"!=typeof Notification){var u=new Notification(t,{body:n,icon:"assets/img/favicon.png"});u.id=m.length,m.push(u);u.onshow=function(){setTimeout(function(){u.close()},15e3)},u.onclick=function(){f.setActiveBuffer(e.id),window.focus(),u.close()},u.onclose=function(){delete m[this.id]}}else if(d.isCordova()&&void 0!==window.cordova.plugins&&void 0!==window.cordova.plugins.notification&&void 0!==window.cordova.plugins.notification.local){var l=parseInt(e.id,16);window.cordova.plugins.notification.local.clear(l),window.cordova.plugins.notification.local.schedule({id:l,text:n,title:t,data:{buffer:e.id}})}}(e,n+=e.shortName+" ("+e.server+")",i),!d.isCordova()&&s.soundnotification){document.getElementById("soundNotification").innerHTML=''}},cancelAll:function(){for(;0$2')}}),e.filter("inlinecolour",function(){return function(e){if(!e)return e;var t='$1$2
';return e=(e=e.replace(/(^|[^&])(\#[0-9a-f]{6};?)(?!\w)/gim,t)).replace(/(.?)(rgba?\((?:\s*\d+\s*,){2}\s*\d+\s*(?:,\s*[\d.]+\s*)?\);?)/gim,t)}}),e.filter("conditionalLinkify",["$filter",function(n){return function(e,t){return!e||t?e:n("linky")(e,"_blank",{rel:"noopener noreferrer"})}}]),e.filter("DOMfilter",["$filter","$sce",function(i,r){var o=["irclinky"];return function(e,t){if(!e||!t)return e;var u=-1":">",'"':""","'":"'","&":"&","/":"/"},a.replace(/[<>"'&\/]/g,function(e){return s[e]})),n=d(t,l,f);if(n!==t){var i=document.createElement("span");i.innerHTML=n;var r=e.parentNode,o=e.nextSibling;return r.removeChild(e),o?r.insertBefore(i,o):r.appendChild(i),i}}var a,s;if(null!=e)for(e=e.firstChild;e;){var c=null;u&&"A"===e.tagName||(c=h(e)),e=(c||e).nextSibling}};return h(n),r.trustAsHtml(n.innerHTML)}}]),e.filter("linksForCordova",["$sce",function(t){return function(e){return e=e.replace(/t?(e=e.substring(0,t))+"+":e}}),e.filter("codify",function(){return function(e){return e.replace(/(^|\s)(```|`)([^`].*?)\2/g,function(e,t,n,i){return t+''+n+""+i+''+n+""})}})}(),function(){"use strict";angular.module("weechat").factory("handlers",["$rootScope","$log","models","plugins","notifications","bufferResume",function(l,c,f,s,u,a){function d(e,t,n,i){if(1!==e.bufferType&&(n.setHours(0,0,0,0),i.setHours(0,0,0,0),n.valueOf()!==i.valueOf())){t&&++e.lastSeen;var r=n;r.setDate(n.getDate()+1),r.setHours(0,0,0,0);var o="43";if(l.supports_formatting_date)o+=i.toLocaleDateString(window.navigator.language,{weekday:"long"});else{o+=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][i.getDay()]}var a={day:"numeric",month:"long"};if(i.getYear()!==n.getYear()&&(a.year="numeric"),o+=" (",l.supports_formatting_date)o+=i.toLocaleDateString(window.navigator.language,a);else{o+=["January","February","March","April","May","June","July","August","September","October","November","December"][i.getMonth()]+" "+i.getDate().toString(),"numeric"===a.year&&(o+=", "+i.getFullYear().toString())}if(r.valueOf()!==i.valueOf()){var s=Math.round((i-n)/864e5)+1;o+=s<0?1===(s*=-1)?", 1 day before":", "+s+" days before":", "+s+" days later"}o+=")";var c={buffer:e.id,date:i,prefix:"43─",tags_array:[],displayed:!0,highlight:0,message:o},u=new f.BufferLine(c);e.addLine(u)}}function h(e,t){var n=new f.BufferLine(e),i=f.getBuffer(n.buffer);if(i.requestedLines++,n.displayed){if(0r&&e.number<=o&&--e.number,e.number=o&&(e.number+=1)}),i.number=o},_buffer_opened:function(e){var t=e.objects[0].content[0],n=new f.Buffer(t);"server"===n.type?f.registerServer(n):f.getServerForBuffer(n).unread+=n.unread+n.notification;f.addBuffer(n)},_buffer_title_changed:function(e){var t=e.objects[0].content[0],n=t.pointers[0],i=f.getBuffer(n);i.fullName=t.full_name,i.title=f.parseRichText(t.title),i.number=t.number,i.rtitle="";for(var r=0;r'+e+"'"}var t=v.wconfig["weechat.look.buffer_time_format"],n="",i=e(":"),r="hh"+i+"mm"+i+"ss"+"' 'a",o="HH"+i+"mm",a=o+i+"ss";n=-1:'mm' 'a":-1Successfully deleted.')(k)[0];document.body.appendChild(t),setTimeout(function(){document.body.removeChild(t)},5e3);var n=document.querySelector("[data-imgur-deletehash='"+e+"']");n&&document.body.removeChild(n)}k.imgurDelete=function(e){o.deleteImage(e,n)},k.sendMessage=function(){var e=S.getActiveBuffer();if(void 0!==k.command&&""!==k.command){e.addToHistory(k.command),_.each(k.command.split(/\r?\n/),function(e){("/quit"!==e&&0!==e.indexOf("/quit ")||window.confirm("Are you sure you want to quit WeeChat? This will prevent you from connecting with Glowing Bear until you restart WeeChat on the command line!"))&&C.sendMessage(e)}),"/buffer clear"!==k.command&&"/c"!==k.command||(r.debug("Clearing lines"),e.clear());var t=k.command.indexOf(" "),n=k.command.substr(0,t);if(0<=["/query","/join","/j","/q"].indexOf(n)){var i=k.command.substring(t+1);S.outgoingQueries.push(i)}k.command=""}x.hotlistsync&&1<=S.version[0]&&C.sendHotlistClear(),k.getInputNode().focus()},w.addMention=function(e){if(e.showHiddenBrackets){var t=e.prefix,n=t[t.length-1].text,i=S.getBuffer(e.buffer),r=i.queryNicklist(n);if("channel"===i.type&&!r){var o=document.createElement("div");o.className="toast toast-short",o.innerHTML=n+" has left the room",document.body.appendChild(o),setTimeout(function(){document.body.removeChild(o)},5e3)}var a=k.command||"",s=0===a.length;if(0b.clientHeight/2){p[v].scrollIntoView(!0);break}return!0}if(x.readlineBindings&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&document.activeElement===t){if(s=t.selectionStart,65==n)t.setSelectionRange(0,0);else if(69==n)t.setSelectionRange(k.command.length,k.command.length);else if(85==n)k.command=k.command.slice(s),setTimeout(function(){t.setSelectionRange(0,0)});else if(75==n)k.command=k.command.slice(0,s),setTimeout(function(){t.setSelectionRange(k.command.length,k.command.length)});else{if(87!=n)return!1;var y=k.command.slice(0,s).replace(/\s+$/,"").lastIndexOf(" ")+1;k.command=k.command.slice(0,y)+k.command.slice(s,k.command.length),setTimeout(function(){t.setSelectionRange(y,y)})}return e.preventDefault(),!0}"keydown"!==e.type||18!==n||e.ctrlKey||e.shiftKey||!x.enableQuickKeys||(w.showQuickKeys=!0)},w.handleKeyRelease=function(e){if(18===e.keyCode)return void 0!==w.quickKeysTimer&&clearTimeout(w.quickKeysTimer),w.quickKeysTimer=setTimeout(function(){w.showQuickKeys&&(w.showQuickKeys=!1,w.$apply()),delete w.quickKeysTimer},1e3),!0},k.handleCompleteNickButton=function(e){return e.preventDefault(),k.completeNick(),k.completeCommand("forward"),setTimeout(function(){k.getInputNode().focus()},0),!0},k.inputPasted=function(e){if(e.clipboardData&&e.clipboardData.files&&e.clipboardData.files.length){e.stopPropagation(),e.preventDefault();for(var t=function(e,t){void 0!==e&&""!==e&&w.insertAtCaret(String(e));var n=i('')(k)[0];document.body.appendChild(n),setTimeout(function(){document.body.removeChild(n)},15e3),console.log("An image was uploaded to imgur, delete it with $scope.imgurDelete('"+t+"')")},n=0;n=h.length&&h.push(e),m<=0||m>=h.length?e:h[--m]},getHistoryDown:function(e){return m===h.length?(void 0!==e&&""!==e&&(h.push(e),m++),""):m<0||m>h.length?e:(m++,0]/g;e.service("plugins",["userPlugins","$sce",function(e,u){this.PluginManager=new function(){var s=[],c=new RegExp("nsfw","i");return{registerPlugins:function(e){for(var t=0;t").attr("src","//embed.spotify.com/?uri="+e[t]).attr("width","350").attr("height","80").attr("frameborder","0").attr("allowtransparency","true");i.push(n.prop("outerHTML"))}}var i=[];return t(e.match(/spotify:track:[a-zA-Z-0-9]{22}/g)),t(e.match(/spotify:artist:[a-zA-Z-0-9]{22}/g)),t(e.match(/spotify:user:\w+:playlist:[a-zA-Z-0-9]{22}/g)),t(e.match(/(open|play)\.spotify\.com\/track\/[a-zA-Z-0-9]{22}/g)),t(e.match(/(open|play)\.spotify\.com\/artist\/[a-zA-Z-0-9]{22}/g)),t(e.match(/(open|play)\.spotify\.com\/user\/\w+\/playlist\/[a-zA-Z-0-9]{22}/g)),i}),t=new c("YouTube video",function(e){var t=e.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i);if(t){var n="https://www.youtube.com/embed/"+t[1]+"?html5=1&iv_load_policy=3&modestbranding=1&rel=0";return angular.element("").attr("src",n).attr("width","560").attr("height","315").attr("frameborder","0").attr("allowfullscreen","true").prop("outerHTML")}}),n=new s("Dailymotion video",function(e){var t=e.match(/dailymotion\.com\/.*video\/([^_?# ]+)/)||e.match(/dailymotion\.com\/.*#video=([^_& ]+)/)||e.match(/dai\.ly\/([^_?# ]+)/);if(t){var n="https://www.dailymotion.com/embed/video/"+t[1]+"?html&controls=html&startscreen=html&info=0&logo=0&related=0";return angular.element("").attr("src",n).attr("width","480").attr("height","270").attr("frameborder","0").prop("outerHTML")}return null}),r=new s("AlloCine video",function(e){var t=e.match(/allocine\.fr\/videokast\/video-(\d+)/)||e.match(/allocine\.fr\/.*cmedia=(\d+)/);if(t){var n="http://www.allocine.fr/_video/iblogvision.aspx?cmedia="+t[1];return angular.element("").attr("src",n).attr("width","480").attr("height","270").attr("frameborder","0").prop("outerHTML")}return null}),o=new c("image",function(n){if(n.match(/\.(bmp|gif|ico|jpeg|jpg|png|svg|svgz|tif|tiff|webp)(:(small|medium|large))?\b/i)){if(-1!=n.indexOf("^https?://fukung.net/v/"))n=n.replace(/.*\//,"http://media.fukung.net/imgs/");else if(n.match(/^http:\/\/(i\.)?imgur\.com\//i))n=n.replace(/^http:/,"https:");else if(n.match(/^https:\/\/www\.dropbox\.com\/s\/[a-z0-9]+\//i)){var e=document.createElement("a");e.href=n;for(var t=e.protocol+"//"+e.host+e.pathname+"?",i=e.search.substring(1).split("&"),r=!1,o=0;o").attr("target","_blank").attr("href",n).append(angular.element("").addClass("embed").attr("src",n));e.innerHTML=t.prop("outerHTML")}}}),a=new c("audio",function(n){if(n.match(/\.(flac|m4a|mid|midi|mp3|oga|ogg|ogx|opus|pls|spx|wav|wave|wma)\b/i))return function(){var e=this.getElement(),t=angular.element("").addClass("embed").attr("width","560").append(angular.element("").attr("src",n));e.innerHTML=t.prop("outerHTML")}});return{plugins:[t,n,r,o,new c("video",function(i){if(i.match(/\.(3gp|avi|flv|gifv|mkv|mp4|ogv|webm|wmv)\b/i))return i.match(/^http:\/\/(i\.)?imgur\.com\//i)&&(i=i.replace(/^http:/,"https:")),function(){var e,t=this.getElement(),n=angular.element("").addClass("embed").attr("width","560");e=i.match(/^https:\/\/(i\.)?imgur\.com\/.*\.gifv/i)?(e=angular.element("").attr("src",i.replace(/\.gifv\b/i,".webm")).attr("type","video/webm"),n.append(e),angular.element("").attr("src",i.replace(/\.gifv\b/i,".mp4")).attr("type","video/mp4")):angular.element("").attr("src",i),n.append(e),t.innerHTML=n.prop("outerHTML")}}),a,e,new c("cloud music",function(e){return e.match(/^https?:\/\/soundcloud\.com\//)?angular.element("").attr("width","100%").attr("height","120").attr("scrolling","no").attr("frameborder","no").attr("src","https://w.soundcloud.com/player/?url="+e+"&color=ff6600&auto_play=false&show_artwork=true").prop("outerHTML"):e.match(/^https?:\/\/([a-z]+\.)?mixcloud\.com\//)?angular.element("").attr("width","480").attr("height","60").attr("frameborder","0").attr("src","//www.mixcloud.com/widget/iframe/?feed="+e+"&mini=1&stylecolor=&hide_artwork=&embed_type=widget_standard&hide_tracklist=1&hide_cover=").prop("outerHTML"):void 0}),new c("Google Map",function(e){if(e.match(/^https?:\/\/maps\.google\./i)||e.match(/^https?:\/\/(?:[\w]+\.)?google\.[\w]+\/maps/i))return angular.element("").attr("width","450").attr("height","350").attr("frameborder","0").attr("scrolling","no").attr("marginheight","0").attr("src",e+"&output=embed").prop("outerHTML")}),new c("ascii cast",function(e){var t=e.match(/^https?:\/\/(?:www\.)?asciinema\.org\/a\/([0-9a-z]+)/i);if(t){var n=t[1];return function(){var e=this.getElement(),t=document.createElement("script");t.src="https://asciinema.org/a/"+n+".js",t.id="asciicast-"+n,t.async=!0,e.appendChild(t)}}}),new c("meteogram",function(o){var a=o.match(/^https?:\/\/(?:www\.)?yr\.no\/(place|stad|sted|sadji|paikka)\/(([^\s.;,(){}<>\/]+\/){3,})/);if(a)return function(){var e=this.getElement(),t=a[1],n=a[2],i=a[a.length-1].slice(0,-1);o="http://www.yr.no/"+t+"/"+n+"avansert_meteogram.png";var r=angular.element("").attr("src",o).attr("alt","Meteogram for "+i);e.innerHTML=r.prop("outerHTML")}}),new c("Gist",function(e){var t=e.match(/^(https:\/\/gist\.github\.com\/(?:.*?))[\/]?(?:\#.*)?$/i);if(t)return e=t[1]+".json",function(){var n=this.getElement();i(e,function(e){if(document.querySelectorAll('link[rel=stylesheet][href="'+e.stylesheet+'"]').length<1){var t=document.createElement("link");t.href=e.stylesheet,t.setAttribute("rel","stylesheet"),document.head.appendChild(t)}n.innerHTML='
'+e.div+"
"})}}),new c("Pastebin",function(e){var t=e.match(/^https?:\/\/pastebin\.com\/(raw\/)?([^.?]+)/i);if(t){var n="https://pastebin.com/embed_iframe/"+t[2];return angular.element("").attr("src",n).attr("width","100%").attr("height","480").prop("outerHTML")}}),new c("Giphy",function(n){var e=n.match(/^https?:\/\/giphy\.com\/gifs\/.*-(.*)\/?/i);if(e){var i="https://media.giphy.com/media/"+e[1]+"/giphy.gif";return function(){var e=this.getElement(),t=angular.element("").attr("target","_blank").attr("href",n).append(angular.element("").addClass("embed").attr("src",i));e.innerHTML=t.prop("outerHTML")}}}),new c("Tweet",function(e){var t=e.match(/^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)/i);if(t)return e="https://api.twitter.com/1/statuses/oembed.json?id="+t[2],function(){var r=this.getElement();i(e,function(e){var t=e.html.indexOf("