Skip to content

Instantly share code, notes, and snippets.

@blubbll
Last active January 5, 2020 00:07
Show Gist options
  • Save blubbll/bbbe1cd744e4ad4e1a8086e7e6f3a849 to your computer and use it in GitHub Desktop.
Save blubbll/bbbe1cd744e4ad4e1a8086e7e6f3a849 to your computer and use it in GitHub Desktop.
bcsocket.js
!function(){var f,aa=aa||{},l=this;function ba(t){t=t.split(".");for(var e,n=l;e=t.shift();){if(null==n[e])return null;n=n[e]}return n}function ca(){}function da(t){var e=typeof t;if("object"==e){if(!t)return"null";if(t instanceof Array)return"array";if(t instanceof Object)return e;var n=Object.prototype.toString.call(t);if("[object Window]"==n)return"object";if("[object Array]"==n||"number"==typeof t.length&&void 0!==t.splice&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("splice"))return"array";if("[object Function]"==n||void 0!==t.call&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("call"))return"function"}else if("function"==e&&void 0===t.call)return"object";return e}function m(t){return"array"==da(t)}function ea(t){var e=da(t);return"array"==e||"object"==e&&"number"==typeof t.length}function n(t){return"string"==typeof t}function fa(t){return"function"==da(t)}var ga="closure_uid_"+(1e9*Math.random()>>>0),ha=0;function ia(t,e,n){return t.call.apply(t.bind,arguments)}function ja(t,e,n){if(!t)throw Error();if(2<arguments.length){var i=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,i),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function p(t,e,n){return(p=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ia:ja).apply(null,arguments)}var q=Date.now||function(){return+new Date};function s(t,e){function n(){}n.prototype=e.prototype,t.pa=e.prototype,t.prototype=new n,t.Hc=function(t,n,i){var a=Array.prototype.slice.call(arguments,2);return e.prototype[n].apply(t,a)}}function ka(t,e){for(var n=t.split("%s"),i="",a=Array.prototype.slice.call(arguments,1);a.length&&1<n.length;)i+=n.shift()+a.shift();return i+n.join("%s")}function la(t){return ma.test(t)?(-1!=t.indexOf("&")&&(t=t.replace(na,"&amp;")),-1!=t.indexOf("<")&&(t=t.replace(oa,"&lt;")),-1!=t.indexOf(">")&&(t=t.replace(pa,"&gt;")),-1!=t.indexOf('"')&&(t=t.replace(qa,"&quot;")),-1!=t.indexOf("'")&&(t=t.replace(ra,"&#39;")),t):t}var na=/&/g,oa=/</g,pa=/>/g,qa=/"/g,ra=/'/g,ma=/[&<>"']/,x,ua,va,wa,ya;function sa(){return Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^q()).toString(36)}function ta(t,e){return t<e?-1:t>e?1:0}function xa(){return l.navigator?l.navigator.userAgent:null}if(wa=va=ua=x=!1,ya=xa()){var za=l.navigator;x=0==ya.lastIndexOf("Opera",0),ua=!x&&(-1!=ya.indexOf("MSIE")||-1!=ya.indexOf("Trident")),va=!x&&-1!=ya.indexOf("WebKit"),wa=!x&&!va&&!ua&&"Gecko"==za.product}var Aa=x,y=ua,Ba=wa,z=va,Da;function Ca(){var t=l.document;return t?t.documentMode:void 0}t:{var Ea="",Fa;if(Aa&&l.opera)var Ga=l.opera.version,Ea="function"==typeof Ga?Ga():Ga;else if(Ba?Fa=/rv\:([^\);]+)(\)|;)/:y?Fa=/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/:z&&(Fa=/WebKit\/(\S+)/),Fa)var Ha=Fa.exec(xa()),Ea=Ha?Ha[1]:"";if(y){var Ia=Ca();if(Ia>parseFloat(Ea)){Da=String(Ia);break t}}Da=Ea}var Ja={};function A(t){var e;if(!(e=Ja[t])){e=0;for(var n=String(Da).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),i=String(t).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),a=Math.max(n.length,i.length),r=0;0==e&&r<a;r++){var s=n[r]||"",o=i[r]||"",h=RegExp("(\\d*)(\\D*)","g"),c=RegExp("(\\d*)(\\D*)","g");do{var u=h.exec(s)||["","",""],l=c.exec(o)||["","",""];if(0==u[0].length&&0==l[0].length)break;e=ta(0==u[1].length?0:parseInt(u[1],10),0==l[1].length?0:parseInt(l[1],10))||ta(0==u[2].length,0==l[2].length)||ta(u[2],l[2])}while(0==e)}e=Ja[t]=0<=e}return e}var La=l.document,Ma=La&&y?Ca()||("CSS1Compat"==La.compatMode?parseInt(Da,10):5):void 0;function Na(t){Error.captureStackTrace?Error.captureStackTrace(this,Na):this.stack=Error().stack||"",t&&(this.message=String(t))}function Oa(t,e){e.unshift(t),Na.call(this,ka.apply(null,e)),e.shift()}function Pa(t,e){throw new Oa("Failure"+(t?": "+t:""),Array.prototype.slice.call(arguments,1))}s(Na,Error),Na.prototype.name="CustomError",s(Oa,Na),Oa.prototype.name="AssertionError";var Qa=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#(.*))?$");function Ra(t){if(Sa){Sa=!1;var e=l.location;if(e){var n=e.href;if(n&&(n=(n=Ra(n)[3]||null)&&decodeURIComponent(n))&&n!=e.hostname)throw Sa=!0,Error()}}return t.match(Qa)}var Sa=z;function Ta(t){var e,n=[],i=0;for(e in t)n[i++]=t[e];return n}function Ua(t){var e,n=[],i=0;for(e in t)n[i++]=e;return n}var Va="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Wa(t,e){for(var n,i,a=1;a<arguments.length;a++){for(n in i=arguments[a])t[n]=i[n];for(var r=0;r<Va.length;r++)n=Va[r],Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}}var B=Array.prototype,Xa=B.indexOf?function(t,e,n){return B.indexOf.call(t,e,n)}:function(t,e,i){if(i=null==i?0:0>i?Math.max(0,t.length+i):i,n(t))return n(e)&&1==e.length?t.indexOf(e,i):-1;for(;i<t.length;i++)if(i in t&&t[i]===e)return i;return-1},Ya=B.forEach?function(t,e,n){B.forEach.call(t,e,n)}:function(t,e,i){for(var a=t.length,r=n(t)?t.split(""):t,s=0;s<a;s++)s in r&&e.call(i,r[s],s,t)};function Za(t){var e;t:{e=$a;for(var i=t.length,a=n(t)?t.split(""):t,r=0;r<i;r++)if(r in a&&e.call(void 0,a[r],r,t)){e=r;break t}e=-1}return 0>e?null:n(t)?t.charAt(e):t[e]}function ab(t){return B.concat.apply(B,arguments)}function bb(t){var e=t.length;if(0<e){for(var n=Array(e),i=0;i<e;i++)n[i]=t[i];return n}return[]}function cb(t,e){this.O={},this.j=[],this.o=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var i=0;i<n;i+=2)this.set(arguments[i],arguments[i+1])}else if(t){t instanceof cb?(n=t.ca(),i=t.N()):(n=Ua(t),i=Ta(t));for(var a=0;a<n.length;a++)this.set(n[a],i[a])}}function db(t){if(t.o!=t.j.length){for(var e=0,n=0;e<t.j.length;){var i=t.j[e];C(t.O,i)&&(t.j[n++]=i),e++}t.j.length=n}if(t.o!=t.j.length){var a={};for(n=e=0;e<t.j.length;)C(a,i=t.j[e])||(t.j[n++]=i,a[i]=1),e++;t.j.length=n}}function C(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function eb(t){if("function"==typeof t.N)return t.N();if(n(t))return t.split("");if(ea(t)){for(var e=[],i=t.length,a=0;a<i;a++)e.push(t[a]);return e}return Ta(t)}function D(t,e,i){if("function"==typeof t.forEach)t.forEach(e,i);else if(ea(t)||n(t))Ya(t,e,i);else{var a;if("function"==typeof t.ca)a=t.ca();else if("function"!=typeof t.N)if(ea(t)||n(t)){a=[];for(var r=t.length,s=0;s<r;s++)a.push(s)}else a=Ua(t);else a=void 0;s=(r=eb(t)).length;for(var o=0;o<s;o++)e.call(i,r[o],a&&a[o],t)}}function E(t,e){var n;if(t instanceof E)this.D=void 0!==e?e:t.D,fb(this,t.oa),n=t.eb,F(this),this.eb=n,gb(this,t.ja),hb(this,t.Ca),ib(this,t.I),jb(this,t.R.n()),n=t.Na,F(this),this.Na=n;else if(t&&(n=Ra(String(t)))){this.D=!!e,fb(this,n[1]||"",!0);var i=n[2]||"";F(this),this.eb=i?decodeURIComponent(i):"",gb(this,n[3]||"",!0),hb(this,n[4]),ib(this,n[5]||"",!0),jb(this,n[6]||"",!0),n=n[7]||"",F(this),this.Na=n?decodeURIComponent(n):""}else this.D=!!e,this.R=new kb(null,0,this.D)}function fb(t,e,n){F(t),t.oa=n?e?decodeURIComponent(e):"":e,t.oa&&(t.oa=t.oa.replace(/:$/,""))}function gb(t,e,n){F(t),t.ja=n?e?decodeURIComponent(e):"":e}function hb(t,e){if(F(t),e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.Ca=e}else t.Ca=null}function ib(t,e,n){F(t),t.I=n?e?decodeURIComponent(e):"":e}function jb(t,e,n){F(t),e instanceof kb?(t.R=e,t.R.ub(t.D)):(n||(e=lb(e,qb)),t.R=new kb(e,0,t.D))}function G(t,e,n){F(t),t.R.set(e,n)}function rb(t,e,n){F(t),m(n)||(n=[String(n)]),sb(t.R,e,n)}function H(t){return F(t),G(t,"zx",sa()),t}function F(t){if(t.oc)throw Error("Tried to modify a read-only Uri")}function tb(t){return t instanceof E?t.n():new E(t,void 0)}function ub(t,e,n,i){var a=new E(null,void 0);return t&&fb(a,t),e&&gb(a,e),n&&hb(a,n),i&&ib(a,i),a}function lb(t,e){return n(t)?encodeURI(t).replace(e,vb):null}function vb(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}f=cb.prototype,f.N=function(){db(this);for(var t=[],e=0;e<this.j.length;e++)t.push(this.O[this.j[e]]);return t},f.ca=function(){return db(this),this.j.concat()},f.wa=function(t){return C(this.O,t)},f.remove=function(t){return!!C(this.O,t)&&(delete this.O[t],this.o--,this.j.length>2*this.o&&db(this),!0)},f.get=function(t,e){return C(this.O,t)?this.O[t]:e},f.set=function(t,e){C(this.O,t)||(this.o++,this.j.push(t)),this.O[t]=e},f.n=function(){return new cb(this)},f=E.prototype,f.oa="",f.eb="",f.ja="",f.Ca=null,f.I="",f.Na="",f.oc=!1,f.D=!1,f.toString=function(){var t=[],e=this.oa;if(e&&t.push(lb(e,mb),":"),e=this.ja){t.push("//");var n=this.eb;n&&t.push(lb(n,mb),"@"),t.push(encodeURIComponent(String(e))),null!=(e=this.Ca)&&t.push(":",String(e))}return(e=this.I)&&(this.ja&&"/"!=e.charAt(0)&&t.push("/"),t.push(lb(e,"/"==e.charAt(0)?nb:ob))),(e=this.R.toString())&&t.push("?",e),(e=this.Na)&&t.push("#",lb(e,pb)),t.join("")},f.n=function(){return new E(this)},f.ub=function(t){return this.D=t,this.R&&this.R.ub(t),this};var mb=/[#\/\?@]/g,ob=/[\#\?:]/g,nb=/[\#\?]/g,qb=/[\#\?@]/g,pb=/#/g;function kb(t,e,n){this.C=t||null,this.D=!!n}function I(t){if(!t.h&&(t.h=new cb,t.o=0,t.C))for(var e=t.C.split("&"),n=0;n<e.length;n++){var i=e[n].indexOf("="),a=null,r=null;0<=i?(a=e[n].substring(0,i),r=e[n].substring(i+1)):a=e[n],a=J(t,a=decodeURIComponent(a.replace(/\+/g," "))),t.add(a,r?decodeURIComponent(r.replace(/\+/g," ")):"")}}function sb(t,e,n){t.remove(e),0<n.length&&(t.C=null,t.h.set(J(t,e),bb(n)),t.o+=n.length)}function J(t,e){var n=String(e);return t.D&&(n=n.toLowerCase()),n}function wb(a){if(a=String(a),!/^\s*$/.test(a)&&/^[\],:{}\s\u2028\u2029]*$/.test(a.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r\u2028\u2029\x00-\x08\x0a-\x1f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,"")))try{return eval("("+a+")")}catch(t){}throw Error("Invalid JSON string: "+a)}function xb(a){return eval("("+a+")")}function yb(t){var e=[];return zb(new Ab,t,e),e.join("")}function Ab(){this.Ya=void 0}function zb(t,e,n){switch(typeof e){case"string":Bb(e,n);break;case"number":n.push(isFinite(e)&&!isNaN(e)?e:"null");break;case"boolean":n.push(e);break;case"undefined":n.push("null");break;case"object":if(null==e){n.push("null");break}if(m(e)){var i=e.length;n.push("[");for(var a="",r=0;r<i;r++)n.push(a),a=e[r],zb(t,t.Ya?t.Ya.call(e,String(r),a):a,n),a=",";n.push("]");break}for(r in n.push("{"),i="",e)Object.prototype.hasOwnProperty.call(e,r)&&("function"!=typeof(a=e[r])&&(n.push(i),Bb(r,n),n.push(":"),zb(t,t.Ya?t.Ya.call(e,r,a):a,n),i=","));n.push("}");break;case"function":break;default:throw Error("Unknown type: "+typeof e)}}f=kb.prototype,f.h=null,f.o=null,f.add=function(t,e){I(this),this.C=null,t=J(this,t);var n=this.h.get(t);return n||this.h.set(t,n=[]),n.push(e),this.o++,this},f.remove=function(t){return I(this),t=J(this,t),!!this.h.wa(t)&&(this.C=null,this.o-=this.h.get(t).length,this.h.remove(t))},f.wa=function(t){return I(this),t=J(this,t),this.h.wa(t)},f.ca=function(){I(this);for(var t=this.h.N(),e=this.h.ca(),n=[],i=0;i<e.length;i++)for(var a=t[i],r=0;r<a.length;r++)n.push(e[i]);return n},f.N=function(t){I(this);var e=[];if(n(t))this.wa(t)&&(e=ab(e,this.h.get(J(this,t))));else{t=this.h.N();for(var i=0;i<t.length;i++)e=ab(e,t[i])}return e},f.set=function(t,e){return I(this),this.C=null,t=J(this,t),this.wa(t)&&(this.o-=this.h.get(t).length),this.h.set(t,[e]),this.o++,this},f.get=function(t,e){var n=t?this.N(t):[];return 0<n.length?String(n[0]):e},f.toString=function(){if(this.C)return this.C;if(!this.h)return"";for(var t=[],e=this.h.ca(),n=0;n<e.length;n++)for(var i=e[n],a=encodeURIComponent(String(i)),r=(i=this.N(i),0);r<i.length;r++){var s=a;""!==i[r]&&(s+="="+encodeURIComponent(String(i[r]))),t.push(s)}return this.C=t.join("&")},f.n=function(){var t=new kb;return t.C=this.C,this.h&&(t.h=this.h.n(),t.o=this.o),t},f.ub=function(t){t&&!this.D&&(I(this),this.C=null,D(this.h,function(t,e){var n=e.toLowerCase();e!=n&&(this.remove(e),sb(this,n,t))},this)),this.D=t};var Cb={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\u000b"},Db=/\uffff/.test("￿")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;function Bb(t,e){e.push('"',t.replace(Db,function(t){if(t in Cb)return Cb[t];var e=t.charCodeAt(0),n="\\u";return 16>e?n+="000":256>e?n+="00":4096>e&&(n+="0"),Cb[t]=n+e.toString(16)}),'"')}function Eb(t){return Fb(t||arguments.callee.caller,[])}function Fb(t,e){var n=[];if(0<=Xa(e,t))n.push("[...circular reference...]");else if(t&&50>e.length){n.push(Gb(t)+"(");for(var i=t.arguments,a=0;a<i.length;a++){var r;switch(0<a&&n.push(", "),typeof(r=i[a])){case"object":r=r?"object":"null";break;case"string":break;case"number":r=String(r);break;case"boolean":r=r?"true":"false";break;case"function":r=(r=Gb(r))?r:"[fn]";break;default:r=typeof r}40<r.length&&(r=r.substr(0,40)+"..."),n.push(r)}e.push(t),n.push(")\n");try{n.push(Fb(t.caller,e))}catch(t){n.push("[exception trying to get caller]\n")}}else t?n.push("[...long stack...]"):n.push("[end]");return n.join("")}function Gb(t){if(Hb[t])return Hb[t];if(t=String(t),!Hb[t]){var e=/function ([^\(]+)/.exec(t);Hb[t]=e?e[1]:"[Anonymous]"}return Hb[t]}var Hb={};function Ib(t,e,n,i,a){this.reset(t,e,n,i,a)}Ib.prototype.Fb=null,Ib.prototype.Eb=null;var Jb=0;function L(t){this.rc=t}function Kb(t,e){this.name=t,this.value=e}Ib.prototype.reset=function(t,e,n,i,a){"number"==typeof a||Jb++,i||q(),this.Aa=t,this.qc=e,delete this.Fb,delete this.Eb},Ib.prototype.$b=function(t){this.Aa=t},L.prototype.Sa=null,L.prototype.Aa=null,L.prototype.jb=null,L.prototype.Jb=null,Kb.prototype.toString=function(){return this.name};var Lb=new Kb("SEVERE",1e3),Mb=new Kb("WARNING",900),Nb=new Kb("INFO",800),Ob=new Kb("CONFIG",700),Pb=new Kb("FINE",500);function Qb(t){return t.Aa?t.Aa:t.Sa?Qb(t.Sa):(Pa("Root logger has no level set."),null)}f=L.prototype,f.getParent=function(){return this.Sa},f.$b=function(t){this.Aa=t},f.log=function(t,e,n){if(t.value>=Qb(this).value&&debug)for(fa(e)&&(e=e()),e="log:"+(t=this.mc(t,e,n)).qc,l.console&&(l.console.timeStamp?l.console.timeStamp(e):l.console.markTimeline&&l.console.markTimeline(e)),l.msWriteProfilerMark&&l.msWriteProfilerMark(e),e=this;e;){var i=t;if((n=e).Jb)for(var a=0,r=void 0;r=n.Jb[a];a++)r(i);e=e.getParent()}},f.mc=function(t,e,i){var a=new Ib(t,String(e),this.rc);if(i){var r;a.Fb=i;var s=arguments.callee.caller;try{var o,h=ba("window.location.href");if(n(i))o={message:i,name:"Unknown error",lineNumber:"Not available",fileName:h,stack:"Not available"};else{var c,u,f=!1;try{c=i.lineNumber||i.Ic||"Not available"}catch(t){c="Not available",f=!0}try{u=i.fileName||i.filename||i.sourceURL||l.$googDebugFname||h}catch(t){u="Not available",f=!0}o=!f&&i.lineNumber&&i.fileName&&i.stack&&i.message&&i.name?i:{message:i.message||"Not available",name:i.name||"UnknownError",lineNumber:c,fileName:u,stack:i.stack||"Not available"}}r="Message: "+la(o.message)+'\nUrl: <a href="view-source:'+o.fileName+'" target="_new">'+o.fileName+"</a>\nLine: "+o.lineNumber+"\n\nBrowser stack:\n"+la(o.stack+"-> ")+"[end]\n\nJS stack traversal:\n"+la(Eb(s)+"-> ")}catch(t){r="Exception trying to expose exception! You win, we lose. "+t}a.Eb=r}return a},f.J=function(t,e){this.log(Lb,t,e)},f.Z=function(t,e){this.log(Mb,t,e)},f.info=function(t,e){this.log(Nb,t,e)};var Rb={},Sb=null;function Tb(t){var e;if(Sb||(Sb=new L(""),Rb[""]=Sb,Sb.$b(Ob)),!(e=Rb[t])){e=new L(t);var n=t.lastIndexOf("."),i=t.substr(n+1);(n=Tb(t.substr(0,n))).jb||(n.jb={}),n.jb[i]=e,e.Sa=n,Rb[t]=e}return e}function M(t,e){t&&t.log(Pb,e,void 0)}function N(){this.r=Tb("goog.net.BrowserChannel")}function Ub(t,e,n,i){t.info("XMLHTTP TEXT ("+e+"): "+Vb(t,n)+(i?" "+i:""))}function Wb(t,e,n){t.J((n||"Exception")+e)}function Vb(t,e){if(!e||e==Xb)return e;try{var n=xb(e);if(n)for(var i=0;i<n.length;i++)if(m(n[i])){var a=n[i];if(!(2>a.length)){var r=a[1];if(m(r)&&!(1>r.length)){var s=r[0];if("noop"!=s&&"stop"!=s)for(var o=1;o<r.length;o++)r[o]=""}}}return yb(n)}catch(n){return t.debug("Exception parsing expected JS array - probably was not JS"),e}}function Yb(t,e){this.P=e?xb:wb}function O(){0!=Zb&&($b[this[ga]||(this[ga]=++ha)]=this)}N.prototype.debug=function(t){this.info(t)},N.prototype.info=function(t){var e=this.r;e&&e.info(t,void 0)},N.prototype.Z=function(t){var e=this.r;e&&e.Z(t,void 0)},N.prototype.J=function(t){var e=this.r;e&&e.J(t,void 0)},Yb.prototype.parse=function(t){return this.P(t)};var Zb=0,$b={};O.prototype.mb=!1,O.prototype.Ja=function(){if(!this.mb&&(this.mb=!0,this.u(),0!=Zb)){var t=this[ga]||(this[ga]=++ha);delete $b[t]}},O.prototype.u=function(){if(this.Pb)for(;this.Pb.length;)this.Pb.shift()()};var ac="closure_listenable_"+(1e6*Math.random()|0);function bc(t){try{return!(!t||!t[ac])}catch(t){return!1}}var cc=0;function dc(t,e,n,i,a){this.fa=t,this.Ua=null,this.src=e,this.type=n,this.capture=!!i,this.Oa=a,this.key=++cc,this.na=this.Ia=!1}function ec(t){t.na=!0,t.fa=null,t.Ua=null,t.src=null,t.Oa=null}function P(t){this.src=t,this.s={},this.Ga=0}function gc(t,e){var n=e.type;if(!(n in t.s))return!1;var i,a=t.s[n],r=Xa(a,e);return(i=0<=r)&&B.splice.call(a,r,1),i&&(ec(e),0==t.s[n].length&&(delete t.s[n],t.Ga--)),i}function fc(t,e,n,i){for(var a=0;a<t.length;++a){var r=t[a];if(!r.na&&r.fa==e&&r.capture==!!n&&r.Oa==i)return a}return-1}P.prototype.add=function(t,e,n,i,a){var r=this.s[t];r||(r=this.s[t]=[],this.Ga++);var s=fc(r,e,i,a);return-1<s?(t=r[s],n||(t.Ia=!1)):((t=new dc(e,this.src,t,!!i,a)).Ia=n,r.push(t)),t},P.prototype.remove=function(t,e,n,i){if(!(t in this.s))return!1;var a=this.s[t];return-1<(e=fc(a,e,n,i))&&(ec(a[e]),B.splice.call(a,e,1),0==a.length&&(delete this.s[t],this.Ga--),!0)},P.prototype.Xa=function(t){var e,n=0;for(e in this.s)if(!t||e==t){for(var i=this.s[e],a=0;a<i.length;a++)++n,ec(i[a]);delete this.s[e],this.Ga--}return n},P.prototype.ya=function(t,e,n,i){var a=-1;return(t=this.s[t])&&(a=fc(t,e,n,i)),-1<a?t[a]:null};var hc=!y||y&&9<=Ma,ic=y&&!A("9");function Q(t,e){this.type=t,this.currentTarget=this.target=e}function jc(t){return jc[" "](t),t}function kc(t,e){if(Q.call(this,t?t.type:""),this.relatedTarget=this.currentTarget=this.target=null,this.charCode=this.keyCode=this.button=this.screenY=this.screenX=this.clientY=this.clientX=this.offsetY=this.offsetX=0,this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.Db=this.state=null,t){var n=this.type=t.type;this.target=t.target||t.srcElement,this.currentTarget=e;var i=t.relatedTarget;if(i){if(Ba){var a;t:{try{jc(i.nodeName),a=!0;break t}catch(t){}a=!1}a||(i=null)}}else"mouseover"==n?i=t.fromElement:"mouseout"==n&&(i=t.toElement);this.relatedTarget=i,this.offsetX=z||void 0!==t.offsetX?t.offsetX:t.layerX,this.offsetY=z||void 0!==t.offsetY?t.offsetY:t.layerY,this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0,this.button=t.button,this.keyCode=t.keyCode||0,this.charCode=t.charCode||("keypress"==n?t.keyCode:0),this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.state=t.state,this.Db=t,t.defaultPrevented&&this.preventDefault(),delete this.ga}}!z||A("528"),Ba&&A("1.9b")||y&&A("8")||Aa&&A("9.5")||z&&A("528"),Ba&&!A("8")||y&&A("9"),f=Q.prototype,f.u=function(){},f.Ja=function(){},f.ga=!1,f.defaultPrevented=!1,f.Yb=!0,f.preventDefault=function(){this.defaultPrevented=!0,this.Yb=!1},jc[" "]=ca,s(kc,Q),kc.prototype.preventDefault=function(){kc.pa.preventDefault.call(this);var t=this.Db;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,ic)try{(t.ctrlKey||112<=t.keyCode&&123>=t.keyCode)&&(t.keyCode=-1)}catch(t){}},kc.prototype.u=function(){};var lc="closure_lm_"+(1e6*Math.random()|0),mc={},nc=0;function oc(t,e,n,i,a){if(m(e)){for(var r=0;r<e.length;r++)oc(t,e[r],n,i,a);return null}if(n=pc(n),bc(t))t=t.Ra(e,n,i,a);else{if(!e)throw Error("Invalid event type");r=!!i;var s=qc(t);s||(t[lc]=s=new P(t)),(n=s.add(e,n,!1,i,a)).Ua||(i=rc(),n.Ua=i,i.src=t,i.fa=n,t.addEventListener?t.addEventListener(e,i,r):t.attachEvent(e in mc?mc[e]:mc[e]="on"+e,i),nc++),t=n}return t}function rc(){var t=sc,e=hc?function(n){return t.call(e.src,e.fa,n)}:function(n){if(!(n=t.call(e.src,e.fa,n)))return n};return e}function tc(t,e,n,i,a){if(m(e))for(var r=0;r<e.length;r++)tc(t,e[r],n,i,a);else n=pc(n),bc(t)?t.vb(e,n,i,a):t&&(t=qc(t))&&(e=t.ya(e,n,!!i,a))&&uc(e)}function uc(t){if("number"==typeof t||!t||t.na)return!1;var e=t.src;if(bc(e))return gc(e.W,t);var n=t.type,i=t.Ua;return e.removeEventListener?e.removeEventListener(n,i,t.capture):e.detachEvent&&e.detachEvent(n in mc?mc[n]:mc[n]="on"+n,i),nc--,(n=qc(e))?(gc(n,t),0==n.Ga&&(n.src=null,e[lc]=null)):ec(t),!0}function vc(t,e,n,i){var a=1;if((t=qc(t))&&(e=t.s[e]))for(e=bb(e),t=0;t<e.length;t++){var r=e[t];r&&r.capture==n&&!r.na&&(a&=!1!==wc(r,i))}return Boolean(a)}function wc(t,e){var n=t.fa,i=t.Oa||t.src;return t.Ia&&uc(t),n.call(i,e)}function sc(t,e){if(t.na)return!0;if(!hc){var n=e||ba("window.event"),i=new kc(n,this),a=!0;if(!(0>n.keyCode||null!=n.returnValue)){t:{var r=!1;if(0==n.keyCode)try{n.keyCode=-1;break t}catch(t){r=!0}(r||null==n.returnValue)&&(n.returnValue=!0)}for(n=[],r=i.currentTarget;r;r=r.parentNode)n.push(r);r=t.type;for(var s=n.length-1;!i.ga&&0<=s;s--)i.currentTarget=n[s],a&=vc(n[s],r,!0,i);for(s=0;!i.ga&&s<n.length;s++)i.currentTarget=n[s],a&=vc(n[s],r,!1,i)}return a}return wc(t,new kc(e,this))}function qc(t){return(t=t[lc])instanceof P?t:null}var xc="__closure_events_fn_"+(1e9*Math.random()>>>0);function pc(t){return fa(t)?t:t[xc]||(t[xc]=function(e){return t.handleEvent(e)})}function R(){O.call(this),this.W=new P(this),this.fc=this}function yc(t,e,n,i){if(!(e=t.W.s[String(e)]))return!0;e=bb(e);for(var a=!0,r=0;r<e.length;++r){var s=e[r];if(s&&!s.na&&s.capture==n){var o=s.fa,h=s.Oa||s.src;s.Ia&&gc(t.W,s),a=!1!==o.call(h,i)&&a}}return a&&0!=i.Yb}function zc(t,e){R.call(this),this.ea=t||1,this.ra=e||l,this.ib=p(this.Gc,this),this.sb=q()}s(R,O),R.prototype[ac]=!0,f=R.prototype,f.tb=null,f.addEventListener=function(t,e,n,i){oc(this,t,e,n,i)},f.removeEventListener=function(t,e,n,i){tc(this,t,e,n,i)},f.dispatchEvent=function(t){var e;if(i=this.tb)for(e=[];i;i=i.tb)e.push(i);var i=this.fc,a=t.type||t;if(n(t))t=new Q(t,i);else if(t instanceof Q)t.target=t.target||i;else{var r=t;Wa(t=new Q(a,i),r)}var s;r=!0;if(e)for(var o=e.length-1;!t.ga&&0<=o;o--)r=yc(s=t.currentTarget=e[o],a,!0,t)&&r;if(t.ga||(r=yc(s=t.currentTarget=i,a,!0,t)&&r,t.ga||(r=yc(s,a,!1,t)&&r)),e)for(o=0;!t.ga&&o<e.length;o++)r=yc(s=t.currentTarget=e[o],a,!1,t)&&r;return r},f.u=function(){R.pa.u.call(this),this.W&&this.W.Xa(void 0),this.tb=null},f.Ra=function(t,e,n,i){return this.W.add(String(t),e,!1,n,i)},f.vb=function(t,e,n,i){return this.W.remove(String(t),e,n,i)},f.ya=function(t,e,n,i){return this.W.ya(String(t),e,n,i)},s(zc,R),f=zc.prototype,f.enabled=!1,f.l=null,f.setInterval=function(t){this.ea=t,this.l&&this.enabled?(this.stop(),this.start()):this.l&&this.stop()},f.Gc=function(){if(this.enabled){var t=q()-this.sb;0<t&&t<.8*this.ea?this.l=this.ra.setTimeout(this.ib,this.ea-t):(this.l&&(this.ra.clearTimeout(this.l),this.l=null),this.dispatchEvent(Ac),this.enabled&&(this.l=this.ra.setTimeout(this.ib,this.ea),this.sb=q()))}},f.start=function(){this.enabled=!0,this.l||(this.l=this.ra.setTimeout(this.ib,this.ea),this.sb=q())},f.stop=function(){this.enabled=!1,this.l&&(this.ra.clearTimeout(this.l),this.l=null)},f.u=function(){zc.pa.u.call(this),this.stop(),delete this.ra};var Ac="tick",Fc;function Bc(t,e,n){if(fa(t))n&&(t=p(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=p(t.handleEvent,t)}return 2147483647<e?-1:l.setTimeout(t,e||0)}function Cc(){}function Dc(t){var e;return(e=t.Ab)||(e={},Ec(t)&&(e[0]=!0,e[1]=!0),e=t.Ab=e),e}function Gc(){}function Hc(t){return(t=Ec(t))?new ActiveXObject(t):new XMLHttpRequest}function Ec(t){if(!t.Kb&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(var e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],n=0;n<e.length;n++){var i=e[n];try{return new ActiveXObject(i),t.Kb=i}catch(t){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed")}return t.Kb}function Ic(t){R.call(this),this.headers=new cb,this.gb=t||null,this.T=!1,this.fb=this.f=null,this.Mb=this.Qa="",this.ka=0,this.q="",this.da=this.qb=this.Pa=this.nb=!1,this.Fa=0,this.bb=null,this.Xb=Jc,this.cb=this.dc=!1}Cc.prototype.Ab=null,s(Gc,Cc),Fc=new Gc,s(Ic,R);var Jc="";Ic.prototype.r=Tb("goog.net.XhrIo");var Kc=/^https?$/i,Lc=["POST","PUT"];function Oc(t){return y&&A(9)&&"number"==typeof t.timeout&&void 0!==t.ontimeout}function $a(t){return"content-type"==t.toLowerCase()}function Mc(t,e){t.T=!1,t.f&&(t.da=!0,t.f.abort(),t.da=!1),t.q=e,t.ka=5,Pc(t),Qc(t)}function Pc(t){t.nb||(t.nb=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function Rc(t){if(t.T&&void 0!==aa)if(t.fb[1]&&4==T(t)&&2==Sc(t))M(t.r,S(t,"Local request error detected and ignored"));else if(t.Pa&&4==T(t))Bc(t.Qb,0,t);else if(t.dispatchEvent("readystatechange"),4==T(t)){M(t.r,S(t,"Request complete")),t.T=!1;try{var e,n,i=Sc(t);t:switch(i){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:n=!0;break t;default:n=!1}if(!(e=n)){var a;if(a=0===i){if(!(s=Ra(String(t.Qa))[1]||null)&&self.location)var r=self.location.protocol,s=r.substr(0,r.length-1);a=!Kc.test(s?s.toLowerCase():"")}e=a}if(e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{var o;t.ka=6;try{o=2<T(t)?t.f.statusText:""}catch(e){M(t.r,"Can not get status: "+e.message),o=""}t.q=o+" ["+Sc(t)+"]",Pc(t)}}finally{Qc(t)}}}function Qc(t,e){if(t.f){Nc(t);var n=t.f,i=t.fb[0]?ca:null;t.f=null,t.fb=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=i}catch(e){(n=t.r)&&n.J("Problem encountered resetting onreadystatechange: "+e.message,void 0)}}}function Nc(t){t.f&&t.cb&&(t.f.ontimeout=null),"number"==typeof t.bb&&(l.clearTimeout(t.bb),t.bb=null)}function T(t){return t.f?t.f.readyState:0}function Sc(t){try{return 2<T(t)?t.f.status:-1}catch(e){return(t=t.r)&&t.Z("Can not get status: "+e.message,void 0),-1}}function Tc(t){try{return t.f?t.f.responseText:""}catch(e){return M(t.r,"Can not get responseText: "+e.message),""}}function S(t,e){return e+" ["+t.Mb+" "+t.Qa+" "+Sc(t)+"]"}function Uc(){this.Wb=q()}function Vc(t){O.call(this),this.e=t,this.j={}}f=Ic.prototype,f.send=function(t,e,n,i){if(this.f)throw Error("[goog.net.XhrIo] Object is active with another request="+this.Qa+"; newUri="+t);e=e?e.toUpperCase():"GET",this.Qa=t,this.q="",this.ka=0,this.Mb=e,this.nb=!1,this.T=!0,this.f=this.gb?Hc(this.gb):Hc(Fc),this.fb=this.gb?Dc(this.gb):Dc(Fc),this.f.onreadystatechange=p(this.Qb,this);try{M(this.r,S(this,"Opening Xhr")),this.qb=!0,this.f.open(e,t,!0),this.qb=!1}catch(t){return M(this.r,S(this,"Error opening Xhr: "+t.message)),void Mc(this,t)}t=n||"";var a=this.headers.n();i&&D(i,function(t,e){a.set(e,t)}),i=Za(a.ca()),n=l.FormData&&t instanceof l.FormData,!(0<=Xa(Lc,e))||i||n||a.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),D(a,function(t,e){this.f.setRequestHeader(e,t)},this),this.Xb&&(this.f.responseType=this.Xb),"withCredentials"in this.f&&(this.f.withCredentials=this.dc);try{Nc(this),0<this.Fa&&(this.cb=Oc(this.f),M(this.r,S(this,"Will abort after "+this.Fa+"ms if incomplete, xhr2 "+this.cb)),this.cb?(this.f.timeout=this.Fa,this.f.ontimeout=p(this.qa,this)):this.bb=Bc(this.qa,this.Fa,this)),M(this.r,S(this,"Sending request")),this.Pa=!0,this.f.send(t),this.Pa=!1}catch(t){M(this.r,S(this,"Send error: "+t.message)),Mc(this,t)}},f.qa=function(){void 0!==aa&&this.f&&(this.q="Timed out after "+this.Fa+"ms, aborting",this.ka=8,M(this.r,S(this,this.q)),this.dispatchEvent("timeout"),this.abort(8))},f.abort=function(t){this.f&&this.T&&(M(this.r,S(this,"Aborting")),this.T=!1,this.da=!0,this.f.abort(),this.da=!1,this.ka=t||7,this.dispatchEvent("complete"),this.dispatchEvent("abort"),Qc(this))},f.u=function(){this.f&&(this.T&&(this.T=!1,this.da=!0,this.f.abort(),this.da=!1),Qc(this,!0)),Ic.pa.u.call(this)},f.Qb=function(){this.mb||(this.qb||this.Pa||this.da?Rc(this):this.uc())},f.uc=function(){Rc(this)},f.isActive=function(){return!!this.f},f.Ib=function(){return n(this.q)?this.q:String(this.q)},new Uc,Uc.prototype.set=function(t){this.Wb=t},Uc.prototype.reset=function(){this.set(q())},Uc.prototype.get=function(){return this.Wb},s(Vc,O);var Wc=[];function Xc(t,e,n){O.call(this),this.pc=t,this.ea=e,this.e=n,this.jc=p(this.vc,this)}function Yc(t){t.l=Bc(t.jc,t.ea),t.pc.call(t.e)}function U(t,e,n,i,a){this.b=t,this.a=e,this.Y=n,this.B=i,this.Ea=a||1,this.qa=Zc,this.ob=new Vc(this),this.Ta=new zc,this.Ta.setInterval($c)}f=Vc.prototype,f.Ra=function(t,e,n,i){m(e)||(Wc[0]=e,e=Wc);for(var a=0;a<e.length;a++){var r=oc(t,e[a],n||this.handleEvent,i||!1,this.e||this);if(!r)break;this.j[r.key]=r}return this},f.vb=function(t,e,n,i,a){if(m(e))for(var r=0;r<e.length;r++)this.vb(t,e[r],n,i,a);else n=n||this.handleEvent,a=a||this.e||this,n=pc(n),i=!!i,(e=bc(t)?t.ya(e,n,i,a):t&&(t=qc(t))?t.ya(e,n,i,a):null)&&(uc(e),delete this.j[e.key]);return this},f.Xa=function(){var t,e=this.j,n=uc;for(t in e)n.call(void 0,e[t],t,e);this.j={}},f.u=function(){Vc.pa.u.call(this),this.Xa()},f.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},s(Xc,O),f=Xc.prototype,f.Za=!1,f.Vb=0,f.l=null,f.stop=function(){this.l&&(l.clearTimeout(this.l),this.l=null,this.Za=!1)},f.u=function(){Xc.pa.u.call(this),this.stop()},f.vc=function(){this.l=null,this.Za&&!this.Vb&&(this.Za=!1,Yc(this))},f=U.prototype,f.v=null,f.F=!1,f.ua=null,f.xb=null,f.Da=null,f.sa=null,f.U=null,f.w=null,f.X=null,f.k=null,f.Ha=0,f.K=null,f.ta=null,f.q=null,f.g=-1,f.Zb=!0,f.$=!1,f.ma=0,f.Va=null;var Zc=45e3,$c=250;function ad(t,e){switch(t){case 0:return"Non-200 return code ("+e+")";case 1:return"XMLHTTP failure (no data)";case 2:return"HttpConnection timeout";default:return"Unknown error"}}var bd={},dd={};function ed(){return!y||y&&10<=Ma}function fd(t,e,n){t.sa=1,t.U=H(e.n()),t.X=n,t.Cb=!0,gd(t,null)}function hd(t,e,n,i,a){t.sa=1,t.U=H(e.n()),t.X=null,t.Cb=n,a&&(t.Zb=!1),gd(t,i)}function gd(t,e){var n;if(t.Da=q(),id(t),t.w=t.U.n(),rb(t.w,"t",t.Ea),t.Ha=0,t.k=t.b.lb(t.b.$a()?e:null),0<t.ma&&(t.Va=new Xc(p(t.ec,t,t.k),t.ma)),t.ob.Ra(t.k,"readystatechange",t.Bc),t.v){n=t.v;var i,a={};for(i in n)a[i]=n[i];n=a}else n={};if(t.X?(t.ta="POST",n["Content-Type"]="application/x-www-form-urlencoded",t.k.send(t.w,t.ta,t.X,n)):(t.ta="GET",t.Zb&&!z&&(n.Connection="close"),t.k.send(t.w,t.ta,null,n)),t.b.H(jd),a=t.X)for(n="",a=a.split("&"),i=0;i<a.length;i++){if(1<(s=a[i].split("=")).length){var r=s[0],s=s[1],o=r.split("_");n=2<=o.length&&"type"==o[1]?n+(r+"=")+s+"&":n+(r+"=redacted&")}}else n=null;t.a.info("XMLHTTP REQ ("+t.B+") [attempt "+t.Ea+"]: "+t.ta+"\n"+t.w+"\n"+n)}function nd(t,e,n){for(var i=!0;!t.$&&t.Ha<n.length;){var a=qd(t,n);if(a==dd){4==e&&(t.q=4,W(),i=!1),Ub(t.a,t.B,null,"[Incomplete Response]");break}if(a==bd){t.q=4,W(),Ub(t.a,t.B,n,"[Invalid Chunk]"),i=!1;break}Ub(t.a,t.B,a,null),od(t,a)}4==e&&0==n.length&&(t.q=1,W(),i=!1),t.F=t.F&&i,i||(Ub(t.a,t.B,n,"[Invalid Chunked Response]"),V(t),pd(t))}function qd(t,e){var n=t.Ha,i=e.indexOf("\n",n);if(-1==i)return dd;if(n=Number(e.substring(n,i)),isNaN(n))return bd;if((i+=1)+n>e.length)return dd;var a=e.substr(i,n);return t.Ha=i+n,a}function rd(t,e){t.Da=q(),id(t);var n=e?window.location.hostname:"";t.w=t.U.n(),G(t.w,"DOMAIN",n),G(t.w,"t",t.Ea);try{t.K=new ActiveXObject("htmlfile")}catch(e){return t.a.J("ActiveX blocked"),V(t),t.q=7,W(),void pd(t)}var i="<html><body>";e&&(i+='<script>document.domain="'+n+'"<\/script>'),i+="</body></html>",t.K.open(),t.K.write(i),t.K.close(),t.K.parentWindow.m=p(t.yc,t),t.K.parentWindow.d=p(t.Ub,t,!0),t.K.parentWindow.rpcClose=p(t.Ub,t,!1),n=t.K.createElement("div"),t.K.parentWindow.document.body.appendChild(n),n.innerHTML='<iframe src="'+t.w+'"></iframe>',t.a.info("TRIDENT REQ ("+t.B+") [ attempt "+t.Ea+"]: GET\n"+t.w),t.b.H(jd)}function id(t){t.xb=q()+t.qa,td(t,t.qa)}function td(t,e){if(null!=t.ua)throw Error("WatchDog timer not null");t.ua=Y(p(t.zc,t),e)}function md(t){t.ua&&(l.clearTimeout(t.ua),t.ua=null)}function pd(t){t.b.Lb()||t.$||t.b.la(t)}function V(t){md(t);var e=t.Va;e&&"function"==typeof e.Ja&&e.Ja(),t.Va=null,t.Ta.stop(),t.ob.Xa(),t.k&&(e=t.k,t.k=null,e.abort(),e.Ja()),t.K&&(t.K=null)}function od(t,e){try{t.b.Rb(t,e),t.b.H(sd)}catch(e){Wb(t.a,e,"Error in httprequest callback")}}function ud(t,e,n,i,a){if((new N).debug("TestLoadImageWithRetries: "+a),0==i)n(!1);else{var r=a||0;i--,vd(t,e,function(a){a?n(!0):l.setTimeout(function(){ud(t,e,n,i,r)},r)})}}function vd(t,e,n){function i(t,e){return function(){try{a.debug("TestLoadImage: "+e),r.onload=null,r.onerror=null,r.onabort=null,r.ontimeout=null,l.clearTimeout(s),n(t)}catch(t){Wb(a,t)}}}var a=new N;a.debug("TestLoadImage: loading "+t);var r=new Image,s=null;r.onload=i(!0,"loaded"),r.onerror=i(!1,"error"),r.onabort=i(!1,"abort"),r.ontimeout=i(!1,"timeout"),s=l.setTimeout(function(){r.ontimeout&&r.ontimeout()},e),r.src=t}function wd(t,e){this.b=t,this.a=e,this.P=new Yb(0,!0)}function yd(t){var e=Ad(t.b,t.va,"/mail/images/cleardot.gif");H(e),ud(e.toString(),5e3,p(t.kc,t),3,2e3),t.H(jd)}function zd(t){t.a.debug("TestConnection: starting stage 2");var e=t.b.Dc;if(null!=e)t.a.debug("Buffered"),W(),e?(W(),Bd(t.b,t,!1)):(W(),Bd(t.b,t,!0));else if(t.A=new U(t,t.a,void 0,void 0,void 0),t.A.S(t.v),e=Cd(t.b,t.L,t.I),W(),ed())rb(e,"TYPE","xmlhttp"),hd(t.A,e,!1,t.L,!1);else{rb(e,"TYPE","html");var n=t.A;t=Boolean(t.L),n.sa=3,n.U=H(e.n()),rd(n,t)}}function Ed(t,e,n){this.Bb=t||null,this.c=Fd,this.t=[],this.Q=[],this.a=new N,this.P=new Yb(0,!0),this.Gb=e||null,this.Dc=null!=n?n:null}function Gd(t,e){this.Ob=t,this.map=e}f=U.prototype,f.S=function(t){this.v=t},f.setTimeout=function(t){this.qa=t},f.bc=function(t){this.ma=t},f.Bc=function(t){t=t.target;var e=this.Va;e&&3==T(t)?(this.a.debug("Throttling readystatechange."),e.l||e.Vb?e.Za=!0:Yc(e)):this.ec(t)},f.ec=function(t){try{if(t==this.k)t:{var e=T(this.k),n=this.k.ka,i=Sc(this.k);if(!ed()||z&&!A("420+")){if(4>e)break t}else if(3>e||3==e&&!Aa&&!Tc(this.k))break t;this.$||4!=e||7==n||(8==n||0>=i?this.b.H(kd):this.b.H(ld)),md(this);var a=Sc(this.k);this.g=a;var r=Tc(this.k);r||this.a.debug("No response text for uri "+this.w+" status "+a),this.F=200==a,this.a.info("XMLHTTP RESP ("+this.B+") [ attempt "+this.Ea+"]: "+this.ta+"\n"+this.w+"\n"+e+" "+a),this.F?(4==e&&V(this),this.Cb?(nd(this,e,r),Aa&&this.F&&3==e&&(this.ob.Ra(this.Ta,Ac,this.Ac),this.Ta.start())):(Ub(this.a,this.B,r,null),od(this,r)),this.F&&!this.$&&(4==e?this.b.la(this):(this.F=!1,id(this)))):(400==a&&0<r.indexOf("Unknown SID")?(this.q=3,W(),this.a.Z("XMLHTTP Unknown SID ("+this.B+")")):(this.q=0,W(),this.a.Z("XMLHTTP Bad status "+a+" ("+this.B+")")),V(this),pd(this))}else this.a.Z("Called back with an unexpected xmlhttp")}catch(t){this.a.debug("Failed call to OnXmlHttpReadyStateChanged_"),this.k&&Tc(this.k)?Wb(this.a,t,"ResponseText: "+Tc(this.k)):Wb(this.a,t,"No response text")}},f.Ac=function(){var t=T(this.k),e=Tc(this.k);this.Ha<e.length&&(md(this),nd(this,t,e),this.F&&4!=t&&id(this))},f.yc=function(t){Y(p(this.xc,this,t),0)},f.xc=function(t){if(!this.$){var e=this.a;e.info("TRIDENT TEXT ("+this.B+"): "+Vb(e,t)),md(this),od(this,t),id(this)}},f.Ub=function(t){Y(p(this.wc,this,t),0)},f.wc=function(t){this.$||(this.a.info("TRIDENT TEXT ("+this.B+"): "+t?"success":"failure"),V(this),this.F=t,this.b.la(this),this.b.H(sd))},f.nc=function(){md(this),this.b.la(this)},f.cancel=function(){this.$=!0,V(this)},f.zc=function(){this.ua=null;var t=q();0<=t-this.xb?(this.F&&this.a.J("Received watchdog timeout even though request loaded successfully"),this.a.info("TIMEOUT: "+this.w),2!=this.sa&&this.b.H(kd),V(this),this.q=2,W(),pd(this)):(this.a.Z("WatchDog timer called too early"),td(this,this.xb-t))},f.Ib=function(){return this.q},f=wd.prototype,f.v=null,f.A=null,f.Wa=!1,f.cc=null,f.La=null,f.rb=null,f.I=null,f.c=null,f.g=-1,f.L=null,f.va=null,f.S=function(t){this.v=t},f.ac=function(t){this.P=t},f.kb=function(t){this.I=t,t=xd(this.b,this.I),W(),this.cc=q();var e=this.b.Gb;null!=e?(this.L=this.b.correctHostPrefix(e[0]),(this.va=e[1])?(this.c=1,yd(this)):(this.c=2,zd(this))):(rb(t,"MODE","init"),this.A=new U(this,this.a,void 0,void 0,void 0),this.A.S(this.v),hd(this.A,t,!1,null,!0),this.c=0)},f.kc=function(t){if(t)this.c=2,zd(this);else{W();var e=this.b;e.a.debug("Test Connection Blocked"),e.g=e.V.g,Z(e,9)}t&&this.H(ld)},f.lb=function(t){return this.b.lb(t)},f.abort=function(){this.A&&(this.A.cancel(),this.A=null),this.g=-1},f.Lb=function(){return!1},f.Rb=function(t,e){if(this.g=t.g,0==this.c)if(this.a.debug("TestConnection: Got data for stage 1"),e){try{var n=this.P.parse(e)}catch(t){return Wb(this.a,t),void Dd(this.b,this)}this.L=this.b.correctHostPrefix(n[0]),this.va=n[1]}else this.a.debug("TestConnection: Null responseText"),Dd(this.b,this);else 2==this.c&&(this.Wa?(W(),this.rb=q()):"11111"==e?(W(),this.Wa=!0,this.La=q(),n=this.La-this.cc,(ed()||500>n)&&(this.g=200,this.A.cancel(),this.a.debug("Test connection succeeded; using streaming connection"),W(),Bd(this.b,this,!0))):(W(),this.La=this.rb=q(),this.Wa=!1))},f.la=function(){if(this.g=this.A.g,this.A.F){if(0==this.c)this.a.debug("TestConnection: request complete for initial check"),this.va?(this.c=1,yd(this)):(this.c=2,zd(this));else if(2==this.c){this.a.debug("TestConnection: request complete for stage 2");(ed()?this.Wa:!(200>this.rb-this.La))?(this.a.debug("Test connection succeeded; using streaming connection"),W(),Bd(this.b,this,!0)):(this.a.debug("Test connection failed; not using streaming"),W(),Bd(this.b,this,!1))}}else this.a.debug("TestConnection: request failed, in state "+this.c),0==this.c?W():2==this.c&&W(),Dd(this.b,this)},f.$a=function(){return this.b.$a()},f.isActive=function(){return this.b.isActive()},f.H=function(t){this.b.H(t)},f=Ed.prototype,f.v=null,f.xa=null,f.p=null,f.i=null,f.I=null,f.Ma=null,f.zb=null,f.L=null,f.hc=!0,f.Ba=0,f.sc=0,f.Ka=!1,f.e=null,f.G=null,f.M=null,f.aa=null,f.V=null,f.wb=null,f.gc=!0,f.za=-1,f.Nb=-1,f.g=-1,f.ba=0,f.ha=0,f.ic=5e3,f.Cc=1e4,f.pb=2,f.Hb=2e4,f.ma=0,f.ab=!1,f.ia=8;var Fd=1,Hd=new R;function Id(t){Q.call(this,"statevent",t)}function Jd(t,e){Q.call(this,"timingevent",t),this.size=e}s(Id,Q),s(Jd,Q);var jd=1,ld=2,kd=3,sd=4;function Kd(t){Q.call(this,"serverreachability",t)}s(Kd,Q);var Xb="y2f%",$,Yd,debug;function Md(t){t.V&&(t.V.abort(),t.V=null),t.i&&(t.i.cancel(),t.i=null),t.M&&(l.clearTimeout(t.M),t.M=null),Pd(t),t.p&&(t.p.cancel(),t.p=null),t.G&&(l.clearTimeout(t.G),t.G=null)}function Qd(t){t.p||t.G||(t.G=Y(p(t.Tb,t),0),t.ba=0)}function Sd(t,e){var n,i;e?6<t.ia?(t.t=t.Q.concat(t.t),t.Q.length=0,n=t.Ba-1,i=Rd(t)):(n=e.B,i=e.X):(n=t.Ba++,i=Rd(t));var a=t.Ma.n();G(a,"SID",t.Y),G(a,"RID",n),G(a,"AID",t.za),Nd(t,a),(n=new U(t,t.a,t.Y,n,t.ba+1)).S(t.v),n.setTimeout(Math.round(.5*t.Hb)+Math.round(.5*t.Hb*Math.random())),t.p=n,fd(n,a,i)}function Nd(t,e){if(t.e){var n=t.e.getAdditionalParams(t);n&&D(n,function(t,n){G(e,n,t)})}}function Rd(t){var e,n=Math.min(t.t.length,1e3),i=["count="+n];6<t.ia&&0<n?(e=t.t[0].Ob,i.push("ofs="+e)):e=0;for(var a=0;a<n;a++){var r=t.t[a].Ob,s=t.t[a].map;r=6>=t.ia?a:r-e;try{D(s,function(t,e){i.push("req"+r+"_"+e+"="+encodeURIComponent(t))})}catch(e){i.push("req"+r+"_type="+encodeURIComponent("_badmap")),t.e&&t.e.badMapError(t,s)}}return t.Q=t.Q.concat(t.t.splice(0,n)),i.join("&")}function Td(t){t.i||t.M||(t.yb=1,t.M=Y(p(t.Sb,t),0),t.ha=0)}function Ud(t){return t.i||t.M?(t.a.J("Request already in progress"),!1):!(3<=t.ha)&&(t.a.debug("Going to retry GET"),t.yb++,t.M=Y(p(t.Sb,t),Vd(t,t.ha)),t.ha++,!0)}function Ld(t){if(t.e){var e=t.e.okToMakeRequest(t);if(0!=e)return t.a.debug("Handler returned error code from okToMakeRequest"),Z(t,e),!1}return!0}function Bd(t,e,n){t.a.debug("Test Connection Finished"),t.wb=t.gc&&n,t.g=e.g,t.a.debug("connectChannel_()"),t.lc(Fd,0),t.Ma=xd(t,t.I),Qd(t)}function Dd(t,e){t.a.debug("Test Connection Failed"),t.g=e.g,Z(t,2)}function Pd(t){null!=t.aa&&(l.clearTimeout(t.aa),t.aa=null)}function Vd(t,e){var n=t.ic+Math.floor(Math.random()*t.Cc);return t.isActive()||(t.a.debug("Inactive channel"),n*=2),n*e}function Z(t,e){if(t.a.info("Error code "+e),2==e||9==e){var n=null;t.e&&(n=t.e.getNetworkTestImageUri(t));var i=p(t.Fc,t);n||H(n=new E("//www.google.com/images/cleardot.gif")),vd(n.toString(),1e4,i)}else W();Wd(t,e)}function Wd(t,e){t.a.debug("HttpChannel: error - "+e),t.c=0,t.e&&t.e.channelError(t,e),Od(t),Md(t)}function Od(t){if(t.c=0,t.g=-1,t.e)if(0==t.Q.length&&0==t.t.length)t.e.channelClosed(t);else{t.a.debug("Number of undelivered maps, pending: "+t.Q.length+", outgoing: "+t.t.length);var e=bb(t.Q),n=bb(t.t);t.Q.length=0,t.t.length=0,t.e.channelClosed(t,e,n)}}function xd(t,e){var n=Ad(t,null,e);return t.a.debug("GetForwardChannelUri: "+n),n}function Cd(t,e,n){return e=Ad(t,t.$a()?e:null,n),t.a.debug("GetBackChannelUri: "+e),e}function Ad(t,e,n){if(""!=(a=tb(n)).ja)e&&gb(a,e+"."+a.ja),hb(a,a.Ca);else var i=window.location,a=ub(i.protocol,e?e+"."+i.hostname:i.hostname,i.port,n);return t.xa&&D(t.xa,function(t,e){G(a,e,t)}),G(a,"VER",t.ia),Nd(t,a),a}function Y(t,e){if(!fa(t))throw Error("Fn must not be null and must be a function");return l.setTimeout(function(){t()},e)}function W(){Hd.dispatchEvent(new Id(Hd))}function Xd(){}f=Ed.prototype,f.kb=function(t,e,n,i,a){this.a.debug("connect()"),W(),this.I=e,this.xa=n||{},i&&void 0!==a&&(this.xa.OSID=i,this.xa.OAID=a),this.a.debug("connectTest_()"),Ld(this)&&(this.V=new wd(this,this.a),this.V.S(this.v),this.V.ac(this.P),this.V.kb(t))},f.disconnect=function(){if(this.a.debug("disconnect()"),Md(this),3==this.c){var t=this.Ba++,e=this.Ma.n();G(e,"SID",this.Y),G(e,"RID",t),G(e,"TYPE","terminate"),Nd(this,e),(t=new U(this,this.a,this.Y,t,void 0)).sa=2,t.U=H(e.n()),(e=new Image).src=t.U,e.onload=e.onerror=p(t.nc,t),t.Da=q(),id(t)}Od(this)},f.S=function(t){this.v=t},f.bc=function(t){this.ma=t},f.Lb=function(){return 0==this.c},f.ac=function(t){this.P=t},f.Tb=function(t){if(this.G=null,this.a.debug("startForwardChannel_"),Ld(this))if(this.c==Fd)if(t)this.a.J("Not supposed to retry the open");else{this.a.debug("open_()"),this.Ba=Math.floor(1e5*Math.random()),t=this.Ba++;var e=new U(this,this.a,"",t,void 0);e.S(this.v);var n=Rd(this),i=this.Ma.n();G(i,"RID",t),this.Bb&&G(i,"CVER",this.Bb),Nd(this,i),fd(e,i,n),this.p=e,this.c=2}else 3==this.c&&(t?Sd(this,t):0==this.t.length?this.a.debug("startForwardChannel_ returned: nothing to send"):this.p?this.a.J("startForwardChannel_ returned: connection already in progress"):(Sd(this),this.a.debug("startForwardChannel_ finished, sent request")))},f.Sb=function(){if(this.M=null,Ld(this)){this.a.debug("Creating new HttpRequest"),this.i=new U(this,this.a,this.Y,"rpc",this.yb),this.i.S(this.v),this.i.bc(this.ma);var t=this.zb.n();if(G(t,"RID","rpc"),G(t,"SID",this.Y),G(t,"CI",this.wb?"0":"1"),G(t,"AID",this.za),Nd(this,t),ed())G(t,"TYPE","xmlhttp"),hd(this.i,t,!0,this.L,!1);else{G(t,"TYPE","html");var e=this.i,n=Boolean(this.L);e.sa=3,e.U=H(t.n()),rd(e,n)}this.a.debug("New Request created")}},f.Rb=function(t,e){if(0!=this.c&&(this.i==t||this.p==t))if(this.g=t.g,this.p==t&&3==this.c)if(7<this.ia){var n;try{n=this.P.parse(e)}catch(t){n=null}if(m(n)&&3==n.length)if(0==(i=n)[0])t:if(this.a.debug("Server claims our backchannel is missing."),this.M)this.a.debug("But we are currently starting the request.");else{if(this.i){if(!(this.i.Da+3e3<this.p.Da))break t;Pd(this),this.i.cancel(),this.i=null}else this.a.Z("We do not have a BackChannel established");Ud(this),W()}else this.Nb=i[1],0<(n=this.Nb-this.za)&&(i=i[2],this.a.debug(i+" bytes (in "+n+" arrays) are outstanding on the BackChannel"),37500>i&&this.wb&&0==this.ha&&!this.aa&&(this.aa=Y(p(this.tc,this),6e3)));else this.a.debug("Bad POST response data returned"),Z(this,11)}else e!=Xb&&(this.a.debug("Bad data returned - missing/invald magic cookie"),Z(this,11));else if(this.i==t&&Pd(this),!/^[\s\xa0]*$/.test(e)){n=this.P.parse(e);for(var i=this.e&&this.e.channelHandleMultipleArrays?[]:null,a=0;a<n.length;a++){var r=n[a];this.za=r[0],r=r[1],2==this.c?"c"==r[0]?(this.Y=r[1],this.L=this.correctHostPrefix(r[2]),r=r[3],this.ia=null!=r?r:6,this.c=3,this.e&&this.e.channelOpened(this),this.zb=Cd(this,this.L,this.I),Td(this)):"stop"==r[0]&&Z(this,7):3==this.c&&("stop"==r[0]?(i&&0!=i.length&&(this.e.channelHandleMultipleArrays(this,i),i.length=0),Z(this,7)):"noop"!=r[0]&&(i?i.push(r):this.e&&this.e.channelHandleArray(this,r)),this.ha=0)}i&&0!=i.length&&this.e.channelHandleMultipleArrays(this,i)}},f.correctHostPrefix=function(t){return this.hc?this.e?this.e.correctHostPrefix(t):t:null},f.tc=function(){null!=this.aa&&(this.aa=null,this.i.cancel(),this.i=null,Ud(this),W())},f.la=function(t){var e;if(this.a.debug("Request complete"),this.i==t)Pd(this),this.i=null,e=2;else{if(this.p!=t)return;this.p=null,e=1}if(this.g=t.g,0!=this.c)if(t.F)1==e?(q(),Hd.dispatchEvent(new Jd(Hd,t.X?t.X.length:0)),Qd(this),this.Q.length=0):Td(this);else{var n=t.Ib();if(3==n||7==n||0==n&&0<this.g)this.a.debug("Not retrying due to error type");else{var i;if(this.a.debug("Maybe retrying, last error: "+ad(n,this.g)),(i=1==e)&&(this.p||this.G?(this.a.J("Request already in progress"),i=!1):this.c==Fd||this.ba>=(this.Ka?0:this.pb)?i=!1:(this.a.debug("Going to retry POST"),this.G=Y(p(this.Tb,this,t),Vd(this,this.ba)),this.ba++,i=!0)),i||2==e&&Ud(this))return;this.a.debug("Exceeded max number of retries")}switch(this.a.debug("Error: HTTP request failed"),n){case 1:Z(this,5);break;case 4:Z(this,10);break;case 3:Z(this,6);break;case 7:Z(this,12);break;default:Z(this,2)}}},f.lc=function(t){if(!(0<=Xa(arguments,this.c)))throw Error("Unexpected channel state: "+this.c)},f.Fc=function(t){t?(this.a.info("Successfully pinged google.com"),W()):(this.a.info("Failed to ping google.com"),W(),Wd(this,8))},f.lb=function(t){if(t&&!this.ab)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new Ic).dc=this.ab,t},f.isActive=function(){return!!this.e&&this.e.isActive(this)},f.H=function(){Hd.dispatchEvent(new Kd(Hd))},f.$a=function(){return this.ab||!ed()},f=Xd.prototype,f.channelHandleMultipleArrays=null,f.okToMakeRequest=function(){return 0},f.channelOpened=function(){},f.channelHandleArray=function(){},f.channelError=function(){},f.channelClosed=function(){},f.getAdditionalParams=function(){return{}},f.getNetworkTestImageUri=function(){return null},f.isActive=function(){return!0},f.badMapError=function(){},f.correctHostPrefix=function(t){return t},Yd={0:"Ok",4:"User is logging out",6:"Unknown session ID",7:"Stopped by server",8:"General network error",2:"Request failed",9:"Blocked by a network administrator",5:"No data from server",10:"Got bad data from the server",11:"Got a bad response from the server"},$=function(t,e){var n,i,a,r,s,o,h,c,u,f,d,b,p,g;if(!(this instanceof $))return new $(t,e);f=this,t||(t="channel"),t.match(/:\/\//)&&t.replace(/^ws/,"http"),e||(e={}),m(e||"string"==typeof e)&&(e={}),c=e.reconnectTime||3e3,debug=void 0===e.debug||e.debug,n=e.extraHeaders||null,i=e.extraParams||null,null!==e.affinity&&(i||(i={}),e.affinityParam||(e.affinityParam="a"),this.affinity=e.affinity||sa(),i[e.affinityParam]=this.affinity),(p=function(t){f.readyState=f.readyState=t})(this.CLOSED),b=null,o=null!=(g=e.prev)?g.Ec:void 0,a=function(t,e,n,i,a){try{return"function"==typeof f[t]?f[t](n,i,a):void 0}catch(t){throw"undefined"!=typeof console&&null!==console&&console.error(t.stack),t}},(r=new Xd).channelOpened=function(){return o=b,p($.OPEN),a("onopen")},s=null,r.channelError=function(t,e){var n;return n=Yd[e],s=e,f.readyState!==$.CLOSED&&p($.hb),a("onerror",0,n,e)},u=null,r.channelClosed=function(t,n,i){var r;if(f.readyState!==$.CLOSED)return b=null,t=s?Yd[s]:"Closed",p($.CLOSED),e.reconnect&&7!==s&&0!==s&&(r=6===s?0:c,clearTimeout(u),u=setTimeout(h,r)),a("onclose",0,t,n,i),s=null},r.channelHandleArray=function(t,e){return a("onmessage",0,{type:"message",data:e})},h=function(){if(b)throw Error("Reconnect() called from invalid state");if(p($.CONNECTING),a("onconnecting"),clearTimeout(u),f.Ec=b=new Ed(e.appVersion,null!=o?o.Gb:void 0),e.crossDomainXhr&&(b.ab=!0),b.e=r,n&&b.S(n),s=null,e.failFast){var h=b;h.Ka=!0,h.a.info("setFailFast: true"),(h.p||h.G)&&h.ba>(h.Ka?0:h.pb)&&(h.a.info("Retry count "+h.ba+" > new maxRetries "+(h.Ka?0:h.pb)+". Fail immediately!"),h.p?(h.p.cancel(),h.la(h.p)):(l.clearTimeout(h.G),h.G=null,Z(h,2)))}return b.kb(t+"/test",t+"/bind",i,null!=o?o.Y:void 0,null!=o?o.za:void 0)},this.open=function(){if(f.readyState!==f.CLOSED)throw Error("Already open");return h()},this.close=function(){if(clearTimeout(u),s=0,f.readyState!==$.CLOSED)return p($.hb),b.disconnect()},this.sendMap=d=function(t){var e;if((e=f.readyState)!==$.hb&&e!==$.CLOSED){if(0==(e=b).c)throw Error("Invalid operation: sending map when state is closed");1e3==e.t.length&&e.a.J("Already have 1000 queued maps upon queueing "+yb(t)),e.t.push(new Gd(e.sc++,t)),2!=e.c&&3!=e.c||Qd(e)}},this.send=function(t){return d("string"==typeof t?{_S:t}:{JSON:yb(t)})},h()},$.prototype.canSendWhileConnecting=$.canSendWhileConnecting=!0,$.prototype.canSendJSON=$.canSendJSON=!0,$.prototype.CONNECTING=$.CONNECTING=$.CONNECTING=0,$.prototype.OPEN=$.OPEN=$.OPEN=1,$.prototype.CLOSING=$.CLOSING=$.hb=2,$.prototype.CLOSED=$.CLOSED=$.CLOSED=3,("undefined"!=typeof exports&&null!==exports?exports:window).BCSocket=$}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment