/**
 * Copyright (c) 2007-2009, Kaazing Corporation. All rights reserved.
 * 
 * Licensed under the Kaazing Corporation Developer Agreement (2009-07-13), see:
 * 
 *   http://www.kaazing.com/license
 * 
 */

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");
}
}
}
}
}
switch(browser){
case "ie":
(function(){
if(document.createEvent===undefined){
var _1=function(){
};
_1.prototype.initEvent=function(_2,_3,_4){
this.type=_2;
this.bubbles=_3;
this.cancelable=_4;
};
document.createEvent=function(_5){
if(_5!="Events"){
throw new Error("Unsupported event name: "+_5);
}
return new _1();
};
}
document._w_3_c_d_o_m_e_v_e_n_t_s_createElement=document.createElement;
document.createElement=function(_6){
var _7=this._w_3_c_d_o_m_e_v_e_n_t_s_createElement(_6);
if(_7.addEventListener===undefined){
var _8={};
_7.addEventListener=function(_9,_a,_b){
return addEventListener(_8,_9,_a,_b);
};
_7.removeEventListener=function(_c,_d,_e){
return removeEventListener(_8,_c,_d,_e);
};
_7.dispatchEvent=function(_f){
return dispatchEvent(_8,_f);
};
}
return _7;
};
if(window.addEventListener===undefined){
var _10=document.createElement("div");
var _11=(typeof (postMessage)==="undefined");
window.addEventListener=function(_12,_13,_14){
if(_11&&_12=="message"){
_10.addEventListener(_12,_13,_14);
}else{
window.attachEvent("on"+_12,_13);
}
};
window.removeEventListener=function(_15,_16,_17){
if(_11&&_15=="message"){
_10.removeEventListener(_15,_16,_17);
}else{
window.detachEvent("on"+_15,_16);
}
};
window.dispatchEvent=function(_18){
if(_11&&_18.type=="message"){
_10.dispatchEvent(_18);
}else{
window.fireEvent("on"+_18.type,_18);
}
};
}
function addEventListener(_19,_1a,_1b,_1c){
if(_1c){
throw new Error("Not implemented");
}
var _1d=_19[_1a]||{};
_19[_1a]=_1d;
_1d[_1b]=_1b;
};
function removeEventListener(_1e,_1f,_20,_21){
if(_21){
throw new Error("Not implemented");
}
var _22=_1e[_1f]||{};
delete _22[_20];
};
function dispatchEvent(_23,_24){
var _25=_24.type;
var _26=_23[_25]||{};
for(var key in _26){
if(typeof (_26[key])=="function"){
try{
_26[key](_24);
}
catch(e){
}
}
}
};
})();
break;
case "chrome":
case "safari":
if(typeof (window.postMessage)==="undefined"&&typeof (window.dispatchEvent)==="undefined"&&typeof (document.dispatchEvent)==="function"){
window.dispatchEvent=function(_28){
document.dispatchEvent(_28);
};
var addEventListener0=window.addEventListener;
window.addEventListener=function(_29,_2a,_2b){
if(_29==="message"){
document.addEventListener(_29,_2a,_2b);
}else{
addEventListener0.call(window,_29,_2a,_2b);
}
};
var removeEventListener0=window.removeEventListener;
window.removeEventListener=function(_2c,_2d,_2e){
if(_2c==="message"){
document.removeEventListener(_2c,_2d,_2e);
}else{
removeEventListener0.call(window,_2c,_2d,_2e);
}
};
}
break;
case "opera":
var addEventListener0=window.addEventListener;
window.addEventListener=function(_2f,_30,_31){
var _32=_30;
if(_2f==="message"){
_32=function(_33){
if(_33.origin===undefined&&_33.uri!==undefined){
var uri=new URI(_33.uri);
delete uri.path;
delete uri.query;
delete uri.fragment;
_33.origin=uri.toString();
}
return _30(_33);
};
_30._$=_32;
}
addEventListener0.call(window,_2f,_32,_31);
};
var removeEventListener0=window.removeEventListener;
window.removeEventListener=function(_35,_36,_37){
var _38=_36;
if(_35==="message"){
_38=_36._$;
}
removeEventListener0.call(window,_35,_38,_37);
};
break;
}
function URI(str){
str=str||"";
var _3a=0;
var _3b=str.indexOf("://");
if(_3b!=-1){
this.scheme=str.slice(0,_3b);
_3a=_3b+3;
var _3c=str.indexOf("/",_3a);
if(_3c==-1){
_3c=str.length;
str+="/";
}
var _3d=str.slice(_3a,_3c);
this.authority=_3d;
_3a=_3c;
this.host=_3d;
var _3e=_3d.indexOf(":");
if(_3e!=-1){
this.host=_3d.slice(0,_3e);
this.port=parseInt(_3d.slice(_3e+1),10);
if(isNaN(this.port)){
throw new Error("Invalid URI syntax");
}
}
}
var _3f=str.indexOf("?",_3a);
if(_3f!=-1){
this.path=str.slice(_3a,_3f);
_3a=_3f+1;
}
var _40=str.indexOf("#",_3a);
if(_40!=-1){
if(_3f!=-1){
this.query=str.slice(_3a,_40);
}else{
this.path=str.slice(_3a,_40);
}
_3a=_40+1;
this.fragment=str.slice(_3a);
}else{
if(_3f!=-1){
this.query=str.slice(_3a);
}else{
this.path=str.slice(_3a);
}
}
};
(function(){
var _41=URI.prototype;
_41.toString=function(){
var sb=[];
var _43=this.scheme;
if(_43!==undefined){
sb.push(_43);
sb.push("://");
sb.push(this.host);
var _44=this.port;
if(_44!==undefined){
sb.push(":");
sb.push(_44.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 _45={"http":80,"ws":81,"https":443,"wss":815};
})();
(function(){
Base64={};
Base64.encode=function(_46){
var _47=[];
var _48;
var _49;
var _4a;
while(_46.length){
switch(_46.length){
case 1:
_48=_46.shift();
_47.push(_4b[(_48>>2)&63]);
_47.push(_4b[((_48<<4)&48)]);
_47.push("=");
_47.push("=");
break;
case 2:
_48=_46.shift();
_49=_46.shift();
_47.push(_4b[(_48>>2)&63]);
_47.push(_4b[((_48<<4)&48)|((_49>>4)&15)]);
_47.push(_4b[(_49<<2)&60]);
_47.push("=");
break;
default:
_48=_46.shift();
_49=_46.shift();
_4a=_46.shift();
_47.push(_4b[(_48>>2)&63]);
_47.push(_4b[((_48<<4)&48)|((_49>>4)&15)]);
_47.push(_4b[((_49<<2)&60)|((_4a>>6)&3)]);
_47.push(_4b[_4a&63]);
break;
}
}
return _47.join("");
};
Base64.decode=function(_4c){
if(_4c.length===0){
return [];
}
if(_4c.length%4!==0){
throw new Error("Invalid base64 string (must be quads)");
}
var _4d=[];
for(var i=0;i<_4c.length;i+=4){
var _4f=_4c.charAt(i);
var _50=_4c.charAt(i+1);
var _51=_4c.charAt(i+2);
var _52=_4c.charAt(i+3);
var _53=_54[_4f];
var _55=_54[_50];
var _56=_54[_51];
var _57=_54[_52];
_4d.push(((_53<<2)&252)|((_55>>4)&3));
if(_51!="="){
_4d.push(((_55<<4)&240)|((_56>>2)&15));
if(_52!="="){
_4d.push(((_56<<6)&192)|(_57&63));
}
}
}
return _4d;
};
var _4b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
var _54={"=":0};
for(var i=0;i<_4b.length;i++){
_54[_4b[i]]=i;
}
if(typeof (window.btoa)==="undefined"){
window.btoa=function(s){
var _5a=s.split("");
for(var i=0;i<_5a.length;i++){
_5a[i]=(_5a[i]).charCodeAt();
}
return Base64.encode(_5a);
};
window.atob=function(_5c){
var _5d=Base64.decode(_5c);
for(var i=0;i<_5d.length;i++){
_5d[i]=String.fromCharCode(_5d[i]);
}
return _5d.join("");
};
}
})();
var postMessage0=(function(){
var _5f=new URI((browser=="ie")?document.URL:location.href);
var _60={"http":80,"https":443};
if(_5f.port==null){
_5f.port=_60[_5f.scheme];
_5f.authority=_5f.host+":"+_5f.port;
}
var _61=_5f.scheme+"://"+_5f.authority;
var _62="/.kr";
if(typeof (postMessage)!=="undefined"){
return function(_63,_64,_65){
switch(browser){
case "ie":
case "opera":
case "firefox":
setTimeout(function(){
_63.postMessage(_64,_65);
},0);
break;
default:
_63.postMessage(_64,_65);
break;
}
};
}else{
function MessagePipe(_66){
this.sourceToken=toPaddedHex(Math.floor(Math.random()*(Math.pow(2,32)-1)),8);
this.iframe=_66;
this.bridged=false;
this.lastWrite=0;
this.lastRead=0;
this.lastReadIndex=2;
this.lastSyn=0;
this.lastAck=0;
this.queue=[];
this.escapedFragments=[];
};
var _67=MessagePipe.prototype;
_67.attach=function(_68,_69,_6a,_6b,_6c,_6d){
this.target=_68;
this.targetOrigin=_69;
this.targetToken=_6a;
this.reader=_6b;
this.writer=_6c;
this.writerURL=_6d;
try{
this._lastHash=_6b.location.hash;
this.poll=pollLocationHash;
}
catch(permissionDenied){
this._lastDocumentURL=_6b.document.URL;
this.poll=pollDocumentURL;
}
if(_68==parent){
dequeue(this,true);
}
};
_67.detach=function(){
this.poll=function(){
};
delete this.target;
delete this.targetOrigin;
delete this.reader;
delete this.lastFragment;
delete this.writer;
delete this.writerURL;
};
_67.poll=function(){
};
function pollLocationHash(){
var _6e=this.reader.location.hash;
if(this._lastHash!=_6e){
process(this,_6e.substring(1));
this._lastHash=_6e;
}
};
function pollDocumentURL(){
var _6f=this.reader.document.URL;
if(this._lastDocumentURL!=_6f){
var _70=_6f.indexOf("#");
if(_70!=-1){
process(this,_6f.substring(_70+1));
this._lastDocumentURL=_6f;
}
}
};
_67.post=function(_71,_72,_73){
bridgeIfNecessary(this,_71);
var _74=1000;
var _75=escape(_72);
var _76=[];
while(_75.length>_74){
var _77=_75.substring(0,_74);
_75=_75.substring(_74);
_76.push(_77);
}
_76.push(_75);
this.queue.push([_73,_76]);
if(this.writer!=null&&this.lastAck>=this.lastSyn){
dequeue(this,false);
}
};
function bridgeIfNecessary(_78,_79){
if(_78.lastWrite<1&&!_78.bridged){
if(_79.parent==window){
var src=_78.iframe.src;
var _7b=src.split("#");
var _7c=null;
var _7d=document.getElementsByTagName("meta");
for(var i=0;i<_7d.length;i++){
if(_7d[i].name=="kaazing:resources"){
_7c=_7d[i].content;
}
}
var _7f=["I",document.domain,escape(_61),_78.sourceToken,escape(_62),_7c];
if(_7b.length>1){
var _80=_7b[1];
_7f.push(escape(_80));
}
_7b[1]=_7f.join("!");
setTimeout(function(){
_79.location.replace(_7b.join("#"));
},200);
_78.bridged=true;
}
}
};
function flush(_81,_82){
var _83=_81.writerURL+"#"+_82;
_81.writer.location.replace(_83);
};
function fromHex(_84){
return parseInt(_84,16);
};
function toPaddedHex(_85,_86){
var hex=_85.toString(16);
var _88=[];
_86-=hex.length;
while(_86-->0){
_88.push("0");
}
_88.push(hex);
return _88.join("");
};
function dequeue(_89,_8a){
var _8b=_89.queue;
var _8c=_89.lastRead;
if((_8b.length>0||_8a)&&_89.lastSyn>_89.lastAck){
var _8d=_89.lastFrames;
var _8e=_89.lastReadIndex;
if(fromHex(_8d[_8e])!=_8c){
_8d[_8e]=toPaddedHex(_8c,8);
flush(_89,_8d.join(""));
}
}else{
if(_8b.length>0){
var _8f=_8b.shift();
var _90=_8f[0];
if(_90=="*"||_90==_89.targetOrigin){
_89.lastWrite++;
var _91=_8f[1];
var _92=_91.shift();
var _93=3;
var _8d=[_89.targetToken,toPaddedHex(_89.lastWrite,8),toPaddedHex(_8c,8),"F",toPaddedHex(_92.length,4),_92];
var _8e=2;
if(_91.length>0){
_8d[_93]="f";
_89.queue.unshift(_8f);
}
if(_89.resendAck){
var _94=[_89.targetToken,toPaddedHex(_89.lastWrite-1,8),toPaddedHex(_8c,8),"a"];
_8d=_94.concat(_8d);
_8e+=_94.length;
}
flush(_89,_8d.join(""));
_89.lastFrames=_8d;
_89.lastReadIndex=_8e;
_89.lastSyn=_89.lastWrite;
_89.resendAck=false;
}
}else{
if(_8a){
_89.lastWrite++;
var _8d=[_89.targetToken,toPaddedHex(_89.lastWrite,8),toPaddedHex(_8c,8),"a"];
var _8e=2;
if(_89.resendAck){
var _94=[_89.targetToken,toPaddedHex(_89.lastWrite-1,8),toPaddedHex(_8c,8),"a"];
_8d=_94.concat(_8d);
_8e+=_94.length;
}
flush(_89,_8d.join(""));
_89.lastFrames=_8d;
_89.lastReadIndex=_8e;
_89.resendAck=true;
}
}
}
};
function process(_95,_96){
var _97=_96.substring(0,8);
var _98=fromHex(_96.substring(8,16));
var _99=fromHex(_96.substring(16,24));
var _9a=_96.charAt(24);
if(_97!=_95.sourceToken){
throw new Error("postMessage emulation tampering detected");
}
var _9b=_95.lastRead;
var _9c=_9b+1;
if(_98==_9c){
_95.lastRead=_9c;
}
if(_98==_9c||_98==_9b){
_95.lastAck=_99;
}
if(_98==_9c||(_98==_9b&&_9a=="a")){
switch(_9a){
case "f":
var _9d=_96.substr(29,fromHex(_96.substring(25,29)));
_95.escapedFragments.push(_9d);
dequeue(_95,true);
break;
case "F":
var _9e=_96.substr(29,fromHex(_96.substring(25,29)));
if(_95.escapedFragments!==undefined){
_95.escapedFragments.push(_9e);
_9e=_95.escapedFragments.join("");
_95.escapedFragments=[];
}
var _9f=unescape(_9e);
dispatch(_9f,_95.target,_95.targetOrigin);
dequeue(_95,true);
break;
case "a":
if(_96.length>25){
process(_95,_96.substring(25));
}else{
dequeue(_95,false);
}
break;
default:
throw new Error("unknown postMessage emulation payload type: "+_9a);
}
}
};
function dispatch(_a0,_a1,_a2){
var _a3=document.createEvent("Events");
_a3.initEvent("message",false,true);
_a3.data=_a0;
_a3.origin=_a2;
_a3.source=_a1;
dispatchEvent(_a3);
};
var _a4={};
var _a5=[];
function pollReaders(){
for(var i=0,len=_a5.length;i<len;i++){
var _a8=_a5[i];
_a8.poll();
}
setTimeout(pollReaders,20);
};
function findMessagePipe(_a9){
if(_a9==parent){
return _a4["parent"];
}else{
if(_a9.parent==window){
var _aa=document.getElementsByTagName("iframe");
for(var i=0;i<_aa.length;i++){
var _ac=_aa[i];
if(_a9==_ac.contentWindow){
return supplyIFrameMessagePipe(_ac);
}
}
}else{
throw new Error("Generic peer postMessage not yet implemented");
}
}
};
function supplyIFrameMessagePipe(_ad){
var _ae=_ad._name;
if(_ae===undefined){
_ae="iframe$"+String(Math.random()).substring(2);
_ad._name=_ae;
}
var _af=_a4[_ae];
if(_af===undefined){
_af=new MessagePipe(_ad);
_a4[_ae]=_af;
}
return _af;
};
function postMessage0(_b0,_b1,_b2){
if(_b0==window){
if(_b2=="*"||_b2==_61){
dispatch(_b1,window,_61);
}
}else{
var _b3=findMessagePipe(_b0);
_b3.post(_b0,_b1,_b2);
}
};
postMessage0.attach=function(_b4,_b5,_b6,_b7,_b8,_b9){
var _ba=findMessagePipe(_b4);
_ba.attach(_b4,_b5,_b6,_b7,_b8,_b9);
_a5.push(_ba);
};
postMessage0.detach=function(_bb){
var _bc=findMessagePipe(_bb);
for(var i=0;i<_a5.length;i++){
if(_a5[i]==_bc){
_a5.splice(i,1);
}
}
_bc.detach();
};
if(window!=top){
_a4["parent"]=new MessagePipe();
function pollParentOrigin(){
var _be=new URI((browser=="ie")?document.URL:location.href);
var _bf=_be.fragment||"";
if(document.body!=null&&_bf.length>0&&_bf.charAt(0)=="I"){
var _c0=unescape(_bf);
var _c1=_c0.split("!");
if(_c1.shift()=="I"){
var _c2=_c1.shift();
var _c3=_c1.shift();
var _c4=_c1.shift();
var _c5=_c1.shift();
var _c6=_c1.shift();
if(_c2==document.domain){
try{
parent.location.hash;
}
catch(permissionDenied){
document.domain=_c2;
}
}
var _c7=_c1.shift()||"";
switch(browser){
case "firefox":
location.replace([location.href.split("#")[0],_c7].join("#"));
break;
default:
location.hash=_c7;
break;
}
var _c8=findMessagePipe(parent);
_c8.targetToken=_c4;
var _c9=_c8.sourceToken;
var _ca="parentBridge"+String(Math.random()).substring(2);
var _cb=new URI(_c3+_c5);
if(_c6){
var _cc=new URI(_cb.scheme+"://"+_c6);
if(typeof (_cc.port)!=="undefined"){
_cb.port=_cc.port;
}
_cb.host=_cc.host;
}
var _cd=_cb.toString()+"?.kr=xsp&.kv=9.06#"+escape([_c2,_ca,_61,_c4,_c9,_c5,_62].join(","));
var _ce;
if(browser=="ie"){
_ce=document.createElement("<iframe id=\""+_ca+"\" name=\""+_ca+"\" src=\""+_cd+"\"></iframe>");
}else{
_ce=document.createElement("iframe");
_ce.src=_cd;
}
_ce.style.position="absolute";
_ce.style.left="-10px";
_ce.style.top="10px";
_ce.style.visibility="hidden";
_ce.style.width="0px";
_ce.style.height="0px";
document.body.appendChild(_ce);
return;
}
}
setTimeout(pollParentOrigin,20);
};
pollParentOrigin();
}
var _cf=document.getElementsByTagName("meta");
for(var i=0;i<_cf.length;i++){
if(_cf[i].name==="kaazing:postMessage"){
if("immediate"==_cf[i].content){
var _d1=function(){
var _d2=document.getElementsByTagName("iframe");
for(var i=0;i<_d2.length;i++){
var _d4=_d2[i];
if(_d4.style["KaaPostMessage"]=="immediate"){
_d4.style["KaaPostMessage"]="none";
var _d5=supplyIFrameMessagePipe(_d4);
bridgeIfNecessary(_d5,_d4.contentWindow);
}
}
setTimeout(_d1,20);
};
setTimeout(_d1,20);
}
break;
}
}
for(var i=0;i<_cf.length;i++){
if(_cf[i].name==="kaazing:postMessagePrefix"){
var _d6=_cf[i].content;
if(_d6!=null&&_d6.length>0){
if(_d6.charAt(0)!="/"){
_d6="/"+_d6;
}
_62=_d6;
}
}
}
setTimeout(pollReaders,20);
return postMessage0;
}
})();
var XMLHttpRequest0=(function(){
var _d7=new URI((browser=="ie")?document.URL:location.href);
var _d8={"http":80,"https":443};
if(_d7.port==null){
_d7.port=_d8[_d7.scheme];
_d7.authority=_d7.host+":"+_d7.port;
}
var _d9={};
var _da={};
var _db=0;
function XMLHttpRequest0(){
if(browser=="firefox"&&typeof (Object.getPrototypeOf)=="function"){
var xhr=new XMLHttpRequest();
xhr.withCredentials=true;
return xhr;
}
};
var _dd=XMLHttpRequest0.prototype;
_dd.readyState=0;
_dd.responseText="";
_dd.status=0;
_dd.statusText="";
_dd.timeout=0;
_dd.onreadystatechange;
_dd.onerror;
_dd.onload;
_dd.onprogress;
_dd.open=function(_de,_df,_e0){
if(!_e0){
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=toPaddedHex(_db++,8);
_da[id]=this;
this._id=id;
}
if(_df.indexOf(".kv=")==-1){
_df+=((_df.indexOf("?")==-1)?"?":"&")+".kv=9.06";
}else{
_df=_df.replace(/\.kv=[^&]*(.*)/,".kv=9.06$1");
}
var uri=new URI(_df);
var _e3=(uri.scheme!=null&&uri.authority!=null);
var _e4=_e3?uri.scheme:_d7.scheme;
var _e5=_e3?uri.authority:_d7.authority;
if(_e5!=null&&uri.port==null){
_e5=uri.host+":"+_d8[_e4];
}
var _e6=_e4+"://"+_e5;
var _e7=_d9[_e6];
if(_e7===undefined){
var _e8=document.createElement("iframe");
_e8.style.position="absolute";
_e8.style.left="-10px";
_e8.style.top="10px";
_e8.style.visibility="hidden";
_e8.style.width="0px";
_e8.style.height="0px";
var _e9=new URI(_e6);
_e9.query=".kr=xs&.kv=9.06";
_e9.path="/";
_e8.src=_e9.toString();
function post(_ea){
this.buffer.push(_ea);
};
function attach(id){
var _ec=this.attached[id];
if(_ec===undefined){
_ec={};
this.attached[id]=_ec;
}
if(_ec.timerID!==undefined){
clearTimeout(_ec.timerID);
delete _ec.timerID;
}
};
function detach(id){
var _ee=this.attached[id];
if(_ee!==undefined&&_ee.timerID===undefined){
var _ef=this;
_ee.timerID=setTimeout(function(){
delete _ef.attached[id];
var xhr=_da[id];
if(xhr._pipe==_e7){
delete _da[id];
delete xhr._id;
delete xhr._pipe;
}
postMessage0(_e7.iframe.contentWindow,["d",id].join(""),_e7.targetOrigin);
},10000);
}
};
_e7={"targetOrigin":_e6,"iframe":_e8,"buffer":[],"post":post,"attach":attach,"detach":detach,"attached":{count:0}};
_d9[_e6]=_e7;
var _f1=this;
function sendInitWhenReady(){
var _f2=_e8.contentWindow;
if(!_f2){
setTimeout(sendInitWhenReady,20);
}else{
postMessage0(_f2,"I",_e6);
}
};
_e7.handshakeID=setTimeout(function(){
_d9[_e6]=undefined;
_e7.post=function(_f3){
_f1.readyState=4;
_f1.status=0;
onreadystatechange(_f1);
};
if(_e7.buffer.length>0){
_e7.post();
}
},30000);
document.body.appendChild(_e8);
sendInitWhenReady();
}
this._pipe=_e7;
this._requestHeaders=[];
this._method=_de;
this._location=_df;
this._responseHeaders=null;
this._readyState=1;
this.status=0;
this.statusText="";
this.responseText="";
_e7.attach(this._id);
var _f1=this;
setTimeout(function(){
_f1.readyState=1;
onreadystatechange(_f1);
},0);
};
_dd.setRequestHeader=function(_f4,_f5){
if(this._readyState!==1){
throw new Error("Invalid ready state");
}
this._requestHeaders.push([_f4,_f5]);
};
_dd.send=function(_f6){
if(this._readyState!==1){
throw new Error("Invalid ready state");
}
if(typeof (_f6)!=="string"){
_f6="";
}
var _f7=this;
setTimeout(function(){
_f7.readyState=2;
onreadystatechange(_f7);
},0);
var _f8=this._method.substring(0,10);
var _f9=this._location;
var _fa=this._requestHeaders;
var _fb=toPaddedHex(this.timeout,4);
var _fc=(this.onprogress!==undefined)?"t":"f";
var _fd=["s",this._id,_f8.length,_f8,toPaddedHex(_f9.length,4),_f9,toPaddedHex(_fa.length,4)];
for(var i=0;i<_fa.length;i++){
var _ff=_fa[i];
_fd.push(toPaddedHex(_ff[0].length,4));
_fd.push(_ff[0]);
_fd.push(toPaddedHex(_ff[1].length,4));
_fd.push(_ff[1]);
}
_fd.push(toPaddedHex(_f6.length,8),_f6,toPaddedHex(_fb,4),_fc);
this._pipe.post(_fd.join(""));
};
_dd.abort=function(){
var pipe=this._pipe;
if(pipe!==undefined){
pipe.post(["a",this._id].join(""));
pipe.detach(this._id);
}
};
_dd.getResponseHeader=function(_101){
if(this.status==0){
throw new Error("Invalid ready state");
}
var _102=this._responseHeaders;
return _102[_101];
};
_dd.getAllResponseHeaders=function(){
if(this.status==0){
throw new Error("Invalid ready state");
}
return null;
};
function onreadystatechange(_103){
if(typeof (_103.onreadystatechange)!=="undefined"){
_103.onreadystatechange();
}
switch(_103.readyState){
case 3:
if(typeof (_103.onprogress)!=="undefined"){
_103.onprogress();
}
break;
case 4:
switch(Math.floor(_103.status/100)){
case 0:
case 5:
if(typeof (_103.onerror)!=="undefined"){
_103.onerror();
}
break;
default:
if(typeof (_103.onprogress)!=="undefined"){
_103.onprogress();
}
if(typeof (_103.onload)!=="undefined"){
_103.onload();
}
break;
}
break;
}
};
function onmessage(_104){
var _105=_104.origin;
var _106={"http":":80","https":":443"};
var _107=_105.split(":");
if(_107.length===2){
_105+=_106[_107[0]];
}
var pipe=_d9[_105];
if(pipe!==undefined&&pipe.iframe!==undefined&&_104.source==pipe.iframe.contentWindow){
if(_104.data=="I"){
clearTimeout(pipe.handshakeID);
var _109;
while((_109=pipe.buffer.shift())!==undefined){
postMessage0(pipe.iframe.contentWindow,_109,pipe.targetOrigin);
}
pipe.post=function(_10a){
postMessage0(pipe.iframe.contentWindow,_10a,pipe.targetOrigin);
};
}else{
var _109=_104.data;
if(_109.length>=9){
var _10b=0;
var type=_109.substring(_10b,_10b+=1);
var id=_109.substring(_10b,_10b+=8);
var _10e=_da[id];
if(_10e!==undefined){
switch(type){
case "r":
var _10f={};
var _110=fromHex(_109.substring(_10b,_10b+=2));
for(var i=0;i<_110;i++){
var _112=fromHex(_109.substring(_10b,_10b+=4));
var _113=_109.substring(_10b,_10b+=_112);
var _114=fromHex(_109.substring(_10b,_10b+=4));
var _115=_109.substring(_10b,_10b+=_114);
_10f[_113]=_115;
}
_10e._responseHeaders=_10f;
_10e.status=fromHex(_109.substring(_10b,_10b+=4));
var _116=fromHex(_109.substring(_10b,_10b+=2));
_10e.statusText=_109.substring(_10b,_10b+=_116);
break;
case "p":
_10e.readyState=parseInt(_109.substring(_10b,_10b+=1));
var _117=fromHex(_109.substring(_10b,_10b+=8));
var _118=_109.substring(_10b,_10b+=_117);
if(_118.length>0){
_10e.responseText+=_118;
}
onreadystatechange(_10e);
if(_10e.readyState==4){
pipe.detach(id);
}
break;
case "e":
_10e.status=0;
_10e.statusText="";
_10e.readyState=4;
onreadystatechange(_10e);
pipe.detach(id);
break;
case "t":
_10e.status=0;
_10e.statusText="";
_10e.readyState=4;
if(typeof ($this.ontimeout)!=="undefined"){
$this.ontimeout();
}
pipe.detach(id);
break;
}
}
}
}
}else{
}
};
function fromHex(_119){
return parseInt(_119,16);
};
function toPaddedHex(_11a,_11b){
var hex=_11a.toString(16);
var _11d=[];
_11b-=hex.length;
while(_11b-->0){
_11d.push("0");
}
_11d.push(hex);
return _11d.join("");
};
window.addEventListener("message",onmessage,false);
return XMLHttpRequest0;
})();
(function(){
var _11e=function(_11f,_120,_121){
var self=this;
var _123=300;
var ID="Loader";
var ie=false;
var _126=-1;
self.elt=null;
var _127=false;
var _128={};
var _129=function(){
var exp=exp=new RegExp(".*"+_11f+".js$");
var _12b=document.getElementsByTagName("script");
for(var i=0;i<_12b.length;i++){
if(_12b[i].src){
var name=(_12b[i].src).match(exp);
if(name){
name=name.pop();
var _12e=name.split("/");
_12e.pop();
var s=_12e.join("/")+"/";
return s;
}
}
}
};
var _130=_129();
var _131=_130+"Loader.swf?.kv=9.06";
var _132=_130+_11f+"Impl.js";
self.loader=function(){
var _133="flash";
var tags=document.getElementsByTagName("meta");
for(var i=0;i<tags.length;i++){
if(tags[i].name==="kaazing:upgrade"){
_133=tags[i].content;
}
}
if(_133!="flash"||!_136([9,0,115])){
_137();
return;
}
_126=setTimeout(_137,_123);
_138();
};
self.clearFlashTimer=function(){
clearTimeout(_126);
_126="cleared";
if(!_127){
setTimeout(function(){
_139(self.elt.handshake(_11f));
},0);
}
};
var _139=function(text){
self.saveProxies();
eval(text);
for(var i=0;i<_121.length;i++){
var obj=window[_121[i]];
if(obj._flashHook){
obj._flashHook.elt=self.elt;
}
}
self.initProxies();
window.___Loader=undefined;
};
self.saveProxies=function(){
for(var i=0;i<_121.length;i++){
var name=_121[i];
_128[name]=window[name];
if(window[name]._processWaitQueue){
window[name]=undefined;
}
}
};
self.initProxies=function(){
for(var i=0;i<_121.length;i++){
var name=_121[i];
_128[name]._impl=window[name];
if(_128[name]._processWaitQueue){
_128[name]._processWaitQueue();
}
}
};
var _141=function(){
var _142=null;
if(typeof (ActiveXObject)!="undefined"){
try{
ie=true;
var swf=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
var _144=swf.GetVariable("$version");
var _145=_144.split(" ")[1].split(",");
_142=[];
for(var i=0;i<_145.length;i++){
_142[i]=parseInt(_145[i]);
}
}
catch(e){
ie=false;
}
}
if(typeof navigator.plugins!="undefined"){
if(typeof navigator.plugins["Shockwave Flash"]!="undefined"){
var _144=navigator.plugins["Shockwave Flash"].description;
_144=_144.replace(/\s*r/g,".");
var _145=_144.split(" ")[2].split(".");
_142=[];
for(var i=0;i<_145.length;i++){
_142[i]=parseInt(_145[i]);
}
}
}
var _147=navigator.userAgent;
if(_142!==null&&_142[0]===10&&_147.indexOf("Windows NT 6.0")!==-1){
_142=null;
}
return _142;
};
var _136=function(_148){
var _149=_141();
if(_149==null){
return false;
}
for(var i=0;i<Math.max(_149.length,_148.length);i++){
var _14b=_149[i]-_148[i];
if(_14b!=0){
return (_14b>0)?true:false;
}
}
return true;
};
var _138=function(){
if(ie){
var elt=document.createElement("div");
document.body.appendChild(elt);
elt.outerHTML="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" height=\"0\" width=\"0\" id=\""+ID+"\"><param name=\"movie\" value=\""+_131+"\"></param></object>";
self.elt=document.getElementById(ID);
}else{
var elt=document.createElement("object");
elt.setAttribute("type","application/x-shockwave-flash");
elt.setAttribute("width",0);
elt.setAttribute("height",0);
elt.setAttribute("id",ID);
elt.setAttribute("data",_131);
document.body.appendChild(elt);
self.elt=elt;
}
};
var _137=function(){
_127=true;
var _14d=document.createElement("script");
_14d.src=_132;
document.body.appendChild(_14d);
};
self.attachToOnload=function(_14e){
if(window.addEventListener){
window.addEventListener("load",_14e,true);
}else{
if(window.attachEvent){
window.attachEvent("onload",_14e);
}else{
onload=_14e;
}
}
};
self.attachToOnload(self.loader);
};
var _14f=function(_150,_151,_152){
_152.push({"sock":_150,"location":_151});
};
var _153=function(_154,_155,impl){
if(typeof (_154)==="undefined"){
return;
}
if(typeof (impl)!=="undefined"&&impl!==null){
this._createInstance(_154,impl);
}else{
_14f(this,_154,_155);
}
};
var _157=_153.prototype;
_157._createInstance=function(_158,impl){
var sock=new impl(_158);
var _15b=this;
sock.onopen=function(){
_15b.readyState=1;
_15b.onopen();
};
sock.onmessage=function(_15c){
_15b.onmessage(_15c);
};
sock.onclose=function(){
_15b.readyState=2;
_15b.onclose();
};
this._sock=sock;
};
var _15d=function(_15e,impl){
var _160=null;
for(var i=0;i<_15e.length;i++){
_160=_15e[i];
(_160.sock)._createInstance(_160.location,impl);
}
};
var _162=function(_163){
_163.bufferedAmount=_163._sock.bufferedAmount;
if(_163.bufferedAmount!=0){
setTimeout(function(){
_162(_163);
},1000);
}
};
_157.readyState=0;
_157.bufferedAmount=0;
_157.URL="";
_157.onclose=function(){
};
_157.onopen=function(){
};
_157.onmessage=function(_164){
};
_157.send=function(data){
switch(this.readyState){
case 0:
throw new Error("INVALID_STATE_ERR");
break;
case 1:
if(data===null){
throw new Error("data is null");
}
this._sock.send(data);
_162(this);
return true;
break;
case 2:
return false;
break;
default:
throw new Error("INVALID_STATE_ERR");
}
};
_157.postMessage=_157.send;
_157.close=function(){
switch(this.readyState){
case 1:
case 2:
this._sock.close();
break;
}
};
_157.disconnect=_157.close;
(function(){
if(typeof (window.WebSocket)!=="undefined"){
window.WebSocket.prototype.postMessage=window.WebSocket.prototype.send;
window.WebSocket.prototype.disconnect=window.WebSocket.prototype.close;
return;
}
var _166=[];
window.WebSocket=function(_167){
this.URL=_167;
var impl=window.WebSocket._hasLoaded?window.WebSocket._impl:null;
this.constructor(_167,_166,impl);
};
var _169=window.WebSocket;
_169.prototype=new _153();
_169.constructor=_153;
_169._impl=null;
_169._processWaitQueue=function(){
if(_169._hasLoaded){
throw new Error("WebSocket has already loaded");
}
_169._hasLoaded=true;
_15d(_166,_169._impl);
};
})();
(function(){
if(typeof (window.ByteSocket)!=="undefined"){
return;
}
var _16a=[];
window.ByteSocket=function(_16b){
this.URL=_16b;
var impl=window.ByteSocket._hasLoaded?window.ByteSocket._impl:null;
this.constructor(_16b,_16a,impl);
};
var _16d=window.ByteSocket;
_16d.prototype=new _153();
_16d.constructor=_153;
_16d._impl=null;
_16d._processWaitQueue=function(){
if(_16d._hasLoaded){
throw new Error("ByteSocket has already loaded");
}
_16d._hasLoaded=true;
_15d(_16a,_16d._impl);
};
})();
window.___Loader=new _11e("ByteSocket",[window.WebSocket,window.ByteSocket],["WebSocket","ByteSocket"]);
})();
ByteOrder=function(){
};
(function(){
var _16e=ByteOrder.prototype;
_16e.toString=function(){
throw new Error("Abstract");
};
var _16f=function(v){
return (v&255);
};
var _171=function(_172){
return (_172&128)?(_172|-256):_172;
};
var _173=function(v){
return [((v>>8)&255),(v&255)];
};
var _175=function(_176,_177){
return (_171(_176)<<8)|(_177&255);
};
var _178=function(_179,_17a){
return ((_179&255)<<8)|(_17a&255);
};
var _17b=function(v){
return [((v>>16)&255),((v>>8)&255),(v&255)];
};
var _17d=function(_17e,_17f,_180){
return ((_17e&255)<<16)|((_17f&255)<<8)|(_180&255);
};
var _181=function(v){
return [((v>>24)&255),((v>>16)&255),((v>>8)&255),(v&255)];
};
var _183=function(_184,_185,_186,_187){
return (_171(_184)<<24)|((_185&255)<<16)|((_186&255)<<8)|(_187&255);
};
var _188=function(_189,_18a,_18b,_18c){
var _18d=_178(_189,_18a);
var _18e=_178(_18b,_18c);
return (_18d*65536+_18e);
};
var _18f=function(v){
var v1=Math.floor(v/4294967296);
var v0=v%4294967296;
var a1=_181(v1);
var a2=_181(v0);
return a1.concat(a2);
};
var _195=function(_196,_197,_198,_199,_19a,_19b,_19c,_19d){
var v1=_183(_196,_197,_198,_199);
var v0=_188(_19a,_19b,_19c,_19d);
return (v1*4294967296+v0);
};
ByteOrder.BIG_ENDIAN=(function(){
var _1a0=function(){
};
_1a0.prototype=new ByteOrder();
var _1a1=_1a0.prototype;
_1a1._toUnsignedByte=_16f;
_1a1._toByte=_171;
_1a1._fromShort=_173;
_1a1._toShort=_175;
_1a1._toUnsignedShort=_178;
_1a1._fromMediumInt=_17b;
_1a1._toMediumInt=_17d;
_1a1._fromInt=_181;
_1a1._toInt=_183;
_1a1._toUnsignedInt=_188;
_1a1._fromLong=_18f;
_1a1._toLong=_195;
_1a1.toString=function(){
return "<ByteOrder.BIG_ENDIAN>";
};
return new _1a0();
})();
ByteOrder.LITTLE_ENDIAN=(function(){
var _1a2=function(){
};
_1a2.prototype=new ByteOrder();
var _1a3=_1a2.prototype;
_1a3._toByte=_171;
_1a3._toUnsignedByte=_16f;
_1a3._fromShort=function(v){
return _173(v).reverse();
};
_1a3._toShort=function(_1a5,_1a6){
return _175(_1a6,_1a5);
};
_1a3._toUnsignedShort=function(_1a7,_1a8){
return _178(_1a8,_1a7);
};
_1a3._fromMediumInt=function(v){
return _17b(v).reverse();
};
_1a3._toMediumInt=function(_1aa,_1ab,_1ac,_1ad,_1ae,_1af){
return _17d(_1af,_1ae,_1ad,_1ac,_1ab,_1aa);
};
_1a3._fromInt=function(v){
return _181(v).reverse();
};
_1a3._toInt=function(_1b1,_1b2,_1b3,_1b4){
return _183(_1b4,_1b3,_1b2,_1b1);
};
_1a3._toUnsignedInt=function(_1b5,_1b6,_1b7,_1b8){
return _188(_1b8,_1b7,_1b6,_1b5);
};
_1a3._fromLong=function(v){
return _18f(v).reverse();
};
_1a3._toLong=function(_1ba,_1bb,_1bc,_1bd,_1be,_1bf,_1c0,_1c1){
return _195(_1c1,_1c0,_1bf,_1be,_1bd,_1bc,_1bb,_1ba);
};
_1a3.toString=function(){
return "<ByteOrder.LITTLE_ENDIAN>";
};
return new _1a2();
})();
})();
function ByteBuffer(_1c2){
this.array=_1c2||[];
this._mark=-1;
this.limit=this.capacity=this.array.length;
this.order=ByteOrder.BIG_ENDIAN;
};
(function(){
ByteBuffer.allocate=function(_1c3){
var buf=new ByteBuffer();
buf.capacity=_1c3;
return buf;
};
ByteBuffer.wrap=function(_1c5){
return new ByteBuffer(_1c5);
};
var _1c6=ByteBuffer.prototype;
_1c6.autoExpand=true;
_1c6.capacity=0;
_1c6.position=0;
_1c6.limit=0;
_1c6.order=ByteOrder.BIG_ENDIAN;
_1c6.array=[];
_1c6.mark=function(){
this._mark=this.position;
return this;
};
_1c6.reset=function(){
var m=this._mark;
if(m<0){
throw new Error("Invalid mark");
}
this.position=m;
return this;
};
_1c6.compact=function(){
this.array.splice(0,this.position);
this.limit-=this.position;
this.position=0;
return this;
};
_1c6.duplicate=function(){
var buf=new ByteBuffer(this.array);
buf.position=this.position;
buf.limit=this.limit;
buf.capacity=this.capacity;
return buf;
};
_1c6.fill=function(size){
_autoExpand(this,size);
while(size-->0){
this.put(0);
}
return this;
};
_1c6.fillWith=function(b,size){
_autoExpand(this,size);
while(size-->0){
this.put(b);
}
return this;
};
_1c6.indexOf=function(b){
var _1cd=this.limit;
var _1ce=this.array;
for(var i=this.position;i<_1cd;i++){
if(_1ce[i]==b){
return i;
}
}
return -1;
};
_1c6.put=function(v){
_autoExpand(this,1);
this.putAt(this.position++,v);
return this;
};
_1c6.putAt=function(i,v){
_checkIndex(this,i);
this.array[i]=this.order._toUnsignedByte(v);
return this;
};
_1c6.putShort=function(v){
_autoExpand(this,2);
this.putShortAt(this.position,v);
this.position+=2;
return this;
};
_1c6.putShortAt=function(i,v){
this.putBytesAt(i,this.order._fromShort(v));
return this;
};
_1c6.putMediumInt=function(v){
_autoExpand(this,3);
this.putMediumIntAt(this.position,v);
this.position+=3;
return this;
};
_1c6.putMediumIntAt=function(i,v){
this.putBytesAt(i,this.order._fromMediumInt(v));
return this;
};
_1c6.putInt=function(v){
_autoExpand(this,4);
this.putIntAt(this.position,v);
this.position+=4;
return this;
};
_1c6.putIntAt=function(i,v){
this.putBytesAt(i,this.order._fromInt(v));
return this;
};
_1c6.putLong=function(v){
_autoExpand(this,8);
this.putLongAt(this.position,v);
this.position+=8;
return this;
};
_1c6.putLongAt=function(i,v){
this.putBytesAt(i,this.order._fromLong(v));
return this;
};
_1c6.putString=function(v,cs){
cs.encode(v,this);
return this;
};
_1c6.putPrefixedString=function(_1e1,v,cs){
if(typeof (cs)==="undefined"||typeof (cs.encode)==="undefined"){
throw new Error("ByteBuffer.putPrefixedString: character set parameter missing");
}
if(_1e1===0){
return this;
}
_autoExpand(this,_1e1);
var len=v.length;
switch(_1e1){
case 1:
this.put(len);
break;
case 2:
this.putShort(len);
break;
case 4:
this.putInt(len);
break;
}
cs.encode(v,this);
return this;
};
_1c6.putBytes=function(v){
_autoExpand(this,v.length);
this.putBytesAt(this.position,v);
this.position+=v.length;
return this;
};
_1c6.putBytesAt=function(i,v){
for(var j=0,k=i,len=v.length;j<len;j++,k++){
this.putAt(k,v[j]);
}
return this;
};
_1c6.putBuffer=function(v){
this.putBytes(v.array.slice(v.position,v.limit));
return this;
};
_1c6.putBufferAt=function(i,v){
this.putBytesAt(i,v.array.slice(v.position,v.limit));
return this;
};
_1c6.get=function(){
return this.getAt(this.position++);
};
_1c6.getAt=function(i){
return this.order._toByte(this.array[i]);
};
_1c6.getShort=function(){
var val=this.getShortAt(this.position);
this.position+=2;
return val;
};
_1c6.getShortAt=function(i){
var _1f1=this.array;
return this.order._toShort(_1f1[i++],_1f1[i++]);
};
_1c6.getMediumInt=function(){
var val=this.getMediumIntAt(this.position);
this.position+=3;
return val;
};
_1c6.getMediumIntAt=function(i){
var _1f4=this.array;
return this.order._toMediumInt(_1f4[i++],_1f4[i++],_1f4[i++]);
};
_1c6.getInt=function(){
var val=this.getIntAt(this.position);
this.position+=4;
return val;
};
_1c6.getIntAt=function(i){
var _1f7=this.array;
return this.order._toInt(_1f7[i++],_1f7[i++],_1f7[i++],_1f7[i++]);
};
_1c6.getLong=function(){
var val=this.getLongAt(this.position);
this.position+=8;
return val;
};
_1c6.getLongAt=function(i){
var _1fa=this.array;
return this.order._toLong(_1fa[i++],_1fa[i++],_1fa[i++],_1fa[i++],_1fa[i++],_1fa[i++],_1fa[i++],_1fa[i++]);
};
_1c6.getUnsigned=function(){
return this.order._toUnsignedByte(this.array[this.position++]);
};
_1c6.getUnsignedShort=function(){
var _1fb=this.array;
return this.order._toUnsignedShort(_1fb[this.position++],_1fb[this.position++]);
};
_1c6.getUnsignedMediumInt=function(){
var _1fc=this.array;
return this.order._toUnsignedMediumInt(_1fc[this.position++],_1fc[this.position++],_1fc[this.position++]);
};
_1c6.getUnsignedInt=function(){
var _1fd=this.array;
return this.order._toUnsignedInt(_1fd[this.position++],_1fd[this.position++],_1fd[this.position++],_1fd[this.position++]);
return val;
};
_1c6.getPrefixedString=function(_1fe,cs){
var len=0;
switch(_1fe||2){
case 1:
len=this.getUnsigned();
break;
case 2:
len=this.getUnsignedShort();
break;
case 4:
len=this.getInt();
break;
}
if(len===0){
return "";
}
var _201=this.limit;
try{
this.limit=this.position+len;
return cs.decode(this);
}
finally{
this.limit=_201;
}
};
_1c6.getString=function(cs){
var _203=this.position;
var _204=this.limit;
var _205=this.array;
while(_203<_204&&_205[_203]!==0){
_203++;
}
try{
this.limit=_203;
return cs.decode(this);
}
finally{
if(_203!=_204){
this.limit=_204;
this.position=_203+1;
}
}
};
_1c6.slice=function(){
return new ByteBuffer(this.array.slice(this.position,this.limit));
};
_1c6.flip=function(){
this.limit=this.position;
this.position=0;
this._mark=-1;
return this;
};
_1c6.rewind=function(){
this.position=0;
this._mark=-1;
return this;
};
_1c6.clear=function(){
this.position=0;
this.limit=this.capacity;
this._mark=-1;
return this;
};
_1c6.remaining=function(){
return (this.limit-this.position);
};
_1c6.hasRemaining=function(){
return (this.limit>this.position);
};
_1c6.skip=function(size){
this.position+=size;
return this;
};
_1c6.getHexDump=function(){
var _207=this.array;
var pos=this.position;
var _209=this.limit;
if(pos==_209){
return "empty";
}
var _20a=[];
for(var i=pos;i<_209;i++){
var hex=(_207[i]||0).toString(16);
if(hex.length==1){
hex="0"+hex;
}
_20a.push(hex);
}
return _20a.join(" ");
};
_1c6.toString=_1c6.getHexDump;
_1c6.expand=function(_20d){
return this.expandAt(this.position,_20d);
};
_1c6.expandAt=function(i,_20f){
var end=i+_20f;
if(end>this.capacity){
this.capacity=end;
}
if(end>this.limit){
this.limit=end;
}
return this;
};
function _autoExpand(_211,_212){
if(_211.autoExpand){
_211.expand(_212);
}
return this;
};
function _checkIndex(_213,_214){
if(_214<0||_214>_213.capacity){
throw new Error("Index out of bounds");
}
return this;
};
})();
function Charset(){
};
(function(){
var _215=Charset.prototype;
_215.decode=function(buf){
};
_215.encode=function(text){
};
Charset.UTF8=(function(){
function UTF8(){
};
UTF8.prototype=new Charset();
var _218=UTF8.prototype;
_218.decode=function(buf){
var _21a=[];
while(buf.hasRemaining()){
var _21b=buf.remaining();
var _21c=buf.getUnsigned();
var _21d=charByteCount(_21c);
if(_21b<_21d){
buf.skip(-1);
break;
}
var _21e=null;
switch(_21d){
case 1:
_21e=_21c;
break;
case 2:
_21e=((_21c&31)<<6)|(buf.getUnsigned()&63);
break;
case 3:
_21e=((_21c&15)<<12)|((buf.getUnsigned()&63)<<6)|(buf.getUnsigned()&63);
break;
case 4:
_21e=((_21c&7)<<18)|((buf.getUnsigned()&63)<<12)|((buf.getUnsigned()&63)<<6)|(buf.getUnsigned()&63);
break;
}
_21a.push(_21e);
}
return String.fromCharCode.apply(null,_21a);
};
_218.encode=function(str,buf){
for(var i=0;i<str.length;i++){
var _222=str.charCodeAt(i);
if(_222<128){
buf.put(_222);
}else{
if(_222<2048){
buf.put((_222>>6)|192);
buf.put((_222&63)|128);
}else{
if(_222<65536){
buf.put((_222>>12)|224);
buf.put(((_222>>6)&63)|128);
buf.put((_222&63)|128);
}else{
if(_222<1114112){
buf.put((_222>>18)|240);
buf.put(((_222>>12)&63)|128);
buf.put(((_222>>6)&63)|128);
buf.put((_222&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();
})();
})();
