diff --git a/client-test/server.js b/client-test/server.js index 956f2e7..a7612cf 100644 --- a/client-test/server.js +++ b/client-test/server.js @@ -10,6 +10,12 @@ const type = new sb.ArrayType( id: new sb.UnsignedShortType }) ); +const downloadType = new sb.ArrayType( + new sb.StructType({ + name: new sb.StringType, + id: new sb.PointerType(new sb.UnsignedShortType) + }) +); const VALUE = [{name: 'John', id: 2}, {name: 'Jane', id: 10}]; const PORT = 8080; @@ -28,7 +34,7 @@ http.createServer((req, res) => { }); } else if (req.url.startsWith('/downloadtest')) { - sb.httpRespond({req, res, type, value: VALUE}); + sb.httpRespond({req, res, type: downloadType, value: VALUE}); console.log('Sent download'); } else { diff --git a/compiled/download.js b/compiled/download.js index 3ca0982..3cd03b8 100644 --- a/compiled/download.js +++ b/compiled/download.js @@ -1,2 +1,2 @@ -require=function e(t,r,n){function a(o,u){if(!r[o]){if(!t[o]){var s="function"==typeof require&&require;if(!u&&s)return s(o,!0);if(i)return i(o,!0);var f=Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=r[o]={exports:{}};t[o][0].call(l.exports,function(e){var r=t[o][1][e];return a(r?r:e)},l,l.exports,e,t,r,n)}return r[o].exports}for(var i="function"==typeof require&&require,o=0;o=200&&t.status<300||304===t.status;r?e[o]=t.response:e.text=t.statusText,n(t.status,t.statusText,e,t.getAllResponseHeaders())}),t.open(i,a,s),t.responseType=o;for(var f in r)r.hasOwnProperty(f)&&t.setRequestHeader(f,r[f]);t.send(u)},abort:function(){t&&t.abort()}}}})}(jQuery)},{}],"/client-side/common.js":[function(e,t,r){"use strict";var n=e("/lib/assert.js");if(n.instanceOf(window.Map,Function),n.instanceOf(window.Set,Function),n.instanceOf(window.ArrayBuffer,Function),n.instanceOf(window.Uint8Array,Function),n.instanceOf(window.Symbol,Function),e("/client-side/binary-ajax.js"),void 0===window.sb)window.sb=e("/structure-types.js");else if(!(window.sb instanceof Object))throw Error("window.sb is already defined")},{"/client-side/binary-ajax.js":"/client-side/binary-ajax.js","/lib/assert.js":"/lib/assert.js","/structure-types.js":"/structure-types.js"}],"/config.js":[function(e,t,r){(function(r){"use strict";"/"===r&&(r="");var n=e(r+"/lib/assert.js"),a=e("base64-js"),i=8;n.between(0,i,65536);var o=2,u=new ArrayBuffer(o);new DataView(u).setUint16(0,i);var s=a.fromByteArray(new Uint8Array(u));t.exports={VERSION_STRING:s}}).call(this,"/")},{"base64-js":2}],"/lib/assert.js":[function(e,t,r){"use strict";var n=e("/lib/util-inspect.js"),a={instanceOf:function(e,t){t instanceof Array||(t=[t]);var r=!1,a=!0,i=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(a=(u=s.next()).done);a=!0){var f=u.value;if(e instanceof f||void 0!==e&&null!==e&&e.constructor===f){r=!0;break}}}catch(e){i=!0,o=e}finally{try{!a&&s.return&&s.return()}finally{if(i)throw o}}if(!r)throw new TypeError(n.inspect(e)+" is not an instance of "+t.map(function(e){return e.name}).join(" or "))},integer:function(e){if(a.instanceOf(e,Number),!Number.isSafeInteger(e))throw new RangeError(n.inspect(e)+" is not an integer")},between:function(e,t,r,a){if(t=r){var i=n.inspect(t)+" is not in ["+n.inspect(e)+","+n.inspect(r)+")";throw void 0===a?new RangeError(i):new RangeError(a+" ("+i+")")}},byteUnsignedInteger:function(e){a.integer(e),a.between(0,e,256)},twoByteUnsignedInteger:function(e){a.integer(e),a.between(0,e,65536)},fourByteUnsignedInteger:function(e){a.integer(e),a.between(0,e,4294967296)},fail:function(e){throw Error(e)},assert:function(e,t){e||a.fail(t)},throws:function(e,t){var r=!0;try{e(),r=!1}catch(e){void 0!==t&&a.message(e,t)}a.assert(r,"Should throw an error")},equal:function(e,t){var r=new RangeError("Expected "+n.inspect(t)+" but got "+n.inspect(e));if(t&&t.constructor===Object){for(var i in t)if(t.hasOwnProperty(i))try{a.equal(e[i],t[i])}catch(e){throw r}}else if(t&&t.constructor===Array){if(!e||e.constructor!==Array)throw r;try{a.equal(e.length,t.length)}catch(e){throw r}for(var o=0;o>>3},modEight:function(e){return 7&e}}},{}],"/lib/buffer-string.js":[function(e,t,r){(function(r){"use strict";var n=e(r+"/assert.js"),a=e(r+"/growable-buffer.js"),i=4096;t.exports={toString:function(e){e&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),n.instanceOf(e,Uint8Array);for(var t=[],r=0;r239?4:a>223?3:a>191?2:1;if(r+u<=e.length){var s=void 0,f=void 0,l=void 0,c=void 0;switch(u){case 1:a<128&&(o=a);break;case 2:s=e[r+1],128===(192&s)&&(c=(31&a)<<6|63&s,c>127&&(o=c));break;case 3:s=e[r+1],f=e[r+2],128===(192&s)&&128===(192&f)&&(c=(15&a)<<12|(63&s)<<6|63&f,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:s=e[r+1],f=e[r+2],l=e[r+3],128===(192&s)&&128===(192&f)&&128===(192&l)&&(c=(15&a)<<18|(63&s)<<12|(63&f)<<6|63&l,c>65535&&c<1114112&&(o=c))}}void 0===o?(o=65533,u=1):o>65535&&(o-=65536,t.push(o>>>10&1023|55296),o=56320|1023&o),t.push(o),r+=u}for(var y="",h=0;h>6),t.add(128|63&l)):l<55296||l>=57344?(t.add(224|l>>12),t.add(128|l>>6&63),t.add(128|63&l)):(l=65536+((1023&l)<<10|1023&l),t.add(240|l>>18),t.add(128|l>>12&63),t.add(128|l>>6&63),t.add(128|63&l))}}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return t.toBuffer()},toBinaryString:function(e){n.instanceOf(e,ArrayBuffer);var t="",r=new Uint8Array(e),a=!0,i=!1,o=void 0;try{for(var u,s=r[Symbol.iterator]();!(a=(u=s.next()).done);a=!0){var f=u.value;t+=String.fromCharCode(f)}}catch(e){i=!0,o=e}finally{try{!a&&s.return&&s.return()}finally{if(i)throw o}}return t},fromBinaryString:function(e){n.instanceOf(e,String);for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),a=0;athis.buffer.byteLength){var t=new ArrayBuffer(e<<1);new Uint8Array(t).set(new Uint8Array(this.buffer).subarray(0,this.size)),this.buffer=t}return this}},{key:"set",value:function(e,t){i.integer(e),i.integer(t),i.between(0,e,this.size,"Index out of bounds: "+(e+"")),i.between(0,t,256,"Not a byte: "+(t+""));var r=new Uint8Array(this.buffer);return r[e]=t,this}},{key:"setAll",value:function(e,t){i.instanceOf(t,ArrayBuffer),i.integer(e),i.between(0,e,this.size-t.byteLength+1,"Index out of bounds: "+(e+"")),new Uint8Array(this.buffer).set(new Uint8Array(t),e)}},{key:"get",value:function(e){return i.integer(e),i.between(0,e,this.size,"Index out of bounds: "+(e+"")),new Uint8Array(this.buffer)[e]}},{key:"add",value:function(e){var t=this.size,r=t+1;this.grow(r),this.size=r;var n=new Uint8Array(this.buffer);return n[t]=e,this}},{key:"addAll",value:function(e){i.instanceOf(e,ArrayBuffer);var t=this.size,r=this.size+e.byteLength;return this.grow(r),this.size=r,new Uint8Array(this.buffer).set(new Uint8Array(e),t),this}},{key:"toBuffer",value:function(){return this.buffer.slice(0,this.size)}},{key:"length",get:function(){return this.size}},{key:"rawBuffer",get:function(){return this.buffer}}]),e}();t.exports=u}).call(this,"/lib")},{}],"/lib/strint.js":[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},a={};!function(){function e(e,t){return k(e)===k(t)}function t(e,t){for(;t>0;)e+="0",t--;return e}function r(e){f(e,"string")}function i(e){r(e),s(e,k,"isPositive")}function o(e){f(e,"number")}function u(e){if(f(e,"number"),e<0)throw Error("Expected a positive number: "+e)}function s(e,t,r){if(!t.call(null,e))throw Error("Condition "+r+" failed for value "+e)}function f(e,t){if((void 0===e?"undefined":n(e))!==t)throw Error("Not a "+t+": "+e)}var l=a.subPositive=function(e,t){if(i(e),i(t),!O(e,t))throw Error("x must be greater or equal to y");for(var r=Math.max(e.length,t.length),n="",a=0,o=0,u=0;u=10;)l-=10,a++;0===l?o++:(n=l+""+V(n,o),o=0)}return a>0&&(n=a+""+V(n,o)),n},y=a.add=function(e,t){if(r(e),r(t),k(e)&&k(t))return c(e,t);if(B(e)&&B(t))return S(c(m(e),m(t)));if(T(m(e),m(t))){var n=e;e=t,t=n}var a=l(m(e),m(t));return k(e)?a:S(a)},h=a.sub=function(e,t){return r(e),r(t),y(e,S(t))},v=a.timesDigit=function(e,t){i(e),o(t);for(var r="",n=I(e),a=0,u=0,s=0;s=10;)f-=10,a++;0===f?u++:(r=f+""+V(r,u),u=0)}return a>0&&(r=a+""+V(r,u)),0===r.length?"0":r},g=a.mulPositive=function(e,r){i(e),i(r);for(var n="0",a=I(r),o=0;o=I(e)?"0":e.charAt(e.length-t-1)},I=function(e){return B(e)?e.length-1:e.length}}(),a.LONG_UPPER_SHIFT="4294967296",a.BYTE_SHIFT="256",t.exports=a},{}],"/lib/util-inspect.js":[function(e,t,r){"use strict";r.inspect=function(e){if(void 0===e)return"undefined";if(null===e||e.constructor===Object||e.constructor===Array||e.constructor===String||e.constructor===Number||e.constructor===Boolean||e.constructor===Date)return JSON.stringify(e);if(e.constructor===Set){for(var t="Set {",n=e.values(),a=n.next();!a.done;)t+=r.inspect(a.value),a=n.next(),a.done||(t+=", ");return t+"}"}if(e.constructor===Map){for(var i="Map {",o=e.entries(),u=o.next();!u.done;)i+=r.inspect(u.value[0]),i+=" => ",i+=r.inspect(u.value[1]),u=o.next(),u.done||(i+=", ");return i+"}"}return e.constructor.name?e.constructor.name+" "+JSON.stringify(e):JSON.stringify(e)}},{}],1:[function(e,t,r){"use strict";!function(){function t(){var e={};for(var t in i)e[t]={sig:i[t].sig,type:n.fromByteArray(new Uint8Array(i[t].type.toBuffer()))};localStorage.typeCache=JSON.stringify(e)}e("/client-side/common.js");var r=e("/lib/assert.js"),n=e("base64-js"),a=e("/read.js"),i={};if(void 0===localStorage.typeCache)t();else{var o=JSON.parse(localStorage.typeCache);for(var u in o)i[u]={sig:o[u].sig,type:a.type(new Uint8Array(n.toByteArray(o[u].type)).buffer)}}window.sb.download=function(e,n){function o(e,t,r){if(s){s instanceof Array||(s=[s]);var n=!0,a=!1,i=void 0;try{for(var o,u=s[Symbol.iterator]();!(n=(o=u.next()).done);n=!0){var f=o.value;f(e,t,r)}}catch(e){a=!0,i=e}finally{try{!n&&u.return&&u.return()}finally{if(a)throw i}}}}r.instanceOf(e,String),r.instanceOf(n,Object),n.processData=!1,n.dataType="arraybuffer";var u=!1;i[e]&&(u=!0,n.headers||(n.headers={}),n.headers.sig=i[e].sig);var s=n.success;n.success=function(r,n,s){var f=s.getResponseHeader("sig");if(u&&i[e].sig===f){var l=i[e].type,c=a.value({buffer:r,type:l});o(c,n,s)}else{var y=a._consumeType(r,0),h=a.value({buffer:r,offset:y.length,type:y.value}),v=y.value;i[e]={sig:f,type:v},t(),o(h,n,s)}},$.ajax(n)}}()},{"/client-side/common.js":"/client-side/common.js","/lib/assert.js":"/lib/assert.js","/read.js":"/read.js","base64-js":2}],2:[function(e,t,r){"use strict";function n(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t0)throw Error("Invalid string. Length must be a multiple of 4");i="="===e[u-2]?2:"="===e[u-1]?1:0,o=new l(3*u/4-i),n=i>0?u-4:u;var s=0;for(t=0,r=0;t>16&255,o[s++]=a>>8&255,o[s++]=255&a;return 2===i?(a=f[e.charCodeAt(t)]<<2|f[e.charCodeAt(t+1)]>>4,o[s++]=255&a):1===i&&(a=f[e.charCodeAt(t)]<<10|f[e.charCodeAt(t+1)]<<4|f[e.charCodeAt(t+2)]>>2,o[s++]=a>>8&255,o[s++]=255&a),o}function i(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function o(e,t,r){for(var n,a=[],o=t;ol?l:f+u));return 1===n?(t=e[r-1],a+=s[t>>2],a+=s[t<<4&63],a+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],a+=s[t>>10],a+=s[t>>4&63],a+=s[t<<2&63],a+="="),i.push(a),i.join("")}r.toByteArray=a,r.fromByteArray=u;var s=[],f=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],3:[function(e,t,r){!function(e){"use strict";function r(e){return e.map(function(e){return n(e.toString(16),2)}).join("")}function n(e,t){return e.length>t?e:Array(t-e.length+1).join("0")+e}var a={bytesToHex:function(e){return r(e)},hexToBytes:function(e){if(e.length%2===1)throw Error("hexToBytes can't have a string with an odd number of characters.");return 0===e.indexOf("0x")&&(e=e.slice(2)),e.match(/../g).map(function(e){return parseInt(e,16)})}};void 0!==t&&t.exports?t.exports=a:e.convertHex=a}(this)},{}],4:[function(e,t,r){!function(e){"use strict";var r={bytesToString:function(e){return e.map(function(e){return String.fromCharCode(e)}).join("")},stringToBytes:function(e){return e.split("").map(function(e){return e.charCodeAt(0)})}};r.UTF8={bytesToString:function(e){return decodeURIComponent(escape(r.bytesToString(e)))},stringToBytes:function(e){return r.stringToBytes(unescape(encodeURIComponent(e)))}},void 0!==t&&t.exports?t.exports=r:e.convertString=r}(this)},{}],5:[function(e,t,r){!function(r){"use strict";function n(e,t){e.constructor===String&&(e=a.convertString.UTF8.stringToBytes(e));var r=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],n=o(e),i=8*e.length;n[i>>5]|=128<<24-i%32,n[(i+64>>9<<4)+15]=i;for(var s=0;s>>5]|=e[r]<<24-n%32;return t},u=function(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t},s=[],f=function(e,t,r){for(var n=e[0],a=e[1],o=e[2],u=e[3],f=e[4],l=e[5],c=e[6],y=e[7],h=0;h<64;h++){if(h<16)s[h]=0|t[r+h];else{var v=s[h-15],g=(v<<25|v>>>7)^(v<<14|v>>>18)^v>>>3,d=s[h-2],p=(d<<15|d>>>17)^(d<<13|d>>>19)^d>>>10;s[h]=g+s[h-7]+p+s[h-16]}var b=f&l^~f&c,w=n&a^n&o^a&o,T=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),O=(f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25),A=y+O+b+i[h]+s[h],B=T+w;y=c,c=l,l=f,f=u+A|0,u=o,o=a,a=n,n=A+B|0}e[0]=e[0]+n|0,e[1]=e[1]+a|0,e[2]=e[2]+o|0,e[3]=e[3]+u|0,e[4]=e[4]+f|0,e[5]=e[5]+l|0,e[6]=e[6]+c|0,e[7]=e[7]+y|0};n.x2=function(e,t){return n(n(e,{asBytes:!0}),t)}}(this)},{"convert-hex":3,"convert-string":4}],"/read.js":[function(e,t,r){(function(r){"use strict";function n(e,t){try{return{value:new DataView(e).getUint32(t),length:4}}catch(e){l.fail(d)}}function a(e,t){return e.length=0,"Offset is negative: "+(t+"")),l.assert(e.byteLength>t,d);var r=void 0,o=1,u=new Uint8Array(e)[t],f=!0,c=!1,h=void 0;try{for(var g,b=p[Symbol.iterator]();!(f=(g=b.next()).done);f=!0){var w=g.value;if(u===w._value)return{value:new w,length:o}}}catch(e){c=!0,h=e}finally{try{!f&&b.return&&b.return()}finally{if(c)throw h}}switch(u){case v.BooleanTupleType._value:var T=n(e,t+o);r=new v.BooleanTupleType(T.value),o+=T.length;break;case v.TupleType._value:var O=i(e,t+o);o+=O.length;var A=n(e,t+o);o+=A.length,r=new v.TupleType({type:O.value,length:A.value});break;case v.StructType._value:l.assert(e.byteLength>t+o,d);var B=new Uint8Array(e),k=B[t+o];o++;for(var m={},S=0;St+o,d);var j=B[t+o];o++,l.assert(e.byteLength>=t+o+j,d);var U=y.toString(B.subarray(t+o,t+o+j));o+=j;var x=i(e,t+o);m[U]=x.value,o+=x.length}r=new v.StructType(m);break;case v.ArrayType._value:var _=i(e,t+o);o+=_.length,r=new v.ArrayType(_.value);break;case v.SetType._value:var V=i(e,t+o);o+=V.length,r=new v.SetType(V.value);break;case v.MapType._value:var P=i(e,t+o);o+=P.length;var I=i(e,t+o);o+=I.length,r=new v.MapType(P.value,I.value);break;case v.EnumType._value:var E=i(e,t+o);o+=E.length,l.assert(e.byteLength>t+o,d);var L=new Uint8Array(e)[t+o];o++;for(var D=[],C=0;Ct+o,d);var F=new Uint8Array(e)[t+o];o++;for(var H=Array(F),q=0;q=t+G,d);var Y=new DataView(e).getUint16(t+o),J=i(e,t+o-Y);r=J.value,o=G;break;default:l.fail("No such type: 0x"+a(new Uint8Array(e)[t].toString(16),2))}return{value:r,length:o}}function o(e){var t=arguments.length<=1||void 0===arguments[1]||arguments[1];l.instanceOf(e,ArrayBuffer);var r=i(e,0),n=r.value,a=r.length;return t&&l.assert(a===e.byteLength,"Did not consume all of the buffer"),n}function u(e){var t=e.buffer,r=e.offset,n=e.count,a=Array(n),i=c.modEight(a.length),o=c.dividedByEight(a.length),u=void 0;u=i?o+1:o,l.assert(t.byteLength>=r+u,d);for(var s=new Uint8Array(t),f=0;f=r+o,d),i=new Int8Array(t)[r];break;case v.ShortType:o=2,l.assert(t.byteLength>=r+o,d);var f=new DataView(t);i=f.getInt16(r);break;case v.IntType:o=4;var c=new DataView(t);i=c.getInt32(r);break;case v.LongType:o=8,l.assert(t.byteLength>=r+o,d);var p=new DataView(t),b=p.getInt32(r),w=p.getUint32(r+4);i=h.add(h.mul(b+"",h.LONG_UPPER_SHIFT),w+"");break;case v.BigIntType:o=2,l.assert(t.byteLength>=r+o,d);var T=new DataView(t),O=T.getUint16(r);l.assert(t.byteLength>=r+o+O,d),i=O?T.getInt8(r+o)+"":"0";for(var A=1;A=r+o,d),i=new Uint8Array(t)[r];break;case v.UnsignedShortType:o=2,l.assert(t.byteLength>=r+o,d),i=new DataView(t).getUint16(r);break;case v.UnsignedIntType:o=4,l.assert(t.byteLength>=r+o,d),i=new DataView(t).getUint32(r);break;case v.UnsignedLongType:case v.DateType:o=8,l.assert(t.byteLength>=r+o,d);var B=new DataView(t),k=B.getUint32(r),m=B.getUint32(r+4);i=h.add(h.mul(k+"",h.LONG_UPPER_SHIFT),m+""),a.constructor===v.DateType&&(i=new Date(+i));break;case v.BigUnsignedIntType:o=2,l.assert(t.byteLength>=r+o,d);var S=new DataView(t),j=S.getUint16(r);l.assert(t.byteLength>=r+o+j,d),i="0";for(var U=0;U=r+o,d),i=new DataView(t).getFloat32(r);break;case v.DoubleType:o=8,l.assert(t.byteLength>=r+o,d),i=new DataView(t).getFloat64(r);break;case v.BooleanType:o=1,l.assert(t.byteLength>=r+o,d);var x=new Uint8Array(t)[r];l.assert(0===x||255===x,"0x"+x.toString(16)+" is an invalid Boolean value"),i=!!x;break;case v.BooleanArrayType:var _=n(t,r);o=_.length;var V=u({buffer:t,offset:r+o,count:_.value});o+=V.length,i=V.value;break;case v.BooleanTupleType:var P=u({buffer:t,offset:r,count:a.length});i=P.value,o=P.length;break;case v.CharType:l.assert(t.byteLength>r,d),i=y.toString(new Uint8Array(t).subarray(r,r+4))[0],o=y.fromString(i).byteLength;break;case v.StringType:var I=new Uint8Array(t);for(o=0;l.assert(t.byteLength>r+o,d),I[r+o];o++);i=y.toString(new Uint8Array(t).subarray(r,r+o)),o++;break;case v.OctetsType:var E=n(t,r);o=E.length;var L=o+E.value;l.assert(t.byteLength>=r+L,d),i=t.slice(r+o,r+L),o=L;break;case v.TupleType:o=0,i=Array(a.length);for(var D=0;D=r+o,d);var ne=new Uint8Array(t)[r];i=a.values[ne],void 0===i&&l.fail("Index "+(ne+"")+" is invalid");break;case v.ChoiceType:o=1,l.assert(t.byteLength>=r+o,d);var ae=new Uint8Array(t)[r],ie=s({buffer:t,offset:r+o,type:a.types[ae]});o+=ie.length,i=ie.value;break;case v.OptionalType:o=1,l.assert(t.byteLength>=r+o,d);var oe=new Uint8Array(t)[r];if(l.assert(0===oe||255===oe,"0x"+oe.toString(16)+" is an invalid Optional byte"),oe){var ue=s({buffer:t,offset:r+o,type:a.type});o+=ue.length,i=ue.value}else i=null;break;case v.PointerType:var se=n(t,r);o=se.length,i=s({buffer:t,offset:se.value,type:a.type}).value;break;default:l.fail("Not a structure type: "+g.inspect(a))}return{value:i,length:o}}function f(e){var t=e.buffer,r=e.type,n=e.offset;l.instanceOf(t,ArrayBuffer),l.instanceOf(r,v.Type),void 0===n&&(n=0),l.instanceOf(n,Number);var a=s({buffer:t,offset:n,type:r}),i=a.value;return i}"/"===r&&(r="");var l=e(r+"/lib/assert.js"),c=e(r+"/lib/bit-math.js"),y=e(r+"/lib/buffer-string.js"),h=e(r+"/lib/strint.js"),v=e(r+"/structure-types.js"),g=e("/lib/util-inspect.js"),d="Buffer is not long enough",p=[v.ByteType,v.ShortType,v.IntType,v.LongType,v.BigIntType,v.UnsignedByteType,v.UnsignedShortType,v.UnsignedIntType,v.UnsignedLongType,v.DateType,v.BigUnsignedIntType,v.FloatType,v.DoubleType,v.BooleanType,v.BooleanArrayType,v.CharType,v.StringType,v.OctetsType];t.exports={_consumeType:i,type:o,value:f}}).call(this,"/")},{"/lib/util-inspect.js":"/lib/util-inspect.js"}],"/structure-types.js":[function(e,t,r){(function(r){"use strict";function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){var t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e),t}function u(e,t){if(t&&e.pointers){var r=!0,n=!1,a=void 0;try{for(var i,o=e.pointers[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=h(i.value,2),s=u[0],f=u[1],l=e.length;e.addAll(d.fromBinaryString(s));var c=new ArrayBuffer(4);new DataView(c).setUint32(0,l);var y=!0,v=!1,g=void 0;try{for(var p,b=f[Symbol.iterator]();!(y=(p=b.next()).done);y=!0){var w=p.value;e.setAll(w,c)}}catch(e){v=!0,g=e}finally{try{!y&&b.return&&b.return()}finally{if(v)throw g}}}}catch(e){n=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw a}}}}function s(e){if(e&&e.constructor===String){var t=+e;if(!isNaN(t))return t}}function f(e,t){v.instanceOf(e,w),v.instanceOf(t,String),(T.gt(t,q)||T.lt(t,"0"))&&v.fail("Value out of range");var r=T.div(t,T.LONG_UPPER_SHIFT),n=T.sub(t,T.mul(r,T.LONG_UPPER_SHIFT)),a=new ArrayBuffer(8),i=new DataView(a);i.setUint32(0,+r),i.setUint32(4,+n),e.addAll(a)}function l(e,t){v.instanceOf(t,Array);var r=k(t.length),n=B(t.length),a=void 0;a=r?n+1:n;for(var i=new ArrayBuffer(a),o=new Uint8Array(i),u=0;u-1;s--,u++)o.setUint8(u,r[s]);r.length&&o.setInt8(2,r[r.length-1]),e.addAll(i)}}],[{key:"_value",get:function(){return 6}}]),t}(x),C=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),t}(U),N=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,256,"Value out of range");var n=new ArrayBuffer(1);new Uint8Array(n)[0]=t,e.addAll(n)}}],[{key:"_value",get:function(){return 17}}]),t}(C),F=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,65536,"Value out of range");var n=new ArrayBuffer(2);new DataView(n).setUint16(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 18}}]),t}(C),H=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,4294967296,"Value out of range");var n=new ArrayBuffer(4);new DataView(n).setUint32(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 19}}]),t}(C),q="18446744073709551615",R=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){f(e,t)}}],[{key:"_value",get:function(){return 20}}]),t}(C),M=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(t,Date),f(e,t.getTime()+"")}}],[{key:"_value",get:function(){return 21}}]),t}(U),z=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String),T.isNegative(t)&&v.fail("Value out of range");var r=[];if(!T.eq(t,"0")){for(;T.ge(t,T.BYTE_SHIFT);){var n=T.quotientRemainderPositive(t,T.BYTE_SHIFT),a=h(n,2),i=a[0],o=a[1];r.push(+o),t=i}r.push(+t),v.twoByteUnsignedInteger(r.length)}var u=new ArrayBuffer(2+r.length),s=new DataView(u);s.setUint16(0,r.length);for(var f=2,l=r.length-1;l>-1;l--,f++)s.setUint8(f,r[l]);e.addAll(u)}}],[{key:"_value",get:function(){return 22}}]),t}(C),G=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),t}(U),Y=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.instanceOf(t,Number);var n=new ArrayBuffer(4);new DataView(n).setFloat32(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 32}}]),t}(G),J=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.instanceOf(t,Number);var n=new ArrayBuffer(8);new DataView(n).setFloat64(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 33}}]),t}(G),W=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,Boolean),t?e.add(255):e.add(0)}}],[{key:"_value",get:function(){return 48}}]),t}(U),X=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));return v.fourByteUnsignedInteger(e),r.length=e,r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 49}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&e.addAll(o(this.length))}},{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,Array),t.length!==this.length&&v.fail("Length does not match"),l(e,t)}}]),t}(U),$=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(t,Array),v.fourByteUnsignedInteger(t.length),e.addAll(o(t.length)),l(e,t)}}],[{key:"_value",get:function(){return 50}}]),t}(U),Q=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String),v.assert(1===t.length,"String must contain only 1 character"),e.addAll(d.fromString(t))}}],[{key:"_value",get:function(){return 64}}]),t}(U),K=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String);var r=d.fromString(t);e.addAll(r),e.add(0)}}],[{key:"_value",get:function(){return 65}}]),t}(U),Z=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,ArrayBuffer),v.fourByteUnsignedInteger(t.byteLength),e.addAll(o(t.byteLength)),e.addAll(t)}}],[{key:"_value",get:function(){return 66}}]),t}(U),ee=function(e){function t(e){var r=e.type,a=e.length;i(this,t);var o=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(r,j),v.fourByteUnsignedInteger(a),o.type=r,o.length=a,o}return a(t,e),y(t,null,[{key:"_value",get:function(){return 80}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&(this.type.addToBuffer(e),e.addAll(o(this.length)))}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Array),t.length!==this.length&&v.fail("Length does not match: expected "+(this.length+"")+" but got "+t.length);var n=!0,a=!1,i=void 0;try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var f=o.value;this.type.writeValue(e,f,!1)}}catch(e){a=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),te="name",re="type",ne="buffer",ae=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));v.instanceOf(e,Object);var a=0;for(var o in e)a++;try{v.byteUnsignedInteger(a)}catch(e){v.fail(a+" fields is too many")}r.fields=Array(a);var u=0;for(var s in e){var f=d.fromString(s);try{v.byteUnsignedInteger(f.byteLength)}catch(e){v.fail("Field name "+s+" is too long")}var l=e[s];try{v.instanceOf(l,j)}catch(e){v.fail(l+" is not a valid field type")}var c={};c[te]=s,c[re]=l,c[ne]=f,r.fields[u]=c,u++}return r.fields.sort(function(e,t){return e[te]t[te]?1:void 0}),r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 81}}]),y(t,[{key:"addToBuffer",value:function(e){if(c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)){e.add(this.fields.length);var r=!0,n=!1,a=void 0;try{for(var i,o=this.fields[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=i.value,s=u[ne];e.add(s.byteLength),e.addAll(s),u[re].addToBuffer(e)}}catch(e){n=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw a}}}}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Object);var n=!0,a=!1,i=void 0;try{for(var o,s=this.fields[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var f=o.value,l=t[f[te]];void 0===l&&v.fail("Value for field "+f[te]+" missing"),f[re].writeValue(e,l,!1)}}catch(e){a=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),ie=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(e,j),r.type=e,r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 82}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&this.type.addToBuffer(e)}},{key:"_writeValue",value:function(e,t,r){v.instanceOf(e,w),v.fourByteUnsignedInteger(t.length),e.addAll(o(t.length));var n=!0,a=!1,i=void 0;try{for(var s,f=t[Symbol.iterator]();!(n=(s=f.next()).done);n=!0){var l=s.value;this.type.writeValue(e,l,!1)}}catch(e){a=!0,i=e}finally{try{!n&&f.return&&f.return()}finally{if(a)throw i}}u(e,r)}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,Array),this._writeValue(e,t,r)}}]),t}(U),oe=function(e){function t(e){return i(this,t),n(this,Object.getPrototypeOf(t).call(this,e))}return a(t,e),y(t,null,[{key:"_value",get:function(){return 83}}]),y(t,[{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,Set),t.length=t.size,this._writeValue(e,t,r)}}]),t}(ie),ue=function(e){function t(e,r){i(this,t);var a=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(e,j),v.instanceOf(r,j),a.keyType=e,a.valueType=r,a}return a(t,e),y(t,null,[{key:"_value",get:function(){return 84}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&(this.keyType.addToBuffer(e),this.valueType.addToBuffer(e))}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Map),v.fourByteUnsignedInteger(t.size),e.addAll(o(t.size));var n=!0,a=!1,i=void 0;try{for(var s,f=t[Symbol.iterator]();!(n=(s=f.next()).done);n=!0){var l=h(s.value,2),c=l[0],y=l[1];this.keyType.writeValue(e,c,!1),this.valueType.writeValue(e,y,!1)}}catch(e){a=!0,i=e}finally{try{!n&&f.return&&f.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),se=function(e){function t(e){var r=e.type,a=e.values;i(this,t);var o=n(this,Object.getPrototypeOf(t).call(this));v.instanceOf(r,U),v.instanceOf(a,Array);try{v.byteUnsignedInteger(a.length)}catch(e){v.fail(a.length+" values is too many")}for(var u=new Map,s=0;s=200&&t.status<300||304===t.status;r?e[o]=t.response:e.text=t.statusText,n(t.status,t.statusText,e,t.getAllResponseHeaders())}),t.open(i,a,s),t.responseType=o;for(var f in r)r.hasOwnProperty(f)&&t.setRequestHeader(f,r[f]);t.send(u)},abort:function(){t&&t.abort()}}}})}(jQuery)},{}],"/client-side/common.js":[function(e,t,r){"use strict";var n=e("/lib/assert.js");if(n.instanceOf(window.Map,Function),n.instanceOf(window.Set,Function),n.instanceOf(window.ArrayBuffer,Function),n.instanceOf(window.Uint8Array,Function),n.instanceOf(window.Symbol,Function),e("/client-side/binary-ajax.js"),void 0===window.sb)window.sb=e("/structure-types.js");else if(!(window.sb instanceof Object))throw Error("window.sb is already defined")},{"/client-side/binary-ajax.js":"/client-side/binary-ajax.js","/lib/assert.js":"/lib/assert.js","/structure-types.js":"/structure-types.js"}],"/config.js":[function(e,t,r){(function(r){"use strict";"/"===r&&(r="");var n=e(r+"/lib/assert.js"),a=e("base64-js"),i=8;n.between(0,i,65536);var o=2,u=new ArrayBuffer(o);new DataView(u).setUint16(0,i);var s=a.fromByteArray(new Uint8Array(u));t.exports={VERSION_STRING:s}}).call(this,"/")},{"base64-js":2}],"/lib/assert.js":[function(e,t,r){"use strict";var n=e("/lib/util-inspect.js"),a={instanceOf:function(e,t){t instanceof Array||(t=[t]);var r=!1,a=!0,i=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(a=(u=s.next()).done);a=!0){var f=u.value;if(e instanceof f||void 0!==e&&null!==e&&e.constructor===f){r=!0;break}}}catch(e){i=!0,o=e}finally{try{!a&&s.return&&s.return()}finally{if(i)throw o}}if(!r)throw new TypeError(n.inspect(e)+" is not an instance of "+t.map(function(e){return e.name}).join(" or "))},integer:function(e){if(a.instanceOf(e,Number),!Number.isSafeInteger(e))throw new RangeError(n.inspect(e)+" is not an integer")},between:function(e,t,r,a){if(t=r){var i=n.inspect(t)+" is not in ["+n.inspect(e)+","+n.inspect(r)+")";throw void 0===a?new RangeError(i):new RangeError(a+" ("+i+")")}},byteUnsignedInteger:function(e){a.integer(e),a.between(0,e,256)},twoByteUnsignedInteger:function(e){a.integer(e),a.between(0,e,65536)},fourByteUnsignedInteger:function(e){a.integer(e),a.between(0,e,4294967296)},fail:function(e){throw Error(e)},assert:function(e,t){e||a.fail(t)},throws:function(e,t){var r=!0;try{e(),r=!1}catch(e){void 0!==t&&a.message(e,t)}a.assert(r,"Should throw an error")},equal:function(e,t){var r=new RangeError("Expected "+n.inspect(t)+" but got "+n.inspect(e));if(t&&t.constructor===Object){for(var i in t)if(t.hasOwnProperty(i))try{a.equal(e[i],t[i])}catch(e){throw r}}else if(t&&t.constructor===Array){if(!e||e.constructor!==Array)throw r;try{a.equal(e.length,t.length)}catch(e){throw r}for(var o=0;o>>3},modEight:function(e){return 7&e}}},{}],"/lib/buffer-string.js":[function(e,t,r){(function(r){"use strict";var n=e(r+"/assert.js"),a=e(r+"/growable-buffer.js"),i=4096;t.exports={toString:function(e){e&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),n.instanceOf(e,Uint8Array);for(var t=[],r=0;r239?4:a>223?3:a>191?2:1;if(r+u<=e.length){var s=void 0,f=void 0,l=void 0,c=void 0;switch(u){case 1:a<128&&(o=a);break;case 2:s=e[r+1],128===(192&s)&&(c=(31&a)<<6|63&s,c>127&&(o=c));break;case 3:s=e[r+1],f=e[r+2],128===(192&s)&&128===(192&f)&&(c=(15&a)<<12|(63&s)<<6|63&f,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:s=e[r+1],f=e[r+2],l=e[r+3],128===(192&s)&&128===(192&f)&&128===(192&l)&&(c=(15&a)<<18|(63&s)<<12|(63&f)<<6|63&l,c>65535&&c<1114112&&(o=c))}}void 0===o?(o=65533,u=1):o>65535&&(o-=65536,t.push(o>>>10&1023|55296),o=56320|1023&o),t.push(o),r+=u}for(var y="",h=0;h>6),t.add(128|63&l)):l<55296||l>=57344?(t.add(224|l>>12),t.add(128|l>>6&63),t.add(128|63&l)):(l=65536+((1023&l)<<10|1023&l),t.add(240|l>>18),t.add(128|l>>12&63),t.add(128|l>>6&63),t.add(128|63&l))}}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return t.toBuffer()},toBinaryString:function(e){n.instanceOf(e,ArrayBuffer);var t="",r=new Uint8Array(e),a=!0,i=!1,o=void 0;try{for(var u,s=r[Symbol.iterator]();!(a=(u=s.next()).done);a=!0){var f=u.value;t+=String.fromCharCode(f)}}catch(e){i=!0,o=e}finally{try{!a&&s.return&&s.return()}finally{if(i)throw o}}return t},fromBinaryString:function(e){n.instanceOf(e,String);for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),a=0;athis.buffer.byteLength){var t=new ArrayBuffer(e<<1);new Uint8Array(t).set(new Uint8Array(this.buffer).subarray(0,this.size)),this.buffer=t}return this}},{key:"set",value:function(e,t){i.integer(e),i.integer(t),i.between(0,e,this.size,"Index out of bounds: "+(e+"")),i.between(0,t,256,"Not a byte: "+(t+""));var r=new Uint8Array(this.buffer);return r[e]=t,this}},{key:"setAll",value:function(e,t){i.instanceOf(t,ArrayBuffer),i.integer(e),i.between(0,e,this.size-t.byteLength+1,"Index out of bounds: "+(e+"")),new Uint8Array(this.buffer).set(new Uint8Array(t),e)}},{key:"get",value:function(e){return i.integer(e),i.between(0,e,this.size,"Index out of bounds: "+(e+"")),new Uint8Array(this.buffer)[e]}},{key:"add",value:function(e){var t=this.size,r=t+1;this.grow(r),this.size=r;var n=new Uint8Array(this.buffer);return n[t]=e,this}},{key:"addAll",value:function(e){i.instanceOf(e,ArrayBuffer);var t=this.size,r=this.size+e.byteLength;return this.grow(r),this.size=r,new Uint8Array(this.buffer).set(new Uint8Array(e),t),this}},{key:"toBuffer",value:function(){return this.buffer.slice(0,this.size)}},{key:"length",get:function(){return this.size}},{key:"rawBuffer",get:function(){return this.buffer}}]),e}();t.exports=u}).call(this,"/lib")},{}],"/lib/strint.js":[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},a={};!function(){function e(e,t){return S(e)===S(t)}function t(e,t){for(;t>0;)e+="0",t--;return e}function r(e){f(e,"string")}function i(e){r(e),s(e,S,"isPositive")}function o(e){f(e,"number")}function u(e){if(f(e,"number"),e<0)throw Error("Expected a positive number: "+e)}function s(e,t,r){if(!t.call(null,e))throw Error("Condition "+r+" failed for value "+e)}function f(e,t){if((void 0===e?"undefined":n(e))!==t)throw Error("Not a "+t+": "+e)}var l=a.subPositive=function(e,t){if(i(e),i(t),!O(e,t))throw Error("x must be greater or equal to y");for(var r=Math.max(e.length,t.length),n="",a=0,o=0,u=0;u=10;)l-=10,a++;0===l?o++:(n=l+""+V(n,o),o=0)}return a>0&&(n=a+""+V(n,o)),n},y=a.add=function(e,t){if(r(e),r(t),S(e)&&S(t))return c(e,t);if(B(e)&&B(t))return m(c(k(e),k(t)));if(T(k(e),k(t))){var n=e;e=t,t=n}var a=l(k(e),k(t));return S(e)?a:m(a)},h=a.sub=function(e,t){return r(e),r(t),y(e,m(t))},v=a.timesDigit=function(e,t){i(e),o(t);for(var r="",n=I(e),a=0,u=0,s=0;s=10;)f-=10,a++;0===f?u++:(r=f+""+V(r,u),u=0)}return a>0&&(r=a+""+V(r,u)),0===r.length?"0":r},g=a.mulPositive=function(e,r){i(e),i(r);for(var n="0",a=I(r),o=0;o=I(e)?"0":e.charAt(e.length-t-1)},I=function(e){return B(e)?e.length-1:e.length}}(),a.LONG_UPPER_SHIFT="4294967296",a.BYTE_SHIFT="256",t.exports=a},{}],"/lib/util-inspect.js":[function(e,t,r){"use strict";r.inspect=function(e){if(void 0===e)return"undefined";if(null===e||e.constructor===Object||e.constructor===Array||e.constructor===String||e.constructor===Number||e.constructor===Boolean||e.constructor===Date)return JSON.stringify(e);if(e.constructor===Set){for(var t="Set {",n=e.values(),a=n.next();!a.done;)t+=r.inspect(a.value),a=n.next(),a.done||(t+=", ");return t+"}"}if(e.constructor===Map){for(var i="Map {",o=e.entries(),u=o.next();!u.done;)i+=r.inspect(u.value[0]),i+=" => ",i+=r.inspect(u.value[1]),u=o.next(),u.done||(i+=", ");return i+"}"}return e.constructor.name?e.constructor.name+" "+JSON.stringify(e):JSON.stringify(e)}},{}],"/read.js":[function(e,t,r){(function(r){"use strict";function n(e,t){try{return{value:new DataView(e).getUint32(t),length:4}}catch(e){l.fail(d)}}function a(e,t){return e.length=0,"Offset is negative: "+(t+"")),l.assert(e.byteLength>t,d);var r=void 0,o=1,u=new Uint8Array(e)[t],f=!0,c=!1,h=void 0;try{for(var g,b=p[Symbol.iterator]();!(f=(g=b.next()).done);f=!0){var w=g.value;if(u===w._value)return{value:new w,length:o}}}catch(e){c=!0,h=e}finally{try{!f&&b.return&&b.return()}finally{if(c)throw h}}switch(u){case v.BooleanTupleType._value:var T=n(e,t+o);r=new v.BooleanTupleType(T.value),o+=T.length;break;case v.TupleType._value:var O=i(e,t+o);o+=O.length;var A=n(e,t+o);o+=A.length,r=new v.TupleType({type:O.value,length:A.value});break;case v.StructType._value:l.assert(e.byteLength>t+o,d);var B=new Uint8Array(e),S=B[t+o];o++;for(var k={},m=0;mt+o,d);var j=B[t+o];o++,l.assert(e.byteLength>=t+o+j,d);var U=y.toString(B.subarray(t+o,t+o+j));o+=j;var x=i(e,t+o);k[U]=x.value,o+=x.length}r=new v.StructType(k);break;case v.ArrayType._value:var _=i(e,t+o);o+=_.length,r=new v.ArrayType(_.value);break;case v.SetType._value:var V=i(e,t+o);o+=V.length,r=new v.SetType(V.value);break;case v.MapType._value:var P=i(e,t+o);o+=P.length;var I=i(e,t+o);o+=I.length,r=new v.MapType(P.value,I.value);break;case v.EnumType._value:var E=i(e,t+o);o+=E.length,l.assert(e.byteLength>t+o,d);var L=new Uint8Array(e)[t+o];o++;for(var D=[],C=0;Ct+o,d);var H=new Uint8Array(e)[t+o];o++;for(var q=Array(H),R=0;R=t+Y,d);var J=new DataView(e).getUint16(t+o),W=i(e,t+o-J);r=W.value,o=Y;break;default:l.fail("No such type: 0x"+a(new Uint8Array(e)[t].toString(16),2))}return{value:r,length:o}}function o(e){var t=arguments.length<=1||void 0===arguments[1]||arguments[1];l.instanceOf(e,ArrayBuffer);var r=i(e,0),n=r.value,a=r.length;return t&&l.assert(a===e.byteLength,"Did not consume all of the buffer"),n}function u(e){var t=e.buffer,r=e.offset,n=e.count,a=Array(n),i=c.modEight(a.length),o=c.dividedByEight(a.length),u=void 0;u=i?o+1:o,l.assert(t.byteLength>=r+u,d);for(var s=new Uint8Array(t),f=0;f=a+f,d),o=new Int8Array(t)[a];break;case v.ShortType:f=2,l.assert(t.byteLength>=a+f,d);var c=new DataView(t);o=c.getInt16(a);break;case v.IntType:f=4;var p=new DataView(t);o=p.getInt32(a);break;case v.LongType:f=8,l.assert(t.byteLength>=a+f,d);var b=new DataView(t),w=b.getInt32(a),T=b.getUint32(a+4);o=h.add(h.mul(w+"",h.LONG_UPPER_SHIFT),T+"");break;case v.BigIntType:f=2,l.assert(t.byteLength>=a+f,d);var O=new DataView(t),A=O.getUint16(a);l.assert(t.byteLength>=a+f+A,d),o=A?O.getInt8(a+f)+"":"0";for(var B=1;B=a+f,d),o=new Uint8Array(t)[a];break;case v.UnsignedShortType:f=2,l.assert(t.byteLength>=a+f,d),o=new DataView(t).getUint16(a);break;case v.UnsignedIntType:f=4,l.assert(t.byteLength>=a+f,d),o=new DataView(t).getUint32(a);break;case v.UnsignedLongType:case v.DateType:f=8,l.assert(t.byteLength>=a+f,d);var S=new DataView(t),k=S.getUint32(a),m=S.getUint32(a+4);o=h.add(h.mul(k+"",h.LONG_UPPER_SHIFT),m+""),i.constructor===v.DateType&&(o=new Date(+o));break;case v.BigUnsignedIntType:f=2,l.assert(t.byteLength>=a+f,d);var j=new DataView(t),U=j.getUint16(a);l.assert(t.byteLength>=a+f+U,d),o="0";for(var x=0;x=a+f,d),o=new DataView(t).getFloat32(a);break;case v.DoubleType:f=8,l.assert(t.byteLength>=a+f,d),o=new DataView(t).getFloat64(a);break;case v.BooleanType:f=1,l.assert(t.byteLength>=a+f,d);var _=new Uint8Array(t)[a];l.assert(0===_||255===_,"0x"+_.toString(16)+" is an invalid Boolean value"),o=!!_;break;case v.BooleanArrayType:var V=n(t,a);f=V.length;var P=u({buffer:t,offset:a+f,count:V.value});f+=P.length,o=P.value;break;case v.BooleanTupleType:var I=u({buffer:t,offset:a,count:i.length});o=I.value,f=I.length;break;case v.CharType:l.assert(t.byteLength>a,d),o=y.toString(new Uint8Array(t).subarray(a,a+4))[0],f=y.fromString(o).byteLength;break;case v.StringType:var E=new Uint8Array(t);for(f=0;l.assert(t.byteLength>a+f,d),E[a+f];f++);o=y.toString(new Uint8Array(t).subarray(a,a+f)),f++;break;case v.OctetsType:var L=n(t,a);f=L.length;var D=f+L.value;l.assert(t.byteLength>=a+D,d),o=t.slice(a+f,a+D),f=D;break;case v.TupleType:f=0,o=Array(i.length);for(var C=0;C=a+f,d);var ae=new Uint8Array(t)[a];o=i.values[ae],void 0===o&&l.fail("Index "+(ae+"")+" is invalid");break;case v.ChoiceType:f=1,l.assert(t.byteLength>=a+f,d);var ie=new Uint8Array(t)[a],oe=s({buffer:t,pointerStart:r,offset:a+f,type:i.types[ie]});f+=oe.length,o=oe.value;break;case v.OptionalType:f=1,l.assert(t.byteLength>=a+f,d);var ue=new Uint8Array(t)[a];if(l.assert(0===ue||255===ue,"0x"+ue.toString(16)+" is an invalid Optional byte"),ue){var se=s({buffer:t,pointerStart:r,offset:a+f,type:i.type});f+=se.length,o=se.value}else o=null;break;case v.PointerType:var fe=n(t,a);f=fe.length,o=s({buffer:t,pointerStart:r,offset:r+fe.value,type:i.type}).value;break;default:l.fail("Not a structure type: "+g.inspect(i))}return{value:o,length:f}}function f(e){var t=e.buffer,r=e.type,n=e.offset;l.instanceOf(t,ArrayBuffer),l.instanceOf(r,v.Type),void 0===n&&(n=0),l.instanceOf(n,Number);var a=s({buffer:t,offset:n,type:r,pointerStart:n}),i=a.value;return i}"/"===r&&(r="");var l=e(r+"/lib/assert.js"),c=e(r+"/lib/bit-math.js"),y=e(r+"/lib/buffer-string.js"),h=e(r+"/lib/strint.js"),v=e(r+"/structure-types.js"),g=e("/lib/util-inspect.js"),d="Buffer is not long enough",p=[v.ByteType,v.ShortType,v.IntType,v.LongType,v.BigIntType,v.UnsignedByteType,v.UnsignedShortType,v.UnsignedIntType,v.UnsignedLongType,v.DateType,v.BigUnsignedIntType,v.FloatType,v.DoubleType,v.BooleanType,v.BooleanArrayType,v.CharType,v.StringType,v.OctetsType];t.exports={_consumeType:i,type:o,value:f}}).call(this,"/")},{"/lib/util-inspect.js":"/lib/util-inspect.js"}],"/structure-types.js":[function(e,t,r){(function(r){"use strict";function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){var t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e),t}function u(e,t){if(t&&e.pointers){var r=!0,n=!1,a=void 0;try{for(var i,o=e.pointers[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=h(i.value,2),s=u[0],f=u[1],l=e.length;e.addAll(d.fromBinaryString(s));var c=new ArrayBuffer(4);new DataView(c).setUint32(0,l);var y=!0,v=!1,g=void 0;try{for(var p,b=f[Symbol.iterator]();!(y=(p=b.next()).done);y=!0){var w=p.value;e.setAll(w,c)}}catch(e){v=!0,g=e}finally{try{!y&&b.return&&b.return()}finally{if(v)throw g}}}}catch(e){n=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw a}}}}function s(e){if(e&&e.constructor===String){var t=+e;if(!isNaN(t))return t}}function f(e,t){v.instanceOf(e,w),v.instanceOf(t,String),(T.gt(t,q)||T.lt(t,"0"))&&v.fail("Value out of range");var r=T.div(t,T.LONG_UPPER_SHIFT),n=T.sub(t,T.mul(r,T.LONG_UPPER_SHIFT)),a=new ArrayBuffer(8),i=new DataView(a);i.setUint32(0,+r),i.setUint32(4,+n),e.addAll(a)}function l(e,t){v.instanceOf(t,Array);var r=S(t.length),n=B(t.length),a=void 0;a=r?n+1:n;for(var i=new ArrayBuffer(a),o=new Uint8Array(i),u=0;u-1;s--,u++)o.setUint8(u,r[s]);r.length&&o.setInt8(2,r[r.length-1]),e.addAll(i)}}],[{key:"_value",get:function(){return 6}}]),t}(x),C=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),t}(U),N=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,256,"Value out of range");var n=new ArrayBuffer(1);new Uint8Array(n)[0]=t,e.addAll(n)}}],[{key:"_value",get:function(){return 17}}]),t}(C),F=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,65536,"Value out of range");var n=new ArrayBuffer(2);new DataView(n).setUint16(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 18}}]),t}(C),H=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,4294967296,"Value out of range");var n=new ArrayBuffer(4);new DataView(n).setUint32(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 19}}]),t}(C),q="18446744073709551615",R=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){f(e,t)}}],[{key:"_value",get:function(){return 20}}]),t}(C),M=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(t,Date),f(e,t.getTime()+"")}}],[{key:"_value",get:function(){return 21}}]),t}(U),z=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String),T.isNegative(t)&&v.fail("Value out of range");var r=[];if(!T.eq(t,"0")){for(;T.ge(t,T.BYTE_SHIFT);){var n=T.quotientRemainderPositive(t,T.BYTE_SHIFT),a=h(n,2),i=a[0],o=a[1];r.push(+o),t=i}r.push(+t),v.twoByteUnsignedInteger(r.length)}var u=new ArrayBuffer(2+r.length),s=new DataView(u);s.setUint16(0,r.length);for(var f=2,l=r.length-1;l>-1;l--,f++)s.setUint8(f,r[l]);e.addAll(u)}}],[{key:"_value",get:function(){return 22}}]),t}(C),G=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),t}(U),Y=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.instanceOf(t,Number);var n=new ArrayBuffer(4);new DataView(n).setFloat32(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 32}}]),t}(G),J=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.instanceOf(t,Number);var n=new ArrayBuffer(8);new DataView(n).setFloat64(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 33}}]),t}(G),W=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,Boolean),t?e.add(255):e.add(0)}}],[{key:"_value",get:function(){return 48}}]),t}(U),X=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));return v.fourByteUnsignedInteger(e),r.length=e,r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 49}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&e.addAll(o(this.length))}},{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,Array),t.length!==this.length&&v.fail("Length does not match"),l(e,t); +}}]),t}(U),$=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(t,Array),v.fourByteUnsignedInteger(t.length),e.addAll(o(t.length)),l(e,t)}}],[{key:"_value",get:function(){return 50}}]),t}(U),Q=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String),v.assert(1===t.length,"String must contain only 1 character"),e.addAll(d.fromString(t))}}],[{key:"_value",get:function(){return 64}}]),t}(U),K=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String);var r=d.fromString(t);e.addAll(r),e.add(0)}}],[{key:"_value",get:function(){return 65}}]),t}(U),Z=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,ArrayBuffer),v.fourByteUnsignedInteger(t.byteLength),e.addAll(o(t.byteLength)),e.addAll(t)}}],[{key:"_value",get:function(){return 66}}]),t}(U),ee=function(e){function t(e){var r=e.type,a=e.length;i(this,t);var o=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(r,j),v.fourByteUnsignedInteger(a),o.type=r,o.length=a,o}return a(t,e),y(t,null,[{key:"_value",get:function(){return 80}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&(this.type.addToBuffer(e),e.addAll(o(this.length)))}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Array),t.length!==this.length&&v.fail("Length does not match: expected "+(this.length+"")+" but got "+t.length);var n=!0,a=!1,i=void 0;try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var f=o.value;this.type.writeValue(e,f,!1)}}catch(e){a=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),te="name",re="type",ne="buffer",ae=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));v.instanceOf(e,Object);var a=0;for(var o in e)a++;try{v.byteUnsignedInteger(a)}catch(e){v.fail(a+" fields is too many")}r.fields=Array(a);var u=0;for(var s in e){var f=d.fromString(s);try{v.byteUnsignedInteger(f.byteLength)}catch(e){v.fail("Field name "+s+" is too long")}var l=e[s];try{v.instanceOf(l,j)}catch(e){v.fail(l+" is not a valid field type")}var c={};c[te]=s,c[re]=l,c[ne]=f,r.fields[u]=c,u++}return r.fields.sort(function(e,t){return e[te]t[te]?1:void 0}),r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 81}}]),y(t,[{key:"addToBuffer",value:function(e){if(c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)){e.add(this.fields.length);var r=!0,n=!1,a=void 0;try{for(var i,o=this.fields[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=i.value,s=u[ne];e.add(s.byteLength),e.addAll(s),u[re].addToBuffer(e)}}catch(e){n=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw a}}}}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Object);var n=!0,a=!1,i=void 0;try{for(var o,s=this.fields[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var f=o.value,l=t[f[te]];void 0===l&&v.fail("Value for field "+f[te]+" missing"),f[re].writeValue(e,l,!1)}}catch(e){a=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),ie=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(e,j),r.type=e,r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 82}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&this.type.addToBuffer(e)}},{key:"_writeValue",value:function(e,t,r){v.instanceOf(e,w),v.fourByteUnsignedInteger(t.length),e.addAll(o(t.length));var n=!0,a=!1,i=void 0;try{for(var s,f=t[Symbol.iterator]();!(n=(s=f.next()).done);n=!0){var l=s.value;this.type.writeValue(e,l,!1)}}catch(e){a=!0,i=e}finally{try{!n&&f.return&&f.return()}finally{if(a)throw i}}u(e,r)}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,Array),this._writeValue(e,t,r)}}]),t}(U),oe=function(e){function t(e){return i(this,t),n(this,Object.getPrototypeOf(t).call(this,e))}return a(t,e),y(t,null,[{key:"_value",get:function(){return 83}}]),y(t,[{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,Set),t.length=t.size,this._writeValue(e,t,r)}}]),t}(ie),ue=function(e){function t(e,r){i(this,t);var a=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(e,j),v.instanceOf(r,j),a.keyType=e,a.valueType=r,a}return a(t,e),y(t,null,[{key:"_value",get:function(){return 84}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&(this.keyType.addToBuffer(e),this.valueType.addToBuffer(e))}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Map),v.fourByteUnsignedInteger(t.size),e.addAll(o(t.size));var n=!0,a=!1,i=void 0;try{for(var s,f=t[Symbol.iterator]();!(n=(s=f.next()).done);n=!0){var l=h(s.value,2),c=l[0],y=l[1];this.keyType.writeValue(e,c,!1),this.valueType.writeValue(e,y,!1)}}catch(e){a=!0,i=e}finally{try{!n&&f.return&&f.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),se=function(e){function t(e){var r=e.type,a=e.values;i(this,t);var o=n(this,Object.getPrototypeOf(t).call(this));v.instanceOf(r,U),v.instanceOf(a,Array);try{v.byteUnsignedInteger(a.length)}catch(e){v.fail(a.length+" values is too many")}for(var u=new Map,s=0;s0)throw Error("Invalid string. Length must be a multiple of 4");i="="===e[u-2]?2:"="===e[u-1]?1:0,o=new l(3*u/4-i),n=i>0?u-4:u;var s=0;for(t=0,r=0;t>16&255,o[s++]=a>>8&255,o[s++]=255&a;return 2===i?(a=f[e.charCodeAt(t)]<<2|f[e.charCodeAt(t+1)]>>4,o[s++]=255&a):1===i&&(a=f[e.charCodeAt(t)]<<10|f[e.charCodeAt(t+1)]<<4|f[e.charCodeAt(t+2)]>>2,o[s++]=a>>8&255,o[s++]=255&a),o}function i(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function o(e,t,r){for(var n,a=[],o=t;ol?l:f+u));return 1===n?(t=e[r-1],a+=s[t>>2],a+=s[t<<4&63],a+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],a+=s[t>>10],a+=s[t>>4&63],a+=s[t<<2&63],a+="="),i.push(a),i.join("")}r.toByteArray=a,r.fromByteArray=u;var s=[],f=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],3:[function(e,t,r){!function(e){"use strict";function r(e){return e.map(function(e){return n(e.toString(16),2)}).join("")}function n(e,t){return e.length>t?e:Array(t-e.length+1).join("0")+e}var a={bytesToHex:function(e){return r(e)},hexToBytes:function(e){if(e.length%2===1)throw Error("hexToBytes can't have a string with an odd number of characters.");return 0===e.indexOf("0x")&&(e=e.slice(2)),e.match(/../g).map(function(e){return parseInt(e,16)})}};void 0!==t&&t.exports?t.exports=a:e.convertHex=a}(this)},{}],4:[function(e,t,r){!function(e){"use strict";var r={bytesToString:function(e){return e.map(function(e){return String.fromCharCode(e)}).join("")},stringToBytes:function(e){return e.split("").map(function(e){return e.charCodeAt(0)})}};r.UTF8={bytesToString:function(e){return decodeURIComponent(escape(r.bytesToString(e)))},stringToBytes:function(e){return r.stringToBytes(unescape(encodeURIComponent(e)))}},void 0!==t&&t.exports?t.exports=r:e.convertString=r}(this)},{}],5:[function(e,t,r){!function(r){"use strict";function n(e,t){e.constructor===String&&(e=a.convertString.UTF8.stringToBytes(e));var r=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],n=o(e),i=8*e.length;n[i>>5]|=128<<24-i%32,n[(i+64>>9<<4)+15]=i;for(var s=0;s>>5]|=e[r]<<24-n%32;return t},u=function(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t},s=[],f=function(e,t,r){for(var n=e[0],a=e[1],o=e[2],u=e[3],f=e[4],l=e[5],c=e[6],y=e[7],h=0;h<64;h++){if(h<16)s[h]=0|t[r+h];else{var v=s[h-15],g=(v<<25|v>>>7)^(v<<14|v>>>18)^v>>>3,d=s[h-2],p=(d<<15|d>>>17)^(d<<13|d>>>19)^d>>>10;s[h]=g+s[h-7]+p+s[h-16]}var b=f&l^~f&c,w=n&a^n&o^a&o,T=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),O=(f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25),A=y+O+b+i[h]+s[h],B=T+w;y=c,c=l,l=f,f=u+A|0,u=o,o=a,a=n,n=A+B|0}e[0]=e[0]+n|0,e[1]=e[1]+a|0,e[2]=e[2]+o|0,e[3]=e[3]+u|0,e[4]=e[4]+f|0,e[5]=e[5]+l|0,e[6]=e[6]+c|0,e[7]=e[7]+y|0};n.x2=function(e,t){return n(n(e,{asBytes:!0}),t)}}(this)},{"convert-hex":3,"convert-string":4}]},{},[1]); \ No newline at end of file diff --git a/compiled/upload-download.js b/compiled/upload-download.js index d1b4026..a2e15bb 100644 --- a/compiled/upload-download.js +++ b/compiled/upload-download.js @@ -1,2 +1,2 @@ -require=function e(t,r,n){function a(o,u){if(!r[o]){if(!t[o]){var s="function"==typeof require&&require;if(!u&&s)return s(o,!0);if(i)return i(o,!0);var f=Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=r[o]={exports:{}};t[o][0].call(l.exports,function(e){var r=t[o][1][e];return a(r?r:e)},l,l.exports,e,t,r,n)}return r[o].exports}for(var i="function"==typeof require&&require,o=0;o=200&&t.status<300||304===t.status;r?e[o]=t.response:e.text=t.statusText,n(t.status,t.statusText,e,t.getAllResponseHeaders())}),t.open(i,a,s),t.responseType=o;for(var f in r)r.hasOwnProperty(f)&&t.setRequestHeader(f,r[f]);t.send(u)},abort:function(){t&&t.abort()}}}})}(jQuery)},{}],"/client-side/common.js":[function(e,t,r){"use strict";var n=e("/lib/assert.js");if(n.instanceOf(window.Map,Function),n.instanceOf(window.Set,Function),n.instanceOf(window.ArrayBuffer,Function),n.instanceOf(window.Uint8Array,Function),n.instanceOf(window.Symbol,Function),e("/client-side/binary-ajax.js"),void 0===window.sb)window.sb=e("/structure-types.js");else if(!(window.sb instanceof Object))throw Error("window.sb is already defined")},{"/client-side/binary-ajax.js":"/client-side/binary-ajax.js","/lib/assert.js":"/lib/assert.js","/structure-types.js":"/structure-types.js"}],"/config.js":[function(e,t,r){(function(r){"use strict";"/"===r&&(r="");var n=e(r+"/lib/assert.js"),a=e("base64-js"),i=8;n.between(0,i,65536);var o=2,u=new ArrayBuffer(o);new DataView(u).setUint16(0,i);var s=a.fromByteArray(new Uint8Array(u));t.exports={VERSION_STRING:s}}).call(this,"/")},{"base64-js":2}],"/lib/assert.js":[function(e,t,r){"use strict";var n=e("/lib/util-inspect.js"),a={instanceOf:function(e,t){t instanceof Array||(t=[t]);var r=!1,a=!0,i=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(a=(u=s.next()).done);a=!0){var f=u.value;if(e instanceof f||void 0!==e&&null!==e&&e.constructor===f){r=!0;break}}}catch(e){i=!0,o=e}finally{try{!a&&s.return&&s.return()}finally{if(i)throw o}}if(!r)throw new TypeError(n.inspect(e)+" is not an instance of "+t.map(function(e){return e.name}).join(" or "))},integer:function(e){if(a.instanceOf(e,Number),!Number.isSafeInteger(e))throw new RangeError(n.inspect(e)+" is not an integer")},between:function(e,t,r,a){if(t=r){var i=n.inspect(t)+" is not in ["+n.inspect(e)+","+n.inspect(r)+")";throw void 0===a?new RangeError(i):new RangeError(a+" ("+i+")")}},byteUnsignedInteger:function(e){a.integer(e),a.between(0,e,256)},twoByteUnsignedInteger:function(e){a.integer(e),a.between(0,e,65536)},fourByteUnsignedInteger:function(e){a.integer(e),a.between(0,e,4294967296)},fail:function(e){throw Error(e)},assert:function(e,t){e||a.fail(t)},throws:function(e,t){var r=!0;try{e(),r=!1}catch(e){void 0!==t&&a.message(e,t)}a.assert(r,"Should throw an error")},equal:function(e,t){var r=new RangeError("Expected "+n.inspect(t)+" but got "+n.inspect(e));if(t&&t.constructor===Object){for(var i in t)if(t.hasOwnProperty(i))try{a.equal(e[i],t[i])}catch(e){throw r}}else if(t&&t.constructor===Array){if(!e||e.constructor!==Array)throw r;try{a.equal(e.length,t.length)}catch(e){throw r}for(var o=0;o>>3},modEight:function(e){return 7&e}}},{}],"/lib/buffer-string.js":[function(e,t,r){(function(r){"use strict";var n=e(r+"/assert.js"),a=e(r+"/growable-buffer.js"),i=4096;t.exports={toString:function(e){e&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),n.instanceOf(e,Uint8Array);for(var t=[],r=0;r239?4:a>223?3:a>191?2:1;if(r+u<=e.length){var s=void 0,f=void 0,l=void 0,c=void 0;switch(u){case 1:a<128&&(o=a);break;case 2:s=e[r+1],128===(192&s)&&(c=(31&a)<<6|63&s,c>127&&(o=c));break;case 3:s=e[r+1],f=e[r+2],128===(192&s)&&128===(192&f)&&(c=(15&a)<<12|(63&s)<<6|63&f,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:s=e[r+1],f=e[r+2],l=e[r+3],128===(192&s)&&128===(192&f)&&128===(192&l)&&(c=(15&a)<<18|(63&s)<<12|(63&f)<<6|63&l,c>65535&&c<1114112&&(o=c))}}void 0===o?(o=65533,u=1):o>65535&&(o-=65536,t.push(o>>>10&1023|55296),o=56320|1023&o),t.push(o),r+=u}for(var y="",h=0;h>6),t.add(128|63&l)):l<55296||l>=57344?(t.add(224|l>>12),t.add(128|l>>6&63),t.add(128|63&l)):(l=65536+((1023&l)<<10|1023&l),t.add(240|l>>18),t.add(128|l>>12&63),t.add(128|l>>6&63),t.add(128|63&l))}}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return t.toBuffer()},toBinaryString:function(e){n.instanceOf(e,ArrayBuffer);var t="",r=new Uint8Array(e),a=!0,i=!1,o=void 0;try{for(var u,s=r[Symbol.iterator]();!(a=(u=s.next()).done);a=!0){var f=u.value;t+=String.fromCharCode(f)}}catch(e){i=!0,o=e}finally{try{!a&&s.return&&s.return()}finally{if(i)throw o}}return t},fromBinaryString:function(e){n.instanceOf(e,String);for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),a=0;athis.buffer.byteLength){var t=new ArrayBuffer(e<<1);new Uint8Array(t).set(new Uint8Array(this.buffer).subarray(0,this.size)),this.buffer=t}return this}},{key:"set",value:function(e,t){i.integer(e),i.integer(t),i.between(0,e,this.size,"Index out of bounds: "+(e+"")),i.between(0,t,256,"Not a byte: "+(t+""));var r=new Uint8Array(this.buffer);return r[e]=t,this}},{key:"setAll",value:function(e,t){i.instanceOf(t,ArrayBuffer),i.integer(e),i.between(0,e,this.size-t.byteLength+1,"Index out of bounds: "+(e+"")),new Uint8Array(this.buffer).set(new Uint8Array(t),e)}},{key:"get",value:function(e){return i.integer(e),i.between(0,e,this.size,"Index out of bounds: "+(e+"")),new Uint8Array(this.buffer)[e]}},{key:"add",value:function(e){var t=this.size,r=t+1;this.grow(r),this.size=r;var n=new Uint8Array(this.buffer);return n[t]=e,this}},{key:"addAll",value:function(e){i.instanceOf(e,ArrayBuffer);var t=this.size,r=this.size+e.byteLength;return this.grow(r),this.size=r,new Uint8Array(this.buffer).set(new Uint8Array(e),t),this}},{key:"toBuffer",value:function(){return this.buffer.slice(0,this.size)}},{key:"length",get:function(){return this.size}},{key:"rawBuffer",get:function(){return this.buffer}}]),e}();t.exports=u}).call(this,"/lib")},{}],"/lib/strint.js":[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},a={};!function(){function e(e,t){return m(e)===m(t)}function t(e,t){for(;t>0;)e+="0",t--;return e}function r(e){f(e,"string")}function i(e){r(e),s(e,m,"isPositive")}function o(e){f(e,"number")}function u(e){if(f(e,"number"),e<0)throw Error("Expected a positive number: "+e)}function s(e,t,r){if(!t.call(null,e))throw Error("Condition "+r+" failed for value "+e)}function f(e,t){if((void 0===e?"undefined":n(e))!==t)throw Error("Not a "+t+": "+e)}var l=a.subPositive=function(e,t){if(i(e),i(t),!O(e,t))throw Error("x must be greater or equal to y");for(var r=Math.max(e.length,t.length),n="",a=0,o=0,u=0;u=10;)l-=10,a++;0===l?o++:(n=l+""+V(n,o),o=0)}return a>0&&(n=a+""+V(n,o)),n},y=a.add=function(e,t){if(r(e),r(t),m(e)&&m(t))return c(e,t);if(B(e)&&B(t))return S(c(k(e),k(t)));if(T(k(e),k(t))){var n=e;e=t,t=n}var a=l(k(e),k(t));return m(e)?a:S(a)},h=a.sub=function(e,t){return r(e),r(t),y(e,S(t))},v=a.timesDigit=function(e,t){i(e),o(t);for(var r="",n=I(e),a=0,u=0,s=0;s=10;)f-=10,a++;0===f?u++:(r=f+""+V(r,u),u=0)}return a>0&&(r=a+""+V(r,u)),0===r.length?"0":r},g=a.mulPositive=function(e,r){i(e),i(r);for(var n="0",a=I(r),o=0;o=I(e)?"0":e.charAt(e.length-t-1)},I=function(e){return B(e)?e.length-1:e.length}}(),a.LONG_UPPER_SHIFT="4294967296",a.BYTE_SHIFT="256",t.exports=a},{}],"/lib/util-inspect.js":[function(e,t,r){"use strict";r.inspect=function(e){if(void 0===e)return"undefined";if(null===e||e.constructor===Object||e.constructor===Array||e.constructor===String||e.constructor===Number||e.constructor===Boolean||e.constructor===Date)return JSON.stringify(e);if(e.constructor===Set){for(var t="Set {",n=e.values(),a=n.next();!a.done;)t+=r.inspect(a.value),a=n.next(),a.done||(t+=", ");return t+"}"}if(e.constructor===Map){for(var i="Map {",o=e.entries(),u=o.next();!u.done;)i+=r.inspect(u.value[0]),i+=" => ",i+=r.inspect(u.value[1]),u=o.next(),u.done||(i+=", ");return i+"}"}return e.constructor.name?e.constructor.name+" "+JSON.stringify(e):JSON.stringify(e)}},{}],1:[function(e,t,r){"use strict";!function(){e("/client-side/common.js");var t=e("/lib/assert.js");window.sb.upload=function(e,r){var n=e.type,a=e.value;if(t.instanceOf(n,window.sb.Type),t.instanceOf(r,Object),"POST"!==r.type&&"POST"!==r.method)throw Error("Must use POST when uploading");r.processData=!1,r.data=n.valueBuffer(a),$.ajax(r)}}(),function(){function t(){var e={};for(var t in i)e[t]={sig:i[t].sig,type:n.fromByteArray(new Uint8Array(i[t].type.toBuffer()))};localStorage.typeCache=JSON.stringify(e)}e("/client-side/common.js");var r=e("/lib/assert.js"),n=e("base64-js"),a=e("/read.js"),i={};if(void 0===localStorage.typeCache)t();else{var o=JSON.parse(localStorage.typeCache);for(var u in o)i[u]={sig:o[u].sig,type:a.type(new Uint8Array(n.toByteArray(o[u].type)).buffer)}}window.sb.download=function(e,n){function o(e,t,r){if(s){s instanceof Array||(s=[s]);var n=!0,a=!1,i=void 0;try{for(var o,u=s[Symbol.iterator]();!(n=(o=u.next()).done);n=!0){var f=o.value;f(e,t,r)}}catch(e){a=!0,i=e}finally{try{!n&&u.return&&u.return()}finally{if(a)throw i}}}}r.instanceOf(e,String),r.instanceOf(n,Object),n.processData=!1,n.dataType="arraybuffer";var u=!1;i[e]&&(u=!0,n.headers||(n.headers={}),n.headers.sig=i[e].sig);var s=n.success;n.success=function(r,n,s){var f=s.getResponseHeader("sig");if(u&&i[e].sig===f){var l=i[e].type,c=a.value({buffer:r,type:l});o(c,n,s)}else{var y=a._consumeType(r,0),h=a.value({buffer:r,offset:y.length,type:y.value}),v=y.value;i[e]={sig:f,type:v},t(),o(h,n,s)}},$.ajax(n)}}()},{"/client-side/common.js":"/client-side/common.js","/lib/assert.js":"/lib/assert.js","/read.js":"/read.js","base64-js":2}],2:[function(e,t,r){"use strict";function n(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t0)throw Error("Invalid string. Length must be a multiple of 4");i="="===e[u-2]?2:"="===e[u-1]?1:0,o=new l(3*u/4-i),n=i>0?u-4:u;var s=0;for(t=0,r=0;t>16&255,o[s++]=a>>8&255,o[s++]=255&a;return 2===i?(a=f[e.charCodeAt(t)]<<2|f[e.charCodeAt(t+1)]>>4,o[s++]=255&a):1===i&&(a=f[e.charCodeAt(t)]<<10|f[e.charCodeAt(t+1)]<<4|f[e.charCodeAt(t+2)]>>2,o[s++]=a>>8&255,o[s++]=255&a),o}function i(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function o(e,t,r){for(var n,a=[],o=t;ol?l:f+u));return 1===n?(t=e[r-1],a+=s[t>>2],a+=s[t<<4&63],a+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],a+=s[t>>10],a+=s[t>>4&63],a+=s[t<<2&63],a+="="),i.push(a),i.join("")}r.toByteArray=a,r.fromByteArray=u;var s=[],f=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],3:[function(e,t,r){!function(e){"use strict";function r(e){return e.map(function(e){return n(e.toString(16),2)}).join("")}function n(e,t){return e.length>t?e:Array(t-e.length+1).join("0")+e}var a={bytesToHex:function(e){return r(e)},hexToBytes:function(e){if(e.length%2===1)throw Error("hexToBytes can't have a string with an odd number of characters.");return 0===e.indexOf("0x")&&(e=e.slice(2)),e.match(/../g).map(function(e){return parseInt(e,16)})}};void 0!==t&&t.exports?t.exports=a:e.convertHex=a}(this)},{}],4:[function(e,t,r){!function(e){"use strict";var r={bytesToString:function(e){return e.map(function(e){return String.fromCharCode(e)}).join("")},stringToBytes:function(e){return e.split("").map(function(e){return e.charCodeAt(0)})}};r.UTF8={bytesToString:function(e){return decodeURIComponent(escape(r.bytesToString(e)))},stringToBytes:function(e){return r.stringToBytes(unescape(encodeURIComponent(e)))}},void 0!==t&&t.exports?t.exports=r:e.convertString=r}(this)},{}],5:[function(e,t,r){!function(r){"use strict";function n(e,t){e.constructor===String&&(e=a.convertString.UTF8.stringToBytes(e));var r=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],n=o(e),i=8*e.length;n[i>>5]|=128<<24-i%32,n[(i+64>>9<<4)+15]=i;for(var s=0;s>>5]|=e[r]<<24-n%32;return t},u=function(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t},s=[],f=function(e,t,r){for(var n=e[0],a=e[1],o=e[2],u=e[3],f=e[4],l=e[5],c=e[6],y=e[7],h=0;h<64;h++){if(h<16)s[h]=0|t[r+h];else{var v=s[h-15],g=(v<<25|v>>>7)^(v<<14|v>>>18)^v>>>3,d=s[h-2],p=(d<<15|d>>>17)^(d<<13|d>>>19)^d>>>10;s[h]=g+s[h-7]+p+s[h-16]}var b=f&l^~f&c,w=n&a^n&o^a&o,T=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),O=(f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25),A=y+O+b+i[h]+s[h],B=T+w;y=c,c=l,l=f,f=u+A|0,u=o,o=a,a=n,n=A+B|0}e[0]=e[0]+n|0,e[1]=e[1]+a|0,e[2]=e[2]+o|0,e[3]=e[3]+u|0,e[4]=e[4]+f|0,e[5]=e[5]+l|0,e[6]=e[6]+c|0,e[7]=e[7]+y|0};n.x2=function(e,t){return n(n(e,{asBytes:!0}),t)}}(this)},{"convert-hex":3,"convert-string":4}],"/read.js":[function(e,t,r){(function(r){"use strict";function n(e,t){try{return{value:new DataView(e).getUint32(t),length:4}}catch(e){l.fail(d)}}function a(e,t){return e.length=0,"Offset is negative: "+(t+"")),l.assert(e.byteLength>t,d);var r=void 0,o=1,u=new Uint8Array(e)[t],f=!0,c=!1,h=void 0;try{for(var g,b=p[Symbol.iterator]();!(f=(g=b.next()).done);f=!0){var w=g.value;if(u===w._value)return{value:new w,length:o}}}catch(e){c=!0,h=e}finally{try{!f&&b.return&&b.return()}finally{if(c)throw h}}switch(u){case v.BooleanTupleType._value:var T=n(e,t+o);r=new v.BooleanTupleType(T.value),o+=T.length;break;case v.TupleType._value:var O=i(e,t+o);o+=O.length;var A=n(e,t+o);o+=A.length,r=new v.TupleType({type:O.value,length:A.value});break;case v.StructType._value:l.assert(e.byteLength>t+o,d);var B=new Uint8Array(e),m=B[t+o];o++;for(var k={},S=0;St+o,d);var j=B[t+o];o++,l.assert(e.byteLength>=t+o+j,d);var U=y.toString(B.subarray(t+o,t+o+j));o+=j;var x=i(e,t+o);k[U]=x.value,o+=x.length}r=new v.StructType(k);break;case v.ArrayType._value:var _=i(e,t+o);o+=_.length,r=new v.ArrayType(_.value);break;case v.SetType._value:var V=i(e,t+o);o+=V.length,r=new v.SetType(V.value);break;case v.MapType._value:var P=i(e,t+o);o+=P.length;var I=i(e,t+o);o+=I.length,r=new v.MapType(P.value,I.value);break;case v.EnumType._value:var E=i(e,t+o);o+=E.length,l.assert(e.byteLength>t+o,d);var L=new Uint8Array(e)[t+o];o++;for(var D=[],C=0;Ct+o,d);var F=new Uint8Array(e)[t+o];o++;for(var H=Array(F),q=0;q=t+G,d);var Y=new DataView(e).getUint16(t+o),J=i(e,t+o-Y);r=J.value,o=G;break;default:l.fail("No such type: 0x"+a(new Uint8Array(e)[t].toString(16),2))}return{value:r,length:o}}function o(e){var t=arguments.length<=1||void 0===arguments[1]||arguments[1];l.instanceOf(e,ArrayBuffer);var r=i(e,0),n=r.value,a=r.length;return t&&l.assert(a===e.byteLength,"Did not consume all of the buffer"),n}function u(e){var t=e.buffer,r=e.offset,n=e.count,a=Array(n),i=c.modEight(a.length),o=c.dividedByEight(a.length),u=void 0;u=i?o+1:o,l.assert(t.byteLength>=r+u,d);for(var s=new Uint8Array(t),f=0;f=r+o,d),i=new Int8Array(t)[r];break;case v.ShortType:o=2,l.assert(t.byteLength>=r+o,d);var f=new DataView(t);i=f.getInt16(r);break;case v.IntType:o=4;var c=new DataView(t);i=c.getInt32(r);break;case v.LongType:o=8,l.assert(t.byteLength>=r+o,d);var p=new DataView(t),b=p.getInt32(r),w=p.getUint32(r+4);i=h.add(h.mul(b+"",h.LONG_UPPER_SHIFT),w+"");break;case v.BigIntType:o=2,l.assert(t.byteLength>=r+o,d);var T=new DataView(t),O=T.getUint16(r);l.assert(t.byteLength>=r+o+O,d),i=O?T.getInt8(r+o)+"":"0";for(var A=1;A=r+o,d),i=new Uint8Array(t)[r];break;case v.UnsignedShortType:o=2,l.assert(t.byteLength>=r+o,d),i=new DataView(t).getUint16(r);break;case v.UnsignedIntType:o=4,l.assert(t.byteLength>=r+o,d),i=new DataView(t).getUint32(r);break;case v.UnsignedLongType:case v.DateType:o=8,l.assert(t.byteLength>=r+o,d);var B=new DataView(t),m=B.getUint32(r),k=B.getUint32(r+4);i=h.add(h.mul(m+"",h.LONG_UPPER_SHIFT),k+""),a.constructor===v.DateType&&(i=new Date(+i));break;case v.BigUnsignedIntType:o=2,l.assert(t.byteLength>=r+o,d);var S=new DataView(t),j=S.getUint16(r);l.assert(t.byteLength>=r+o+j,d),i="0";for(var U=0;U=r+o,d),i=new DataView(t).getFloat32(r);break;case v.DoubleType:o=8,l.assert(t.byteLength>=r+o,d),i=new DataView(t).getFloat64(r);break;case v.BooleanType:o=1,l.assert(t.byteLength>=r+o,d);var x=new Uint8Array(t)[r];l.assert(0===x||255===x,"0x"+x.toString(16)+" is an invalid Boolean value"),i=!!x;break;case v.BooleanArrayType:var _=n(t,r);o=_.length;var V=u({buffer:t,offset:r+o,count:_.value});o+=V.length,i=V.value;break;case v.BooleanTupleType:var P=u({buffer:t,offset:r,count:a.length});i=P.value,o=P.length;break;case v.CharType:l.assert(t.byteLength>r,d),i=y.toString(new Uint8Array(t).subarray(r,r+4))[0],o=y.fromString(i).byteLength;break;case v.StringType:var I=new Uint8Array(t);for(o=0;l.assert(t.byteLength>r+o,d),I[r+o];o++);i=y.toString(new Uint8Array(t).subarray(r,r+o)),o++;break;case v.OctetsType:var E=n(t,r);o=E.length;var L=o+E.value;l.assert(t.byteLength>=r+L,d),i=t.slice(r+o,r+L),o=L;break;case v.TupleType:o=0,i=Array(a.length);for(var D=0;D=r+o,d);var ne=new Uint8Array(t)[r];i=a.values[ne],void 0===i&&l.fail("Index "+(ne+"")+" is invalid");break;case v.ChoiceType:o=1,l.assert(t.byteLength>=r+o,d);var ae=new Uint8Array(t)[r],ie=s({buffer:t,offset:r+o,type:a.types[ae]});o+=ie.length,i=ie.value;break;case v.OptionalType:o=1,l.assert(t.byteLength>=r+o,d);var oe=new Uint8Array(t)[r];if(l.assert(0===oe||255===oe,"0x"+oe.toString(16)+" is an invalid Optional byte"),oe){var ue=s({buffer:t,offset:r+o,type:a.type});o+=ue.length,i=ue.value}else i=null;break;case v.PointerType:var se=n(t,r);o=se.length,i=s({buffer:t,offset:se.value,type:a.type}).value;break;default:l.fail("Not a structure type: "+g.inspect(a))}return{value:i,length:o}}function f(e){var t=e.buffer,r=e.type,n=e.offset;l.instanceOf(t,ArrayBuffer),l.instanceOf(r,v.Type),void 0===n&&(n=0),l.instanceOf(n,Number);var a=s({buffer:t,offset:n,type:r}),i=a.value;return i}"/"===r&&(r="");var l=e(r+"/lib/assert.js"),c=e(r+"/lib/bit-math.js"),y=e(r+"/lib/buffer-string.js"),h=e(r+"/lib/strint.js"),v=e(r+"/structure-types.js"),g=e("/lib/util-inspect.js"),d="Buffer is not long enough",p=[v.ByteType,v.ShortType,v.IntType,v.LongType,v.BigIntType,v.UnsignedByteType,v.UnsignedShortType,v.UnsignedIntType,v.UnsignedLongType,v.DateType,v.BigUnsignedIntType,v.FloatType,v.DoubleType,v.BooleanType,v.BooleanArrayType,v.CharType,v.StringType,v.OctetsType];t.exports={_consumeType:i,type:o,value:f}}).call(this,"/")},{"/lib/util-inspect.js":"/lib/util-inspect.js"}],"/structure-types.js":[function(e,t,r){(function(r){"use strict";function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){var t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e),t}function u(e,t){if(t&&e.pointers){var r=!0,n=!1,a=void 0;try{for(var i,o=e.pointers[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=h(i.value,2),s=u[0],f=u[1],l=e.length;e.addAll(d.fromBinaryString(s));var c=new ArrayBuffer(4);new DataView(c).setUint32(0,l);var y=!0,v=!1,g=void 0;try{for(var p,b=f[Symbol.iterator]();!(y=(p=b.next()).done);y=!0){var w=p.value;e.setAll(w,c)}}catch(e){v=!0,g=e}finally{try{!y&&b.return&&b.return()}finally{if(v)throw g}}}}catch(e){n=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw a}}}}function s(e){if(e&&e.constructor===String){var t=+e;if(!isNaN(t))return t}}function f(e,t){v.instanceOf(e,w),v.instanceOf(t,String),(T.gt(t,q)||T.lt(t,"0"))&&v.fail("Value out of range");var r=T.div(t,T.LONG_UPPER_SHIFT),n=T.sub(t,T.mul(r,T.LONG_UPPER_SHIFT)),a=new ArrayBuffer(8),i=new DataView(a);i.setUint32(0,+r),i.setUint32(4,+n),e.addAll(a)}function l(e,t){v.instanceOf(t,Array);var r=m(t.length),n=B(t.length),a=void 0;a=r?n+1:n;for(var i=new ArrayBuffer(a),o=new Uint8Array(i),u=0;u-1;s--,u++)o.setUint8(u,r[s]);r.length&&o.setInt8(2,r[r.length-1]),e.addAll(i)}}],[{key:"_value",get:function(){return 6}}]),t}(x),C=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),t}(U),N=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,256,"Value out of range");var n=new ArrayBuffer(1);new Uint8Array(n)[0]=t,e.addAll(n)}}],[{key:"_value",get:function(){return 17}}]),t}(C),F=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,65536,"Value out of range");var n=new ArrayBuffer(2);new DataView(n).setUint16(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 18}}]),t}(C),H=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,4294967296,"Value out of range");var n=new ArrayBuffer(4);new DataView(n).setUint32(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 19}}]),t}(C),q="18446744073709551615",R=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){f(e,t)}}],[{key:"_value",get:function(){return 20}}]),t}(C),M=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(t,Date),f(e,t.getTime()+"")}}],[{key:"_value",get:function(){return 21}}]),t}(U),z=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String),T.isNegative(t)&&v.fail("Value out of range");var r=[];if(!T.eq(t,"0")){for(;T.ge(t,T.BYTE_SHIFT);){var n=T.quotientRemainderPositive(t,T.BYTE_SHIFT),a=h(n,2),i=a[0],o=a[1];r.push(+o),t=i}r.push(+t),v.twoByteUnsignedInteger(r.length)}var u=new ArrayBuffer(2+r.length),s=new DataView(u);s.setUint16(0,r.length);for(var f=2,l=r.length-1;l>-1;l--,f++)s.setUint8(f,r[l]);e.addAll(u)}}],[{key:"_value",get:function(){return 22}}]),t}(C),G=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),t}(U),Y=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.instanceOf(t,Number);var n=new ArrayBuffer(4);new DataView(n).setFloat32(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 32}}]),t}(G),J=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.instanceOf(t,Number);var n=new ArrayBuffer(8);new DataView(n).setFloat64(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 33}}]),t}(G),$=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,Boolean),t?e.add(255):e.add(0)}}],[{key:"_value",get:function(){return 48}}]),t}(U),W=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));return v.fourByteUnsignedInteger(e),r.length=e,r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 49}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&e.addAll(o(this.length))}},{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,Array),t.length!==this.length&&v.fail("Length does not match"),l(e,t)}}]),t}(U),X=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(t,Array),v.fourByteUnsignedInteger(t.length),e.addAll(o(t.length)),l(e,t)}}],[{key:"_value",get:function(){return 50}}]),t}(U),Q=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String),v.assert(1===t.length,"String must contain only 1 character"),e.addAll(d.fromString(t))}}],[{key:"_value",get:function(){return 64}}]),t}(U),K=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String);var r=d.fromString(t);e.addAll(r),e.add(0)}}],[{key:"_value",get:function(){return 65}}]),t}(U),Z=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,ArrayBuffer),v.fourByteUnsignedInteger(t.byteLength),e.addAll(o(t.byteLength)),e.addAll(t)}}],[{key:"_value",get:function(){return 66}}]),t}(U),ee=function(e){function t(e){var r=e.type,a=e.length;i(this,t);var o=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(r,j),v.fourByteUnsignedInteger(a),o.type=r,o.length=a,o}return a(t,e),y(t,null,[{key:"_value",get:function(){return 80}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&(this.type.addToBuffer(e),e.addAll(o(this.length)))}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Array),t.length!==this.length&&v.fail("Length does not match: expected "+(this.length+"")+" but got "+t.length);var n=!0,a=!1,i=void 0;try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var f=o.value;this.type.writeValue(e,f,!1)}}catch(e){a=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),te="name",re="type",ne="buffer",ae=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));v.instanceOf(e,Object);var a=0;for(var o in e)a++;try{v.byteUnsignedInteger(a)}catch(e){v.fail(a+" fields is too many")}r.fields=Array(a);var u=0;for(var s in e){var f=d.fromString(s);try{v.byteUnsignedInteger(f.byteLength)}catch(e){v.fail("Field name "+s+" is too long")}var l=e[s];try{v.instanceOf(l,j)}catch(e){v.fail(l+" is not a valid field type")}var c={};c[te]=s,c[re]=l,c[ne]=f,r.fields[u]=c,u++}return r.fields.sort(function(e,t){return e[te]t[te]?1:void 0}),r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 81}}]),y(t,[{key:"addToBuffer",value:function(e){if(c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)){e.add(this.fields.length);var r=!0,n=!1,a=void 0;try{for(var i,o=this.fields[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=i.value,s=u[ne];e.add(s.byteLength),e.addAll(s),u[re].addToBuffer(e)}}catch(e){n=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw a}}}}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Object);var n=!0,a=!1,i=void 0;try{for(var o,s=this.fields[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var f=o.value,l=t[f[te]];void 0===l&&v.fail("Value for field "+f[te]+" missing"),f[re].writeValue(e,l,!1)}}catch(e){a=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),ie=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(e,j),r.type=e,r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 82}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&this.type.addToBuffer(e)}},{key:"_writeValue",value:function(e,t,r){v.instanceOf(e,w),v.fourByteUnsignedInteger(t.length),e.addAll(o(t.length));var n=!0,a=!1,i=void 0;try{for(var s,f=t[Symbol.iterator]();!(n=(s=f.next()).done);n=!0){var l=s.value;this.type.writeValue(e,l,!1)}}catch(e){a=!0,i=e}finally{try{!n&&f.return&&f.return()}finally{if(a)throw i}}u(e,r)}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,Array),this._writeValue(e,t,r)}}]),t}(U),oe=function(e){function t(e){return i(this,t),n(this,Object.getPrototypeOf(t).call(this,e))}return a(t,e),y(t,null,[{key:"_value",get:function(){return 83}}]),y(t,[{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,Set),t.length=t.size,this._writeValue(e,t,r)}}]),t}(ie),ue=function(e){function t(e,r){i(this,t);var a=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(e,j),v.instanceOf(r,j),a.keyType=e,a.valueType=r,a}return a(t,e),y(t,null,[{key:"_value",get:function(){return 84}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&(this.keyType.addToBuffer(e),this.valueType.addToBuffer(e))}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Map),v.fourByteUnsignedInteger(t.size),e.addAll(o(t.size));var n=!0,a=!1,i=void 0;try{for(var s,f=t[Symbol.iterator]();!(n=(s=f.next()).done);n=!0){var l=h(s.value,2),c=l[0],y=l[1];this.keyType.writeValue(e,c,!1),this.valueType.writeValue(e,y,!1)}}catch(e){a=!0,i=e}finally{try{!n&&f.return&&f.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),se=function(e){function t(e){var r=e.type,a=e.values;i(this,t);var o=n(this,Object.getPrototypeOf(t).call(this));v.instanceOf(r,U),v.instanceOf(a,Array);try{v.byteUnsignedInteger(a.length)}catch(e){v.fail(a.length+" values is too many")}for(var u=new Map,s=0;s=200&&t.status<300||304===t.status;r?e[o]=t.response:e.text=t.statusText,n(t.status,t.statusText,e,t.getAllResponseHeaders())}),t.open(i,a,s),t.responseType=o;for(var f in r)r.hasOwnProperty(f)&&t.setRequestHeader(f,r[f]);t.send(u)},abort:function(){t&&t.abort()}}}})}(jQuery)},{}],"/client-side/common.js":[function(e,t,r){"use strict";var n=e("/lib/assert.js");if(n.instanceOf(window.Map,Function),n.instanceOf(window.Set,Function),n.instanceOf(window.ArrayBuffer,Function),n.instanceOf(window.Uint8Array,Function),n.instanceOf(window.Symbol,Function),e("/client-side/binary-ajax.js"),void 0===window.sb)window.sb=e("/structure-types.js");else if(!(window.sb instanceof Object))throw Error("window.sb is already defined")},{"/client-side/binary-ajax.js":"/client-side/binary-ajax.js","/lib/assert.js":"/lib/assert.js","/structure-types.js":"/structure-types.js"}],"/config.js":[function(e,t,r){(function(r){"use strict";"/"===r&&(r="");var n=e(r+"/lib/assert.js"),a=e("base64-js"),i=8;n.between(0,i,65536);var o=2,u=new ArrayBuffer(o);new DataView(u).setUint16(0,i);var s=a.fromByteArray(new Uint8Array(u));t.exports={VERSION_STRING:s}}).call(this,"/")},{"base64-js":2}],"/lib/assert.js":[function(e,t,r){"use strict";var n=e("/lib/util-inspect.js"),a={instanceOf:function(e,t){t instanceof Array||(t=[t]);var r=!1,a=!0,i=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(a=(u=s.next()).done);a=!0){var f=u.value;if(e instanceof f||void 0!==e&&null!==e&&e.constructor===f){r=!0;break}}}catch(e){i=!0,o=e}finally{try{!a&&s.return&&s.return()}finally{if(i)throw o}}if(!r)throw new TypeError(n.inspect(e)+" is not an instance of "+t.map(function(e){return e.name}).join(" or "))},integer:function(e){if(a.instanceOf(e,Number),!Number.isSafeInteger(e))throw new RangeError(n.inspect(e)+" is not an integer")},between:function(e,t,r,a){if(t=r){var i=n.inspect(t)+" is not in ["+n.inspect(e)+","+n.inspect(r)+")";throw void 0===a?new RangeError(i):new RangeError(a+" ("+i+")")}},byteUnsignedInteger:function(e){a.integer(e),a.between(0,e,256)},twoByteUnsignedInteger:function(e){a.integer(e),a.between(0,e,65536)},fourByteUnsignedInteger:function(e){a.integer(e),a.between(0,e,4294967296)},fail:function(e){throw Error(e)},assert:function(e,t){e||a.fail(t)},throws:function(e,t){var r=!0;try{e(),r=!1}catch(e){void 0!==t&&a.message(e,t)}a.assert(r,"Should throw an error")},equal:function(e,t){var r=new RangeError("Expected "+n.inspect(t)+" but got "+n.inspect(e));if(t&&t.constructor===Object){for(var i in t)if(t.hasOwnProperty(i))try{a.equal(e[i],t[i])}catch(e){throw r}}else if(t&&t.constructor===Array){if(!e||e.constructor!==Array)throw r;try{a.equal(e.length,t.length)}catch(e){throw r}for(var o=0;o>>3},modEight:function(e){return 7&e}}},{}],"/lib/buffer-string.js":[function(e,t,r){(function(r){"use strict";var n=e(r+"/assert.js"),a=e(r+"/growable-buffer.js"),i=4096;t.exports={toString:function(e){e&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),n.instanceOf(e,Uint8Array);for(var t=[],r=0;r239?4:a>223?3:a>191?2:1;if(r+u<=e.length){var s=void 0,f=void 0,l=void 0,c=void 0;switch(u){case 1:a<128&&(o=a);break;case 2:s=e[r+1],128===(192&s)&&(c=(31&a)<<6|63&s,c>127&&(o=c));break;case 3:s=e[r+1],f=e[r+2],128===(192&s)&&128===(192&f)&&(c=(15&a)<<12|(63&s)<<6|63&f,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:s=e[r+1],f=e[r+2],l=e[r+3],128===(192&s)&&128===(192&f)&&128===(192&l)&&(c=(15&a)<<18|(63&s)<<12|(63&f)<<6|63&l,c>65535&&c<1114112&&(o=c))}}void 0===o?(o=65533,u=1):o>65535&&(o-=65536,t.push(o>>>10&1023|55296),o=56320|1023&o),t.push(o),r+=u}for(var y="",h=0;h>6),t.add(128|63&l)):l<55296||l>=57344?(t.add(224|l>>12),t.add(128|l>>6&63),t.add(128|63&l)):(l=65536+((1023&l)<<10|1023&l),t.add(240|l>>18),t.add(128|l>>12&63),t.add(128|l>>6&63),t.add(128|63&l))}}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return t.toBuffer()},toBinaryString:function(e){n.instanceOf(e,ArrayBuffer);var t="",r=new Uint8Array(e),a=!0,i=!1,o=void 0;try{for(var u,s=r[Symbol.iterator]();!(a=(u=s.next()).done);a=!0){var f=u.value;t+=String.fromCharCode(f)}}catch(e){i=!0,o=e}finally{try{!a&&s.return&&s.return()}finally{if(i)throw o}}return t},fromBinaryString:function(e){n.instanceOf(e,String);for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),a=0;athis.buffer.byteLength){var t=new ArrayBuffer(e<<1);new Uint8Array(t).set(new Uint8Array(this.buffer).subarray(0,this.size)),this.buffer=t}return this}},{key:"set",value:function(e,t){i.integer(e),i.integer(t),i.between(0,e,this.size,"Index out of bounds: "+(e+"")),i.between(0,t,256,"Not a byte: "+(t+""));var r=new Uint8Array(this.buffer);return r[e]=t,this}},{key:"setAll",value:function(e,t){i.instanceOf(t,ArrayBuffer),i.integer(e),i.between(0,e,this.size-t.byteLength+1,"Index out of bounds: "+(e+"")),new Uint8Array(this.buffer).set(new Uint8Array(t),e)}},{key:"get",value:function(e){return i.integer(e),i.between(0,e,this.size,"Index out of bounds: "+(e+"")),new Uint8Array(this.buffer)[e]}},{key:"add",value:function(e){var t=this.size,r=t+1;this.grow(r),this.size=r;var n=new Uint8Array(this.buffer);return n[t]=e,this}},{key:"addAll",value:function(e){i.instanceOf(e,ArrayBuffer);var t=this.size,r=this.size+e.byteLength;return this.grow(r),this.size=r,new Uint8Array(this.buffer).set(new Uint8Array(e),t),this}},{key:"toBuffer",value:function(){return this.buffer.slice(0,this.size)}},{key:"length",get:function(){return this.size}},{key:"rawBuffer",get:function(){return this.buffer}}]),e}();t.exports=u}).call(this,"/lib")},{}],"/lib/strint.js":[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},a={};!function(){function e(e,t){return S(e)===S(t)}function t(e,t){for(;t>0;)e+="0",t--;return e}function r(e){f(e,"string")}function i(e){r(e),s(e,S,"isPositive")}function o(e){f(e,"number")}function u(e){if(f(e,"number"),e<0)throw Error("Expected a positive number: "+e)}function s(e,t,r){if(!t.call(null,e))throw Error("Condition "+r+" failed for value "+e)}function f(e,t){if((void 0===e?"undefined":n(e))!==t)throw Error("Not a "+t+": "+e)}var l=a.subPositive=function(e,t){if(i(e),i(t),!O(e,t))throw Error("x must be greater or equal to y");for(var r=Math.max(e.length,t.length),n="",a=0,o=0,u=0;u=10;)l-=10,a++;0===l?o++:(n=l+""+V(n,o),o=0)}return a>0&&(n=a+""+V(n,o)),n},y=a.add=function(e,t){if(r(e),r(t),S(e)&&S(t))return c(e,t);if(B(e)&&B(t))return k(c(m(e),m(t)));if(T(m(e),m(t))){var n=e;e=t,t=n}var a=l(m(e),m(t));return S(e)?a:k(a)},h=a.sub=function(e,t){return r(e),r(t),y(e,k(t))},v=a.timesDigit=function(e,t){i(e),o(t);for(var r="",n=I(e),a=0,u=0,s=0;s=10;)f-=10,a++;0===f?u++:(r=f+""+V(r,u),u=0)}return a>0&&(r=a+""+V(r,u)),0===r.length?"0":r},g=a.mulPositive=function(e,r){i(e),i(r);for(var n="0",a=I(r),o=0;o=I(e)?"0":e.charAt(e.length-t-1)},I=function(e){return B(e)?e.length-1:e.length}}(),a.LONG_UPPER_SHIFT="4294967296",a.BYTE_SHIFT="256",t.exports=a},{}],"/lib/util-inspect.js":[function(e,t,r){"use strict";r.inspect=function(e){if(void 0===e)return"undefined";if(null===e||e.constructor===Object||e.constructor===Array||e.constructor===String||e.constructor===Number||e.constructor===Boolean||e.constructor===Date)return JSON.stringify(e);if(e.constructor===Set){for(var t="Set {",n=e.values(),a=n.next();!a.done;)t+=r.inspect(a.value),a=n.next(),a.done||(t+=", ");return t+"}"}if(e.constructor===Map){for(var i="Map {",o=e.entries(),u=o.next();!u.done;)i+=r.inspect(u.value[0]),i+=" => ",i+=r.inspect(u.value[1]),u=o.next(),u.done||(i+=", ");return i+"}"}return e.constructor.name?e.constructor.name+" "+JSON.stringify(e):JSON.stringify(e)}},{}],"/read.js":[function(e,t,r){(function(r){"use strict";function n(e,t){try{return{value:new DataView(e).getUint32(t),length:4}}catch(e){l.fail(d)}}function a(e,t){return e.length=0,"Offset is negative: "+(t+"")),l.assert(e.byteLength>t,d);var r=void 0,o=1,u=new Uint8Array(e)[t],f=!0,c=!1,h=void 0;try{for(var g,b=p[Symbol.iterator]();!(f=(g=b.next()).done);f=!0){var w=g.value;if(u===w._value)return{value:new w,length:o}}}catch(e){c=!0,h=e}finally{try{!f&&b.return&&b.return()}finally{if(c)throw h}}switch(u){case v.BooleanTupleType._value:var T=n(e,t+o);r=new v.BooleanTupleType(T.value),o+=T.length;break;case v.TupleType._value:var O=i(e,t+o);o+=O.length;var A=n(e,t+o);o+=A.length,r=new v.TupleType({type:O.value,length:A.value});break;case v.StructType._value:l.assert(e.byteLength>t+o,d);var B=new Uint8Array(e),S=B[t+o];o++;for(var m={},k=0;kt+o,d);var j=B[t+o];o++,l.assert(e.byteLength>=t+o+j,d);var U=y.toString(B.subarray(t+o,t+o+j));o+=j;var x=i(e,t+o);m[U]=x.value,o+=x.length}r=new v.StructType(m);break;case v.ArrayType._value:var _=i(e,t+o);o+=_.length,r=new v.ArrayType(_.value);break;case v.SetType._value:var V=i(e,t+o);o+=V.length,r=new v.SetType(V.value);break;case v.MapType._value:var P=i(e,t+o);o+=P.length;var I=i(e,t+o);o+=I.length,r=new v.MapType(P.value,I.value);break;case v.EnumType._value:var E=i(e,t+o);o+=E.length,l.assert(e.byteLength>t+o,d);var L=new Uint8Array(e)[t+o];o++;for(var D=[],C=0;Ct+o,d);var H=new Uint8Array(e)[t+o];o++;for(var q=Array(H),R=0;R=t+Y,d);var J=new DataView(e).getUint16(t+o),$=i(e,t+o-J);r=$.value,o=Y;break;default:l.fail("No such type: 0x"+a(new Uint8Array(e)[t].toString(16),2))}return{value:r,length:o}}function o(e){var t=arguments.length<=1||void 0===arguments[1]||arguments[1];l.instanceOf(e,ArrayBuffer);var r=i(e,0),n=r.value,a=r.length;return t&&l.assert(a===e.byteLength,"Did not consume all of the buffer"),n}function u(e){var t=e.buffer,r=e.offset,n=e.count,a=Array(n),i=c.modEight(a.length),o=c.dividedByEight(a.length),u=void 0;u=i?o+1:o,l.assert(t.byteLength>=r+u,d);for(var s=new Uint8Array(t),f=0;f=a+f,d),o=new Int8Array(t)[a];break;case v.ShortType:f=2,l.assert(t.byteLength>=a+f,d);var c=new DataView(t);o=c.getInt16(a);break;case v.IntType:f=4;var p=new DataView(t);o=p.getInt32(a);break;case v.LongType:f=8,l.assert(t.byteLength>=a+f,d);var b=new DataView(t),w=b.getInt32(a),T=b.getUint32(a+4);o=h.add(h.mul(w+"",h.LONG_UPPER_SHIFT),T+"");break;case v.BigIntType:f=2,l.assert(t.byteLength>=a+f,d);var O=new DataView(t),A=O.getUint16(a);l.assert(t.byteLength>=a+f+A,d),o=A?O.getInt8(a+f)+"":"0";for(var B=1;B=a+f,d),o=new Uint8Array(t)[a];break;case v.UnsignedShortType:f=2,l.assert(t.byteLength>=a+f,d),o=new DataView(t).getUint16(a);break;case v.UnsignedIntType:f=4,l.assert(t.byteLength>=a+f,d),o=new DataView(t).getUint32(a);break;case v.UnsignedLongType:case v.DateType:f=8,l.assert(t.byteLength>=a+f,d);var S=new DataView(t),m=S.getUint32(a),k=S.getUint32(a+4);o=h.add(h.mul(m+"",h.LONG_UPPER_SHIFT),k+""),i.constructor===v.DateType&&(o=new Date(+o));break;case v.BigUnsignedIntType:f=2,l.assert(t.byteLength>=a+f,d);var j=new DataView(t),U=j.getUint16(a);l.assert(t.byteLength>=a+f+U,d),o="0";for(var x=0;x=a+f,d),o=new DataView(t).getFloat32(a);break;case v.DoubleType:f=8,l.assert(t.byteLength>=a+f,d),o=new DataView(t).getFloat64(a);break;case v.BooleanType:f=1,l.assert(t.byteLength>=a+f,d);var _=new Uint8Array(t)[a];l.assert(0===_||255===_,"0x"+_.toString(16)+" is an invalid Boolean value"),o=!!_;break;case v.BooleanArrayType:var V=n(t,a);f=V.length;var P=u({buffer:t,offset:a+f,count:V.value});f+=P.length,o=P.value;break;case v.BooleanTupleType:var I=u({buffer:t,offset:a,count:i.length});o=I.value,f=I.length;break;case v.CharType:l.assert(t.byteLength>a,d),o=y.toString(new Uint8Array(t).subarray(a,a+4))[0],f=y.fromString(o).byteLength;break;case v.StringType:var E=new Uint8Array(t);for(f=0;l.assert(t.byteLength>a+f,d),E[a+f];f++);o=y.toString(new Uint8Array(t).subarray(a,a+f)),f++;break;case v.OctetsType:var L=n(t,a);f=L.length;var D=f+L.value;l.assert(t.byteLength>=a+D,d),o=t.slice(a+f,a+D),f=D;break;case v.TupleType:f=0,o=Array(i.length);for(var C=0;C=a+f,d);var ae=new Uint8Array(t)[a];o=i.values[ae],void 0===o&&l.fail("Index "+(ae+"")+" is invalid");break;case v.ChoiceType:f=1,l.assert(t.byteLength>=a+f,d);var ie=new Uint8Array(t)[a],oe=s({buffer:t,pointerStart:r,offset:a+f,type:i.types[ie]});f+=oe.length,o=oe.value;break;case v.OptionalType:f=1,l.assert(t.byteLength>=a+f,d);var ue=new Uint8Array(t)[a];if(l.assert(0===ue||255===ue,"0x"+ue.toString(16)+" is an invalid Optional byte"),ue){var se=s({buffer:t,pointerStart:r,offset:a+f,type:i.type});f+=se.length,o=se.value}else o=null;break;case v.PointerType:var fe=n(t,a);f=fe.length,o=s({buffer:t,pointerStart:r,offset:r+fe.value,type:i.type}).value;break;default:l.fail("Not a structure type: "+g.inspect(i))}return{value:o,length:f}}function f(e){var t=e.buffer,r=e.type,n=e.offset;l.instanceOf(t,ArrayBuffer),l.instanceOf(r,v.Type),void 0===n&&(n=0),l.instanceOf(n,Number);var a=s({buffer:t,offset:n,type:r,pointerStart:n}),i=a.value;return i}"/"===r&&(r="");var l=e(r+"/lib/assert.js"),c=e(r+"/lib/bit-math.js"),y=e(r+"/lib/buffer-string.js"),h=e(r+"/lib/strint.js"),v=e(r+"/structure-types.js"),g=e("/lib/util-inspect.js"),d="Buffer is not long enough",p=[v.ByteType,v.ShortType,v.IntType,v.LongType,v.BigIntType,v.UnsignedByteType,v.UnsignedShortType,v.UnsignedIntType,v.UnsignedLongType,v.DateType,v.BigUnsignedIntType,v.FloatType,v.DoubleType,v.BooleanType,v.BooleanArrayType,v.CharType,v.StringType,v.OctetsType];t.exports={_consumeType:i,type:o,value:f}}).call(this,"/")},{"/lib/util-inspect.js":"/lib/util-inspect.js"}],"/structure-types.js":[function(e,t,r){(function(r){"use strict";function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){var t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e),t}function u(e,t){if(t&&e.pointers){var r=!0,n=!1,a=void 0;try{for(var i,o=e.pointers[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=h(i.value,2),s=u[0],f=u[1],l=e.length;e.addAll(d.fromBinaryString(s));var c=new ArrayBuffer(4);new DataView(c).setUint32(0,l);var y=!0,v=!1,g=void 0;try{for(var p,b=f[Symbol.iterator]();!(y=(p=b.next()).done);y=!0){var w=p.value;e.setAll(w,c)}}catch(e){v=!0,g=e}finally{try{!y&&b.return&&b.return()}finally{if(v)throw g}}}}catch(e){n=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw a}}}}function s(e){if(e&&e.constructor===String){var t=+e;if(!isNaN(t))return t}}function f(e,t){v.instanceOf(e,w),v.instanceOf(t,String),(T.gt(t,q)||T.lt(t,"0"))&&v.fail("Value out of range");var r=T.div(t,T.LONG_UPPER_SHIFT),n=T.sub(t,T.mul(r,T.LONG_UPPER_SHIFT)),a=new ArrayBuffer(8),i=new DataView(a);i.setUint32(0,+r),i.setUint32(4,+n),e.addAll(a)}function l(e,t){v.instanceOf(t,Array);var r=S(t.length),n=B(t.length),a=void 0;a=r?n+1:n;for(var i=new ArrayBuffer(a),o=new Uint8Array(i),u=0;u-1;s--,u++)o.setUint8(u,r[s]);r.length&&o.setInt8(2,r[r.length-1]),e.addAll(i)}}],[{key:"_value",get:function(){return 6}}]),t}(x),C=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),t}(U),N=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,256,"Value out of range");var n=new ArrayBuffer(1);new Uint8Array(n)[0]=t,e.addAll(n)}}],[{key:"_value",get:function(){return 17}}]),t}(C),F=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,65536,"Value out of range");var n=new ArrayBuffer(2);new DataView(n).setUint16(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 18}}]),t}(C),H=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.integer(t),v.between(0,t,4294967296,"Value out of range");var n=new ArrayBuffer(4);new DataView(n).setUint32(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 19}}]),t}(C),q="18446744073709551615",R=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){f(e,t)}}],[{key:"_value",get:function(){return 20}}]),t}(C),M=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(t,Date),f(e,t.getTime()+"")}}],[{key:"_value",get:function(){return 21}}]),t}(U),z=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String),T.isNegative(t)&&v.fail("Value out of range");var r=[];if(!T.eq(t,"0")){for(;T.ge(t,T.BYTE_SHIFT);){var n=T.quotientRemainderPositive(t,T.BYTE_SHIFT),a=h(n,2),i=a[0],o=a[1];r.push(+o),t=i}r.push(+t),v.twoByteUnsignedInteger(r.length)}var u=new ArrayBuffer(2+r.length),s=new DataView(u);s.setUint16(0,r.length);for(var f=2,l=r.length-1;l>-1;l--,f++)s.setUint8(f,r[l]);e.addAll(u)}}],[{key:"_value",get:function(){return 22}}]),t}(C),G=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),t}(U),Y=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.instanceOf(t,Number);var n=new ArrayBuffer(4);new DataView(n).setFloat32(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 32}}]),t}(G),J=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w);var r=s(t);void 0!==r&&(t=r),v.instanceOf(t,Number);var n=new ArrayBuffer(8);new DataView(n).setFloat64(0,t),e.addAll(n)}}],[{key:"_value",get:function(){return 33}}]),t}(G),$=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,Boolean),t?e.add(255):e.add(0)}}],[{key:"_value",get:function(){return 48}}]),t}(U),W=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));return v.fourByteUnsignedInteger(e),r.length=e,r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 49}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&e.addAll(o(this.length))}},{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,Array),t.length!==this.length&&v.fail("Length does not match"),l(e,t); +}}]),t}(U),X=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(t,Array),v.fourByteUnsignedInteger(t.length),e.addAll(o(t.length)),l(e,t)}}],[{key:"_value",get:function(){return 50}}]),t}(U),Q=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String),v.assert(1===t.length,"String must contain only 1 character"),e.addAll(d.fromString(t))}}],[{key:"_value",get:function(){return 64}}]),t}(U),K=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,String);var r=d.fromString(t);e.addAll(r),e.add(0)}}],[{key:"_value",get:function(){return 65}}]),t}(U),Z=function(e){function t(){return i(this,t),n(this,Object.getPrototypeOf(t).apply(this,arguments))}return a(t,e),y(t,[{key:"writeValue",value:function(e,t){v.instanceOf(e,w),v.instanceOf(t,ArrayBuffer),v.fourByteUnsignedInteger(t.byteLength),e.addAll(o(t.byteLength)),e.addAll(t)}}],[{key:"_value",get:function(){return 66}}]),t}(U),ee=function(e){function t(e){var r=e.type,a=e.length;i(this,t);var o=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(r,j),v.fourByteUnsignedInteger(a),o.type=r,o.length=a,o}return a(t,e),y(t,null,[{key:"_value",get:function(){return 80}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&(this.type.addToBuffer(e),e.addAll(o(this.length)))}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Array),t.length!==this.length&&v.fail("Length does not match: expected "+(this.length+"")+" but got "+t.length);var n=!0,a=!1,i=void 0;try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var f=o.value;this.type.writeValue(e,f,!1)}}catch(e){a=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),te="name",re="type",ne="buffer",ae=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));v.instanceOf(e,Object);var a=0;for(var o in e)a++;try{v.byteUnsignedInteger(a)}catch(e){v.fail(a+" fields is too many")}r.fields=Array(a);var u=0;for(var s in e){var f=d.fromString(s);try{v.byteUnsignedInteger(f.byteLength)}catch(e){v.fail("Field name "+s+" is too long")}var l=e[s];try{v.instanceOf(l,j)}catch(e){v.fail(l+" is not a valid field type")}var c={};c[te]=s,c[re]=l,c[ne]=f,r.fields[u]=c,u++}return r.fields.sort(function(e,t){return e[te]t[te]?1:void 0}),r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 81}}]),y(t,[{key:"addToBuffer",value:function(e){if(c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)){e.add(this.fields.length);var r=!0,n=!1,a=void 0;try{for(var i,o=this.fields[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=i.value,s=u[ne];e.add(s.byteLength),e.addAll(s),u[re].addToBuffer(e)}}catch(e){n=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw a}}}}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Object);var n=!0,a=!1,i=void 0;try{for(var o,s=this.fields[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var f=o.value,l=t[f[te]];void 0===l&&v.fail("Value for field "+f[te]+" missing"),f[re].writeValue(e,l,!1)}}catch(e){a=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),ie=function(e){function t(e){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(e,j),r.type=e,r}return a(t,e),y(t,null,[{key:"_value",get:function(){return 82}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&this.type.addToBuffer(e)}},{key:"_writeValue",value:function(e,t,r){v.instanceOf(e,w),v.fourByteUnsignedInteger(t.length),e.addAll(o(t.length));var n=!0,a=!1,i=void 0;try{for(var s,f=t[Symbol.iterator]();!(n=(s=f.next()).done);n=!0){var l=s.value;this.type.writeValue(e,l,!1)}}catch(e){a=!0,i=e}finally{try{!n&&f.return&&f.return()}finally{if(a)throw i}}u(e,r)}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,Array),this._writeValue(e,t,r)}}]),t}(U),oe=function(e){function t(e){return i(this,t),n(this,Object.getPrototypeOf(t).call(this,e))}return a(t,e),y(t,null,[{key:"_value",get:function(){return 83}}]),y(t,[{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,Set),t.length=t.size,this._writeValue(e,t,r)}}]),t}(ie),ue=function(e){function t(e,r){i(this,t);var a=n(this,Object.getPrototypeOf(t).call(this));return v.instanceOf(e,j),v.instanceOf(r,j),a.keyType=e,a.valueType=r,a}return a(t,e),y(t,null,[{key:"_value",get:function(){return 84}}]),y(t,[{key:"addToBuffer",value:function(e){c(Object.getPrototypeOf(t.prototype),"addToBuffer",this).call(this,e)&&(this.keyType.addToBuffer(e),this.valueType.addToBuffer(e))}},{key:"writeValue",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,w),v.instanceOf(t,Map),v.fourByteUnsignedInteger(t.size),e.addAll(o(t.size));var n=!0,a=!1,i=void 0;try{for(var s,f=t[Symbol.iterator]();!(n=(s=f.next()).done);n=!0){var l=h(s.value,2),c=l[0],y=l[1];this.keyType.writeValue(e,c,!1),this.valueType.writeValue(e,y,!1)}}catch(e){a=!0,i=e}finally{try{!n&&f.return&&f.return()}finally{if(a)throw i}}u(e,r)}}]),t}(U),se=function(e){function t(e){var r=e.type,a=e.values;i(this,t);var o=n(this,Object.getPrototypeOf(t).call(this));v.instanceOf(r,U),v.instanceOf(a,Array);try{v.byteUnsignedInteger(a.length)}catch(e){v.fail(a.length+" values is too many")}for(var u=new Map,s=0;s0)throw Error("Invalid string. Length must be a multiple of 4");i="="===e[u-2]?2:"="===e[u-1]?1:0,o=new l(3*u/4-i),n=i>0?u-4:u;var s=0;for(t=0,r=0;t>16&255,o[s++]=a>>8&255,o[s++]=255&a;return 2===i?(a=f[e.charCodeAt(t)]<<2|f[e.charCodeAt(t+1)]>>4,o[s++]=255&a):1===i&&(a=f[e.charCodeAt(t)]<<10|f[e.charCodeAt(t+1)]<<4|f[e.charCodeAt(t+2)]>>2,o[s++]=a>>8&255,o[s++]=255&a),o}function i(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function o(e,t,r){for(var n,a=[],o=t;ol?l:f+u));return 1===n?(t=e[r-1],a+=s[t>>2],a+=s[t<<4&63],a+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],a+=s[t>>10],a+=s[t>>4&63],a+=s[t<<2&63],a+="="),i.push(a),i.join("")}r.toByteArray=a,r.fromByteArray=u;var s=[],f=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],3:[function(e,t,r){!function(e){"use strict";function r(e){return e.map(function(e){return n(e.toString(16),2)}).join("")}function n(e,t){return e.length>t?e:Array(t-e.length+1).join("0")+e}var a={bytesToHex:function(e){return r(e)},hexToBytes:function(e){if(e.length%2===1)throw Error("hexToBytes can't have a string with an odd number of characters.");return 0===e.indexOf("0x")&&(e=e.slice(2)),e.match(/../g).map(function(e){return parseInt(e,16)})}};void 0!==t&&t.exports?t.exports=a:e.convertHex=a}(this)},{}],4:[function(e,t,r){!function(e){"use strict";var r={bytesToString:function(e){return e.map(function(e){return String.fromCharCode(e)}).join("")},stringToBytes:function(e){return e.split("").map(function(e){return e.charCodeAt(0)})}};r.UTF8={bytesToString:function(e){return decodeURIComponent(escape(r.bytesToString(e)))},stringToBytes:function(e){return r.stringToBytes(unescape(encodeURIComponent(e)))}},void 0!==t&&t.exports?t.exports=r:e.convertString=r}(this)},{}],5:[function(e,t,r){!function(r){"use strict";function n(e,t){e.constructor===String&&(e=a.convertString.UTF8.stringToBytes(e));var r=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],n=o(e),i=8*e.length;n[i>>5]|=128<<24-i%32,n[(i+64>>9<<4)+15]=i;for(var s=0;s>>5]|=e[r]<<24-n%32;return t},u=function(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t},s=[],f=function(e,t,r){for(var n=e[0],a=e[1],o=e[2],u=e[3],f=e[4],l=e[5],c=e[6],y=e[7],h=0;h<64;h++){if(h<16)s[h]=0|t[r+h];else{var v=s[h-15],g=(v<<25|v>>>7)^(v<<14|v>>>18)^v>>>3,d=s[h-2],p=(d<<15|d>>>17)^(d<<13|d>>>19)^d>>>10;s[h]=g+s[h-7]+p+s[h-16]}var b=f&l^~f&c,w=n&a^n&o^a&o,T=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),O=(f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25),A=y+O+b+i[h]+s[h],B=T+w;y=c,c=l,l=f,f=u+A|0,u=o,o=a,a=n,n=A+B|0}e[0]=e[0]+n|0,e[1]=e[1]+a|0,e[2]=e[2]+o|0,e[3]=e[3]+u|0,e[4]=e[4]+f|0,e[5]=e[5]+l|0,e[6]=e[6]+c|0,e[7]=e[7]+y|0};n.x2=function(e,t){return n(n(e,{asBytes:!0}),t)}}(this)},{"convert-hex":3,"convert-string":4}]},{},[1]); \ No newline at end of file diff --git a/compiled/upload.js b/compiled/upload.js index a697808..d32f860 100644 --- a/compiled/upload.js +++ b/compiled/upload.js @@ -1,2 +1,2 @@ -require=function t(e,n,r){function i(o,u){if(!n[o]){if(!e[o]){var f="function"==typeof require&&require;if(!u&&f)return f(o,!0);if(a)return a(o,!0);var s=Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var c=n[o]={exports:{}};e[o][0].call(c.exports,function(t){var n=e[o][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o=200&&e.status<300||304===e.status;n?t[o]=e.response:t.text=e.statusText,r(e.status,e.statusText,t,e.getAllResponseHeaders())}),e.open(a,i,f),e.responseType=o;for(var s in n)n.hasOwnProperty(s)&&e.setRequestHeader(s,n[s]);e.send(u)},abort:function(){e&&e.abort()}}}})}(jQuery)},{}],"/client-side/common.js":[function(t,e,n){"use strict";var r=t("/lib/assert.js");if(r.instanceOf(window.Map,Function),r.instanceOf(window.Set,Function),r.instanceOf(window.ArrayBuffer,Function),r.instanceOf(window.Uint8Array,Function),r.instanceOf(window.Symbol,Function),t("/client-side/binary-ajax.js"),void 0===window.sb)window.sb=t("/structure-types.js");else if(!(window.sb instanceof Object))throw Error("window.sb is already defined")},{"/client-side/binary-ajax.js":"/client-side/binary-ajax.js","/lib/assert.js":"/lib/assert.js","/structure-types.js":"/structure-types.js"}],"/config.js":[function(t,e,n){(function(n){"use strict";"/"===n&&(n="");var r=t(n+"/lib/assert.js"),i=t("base64-js"),a=8;r.between(0,a,65536);var o=2,u=new ArrayBuffer(o);new DataView(u).setUint16(0,a);var f=i.fromByteArray(new Uint8Array(u));e.exports={VERSION_STRING:f}}).call(this,"/")},{"base64-js":2}],"/lib/assert.js":[function(t,e,n){"use strict";var r=t("/lib/util-inspect.js"),i={instanceOf:function(t,e){e instanceof Array||(e=[e]);var n=!1,i=!0,a=!1,o=void 0;try{for(var u,f=e[Symbol.iterator]();!(i=(u=f.next()).done);i=!0){var s=u.value;if(t instanceof s||void 0!==t&&null!==t&&t.constructor===s){n=!0;break}}}catch(t){a=!0,o=t}finally{try{!i&&f.return&&f.return()}finally{if(a)throw o}}if(!n)throw new TypeError(r.inspect(t)+" is not an instance of "+e.map(function(t){return t.name}).join(" or "))},integer:function(t){if(i.instanceOf(t,Number),!Number.isSafeInteger(t))throw new RangeError(r.inspect(t)+" is not an integer")},between:function(t,e,n,i){if(e=n){var a=r.inspect(e)+" is not in ["+r.inspect(t)+","+r.inspect(n)+")";throw void 0===i?new RangeError(a):new RangeError(i+" ("+a+")")}},byteUnsignedInteger:function(t){i.integer(t),i.between(0,t,256)},twoByteUnsignedInteger:function(t){i.integer(t),i.between(0,t,65536)},fourByteUnsignedInteger:function(t){i.integer(t),i.between(0,t,4294967296)},fail:function(t){throw Error(t)},assert:function(t,e){t||i.fail(e)},throws:function(t,e){var n=!0;try{t(),n=!1}catch(t){void 0!==e&&i.message(t,e)}i.assert(n,"Should throw an error")},equal:function(t,e){var n=new RangeError("Expected "+r.inspect(e)+" but got "+r.inspect(t));if(e&&e.constructor===Object){for(var a in e)if(e.hasOwnProperty(a))try{i.equal(t[a],e[a])}catch(t){throw n}}else if(e&&e.constructor===Array){if(!t||t.constructor!==Array)throw n;try{i.equal(t.length,e.length)}catch(t){throw n}for(var o=0;o>>3},modEight:function(t){return 7&t}}},{}],"/lib/buffer-string.js":[function(t,e,n){(function(n){"use strict";var r=t(n+"/assert.js"),i=t(n+"/growable-buffer.js"),a=4096;e.exports={toString:function(t){t&&t.constructor===ArrayBuffer&&(t=new Uint8Array(t)),r.instanceOf(t,Uint8Array);for(var e=[],n=0;n239?4:i>223?3:i>191?2:1;if(n+u<=t.length){var f=void 0,s=void 0,c=void 0,l=void 0;switch(u){case 1:i<128&&(o=i);break;case 2:f=t[n+1],128===(192&f)&&(l=(31&i)<<6|63&f,l>127&&(o=l));break;case 3:f=t[n+1],s=t[n+2],128===(192&f)&&128===(192&s)&&(l=(15&i)<<12|(63&f)<<6|63&s,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:f=t[n+1],s=t[n+2],c=t[n+3],128===(192&f)&&128===(192&s)&&128===(192&c)&&(l=(15&i)<<18|(63&f)<<12|(63&s)<<6|63&c,l>65535&&l<1114112&&(o=l))}}void 0===o?(o=65533,u=1):o>65535&&(o-=65536,e.push(o>>>10&1023|55296),o=56320|1023&o),e.push(o),n+=u}for(var y="",h=0;h>6),e.add(128|63&c)):c<55296||c>=57344?(e.add(224|c>>12),e.add(128|c>>6&63),e.add(128|63&c)):(c=65536+((1023&c)<<10|1023&c),e.add(240|c>>18),e.add(128|c>>12&63),e.add(128|c>>6&63),e.add(128|63&c))}}catch(t){a=!0,o=t}finally{try{!n&&f.return&&f.return()}finally{if(a)throw o}}return e.toBuffer()},toBinaryString:function(t){r.instanceOf(t,ArrayBuffer);var e="",n=new Uint8Array(t),i=!0,a=!1,o=void 0;try{for(var u,f=n[Symbol.iterator]();!(i=(u=f.next()).done);i=!0){var s=u.value;e+=String.fromCharCode(s)}}catch(t){a=!0,o=t}finally{try{!i&&f.return&&f.return()}finally{if(a)throw o}}return e},fromBinaryString:function(t){r.instanceOf(t,String);for(var e=new ArrayBuffer(t.length),n=new Uint8Array(e),i=0;ithis.buffer.byteLength){var e=new ArrayBuffer(t<<1);new Uint8Array(e).set(new Uint8Array(this.buffer).subarray(0,this.size)),this.buffer=e}return this}},{key:"set",value:function(t,e){a.integer(t),a.integer(e),a.between(0,t,this.size,"Index out of bounds: "+(t+"")),a.between(0,e,256,"Not a byte: "+(e+""));var n=new Uint8Array(this.buffer);return n[t]=e,this}},{key:"setAll",value:function(t,e){a.instanceOf(e,ArrayBuffer),a.integer(t),a.between(0,t,this.size-e.byteLength+1,"Index out of bounds: "+(t+"")),new Uint8Array(this.buffer).set(new Uint8Array(e),t)}},{key:"get",value:function(t){return a.integer(t),a.between(0,t,this.size,"Index out of bounds: "+(t+"")),new Uint8Array(this.buffer)[t]}},{key:"add",value:function(t){var e=this.size,n=e+1;this.grow(n),this.size=n;var r=new Uint8Array(this.buffer);return r[e]=t,this}},{key:"addAll",value:function(t){a.instanceOf(t,ArrayBuffer);var e=this.size,n=this.size+t.byteLength;return this.grow(n),this.size=n,new Uint8Array(this.buffer).set(new Uint8Array(t),e),this}},{key:"toBuffer",value:function(){return this.buffer.slice(0,this.size)}},{key:"length",get:function(){return this.size}},{key:"rawBuffer",get:function(){return this.buffer}}]),t}();e.exports=u}).call(this,"/lib")},{}],"/lib/strint.js":[function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},i={};!function(){function t(t,e){return m(t)===m(e)}function e(t,e){for(;e>0;)t+="0",e--;return t}function n(t){s(t,"string")}function a(t){n(t),f(t,m,"isPositive")}function o(t){s(t,"number")}function u(t){if(s(t,"number"),t<0)throw Error("Expected a positive number: "+t)}function f(t,e,n){if(!e.call(null,t))throw Error("Condition "+n+" failed for value "+t)}function s(t,e){if((void 0===t?"undefined":r(t))!==e)throw Error("Not a "+e+": "+t)}var c=i.subPositive=function(t,e){if(a(t),a(e),!T(t,e))throw Error("x must be greater or equal to y");for(var n=Math.max(t.length,e.length),r="",i=0,o=0,u=0;u=10;)c-=10,i++;0===c?o++:(r=c+""+U(r,o),o=0)}return i>0&&(r=i+""+U(r,o)),r},y=i.add=function(t,e){if(n(t),n(e),m(t)&&m(e))return l(t,e);if(A(t)&&A(e))return S(l(j(t),j(e)));if(O(j(t),j(e))){var r=t;t=e,e=r}var i=c(j(t),j(e));return m(t)?i:S(i)},h=i.sub=function(t,e){return n(t),n(e),y(t,S(e))},v=i.timesDigit=function(t,e){a(t),o(e);for(var n="",r=E(t),i=0,u=0,f=0;f=10;)s-=10,i++;0===s?u++:(n=s+""+U(n,u),u=0)}return i>0&&(n=i+""+U(n,u)),0===n.length?"0":n},d=i.mulPositive=function(t,n){a(t),a(n);for(var r="0",i=E(n),o=0;o=E(t)?"0":t.charAt(t.length-e-1)},E=function(t){return A(t)?t.length-1:t.length}}(),i.LONG_UPPER_SHIFT="4294967296",i.BYTE_SHIFT="256",e.exports=i},{}],"/lib/util-inspect.js":[function(t,e,n){"use strict";n.inspect=function(t){if(void 0===t)return"undefined";if(null===t||t.constructor===Object||t.constructor===Array||t.constructor===String||t.constructor===Number||t.constructor===Boolean||t.constructor===Date)return JSON.stringify(t);if(t.constructor===Set){for(var e="Set {",r=t.values(),i=r.next();!i.done;)e+=n.inspect(i.value),i=r.next(),i.done||(e+=", ");return e+"}"}if(t.constructor===Map){for(var a="Map {",o=t.entries(),u=o.next();!u.done;)a+=n.inspect(u.value[0]),a+=" => ",a+=n.inspect(u.value[1]),u=o.next(),u.done||(a+=", ");return a+"}"}return t.constructor.name?t.constructor.name+" "+JSON.stringify(t):JSON.stringify(t)}},{}],1:[function(t,e,n){"use strict";!function(){t("/client-side/common.js");var e=t("/lib/assert.js");window.sb.upload=function(t,n){var r=t.type,i=t.value;if(e.instanceOf(r,window.sb.Type),e.instanceOf(n,Object),"POST"!==n.type&&"POST"!==n.method)throw Error("Must use POST when uploading");n.processData=!1,n.data=r.valueBuffer(i),$.ajax(n)}}()},{"/client-side/common.js":"/client-side/common.js","/lib/assert.js":"/lib/assert.js"}],2:[function(t,e,n){"use strict";function r(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,n=t.length;e0)throw Error("Invalid string. Length must be a multiple of 4");a="="===t[u-2]?2:"="===t[u-1]?1:0,o=new c(3*u/4-a),r=a>0?u-4:u;var f=0;for(e=0,n=0;e>16&255,o[f++]=i>>8&255,o[f++]=255&i;return 2===a?(i=s[t.charCodeAt(e)]<<2|s[t.charCodeAt(e+1)]>>4,o[f++]=255&i):1===a&&(i=s[t.charCodeAt(e)]<<10|s[t.charCodeAt(e+1)]<<4|s[t.charCodeAt(e+2)]>>2,o[f++]=i>>8&255,o[f++]=255&i),o}function a(t){return f[t>>18&63]+f[t>>12&63]+f[t>>6&63]+f[63&t]}function o(t,e,n){for(var r,i=[],o=e;oc?c:s+u));return 1===r?(e=t[n-1],i+=f[e>>2],i+=f[e<<4&63],i+="=="):2===r&&(e=(t[n-2]<<8)+t[n-1],i+=f[e>>10],i+=f[e>>4&63],i+=f[e<<2&63],i+="="),a.push(i),a.join("")}n.toByteArray=i,n.fromByteArray=u;var f=[],s=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array;r()},{}],3:[function(t,e,n){!function(t){"use strict";function n(t){return t.map(function(t){return r(t.toString(16),2)}).join("")}function r(t,e){return t.length>e?t:Array(e-t.length+1).join("0")+t}var i={bytesToHex:function(t){return n(t)},hexToBytes:function(t){if(t.length%2===1)throw Error("hexToBytes can't have a string with an odd number of characters.");return 0===t.indexOf("0x")&&(t=t.slice(2)),t.match(/../g).map(function(t){return parseInt(t,16)})}};void 0!==e&&e.exports?e.exports=i:t.convertHex=i}(this)},{}],4:[function(t,e,n){!function(t){"use strict";var n={bytesToString:function(t){return t.map(function(t){return String.fromCharCode(t)}).join("")},stringToBytes:function(t){return t.split("").map(function(t){return t.charCodeAt(0)})}};n.UTF8={bytesToString:function(t){return decodeURIComponent(escape(n.bytesToString(t)))},stringToBytes:function(t){return n.stringToBytes(unescape(encodeURIComponent(t)))}},void 0!==e&&e.exports?e.exports=n:t.convertString=n}(this)},{}],5:[function(t,e,n){!function(n){"use strict";function r(t,e){t.constructor===String&&(t=i.convertString.UTF8.stringToBytes(t));var n=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],r=o(t),a=8*t.length;r[a>>5]|=128<<24-a%32,r[(a+64>>9<<4)+15]=a;for(var f=0;f>>5]|=t[n]<<24-r%32;return e},u=function(t){for(var e=[],n=0;n<32*t.length;n+=8)e.push(t[n>>>5]>>>24-n%32&255);return e},f=[],s=function(t,e,n){for(var r=t[0],i=t[1],o=t[2],u=t[3],s=t[4],c=t[5],l=t[6],y=t[7],h=0;h<64;h++){if(h<16)f[h]=0|e[n+h];else{var v=f[h-15],d=(v<<25|v>>>7)^(v<<14|v>>>18)^v>>>3,g=f[h-2],p=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;f[h]=d+f[h-7]+p+f[h-16]}var w=s&c^~s&l,b=r&i^r&o^i&o,O=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),T=(s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25),B=y+T+w+a[h]+f[h],A=O+b;y=l,l=c,c=s,s=u+B|0,u=o,o=i,i=r,r=B+A|0}t[0]=t[0]+r|0,t[1]=t[1]+i|0,t[2]=t[2]+o|0,t[3]=t[3]+u|0,t[4]=t[4]+s|0,t[5]=t[5]+c|0,t[6]=t[6]+l|0,t[7]=t[7]+y|0};r.x2=function(t,e){return r(r(t,{asBytes:!0}),e)}}(this)},{"convert-hex":3,"convert-string":4}],"/structure-types.js":[function(t,e,n){(function(n){"use strict";function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t){var e=new ArrayBuffer(4);return new DataView(e).setUint32(0,t),e}function u(t,e){if(e&&t.pointers){var n=!0,r=!1,i=void 0;try{for(var a,o=t.pointers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var u=h(a.value,2),f=u[0],s=u[1],c=t.length;t.addAll(g.fromBinaryString(f));var l=new ArrayBuffer(4);new DataView(l).setUint32(0,c);var y=!0,v=!1,d=void 0;try{for(var p,w=s[Symbol.iterator]();!(y=(p=w.next()).done);y=!0){var b=p.value;t.setAll(b,l)}}catch(t){v=!0,d=t}finally{try{!y&&w.return&&w.return()}finally{if(v)throw d}}}}catch(t){r=!0,i=t}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}}function f(t){if(t&&t.constructor===String){var e=+t;if(!isNaN(e))return e}}function s(t,e){v.instanceOf(t,b),v.instanceOf(e,String),(O.gt(e,L)||O.lt(e,"0"))&&v.fail("Value out of range");var n=O.div(e,O.LONG_UPPER_SHIFT),r=O.sub(e,O.mul(n,O.LONG_UPPER_SHIFT)),i=new ArrayBuffer(8),a=new DataView(i);a.setUint32(0,+n),a.setUint32(4,+r),t.addAll(i)}function c(t,e){v.instanceOf(e,Array);var n=m(e.length),r=A(e.length),i=void 0;i=n?r+1:r;for(var a=new ArrayBuffer(i),o=new Uint8Array(a),u=0;u-1;f--,u++)o.setUint8(u,n[f]);n.length&&o.setInt8(2,n[n.length-1]),t.addAll(a)}}],[{key:"_value",get:function(){return 6}}]),e}(P),C=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),e}(x),H=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b);var n=f(e);void 0!==n&&(e=n),v.integer(e),v.between(0,e,256,"Value out of range");var r=new ArrayBuffer(1);new Uint8Array(r)[0]=e,t.addAll(r)}}],[{key:"_value",get:function(){return 17}}]),e}(C),D=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b);var n=f(e);void 0!==n&&(e=n),v.integer(e),v.between(0,e,65536,"Value out of range");var r=new ArrayBuffer(2);new DataView(r).setUint16(0,e),t.addAll(r)}}],[{key:"_value",get:function(){return 18}}]),e}(C),F=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b);var n=f(e);void 0!==n&&(e=n),v.integer(e),v.between(0,e,4294967296,"Value out of range");var r=new ArrayBuffer(4);new DataView(r).setUint32(0,e),t.addAll(r)}}],[{key:"_value",get:function(){return 19}}]),e}(C),L="18446744073709551615",R=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){s(t,e)}}],[{key:"_value",get:function(){return 20}}]),e}(C),z=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(e,Date),s(t,e.getTime()+"")}}],[{key:"_value",get:function(){return 21}}]),e}(x),M=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,String),O.isNegative(e)&&v.fail("Value out of range");var n=[];if(!O.eq(e,"0")){for(;O.ge(e,O.BYTE_SHIFT);){var r=O.quotientRemainderPositive(e,O.BYTE_SHIFT),i=h(r,2),a=i[0],o=i[1];n.push(+o),e=a}n.push(+e),v.twoByteUnsignedInteger(n.length)}var u=new ArrayBuffer(2+n.length),f=new DataView(u);f.setUint16(0,n.length);for(var s=2,c=n.length-1;c>-1;c--,s++)f.setUint8(s,n[c]);t.addAll(u)}}],[{key:"_value",get:function(){return 22}}]),e}(C),G=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),e}(x),Y=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b);var n=f(e);void 0!==n&&(e=n),v.instanceOf(e,Number);var r=new ArrayBuffer(4);new DataView(r).setFloat32(0,e),t.addAll(r)}}],[{key:"_value",get:function(){return 32}}]),e}(G),J=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b);var n=f(e);void 0!==n&&(e=n),v.instanceOf(e,Number);var r=new ArrayBuffer(8);new DataView(r).setFloat64(0,e),t.addAll(r)}}],[{key:"_value",get:function(){return 33}}]),e}(G),W=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,Boolean),e?t.add(255):t.add(0)}}],[{key:"_value",get:function(){return 48}}]),e}(x),X=function(t){function e(t){a(this,e);var n=r(this,Object.getPrototypeOf(e).call(this));return v.fourByteUnsignedInteger(t),n.length=t,n}return i(e,t),y(e,null,[{key:"_value",get:function(){return 49}}]),y(e,[{key:"addToBuffer",value:function(t){l(Object.getPrototypeOf(e.prototype),"addToBuffer",this).call(this,t)&&t.addAll(o(this.length))}},{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,Array),e.length!==this.length&&v.fail("Length does not match"),c(t,e)}}]),e}(x),$=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(e,Array),v.fourByteUnsignedInteger(e.length),t.addAll(o(e.length)),c(t,e)}}],[{key:"_value",get:function(){return 50}}]),e}(x),Q=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,String),v.assert(1===e.length,"String must contain only 1 character"),t.addAll(g.fromString(e))}}],[{key:"_value",get:function(){return 64}}]),e}(x),K=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,String);var n=g.fromString(e);t.addAll(n),t.add(0)}}],[{key:"_value",get:function(){return 65}}]),e}(x),Z=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,ArrayBuffer),v.fourByteUnsignedInteger(e.byteLength),t.addAll(o(e.byteLength)),t.addAll(e)}}],[{key:"_value",get:function(){return 66}}]),e}(x),tt=function(t){function e(t){var n=t.type,i=t.length;a(this,e);var o=r(this,Object.getPrototypeOf(e).call(this));return v.instanceOf(n,k),v.fourByteUnsignedInteger(i),o.type=n,o.length=i,o}return i(e,t),y(e,null,[{key:"_value",get:function(){return 80}}]),y(e,[{key:"addToBuffer",value:function(t){l(Object.getPrototypeOf(e.prototype),"addToBuffer",this).call(this,t)&&(this.type.addToBuffer(t),t.addAll(o(this.length)))}},{key:"writeValue",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,b),v.instanceOf(e,Array),e.length!==this.length&&v.fail("Length does not match: expected "+(this.length+"")+" but got "+e.length);var r=!0,i=!1,a=void 0;try{for(var o,f=e[Symbol.iterator]();!(r=(o=f.next()).done);r=!0){var s=o.value;this.type.writeValue(t,s,!1)}}catch(t){i=!0,a=t}finally{try{!r&&f.return&&f.return()}finally{if(i)throw a}}u(t,n)}}]),e}(x),et="name",nt="type",rt="buffer",it=function(t){function e(t){a(this,e);var n=r(this,Object.getPrototypeOf(e).call(this));v.instanceOf(t,Object);var i=0;for(var o in t)i++;try{v.byteUnsignedInteger(i)}catch(t){v.fail(i+" fields is too many")}n.fields=Array(i);var u=0;for(var f in t){var s=g.fromString(f);try{v.byteUnsignedInteger(s.byteLength)}catch(t){v.fail("Field name "+f+" is too long")}var c=t[f];try{v.instanceOf(c,k)}catch(t){v.fail(c+" is not a valid field type")}var l={};l[et]=f,l[nt]=c,l[rt]=s,n.fields[u]=l,u++}return n.fields.sort(function(t,e){return t[et]e[et]?1:void 0}),n}return i(e,t),y(e,null,[{key:"_value",get:function(){return 81}}]),y(e,[{key:"addToBuffer",value:function(t){if(l(Object.getPrototypeOf(e.prototype),"addToBuffer",this).call(this,t)){t.add(this.fields.length);var n=!0,r=!1,i=void 0;try{for(var a,o=this.fields[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var u=a.value,f=u[rt];t.add(f.byteLength),t.addAll(f),u[nt].addToBuffer(t)}}catch(t){r=!0,i=t}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}}},{key:"writeValue",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,b),v.instanceOf(e,Object);var r=!0,i=!1,a=void 0;try{for(var o,f=this.fields[Symbol.iterator]();!(r=(o=f.next()).done);r=!0){var s=o.value,c=e[s[et]];void 0===c&&v.fail("Value for field "+s[et]+" missing"), -s[nt].writeValue(t,c,!1)}}catch(t){i=!0,a=t}finally{try{!r&&f.return&&f.return()}finally{if(i)throw a}}u(t,n)}}]),e}(x),at=function(t){function e(t){a(this,e);var n=r(this,Object.getPrototypeOf(e).call(this));return v.instanceOf(t,k),n.type=t,n}return i(e,t),y(e,null,[{key:"_value",get:function(){return 82}}]),y(e,[{key:"addToBuffer",value:function(t){l(Object.getPrototypeOf(e.prototype),"addToBuffer",this).call(this,t)&&this.type.addToBuffer(t)}},{key:"_writeValue",value:function(t,e,n){v.instanceOf(t,b),v.fourByteUnsignedInteger(e.length),t.addAll(o(e.length));var r=!0,i=!1,a=void 0;try{for(var f,s=e[Symbol.iterator]();!(r=(f=s.next()).done);r=!0){var c=f.value;this.type.writeValue(t,c,!1)}}catch(t){i=!0,a=t}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}u(t,n)}},{key:"writeValue",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,Array),this._writeValue(t,e,n)}}]),e}(x),ot=function(t){function e(t){return a(this,e),r(this,Object.getPrototypeOf(e).call(this,t))}return i(e,t),y(e,null,[{key:"_value",get:function(){return 83}}]),y(e,[{key:"writeValue",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,Set),e.length=e.size,this._writeValue(t,e,n)}}]),e}(at),ut=function(t){function e(t,n){a(this,e);var i=r(this,Object.getPrototypeOf(e).call(this));return v.instanceOf(t,k),v.instanceOf(n,k),i.keyType=t,i.valueType=n,i}return i(e,t),y(e,null,[{key:"_value",get:function(){return 84}}]),y(e,[{key:"addToBuffer",value:function(t){l(Object.getPrototypeOf(e.prototype),"addToBuffer",this).call(this,t)&&(this.keyType.addToBuffer(t),this.valueType.addToBuffer(t))}},{key:"writeValue",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,b),v.instanceOf(e,Map),v.fourByteUnsignedInteger(e.size),t.addAll(o(e.size));var r=!0,i=!1,a=void 0;try{for(var f,s=e[Symbol.iterator]();!(r=(f=s.next()).done);r=!0){var c=h(f.value,2),l=c[0],y=c[1];this.keyType.writeValue(t,l,!1),this.valueType.writeValue(t,y,!1)}}catch(t){i=!0,a=t}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}u(t,n)}}]),e}(x),ft=function(t){function e(t){var n=t.type,i=t.values;a(this,e);var o=r(this,Object.getPrototypeOf(e).call(this));v.instanceOf(n,x),v.instanceOf(i,Array);try{v.byteUnsignedInteger(i.length)}catch(t){v.fail(i.length+" values is too many")}for(var u=new Map,f=0;f=200&&e.status<300||304===e.status;n?t[o]=e.response:t.text=e.statusText,r(e.status,e.statusText,t,e.getAllResponseHeaders())}),e.open(a,i,f),e.responseType=o;for(var s in n)n.hasOwnProperty(s)&&e.setRequestHeader(s,n[s]);e.send(u)},abort:function(){e&&e.abort()}}}})}(jQuery)},{}],"/client-side/common.js":[function(t,e,n){"use strict";var r=t("/lib/assert.js");if(r.instanceOf(window.Map,Function),r.instanceOf(window.Set,Function),r.instanceOf(window.ArrayBuffer,Function),r.instanceOf(window.Uint8Array,Function),r.instanceOf(window.Symbol,Function),t("/client-side/binary-ajax.js"),void 0===window.sb)window.sb=t("/structure-types.js");else if(!(window.sb instanceof Object))throw Error("window.sb is already defined")},{"/client-side/binary-ajax.js":"/client-side/binary-ajax.js","/lib/assert.js":"/lib/assert.js","/structure-types.js":"/structure-types.js"}],"/config.js":[function(t,e,n){(function(n){"use strict";"/"===n&&(n="");var r=t(n+"/lib/assert.js"),i=t("base64-js"),a=8;r.between(0,a,65536);var o=2,u=new ArrayBuffer(o);new DataView(u).setUint16(0,a);var f=i.fromByteArray(new Uint8Array(u));e.exports={VERSION_STRING:f}}).call(this,"/")},{"base64-js":2}],"/lib/assert.js":[function(t,e,n){"use strict";var r=t("/lib/util-inspect.js"),i={instanceOf:function(t,e){e instanceof Array||(e=[e]);var n=!1,i=!0,a=!1,o=void 0;try{for(var u,f=e[Symbol.iterator]();!(i=(u=f.next()).done);i=!0){var s=u.value;if(t instanceof s||void 0!==t&&null!==t&&t.constructor===s){n=!0;break}}}catch(t){a=!0,o=t}finally{try{!i&&f.return&&f.return()}finally{if(a)throw o}}if(!n)throw new TypeError(r.inspect(t)+" is not an instance of "+e.map(function(t){return t.name}).join(" or "))},integer:function(t){if(i.instanceOf(t,Number),!Number.isSafeInteger(t))throw new RangeError(r.inspect(t)+" is not an integer")},between:function(t,e,n,i){if(e=n){var a=r.inspect(e)+" is not in ["+r.inspect(t)+","+r.inspect(n)+")";throw void 0===i?new RangeError(a):new RangeError(i+" ("+a+")")}},byteUnsignedInteger:function(t){i.integer(t),i.between(0,t,256)},twoByteUnsignedInteger:function(t){i.integer(t),i.between(0,t,65536)},fourByteUnsignedInteger:function(t){i.integer(t),i.between(0,t,4294967296)},fail:function(t){throw Error(t)},assert:function(t,e){t||i.fail(e)},throws:function(t,e){var n=!0;try{t(),n=!1}catch(t){void 0!==e&&i.message(t,e)}i.assert(n,"Should throw an error")},equal:function(t,e){var n=new RangeError("Expected "+r.inspect(e)+" but got "+r.inspect(t));if(e&&e.constructor===Object){for(var a in e)if(e.hasOwnProperty(a))try{i.equal(t[a],e[a])}catch(t){throw n}}else if(e&&e.constructor===Array){if(!t||t.constructor!==Array)throw n;try{i.equal(t.length,e.length)}catch(t){throw n}for(var o=0;o>>3},modEight:function(t){return 7&t}}},{}],"/lib/buffer-string.js":[function(t,e,n){(function(n){"use strict";var r=t(n+"/assert.js"),i=t(n+"/growable-buffer.js"),a=4096;e.exports={toString:function(t){t&&t.constructor===ArrayBuffer&&(t=new Uint8Array(t)),r.instanceOf(t,Uint8Array);for(var e=[],n=0;n239?4:i>223?3:i>191?2:1;if(n+u<=t.length){var f=void 0,s=void 0,c=void 0,l=void 0;switch(u){case 1:i<128&&(o=i);break;case 2:f=t[n+1],128===(192&f)&&(l=(31&i)<<6|63&f,l>127&&(o=l));break;case 3:f=t[n+1],s=t[n+2],128===(192&f)&&128===(192&s)&&(l=(15&i)<<12|(63&f)<<6|63&s,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:f=t[n+1],s=t[n+2],c=t[n+3],128===(192&f)&&128===(192&s)&&128===(192&c)&&(l=(15&i)<<18|(63&f)<<12|(63&s)<<6|63&c,l>65535&&l<1114112&&(o=l))}}void 0===o?(o=65533,u=1):o>65535&&(o-=65536,e.push(o>>>10&1023|55296),o=56320|1023&o),e.push(o),n+=u}for(var y="",h=0;h>6),e.add(128|63&c)):c<55296||c>=57344?(e.add(224|c>>12),e.add(128|c>>6&63),e.add(128|63&c)):(c=65536+((1023&c)<<10|1023&c),e.add(240|c>>18),e.add(128|c>>12&63),e.add(128|c>>6&63),e.add(128|63&c))}}catch(t){a=!0,o=t}finally{try{!n&&f.return&&f.return()}finally{if(a)throw o}}return e.toBuffer()},toBinaryString:function(t){r.instanceOf(t,ArrayBuffer);var e="",n=new Uint8Array(t),i=!0,a=!1,o=void 0;try{for(var u,f=n[Symbol.iterator]();!(i=(u=f.next()).done);i=!0){var s=u.value;e+=String.fromCharCode(s)}}catch(t){a=!0,o=t}finally{try{!i&&f.return&&f.return()}finally{if(a)throw o}}return e},fromBinaryString:function(t){r.instanceOf(t,String);for(var e=new ArrayBuffer(t.length),n=new Uint8Array(e),i=0;ithis.buffer.byteLength){var e=new ArrayBuffer(t<<1);new Uint8Array(e).set(new Uint8Array(this.buffer).subarray(0,this.size)),this.buffer=e}return this}},{key:"set",value:function(t,e){a.integer(t),a.integer(e),a.between(0,t,this.size,"Index out of bounds: "+(t+"")),a.between(0,e,256,"Not a byte: "+(e+""));var n=new Uint8Array(this.buffer);return n[t]=e,this}},{key:"setAll",value:function(t,e){a.instanceOf(e,ArrayBuffer),a.integer(t),a.between(0,t,this.size-e.byteLength+1,"Index out of bounds: "+(t+"")),new Uint8Array(this.buffer).set(new Uint8Array(e),t)}},{key:"get",value:function(t){return a.integer(t),a.between(0,t,this.size,"Index out of bounds: "+(t+"")),new Uint8Array(this.buffer)[t]}},{key:"add",value:function(t){var e=this.size,n=e+1;this.grow(n),this.size=n;var r=new Uint8Array(this.buffer);return r[e]=t,this}},{key:"addAll",value:function(t){a.instanceOf(t,ArrayBuffer);var e=this.size,n=this.size+t.byteLength;return this.grow(n),this.size=n,new Uint8Array(this.buffer).set(new Uint8Array(t),e),this}},{key:"toBuffer",value:function(){return this.buffer.slice(0,this.size)}},{key:"length",get:function(){return this.size}},{key:"rawBuffer",get:function(){return this.buffer}}]),t}();e.exports=u}).call(this,"/lib")},{}],"/lib/strint.js":[function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},i={};!function(){function t(t,e){return m(t)===m(e)}function e(t,e){for(;e>0;)t+="0",e--;return t}function n(t){s(t,"string")}function a(t){n(t),f(t,m,"isPositive")}function o(t){s(t,"number")}function u(t){if(s(t,"number"),t<0)throw Error("Expected a positive number: "+t)}function f(t,e,n){if(!e.call(null,t))throw Error("Condition "+n+" failed for value "+t)}function s(t,e){if((void 0===t?"undefined":r(t))!==e)throw Error("Not a "+e+": "+t)}var c=i.subPositive=function(t,e){if(a(t),a(e),!T(t,e))throw Error("x must be greater or equal to y");for(var n=Math.max(t.length,e.length),r="",i=0,o=0,u=0;u=10;)c-=10,i++;0===c?o++:(r=c+""+U(r,o),o=0)}return i>0&&(r=i+""+U(r,o)),r},y=i.add=function(t,e){if(n(t),n(e),m(t)&&m(e))return l(t,e);if(A(t)&&A(e))return S(l(j(t),j(e)));if(O(j(t),j(e))){var r=t;t=e,e=r}var i=c(j(t),j(e));return m(t)?i:S(i)},h=i.sub=function(t,e){return n(t),n(e),y(t,S(e))},v=i.timesDigit=function(t,e){a(t),o(e);for(var n="",r=E(t),i=0,u=0,f=0;f=10;)s-=10,i++;0===s?u++:(n=s+""+U(n,u),u=0)}return i>0&&(n=i+""+U(n,u)),0===n.length?"0":n},d=i.mulPositive=function(t,n){a(t),a(n);for(var r="0",i=E(n),o=0;o=E(t)?"0":t.charAt(t.length-e-1)},E=function(t){return A(t)?t.length-1:t.length}}(),i.LONG_UPPER_SHIFT="4294967296",i.BYTE_SHIFT="256",e.exports=i},{}],"/lib/util-inspect.js":[function(t,e,n){"use strict";n.inspect=function(t){if(void 0===t)return"undefined";if(null===t||t.constructor===Object||t.constructor===Array||t.constructor===String||t.constructor===Number||t.constructor===Boolean||t.constructor===Date)return JSON.stringify(t);if(t.constructor===Set){for(var e="Set {",r=t.values(),i=r.next();!i.done;)e+=n.inspect(i.value),i=r.next(),i.done||(e+=", ");return e+"}"}if(t.constructor===Map){for(var a="Map {",o=t.entries(),u=o.next();!u.done;)a+=n.inspect(u.value[0]),a+=" => ",a+=n.inspect(u.value[1]),u=o.next(),u.done||(a+=", ");return a+"}"}return t.constructor.name?t.constructor.name+" "+JSON.stringify(t):JSON.stringify(t)}},{}],"/structure-types.js":[function(t,e,n){(function(n){"use strict";function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t){var e=new ArrayBuffer(4);return new DataView(e).setUint32(0,t),e}function u(t,e){if(e&&t.pointers){var n=!0,r=!1,i=void 0;try{for(var a,o=t.pointers[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var u=h(a.value,2),f=u[0],s=u[1],c=t.length;t.addAll(g.fromBinaryString(f));var l=new ArrayBuffer(4);new DataView(l).setUint32(0,c);var y=!0,v=!1,d=void 0;try{for(var p,w=s[Symbol.iterator]();!(y=(p=w.next()).done);y=!0){var b=p.value;t.setAll(b,l)}}catch(t){v=!0,d=t}finally{try{!y&&w.return&&w.return()}finally{if(v)throw d}}}}catch(t){r=!0,i=t}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}}function f(t){if(t&&t.constructor===String){var e=+t;if(!isNaN(e))return e}}function s(t,e){v.instanceOf(t,b),v.instanceOf(e,String),(O.gt(e,L)||O.lt(e,"0"))&&v.fail("Value out of range");var n=O.div(e,O.LONG_UPPER_SHIFT),r=O.sub(e,O.mul(n,O.LONG_UPPER_SHIFT)),i=new ArrayBuffer(8),a=new DataView(i);a.setUint32(0,+n),a.setUint32(4,+r),t.addAll(i)}function c(t,e){v.instanceOf(e,Array);var n=m(e.length),r=A(e.length),i=void 0;i=n?r+1:r;for(var a=new ArrayBuffer(i),o=new Uint8Array(a),u=0;u-1;f--,u++)o.setUint8(u,n[f]);n.length&&o.setInt8(2,n[n.length-1]),t.addAll(a)}}],[{key:"_value",get:function(){return 6}}]),e}(P),C=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),e}(x),H=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b);var n=f(e);void 0!==n&&(e=n),v.integer(e),v.between(0,e,256,"Value out of range");var r=new ArrayBuffer(1);new Uint8Array(r)[0]=e,t.addAll(r)}}],[{key:"_value",get:function(){return 17}}]),e}(C),D=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b);var n=f(e);void 0!==n&&(e=n),v.integer(e),v.between(0,e,65536,"Value out of range");var r=new ArrayBuffer(2);new DataView(r).setUint16(0,e),t.addAll(r)}}],[{key:"_value",get:function(){return 18}}]),e}(C),F=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b);var n=f(e);void 0!==n&&(e=n),v.integer(e),v.between(0,e,4294967296,"Value out of range");var r=new ArrayBuffer(4);new DataView(r).setUint32(0,e),t.addAll(r)}}],[{key:"_value",get:function(){return 19}}]),e}(C),L="18446744073709551615",R=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){s(t,e)}}],[{key:"_value",get:function(){return 20}}]),e}(C),z=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(e,Date),s(t,e.getTime()+"")}}],[{key:"_value",get:function(){return 21}}]),e}(x),M=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,String),O.isNegative(e)&&v.fail("Value out of range");var n=[];if(!O.eq(e,"0")){for(;O.ge(e,O.BYTE_SHIFT);){var r=O.quotientRemainderPositive(e,O.BYTE_SHIFT),i=h(r,2),a=i[0],o=i[1];n.push(+o),e=a}n.push(+e),v.twoByteUnsignedInteger(n.length)}var u=new ArrayBuffer(2+n.length),f=new DataView(u);f.setUint16(0,n.length);for(var s=2,c=n.length-1;c>-1;c--,s++)f.setUint8(s,n[c]);t.addAll(u)}}],[{key:"_value",get:function(){return 22}}]),e}(C),G=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),e}(x),Y=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b);var n=f(e);void 0!==n&&(e=n),v.instanceOf(e,Number);var r=new ArrayBuffer(4);new DataView(r).setFloat32(0,e),t.addAll(r)}}],[{key:"_value",get:function(){return 32}}]),e}(G),J=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b);var n=f(e);void 0!==n&&(e=n),v.instanceOf(e,Number);var r=new ArrayBuffer(8);new DataView(r).setFloat64(0,e),t.addAll(r)}}],[{key:"_value",get:function(){return 33}}]),e}(G),W=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,Boolean),e?t.add(255):t.add(0)}}],[{key:"_value",get:function(){return 48}}]),e}(x),X=function(t){function e(t){a(this,e);var n=r(this,Object.getPrototypeOf(e).call(this));return v.fourByteUnsignedInteger(t),n.length=t,n}return i(e,t),y(e,null,[{key:"_value",get:function(){return 49}}]),y(e,[{key:"addToBuffer",value:function(t){l(Object.getPrototypeOf(e.prototype),"addToBuffer",this).call(this,t)&&t.addAll(o(this.length))}},{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,Array),e.length!==this.length&&v.fail("Length does not match"),c(t,e)}}]),e}(x),$=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(e,Array),v.fourByteUnsignedInteger(e.length),t.addAll(o(e.length)),c(t,e)}}],[{key:"_value",get:function(){return 50}}]),e}(x),Q=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,String),v.assert(1===e.length,"String must contain only 1 character"),t.addAll(g.fromString(e))}}],[{key:"_value",get:function(){return 64}}]),e}(x),K=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,String);var n=g.fromString(e);t.addAll(n),t.add(0)}}],[{key:"_value",get:function(){return 65}}]),e}(x),Z=function(t){function e(){return a(this,e),r(this,Object.getPrototypeOf(e).apply(this,arguments))}return i(e,t),y(e,[{key:"writeValue",value:function(t,e){v.instanceOf(t,b),v.instanceOf(e,ArrayBuffer),v.fourByteUnsignedInteger(e.byteLength),t.addAll(o(e.byteLength)),t.addAll(e)}}],[{key:"_value",get:function(){return 66}}]),e}(x),tt=function(t){function e(t){var n=t.type,i=t.length;a(this,e);var o=r(this,Object.getPrototypeOf(e).call(this));return v.instanceOf(n,k),v.fourByteUnsignedInteger(i),o.type=n,o.length=i,o}return i(e,t),y(e,null,[{key:"_value",get:function(){return 80}}]),y(e,[{key:"addToBuffer",value:function(t){l(Object.getPrototypeOf(e.prototype),"addToBuffer",this).call(this,t)&&(this.type.addToBuffer(t),t.addAll(o(this.length)))}},{key:"writeValue",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,b),v.instanceOf(e,Array),e.length!==this.length&&v.fail("Length does not match: expected "+(this.length+"")+" but got "+e.length);var r=!0,i=!1,a=void 0;try{for(var o,f=e[Symbol.iterator]();!(r=(o=f.next()).done);r=!0){var s=o.value;this.type.writeValue(t,s,!1)}}catch(t){i=!0,a=t}finally{try{!r&&f.return&&f.return()}finally{if(i)throw a}}u(t,n)}}]),e}(x),et="name",nt="type",rt="buffer",it=function(t){function e(t){a(this,e);var n=r(this,Object.getPrototypeOf(e).call(this));v.instanceOf(t,Object);var i=0;for(var o in t)i++;try{v.byteUnsignedInteger(i)}catch(t){v.fail(i+" fields is too many")}n.fields=Array(i);var u=0;for(var f in t){var s=g.fromString(f);try{v.byteUnsignedInteger(s.byteLength)}catch(t){v.fail("Field name "+f+" is too long")}var c=t[f];try{v.instanceOf(c,k)}catch(t){v.fail(c+" is not a valid field type")}var l={};l[et]=f,l[nt]=c,l[rt]=s,n.fields[u]=l,u++}return n.fields.sort(function(t,e){return t[et]e[et]?1:void 0}),n}return i(e,t),y(e,null,[{key:"_value",get:function(){return 81}}]),y(e,[{key:"addToBuffer",value:function(t){if(l(Object.getPrototypeOf(e.prototype),"addToBuffer",this).call(this,t)){t.add(this.fields.length);var n=!0,r=!1,i=void 0;try{for(var a,o=this.fields[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var u=a.value,f=u[rt];t.add(f.byteLength),t.addAll(f),u[nt].addToBuffer(t)}}catch(t){r=!0,i=t}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}}},{key:"writeValue",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,b),v.instanceOf(e,Object);var r=!0,i=!1,a=void 0;try{for(var o,f=this.fields[Symbol.iterator]();!(r=(o=f.next()).done);r=!0){var s=o.value,c=e[s[et]];void 0===c&&v.fail("Value for field "+s[et]+" missing"),s[nt].writeValue(t,c,!1)}}catch(t){i=!0,a=t}finally{try{!r&&f.return&&f.return()}finally{if(i)throw a}}u(t,n)}}]),e}(x),at=function(t){function e(t){a(this,e);var n=r(this,Object.getPrototypeOf(e).call(this));return v.instanceOf(t,k),n.type=t,n}return i(e,t),y(e,null,[{key:"_value",get:function(){return 82}}]),y(e,[{key:"addToBuffer",value:function(t){l(Object.getPrototypeOf(e.prototype),"addToBuffer",this).call(this,t)&&this.type.addToBuffer(t)}},{key:"_writeValue",value:function(t,e,n){v.instanceOf(t,b),v.fourByteUnsignedInteger(e.length),t.addAll(o(e.length));var r=!0,i=!1,a=void 0;try{for(var f,s=e[Symbol.iterator]();!(r=(f=s.next()).done);r=!0){var c=f.value;this.type.writeValue(t,c,!1)}}catch(t){i=!0,a=t}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}u(t,n)}},{key:"writeValue",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,Array),this._writeValue(t,e,n)}}]),e}(x),ot=function(t){function e(t){return a(this,e),r(this,Object.getPrototypeOf(e).call(this,t))}return i(e,t),y(e,null,[{key:"_value",get:function(){return 83}}]),y(e,[{key:"writeValue",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(e,Set),e.length=e.size,this._writeValue(t,e,n)}}]),e}(at),ut=function(t){function e(t,n){a(this,e);var i=r(this,Object.getPrototypeOf(e).call(this));return v.instanceOf(t,k),v.instanceOf(n,k),i.keyType=t,i.valueType=n,i}return i(e,t),y(e,null,[{key:"_value",get:function(){return 84}}]),y(e,[{key:"addToBuffer",value:function(t){l(Object.getPrototypeOf(e.prototype),"addToBuffer",this).call(this,t)&&(this.keyType.addToBuffer(t),this.valueType.addToBuffer(t))}},{key:"writeValue",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]||arguments[2];v.instanceOf(t,b),v.instanceOf(e,Map),v.fourByteUnsignedInteger(e.size),t.addAll(o(e.size));var r=!0,i=!1,a=void 0;try{for(var f,s=e[Symbol.iterator]();!(r=(f=s.next()).done);r=!0){var c=h(f.value,2),l=c[0],y=c[1];this.keyType.writeValue(t,l,!1),this.valueType.writeValue(t,y,!1)}}catch(t){i=!0,a=t}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}u(t,n)}}]),e}(x),ft=function(t){function e(t){var n=t.type,i=t.values;a(this,e);var o=r(this,Object.getPrototypeOf(e).call(this));v.instanceOf(n,x),v.instanceOf(i,Array);try{v.byteUnsignedInteger(i.length)}catch(t){v.fail(i.length+" values is too many")}for(var u=new Map,f=0;f0)throw Error("Invalid string. Length must be a multiple of 4");a="="===t[u-2]?2:"="===t[u-1]?1:0,o=new c(3*u/4-a),r=a>0?u-4:u;var f=0;for(e=0,n=0;e>16&255,o[f++]=i>>8&255,o[f++]=255&i;return 2===a?(i=s[t.charCodeAt(e)]<<2|s[t.charCodeAt(e+1)]>>4,o[f++]=255&i):1===a&&(i=s[t.charCodeAt(e)]<<10|s[t.charCodeAt(e+1)]<<4|s[t.charCodeAt(e+2)]>>2,o[f++]=i>>8&255,o[f++]=255&i),o}function a(t){return f[t>>18&63]+f[t>>12&63]+f[t>>6&63]+f[63&t]}function o(t,e,n){for(var r,i=[],o=e;oc?c:s+u));return 1===r?(e=t[n-1],i+=f[e>>2],i+=f[e<<4&63],i+="=="):2===r&&(e=(t[n-2]<<8)+t[n-1],i+=f[e>>10],i+=f[e>>4&63],i+=f[e<<2&63],i+="="),a.push(i),a.join("")}n.toByteArray=i,n.fromByteArray=u;var f=[],s=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array;r()},{}],3:[function(t,e,n){!function(t){"use strict";function n(t){return t.map(function(t){return r(t.toString(16),2)}).join("")}function r(t,e){return t.length>e?t:Array(e-t.length+1).join("0")+t}var i={bytesToHex:function(t){return n(t)},hexToBytes:function(t){if(t.length%2===1)throw Error("hexToBytes can't have a string with an odd number of characters.");return 0===t.indexOf("0x")&&(t=t.slice(2)),t.match(/../g).map(function(t){return parseInt(t,16)})}};void 0!==e&&e.exports?e.exports=i:t.convertHex=i}(this)},{}],4:[function(t,e,n){!function(t){"use strict";var n={bytesToString:function(t){return t.map(function(t){return String.fromCharCode(t)}).join("")},stringToBytes:function(t){return t.split("").map(function(t){return t.charCodeAt(0)})}};n.UTF8={bytesToString:function(t){return decodeURIComponent(escape(n.bytesToString(t)))},stringToBytes:function(t){return n.stringToBytes(unescape(encodeURIComponent(t)))}},void 0!==e&&e.exports?e.exports=n:t.convertString=n}(this)},{}],5:[function(t,e,n){!function(n){"use strict";function r(t,e){t.constructor===String&&(t=i.convertString.UTF8.stringToBytes(t));var n=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],r=o(t),a=8*t.length;r[a>>5]|=128<<24-a%32,r[(a+64>>9<<4)+15]=a;for(var f=0;f>>5]|=t[n]<<24-r%32;return e},u=function(t){for(var e=[],n=0;n<32*t.length;n+=8)e.push(t[n>>>5]>>>24-n%32&255);return e},f=[],s=function(t,e,n){for(var r=t[0],i=t[1],o=t[2],u=t[3],s=t[4],c=t[5],l=t[6],y=t[7],h=0;h<64;h++){if(h<16)f[h]=0|e[n+h];else{var v=f[h-15],d=(v<<25|v>>>7)^(v<<14|v>>>18)^v>>>3,g=f[h-2],p=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;f[h]=d+f[h-7]+p+f[h-16]}var w=s&c^~s&l,b=r&i^r&o^i&o,O=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),T=(s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25),B=y+T+w+a[h]+f[h],A=O+b;y=l,l=c,c=s,s=u+B|0,u=o,o=i,i=r,r=B+A|0}t[0]=t[0]+r|0,t[1]=t[1]+i|0,t[2]=t[2]+o|0,t[3]=t[3]+u|0,t[4]=t[4]+s|0,t[5]=t[5]+c|0,t[6]=t[6]+l|0,t[7]=t[7]+y|0};r.x2=function(t,e){return r(r(t,{asBytes:!0}),e)}}(this)},{"convert-hex":3,"convert-string":4}]},{},[1]); \ No newline at end of file diff --git a/doc/r.html b/doc/r.html index 3cfbc23..114659e 100644 --- a/doc/r.html +++ b/doc/r.html @@ -70,7 +70,7 @@

r

Source:
@@ -262,7 +262,7 @@
Parameters:
Source:
@@ -555,7 +555,7 @@
Properties
Source:
diff --git a/doc/read.js.html b/doc/read.js.html index fcaff82..18693c3 100644 --- a/doc/read.js.html +++ b/doc/read.js.html @@ -144,7 +144,13 @@

Source: read.js

length++; const values = []; for (let i = 0; i < valueCount; i++) { - const value = consumeValue({buffer: typeBuffer, offset: offset + length, type: enumType.value}); //reading values rather than types + const valueLocation = offset + length; + const value = consumeValue({ //reading values rather than types + buffer: typeBuffer, + pointerStart: valueLocation, + offset: valueLocation, + type: enumType.value + }); length += value.length; values[i] = value.value; } @@ -212,9 +218,14 @@

Source: read.js

} return {value, length: byteLength}; } -//Reads a value from the specified bytes at the specified offset, given a type -//Returns the value that was read and the number of bytes consumed (excepting any values being pointed to) -function consumeValue({buffer, offset, type}) { +/* + Reads a value from the specified bytes at the specified offset, given a type + Returns the value that was read and the number of bytes consumed (excepting any values being pointed to) + Pointer start refers to the position in the buffer where the root value starts + (pointers will be relative to this location) +*/ +function consumeValue({buffer, pointerStart, offset, type}) { + assert.instanceOf(pointerStart, Number); let value, length; switch (type.constructor) { case t.ByteType: @@ -346,7 +357,7 @@

Source: read.js

length = 0; value = new Array(type.length); for (let i = 0; i < type.length; i++) { - const tupleElement = consumeValue({buffer, offset: offset + length, type: type.type}); + const tupleElement = consumeValue({buffer, pointerStart, offset: offset + length, type: type.type}); length += tupleElement.length; value[i] = tupleElement.value; } @@ -357,7 +368,7 @@

Source: read.js

for (let field of type.fields) { const fieldName = field.name; const fieldType = field.type; - const readField = consumeValue({buffer, offset: offset + length, type: fieldType}); + const readField = consumeValue({buffer, pointerStart, offset: offset + length, type: fieldType}); value[fieldName] = readField.value; length += readField.length; } @@ -367,7 +378,7 @@

Source: read.js

length = arrayLength.length; value = new Array(arrayLength.value); for (let i = 0; i < value.length; i++) { - const arrayElement = consumeValue({buffer, offset: offset + length, type: type.type}); + const arrayElement = consumeValue({buffer, pointerStart, offset: offset + length, type: type.type}); length += arrayElement.length; value[i] = arrayElement.value; } @@ -377,7 +388,7 @@

Source: read.js

length = setLength.length; value = new Set; for (let i = 0; i < setLength.value; i++) { - const setElement = consumeValue({buffer, offset: offset + length, type: type.type}); + const setElement = consumeValue({buffer, pointerStart, offset: offset + length, type: type.type}); length += setElement.length; value.add(setElement.value); } @@ -387,9 +398,9 @@

Source: read.js

length = mapSize.length; value = new Map; for (let i = 0; i < mapSize.value; i++) { - const keyElement = consumeValue({buffer, offset: offset + length, type: type.keyType}); + const keyElement = consumeValue({buffer, pointerStart, offset: offset + length, type: type.keyType}); length += keyElement.length; - const valueElement = consumeValue({buffer, offset: offset + length, type: type.valueType}); + const valueElement = consumeValue({buffer, pointerStart, offset: offset + length, type: type.valueType}); length += valueElement.length; value.set(keyElement.value, valueElement.value); } @@ -405,7 +416,7 @@

Source: read.js

length = 1; assert.assert(buffer.byteLength >= offset + length, NOT_LONG_ENOUGH); const typeIndex = new Uint8Array(buffer)[offset]; - const subValue = consumeValue({buffer, offset: offset + length, type: type.types[typeIndex]}); + const subValue = consumeValue({buffer, pointerStart, offset: offset + length, type: type.types[typeIndex]}); length += subValue.length; value = subValue.value; break; @@ -415,7 +426,7 @@

Source: read.js

const optionalByte = new Uint8Array(buffer)[offset]; assert.assert(optionalByte === 0x00 || optionalByte === 0xFF, '0x' + optionalByte.toString(16) + ' is an invalid Optional byte'); if (optionalByte) { - const subValue = consumeValue({buffer, offset: offset + length, type: type.type}); + const subValue = consumeValue({buffer, pointerStart, offset: offset + length, type: type.type}); length += subValue.length; value = subValue.value; } @@ -424,7 +435,7 @@

Source: read.js

case t.PointerType: const location = readLengthBuffer(buffer, offset); length = location.length; - value = consumeValue({buffer, offset: location.value, type: type.type}).value; + value = consumeValue({buffer, pointerStart, offset: pointerStart + location.value, type: type.type}).value; break; default: assert.fail('Not a structure type: ' + util.inspect(type)); @@ -436,7 +447,7 @@

Source: read.js

assert.instanceOf(type, t.Type); if (offset === undefined) offset = 0; //for some reason, isparta doesn't like default parameters inside destructuring assert.instanceOf(offset, Number); - const {value} = consumeValue({buffer, offset, type}); + const {value} = consumeValue({buffer, offset, type, pointerStart: offset}); //no length validation because bytes being pointed to don't get counted in the length return value; } diff --git a/package.json b/package.json index f6b5fa9..098393e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "structure-bytes", - "version": "2.9.8", + "version": "2.10.8", "description": "Efficiently stores data of any shape by separating it into structure and value", "main": "index.js", "dependencies": { diff --git a/read.js b/read.js index e0ac713..9bfd9de 100644 --- a/read.js +++ b/read.js @@ -116,7 +116,13 @@ function consumeType(typeBuffer, offset) { length++; const values = []; for (let i = 0; i < valueCount; i++) { - const value = consumeValue({buffer: typeBuffer, offset: offset + length, type: enumType.value}); //reading values rather than types + const valueLocation = offset + length; + const value = consumeValue({ //reading values rather than types + buffer: typeBuffer, + pointerStart: valueLocation, + offset: valueLocation, + type: enumType.value + }); length += value.length; values[i] = value.value; } @@ -184,9 +190,13 @@ function readBooleans({buffer, offset, count}) { //complement to writeBooleans() } return {value, length: byteLength}; } -//Reads a value from the specified bytes at the specified offset, given a type -//Returns the value that was read and the number of bytes consumed (excepting any values being pointed to) -function consumeValue({buffer, offset, type}) { +/* + Reads a value from the specified bytes at the specified offset, given a type + Returns the value that was read and the number of bytes consumed (excepting any values being pointed to) + Pointer start refers to the position in the buffer where the root value starts + (pointers will be relative to this location) +*/ +function consumeValue({buffer, pointerStart, offset, type}) { let value, length; switch (type.constructor) { case t.ByteType: @@ -318,7 +328,7 @@ function consumeValue({buffer, offset, type}) { length = 0; value = new Array(type.length); for (let i = 0; i < type.length; i++) { - const tupleElement = consumeValue({buffer, offset: offset + length, type: type.type}); + const tupleElement = consumeValue({buffer, pointerStart, offset: offset + length, type: type.type}); length += tupleElement.length; value[i] = tupleElement.value; } @@ -329,7 +339,7 @@ function consumeValue({buffer, offset, type}) { for (let field of type.fields) { const fieldName = field.name; const fieldType = field.type; - const readField = consumeValue({buffer, offset: offset + length, type: fieldType}); + const readField = consumeValue({buffer, pointerStart, offset: offset + length, type: fieldType}); value[fieldName] = readField.value; length += readField.length; } @@ -339,7 +349,7 @@ function consumeValue({buffer, offset, type}) { length = arrayLength.length; value = new Array(arrayLength.value); for (let i = 0; i < value.length; i++) { - const arrayElement = consumeValue({buffer, offset: offset + length, type: type.type}); + const arrayElement = consumeValue({buffer, pointerStart, offset: offset + length, type: type.type}); length += arrayElement.length; value[i] = arrayElement.value; } @@ -349,7 +359,7 @@ function consumeValue({buffer, offset, type}) { length = setLength.length; value = new Set; for (let i = 0; i < setLength.value; i++) { - const setElement = consumeValue({buffer, offset: offset + length, type: type.type}); + const setElement = consumeValue({buffer, pointerStart, offset: offset + length, type: type.type}); length += setElement.length; value.add(setElement.value); } @@ -359,9 +369,9 @@ function consumeValue({buffer, offset, type}) { length = mapSize.length; value = new Map; for (let i = 0; i < mapSize.value; i++) { - const keyElement = consumeValue({buffer, offset: offset + length, type: type.keyType}); + const keyElement = consumeValue({buffer, pointerStart, offset: offset + length, type: type.keyType}); length += keyElement.length; - const valueElement = consumeValue({buffer, offset: offset + length, type: type.valueType}); + const valueElement = consumeValue({buffer, pointerStart, offset: offset + length, type: type.valueType}); length += valueElement.length; value.set(keyElement.value, valueElement.value); } @@ -377,7 +387,7 @@ function consumeValue({buffer, offset, type}) { length = 1; assert.assert(buffer.byteLength >= offset + length, NOT_LONG_ENOUGH); const typeIndex = new Uint8Array(buffer)[offset]; - const subValue = consumeValue({buffer, offset: offset + length, type: type.types[typeIndex]}); + const subValue = consumeValue({buffer, pointerStart, offset: offset + length, type: type.types[typeIndex]}); length += subValue.length; value = subValue.value; break; @@ -387,7 +397,7 @@ function consumeValue({buffer, offset, type}) { const optionalByte = new Uint8Array(buffer)[offset]; assert.assert(optionalByte === 0x00 || optionalByte === 0xFF, '0x' + optionalByte.toString(16) + ' is an invalid Optional byte'); if (optionalByte) { - const subValue = consumeValue({buffer, offset: offset + length, type: type.type}); + const subValue = consumeValue({buffer, pointerStart, offset: offset + length, type: type.type}); length += subValue.length; value = subValue.value; } @@ -396,7 +406,7 @@ function consumeValue({buffer, offset, type}) { case t.PointerType: const location = readLengthBuffer(buffer, offset); length = location.length; - value = consumeValue({buffer, offset: location.value, type: type.type}).value; + value = consumeValue({buffer, pointerStart, offset: pointerStart + location.value, type: type.type}).value; break; default: assert.fail('Not a structure type: ' + util.inspect(type)); @@ -408,7 +418,7 @@ function value({buffer, type, offset}) { assert.instanceOf(type, t.Type); if (offset === undefined) offset = 0; //for some reason, isparta doesn't like default parameters inside destructuring assert.instanceOf(offset, Number); - const {value} = consumeValue({buffer, offset, type}); + const {value} = consumeValue({buffer, offset, type, pointerStart: offset}); //no length validation because bytes being pointed to don't get counted in the length return value; } diff --git a/test/io/type-and-value.js b/test/io/type-and-value.js index 2875f6f..ddbba78 100644 --- a/test/io/type-and-value.js +++ b/test/io/type-and-value.js @@ -2,10 +2,10 @@ const fs = require('fs'); const OUT_FILE = 'type-value-out'; -let type = new t.MapType(new t.StringType, new t.UnsignedIntType); -let value = new Map().set('abc', 123).set('def', 4560).set('—ݥ—', 7512112); +let type = new t.MapType(new t.StringType, new t.PointerType(new t.UnsignedIntType)); +let value = new Map().set('abc', 4560).set('def', 4560).set('—ݥ—', 4560); let outStream = fs.createWriteStream(OUT_FILE); -const BUFFER = bufferFrom([0x54, 0x41, 0x13, 0, 0, 0, 3, 0x61, 0x62, 0x63, 0, 0, 0, 0, 0x7b, 0x64, 0x65, 0x66, 0, 0, 0, 0x11, 0xd0, 0xe2, 0x80, 0x94, 0xdd, 0xa5, 0xe2, 0x80, 0x94, 0, 0, 0x72, 0xa0, 0x30]); +const BUFFER = bufferFrom([0x54, 0x41, 0x70, 0x13, 0, 0, 0, 3, 0x61, 0x62, 0x63, 0, 0, 0, 0, 33, 0x64, 0x65, 0x66, 0, 0, 0, 0, 33, 0xe2, 0x80, 0x94, 0xdd, 0xa5, 0xe2, 0x80, 0x94, 0, 0, 0, 0, 33, 0, 0, 0x11, 0xd0]); let s = new Simultaneity; s.addTask(() => { io.writeTypeAndValue({type, value, outStream}, err => {