diff --git a/min.js b/min.js index 831739c..d1e956e 100644 --- a/min.js +++ b/min.js @@ -1,4 +1,2 @@ -!function(){"use strict";var e=angular.module("localStorage",[]);e.factory("$store",["$parse",function(e){var t="undefined"==typeof window.localStorage?void 0:window.localStorage,n=!("undefined"==typeof t||"undefined"==typeof window.JSON);n||console.log("Warning: localStorage is not supported");var r={parseValue:function(e){var t;try{t=JSON.parse(e),void 0===t&&(t=e),"true"===t&&(t=!0),"false"===t&&(t=!1),parseFloat(t)!=t||angular.isObject(t)||(t=parseFloat(t))}catch(n){t=e}return t}},i={set:function(e,i){n||console.log("Local Storage not supported");var o=JSON.stringify(i);return t.setItem(e,o),r.parseValue(o)},get:function(e){if(!n)return null;var i=t.getItem(e);return r.parseValue(i)},remove:function(e){return n?(t.removeItem(e),!0):!1},enumerateKeys:function(){for(var e=[],n=0,r=t.length;r>n;++n)e.push(t.key(n));return e},bind:function(t,n,r){return void 0===r&&(r=""),void 0!==i.get(n)&&null!==i.get(n)||i.set(n,r),e(n).assign(t,i.get(n)),t.$watch(n,function(e){i.set(n,e)},!0),i.get(n)}};return i}])}(),function(e){"use strict";!function(){var t=function(){this._types={chr:this._getChar,int:this._getInt,str:this._getString,inf:this._getInfo,hda:this._getHdata,ptr:this._getPointer,lon:this._getStrNumber,tim:this._getTime,buf:this._getString,arr:this._getArray,htb:this._getHashTable,inl:this._getInfolist},this._typesStr={chr:this._strDirect,str:this._strDirect,int:this._strToString,tim:this._strToString,ptr:this._strDirect}};t._weeChatColorsNames=["default","black","darkgray","red","lightred","green","lightgreen","brown","yellow","blue","lightblue","magenta","lightmagenta","cyan","lightcyan","gray","white"],t._colorsOptionsNames=["separator","chat","chat_time","chat_time_delimiters","chat_prefix_error","chat_prefix_network","chat_prefix_action","chat_prefix_join","chat_prefix_quit","chat_prefix_more","chat_prefix_suffix","chat_buffer","chat_server","chat_channel","chat_nick","chat_nick_self","chat_nick_other","invalid","invalid","invalid","invalid","invalid","invalid","invalid","invalid","invalid","invalid","chat_host","chat_delimiters","chat_highlight","chat_read_marker","chat_text_found","chat_value","chat_prefix_buffer","chat_tags","chat_inactive_window","chat_inactive_buffer","chat_prefix_buffer_inactive_buffer","chat_nick_offline","chat_nick_offline_highlight","chat_nick_prefix","chat_nick_suffix","emphasis","chat_day_change"],t._getDefaultColor=function(){return{type:"weechat",name:"default"}},t._getDefaultAttributes=function(){return{name:null,override:{bold:!1,reverse:!1,italic:!1,underline:!1}}},t._getDefaultStyle=function(){return{fgColor:t._getDefaultColor(),bgColor:t._getDefaultColor(),attrs:t._getDefaultAttributes()}},t._cloneColor=function(e){var t={};for(var n in e)t[n]=e[n];return t},t._cloneAttrs=function(e){var t={};t.name=e.name,t.override={};for(var n in e.override)t.override[n]=e.override[n];return t},t._attrNameFromChar=function(e){var t={"*":"b","!":"r","/":"i",_:"u","":"b","":"r","":"i","":"u"};return e in t?t[e]:null},t._attrsFromStr=function(e){for(var n=t._getDefaultAttributes(),r=0;r16?t._getDefaultColor():{type:"weechat",name:t._weeChatColorsNames[n]}}var r=e.substring(1);return{type:"ext",name:parseInt(r).toString()}},t._getStyle=function(e){var n=[{regex:/^(\d{2})/,fn:function(e){var n={},r=parseInt(e[1]);if(r>=t._colorsOptionsNames.length)return{fgColor:null,bgColor:null,attrs:null};var i=t._colorsOptionsNames[r];return n.fgColor={type:"option",name:i},n.bgColor=t._cloneColor(n.fgColor),n.attrs={name:i,override:{}},n}},{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 n={bgColor:null};return e[2]?(n.attrs=t._attrsFromStr(e[1]),n.fgColor=t._getColorObj(e[2])):(n.attrs=t._attrsFromStr(e[3]),n.fgColor=t._getColorObj(e[4])),n}},{regex:/^B(\d{2}|@\d{5})/,fn:function(e){return{fgColor:null,bgColor:t._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 n={};return e[2]?(n.attrs=t._attrsFromStr(e[1]),n.fgColor=t._getColorObj(e[2])):(n.attrs=t._attrsFromStr(e[3]),n.fgColor=t._getColorObj(e[4])),n.bgColor=t._getColorObj(e[5]),n}},{regex:/^\*([\x01\x02\x03\x04*!\/_|]*)(\d{2}|@\d{5})/,fn:function(e){return{fgColor:t._getColorObj(e[2]),bgColor:null,attrs:t._attrsFromStr(e[1])}}},{regex:/^E/,fn:function(e){var n={};return n.fgColor={type:"option",name:"emphasis"},n.bgColor=t._cloneColor(n.fgColor),n.attrs={name:"emphasis",override:{}},n}}],r={fgColor:null,bgColor:null,attrs:null,text:e};return n.some(function(t){var n=e.match(t.regex);return n?(r=t.fn(n),r.text=e.substring(n[0].length),!0):!1}),r},t.rawText2Rich=function(e){var n=e.split(/(\x19|\x1a|\x1b|\x1c)/);if(1===n.length)return[{attrs:t._getDefaultAttributes(),fgColor:t._getDefaultColor(),bgColor:t._getDefaultColor(),text:n[0]}];var r=t._getDefaultColor(),i=t._getDefaultColor(),o=t._getDefaultAttributes(),a=null,c=!0;return n.map(function(e){if(0===e.length)return null;var n=e.charCodeAt(0),s=e.charAt(0);if(n>=25&&28>=n)return 28===n&&(r=t._getDefaultColor(),i=t._getDefaultColor(),25!==a&&(o=t._getDefaultAttributes())),a=n,null;var u=e;if(25===a){var l=t._getStyle(e);null!==l.fgColor&&(r=l.fgColor),null!==l.bgColor&&(i=l.bgColor),null!==l.attrs&&(o=l.attrs),u=l.text}else if(26===a||27===a){var f=26===a;if("|"!==s){var d=t._attrNameFromChar(s);d&&(o.override[d]=f,u=e.substring(1))}}if(a=null,0===u.length)return null;if(c&&null===o.name){var m=!0;for(var h in o.override)if(o.override[h]){m=!1;break}m?o.override={}:c=!1}return{fgColor:t._cloneColor(r),bgColor:t._cloneColor(i),attrs:t._cloneAttrs(o),text:u}}).filter(function(e){return null!==e})},t._uia2s=function(e){if(!e.length||0===e[0])return"";try{var t=String.fromCharCode.apply(null,e),n=decodeURIComponent(escape(t));return n}catch(t){for(var r="",i=0,o=e.length;o>i;i++)r+=e[i]<128?String.fromCharCode(e[i]):"?";return r}},t._mergeParams=function(e,t){for(var n in t)e[n]=t[n];return e},t._formatCmd=function(e,t,n){var r,i;return r=null!==e?"("+e+") ":"",r+=t,n.unshift(r),i=n.join(" "),i+="\n",i.replace(/[\r\n]+$/g,"").split("\n"),i},t.formatInit=function(e){var n={password:null,compression:"zlib"},r=[],i=[];return e=t._mergeParams(n,e),r.push("compression="+e.compression),null!==e.password&&r.push("password="+e.password),i.push(r.join(",")),t._formatCmd(null,"init",i)},t.formatHdata=function(e){var n={id:null,keys:null},r=[];return e=t._mergeParams(n,e),r.push(e.path),null!==e.keys&&r.push(e.keys.join(",")),t._formatCmd(e.id,"hdata",r)},t.formatInfo=function(e){var n={id:null},r=[];return e=t._mergeParams(n,e),r.push(e.name),t._formatCmd(e.id,"info",r)},t.formatInfolist=function(e){var n={id:null,pointer:null,args:null},r=[];return e=t._mergeParams(n,e),r.push(e.name),null!==e.pointer&&r.push(e.pointer),null!==e.pointer&&r.push(e.args),t._formatCmd(e.id,"infolist",r)},t.formatNicklist=function(e){var n={id:null,buffer:null},r=[];return e=t._mergeParams(n,e),null!==e.buffer&&r.push(e.buffer),t._formatCmd(e.id,"nicklist",r)},t.formatInput=function(e){var n={id:null},r=[];return e=t._mergeParams(n,e),r.push(e.buffer),r.push(e.data),t._formatCmd(e.id,"input",r)},t._formatSyncDesync=function(e,n){var r={id:null,buffers:null,options:null},i=[];return n=t._mergeParams(r,n),null!==n.buffers&&(i.push(n.buffers.join(",")),null!==n.options&&i.push(n.options.join(","))),t._formatCmd(n.id,e,i)},t.formatSync=function(e){return t._formatSyncDesync("sync",e)},t.formatDesync=function(e){return t._formatSyncDesync("desync",e)},t.formatTest=function(e){var n={id:null},r=[];return e=t._mergeParams(n,e),t._formatCmd(e.id,"test",r)},t.formatQuit=function(){return t._formatCmd(null,"quit",[])},t.formatPing=function(e){var n={id:null,args:null},r=[];return e=t._mergeParams(n,e),null!==e.args&&r.push(e.args.join(" ")),t._formatCmd(e.id,"ping",r)},t.prototype={_warnUnimplemented:function(e){console.log("Warning: "+e+" message parsing is not implemented")},_getType:function(){var e=this._getSlice(3);return e?t._uia2s(new Uint8Array(e)):null},_runType:function(e){var t=this._types[e],n=t.bind(this);return n()},_getStrNumber:function(){var e=this._getByte(),n=this._getSlice(e);return t._uia2s(new Uint8Array(n))},_strDirect:function(e){return e},_strToString:function(e){return e.toString()},_objToString:function(e,t){var n=this._typesStr[t],r=n.bind(this);return r(e)},_getInfo:function(){var e={};return e.key=this._getString(),e.value=this._getString(),e},_getHdata:function(){function e(){var e={};e.pointers=t.map(function(e){return r._getPointer()}),a.forEach(function(t){e[t[0]]=r._runType(t[1])}),i.push(e)}var t,n,r=this,i=[],o=this._getString(),a=this._getString().split(",");t=o.split("/"),n=this._getInt(),a=a.map(function(e){return e.split(":")});for(var c=0;n>c;c++)e();return i},_getPointer:function(){return this._getStrNumber()},_getTime:function(){var e=this._getStrNumber();return new Date(1e3*parseInt(e,10))},_getInt:function(){var e=new Uint8Array(this._getSlice(4));return(255&e[0])<<24|(255&e[1])<<16|(255&e[2])<<8|255&e[3]},_getByte:function(){var e=new Uint8Array(this._getSlice(1));return e[0]},_getChar:function(){return this._getByte()},_getString:function(){var e=this._getInt();if(e>0){var n=this._getSlice(e),r=new Uint8Array(n);return t._uia2s(r)}return""},_getHeader:function(){var e=this._getInt(),t=this._getByte();return{length:e,compression:t}},_getId:function(){return this._getString()},_getObject:function(){var e=this,t=this._getType();return t?{type:t,content:e._runType(t)}:void 0},_getHashTable:function(){var e,t,n,r=this,i={};e=this._getType(),t=this._getType(),n=this._getInt();for(var o=0;n>o;++o){var a=r._runType(e),c=r._objToString(a,e),s=r._runType(t);i[c]=s}return i},_getArray:function(){var e,t,n,r=this;e=this._getType(),t=this._getInt(),n=[];for(var i=0;t>i;i++)n.push(r._runType(e));return n},_getInfolist:function(){var e,t,n,r=this;e=this._getString(),t=this._getInt(),n=[];for(var i=0;t>i;i++){for(var o=r._getInt(),a=[],c=0;o>c;c++){var s={};s[r._getString()]=r._runType(r._getType()),a.push(s)}n.push(a)}return n},_getSlice:function(e){if(this.dataAt+e>this._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){var n=this;this._setData(e),this._dataAt=0;var r=this._getHeader();if(r.compression){var i=new Uint8Array(e,5),o=new Zlib.Inflate(i),a=o.decompress();this._setData(a.buffer),this._dataAt=0}for(var c=this._getId(),s=[],u=this._getObject();u;)s.push(u),u=n._getObject();var l={header:r,id:c,objects:s};return l}},e.Protocol=t}()}("undefined"==typeof exports?this.weeChat={}:exports),function(){"use strict";var e=angular.module("IrcUtils",[]);e.service("IrcUtils",[function(){var e=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},t=function(e){var t=_(e).sortBy(function(e){return-e.spokeAt});return t=_(t).pluck("name")},n=function(e,t){var n=null;return t.some(function(t){return 0===t.toLowerCase().search(e.toLowerCase())?(n=t,!0):!1}),n},r=function(t,n,r){for(var i=[],o=null,a=t.toLowerCase(),c=n.toLowerCase(),s=0;s0&&(o.lines.splice(0,m),o.requestedLines-=m,o.lastSeen-=m,o.allLinesFetched=!1),n.bufferlines=o.lines,n.nicklist=o.nicklist,o.nicklistRequested()?n.showNicklist=n.updateShowNicklist():c.requestNicklist(o.id,function(){n.showNicklist=n.updateShowNicklist(),t.scrollWithBuffer(!0)}),o.requestedLinesh&&(h=Math.min(4*h,r)),n.fetchMoreLines(h).then(function(){i(function(){var e=document.getElementById("bufferlines"),n=e.scrollHeight,r=function(){if(e){var i=e.scrollHeight;i!==n&&(t.updateBufferBottom(t.bufferBottom),n=i),setTimeout(r,500)}};t.updateBufferBottom(!0),t.scrollWithBuffer(!0),e.onscroll=_.debounce(function(){t.updateBufferBottom()},80),setTimeout(r,500)})})}s.updateTitle(o),setTimeout(function(){n.notifications=s.unreadCount("notification"),n.unread=s.unreadCount("unread")}),i(function(){t.scrollWithBuffer(!0)}),n.search="",u.isMobileUi()||setTimeout(function(){document.getElementById("sendMessage").focus()},0),l.hotlistsync&&o.fullName&&c.sendHotlistClear()}),t.favico=new Favico({animation:"none"}),n.notifications=s.unreadCount("notification"),n.unread=s.unreadCount("unread"),t.$on("notificationChanged",function(){s.updateTitle(),n.notifications=s.unreadCount("notification"),n.unread=s.unreadCount("unread"),l.useFavico&&t.favico&&s.updateFavico()}),t.$on("relayDisconnect",function(){t.pageTitle="",t.notificationStatus="",s.cancelAll(),a.reinitialize(),t.$emit("notificationChanged"),n.connectbutton="Connect",n.connectbuttonicon="glyphicon-chevron-right"}),n.connectbutton="Connect",n.connectbuttonicon="glyphicon-chevron-right",n.getBuffers=a.getBuffers.bind(a),n.bufferlines={},n.nicklist={},n.activeBuffer=a.getActiveBuffer,t.connected=!1,t.waseverconnected=!1,t.userdisconnect=!1,t.reconnecting=!1,t.models=a,t.iterCandidate=null,l.savepassword?(n.$watch("password",function(){l.password=n.password}),l.addCallback("password",function(e){n.password=e}),n.password=l.password):l.password="",l.addCallback("savepassword",function(e){l.savepassword&&(l.setDefaults({password:n.password}),l.password=n.password)}),t.wasMobileUi=!1,u.isMobileUi()&&(t.wasMobileUi=!0),l.fontfamily||(u.isMobileUi()?l.fontfamily="sans-serif":l.fontfamily="Inconsolata, Consolas, Monaco, Ubuntu Mono, monospace"),n.isSidebarVisible=function(){return"visible"===document.getElementById("content").getAttribute("sidebar-state")},n.showSidebar=function(){document.getElementById("sidebar").setAttribute("data-state","visible"),document.getElementById("content").setAttribute("sidebar-state","visible"),u.isMobileUi()&&_.each(document.getElementsByTagName("textarea"),function(e){i(function(){e.blur()})})},t.hideSidebar=function(){u.isMobileUi()&&(document.getElementById("sidebar").setAttribute("data-state","hidden"),document.getElementById("content").setAttribute("sidebar-state","hidden"))},l.addCallback("autoconnect",function(e){!e||t.connected||t.sslError||t.securityError||t.errorMessage||n.connect()}),n.toggleSidebar=function(){u.isMobileUi()&&(n.isSidebarVisible()?n.hideSidebar():n.showSidebar())},n.openNick=function(){u.isMobileUi()&&l.nonicklist&&(l.nonicklist=!1)},n.closeNick=function(){u.isMobileUi()&&(l.nonicklist||(l.nonicklist=!0))},l.addCallback("orderbyserver",function(e){t.predicate=e?"serverSortKey":"number"}),l.addCallback("useFavico",function(e){t.connected&&(e?s.updateFavico():t.favico.reset())}),l.addCallback("enableMathjax",function(e){e&&!t.mathjax_init&&(t.mathjax_init=!0,function(){var e,t=document.getElementsByTagName("head")[0];e=document.createElement("script"),e.type="text/x-mathjax-config",e[window.opera?"innerHTML":"text"]="MathJax.Hub.Config({\n tex2jax: { inlineMath: [['$$','$$'], ['\\\\(','\\\\)']], displayMath: [['\\\\[','\\\\]']] },\n});",t.appendChild(e),e=document.createElement("script"),e.type="text/javascript",e.src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML",t.appendChild(e)}())}),l.addCallback("theme",function(e){var t=document.getElementById("themeCSS");t&&t.parentNode.removeChild(t),function(){var t=document.createElement("link");t.rel="stylesheet",t.href="css/themes/"+e+".css",t.media="screen",t.id="themeCSS",document.getElementsByTagName("head")[0].appendChild(t)}()}),l.addCallback("customCSS",function(e){var t=document.getElementById("custom-css-tag");t&&t.parentNode.removeChild(t);var n=document.createElement("style");n.type="text/css",n.id="custom-css-tag",n.appendChild(document.createTextNode(e));var r=document.getElementsByTagName("head");r[0].appendChild(n)}),l.addCallback("fontfamily",function(e){u.changeClassStyle("favorite-font","fontFamily",e)}),l.addCallback("fontsize",function(e){u.changeClassStyle("favorite-font","fontSize",e)}),n.setActiveBuffer=function(e,t){return u.isMobileUi()&&n.hideSidebar(),a.version[0]>=1&&c.sendHotlistClear(),a.setActiveBuffer(e,t)},n.openBuffer=function(e){var t=a.getActiveBuffer().fullName;if(t=t.substring(0,t.lastIndexOf(".")+1)+e,!n.setActiveBuffer(t,"fullName")){var r="join -noswitch";["#","&","+","!"].indexOf(e.charAt(0))<0&&(r="query",(1==a.version[0]&&a.version[1]>=2||a.version[1]>1)&&(r+=" -noswitch")),c.sendMessage("/"+r+" "+e)}},n.calculateNumLines=function(){for(var e=document.querySelectorAll(".bufferline"),t=0,r=0;0===t&&ri||Math.abs(i-o)<3){var a=document.querySelector(".readmarker");if(e&&a)r.scrollTop=a.offsetTop-a.parentElement.scrollHeight+a.scrollHeight;else if(n)r.scrollTop=r.scrollHeight-r.clientHeight-o;else{var c=document.getElementById("end-of-buffer");c.scrollIntoView()}t.updateBufferBottom()}};i(a),window.requestAnimationFrame(a)},n.connect=function(){s.requestNotificationPermission(),t.sslError=!1,t.securityError=!1,t.errorMessage=!1,t.bufferBottom=!0,n.connectbutton="Connecting",n.connectbuttonicon="glyphicon-refresh glyphicon-spin",c.connect(l.host,l.port,n.password,l.ssl)},n.disconnect=function(){n.connectbutton="Connect",n.connectbuttonicon="glyphicon-chevron-right",c.disconnect()},n.reconnect=function(){var e=a.getActiveBuffer().id;c.attemptReconnect(e,3e3)},n.install=function(){if(void 0!==navigator.mozApps){var e=location.protocol+"//"+location.host+location.pathname.replace(/\/(index\.html)?$/,""),t=navigator.mozApps.install(e+"/manifest.webapp");t.onsuccess=function(){n.isinstalled=!0;var e=this.result;e.launch(),alert("Installation successful!")},t.onerror=function(){alert("Install failed, error: "+this.error.name)}}else alert("Sorry. Only supported in Firefox v26+")},n.showModal=function(e){document.getElementById(e).setAttribute("data-state","visible")},n.closeModal=function(e){function t(e,t){for(var n=e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector;e;){if(n.call(e,t))return e;e=e.parentElement}}t(e.target,".gb-modal").setAttribute("data-state","hidden")},n.toggleAccordion=function(e){e.stopPropagation(),e.preventDefault();var t=e.target.parentNode.parentNode.parentNode;t.setAttribute("data-state","active"===t.getAttribute("data-state")?"collapsed":"active");var n=t.parentNode.children;for(var r in n){var i=n[r];1===i.nodeType&&i!==t&&i.setAttribute("data-state","collapsed")}},n.hasUnread=function(e){return n.search&&""!==n.search?!0:l.onlyUnread?a.getActiveBuffer()===e?!0:"core.weechat"===e.fullName||l.orderbyserver&&"server"===e.type?!0:(e.unread>0||e.notification>0)&&!e.hidden:!e.hidden},l.addCallback("nonicklist",function(){n.showNicklist=n.updateShowNicklist(),t.connected&&t.bufferBottom&&i(function(){t.updateBufferBottom(!0)},500)}),n.showNicklist=!1,n.updateShowNicklist=function(){var e=a.getActiveBuffer();return e?l.nonicklist?!1:!e.isNicklistEmpty():!1},t.switchToActivityBuffer=function(){var e,t,r=_.sortBy(n.getBuffers(),"number");for(e in r)if(t=r[e],t.notification>0)return void n.setActiveBuffer(t.id);for(e in r)if(t=r[e],t.unread>0)return void n.setActiveBuffer(t.id)},t.toggleNicklist=function(){l.nonicklist=!l.nonicklist},t.switchToAdjacentBuffer=function(e){var r=_.sortBy(n.getBuffers(),t.predicate),i=a.getActiveBuffer(),o=r.indexOf(i);if(o>=0){var c=r[o+e];c&&n.setActiveBuffer(c.id)}},n.handleSearchBoxKey=function(e){var t=e.keyCode?e.keyCode:e.charCode;27===t?(e.preventDefault(),n.search=""):13===t&&(e.preventDefault(),n.filteredBuffers.length>0&&n.setActiveBuffer(n.filteredBuffers[0].id),n.search="")},t.supports_formatting_date=function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"!==e.name&&o.info("Browser does not support toLocaleDateString(), falling back to en-US"),"RangeError"===e.name}return o.info("Browser does not support toLocaleDateString(), falling back to en-US"),!1}(),window.onbeforeunload=function(e){null!==n.command&&""!==n.command?(e.preventDefault(),e.returnValue="Any unsent input will be lost. Are you sure that you want to quit?"):(t.connected&&n.disconnect(),n.favico.reset())},n.init=function(){if(window.location.hash){var e=atob(window.location.hash.substring(1));window.location.hash="";var r=e.split(":"),i=r[0],o=parseInt(r[1]),a=r[2],u=r.length>3;s.requestNotificationPermission(),t.sslError=!1,t.securityError=!1,t.errorMessage=!1,t.bufferBottom=!0,n.connectbutton="Connecting",n.connectbuttonicon="glyphicon-chevron-right",c.connect(i,o,a,u)}}}]),e.config(["$routeProvider",function(e){e.when("/",{templateUrl:"index.html",controller:"WeechatCtrl"})}])}(),function(){"use strict";var e=angular.module("weechat");e.factory("settings",["$store","$rootScope",function(e,t){var n=this;this.callbacks={},this.cache={};var r=function(r){Object.defineProperty(n,r,{enumerable:!0,key:r,get:function(){return r in this.cache||(this.cache[r]=e.get(r)),this.cache[r]},set:function(i){this.cache[r]=i,e.set(r,i);for(var o=n.callbacks[r],a=0;void 0!==o&&a0?e.notificationStatus="("+t+") ":e.notificationStatus="";var r=n.getActiveBuffer();r&&(e.pageTitle=r.shortName+" | "+r.rtitle)},l=function(){var t=s("notification");if(t>0)e.favico.badge(t,{bgColor:"#d00",textColor:"#fff"});else{var n=s("unread");0===n?e.favico.reset():e.favico.badge(n,{bgColor:"#5CB85C",textColor:"#ff0"})}},f=function(e,t){var n="",i="",o=e.notification;if("private"===e.type)n=o>1?o.toString()+" private messages from ":"Private message from ",i=t.text;else{n=o>1?o.toString()+" highlights in ":"Highlight in ";for(var a="",s=0;s "+t.text}if(n+=e.shortName+" ("+e.server+")",c(e,n,i),r.soundnotification){var u="assets/audio/sonar",l='';document.getElementById("soundNotification").innerHTML=l}},d=function(){for(;o.length>0;){var e=o.pop();void 0!==e&&e.close()}};return{requestNotificationPermission:a,updateTitle:u,updateFavico:l,createHighlight:f,cancelAll:d,unreadCount:s}}]),function(){"use strict";var e=angular.module("weechat");e.filter("toArray",function(){return function(e,t){return e instanceof Object?t?Object.keys(e).map(function(t,n){return Object.defineProperties(e[t],{$key:{value:t},$idx:{value:n,configurable:!0}})}):Object.keys(e).map(function(t){return Object.defineProperty(e[t],"$key",{value:t})}):e}}),e.filter("irclinky",function(){return function(e){if(!e)return e;var t=/(^|[\s,.:;?!"'()+@-\~%])(#+[^\x00\x07\r\n\s,:]*[a-z][^\x00\x07\r\n\s,:]*)/gim,n='$1$2';return e.replace(t,n)}}),e.filter("inlinecolour",function(){return function(e){if(!e)return e;var t=/(^|[^&])(\#[0-9a-f]{6};?)(?!\w)/gim,n=/(.?)(rgba?\((?:\s*\d+\s*,){2}\s*\d+\s*(?:,\s*[\d.]+\s*)?\);?)/gim,r='$1$2
';return e=e.replace(t,r),e=e.replace(n,r)}}),e.filter("DOMfilter",["$filter","$sce",function(e,t){var n=["irclinky"];return function(r,i){if(!r||!i)return r;var o=n.indexOf(i)>-1,a=function(e){var t={"<":"<",">":">",'"':""","'":"'","&":"&","/":"/"};return e.replace(/[<>"'&\/]/g,function(e){return t[e]})},c=arguments.length>2?arguments[2]:null,s=arguments.length>3?arguments[3]:null,u=e(i),l=document.createElement("div");l.innerHTML=r;var f=function(e){if(3===e.nodeType){var t=a(e.nodeValue),n=u(t,c,s);if(n!==t){var r=document.createElement("span");r.innerHTML=n;var i=e.parentNode,l=e.nextSibling;return i.removeChild(e),l?i.insertBefore(r,l):i.appendChild(r),r}}if(void 0!==e&&null!==e)for(e=e.firstChild;e;){var d=null;o&&"A"===e.tagName||(d=f(e)),e=(d?d:e).nextSibling}};return f(l),t.trustAsHtml(l.innerHTML)}}]),e.filter("getBufferQuickKeys",function(){return function(e,t){return t?(void 0!==t.search&&t.search.length||t.onlyUnread?e.forEach(function(e,t){e.$quickKey=10>t?(t+1)%10:""}):_.map(e,function(e,t){return[e.number,e.$idx,t]}).sort(function(e,t){return e[0]-t[0]||e[1]-t[1]}).forEach(function(t,n){e[t[2]].$quickKey=10>n?(n+1)%10:""}),e):e}}),e.filter("emojify",function(){return function(e,t){if(t===!0&&void 0!==window.emojione){var n=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return n.test(e)?emojione.unicodeToImage(e):e}return e}}),e.filter("mathjax",function(){return function(e,t,n){if(!n||"undefined"==typeof MathJax)return e;if(-1!=e.indexOf("$$")||-1!=e.indexOf("\\[")||-1!=e.indexOf("\\(")){var r=document.querySelector(t);MathJax.Hub.Queue(["Typeset",MathJax.Hub,r])}return e}}),e.filter("prefixlimit",function(){ -return function(e,t){return isNaN(t)?e:0>=t?"":e&&e.length>t?(e=e.substring(0,t),e+"+"):e}})}(),function(){"use strict";var e=angular.module("weechat");e.factory("handlers",["$rootScope","$log","models","plugins","notifications",function(e,t,n,r,i){var o=function(e){var t=e.objects[0].content,r=t.value;n.version=r.split(".").map(function(e){return parseInt(e)})},a=function(e){for(var r=e.objects[0].content,i=0;if?(f=-1*f,c+=1===f?", 1 day before":", "+f+" days before"):c+=", "+f+" days later"}c+=")";var d={buffer:t.id,date:o,prefix:"43─",tags_array:[],displayed:!0,highlight:0,message:c},m=new n.BufferLine(d);t.addLine(m)}},u=function(t,o){var a=new n.BufferLine(t),c=n.getBuffer(a.buffer);if(c.requestedLines++,a.displayed){if(c.lines.length>0){var u=new Date(c.lines[c.lines.length-1].date),l=new Date(a.date);s(c,o,u,l)}a=r.PluginManager.contentForMessage(a),c.addLine(a),o&&c.lastSeen++,c.active&&!o&&e.scrollWithBuffer(),o||c.active&&e.isWindowFocused()||(c.notify>1&&_.contains(a.tags,"notify_message")&&!_.contains(a.tags,"notify_none")&&(c.unread++,e.$emit("notificationChanged")),(0!==c.notify&&a.highlight||_.contains(a.tags,"notify_private"))&&(c.notification++,i.createHighlight(c,a),e.$emit("notificationChanged")))}},l=function(e){for(var t=e.objects[0].content,r=0;r=0),void 0!==t.notify&&(e.notify=t.notify))},d=function(e){e.objects[0].content.forEach(function(e){u(e,!1)})},m=function(e){var t=e.objects[0].content[0],r=new n.Buffer(t);n.addBuffer(r)},h=function(e){var t=e.objects[0].content[0],r=t.pointers[0],i=n.getBuffer(r);i.fullName=t.full_name,i.title=n.parseRichText(t.title),i.number=t.number,i.rtitle="";for(var o=0;o=0?t.short_name.charAt(0):"";var o=n.outgoingQueries.indexOf(i.shortName);o>=0&&(n.outgoingQueries.splice(o,1),n.setActiveBuffer(i.id))},p=function(e){var t=e.objects[0].content[0],r=t.pointers[0],i=n.getBuffer(r);i.hidden=!0},v=function(e){var t=e.objects[0].content[0],r=t.pointers[0],i=n.getBuffer(r);i.hidden=!1},b=function(e){var t=e.objects[0].content[0],r=t.pointers[0],i=n.getBuffer(r),o=t.local_variables;void 0!==i&&void 0!==o&&(i.type=o.type,i.indent=["channel","private"].indexOf(o.type)>=0,i.plugin=o.plugin,i.server=o.server,i.serverSortKey=i.plugin+"."+i.server+("server"===i.type?"":"."+i.shortName))},y=function(e){var t=e.objects[0].content[0],r=t.pointers[0];n.getBuffer(r);r.bufferType=t.type},w=function(e,t){var r=e.objects[0].content.reverse();if(void 0===t&&(t=!0),r.forEach(function(e){u(e,t)}),e.objects[0].content.length>0){var i=e.objects[0].content[e.objects[0].content.length-1],o=n.getBuffer(i.buffer);if(o.lines.length>0){var a=new Date(o.lines[o.lines.length-1].date);s(o,!0,a,new Date)}}},C=function(e){if(0!==e.objects.length){var t=e.objects[0].content;t.forEach(function(e){var t=n.getBuffer(e.buffer);t.unread+=e.count[1],t.notification+=e.count[2],t.notification+=e.count[3];var r=_.reduce(e.count,function(e,t){return e+t},0);t.lastSeen=t.lines.length-1-r})}},k=function(e){var t=e.objects[0].content,r="root";t.forEach(function(e){var t=n.getBuffer(e.pointers[0]);if(1===e.group){var i=new n.NickGroup(e);r=i.name,t.nicklist[r]=i}else{var o=new n.Nick(e);t.addNick(r,o)}})},S=function(e){var t,r=e.objects[0].content;r.forEach(function(e){var r=n.getBuffer(e.pointers[0]),i=e._diff;if(1===e.group){if(t=e.name,void 0===t){var o=new n.NickGroup(e);r.nicklist[t]=o,t=o.name}}else{var a=new n.Nick(e);43===i?r.addNick(t,a):45===i?r.delNick(t,a):42===i&&r.updateNick(t,a)}})},x={_buffer_closing:c,_buffer_line_added:d,_buffer_localvar_added:b,_buffer_localvar_removed:b,_buffer_localvar_changed:b,_buffer_opened:m,_buffer_title_changed:h,_buffer_type_changed:y,_buffer_renamed:g,_buffer_hidden:p,_buffer_unhidden:v,_nicklist:k,_nicklist_diff:S};e.$on("onMessage",function(e,n){_.has(x,n.id)?x[n.id](n):t.debug("Unhandled event received: "+n.id)});var B=function(e){_.has(x,e.id)&&x[e.id](e)};return{handleVersionInfo:o,handleConfValue:a,handleEvent:B,handleLineInfo:w,handleHotlistInfo:C,handleNicklist:k,handleBufferInfo:l}}])}(),function(){"use strict";var e=angular.module("weechat");e.factory("connection",["$rootScope","$log","handlers","models","ngWebsockets",function(e,t,n,r,i){var o,a=new weeChat.Protocol,c=[],s=function(r,o,s,u,f,d,m){e.passwordError=!1,c=[r,o,s,u,f];var h=u?"wss":"ws";-1!==r.indexOf(":")&&"["!==r[0]&&"]"!==r[r.length-1]&&(r="["+r+"]");var g=h+"://"+r+":"+o+"/weechat";t.debug("Connecting to URL: ",g);var p=function(){var r=function(e){return i.send(weeChat.Protocol.formatInit({password:e,compression:f?"off":"zlib"})),i.send(weeChat.Protocol.formatInfo({name:"version"}))},o=function(){return i.send(weeChat.Protocol.formatHdata({path:"hotlist:gui_hotlist(*)",keys:[]}))},a=function(){return i.send(weeChat.Protocol.formatHdata({path:"buffer:gui_buffers(*)",keys:["local_variables,notify,number,full_name,short_name,title,hidden,type"]}))},c=function(){return i.send(weeChat.Protocol.formatSync({}))};r(s).then(function(r){n.handleVersionInfo(r),a().then(function(e){n.handleBufferInfo(e)}),o().then(function(e){n.handleHotlistInfo(e),d&&d()}),c(),t.info("Connected to relay"),e.connected=!0},function(){_()})},v=function(){e.waseverconnected=!0},b=function(n){t.info("Disconnected from relay"),e.$emit("relayDisconnect"),e.userdisconnect||!e.waseverconnected?(y(n),e.userdisconnect=!1):l(n),_()},y=function(t){u&&t&&1006===t.code&&"undefined"!=typeof e.lastError&&Date.now()-e.lastError<1e3&&(e.sslError=!0,e.$apply())},_=function(){e.waseverconnected||e.errorMessage||(e.passwordError=!0,e.$apply())},w=function(n){t.error("Relay error",n),e.lastError=Date.now(),"error"===n.type&&1!==this.readyState&&(i.failCallbacks("error"),e.errorMessage=!0)};try{i.connect(g,a,{binaryType:"arraybuffer",onopen:p,onclose:b,onmessage:v,onerror:w})}catch(n){t.debug("Websocket caught DOMException:",n),e.lastError=Date.now(),e.errorMessage=!0,e.securityError=!0,e.$emit("relayDisconnect"),m&&m()}},u=function(n,i){t.info("Attempting to reconnect...");var a=c;s(a[0],a[1],a[2],a[3],a[4],function(){e.reconnecting=!1,r.setActiveBuffer(n),t.info("Sucessfully reconnected to relay")},function(){i>=6e5?(t.info("Failed to reconnect, giving up"),handleClose()):(t.info("Failed to reconnect, scheduling next attempt in",i/1e3,"seconds"),void 0!==o&&clearTimeout(o),o=setTimeout(function(){u(n,1.5*i)},i))})},l=function(n){if(c.length<5)return void t.error("Cannot reconnect, connection information is missing");r.reinitialize(),e.reconnecting=!0,e.$apply();var i=r.getActiveBuffer().id,a=3e3;o=setTimeout(function(){u(i,a)},a)},f=function(){t.info("Disconnecting from relay"),e.userdisconnect=!0,i.send(weeChat.Protocol.formatQuit());setTimeout(function(){i.disconnect(),i.failCallbacks("disconnection"),e.connected=!1,e.$emit("relayDisconnect"),e.$apply()})},d=function(e){i.send(weeChat.Protocol.formatInput({buffer:r.getActiveBufferReference(),data:e}))},m=function(e){i.send(weeChat.Protocol.formatInput({buffer:"core.weechat",data:e}))},h=function(){r.version[0]>=1?(d("/buffer set hotlist -1"),d("/input set_unread_current_buffer")):m("/buffer "+r.getActiveBuffer().fullName)},g=function(e,t){e&&i.send(weeChat.Protocol.formatNicklist({buffer:"0x"+e})).then(function(e){n.handleNicklist(e),void 0!==t&&t()})},p=function(o){t.debug("Fetching ",o," lines");var a=r.getActiveBuffer();return void 0===o&&(o=0),o=Math.max(o,2*a.requestedLines),e.loadingLines=!0,i.send(weeChat.Protocol.formatHdata({path:"buffer:0x"+a.id+"/own_lines/last_line(-"+o+")/data",keys:[]})).then(function(t){var r=a.lines.length,i=a.lastSeen>=0;a.lines.length=0,a.requestedLines=0;var c=t.objects[0].content.length;n.handleLineInfo(t,!0),a.lastSeen-=r,o>c&&(a.allLinesFetched=!0),e.loadingLines=!1;var s=!i&&a.lastSeen>=0;e.scrollWithBuffer(s,!0)})};return{connect:s,disconnect:f,sendMessage:d,sendCoreCommand:m,sendHotlistClear:h,fetchMoreLines:p,requestNicklist:g,attemptReconnect:u}}])}(),function(){"use strict";var e=angular.module("weechat");e.directive("fileChange",["$parse",function(e){return{restrict:"A",link:function(t,n,r){var i=e(r.fileChange),o=function(e){t.$apply(function(){i(t,{$event:e,files:e.target.files})})};n[0].addEventListener("change",o,!1)}}}])}(),function(){"use strict";var e=angular.module("weechat");e.directive("imgurDrop",["connection","imgur","$rootScope",function(e,t,n){return{restrict:"A",link:function(e,r,i){var o=r[0];o.ondragover=function(){return this.classList.add("imgur-drop-hover"),!1},o.ondragend=function(){return this.classList.remove("imgur-drop-hover"),!1},o.ondrop=function(e){this.classList.remove("imgur-drop-hover");var r=e.dataTransfer.files;e.stopPropagation(),e.preventDefault();var i=function(e){void 0!==e&&""!==e&&n.insertAtCaret(String(e))};if("undefined"!=typeof r&&r.length>0)for(var o=0;o0&&" "!==i[i.length-1]&&(i+=" "),o.length>0&&" "!==o[0]&&(o=" ".concat(o)),t.command=i+e+o,setTimeout(function(){n.focus();var e=t.command.length-o.length;n.setSelectionRange(e,e),t.$apply()},0)},t.uploadImage=function(t,n){var r=function(t){void 0!==t&&""!==t&&e.insertAtCaret(String(t))};if("undefined"!=typeof n&&n.length>0)for(var i=0;i=0){var u=t.command.substring(o+1);a.outgoingQueries.push(u)}t.command=""}a.version[0]>=1&&i.sendHotlistClear(),t.getInputNode().focus()},e.addMention=function(e){var n=e[e.length-1].text,r=t.command||"",i=0===r.length;if(r.length>0){var o=r.trim();if(":"===o.charAt(o.length-1)){var c=o.lastIndexOf(" ")+1,s=o.slice(c,o.length-1),u=a.getActiveBuffer().getNicklistByTime();for(var l in u)if(u[l].name===s){r=r.slice(0,r.lastIndexOf(":"))+" ",i=!0;break}}" "!==r.charAt(r.length-1)&&(r+=" ")}r+=n,i&&(r+=": "),t.command=r,t.getInputNode().focus()},e.handleKeyPress=function(n){if(!e.connected)return!0;var r=t.getInputNode(),o=n.keyCode?n.keyCode:n.charCode,c=n.getModifierState?n.getModifierState("AltGraph"):!1;if(c)return!1;e.showQuickKeys=!1;var u=t.iterCandidate;if(t.iterCandidate=null,n.altKey&&!n.ctrlKey&&o>47&&58>o){48===o&&(o=58);var l,f=o-48-1;if((t.$parent.search.length||t.$parent.onlyUnread)&&t.$parent.filteredBuffers.length){var d=t.$parent.filteredBuffers[f];void 0!==d&&(l=[d.number,d.id])}else{var m=_.map(a.getBuffers(),function(e){return[e.number,e.id]}).sort(function(e,t){return e[0]-t[0]});l=m[f]}l&&(t.$parent.setActiveBuffer(l[1]),n.preventDefault())}if(9===o&&!n.altKey&&!n.ctrlKey)return n.preventDefault(),t.iterCandidate=u,t.completeNick(),!0;if(n.altKey&&!n.ctrlKey&&78===o)return n.preventDefault(),e.toggleNicklist(),!0;if(n.altKey&&(97===o||65===o))return n.preventDefault(),e.switchToActivityBuffer(),!0;if(n.altKey&&!n.ctrlKey&&(38===o||40===o)){n.preventDefault();var h=o-39;return e.switchToAdjacentBuffer(h),!0}if(n.altKey&&(76===o||108===o))return n.preventDefault(),r.focus(),r.setSelectionRange(t.command.length,t.command.length),!0;if(n.altKey&&(60===o||226===o)){var g=a.getPreviousBuffer();if(g)return a.setActiveBuffer(g.id),n.preventDefault(),!0}if(27===o){n.preventDefault();for(var p=document.querySelectorAll(".gb-modal"),v=0;v=0;w--)if(y[w].offsetTop-C.scrollTopC.clientHeight/2){y[w].scrollIntoView(!0);break}return!0}if(s.readlineBindings&&n.ctrlKey&&!n.altKey&&!n.shiftKey&&document.activeElement===r){if(b=r.selectionStart,65==o)r.setSelectionRange(0,0);else if(69==o)r.setSelectionRange(t.command.length,t.command.length);else if(85==o)t.command=t.command.slice(b),setTimeout(function(){r.setSelectionRange(0,0)});else if(75==o)t.command=t.command.slice(0,b),setTimeout(function(){r.setSelectionRange(t.command.length,t.command.length)});else{if(87!=o)return!1;var k=t.command.slice(0,b),S=k.lastIndexOf(" ")+1;t.command=t.command.slice(0,S)+t.command.slice(b,t.command.length),setTimeout(function(){r.setSelectionRange(S,S)})}return n.preventDefault(),!0}"keydown"!==n.type||18!==o||n.ctrlKey||n.shiftKey||(e.showQuickKeys=!0)},e.handleKeyRelease=function(t){return 18===t.keyCode?(void 0!==e.quickKeysTimer&&clearTimeout(e.quickKeysTimer),e.quickKeysTimer=setTimeout(function(){e.showQuickKeys&&(e.showQuickKeys=!1,e.$apply()),delete e.quickKeysTimer},1e3),!0):void 0}}]}})}(),function(){"use strict";var e=angular.module("weechat");e.directive("plugin",["$rootScope","settings",function(e,t){return{templateUrl:"directives/plugin.html",scope:{plugin:"=data"},controller:["$scope",function(n){n.displayedContent="",n.plugin.visible=!t.noembed&&!n.plugin.nsfw,n.plugin.className="embed_"+n.plugin.$$hashKey.replace(":","_"),n.plugin.getElement=function(){return document.querySelector("."+n.plugin.className)},n.hideContent=function(){n.plugin.visible=!1},n.showContent=function(t){var r=n.plugin.getElement();n.plugin.content instanceof Function?r&&""!==r.innerHTML||setTimeout(function(){n.plugin.content()}):n.displayedContent=n.plugin.content,n.plugin.visible=!0;var i;if(t){var o=e.bufferBottom;i=function(){e.updateBufferBottom(o)}}else i=function(){r&&void 0!==r.scrollIntoViewIfNeeded&&(r.scrollIntoViewIfNeeded(),e.updateBufferBottom())};setTimeout(i,500)},n.plugin.visible&&n.showContent(!0)}]}}])}(),function(){"use strict";var e=angular.module("ngWebsockets",[]);e.factory("ngWebsockets",["$rootScope","$q",function(e,t){var n=null,r=null,i={},o=0,a=function(e){for(var t in i)i[t].cb.reject(e)},c=function(){return o+=1,o>1e3&&(o=0),o},s=function(e){var t=u(e);return e=n.setId(t.id,e),r.send(e),t.promise},u=function(){var e=t.defer(),n=c();return i[n]={time:new Date,cb:e},e.id=n,e},l=function(e){var n=[];for(var r in e){var i=s(e[r]);n.push(i)}return t.all(n)},f=function(t){var r=n.parse(t.data);if(_.has(i,r.id)){var o=i[r.id];o.cb.resolve(r),delete i[r.id]}else e.$emit("onMessage",r);e.$apply()},d=function(e,t,i){r=new WebSocket(e),n=t;for(var o in i)r[o]=i[o];"onmessage"in i?r.onmessage=function(e){i.onmessage(e),f(e)}:r.onmessage=f},m=function(){r.close()};return{send:s,sendAll:l,connect:d,disconnect:m,failCallbacks:a}}])}(),function(){"use strict";var e=angular.module("weechatModels",[]);e.service("models",["$rootScope","$filter",function(e,t){function n(e,t){if(t in e&&e[t]&&e[t].length>0){var n=e[t];if(n.match(/^weechat/)){var r=n.match(/[a-zA-Z0-9_]+$/)[0];return["cof-"+r,"cob-"+r,"coa-"+r]}if(n.match(/^[a-zA-Z]+$/))return["cwf-"+n];if(n.match(/^[0-9]+$/))return["cef-"+n]}return["cwf-default"]}function r(e){return{name:n(e,"color"),prefix:n(e,"prefix_color")}}this.version=null,this.wconfig={},this.outgoingQueries=[];var i=function(e){var t=weeChat.Protocol.rawText2Rich(e),n={option:"cof-",weechat:"cwf-",ext:"cef-"},r={option:"cob-",weechat:"cwb-",ext:"ceb-"};return t.forEach(function(e){e.classes=[];var t=n[e.fgColor.type];e.classes.push(t+e.fgColor.name),t=r[e.bgColor.type],e.classes.push(t+e.bgColor.name),null!==e.attrs.name&&e.classes.push("coa-"+e.attrs.name);var i,o;for(i in e.attrs.override)o=e.attrs.override[i],o?e.classes.push("a-"+i):e.classes.push("a-no-"+i)}),t};this.parseRichText=i,this.Buffer=function(e){var t=e.full_name,n=e.short_name,r=e.hidden,o=n.replace(/^[#&+]/,"")||(n?" ":null),a=["#","&","+"].indexOf(n.charAt(0))>=0?n.charAt(0):"",c=i(e.title),s=e.number,u=e.pointers[0],l=3,f=[],d=0,m={},h=[],g=0,p=0,v=0,b=-1,y=e.type,w=e.local_variables.type,C=["channel","private"].indexOf(w)>=0,k=e.local_variables.plugin,S=e.local_variables.server,x=k+"."+S+("server"===w?"":"."+n);x=x.toLowerCase(),void 0!==e.notify&&(l=e.notify);for(var B="",T=0;T=h.length&&h.push(e),0>=g||g>=h.length)return e;g--;var t=h[g];return t},j=function(e){return g===h.length?(void 0!==e&&""!==e&&(h.push(e),g++),""):0>g||g>h.length?e:(g++,h.length>0&&g==h.length-1?h.pop():h[g])},L=function(){for(var e in m)if("root"!==e)return!1;return!0},P=function(){return m.hasOwnProperty("root")},O=function(){for(;f.length>0;)f.pop();d=0};return{id:u,fullName:t,shortName:n,hidden:r,trimmedName:o,prefix:a,number:s,title:c,rtitle:B,lines:f,clear:O,requestedLines:d,addLine:A,lastSeen:b,unread:v,notification:p,notify:l,nicklist:m,addNick:N,delNick:M,updateNick:$,getNicklistByTime:I,serverSortKey:x,indent:C,bufferType:y,type:w,plugin:k,server:S,history:h,addToHistory:H,getHistoryUp:D,getHistoryDown:j,isNicklistEmpty:L,nicklistRequested:P}},this.BufferLine=function(e){var n=e.buffer,r=e.date,o=t("date")(r,"HH:mm"),a=i(e.prefix),c=e.tags_array,s=e.displayed,u=e.highlight,l=i(e.message);u&&a.forEach(function(e){e.classes.push("highlight")});for(var f="",d=0;d=1?"0x"+o.id:o.fullName},this.getPreviousBuffer=function(){return a},this.setActiveBuffer=function(t,n){if(void 0===n&&(n="id"),a=this.getActiveBuffer(),o="id"===n?this.model.buffers[t]:_.find(this.model.buffers,function(e){return e[n]===t?e:void 0}),void 0===o)return o=a,!1;a&&(a.active=!1,a.lastSeen=a.lines.length-1);var r=o.unread+o.notification;return o.active=!0,o.unread=0,o.notification=0,e.$emit("activeBufferChanged",r),e.$emit("notificationChanged"),!0},this.getBuffers=function(){return this.model.buffers},this.reinitialize=function(){this.model.buffers={}},this.getBuffer=function(e){return this.model.buffers[e]},this.closeBuffer=function(e){var t=this.getBuffer(e);if(void 0!==t){if(t.active){var n=_.keys(this.model.buffers)[0];this.setActiveBuffer(n)}delete this.model.buffers[e]}}}])}(),function(){"use strict";var e=angular.module("plugins",[]),t=function(e,t){return{contentForMessage:t,exclusive:!1,name:e}},n=/(?:(?:https?|ftp):\/\/|www\.|ftp\.)\S*[^\s.;,(){}<>]/g,r=function(e,t){return{contentForMessage:function(e){for(var r=e.match(n),i=[],o=0;r&&o=0;s--){var u=1==c.length?void 0:s+1;i(c[s],e[o].name,u)}else i(c,e[o].name);if(e[o].exclusive)break}}return n};return{registerPlugins:n,contentForMessage:i}};this.PluginManager=new n,this.PluginManager.registerPlugins(e.plugins)}]),e.factory("userPlugins",function(){var e=function(e,t){var n="jsonp_callback_"+Math.round(1e5*Math.random());window[n]=function(e){delete window[n],document.body.removeChild(r),t(e)};var r=document.createElement("script");r.src=e+(e.indexOf("?")>=0?"&":"?")+"callback="+n,document.body.appendChild(r)},n=new t("Spotify track",function(e){var t=[],n=function(e){for(var n=0;e&&n").attr("src","//embed.spotify.com/?uri=spotify:track:"+r).attr("width","300").attr("height","80").attr("frameborder","0").attr("allowtransparency","true");t.push(i.prop("outerHTML"))}};return n(e.match(/spotify:track:([a-zA-Z-0-9]{22})/g)),n(e.match(/open.spotify.com\/track\/([a-zA-Z-0-9]{22})/g)),t}),i=new r("YouTube video",function(e){var t=/(?:youtube.com|youtu.be)\/(?:v\/|embed\/|watch(?:\?v=|\/))?([a-zA-Z0-9-]+)/i,n=e.match(t);if(n){var r=n[1],i="https://www.youtube.com/embed/"+r+"?html5=1&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0",o=angular.element("").attr("src",i).attr("width","560").attr("height","315").attr("frameborder","0").attr("allowfullscreen","true");return o.prop("outerHTML")}}),o=new t("Dailymotion video",function(e){var t=/dailymotion.com\/.*video\/([^_?# ]+)/,n=/dailymotion.com\/.*#video=([^_& ]+)/,r=/dai.ly\/([^_?# ]+)/,i=e.match(t)||e.match(n)||e.match(r);if(i){var o=i[1],a="https://www.dailymotion.com/embed/video/"+o+"?html&controls=html&startscreen=html&info=0&logo=0&related=0",c=angular.element("").attr("src",a).attr("width","480").attr("height","270").attr("frameborder","0");return c.prop("outerHTML")}return null}),a=new t("AlloCine video",function(e){var t=/allocine.fr\/videokast\/video-(\d+)/,n=/allocine.fr\/.*cmedia=(\d+)/,r=e.match(t)||e.match(n);if(r){var i=r[1],o="http://www.allocine.fr/_video/iblogvision.aspx?cmedia="+i,a=angular.element("").attr("src",o).attr("width","480").attr("height","270").attr("frameborder","0");return a.prop("outerHTML")}return null}),c=new r("image",function(e){if(e.match(/\.(png|gif|jpg|jpeg)(:(small|medium|large))?\b/i)){if(-1!=e.indexOf("^https?://fukung.net/v/"))e=e.replace(/.*\//,"http://media.fukung.net/imgs/");else if(e.match(/^http:\/\/(i\.)?imgur\.com\//i))e=e.replace(/http:/,"");else if(e.match(/^https:\/\/www\.dropbox\.com\/s\/[a-z0-9]+\//i)){var t=document.createElement("a");t.href=e;for(var n=t.protocol+"//"+t.host+t.pathname+"?",r=t.search.substring(1).split("&"),i=!1,o=0;o").attr("target","_blank").attr("href",e).append(angular.element("").addClass("embed").attr("src",e));t.innerHTML=n.prop("outerHTML")}}}),s=new r("audio",function(e){return e.match(/\.(mp3|ogg|wav)\b/i)?function(){var t=this.getElement(),n=angular.element("").addClass("embed").attr("width","560").append(angular.element("").attr("src",e));t.innerHTML=n.prop("outerHTML")}:void 0}),u=new r("video",function(e){return e.match(/\.(mp4|webm|ogv|gifv)\b/i)?(e.match(/^http:\/\/(i\.)?imgur\.com\//i)&&(e=e.replace(/\.(gifv)\b/i,".webm")),function(){var t=this.getElement(),n=angular.element("").addClass("embed").attr("width","560").append(angular.element("").attr("src",e));t.innerHTML=n.prop("outerHTML")}):void 0}),l=new r("cloud music",function(e){var t;return e.match(/^https?:\/\/soundcloud.com\//)?(t=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"),t.prop("outerHTML")):e.match(/^https?:\/\/([a-z]+\.)?mixcloud.com\//)?(t=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="),t.prop("outerHTML")):void 0}),f=new r("Google Map",function(e){if(e.match(/^https?:\/\/maps\.google\./i)||e.match(/^https?:\/\/(?:[\w]+\.)?google\.[\w]+\/maps/i)){var t=angular.element("").attr("width","450").attr("height","350").attr("frameborder","0").attr("scrolling","no").attr("marginheight","0").attr("src",e+"&output=embed");return t.prop("outerHTML")}}),d=new r("ascii cast",function(e){var t=/^https?:\/\/(?:www\.)?asciinema.org\/a\/(\d+)/i,n=e.match(t);if(n){var r=n[1];return function(){var e=this.getElement(),t=document.createElement("script");t.src="https://asciinema.org/a/"+r+".js",t.id="asciicast-"+r,t.async=!0,e.appendChild(t)}}}),m=new r("meteogram",function(e){var t=/^https?:\/\/(?:www\.)?yr\.no\/(place|stad|sted|sadji|paikka)\/(([^\s.;,(){}<>\/]+\/){3,})/,n=e.match(t);return n?function(){var t=this.getElement(),r=n[1],i=n[2],o=n[n.length-1].slice(0,-1);e="http://www.yr.no/"+r+"/"+i+"avansert_meteogram.png";var a=angular.element("").attr("src",e).attr("alt","Meteogram for "+o);t.innerHTML=a.prop("outerHTML")}:void 0}),h=new r("Gist",function(t){var n=/^https:\/\/gist\.github.com\/[^.?]+/i,r=t.match(n);return r?(t=r[0]+".json",function(){var n=this.getElement();e(t,function(e){if(document.querySelectorAll('link[rel=stylesheet][href="'+e.stylesheet+'"]').length<1){var t='';document.getElementsByTagName("head")[0].innerHTML+=t}n.innerHTML='
'+e.div+"
"})}):void 0}),g=new r("Giphy",function(e){var t=/^https?:\/\/giphy.com\/gifs\/.*-(.*)\/?/i,n=e.match(t);if(n){var r="https://media.giphy.com/media/"+n[1]+"/giphy.gif";return function(){var t=this.getElement(),n=angular.element("").attr("target","_blank").attr("href",e).append(angular.element("").addClass("embed").attr("src",r));t.innerHTML=n.prop("outerHTML")}}}),p=new r("Tweet",function(t){var n=/^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)/i,r=t.match(n);return r?(t="https://api.twitter.com/1/statuses/oembed.json?id="+r[2],function(){var n=this.getElement();e(t,function(e){var t=e.html.indexOf("'}});return{plugins:[i,o,a,c,u,s,n,l,f,d,m,h,g,p,v]}})}(),function(){"use strict";var e=angular.module("weechat");e.factory("imgur",["$rootScope",function(e){var t=function(e,t){if(e&&e.type.match(/image.*/)){var r=new FileReader;r.onload=function(e){var r=e.target.result.split(",")[1];n(r,t)},r.readAsDataURL(e)}},n=function(e,t){var n="164efef8979cd4b",i=document.getElementById("imgur-upload-progress"),o=document.createElement("div"); -o.className="imgur-progress-bar",o.style.width="0",i.appendChild(o);var a=new FormData;a.append("image",e),a.append("type","base64");var c=new XMLHttpRequest;c.open("POST","https://api.imgur.com/3/image",!0),c.setRequestHeader("Authorization","Client-ID "+n),c.setRequestHeader("Accept","application/json"),c.onload=function(){if(o.parentNode.removeChild(o),200===c.status){var e=JSON.parse(c.responseText);e.data&&e.data.link?t&&"function"==typeof t&&t(e.data.link):r()}else r()},"upload"in c&&(c.upload.onprogress=function(e){if(e.lengthComputable){var t=e.loaded/e.total*100|0;o.style.width=t+"%"}}),c.send(a)},r=function(){e.uploadError=!0,e.$apply(),setTimeout(function(){e.uploadError=!1,e.$apply()},5e3)};return{process:t}}])}(); -//# sourceMappingURL=min.map \ No newline at end of file +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(){var g=function(t,e){var n=null;return e.some(function(e){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&(n=e,!0)}),n},p=function(e,t,n){for(var i=[],r=null,o=e.toLowerCase(),a=t.toLowerCase(),s=0;s "+t.text}(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("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}})}(),function(){"use strict";angular.module("weechat").factory("handlers",["$rootScope","$log","models","plugins","notifications","bufferResume",function(l,c,f,s,u,a){var d=function(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)}},h=function(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-=1),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+"'"},t=v.wconfig["weechat.look.buffer_time_format"],n="",i=e(":"),r="hh"+i+"mm",o="' 'a",a=r+o,s=r+i+"ss"+o,c="HH"+i+"mm",u=c+i+"ss";n=-1b.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(C.command.length,C.command.length);else if(85==n)C.command=C.command.slice(s),setTimeout(function(){t.setSelectionRange(0,0)});else if(75==n)C.command=C.command.slice(0,s),setTimeout(function(){t.setSelectionRange(C.command.length,C.command.length)});else{if(87!=n)return!1;var y=C.command.slice(0,s).replace(/\s+$/,"").lastIndexOf(" ")+1;C.command=C.command.slice(0,y)+C.command.slice(s,C.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},C.handleCompleteNickButton=function(e){return e.preventDefault(),C.completeNick(),setTimeout(function(){C.getInputNode().focus()},0),!0},C.inputPasted=function(e){if(e.clipboardData&&e.clipboardData.files&&e.clipboardData.files.length){e.stopPropagation(),e.preventDefault();for(var t=function(e){void 0!==e&&""!==e&&w.insertAtCaret(String(e))},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,c=function(e,o){return{contentForMessage:function(e){for(var t=_.uniq(e.match(a)),n=[],i=0;t&&i").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"))}};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.getElementsByTagName("head")[0].innerHTML+=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("