/**
 * The contents of this file are subject to the Common Public Attribution 
 * License Version 1.0 (the "License"); you may not use this file except 
 * in compliance with the License. You may obtain a copy of the License 
 * at http://www.kaazing.org/CPAL.
 * 
 * The License is based on the Mozilla Public License Version 1.1 but 
 * Sections 14 and 15 have been added to cover use of software over a 
 * computer network and provide for limited attribution for the Original 
 * Developer.
 * 
 * In addition, Exhibit A has been modified to be consistent with Exhibit B.
 * 
 * Software distributed under the License is distributed on an "AS IS" 
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
 * the License for the specific language governing rights and limitations 
 * under the License.
 * 
 * The Original Code is Kaazing Gateway. The Initial Developer of the 
 * Original Code is Kaazing Corporation.
 *  
 * All portions of the code written by Kaazing Corporation are 
 * Copyright (c) 2007-2009 Kaazing Corporation. All Rights Reserved.
 */

var browser=null;
if(typeof (ActiveXObject)!="undefined"){
browser="ie";
}else{
if(typeof (window.addEventStream)==="function"){
browser="opera";
}else{
if(navigator.vendor.indexOf("Apple")!=-1){
browser="safari";
}else{
if(navigator.vendor.indexOf("Google")!=-1){
browser="chrome";
}else{
if(navigator.product=="Gecko"&&window.find&&!navigator.savePreferences){
browser="firefox";
}else{
throw new Error("couldn't detect browser");
}
}
}
}
}
(function(){
Base64={};
Base64.encode=function(_1){
var _2=[];
var _3;
var _4;
var _5;
while(_1.length){
switch(_1.length){
case 1:
_3=_1.shift();
_2.push(_6[(_3>>2)&63]);
_2.push(_6[((_3<<4)&48)]);
_2.push("=");
_2.push("=");
break;
case 2:
_3=_1.shift();
_4=_1.shift();
_2.push(_6[(_3>>2)&63]);
_2.push(_6[((_3<<4)&48)|((_4>>4)&15)]);
_2.push(_6[(_4<<2)&60]);
_2.push("=");
break;
default:
_3=_1.shift();
_4=_1.shift();
_5=_1.shift();
_2.push(_6[(_3>>2)&63]);
_2.push(_6[((_3<<4)&48)|((_4>>4)&15)]);
_2.push(_6[((_4<<2)&60)|((_5>>6)&3)]);
_2.push(_6[_5&63]);
break;
}
}
return _2.join("");
};
Base64.decode=function(_7){
if(_7.length===0){
return [];
}
if(_7.length%4!==0){
throw new Error("Invalid base64 string (must be quads)");
}
var _8=[];
for(var i=0;i<_7.length;i+=4){
var _a=_7.charAt(i);
var _b=_7.charAt(i+1);
var _c=_7.charAt(i+2);
var _d=_7.charAt(i+3);
var _e=_f[_a];
var _10=_f[_b];
var _11=_f[_c];
var _12=_f[_d];
_8.push(((_e<<2)&252)|((_10>>4)&3));
if(_c!="="){
_8.push(((_10<<4)&240)|((_11>>2)&15));
if(_d!="="){
_8.push(((_11<<6)&192)|(_12&63));
}
}
}
return _8;
};
var _6="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
var _f={"=":0};
for(var i=0;i<_6.length;i++){
_f[_6[i]]=i;
}
if(typeof (window.btoa)==="undefined"){
window.btoa=function(s){
var _15=s.split("");
for(var i=0;i<_15.length;i++){
_15[i]=(_15[i]).charCodeAt();
}
return Base64.encode(_15);
};
window.atob=function(_17){
var _18=Base64.decode(_17);
for(var i=0;i<_18.length;i++){
_18[i]=String.fromCharCode(_18[i]);
}
return _18.join("");
};
}
})();
function URI(str){
str=str||"";
var _1b=0;
var _1c=str.indexOf("://");
if(_1c!=-1){
this.scheme=str.slice(0,_1c);
_1b=_1c+3;
var _1d=str.indexOf("/",_1b);
if(_1d==-1){
_1d=str.length;
str+="/";
}
var _1e=str.slice(_1b,_1d);
this.authority=_1e;
_1b=_1d;
this.host=_1e;
var _1f=_1e.indexOf(":");
if(_1f!=-1){
this.host=_1e.slice(0,_1f);
this.port=parseInt(_1e.slice(_1f+1),10);
if(isNaN(this.port)){
throw new Error("Invalid URI syntax");
}
}
}
var _20=str.indexOf("?",_1b);
if(_20!=-1){
this.path=str.slice(_1b,_20);
_1b=_20+1;
}
var _21=str.indexOf("#",_1b);
if(_21!=-1){
if(_20!=-1){
this.query=str.slice(_1b,_21);
}else{
this.path=str.slice(_1b,_21);
}
_1b=_21+1;
this.fragment=str.slice(_1b);
}else{
if(_20!=-1){
this.query=str.slice(_1b);
}else{
this.path=str.slice(_1b);
}
}
};
(function(){
var _22=URI.prototype;
_22.toString=function(){
var sb=[];
var _24=this.scheme;
if(_24!==undefined){
sb.push(_24);
sb.push("://");
sb.push(this.host);
var _25=this.port;
if(_25!==undefined){
sb.push(":");
sb.push(_25.toString());
}
}
if(this.path!==undefined){
sb.push(this.path);
}
if(this.query!==undefined){
sb.push("?");
sb.push(this.query);
}
if(this.fragment!==undefined){
sb.push("#");
sb.push(this.fragment);
}
return sb.join("");
};
var _26={"http":80,"ws":81,"https":443,"wss":815};
})();
switch(browser){
case "ie":
(function(){
if(document.createEvent===undefined){
var _27=function(){
};
_27.prototype.initEvent=function(_28,_29,_2a){
this.type=_28;
this.bubbles=_29;
this.cancelable=_2a;
};
document.createEvent=function(_2b){
if(_2b!="Events"){
throw new Error("Unsupported event name: "+_2b);
}
return new _27();
};
}
document._w_3_c_d_o_m_e_v_e_n_t_s_createElement=document.createElement;
document.createElement=function(_2c){
var _2d=this._w_3_c_d_o_m_e_v_e_n_t_s_createElement(_2c);
if(_2d.addEventListener===undefined){
var _2e={};
_2d.addEventListener=function(_2f,_30,_31){
return addEventListener(_2e,_2f,_30,_31);
};
_2d.removeEventListener=function(_32,_33,_34){
return removeEventListener(_2e,_32,_33,_34);
};
_2d.dispatchEvent=function(_35){
return dispatchEvent(_2e,_35);
};
}
return _2d;
};
if(window.addEventListener===undefined){
var _36=document.createElement("div");
var _37=(typeof (postMessage)==="undefined");
window.addEventListener=function(_38,_39,_3a){
if(_37&&_38=="message"){
_36.addEventListener(_38,_39,_3a);
}else{
window.attachEvent("on"+_38,_39);
}
};
window.removeEventListener=function(_3b,_3c,_3d){
if(_37&&_3b=="message"){
_36.removeEventListener(_3b,_3c,_3d);
}else{
window.detachEvent("on"+_3b,_3c);
}
};
window.dispatchEvent=function(_3e){
if(_37&&_3e.type=="message"){
_36.dispatchEvent(_3e);
}else{
window.fireEvent("on"+_3e.type,_3e);
}
};
}
function addEventListener(_3f,_40,_41,_42){
if(_42){
throw new Error("Not implemented");
}
var _43=_3f[_40]||{};
_3f[_40]=_43;
_43[_41]=_41;
};
function removeEventListener(_44,_45,_46,_47){
if(_47){
throw new Error("Not implemented");
}
var _48=_44[_45]||{};
delete _48[_46];
};
function dispatchEvent(_49,_4a){
var _4b=_4a.type;
var _4c=_49[_4b]||{};
for(var key in _4c){
if(typeof (_4c[key])=="function"){
try{
_4c[key](_4a);
}
catch(e){
}
}
}
};
})();
break;
case "chrome":
case "safari":
if(typeof (window.postMessage)==="undefined"&&typeof (window.dispatchEvent)==="undefined"&&typeof (document.dispatchEvent)==="function"){
window.dispatchEvent=function(_4e){
document.dispatchEvent(_4e);
};
var addEventListener0=window.addEventListener;
window.addEventListener=function(_4f,_50,_51){
if(_4f==="message"){
document.addEventListener(_4f,_50,_51);
}else{
addEventListener0.call(window,_4f,_50,_51);
}
};
var removeEventListener0=window.removeEventListener;
window.removeEventListener=function(_52,_53,_54){
if(_52==="message"){
document.removeEventListener(_52,_53,_54);
}else{
removeEventListener0.call(window,_52,_53,_54);
}
};
}
break;
case "opera":
var addEventListener0=window.addEventListener;
window.addEventListener=function(_55,_56,_57){
var _58=_56;
if(_55==="message"){
_58=function(_59){
if(_59.origin===undefined&&_59.uri!==undefined){
var uri=new URI(_59.uri);
delete uri.path;
delete uri.query;
_59.origin=uri.toString();
}
return _56(_59);
};
_56._$=_58;
}
addEventListener0.call(window,_55,_58,_57);
};
var removeEventListener0=window.removeEventListener;
window.removeEventListener=function(_5b,_5c,_5d){
var _5e=_5c;
if(_5b==="message"){
_5e=_5c._$;
}
removeEventListener0.call(window,_5b,_5e,_5d);
};
break;
}
var postMessage0=(function(){
var _5f={"http":80,"https":443};
var _60=location.protocol+"//"+location.hostname+":"+(location.port||_5f[location.protocol.substring(0,location.protocol.length-1)]);
var _61="/";
if(typeof (postMessage)!=="undefined"){
return function(_62,_63,_64){
switch(browser){
case "firefox":
case "ie":
setTimeout(function(){
_62.postMessage(_63,_64);
},0);
break;
default:
_62.postMessage(_63,_64);
break;
}
};
}else{
function MessagePipe(_65){
this.sourceToken=String(Math.random()).substring(2);
this.iframe=_65;
this.bridged=false;
this.lastWrite=-1;
this.lastRead=-1;
this.lastSyn=-1;
this.lastAck=-1;
this.queue=[];
this.escapedFragments=[];
};
var _66=MessagePipe.prototype;
_66.attach=function(_67,_68,_69,_6a,_6b,_6c){
this.target=_67;
this.targetOrigin=_68;
this.targetToken=_69;
this.reader=_6a;
this.lastFragment=_6a.location.hash;
this.writer=_6b;
this.writerURL=_6c;
if(_67==parent){
dequeue(this,true);
}
};
_66.detach=function(){
delete this.target;
delete this.targetOrigin;
delete this.reader;
delete this.lastFragment;
delete this.writer;
delete this.writerURL;
};
_66.poll=function(){
var _6d=this.reader.location.hash;
if(this.lastFragment!=_6d){
process(this,_6d.substring(1));
this.lastFragment=_6d;
}
};
_66.post=function(_6e,_6f,_70){
bridgeIfNecessary(this,_6e);
var _71=1000;
var _72=escape(_6f);
var _73=[];
while(_72.length>_71){
var _74=_72.substring(0,_71);
_72=_72.substring(_71);
_73.push(_74);
}
_73.push(_72);
this.queue.push([_70,_73]);
if(this.writer!=null&&this.lastAck>=this.lastSyn){
dequeue(this,false);
}
};
function bridgeIfNecessary(_75,_76){
if(_75.lastWrite<0&&!_75.bridged){
if(_76.parent==window){
var src=_75.iframe.src;
var _78=src.split("#");
var _79=null;
var _7a=document.getElementsByTagName("meta");
for(var i=0;i<_7a.length;i++){
if(_7a[i].name=="kaazing:resources"){
_79=_7a[i].content;
}
}
var _7c=["I",document.domain,escape(_60),_75.sourceToken,escape(_61),_79];
if(_78.length>1){
var _7d=_78[1];
_7c.push(escape(_7d));
}
_78[1]=_7c.join("!");
_76.location.replace(_78.join("#"));
_75.bridged=true;
}
}
};
function flush(_7e,_7f){
var _80=_7e.writerURL+"#"+_7f;
_7e.writer.location.replace(_80);
};
function dequeue(_81,_82){
var _83=_81.queue;
var _84=_81.lastRead;
if((_83.length>0||_82)&&_81.lastSyn>_81.lastAck){
var _85=_81.lastFrames;
var _86=_85.length-1;
var _87=_85[_86];
var _88=_87.split("!");
if(_88[2]!=_84){
_88[2]=_84;
_85[_86]=_88.join("!");
flush(_81,_85.join("!"));
}
}else{
if(_83.length>0){
var _89=_83.shift();
var _8a=_89[0];
if(_8a=="*"||_8a==_81.targetOrigin){
_81.lastWrite++;
var _8b=_89[1];
var _8c=_8b.shift();
var _8d=3;
var _88=[_81.targetToken,_81.lastWrite,_84,"F",_8c];
if(_8b.length>0){
_88[_8d]="f";
_81.queue.unshift(_89);
}
var _85=[_88.join("!")];
if(_81.resendAck){
var _8e=[_81.targetToken,_81.lastWrite-1,_84,"a"];
_85.unshift(_8e.join("!"));
}
flush(_81,_85.join("!"));
_81.lastFrames=_85;
_81.lastSyn=_81.lastWrite;
_81.resendAck=false;
}
}else{
if(_82){
_81.lastWrite++;
var _88=[_81.targetToken,_81.lastWrite,_84,"a"];
var _85=[_88.join("!")];
if(_81.resendAck){
var _8e=[_81.targetToken,_81.lastWrite-1,_84,"a"];
_85.unshift(_8e.join("!"));
}
flush(_81,_85.join("!"));
_81.lastFrames=_85;
_81.resendAck=true;
}
}
}
};
function process(_8f,_90){
var _91=_90.split("!");
var _92=_91.shift();
var _93=parseInt(_91.shift());
var _94=parseInt(_91.shift());
var _95=_91.shift();
if(_92!=_8f.sourceToken){
throw new Error("postMessage emulation tampering detected");
}
var _96=_8f.lastRead;
var _97=_96+1;
if(_93==_97){
_8f.lastRead=_97;
}
if(_93==_97||_93==_96){
_8f.lastAck=_94;
}
if(_93==_97||(_93==_96&&_95=="a")){
switch(_95){
case "f":
var _98=_91.join("!");
_8f.escapedFragments.push(_98);
dequeue(_8f,true);
break;
case "F":
var _99=_91.join("!");
if(_8f.escapedFragments!==undefined){
_8f.escapedFragments.push(_99);
_99=_8f.escapedFragments.join("");
_8f.escapedFragments=[];
}
var _9a=unescape(_99);
dispatch(_9a,_8f.target,_8f.targetOrigin);
dequeue(_8f,true);
break;
case "a":
if(_91.length>0){
process(_8f,_91.join("!"));
}else{
dequeue(_8f,false);
}
break;
default:
throw new Error("unknown postMessage emulation payload type: "+_95);
}
}
};
function dispatch(_9b,_9c,_9d){
var _9e=document.createEvent("Events");
_9e.initEvent("message",false,true);
_9e.data=_9b;
_9e.origin=_9d;
_9e.source=_9c;
dispatchEvent(_9e);
};
var _9f={};
var _a0=[];
function pollReaders(){
for(var i=0,len=_a0.length;i<len;i++){
var _a3=_a0[i];
_a3.poll();
}
setTimeout(pollReaders,20);
};
function findMessagePipe(_a4){
if(_a4==parent){
return _9f["parent"];
}else{
if(_a4.parent==window){
var _a5=document.getElementsByTagName("iframe");
for(var i=0;i<_a5.length;i++){
var _a7=_a5[i];
if(_a4==_a7.contentWindow){
return supplyIFrameMessagePipe(_a7);
}
}
}else{
throw new Error("Generic peer postMessage not yet implemented");
}
}
};
function supplyIFrameMessagePipe(_a8){
var _a9=_a8._name;
if(_a9===undefined){
_a9="iframe$"+String(Math.random()).substring(2);
_a8._name=_a9;
}
var _aa=_9f[_a9];
if(_aa===undefined){
_aa=new MessagePipe(_a8);
_9f[_a9]=_aa;
}
return _aa;
};
function postMessage0(_ab,_ac,_ad){
if(_ab==window){
if(_ad=="*"||_ad==_60){
dispatch(_ac,window,_60);
}
}else{
var _ae=findMessagePipe(_ab);
_ae.post(_ab,_ac,_ad);
}
};
postMessage0.attach=function(_af,_b0,_b1,_b2,_b3,_b4){
var _b5=findMessagePipe(_af);
_b5.attach(_af,_b0,_b1,_b2,_b3,_b4);
_a0.push(_b5);
};
postMessage0.detach=function(_b6){
var _b7=findMessagePipe(_b6);
for(var i=0;i<_a0.length;i++){
if(_a0[i]==_b7){
_a0.splice(i,1);
}
}
_b7.detach();
};
if(window!=top){
_9f["parent"]=new MessagePipe();
function pollParentOrigin(){
var _b9=location.hash;
if(document.body!=null&&_b9.length>1&&_b9.charAt(1)=="I"){
var _ba=unescape(_b9.substring(1));
var _bb=_ba.split("!");
if(_bb.shift()=="I"){
var _bc=_bb.shift();
var _bd=_bb.shift();
var _be=_bb.shift();
var _bf=_bb.shift();
var _c0=_bb.shift();
var _c1=_bb.shift();
if(_c1!==undefined){
location.hash="#"+_c1;
}
var _c2=findMessagePipe(parent);
_c2.targetToken=_be;
var _c3=_c2.sourceToken;
var _c4="parentBridge"+String(Math.random()).substring(2);
var _c5=new URI(_bd+_bf);
if(_c0){
var _c6=new URI(_c5.scheme+"://"+_c0);
if(typeof (_c6.port)!=="undefined"){
_c5.port=_c6.port;
}
_c5.host=_c6.host;
}
var _c7=_c5.toString()+"?.kr=xsp#"+escape([_bc,_c4,_60,_be,_c3,_bf,_61].join(","));
var _c8;
if(browser=="ie"){
_c8=document.createElement("<iframe id=\""+_c4+"\" name=\""+_c4+"\" src=\""+_c7+"\"></iframe>");
}else{
_c8=document.createElement("iframe");
_c8.src=_c7;
}
_c8.style.position="absolute";
_c8.style.left="-10px";
_c8.style.top="10px";
_c8.style.visibility="hidden";
_c8.style.width="0px";
_c8.style.height="0px";
document.body.appendChild(_c8);
return;
}
}
setTimeout(pollParentOrigin,20);
};
pollParentOrigin();
}
var _c9=document.getElementsByTagName("meta");
for(var i=0;i<_c9.length;i++){
if(_c9[i].name==="kaazing:postMessage"){
if("immediate"==_c9[i].content){
var _cb=function(){
var _cc=document.getElementsByTagName("iframe");
for(var i=0;i<_cc.length;i++){
var _ce=_cc[i];
if(_ce.style["KaaPostMessage"]=="immediate"){
_ce.style["KaaPostMessage"]="none";
var _cf=supplyIFrameMessagePipe(_ce);
bridgeIfNecessary(_cf,_ce.contentWindow);
}
}
setTimeout(_cb,20);
};
setTimeout(_cb,20);
}
break;
}
}
for(var i=0;i<_c9.length;i++){
if(_c9[i].name==="kaazing:postMessagePrefix"){
var _d0=_c9[i].content;
if(_d0!=null&&_d0.length>0){
if(_d0.charAt(0)!="/"){
_d0="/"+_d0;
}
_61=_d0;
}
}
}
setTimeout(pollReaders,20);
return postMessage0;
}
})();
var XMLHttpRequest0=(function(){
var _d1=new URI(location.href);
var _d2={"http":80,"https":443};
var _d3={};
var _d4={};
var _d5=0;
function XMLHttpRequest0(){
};
var _d6=XMLHttpRequest0.prototype;
_d6.readyState=0;
_d6.responseText="";
_d6.status=0;
_d6.statusText="";
_d6.onreadystatechange;
_d6.onerror;
_d6.onload;
_d6.onprogress;
_d6.open=function(_d7,_d8,_d9){
if(!_d9){
throw new Error("Asynchronous is required for cross-origin XMLHttpRequest emulation");
}
switch(this.readyState){
case 0:
case 4:
break;
default:
throw new Error("Invalid ready state");
}
if(this._id===undefined){
var id=_d5++;
_d4[id]=this;
this._id=id;
}
var uri=new URI(_d8);
var _dc=(uri.scheme!=null)?uri.scheme:_d1.scheme;
var _dd=(uri.host!=null)?uri.host:_d1.host;
var _de=(uri.port!=null)?uri.port:_d1.port;
if(_de==null){
_de=_d2[_dc];
}
var _df=_dc+"://"+_dd+":"+_de;
var _e0=_d3[_df];
if(_e0===undefined){
var _e1=document.createElement("iframe");
_e1.style.position="absolute";
_e1.style.left="-10px";
_e1.style.top="10px";
_e1.style.visibility="hidden";
_e1.style.width="0px";
_e1.style.height="0px";
var _e2=new URI(_d8);
_e2.query=".kr=xs";
_e2.path="/";
_e1.src=_e2.toString();
document.body.appendChild(_e1);
function post(_e3){
this.buffer.push(_e3);
};
function attach(id){
var _e5=this.attached[id];
if(_e5===undefined){
_e5={};
this.attached[id]=_e5;
}
if(_e5.timerID!==undefined){
clearTimeout(_e5.timerID);
delete _e5.timerID;
}
};
function detach(id){
var _e7=this.attached[id];
if(_e7!==undefined&&_e7.timerID===undefined){
var _e8=this;
_e7.timerID=setTimeout(function(){
delete _e8.attached[id];
var xhr=_d4[id];
if(xhr._pipe==_e0){
delete _d4[id];
delete xhr._id;
delete xhr._pipe;
}
postMessage0(_e0.iframe.contentWindow,["d",id].join("\uffff"),_e0.targetOrigin);
},10000);
}
};
_e0={"targetOrigin":_df,"iframe":_e1,"buffer":[],"post":post,"attach":attach,"detach":detach,"attached":{count:0}};
_d3[_df]=_e0;
function sendInitWhenReady(){
var _ea=_e1.contentWindow;
if(!_ea){
setTimeout(sendInitWhenReady,20);
}else{
postMessage0(_ea,"I",_df);
}
};
sendInitWhenReady();
}
this._pipe=_e0;
this._requestHeaders={};
this._method=_d7;
this._location=_d8;
this._responseHeaders=null;
this._readyState=1;
this.status=0;
this.statusText="";
this.responseText="";
_e0.attach(this._id);
var _eb=this;
setTimeout(function(){
_eb.readyState=1;
onreadystatechange(_eb);
},0);
};
_d6.setRequestHeader=function(_ec,_ed){
if(this._readyState!==1){
throw new Error("Invalid ready state");
}
this._requestHeaders[_ec]=_ed;
};
_d6.send=function(_ee){
if(this._readyState!==1){
throw new Error("Invalid ready state");
}
if(typeof (_ee)!=="string"){
_ee="";
}
var _ef=[];
for(var _f0 in this._requestHeaders){
_ef.push(_f0+"\ufffd"+this._requestHeaders[_f0]);
}
var _f1=(this.onprogress!==undefined);
this._pipe.post(["s",this._id,this._method,this._location,_ef.join("\ufffe"),_ee,_f1].join("\uffff"));
var _f2=this;
setTimeout(function(){
_f2.readyState=2;
onreadystatechange(_f2);
},0);
};
_d6.abort=function(){
var _f3=this._pipe;
if(_f3!==undefined){
_f3.post(["a",this._id].join("\uffff"));
_f3.detach(this._id);
}
};
_d6.getResponseHeader=function(_f4){
if(this.status==0){
throw new Error("Invalid ready state");
}
var _f5=this._responseHeaders;
return _f5[_f4];
};
_d6.getAllResponseHeaders=function(){
if(this.status==0){
throw new Error("Invalid ready state");
}
return null;
};
function onreadystatechange(_f6){
if(typeof (_f6.onreadystatechange)!=="undefined"){
_f6.onreadystatechange();
}
switch(_f6.readyState){
case 3:
if(typeof (_f6.onprogress)!=="undefined"){
_f6.onprogress();
}
break;
case 4:
if(typeof (_f6.onprogress)!=="undefined"){
_f6.onprogress();
}
if(typeof (_f6.onload)!=="undefined"){
_f6.onload();
}
break;
}
};
function onmessage(_f7){
var _f8=_f7.origin;
var _f9={"http":":80","https":":443"};
var _fa=_f8.split(":");
if(_fa.length===2){
_f8+=_f9[_fa[0]];
}
var _fb=_d3[_f8];
if(_fb!==undefined&&_fb.iframe!==undefined&&_f7.source==_fb.iframe.contentWindow){
if(_f7.data=="I"){
var _fc;
while((_fc=_fb.buffer.shift())!==undefined){
postMessage0(_fb.iframe.contentWindow,_fc,_fb.targetOrigin);
}
_fb.post=function(_fd){
postMessage0(_fb.iframe.contentWindow,_fd,_fb.targetOrigin);
};
}else{
var _fe=_f7.data.split("\uffff");
if(_fe.length>2){
var _ff=_fe.shift();
var id=_fe.shift();
var _101=_d4[id];
if(_101!==undefined){
switch(_ff){
case "r":
var _102=_fe.shift();
_101.status=parseInt(_fe.shift());
_101.statusText=_fe.shift();
var _103={};
var _104=_102.split("\n");
for(var i=0;i<_104.length;i++){
var _106=_104[i];
var _107=_106.indexOf(": ");
if(_107!=-1){
_103[_106.substring(0,_107)]=_106.substring(_107+1);
}
}
_101._responseHeaders=_103;
break;
case "p":
_101.readyState=parseInt(_fe.shift());
var _108=_fe.join("\uffff");
if(_108.length>0){
_101.responseText+=_108;
}
onreadystatechange(_101);
if(_101.readyState==4){
_fb.detach(id);
}
break;
}
}
}
}
}else{
}
};
window.addEventListener("message",onmessage,false);
return XMLHttpRequest0;
})();
(function(){
var _109=new URI(location.href);
if(browser=="ie"){
document._s_s_e_createElement=document.createElement;
document.createElement=function(name){
var _10b=this._s_s_e_createElement(name);
if(name=="eventsource"){
applyRemoteEventTargetMixin(_10b);
}
return _10b;
};
}else{
var _10c=document.createElement;
document.createElement=function(name){
var _10e=_10c.call(this,name);
if(name=="eventsource"){
applyRemoteEventTargetMixin(_10e);
}
return _10e;
};
}
window.addEventListener("load",function(_10f){
var _110=document.getElementsByTagName("eventsource");
for(var i=0;i<_110.length;i++){
var _112=_110[i];
applyRemoteEventTargetMixin(_112);
}
},false);
function applyRemoteEventTargetMixin(_113){
var _114=new RemoteEventTarget(_113);
_113.addEventSource=function(src){
_114.addEventSource(src);
};
_113.removeEventSource=function(src){
_114.removeEventSource(src);
};
};
function RemoteEventTarget(_117){
this.element=_117;
this.eventSources={};
};
var _118=RemoteEventTarget.prototype;
_118.addEventSource=function(src){
var _11a=resolve(src,true);
var _11b=this.eventSources[_11a];
if(_11b===undefined){
_11b=[];
this.eventSources[_11a]=_11b;
}
var _11c=new _11d(this.element,src);
_11b.push(_11c);
_11c.connect();
};
_118.removeEventSource=function(src){
var _11f=resolve(src,false);
if(_11f!=null){
var _120=this.eventSources[_11f];
if(_120!==undefined){
var _121=_120.pop();
if(_121!==undefined){
_121.disconnect();
}
}
}
};
function resolve(src,_123){
var _124=new URI(src);
if(_124.scheme!==undefined){
return src;
}
_124.scheme=_109.scheme;
_124.host=_109.host;
_124.port=_109.port;
var _125=_124.path;
if(_125.length>0){
if(_125.charAt(0)!="/"){
var _126=_109.path;
if(_126.length>0){
var _127=_126.lastIndexOf("/");
if(_127!=-1){
_124.path=[_126.substring(0,_127),_126].join("/");
}else{
_124.path="/"+_126;
}
}
return _124.toString();
}
}
if(_123){
throw new Error("SYNTAX_ERR");
}
return null;
};
var _11d=(function(){
function _11d(_128,src){
this.element=_128;
this.lastEventId=null;
this.immediate=false;
this.retry=3000;
this.src=src;
this.position=0;
this.lineQueue=[];
this.xhr=null;
this.reconnectTimer=null;
};
var _12a=_11d.prototype;
_12a.connect=function(){
if(this.reconnectTimer!==null){
this.reconnectTimer=null;
}
var _12b=new URI(this.src);
var _12c=[];
if(this.lastEventId!==null){
_12c.push(".ka="+this.lastEventId);
}
if(this.src.indexOf("&.kb=")===-1&&this.src.indexOf("?.kb=")===-1){
_12c.push(".kb=512");
}
switch(browser){
case "ie":
case "safari":
_12c.push(".kp=256");
break;
}
if(_12c.length>0){
if(_12b.query===undefined){
_12b.query=_12c.join("&");
}else{
_12b.query+="&"+_12c.join("&");
}
}
var xhr=this.xhr;
if(xhr===null){
this.xhr=xhr=new XMLHttpRequest0();
}
var _12e=this;
xhr.open("GET",_12b.toString(),true);
xhr.onprogress=function(){
process(_12e);
};
xhr.onload=function(){
process(_12e);
reconnect(_12e);
};
xhr.onerror=function(){
_12e.element.removeEventSource(_12e.src);
};
xhr.ontimeout=function(){
_12e.element.removeEventSource(_12e.src);
};
xhr.send(null);
};
_12a.disconnect=function(){
if(this.src!==null){
if(this.reconnectTimer!==null){
clearTimeout(this.reconnectTimer);
this.reconnectTimer=null;
}
if(this.xhr!==null){
this.xhr.onprogress=function(){
};
this.xhr.onload=function(){
};
this.xhr.onerror=function(){
};
this.xhr.abort();
}
this.position=0;
this.lineQueue=[];
this.lastEventId=null;
this.src=null;
}
};
function reconnect(_12f){
_12f.position=0;
if(_12f.src!==null){
var _130=_12f.retry;
if(_12f.immediate){
_12f.immediate=false;
_130=0;
}
_12f.reconnectTimer=setTimeout(function(){
_12f.connect();
},_130);
}
};
var _131=/[^\r\n]+|\r\n|\r|\n/g;
function process(_132){
var _133=_132.xhr.responseText;
var _134=_133.slice(_132.position);
var _135=_134.match(_131)||[];
var _136=_132.lineQueue;
var _137="";
while(_135.length>0){
var _138=_135.shift();
switch(_138.charAt(0)){
case "\r":
case "\n":
if(_137===""){
dispatch(_132);
}else{
_136.push(_137);
_137="";
}
break;
default:
_137=_138;
break;
}
}
_132.position=_133.length-_137.length;
};
function dispatch(_139){
var data="";
var name="message";
var _13c=_139.lineQueue;
while(_13c.length>0){
var line=_13c.shift();
var _13e=null;
var _13f="";
var _140=line.indexOf(":");
if(_140==-1){
_13e=line;
_13f="";
}else{
if(_140===0){
continue;
}else{
_13e=line.slice(0,_140);
var _141=_140+1;
if(line.charAt(_141)==" "){
_141++;
}
_13f=line.slice(_141);
}
}
switch(_13e){
case "event":
name=_13f;
break;
case "id":
_139.lastEventId=_13f;
break;
case "retry":
_13f=parseInt(_13f,10);
if(!isNaN(_13f)){
_139.retry=_13f;
}
break;
case "data":
if(data.length>0){
data+="\n";
}
data+=_13f;
break;
case "reconnect":
_139.immediate=true;
if(_13f!=""){
_139.src=_13f;
}
break;
default:
break;
}
}
if(data.length>0||(name.length>0&&name!="message")){
var e=document.createEvent("Events");
e.initEvent(name,true,true);
e.lastEventId=_139.lastEventId;
e.data=data;
e.origin=document.domain;
if(e.source!==null){
e.source=null;
}
_139.element.dispatchEvent(e);
}
};
return _11d;
})();
})();
if(typeof (window.WebSocket)==="undefined"){
WebSocket=(function(){
var _143=45000;
var _144={"ws":{scheme:"http",port:81},"wss":{scheme:"https",port:815}};
var _145=function(_146){
var _147=new URI(_146);
var _148=_144[_147.scheme];
if(_148===undefined){
throw new Error("SYNTAX_ERR: WebSocket location must use scheme \"ws\" or \"wss\"");
}
_147.scheme=_148.scheme;
if(_147.port===undefined){
_147.port=_148.port;
}
this._xhr=new XMLHttpRequest0();
this._seqId=0;
this._sendQueue=[];
var _149=this;
this.closeReceived=function(evt){
doClose(_149);
};
this.pingReceived=function(evt){
doResetTimer(_149);
doAcknowledge(_149,evt.lastEventId);
};
this.reconnectReceived=function(evt){
doResetTimer(_149);
};
this.messageReceived=function(evt){
doResetTimer(_149);
if(_149.readyState==1){
_149.onmessage(evt);
}else{
throw new Error("Unexpected Data");
}
};
doHandshake(this,_147);
};
var _14e=_145.prototype;
_14e.readyState=0;
_14e.onopen=function(){
};
_14e.onmessage=function(_14f){
};
_14e.onclosed=function(){
};
_14e.postMessage=function(data){
if(data===null){
throw new Error("data is null");
}
var _151=[];
_151.push("data:");
_151.push(data.split("\n").join("\r\ndata:"));
_151.push("\r\nid:");
_151.push(this._seqId++);
_151.push("\r\n\r\n");
this._sendQueue.push(_151.join(""));
if(!this.sending){
doSend(this);
}
};
_14e.disconnect=function(){
switch(this.readyState){
case 1:
case 2:
this.closeReceived();
break;
}
};
function doHandshake(_152,_153){
var xhr=_152._xhr;
xhr.open("POST",_153.toString(),true);
xhr.onreadystatechange=function(){
if(xhr.readyState==4){
switch(xhr.status){
case 201:
var _155=xhr.responseText.split("\n");
_152.upstream=new URI(_155[0]).toString();
_152.downstream=(_155.length>=2)?_155[1]:_155[0];
doBind(_152);
doOpen(_152);
break;
default:
doClose(_152);
break;
}
}
};
xhr.send(null);
};
function doBind(_156){
var _157=_156.downstream;
var _158=document.createElement("eventsource");
_158.addEventListener("message",_156.messageReceived,false);
_158.addEventListener("ping",_156.pingReceived,false);
_158.addEventListener("reconnect",_156.reconnectReceived,false);
_158.addEventListener("close",_156.closeReceived,false);
_158.addEventSource(_157);
document.body.appendChild(_158);
_156._eventSource=_158;
};
function doUnbind(_159){
var _15a=_159._eventSource;
if(_15a!==undefined){
_15a.removeEventSource(_159.downstream);
_15a.removeEventListener("message",_159.messageReceived,false);
_15a.removeEventListener("ping",_159.pingReceived,false);
_15a.removeEventListener("reconnect",_159.reconnectReceived,false);
_15a.removeEventListener("close",_159.closeReceived,false);
_15a.parentNode.removeChild(_15a);
delete _159._eventSource;
}
};
function doOpen(_15b){
_15b.readyState=1;
doResetTimer(_15b);
_15b.onopen();
};
function doSend(_15c){
var _15d=_15c._sendQueue;
var _15e=_15d.length;
_15c.sending=(_15e>0);
if(_15e>0){
var xhr=_15c._xhr;
xhr.open("POST",_15c.upstream,true);
xhr.setRequestHeader("Content-Type","text/plain; charset=UTF-8");
xhr.onreadystatechange=function(){
if(xhr.readyState===4){
switch(xhr.status){
case 200:
_15d.splice(0,_15e);
setTimeout(function(){
doSend(_15c);
},0);
break;
default:
doClose(_15c);
}
}
};
xhr.send(_15d.join(""));
doResetTimer(_15c);
}
};
function doAcknowledge(_160,_161){
var _162=[];
_162.push("event:ack\r\ndata:");
_162.push(_161);
_162.push("\r\nid:");
_162.push(_160._seqId++);
_162.push("\r\n\r\n");
_160._sendQueue.push(_162.join(""));
if(!_160.sending){
doSend(_160);
}
};
function doClose(_163){
if(_163.readyState<2){
_163.readyState=2;
doUnbind(_163);
_163._xhr.abort();
_163.onclosed();
}
};
function doResetTimer(_164){
if(_164._pingTimer!==null){
clearTimeout(_164._pingTimer);
}
_164._pingTimer=setTimeout(function(){
doClose(_164);
},_143);
};
return _145;
})();
}
function Charset(){
};
(function(){
var _165=Charset.prototype;
_165.decode=function(buf){
};
_165.encode=function(text){
};
Charset.UTF8=(function(){
function UTF8(){
};
UTF8.prototype=new Charset();
var _168=UTF8.prototype;
_168.decode=function(buf){
var _16a=[];
while(buf.hasRemaining()){
var _16b=buf.remaining();
var _16c=buf.getUnsigned();
var _16d=charByteCount(_16c);
if(_16b<_16d){
buf.skip(-1);
break;
}
var _16e=null;
switch(_16d){
case 1:
_16e=_16c;
break;
case 2:
_16e=((_16c&31)<<6)|(buf.getUnsigned()&63);
break;
case 3:
_16e=((_16c&15)<<12)|((buf.getUnsigned()&63)<<6)|(buf.getUnsigned()&63);
break;
case 4:
_16e=((_16c&7)<<18)|((buf.getUnsigned()&63)<<12)|((buf.getUnsigned()&63)<<6)|(buf.getUnsigned()&63);
break;
}
_16a.push(String.fromCharCode(_16e));
}
return _16a.join("");
};
_168.encode=function(str,buf){
for(var i=0;i<str.length;i++){
var _172=str.charCodeAt(i);
if(_172<128){
buf.put(_172);
}else{
if(_172<2048){
buf.put((_172>>6)|192);
buf.put((_172&63)|128);
}else{
if(_172<65536){
buf.put((_172>>12)|224);
buf.put(((_172>>6)&63)|128);
buf.put((_172&63)|128);
}else{
if(_172<1114112){
buf.put((_172>>18)|240);
buf.put(((_172>>12)&63)|128);
buf.put(((_172>>6)&63)|128);
buf.put((_172&63)|128);
}else{
throw new Error("Invalid UTF-8 string");
}
}
}
}
}
};
function charByteCount(b){
if((b&128)===0){
return 1;
}
if((b&32)===0){
return 2;
}
if((b&16)===0){
return 3;
}
if((b&8)===0){
return 4;
}
throw new Error("Invalid UTF-8 bytes");
};
return new UTF8();
})();
})();
ByteOrder=function(){
};
(function(){
var _174=4294967296;
var _175=ByteOrder.prototype;
_175.toString=function(){
throw new Error("Abstract");
};
var _176=function(v,_178){
var _179=[];
for(var i=0;i<_178;i++){
var val=(v>>(i*8))&255;
_179.unshift(val);
}
return _179;
};
var _17c=function(_17d){
var val=0;
var _17f=_17d.length;
for(var i=0;i<_17f;i++){
val=val*256;
val+=_17d[i];
}
return val;
};
var _181=function(x,_183){
if(x>=0){
return x;
}
var _184=Math.pow(2,_183*8)-1;
return x+_184+1;
};
var _185=function(x,_187){
if(x<0){
return x;
}
var _188=Math.pow(2,_187*8)-1;
if(x>(_188/2)){
return x-(_188+1);
}else{
return x;
}
};
_175._putValue=function(_189,i,v,_18c){
var val=v;
val=_181(v,_18c);
if(false){
throw new Error("cannot pack 64bit integer");
var _18e=x/_174;
var _18f=x%_174;
_175._putValue(_189,_18e,4,unsigned);
_175._putValue(_189,_18f,4,true);
}else{
var _190=_176(val,_18c);
_190=this._reorder(_190);
var func=_189.splice;
var args=[i,_18c].concat(_190);
func.apply(_189,args);
}
};
_175._getValue=function(_193,i,_195,_196){
var _197=_193.slice(i,i+_195);
_197=this._reorder(_197);
var val=_17c(_197);
if(typeof (_196)==="undefined"||!_196){
val=_185(val,_195);
}
return val;
};
ByteOrder.BIG_ENDIAN=(function(){
var _199=function(){
};
_199.prototype=new ByteOrder();
var _19a=_199.prototype;
_19a._reorder=function(_19b){
return _19b;
};
_19a.toString=function(){
return "<ByteOrder.BIG_ENDIAN>";
};
return new _199();
})();
ByteOrder.LITTLE_ENDIAN=(function(){
var _19c=function(){
};
_19c.prototype=new ByteOrder();
var _19d=_19c.prototype;
_19d._reorder=function(_19e){
return _19e.reverse();
};
_19d.toString=function(){
return "<ByteOrder.LITTLE_ENDIAN>";
};
return new _19c();
})();
})();
function ByteBuffer(_19f){
this.array=_19f||[];
this._mark=-1;
this.limit=this.capacity=this.array.length;
this.order=ByteOrder.BIG_ENDIAN;
};
(function(){
ByteBuffer.allocate=function(_1a0){
var buf=new ByteBuffer();
buf.capacity=_1a0;
return buf;
};
ByteBuffer.wrap=function(_1a2){
return new ByteBuffer(_1a2);
};
var _1a3=ByteBuffer.prototype;
_1a3.autoExpand=true;
_1a3.capacity=0;
_1a3.position=0;
_1a3.limit=0;
_1a3.order=ByteOrder.BIG_ENDIAN;
_1a3.array=[];
_1a3.mark=function(){
this._mark=this.position;
return this;
};
_1a3.reset=function(){
var m=this._mark;
if(m<0){
throw new Error("Invalid mark");
}
this.position=m;
return this;
};
_1a3.compact=function(){
this.array.splice(0,this.position);
this.limit-=this.position;
this.position=0;
return this;
};
_1a3.duplicate=function(){
var buf=new ByteBuffer(this.array);
buf.position=this.position;
buf.limit=this.limit;
buf.capacity=this.capacity;
return buf;
};
_1a3.fill=function(size){
_autoExpand(this,size);
while(size-->0){
this.put(0);
}
return this;
};
_1a3.fillWith=function(b,size){
_autoExpand(this,size);
while(size-->0){
this.put(b);
}
return this;
};
_1a3.indexOf=function(b){
var _1aa=this.limit;
var _1ab=this.array;
for(var i=this.position;i<_1aa;i++){
if(_1ab[i]==b){
return i;
}
}
return -1;
};
_1a3.put=function(v){
_autoExpand(this,1);
this.putAt(this.position++,v);
return this;
};
_1a3.putAt=function(i,v){
_checkIndex(this,i);
this.array[i]=(v&255);
return this;
};
_1a3.putShort=function(v){
_autoExpand(this,2);
this.putShortAt(this.position,v);
this.position+=2;
return this;
};
_1a3.putShortAt=function(i,v){
this.order._putValue(this.array,i,v,2);
return this;
};
_1a3.putMediumInt=function(v){
_autoExpand(this,3);
this.putMediumIntAt(this.position,v);
this.position+=3;
return this;
};
_1a3.putMediumIntAt=function(i,v){
this.order._putValue(this.array,i,v,3);
return this;
};
_1a3.putInt=function(v){
_autoExpand(this,4);
this.putIntAt(this.position,v);
this.position+=4;
return this;
};
_1a3.putIntAt=function(i,v){
this.order._putValue(this.array,i,v,4);
return this;
};
_1a3.putLong=function(v){
_autoExpand(this,8);
this.putLongAt(this.position,v);
this.position+=8;
return this;
};
_1a3.putLongAt=function(i,v){
this.order._putValue(this.array,i,v,8);
return this;
};
_1a3.putString=function(v,cs){
cs.encode(v,this);
return this;
};
_1a3.putPrefixedString=function(_1be,v,cs){
if(typeof (cs)==="undefined"||typeof (cs.encode)==="undefined"){
throw new Error("ByteBuffer.putPrefixedString: character set parameter missing");
}
if(_1be===0){
return this;
}
_autoExpand(this,_1be);
var len=v.length;
switch(_1be){
case 1:
this.put(len);
break;
case 2:
this.putShort(len);
break;
case 4:
this.putInt(len);
break;
}
cs.encode(v,this);
return this;
};
_1a3.putBytes=function(v){
_autoExpand(this,v.length);
this.putBytesAt(this.position,v);
this.position+=v.length;
return this;
};
_1a3.putBytesAt=function(i,v){
for(var j=0,k=i,len=v.length;j<len;j++,k++){
this.putAt(k,v[j]);
}
return this;
};
_1a3.putBuffer=function(v){
this.putBytes(v.array.slice(v.position,v.limit));
return this;
};
_1a3.putBufferAt=function(i,v){
this.putBytesAt(i,v.array.slice(v.position,v.limit));
return this;
};
_1a3.get=function(){
return this.getAt(this.position++);
};
_1a3.getAt=function(i){
return this.order._getValue(this.array,i,1);
};
_1a3.getShort=function(){
var val=this.getShortAt(this.position);
this.position+=2;
return val;
};
_1a3.getShortAt=function(i){
return this.order._getValue(this.array,i,2);
};
_1a3.getMediumInt=function(){
var val=this.getMediumIntAt(this.position);
this.position+=3;
return val;
};
_1a3.getMediumIntAt=function(i){
return this.order._getValue(this.array,i,3);
};
_1a3.getInt=function(){
var val=this.getIntAt(this.position);
this.position+=4;
return val;
};
_1a3.getIntAt=function(i){
return this.order._getValue(this.array,i,4);
};
_1a3.getLong=function(){
var val=this.getLongAt(this.position);
this.position+=8;
return val;
};
_1a3.getLongAt=function(i){
return this.order._getValue(this.array,i,8);
};
_1a3.getUnsigned=function(){
return (this.get()&255);
};
_1a3.getUnsignedShort=function(){
var val=(this.getShort()&65535);
};
_1a3.getUnsignedMediumInt=function(){
return (this.getMediumInt()&16777215);
};
_1a3.getUnsignedInt=function(){
var val=this.order._getValue(this.array,this.position,4,true);
this.position+=4;
return val;
};
_1a3.getPrefixedString=function(_1d6,cs){
var len=0;
switch(_1d6||2){
case 1:
len=this.getUnsigned();
break;
case 2:
len=this.getUnsignedShort();
break;
case 4:
len=this.getInt();
break;
}
if(len===0){
return "";
}
var _1d9=this.limit;
try{
this.limit=this.position+len;
return cs.decode(this);
}
finally{
this.limit=_1d9;
}
};
_1a3.getString=function(cs){
var _1db=this.position;
var _1dc=this.limit;
var _1dd=this.array;
while(_1db<_1dc&&_1dd[_1db]!==0){
_1db++;
}
try{
this.limit=_1db;
return cs.decode(this);
}
finally{
if(_1db!=_1dc){
this.limit=_1dc;
this.position=_1db+1;
}
}
};
_1a3.slice=function(){
return new ByteBuffer(this.array.slice(this.position,this.limit));
};
_1a3.flip=function(){
this.limit=this.position;
this.position=0;
this._mark=-1;
return this;
};
_1a3.rewind=function(){
this.position=0;
this._mark=-1;
return this;
};
_1a3.clear=function(){
this.position=0;
this.limit=this.capacity;
this._mark=-1;
return this;
};
_1a3.remaining=function(){
return (this.limit-this.position);
};
_1a3.hasRemaining=function(){
return (this.limit>this.position);
};
_1a3.skip=function(size){
this.position+=size;
return this;
};
_1a3.getHexDump=function(){
var _1df=this.array;
var pos=this.position;
var _1e1=this.limit;
if(pos==_1e1){
return "empty";
}
var _1e2=[];
for(var i=pos;i<_1e1;i++){
var hex=(_1df[i]||0).toString(16);
if(hex.length==1){
hex="0"+hex;
}
_1e2.push(hex);
}
return _1e2.join(" ");
};
_1a3.toString=_1a3.getHexDump;
_1a3.expand=function(_1e5){
return this.expandAt(this.position,_1e5);
};
_1a3.expandAt=function(i,_1e7){
var end=i+_1e7;
if(end>this.capacity){
this.capacity=end;
}
if(end>this.limit){
this.limit=end;
}
return this;
};
function _castToByte(v){
var _1ea=v&255;
return (_1ea>128?_1ea-256:_1ea);
};
function _autoExpand(_1eb,_1ec){
if(_1eb.autoExpand){
_1eb.expand(_1ec);
}
return this;
};
function _checkIndex(_1ed,_1ee){
if(_1ee<0||_1ee>_1ed.capacity){
throw new Error("Index out of bounds");
}
return this;
};
})();
if(typeof (window.ByteSocket)==="undefined"){
ByteSocket=(function(){
var _1ef=function(_1f0){
var _1f1=this;
var _1f2=new URI(_1f0);
var _1f3=_1f2.query;
var _1f4=(_1f3!==undefined)?_1f3.split("&"):[];
_1f4.push("encoding=base64");
_1f2.query=_1f4.join("&");
var ws=new WebSocket(_1f2.toString());
ws.onopen=function(){
_1f1.readyState=ws.readyState;
_1f1.onopen();
};
ws.onmessage=function(evt){
evt.data=fromBase64(evt.data);
_1f1.onmessage(evt);
};
ws.onclosed=function(){
_1f1.readyState=ws.readyState;
_1f1.onclosed();
};
_1f1._ws=ws;
};
var _1f7=_1ef.prototype;
_1f7.onopen=function(){
};
_1f7.onclosed=function(){
};
_1f7.onmessage=function(evt){
};
_1f7.readyState=0;
_1f7.postMessage=function(data){
if(data.constructor!==ByteBuffer){
throw new Error("Sending binary data requires using a ByteBuffer");
}
this._ws.postMessage(toBase64(data));
};
_1f7.disconnect=function(){
this._ws.disconnect();
};
function fromBase64(_1fa){
if(_1fa.length===0){
return [];
}
if(_1fa.length%4!==0){
throw new Error("Invalid base64 string (must be quads)");
}
var _1fb=new ByteBuffer();
for(var i=0;i<_1fa.length;i+=4){
var _1fd=_1fa.charAt(i);
var _1fe=_1fa.charAt(i+1);
var _1ff=_1fa.charAt(i+2);
var _200=_1fa.charAt(i+3);
var _201=_202[_1fd];
var _203=_202[_1fe];
var _204=_202[_1ff];
var _205=_202[_200];
_1fb.put(((_201<<2)&252)|((_203>>4)&3));
if(_1ff!="="){
_1fb.put(((_203<<4)&240)|((_204>>2)&15));
if(_200!="="){
_1fb.put(((_204<<6)&192)|(_205&63));
}
}
}
return _1fb.flip();
};
function toBase64(buf){
var _207=[];
var _208;
var _209;
var _20a;
while(buf.hasRemaining()){
switch(buf.remaining()){
case 1:
_208=buf.getUnsigned();
_207.push(_20b[(_208>>2)&63]);
_207.push(_20b[((_208<<4)&48)]);
_207.push("=");
_207.push("=");
break;
case 2:
_208=buf.getUnsigned();
_209=buf.getUnsigned();
_207.push(_20b[(_208>>2)&63]);
_207.push(_20b[((_208<<4)&48)|((_209>>4)&15)]);
_207.push(_20b[(_209<<2)&60]);
_207.push("=");
break;
default:
_208=buf.getUnsigned();
_209=buf.getUnsigned();
_20a=buf.getUnsigned();
_207.push(_20b[(_208>>2)&63]);
_207.push(_20b[((_208<<4)&48)|((_209>>4)&15)]);
_207.push(_20b[((_209<<2)&60)|((_20a>>6)&3)]);
_207.push(_20b[_20a&63]);
break;
}
}
return _207.join("");
};
var _20b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
var _202={"=":0};
for(var i=0;i<_20b.length;i++){
_202[_20b[i]]=i;
}
return _1ef;
})();
}
