make the Tracker example do an actual sparql query (dump classes and relations)
[contrib/cloudeebus.git] / lib / autobahn.min.js
1 /*
2  AutobahnJS - http://autobahn.ws
3
4  Copyright 2011, 2012 Tavendo GmbH.
5  Licensed under the MIT License.
6  See license text at http://www.opensource.org/licenses/mit-license.php
7
8  AutobahnJS includes code from:
9
10  when - http://cujojs.com
11
12  (c) copyright B Cavalier & J Hann
13  Licensed under the MIT License at:
14  http://www.opensource.org/licenses/mit-license.php
15
16  Crypto-JS - http://code.google.com/p/crypto-js/
17
18  (c) 2009-2012 by Jeff Mott. All rights reserved.
19  Licensed under the New BSD License at:
20  http://code.google.com/p/crypto-js/wiki/License
21 */
22 /*
23  MIT License (c) copyright B Cavalier & J Hann */
24 (function(a){a(function(){function a(){}function e(){}function d(a){var d=new e;d.then=function(d){f(arguments);var c;try{return d&&(c=d(a)),j(c===q?a:c)}catch(e){return b(e)}};return o(d)}function b(a){var d=new e;d.then=function(d,c){f(arguments);var e;try{return c?(e=c(a),j(e===q?a:e)):b(a)}catch(g){return b(g)}};return o(d)}function f(a){for(var b,d=a.length;d;)if(b=a[--d],null!=b&&"function"!=typeof b)throw Error("callback is not a function");}function h(){var a,c,g,m,i,j,k;g=[];m=[];i=function(a,
25 b,d){f(arguments);var c=h();g.push(function(d){d.then(a,b).then(c.resolve,c.reject,c.progress)});d&&m.push(d);return c.promise};j=function(a){for(var d,b=0;d=m[b++];)d(a)};k=function(a){var d,b=0;i=a.then;k=j=function(){throw Error("already completed");};for(m=q;d=g[b++];)d(a);g=[]};a={};c=new e;c.then=a.then=function(a,d,b){return i(a,d,b)};a.promise=o(c);a.resolver=o({resolve:a.resolve=function(a){k(d(a))},reject:a.reject=function(a){k(b(a))},progress:a.progress=function(a){j(a)}});return a}function g(a){return a&&
26 "function"===typeof a.then}function i(a,d,b,f){return j(a).then(d,b,f)}function j(a){var d;a instanceof e||(d=h(),g(a)?a.then(d.resolve,d.reject,d.progress):d.resolve(a),a=d.promise);return a}function k(d,b,f,e,g){function j(a){q(a)}function k(a){w(a)}function p(a){x(a)}var o,n,l,q,w,x,y;y=d.length>>>0;o=Math.max(0,Math.min(b,y));n=[];l=h();b=i(l,f,e,g);if(o){q=function(d){n.push(d);--o||(q=w=x=a,l.resolve(n))};w=function(d){q=w=x=a;l.reject(d)};x=l.progress;for(f=0;f<y;++f)f in d&&i(d[f],j,k,p)}else l.resolve(n);
27 return b}function l(a,d,b){a[b]=d;return a}function n(a,d,b){var f,c;f=a.length;c=[function(a,b,c){return i(a,function(a){return i(b,function(b){return d(a,b,c,f)})})}];3<=arguments.length&&c.push(b);return j(p.apply(a,c))}var o,p,q;o=Object.freeze||function(a){return a};p=[].reduce||function(a){var d,b,f,c,e;e=0;d=Object(this);c=d.length>>>0;b=arguments;if(1>=b.length)for(;;){if(e in d){f=d[e++];break}if(++e>=c)throw new TypeError;}else f=b[1];for(;e<c;++e)e in d&&(f=a(f,d[e],e,d));return f};i.defer=
28 h;i.isPromise=g;i.some=k;i.all=function(a,d,b,f){a=n(a,l,Array(a.length));return i(a,d,b,f)};i.any=function(a,d,b,f){return k(a,1,function(a){return d(a[0])},b,f)};i.reduce=n;i.map=function(a,d){var b,f;f=a.length;for(b=Array(f);0<=f;--f)f in a&&(b[f]=i(a[f],d));return n(b,l,b)};i.chain=function(a,d,f){var c=2<arguments.length;return i(a,function(a){c&&(a=f);d.resolve(a);return a},function(a){d.reject(a);return b(a)},d.progress)};return i})})("function"==typeof define?define:function(a){"undefined"!=
29 typeof module?module.exports=a():this.when=a()});("undefined"==typeof Crypto||!Crypto.util)&&function(){var a=window.Crypto={},c=a.util={rotl:function(a,b){return a<<b|a>>>32-b},rotr:function(a,b){return a<<32-b|a>>>b},endian:function(a){if(a.constructor==Number)return c.rotl(a,8)&16711935|c.rotl(a,24)&4278255360;for(var b=0;b<a.length;b++)a[b]=c.endian(a[b]);return a},randomBytes:function(a){for(var b=[];0<a;a--)b.push(Math.floor(256*Math.random()));return b},bytesToWords:function(a){for(var b=[],f=0,c=0;f<a.length;f++,c+=8)b[c>>>5]|=(a[f]&255)<<
30 24-c%32;return b},wordsToBytes:function(a){for(var b=[],f=0;f<32*a.length;f+=8)b.push(a[f>>>5]>>>24-f%32&255);return b},bytesToHex:function(a){for(var b=[],f=0;f<a.length;f++)b.push((a[f]>>>4).toString(16)),b.push((a[f]&15).toString(16));return b.join("")},hexToBytes:function(a){for(var b=[],f=0;f<a.length;f+=2)b.push(parseInt(a.substr(f,2),16));return b},bytesToBase64:function(a){if("function"==typeof btoa)return btoa(e.bytesToString(a));for(var b=[],f=0;f<a.length;f+=3)for(var c=a[f]<<16|a[f+1]<<
31 8|a[f+2],g=0;4>g;g++)8*f+6*g<=8*a.length?b.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c>>>6*(3-g)&63)):b.push("=");return b.join("")},base64ToBytes:function(a){if("function"==typeof atob)return e.stringToBytes(atob(a));for(var a=a.replace(/[^A-Z0-9+\/]/ig,""),b=[],f=0,c=0;f<a.length;c=++f%4)0!=c&&b.push(("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(f-1))&Math.pow(2,-2*c+8)-1)<<2*c|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(f))>>>
32 6-2*c);return b}},a=a.charenc={};a.UTF8={stringToBytes:function(a){return e.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(e.bytesToString(a)))}};var e=a.Binary={stringToBytes:function(a){for(var b=[],f=0;f<a.length;f++)b.push(a.charCodeAt(f)&255);return b},bytesToString:function(a){for(var b=[],f=0;f<a.length;f++)b.push(String.fromCharCode(a[f]));return b.join("")}}}();("undefined"==typeof Crypto||!Crypto.util)&&function(){var a=window.Crypto={},c=a.util={rotl:function(a,b){return a<<b|a>>>32-b},rotr:function(a,b){return a<<32-b|a>>>b},endian:function(a){if(a.constructor==Number)return c.rotl(a,8)&16711935|c.rotl(a,24)&4278255360;for(var b=0;b<a.length;b++)a[b]=c.endian(a[b]);return a},randomBytes:function(a){for(var b=[];0<a;a--)b.push(Math.floor(256*Math.random()));return b},bytesToWords:function(a){for(var b=[],f=0,c=0;f<a.length;f++,c+=8)b[c>>>5]|=(a[f]&255)<<
33 24-c%32;return b},wordsToBytes:function(a){for(var b=[],f=0;f<32*a.length;f+=8)b.push(a[f>>>5]>>>24-f%32&255);return b},bytesToHex:function(a){for(var b=[],f=0;f<a.length;f++)b.push((a[f]>>>4).toString(16)),b.push((a[f]&15).toString(16));return b.join("")},hexToBytes:function(a){for(var b=[],f=0;f<a.length;f+=2)b.push(parseInt(a.substr(f,2),16));return b},bytesToBase64:function(a){if("function"==typeof btoa)return btoa(e.bytesToString(a));for(var b=[],f=0;f<a.length;f+=3)for(var c=a[f]<<16|a[f+1]<<
34 8|a[f+2],g=0;4>g;g++)8*f+6*g<=8*a.length?b.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c>>>6*(3-g)&63)):b.push("=");return b.join("")},base64ToBytes:function(a){if("function"==typeof atob)return e.stringToBytes(atob(a));for(var a=a.replace(/[^A-Z0-9+\/]/ig,""),b=[],c=0,h=0;c<a.length;h=++c%4)0!=h&&b.push(("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c-1))&Math.pow(2,-2*h+8)-1)<<2*h|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c))>>>
35 6-2*h);return b}},a=a.charenc={};a.UTF8={stringToBytes:function(a){return e.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(e.bytesToString(a)))}};var e=a.Binary={stringToBytes:function(a){for(var b=[],c=0;c<a.length;c++)b.push(a.charCodeAt(c)&255);return b},bytesToString:function(a){for(var b=[],c=0;c<a.length;c++)b.push(String.fromCharCode(a[c]));return b.join("")}}}();
36 (function(){var a=Crypto,c=a.util,e=a.charenc,d=e.UTF8,b=e.Binary,f=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,
37 2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],h=a.SHA256=function(a,f){var d=c.wordsToBytes(h._sha256(a));return f&&f.asBytes?d:f&&f.asString?b.bytesToString(d):c.bytesToHex(d)};h._sha256=function(a){a.constructor==String&&(a=d.stringToBytes(a));var b=c.bytesToWords(a),e=8*a.length,a=[1779033703,3144134277,
38 1013904242,2773480762,1359893119,2600822924,528734635,1541459225],h=[],l,n,o,p,q,t,v,u,m,s,r;b[e>>5]|=128<<24-e%32;b[(e+64>>9<<4)+15]=e;for(u=0;u<b.length;u+=16){e=a[0];l=a[1];n=a[2];o=a[3];p=a[4];q=a[5];t=a[6];v=a[7];for(m=0;64>m;m++){16>m?h[m]=b[m+u]:(s=h[m-15],r=h[m-2],h[m]=((s<<25|s>>>7)^(s<<14|s>>>18)^s>>>3)+(h[m-7]>>>0)+((r<<15|r>>>17)^(r<<13|r>>>19)^r>>>10)+(h[m-16]>>>0));r=e&l^e&n^l&n;var z=(e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22);s=(v>>>0)+((p<<26|p>>>6)^(p<<21|p>>>11)^(p<<7|p>>>25))+
39 (p&q^~p&t)+f[m]+(h[m]>>>0);r=z+r;v=t;t=q;q=p;p=o+s>>>0;o=n;n=l;l=e;e=s+r>>>0}a[0]+=e;a[1]+=l;a[2]+=n;a[3]+=o;a[4]+=p;a[5]+=q;a[6]+=t;a[7]+=v}return a};h._blocksize=16;h._digestsize=32})();
40 (function(){var a=Crypto,c=a.util,e=a.charenc,d=e.UTF8,b=e.Binary;a.HMAC=function(a,e,g,i){e.constructor==String&&(e=d.stringToBytes(e));g.constructor==String&&(g=d.stringToBytes(g));g.length>4*a._blocksize&&(g=a(g,{asBytes:!0}));for(var j=g.slice(0),g=g.slice(0),k=0;k<4*a._blocksize;k++)j[k]^=92,g[k]^=54;a=a(j.concat(a(g.concat(e),{asBytes:!0})),{asBytes:!0});return i&&i.asBytes?a:i&&i.asString?b.bytesToString(a):c.bytesToHex(a)}})();/*
41  MIT License (c) 2011,2012 Copyright Tavendo GmbH. */
42 var AUTOBAHNJS_VERSION="0.7.1",AUTOBAHNJS_DEBUG=!1,ab=window.ab={};ab._version=AUTOBAHNJS_VERSION;
43 (function(){Array.prototype.indexOf||(Array.prototype.indexOf=function(a){if(null===this)throw new TypeError;var c=Object(this),e=c.length>>>0;if(0===e)return-1;var d=0;0<arguments.length&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&Infinity!==d&&-Infinity!==d&&(d=(0<d||-1)*Math.floor(Math.abs(d))));if(d>=e)return-1;for(d=0<=d?d:Math.max(e-Math.abs(d),0);d<e;d++)if(d in c&&c[d]===a)return d;return-1});Array.prototype.forEach||(Array.prototype.forEach=function(a,c){var e,d;if(this===null)throw new TypeError(" this is null or not defined");
44 var b=Object(this),f=b.length>>>0;if({}.toString.call(a)!=="[object Function]")throw new TypeError(a+" is not a function");c&&(e=c);for(d=0;d<f;){var h;if(d in b){h=b[d];a.call(e,h,d,b)}d++}})})();ab._sliceUserAgent=function(a,c,e){var d=[],b=navigator.userAgent,a=b.indexOf(a),c=b.indexOf(c,a);0>c&&(c=b.length);e=b.slice(a,c).split(e);b=e[1].split(".");for(c=0;c<b.length;++c)d.push(parseInt(b[c],10));return{name:e[0],version:d}};
45 ab.getBrowser=function(){var a=navigator.userAgent;return-1<a.indexOf("Chrome")?ab._sliceUserAgent("Chrome"," ","/"):-1<a.indexOf("Safari")?ab._sliceUserAgent("Safari"," ","/"):-1<a.indexOf("Firefox")?ab._sliceUserAgent("Firefox"," ","/"):-1<a.indexOf("MSIE")?ab._sliceUserAgent("MSIE",";"," "):null};ab.browserNotSupportedMessage="Browser does not support WebSockets (RFC6455)";ab._idchars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";ab._idlen=16;ab._subprotocol="wamp";
46 ab._newid=function(){for(var a="",c=0;c<ab._idlen;c+=1)a+=ab._idchars.charAt(Math.floor(Math.random()*ab._idchars.length));return a};ab.log=function(a){if(window.console&&console.log)if(1<arguments.length){console.group("Log Item");for(var c=0;c<arguments.length;c+=1)console.log(arguments[c]);console.groupEnd()}else console.log(arguments[0])};ab._debugrpc=!1;ab._debugpubsub=!1;ab._debugws=!1;
47 ab.debug=function(a,c){if("console"in window)ab._debugrpc=a,ab._debugpubsub=a,ab._debugws=c;else throw"browser does not support console object";};ab.version=function(){return ab._version};ab.PrefixMap=function(){this._index={};this._rindex={}};ab.PrefixMap.prototype.get=function(a){return this._index[a]};ab.PrefixMap.prototype.set=function(a,c){this._index[a]=c;this._rindex[c]=a};ab.PrefixMap.prototype.setDefault=function(a){this._index[""]=a;this._rindex[a]=""};
48 ab.PrefixMap.prototype.remove=function(a){var c=this._index[a];c&&(delete this._index[a],delete this._rindex[c])};ab.PrefixMap.prototype.resolve=function(a,c){var e=a.indexOf(":");if(0<=e){var d=a.substring(0,e);if(this._index[d])return this._index[d]+a.substring(e+1)}return!0==c?a:null};ab.PrefixMap.prototype.shrink=function(a,c){for(var e=a.length;0<e;e-=1){var d=this._rindex[a.substring(0,e)];if(d)return d+":"+a.substring(e)}return!0==c?a:null};ab._MESSAGE_TYPEID_WELCOME=0;
49 ab._MESSAGE_TYPEID_PREFIX=1;ab._MESSAGE_TYPEID_CALL=2;ab._MESSAGE_TYPEID_CALL_RESULT=3;ab._MESSAGE_TYPEID_CALL_ERROR=4;ab._MESSAGE_TYPEID_SUBSCRIBE=5;ab._MESSAGE_TYPEID_UNSUBSCRIBE=6;ab._MESSAGE_TYPEID_PUBLISH=7;ab._MESSAGE_TYPEID_EVENT=8;ab.CONNECTION_CLOSED=0;ab.CONNECTION_LOST=1;ab.CONNECTION_RETRIES_EXCEEDED=2;ab.CONNECTION_UNREACHABLE=3;ab.CONNECTION_UNSUPPORTED=4;ab.CONNECTION_UNREACHABLE_SCHEDULED_RECONNECT=5;ab.CONNECTION_LOST_SCHEDULED_RECONNECT=6;ab._Deferred=when.defer;
50 ab._construct=function(a,c){return"WebSocket"in window?new WebSocket(a,c):"MozWebSocket"in window?new MozWebSocket(a,c):null};
51 ab.Session=function(a,c,e,d){var b=this;b._wsuri=a;b._options=d;b._websocket_onopen=c;b._websocket_onclose=e;b._websocket=null;b._websocket_connected=!1;b._session_id=null;b._wamp_version=null;b._server=null;b._calls={};b._subscriptions={};b._prefixes=new ab.PrefixMap;b._txcnt=0;b._rxcnt=0;b._websocket=ab._construct(b._wsuri,[ab._subprotocol]);if(!b._websocket){if(void 0!==e){e(ab.CONNECTION_UNSUPPORTED);return}throw ab.browserNotSupportedMessage;}b._websocket.onmessage=function(a){ab._debugws&&(b._rxcnt+=
52 1,console.group("WS Receive"),console.info(b._wsuri+"  ["+b._session_id+"]"),console.log(b._rxcnt),console.log(a.data),console.groupEnd());a=JSON.parse(a.data);if(a[1]in b._calls){if(a[0]===ab._MESSAGE_TYPEID_CALL_RESULT){var c=b._calls[a[1]],d=a[2];if(ab._debugrpc&&void 0!==c._ab_callobj){console.group("WAMP Call",c._ab_callobj[2]);console.timeEnd(c._ab_tid);console.group("Arguments");for(var e=3;e<c._ab_callobj.length;e+=1){var j=c._ab_callobj[e];if(void 0!==j)console.log(j);else break}console.groupEnd();
53 console.group("Result");console.log(d);console.groupEnd();console.groupEnd()}c.resolve(d)}else if(a[0]===ab._MESSAGE_TYPEID_CALL_ERROR){c=b._calls[a[1]];d=a[2];e=a[3];j=a[4];if(ab._debugrpc&&void 0!==c._ab_callobj){console.group("WAMP Call",c._ab_callobj[2]);console.timeEnd(c._ab_tid);console.group("Arguments");for(var k=3;k<c._ab_callobj.length;k+=1){var l=c._ab_callobj[k];if(void 0!==l)console.log(l);else break}console.groupEnd();console.group("Error");console.log(d);console.log(e);void 0!==j&&
54 console.log(j);console.groupEnd();console.groupEnd()}void 0!==j?c.reject({uri:d,desc:e,detail:j}):c.reject({uri:d,desc:e})}delete b._calls[a[1]]}else if(a[0]===ab._MESSAGE_TYPEID_EVENT){if(c=b._prefixes.resolve(a[1],!0),c in b._subscriptions){var n=a[1],o=a[2];ab._debugpubsub&&(console.group("WAMP Event"),console.info(b._wsuri+"  ["+b._session_id+"]"),console.log(n),console.log(o),console.groupEnd());b._subscriptions[c].forEach(function(a){a(n,o)})}}else if(a[0]===ab._MESSAGE_TYPEID_WELCOME)if(null===
55 b._session_id){b._session_id=a[1];b._wamp_version=a[2];b._server=a[3];if(ab._debugrpc||ab._debugpubsub)console.group("WAMP Welcome"),console.info(b._wsuri+"  ["+b._session_id+"]"),console.log(b._wamp_version),console.log(b._server),console.groupEnd();null!==b._websocket_onopen&&b._websocket_onopen()}else throw"protocol error (welcome message received more than once)";};b._websocket.onopen=function(){if(b._websocket.protocol!==ab._subprotocol)if("undefined"===typeof b._websocket.protocol)ab._debugws&&
56 (console.group("WS Warning"),console.info(b._wsuri),console.log("WebSocket object has no protocol attribute: WAMP subprotocol check skipped!"),console.groupEnd());else if(b._options&&b._options.skipSubprotocolCheck)ab._debugws&&(console.group("WS Warning"),console.info(b._wsuri),console.log("Server does not speak WAMP, but subprotocol check disabled by option!"),console.log(b._websocket.protocol),console.groupEnd());else throw b._websocket.close(1E3,"server does not speak WAMP"),"server does not speak WAMP (but '"+
57 b._websocket.protocol+"' !)";ab._debugws&&(console.group("WAMP Connect"),console.info(b._wsuri),console.log(b._websocket.protocol),console.groupEnd());b._websocket_connected=!0};b._websocket.onerror=function(){};b._websocket.onclose=function(a){ab._debugws&&(b._websocket_connected?console.log("Autobahn connection to "+b._wsuri+" lost (code "+a.code+", reason '"+a.reason+"', wasClean "+a.wasClean+")."):console.log("Autobahn could not connect to "+b._wsuri+" (code "+a.code+", reason '"+a.reason+"', wasClean "+
58 a.wasClean+")."));void 0!==b._websocket_onclose&&(b._websocket_connected?a.wasClean?b._websocket_onclose(ab.CONNECTION_CLOSED):b._websocket_onclose(ab.CONNECTION_LOST):b._websocket_onclose(ab.CONNECTION_UNREACHABLE));b._websocket_connected=!1;b._wsuri=null;b._websocket_onopen=null;b._websocket_onclose=null;b._websocket=null}};
59 ab.Session.prototype._send=function(a){if(!this._websocket_connected)throw"Autobahn not connected";a=JSON.stringify(a);this._websocket.send(a);this._txcnt+=1;ab._debugws&&(console.group("WS Send"),console.info(this._wsuri+"  ["+this._session_id+"]"),console.log(this._txcnt),console.log(a),console.groupEnd())};ab.Session.prototype.close=function(){this._websocket_connected&&this._websocket.close()};ab.Session.prototype.sessionid=function(){return this._session_id};
60 ab.Session.prototype.shrink=function(a,c){void 0===c&&(c=!0);return this._prefixes.shrink(a,c)};ab.Session.prototype.resolve=function(a,c){void 0===c&&(c=!0);return this._prefixes.resolve(a,c)};ab.Session.prototype.prefix=function(a,c){this._prefixes.set(a,c);if(ab._debugrpc||ab._debugpubsub)console.group("WAMP Prefix"),console.info(this._wsuri+"  ["+this._session_id+"]"),console.log(a),console.log(c),console.groupEnd();this._send([ab._MESSAGE_TYPEID_PREFIX,a,c])};
61 ab.Session.prototype.call=function(){for(var a=new ab._Deferred,c;!(c=ab._newid(),!(c in this._calls)););this._calls[c]=a;for(var e=this._prefixes.shrink(arguments[0],!0),e=[ab._MESSAGE_TYPEID_CALL,c,e],d=1;d<arguments.length;d+=1)e.push(arguments[d]);this._send(e);ab._debugrpc&&(a._ab_callobj=e,a._ab_tid=this._wsuri+"  ["+this._session_id+"]["+c+"]",console.time(a._ab_tid),console.info());return a};
62 ab.Session.prototype.subscribe=function(a,c){var e=this._prefixes.resolve(a,!0);e in this._subscriptions||(ab._debugpubsub&&(console.group("WAMP Subscribe"),console.info(this._wsuri+"  ["+this._session_id+"]"),console.log(a),console.log(c),console.groupEnd()),this._send([ab._MESSAGE_TYPEID_SUBSCRIBE,a]),this._subscriptions[e]=[]);if(-1===this._subscriptions[e].indexOf(c))this._subscriptions[e].push(c);else throw"callback "+c+" already subscribed for topic "+e;};
63 ab.Session.prototype.unsubscribe=function(a,c){var e=this._prefixes.resolve(a,!0);if(e in this._subscriptions){var d;if(void 0!==c){var b=this._subscriptions[e].indexOf(c);if(-1!==b)d=c,this._subscriptions[e].splice(b,1);else throw"no callback "+c+" subscribed on topic "+e;}else d=this._subscriptions[e].slice(),this._subscriptions[e]=[];0===this._subscriptions[e].length&&(delete this._subscriptions[e],ab._debugpubsub&&(console.group("WAMP Unsubscribe"),console.info(this._wsuri+"  ["+this._session_id+
64 "]"),console.log(a),console.log(d),console.groupEnd()),this._send([ab._MESSAGE_TYPEID_UNSUBSCRIBE,a]))}else throw"not subscribed to topic "+e;};
65 ab.Session.prototype.publish=function(){var a=arguments[0],c=arguments[1],e=null,d=null,b=null,f=null;if(3<arguments.length){if(!(arguments[2]instanceof Array))throw"invalid argument type(s)";if(!(arguments[3]instanceof Array))throw"invalid argument type(s)";d=arguments[2];b=arguments[3];f=[ab._MESSAGE_TYPEID_PUBLISH,a,c,d,b]}else if(2<arguments.length)if("boolean"===typeof arguments[2])e=arguments[2],f=[ab._MESSAGE_TYPEID_PUBLISH,a,c,e];else if(arguments[2]instanceof Array)d=arguments[2],f=[ab._MESSAGE_TYPEID_PUBLISH,
66 a,c,d];else throw"invalid argument type(s)";else f=[ab._MESSAGE_TYPEID_PUBLISH,a,c];ab._debugpubsub&&(console.group("WAMP Publish"),console.info(this._wsuri+"  ["+this._session_id+"]"),console.log(a),console.log(c),null!==e?console.log(e):null!==d&&(console.log(d),null!==b&&console.log(b)),console.groupEnd());this._send(f)};ab.Session.prototype.authreq=function(a,c){return this.call("http://api.wamp.ws/procedure#authreq",a,c)};
67 ab.Session.prototype.authsign=function(a,c){c||(c="");return Crypto.util.bytesToBase64(Crypto.HMAC(Crypto.SHA256,a,c,{asBytes:!0}))};ab.Session.prototype.auth=function(a){return this.call("http://api.wamp.ws/procedure#auth",a)};
68 ab._connect=function(a){var c=new ab.Session(a.wsuri,function(){a.connects+=1;a.retryCount=0;a.onConnect(c)},function(c){switch(c){case ab.CONNECTION_CLOSED:a.onHangup(c,"Connection was closed properly - done.");break;case ab.CONNECTION_UNSUPPORTED:a.onHangup(c,"Browser does not support WebSocket.");break;case ab.CONNECTION_UNREACHABLE:a.retryCount+=1;if(0==a.connects)a.onHangup(c,"Connection could not be established.");else if(a.retryCount<=a.options.maxRetries)(c=a.onHangup(ab.CONNECTION_UNREACHABLE_SCHEDULED_RECONNECT,
69 "Connection unreachable - scheduled reconnect to occur in "+a.options.retryDelay/1E3+" second(s).",{delay:a.options.retryDelay,retries:a.retryCount,maxretries:a.options.maxRetries}))?(console.log("Connection unreachable - retrying stopped by app"),a.onHangup(ab.CONNECTION_RETRIES_EXCEEDED,"Number of connection retries exceeded.")):(console.log("Connection unreachable - retrying ("+a.retryCount+") .."),window.setTimeout(ab._connect,a.options.retryDelay,a));else a.onHangup(ab.CONNECTION_RETRIES_EXCEEDED,
70 "Number of connection retries exceeded.");break;case ab.CONNECTION_LOST:a.retryCount+=1;if(a.retryCount<=a.options.maxRetries)(c=a.onHangup(ab.CONNECTION_LOST_SCHEDULED_RECONNECT,"Connection lost - scheduled reconnect to occur in "+a.options.retryDelay/1E3+" second(s).",{delay:a.options.retryDelay,retries:a.retryCount,maxretries:a.options.maxRetries}))?(console.log("Connection lost - retrying stopped by app"),a.onHangup(ab.CONNECTION_RETRIES_EXCEEDED,"Connection lost.")):(console.log("Connection lost - retrying ("+
71 a.retryCount+") .."),window.setTimeout(ab._connect,a.options.retryDelay,a));else a.onHangup(ab.CONNECTION_RETRIES_EXCEEDED,"Connection lost.");break;default:throw"unhandled close code in ab._connect";}},a.options)};
72 ab.connect=function(a,c,e,d){peer={};peer.wsuri=a;peer.options=d?d:{};void 0==peer.options.retryDelay&&(peer.options.retryDelay=5E3);void 0==peer.options.maxRetries&&(peer.options.maxRetries=10);void 0==peer.options.skipSubprotocolCheck&&(peer.options.skipSubprotocolCheck=!1);if(c)peer.onConnect=c;else throw"onConnect handler required!";peer.onHangup=e?e:function(a,c){console.log(c)};peer.connects=0;peer.retryCount=0;ab._connect(peer)};ab._UA_FIREFOX=/.*Firefox\/([0-9+]*).*/;ab._UA_CHROME=/.*Chrome\/([0-9+]*).*/;ab._UA_CHROMEFRAME=/.*chromeframe\/([0-9]*).*/;ab._UA_WEBKIT=/.*AppleWebKit\/([0-9+.]*)w*.*/;ab._UA_WEBOS=/.*webOS\/([0-9+.]*)w*.*/;ab._matchRegex=function(a,c){var e=c.exec(a);return e?e[1]:e};
73 ab.lookupWsSupport=function(){var a=navigator.userAgent;if(-1<a.indexOf("MSIE")){if(-1<a.indexOf("MSIE 10"))return[!0,!0,!0];if(-1<a.indexOf("chromeframe")){var c=parseInt(ab._matchRegex(a,ab._UA_CHROMEFRAME));return 14<=c?[!0,!1,!0]:[!1,!1,!1]}if(-1<a.indexOf("MSIE 8")||-1<a.indexOf("MSIE 9"))return[!0,!0,!0]}else{if(-1<a.indexOf("Firefox")){if(c=parseInt(ab._matchRegex(a,ab._UA_FIREFOX))){if(7<=c)return[!0,!1,!0];if(3<=c)return[!0,!0,!0]}return[!1,!1,!0]}if(-1<a.indexOf("Safari")&&-1==a.indexOf("Chrome")){if(c=
74 ab._matchRegex(a,ab._UA_WEBKIT))return-1<a.indexOf("Windows")&&"534+"==c||-1<a.indexOf("Macintosh")&&(c=c.replace("+","").split("."),535==parseInt(c[0])&&24<=parseInt(c[1])||535<parseInt(c[0]))?[!0,!1,!0]:-1<a.indexOf("webOS")?(c=ab._matchRegex(a,ab._UA_WEBOS).split("."),2==parseInt(c[0])?[!1,!0,!0]:[!1,!1,!1]):[!0,!0,!0]}else if(-1<a.indexOf("Chrome")){if(c=parseInt(ab._matchRegex(a,ab._UA_CHROME)))return 14<=c?[!0,!1,!0]:4<=c?[!0,!0,!0]:[!1,!1,!0]}else if(-1<a.indexOf("Android")){if(-1<a.indexOf("Firefox")||
75 -1<a.indexOf("CrMo"))return[!0,!1,!0];if(-1<a.indexOf("Opera"))return[!1,!1,!0];if(-1<a.indexOf("CrMo"))return[!0,!0,!0]}else if(-1<a.indexOf("iPhone")||-1<a.indexOf("iPad")||-1<a.indexOf("iPod"))return[!1,!1,!0]}return[!1,!1,!1]};