diffusion
Version:
Diffusion JavaScript client
8 lines • 109 kB
JavaScript
!function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=24)}([function(t,e,r){"use strict";var n,i=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.InternalError=e.IllegalStateError=e.RetryLimitError=e.SchemaParseError=e.SchemaViolationError=e.InvalidFilterError=e.OutOfBoundsError=e.IllegalArgumentError=e.SessionError=e.IOError=e.InvalidDataError=e.AssertionError=e.RuntimeError=e.NullValueError=void 0;var o=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.getType=function(){return e.type},e.type="null_value_error",e}(Error);e.NullValueError=o;var s=function(t){function e(e,r){var n=t.call(this,e)||this;return n.cause=r,n}return i(e,t),e.prototype.getType=function(){return e.type},e.type="runtime_error",e}(Error);e.RuntimeError=s;var a=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.getType=function(){return e.type},e.type="assertion_error",e}(Error);e.AssertionError=a;var u=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.getType=function(){return e.type},e.type="invalid_data_error",e}(Error);e.InvalidDataError=u;var c=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.getType=function(){return e.type},e.type="io_error",e}(Error);e.IOError=c;var l=function(t){function e(e,r){var n=t.call(this,e)||this;return n.cause=r,n}return i(e,t),e.prototype.getType=function(){return e.type},e.type="session_error",e}(Error);e.SessionError=l;var p=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.getType=function(){return e.type},e.type="illegal_argument_error",e}(Error);e.IllegalArgumentError=p;var f=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.getType=function(){return e.type},e.type="out_of_bounds_error",e}(Error);e.OutOfBoundsError=f;var h=function(t){function e(e,r){var n=t.call(this,e)||this;return n.errors=r,n}return i(e,t),e.prototype.getType=function(){return e.type},e.type="invalid_filter_error",e}(Error);e.InvalidFilterError=h;var d=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.getType=function(){return e.type},e.type="schema_violation_error",e}(Error);e.SchemaViolationError=d;var y=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.getType=function(){return e.type},e.type="schema_parse_error",e}(Error);e.SchemaParseError=y;var v=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.getType=function(){return e.type},e.type="retry_limit_error",e}(Error);e.RetryLimitError=v;var g=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.getType=function(){return e.type},e.type="illegal_state_error",e}(Error);e.IllegalStateError=g;var S=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.getType=function(){return e.type},e.type="internal_error",e}(Error);e.InternalError=S},function(t,e,r){"use strict";var n=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.readOptional=e.writeOptional=e.writeBoolean=e.readBoolean=e.writeMap=e.readMap=e.readObject=e.writeObject=e.writeDictionary=e.readDictionary=e.readCollection=e.writeCollection=e.writeString=e.readString=e.writeBytes=e.readBytes=e.writeByte=e.writeInt32=e.readInt32=e.writeInt64=e.readInt64=e.readByte=void 0;var i=r(0),o=r(29),s=r(10),a=o.fromNumber(128),u=o.fromNumber(127),c=u.not();function l(t){var e=t.read();if(-1===e)throw new i.IOError("End of stream");return e}function p(t){for(var e=0,r=0;e<32;){var n=l(t);if(r|=(127&n)<<e,0==(128&n))return r;e+=7}throw new i.IOError("Malformed int32")}function f(t,e){for(;0!=(-128&e);)t.write(127&e|128),e>>>=7;t.write(e)}function h(t,e){t.write(e)}function d(t){var e=p(t);return t.readMany(e)}function y(t,e){f(t,e.length),t.writeMany(e)}function v(t){var e=d(t);return e?s.uint8toUtf8(e):""}function g(t,e){y(t,s.uint8FromUtf8(e))}function S(t,e,r,i){var o,s;f(t,Object.keys(e).length);try{for(var a=n(Object.getOwnPropertyNames(e)),u=a.next();!u.done;u=a.next()){var c=u.value;r(t,c),i(t,e[c])}}catch(t){o={error:t}}finally{try{u&&!u.done&&(s=a.return)&&s.call(a)}finally{if(o)throw o.error}}}function w(t,e,r){for(var n=p(t),i={},o=0;o<n;++o){i[e(t)]=r(t)}return i}e.readByte=l,e.readInt64=function(t){for(var e=o.fromNumber(0),r=0;r<64;){var n=l(t),s=o.fromNumber(n);if(e=e.or(s.and(u).shiftLeft(r)),s.and(a).equals(0))return e;r+=7}throw new i.IOError("Malformed int64")},e.writeInt64=function(t,e){for(var r=e instanceof o?e:o.fromNumber(e,!1);!r.and(c).equals(0);)t.write(r.and(u).or(a).toInt()),r=r.shiftRightUnsigned(7);t.write(r.toInt())},e.readInt32=p,e.writeInt32=f,e.writeByte=h,e.readBytes=d,e.writeBytes=y,e.readString=v,e.writeString=g,e.writeCollection=function(t,e,r){var i,o;f(t,e.length);try{for(var s=n(e),a=s.next();!a.done;a=s.next()){r(t,a.value)}}catch(t){i={error:t}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}},e.readCollection=function(t,e){for(var r=p(t),n=[],i=0;i<r;++i)n.push(e(t));return n},e.readDictionary=function(t,e){return w(t,v,e)},e.writeDictionary=function(t,e,r){S(t,e,g,r)},e.writeObject=S,e.readObject=w,e.readMap=function(t,e,r){for(var n=p(t),i=new Map,o=0;o<n;++o){var s=e(t);i.set(s,r(t))}return i},e.writeMap=function(t,e,r,n){f(t,e.size),e.forEach((function(e,i){r(t,i),n(t,e)}))},e.readBoolean=function(t){return 0!==t.readInt8()},e.writeBoolean=function(t,e){t.writeInt8(e?1:0)},e.writeOptional=function(t,e,r,n){void 0===n&&(n=function(t){return null!=t}),n(e)?(h(t,1),r(t,e)):h(t,0)},e.readOptional=function(t,e){return l(t)?e(t):void 0}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractSerialiser=void 0;var n=r(0),i=function(){function t(){}return t.prototype.read=function(t){throw new n.InternalError("AbstractSerialiser#read is not implemented")},t.prototype.write=function(t,e){throw new n.InternalError("AbstractSerialiser#write is not implemented")},t}();e.AbstractSerialiser=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TopicUpdateNamespace=e.TopicCreationResult=void 0;var n,i=r(43);!function(t){t[t.CREATED=1]="CREATED",t[t.EXISTS=2]="EXISTS"}(n=e.TopicCreationResult||(e.TopicCreationResult={})),e.TopicUpdateNamespace={TopicCreationResult:n,UpdateConstraintOperator:i.UpdateConstraintOperator}},function(t,e,r){"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.write=void 0;var i=r(0),o=r(1),s=r(11),a=r(34),u=r(35),c=r(36),l=r(37),p=r(38),f=r(40),h=r(41),d=((n={})[s.ConstraintType.UNCONSTRAINED]=h,n[s.ConstraintType.CONJUNCTION]=a,n[s.ConstraintType.TOPIC_VALUE]=f,n[s.ConstraintType.NO_VALUE]=l,n[s.ConstraintType.LOCKED]=u,n[s.ConstraintType.NO_TOPIC]=c,n[s.ConstraintType.PARTIAL_JSON]=p,n[s.ConstraintType.DISJUNCTION]=a,n);e.write=function t(e,r){if(void 0===r.getConstraintType||void 0===s.ConstraintType[r.getConstraintType()])throw new i.IOError("Unknown constraint type");o.writeByte(e,r.getConstraintType()),d[r.getConstraintType()].write(e,r,t)}},function(t,e,r){"use strict";var n=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.setLevel=e.create=e.LoggingLevel=void 0;var i,o=r(62);function s(t,e){var r="|"+t.toUpperCase()+"|"+e+"|",n=function(){return new Date};return function(e,i){i?o[t](n()+r+e,i):o[t](n()+r+e)}}!function(t){t.trace="trace",t.debug="debug",t.info="info",t.warn="warn",t.error="error"}(i=e.LoggingLevel||(e.LoggingLevel={})),e.create=function(t){var e,r,o={};try{for(var a=n(Object.keys(i)),u=a.next();!u.done;u=a.next()){var c=u.value;o[c]=s(c,t)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return o},e.setLevel=o.setLevel},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.write=e.read=void 0;var n=r(0),i=r(1);e.read=function(t,e){var r=i.readByte(t);if(void 0===e[r])throw new n.IllegalArgumentError("Unable to decode enum value "+r);return e[e[r]]},e.write=function(t,e){"number"==typeof e?i.writeByte(t,e):i.writeByte(t,e.id)}},function(t,e,r){"use strict";var n,i=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.UpdateStreamIdSerialiser=e.UpdateStreamIdSerialiserClass=void 0;var o=r(1),s=r(2),a=r(50),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.read=function(t){var e=o.readInt32(t),r=o.readInt32(t),n=o.readInt32(t),i=o.readInt32(t),s=0!==n;return new a.UpdateStreamId(e,r,s,s?n-1:0,s?i:0)},e.prototype.write=function(t,e){o.writeInt32(t,e.topicId),o.writeInt32(t,e.instanceId),e.clustered?(o.writeInt32(t,e.partitionId+1),o.writeInt32(t,e.generationId)):(o.writeInt32(t,0),o.writeInt32(t,0))},e}(s.AbstractSerialiser);e.UpdateStreamIdSerialiserClass=u,e.UpdateStreamIdSerialiser=new u},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UpdateStreamRequest=void 0;var n=function(t,e){this.streamId=t,this.update=e};e.UpdateStreamRequest=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.requireNonNull=void 0;var n=r(0);e.requireNonNull=function(t,e){if(null==t)throw new n.NullValueError(e+" is null");return t}},function(t,e,r){"use strict";(function(t){var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(t,e){for(var r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];return t};function o(t){for(var e=[],r=0;r<t.length;r+=128)e.push(t.subarray(r,Math.min(r+128,t.length)));return e.map((function(t){return String.fromCharCode.apply(String,i([],n(t)))})).join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.isUint8Array=e.isEqualUint8Arrays=e.uint8toUtf8=e.uint8ToBase64=e.uint8ToAscii=e.uint8FromDoubleBE=e.uint8FromBase64=e.uint8FromUtf8=e.uint8FromBinary=e.writeInt32BE=e.writeInt8=e.readDoubleBE=e.readFloatBE=e.readInt32BE=e.readUInt32BE=e.readUInt16BE=e.readInt8=e.concatUint8Arrays=void 0,e.concatUint8Arrays=function(t){var e,n,i=t.reduce((function(t,e){return t+e.length}),0),o=new Uint8Array(i),s=0;try{for(var a=r(t),u=a.next();!u.done;u=a.next()){var c=u.value;o.set(c,s),s+=c.length}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return o},e.readInt8=function(t,e){return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(e)},e.readUInt16BE=function(t,e){return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint16(e,!1)},e.readUInt32BE=function(t,e){return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(e,!1)},e.readInt32BE=function(t,e){return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt32(e,!1)},e.readFloatBE=function(t,e){return new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat32(e,!1)},e.readDoubleBE=function(t,e){return new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat64(e,!1)},e.writeInt8=function(t,e,r){t[e]=r},e.writeInt32BE=function(t,e,r){new DataView(t.buffer,t.byteOffset,t.byteLength).setInt32(e,r,!1)},e.uint8FromBinary=function(t){for(var e=new Uint8Array(t.length),r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e},e.uint8FromUtf8=function(t){return(new TextEncoder).encode(t)},e.uint8FromBase64="undefined"==typeof window||void 0===window.atob?function(e){return new Uint8Array(t.from(e,"base64"))}:function(t){return new Uint8Array(window.atob(t).split("").map((function(t){return t.charCodeAt(0)})))},e.uint8FromDoubleBE=function(t){var e=new ArrayBuffer(8);return new DataView(e).setFloat64(0,t,!1),new Uint8Array(e)},e.uint8ToAscii=o,e.uint8ToBase64="undefined"==typeof window||void 0===window.btoa?function(e){return t.from(e).toString("base64")}:function(t){return window.btoa(o(t))},e.uint8toUtf8=function(t,e,r){return void 0===e&&(e=0),void 0===r&&(r=t.length),(new TextDecoder).decode(t.subarray(e,r))},e.isEqualUint8Arrays=function(t,e){if(t.length!==e.length)return!1;for(var r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0},e.isUint8Array=function(t){return"function"==typeof Uint8Array&&t instanceof Uint8Array||"[object Uint8Array]"===Object.prototype.toString.call(t)}}).call(this,r(30).Buffer)},function(t,e,r){"use strict";var n,i=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.Locked=e.Disjunction=e.Conjunction=e.NoValueConstraint=e.TopicConstraint=e.CompoundConstraint=e.Unconstrained=e.UpdateConstraintImpl=e.ConstraintValueType=e.ConstraintType=void 0;var o,s=r(0);!function(t){t[t.UNCONSTRAINED=0]="UNCONSTRAINED",t[t.CONJUNCTION=1]="CONJUNCTION",t[t.TOPIC_VALUE=2]="TOPIC_VALUE",t[t.NO_VALUE=3]="NO_VALUE",t[t.LOCKED=4]="LOCKED",t[t.NO_TOPIC=5]="NO_TOPIC",t[t.PARTIAL_JSON=6]="PARTIAL_JSON",t[t.DISJUNCTION=7]="DISJUNCTION"}(o=e.ConstraintType||(e.ConstraintType={})),function(t){t[t.NULL=0]="NULL",t[t.STRING=1]="STRING",t[t.INT64=2]="INT64",t[t.DOUBLE=3]="DOUBLE",t[t.BINARY=4]="BINARY",t[t.JSON=5]="JSON",t[t.RECORD_V2=6]="RECORD_V2",t[t.BOOLEAN=7]="BOOLEAN"}(e.ConstraintValueType||(e.ConstraintValueType={}));var a=function(){function t(t){this.id=t}return t.prototype.and=function(t){if(this===t)throw new s.IllegalArgumentError("Cannot 'and' a constraint with itself");if(this.andBlockedFor(t))throw new s.IllegalArgumentError("Constraint could not be satisfied");return new f(this,t)},t.prototype.or=function(t){if(this===t)throw new s.IllegalArgumentError("Cannot 'or' a constraint with itself");return new h(this,t)},t.prototype.getConstraintType=function(){return this.id},t.prototype.andBlockedFor=function(t){return!1},t}();e.UpdateConstraintImpl=a;var u=function(t){function e(){return t.call(this,o.UNCONSTRAINED)||this}return i(e,t),e}(a);e.Unconstrained=u;var c=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.left=r,i.right=n,i}return i(e,t),e}(a);e.CompoundConstraint=c;var l=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e}(a);e.TopicConstraint=l;var p=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e.prototype.andBlockedFor=function(t){return t instanceof l||t instanceof c&&t.andBlockedFor(this)},e}(l);e.NoValueConstraint=p;var f=function(t){function e(e,r){return t.call(this,o.CONJUNCTION,e,r)||this}return i(e,t),e.prototype.andBlockedFor=function(t){return(t instanceof l||t instanceof e&&t.hasNoValueConstraint())&&this.hasNoValueConstraint()},e.prototype.hasNoValueConstraint=function(){return this.left instanceof p||this.right instanceof p||(this.left instanceof e&&this.left.hasNoValueConstraint()||this.right instanceof e&&this.right.hasNoValueConstraint())},e}(c);e.Conjunction=f;var h=function(t){function e(e,r){return t.call(this,o.DISJUNCTION,e,r)||this}return i(e,t),e}(c);e.Disjunction=h;var d=function(t){function e(e){var r=t.call(this,o.LOCKED)||this;return r.lock=e,r.lockName=e.getName(),r.sequence=e.getSequence(),r}return i(e,t),e.prototype.getLockName=function(){return this.lockName},e.prototype.getSequence=function(){return this.sequence},e}(a);e.Locked=d},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidSetStream=void 0;var n=function(){function t(t,e){this.value=e,this.err=t}return t.prototype.set=function(){return Promise.reject(this.err)},t.prototype.get=function(){return this.value},t.prototype.validate=function(){return Promise.reject(this.err)},t.prototype.onSetComplete=function(){},t.prototype.onSetFailed=function(){},t.prototype.onValidateComplete=function(){},t.prototype.onValidateFailed=function(){},t}();e.InvalidSetStream=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SetStream=void 0;var n=r(8),i=r(12),o=r(5),s=r(3),a=o.create("diffusion.TopicUpdate"),u=function(){function t(t,e,r,n,i){this.streamServices=t,this.options=e,this.stream=r,this.streamId=n,this.cache=i}return t.prototype.set=function(t){var e=this;return this.options.checkOperation(t),new Promise((function(r,i){var o=e.options.toBuffer(e.cache,t);e.cache=t,e.options.deltaService.send(new n.UpdateStreamRequest(e.streamId,o),(function(t){t?(a.debug("Set update stream failed"),e.stream.onSetFailed(t),i(t)):(e.stream.onSetComplete(e.streamId,e.options.retainsValue,e.options.supportsConflation),r())}))}))},t.prototype.get=function(){return this.cache},t.prototype.validate=function(){var t=this;return new Promise((function(e,r){t.streamServices.CHECK_UPDATE_STREAM.send(t.streamId,(function(n){n?(a.debug("Validate update stream failed"),t.stream.onValidateFailed(n),r(n)):(t.stream.onValidateComplete(t.streamId,t.options.retainsValue,t.options.supportsConflation),e(s.TopicCreationResult.EXISTS))}))}))},t.prototype.onSetComplete=function(){},t.prototype.onSetFailed=function(t){this.stream.setDelegate(new i.InvalidSetStream(t,this.cache))},t.prototype.onValidateComplete=function(){},t.prototype.onValidateFailed=function(t){this.stream.setDelegate(new i.InvalidSetStream(t,this.cache))},t}();e.SetStream=u},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MIN_SAFE_INTEGER=e.MAX_SAFE_INTEGER=e.MAX_INT32=e.findNextPowerOfTwo=e.approximateSquareRoot=void 0;var n=r(0);e.approximateSquareRoot=function(t){if(t<0)throw new n.IllegalArgumentError("Value must be great or equal to 0");if(0===t)return 0;var e=32-function(t){if(0===t)return 32;var e=1;return t>>>16==0&&(e+=16,t<<=16),t>>>24==0&&(e+=8,t<<=8),t>>>28==0&&(e+=4,t<<=4),t>>>30==0&&(e+=2,t<<=2),e-=t>>>31}(t);return 1<<Math.round(e/2)},e.findNextPowerOfTwo=function(t){if(t<0||t>1<<30)throw new n.IllegalArgumentError("Illegal argument: "+t);return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},e.MAX_INT32=2147483647,e.MAX_SAFE_INTEGER=9007199254740991,e.MIN_SAFE_INTEGER=-9007199254740991},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.write=e.read=void 0;var n,i,o,s=r(1),a=r(6),u=r(10),c=r(42),l=r(17);e.read=function(t){if(i){var e=t.buffer.subarray(t.pos,t.pos+o);if(u.isEqualUint8Arrays(e,i))return t.readMany(o),n}var r=t.pos,p=a.read(t,l.TopicTypeEnum),f=s.readDictionary(t,s.readString),h=new c.TopicSpecification(p,f);return o=t.pos-r,i=Uint8Array.from(t.buffer.subarray(r,t.pos)),n=Object.freeze(h),h},e.write=function(t,e){a.write(t,e.type),s.writeDictionary(t,e.properties,s.writeString)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TopicTypeEnum=e.TopicType=void 0;var n=r(18),i=function(t,e,r){this.id=t,this.stateful=e,this.functional=r};e.TopicType=i,e.TopicTypeEnum={BINARY:new i(14,!0,!1),JSON:new i(15,!0,!1),STRING:new i(17,!0,!1),INT64:new i(18,!0,!1),DOUBLE:new i(19,!0,!1),TIME_SERIES:new i(16,!0,!1),RECORD_V2:new i(20,!0,!1),UNKNOWN_TOPIC_TYPE:new i(21,!1,!1)},n.enumerize(e.TopicTypeEnum)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.enumerize=void 0,e.enumerize=function(t){Object.keys(t).forEach((function(e){var r=t[e].id;void 0!==r&&(t[r]=e)}))}},function(t,e,r){"use strict";var n,i=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.AddTopicResultSerialiser=e.AddTopicResultSerialiserClass=void 0;var o,s=r(6),a=r(2),u=r(3),c=r(44);!function(t){t[t.CREATED=0]="CREATED",t[t.EXISTS=1]="EXISTS"}(o||(o={}));var l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.read=function(t){var e=s.read(t,o)===o.CREATED?u.TopicCreationResult.CREATED:u.TopicCreationResult.EXISTS;return new c.AddTopicResult(e)},e}(a.AbstractSerialiser);e.AddTopicResultSerialiserClass=l,e.AddTopicResultSerialiser=new l},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PendingSetStream=void 0;var n=r(0),i=r(8),o=r(12),s=r(13),a=r(3),u=r(10),c=function(){function t(t,e,r,n,i){this.streamServices=t,this.options=e,this.stream=r,this.pendingResult=n,this.deferredResolvers=[],this.value=i,this.nextValue=i}return t.prototype.set=function(t){var e=this;return this.options.checkOperation(t),this.nextValue=t,new Promise((function(r,n){e.deferredResolvers.push({value:t,resolve:r,reject:n})}))},t.prototype.get=function(){return this.nextValue},t.prototype.validate=function(){var t=this;return new Promise((function(e,r){t.pendingResult.then((function(t){return e(a.TopicCreationResult.EXISTS),t}),(function(t){r(t)}))}))},t.prototype.onSetComplete=function(t,e,r){var n=this;this.options.retainsValue=e,this.options.supportsConflation=r,e||(this.options.toBuffer=function(t,e){return n.options.dataType.toBytes(e).asArray()},this.options.deltaService=this.streamServices.STREAM_SET_TOPIC_SERVICE),this.stream.setDelegate(new s.SetStream(this.streamServices,this.options,this.stream,t,this.nextValue)),e&&r?this.processPendingUpdatesRetainsValue(t):this.processPendingUpdatesDoesntRetainValue(t)},t.prototype.processPendingUpdatesRetainsValue=function(t){var e=this,r=this.options.dataType.toBytes(this.value).asArray(),n=this.options.dataType.toBytes(this.nextValue).asArray();if(u.isEqualUint8Arrays(r,n))this.deferredResolvers.forEach((function(t){t.resolve()}));else{var o=this.options.toBuffer(this.value,this.nextValue);this.options.deltaService.send(new i.UpdateStreamRequest(t,o),(function(t){t?e.deferredResolvers.forEach((function(e){e.reject(t)})):e.deferredResolvers.forEach((function(t){t.resolve()}))}))}},t.prototype.processPendingUpdatesDoesntRetainValue=function(t){var e=this,r=this.value;this.deferredResolvers.forEach((function(n){var o=e.options.toBuffer(r,n.value);r=n.value,e.options.deltaService.send(new i.UpdateStreamRequest(t,o),(function(t){t?n.reject(t):n.resolve()}))}))},t.prototype.onSetFailed=function(t){this.stream.setDelegate(new o.InvalidSetStream(t,this.nextValue)),this.deferredResolvers.forEach((function(e){e.reject(t)}))},t.prototype.onValidateComplete=function(){throw new n.IllegalStateError("No validate request has been sent")},t.prototype.onValidateFailed=function(){throw new n.IllegalStateError("No validate request has been sent")},t}();e.PendingSetStream=c},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PendingValidateStream=void 0;var n=r(0),i=r(22),o=r(63),s=r(64),a=r(3),u=function(){function t(t,e,r,n){this.streamServices=t,this.options=e,this.stream=r,this.pendingResult=n}return t.prototype.set=function(t){var e=this;return this.options.checkOperation(t),new Promise((function(r,n){e.stream.setDelegate(new o.PendingValidateAndSetStream(e.streamServices,e.options,e.stream,e.pendingResult,{value:t,resolve:r,reject:n},t))}))},t.prototype.get=function(){throw new n.IllegalStateError("The set method has not been called")},t.prototype.validate=function(){var t=this;return new Promise((function(e,r){t.pendingResult.then((function(t){return e(a.TopicCreationResult.EXISTS),t}),(function(t){r(t)}))}))},t.prototype.onSetComplete=function(){throw new n.IllegalStateError("No set request has been sent")},t.prototype.onSetFailed=function(){throw new n.IllegalStateError("No set request has been sent")},t.prototype.onValidateComplete=function(t,e,r){var n=this;this.options.retainsValue=e,this.options.supportsConflation=r,e||(this.options.toBuffer=function(t,e){return n.options.dataType.toBytes(e).asArray()},this.options.deltaService=this.streamServices.STREAM_SET_TOPIC_SERVICE),this.stream.setDelegate(new s.ValidatedStream(this.streamServices,this.options,this.stream,t))},t.prototype.onValidateFailed=function(t){this.stream.setDelegate(new i.InvalidUnsetStream(t))},t}();e.PendingValidateStream=u},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidUnsetStream=void 0;var n=r(0),i=function(){function t(t){this.err=t}return t.prototype.set=function(){return Promise.reject(this.err)},t.prototype.get=function(){throw new n.IllegalStateError("No value has been set")},t.prototype.validate=function(){return Promise.reject(this.err)},t.prototype.onSetComplete=function(){},t.prototype.onSetFailed=function(){},t.prototype.onValidateComplete=function(){},t.prototype.onValidateFailed=function(){},t}();e.InvalidUnsetStream=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.responseSuccess=void 0,e.responseSuccess=function(t,e){return!t}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),void 0===window._diffusion_features&&(window._diffusion_features={client_control:{},gateway_control:{},log_retrieval:{},messages:{},metrics:{},ping:{},remote_servers:{},replace_license:{},security:{},session_lock:{},session_trees:{},topic_control:{},topic_notifications:{},topic_update:{},topic_views:{},time_series:{}});var n=r(25);window._diffusion_features.topic_update.TopicUpdateImpl=n.TopicUpdateImpl},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TopicUpdateImpl=void 0;var n=r(0),i=r(26),o=r(11),s=r(58),a=r(5),u=r(69),c=a.create("Session.TopicUpdate"),l=new o.Unconstrained,p=function(){function t(t){this.internal=t;var e=t.getServiceLocator();this.SET_TOPIC=e.obtain(i.SET_TOPIC),this.ADD_AND_SET_TOPIC=e.obtain(i.ADD_AND_SET_TOPIC),this.APPLY_JSON_PATCH=e.obtain(i.APPLY_JSON_PATCH);var r={CREATE_UPDATE_STREAM:e.obtain(i.CREATE_UPDATE_STREAM),CREATE_UPDATE_STREAM_AND_SET:e.obtain(i.CREATE_UPDATE_STREAM_AND_SET),CHECK_UPDATE_STREAM:e.obtain(i.CHECK_UPDATE_STREAM),STREAM_SET_TOPIC_SERVICE:e.obtain(i.STREAM_SET_TOPIC_SERVICE),STREAM_APPLY_DELTA_SERVICE:e.obtain(i.STREAM_APPLY_DELTA_SERVICE),STREAM_ADD_TOPIC_SERVICE:e.obtain(i.STREAM_ADD_TOPIC_SERVICE),STREAM_ADD_AND_SET_TOPIC_SERVICE:e.obtain(i.STREAM_ADD_AND_SET_TOPIC_SERVICE)};this.updateStreamFactory=new s.UpdateStreamFactory(r,t.getContext())}return t.prototype.setTopic=function(t,e,r,n){var i=this;return new Promise((function(o,s){var a=i.internal.getContext().TopicTypeEnum;i.SET_TOPIC.send({path:t,topicType:a[e.name().toUpperCase()],value:e.toBytes(r).asArray(),constraint:n},(function(t){t?(c.debug("Set topic failed"),s(t)):o()}))}))},t.prototype.addAndSetTopic=function(t,e,r,i,o){var s=this,a=this.internal.getContext().TopicTypeEnum;if(e.type!==a[r.name().toUpperCase()]&&e.type!==a.TIME_SERIES)throw new n.IllegalArgumentError("The specification and value have different data types");var u=r.toBytes(i).asArray();return new Promise((function(r,n){s.ADD_AND_SET_TOPIC.send({path:t,topicSpecification:e,value:u,constraint:o},(function(t,e){t?(c.debug("Add and set topic failed"),n(t)):r(e.result)}))}))},t.prototype.set=function(t,e,r,n){var i=void 0!==n&&void 0!==n.constraint?n.constraint:l;return void 0!==n&&void 0!==n.specification?this.addAndSetTopic(t,n.specification,e,r,i):this.setTopic(t,e,r,i)},t.prototype.createUpdateStream=function(t,e,r){var n,i=null!==(n=null==r?void 0:r.constraint)&&void 0!==n?n:l;return void 0!==r&&void 0!==r.specification?this.updateStreamFactory.createUpdateStreamThatAddsTopic(t,r.specification,e,i):this.updateStreamFactory.createUpdateStream(t,e,i)},t.prototype.newUpdateStreamBuilder=function(){return new u.UpdateStreamBuilderImpl(this.internal.getContext(),this.updateStreamFactory)},t.prototype.applyJsonPatch=function(t,e,r){var n=this;return new Promise((function(i,o){n.APPLY_JSON_PATCH.send({path:t,patch:"string"==typeof e?e:JSON.stringify(e),constraint:r||l},(function(t,e){t?(c.debug("Apply JSON patch failed"),o(t)):i(e)}))}))},t}();e.TopicUpdateImpl=p},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.STREAM_ADD_AND_SET_TOPIC_SERVICE=e.STREAM_ADD_TOPIC_SERVICE=e.STREAM_APPLY_DELTA_SERVICE=e.STREAM_SET_TOPIC_SERVICE=e.CHECK_UPDATE_STREAM=e.CREATE_UPDATE_STREAM_AND_SET=e.CREATE_UPDATE_STREAM=e.APPLY_JSON_PATCH=e.ADD_AND_SET_TOPIC=e.SET_TOPIC=void 0;var n=r(27),i=r(28),o=r(19),s=r(45),a=r(46),u=r(47),c=r(48),l=r(51),p=r(53),f=r(54),h=r(55),d=r(7),y=r(57);e.SET_TOPIC={id:118,request:p.SetTopicRequestSerialiser,response:n.NullSerialiser},e.ADD_AND_SET_TOPIC={id:122,request:i.AddAndSetTopicRequestSerialiser,response:o.AddTopicResultSerialiser},e.APPLY_JSON_PATCH={id:151,request:s.ApplyJsonPatchRequestSerialiser,response:l.JsonPatchResultSerialiser},e.CREATE_UPDATE_STREAM={id:125,request:u.CreateUpdateStreamRequestSerialiser,response:c.CreateUpdateStreamResponseSerialiser},e.CREATE_UPDATE_STREAM_AND_SET={id:126,request:a.CreateUpdateStreamAndSetRequestSerialiser,response:c.CreateUpdateStreamResponseSerialiser},e.CHECK_UPDATE_STREAM={id:127,request:d.UpdateStreamIdSerialiser,response:n.NullSerialiser},e.STREAM_SET_TOPIC_SERVICE={id:128,request:y.UpdateStreamRequestSerialiser,response:n.NullSerialiser},e.STREAM_APPLY_DELTA_SERVICE={id:129,request:y.UpdateStreamRequestSerialiser,response:n.NullSerialiser},e.STREAM_ADD_TOPIC_SERVICE={id:130,request:f.UpdateStreamAddTopicRequestSerialiser,response:h.UpdateStreamAddTopicResponseSerialiser},e.STREAM_ADD_AND_SET_TOPIC_SERVICE={id:131,request:i.AddAndSetTopicRequestSerialiser,response:h.UpdateStreamAddTopicResponseSerialiser}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NullSerialiser=void 0,e.NullSerialiser={read:function(){return null},write:function(){}}},function(t,e,r){"use strict";var n,i=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.AddAndSetTopicRequestSerialiser=e.AddAndSetTopicRequestSerialiserClass=void 0;var o=r(1),s=r(2),a=r(4),u=r(16),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.write=function(t,e){o.writeString(t,e.path),u.write(t,e.topicSpecification),o.writeBytes(t,e.value),a.write(t,e.constraint)},e}(s.AbstractSerialiser);e.AddAndSetTopicRequestSerialiserClass=c,e.AddAndSetTopicRequestSerialiser=new c},function(t,e){t.exports=n;var r=null;try{r=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(t){}function n(t,e,r){this.low=0|t,this.high=0|e,this.unsigned=!!r}function i(t){return!0===(t&&t.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=i;var o={},s={};function a(t,e){var r,n,i;return e?(i=0<=(t>>>=0)&&t<256)&&(n=s[t])?n:(r=c(t,(0|t)<0?-1:0,!0),i&&(s[t]=r),r):(i=-128<=(t|=0)&&t<128)&&(n=o[t])?n:(r=c(t,t<0?-1:0,!1),i&&(o[t]=r),r)}function u(t,e){if(isNaN(t))return e?S:g;if(e){if(t<0)return S;if(t>=d)return T}else{if(t<=-y)return A;if(t+1>=y)return m}return t<0?u(-t,e).neg():c(t%h|0,t/h|0,e)}function c(t,e,r){return new n(t,e,r)}n.fromInt=a,n.fromNumber=u,n.fromBits=c;var l=Math.pow;function p(t,e,r){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return g;if("number"==typeof e?(r=e,e=!1):e=!!e,(r=r||10)<2||36<r)throw RangeError("radix");var n;if((n=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return p(t.substring(1),e,r).neg();for(var i=u(l(r,8)),o=g,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),c=parseInt(t.substring(s,s+a),r);if(a<8){var f=u(l(r,a));o=o.mul(f).add(u(c))}else o=(o=o.mul(i)).add(u(c))}return o.unsigned=e,o}function f(t,e){return"number"==typeof t?u(t,e):"string"==typeof t?p(t,e):c(t.low,t.high,"boolean"==typeof e?e:t.unsigned)}n.fromString=p,n.fromValue=f;var h=4294967296,d=h*h,y=d/2,v=a(1<<24),g=a(0);n.ZERO=g;var S=a(0,!0);n.UZERO=S;var w=a(1);n.ONE=w;var E=a(1,!0);n.UONE=E;var _=a(-1);n.NEG_ONE=_;var m=c(-1,2147483647,!1);n.MAX_VALUE=m;var T=c(-1,-1,!0);n.MAX_UNSIGNED_VALUE=T;var A=c(0,-2147483648,!1);n.MIN_VALUE=A;var b=n.prototype;b.toInt=function(){return this.unsigned?this.low>>>0:this.low},b.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},b.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(A)){var e=u(t),r=this.div(e),n=r.mul(e).sub(this);return r.toString(t)+n.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var i=u(l(t,6),this.unsigned),o=this,s="";;){var a=o.div(i),c=(o.sub(a.mul(i)).toInt()>>>0).toString(t);if((o=a).isZero())return c+s;for(;c.length<6;)c="0"+c;s=""+c+s}},b.getHighBits=function(){return this.high},b.getHighBitsUnsigned=function(){return this.high>>>0},b.getLowBits=function(){return this.low},b.getLowBitsUnsigned=function(){return this.low>>>0},b.getNumBitsAbs=function(){if(this.isNegative())return this.eq(A)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&0==(t&1<<e);e--);return 0!=this.high?e+33:e+1},b.isZero=function(){return 0===this.high&&0===this.low},b.eqz=b.isZero,b.isNegative=function(){return!this.unsigned&&this.high<0},b.isPositive=function(){return this.unsigned||this.high>=0},b.isOdd=function(){return 1==(1&this.low)},b.isEven=function(){return 0==(1&this.low)},b.equals=function(t){return i(t)||(t=f(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},b.eq=b.equals,b.notEquals=function(t){return!this.eq(t)},b.neq=b.notEquals,b.ne=b.notEquals,b.lessThan=function(t){return this.comp(t)<0},b.lt=b.lessThan,b.lessThanOrEqual=function(t){return this.comp(t)<=0},b.lte=b.lessThanOrEqual,b.le=b.lessThanOrEqual,b.greaterThan=function(t){return this.comp(t)>0},b.gt=b.greaterThan,b.greaterThanOrEqual=function(t){return this.comp(t)>=0},b.gte=b.greaterThanOrEqual,b.ge=b.greaterThanOrEqual,b.compare=function(t){if(i(t)||(t=f(t)),this.eq(t))return 0;var e=this.isNegative(),r=t.isNegative();return e&&!r?-1:!e&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},b.comp=b.compare,b.negate=function(){return!this.unsigned&&this.eq(A)?A:this.not().add(w)},b.neg=b.negate,b.add=function(t){i(t)||(t=f(t));var e=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,s=t.high>>>16,a=65535&t.high,u=t.low>>>16,l=0,p=0,h=0,d=0;return h+=(d+=o+(65535&t.low))>>>16,p+=(h+=n+u)>>>16,l+=(p+=r+a)>>>16,l+=e+s,c((h&=65535)<<16|(d&=65535),(l&=65535)<<16|(p&=65535),this.unsigned)},b.subtract=function(t){return i(t)||(t=f(t)),this.add(t.neg())},b.sub=b.subtract,b.multiply=function(t){if(this.isZero())return g;if(i(t)||(t=f(t)),r)return c(r.mul(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned);if(t.isZero())return g;if(this.eq(A))return t.isOdd()?A:g;if(t.eq(A))return this.isOdd()?A:g;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(v)&&t.lt(v))return u(this.toNumber()*t.toNumber(),this.unsigned);var e=this.high>>>16,n=65535&this.high,o=this.low>>>16,s=65535&this.low,a=t.high>>>16,l=65535&t.high,p=t.low>>>16,h=65535&t.low,d=0,y=0,S=0,w=0;return S+=(w+=s*h)>>>16,y+=(S+=o*h)>>>16,S&=65535,y+=(S+=s*p)>>>16,d+=(y+=n*h)>>>16,y&=65535,d+=(y+=o*p)>>>16,y&=65535,d+=(y+=s*l)>>>16,d+=e*h+n*p+o*l+s*a,c((S&=65535)<<16|(w&=65535),(d&=65535)<<16|(y&=65535),this.unsigned)},b.mul=b.multiply,b.divide=function(t){if(i(t)||(t=f(t)),t.isZero())throw Error("division by zero");var e,n,o;if(r)return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?c((this.unsigned?r.div_u:r.div_s)(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?S:g;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return S;if(t.gt(this.shru(1)))return E;o=S}else{if(this.eq(A))return t.eq(w)||t.eq(_)?A:t.eq(A)?w:(e=this.shr(1).div(t).shl(1)).eq(g)?t.isNegative()?w:_:(n=this.sub(t.mul(e)),o=e.add(n.div(t)));if(t.eq(A))return this.unsigned?S:g;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();o=g}for(n=this;n.gte(t);){e=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(e)/Math.LN2),a=s<=48?1:l(2,s-48),p=u(e),h=p.mul(t);h.isNegative()||h.gt(n);)h=(p=u(e-=a,this.unsigned)).mul(t);p.isZero()&&(p=w),o=o.add(p),n=n.sub(h)}return o},b.div=b.divide,b.modulo=function(t){return i(t)||(t=f(t)),r?c((this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},b.mod=b.modulo,b.rem=b.modulo,b.not=function(){return c(~this.low,~this.high,this.unsigned)},b.and=function(t){return i(t)||(t=f(t)),c(this.low&t.low,this.high&t.high,this.unsigned)},b.or=function(t){return i(t)||(t=f(t)),c(this.low|t.low,this.high|t.high,this.unsigned)},b.xor=function(t){return i(t)||(t=f(t)),c(this.low^t.low,this.high^t.high,this.unsigned)},b.shiftLeft=function(t){return i(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?c(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):c(0,this.low<<t-32,this.unsigned)},b.shl=b.shiftLeft,b.shiftRight=function(t){return i(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?c(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):c(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},b.shr=b.shiftRight,b.shiftRightUnsigned=function(t){if(i(t)&&(t=t.toInt()),0===(t&=63))return this;var e=this.high;return t<32?c(this.low>>>t|e<<32-t,e>>>t,this.unsigned):c(32===t?e:e>>>t-32,0,this.unsigned)},b.shru=b.shiftRightUnsigned,b.shr_u=b.shiftRightUnsigned,b.toSigned=function(){return this.unsigned?c(this.low,this.high,!1):this},b.toUnsigned=function(){return this.unsigned?this:c(this.low,this.high,!0)},b.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},b.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},b.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},n.fromBytes=function(t,e,r){return r?n.fromBytesLE(t,e):n.fromBytesBE(t,e)},n.fromBytesLE=function(t,e){return new n(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)},n.fromBytesBE=function(t,e){return new n(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)}},function(t,e,r){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var n=r(31),i=r(32),o=r(33);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return p(this,t)}return c(this,t,e,r)}function c(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=f(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,r),i=(t=a(t,n)).write(e,r);i!==n&&(t=t.slice(0,i));return t}(t,e,r):function(t,e){if(u.isBuffer(e)){var r=0|h(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):f(t,e);if("Buffer"===e.type&&o(e.data))return f(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function p(t,e){if(l(e),t=a(t,e<0?0:0|h(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function f(t,e){var r=e.length<0?0:0|h(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function h(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function d(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return x(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(n)return x(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return R(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return b(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:S(t,e,r,n,i);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):S(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function S(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var l=-1;for(o=r;o<a;o++)if(c(t,o)===c(e,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===u)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var p=!0,f=0;f<u;f++)if(c(t,o+f)!==c(e,f)){p=!1;break}if(p)return o}return-1}function w(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function E(t,e,r,n){return Y(x(e,t.length-r),t,r,n)}function _(t,e,r,n){return Y(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function m(t,e,r,n){return _(t,e,r,n)}function T(t,e,r,n){return Y(F(e),t,r,n)}function A(t,e,r,n){return Y(function(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function b(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function R(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,s,a,u,c=t[i],l=null,p=c>239?4:c>223?3:c>191?2:1;if(i+p<=r)switch(p){case 1:c<128&&(l=c);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,p=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=p}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return c(null,t,e,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,r){return function(t,e,r,n){return l(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},u.allocUnsafe=function(t){return p(null,t)}