web-dc-api 0.0.87 → 0.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/protobuf-BVBdi7Hh.js +1 -0
- package/dist/dc.min.js +1 -19
- package/dist/esm/chunks/protobuf-CbxDm-Gy.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/index.d.ts +947 -886
- package/package.json +14 -17
- package/dist/index.cjs.js +0 -19
- package/dist/index.esm.js +0 -19
- package/lib/common/blowfish/block.ts +0 -259
- package/lib/common/blowfish/cipher.ts +0 -144
- package/lib/common/blowfish/const.ts +0 -195
- package/lib/common/chain.ts +0 -469
- package/lib/common/commonclient.ts +0 -202
- package/lib/common/constants.ts +0 -55
- package/lib/common/dc-key/ed25519.ts +0 -343
- package/lib/common/dc-key/keyManager.ts +0 -424
- package/lib/common/dcapi.ts +0 -98
- package/lib/common/dcutil.ts +0 -595
- package/lib/common/define.ts +0 -66
- package/lib/common/error.ts +0 -67
- package/lib/common/grpc-dc.ts +0 -104
- package/lib/common/module-system.ts +0 -184
- package/lib/common/service-worker.ts +0 -234
- package/lib/common/types/types.ts +0 -344
- package/lib/dc.ts +0 -694
- package/lib/implements/account/client.ts +0 -185
- package/lib/implements/account/manager.ts +0 -683
- package/lib/implements/aiproxy/client.ts +0 -357
- package/lib/implements/aiproxy/manager.ts +0 -670
- package/lib/implements/cache/client.ts +0 -105
- package/lib/implements/cache/manager.ts +0 -127
- package/lib/implements/comment/client.ts +0 -982
- package/lib/implements/comment/manager.ts +0 -1151
- package/lib/implements/dc/client.ts +0 -51
- package/lib/implements/dc/manager.ts +0 -33
- package/lib/implements/file/client.ts +0 -253
- package/lib/implements/file/file-cache-manager.ts +0 -142
- package/lib/implements/file/manager.ts +0 -1240
- package/lib/implements/file/seekableFileStream.ts +0 -344
- package/lib/implements/file/streamwriter.ts +0 -322
- package/lib/implements/keyvalue/client.ts +0 -376
- package/lib/implements/keyvalue/manager.ts +0 -759
- package/lib/implements/message/client.ts +0 -250
- package/lib/implements/message/manager.ts +0 -215
- package/lib/implements/threaddb/cbor/coding.ts +0 -62
- package/lib/implements/threaddb/cbor/event.ts +0 -336
- package/lib/implements/threaddb/cbor/node.ts +0 -542
- package/lib/implements/threaddb/cbor/record.ts +0 -398
- package/lib/implements/threaddb/common/AsyncMutex.ts +0 -24
- package/lib/implements/threaddb/common/addrinfo.ts +0 -135
- package/lib/implements/threaddb/common/dispatcher.ts +0 -81
- package/lib/implements/threaddb/common/idbstore-adapter.ts +0 -260
- package/lib/implements/threaddb/common/json-patcher.ts +0 -204
- package/lib/implements/threaddb/common/key.ts +0 -290
- package/lib/implements/threaddb/common/level-adapter.ts +0 -235
- package/lib/implements/threaddb/common/lineReader.ts +0 -79
- package/lib/implements/threaddb/common/logstore.ts +0 -215
- package/lib/implements/threaddb/common/transformed-datastore.ts +0 -308
- package/lib/implements/threaddb/core/app.ts +0 -202
- package/lib/implements/threaddb/core/core.ts +0 -230
- package/lib/implements/threaddb/core/db.ts +0 -249
- package/lib/implements/threaddb/core/event.ts +0 -54
- package/lib/implements/threaddb/core/head.ts +0 -89
- package/lib/implements/threaddb/core/identity.ts +0 -171
- package/lib/implements/threaddb/core/logstore.ts +0 -137
- package/lib/implements/threaddb/core/options.ts +0 -14
- package/lib/implements/threaddb/core/record.ts +0 -54
- package/lib/implements/threaddb/db/collection.ts +0 -1910
- package/lib/implements/threaddb/db/db.ts +0 -698
- package/lib/implements/threaddb/db/json2Query.ts +0 -192
- package/lib/implements/threaddb/db/query.ts +0 -524
- package/lib/implements/threaddb/dbclient.ts +0 -443
- package/lib/implements/threaddb/dbmanager.ts +0 -1901
- package/lib/implements/threaddb/lsstoreds/addr_book.ts +0 -452
- package/lib/implements/threaddb/lsstoreds/cache.ts +0 -36
- package/lib/implements/threaddb/lsstoreds/cyclic_batch.ts +0 -87
- package/lib/implements/threaddb/lsstoreds/global.ts +0 -151
- package/lib/implements/threaddb/lsstoreds/headbook.ts +0 -280
- package/lib/implements/threaddb/lsstoreds/keybook.ts +0 -297
- package/lib/implements/threaddb/lsstoreds/logstore.ts +0 -29
- package/lib/implements/threaddb/lsstoreds/metadata.ts +0 -223
- package/lib/implements/threaddb/net/define.ts +0 -138
- package/lib/implements/threaddb/net/grpcClient.ts +0 -582
- package/lib/implements/threaddb/net/grpcserver.ts +0 -146
- package/lib/implements/threaddb/net/net.ts +0 -2006
- package/lib/implements/threaddb/pb/lstore.proto +0 -38
- package/lib/implements/threaddb/pb/lstore.ts +0 -393
- package/lib/implements/threaddb/pb/lstore_pb.d.ts +0 -433
- package/lib/implements/threaddb/pb/lstore_pb.js +0 -1085
- package/lib/implements/threaddb/pb/net.proto +0 -194
- package/lib/implements/threaddb/pb/net_pb.d.ts +0 -2349
- package/lib/implements/threaddb/pb/net_pb.js +0 -5525
- package/lib/implements/threaddb/pb/proto-custom-types.ts +0 -212
- package/lib/implements/util/client.ts +0 -72
- package/lib/implements/util/manager.ts +0 -146
- package/lib/implements/wallet/manager.ts +0 -664
- package/lib/index.ts +0 -57
- package/lib/interfaces/DCContext.ts +0 -51
- package/lib/interfaces/aiproxy-interface.ts +0 -145
- package/lib/interfaces/auth-interface.ts +0 -118
- package/lib/interfaces/cache-interface.ts +0 -22
- package/lib/interfaces/client-interface.ts +0 -11
- package/lib/interfaces/comment-interface.ts +0 -167
- package/lib/interfaces/database-interface.ts +0 -169
- package/lib/interfaces/file-interface.ts +0 -120
- package/lib/interfaces/index.ts +0 -10
- package/lib/interfaces/keyvalue-interface.ts +0 -156
- package/lib/interfaces/message-interface.ts +0 -22
- package/lib/interfaces/util-interface.ts +0 -31
- package/lib/modules/aiproxy-module.ts +0 -246
- package/lib/modules/auth-module.ts +0 -753
- package/lib/modules/cache-module.ts +0 -99
- package/lib/modules/client-module.ts +0 -71
- package/lib/modules/comment-module.ts +0 -429
- package/lib/modules/database-module.ts +0 -598
- package/lib/modules/file-module.ts +0 -291
- package/lib/modules/index.ts +0 -13
- package/lib/modules/keyvalue-module.ts +0 -379
- package/lib/modules/message-module.ts +0 -107
- package/lib/modules/util-module.ts +0 -148
- package/lib/polyfills/process-env-browser.ts +0 -1
- package/lib/proto/datasource.ts +0 -93
- package/lib/proto/dcnet.proto +0 -1601
- package/lib/proto/dcnet_proto.d.ts +0 -22857
- package/lib/proto/dcnet_proto.js +0 -55204
- package/lib/proto/dcnet_proto_sparse.js +0 -55166
- package/lib/proto/oidfetch.proto +0 -25
- package/lib/proto/oidfetch_proto.d.ts +0 -585
- package/lib/proto/oidfetch_proto.js +0 -1247
- package/lib/serverless/babel-browser.ts +0 -39
- package/lib/serverless/base_entity.ts +0 -78
- package/lib/serverless/base_repository.ts +0 -414
- package/lib/serverless/browser_schema_extractor.ts +0 -283
- package/lib/serverless/decorator_factory.ts +0 -322
- package/lib/util/BrowserLineReader.ts +0 -73
- package/lib/util/base64.ts +0 -105
- package/lib/util/bcrypt.ts +0 -206
- package/lib/util/curve25519Encryption.ts +0 -418
- package/lib/util/dccrypt.ts +0 -73
- package/lib/util/logger.ts +0 -104
- package/lib/util/utils.ts +0 -289
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("@multiformats/multiaddr"),t=require("@polkadot/api"),r=require("@libp2p/peer-id"),n=require("@libp2p/crypto"),o=require("./protobuf-BVBdi7Hh.js"),i=require("protobufjs"),s=require("@stablelib/random"),a=require("tweetnacl"),c=require("jsbn"),u=require("datastore-idb"),l=require("blockstore-idb"),d=require("@libp2p/interface"),h=require("process"),p=require("uint8arrays"),y=require("helia"),f=require("libp2p"),g=require("@helia/block-brokers"),b=require("grpc-libp2p-client"),m=require("@scure/bip39"),w=require("@scure/bip32"),v=require("@textile/threads-id"),k=require("@helia/unixfs"),S=require("it-to-buffer"),O=require("google-protobuf"),A=require("lru-cache"),I=require("async-mutex");require("ulid");var x=require("@helia/dag-cbor"),P=require("@ipld/dag-cbor"),E=require("ajv"),C=require("jose"),B=require("jwt-decode"),T=require("multiformats");function D(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}function R(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}var j=D(i),N=D(p),U=D(O),K=D(P);function q(e,t){this.v=e,this.k=t}function L(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}function _(e){var t={},r=!1;function n(t,n){return r=!0,n=new Promise((function(r){r(e[t](n))})),{done:!1,value:new q(n,1)}}return t["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},t.next=function(e){return r?(r=!1,e):n("next",e)},"function"==typeof e.throw&&(t.throw=function(e){if(r)throw r=!1,e;return n("throw",e)}),"function"==typeof e.return&&(t.return=function(e){return r?(r=!1,e):n("return",e)}),t}function M(e){var t,r,n,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new F(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function F(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return F=function(e){this.s=e,this.n=e.next},F.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new F(e)}function z(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function G(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){z(i,n,o,s,a,"next",e)}function a(e){z(i,n,o,s,a,"throw",e)}s(void 0)}))}}function V(e){return new q(e,0)}function H(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function W(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},J.apply(null,arguments)}function $(e){if(null==e)throw new TypeError("Cannot destructure "+e)}function Y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Z(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(r),!0).forEach((function(t){W(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Y(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Q(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},X(e,t)}function ee(e){return function(){return new te(e.apply(this,arguments))}}function te(e){var t,r;function n(t,r){try{var i=e[t](r),s=i.value,a=s instanceof q;Promise.resolve(a?s.v:s).then((function(r){if(a){var c="return"===t?"return":"next";if(!s.k||r.done)return n(c,r);r=e[c](r).value}o(i.done?"return":"normal",r)}),(function(e){n("throw",e)}))}catch(e){o("throw",e)}}function o(e,o){switch(e){case"return":t.resolve({value:o,done:!0});break;case"throw":t.reject(o);break;default:t.resolve({value:o,done:!1})}(t=t.next)?n(t.key,t.arg):r=null}this._invoke=function(e,o){return new Promise((function(i,s){var a={key:e,arg:o,resolve:i,reject:s,next:null};r?r=r.next=a:(t=r=a,n(e,o))}))},"function"!=typeof e.return&&(this.return=void 0)}function re(){re=function(e,t){return new r(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function r(e,n,o){var i=RegExp(e,n);return t.set(i,o||t.get(e)),X(i,r.prototype)}function n(e,r){var n=t.get(r);return Object.keys(n).reduce((function(t,r){var o=n[r];if("number"==typeof o)t[r]=e[o];else{for(var i=0;void 0===e[o[i]]&&i+1<o.length;)i++;t[r]=e[o[i]]}return t}),Object.create(null))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}(r,RegExp),r.prototype.exec=function(t){var r=e.exec.call(this,t);if(r){r.groups=n(r,this);var o=r.indices;o&&(o.groups=n(o,this))}return r},r.prototype[Symbol.replace]=function(r,o){if("string"==typeof o){var i=t.get(this);return e[Symbol.replace].call(this,r,o.replace(/\$<([^>]+)(>|$)/g,(function(e,t,r){if(""===r)return e;var n=i[t];return Array.isArray(n)?"$"+n.join("$"):"number"==typeof n?"$"+n:""})))}if("function"==typeof o){var s=this;return e[Symbol.replace].call(this,r,(function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(n(e,s)),o.apply(this,e)}))}return e[Symbol.replace].call(this,r,o)},re.apply(this,arguments)}function ne(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}te.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},te.prototype.next=function(e){return this._invoke("next",e)},te.prototype.throw=function(e){return this._invoke("throw",e)},te.prototype.return=function(e){return this._invoke("return",e)};var oe=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(255!==r[s])throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function d(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,o=0;e[t]===c;)n++,t++;for(var i=(e.length-t)*u+1>>>0,s=new Uint8Array(i);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var d=0,h=i-1;(0!==l||d<o)&&-1!==h;h--,d++)l+=a*s[h]>>>0,s[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=d,t++}if(" "!==e[t]){for(var p=i-o;p!==i&&0===s[p];)p++;for(var y=new Uint8Array(n+(i-p)),f=n;p!==i;)y[f++]=s[p++];return y}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*l+1>>>0,u=new Uint8Array(s);o!==i;){for(var d=t[o],h=0,p=s-1;(0!==d||h<n)&&-1!==p;p--,h++)d+=256*u[p]>>>0,u[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");n=h,o++}for(var y=s-n;y!==s&&0===u[y];)y++;for(var f=c.repeat(r);y<s;++y)f+=e.charAt(u[y]);return f},decodeUnsafe:d,decode:function(e){var r=d(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}},ie=oe;let se=class{constructor(e,t,r){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}},ae=class{constructor(e,t,r){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseDecode",void 0),W(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t;var n=t.codePointAt(0);if(void 0===n)throw new Error("Invalid prefix character");this.prefixCodePoint=n,this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return ue(this,e)}},ce=class{constructor(e){W(this,"decoders",void 0),this.decoders=e}or(e){return ue(this,e)}decode(e){var t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}};function ue(e,t){var r,n;return new ce(Z(Z({},null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e}),null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}))}let le=class{constructor(e,t,r,n){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseEncode",void 0),W(this,"baseDecode",void 0),W(this,"encoder",void 0),W(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new se(e,t,r),this.decoder=new ae(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function de(e){var{name:t,prefix:r,encode:n,decode:o}=e;return new le(t,r,n,o)}function he(e){var{name:t,prefix:r,alphabet:n}=e,{encode:o,decode:i}=ie(n,t);return de({prefix:r,name:t,encode:o,decode:e=>ne(i(e))})}function pe(e){var{name:t,prefix:r,bitsPerChar:n,alphabet:o}=e,i=function(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=r;return t}(o);return de({prefix:r,name:t,encode:e=>function(e,t,r){for(var n="="===t[t.length-1],o=(1<<r)-1,i="",s=0,a=0,c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)i+=t[o&a>>(s-=r)];if(0!==s&&(i+=t[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}(e,o,n),decode:e=>function(e,t,r,n){for(var o=e.length;"="===e[o-1];)--o;for(var i=new Uint8Array(o*r/8|0),s=0,a=0,c=0,u=0;u<o;++u){var l=t[e[u]];if(void 0===l)throw new SyntaxError("Non-".concat(n," character"));a=a<<r|l,(s+=r)>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||255&a<<8-s)throw new SyntaxError("Unexpected end of data");return i}(e,i,n,t)})}var ye=pe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fe=pe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ge=pe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),be=pe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),me=pe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),we=pe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ve=pe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ke=pe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Se=pe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Oe=Object.freeze({__proto__:null,base32:ye,base32hex:me,base32hexpad:ve,base32hexpadupper:ke,base32hexupper:we,base32pad:ge,base32padupper:be,base32upper:fe,base32z:Se});var Ae,Ie="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",xe=(Ae=parseInt((/msie (\d+)/.exec(Ie)||[])[1],10),isNaN(Ae)?(Ae=parseInt((/trident\/.*; rv:(\d+)/.exec(Ie)||[])[1],10),!isNaN(Ae)&&Ae):Ae);var Pe=function(){if("undefined"!=typeof window){var e=window.crypto||window.msCrypto;if(!e){if(function(e,t){return!1!==xe&&xe<t}(0,11))return function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return e.getRandomValues(new Uint32Array(1))[0]}}return"undefined"!=typeof global&&global.crypto?function(){return global.crypto.randomBytes(4).readInt32LE()}:function(){return __non_webpack_require__("crypto").randomBytes(4).readInt32LE()}}(),Ee={stringify(e){for(var t=e.nSigBytes,r=e.words,n=[],o=0;o<t;o++){var i=r[o>>>2]>>>24-o%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse(e){var t=e.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(e))throw new Error("Invalid Hex string: ".concat(e));for(var r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new Ce(r,t/2)}};let Ce=class e{constructor(t,r){if(Array.isArray(t)||!t)return this._words=Array.isArray(t)?t:[],void(this._nSignificantBytes="number"==typeof r?r:4*this._words.length);if(t instanceof e)return this._words=t.words.slice(),void(this._nSignificantBytes=t.nSigBytes);var n;try{t instanceof ArrayBuffer?n=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(e){throw new Error("Invalid argument")}if(!n)throw new Error("Invalid argument");for(var o=n.byteLength,i=[],s=0;s<o;s++)i[s>>>2]|=n[s]<<24-s%4*8;this._words=i,this._nSignificantBytes=o}get nSigBytes(){return this._nSignificantBytes}set nSigBytes(e){this._nSignificantBytes=e}get words(){return this._words}toString(e){return e?e.stringify(this):Ee.stringify(this)}toUint8Array(){for(var e=this._words,t=this._nSignificantBytes,r=new Uint8Array(t),n=0;n<t;n++)r[n]=e[n>>>2]>>>24-n%4*8&255;return r}concat(e){var t=e.words.slice(),r=e.nSigBytes;if(this.clamp(),this._nSignificantBytes%4)for(var n=0;n<r;n++){var o=t[n>>>2]>>>24-n%4*8&255;this._words[this._nSignificantBytes+n>>>2]|=o<<24-(this._nSignificantBytes+n)%4*8}else for(var i=0;i<r;i+=4)this._words[this._nSignificantBytes+i>>>2]=t[i>>>2];return this._nSignificantBytes+=r,this}clamp(){var e=this._nSignificantBytes;this._words[e>>>2]&=4294967295<<32-e%4*8,this._words.length=Math.ceil(e/4)}clone(){return new e(this._words.slice(),this._nSignificantBytes)}static random(t){for(var r=[],n=0;n<t;n+=4)r.push(Pe());return new e(r,t)}};class Be{constructor(e,t){this.high=e,this.low=t}clone(){return new Be(this.high,this.low)}}class Te{constructor(e,t){this._words=e||[],this._nSignificantBytes="number"==typeof t?t:8*this._words.length}get nSigBytes(){return this._nSignificantBytes}set nSigBytes(e){this._nSignificantBytes=e}get words(){return this._words}to32(){for(var e=[],t=0;t<this._words.length;t++){var r=this._words[t];e.push(r.high),e.push(r.low)}return new Ce(e,this._nSignificantBytes)}toString(e){return e?e.stringify(this.to32()):Ee.stringify(this.to32())}clone(){for(var e=this._words.slice(),t=0;t<e.length;t++)e[t]=e[t].clone();return new Te(e,this._nSignificantBytes)}}for(var De="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Re=[],je=0;je<65;je++)Re[De.charCodeAt(je)]=je;var Ne={stringify(e){var t=e.words,r=e.nSigBytes;e.clamp();for(var n=[],o=0;o<r;o+=3)for(var i=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)n.push(De.charAt(i>>>6*(3-s)&63));var a=De.charAt(64);if(a)for(;n.length%4;)n.push(a);return n.join("")},parse(e){var t=e.length,r=De.charAt(64);if(r){var n=e.indexOf(r);-1!==n&&(t=n)}for(var o=[],i=0,s=0;s<t;s++)if(s%4){var a=Re[e.charCodeAt(s-1)]<<s%4*2|Re[e.charCodeAt(s)]>>>6-s%4*2;o[i>>>2]|=a<<24-i%4*8,i++}return new Ce(o,i)}},Ue={stringify(e){for(var t=e.nSigBytes,r=e.words,n=[],o=0;o<t;o++){var i=r[o>>>2]>>>24-o%4*8&255;n.push(String.fromCharCode(i))}return n.join("")},parse(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new Ce(r,t)}},Ke={stringify(e){try{return decodeURIComponent(escape(Ue.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:e=>Ue.parse(unescape(encodeURIComponent(e)))},qe={stringify(e){for(var t=e.words,r=e.nSigBytes,n=[],o=0;o<r;o+=2){var i=t[o>>>2]>>>16-o%4*8&65535;n.push(String.fromCharCode(i))}return n.join("")},parse(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>1]|=e.charCodeAt(n)<<16-n%2*16;return new Ce(r,2*t)}};function Le(e){return e<<8&4278255360|e>>>8&16711935}var _e={stringify(e){for(var t=e.words,r=e.nSigBytes,n=[],o=0;o<r;o+=2){var i=Le(t[o>>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(i))}return n.join("")},parse(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>1]|=Le(e.charCodeAt(n)<<16-n%2*16);return new Ce(r,2*t)}},Me=qe,Fe={stringify(e){var t=e.cipherText,r=e.salt;return t?r?new Ce([1398893684,1701076831]).concat(r).concat(t).toString(Ne):t.toString(Ne):""},parse(e){var t,r=Ne.parse(e),n=r.words;return 1398893684===n[0]&&1701076831===n[1]&&(t=new Ce(n.slice(2,4)),n.splice(0,4),r.nSigBytes-=16),new ze({cipherText:r,salt:t})}};class ze{constructor(e){this.formatter=Fe,e&&(this.cipherText=e.cipherText,this.key=e.key,this.iv=e.iv,this.salt=e.salt,this.Algorithm=e.Algorithm,this.mode=e.mode,this.padding=e.padding,this.blockSize=e.blockSize,this.formatter=e.formatter||Fe)}toString(e){return(e||this.formatter).stringify(this)}}class Ge{constructor(e){this._minBufferSize=0,this._blockSize=0,this._props=e,this._data=e&&void 0!==e.data?e.data.clone():new Ce,this._nBytes=e&&"number"==typeof e.nBytes?e.nBytes:0}get blockSize(){return this._blockSize}reset(e,t){this._data=void 0!==e?e.clone():new Ce,this._nBytes="number"==typeof t?t:0}_append(e){var t="string"==typeof e?Ke.parse(e):e;this._data.concat(t),this._nBytes+=t.nSigBytes}_process(e){var t,r=this._data.words,n=this._data.nSigBytes,o=this._blockSize,i=n/(4*this._blockSize),s=(i=e?Math.ceil(i):Math.max((0|i)-this._minBufferSize,0))*o,a=Math.min(4*s,n);if(s){for(var c=0;c<s;c+=o)this._doProcessBlock(r,c);t=r.splice(0,s),this._data.nSigBytes-=a}return new Ce(t,a)}_doProcessBlock(e,t){throw new Error("Not implemented")}}let Ve=class extends Ge{constructor(e){super(e),this._blockSize=16,this._props=e,e&&"number"==typeof e.blockSize&&(this._blockSize=e.blockSize),this.reset(e?e.data:void 0,e?e.nBytes:void 0)}get blockSize(){return this._blockSize}reset(e,t){super.reset.call(this,e,t),this._doReset()}update(e){return this._append(e),this._process(),this}finalize(e){return e&&this._append(e),this._doFinalize()}_doReset(){throw new Error("Not implemented")}_doFinalize(){throw new Error("Not implemented")}};var He=[],We=[];function Je(e){for(var t=Math.sqrt(e),r=2;r<=t;r++)if(!(e%r))return!1;return!0}function $e(e){return 4294967296*(e-(0|e))|0}!function(){for(var e=2,t=0;t<64;)Je(e)&&(t<8&&(He[t]=$e(Math.pow(e,.5))),We[t]=$e(Math.pow(e,1/3)),t++),e++}();var Ye=[];let Ze=class e extends Ve{constructor(e){super(e),this._hash=new Ce(He.slice(0)),this._props=e,e&&void 0!==e.hash&&(this._hash=e.hash.clone())}_doReset(){this._hash=new Ce(He.slice(0))}_doProcessBlock(e,t){for(var r=this._hash.words,n=r[0],o=r[1],i=r[2],s=r[3],a=r[4],c=r[5],u=r[6],l=r[7],d=0;d<64;d++){if(d<16)Ye[d]=0|e[t+d];else{var h=Ye[d-15],p=(h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3,y=Ye[d-2],f=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;Ye[d]=p+Ye[d-7]+f+Ye[d-16]}var g=n&o^n&i^o&i,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),m=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&c^~a&u)+We[d]+Ye[d];l=u,u=c,c=a,a=s+m|0,s=i,i=o,o=n,n=m+(b+g)|0}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+i|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+c|0,r[6]=r[6]+u|0,r[7]=r[7]+l|0}_doFinalize(){var e=this._data.words,t=8*this._nBytes,r=8*this._data.nSigBytes;return e[r>>>5]|=128<<24-r%32,e[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),e[15+(r+64>>>9<<4)]=t,this._data.nSigBytes=4*e.length,this._process(),this._hash}clone(){var t={hash:this._hash,blockSize:this._blockSize,data:this._data,nBytes:this._nBytes};return new e(t)}static hash(t,r){return new e(r).finalize(t)}};class Qe{constructor(e,t){this._hasher=e,"string"==typeof t&&(t=Ke.parse(t));var r=e.blockSize,n=4*r;t.nSigBytes>n&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),s=o.words,a=i.words,c=0;c<r;c++)s[c]^=1549556828,a[c]^=909522486;i.nSigBytes=n,o.nSigBytes=n,this.reset()}reset(){this._hasher.reset(),this._hasher.update(this._iKey)}update(e){return this._hasher.update(e),this}finalize(e){var t=this._hasher.finalize(e);return this._hasher.reset(),this._hasher.finalize(this._oKey.clone().concat(t))}}class Xe{constructor(e){this._props=e}compute(e,t){throw new Error("Not implemented")}static getKey(e,t,r){throw new Error("Not implemented")}}class et extends Xe{constructor(e){super(e),this._keySize=4,this._Hasher=Ze,this._iterations=1e4,e&&(this._keySize=void 0!==e.keySize?e.keySize:this._keySize,this._Hasher=void 0!==e.Hasher?e.Hasher:this._Hasher,this._iterations=void 0!==e.iterations?e.iterations:this._iterations)}compute(e,t){for(var r=new Qe(new this._Hasher,e),n=new Ce,o=new Ce([1]),i=n.words,s=o.words,a=this._keySize,c=this._iterations;i.length<a;){var u=r.update(t).finalize(o);r.reset();for(var l=u.words,d=l.length,h=u,p=1;p<c;p++){h=r.finalize(h),r.reset();for(var y=h.words,f=0;f<d;f++)l[f]^=y[f]}n.concat(u),s[0]++}return n.nSigBytes=4*a,n}static getKey(e,t,r){return new et(r).compute(e,t)}}var tt={execute(e,t,r,n,o){n||(n=Ce.random(8));var i=o&&o.kdfModule||et,s=o?{Hasher:o.kdfHasher,iterations:o.kdfIterations}:{},a=i.getKey(e,n,Object.assign(Object.assign({},s),{keySize:t+r})),c=new Ce(a.words.slice(t),4*r);return a.nSigBytes=4*t,new ze({key:a,iv:c,salt:n})}},rt=[];function nt(e,t,r,n,o,i,s){var a=e+(t&r|~t&n)+o+s;return(a<<i|a>>>32-i)+t}function ot(e,t,r,n,o,i,s){var a=e+(t&n|r&~n)+o+s;return(a<<i|a>>>32-i)+t}function it(e,t,r,n,o,i,s){var a=e+(t^r^n)+o+s;return(a<<i|a>>>32-i)+t}function st(e,t,r,n,o,i,s){var a=e+(r^(t|~n))+o+s;return(a<<i|a>>>32-i)+t}!function(){for(var e=0;e<64;e++)rt[e]=4294967296*Math.abs(Math.sin(e+1))|0}();class at extends Ve{constructor(e){super(e),this._hash=new Ce([1732584193,4023233417,2562383102,271733878]),e&&void 0!==e.hash&&(this._hash=e.hash.clone())}_doReset(){this._hash=new Ce([1732584193,4023233417,2562383102,271733878])}_doProcessBlock(e,t){for(var r=0;r<16;r++){var n=t+r,o=e[n];e[n]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var i=this._hash.words,s=e[t],a=e[t+1],c=e[t+2],u=e[t+3],l=e[t+4],d=e[t+5],h=e[t+6],p=e[t+7],y=e[t+8],f=e[t+9],g=e[t+10],b=e[t+11],m=e[t+12],w=e[t+13],v=e[t+14],k=e[t+15],S=i[0],O=i[1],A=i[2],I=i[3];S=nt(S,O,A,I,s,7,rt[0]),I=nt(I,S,O,A,a,12,rt[1]),A=nt(A,I,S,O,c,17,rt[2]),O=nt(O,A,I,S,u,22,rt[3]),S=nt(S,O,A,I,l,7,rt[4]),I=nt(I,S,O,A,d,12,rt[5]),A=nt(A,I,S,O,h,17,rt[6]),O=nt(O,A,I,S,p,22,rt[7]),S=nt(S,O,A,I,y,7,rt[8]),I=nt(I,S,O,A,f,12,rt[9]),A=nt(A,I,S,O,g,17,rt[10]),O=nt(O,A,I,S,b,22,rt[11]),S=nt(S,O,A,I,m,7,rt[12]),I=nt(I,S,O,A,w,12,rt[13]),A=nt(A,I,S,O,v,17,rt[14]),S=ot(S,O=nt(O,A,I,S,k,22,rt[15]),A,I,a,5,rt[16]),I=ot(I,S,O,A,h,9,rt[17]),A=ot(A,I,S,O,b,14,rt[18]),O=ot(O,A,I,S,s,20,rt[19]),S=ot(S,O,A,I,d,5,rt[20]),I=ot(I,S,O,A,g,9,rt[21]),A=ot(A,I,S,O,k,14,rt[22]),O=ot(O,A,I,S,l,20,rt[23]),S=ot(S,O,A,I,f,5,rt[24]),I=ot(I,S,O,A,v,9,rt[25]),A=ot(A,I,S,O,u,14,rt[26]),O=ot(O,A,I,S,y,20,rt[27]),S=ot(S,O,A,I,w,5,rt[28]),I=ot(I,S,O,A,c,9,rt[29]),A=ot(A,I,S,O,p,14,rt[30]),S=it(S,O=ot(O,A,I,S,m,20,rt[31]),A,I,d,4,rt[32]),I=it(I,S,O,A,y,11,rt[33]),A=it(A,I,S,O,b,16,rt[34]),O=it(O,A,I,S,v,23,rt[35]),S=it(S,O,A,I,a,4,rt[36]),I=it(I,S,O,A,l,11,rt[37]),A=it(A,I,S,O,p,16,rt[38]),O=it(O,A,I,S,g,23,rt[39]),S=it(S,O,A,I,w,4,rt[40]),I=it(I,S,O,A,s,11,rt[41]),A=it(A,I,S,O,u,16,rt[42]),O=it(O,A,I,S,h,23,rt[43]),S=it(S,O,A,I,f,4,rt[44]),I=it(I,S,O,A,m,11,rt[45]),A=it(A,I,S,O,k,16,rt[46]),S=st(S,O=it(O,A,I,S,c,23,rt[47]),A,I,s,6,rt[48]),I=st(I,S,O,A,p,10,rt[49]),A=st(A,I,S,O,v,15,rt[50]),O=st(O,A,I,S,d,21,rt[51]),S=st(S,O,A,I,m,6,rt[52]),I=st(I,S,O,A,u,10,rt[53]),A=st(A,I,S,O,g,15,rt[54]),O=st(O,A,I,S,a,21,rt[55]),S=st(S,O,A,I,y,6,rt[56]),I=st(I,S,O,A,k,10,rt[57]),A=st(A,I,S,O,h,15,rt[58]),O=st(O,A,I,S,w,21,rt[59]),S=st(S,O,A,I,l,6,rt[60]),I=st(I,S,O,A,b,10,rt[61]),A=st(A,I,S,O,c,15,rt[62]),O=st(O,A,I,S,f,21,rt[63]),i[0]=i[0]+S|0,i[1]=i[1]+O|0,i[2]=i[2]+A|0,i[3]=i[3]+I|0}_doFinalize(){var e=this._data,t=e.words,r=8*this._nBytes,n=8*e.nSigBytes;t[n>>>5]|=128<<24-n%32;var o=Math.floor(r/4294967296),i=r;t[15+(n+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.nSigBytes=4*(t.length+1),this._process();for(var s=this._hash,a=s.words,c=0;c<4;c++){var u=a[c];a[c]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return s}clone(){var e={hash:this._hash,blockSize:this._blockSize,data:this._data,nBytes:this._nBytes};return new at(e)}static hash(e){return(new at).finalize(e)}}class ct extends Xe{constructor(e){super(e),this._keySize=4,this._Hasher=at,this._iterations=1,e&&(this._keySize=void 0!==e.keySize?e.keySize:this._keySize,this._Hasher=void 0!==e.Hasher?e.Hasher:this._Hasher,this._iterations=void 0!==e.iterations?e.iterations:this._iterations)}compute(e,t){for(var r,n=new this._Hasher,o=new Ce,i=o.words,s=this._keySize,a=this._iterations;i.length<s;){r&&n.update(r),r=n.update(e).finalize(t),n.reset();for(var c=1;c<a;c++)r=n.finalize(r),n.reset();o.concat(r)}return o.nSigBytes=4*s,o}static getKey(e,t,r){return new ct(r).compute(e,t)}}function ut(e,t){return"string"==typeof e?t.parse(e):e}var lt={encrypt(e,t,r,n){var o=e.createEncryptor(r,n),i=o.finalize(t);return new ze({cipherText:i,key:r,iv:o.iv,Algorithm:e,mode:o.mode,padding:o.padding,blockSize:o.blockSize,formatter:(null==n?void 0:n.formatter)||Fe})},decrypt(e,t,r,n){var o=e.createDecryptor(r,n),i=ut(t,(null==n?void 0:n.formatter)||Fe);return o.finalize(i.cipherText||"")}},dt={encrypt(e,t,r,n){var o=n?Object.assign({},n):{},i=n&&n.KDF?n.KDF:tt,s={};n&&n.kdfHasher&&(s.kdfHasher=n.kdfHasher),n&&n.kdfIterations&&(s.kdfIterations=n.kdfIterations),n&&n.kdfModule&&(s.kdfModule=n.kdfModule);var a=i.execute(r,e.keySize,e.ivSize,o.kdfSalt,s);o.iv=a.iv;var c=lt.encrypt(e,t,a.key,o);return new ze(Object.assign(Object.assign({},c),{key:a.key,iv:a.iv,salt:a.salt}))},decrypt(e,t,r,n){var o=n?Object.assign({},n):{},i=o.KDF?o.KDF:tt,s=ut(t,o.formatter?o.formatter:Fe),a={};n&&n.kdfHasher&&(a.kdfHasher=n.kdfHasher),n&&n.kdfIterations&&(a.kdfIterations=n.kdfIterations),n&&n.kdfModule&&(a.kdfModule=n.kdfModule);var c=i.execute(r,e.keySize,e.ivSize,s.salt,a);return o.iv=c.iv,lt.decrypt(e,s,c.key,o)}};var ht=[];class pt extends Ve{constructor(e){super(e),this._hash=new Ce([1732584193,4023233417,2562383102,271733878,3285377520]),this._props=e,e&&void 0!==e.hash&&(this._hash=e.hash.clone())}_doReset(){this._hash=new Ce([1732584193,4023233417,2562383102,271733878,3285377520])}_doProcessBlock(e,t){for(var r=this._hash.words,n=r[0],o=r[1],i=r[2],s=r[3],a=r[4],c=0;c<80;c++){if(c<16)ht[c]=0|e[t+c];else{var u=ht[c-3]^ht[c-8]^ht[c-14]^ht[c-16];ht[c]=u<<1|u>>>31}var l=(n<<5|n>>>27)+a+ht[c];l+=c<20?1518500249+(o&i|~o&s):c<40?1859775393+(o^i^s):c<60?(o&i|o&s|i&s)-1894007588:(o^i^s)-899497514,a=s,s=i,i=o<<30|o>>>2,o=n,n=l}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+i|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0}_doFinalize(){var e=this._data.words,t=8*this._nBytes,r=8*this._data.nSigBytes;return e[r>>>5]|=128<<24-r%32,e[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),e[15+(r+64>>>9<<4)]=t,this._data.nSigBytes=4*e.length,this._process(),this._hash}clone(){var e={hash:this._hash,blockSize:this._blockSize,data:this._data,nBytes:this._nBytes};return new pt(e)}static hash(e,t){return new pt(t).finalize(e)}}class yt extends Ze{constructor(e){super(e),this._hash=new Ce([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),this._props=e,e&&void 0!==e.hash&&(this._hash=e.hash.clone())}_doReset(){this._hash=new Ce([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])}_doFinalize(){var e=super._doFinalize.call(this);return e.nSigBytes-=4,e}clone(){var e={hash:this._hash,blockSize:this._blockSize,data:this._data,nBytes:this._nBytes};return new yt(e)}static hash(e,t){return new yt(t).finalize(e)}}var ft=[new Be(1116352408,3609767458),new Be(1899447441,602891725),new Be(3049323471,3964484399),new Be(3921009573,2173295548),new Be(961987163,4081628472),new Be(1508970993,3053834265),new Be(2453635748,2937671579),new Be(2870763221,3664609560),new Be(3624381080,2734883394),new Be(310598401,1164996542),new Be(607225278,1323610764),new Be(1426881987,3590304994),new Be(1925078388,4068182383),new Be(2162078206,991336113),new Be(2614888103,633803317),new Be(3248222580,3479774868),new Be(3835390401,2666613458),new Be(4022224774,944711139),new Be(264347078,2341262773),new Be(604807628,2007800933),new Be(770255983,1495990901),new Be(1249150122,1856431235),new Be(1555081692,3175218132),new Be(1996064986,2198950837),new Be(2554220882,3999719339),new Be(2821834349,766784016),new Be(2952996808,2566594879),new Be(3210313671,3203337956),new Be(3336571891,1034457026),new Be(3584528711,2466948901),new Be(113926993,3758326383),new Be(338241895,168717936),new Be(666307205,1188179964),new Be(773529912,1546045734),new Be(1294757372,1522805485),new Be(1396182291,2643833823),new Be(1695183700,2343527390),new Be(1986661051,1014477480),new Be(2177026350,1206759142),new Be(2456956037,344077627),new Be(2730485921,1290863460),new Be(2820302411,3158454273),new Be(3259730800,3505952657),new Be(3345764771,106217008),new Be(3516065817,3606008344),new Be(3600352804,1432725776),new Be(4094571909,1467031594),new Be(275423344,851169720),new Be(430227734,3100823752),new Be(506948616,1363258195),new Be(659060556,3750685593),new Be(883997877,3785050280),new Be(958139571,3318307427),new Be(1322822218,3812723403),new Be(1537002063,2003034995),new Be(1747873779,3602036899),new Be(1955562222,1575990012),new Be(2024104815,1125592928),new Be(2227730452,2716904306),new Be(2361852424,442776044),new Be(2428436474,593698344),new Be(2756734187,3733110249),new Be(3204031479,2999351573),new Be(3329325298,3815920427),new Be(3391569614,3928383900),new Be(3515267271,566280711),new Be(3940187606,3454069534),new Be(4118630271,4000239992),new Be(116418474,1914138554),new Be(174292421,2731055270),new Be(289380356,3203993006),new Be(460393269,320620315),new Be(685471733,587496836),new Be(852142971,1086792851),new Be(1017036298,365543100),new Be(1126000580,2618297676),new Be(1288033470,3409855158),new Be(1501505948,4234509866),new Be(1607167915,987167468),new Be(1816402316,1246189591)],gt=[];!function(){for(var e=0;e<80;e++)gt[e]=new Be(0,0)}();let bt=class e extends Ve{constructor(e){super(e),this._blockSize=32,this._hash=new Te([new Be(1779033703,4089235720),new Be(3144134277,2227873595),new Be(1013904242,4271175723),new Be(2773480762,1595750129),new Be(1359893119,2917565137),new Be(2600822924,725511199),new Be(528734635,4215389547),new Be(1541459225,327033209)]),this._props=e,e&&void 0!==e.hash&&(this._hash=e.hash.clone())}_doReset(){this._hash=new Te([new Be(1779033703,4089235720),new Be(3144134277,2227873595),new Be(1013904242,4271175723),new Be(2773480762,1595750129),new Be(1359893119,2917565137),new Be(2600822924,725511199),new Be(528734635,4215389547),new Be(1541459225,327033209)])}_doProcessBlock(e,t){for(var r=this._hash.words,n=r[0],o=r[1],i=r[2],s=r[3],a=r[4],c=r[5],u=r[6],l=r[7],d=n.high,h=n.low,p=o.high,y=o.low,f=i.high,g=i.low,b=s.high,m=s.low,w=a.high,v=a.low,k=c.high,S=c.low,O=u.high,A=u.low,I=l.high,x=l.low,P=d,E=h,C=p,B=y,T=f,D=g,R=b,j=m,N=w,U=v,K=k,q=S,L=O,_=A,M=I,F=x,z=0;z<80;z++){var G=void 0,V=void 0,H=gt[z];if(z<16)V=H.high=0|e[t+2*z],G=H.low=0|e[t+2*z+1];else{var W=gt[z-15],J=W.high,$=W.low,Y=(J>>>1|$<<31)^(J>>>8|$<<24)^J>>>7,Z=($>>>1|J<<31)^($>>>8|J<<24)^($>>>7|J<<25),Q=gt[z-2],X=Q.high,ee=Q.low,te=(X>>>19|ee<<13)^(X<<3|ee>>>29)^X>>>6,re=(ee>>>19|X<<13)^(ee<<3|X>>>29)^(ee>>>6|X<<26),ne=gt[z-7],oe=ne.high,ie=ne.low,se=gt[z-16],ae=se.high,ce=se.low;V=(V=(V=Y+oe+((G=Z+ie)>>>0<Z>>>0?1:0))+te+((G+=re)>>>0<re>>>0?1:0))+ae+((G+=ce)>>>0<ce>>>0?1:0),H.high=V,H.low=G}var ue=N&K^~N&L,le=U&q^~U&_,de=P&C^P&T^C&T,he=E&B^E&D^B&D,pe=(P>>>28|E<<4)^(P<<30|E>>>2)^(P<<25|E>>>7),ye=(E>>>28|P<<4)^(E<<30|P>>>2)^(E<<25|P>>>7),fe=(N>>>14|U<<18)^(N>>>18|U<<14)^(N<<23|U>>>9),ge=(U>>>14|N<<18)^(U>>>18|N<<14)^(U<<23|N>>>9),be=ft[z],me=be.high,we=be.low,ve=F+ge,ke=M+fe+(ve>>>0<F>>>0?1:0),Se=ye+he;M=L,F=_,L=K,_=q,K=N,q=U,N=R+(ke=(ke=(ke=ke+ue+((ve+=le)>>>0<le>>>0?1:0))+me+((ve+=we)>>>0<we>>>0?1:0))+V+((ve+=G)>>>0<G>>>0?1:0))+((U=j+ve|0)>>>0<j>>>0?1:0)|0,R=T,j=D,T=C,D=B,C=P,B=E,P=ke+(pe+de+(Se>>>0<ye>>>0?1:0))+((E=ve+Se|0)>>>0<ve>>>0?1:0)|0}h=n.low=h+E,n.high=d+P+(h>>>0<E>>>0?1:0),y=o.low=y+B,o.high=p+C+(y>>>0<B>>>0?1:0),g=i.low=g+D,i.high=f+T+(g>>>0<D>>>0?1:0),m=s.low=m+j,s.high=b+R+(m>>>0<j>>>0?1:0),v=a.low=v+U,a.high=w+N+(v>>>0<U>>>0?1:0),S=c.low=S+q,c.high=k+K+(S>>>0<q>>>0?1:0),A=u.low=A+_,u.high=O+L+(A>>>0<_>>>0?1:0),x=l.low=x+F,l.high=I+M+(x>>>0<F>>>0?1:0)}_doFinalize(){var e=this._data,t=e.words,r=8*this._nBytes,n=8*e.nSigBytes;return t[n>>>5]|=128<<24-n%32,t[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),t[31+(n+128>>>10<<5)]=r,e.nSigBytes=4*t.length,this._process(),this._hash.to32()}clone(){var t={hash:this._hash,blockSize:this._blockSize,data:this._data,nBytes:this._nBytes};return new e(t)}static hash(t,r){return new e(r).finalize(t)}};class mt extends bt{constructor(e){super(e),this._hash=new Te([new Be(3418070365,3238371032),new Be(1654270250,914150663),new Be(2438529370,812702999),new Be(355462360,4144912697),new Be(1731405415,4290775857),new Be(2394180231,1750603025),new Be(3675008525,1694076839),new Be(1203062813,3204075428)]),this._props=e,e&&void 0!==e.hash&&(this._hash=e.hash.clone())}_doReset(){this._hash=new Te([new Be(3418070365,3238371032),new Be(1654270250,914150663),new Be(2438529370,812702999),new Be(355462360,4144912697),new Be(1731405415,4290775857),new Be(2394180231,1750603025),new Be(3675008525,1694076839),new Be(1203062813,3204075428)])}_doFinalize(){var e=super._doFinalize.call(this);return e.nSigBytes-=16,e}clone(){var e={hash:this._hash,blockSize:this._blockSize,data:this._data,nBytes:this._nBytes};return new mt(e)}static hash(e,t){return new mt(t).finalize(e)}}let wt=class e extends Ge{constructor(e){super(e),this._transformMode=1,this._props=e,this._key=e.key,this._iv=void 0!==e.iv?e.iv:this._iv,this._transformMode=void 0!==e.transformMode?e.transformMode:this._transformMode}get iv(){return this._iv}reset(e,t){super.reset(e,t),this._doReset()}process(e){return this._append(e),this._process()}finalize(e){return e&&this._append(e),this._doFinalize()}_doReset(){throw new Error("Not implemented")}_doProcessBlock(e,t){throw new Error("Not implemented")}_doFinalize(){throw new Error("Not implemented")}static createEncryptor(t,r){return r=void 0===r?{}:r,new e(Object.assign(Object.assign({},r),{key:t,transformMode:e.ENC_TRANSFORM_MODE}))}static createDecryptor(t,r){return r=void 0===r?{}:r,new e(Object.assign(Object.assign({},r),{key:t,transformMode:e.DEC_TRANSFORM_MODE}))}};wt.ENC_TRANSFORM_MODE=1,wt.DEC_TRANSFORM_MODE=2,wt.keySize=4,wt.ivSize=4;class vt{constructor(e){this._props=e,this._cipher=e.cipher,this._iv=e.iv}processBlock(e,t){}static createEncryptor(e){throw new Error("Not implemented yet")}static createDecryptor(e){throw new Error("Not implemented yet")}}class kt extends vt{constructor(e){super(e),this._prevBlock=[]}xorBlock(e,t,r){var n,o=this._iv;o?(n=o.words,this._iv=void 0):n=this._prevBlock;for(var i=0;i<r;i++)e[t+i]^=n[i]}static createEncryptor(e){return new kt.Encryptor(e)}static createDecryptor(e){return new kt.Decryptor(e)}}kt.Encryptor=class extends kt{processBlock(e,t){var r=this._cipher,n=r.blockSize;this.xorBlock(e,t,n),r.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}},kt.Decryptor=class extends kt{processBlock(e,t){var r=this._cipher,n=r.blockSize,o=e.slice(t,t+n);r.decryptBlock(e,t),this.xorBlock(e,t,n),this._prevBlock=o}};var St={pad:function(e,t){for(var r=4*t,n=r-e.nSigBytes%r,o=n<<24|n<<16|n<<8|n,i=[],s=0;s<n;s+=4)i.push(o);var a=new Ce(i,n);e.concat(a)},unpad:function(e){var t=255&e.words[e.nSigBytes-1>>>2];e.nSigBytes-=t}};class Ot extends wt{constructor(e){super(e),this._blockSize=4,this._Mode=kt,this._padding=St,this._props=e,this._Mode=void 0!==e.mode?e.mode:this._Mode,this._padding=void 0!==e.padding?e.padding:this._padding,this.reset(null==e?void 0:e.data,null==e?void 0:e.nBytes)}get mode(){return this._mode}get padding(){return this._padding}reset(e,t){var r;super.reset(e,t),this._transformMode===wt.ENC_TRANSFORM_MODE?r=this._Mode.createEncryptor:(r=this._Mode.createDecryptor,this._minBufferSize=1),this._Mode&&this._modeCreator===r?this._mode=new this._Mode({cipher:this,iv:this._iv}):(this._mode=r.call(this._Mode,{cipher:this,iv:this._iv}),this._modeCreator=r)}_doProcessBlock(e,t){var r;null===(r=this._mode)||void 0===r||r.processBlock(e,t)}_doFinalize(){var e,t=this._padding;return this._transformMode===wt.ENC_TRANSFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e}encryptBlock(e,t){throw new Error("Not implemented")}decryptBlock(e,t){throw new Error("Not implemented")}static createEncryptor(e,t){return t=void 0===t?{}:t,new Ot(Object.assign(Object.assign({},t),{key:e,transformMode:wt.ENC_TRANSFORM_MODE}))}static createDecryptor(e,t){return t=void 0===t?{}:t,new Ot(Object.assign(Object.assign({},t),{key:e,transformMode:wt.DEC_TRANSFORM_MODE}))}}var At=[],It=[],xt=[],Pt=[],Et=[],Ct=[],Bt=[],Tt=[],Dt=[],Rt=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=0,n=0,o=0;o<256;o++){var i=n^n<<1^n<<2^n<<3^n<<4;i=i>>>8^255&i^99,At[r]=i,It[i]=r;var s=e[r],a=e[s],c=e[a],u=257*e[i]^16843008*i;xt[r]=u<<24|u>>>8,Pt[r]=u<<16|u>>>16,Et[r]=u<<8|u>>>24,Ct[r]=u,u=16843009*c^65537*a^257*s^16843008*r,Bt[i]=u<<24|u>>>8,Tt[i]=u<<16|u>>>16,Dt[i]=u<<8|u>>>24,Rt[i]=u,r?(r=s^e[e[e[c^s]]],n^=e[e[n]]):r=n=1}}();var jt=[0,1,2,4,8,16,32,64,128,27,54];let Nt=class e extends Ot{constructor(e){super(e),this._nRounds=0,this._keySchedule=[],this._invKeySchedule=[],this._props=e,this._doReset()}_doReset(){var e;if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,r=t.words,n=t.nSigBytes/4,o=4*((this._nRounds=n+6)+1),i=this._keySchedule=[],s=0;s<o;s++)s<n?i[s]=r[s]:(e=i[s-1],s%n?n>6&&s%n===4&&(e=At[e>>>24]<<24|At[e>>>16&255]<<16|At[e>>>8&255]<<8|At[255&e]):(e=At[(e=e<<8|e>>>24)>>>24]<<24|At[e>>>16&255]<<16|At[e>>>8&255]<<8|At[255&e],e^=jt[s/n|0]<<24),i[s]=i[s-n]^e);this._invKeySchedule=[];for(var a=0;a<o;a++){var c=o-a;e=a%4?i[c]:i[c-4],this._invKeySchedule[a]=a<4||c<=4?e:Bt[At[e>>>24]]^Tt[At[e>>>16&255]]^Dt[At[e>>>8&255]]^Rt[At[255&e]]}}}encryptBlock(e,t){this._doCryptBlock(e,t,this._keySchedule,xt,Pt,Et,Ct,At)}decryptBlock(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,Bt,Tt,Dt,Rt,It),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r}_doCryptBlock(e,t,r,n,o,i,s,a){for(var c=this._nRounds,u=e[t]^r[0],l=e[t+1]^r[1],d=e[t+2]^r[2],h=e[t+3]^r[3],p=4,y=1;y<c;y++){var f=n[u>>>24]^o[l>>>16&255]^i[d>>>8&255]^s[255&h]^r[p++],g=n[l>>>24]^o[d>>>16&255]^i[h>>>8&255]^s[255&u]^r[p++],b=n[d>>>24]^o[h>>>16&255]^i[u>>>8&255]^s[255&l]^r[p++],m=n[h>>>24]^o[u>>>16&255]^i[l>>>8&255]^s[255&d]^r[p++];u=f,l=g,d=b,h=m}var w=(a[u>>>24]<<24|a[l>>>16&255]<<16|a[d>>>8&255]<<8|a[255&h])^r[p++],v=(a[l>>>24]<<24|a[d>>>16&255]<<16|a[h>>>8&255]<<8|a[255&u])^r[p++],k=(a[d>>>24]<<24|a[h>>>16&255]<<16|a[u>>>8&255]<<8|a[255&l])^r[p++],S=(a[h>>>24]<<24|a[u>>>16&255]<<16|a[l>>>8&255]<<8|a[255&d])^r[p++];e[t]=w,e[t+1]=v,e[t+2]=k,e[t+3]=S}static createEncryptor(t,r){return r=void 0===r?{}:r,new e(Object.assign(Object.assign({},r),{key:t,transformMode:wt.ENC_TRANSFORM_MODE}))}static createDecryptor(t,r){return r=void 0===r?{}:r,new e(Object.assign(Object.assign({},r),{key:t,transformMode:wt.DEC_TRANSFORM_MODE}))}static encrypt(t,r,n){if("string"==typeof r)return dt.encrypt(e,t,r,n);if(r.nSigBytes%4!=0)throw new Error("Key size must be multiple of 32bit/4byte/1word");return lt.encrypt(e,t,r,n)}static decrypt(t,r,n){if("string"==typeof r)return dt.decrypt(e,t,r,n);if(r.nSigBytes%4!=0)throw new Error("Key size must be multiple of 32bit/4byte/1word");return lt.decrypt(e,t,r,n)}};function Ut(e){var t=e.nSigBytes%16;if(0!==t){for(var r=16-t,n=[],o=Math.floor(r/4),i=0;i<o;i++)n.push(0);r%4>0&&n.push(0),e.concat(new Ce(n,r))}}function Kt(e,t){return new Ce(e.words.slice(),t)}function qt(e,t){for(var r=e.nSigBytes-t,n=[],o=0;o<t;o++){var i=o>>>2,s=r+o,a=s>>>2,c=e.words[a]>>>24-s%4*8&255;n[i]=n[i]|c<<24-o%4*8}var u=new Ce(n,t);return u.clamp(),u}Nt.keySize=8;class Lt extends vt{constructor(e){if(super(e),this._H=[],this._J0=[],this._CB=[],4!==e.cipher.blockSize)throw new Error("In GCM block cipher mode, cipher block size must be 128bit");var{cipher:t,iv:r}=e,n=[0,0,0,0];t.encryptBlock(n,0),this._H=n,this._J0=Lt.getJ0(n,null==r?void 0:r.words),this._CB=this._J0.slice()}static getJ0(e,t){var r;if(t&&0!==t.length)if(3===t.length)r=[t[0],t[1],t[2],1];else{for(var n=t.length%4>0?4-t.length%4:0,o=t.slice(),i=0;i<n+2;i++)o.push(0);o.push(0),o.push(32*t.length),r=Lt.GHASH(e,o)}else r=[0,0,0,1];return r}static inc32(e){var t=e.slice(),r=t[3]>>>0,n=r+1>>>0<r;if(t[3]=t[3]+1|0,n){var o=t[2]>>>0,i=o+1>>>0<o;t[2]=t[2]+1|0,i&&(t[1]=t[1]+1|0)}return t}static mul(e,t){for(var r=[3774873600,0,0,0],n=[0,0,0,0],o=t.slice(),i=0;i<128;i++){(e[i>>>5]>>>31-i%32&1)>0&&(n[0]=n[0]^o[0],n[1]=n[1]^o[1],n[2]=n[2]^o[2],n[3]=n[3]^o[3]);var s=(1&o[3])>>>0,a=(1&o[0])>>>0,c=(1&o[1])>>>0,u=(1&o[2])>>>0;o[0]=o[0]>>>1,o[1]=o[1]>>>1|(a?2147483648:0),o[2]=o[2]>>>1|(c?2147483648:0),o[3]=o[3]>>>1|(u?2147483648:0),s>0&&(o[0]^=r[0],o[1]^=r[1],o[2]^=r[2],o[3]^=r[3])}return n}static GHASH(e,t){if(e.length%4!=0)throw new Error("Length of 32bit word array 'H' must be multiple of 4(128bit)");if(t.length%4!=0)throw new Error("Length of 32bit word array 'X' must be multiple of 4(128bit)");for(var r=t.length,n=[0,0,0,0],o=0;o<r;o+=4)n[0]=n[0]^t[o],n[1]=n[1]^t[o+1],n[2]=n[2]^t[o+2],n[3]=n[3]^t[o+3],n=Lt.mul(n,e);return n}static GCTR(e,t,r){if(0===r.nSigBytes)return r.clone();if(4!==t.length)throw new Error("Initial Counter Block size must be 128bit");for(var n=r.words,o=Math.ceil(r.nSigBytes/16),i=[t.slice()],s=1;s<o;s++){var a=Lt.inc32(i[s-1]);i.push(a)}for(var c=new Ce,u=0;u<o;u++){e.encryptBlock(i[u],0);var l=r.nSigBytes%16;if(u<o-1||0===l){var d=n[4*u]^i[u][0],h=n[4*u+1]^i[u][1],p=n[4*u+2]^i[u][2],y=n[4*u+3]^i[u][3],f=new Ce([d,h,p,y]);c.concat(f)}else{for(var g=[],b=0,m=Math.floor(l/4),w=0;w<m;w++){var v=n[4*u+w]^i[u][w];g.push(v),b+=4}var k=l%4;if(k>0){var S=n[4*u+m]<<32-8*k^i[u][m];g.push(S),b+=k}var O=new Ce(g,b);c.concat(O)}}return c.nSigBytes=r.nSigBytes,c.clamp(),c}static mac(e,t,r,n,o,i){var s=new e({key:t,iv:r}),a=[0,0,0,0];s.encryptBlock(a,0);var c=Lt.getJ0(a,r.words),u=(null==n?void 0:n.clone())||new Ce,l=[0,8*u.nSigBytes],d=(null==o?void 0:o.clone())||new Ce,h=[0,8*d.nSigBytes],p=i||16;Ut(u),Ut(d);var y=u.words.concat(d.words).concat(l).concat(h),f=Lt.GHASH(a,y);return Kt(Lt.GCTR(s,c,new Ce(f)),p)}static createEncryptor(e){return new Lt.Encryptor(e)}static createDecryptor(e){return new Lt.Decryptor(e)}}Lt.Encryptor=class extends Lt{processBlock(e,t){var r=this._cipher.blockSize;this._CB=Lt.inc32(this._CB);for(var n=new Ce(e.slice(t,t+r)),o=Lt.GCTR(this._cipher,this._CB,n),i=0;i<r;i++)e[t+i]=o.words[i]}},Lt.Decryptor=class extends Lt{processBlock(e,t){var r=this._cipher.blockSize;this._CB=Lt.inc32(this._CB);for(var n=new Ce(e.slice(t,t+r)),o=Lt.GCTR(this._cipher,this._CB,n),i=0;i<r;i++)e[t+i]=o.words[i]}};class _t extends vt{constructor(e){super(e),this._CBIndex=1;var{cipher:t,iv:r}=e;if(4!==t.blockSize)throw new Error("In CCM, cipher block size must be 128bit");if(r&&(r.nSigBytes>13||r.nSigBytes<7))throw new Error("Byte size of iv must be between 7 and 13");this._N=r||new Ce([0,0],8),this._q=15-this._N.nSigBytes}static getB0(e,t,r,n){if(r.nSigBytes+n.nSigBytes!==15)throw new Error("LEN(Q)+LEN(N) must be 15");var o=255&(0|(e?1:0)<<6|(t-2)/2<<3|r.nSigBytes-1),i=n.clone().concat(r);return new Ce([o<<24],1).concat(i)}static formatAssociatedDataAndPayload(e,t){var r,n=e.nSigBytes;if(0===n)r=new Ce([0],0);else if(n<Math.pow(2,16)-Math.pow(2,8))r=new Ce([n<<16],2);else{if(!(n<Math.pow(2,32)))throw new Error("LEN(A) larger than 2**32-1 is not supported");r=new Ce([4294836224],2).concat(new Ce([n],4))}for(var o=Math.floor(e.nSigBytes/4),i=0;i<o;i++)r.concat(new Ce([e.words[i]],4));e.nSigBytes%4&&(r.concat(new Ce([e.words[o]],e.nSigBytes%4)),r.concat(new Ce([0],4-e.nSigBytes%4))),r.nSigBytes%16&&r.concat(new Ce([0],16-r.nSigBytes%16));for(var s=Math.floor(t.nSigBytes/4),a=0;a<s;a++)r.concat(new Ce([t.words[a]],4));return t.nSigBytes%4&&(r.concat(new Ce([t.words[s]],t.nSigBytes%4)),r.concat(new Ce([0],4-t.nSigBytes%4))),r.nSigBytes%16&&r.concat(new Ce([0],16-r.nSigBytes%16)),r}static genCtr(e,t,r){if(t.nSigBytes+e!==15)throw new Error("LEN(Q)+LEN(N) must be 15");for(var n=new Ce([(e-1&7)<<24],1),o=new Ce([],0),i=Math.floor(e/4),s=0;s<i-1;s++)o.concat(new Ce([0],4));return e%4?e>4?(o.concat(new Ce([0],e%4)),o.concat(new Ce([r],4))):o.concat(new Ce([r<<32-8*e],e)):o.concat(new Ce([r],4)),n.concat(t).concat(o)}static mac(e,t,r,n,o,i){var s=new e({key:t,iv:r});if(4!==s.blockSize)throw new Error("In CCM, cipher block size must be 128bit");if(r&&(r.nSigBytes>13||r.nSigBytes<7))throw new Error("Byte size of iv must be between 7 and 13");var a=r||new Ce([0,0],8),c=(null==n?void 0:n.clone())||new Ce,u=c.nSigBytes,l=(null==o?void 0:o.clone())||new Ce,d=l.nSigBytes;if(d>>>0>4294967295)throw new Error("Byte length of Payload(plainText) larger than 2^32-1 (4,294,967,295byte) is not supported at this time.");var h=15-a.nSigBytes,p=qt(new Ce([0,d],8),h),y=i||16,f=_t.getB0(Boolean(u),y,p,a),g=_t.formatAssociatedDataAndPayload(c,l),b=f.words.slice();s.encryptBlock(b,0);for(var m=g.nSigBytes/16,w=g.words,v=b,k=0;k<m;k++){var S=[w[4*k]^v[0],w[4*k+1]^v[1],w[4*k+2]^v[2],w[4*k+3]^v[3]];s.encryptBlock(S,0),v=S}var O=new Ce(v,y),A=_t.genCtr(h,a,0);s.encryptBlock(A.words,0);for(var I=0;I<4;I++)O.words[I]^=A.words[I];return O.clamp(),O}static combineCipherTextAndAuthTag(e,t){return e.clone().concat(t)}static splitCipherTextAndAuthTag(e,t){var r=t||16;return{cipherText:Kt(e,e.nSigBytes-r),authTag:qt(e,r)}}static createEncryptor(e){return new _t.Encryptor(e)}static createDecryptor(e){return new _t.Decryptor(e)}}_t.Encryptor=class extends _t{processBlock(e,t){var r=this._cipher,n=r.blockSize,o=_t.genCtr(this._q,this._N,this._CBIndex);r.encryptBlock(o.words,0);for(var i=0;i<n;i++)e[t+i]^=o.words[i];this._CBIndex++}},_t.Decryptor=class extends _t{processBlock(e,t){var r=this._cipher,n=r.blockSize,o=_t.genCtr(this._q,this._N,this._CBIndex);r.encryptBlock(o.words,0);for(var i=0;i<n;i++)e[t+i]^=o.words[i];this._CBIndex++}};var Mt=[],Ft=[],zt=[];!function(){for(var e=1,t=0,r=0;r<24;r++){Mt[e+5*t]=(r+1)*(r+2)/2%64;var n=(2*e+3*t)%5;e=t%5,t=n}for(var o=0;o<5;o++)for(var i=0;i<5;i++)Ft[o+5*i]=i+(2*o+3*i)%5*5;for(var s=1,a=0;a<24;a++){for(var c=0,u=0,l=0;l<7;l++){if(1&s){var d=(1<<l)-1;d<32?u^=1<<d:c^=1<<d-32}128&s?s=s<<1^113:s<<=1}zt[a]=new Be(c,u)}}();var Gt=[];!function(){for(var e=0;e<25;e++)Gt[e]=new Be(0,0)}();class Vt extends Ve{constructor(e){if(super(e),this._blockSize=32,this._state=[],this._outputLength=512,this._props=e,e){if(void 0!==e.outputLength){if(![224,256,384,512].includes(e.outputLength))throw new Error("Unsupported output length.");this._outputLength=e.outputLength}void 0!==e.state&&(this._state=e.state.map((e=>e.clone())))}if(0===this._state.length)for(var t=0;t<25;t++)this._state[t]=new Be(0,0);this._blockSize=(1600-2*this._outputLength)/32}_doReset(){this._state=[];for(var e=0;e<25;e++)this._state[e]=new Be(0,0);this._blockSize=(1600-2*this._outputLength)/32}_doProcessBlock(e,t){for(var r=this._state,n=this._blockSize/2,o=0;o<n;o++){var i=e[t+2*o],s=e[t+2*o+1];i=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),r[o].high^=s,r[o].low^=i}for(var a=0;a<24;a++){for(var c=0;c<5;c++){for(var u=0,l=0,d=0;d<5;d++){var h=r[c+5*d];u^=h.high,l^=h.low}var p=Gt[c];p.high=u,p.low=l}for(var y=0;y<5;y++)for(var f=Gt[(y+4)%5],g=Gt[(y+1)%5],b=g.high,m=g.low,w=f.high^(b<<1|m>>>31),v=f.low^(m<<1|b>>>31),k=0;k<5;k++){var S=r[y+5*k];S.high^=w,S.low^=v}for(var O=1;O<25;O++){var A=void 0,I=void 0,x=r[O].high,P=r[O].low,E=Mt[O];E<32?(A=x<<E|P>>>32-E,I=P<<E|x>>>32-E):(A=P<<E-32|x>>>64-E,I=x<<E-32|P>>>64-E);var C=Gt[Ft[O]];C.high=A,C.low=I}var B=Gt[0],T=r[0];B.high=T.high,B.low=T.low;for(var D=0;D<5;D++)for(var R=0;R<5;R++){var j=D+5*R,N=r[j],U=Gt[j],K=Gt[(D+1)%5+5*R],q=Gt[(D+2)%5+5*R];N.high=U.high^~K.high&q.high,N.low=U.low^~K.low&q.low}var L=r[0],_=zt[a];L.high^=_.high,L.low^=_.low}}_doFinalize(){var e=this._data,t=e.words,r=8*e.nSigBytes,n=32*this.blockSize;t[r>>>5]|=1<<24-r%32,t[(Math.ceil((r+1)/n)*n>>>5)-1]|=128,e.nSigBytes=4*t.length,this._process();for(var o=this._state,i=this._outputLength/8,s=i/8,a=[],c=0;c<s;c++){var u=o[c],l=u.high,d=u.low;l=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),a.push(d),a.push(l)}return new Ce(a,i)}clone(){var e={outputLength:this._outputLength,state:this._state,blockSize:this._blockSize,data:this._data,nBytes:this._nBytes};return new Vt(e)}static hash(e,t){return new Vt(t).finalize(e)}}var Ht=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],Wt=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],Jt=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],$t=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],Yt=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679];class Zt extends Ot{constructor(e){super(e),this._blockSize=2,this._subKeys=[],this._invSubKeys=[],this._lBlock=0,this._rBlock=0,this._props=e,this._doReset()}_doReset(){for(var e=this._key.words,t=[],r=0;r<56;r++){var n=Ht[r]-1;t[r]=e[n>>>5]>>>31-n%32&1}for(var o=this._subKeys=[],i=0;i<16;i++){for(var s=o[i]=[],a=Jt[i],c=0;c<24;c++)s[c/6|0]|=t[(Wt[c]-1+a)%28]<<31-c%6,s[4+(c/6|0)]|=t[28+(Wt[c+24]-1+a)%28]<<31-c%6;s[0]=s[0]<<1|s[0]>>>31;for(var u=1;u<7;u++)s[u]=s[u]>>>4*(u-1)+3;s[7]=s[7]<<5|s[7]>>>27}this._invSubKeys=[];for(var l=0;l<16;l++)this._invSubKeys[l]=o[15-l]}encryptBlock(e,t){this._doCryptoBlock(e,t,this._subKeys)}decryptBlock(e,t){this._doCryptoBlock(e,t,this._invSubKeys)}_doCryptoBlock(e,t,r){this._lBlock=e[t],this._rBlock=e[t+1],this._exchangeLR(4,252645135),this._exchangeLR(16,65535),this._exchangeRL(2,858993459),this._exchangeRL(8,16711935),this._exchangeLR(1,1431655765);for(var n=0;n<16;n++){for(var o=r[n],i=this._lBlock,s=this._rBlock,a=0,c=0;c<8;c++){var u=(s^o[c])&Yt[c];a|=$t[c][u>>>0]}this._lBlock=s,this._rBlock=i^a}var l=this._lBlock;this._lBlock=this._rBlock,this._rBlock=l,this._exchangeLR(1,1431655765),this._exchangeRL(8,16711935),this._exchangeRL(2,858993459),this._exchangeLR(16,65535),this._exchangeLR(4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock}_exchangeLR(e,t){var r=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=r,this._lBlock^=r<<e}_exchangeRL(e,t){var r=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=r,this._rBlock^=r<<e}static createEncryptor(e,t){return t=void 0===t?{}:t,new Zt(Object.assign(Object.assign({},t),{key:e,transformMode:wt.ENC_TRANSFORM_MODE}))}static createDecryptor(e,t){return t=void 0===t?{}:t,new Zt(Object.assign(Object.assign({},t),{key:e,transformMode:wt.DEC_TRANSFORM_MODE}))}static encrypt(e,t,r){return"string"==typeof t?dt.encrypt(Zt,e,t,r):lt.encrypt(Zt,e,t,r)}static decrypt(e,t,r){return"string"==typeof t?dt.decrypt(Zt,e,t,r):lt.decrypt(Zt,e,t,r)}}Zt.keySize=2,Zt.ivSize=2;class Qt extends Ot{constructor(e){super(e),this._blockSize=2,this._props=e;var t=this._get3DES();this._des1=t[0],this._des2=t[1],this._des3=t[2]}_get3DES(){var e=this._key.words;if(2!==e.length&&4!==e.length&&e.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=e.slice(0,2),r=e.length<4?e.slice(0,2):e.slice(2,4),n=e.length<6?e.slice(0,2):e.slice(4,6);return[Zt.createEncryptor(new Ce(t)),Zt.createEncryptor(new Ce(r)),Zt.createEncryptor(new Ce(n))]}_doReset(){var e=this._get3DES();this._des1=e[0],this._des2=e[1],this._des3=e[2]}encryptBlock(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)}decryptBlock(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)}static createEncryptor(e,t){return t=void 0===t?{}:t,new Qt(Object.assign(Object.assign({},t),{key:e,transformMode:wt.ENC_TRANSFORM_MODE}))}static createDecryptor(e,t){return t=void 0===t?{}:t,new Qt(Object.assign(Object.assign({},t),{key:e,transformMode:wt.DEC_TRANSFORM_MODE}))}static encrypt(e,t,r){return"string"==typeof t?dt.encrypt(Qt,e,t,r):lt.encrypt(Qt,e,t,r)}static decrypt(e,t,r){return"string"==typeof t?dt.decrypt(Qt,e,t,r):lt.decrypt(Qt,e,t,r)}}Qt.keySize=6,Qt.ivSize=2;var Xt=new Ce([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),er=new Ce([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),tr=new Ce([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),rr=new Ce([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),nr=new Ce([0,1518500249,1859775393,2400959708,2840853838]),or=new Ce([1352829926,1548603684,1836072691,2053994217,0]);function ir(e,t,r){return e^t^r}function sr(e,t,r){return e&t|~e&r}function ar(e,t,r){return(e|~t)^r}function cr(e,t,r){return e&r|t&~r}function ur(e,t,r){return e^(t|~r)}function lr(e,t){return e<<t|e>>>32-t}class dr extends Ve{constructor(e){super(e),this._hash=new Ce([1732584193,4023233417,2562383102,271733878,3285377520]),this._props=e,e&&void 0!==e.hash&&(this._hash=e.hash.clone())}_doReset(){this._hash=new Ce([1732584193,4023233417,2562383102,271733878,3285377520])}_doProcessBlock(e,t){for(var r=0;r<16;r++){var n=t+r,o=e[n];e[n]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var i,s,a,c,u,l,d,h,p,y,f,g=this._hash.words,b=nr.words,m=or.words,w=Xt.words,v=er.words,k=tr.words,S=rr.words;l=i=g[0],d=s=g[1],h=a=g[2],p=c=g[3],y=u=g[4];for(var O=0;O<80;O+=1)f=i+e[t+w[O]]|0,f+=O<16?ir(s,a,c)+b[0]:O<32?sr(s,a,c)+b[1]:O<48?ar(s,a,c)+b[2]:O<64?cr(s,a,c)+b[3]:ur(s,a,c)+b[4],f=(f=lr(f|=0,k[O]))+u|0,i=u,u=c,c=lr(a,10),a=s,s=f,f=l+e[t+v[O]]|0,f+=O<16?ur(d,h,p)+m[0]:O<32?cr(d,h,p)+m[1]:O<48?ar(d,h,p)+m[2]:O<64?sr(d,h,p)+m[3]:ir(d,h,p)+m[4],f=(f=lr(f|=0,S[O]))+y|0,l=y,y=p,p=lr(h,10),h=d,d=f;f=g[1]+a+p|0,g[1]=g[2]+c+y|0,g[2]=g[3]+u+l|0,g[3]=g[4]+i+d|0,g[4]=g[0]+s+h|0,g[0]=f}_doFinalize(){var e=this._data,t=e.words,r=8*this._nBytes,n=8*e.nSigBytes;t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.nSigBytes=4*(t.length+1),this._process();for(var o=this._hash,i=o.words,s=0;s<5;s++){var a=i[s];i[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return o}clone(){var e={hash:this._hash,blockSize:this._blockSize,data:this._data,nBytes:this._nBytes};return new dr(e)}static hash(e,t){return new dr(t).finalize(e)}}class hr extends wt{constructor(e){super(e),this._blockSize=1}_doFinalize(){return this._process(!0)}}class pr extends hr{constructor(e){super(e),this._blockSize=4,this.S=[],this.C=[],this.G=[],this._X=[],this._C=[],this._b=0,this._props=e,this._doReset()}_doReset(){for(var e=this._key.words,t=this._iv,r=0;r<4;r++)e[r]=16711935&(e[r]<<8|e[r]>>>24)|4278255360&(e[r]<<24|e[r]>>>8);var n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],o=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var i=0;i<4;i++)this.nextState();for(var s=0;s<8;s++)o[s]^=n[s+4&7];if(t){var a=t.words,c=a[0],u=a[1],l=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),d=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=l>>>16|4294901760&d,p=d<<16|65535&l;o[0]^=l,o[1]^=h,o[2]^=d,o[3]^=p,o[4]^=l,o[5]^=h,o[6]^=d,o[7]^=p;for(var y=0;y<4;y++)this.nextState()}}_doProcessBlock(e,t){var r=this._X;this.nextState(),this.S[0]=r[0]^r[5]>>>16^r[3]<<16,this.S[1]=r[2]^r[7]>>>16^r[5]<<16,this.S[2]=r[4]^r[1]>>>16^r[7]<<16,this.S[3]=r[6]^r[3]>>>16^r[1]<<16;for(var n=0;n<4;n++)this.S[n]=16711935&(this.S[n]<<8|this.S[n]>>>24)|4278255360&(this.S[n]<<24|this.S[n]>>>8),e[t+n]^=this.S[n]}nextState(){for(var e=this._X,t=this._C,r=0;r<8;r++)this.C[r]=t[r];t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<this.C[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<this.C[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<this.C[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<this.C[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<this.C[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<this.C[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<this.C[6]>>>0?1:0)|0,this._b=t[7]>>>0<this.C[7]>>>0?1:0;for(var n=0;n<8;n++){var o=e[n]+t[n],i=65535&o,s=o>>>16,a=((i*i>>>17)+i*s>>>15)+s*s,c=((4294901760&o)*o|0)+((65535&o)*o|0);this.G[n]=a^c}var u=this.G;e[0]=u[0]+(u[7]<<16|u[7]>>>16)+(u[6]<<16|u[6]>>>16)|0,e[1]=u[1]+(u[0]<<8|u[0]>>>24)+u[7]|0,e[2]=u[2]+(u[1]<<16|u[1]>>>16)+(u[0]<<16|u[0]>>>16)|0,e[3]=u[3]+(u[2]<<8|u[2]>>>24)+u[1]|0,e[4]=u[4]+(u[3]<<16|u[3]>>>16)+(u[2]<<16|u[2]>>>16)|0,e[5]=u[5]+(u[4]<<8|u[4]>>>24)+u[3]|0,e[6]=u[6]+(u[5]<<16|u[5]>>>16)+(u[4]<<16|u[4]>>>16)|0,e[7]=u[7]+(u[6]<<8|u[6]>>>24)+u[5]|0}static createEncryptor(e,t){return t=void 0===t?{}:t,new pr(Object.assign(Object.assign({},t),{key:e}))}static createDecryptor(e,t){return t=void 0===t?{}:t,new pr(Object.assign(Object.assign({},t),{key:e}))}static encrypt(e,t,r){return"string"==typeof t?dt.encrypt(pr,e,t,r):lt.encrypt(pr,e,t,r)}static decrypt(e,t,r){return"string"==typeof t?dt.decrypt(pr,e,t,r):lt.decrypt(pr,e,t,r)}}pr.ivSize=4;class yr extends hr{constructor(e){super(e),this.S=[],this.i=0,this.j=0,this._props=e,this._doReset()}_doReset(){var e=this._key,t=e.words,r=e.nSigBytes;this.S=[];for(var n=0;n<256;n++)this.S[n]=n;for(var o=0,i=0;o<256;o++){var s=o%r,a=t[s>>>2]>>>24-s%4*8&255;i=(i+this.S[o]+a)%256;var c=this.S[o];this.S[o]=this.S[i],this.S[i]=c}this.i=this.j=0}_doProcessBlock(e,t){e[t]^=this.generateKeyStreamWord()}generateKeyStreamWord(){for(var e=this.S,t=this.i,r=this.j,n=0,o=0;o<4;o++){r=(r+e[t=(t+1)%256])%256;var i=e[t];e[t]=e[r],e[r]=i,n|=e[(e[t]+e[r])%256]<<24-8*o}return this.i=t,this.j=r,n}static createEncryptor(e,t){return t=void 0===t?{}:t,new yr(Object.assign(Object.assign({},t),{key:e}))}static createDecryptor(e,t){return t=void 0===t?{}:t,new yr(Object.assign(Object.assign({},t),{key:e}))}static encrypt(e,t,r){return"string"==typeof t?dt.encrypt(yr,e,t,r):lt.encrypt(yr,e,t,r)}static decrypt(e,t,r){return"string"==typeof t?dt.decrypt(yr,e,t,r):lt.decrypt(yr,e,t,r)}}yr.ivSize=0,yr.keySize=8;class fr extends yr{constructor(e){super(e),this.drop=192,this._props=e,e&&"number"==typeof e.drop&&(this.drop=e.drop),this._doReset()}_doReset(){super._doReset();for(var e=this.drop;e>0;e--)this.generateKeyStreamWord()}static createEncryptor(e,t){return t=void 0===t?{}:t,new fr(Object.assign(Object.assign({},t),{key:e}))}static createDecryptor(e,t){return t=void 0===t?{}:t,new fr(Object.assign(Object.assign({},t),{key:e}))}static encrypt(e,t,r){return"string"==typeof t?dt.encrypt(fr,e,t,r):lt.encrypt(fr,e,t,r)}static decrypt(e,t,r){return"string"==typeof t?dt.decrypt(fr,e,t,r):lt.decrypt(fr,e,t,r)}}class gr extends vt{constructor(e){super(e),this._prevBlock=[]}generateKeyStreamAndEncrypt(e,t,r,n){var o,i=this._iv;i?(o=i.words.slice(0),this._iv=void 0):o=this._prevBlock,n.encryptBlock(o,0);for(var s=0;s<r;s++)e[t+s]^=o[s]}static createEncryptor(e){return new gr.Encryptor(e)}static createDecryptor(e){return new gr.Decryptor(e)}}gr.Encryptor=class extends gr{processBlock(e,t){this.generateKeyStreamAndEncrypt(e,t,this._cipher.blockSize,this._cipher),this._prevBlock=e.slice(t,t+this._cipher.blockSize)}},gr.Decryptor=class extends gr{processBlock(e,t){var r=e.slice(t,t+this._cipher.blockSize);this.generateKeyStreamAndEncrypt(e,t,this._cipher.blockSize,this._cipher),this._prevBlock=r}};class br extends vt{constructor(e){super(e),this._counter=[]}static createEncryptor(e){return new br.Encryptor(e)}static createDecryptor(e){return new br.Decryptor(e)}}br.Encryptor=class extends br{processBlock(e,t){var r=this._cipher,n=r.blockSize,o=this._iv,i=this._counter;o&&(i=this._counter=o.words.slice(0),this._iv=void 0);var s=i.slice(0);r.encryptBlock(s,0),i[n-1]=i[n-1]+1|0;for(var a=0;a<n;a++)e[t+a]^=s[a]}},br.Decryptor=br.Encryptor;class mr extends vt{constructor(e){super(e)}static createEncryptor(e){return new mr.Encryptor(e)}static createDecryptor(e){return new mr.Decryptor(e)}}mr.Encryptor=class extends mr{processBlock(e,t){this._cipher.encryptBlock(e,t)}},mr.Decryptor=class extends mr{processBlock(e,t){this._cipher.decryptBlock(e,t)}};class wr extends vt{constructor(e){super(e),this._keyStream=[]}static createEncryptor(e){return new wr.Encryptor(e)}static createDecryptor(e){return new wr.Decryptor(e)}}wr.Encryptor=class extends wr{processBlock(e,t){var r=this._cipher,n=r.blockSize,o=this._iv,i=this._keyStream;o&&(i=this._keyStream=o.words.slice(0),this._iv=void 0),r.encryptBlock(i,0);for(var s=0;s<n;s++)e[t+s]^=i[s]}},wr.Decryptor=wr.Encryptor;var vr={pad:function(e,t){var r=4*t;e.clamp(),e.nSigBytes+=r-(e.nSigBytes%r||r)},unpad:function(e){for(var t=e.words,r=e.nSigBytes-1;r>=0;r--)if(t[r>>>2]>>>24-r%4*8&255){e.nSigBytes=r+1;break}}};var kr,Sr={CBC:kt,CFB:gr,CTR:br,ECB:mr,OFB:wr,GCM:Lt,CCM:_t},Or={AnsiX923:{pad:function(e,t){var r=e.nSigBytes,n=4*t,o=n-r%n,i=r+o-1;e.clamp(),e.words[i>>>2]|=o<<24-i%4*8,e.nSigBytes+=o},unpad:function(e){var t=255&e.words[e.nSigBytes-1>>>2];e.nSigBytes-=t}},ISO10126:{pad:function(e,t){var r=4*t,n=r-e.nSigBytes%r;e.concat(Ce.random(n-1)).concat(new Ce([n<<24],1))},unpad:function(e){var t=255&e.words[e.nSigBytes-1>>>2];e.nSigBytes-=t}},ISO97971:{pad:function(e,t){e.concat(new Ce([2147483648],1)),vr.pad(e,t)},unpad:function(e){vr.unpad(e),e.nSigBytes-=1}},Pkcs7:St,NoPadding:{pad:function(e,t){},unpad:function(e){}},Zero:vr},Ar={OpenSSLFormatter:Fe},Ir=Object.freeze({__proto__:null,AES:Nt,Base64:Ne,CBCMAC:function(e,t,r,n,o,i){var s=i&&i.Cipher?i.Cipher:Nt,a="string"==typeof r?Ke.parse(r):r,c=n||new Ce([0,0]),u="string"==typeof t?Ke.parse(t):t,l="string"==typeof e?Ke.parse(e):e,d=o||16;return _t.mac(s,a,c,u,l,d)},CipherParams:ze,DES:Zt,DES3:Qt,EvpKDF:ct,GMAC:function(e,t,r,n,o){var i="string"==typeof e?Ke.parse(e):e,s=r||new Ce([0,0,0,0]),a=o&&o.Cipher?o.Cipher:Nt,c="string"==typeof t?Ke.parse(t):t,u=n||16;return Lt.mac(a,c,s,i,void 0,u)},Hex:Ee,Hmac:Qe,HmacMD5:function(e,t){return new Qe(new at,t).finalize(e)},HmacSHA1:function(e,t){return new Qe(new pt,t).finalize(e)},HmacSHA224:function(e,t){return new Qe(new yt,t).finalize(e)},HmacSHA256:function(e,t){return new Qe(new Ze,t).finalize(e)},HmacSHA384:function(e,t){return new Qe(new mt,t).finalize(e)},HmacSHA512:function(e,t){return new Qe(new bt,t).finalize(e)},Latin1:Ue,MD5:at,OpenSSLKDF:tt,PBKDF2:et,PasswordBasedCipher:dt,RC4:yr,RC4Drop:fr,RIPEMD160:dr,Rabbit:pr,SHA1:pt,SHA224:yt,SHA256:Ze,SHA3:Vt,SHA384:mt,SHA512:bt,SerializableCipher:lt,Utf16:Me,Utf16BE:qe,Utf16LE:_e,Utf8:Ke,Word32Array:Ce,Word64:Be,Word64Array:Te,formatter:Ar,mode:Sr,pad:Or}),xr={},Pr={};var Er,Cr,Br={};function Tr(){return Er||(Er=1,Br.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,c=(1<<a)-1,u=c>>1,l=-7,d=r?o-1:0,h=r?-1:1,p=e[t+d];for(d+=h,i=p&(1<<-l)-1,p>>=-l,l+=a;l>0;i=256*i+e[t+d],d+=h,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+e[t+d],d+=h,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=u}return(p?-1:1)*s*Math.pow(2,i-n)},Br.write=function(e,t,r,n,o,i){var s,a,c,u=8*i-o-1,l=(1<<u)-1,d=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,f=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(s++,c/=2),s+d>=l?(a=0,s=l):s+d>=1?(a=(t*c-1)*Math.pow(2,o),s+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,o),s=0));o>=8;e[r+p]=255&a,p+=y,a/=256,o-=8);for(s=s<<o|a,u+=o;u>0;e[r+p]=255&s,p+=y,s/=256,u-=8);e[r+p-y]|=128*f}),Br}var Dr=(Cr||(Cr=1,function(e){var t=function(){if(kr)return Pr;kr=1,Pr.byteLength=function(e){var t=i(e),r=t[0],n=t[1];return 3*(r+n)/4-n},Pr.toByteArray=function(e){var n,o,s=i(e),a=s[0],c=s[1],u=new r(function(e,t,r){return 3*(t+r)/4-r}(0,a,c)),l=0,d=c>0?a-4:a;for(o=0;o<d;o+=4)n=t[e.charCodeAt(o)]<<18|t[e.charCodeAt(o+1)]<<12|t[e.charCodeAt(o+2)]<<6|t[e.charCodeAt(o+3)],u[l++]=n>>16&255,u[l++]=n>>8&255,u[l++]=255&n;return 2===c&&(n=t[e.charCodeAt(o)]<<2|t[e.charCodeAt(o+1)]>>4,u[l++]=255&n),1===c&&(n=t[e.charCodeAt(o)]<<10|t[e.charCodeAt(o+1)]<<4|t[e.charCodeAt(o+2)]>>2,u[l++]=n>>8&255,u[l++]=255&n),u},Pr.fromByteArray=function(t){for(var r,n=t.length,o=n%3,i=[],a=16383,c=0,u=n-o;c<u;c+=a)i.push(s(t,c,c+a>u?u:c+a));return 1===o?(r=t[n-1],i.push(e[r>>2]+e[r<<4&63]+"==")):2===o&&(r=(t[n-2]<<8)+t[n-1],i.push(e[r>>10]+e[r>>4&63]+e[r<<2&63]+"=")),i.join("")};for(var e=[],t=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)e[o]=n[o],t[n.charCodeAt(o)]=o;function i(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function s(t,r,n){for(var o,i,s=[],a=r;a<n;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(e[(i=o)>>18&63]+e[i>>12&63]+e[i>>6&63]+e[63&i]);return s.join("")}return t["-".charCodeAt(0)]=62,t["_".charCodeAt(0)]=63,Pr}(),r=Tr(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=s,e.SlowBuffer=function(e){return+e!=e&&(e=0),s.alloc(+e)},e.INSPECT_MAX_BYTES=50;var o=2147483647;function i(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return u(e)}return a(e,t,r)}function a(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|p(e,t),n=i(r),o=n.write(e,t);return o!==r&&(n=n.slice(0,o)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(W(e,Uint8Array)){var t=new Uint8Array(e);return d(t.buffer,t.byteOffset,t.byteLength)}return l(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(W(e,ArrayBuffer)||e&&W(e.buffer,ArrayBuffer))return d(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(W(e,SharedArrayBuffer)||e&&W(e.buffer,SharedArrayBuffer)))return d(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return s.from(n,t,r);var o=function(e){if(s.isBuffer(e)){var t=0|h(e.length),r=i(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||J(e.length)?i(0):l(e):"Buffer"===e.type&&Array.isArray(e.data)?l(e.data):void 0}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return s.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function u(e){return c(e),i(e<0?0:0|h(e))}function l(e){for(var t=e.length<0?0:0|h(e.length),r=i(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function d(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,s.prototype),n}function h(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function p(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||W(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(e).length;default:if(o)return n?-1:G(e).length;t=(""+t).toLowerCase(),o=!0}}function y(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return E(this,t,r);case"utf8":case"utf-8":return A(this,t,r);case"ascii":return x(this,t,r);case"latin1":case"binary":return P(this,t,r);case"base64":return O(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function f(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,o){var i,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var l=-1;for(i=r;i<a;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(r+c>a&&(r=a-c),i=r;i>=0;i--){for(var d=!0,h=0;h<c;h++)if(u(e,i+h)!==u(t,h)){d=!1;break}if(d)return i}return-1}function m(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i,s=t.length;for(n>s/2&&(n=s/2),i=0;i<n;++i){var a=parseInt(t.substr(2*i,2),16);if(J(a))return i;e[r+i]=a}return i}function w(e,t,r,n){return H(G(t,e.length-r),e,r,n)}function v(e,t,r,n){return H(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function k(e,t,r,n){return H(V(t),e,r,n)}function S(e,t,r,n){return H(function(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function O(e,r,n){return 0===r&&n===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,n))}function A(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i=e[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a<=r){var c=void 0,u=void 0,l=void 0,d=void 0;switch(a){case 1:i<128&&(s=i);break;case 2:128==(192&(c=e[o+1]))&&(d=(31&i)<<6|63&c)>127&&(s=d);break;case 3:c=e[o+1],u=e[o+2],128==(192&c)&&128==(192&u)&&(d=(15&i)<<12|(63&c)<<6|63&u)>2047&&(d<55296||d>57343)&&(s=d);break;case 4:c=e[o+1],u=e[o+2],l=e[o+3],128==(192&c)&&128==(192&u)&&128==(192&l)&&(d=(15&i)<<18|(63&c)<<12|(63&u)<<6|63&l)>65535&&d<1114112&&(s=d)}}null===s?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),o+=a}return function(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=I));return r}(n)}e.kMaxLength=o,s.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),!s.TYPED_ARRAY_SUPPORT&&"undefined"!=typeof console&&console.error,Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(e,t,r){return a(e,t,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(e,t,r){return function(e,t,r){return c(e),e<=0?i(e):void 0!==t?"string"==typeof r?i(e).fill(t,r):i(e).fill(t):i(e)}(e,t,r)},s.allocUnsafe=function(e){return u(e)},s.allocUnsafeSlow=function(e){return u(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(W(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),W(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o<i;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=s.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var i=e[r];if(W(i,Uint8Array))o+i.length>n.length?(s.isBuffer(i)||(i=s.from(i)),i.copy(n,o)):Uint8Array.prototype.set.call(n,i,o);else{if(!s.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o)}o+=i.length}return n},s.byteLength=p,s.prototype._isBuffer=!0,s.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)f(this,t,t+1);return this},s.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)f(this,t,t+3),f(this,t+1,t+2);return this},s.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)f(this,t,t+7),f(this,t+1,t+6),f(this,t+2,t+5),f(this,t+3,t+4);return this},s.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?A(this,0,e):y.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},n&&(s.prototype[n]=s.prototype.inspect),s.prototype.compare=function(e,t,r,n,o){if(W(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),c=Math.min(i,a),u=this.slice(n,o),l=e.slice(t,r),d=0;d<c;++d)if(u[d]!==l[d]){i=u[d],a=l[d];break}return i<a?-1:a<i?1:0},s.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},s.prototype.indexOf=function(e,t,r){return g(this,e,t,r,!0)},s.prototype.lastIndexOf=function(e,t,r){return g(this,e,t,r,!1)},s.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":case"latin1":case"binary":return v(this,e,t,r);case"base64":return k(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function x(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function P(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function E(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=$[e[i]];return o}function C(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function B(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function T(e,t,r,n,o,i){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function D(e,t,r,n,o){_(t,n,o,e,r,7);var i=Number(t&BigInt(4294967295));e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i;var s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function R(e,t,r,n,o){_(t,n,o,e,r,7);var i=Number(t&BigInt(4294967295));e[r+7]=i,i>>=8,e[r+6]=i,i>>=8,e[r+5]=i,i>>=8,e[r+4]=i;var s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function j(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(e,t,n,o,i){return t=+t,n>>>=0,i||j(e,0,n,4),r.write(e,t,n,o,23,4),n+4}function U(e,t,n,o,i){return t=+t,n>>>=0,i||j(e,0,n,8),r.write(e,t,n,o,52,8),n+8}s.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,s.prototype),n},s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=Y((function(e){M(e>>>=0,"offset");var t=this[e],r=this[e+7];void 0!==t&&void 0!==r||F(e,this.length-8);var n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,o=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))})),s.prototype.readBigUInt64BE=Y((function(e){M(e>>>=0,"offset");var t=this[e],r=this[e+7];void 0!==t&&void 0!==r||F(e,this.length-8);var n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],o=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<<BigInt(32))+BigInt(o)})),s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},s.prototype.readInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||B(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||B(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=Y((function(e){M(e>>>=0,"offset");var t=this[e],r=this[e+7];void 0!==t&&void 0!==r||F(e,this.length-8);var n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),s.prototype.readBigInt64BE=Y((function(e){M(e>>>=0,"offset");var t=this[e],r=this[e+7];void 0!==t&&void 0!==r||F(e,this.length-8);var n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)})),s.prototype.readFloatLE=function(e,t){return e>>>=0,t||B(e,4,this.length),r.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||B(e,4,this.length),r.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||B(e,8,this.length),r.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||B(e,8,this.length),r.read(this,e,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||T(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||T(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeBigUInt64LE=Y((function(e){return D(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=Y((function(e){return R(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);T(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s|0)-a&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);T(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s|0)-a&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeBigInt64LE=Y((function(e){return D(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=Y((function(e){return R(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(e,t,r){return N(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return N(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return U(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return U(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),o},s.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var o=e.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(e=o)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var a=s.isBuffer(e)?e:s.from(e,n),c=a.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=a[i%c]}return this};var K={};function q(e,t,r){K[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name="".concat(this.name," [").concat(e,"]"),this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return"".concat(this.name," [").concat(e,"]: ").concat(this.message)}}}function L(e){for(var t="",r=e.length,n="-"===e[0]?1:0;r>=n+4;r-=3)t="_".concat(e.slice(r-3,r)).concat(t);return"".concat(e.slice(0,r)).concat(t)}function _(e,t,r,n,o,i){if(e>r||e<t){var s,a="bigint"==typeof t?"n":"";throw s=0===t||t===BigInt(0)?">= 0".concat(a," and < 2").concat(a," ** ").concat(8*(i+1)).concat(a):">= -(2".concat(a," ** ").concat(8*(i+1)-1).concat(a,") and < 2 ** ")+"".concat(8*(i+1)-1).concat(a),new K.ERR_OUT_OF_RANGE("value",s,e)}!function(e,t,r){M(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||F(t,e.length-(r+1))}(n,o,i)}function M(e,t){if("number"!=typeof e)throw new K.ERR_INVALID_ARG_TYPE(t,"number",e)}function F(e,t,r){if(Math.floor(e)!==e)throw M(e,r),new K.ERR_OUT_OF_RANGE("offset","an integer",e);if(t<0)throw new K.ERR_BUFFER_OUT_OF_BOUNDS;throw new K.ERR_OUT_OF_RANGE("offset",">= ".concat(0," and <= ").concat(t),e)}q("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?"".concat(e," is outside of buffer bounds"):"Attempt to access memory outside buffer bounds"}),RangeError),q("ERR_INVALID_ARG_TYPE",(function(e,t){return'The "'.concat(e,'" argument must be of type number. Received type ').concat(typeof t)}),TypeError),q("ERR_OUT_OF_RANGE",(function(e,t,r){var n='The value of "'.concat(e,'" is out of range.'),o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=L(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=L(o)),o+="n"),n+=" It must be ".concat(t,". Received ").concat(o)}),RangeError);var z=/[^+/0-9A-Za-z-_]/g;function G(e,t){var r;t=t||1/0;for(var n=e.length,o=null,i=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function V(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,r,n){var o;for(o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function W(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function J(e){return e!=e}var $=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var n=16*r,o=0;o<16;++o)t[n+o]=e[r]+e[o];return t}();function Y(e){return"undefined"==typeof BigInt?Z:e}function Z(){throw new Error("BigInt not supported")}}(xr)),xr),Rr=R({__proto__:null,default:o.getDefaultExportFromCjs(Dr)},[Dr]);const{Buffer:jr}=Rr;async function Nr(e){const t=await crypto.subtle.digest("SHA-256",e);return new Uint8Array(t)}function Ur(...e){const t=e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return r}function Kr(e){const t=new ArrayBuffer(8),r=new DataView(t);return r.setUint32(0,4294967295&e,!0),r.setUint32(4,Math.floor(e/2**32),!0),new Uint8Array(t)}function qr(e){const t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e,!0),new Uint8Array(t)}const Lr=e=>new Promise((t=>setTimeout(t,e)));function _r(e,t){if(e.byteLength!=t.byteLength)return!1;const r=new DataView(e.buffer,e.byteOffset),n=new DataView(t.buffer,t.byteOffset);for(let t=0;t<e.length;t++)if(r.getUint8(t)!==n.getUint8(t))return!1;return!0}function Mr(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}async function Fr(e,t){const r=(e=>btoa(String.fromCharCode(...e)))(t.raw);localStorage.setItem(e,r)}async function zr(e){const t=localStorage.getItem(e);if(t){return n.keys.privateKeyFromRaw((r=t,Uint8Array.from(atob(r),(e=>e.charCodeAt(0)))))}var r;return null}function Gr(e){const t=e.startsWith("0x")?e.slice(2):e;return jr.from(t,"hex").toString("ascii")}function Vr(e){return JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t))}function Hr(e){const t=String(e).trim();if(!/^\d+(\.\d+)?$/.test(t))throw new Error("只接受非负数字(可带小数)");const r=t.split(".");let n=r[0]??"0",o=r[1]??"";if(n=n.replace(/^0+/,"")||"0",n.length>30)throw new Error("整数部分超过 20 位宽度");const i=n.padStart(20,"0");return o?`${i}.${o}`:i}var Wr,Jr,$r,Yr;exports.AIStreamResponseFlag=void 0,(Wr=exports.AIStreamResponseFlag||(exports.AIStreamResponseFlag={}))[Wr.STREAMING=0]="STREAMING",Wr[Wr.STREAMING_REASON=1]="STREAMING_REASON",Wr[Wr.PERMISSION_DENIED=2]="PERMISSION_DENIED",Wr[Wr.FETCH_FAILED=3]="FETCH_FAILED",Wr[Wr.CONNECTION_CLOSED=4]="CONNECTION_CLOSED",Wr[Wr.TOKEN_LIMIT_EXCEEDED=5]="TOKEN_LIMIT_EXCEEDED",Wr[Wr.TOOLCALL=6]="TOOLCALL",Wr[Wr.EXTERNAL_EXIT=7]="EXTERNAL_EXIT",Wr[Wr.STREAM_HANG=88]="STREAM_HANG",Wr[Wr.OTHER_ERROR=99]="OTHER_ERROR",exports.NFTBindStatus=void 0,(Jr=exports.NFTBindStatus||(exports.NFTBindStatus={}))[Jr.Success=0]="Success",Jr[Jr.UserBinded=1]="UserBinded",Jr[Jr.NftAccountBinded=2]="NftAccountBinded",Jr[Jr.NoBcAccount=3]="NoBcAccount",Jr[Jr.DcPeerNotConnected=4]="DcPeerNotConnected",Jr[Jr.EncryptError=5]="EncryptError",Jr[Jr.BlockchainError=6]="BlockchainError",Jr[Jr.SignError=7]="SignError",Jr[Jr.SpaceExpired=8]="SpaceExpired",Jr[Jr.NoLeftSpace=9]="NoLeftSpace",Jr[Jr.NetworkErr=10]="NetworkErr",Jr[Jr.Error=99]="Error",exports.UploadStatus=void 0,($r=exports.UploadStatus||(exports.UploadStatus={}))[$r.OK=0]="OK",$r[$r.ENCRYPTING=1]="ENCRYPTING",$r[$r.UPLOADING=2]="UPLOADING",$r[$r.ERROR=3]="ERROR",$r[$r.ABNORMAL=4]="ABNORMAL",$r[$r.PULLERROR=5]="PULLERROR",$r[$r.FILESIZEERROR=6]="FILESIZEERROR",$r[$r.FILECOUNTERROR=7]="FILECOUNTERROR",$r[$r.NOSPACE=8]="NOSPACE",exports.PeerStatus=void 0,(Yr=exports.PeerStatus||(exports.PeerStatus={}))[Yr.PeerStatusOffline=1]="PeerStatusOffline",Yr[Yr.PeerStatusJoining=2]="PeerStatusJoining",Yr[Yr.PeerStatusOnline=3]="PeerStatusOnline",Yr[Yr.PeerStatusStaked=4]="PeerStatusStaked",Yr[Yr.PeerStatusErr=5]="PeerStatusErr",Yr[Yr.PeerStatusClose=6]="PeerStatusClose",Yr[Yr.PeerStatusDiscard=7]="PeerStatusDiscard";var Zr=BigInt(0),Qr=BigInt(1);function Xr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function en(e){if(!Xr(e))throw new Error("Uint8Array expected")}function tn(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function rn(e){var t=e.toString(16);return 1&t.length?"0"+t:t}function nn(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Zr:BigInt("0x"+e)}var on="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,sn=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function an(e){if(en(e),on)return e.toHex();for(var t="",r=0;r<e.length;r++)t+=sn[e[r]];return t}var cn=48,un=57,ln=65,dn=70,hn=97,pn=102;function yn(e){return e>=cn&&e<=un?e-cn:e>=ln&&e<=dn?e-(ln-10):e>=hn&&e<=pn?e-(hn-10):void 0}function fn(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(on)return Uint8Array.fromHex(e);var t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);for(var n=new Uint8Array(r),o=0,i=0;o<r;o++,i+=2){var s=yn(e.charCodeAt(i)),a=yn(e.charCodeAt(i+1));if(void 0===s||void 0===a){var c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=16*s+a}return n}function gn(e){return nn(an(e))}function bn(e){return en(e),nn(an(Uint8Array.from(e).reverse()))}function mn(e,t){return fn(e.toString(16).padStart(2*t,"0"))}function wn(e,t){return mn(e,t).reverse()}function vn(e,t,r){var n;if("string"==typeof t)try{n=fn(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Xr(t))throw new Error(e+" must be hex string or Uint8Array");n=Uint8Array.from(t)}var o=n.length;if("number"==typeof r&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}function kn(){for(var e=0,t=0;t<arguments.length;t++){var r=t<0||arguments.length<=t?void 0:arguments[t];en(r),e+=r.length}for(var n=new Uint8Array(e),o=0,i=0;o<arguments.length;o++){var s=o<0||arguments.length<=o?void 0:arguments[o];n.set(s,i),i+=s.length}return n}var Sn=e=>"bigint"==typeof e&&Zr<=e;function On(e,t,r){return Sn(e)&&Sn(t)&&Sn(r)&&t<=e&&e<r}function An(e,t,r,n){if(!On(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}var In=e=>(Qr<<BigInt(e))-Qr,xn=e=>new Uint8Array(e),Pn=e=>Uint8Array.from(e);var En={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||Xr(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function Cn(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=(t,r,n)=>{var o=En[r];if("function"!=typeof o)throw new Error("invalid validator function");var i=e[t];if(!(n&&void 0===i||o(i,e)))throw new Error("param "+String(t)+" is invalid. Expected "+r+", got "+i)};for(var[o,i]of Object.entries(t))n(o,i,!1);for(var[s,a]of Object.entries(r))n(s,a,!0);return e}function Bn(e){var t=new WeakMap;return function(r){var n=t.get(r);if(void 0!==n)return n;for(var o=arguments.length,i=new Array(o>1?o-1:0),s=1;s<o;s++)i[s-1]=arguments[s];var a=e(r,...i);return t.set(r,a),a}}var Tn="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Dn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Rn(e){if(!((t=e)instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name))throw new Error("Uint8Array expected");for(var t,r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];if(n.length>0&&!n.includes(e.length))throw new Error("Uint8Array expected of length "+n+", got length="+e.length)}function jn(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");Dn(e.outputLen),Dn(e.blockLen)}function Nn(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Un(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var n=0;n<t.length;n++)t[n].fill(0)}function Kn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function qn(e,t){return e<<32-t|e>>>t}var Ln=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),_n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Mn(e){if(Rn(e),Ln)return e.toHex();for(var t="",r=0;r<e.length;r++)t+=_n[e[r]];return t}var Fn=48,zn=57,Gn=65,Vn=70,Hn=97,Wn=102;function Jn(e){return e>=Fn&&e<=zn?e-Fn:e>=Gn&&e<=Vn?e-(Gn-10):e>=Hn&&e<=Wn?e-(Hn-10):void 0}function $n(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Ln)return Uint8Array.fromHex(e);var t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);for(var n=new Uint8Array(r),o=0,i=0;o<r;o++,i+=2){var s=Jn(e.charCodeAt(i)),a=Jn(e.charCodeAt(i+1));if(void 0===s||void 0===a){var c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=16*s+a}return n}function Yn(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),Rn(e),e}class Zn{}function Qn(e){var t=t=>e().update(Yn(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Xn(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(Tn&&"function"==typeof Tn.getRandomValues)return Tn.getRandomValues(new Uint8Array(e));if(Tn&&"function"==typeof Tn.randomBytes)return Uint8Array.from(Tn.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function eo(e,t,r){return e&t^e&r^t&r}class to extends Zn{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Kn(this.buffer)}update(e){Nn(this),Rn(e=Yn(e));for(var{view:t,buffer:r,blockLen:n}=this,o=e.length,i=0;i<o;){var s=Math.min(n-this.pos,o-i);if(s!==n)r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===n&&(this.process(t,0),this.pos=0);else for(var a=Kn(e);n<=o-i;i+=n)this.process(a,i)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Nn(this),function(e,t){Rn(e);var r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;var{buffer:t,view:r,blockLen:n,isLE:o}=this,{pos:i}=this;t[i++]=128,Un(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(r,0),i=0);for(var s=i;s<n;s++)t[s]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);var o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,u=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+u,a,n)}(r,n-8,BigInt(8*this.length),o),this.process(r,0);var a=Kn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");var u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(var d=0;d<u;d++)a.setUint32(4*d,l[d],o)}digest(){var{buffer:e,outputLen:t}=this;this.digestInto(e);var r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());var{blockLen:t,buffer:r,length:n,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=n,e.pos=s,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}var ro=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),no=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),oo=BigInt(2**32-1),io=BigInt(32);function so(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?{h:Number(e&oo),l:Number(e>>io&oo)}:{h:0|Number(e>>io&oo),l:0|Number(e&oo)}}var ao=(e,t,r)=>e>>>r,co=(e,t,r)=>e<<32-r|t>>>r,uo=(e,t,r)=>e>>>r|t<<32-r,lo=(e,t,r)=>e<<32-r|t>>>r,ho=(e,t,r)=>e<<64-r|t>>>r-32,po=(e,t,r)=>e>>>r-32|t<<64-r;function yo(e,t,r,n){var o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:0|o}}var fo=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),go=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,bo=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),mo=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,wo=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),vo=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0,ko=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),So=new Uint32Array(64);class Oo extends to{constructor(){super(64,arguments.length>0&&void 0!==arguments[0]?arguments[0]:32,8,!1),this.A=0|ro[0],this.B=0|ro[1],this.C=0|ro[2],this.D=0|ro[3],this.E=0|ro[4],this.F=0|ro[5],this.G=0|ro[6],this.H=0|ro[7]}get(){var{A:e,B:t,C:r,D:n,E:o,F:i,G:s,H:a}=this;return[e,t,r,n,o,i,s,a]}set(e,t,r,n,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(var r=0;r<16;r++,t+=4)So[r]=e.getUint32(t,!1);for(var n=16;n<64;n++){var o=So[n-15],i=So[n-2],s=qn(o,7)^qn(o,18)^o>>>3,a=qn(i,17)^qn(i,19)^i>>>10;So[n]=a+So[n-7]+s+So[n-16]|0}for(var c,{A:u,B:l,C:d,D:h,E:p,F:y,G:f,H:g}=this,b=0;b<64;b++){var m=g+(qn(p,6)^qn(p,11)^qn(p,25))+((c=p)&y^~c&f)+ko[b]+So[b]|0,w=(qn(u,2)^qn(u,13)^qn(u,22))+eo(u,l,d)|0;g=f,f=y,y=p,p=h+m|0,h=d,d=l,l=u,u=m+w|0}u=u+this.A|0,l=l+this.B|0,d=d+this.C|0,h=h+this.D|0,p=p+this.E|0,y=y+this.F|0,f=f+this.G|0,g=g+this.H|0,this.set(u,l,d,h,p,y,f,g)}roundClean(){Un(So)}destroy(){this.set(0,0,0,0,0,0,0,0),Un(this.buffer)}}var Ao=(()=>function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=e.length,n=new Uint32Array(r),o=new Uint32Array(r),i=0;i<r;i++){var{h:s,l:a}=so(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),Io=(()=>Ao[0])(),xo=(()=>Ao[1])(),Po=new Uint32Array(80),Eo=new Uint32Array(80);class Co extends to{constructor(){super(128,arguments.length>0&&void 0!==arguments[0]?arguments[0]:64,16,!1),this.Ah=0|no[0],this.Al=0|no[1],this.Bh=0|no[2],this.Bl=0|no[3],this.Ch=0|no[4],this.Cl=0|no[5],this.Dh=0|no[6],this.Dl=0|no[7],this.Eh=0|no[8],this.El=0|no[9],this.Fh=0|no[10],this.Fl=0|no[11],this.Gh=0|no[12],this.Gl=0|no[13],this.Hh=0|no[14],this.Hl=0|no[15]}get(){var{Ah:e,Al:t,Bh:r,Bl:n,Ch:o,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:l,Fl:d,Gh:h,Gl:p,Hh:y,Hl:f}=this;return[e,t,r,n,o,i,s,a,c,u,l,d,h,p,y,f]}set(e,t,r,n,o,i,s,a,c,u,l,d,h,p,y,f){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|o,this.Cl=0|i,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|d,this.Gh=0|h,this.Gl=0|p,this.Hh=0|y,this.Hl=0|f}process(e,t){for(var r=0;r<16;r++,t+=4)Po[r]=e.getUint32(t),Eo[r]=e.getUint32(t+=4);for(var n=16;n<80;n++){var o=0|Po[n-15],i=0|Eo[n-15],s=uo(o,i,1)^uo(o,i,8)^ao(o,0,7),a=lo(o,i,1)^lo(o,i,8)^co(o,i,7),c=0|Po[n-2],u=0|Eo[n-2],l=uo(c,u,19)^ho(c,u,61)^ao(c,0,6),d=lo(c,u,19)^po(c,u,61)^co(c,u,6),h=bo(a,d,Eo[n-7],Eo[n-16]),p=mo(h,s,l,Po[n-7],Po[n-16]);Po[n]=0|p,Eo[n]=0|h}for(var{Ah:y,Al:f,Bh:g,Bl:b,Ch:m,Cl:w,Dh:v,Dl:k,Eh:S,El:O,Fh:A,Fl:I,Gh:x,Gl:P,Hh:E,Hl:C}=this,B=0;B<80;B++){var T=uo(S,O,14)^uo(S,O,18)^ho(S,O,41),D=lo(S,O,14)^lo(S,O,18)^po(S,O,41),R=S&A^~S&x,j=wo(C,D,O&I^~O&P,xo[B],Eo[B]),N=vo(j,E,T,R,Io[B],Po[B]),U=0|j,K=uo(y,f,28)^ho(y,f,34)^ho(y,f,39),q=lo(y,f,28)^po(y,f,34)^po(y,f,39),L=y&g^y&m^g&m,_=f&b^f&w^b&w;E=0|x,C=0|P,x=0|A,P=0|I,A=0|S,I=0|O,({h:S,l:O}=yo(0|v,0|k,0|N,0|U)),v=0|m,k=0|w,m=0|g,w=0|b,g=0|y,b=0|f;var M=fo(U,q,_);y=go(M,N,K,L),f=0|M}({h:y,l:f}=yo(0|this.Ah,0|this.Al,0|y,0|f)),({h:g,l:b}=yo(0|this.Bh,0|this.Bl,0|g,0|b)),({h:m,l:w}=yo(0|this.Ch,0|this.Cl,0|m,0|w)),({h:v,l:k}=yo(0|this.Dh,0|this.Dl,0|v,0|k)),({h:S,l:O}=yo(0|this.Eh,0|this.El,0|S,0|O)),({h:A,l:I}=yo(0|this.Fh,0|this.Fl,0|A,0|I)),({h:x,l:P}=yo(0|this.Gh,0|this.Gl,0|x,0|P)),({h:E,l:C}=yo(0|this.Hh,0|this.Hl,0|E,0|C)),this.set(y,f,g,b,m,w,v,k,S,O,A,I,x,P,E,C)}roundClean(){Un(Po,Eo)}destroy(){Un(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}var Bo=Qn((()=>new Oo)),To=Qn((()=>new Co)),Do=BigInt(0),Ro=BigInt(1),jo=BigInt(2),No=BigInt(3),Uo=BigInt(4),Ko=BigInt(5),qo=BigInt(8);function Lo(e,t){var r=e%t;return r>=Do?r:t+r}function _o(e,t,r){for(var n=e;t-- >Do;)n*=n,n%=r;return n}function Mo(e,t){if(e===Do)throw new Error("invert: expected non-zero number");if(t<=Do)throw new Error("invert: expected positive modulus, got "+t);for(var r=Lo(e,t),n=t,o=Do,i=Ro;r!==Do;){var s=n%r,a=o-i*(n/r);n=r,r=s,o=i,i=a}if(n!==Ro)throw new Error("invert: does not exist");return Lo(o,t)}function Fo(e,t){var r=(e.ORDER+Ro)/Uo,n=e.pow(t,r);if(!e.eql(e.sqr(n),t))throw new Error("Cannot find square root");return n}function zo(e,t){var r=(e.ORDER-Ko)/qo,n=e.mul(t,jo),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,jo),o),a=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),t))throw new Error("Cannot find square root");return a}function Go(e){return e%Uo===No?Fo:e%qo===Ko?zo:function(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");for(var t=e-Ro,r=0;t%jo===Do;)t/=jo,r++;for(var n=jo,o=$o(e);1===Wo(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return Fo;var i=o.pow(n,t),s=(t+Ro)/jo;return function(e,n){if(e.is0(n))return n;if(1!==Wo(e,n))throw new Error("Cannot find square root");for(var o=r,a=e.mul(e.ONE,i),c=e.pow(n,t),u=e.pow(n,s);!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;for(var l=1,d=e.sqr(c);!e.eql(d,e.ONE);)if(l++,d=e.sqr(d),l===o)throw new Error("Cannot find square root");var h=Ro<<BigInt(o-l-1),p=e.pow(a,h);o=l,a=e.sqr(p),c=e.mul(c,a),u=e.mul(u,p)}return u}}(e)}var Vo=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ho(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce(((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r))),e.ONE),i=e.inv(o);return t.reduceRight(((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r))),i),n}function Wo(e,t){var r=(e.ORDER-Ro)/jo,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Jo(e,t){void 0!==t&&Dn(t);var r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function $o(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e<=Do)throw new Error("invalid field: expected ORDER > 0, got "+e);var o,{nBitLength:i,nByteLength:s}=Jo(e,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");var a=Object.freeze({ORDER:e,isLE:r,BITS:i,BYTES:s,MASK:In(i),ZERO:Do,ONE:Ro,create:t=>Lo(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return Do<=t&&t<e},is0:e=>e===Do,isOdd:e=>(e&Ro)===Ro,neg:t=>Lo(-t,e),eql:(e,t)=>e===t,sqr:t=>Lo(t*t,e),add:(t,r)=>Lo(t+r,e),sub:(t,r)=>Lo(t-r,e),mul:(t,r)=>Lo(t*r,e),pow:(e,t)=>function(e,t,r){if(r<Do)throw new Error("invalid exponent, negatives unsupported");if(r===Do)return e.ONE;if(r===Ro)return t;for(var n=e.ONE,o=t;r>Do;)r&Ro&&(n=e.mul(n,o)),o=e.sqr(o),r>>=Ro;return n}(a,e,t),div:(t,r)=>Lo(t*Mo(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Mo(t,e),sqrt:n.sqrt||(t=>(o||(o=Go(e)),o(a,t))),toBytes:e=>r?wn(e,s):mn(e,s),fromBytes:e=>{if(e.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+e.length);return r?bn(e):gn(e)},invertBatch:e=>Ho(a,e),cmov:(e,t,r)=>r?t:e});return Object.freeze(a)}function Yo(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");var t=e.toString(2).length;return Math.ceil(t/8)}function Zo(e){var t=Yo(e);return t+Math.ceil(t/2)}var Qo=BigInt(0),Xo=BigInt(1);function ei(e,t){var r=t.negate();return e?r:t}function ti(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ri(e,t){ti(e,t);var r=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:In(e),maxNumber:r,shiftBy:BigInt(e)}}function ni(e,t,r){var{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(e&o),c=e>>s;a>n&&(a-=i,c+=Xo);var u=t*n;return{nextN:c,offset:u+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:u}}var oi=new WeakMap,ii=new WeakMap;function si(e){return ii.get(e)||1}function ai(e,t){return{constTimeNegate:ei,hasPrecomputes:e=>1!==si(e),unsafeLadder(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.ZERO,o=t;r>Qo;)r&Xo&&(n=n.add(o)),o=o.double(),r>>=Xo;return n},precomputeWindow(e,r){for(var{windows:n,windowSize:o}=ri(r,t),i=[],s=e,a=s,c=0;c<n;c++){a=s,i.push(a);for(var u=1;u<o;u++)a=a.add(s),i.push(a);s=a.double()}return i},wNAF(r,n,o){for(var i=e.ZERO,s=e.BASE,a=ri(r,t),c=0;c<a.windows;c++){var{nextN:u,offset:l,isZero:d,isNeg:h,isNegF:p,offsetF:y}=ni(o,c,a);o=u,d?s=s.add(ei(p,n[y])):i=i.add(ei(h,n[l]))}return{p:i,f:s}},wNAFUnsafe(r,n,o){for(var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.ZERO,s=ri(r,t),a=0;a<s.windows&&o!==Qo;a++){var{nextN:c,offset:u,isZero:l,isNeg:d}=ni(o,a,s);if(o=c,!l){var h=n[u];i=i.add(d?h.negate():h)}}return i},getPrecomputes(e,t,r){var n=oi.get(t);return n||(n=this.precomputeWindow(t,e),1!==e&&oi.set(t,r(n))),n},wNAFCached(e,t,r){var n=si(e);return this.wNAF(n,this.getPrecomputes(n,e,r),t)},wNAFCachedUnsafe(e,t,r,n){var o=si(e);return 1===o?this.unsafeLadder(e,t,n):this.wNAFUnsafe(o,this.getPrecomputes(o,e,r),t,n)},setWindowSize(e,r){ti(r,t),ii.set(e,r),oi.delete(e)}}}function ci(e,t,r,n){!function(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)}))}(r,e),function(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)}))}(n,t);var o=r.length,i=n.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");var s=e.ZERO,a=function(e){var t;for(t=0;e>Zr;e>>=Qr,t+=1);return t}(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);for(var u=In(c),l=new Array(Number(u)+1).fill(s),d=s,h=Math.floor((t.BITS-1)/c)*c;h>=0;h-=c){l.fill(s);for(var p=0;p<i;p++){var y=n[p],f=Number(y>>BigInt(h)&u);l[f]=l[f].add(r[p])}for(var g=s,b=l.length-1,m=s;b>0;b--)m=m.add(l[b]),g=g.add(m);if(d=d.add(g),0!==h)for(var w=0;w<c;w++)d=d.double()}return d}function ui(e){var t,r;return t=e.Fp,r=Vo.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}),Cn(t,r),Cn(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze(Z(Z(Z({},Jo(e.n,e.nBitLength)),e),{p:e.Fp.ORDER}))}var li=BigInt(0),di=BigInt(1),hi=BigInt(2),pi=BigInt(8),yi={zip215:!0};function fi(e){var t,r,n=(r=ui(t=e),Cn(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze(Z({},r))),{Fp:o,n:i,prehash:s,hash:a,randomBytes:c,nByteLength:u,h:l}=n,d=hi<<BigInt(8*u)-di,h=o.create,p=$o(n.n,n.nBitLength);if(!function(e,t){var r=o.sqr(e),i=o.sqr(t),s=o.add(o.mul(n.a,r),i),a=o.add(o.ONE,o.mul(n.d,o.mul(r,i)));return o.eql(s,a)}(n.Gx,n.Gy))throw new Error("bad curve params: generator point");var y=n.uvRatio||((e,t)=>{try{return{isValid:!0,value:o.sqrt(e*o.inv(t))}}catch(e){return{isValid:!1,value:li}}}),f=n.adjustScalarBytes||(e=>e),g=n.domain||((e,t,r)=>{if(tn("phflag",r),t.length||r)throw new Error("Contexts/pre-hash are not supported");return e});function b(e,t){An("coordinate "+e,t,arguments.length>2&&void 0!==arguments[2]&&arguments[2]?di:li,d)}function m(e){if(!(e instanceof k))throw new Error("ExtendedPoint expected")}var w=Bn(((e,t)=>{var{ex:r,ey:n,ez:i}=e,s=e.is0();null==t&&(t=s?pi:o.inv(i));var a=h(r*t),c=h(n*t),u=h(i*t);if(s)return{x:li,y:di};if(u!==di)throw new Error("invZ was invalid");return{x:a,y:c}})),v=Bn((e=>{var{a:t,d:r}=n;if(e.is0())throw new Error("bad point: ZERO");var{ex:o,ey:i,ez:s,et:a}=e,c=h(o*o),u=h(i*i),l=h(s*s),d=h(l*l),p=h(c*t);if(h(l*h(p+u))!==h(d+h(r*h(c*u))))throw new Error("bad point: equation left != right (1)");if(h(o*i)!==h(s*a))throw new Error("bad point: equation left != right (2)");return!0}));class k{constructor(e,t,r,n){b("x",e),b("y",t),b("z",r,!0),b("t",n),this.ex=e,this.ey=t,this.ez=r,this.et=n,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof k)throw new Error("extended point not allowed");var{x:t,y:r}=e||{};return b("x",t),b("y",r),new k(t,r,di,h(t*r))}static normalizeZ(e){var t=Ho(o,e.map((e=>e.ez)));return e.map(((e,r)=>e.toAffine(t[r]))).map(k.fromAffine)}static msm(e,t){return ci(k,p,e,t)}_setWindowSize(e){A.setWindowSize(this,e)}assertValidity(){v(this)}equals(e){m(e);var{ex:t,ey:r,ez:n}=this,{ex:o,ey:i,ez:s}=e,a=h(t*s),c=h(o*n),u=h(r*s),l=h(i*n);return a===c&&u===l}is0(){return this.equals(k.ZERO)}negate(){return new k(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){var{a:e}=n,{ex:t,ey:r,ez:o}=this,i=h(t*t),s=h(r*r),a=h(hi*h(o*o)),c=h(e*i),u=t+r,l=h(h(u*u)-i-s),d=c+s,p=d-a,y=c-s,f=h(l*p),g=h(d*y),b=h(l*y),m=h(p*d);return new k(f,g,m,b)}add(e){m(e);var{a:t,d:r}=n,{ex:o,ey:i,ez:s,et:a}=this,{ex:c,ey:u,ez:l,et:d}=e,p=h(o*c),y=h(i*u),f=h(a*r*d),g=h(s*l),b=h((o+i)*(c+u)-p-y),w=g-f,v=g+f,S=h(y-t*p),O=h(b*w),A=h(v*S),I=h(b*S),x=h(w*v);return new k(O,A,x,I)}subtract(e){return this.add(e.negate())}wNAF(e){return A.wNAFCached(this,e,k.normalizeZ)}multiply(e){var t=e;An("scalar",t,di,i);var{p:r,f:n}=this.wNAF(t);return k.normalizeZ([r,n])[0]}multiplyUnsafe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.ZERO,r=e;return An("scalar",r,li,i),r===li?O:this.is0()||r===di?this:A.wNAFCachedUnsafe(this,r,k.normalizeZ,t)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return A.unsafeLadder(this,i).is0()}toAffine(e){return w(this,e)}clearCofactor(){var{h:e}=n;return e===di?this:this.multiplyUnsafe(e)}static fromHex(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{d:r,a:i}=n,s=o.BYTES;e=vn("pointHex",e,s),tn("zip215",t);var a=e.slice(),c=e[s-1];a[s-1]=-129&c;var u=bn(a),l=t?d:o.ORDER;An("pointHex.y",u,li,l);var p=h(u*u),f=h(p-di),g=h(r*p-i),{isValid:b,value:m}=y(f,g);if(!b)throw new Error("Point.fromHex: invalid y coordinate");var w=(m&di)===di,v=!!(128&c);if(!t&&m===li&&v)throw new Error("Point.fromHex: x=0 and x_0=1");return v!==w&&(m=h(-m)),k.fromAffine({x:m,y:u})}static fromPrivateKey(e){var{scalar:t}=P(e);return S.multiply(t)}toRawBytes(){var{x:e,y:t}=this.toAffine(),r=wn(t,o.BYTES);return r[r.length-1]|=e&di?128:0,r}toHex(){return an(this.toRawBytes())}}k.BASE=new k(n.Gx,n.Gy,di,h(n.Gx*n.Gy)),k.ZERO=new k(li,di,di,li);var{BASE:S,ZERO:O}=k,A=ai(k,8*u);function I(e){return Lo(e,i)}function x(e){return I(bn(e))}function P(e){var t=o.BYTES;e=vn("private key",e,t);var r=vn("hashed private key",a(e),2*t),n=f(r.slice(0,t));return{head:n,prefix:r.slice(t,2*t),scalar:x(n)}}function E(e){var{head:t,prefix:r,scalar:n}=P(e),o=S.multiply(n),i=o.toRawBytes();return{head:t,prefix:r,scalar:n,point:o,pointBytes:i}}function C(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Uint8Array.of(),t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var o=kn(...r);return x(a(g(o,vn("context",e),!!s)))}var B=yi;S._setWindowSize(8);var T={getExtendedPublicKey:E,randomPrivateKey:()=>c(o.BYTES),precompute(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.BASE;return t._setWindowSize(e),t.multiply(BigInt(3)),t}};return{CURVE:n,getPublicKey:function(e){return E(e).pointBytes},sign:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e=vn("message",e),s&&(e=s(e));var{prefix:n,scalar:a,pointBytes:c}=E(t),u=C(r.context,n,e),l=S.multiply(u).toRawBytes(),d=I(u+C(r.context,l,c,e)*a);return An("signature.s",d,li,i),vn("result",kn(l,wn(d,o.BYTES)),2*o.BYTES)},verify:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:B,{context:i,zip215:a}=n,c=o.BYTES;e=vn("signature",e,2*c),t=vn("message",t),r=vn("publicKey",r,c),void 0!==a&&tn("zip215",a),s&&(t=s(t));var u,l,d,h=bn(e.slice(c,2*c));try{u=k.fromHex(r,a),l=k.fromHex(e.slice(0,c),a),d=S.multiplyUnsafe(h)}catch(e){return!1}if(!a&&u.isSmallOrder())return!1;var p=C(i,l.toRawBytes(),u.toRawBytes(),t);return l.add(u.multiplyUnsafe(p)).subtract(d).clearCofactor().equals(k.ZERO)},ExtendedPoint:k,utils:T}}var gi=BigInt(0),bi=BigInt(1),mi=BigInt(2);function wi(e){var t,r=(Cn(t=e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze(Z({},t))),{P:n,type:o,adjustScalarBytes:i,powPminus2:s}=r,a="x25519"===o;if(!a&&"x448"!==o)throw new Error("invalid type");var c=a?255:448,u=a?32:56,l=a?BigInt(9):BigInt(5),d=a?BigInt(121665):BigInt(39081),h=a?mi**BigInt(254):mi**BigInt(447),p=a?BigInt(8)*mi**BigInt(251)-bi:BigInt(4)*mi**BigInt(445)-bi,y=h+p+bi,f=e=>Lo(e,n),g=b(l);function b(e){return wn(f(e),u)}function m(e,t){var r=function(e,t){An("u",e,gi,n),An("scalar",t,h,y);for(var r=t,o=e,i=bi,a=gi,u=e,l=bi,p=gi,g=BigInt(c-1);g>=gi;g--){var b=r>>g&bi;p^=b,({x_2:i,x_3:u}=v(p,i,u)),({x_2:a,x_3:l}=v(p,a,l)),p=b;var m=i+a,w=f(m*m),k=i-a,S=f(k*k),O=w-S,A=u+l,I=f((u-l)*m),x=f(A*k),P=I+x,E=I-x;u=f(P*P),l=f(o*f(E*E)),i=f(w*S),a=f(O*(w+f(d*O)))}({x_2:i,x_3:u}=v(p,i,u)),({x_2:a,x_3:l}=v(p,a,l));var C=s(a);return f(i*C)}(function(e){var t=vn("u coordinate",e,u);return a&&(t[31]&=127),f(bn(t))}(t),function(e){return bn(i(vn("scalar",e,u)))}(e));if(r===gi)throw new Error("invalid private or public key received");return b(r)}function w(e){return m(e,g)}function v(e,t,r){var n=f(e*(t-r));return{x_2:t=f(t-n),x_3:r=f(r+n)}}return{scalarMult:m,scalarMultBase:w,getSharedSecret:(e,t)=>m(e,t),getPublicKey:e=>w(e),utils:{randomPrivateKey:()=>r.randomBytes(u)},GuBytes:g.slice()}}var vi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ki=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);var Si=BigInt(1),Oi=BigInt(2),Ai=BigInt(3),Ii=BigInt(5),xi=BigInt(8);function Pi(e){var t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=vi,s=e*e%i*e%i,a=_o(s,Oi,i)*s%i,c=_o(a,Si,i)*e%i,u=_o(c,Ii,i)*c%i,l=_o(u,t,i)*u%i,d=_o(l,r,i)*l%i,h=_o(d,n,i)*d%i,p=_o(h,o,i)*h%i,y=_o(p,o,i)*h%i,f=_o(y,t,i)*u%i;return{pow_p_5_8:_o(f,Oi,i)*e%i,b2:s}}function Ei(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Ci(e,t){var r=vi,n=Lo(t*t*t,r),o=Lo(n*n*t,r),i=Lo(e*n*Pi(e*o).pow_p_5_8,r),s=Lo(t*i*i,r),a=i,c=Lo(i*ki,r),u=s===e,l=s===Lo(-e,r),d=s===Lo(-e*ki,r);return u&&(i=a),(l||d)&&(i=c),(Lo(i,r)&Ro)===Ro&&(i=Lo(-i,r)),{isValid:u||l,value:i}}var Bi=(()=>$o(vi,void 0,!0))(),Ti=(()=>({a:Bi.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Bi,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:xi,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:To,randomBytes:Xn,adjustScalarBytes:Ei,uvRatio:Ci}))(),Di=(()=>fi(Ti))(),Ri=(()=>wi({P:vi,type:"x25519",powPminus2:e=>{var t=vi,{pow_p_5_8:r,b2:n}=Pi(e);return Lo(_o(r,Ai,t)*n,t)},adjustScalarBytes:Ei,randomBytes:Xn}))(),ji=function e(t,r,n){r=r||[];var o=n=n||0;for(;t>=Ki;)r[n++]=255&t|Ni,t/=128;for(;t&Ui;)r[n++]=255&t|Ni,t>>>=7;return r[n]=0|t,e.bytes=n-o+1,r},Ni=128,Ui=-128,Ki=Math.pow(2,31);var qi=function e(t,r){var n,o=0,i=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],o+=i<28?(n&_i)<<i:(n&_i)*Math.pow(2,i),i+=7}while(n>=Li);return e.bytes=s-r,o},Li=128,_i=127;var Mi=Math.pow(2,7),Fi=Math.pow(2,14),zi=Math.pow(2,21),Gi=Math.pow(2,28),Vi=Math.pow(2,35),Hi=Math.pow(2,42),Wi=Math.pow(2,49),Ji=Math.pow(2,56),$i=Math.pow(2,63),Yi={encode:ji,decode:qi,encodingLength:function(e){return e<Mi?1:e<Fi?2:e<zi?3:e<Gi?4:e<Vi?5:e<Hi?6:e<Wi?7:e<Ji?8:e<$i?9:10}};function Zi(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[Yi.decode(e,t),Yi.decode.bytes]}function Qi(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Yi.encode(e,t,r),t}function Xi(e){return Yi.encodingLength(e)}function es(e,t){var r=t.byteLength,n=Xi(e),o=n+Xi(r),i=new Uint8Array(o+r);return Qi(e,i,0),Qi(r,i,n),i.set(t,o),new rs(e,r,t,i)}function ts(e){var t=ne(e),[r,n]=Zi(t),[o,i]=Zi(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new rs(r,o,s,t)}class rs{constructor(e,t,r,n){W(this,"code",void 0),W(this,"size",void 0),W(this,"digest",void 0),W(this,"bytes",void 0),this.code=e,this.size=t,this.digest=r,this.bytes=n}}var ns=ne;var os={code:0,name:"identity",encode:ns,digest:function(e){return es(0,ns(e))}},is=Object.freeze({__proto__:null,identity:os}),ss=he({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),as=he({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),cs=Object.freeze({__proto__:null,base36:ss,base36upper:as}),us=he({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ls=he({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),ds=Object.freeze({__proto__:null,base58btc:us,base58flickr:ls});function hs(e,t){var{bytes:r,version:n}=e;return 0===n?function(e,t,r){var{prefix:n}=r;if(n!==us.prefix)throw Error("Cannot string encode V0 in ".concat(r.name," encoding"));var o=t.get(n);if(null==o){var i=r.encode(e).slice(1);return t.set(n,i),i}return o}(r,ys(e),null!=t?t:us.encoder):function(e,t,r){var{prefix:n}=r,o=t.get(n);if(null==o){var i=r.encode(e);return t.set(n,i),i}return o}(r,ys(e),null!=t?t:ye.encoder)}var ps=new WeakMap;function ys(e){var t=ps.get(e);if(null==t){var r=new Map;return ps.set(e,r),r}return t}class fs{constructor(e,t,r,n){W(this,"code",void 0),W(this,"version",void 0),W(this,"multihash",void 0),W(this,"bytes",void 0),W(this,"/",void 0),W(this,Symbol.toStringTag,"CID"),this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:var{code:e,multihash:t}=this;if(e!==gs)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==bs)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return fs.createV0(t);default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}toV1(){switch(this.version){case 0:var{code:e,digest:t}=this.multihash,r=es(e,t);return fs.createV1(this.code,r);case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 1. This is a bug please report"))}}equals(e){return fs.equals(this,e)}static equals(e,t){var r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;var r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(var r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}(e.multihash,r.multihash)}toString(e){return hs(this,e)}toJSON(){return{"/":hs(this)}}link(){return this}[Symbol.for("nodejs.util.inspect.custom")](){return"CID(".concat(this.toString(),")")}static asCID(e){if(null==e)return null;var t=e;if(t instanceof fs)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){var{version:r,code:n,multihash:o,bytes:i}=t;return new fs(r,n,o,null!=i?i:ms(r,n,o.bytes))}if(!0===t[vs]){var{version:s,multihash:a,code:c}=t,u=ts(a);return fs.create(s,c,u)}return null}static create(e,t,r){if("number"!=typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==gs)throw new Error("Version 0 CID must use dag-pb (code: ".concat(gs,") block encoding"));return new fs(e,t,r,r.bytes);case 1:var n=ms(e,t,r.bytes);return new fs(e,t,r,n);default:throw new Error("Invalid version")}}static createV0(e){return fs.create(0,gs,e)}static createV1(e,t){return fs.create(1,e,t)}static decode(e){var[t,r]=fs.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){var t=fs.inspectBytes(e),r=t.size-t.multihashSize,n=ne(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");var o=n.subarray(t.multihashSize-t.digestSize),i=new rs(t.multihashCode,t.digestSize,o,n);return[0===t.version?fs.createV0(i):fs.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){var t=0,r=()=>{var[r,n]=Zi(e.subarray(t));return t+=n,r},n=r(),o=gs;if(18===n?(n=0,t=0):o=r(),0!==n&&1!==n)throw new RangeError("Invalid CID version ".concat(n));var i=t,s=r(),a=r(),c=t+a;return{version:n,codec:o,multihashCode:s,digestSize:a,multihashSize:c-i,size:c}}static parse(e,t){var[r,n]=function(e,t){switch(e[0]){case"Q":var r=null!=t?t:us;return[us.prefix,r.decode("".concat(us.prefix).concat(e))];case us.prefix:var n=null!=t?t:us;return[us.prefix,n.decode(e)];case ye.prefix:var o=null!=t?t:ye;return[ye.prefix,o.decode(e)];case ss.prefix:var i=null!=t?t:ss;return[ss.prefix,i.decode(e)];default:if(null==t)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),o=fs.decode(n);if(0===o.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return ys(o).set(r,e),o}}var gs=112,bs=18;function ms(e,t,r){var n=Xi(e),o=n+Xi(t),i=new Uint8Array(o+r.byteLength);return Qi(e,i,0),Qi(t,i,n),i.set(r,o),i}var ws,vs=Symbol.for("@ipld/js-cid/CID");class ks{static toHex(e){return Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("")}static bytesToBigInt(e){let t=Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("");return new c.BigInteger(t,16)}static bigIntToBytes(e,t){const r=e.toString(16).padStart(2*t,"0"),n=new Uint8Array(t);for(let e=0;e<t;e++)n[e]=parseInt(r.slice(2*e,2*e+2),16);return n}static extendedEuclidean(e,t){if(t.equals(c.BigInteger.ZERO))return[e,new c.BigInteger("1"),new c.BigInteger("0")];const[r,n,o]=this.extendedEuclidean(t,e.mod(t));return[r,o,n.subtract(e.divide(t).multiply(o))]}static safeModInverse(e,t){let r=e.mod(t);r.compareTo(c.BigInteger.ZERO)<0&&(r=r.add(t));const[n,o]=this.extendedEuclidean(r,t);if(!n.equals(new c.BigInteger("1")))throw new Error("Modular inverse does not exist");let i=o.mod(t);return i.compareTo(c.BigInteger.ZERO)<0&&(i=i.add(t)),i}static ed25519PublicKeyToCurve25519(e){const t=new Uint8Array(32);for(let r=0;r<32;r++)t[31-r]=e[r];t[0]&=127;const r=this.bytesToBigInt(t),n=new c.BigInteger("1"),o=n.add(r),i=n.subtract(r);try{const e=this.safeModInverse(i,this.CURVE25519_P);let t=o.multiply(e).mod(this.CURVE25519_P);const r=this.bigIntToBytes(t,32),n=new Uint8Array(32);for(let e=0;e<32;e++)n[e]=r[31-e];return n}catch(e){throw e}}static async encrypt(e,t){try{if(e.length!==this.PUBLIC_KEY_LENGTH)throw new Error(`Invalid public key length: ${e.length}`);const r=ks.ed25519PublicKeyToCurve25519(e),n=a.box.keyPair(),o=s.randomBytes(this.NONCE_LENGTH),i=a.box(t,o,r,n.secretKey);if(!i)throw new Error("Encryption failed");const c=new Uint8Array(this.NONCE_LENGTH+this.PUBLIC_KEY_LENGTH+i.length);let u=0;return c.set(o,u),u+=this.NONCE_LENGTH,c.set(n.publicKey,u),u+=this.PUBLIC_KEY_LENGTH,c.set(i,u),c}catch(e){throw new Error(`Encryption failed: ${e.message}`)}}static async encryptWithDebug(e,t){try{if(e.length!==this.PUBLIC_KEY_LENGTH)throw new Error(`Invalid public key length: ${e.length}`);const r=ks.ed25519PublicKeyToCurve25519(e),n=a.box.keyPair(),o=s.randomBytes(this.NONCE_LENGTH),i=a.box(t,o,r,n.secretKey);if(!i)throw new Error("Encryption failed");const c=new Uint8Array(this.NONCE_LENGTH+this.PUBLIC_KEY_LENGTH+i.length);let u=0;return c.set(o,u),u+=this.NONCE_LENGTH,c.set(n.publicKey,u),u+=this.PUBLIC_KEY_LENGTH,c.set(i,u),c}catch(e){throw e}}static async sha512Hash(e){try{if("undefined"!=typeof window&&window.crypto){const t=await window.crypto.subtle.digest("SHA-512",e);return new Uint8Array(t)}throw new Error("No crypto implementation available")}catch(e){throw e}}static async ed25519PrivateKeyToCurve25519(e){const t=await this.sha512Hash(e.slice(0,32)),r=new Uint8Array(t);r[0]&=248,r[31]&=127,r[31]|=64;return r.slice(0,32)}static async decrypt(e,t,r=!1){try{const r=this.NONCE_LENGTH+this.PUBLIC_KEY_LENGTH+this.MAC_LENGTH;if(t.length<r)throw new Error(`Invalid encrypted data length: ${t.length} < ${r}`);const n=t.slice(0,this.NONCE_LENGTH),o=t.slice(this.NONCE_LENGTH,this.NONCE_LENGTH+this.PUBLIC_KEY_LENGTH),i=t.slice(this.NONCE_LENGTH+this.PUBLIC_KEY_LENGTH),s=await this.ed25519PrivateKeyToCurve25519(e),c=a.box.before(o,s);if(!c)throw new Error("Failed to compute shared key");const u=a.box.open.after(i,n,c);if(!u)throw new Error("Decryption failed - invalid MAC");return u}catch(e){throw new Error(`Decryption failed: ${e.message}`)}}static async debugDecryptionProcess(e,t){const r={nonce:t.slice(0,this.NONCE_LENGTH),ephemeralPublicKey:t.slice(this.NONCE_LENGTH,this.NONCE_LENGTH+this.PUBLIC_KEY_LENGTH),ciphertext:t.slice(this.NONCE_LENGTH+this.PUBLIC_KEY_LENGTH)};Object.entries(r).forEach((([e,t])=>{}));try{await this.ed25519PrivateKeyToCurve25519(e)}catch(e){return}try{const r=await this.decrypt(e,t,!1);try{(new TextDecoder).decode(r)}catch(e){}}catch(e){}}}ks.NONCE_LENGTH=24,ks.PUBLIC_KEY_LENGTH=32,ks.MAC_LENGTH=16,ks.CURVE25519_P=new c.BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564819949"),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1",e[e.ECDSA=3]="ECDSA"}(ws||(ws={}));const Ss=(e,t)=>e.length===t.length&&e.every(((e,r)=>e===t[r])),Os=new j.Type("PublicKey").add(new j.Field("type",1,"uint32")).add(new j.Field("data",2,"bytes"));class As{constructor(e){if(!(e instanceof Uint8Array))throw new Error("Public key must be Uint8Array");if(32!==e.length)throw new Error("ed25519: bad public key length");this.raw=new Uint8Array(e),this.type="Ed25519"}bytes(){return this.raw}toMultihash(){const e=As.publicKeyToProto(this),t=e.length,r=new Uint8Array(2+t);return r[0]=0,r[1]=t,r.set(e,2),{code:0,size:t,digest:e,bytes:r}}toCID(){const e=this.toMultihash();return fs.create(1,114,e)}equals(e){return Ss(this.raw,e.raw)}verify(e,t){return Di.verify(t,e,this.raw)}async encrypt(e){return await ks.encrypt(this.raw,e)}static formEd25519PublicKey(e){return new As(e.raw)}static fromMultihash(e){if(e.code!==os.code)throw new Error("Invalid multihash code");return new As(e.digest)}static fromCID(e){if(114!==e.code)throw new Error("Invalid CID codec");return As.fromMultihash(e.multihash)}static publicKeyToProto(e){const t={type:ws.Ed25519,data:e.bytes()};return As.proto.encode(t).finish()}static publicKeyFromProto(e){const t=As.proto.decode(e);if(t.type!==ws.Ed25519)throw new Error("Invalid key type");return new As(t.data)}string(){const e=As.publicKeyToProto(this);return ye.encode(e)}static unmarshalString(e){const t=ye.decode(e);return As.publicKeyFromProto(t)}toString(){return Mn(this.bytes())}static fromString(e){return new As($n(e))}toBase58(){const e=this.toMultihash();return us.encode(e.bytes)}static fromBase58(e){const t=us.decode(e),r={code:0,size:t.length-2,digest:t.slice(2),bytes:t};return As.fromMultihash(r)}static edPubkeyFromStr(e){return 0===e.indexOf("0x")?As.fromString(e.substring(2)):As.unmarshalString(e)}}As.proto=Os;class Is{constructor(e){if(64!==e.length)throw new Error("ed25519: bad private key length");this.raw=new Uint8Array(e),this.type="Ed25519",this.publicKey=new As(e.slice(32))}static fromSeed(e){if(32!==e.length)throw new Error("ed25519: bad seed length");const t=Di.getPublicKey(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),new Is(r)}bytes(){return this.raw}sign(e){return Di.sign(e,this.raw.slice(0,32))}async decrypt(e){return await ks.decrypt(this.raw,e)}equals(e){return Ss(this.bytes(),e.bytes())}static privateKeyToProto(e){const t={type:ws.Ed25519,data:e.bytes()};return Is.proto.encode(t).finish()}static privateKeyFromProto(e){const t=Is.proto.decode(e);if(t.type!==ws.Ed25519)throw new Error("Invalid key type");return new Is(t.data)}string(){const e=Is.privateKeyToProto(this);return ye.encode(e)}static unmarshalString(e){const t=ye.decode(e);return Is.privateKeyFromProto(t)}toString(){return Mn(this.bytes())}static fromString(e){return new Is($n(e))}}Is.proto=Os;const{Buffer:xs}=Rr;class Ps{constructor(){this.create=async e=>{const r=new t.WsProvider(e);return this.dcchainapi=await t.ApiPromise.create({provider:r,throwOnConnect:!0,throwOnUnknown:!0}),!!this.dcchainapi},this.getObjNodes=async e=>{const t=await(this.dcchainapi?.query).dcNode.files(e)||null,r=t?.toJSON();if(!r||"object"!=typeof r||0==r.peers.length)return;return r.peers||[]},this.getAccountPeers=async e=>{try{const t="0x"+xs.from(e).toString("hex"),r=await this.getUserInfoWithAccount(t);if(!r)return null;return r.peers}catch(e){return null}},this.getDcNodeWebrtcDirectAddr=async t=>{const r=await(this.dcchainapi?.query).dcNode.peers(t),n=r?.toJSON();if(!n||"object"!=typeof n||""==n.ipAddress)return[null,exports.PeerStatus.PeerStatusOffline];let o=xs.from(n.ipAddress.slice(2),"hex").toString("utf8").split(",");if(o.length<2)return[null,exports.PeerStatus.PeerStatusOffline];return[e.multiaddr(o[1]),n.status||exports.PeerStatus.PeerStatusOffline]},this.getDcNodeList=async()=>{const e=await(this.dcchainapi?.query).dcNode.onlineNodesAddress(),t=e?.toJSON();if(!t||"object"!=typeof t)return[];let r=[];if(Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e];if("string"==typeof n){const e=xs.from(n.slice(2),"hex").toString("utf8");r=r.concat(e)}}return r},this.objectState=async e=>{if(!this.dcchainapi)return[null,new Error("dcchainapi is not initialized")];const t=await this.dcchainapi.query.dcNode.files(e);if(!t||t.isEmpty)return[null,new Error(`File with CID ${e} not found`)];const r=t.toJSON();return r?"object"!=typeof r||null===r||Array.isArray(r)?[null,new Error(`File with CID ${e} not found`)]:[{size:Number(r.fileSize||0),utype:Number(r.fileType||0),peers:new Set(Array.isArray(r.peers)?r.peers.map((e=>{try{return Gr(String(e))}catch(t){return String(e)}})):[]),users:new Set(Array.isArray(r.users)?r.users.map(String):[]),mbusers:new Set(Array.isArray(r.users)?r.users.map((e=>{try{const t=fn(e.slice(2));return ye.encode(t)}catch(t){return String(e)}})):[]),logs:new Set(Array.isArray(r.dbLog)?r.dbLog.map((e=>{try{return Gr(String(e))}catch(t){return String(e)}})):[])},null]:[null,new Error(`File with CID ${e} not found`)]},this.ifEnoughUserSpace=async(e,t)=>{const r="0x"+xs.from(e).toString("hex"),n=await this.getUserInfoWithAccount(r);if(!n)throw new Error("get user info error");if(0!=n.commentFrozenStatus||0!=n.spamFrozenStatus)return!1;const o=await this.getBlockHeight()||0;if(n.expireNumber>0&&n.expireNumber<o)return!1;const i=t||1048576;return!(n.subscribeSpace-n.usedSpace<i)},this.refreshUserInfo=async e=>{const t="0x"+xs.from(e).toString("hex");return await this.getUserInfoWithAccount(t)},this.getAPPInfo=async e=>{if(!this.dcchainapi||!this.dcchainapi.isReady)throw new Error("dcchainapi is not initialized");const t=(new TextEncoder).encode(e),r="0x"+xs.from(t).toString("hex"),n=await(this.dcchainapi?.query).dcNode.appsInfo(r);if(!n||n.isEmpty)throw new Error(`App info for ${e} not found`);const o=n.toJSON();if(!o||"object"!=typeof o)throw new Error(`App info for ${e} is not valid`);const i=fn(o?.ownerAccount.slice(2)),s=new As(i),a=o?.rewardedStash;let c="";if(o?.domain&&o?.domain.length>0){const e=fn(o?.domain.slice(2));c=(new TextDecoder).decode(e).toString()}let u="";if(o?.fileId&&o?.fileId.length>0){const e=fn(o?.fileId.slice(2));u=(new TextDecoder).decode(e).toString()}return{appId:e,domain:c,owner:s.string(),rewarder:a,fid:u}}}async getBlockHeight(){const e=await(this.dcchainapi?.rpc.chain.getBlock()),t=e?.block.header.number.toNumber();return t||0}async getUserInfoWithAccount(e){const t=await(this.dcchainapi?.query).dcNode.walletAccountStorage(e);if(!t)throw new Error("walletAccountStorage is null");let r=t.toJSON();if(null===r)throw new Error("userInfo is null");if(r?.parentAccount!==e){const e=await(this.dcchainapi?.query).dcNode.walletAccountStorage(r?.parentAccount);if(!e)throw new Error("parentWalletAccountStorage is null");const t=e?.toJSON();if(!t)return r;r.requestPeers=t.requestPeers,0==r.peers?.length&&(r.peers=t.peers),r.subscribeSpace=t.subscribeSpace,r.usedSpace=t.usedSpace,r.expireNumber=t.expireNumber,r.purchaseNumber=t.purchaseNumber,0!=t.commentFrozenStatus&&(r.commentFrozenStatus=t.commentFrozenStatus),0!=t.spamFrozenStatus&&(r.spamFrozenStatus=t.spamFrozenStatus)}for(let e=0;e<r.peers.length;e++)r.peers[e]=Gr(r.peers[e]);for(let e=0;e<r.requestPeers.length;e++)r.requestPeers[e]=Gr(r.requestPeers[e]);return r.dbConfig.length<=2?r.dbConfig="":r.dbConfigRaw=fn(r.dbConfig.slice(2)),r.encNftAccount.length<=2&&(r.encNftAccount=""),r.peers&&Array.isArray(r.peers)&&e&&r.peers.sort(((t,r)=>{const n="string"==typeof t?(new TextEncoder).encode(t):t,o="string"==typeof r?(new TextEncoder).encode(r):r,i=fn(e.slice(2)),s=this.calculateDistance(n,i),a=this.calculateDistance(o,i);return s<a?-1:s>a?1:0})),r}async getUserInfoWithNftHex(e){const t=await(this.dcchainapi?.query).dcNode.nftToWalletAccount(e);if(!t||!t.toString())throw new Error("walletAccount is null");return await this.getUserInfoWithAccount(t.toString())}calculateDistance(e,t){const r=Math.min(e.length,t.length),n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=e[o]^t[o];let o="0x";for(let e=0;e<n.length;e++)o+=n[e].toString(16).padStart(2,"0");return"0x"===o?BigInt(0):BigInt(o)}async getUserInfoWithNft(e){const t=(new TextEncoder).encode(e),r=await Nr(t),n="0x"+xs.from(r).toString("hex");return await this.getUserInfoWithNftHex(n)}async getUserWalletAccount(e){const t=(new TextEncoder).encode(e),r=await Nr(t),n="0x"+xs.from(r).toString("hex"),o=await(this.dcchainapi?.query).dcNode.nftToWalletAccount(n);if(!o||!o.toString())throw new Error("walletAccount is null");return o.toString()}}function Es(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(var r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Cs(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function Bs(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function Ts(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));var r=Bs(t),n=0;for(var o of e)r.set(o,n),n+=o.length;return r}var Ds=Symbol.for("@achingbrain/uint8arraylist");function Rs(e,t){if(null==t||t<0)throw new RangeError("index is out of bounds");var r=0;for(var n of e){var o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function js(e){return Boolean(null==e?void 0:e[Ds])}class Ns{constructor(){W(this,"bufs",void 0),W(this,"length",void 0),W(this,Ds,!0),this.bufs=[],this.length=0;for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.appendAll(t)}appendAll(e){var t=0;for(var r of e)if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.push(r);else{if(!js(r))throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.push(...r.bufs)}this.length+=t}prepend(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.prependAll(t)}prependAll(e){var t=0;for(var r of e.reverse())if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.unshift(r);else{if(!js(r))throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.unshift(...r.bufs)}this.length+=t}get(e){var t=Rs(this.bufs,e);return t.buf[t.index]}set(e,t){var r=Rs(this.bufs,e);r.buf[r.index]=t}write(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e instanceof Uint8Array)for(var r=0;r<e.length;r++)this.set(t+r,e[r]);else{if(!js(e))throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList");for(var n=0;n<e.length;n++)this.set(t+n,e.get(n))}}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength)return this.bufs=[],void(this.length=0);for(;this.bufs.length>0;){if(!(e>=this.bufs[0].byteLength)){this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift()}}}slice(e,t){var{bufs:r,length:n}=this._subList(e,t);return Ts(r,n)}subarray(e,t){var{bufs:r,length:n}=this._subList(e,t);return 1===r.length?r[0]:Ts(r,n)}sublist(e,t){var{bufs:r,length:n}=this._subList(e,t),o=new Ns;return o.length=n,o.bufs=[...r],o}_subList(e,t){if(e=null!=e?e:0,t=null!=t?t:this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(0===e&&t===this.length)return{bufs:this.bufs,length:this.length};for(var r=[],n=0,o=0;o<this.bufs.length;o++){var i=this.bufs[o],s=n,a=s+i.byteLength;if(n=a,!(e>=a)){var c=e>=s&&e<a,u=t>s&&t<=a;if(c&&u){if(e===s&&t===a){r.push(i);break}var l=e-s;r.push(i.subarray(l,l+(t-e)));break}if(c){if(0===e){r.push(i);continue}r.push(i.subarray(e-s))}else{if(u){if(t===a){r.push(i);break}r.push(i.subarray(0,t-s));break}r.push(i)}}}return{bufs:r,length:t-e}}indexOf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(js(e)||e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');var r=e instanceof Uint8Array?e:e.subarray();if(t=Number(null!=t?t:0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;var n=r.byteLength;if(0===n)throw new TypeError("search must be at least 1 byte long");for(var o=new Int32Array(256),i=0;i<256;i++)o[i]=-1;for(var s=0;s<n;s++)o[r[s]]=s;for(var a,c=o,u=this.byteLength-r.byteLength,l=r.byteLength-1,d=t;d<=u;d+=a){a=0;for(var h=l;h>=0;h--){var p=this.get(d+h);if(r[h]!==p){a=Math.max(1,h-c[p]);break}}if(0===a)return d}return-1}getInt8(e){var t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){var r=Bs(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt8(0,t),this.write(r,e)}getInt16(e,t){var r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt16(0,t)}setInt16(e,t,r){var n=Cs(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt16(0,t,r),this.write(n,e)}getInt32(e,t){var r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt32(0,t)}setInt32(e,t,r){var n=Cs(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt32(0,t,r),this.write(n,e)}getBigInt64(e,t){var r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigInt64(0,t)}setBigInt64(e,t,r){var n=Cs(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigInt64(0,t,r),this.write(n,e)}getUint8(e){var t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){var r=Bs(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint8(0,t),this.write(r,e)}getUint16(e,t){var r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,t)}setUint16(e,t,r){var n=Cs(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint16(0,t,r),this.write(n,e)}getUint32(e,t){var r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,t)}setUint32(e,t,r){var n=Cs(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint32(0,t,r),this.write(n,e)}getBigUint64(e,t){var r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigUint64(0,t)}setBigUint64(e,t,r){var n=Cs(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigUint64(0,t,r),this.write(n,e)}getFloat32(e,t){var r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat32(0,t)}setFloat32(e,t,r){var n=Cs(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat32(0,t,r),this.write(n,e)}getFloat64(e,t){var r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat64(0,t)}setFloat64(e,t,r){var n=Cs(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat64(0,t,r),this.write(n,e)}equals(e){if(null==e)return!1;if(!(e instanceof Ns))return!1;if(e.bufs.length!==this.bufs.length)return!1;for(var t=0;t<this.bufs.length;t++)if(!Es(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){var r=new Ns;return r.bufs=e,null==t&&(t=e.reduce(((e,t)=>e+t.byteLength),0)),r.length=t,r}}var Us=he({prefix:"9",name:"base10",alphabet:"0123456789"}),Ks=Object.freeze({__proto__:null,base10:Us}),qs=pe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ls=pe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),_s=Object.freeze({__proto__:null,base16:qs,base16upper:Ls}),Ms=pe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Fs=Object.freeze({__proto__:null,base2:Ms}),zs=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Gs=zs.reduce(((e,t,r)=>(e[r]=t,e)),[]),Vs=zs.reduce(((e,t,r)=>{var n=t.codePointAt(0);if(null==n)throw new Error("Invalid character: ".concat(t));return e[n]=r,e}),[]);var Hs=de({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Gs[t]),"")},decode:function(e){var t=[];for(var r of e){var n=r.codePointAt(0);if(null==n)throw new Error("Invalid character: ".concat(r));var o=Vs[n];if(null==o)throw new Error("Non-base256emoji character: ".concat(r));t.push(o)}return new Uint8Array(t)}}),Ws=Object.freeze({__proto__:null,base256emoji:Hs}),Js=pe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$s=pe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ys=pe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Zs=pe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Qs=Object.freeze({__proto__:null,base64:Js,base64pad:$s,base64url:Ys,base64urlpad:Zs}),Xs=pe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),ea=Object.freeze({__proto__:null,base8:Xs}),ta=de({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),ra=Object.freeze({__proto__:null,identity:ta});function na(e){var{name:t,code:r,encode:n}=e;return new oa(t,r,n)}new TextEncoder,new TextDecoder;class oa{constructor(e,t,r){W(this,"name",void 0),W(this,"code",void 0),W(this,"encode",void 0),this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){var t=this.encode(e);return t instanceof Uint8Array?es(this.code,t):t.then((e=>es(this.code,e)))}throw Error("Unknown type, must be binary type")}}function ia(e){return function(){var t=G((function*(t){return new Uint8Array(yield crypto.subtle.digest(e,t))}));return function(e){return t.apply(this,arguments)}}()}var sa=na({name:"sha2-256",code:18,encode:ia("SHA-256")}),aa=na({name:"sha2-512",code:19,encode:ia("SHA-512")}),ca=Object.freeze({__proto__:null,sha256:sa,sha512:aa}),ua=Z(Z(Z(Z(Z(Z(Z(Z(Z(Z({},ra),Fs),ea),Ks),_s),Oe),cs),ds),Qs),Ws);function la(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}Z(Z({},ca),is);var da=la("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),ha=la("ascii","a",(e=>{for(var t="a",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{for(var t=Bs((e=e.substring(1)).length),r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),pa=Z({utf8:da,"utf-8":da,hex:ua.base16,latin1:ha,ascii:ha,binary:ha},ua);function ya(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8",r=pa[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.decoder.decode("".concat(r.prefix).concat(e))}function fa(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8",r=pa[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}var ga=parseInt("11111",2),ba=parseInt("10000000",2),ma=parseInt("01111111",2),wa={0:Sa,1:Sa,2:function(e,t){for(var r=ka(e,t),n=t.offset,o=t.offset+r,i=[],s=n;s<o;s++)s===n&&0===e[s]||i.push(e[s]);return t.offset+=r,Uint8Array.from(i)},3:function(e,t){var r=ka(e,t),n=e[t.offset];t.offset++;var o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,0!==n)throw new Error("Unused bits in bit string is unimplemented");return o},4:function(e,t){var r=ka(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n},5:function(e,t){return t.offset++,null},6:function(e,t){var r=ka(e,t),n=t.offset+r,o=e[t.offset];t.offset++;var i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);var a="".concat(i,".").concat(s),c=[];for(;t.offset<n;){var u=e[t.offset];if(t.offset++,c.push(127&u),u<128){c.reverse();for(var l=0,d=0;d<c.length;d++)l+=c[d]<<7*d;a+=".".concat(l),c=[]}}return a},16:Sa,22:Sa,48:Sa};function va(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{offset:0},r=e[t.offset]&ga;if(t.offset++,null!=wa[r])return wa[r](e,t);throw new Error("No decoder for tag "+r)}function ka(e,t){var r=0;if((e[t.offset]&ba)===ba){var n=e[t.offset]&ma,o="0x";t.offset++;for(var i=0;i<n;i++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function Sa(e,t){ka(e,t);for(var r=[];!(t.offset>=e.byteLength);){var n=va(e,t);if(null===n)break;r.push(n)}return r}function Oa(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);var t=function(e){var t=e.toString(16);t.length%2==1&&(t="0"+t);for(var r=new Ns,n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt("".concat(t[n]).concat(t[n+1]),16)]));return r}(e.byteLength);return new Ns(Uint8Array.from([t.byteLength|ba]),t)}function Aa(e){var t=new Ns;return!(128&~e.subarray()[0])&&t.append(Uint8Array.from([0])),t.append(e),new Ns(Uint8Array.from([2]),Oa(t),t)}function Ia(e){var t=Uint8Array.from([0]),r=new Ns(t,e);return new Ns(Uint8Array.from([3]),Oa(r),r)}function xa(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:48,r=new Ns;for(var n of e)r.append(n);return new Ns(Uint8Array.from([t]),Oa(r),r)}var Pa="1.2.840.10045.3.1.7",Ea="1.3.132.0.34",Ca="1.3.132.0.35";function Ba(){return Ba=G((function*(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"P-256",t=yield crypto.subtle.generateKey({name:"ECDSA",namedCurve:e},!0,["sign","verify"]);return{publicKey:yield crypto.subtle.exportKey("jwk",t.publicKey),privateKey:yield crypto.subtle.exportKey("jwk",t.privateKey)}})),Ba.apply(this,arguments)}function Ta(){return(Ta=G((function*(e,t){var r,n=yield crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:null!==(r=e.crv)&&void 0!==r?r:"P-256"},!1,["sign"]),o=yield crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,t.subarray());return new Uint8Array(o,0,o.byteLength)}))).apply(this,arguments)}function Da(){return(Da=G((function*(e,t,r){var n,o=yield crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:null!==(n=e.crv)&&void 0!==n?n:"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,r.subarray())}))).apply(this,arguments)}var Ra=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),ja=Uint8Array.from([6,5,43,129,4,0,34]),Na=Uint8Array.from([6,5,43,129,4,0,35]),Ua={ext:!0,kty:"EC",crv:"P-256"},Ka={ext:!0,kty:"EC",crv:"P-384"},qa={ext:!0,kty:"EC",crv:"P-521"},La=32,_a=48,Ma=66;function Fa(e){var t,r,n=e[1][1][0];if(65===n.byteLength)return t=fa(n.subarray(1,33),"base64url"),r=fa(n.subarray(33),"base64url"),new Va(Z(Z({},Ua),{},{key_ops:["verify"],x:t,y:r}));if(97===n.byteLength)return t=fa(n.subarray(1,49),"base64url"),r=fa(n.subarray(49),"base64url"),new Va(Z(Z({},Ka),{},{key_ops:["verify"],x:t,y:r}));if(133===n.byteLength)return t=fa(n.subarray(1,67),"base64url"),r=fa(n.subarray(67),"base64url"),new Va(Z(Z({},qa),{},{key_ops:["verify"],x:t,y:r}));throw new d.InvalidParametersError("coordinates were wrong length, got ".concat(n.byteLength,", expected 65, 97 or 133"))}function za(e){if("P-256"===e)return Ra;if("P-384"===e)return ja;if("P-521"===e)return Na;throw new d.InvalidParametersError("Invalid curve ".concat(e))}function Ga(){return Ga=G((function*(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"P-256",t=yield function(){return Ba.apply(this,arguments)}(e);return new Ha(t.privateKey)})),Ga.apply(this,arguments)}class Va{constructor(e){W(this,"type","ECDSA"),W(this,"jwk",void 0),W(this,"_raw",void 0),this.jwk=e}get raw(){var e,t,r;return null==this._raw&&(this._raw=(e=this.jwk,xa([Aa(Uint8Array.from([1])),xa([za(e.crv)],160),xa([Ia(new Ns(Uint8Array.from([4]),ya(null!==(t=e.x)&&void 0!==t?t:"","base64url"),ya(null!==(r=e.y)&&void 0!==r?r:"","base64url")))],161)]).subarray())),this._raw}toMultihash(){return os.digest($u(this))}toCID(){return fs.createV1(114,this.toMultihash())}toString(){return us.encode(this.toMultihash().bytes).substring(1)}equals(e){return null!=e&&e.raw instanceof Uint8Array&&Es(this.raw,e.raw)}verify(e,t){var r=this;return G((function*(){return function(e,t,r){return Da.apply(this,arguments)}(r.jwk,t,e)}))()}}class Ha{constructor(e){W(this,"type","ECDSA"),W(this,"jwk",void 0),W(this,"publicKey",void 0),W(this,"_raw",void 0),this.jwk=e,this.publicKey=new Va({crv:e.crv,ext:e.ext,key_ops:["verify"],kty:"EC",x:e.x,y:e.y})}get raw(){var e,t,r,n,o;return null==this._raw&&(this._raw=(e=this.jwk,xa([Aa(Uint8Array.from([1])),(o=ya(null!==(t=e.d)&&void 0!==t?t:"","base64url"),new Ns(Uint8Array.from([4]),Oa(o),o)),xa([za(e.crv)],160),xa([Ia(new Ns(Uint8Array.from([4]),ya(null!==(r=e.x)&&void 0!==r?r:"","base64url"),ya(null!==(n=e.y)&&void 0!==n?n:"","base64url")))],161)]).subarray())),this._raw}equals(e){return null!=e&&e.raw instanceof Uint8Array&&Es(this.raw,e.raw)}sign(e){var t=this;return G((function*(){return function(e,t){return Ta.apply(this,arguments)}(t.jwk,e)}))()}}var Wa=64;function Ja(){var e=Di.utils.randomPrivateKey(),t=Di.getPublicKey(e),r=function(e,t){for(var r=new Uint8Array(Wa),n=0;n<32;n++)r[n]=e[n],r[32+n]=t[n];return r}(e,t);return{privateKey:r,publicKey:t}}class $a{constructor(e){W(this,"type","Ed25519"),W(this,"raw",void 0),this.raw=Xa(e,32)}toMultihash(){return os.digest($u(this))}toCID(){return fs.createV1(114,this.toMultihash())}toString(){return us.encode(this.toMultihash().bytes).substring(1)}equals(e){return null!=e&&e.raw instanceof Uint8Array&&Es(this.raw,e.raw)}verify(e,t){return function(e,t,r){return Di.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this.raw,t,e)}}class Ya{constructor(e,t){W(this,"type","Ed25519"),W(this,"raw",void 0),W(this,"publicKey",void 0),this.raw=Xa(e,Wa),this.publicKey=new $a(t)}equals(e){return null!=e&&e.raw instanceof Uint8Array&&Es(this.raw,e.raw)}sign(e){return t=this.raw,r=e,n=t.subarray(0,32),Di.sign(r instanceof Uint8Array?r:r.subarray(),n);var t,r,n}}function Za(e){return e=Xa(e,32),new $a(e)}function Qa(){return(Qa=G((function*(){var{privateKey:e,publicKey:t}=Ja();return new Ya(e,t)}))).apply(this,arguments)}function Xa(e,t){if((e=Uint8Array.from(null!=e?e:[])).length!==t)throw new d.InvalidParametersError("Key must be a Uint8Array of length ".concat(t,", got ").concat(e.length));return e}var ec=Math.pow(2,7),tc=Math.pow(2,14),rc=Math.pow(2,21),nc=Math.pow(2,28),oc=Math.pow(2,35),ic=Math.pow(2,42),sc=Math.pow(2,49),ac=128,cc=127;function uc(e){if(e<ec)return 1;if(e<tc)return 2;if(e<rc)return 3;if(e<nc)return 4;if(e<oc)return 5;if(e<ic)return 6;if(e<sc)return 7;if(null!=Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function lc(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;switch(uc(e)){case 8:t[r++]=255&e|ac,e/=128;case 7:t[r++]=255&e|ac,e/=128;case 6:t[r++]=255&e|ac,e/=128;case 5:t[r++]=255&e|ac,e/=128;case 4:t[r++]=255&e|ac,e>>>=7;case 3:t[r++]=255&e|ac,e>>>=7;case 2:t[r++]=255&e|ac,e>>>=7;case 1:t[r++]=255&e,e>>>=7;break;default:throw new Error("unreachable")}return t}function dc(e,t){var r=e[t],n=0;if(n+=r&cc,r<ac)return n;if(n+=((r=e[t+1])&cc)<<7,r<ac)return n;if(n+=((r=e[t+2])&cc)<<14,r<ac)return n;if(n+=((r=e[t+3])&cc)<<21,r<ac)return n;if(n+=((r=e[t+4])&cc)*nc,r<ac)return n;if(n+=((r=e[t+5])&cc)*oc,r<ac)return n;if(n+=((r=e[t+6])&cc)*ic,r<ac)return n;if(n+=((r=e[t+7])&cc)*sc,r<ac)return n;throw new RangeError("Could not decode varint")}function hc(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return null==t&&(t=Bs(uc(e))),t instanceof Uint8Array?lc(e,t,r):function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;switch(uc(e)){case 8:t.set(r++,255&e|ac),e/=128;case 7:t.set(r++,255&e|ac),e/=128;case 6:t.set(r++,255&e|ac),e/=128;case 5:t.set(r++,255&e|ac),e/=128;case 4:t.set(r++,255&e|ac),e>>>=7;case 3:t.set(r++,255&e|ac),e>>>=7;case 2:t.set(r++,255&e|ac),e>>>=7;case 1:t.set(r++,255&e),e>>>=7;break;default:throw new Error("unreachable")}return t}(e,t,r)}function pc(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e instanceof Uint8Array?dc(e,t):function(e,t){var r=e.get(t),n=0;if(n+=r&cc,r<ac)return n;if(n+=((r=e.get(t+1))&cc)<<7,r<ac)return n;if(n+=((r=e.get(t+2))&cc)<<14,r<ac)return n;if(n+=((r=e.get(t+3))&cc)<<21,r<ac)return n;if(n+=((r=e.get(t+4))&cc)*nc,r<ac)return n;if(n+=((r=e.get(t+5))&cc)*oc,r<ac)return n;if(n+=((r=e.get(t+6))&cc)*ic,r<ac)return n;if(n+=((r=e.get(t+7))&cc)*sc,r<ac)return n;throw new RangeError("Could not decode varint")}(e,t)}var yc=new Float32Array([-0]),fc=new Uint8Array(yc.buffer);function gc(e,t,r){yc[0]=e,t[r]=fc[0],t[r+1]=fc[1],t[r+2]=fc[2],t[r+3]=fc[3]}var bc=new Float64Array([-0]),mc=new Uint8Array(bc.buffer);function wc(e,t,r){bc[0]=e,t[r]=mc[0],t[r+1]=mc[1],t[r+2]=mc[2],t[r+3]=mc[3],t[r+4]=mc[4],t[r+5]=mc[5],t[r+6]=mc[6],t[r+7]=mc[7]}var vc=BigInt(Number.MAX_SAFE_INTEGER),kc=BigInt(Number.MIN_SAFE_INTEGER);class Sc{constructor(e,t){W(this,"lo",void 0),W(this,"hi",void 0),this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){var e=1+~this.lo>>>0,t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!=0){var e=1+~this.lo>>>0,t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return Oc;if(e<vc&&e>kc)return this.fromNumber(Number(e));var t=e<0n;t&&(e=-e);var r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>Ac&&(n=0n,++r>Ac&&(r=0n))),new Sc(Number(n),Number(r))}static fromNumber(e){if(0===e)return Oc;var t=e<0;t&&(e=-e);var r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new Sc(r,n)}static from(e){return"number"==typeof e?Sc.fromNumber(e):"bigint"==typeof e?Sc.fromBigInt(e):"string"==typeof e?Sc.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new Sc(e.low>>>0,e.high>>>0):Oc}}var Oc=new Sc(0,0);Oc.toBigInt=function(){return 0n},Oc.zzEncode=Oc.zzDecode=function(){return this},Oc.length=function(){return 1};var Ac=4294967296n;function Ic(e,t,r){for(var n,o,i=r,s=0;s<e.length;++s)(n=e.charCodeAt(s))<128?t[r++]=n:n<2048?(t[r++]=n>>6|192,t[r++]=63&n|128):55296==(64512&n)&&56320==(64512&(o=e.charCodeAt(s+1)))?(n=65536+((1023&n)<<10)+(1023&o),++s,t[r++]=n>>18|240,t[r++]=n>>12&63|128,t[r++]=n>>6&63|128,t[r++]=63&n|128):(t[r++]=n>>12|224,t[r++]=n>>6&63|128,t[r++]=63&n|128);return r-i}function xc(e,t){return RangeError("index out of range: ".concat(e.pos," + ").concat(null!=t?t:1," > ").concat(e.len))}function Pc(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class Ec{constructor(e){W(this,"buf",void 0),W(this,"pos",void 0),W(this,"len",void 0),W(this,"_slice",Uint8Array.prototype.subarray),this.buf=e,this.pos=0,this.len=e.length}uint32(){var e=4294967295;if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,xc(this,10);return e}int32(){return 0|this.uint32()}sint32(){var e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw xc(this,4);return Pc(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw xc(this,4);return 0|Pc(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw xc(this,4);var e,t,r=(e=this.buf,t=this.pos,fc[0]=e[t],fc[1]=e[t+1],fc[2]=e[t+2],fc[3]=e[t+3],yc[0]);return this.pos+=4,r}double(){if(this.pos+8>this.len)throw xc(this,4);var e,t,r=(e=this.buf,t=this.pos,mc[0]=e[t],mc[1]=e[t+1],mc[2]=e[t+2],mc[3]=e[t+3],mc[4]=e[t+4],mc[5]=e[t+5],mc[6]=e[t+6],mc[7]=e[t+7],bc[0]);return this.pos+=8,r}bytes(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw xc(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){var e=this.bytes();return function(e,t,r){var n;if(r-t<1)return"";for(var o,i=[],s=0;t<r;)(o=e[t++])<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((null!=n?n:n=[]).push(String.fromCharCode.apply(String,i)),s=0);return null!=n?(s>0&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))}(e,0,e.length)}skip(e){if("number"==typeof e){if(this.pos+e>this.len)throw xc(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw xc(this)}while(128&this.buf[this.pos++]);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type ".concat(e," at offset ").concat(this.pos))}return this}readLongVarint(){var e=new Sc(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw xc(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw xc(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw xc(this,8);var e=Pc(this.buf,this.pos+=4),t=Pc(this.buf,this.pos+=4);return new Sc(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){var e=dc(this.buf,this.pos);return this.pos+=uc(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function Cc(e,t,r){var n=function(e){return new Ec(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class Bc{constructor(e,t,r){W(this,"fn",void 0),W(this,"len",void 0),W(this,"next",void 0),W(this,"val",void 0),this.fn=e,this.len=t,this.next=void 0,this.val=r}}function Tc(){}class Dc{constructor(e){W(this,"head",void 0),W(this,"tail",void 0),W(this,"len",void 0),W(this,"next",void 0),this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}var Rc,jc,Nc,Uc,Kc,qc,Lc,_c,Mc=(Nc=jc=8192,function(e){if(e<1||e>4096)return Bs(e);Nc+e>jc&&(Rc=Bs(jc),Nc=0);var t=Rc.subarray(Nc,Nc+=e);return 7&Nc&&(Nc=1+(7|Nc)),t});class Fc{constructor(){W(this,"len",void 0),W(this,"head",void 0),W(this,"tail",void 0),W(this,"states",void 0),this.len=0,this.head=new Bc(Tc,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new Bc(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Vc((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Hc,10,Sc.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){var t=Sc.fromBigInt(e);return this._push(Hc,t.length(),t)}uint64Number(e){return this._push(lc,uc(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){var t=Sc.fromBigInt(e).zzEncode();return this._push(Hc,t.length(),t)}sint64Number(e){var t=Sc.fromNumber(e).zzEncode();return this._push(Hc,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(zc,1,e?1:0)}fixed32(e){return this._push(Wc,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){var t=Sc.fromBigInt(e);return this._push(Wc,4,t.lo)._push(Wc,4,t.hi)}fixed64Number(e){var t=Sc.fromNumber(e);return this._push(Wc,4,t.lo)._push(Wc,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(gc,4,e)}double(e){return this._push(wc,8,e)}bytes(e){var t=e.length>>>0;return 0===t?this._push(zc,1,0):this.uint32(t)._push(Jc,t,e)}string(e){var t=function(e){for(var t=0,r=0,n=0;n<e.length;++n)(r=e.charCodeAt(n))<128?t+=1:r<2048?t+=2:55296==(64512&r)&&56320==(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(Ic,t,e):this._push(zc,1,0)}fork(){return this.states=new Dc(this),this.head=this.tail=new Bc(Tc,0,0),this.len=0,this}reset(){return null!=this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Bc(Tc,0,0),this.len=0),this}ldelim(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){for(var e,t=this.head.next,r=(e=this.len,null!=globalThis.Buffer?Bs(e):Mc(e)),n=0;null!=t;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}}function zc(e,t,r){t[r]=255&e}function Gc(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class Vc extends Bc{constructor(e,t){super(Gc,e,t),W(this,"next",void 0),this.next=void 0}}function Hc(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Wc(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Jc(e,t,r){t.set(e,r)}function $c(e,t,r){t.set(e,r)}function Yc(e,t,r){e.length<40?Ic(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(ya(e),r)}function Zc(e,t){var r=new Fc;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function Qc(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Xc(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return Qc("enum",Uc.VARINT,(function(e,r){var n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}function eu(e,t){return Qc("message",Uc.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(Fc.prototype.bytes=function(e){var t=e.length>>>0;return this.uint32(t),t>0&&this._push($c,t,e),this},Fc.prototype.string=function(e){var t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Yc,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(Uc||(Uc={}));class tu extends Error{constructor(){super(...arguments),W(this,"code","ERR_MAX_LENGTH"),W(this,"name","MaxLengthError")}}!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"}(Kc||(Kc={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"}(qc||(qc={})),function(e){e.codec=()=>Xc(qc)}(Kc||(Kc={})),function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),Kc.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.Type=Kc.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&o)}}return r}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(Lc||(Lc={})),function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),Kc.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.Type=Kc.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&o)}}return r}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(_c||(_c={}));class ru extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"An error occurred while signing a message"),this.name="SigningError"}}class nu extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"An error occurred while verifying a message"),this.name="VerificationError"}}class ou extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Missing Web Crypto API"),this.name="WebCryptoMissingError"}}var iu={get(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==(null==e?void 0:e.subtle))throw new ou("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return e}},su=Bo;let au=class{constructor(e,t){W(this,"type","RSA"),W(this,"jwk",void 0),W(this,"_raw",void 0),W(this,"_multihash",void 0),this.jwk=e,this._multihash=t}get raw(){return null==this._raw&&(this._raw=du(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return fs.createV1(114,this._multihash)}toString(){return us.encode(this.toMultihash().bytes).substring(1)}equals(e){return null!=e&&e.raw instanceof Uint8Array&&Es(this.raw,e.raw)}verify(e,t){return function(e,t,r){return bu.apply(this,arguments)}(this.jwk,t,e)}},cu=class{constructor(e,t){W(this,"type","RSA"),W(this,"jwk",void 0),W(this,"_raw",void 0),W(this,"publicKey",void 0),this.jwk=e,this.publicKey=t}get raw(){return null==this._raw&&(this._raw=function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new d.InvalidParametersError("JWK was missing components");return xa([Aa(Uint8Array.from([0])),Aa(ya(e.n,"base64url")),Aa(ya(e.e,"base64url")),Aa(ya(e.d,"base64url")),Aa(ya(e.p,"base64url")),Aa(ya(e.q,"base64url")),Aa(ya(e.dp,"base64url")),Aa(ya(e.dq,"base64url")),Aa(ya(e.qi,"base64url"))]).subarray()}(this.jwk)),this._raw}equals(e){return null!=e&&e.raw instanceof Uint8Array&&Es(this.raw,e.raw)}sign(e){return function(e,t){return gu.apply(this,arguments)}(this.jwk,e)}};var uu=8192,lu=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function du(e){if(null==e.n||null==e.e)throw new d.InvalidParametersError("JWK was missing components");return xa([lu,Ia(xa([Aa(ya(e.n,"base64url")),Aa(ya(e.e,"base64url"))]))]).subarray()}function hu(e){var t=function(e){return{n:fa(e[1],"base64url"),e:fa(e[2],"base64url"),d:fa(e[3],"base64url"),p:fa(e[4],"base64url"),q:fa(e[5],"base64url"),dp:fa(e[6],"base64url"),dq:fa(e[7],"base64url"),qi:fa(e[8],"base64url"),kty:"RSA"}}(e);return function(e){if(function(e){if("RSA"!==e.kty)throw new d.InvalidParametersError("invalid key type");if(null==e.n)throw new d.InvalidParametersError("invalid key modulus");var t=ya(e.n,"base64url");return 8*t.length}(e)>uu)throw new d.InvalidParametersError("Key size is too large");var t=function(e){if(null==e)throw new d.InvalidParametersError("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}(e),r=su(Lc.encode({Type:Kc.RSA,Data:du(t.publicKey)})),n=es(18,r);return new cu(t.privateKey,new au(t.publicKey,n))}(t)}function pu(e,t,r){var n=function(e){var t=va(e[1],{offset:0});return{kty:"RSA",n:fa(t[0],"base64url"),e:fa(t[1],"base64url")}}(e);null==r&&(r=es(18,su(Lc.encode({Type:Kc.RSA,Data:t}))));return new au(n,r)}function yu(){return yu=G((function*(e){if(e>uu)throw new d.InvalidParametersError("Key size is too large");var t=yield function(e){return fu.apply(this,arguments)}(e),r=es(18,su(Lc.encode({Type:Kc.RSA,Data:du(t.publicKey)})));return new cu(t.privateKey,new au(t.publicKey,r))})),yu.apply(this,arguments)}function fu(){return fu=G((function*(e){var t=yield iu.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=yield function(e){return mu.apply(this,arguments)}(t);return{privateKey:r[0],publicKey:r[1]}})),fu.apply(this,arguments)}function gu(){return(gu=G((function*(e,t){var r=yield iu.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=yield iu.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}))).apply(this,arguments)}function bu(){return(bu=G((function*(e,t,r){var n=yield iu.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return iu.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}))).apply(this,arguments)}function mu(){return mu=G((function*(e){if(null==e.privateKey||null==e.publicKey)throw new d.InvalidParametersError("Private and public key are required");return Promise.all([iu.get().subtle.exportKey("jwk",e.privateKey),iu.get().subtle.exportKey("jwk",e.publicKey)])})),mu.apply(this,arguments)}class wu extends Zn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,jn(e);var r=Yn(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;var n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(var i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(var s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Un(o)}update(e){return Nn(this),this.iHash.update(e),this}digestInto(e){Nn(this),Rn(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){var e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));var{oHash:t,iHash:r,finished:n,destroyed:o,blockLen:i,outputLen:s}=this;return e.finished=n,e.destroyed=o,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var vu=(e,t,r)=>new wu(e,t).update(r).digest();function ku(e){void 0!==e.lowS&&tn("lowS",e.lowS),void 0!==e.prehash&&tn("prehash",e.prehash)}vu.create=(e,t)=>new wu(e,t);class Su extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")}}var Ou={Err:Su,_tlv:{encode:(e,t)=>{var{Err:r}=Ou;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&t.length)throw new r("tlv.encode: unpadded data");var n=t.length/2,o=rn(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");var i=n>127?rn(o.length/2|128):"";return rn(e)+i+o+t},decode(e,t){var{Err:r}=Ou,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");var o=t[n++],i=0;if(!!(128&o)){var s=127&o;if(!s)throw new r("tlv.decode(long): indefinite length not supported");if(s>4)throw new r("tlv.decode(long): byte length is too big");var a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: length bytes not complete");if(0===a[0])throw new r("tlv.decode(long): zero leftmost byte");for(var c of a)i=i<<8|c;if(n+=s,i<128)throw new r("tlv.decode(long): not minimal encoding")}else i=o;var u=t.subarray(n,n+i);if(u.length!==i)throw new r("tlv.decode: wrong value length");return{v:u,l:t.subarray(n+i)}}},_int:{encode(e){var{Err:t}=Ou;if(e<Iu)throw new t("integer: negative integers are not allowed");var r=rn(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){var{Err:t}=Ou;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return gn(e)}},toSig(e){var{Err:t,_int:r,_tlv:n}=Ou,o=vn("signature",e),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");var{v:a,l:c}=n.decode(2,i),{v:u,l:l}=n.decode(2,c);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){var{_tlv:t,_int:r}=Ou,n=t.encode(2,r.encode(e.r))+t.encode(2,r.encode(e.s));return t.encode(48,n)}};function Au(e,t){return an(mn(e,t))}var Iu=BigInt(0),xu=BigInt(1);BigInt(2);var Pu=BigInt(3),Eu=BigInt(4);function Cu(e){var t=function(e){var t=ui(e);Cn(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});var{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze(Z({},t))}(e),{Fp:r}=t,n=$o(t.n,t.nBitLength),o=t.toBytes||((e,t,n)=>{var o=t.toAffine();return kn(Uint8Array.from([4]),r.toBytes(o.x),r.toBytes(o.y))}),i=t.fromBytes||(e=>{var t=e.subarray(1);return{x:r.fromBytes(t.subarray(0,r.BYTES)),y:r.fromBytes(t.subarray(r.BYTES,2*r.BYTES))}});function s(e){var{a:n,b:o}=t,i=r.sqr(e),s=r.mul(i,e);return r.add(r.add(s,r.mul(e,n)),o)}function a(e,t){var n=r.sqr(t),o=s(e);return r.eql(n,o)}if(!a(t.Gx,t.Gy))throw new Error("bad curve params: generator point");var c=r.mul(r.pow(t.a,Pu),Eu),u=r.mul(r.sqr(t.b),BigInt(27));if(r.is0(r.add(c,u)))throw new Error("bad curve params: a or b");function l(e){var r,{allowedPrivateKeyLengths:n,nByteLength:o,wrapPrivateKey:i,n:s}=t;if(n&&"bigint"!=typeof e){if(Xr(e)&&(e=an(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*o,"0")}try{r="bigint"==typeof e?e:gn(vn("private key",e,o))}catch(t){throw new Error("invalid private key, expected hex or "+o+" bytes, got "+typeof e)}return i&&(r=Lo(r,s)),An("private key",r,xu,s),r}function d(e){if(!(e instanceof y))throw new Error("ProjectivePoint expected")}var h=Bn(((e,t)=>{var{px:n,py:o,pz:i}=e;if(r.eql(i,r.ONE))return{x:n,y:o};var s=e.is0();null==t&&(t=s?r.ONE:r.inv(i));var a=r.mul(n,t),c=r.mul(o,t),u=r.mul(i,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),p=Bn((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.py))return;throw new Error("bad point: ZERO")}var{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not FE");if(!a(n,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class y{constructor(e,t,n){if(null==e||!r.isValid(e))throw new Error("x required");if(null==t||!r.isValid(t)||r.is0(t))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required");this.px=e,this.py=t,this.pz=n,Object.freeze(this)}static fromAffine(e){var{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof y)throw new Error("projective point not allowed");var o=e=>r.eql(e,r.ZERO);return o(t)&&o(n)?y.ZERO:new y(t,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){var t=Ho(r,e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(y.fromAffine)}static fromHex(e){var t=y.fromAffine(i(vn("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return y.BASE.multiply(l(e))}static msm(e,t){return ci(y,n,e,t)}_setWindowSize(e){b.setWindowSize(this,e)}assertValidity(){p(this)}hasEvenY(){var{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){d(e);var{px:t,py:n,pz:o}=this,{px:i,py:s,pz:a}=e,c=r.eql(r.mul(t,a),r.mul(i,o)),u=r.eql(r.mul(n,a),r.mul(s,o));return c&&u}negate(){return new y(this.px,r.neg(this.py),this.pz)}double(){var{a:e,b:n}=t,o=r.mul(n,Pu),{px:i,py:s,pz:a}=this,c=r.ZERO,u=r.ZERO,l=r.ZERO,d=r.mul(i,i),h=r.mul(s,s),p=r.mul(a,a),f=r.mul(i,s);return f=r.add(f,f),l=r.mul(i,a),l=r.add(l,l),c=r.mul(e,l),u=r.mul(o,p),u=r.add(c,u),c=r.sub(h,u),u=r.add(h,u),u=r.mul(c,u),c=r.mul(f,c),l=r.mul(o,l),p=r.mul(e,p),f=r.sub(d,p),f=r.mul(e,f),f=r.add(f,l),l=r.add(d,d),d=r.add(l,d),d=r.add(d,p),d=r.mul(d,f),u=r.add(u,d),p=r.mul(s,a),p=r.add(p,p),d=r.mul(p,f),c=r.sub(c,d),l=r.mul(p,h),l=r.add(l,l),l=r.add(l,l),new y(c,u,l)}add(e){d(e);var{px:n,py:o,pz:i}=this,{px:s,py:a,pz:c}=e,u=r.ZERO,l=r.ZERO,h=r.ZERO,p=t.a,f=r.mul(t.b,Pu),g=r.mul(n,s),b=r.mul(o,a),m=r.mul(i,c),w=r.add(n,o),v=r.add(s,a);w=r.mul(w,v),v=r.add(g,b),w=r.sub(w,v),v=r.add(n,i);var k=r.add(s,c);return v=r.mul(v,k),k=r.add(g,m),v=r.sub(v,k),k=r.add(o,i),u=r.add(a,c),k=r.mul(k,u),u=r.add(b,m),k=r.sub(k,u),h=r.mul(p,v),u=r.mul(f,m),h=r.add(u,h),u=r.sub(b,h),h=r.add(b,h),l=r.mul(u,h),b=r.add(g,g),b=r.add(b,g),m=r.mul(p,m),v=r.mul(f,v),b=r.add(b,m),m=r.sub(g,m),m=r.mul(p,m),v=r.add(v,m),g=r.mul(b,v),l=r.add(l,g),g=r.mul(k,v),u=r.mul(w,u),u=r.sub(u,g),g=r.mul(w,b),h=r.mul(k,h),h=r.add(h,g),new y(u,l,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(y.ZERO)}wNAF(e){return b.wNAFCached(this,e,y.normalizeZ)}multiplyUnsafe(e){var{endo:n,n:o}=t;An("scalar",e,Iu,o);var i=y.ZERO;if(e===Iu)return i;if(this.is0()||e===xu)return this;if(!n||b.hasPrecomputes(this))return b.wNAFCachedUnsafe(this,e,y.normalizeZ);for(var{k1neg:s,k1:a,k2neg:c,k2:u}=n.splitScalar(e),l=i,d=i,h=this;a>Iu||u>Iu;)a&xu&&(l=l.add(h)),u&xu&&(d=d.add(h)),h=h.double(),a>>=xu,u>>=xu;return s&&(l=l.negate()),c&&(d=d.negate()),d=new y(r.mul(d.px,n.beta),d.py,d.pz),l.add(d)}multiply(e){var n,o,{endo:i,n:s}=t;if(An("scalar",e,xu,s),i){var{k1neg:a,k1:c,k2neg:u,k2:l}=i.splitScalar(e),{p:d,f:h}=this.wNAF(c),{p:p,f:f}=this.wNAF(l);d=b.constTimeNegate(a,d),p=b.constTimeNegate(u,p),p=new y(r.mul(p.px,i.beta),p.py,p.pz),n=d.add(p),o=h.add(f)}else{var{p:g,f:m}=this.wNAF(e);n=g,o=m}return y.normalizeZ([n,o])[0]}multiplyAndAddUnsafe(e,t,r){var n=y.BASE,o=(e,t)=>t!==Iu&&t!==xu&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),i=o(this,t).add(o(e,r));return i.is0()?void 0:i}toAffine(e){return h(this,e)}isTorsionFree(){var{h:e,isTorsionFree:r}=t;if(e===xu)return!0;if(r)return r(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){var{h:e,clearCofactor:r}=t;return e===xu?this:r?r(y,this):this.multiplyUnsafe(t.h)}toRawBytes(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return tn("isCompressed",e),this.assertValidity(),o(y,this,e)}toHex(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return tn("isCompressed",e),an(this.toRawBytes(e))}}y.BASE=new y(t.Gx,t.Gy,r.ONE),y.ZERO=new y(r.ZERO,r.ONE,r.ZERO);var{endo:f,nBitLength:g}=t,b=ai(y,f?Math.ceil(g/2):g);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:l,weierstrassEquation:s,isWithinCurveOrder:function(e){return On(e,xu,t.n)}}}function Bu(e){var t,r=(Cn(t=ui(e),{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze(Z({lowS:!0},t))),{Fp:n,n:o,nByteLength:i,nBitLength:s}=r,a=n.BYTES+1,c=2*n.BYTES+1;function u(e){return Lo(e,o)}function l(e){return Mo(e,o)}var{ProjectivePoint:d,normPrivateKeyToScalar:h,weierstrassEquation:p,isWithinCurveOrder:y}=Cu(Z(Z({},r),{},{toBytes(e,t,r){var o=t.toAffine(),i=n.toBytes(o.x),s=kn;return tn("isCompressed",r),r?s(Uint8Array.from([t.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,n.toBytes(o.y))},fromBytes(e){var t=e.length,r=e[0],o=e.subarray(1);if(t!==a||2!==r&&3!==r){if(t===c&&4===r)return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))};throw new Error("invalid Point, expected length of "+a+", or uncompressed "+c+", got "+t)}var i=gn(o);if(!On(i,xu,n.ORDER))throw new Error("Point is not on curve");var s,u=p(i);try{s=n.sqrt(u)}catch(e){var l=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+l)}return!(1&~r)!==((s&xu)===xu)&&(s=n.neg(s)),{x:i,y:s}}}));function f(e){return e>o>>xu}var g=(e,t,r)=>gn(e.slice(t,r));class b{constructor(e,t,r){An("r",e,xu,o),An("s",t,xu,o),this.r=e,this.s=t,null!=r&&(this.recovery=r),Object.freeze(this)}static fromCompact(e){var t=i;return e=vn("compactSignature",e,2*t),new b(g(e,0,t),g(e,t,2*t))}static fromDER(e){var{r:t,s:r}=Ou.toSig(vn("DER",e));return new b(t,r)}assertValidity(){}addRecoveryBit(e){return new b(this.r,this.s,e)}recoverPublicKey(e){var{r:t,s:o,recovery:i}=this,s=k(vn("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");var a=2===i||3===i?t+r.n:t;if(a>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");var c=1&i?"03":"02",h=d.fromHex(c+Au(a,n.BYTES)),p=l(a),y=u(-s*p),f=u(o*p),g=d.BASE.multiplyAndAddUnsafe(h,y,f);if(!g)throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,u(-this.s),this.recovery):this}toDERRawBytes(){return fn(this.toDERHex())}toDERHex(){return Ou.hexFromSig(this)}toCompactRawBytes(){return fn(this.toCompactHex())}toCompactHex(){var e=i;return Au(this.r,e)+Au(this.s,e)}}var m={isValidPrivateKey(e){try{return h(e),!0}catch(e){return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{var e=Zo(r.n);return function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=e.length,o=Yo(t),i=Zo(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);var s=Lo(r?bn(e):gn(e),t-Ro)+Ro;return r?wn(s,o):mn(s,o)}(r.randomBytes(e),r.n)},precompute(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.BASE;return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function w(e){if("bigint"==typeof e)return!1;if(e instanceof d)return!0;var t=vn("key",e).length,o=n.BYTES,s=o+1,a=2*o+1;return r.allowedPrivateKeyLengths||i===s?void 0:t===s||t===a}var v=r.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");var t=gn(e),r=8*e.length-s;return r>0?t>>BigInt(r):t},k=r.bits2int_modN||function(e){return u(v(e))},S=In(s);function O(e){return An("num < 2^"+s,e,Iu,S),mn(e,i)}function A(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:I;if(["recovered","canonical"].some((e=>e in o)))throw new Error("sign() legacy options not supported");var{hash:i,randomBytes:s}=r,{lowS:a,prehash:c,extraEntropy:p}=o;null==a&&(a=!0),e=vn("msgHash",e),ku(o),c&&(e=vn("prehashed msgHash",i(e)));var g=k(e),m=h(t),w=[O(m),O(g)];if(null!=p&&!1!==p){var S=!0===p?s(n.BYTES):p;w.push(vn("extraEntropy",S))}var A=kn(...w),x=g;return{seed:A,k2sig:function(e){var t=v(e);if(y(t)){var r=l(t),n=d.BASE.multiply(t).toAffine(),o=u(n.x);if(o!==Iu){var i=u(r*u(x+o*m));if(i!==Iu){var s=(n.x===o?0:2)|Number(n.y&xu),c=i;return a&&f(i)&&(c=function(e){return f(e)?u(-e):e}(i),s^=1),new b(o,c,s)}}}}}}var I={lowS:r.lowS,prehash:!1},x={lowS:r.lowS,prehash:!1};return d.BASE._setWindowSize(8),{CURVE:r,getPublicKey:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return d.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!0===w(e))throw new Error("first arg must be private key");if(!1===w(t))throw new Error("second arg must be public key");return d.fromHex(t).multiply(h(e)).toRawBytes(r)},sign:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:I,{seed:o,k2sig:i}=A(e,t,n),s=r,a=function(e,t,r){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");var n=xn(e),o=xn(e),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return r(o,n,...t)},c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xn(0);o=a(Pn([0]),e),n=a(),0!==e.length&&(o=a(Pn([1]),e),n=a())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");for(var e=0,r=[];e<t;){var o=(n=a()).slice();r.push(o),e+=n.length}return kn(...r)};return(e,t)=>{s(),c(e);for(var r=void 0;!(r=t(u()));)c();return s(),r}}(s.hash.outputLen,s.nByteLength,s.hmac);return a(o,i)},verify:function(e,t,n){var o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:x,s=e;t=vn("msgHash",t),n=vn("publicKey",n);var{lowS:a,prehash:c,format:h}=i;if(ku(i),"strict"in i)throw new Error("options.strict was renamed to lowS");if(void 0!==h&&"compact"!==h&&"der"!==h)throw new Error("format must be compact or der");var p="string"==typeof s||Xr(s),y=!p&&!h&&"object"==typeof s&&null!==s&&"bigint"==typeof s.r&&"bigint"==typeof s.s;if(!p&&!y)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");var f,g=void 0;try{if(y&&(g=new b(s.r,s.s)),p){try{"compact"!==h&&(g=b.fromDER(s))}catch(e){if(!(e instanceof Ou.Err))throw e}g||"der"===h||(g=b.fromCompact(s))}f=d.fromHex(n)}catch(e){return!1}if(!g)return!1;if(a&&g.hasHighS())return!1;c&&(t=r.hash(t));var{r:m,s:w}=g,v=k(t),S=l(w),O=u(v*S),A=u(m*S),I=null===(o=d.BASE.multiplyAndAddUnsafe(f,O,A))||void 0===o?void 0:o.toAffine();return!!I&&u(I.x)===m},ProjectivePoint:d,Signature:b,utils:m}}function Tu(e){return{hash:e,hmac:function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return vu(e,t,function(){for(var e=0,t=0;t<arguments.length;t++){var r=t<0||arguments.length<=t?void 0:arguments[t];Rn(r),e+=r.length}for(var n=new Uint8Array(e),o=0,i=0;o<arguments.length;o++){var s=o<0||arguments.length<=o?void 0:arguments[o];n.set(s,i),i+=s.length}return n}(...n))},randomBytes:Xn}}var Du=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ru=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ju=BigInt(0),Nu=BigInt(1),Uu=BigInt(2),Ku=(e,t)=>(e+t/Uu)/t;var qu=$o(Du,void 0,void 0,{sqrt:function(e){var t=Du,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,d=_o(l,r,t)*l%t,h=_o(d,r,t)*l%t,p=_o(h,Uu,t)*u%t,y=_o(p,o,t)*p%t,f=_o(y,i,t)*y%t,g=_o(f,a,t)*f%t,b=_o(g,c,t)*g%t,m=_o(b,a,t)*f%t,w=_o(m,r,t)*l%t,v=_o(w,s,t)*y%t,k=_o(v,n,t)*u%t,S=_o(k,Uu,t);if(!qu.eql(qu.sqr(S),e))throw new Error("Cannot find square root");return S}}),Lu=function(e,t){var r=t=>Bu(Z(Z({},e),Tu(t)));return Z(Z({},r(t)),{},{create:r})}({a:ju,b:BigInt(7),Fp:qu,n:Ru,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{var t=Ru,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Nu*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=Ku(i*e,t),c=Ku(-n*e,t),u=Lo(e-a*r-c*o,t),l=Lo(-a*n-c*i,t),d=u>s,h=l>s;if(d&&(u=t-u),h&&(l=t-l),u>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:u,k2neg:h,k2:l}}}},Bo);function _u(e){return null!=e&&("function"==typeof e.then&&"function"==typeof e.catch&&"function"==typeof e.finally)}var Mu,Fu;class zu{constructor(e){W(this,"type","secp256k1"),W(this,"raw",void 0),W(this,"_key",void 0),this._key=function(e){try{return Lu.ProjectivePoint.fromHex(e),e}catch(e){throw new d.InvalidPublicKeyError(String(e))}}(e),this.raw=function(e){var t=Lu.ProjectivePoint.fromHex(e).toRawBytes(!0);return t}(this._key)}toMultihash(){return os.digest($u(this))}toCID(){return fs.createV1(114,this.toMultihash())}toString(){return us.encode(this.toMultihash().bytes).substring(1)}equals(e){return null!=e&&e.raw instanceof Uint8Array&&Es(this.raw,e.raw)}verify(e,t){return function(e,t,r){var n=sa.digest(r instanceof Uint8Array?r:r.subarray());if(_u(n))return n.then((r=>{var{digest:n}=r;return Lu.verify(t,n,e)})).catch((e=>{throw new nu(String(e))}));try{return Lu.verify(t,n.digest,e)}catch(e){throw new nu(String(e))}}(this._key,t,e)}}class Gu{constructor(e,t){W(this,"type","secp256k1"),W(this,"raw",void 0),W(this,"publicKey",void 0),this.raw=function(e){try{return Lu.getPublicKey(e,!0),e}catch(e){throw new d.InvalidPrivateKeyError(String(e))}}(e),this.publicKey=new zu(null!=t?t:function(e){try{return Lu.getPublicKey(e,!0)}catch(e){throw new d.InvalidPrivateKeyError(String(e))}}(e))}equals(e){return null!=e&&e.raw instanceof Uint8Array&&Es(this.raw,e.raw)}sign(e){return function(e,t){var r=sa.digest(t instanceof Uint8Array?t:t.subarray());if(_u(r))return r.then((t=>{var{digest:r}=t;return Lu.sign(r,e).toDERRawBytes()})).catch((e=>{throw new ru(String(e))}));try{return Lu.sign(r.digest,e).toDERRawBytes()}catch(e){throw new ru(String(e))}}(this.raw,e)}}function Vu(e){return new zu(e)}function Hu(){return(Hu=G((function*(){var e=Lu.utils.randomPrivateKey();return new Gu(e)}))).apply(this,arguments)}function Wu(){return Wu=G((function*(e,t){if("Ed25519"===e)return function(){return Qa.apply(this,arguments)}();if("secp256k1"===e)return function(){return Hu.apply(this,arguments)}();if("RSA"===e)return function(e){return yu.apply(this,arguments)}(function(e){if(null==e)return 2048;return parseInt(e,10)}(t));if("ECDSA"===e)return function(){return Ga.apply(this,arguments)}(function(e){if("P-256"===e||null==e)return"P-256";if("P-384"===e)return"P-384";if("P-521"===e)return"P-521";throw new d.InvalidParametersError("Unsupported curve, should be P-256, P-384 or P-521")}(t));throw new d.UnsupportedKeyTypeError})),Wu.apply(this,arguments)}function Ju(e,t){var{Type:r,Data:n}=Lc.decode(e),o=null!=n?n:new Uint8Array;switch(r){case Kc.RSA:return function(e,t){if(e.byteLength>=1062)throw new d.InvalidPublicKeyError("Key size is too large");return pu(va(e,{offset:0}),e,t)}(o,t);case Kc.Ed25519:return Za(o);case Kc.secp256k1:return Vu(o);case Kc.ECDSA:return function(e){return Fa(va(e))}(o);default:throw new d.UnsupportedKeyTypeError}}function $u(e){return Lc.encode({Type:Kc[e.type],Data:e.raw})}function Yu(e){var t;if(e.byteLength===Wa)return function(e){if(e.length>Wa){var t=(e=Xa(e,96)).subarray(0,Wa),r=e.subarray(Wa,e.length);return new Ya(t,r)}var n=(e=Xa(e,Wa)).subarray(0,Wa),o=e.subarray(32);return new Ya(n,o)}(e);if(32===e.byteLength)return function(e){return new Gu(e)}(e);var r=va(e),n=null===(t=r[2])||void 0===t?void 0:t[0];if(n===Pa||n===Ea||n===Ca)return function(e){var t,r,n=e[1],o=fa(n,"base64url"),i=e[2][1][0];if(n.byteLength===La)return t=fa(i.subarray(1,33),"base64url"),r=fa(i.subarray(33),"base64url"),new Ha(Z(Z({},Ua),{},{key_ops:["sign"],d:o,x:t,y:r}));if(n.byteLength===_a)return t=fa(i.subarray(1,49),"base64url"),r=fa(i.subarray(49),"base64url"),new Ha(Z(Z({},Ka),{},{key_ops:["sign"],d:o,x:t,y:r}));if(n.byteLength===Ma)return t=fa(i.subarray(1,67),"base64url"),r=fa(i.subarray(67),"base64url"),new Ha(Z(Z({},qa),{},{key_ops:["sign"],d:o,x:t,y:r}));throw new d.InvalidParametersError("Private key length was wrong length, got ".concat(n.byteLength,", expected 32, 48 or 66"))}(r);if(r.length>8)return hu(r);throw new d.InvalidParametersError("Could not extract private key from raw bytes")}function Zu(e){return Qu.apply(this,arguments)}function Qu(){return(Qu=G((function*(e){if("RSA"===e.type)return{privateKey:yield crypto.subtle.importKey("jwk",e.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),publicKey:yield crypto.subtle.importKey("jwk",e.publicKey.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])};var t,r;if("ECDSA"===e.type)return{privateKey:yield crypto.subtle.importKey("jwk",e.jwk,{name:"ECDSA",namedCurve:null!==(t=e.jwk.crv)&&void 0!==t?t:"P-256"},!0,["sign"]),publicKey:yield crypto.subtle.importKey("jwk",e.publicKey.jwk,{name:"ECDSA",namedCurve:null!==(r=e.publicKey.jwk.crv)&&void 0!==r?r:"P-256"},!0,["verify"])};throw new d.InvalidParametersError("Only RSA and ECDSA keys are supported")}))).apply(this,arguments)}!function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.publicKey&&e.publicKey.byteLength>0&&(t.uint32(10),t.bytes(e.publicKey)),null!=e.payloadType&&e.payloadType.byteLength>0&&(t.uint32(18),t.bytes(e.payloadType)),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(26),t.bytes(e.payload)),null!=e.signature&&e.signature.byteLength>0&&(t.uint32(42),t.bytes(e.signature)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={publicKey:Cs(0),payloadType:Cs(0),payload:Cs(0),signature:Cs(0)},n=null==t?e.len:e.pos+t;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.publicKey=e.bytes();break;case 2:r.payloadType=e.bytes();break;case 3:r.payload=e.bytes();break;case 5:r.signature=e.bytes();break;default:e.skipType(7&o)}}return r}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(Mu||(Mu={}));class Xu extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Invalid signature"),this.name="InvalidSignatureError"}}class el{constructor(e){W(this,"publicKey",void 0),W(this,"payloadType",void 0),W(this,"payload",void 0),W(this,"signature",void 0),W(this,"marshaled",void 0);var{publicKey:t,payloadType:r,payload:n,signature:o}=e;this.publicKey=t,this.payloadType=r,this.payload=n,this.signature=o}marshal(){return null==this.marshaled&&(this.marshaled=Mu.encode({publicKey:$u(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return null!=e&&Es(this.marshal(),e.marshal())}validate(e){var t=this;return G((function*(){var r=tl(e,t.payloadType,t.payload);return t.publicKey.verify(r.subarray(),t.signature)}))()}}Fu=el,W(el,"createFromProtobuf",function(){var e=G((function*(e){var t=Mu.decode(e),r=Ju(t.publicKey);return new Fu({publicKey:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})}));return function(t){return e.apply(this,arguments)}}()),W(el,"seal",function(){var e=G((function*(e,t){if(null==t)throw new Error("Missing private key");var r=e.domain,n=e.codec,o=e.marshal(),i=tl(r,n,o),s=yield t.sign(i.subarray());return new Fu({publicKey:t.publicKey,payloadType:n,payload:o,signature:s})}));return function(t,r){return e.apply(this,arguments)}}()),W(el,"openAndCertify",function(){var e=G((function*(e,t){var r=yield Fu.createFromProtobuf(e);if(!(yield r.validate(t)))throw new Xu("Envelope signature is not valid for the given domain");return r}));return function(t,r){return e.apply(this,arguments)}}());var tl=(e,t,r)=>{var n=ya(e),o=hc(n.byteLength),i=hc(t.length),s=hc(r.length);return new Ns(o,n,i,t,s,r)};var rl,nl,ol=Uint8Array.from([3,1]);!function(e){var t;!function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.multiaddr&&e.multiaddr.byteLength>0&&(t.uint32(10),t.bytes(e.multiaddr)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={multiaddr:Cs(0)},n=null==t?e.len:e.pos+t;e.pos<n;){var o=e.uint32();if(o>>>3==1)r.multiaddr=e.bytes();else e.skipType(7&o)}return r}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(e.AddressInfo||(e.AddressInfo={})),e.codec=()=>(null==t&&(t=eu((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.peerId&&t.peerId.byteLength>0&&(r.uint32(10),r.bytes(t.peerId)),null!=t.seq&&0n!==t.seq&&(r.uint32(16),r.uint64(t.seq)),null!=t.addresses)for(var o of t.addresses)r.uint32(26),e.AddressInfo.codec().encode(o,r);!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o={peerId:Cs(0),seq:0n,addresses:[]},i=null==r?t.len:t.pos+r;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:o.peerId=t.bytes();break;case 2:o.seq=t.uint64();break;case 3:var a,c;if(null!=(null===(a=n.limits)||void 0===a?void 0:a.addresses)&&o.addresses.length===n.limits.addresses)throw new tu('Decode error - map field "addresses" had too many elements');o.addresses.push(e.AddressInfo.codec().decode(t,t.uint32(),{limits:null===(c=n.limits)||void 0===c?void 0:c.addresses$}));break;default:t.skipType(7&s)}}return o}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(rl||(rl={}));class il{constructor(e){W(this,"peerId",void 0),W(this,"multiaddrs",void 0),W(this,"seqNumber",void 0),W(this,"domain",il.DOMAIN),W(this,"codec",il.CODEC),W(this,"marshaled",void 0);var{peerId:t,multiaddrs:r,seqNumber:n}=e;this.peerId=t,this.multiaddrs=null!=r?r:[],this.seqNumber=null!=n?n:BigInt(Date.now())}marshal(){return null==this.marshaled&&(this.marshaled=rl.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map((e=>({multiaddr:e.bytes})))})),this.marshaled}equals(e){return e instanceof il&&(!!this.peerId.equals(e.peerId)&&(this.seqNumber===e.seqNumber&&!!function(e,t){var r=(e,t)=>e.toString().localeCompare(t.toString());return e.length===t.length&&(t.sort(r),e.sort(r).every(((e,r)=>t[r].equals(e))))}(this.multiaddrs,e.multiaddrs)))}}function sl(){var e={};return e.promise=new Promise(((t,r)=>{e.resolve=t,e.reject=r})),e}nl=il,W(il,"createFromProtobuf",(t=>{var n,o=rl.decode(t),i=r.peerIdFromMultihash(ts(o.peerId)),s=(null!==(n=o.addresses)&&void 0!==n?n:[]).map((t=>e.multiaddr(t.multiaddr))),a=o.seq;return new nl({peerId:i,multiaddrs:s,seqNumber:a})})),W(il,"DOMAIN","libp2p-peer-record"),W(il,"CODEC",ol);let al=class extends Error{constructor(e,t,r){super(null!=e?e:"The operation was aborted"),W(this,"type",void 0),W(this,"code",void 0),this.type="aborted",this.name=null!=r?r:"AbortError",this.code=null!=t?t:"ABORT_ERR"}};function cl(e,t,r){return ul.apply(this,arguments)}function ul(){return ul=G((function*(e,t,r){if(null==t)return e;if(t.aborted)return e.catch((()=>{})),Promise.reject(new al(null==r?void 0:r.errorMessage,null==r?void 0:r.errorCode,null==r?void 0:r.errorName));var n,o=new al(null==r?void 0:r.errorMessage,null==r?void 0:r.errorCode,null==r?void 0:r.errorName);try{return yield Promise.race([e,new Promise(((e,r)=>{n=()=>{r(o)},t.addEventListener("abort",n)}))])}finally{null!=n&&t.removeEventListener("abort",n)}})),ul.apply(this,arguments)}class ll{constructor(){W(this,"readNext",void 0),W(this,"haveNext",void 0),W(this,"ended",void 0),W(this,"nextResult",void 0),W(this,"error",void 0),this.ended=!1,this.readNext=sl(),this.haveNext=sl()}[Symbol.asyncIterator](){return this}next(){var e=this;return G((function*(){if(null==e.nextResult&&(yield e.haveNext.promise),null==e.nextResult)throw new Error("HaveNext promise resolved but nextResult was undefined");var t=e.nextResult;return e.nextResult=void 0,e.readNext.resolve(),e.readNext=sl(),t}))()}throw(e){var t=this;return G((function*(){return t.ended=!0,t.error=e,null!=e&&(t.haveNext.promise.catch((()=>{})),t.haveNext.reject(e)),{done:!0,value:void 0}}))()}return(){var e=this;return G((function*(){var t={done:!0,value:void 0};return e.ended=!0,e.nextResult=t,e.haveNext.resolve(),t}))()}push(e,t){var r=this;return G((function*(){yield r._push(e,t)}))()}end(e,t){var r=this;return G((function*(){null!=e?yield r.throw(e):yield r._push(void 0,t)}))()}_push(e,t){var r=this;return G((function*(){var n;if(null!=e&&r.ended)throw null!==(n=r.error)&&void 0!==n?n:new Error("Cannot push value onto an ended pushable");for(;null!=r.nextResult;)yield r.readNext.promise;null!=e?r.nextResult={done:!1,value:e}:(r.ended=!0,r.nextResult={done:!0,value:void 0}),r.haveNext.resolve(),r.haveNext=sl(),yield cl(r.readNext.promise,null==t?void 0:t.signal,t)}))()}}function dl(){return new ll}let hl=class extends Error{constructor(){super(...arguments),W(this,"name","UnexpectedEOFError"),W(this,"code","ERR_UNEXPECTED_EOF")}};function pl(e,t){var r=dl();e.sink(r).catch(function(){var e=G((function*(e){yield r.end(e)}));return function(t){return e.apply(this,arguments)}}()),e.sink=function(){var e=G((function*(e){var t,n=!1,o=!1;try{for(var i,s=M(e);n=!(i=yield s.next()).done;n=!1){var a=i.value;yield r.push(a)}}catch(e){o=!0,t=e}finally{try{n&&null!=s.return&&(yield s.return())}finally{if(o)throw t}}yield r.end()}));return function(t){return e.apply(this,arguments)}}();var n=e.source;null!=e.source[Symbol.iterator]?n=e.source[Symbol.iterator]():null!=e.source[Symbol.asyncIterator]&&(n=e.source[Symbol.asyncIterator]());var o,i,s=new Ns,a={read:(i=G((function*(e){var t;if(null==e||null===(t=e.signal)||void 0===t||t.throwIfAborted(),null==(null==e?void 0:e.bytes)){var{done:r,value:o}=yield cl(n.next(),null==e?void 0:e.signal);return!0===r?null:o}for(;s.byteLength<e.bytes;){var{value:i,done:a}=yield cl(n.next(),null==e?void 0:e.signal);if(!0===a)throw new hl("unexpected end of input");s.append(i)}var c=s.sublist(0,e.bytes);return s.consume(e.bytes),c})),function(e){return i.apply(this,arguments)}),write:(o=G((function*(e,t){var n;null==t||null===(n=t.signal)||void 0===n||n.throwIfAborted(),e instanceof Uint8Array?yield r.push(e,t):yield r.push(e.subarray(),t)})),function(e,t){return o.apply(this,arguments)}),unwrap:()=>{if(s.byteLength>0){var r=e.source;e.source=ee((function*(){!1===(null==t?void 0:t.yieldBytes)?yield s:yield*_(M(s)),yield*_(M(r))}))()}return e}};return a}let yl=class extends Error{constructor(){super(...arguments),W(this,"name","InvalidMessageLengthError"),W(this,"code","ERR_INVALID_MSG_LENGTH")}},fl=class extends Error{constructor(){super(...arguments),W(this,"name","InvalidDataLengthError"),W(this,"code","ERR_MSG_DATA_TOO_LONG")}},gl=class extends Error{constructor(){super(...arguments),W(this,"name","InvalidDataLengthLengthError"),W(this,"code","ERR_MSG_LENGTH_TOO_LONG")}};function bl(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=pl(e,n);null!=n.maxDataLength&&null==n.maxLengthLength&&(n.maxLengthLength=uc(n.maxDataLength));var i,s,a,c=null!==(t=null==n?void 0:n.lengthDecoder)&&void 0!==t?t:pc,u=null!==(r=null==n?void 0:n.lengthEncoder)&&void 0!==r?r:hc,l={read:(a=G((function*(e){for(var t=-1,r=new Ns;;){r.append(yield o.read(Z(Z({},e),{},{bytes:1})));try{t=c(r)}catch(e){if(e instanceof RangeError)continue;throw e}if(t<0)throw new yl("Invalid message length");if(null!=(null==n?void 0:n.maxLengthLength)&&r.byteLength>n.maxLengthLength)throw new gl("message length length too long");if(t>-1)break}if(null!=(null==n?void 0:n.maxDataLength)&&t>n.maxDataLength)throw new fl("message length too long");return o.read(Z(Z({},e),{},{bytes:t}))})),function(e){return a.apply(this,arguments)}),write:(s=G((function*(e,t){yield o.write(new Ns(u(e.byteLength),e),t)})),function(e,t){return s.apply(this,arguments)}),writeV:(i=G((function*(e,t){var r=new Ns(...e.flatMap((e=>[u(e.byteLength),e])));yield o.write(r,t)})),function(e,t){return i.apply(this,arguments)}),unwrap:()=>o.unwrap()};return l}function ml(e,t){var r,n,o,i=bl(e,t),s={read:(o=G((function*(e,t){var r=yield i.read(t);return e.decode(r)})),function(e,t){return o.apply(this,arguments)}),write:(n=G((function*(e,t,r){yield i.write(t.encode(e),r)})),function(e,t,r){return n.apply(this,arguments)}),writeV:(r=G((function*(e,t,r){yield i.writeV(e.map((e=>t.encode(e))),r)})),function(e,t,n){return r.apply(this,arguments)}),pb:e=>{return{read:(n=G((function*(t){return s.read(e,t)})),function(e){return n.apply(this,arguments)}),write:(r=G((function*(t,r){return s.write(t,e,r)})),function(e,t){return r.apply(this,arguments)}),writeV:(t=G((function*(t,r){return s.writeV(t,e,r)})),function(e,r){return t.apply(this,arguments)}),unwrap:()=>s};var t,r,n},unwrap:()=>i.unwrap()};return s}var wl="".concat(d.KEEP_ALIVE,"-circuit-relay");BigInt(1<<17);var vl,kl,Sl,Ol,Al,Il,xl,Pl,El,Cl="/libp2p/circuit/relay/0.2.0/hop",Bl="/libp2p/circuit/relay/0.2.0/stop";!function(e){var t,r;!function(e){e.RESERVE="RESERVE",e.CONNECT="CONNECT",e.STATUS="STATUS"}(e.Type||(e.Type={})),function(e){e[e.RESERVE=0]="RESERVE",e[e.CONNECT=1]="CONNECT",e[e.STATUS=2]="STATUS"}(t||(t={})),function(e){e.codec=()=>Xc(t)}(e.Type||(e.Type={})),e.codec=()=>(null==r&&(r=eu((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&r.fork(),null!=t.type&&(r.uint32(8),e.Type.codec().encode(t.type,r)),null!=t.peer&&(r.uint32(18),Sl.codec().encode(t.peer,r)),null!=t.reservation&&(r.uint32(26),Ol.codec().encode(t.reservation,r)),null!=t.limit&&(r.uint32(34),Al.codec().encode(t.limit,r)),null!=t.status&&(r.uint32(40),Il.codec().encode(t.status,r)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o={},i=null==r?t.len:t.pos+r;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:o.type=e.Type.codec().decode(t);break;case 2:var a;o.peer=Sl.codec().decode(t,t.uint32(),{limits:null===(a=n.limits)||void 0===a?void 0:a.peer});break;case 3:var c;o.reservation=Ol.codec().decode(t,t.uint32(),{limits:null===(c=n.limits)||void 0===c?void 0:c.reservation});break;case 4:var u;o.limit=Al.codec().decode(t,t.uint32(),{limits:null===(u=n.limits)||void 0===u?void 0:u.limit});break;case 5:o.status=Il.codec().decode(t);break;default:t.skipType(7&s)}}return o}))),r),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(vl||(vl={})),function(e){var t,r;!function(e){e.CONNECT="CONNECT",e.STATUS="STATUS"}(e.Type||(e.Type={})),function(e){e[e.CONNECT=0]="CONNECT",e[e.STATUS=1]="STATUS"}(t||(t={})),function(e){e.codec=()=>Xc(t)}(e.Type||(e.Type={})),e.codec=()=>(null==r&&(r=eu((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&r.fork(),null!=t.type&&(r.uint32(8),e.Type.codec().encode(t.type,r)),null!=t.peer&&(r.uint32(18),Sl.codec().encode(t.peer,r)),null!=t.limit&&(r.uint32(26),Al.codec().encode(t.limit,r)),null!=t.status&&(r.uint32(32),Il.codec().encode(t.status,r)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o={},i=null==r?t.len:t.pos+r;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:o.type=e.Type.codec().decode(t);break;case 2:var a;o.peer=Sl.codec().decode(t,t.uint32(),{limits:null===(a=n.limits)||void 0===a?void 0:a.peer});break;case 3:var c;o.limit=Al.codec().decode(t,t.uint32(),{limits:null===(c=n.limits)||void 0===c?void 0:c.limit});break;case 4:o.status=Il.codec().decode(t);break;default:t.skipType(7&s)}}return o}))),r),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(kl||(kl={})),function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.id&&e.id.byteLength>0&&(t.uint32(10),t.bytes(e.id)),null!=e.addrs)for(var n of e.addrs)t.uint32(18),t.bytes(n);!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={id:Cs(0),addrs:[]},o=null==t?e.len:e.pos+t;e.pos<o;){var i=e.uint32();switch(i>>>3){case 1:n.id=e.bytes();break;case 2:var s;if(null!=(null===(s=r.limits)||void 0===s?void 0:s.addrs)&&n.addrs.length===r.limits.addrs)throw new tu('Decode error - map field "addrs" had too many elements');n.addrs.push(e.bytes());break;default:e.skipType(7&i)}}return n}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(Sl||(Sl={})),function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.expire&&0n!==e.expire&&(t.uint32(8),t.uint64(e.expire)),null!=e.addrs)for(var n of e.addrs)t.uint32(18),t.bytes(n);null!=e.voucher&&(t.uint32(26),El.codec().encode(e.voucher,t)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={expire:0n,addrs:[]},o=null==t?e.len:e.pos+t;e.pos<o;){var i=e.uint32();switch(i>>>3){case 1:n.expire=e.uint64();break;case 2:var s;if(null!=(null===(s=r.limits)||void 0===s?void 0:s.addrs)&&n.addrs.length===r.limits.addrs)throw new tu('Decode error - map field "addrs" had too many elements');n.addrs.push(e.bytes());break;case 3:var a;n.voucher=El.codec().decode(e,e.uint32(),{limits:null===(a=r.limits)||void 0===a?void 0:a.voucher});break;default:e.skipType(7&i)}}return n}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(Ol||(Ol={})),function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.duration&&(t.uint32(8),t.uint32(e.duration)),null!=e.data&&(t.uint32(16),t.uint64(e.data)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.duration=e.uint32();break;case 2:r.data=e.uint64();break;default:e.skipType(7&o)}}return r}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(Al||(Al={})),function(e){e.UNUSED="UNUSED",e.OK="OK",e.RESERVATION_REFUSED="RESERVATION_REFUSED",e.RESOURCE_LIMIT_EXCEEDED="RESOURCE_LIMIT_EXCEEDED",e.PERMISSION_DENIED="PERMISSION_DENIED",e.CONNECTION_FAILED="CONNECTION_FAILED",e.NO_RESERVATION="NO_RESERVATION",e.MALFORMED_MESSAGE="MALFORMED_MESSAGE",e.UNEXPECTED_MESSAGE="UNEXPECTED_MESSAGE"}(Il||(Il={})),function(e){e[e.UNUSED=0]="UNUSED",e[e.OK=100]="OK",e[e.RESERVATION_REFUSED=200]="RESERVATION_REFUSED",e[e.RESOURCE_LIMIT_EXCEEDED=201]="RESOURCE_LIMIT_EXCEEDED",e[e.PERMISSION_DENIED=202]="PERMISSION_DENIED",e[e.CONNECTION_FAILED=203]="CONNECTION_FAILED",e[e.NO_RESERVATION=204]="NO_RESERVATION",e[e.MALFORMED_MESSAGE=400]="MALFORMED_MESSAGE",e[e.UNEXPECTED_MESSAGE=401]="UNEXPECTED_MESSAGE"}(xl||(xl={})),function(e){e.codec=()=>Xc(xl)}(Il||(Il={})),function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.relay&&e.relay.byteLength>0&&(t.uint32(10),t.bytes(e.relay)),null!=e.peer&&e.peer.byteLength>0&&(t.uint32(18),t.bytes(e.peer)),null!=e.expiration&&0n!==e.expiration&&(t.uint32(24),t.uint64(e.expiration)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={relay:Cs(0),peer:Cs(0),expiration:0n},n=null==t?e.len:e.pos+t;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.relay=e.bytes();break;case 2:r.peer=e.bytes();break;case 3:r.expiration=e.uint64();break;default:e.skipType(7&o)}}return r}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(Pl||(Pl={})),function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.publicKey&&e.publicKey.byteLength>0&&(t.uint32(10),t.bytes(e.publicKey)),null!=e.payloadType&&e.payloadType.byteLength>0&&(t.uint32(18),t.bytes(e.payloadType)),null!=e.payload&&(t.uint32(26),Pl.codec().encode(e.payload,t)),null!=e.signature&&e.signature.byteLength>0&&(t.uint32(42),t.bytes(e.signature)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={publicKey:Cs(0),payloadType:Cs(0),signature:Cs(0)},o=null==t?e.len:e.pos+t;e.pos<o;){var i=e.uint32();switch(i>>>3){case 1:n.publicKey=e.bytes();break;case 2:n.payloadType=e.bytes();break;case 3:var s;n.payload=Pl.codec().decode(e,e.uint32(),{limits:null===(s=r.limits)||void 0===s?void 0:s.payload});break;case 5:n.signature=e.bytes();break;default:e.skipType(7&i)}}return n}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(El||(El={}));var Tl=new class{constructor(){W(this,"index",0),W(this,"input","")}new(e){return this.index=0,this.input=e,this}readAtomically(e){var t=this.index,r=e();return void 0===r&&(this.index=t),r}parseWith(e){var t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically((()=>{var t=this.readChar();if(t===e)return t}))}readSeparator(e,t,r){return this.readAtomically((()=>{if(!(t>0&&void 0===this.readGivenChar(e)))return r()}))}readNumber(e,t,r,n){return this.readAtomically((()=>{var o=0,i=0,s=this.peekChar();if(void 0!==s){for(var a="0"===s,c=2**(8*n)-1;;){var u=this.readAtomically((()=>{var t=this.readChar();if(void 0!==t){var r=Number.parseInt(t,e);if(!Number.isNaN(r))return r}}));if(void 0===u)break;if(o*=e,(o+=u)>c)return;if(i+=1,void 0!==t&&i>t)return}return 0===i||!r&&a&&i>1?void 0:o}}))}readIPv4Addr(){return this.readAtomically((()=>{for(var e=new Uint8Array(4),t=0;t<e.length;t++){var r=this.readSeparator(".",t,(()=>this.readNumber(10,3,!1,1)));if(void 0===r)return;e[t]=r}return e}))}readIPv6Addr(){var e=e=>{for(var t=0;t<e.length/2;t++){var r=2*t;if(t<e.length-3){var n=this.readSeparator(":",t,(()=>this.readIPv4Addr()));if(void 0!==n)return e[r]=n[0],e[r+1]=n[1],e[r+2]=n[2],e[r+3]=n[3],[r+4,!0]}var o=this.readSeparator(":",t,(()=>this.readNumber(16,4,!0,2)));if(void 0===o)return[r,!1];e[r]=o>>8,e[r+1]=255&o}return[e.length,!1]};return this.readAtomically((()=>{var t=new Uint8Array(16),[r,n]=e(t);if(16===r)return t;if(!n&&void 0!==this.readGivenChar(":")&&void 0!==this.readGivenChar(":")){var o=new Uint8Array(14),i=16-(r+2),[s]=e(o.subarray(0,i));return t.set(o.subarray(0,s),16-s),t}}))}readIPAddr(){var e;return null!==(e=this.readIPv4Addr())&&void 0!==e?e:this.readIPv6Addr()}};function Dl(e){if(!(e.length>15))return Tl.new(e).parseWith((()=>Tl.readIPv4Addr()))}function Rl(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>45))return Tl.new(e).parseWith((()=>Tl.readIPv6Addr()))}function jl(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>45)){var r=Tl.new(e).parseWith((()=>Tl.readIPAddr()));if(r)return t&&4===r.length?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,r[0],r[1],r[2],r[3]]):r}}function Nl(e){return Boolean(Dl(e))}function Ul(e){return Boolean(Rl(e))}var Kl=e=>({match:t=>!(t.length<1)&&(!!e(t[0])&&t.slice(1)),pattern:"fn"}),ql=e=>({match:t=>Kl((t=>t===e)).match(t),pattern:e}),Ll=()=>({match:e=>Kl((e=>"string"==typeof e)).match(e),pattern:"{string}"}),_l=()=>({match:e=>Kl((e=>!isNaN(parseInt(e)))).match(e),pattern:"{number}"}),Ml=()=>({match:e=>{if(e.length<2)return!1;if("p2p"!==e[0]&&"ipfs"!==e[0])return!1;if(!e[1].startsWith("Q")&&!e[1].startsWith("1"))return!1;try{us.decode("z".concat(e[1]))}catch(e){return!1}return e.slice(2)},pattern:"/p2p/{peerid}"}),Fl=()=>({match:e=>{if(e.length<2)return!1;if("certhash"!==e[0])return!1;try{Ys.decode(e[1])}catch(e){return!1}return e.slice(2)},pattern:"/certhash/{certhash}"}),zl=e=>({match:t=>{var r=e.match(t);return!1===r?t:r},pattern:"optional(".concat(e.pattern,")")}),Gl=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return{match:e=>{var r;for(var n of t){var o=n.match(e);!1!==o&&((null==r||o.length<r.length)&&(r=o))}return null!=r&&r},pattern:"or(".concat(t.map((e=>e.pattern)).join(", "),")")}},Vl=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return{match:e=>{for(var r of t){var n=r.match(e);if(!1===n)return!1;e=n}return e},pattern:"and(".concat(t.map((e=>e.pattern)).join(", "),")")}};function Hl(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];function n(e){var r=(e=>e.toString().split("/").slice(1))(e);for(var n of t){var o=n.match(r);if(!1===o)return!1;r=o}return r}return{matchers:t,matches:function(e){return!1!==n(e)},exactMatch:function(e){var t=n(e);return!1!==t&&0===t.length}}}Hl(Ml());var Wl=Vl(ql("dns4"),Ll()),Jl=Vl(ql("dns6"),Ll()),$l=Vl(ql("dnsaddr"),Ll()),Yl=Vl(ql("dns"),Ll());Hl(Wl,zl(Ml())),Hl(Jl,zl(Ml())),Hl($l,zl(Ml()));var Zl=Hl(Gl(Yl,$l,Wl,Jl),zl(Ml())),Ql=Vl(ql("ip4"),Kl(Nl)),Xl=Vl(ql("ip6"),Kl(Ul)),ed=Gl(Ql,Xl),td=Gl(ed,Yl,Wl,Jl,$l),rd=Hl(Gl(ed,Vl(Gl(Yl,$l,Wl,Jl),zl(Ml()))));Hl(Ql),Hl(Xl);var nd=Hl(ed),od=Vl(td,ql("tcp"),_l()),id=Vl(td,ql("udp"),_l()),sd=Hl(Vl(od,zl(Ml())));Hl(id);var ad=Vl(id,ql("quic"),zl(Ml())),cd=Vl(id,ql("quic-v1"),zl(Ml())),ud=Gl(ad,cd);Hl(ad),Hl(cd);var ld=Gl(td,od,id,ad,cd),dd=Gl(Vl(ld,ql("ws"),zl(Ml())));Hl(dd);var hd=Gl(Vl(ld,ql("wss"),zl(Ml())),Vl(ld,ql("tls"),zl(Vl(ql("sni"),Ll())),ql("ws"),zl(Ml())));Hl(hd);var pd=Vl(id,ql("webrtc-direct"),zl(Fl()),zl(Fl()),zl(Ml())),yd=Hl(pd),fd=Vl(cd,ql("webtransport"),zl(Fl()),zl(Fl()),zl(Ml()));Hl(fd);var gd=Gl(dd,hd,Vl(od,zl(Ml())),Vl(ud,zl(Ml())),Vl(td,zl(Ml())),pd,fd,Ml()),bd=Hl(gd),md=Hl(Vl(gd,ql("p2p-circuit"),Ml())),wd=Hl(Gl(Vl(gd,ql("p2p-circuit"),ql("webrtc"),zl(Ml())),Vl(gd,ql("webrtc"),zl(Ml())),Vl(ql("webrtc"),zl(Ml()))));function vd(e){var t=new globalThis.AbortController;function r(){for(var n of(t.abort(),e))null!=(null==n?void 0:n.removeEventListener)&&n.removeEventListener("abort",r)}for(var n of e){if(!0===(null==n?void 0:n.aborted)){r();break}null!=(null==n?void 0:n.addEventListener)&&n.addEventListener("abort",r)}var o=t.signal;return o.clear=function(){for(var t of e)null!=(null==t?void 0:t.removeEventListener)&&t.removeEventListener("abort",r)},o}Hl(Gl(Vl(td,ql("tcp"),_l(),ql("http"),zl(Ml())),Vl(td,ql("http"),zl(Ml())))),Hl(Gl(Vl(td,ql("tcp"),Gl(Vl(ql("443"),ql("http")),Vl(_l(),ql("https")),Vl(_l(),ql("tls"),ql("http"))),zl(Ml())),Vl(td,ql("tls"),ql("http"),zl(Ml())),Vl(td,ql("https"),zl(Ml())))),Hl(Gl(Vl(ql("memory"),Ll(),zl(Ml()))));class kd extends Error{constructor(){super(...arguments),W(this,"name","HadEnoughRelaysError")}}W(kd,"name","HadEnoughRelaysError");class Sd extends Error{constructor(){super(...arguments),W(this,"name","DoubleRelayError")}}W(Sd,"name","DoubleRelayError");class Od extends Error{constructor(){super(...arguments),W(this,"name","RelayQueueFullError")}}function Ad(e){var t=e*BigInt(1e3),r=(new Date).getTime();return Number(t-BigInt(r))}W(Od,"name","RelayQueueFullError");class Id{constructor(e){W(this,"expires",void 0),W(this,"bytes",void 0),null!=(null==e?void 0:e.duration)&&0!==(null==e?void 0:e.duration)&&(this.expires=Date.now()+1e3*e.duration),this.bytes=null==e?void 0:e.data,0n===this.bytes&&(this.bytes=void 0),this.onData=this.onData.bind(this)}onData(e){null!=this.bytes&&(this.bytes-=BigInt(e.byteLength),this.bytes<0n&&(this.bytes=0n))}getLimits(){if(null!=this.expires||null!=this.bytes){var e={};if(null!=this.bytes){var t=this;Object.defineProperty(e,"bytes",{get:()=>t.bytes})}if(null!=this.expires){var r=this;Object.defineProperty(e,"seconds",{get(){var e;return Math.round(((null!==(e=r.expires)&&void 0!==e?e:0)-Date.now())/1e3)}})}return e}}}var xd=Hl(Vl(bd.matchers[0],ql("p2p-circuit"))),Pd=Hl(ql("p2p-circuit"));function Ed(e,t){var r={[Symbol.iterator]:()=>r,next:()=>{var r=e.next(),n=r.value;return!0===r.done||null==n?{done:!0,value:void 0}:{done:!1,value:t(n)}}};return r}function Cd(e){var t=ts(us.decode("z".concat(e)));return r.peerIdFromMultihash(t)}class Bd{constructor(e){if(W(this,"map",void 0),this.map=new Map,null!=e)for(var[t,r]of e.entries())this.map.set(t.toString(),{key:t,value:r})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){return this.map.delete(e.toString())}entries(){return Ed(this.map.entries(),(e=>[e[1].key,e[1].value]))}forEach(e){this.map.forEach(((t,r)=>{e(t.value,t.key,this)}))}get(e){var t;return null===(t=this.map.get(e.toString()))||void 0===t?void 0:t.value}has(e){return this.map.has(e.toString())}set(e,t){this.map.set(e.toString(),{key:e,value:t})}keys(){return Ed(this.map.values(),(e=>e.key))}values(){return Ed(this.map.values(),(e=>e.value))}get size(){return this.map.size}}class Td{constructor(e){if(W(this,"set",void 0),this.set=new Set,null!=e)for(var t of e)this.set.add(t.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return Ed(this.set.entries(),(e=>{var t=Cd(e[0]);return[t,t]}))}forEach(e){this.set.forEach((t=>{var r=Cd(t);e(r,r,this)}))}has(e){return this.set.has(e.toString())}values(){return Ed(this.set.values(),(e=>Cd(e)))}intersection(e){var t=new Td;for(var r of e)this.has(r)&&t.add(r);return t}difference(e){var t=new Td;for(var r of this)e.has(r)||t.add(r);return t}union(e){var t=new Td;for(var r of e)t.add(r);for(var n of this)t.add(n);return t}}var Dd={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},Rd={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},jd=new globalThis.TextEncoder;function Nd(e){var{size:t=32,utf8Buffer:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Dd[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if("string"==typeof e){if(r)return function(e,t,r){if(0===r.length)throw new Error("The `utf8Buffer` option must have a length greater than zero");for(var n=Dd[t],o=Rd[t],i=e;i.length>0;){var s=jd.encodeInto(i,r);i=i.slice(s.read);for(var a=0;a<s.written;a++)o^=BigInt(r[a]),o=BigInt.asUintN(t,o*n)}return o}(e,t,r);e=jd.encode(e)}return function(e,t){for(var r=Dd[t],n=Rd[t],o=0;o<e.length;o++)n^=BigInt(e[o]),n=BigInt.asUintN(t,n*r);return n}(e,t)}var Ud={hash:e=>Number(Nd(e,{size:32})),hashV:(e,t)=>function(e){var t=e.toString(16);t.length%2==1&&(t="0".concat(t));return ya(t,"base16")}(Ud.hash(e,t))};class Kd{constructor(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2;if(W(this,"fp",void 0),W(this,"h",void 0),W(this,"seed",void 0),n>64)throw new TypeError("Invalid Fingerprint Size");for(var o=t.hashV(e,r),i=Cs(n),s=0;s<i.length;s++)i[s]=o[s];0===i.length&&(i[0]=7),this.fp=i,this.h=t,this.seed=r}hash(){return this.h.hash(this.fp,this.seed)}equals(e){return(null==e?void 0:e.fp)instanceof Uint8Array&&Es(this.fp,e.fp)}}function qd(e,t){return Math.floor(Math.random()*(t-e))+e}class Ld{constructor(e){W(this,"contents",void 0),this.contents=new Array(e).fill(null)}has(e){if(!(e instanceof Kd))throw new TypeError("Invalid Fingerprint");return this.contents.some((t=>e.equals(t)))}add(e){if(!(e instanceof Kd))throw new TypeError("Invalid Fingerprint");for(var t=0;t<this.contents.length;t++)if(null==this.contents[t])return this.contents[t]=e,!0;return!0}swap(e){if(!(e instanceof Kd))throw new TypeError("Invalid Fingerprint");var t=qd(0,this.contents.length-1),r=this.contents[t];return this.contents[t]=e,r}remove(e){if(!(e instanceof Kd))throw new TypeError("Invalid Fingerprint");var t=this.contents.findIndex((t=>e.equals(t)));return t>-1&&(this.contents[t]=null,!0)}}class _d{constructor(e){var t,r,n,o;W(this,"bucketSize",void 0),W(this,"filterSize",void 0),W(this,"fingerprintSize",void 0),W(this,"buckets",void 0),W(this,"count",void 0),W(this,"hash",void 0),W(this,"seed",void 0),this.filterSize=e.filterSize,this.bucketSize=null!==(t=e.bucketSize)&&void 0!==t?t:4,this.fingerprintSize=null!==(r=e.fingerprintSize)&&void 0!==r?r:2,this.count=0,this.buckets=[],this.hash=null!==(n=e.hash)&&void 0!==n?n:Ud,this.seed=null!==(o=e.seed)&&void 0!==o?o:qd(0,Math.pow(2,10))}add(e){"string"==typeof e&&(e=ya(e));var t=new Kd(e,this.hash,this.seed,this.fingerprintSize),r=this.hash.hash(e,this.seed)%this.filterSize,n=(r^t.hash())%this.filterSize;if(null==this.buckets[r]&&(this.buckets[r]=new Ld(this.bucketSize)),null==this.buckets[n]&&(this.buckets[n]=new Ld(this.bucketSize)),this.buckets[r].add(t)||this.buckets[n].add(t))return this.count++,!0;var o=[r,n],i=o[qd(0,o.length-1)];null==this.buckets[i]&&(this.buckets[i]=new Ld(this.bucketSize));for(var s=0;s<500;s++){var a=this.buckets[i].swap(t);if(null!=a&&(i=(i^a.hash())%this.filterSize,null==this.buckets[i]&&(this.buckets[i]=new Ld(this.bucketSize)),this.buckets[i].add(a)))return this.count++,!0}return!1}has(e){var t,r,n,o;"string"==typeof e&&(e=ya(e));var i=new Kd(e,this.hash,this.seed,this.fingerprintSize),s=this.hash.hash(e,this.seed)%this.filterSize,a=null!==(t=null===(r=this.buckets[s])||void 0===r?void 0:r.has(i))&&void 0!==t&&t;if(a)return a;var c=(s^i.hash())%this.filterSize;return null!==(n=null===(o=this.buckets[c])||void 0===o?void 0:o.has(i))&&void 0!==n&&n}remove(e){var t,r,n,o;"string"==typeof e&&(e=ya(e));var i=new Kd(e,this.hash,this.seed,this.fingerprintSize),s=this.hash.hash(e,this.seed)%this.filterSize,a=null!==(t=null===(r=this.buckets[s])||void 0===r?void 0:r.remove(i))&&void 0!==t&&t;if(a)return this.count--,a;var c=(s^i.hash())%this.filterSize,u=null!==(n=null===(o=this.buckets[c])||void 0===o?void 0:o.remove(i))&&void 0!==n&&n;return u&&this.count--,u}get reliable(){return Math.floor(this.count/this.filterSize*100)<=90}}var Md={1:.5,2:.84,4:.95,8:.98};class Fd{constructor(e){var t,r,n,o,i,s;W(this,"filterSize",void 0),W(this,"bucketSize",void 0),W(this,"fingerprintSize",void 0),W(this,"scale",void 0),W(this,"filterSeries",void 0),W(this,"hash",void 0),W(this,"seed",void 0),this.bucketSize=null!==(t=e.bucketSize)&&void 0!==t?t:4,this.filterSize=null!==(r=e.filterSize)&&void 0!==r?r:(1<<18)/this.bucketSize,this.fingerprintSize=null!==(n=e.fingerprintSize)&&void 0!==n?n:2,this.scale=null!==(o=e.scale)&&void 0!==o?o:2,this.hash=null!==(i=e.hash)&&void 0!==i?i:Ud,this.seed=null!==(s=e.seed)&&void 0!==s?s:qd(0,Math.pow(2,10)),this.filterSeries=[new _d({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(e){if("string"==typeof e&&(e=ya(e)),this.has(e))return!0;var t=this.filterSeries.find((e=>e.reliable));if(null==t){var r=this.filterSize*Math.pow(this.scale,this.filterSeries.length);t=new _d({filterSize:r,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(t)}return t.add(e)}has(e){"string"==typeof e&&(e=ya(e));for(var t=0;t<this.filterSeries.length;t++)if(this.filterSeries[t].has(e))return!0;return!1}remove(e){"string"==typeof e&&(e=ya(e));for(var t=0;t<this.filterSeries.length;t++)if(this.filterSeries[t].remove(e))return!0;return!1}get count(){return this.filterSeries.reduce(((e,t)=>e+t.count),0)}}function zd(e){var t=arguments.length>2?arguments[2]:void 0;return new Fd(Z(Z({},function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.001,r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.001;return e>.002?2:e>1e-5?4:8}(t),n=Md[r];return{filterSize:Math.round(e/n),bucketSize:r,fingerprintSize:Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*r)),64)}}(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:.001)),null!=t?t:{}))}class Gd{constructor(e,t){W(this,"filter",void 0),this.filter=zd(e,t)}has(e){return this.filter.has(e.toMultihash().bytes)}add(e){this.filter.add(e.toMultihash().bytes)}remove(e){var t,r;null===(t=(r=this.filter).remove)||void 0===t||t.call(r,e.toMultihash().bytes)}}function Vd(e){return new Gd(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:.001)}function Hd(e){var[t,r]=null!=e[Symbol.asyncIterator]?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:e=>{n.push(e)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}function Wd(e){return null!=(null==e?void 0:e.then)}function Jd(e,t){var r=0;if(null!=e[Symbol.asyncIterator])return ee((function*(){var n,o=!1,i=!1;try{for(var s,a=M(e);o=!(s=yield V(a.next())).done;o=!1){var c=s.value,u=t(c,r++);Wd(u)&&(yield V(u)),yield c}}catch(e){i=!0,n=e}finally{try{o&&null!=a.return&&(yield V(a.return()))}finally{if(i)throw n}}}))();var n=Hd(e),{value:o,done:i}=n.next();if(!0===i)return function*(){}();var s=t(o,r++);if("function"==typeof(null==s?void 0:s.then))return ee((function*(){for(var e of(yield o,n)){var i=t(e,r++);Wd(i)&&(yield V(i)),yield e}}))();var a=t;return function*(){for(var e of(yield o,n))a(e,r++),yield e}()}class $d{constructor(e){if(W(this,"buffer",void 0),W(this,"mask",void 0),W(this,"top",void 0),W(this,"btm",void 0),W(this,"next",void 0),!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){var e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}class Yd{constructor(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};W(this,"size",void 0),W(this,"hwm",void 0),W(this,"head",void 0),W(this,"tail",void 0),this.hwm=null!==(e=t.splitLimit)&&void 0!==e?e:16,this.head=new $d(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return null!=(null==e?void 0:e.byteLength)?e.byteLength:1}push(e){if(null!=(null==e?void 0:e.value)&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){var t=this.head;this.head=t.next=new $d(2*this.head.buffer.length),this.head.push(e)}}shift(){var e,t=this.tail.shift();if(void 0===t&&null!=this.tail.next){var r=this.tail.next;this.tail.next=null,this.tail=r,t=this.tail.shift()}return null!=(null===(e=t)||void 0===e?void 0:e.value)&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}}let Zd=class extends Error{constructor(e,t){super(null!=e?e:"The operation was aborted"),W(this,"type",void 0),W(this,"code",void 0),this.type="aborted",this.code=null!=t?t:"ABORT_ERR"}};function Qd(){return function(e,t){t=null!=t?t:{};var r,n,o,i=t.onEnd,s=new Yd,a=sl(),c=function(){var t=G((function*(){try{return s.isEmpty()?o?{done:!0}:yield new Promise(((t,o)=>{n=i=>{n=null,s.push(i);try{t(e(s))}catch(e){o(e)}return r}})):e(s)}finally{s.isEmpty()&&queueMicrotask((()=>{a.resolve(),a=sl()}))}}));return function(){return t.apply(this,arguments)}}(),u=e=>null!=n?n(e):(s.push(e),r),l=e=>(s=new Yd,null!=n?n({error:e}):(s.push({error:e}),r)),d=e=>{var n;if(o)return r;if(!0!==(null===(n=t)||void 0===n?void 0:n.objectMode)&&null==(null==e?void 0:e.byteLength))throw new Error("objectMode was not true but tried to push non-Uint8Array value");return u({done:!1,value:e})},h=e=>o?r:(o=!0,null!=e?l(e):u({done:!0})),p=()=>(s=new Yd,h(),{done:!0}),y=e=>(h(e),{done:!0});if(r={[Symbol.asyncIterator](){return this},next:c,return:p,throw:y,push:d,end:h,get readableLength(){return s.size},onEmpty:function(){var e=G((function*(e){var t=null==e?void 0:e.signal;if(null==t||t.throwIfAborted(),!s.isEmpty()){var r,n;null!=t&&(r=new Promise(((e,r)=>{n=()=>{r(new Zd)},t.addEventListener("abort",n)})));try{yield Promise.race([a.promise,r])}finally{null!=n&&null!=t&&(null==t||t.removeEventListener("abort",n))}}}));function t(t){return e.apply(this,arguments)}return t}()},null==i)return r;var f=r;return r={[Symbol.asyncIterator](){return this},next:()=>f.next(),throw:e=>(f.throw(e),null!=i&&(i(e),i=void 0),{done:!0}),return:()=>(f.return(),null!=i&&(i(),i=void 0),{done:!0}),push:d,end:e=>(f.end(e),null!=i&&(i(e),i=void 0),r),get readableLength(){return f.readableLength},onEmpty:e=>f.onEmpty(e)},r}((e=>{var t=e.shift();if(null==t)return{done:!0};if(null!=t.error)throw t.error;return{done:!0===t.done,value:t.value}}),arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}function Xd(){return Xd=G((function*(e,t,r){try{yield Promise.all(e.map(function(){var e=G((function*(e){var n,o=!1,i=!1;try{for(var s,a=M(e);o=!(s=yield a.next()).done;o=!1){var c=s.value;yield t.push(c,{signal:r}),r.throwIfAborted()}}catch(e){i=!0,n=e}finally{try{o&&null!=a.return&&(yield a.return())}finally{if(i)throw n}}}));return function(t){return e.apply(this,arguments)}}())),yield t.end(void 0,{signal:r})}catch(e){yield t.end(e,{signal:r}).catch((()=>{}))}})),Xd.apply(this,arguments)}function eh(){return eh=ee((function*(e){var t=new AbortController,r=dl();(function(e,t,r){return Xd.apply(this,arguments)})(e,r,t.signal).catch((()=>{}));try{yield*_(M(r))}finally{t.abort()}})),eh.apply(this,arguments)}function th(){for(var e=[],t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];for(var o of r)null==o[Symbol.asyncIterator]&&e.push(o);return e.length===r.length?function*(e){for(var t of e)yield*t}(e):function(e){return eh.apply(this,arguments)}(r)}function rh(e){if(null==e)throw new Error("Empty pipeline");if(sh(e)){var t=e;e=()=>t.source}else if(ih(e)||oh(e)){var r=e;e=()=>r}for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];var s=[e,...o];if(s.length>1&&sh(s[s.length-1])&&(s[s.length-1]=s[s.length-1].sink),s.length>2)for(var a=1;a<s.length-1;a++)sh(s[a])&&(s[a]=ah(s[a]));return nh(...s)}var nh=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];for(;r.length>0;)e=r.shift()(e);return e},oh=e=>null!=(null==e?void 0:e[Symbol.asyncIterator]),ih=e=>null!=(null==e?void 0:e[Symbol.iterator]),sh=e=>null!=e&&(null!=e.sink&&null!=e.source),ah=e=>t=>{var r=e.sink(t);if(null!=(null==r?void 0:r.then)){var n,o=Qd({objectMode:!0});r.then((()=>{o.end()}),(e=>{o.end(e)}));var i=e.source;if(oh(i))n=function(){var e=ee((function*(){yield*_(M(i)),o.end()}));return function(){return e.apply(this,arguments)}}();else{if(!ih(i))throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");n=function*(){yield*i,o.end()}}return th(o,n())}return e.source};function ch(e){var{stream:t,remoteAddr:r,logger:n,onDataRead:o,onDataWrite:i}=e,s=n.forComponent("libp2p:stream:converter"),a=!1,c=!1,u=t.close.bind(t);t.close=function(){var e=G((function*(e){yield u(e),p(!0)}));return function(t){return e.apply(this,arguments)}}();var l=t.abort.bind(t);t.abort=e=>{l(e),p(!0)};var d=t.sink.bind(t);t.sink=function(){var e=G((function*(e){try{yield d(rh(e,(e=>Jd(e,(e=>null==i?void 0:i(e))))))}catch(e){"aborted"!==e.type&&s.error("%s error in sink",r,e)}finally{c=!0,p()}}));return function(t){return e.apply(this,arguments)}}();var h={log:s,sink:t.sink,source:ee((function*(){try{var e,r=!1,n=!1;try{for(var i,s=M(t.source);r=!(i=yield V(s.next())).done;r=!1){var c=i.value;null==o||o(c),yield c}}catch(t){n=!0,e=t}finally{try{r&&null!=s.return&&(yield V(s.return()))}finally{if(n)throw e}}}finally{a=!0,p()}}))(),remoteAddr:r,timeline:{open:Date.now(),close:void 0},close:t.close,abort:t.abort};function p(e){!0===e&&(a=!0,c=!0),a&&c&&null==h.timeline.close&&(h.timeline.close=Date.now())}return h}class uh extends Event{constructor(e,t){super(e),W(this,"type",void 0),W(this,"detail",void 0),this.type=e,this.detail=t}}let lh=class extends Error{constructor(e,t){super(null!=e?e:"The operation was aborted"),W(this,"type",void 0),W(this,"code",void 0),this.type="aborted",this.name="AbortError",this.code=null!=t?t:"ABORT_ERR"}};function dh(e,t,r,n){return hh.apply(this,arguments)}function hh(){return hh=G((function*(e,t,r,n){var o=new lh(null==n?void 0:n.errorMessage,null==n?void 0:n.errorCode);return!0===(null==r?void 0:r.aborted)?Promise.reject(o):new Promise(((i,s)=>{function a(){null==r||r.removeEventListener("abort",l),e.removeEventListener(t,c),null!=(null==n?void 0:n.errorEvent)&&e.removeEventListener(n.errorEvent,u)}var c=e=>{try{var t;if(!1===(null==n||null===(t=n.filter)||void 0===t?void 0:t.call(n,e)))return}catch(e){return a(),void s(e)}a(),i(e)},u=e=>{a(),s(e.detail)},l=()=>{a(),s(o)};null==r||r.addEventListener("abort",l),e.addEventListener(t,c),null!=(null==n?void 0:n.errorEvent)&&e.addEventListener(n.errorEvent,u)}))})),hh.apply(this,arguments)}function ph(e,t){var r,n=function(){clearTimeout(r),r=setTimeout((function(){r=void 0,e()}),t)};return n.start=()=>{},n.stop=()=>{clearTimeout(r)},n}class yh extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"The queue was full"),this.name="QueueFullError"}}W(yh,"name","QueueFullError");class fh{constructor(e){var t;W(this,"deferred",void 0),W(this,"signal",void 0),this.signal=e,this.deferred=sl(),this.onAbort=this.onAbort.bind(this),null===(t=this.signal)||void 0===t||t.addEventListener("abort",this.onAbort)}onAbort(){var e,t;this.deferred.reject(null!==(e=null===(t=this.signal)||void 0===t?void 0:t.reason)&&void 0!==e?e:new d.AbortError)}cleanup(){var e;null===(e=this.signal)||void 0===e||e.removeEventListener("abort",this.onAbort)}}class gh{constructor(e,t){W(this,"id",void 0),W(this,"fn",void 0),W(this,"options",void 0),W(this,"recipients",void 0),W(this,"status",void 0),W(this,"timeline",void 0),W(this,"controller",void 0),this.id="".concat(parseInt(String(1e9*Math.random()),10).toString()).concat(Date.now()),this.status="queued",this.fn=e,this.options=t,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,d.setMaxListeners(1/0,this.controller.signal),this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce(((e,t)=>{var r;return e&&!0===(null===(r=t.signal)||void 0===r?void 0:r.aborted)}),!0)&&(this.controller.abort(new d.AbortError),this.cleanup())}join(){var e=arguments,t=this;return G((function*(){var r,n=e.length>0&&void 0!==e[0]?e[0]:{},o=new fh(n.signal);return t.recipients.push(o),null===(r=n.signal)||void 0===r||r.addEventListener("abort",t.onAbort),o.deferred.promise}))()}run(){var e=this;return G((function*(){e.status="running",e.timeline.started=Date.now();try{var t;e.controller.signal.throwIfAborted();var r=yield cl(e.fn(Z(Z({},null!==(t=e.options)&&void 0!==t?t:{}),{},{signal:e.controller.signal})),e.controller.signal);e.recipients.forEach((e=>{e.deferred.resolve(r)})),e.status="complete"}catch(t){e.recipients.forEach((e=>{e.deferred.reject(t)})),e.status="errored"}finally{e.timeline.finished=Date.now(),e.cleanup()}}))()}cleanup(){this.recipients.forEach((e=>{var t;e.cleanup(),null===(t=e.signal)||void 0===t||t.removeEventListener("abort",this.onAbort)}))}}class bh extends d.TypedEventEmitter{constructor(){var e,t,r,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(super(),W(this,"concurrency",void 0),W(this,"maxSize",void 0),W(this,"queue",void 0),W(this,"pending",void 0),W(this,"sort",void 0),this.concurrency=null!==(e=n.concurrency)&&void 0!==e?e:Number.POSITIVE_INFINITY,this.maxSize=null!==(t=n.maxSize)&&void 0!==t?t:Number.POSITIVE_INFINITY,this.pending=0,null!=n.metricName)&&(null===(r=n.metrics)||void 0===r||r.registerMetricGroup(n.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}));this.sort=n.sort,this.queue=[],this.emitEmpty=ph(this.emitEmpty.bind(this),1),this.emitIdle=ph(this.emitIdle.bind(this),1)}emitEmpty(){0===this.size&&this.safeDispatchEvent("empty")}emitIdle(){0===this.running&&this.safeDispatchEvent("idle")}tryToStartAnother(){if(0===this.size)return this.emitEmpty(),0===this.running&&this.emitIdle(),!1;if(this.pending<this.concurrency){var e;for(var t of this.queue)if("queued"===t.status){e=t;break}return null!=e&&(this.safeDispatchEvent("active"),this.pending++,e.run().finally((()=>{for(var t=0;t<this.queue.length;t++)if(this.queue[t]===e){this.queue.splice(t,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")})),!0)}return!1}enqueue(e){this.queue.push(e),null!=this.sort&&this.queue.sort(this.sort)}add(e,t){var r=this;return G((function*(){var n;if(null==t||null===(n=t.signal)||void 0===n||n.throwIfAborted(),r.size===r.maxSize)throw new yh;var o=new gh(e,t);return r.enqueue(o),r.safeDispatchEvent("add"),r.tryToStartAnother(),o.join(t).then((e=>(r.safeDispatchEvent("completed",{detail:e}),r.safeDispatchEvent("success",{detail:{job:o,result:e}}),e))).catch((e=>{if("queued"===o.status)for(var t=0;t<r.queue.length;t++)if(r.queue[t]===o){r.queue.splice(t,1);break}throw r.safeDispatchEvent("error",{detail:e}),r.safeDispatchEvent("failure",{detail:{job:o,error:e}}),e}))}))()}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach((e=>{e.abort(new d.AbortError)})),this.clear()}onEmpty(e){var t=this;return G((function*(){0!==t.size&&(yield dh(t,"empty",null==e?void 0:e.signal))}))()}onSizeLessThan(e,t){var r=this;return G((function*(){r.size<e||(yield dh(r,"next",null==t?void 0:t.signal,{filter:()=>r.size<e}))}))()}onIdle(e){var t=this;return G((function*(){0===t.pending&&0===t.size||(yield dh(t,"idle",null==e?void 0:e.signal))}))()}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}toGenerator(e){var t=this;return ee((function*(){var r,n;null==e||null===(r=e.signal)||void 0===r||r.throwIfAborted();var o=Qd({objectMode:!0}),i=e=>{null!=e?t.abort():t.clear(),o.end(e)},s=e=>{null!=e.detail&&o.push(e.detail)},a=e=>{i(e.detail)},c=()=>{i()},u=()=>{i(new d.AbortError("Queue aborted"))};t.addEventListener("completed",s),t.addEventListener("error",a),t.addEventListener("idle",c),null==e||null===(n=e.signal)||void 0===n||n.addEventListener("abort",u);try{yield*_(M(o))}finally{var l;t.removeEventListener("completed",s),t.removeEventListener("error",a),t.removeEventListener("idle",c),null==e||null===(l=e.signal)||void 0===l||l.removeEventListener("abort",u),i()}}))()}}class mh extends bh{has(e){return null!=this.find(e)}find(e){return this.queue.find((t=>e.equals(t.options.peerId)))}}class wh extends d.TypedEventEmitter{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),W(this,"peerStore",void 0),W(this,"registrar",void 0),W(this,"connectionManager",void 0),W(this,"randomWalk",void 0),W(this,"started",void 0),W(this,"running",void 0),W(this,"topologyId",void 0),W(this,"log",void 0),W(this,"discoveryController",void 0),W(this,"filter",void 0),W(this,"queue",void 0),this.log=e.logger.forComponent("libp2p:circuit-relay:discover-relays"),this.started=!1,this.running=!1,this.peerStore=e.peerStore,this.registrar=e.registrar,this.connectionManager=e.connectionManager,this.randomWalk=e.randomWalk,this.filter=t.filter,this.discoveryController=new AbortController,d.setMaxListeners(1/0,this.discoveryController.signal)}isStarted(){return this.started}start(){var e=this;return G((function*(){e.topologyId=yield e.registrar.register(Cl,{filter:e.filter,onConnect:t=>{var r,n;e.log.trace("discovered relay %p queue (length: %d, active %d)",t,null===(r=e.queue)||void 0===r?void 0:r.size,null===(n=e.queue)||void 0===n?void 0:n.running),e.safeDispatchEvent("relay:discover",{detail:t})}}),e.started=!0}))()}stop(){var e;null!=this.topologyId&&this.registrar.unregister(this.topologyId),null===(e=this.discoveryController)||void 0===e||e.abort(),this.started=!1}startDiscovery(){var e=this;this.running||(this.log("start discovery"),this.running=!0,this.discoveryController=new AbortController,d.setMaxListeners(1/0,this.discoveryController.signal),Promise.resolve().then(G((function*(){e.log("searching peer store for relays");var t=yield e.peerStore.all({filters:[e=>e.protocols.includes(Cl)],orders:[()=>Math.random()<.5?1:-1,(e,t)=>{var r=vh(e),n=vh(t);return r>n?-1:n>r?1:0}]});for(var r of t)e.log.trace("found relay peer %p in peer store",r.id),e.safeDispatchEvent("relay:discover",{detail:r.id});e.log("found %d relay peers in peer store",t.length);var n=e.queue=new mh({concurrency:5});e.log("start random walk");var o,i=!1,s=!1;try{for(var a,c=function*(){var t,r=a.value;return e.log.trace("found random peer %p",r.id),n.has(r.id)?(e.log.trace("random peer %p was already in queue",r.id),0):(null===(t=e.connectionManager.getConnections(r.id))||void 0===t?void 0:t.length)>0?(e.log.trace("random peer %p was already connected",r.id),0):(yield e.connectionManager.isDialable(r.multiaddrs))?(n.queued>10&&(e.log.trace("wait for space in queue for %p",r.id),yield n.onSizeLessThan(10,{signal:e.discoveryController.signal})),e.log("adding random peer %p to dial queue (length: %d, active %d)",r.id,n.size,n.running),void n.add(G((function*(){var t=vd([e.discoveryController.signal,AbortSignal.timeout(5e3)]);d.setMaxListeners(1/0,t);try{yield e.connectionManager.openConnection(r.id,{signal:t})}finally{t.clear()}})),{peerId:r.id,signal:e.discoveryController.signal}).catch((t=>{e.log.error("error opening connection to random peer %p",r.id,t)}))):(e.log.trace("random peer %p was not dialable",r.id,r.multiaddrs.map((e=>e.toString()))),0)},u=M(e.randomWalk.walk({signal:e.discoveryController.signal}));i=!(a=yield u.next()).done;i=!1)yield*c()}catch(e){s=!0,o=e}finally{try{i&&null!=u.return&&(yield u.return())}finally{if(s)throw o}}e.log("stop random walk"),yield n.onIdle()}))).catch((e=>{this.discoveryController.signal.aborted||this.log.error("failed when finding relays on the network",e)})))}stopDiscovery(){var e;this.log("stop discovery"),this.running=!1,null===(e=this.discoveryController)||void 0===e||e.abort()}}function vh(e){var t=e.metadata.get("last-dial-success");return null==t?0:new Date(fa(t)).getTime()}class kh extends d.TypedEventEmitter{constructor(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),W(this,"connectionManager",void 0),W(this,"addressManager",void 0),W(this,"reservationStore",void 0),W(this,"listeningAddrs",void 0),W(this,"log",void 0),W(this,"listenTimeout",void 0),W(this,"reservationId",void 0),W(this,"relay",void 0),W(this,"_onRemoveRelayPeer",(e=>{var t,r;this.log("relay removed %p our relay %p",e.detail.relay,this.relay,null===(t=this.relay)||void 0===t?void 0:t.equals(e.detail.relay)),!0===(null===(r=this.relay)||void 0===r?void 0:r.equals(e.detail.relay))&&(this.log("relay peer removed %p",e.detail.relay),this.listeningAddrs.forEach((e=>{this.addressManager.removeObservedAddr(e)})),this.listeningAddrs=[],this.safeDispatchEvent("listening"))})),W(this,"_onAddRelayPeer",(e=>{var{details:t}=e.detail;"configured"!==t.type&&t.id===this.reservationId&&this.addedRelay(e.detail)})),this.log=e.logger.forComponent("libp2p:circuit-relay:transport:listener"),this.connectionManager=e.connectionManager,this.addressManager=e.addressManager,this.reservationStore=e.reservationStore,this.listeningAddrs=[],this.listenTimeout=null!==(t=r.listenTimeout)&&void 0!==t?t:2e3,this.reservationStore.addEventListener("relay:removed",this._onRemoveRelayPeer),this.reservationStore.addEventListener("relay:created-reservation",this._onAddRelayPeer)}listen(e){var t=this;return G((function*(){if(Pd.exactMatch(e))t.log("searching for circuit relay servers"),t.reservationId=t.reservationStore.reserveRelay();else{if(!xd.exactMatch(e))throw new d.ListenError('Could not listen on p2p-circuit address "'.concat(e,'"'));t.log("listen on specific relay server %a",e);var r=AbortSignal.timeout(t.listenTimeout);d.setMaxListeners(1/0,r);var n=e.decapsulate("/p2p-circuit"),o=yield t.connectionManager.openConnection(n,{signal:r});if(!t.reservationStore.hasReservation(o.remotePeer)){t.log("making reservation on peer %p",o.remotePeer);var i=yield t.reservationStore.addRelay(o.remotePeer,"configured");t.addedRelay(i)}}}))()}getAddrs(){return[...this.listeningAddrs.values()].flat()}updateAnnounceAddrs(){}close(){var e=this;return G((function*(){e.reservationStore.cancelReservations(),e.listeningAddrs=[],e.reservationStore.removeEventListener("relay:removed",e._onRemoveRelayPeer),queueMicrotask((()=>{e.safeDispatchEvent("close")}))}))()}addedRelay(t){this.log("relay peer added %p",t.relay),this.relay=t.relay,this.listeningAddrs=t.details.reservation.addrs.map((t=>e.multiaddr(t).encapsulate("/p2p-circuit"))),this.listeningAddrs.forEach((e=>{this.addressManager.confirmObservedAddr(e,{type:"transport"})})),queueMicrotask((()=>{this.safeDispatchEvent("listening")}))}}var Sh=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,t="",r=crypto.getRandomValues(new Uint8Array(e|=0));e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&r[e]];return t},Oh=new WeakSet;class Ah extends d.TypedEventEmitter{constructor(e,t){var r,n,o;super(),H(this,Oh),W(this,"peerId",void 0),W(this,"connectionManager",void 0),W(this,"peerStore",void 0),W(this,"events",void 0),W(this,"reserveQueue",void 0),W(this,"reservations",void 0),W(this,"pendingReservations",void 0),W(this,"maxReservationQueueLength",void 0),W(this,"reservationCompletionTimeout",void 0),W(this,"started",void 0),W(this,"log",void 0),W(this,"relayFilter",void 0),this.log=e.logger.forComponent("libp2p:circuit-relay:transport:reservation-store"),this.peerId=e.peerId,this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.events=e.events,this.reservations=new Bd,this.pendingReservations=[],this.maxReservationQueueLength=null!==(r=null==t?void 0:t.maxReservationQueueLength)&&void 0!==r?r:100,this.reservationCompletionTimeout=null!==(n=null==t?void 0:t.reservationCompletionTimeout)&&void 0!==n?n:2e3,this.started=!1,this.relayFilter=zd(100),this.reserveQueue=new mh({concurrency:null!==(o=null==t?void 0:t.reservationConcurrency)&&void 0!==o?o:1,metricName:"libp2p_relay_reservation_queue",metrics:e.metrics}),this.events.addEventListener("connection:close",(e=>{null!=[...this.reservations.values()].find((t=>t.connection===e.detail.id))&&L(Oh,this,Ph).call(this,e.detail.remotePeer).catch((t=>{this.log("could not remove relay %p - %e",e.detail,t)}))}))}isStarted(){return this.started}start(){this.started=!0}afterStart(){var e=this;Promise.resolve().then(G((function*(){var t=yield e.peerStore.all({filters:[e=>e.tags.has(wl)]});e.log("removing tag from %d old relays",t.length),yield Promise.all(t.map(function(){var t=G((function*(t){yield e.peerStore.merge(t.id,{tags:{[wl]:void 0}})}));return function(e){return t.apply(this,arguments)}}())),e.log("redialing %d old relays",t.length),yield Promise.all(t.map(function(){var t=G((function*(t){return e.addRelay(t.id,"discovered")}));return function(e){return t.apply(this,arguments)}}())),L(Oh,e,Ch).call(e)}))).catch((e=>{this.log.error(e)}))}stop(){this.reserveQueue.clear(),this.reservations.forEach((e=>{var{timeout:t}=e;clearTimeout(t)})),this.reservations.clear(),this.started=!1}reserveRelay(){var e=Sh();return this.pendingReservations.push(e),L(Oh,this,Ch).call(this),e}addRelay(e,t){var r=this;return G((function*(){if(r.peerId.equals(e))throw r.log.trace("not trying to use self as relay"),new d.ListenError("Cannot use self as relay");if(r.reserveQueue.size>r.maxReservationQueueLength)throw new Od("The reservation queue is full");var n=r.reserveQueue.find(e);if(null!=n)return r.log.trace("potential relay peer %p is already in the reservation queue",e),n.join();if(r.relayFilter.has(e.toMultihash().bytes))throw new d.ListenError("The relay was previously invalid");return r.log.trace("try to reserve relay slot with %p",e),r.reserveQueue.add(G((function*(){var n=Date.now();try{var o=r.reservations.get(e);if(null!=o){var i=r.connectionManager.getConnections(e),s=!1;if(0===i.length&&r.log("already have relay reservation with %p but we are no longer connected",e),i.map((e=>e.id)).includes(o.connection)&&(r.log("already have relay reservation with %p and the original connection is still open",e),s=!0),s&&Ad(o.reservation.expire)>6e5)return r.log("already have relay reservation with %p but we are still connected and it does not expire soon",e),{relay:e,details:o};yield L(Oh,r,Ph).call(r,e)}if("discovered"===t&&0===r.pendingReservations.length)throw new kd("Not making reservation on discovered relay because we do not need any more relays");var a=AbortSignal.timeout(r.reservationCompletionTimeout);d.setMaxListeners(1/0,a);var c=yield r.connectionManager.openConnection(e,{signal:a});if(md.matches(c.remoteAddr))throw new Sd("not creating reservation over relayed connection");var u=yield L(Oh,r,Ih).call(r,c,{signal:a}),l=Ad(u.expire);r.log("created reservation on relay peer %p, expiry date is %s",e,new Date(Date.now()+l).toString());var h,p=Math.min(Math.max(l-3e5,3e4),Math.pow(2,31)-1),y=setTimeout((()=>{r.log("refresh reservation to relay %p",e),r.addRelay(e,t).catch(function(){var t=G((function*(t){r.log.error("could not refresh reservation to relay %p - %e",e,t),yield L(Oh,r,Ph).call(r,e)}));return function(e){return t.apply(this,arguments)}}()).catch((t=>{r.log.error("could not remove expired reservation to relay %p - %e",e,t)}))}),p);if("discovered"===t){var f=r.pendingReservations.pop();if(null==f)throw new kd("Made reservation on relay but did not need any more discovered relays");h={timeout:y,reservation:u,type:t,connection:c.id,id:f}}else h={timeout:y,reservation:u,type:t,connection:c.id};r.reservations.set(e,h),yield r.peerStore.merge(e,{tags:{[wl]:{value:1,ttl:l}}}),L(Oh,r,Ch).call(r);var g={relay:e,details:h};return r.safeDispatchEvent("relay:created-reservation",{detail:g}),g}catch(o){throw"discovered"===t&&"HadEnoughRelaysError"===o.name||r.log.error("could not reserve slot on %p after %dms - %e",e,Date.now()-n,o),"DialError"!==o.name&&"UnsupportedProtocolError"!==o.name||r.relayFilter.add(e.toMultihash().bytes),L(Oh,r,Ph).call(r,e).catch((t=>{r.log.error("could not remove reservation on %p after reserving slot failed - %e",e,t)})),o}})),{peerId:e})}))()}hasReservation(e){return this.reservations.has(e)}getReservation(e){var t;return null===(t=this.reservations.get(e))||void 0===t?void 0:t.reservation}reservationCount(e){return null==e?this.reservations.size:[...this.reservations.values()].reduce(((t,r)=>(r.type===e&&t++,t)),0)}cancelReservations(){[...this.reservations.values()].forEach((e=>{clearTimeout(e.timeout)})),this.reservations.clear()}}function Ih(e,t){return xh.apply(this,arguments)}function xh(){return(xh=G((function*(t,r){var n,o;null===(n=r.signal)||void 0===n||n.throwIfAborted(),this.log("requesting reservation from %p",t.remotePeer);var i,s=yield t.newStream(Cl,r),a=ml(s).pb(vl);this.log.trace("send RESERVE to %p",t.remotePeer),yield a.write({type:vl.Type.RESERVE},r);try{this.log.trace("reading response from %p",t.remotePeer),i=yield a.read(r)}catch(e){throw s.abort(e),e}finally{"closed"!==s.status&&(yield s.close(r))}if(this.log.trace("read response %o",i),i.status===Il.OK&&null!=i.reservation){var c=new Set;for(var u of(c.add(t.remoteAddr.toString()),i.reservation.addrs)){var l=e.multiaddr(u);null==l.getPeerId()&&(l=l.encapsulate("/p2p/".concat(t.remotePeer))),l=e.multiaddr(l.toString().replace("/p2p/".concat(t.remotePeer,"/p2p/").concat(t.remotePeer),"/p2p/".concat(t.remotePeer))),c.add(l.toString())}return i.reservation.addrs=[...c].map((t=>e.multiaddr(t).bytes)),i.reservation}var d="reservation failed with status ".concat(null!==(o=i.status)&&void 0!==o?o:"undefined");throw this.log.error(d),new Error(d)}))).apply(this,arguments)}function Ph(e){return Eh.apply(this,arguments)}function Eh(){return Eh=G((function*(e){var t=this.reservations.get(e);null!=t&&(this.log("removing relay reservation with %p from local store",e),clearTimeout(t.timeout),this.reservations.delete(e),"discovered"===t.type&&this.pendingReservations.push(t.id),yield this.peerStore.merge(e,{tags:{[wl]:void 0}}),this.safeDispatchEvent("relay:removed",{detail:{relay:e,details:t}}),L(Oh,this,Ch).call(this))})),Eh.apply(this,arguments)}function Ch(){if(0===this.pendingReservations.length)return this.log.trace("have discovered enough relays"),this.reserveQueue.clear(),void this.safeDispatchEvent("relay:found-enough-relays");this.relayFilter=zd(100),this.log("not discovered enough relays %d/%d",this.reservations.size,this.pendingReservations.length),this.safeDispatchEvent("relay:not-enough-relays")}var Bh,Th=300,Dh=300;class Rh{constructor(e){var t,r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};W(this,"discovery",void 0),W(this,"registrar",void 0),W(this,"peerStore",void 0),W(this,"connectionManager",void 0),W(this,"transportManager",void 0),W(this,"peerId",void 0),W(this,"upgrader",void 0),W(this,"addressManager",void 0),W(this,"connectionGater",void 0),W(this,"reservationStore",void 0),W(this,"logger",void 0),W(this,"maxInboundStopStreams",void 0),W(this,"maxOutboundStopStreams",void 0),W(this,"started",void 0),W(this,"log",void 0),W(this,"shutdownController",void 0),W(this,Symbol.toStringTag,"@libp2p/circuit-relay-v2-transport"),W(this,d.serviceCapabilities,["@libp2p/transport","@libp2p/circuit-relay-v2-transport"]),W(this,d.transportSymbol,!0),this.log=e.logger.forComponent("libp2p:circuit-relay:transport"),this.registrar=e.registrar,this.peerStore=e.peerStore,this.connectionManager=e.connectionManager,this.transportManager=e.transportManager,this.logger=e.logger,this.peerId=e.peerId,this.upgrader=e.upgrader,this.addressManager=e.addressManager,this.connectionGater=e.connectionGater,this.maxInboundStopStreams=null!==(t=o.maxInboundStopStreams)&&void 0!==t?t:Th,this.maxOutboundStopStreams=null!==(r=o.maxOutboundStopStreams)&&void 0!==r?r:Dh,this.shutdownController=new AbortController,this.discovery=new wh(e,{filter:null!==(n=o.discoveryFilter)&&void 0!==n?n:Vd(4096,.001)}),this.discovery.addEventListener("relay:discover",(e=>{this.reservationStore.addRelay(e.detail,"discovered").catch((t=>{"HadEnoughRelaysError"!==t.name&&"RelayQueueFullError"!==t.name&&this.log.error("could not add discovered relay %p",e.detail,t)}))})),this.reservationStore=new Ah(e,o),this.reservationStore.addEventListener("relay:not-enough-relays",(()=>{var e;null===(e=this.discovery)||void 0===e||e.startDiscovery()})),this.reservationStore.addEventListener("relay:found-enough-relays",(()=>{var e;null===(e=this.discovery)||void 0===e||e.stopDiscovery()})),this.started=!1}get[d.serviceDependencies](){return null!=this.discovery?["@libp2p/identify"]:[]}isStarted(){return this.started}start(){var e=this;return G((function*(){e.shutdownController=new AbortController,d.setMaxListeners(1/0,e.shutdownController.signal),yield e.registrar.handle(Bl,(t=>{var r=e.upgrader.createInboundAbortSignal(e.shutdownController.signal);e.onStop(t,r).catch((r=>{e.log.error("error while handling STOP protocol",r),t.stream.abort(r)})).finally((()=>{r.clear()}))}),{maxInboundStreams:e.maxInboundStopStreams,maxOutboundStreams:e.maxOutboundStopStreams,runOnLimitedConnection:!0}),yield d.start(e.discovery,e.reservationStore),e.started=!0}))()}stop(){var e=this;return G((function*(){e.shutdownController.abort(),yield d.stop(e.discovery,e.reservationStore),yield e.registrar.unhandle(Bl),e.started=!1}))()}dial(t,n){var o=this;return G((function*(){if(1!==t.protoCodes().filter((e=>290===e)).length){var i="Invalid circuit relay address";throw o.log.error(i,t),new d.DialError(i)}var s=t.toString().split("/p2p-circuit"),a=e.multiaddr(s[0]),c=e.multiaddr(s[s.length-1]),u=a.getPeerId(),l=c.getPeerId();if(null==u||null==l){var h="ircuit relay dial to ".concat(t.toString()," failed as address did not have both relay and destination PeerIDs");throw o.log.error("c".concat(h)),new d.DialError("C".concat(h))}var p,y,f,g=r.peerIdFromString(u),b=r.peerIdFromString(l),m=o.connectionManager.getConnections(g)[0];null==m?(yield o.peerStore.merge(g,{multiaddrs:[a]}),null===(p=n.onProgress)||void 0===p||p.call(n,new uh("circuit-relay:open-connection")),m=yield o.connectionManager.openConnection(g,n)):null===(y=n.onProgress)||void 0===y||y.call(n,new uh("circuit-relay:reuse-connection"));try{var w,v,k;null===(w=n.onProgress)||void 0===w||w.call(n,new uh("circuit-relay:open-hop-stream"));var S=ml(f=yield m.newStream(Cl,n)),O=S.pb(vl);null===(v=n.onProgress)||void 0===v||v.call(n,new uh("circuit-relay:write-connect-message")),yield O.write({type:vl.Type.CONNECT,peer:{id:b.toMultihash().bytes,addrs:[e.multiaddr(c).bytes]}},n),null===(k=n.onProgress)||void 0===k||k.call(n,new uh("circuit-relay:read-connect-response"));var A,I,x=yield O.read(n);if(x.status!==Il.OK)throw new d.InvalidMessageError("failed to connect via relay with status ".concat(null!==(A=null==x||null===(I=x.status)||void 0===I?void 0:I.toString())&&void 0!==A?A:"undefined"));var P=new Id(x.limit),E=ch({stream:S.unwrap(),remoteAddr:t,localAddr:a.encapsulate("/p2p-circuit/p2p/".concat(o.peerId.toString())),logger:o.logger,onDataRead:P.onData,onDataWrite:P.onData});return o.log("new outbound relayed connection %a",E.remoteAddr),yield o.upgrader.upgradeOutbound(E,Z(Z({},n),{},{limits:P.getLimits()}))}catch(e){var C;throw o.log.error("circuit relay dial to destination %p via relay %p failed",b,g,e),null===(C=f)||void 0===C||C.abort(e),e}}))()}createListener(e){return function(e){return new kh(e)}({peerId:this.peerId,connectionManager:this.connectionManager,addressManager:this.addressManager,reservationStore:this.reservationStore,logger:this.logger})}listenFilter(e){return(e=Array.isArray(e)?e:[e]).filter((e=>xd.exactMatch(e)||Pd.exactMatch(e)))}dialFilter(e){return(e=Array.isArray(e)?e:[e]).filter((e=>md.exactMatch(e)))}onStop(t,n){var o=this;return G((function*(){var i,s,{connection:a,stream:c}=t;if(!o.reservationStore.hasReservation(a.remotePeer))try{o.log("dialed via relay we did not have a reservation on, start listening on that relay address"),yield o.transportManager.listen([a.remoteAddr.encapsulate("/p2p-circuit")])}catch(e){o.log.error("failed to listen on a relay peer we were dialed via but did not have a reservation on",e)}var u=ml(c).pb(kl),l=yield u.read({signal:n});if(o.log("new circuit relay v2 stop stream from %p with type %s",a.remotePeer,l.type),void 0===(null==l?void 0:l.type))return o.log.error("type was missing from circuit v2 stop protocol request from %s",a.remotePeer),yield u.write({type:kl.Type.STATUS,status:Il.MALFORMED_MESSAGE},{signal:n}),void(yield c.close());if(l.type!==kl.Type.CONNECT)return o.log.error("invalid stop connect request via peer %p",a.remotePeer),yield u.write({type:kl.Type.STATUS,status:Il.UNEXPECTED_MESSAGE},{signal:n}),void(yield c.close());if(!(t=>{if(null==t.peer)return!1;try{t.peer.addrs.forEach(e.multiaddr)}catch(e){return!1}return!0})(l))return o.log.error("invalid stop connect request via peer %p",a.remotePeer),yield u.write({type:kl.Type.STATUS,status:Il.MALFORMED_MESSAGE},{signal:n}),void(yield c.close({signal:n}));var d=r.peerIdFromMultihash(ts(l.peer.id));if(!0===(yield null===(i=(s=o.connectionGater).denyInboundRelayedConnection)||void 0===i?void 0:i.call(s,a.remotePeer,d)))return o.log.error("connection gater denied inbound relayed connection from %p",a.remotePeer),yield u.write({type:kl.Type.STATUS,status:Il.PERMISSION_DENIED},{signal:n}),void(yield c.close({signal:n}));o.log.trace("sending success response to %p",a.remotePeer),yield u.write({type:kl.Type.STATUS,status:Il.OK},{signal:n});var h=new Id(l.limit),p=a.remoteAddr.encapsulate("/p2p-circuit/p2p/".concat(d.toString()));o.addressManager.getAddresses()[0];var y=ch({stream:u.unwrap().unwrap(),remoteAddr:p,logger:o.logger,onDataRead:h.onData,onDataWrite:h.onData});o.log("new inbound relayed connection %a",y.remoteAddr),yield o.upgrader.upgradeInbound(y,{limits:h.getLimits(),signal:n}),o.log("%s connection %a upgraded","inbound",y.remoteAddr)}))()}}function jh(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Rh(t,e)}!function(e){var t,r;!function(e){e.FIN="FIN",e.STOP_SENDING="STOP_SENDING",e.RESET="RESET",e.FIN_ACK="FIN_ACK"}(e.Flag||(e.Flag={})),function(e){e[e.FIN=0]="FIN",e[e.STOP_SENDING=1]="STOP_SENDING",e[e.RESET=2]="RESET",e[e.FIN_ACK=3]="FIN_ACK"}(t||(t={})),function(e){e.codec=()=>Xc(t)}(e.Flag||(e.Flag={})),e.codec=()=>(null==r&&(r=eu((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&r.fork(),null!=t.flag&&(r.uint32(8),e.Flag.codec().encode(t.flag,r)),null!=t.message&&(r.uint32(18),r.bytes(t.message)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n={},o=null==r?t.len:t.pos+r;t.pos<o;){var i=t.uint32();switch(i>>>3){case 1:n.flag=e.Flag.codec().decode(t);break;case 2:n.message=t.bytes();break;default:t.skipType(7&i)}}return n}))),r),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(Bh||(Bh={}));var Nh=["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478","stun:stun.cloudflare.com:3478","stun:stun.services.mozilla.com:3478"],Uh=Array.from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"),Kh=16384;var qh=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Kh,t=uc(e-uc(e)),r=1+uc(Object.keys(Bh.Flag).length-1);return t+r+1+uc(e-t-r-1)}(),Lh="/webrtc",_h="/webrtc-signaling/0.0.1",Mh=864e5,Fh=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))},zh=function(e,t,r){this.name=e,this.version=t,this.os=r,this.type="browser"},Gh=function(e){this.version=e,this.type="node",this.name="node",this.os=h.platform},Vh=function(e,t,r,n){this.name=e,this.version=t,this.os=r,this.bot=n,this.type="bot-device"},Hh=function(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null},Wh=function(){this.type="react-native",this.name="react-native",this.version=null,this.os=null},Jh=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,$h=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],Yh=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];class Zh extends Error{constructor(e){super(e),this.name="TimeoutError"}}let Qh=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}};var Xh=e=>void 0===globalThis.DOMException?new Qh(e):new DOMException(e),ep=e=>{var t=void 0===e.reason?Xh("This operation was aborted."):e.reason;return t instanceof Error?t:Xh(t)};function tp(e,t){var r,n,{milliseconds:o,fallback:i,message:s,customTimers:a={setTimeout:setTimeout,clearTimeout:clearTimeout}}=t,c=new Promise(((c,u)=>{if("number"!=typeof o||1!==Math.sign(o))throw new TypeError("Expected `milliseconds` to be a positive number, got `".concat(o,"`"));if(t.signal){var{signal:l}=t;l.aborted&&u(ep(l)),n=()=>{u(ep(l))},l.addEventListener("abort",n,{once:!0})}if(o!==Number.POSITIVE_INFINITY){var d=new Zh;r=a.setTimeout.call(void 0,(()=>{if(i)try{c(i())}catch(e){u(e)}else"function"==typeof e.cancel&&e.cancel(),!1===s?c():s instanceof Error?u(s):(d.message=null!=s?s:"Promise timed out after ".concat(o," milliseconds"),u(d))}),o),G((function*(){try{c(yield e)}catch(e){u(e)}}))()}else e.then(c,u)})),u=c.finally((()=>{u.clear(),n&&t.signal&&t.signal.removeEventListener("abort",n)}));return u.clear=()=>{a.clearTimeout.call(void 0,r),r=void 0},u}var rp="undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new Wh:"undefined"!=typeof navigator?function(e){var t=function(e){return""!==e&&$h.reduce((function(t,r){var n=r[0],o=r[1];if(t)return t;var i=o.exec(e);return!!i&&[n,i]}),!1)}(e);if(!t)return null;var r=t[0],n=t[1];if("searchbot"===r)return new Hh;var o=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);o?o.length<3&&(o=Fh(Fh([],o,!0),function(e){for(var t=[],r=0;r<e;r++)t.push("0");return t}(3-o.length),!0)):o=[];var i=o.join("."),s=function(e){for(var t=0,r=Yh.length;t<r;t++){var n=Yh[t],o=n[0];if(n[1].exec(e))return o}return null}(e),a=Jh.exec(e);return a&&a[1]?new Vh(r,i,s,a[1]):new zh(r,i,s)}(navigator.userAgent):void 0!==h&&h.version?new Gh(h.version.slice(1)):null,np=null!=rp&&"firefox"===rp.name,op=function(){var e=ee((function*(){}));return function(){return e.apply(this,arguments)}}(),ip=function(){var e=G((function*(e){}));return function(t){return e.apply(this,arguments)}}();function sp(e){return ap.apply(this,arguments)}function ap(){return(ap=G((function*(e){var t;return"function"==typeof(e=null!=e?e:{})&&(e=yield e()),e.iceServers=null!==(t=e.iceServers)&&void 0!==t?t:Nh.map((e=>({urls:[e]}))),e}))).apply(this,arguments)}class cp{constructor(e,t){W(this,"log",void 0),W(this,"peerConnection",void 0),W(this,"remoteAddr",void 0),W(this,"timeline",void 0),W(this,"metrics",void 0),W(this,"source",op()),W(this,"sink",ip),this.log=e.logger.forComponent("libp2p:webrtc:maconn"),this.remoteAddr=t.remoteAddr,this.timeline=t.timeline,this.peerConnection=t.peerConnection;var r=this.peerConnection,n=r.connectionState;this.peerConnection.onconnectionstatechange=()=>{this.log.trace("peer connection state change",r.connectionState,"initial state",n),"disconnected"!==r.connectionState&&"failed"!==r.connectionState&&"closed"!==r.connectionState||(this.timeline.close=Date.now())}}close(e){var t=this;return G((function*(){var e;t.log.trace("closing connection"),t.peerConnection.close(),t.timeline.close=Date.now(),null===(e=t.metrics)||void 0===e||e.increment({close:!0})}))()}abort(e){var t;this.log.error("closing connection due to error",e),this.peerConnection.close(),this.timeline.close=Date.now(),null===(t=this.metrics)||void 0===t||t.increment({abort:!0})}}function up(e){if(null!=e){if("function"==typeof e[Symbol.iterator])return e[Symbol.iterator]();if("function"==typeof e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();if("function"==typeof e.next)return e}throw new Error("argument is not an iterator or iterable")}function lp(e){return null!=e&&("function"==typeof e.then&&"function"==typeof e.catch&&"function"==typeof e.finally)}class dp{constructor(e){var t,r;W(this,"id",void 0),W(this,"direction",void 0),W(this,"timeline",void 0),W(this,"protocol",void 0),W(this,"metadata",void 0),W(this,"source",void 0),W(this,"status",void 0),W(this,"readStatus",void 0),W(this,"writeStatus",void 0),W(this,"log",void 0),W(this,"sinkController",void 0),W(this,"sinkEnd",void 0),W(this,"closed",void 0),W(this,"endErr",void 0),W(this,"streamSource",void 0),W(this,"onEnd",void 0),W(this,"onCloseRead",void 0),W(this,"onCloseWrite",void 0),W(this,"onReset",void 0),W(this,"onAbort",void 0),W(this,"sendCloseWriteTimeout",void 0),W(this,"sendingData",void 0),this.sinkController=new AbortController,this.sinkEnd=sl(),this.closed=sl(),this.log=e.log,this.status="open",this.readStatus="ready",this.writeStatus="ready",this.id=e.id,this.metadata=null!==(t=e.metadata)&&void 0!==t?t:{},this.direction=e.direction,this.timeline={open:Date.now()},this.sendCloseWriteTimeout=null!==(r=e.sendCloseWriteTimeout)&&void 0!==r?r:5e3,this.onEnd=e.onEnd,this.onCloseRead=e.onCloseRead,this.onCloseWrite=e.onCloseWrite,this.onReset=e.onReset,this.onAbort=e.onAbort,this.source=this.streamSource=Qd({onEnd:e=>{null!=e?this.log.trace("source ended with error",e):this.log.trace("source ended"),this.onSourceEnd(e)}}),this.sink=this.sink.bind(this)}sink(e){var t=this;return G((function*(){if("ready"!==t.writeStatus)throw new d.StreamStateError('writable end state is "'.concat(t.writeStatus,'" not "ready"'));try{t.writeStatus="writing";var r={signal:t.sinkController.signal};if("outbound"===t.direction){var n=t.sendNewStream(r);lp(n)&&(yield n)}var o=()=>{!function(e,t){var r,n,o,i=null===(r=(n=up(e)).return)||void 0===r?void 0:r.call(n);null!=(o=i)&&"function"==typeof o.then&&"function"==typeof o.catch&&"function"==typeof o.finally&&i.catch((e=>{t.error("could not cause iterator to return",e)}))}(e,t.log)};try{t.sinkController.signal.addEventListener("abort",o),t.log.trace("sink reading from source");var i,s=!1,a=!1;try{for(var c,u=M(e);s=!(c=yield u.next()).done;s=!1){var l=c.value;l=l instanceof Uint8Array?new Ns(l):l;var h=t.sendData(l,r);lp(h)&&(t.sendingData=sl(),yield h,t.sendingData.resolve(),t.sendingData=void 0)}}catch(e){a=!0,i=e}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(a)throw i}}}finally{t.sinkController.signal.removeEventListener("abort",o)}t.log.trace('sink finished reading from source, write status is "%s"',t.writeStatus),"writing"===t.writeStatus&&(t.writeStatus="closing",t.log.trace("send close write to remote"),yield t.sendCloseWrite({signal:AbortSignal.timeout(t.sendCloseWriteTimeout)}),t.writeStatus="closed"),t.onSinkEnd()}catch(e){throw t.log.trace("sink ended with error, calling abort with error",e),t.abort(e),e}finally{t.log.trace("resolve sink end"),t.sinkEnd.resolve()}}))()}onSourceEnd(e){var t;null==this.timeline.closeRead&&(this.timeline.closeRead=Date.now(),this.readStatus="closed",null!=e&&null==this.endErr&&(this.endErr=e),null===(t=this.onCloseRead)||void 0===t||t.call(this),null!=this.timeline.closeWrite?(this.log.trace("source and sink ended"),this.timeline.close=Date.now(),"aborted"!==this.status&&"reset"!==this.status&&(this.status="closed"),null!=this.onEnd&&this.onEnd(this.endErr),this.closed.resolve()):this.log.trace("source ended, waiting for sink to end"))}onSinkEnd(e){var t;null==this.timeline.closeWrite&&(this.timeline.closeWrite=Date.now(),this.writeStatus="closed",null!=e&&null==this.endErr&&(this.endErr=e),null===(t=this.onCloseWrite)||void 0===t||t.call(this),null!=this.timeline.closeRead?(this.log.trace("sink and source ended"),this.timeline.close=Date.now(),"aborted"!==this.status&&"reset"!==this.status&&(this.status="closed"),null!=this.onEnd&&this.onEnd(this.endErr),this.closed.resolve()):this.log.trace("sink ended, waiting for source to end"))}close(e){var t=this;return G((function*(){"open"===t.status&&(t.log.trace("closing gracefully"),t.status="closing",yield cl(Promise.all([t.closeWrite(e),t.closeRead(e),t.closed.promise]),null==e?void 0:e.signal),t.status="closed",t.log.trace("closed gracefully"))}))()}closeRead(){var e=arguments,t=this;return G((function*(){var r=e.length>0&&void 0!==e[0]?e[0]:{};if("closing"!==t.readStatus&&"closed"!==t.readStatus){t.log.trace('closing readable end of stream with starting read status "%s"',t.readStatus);var n=t.readStatus;t.readStatus="closing","reset"!==t.status&&"aborted"!==t.status&&null==t.timeline.closeRead&&(t.log.trace("send close read to remote"),yield t.sendCloseRead(r)),"ready"===n&&(t.log.trace("ending internal source queue with %d queued bytes",t.streamSource.readableLength),t.streamSource.end()),t.log.trace("closed readable end of stream")}}))()}closeWrite(){var e=arguments,t=this;return G((function*(){var r=e.length>0&&void 0!==e[0]?e[0]:{};"closing"!==t.writeStatus&&"closed"!==t.writeStatus&&(t.log.trace('closing writable end of stream with starting write status "%s"',t.writeStatus),"ready"===t.writeStatus&&(t.log.trace("sink was never sunk, sink an empty array"),yield cl(t.sink([]),r.signal)),"writing"===t.writeStatus&&(null!=t.sendingData&&(yield cl(t.sendingData.promise,r.signal)),t.log.trace("aborting source passed to .sink"),t.sinkController.abort(),yield cl(t.sinkEnd.promise,r.signal)),t.writeStatus="closed",t.log.trace("closed writable end of stream"))}))()}abort(e){var t;if("closed"!==this.status&&"aborted"!==this.status&&"reset"!==this.status){this.log("abort with error",e),this.log("try to send reset to remote");var r=this.sendReset();lp(r)&&r.catch((e=>{this.log.error("error sending reset message",e)})),this.status="aborted",this.timeline.abort=Date.now(),this._closeSinkAndSource(e),null===(t=this.onAbort)||void 0===t||t.call(this,e)}}reset(){var e;if("closed"!==this.status&&"aborted"!==this.status&&"reset"!==this.status){var t=new d.StreamResetError("stream reset");this.status="reset",this.timeline.reset=Date.now(),this._closeSinkAndSource(t),null===(e=this.onReset)||void 0===e||e.call(this)}}_closeSinkAndSource(e){this._closeSink(e),this._closeSource(e)}_closeSink(e){"writing"===this.writeStatus&&(this.log.trace("end sink source"),this.sinkController.abort()),this.onSinkEnd(e)}_closeSource(e){"closing"!==this.readStatus&&"closed"!==this.readStatus&&(this.log.trace("ending source with %d bytes to be read by consumer",this.streamSource.readableLength),this.readStatus="closing",this.streamSource.end(e))}remoteCloseWrite(){"closing"!==this.readStatus&&"closed"!==this.readStatus?(this.log.trace("remote close write"),this._closeSource()):this.log("received remote close write but local source is already closed")}remoteCloseRead(){"closing"!==this.writeStatus&&"closed"!==this.writeStatus?(this.log.trace("remote close read"),this._closeSink()):this.log("received remote close read but local sink is already closed")}destroy(){"closed"!==this.status&&"aborted"!==this.status&&"reset"!==this.status?(this.log.trace("stream destroyed"),this._closeSinkAndSource()):this.log("received destroy but we are already closed")}sourcePush(e){this.streamSource.push(e)}sourceReadableLength(){return this.streamSource.readableLength}}var hp=4194304;class pp extends Error{constructor(){super(...arguments),W(this,"name","InvalidMessageLengthError"),W(this,"code","ERR_INVALID_MSG_LENGTH")}}class yp extends Error{constructor(){super(...arguments),W(this,"name","InvalidDataLengthError"),W(this,"code","ERR_MSG_DATA_TOO_LONG")}}class fp extends Error{constructor(){super(...arguments),W(this,"name","InvalidDataLengthLengthError"),W(this,"code","ERR_MSG_LENGTH_TOO_LONG")}}class gp extends Error{constructor(){super(...arguments),W(this,"name","UnexpectedEOFError"),W(this,"code","ERR_UNEXPECTED_EOF")}}function bp(e){return null!=e[Symbol.asyncIterator]}function mp(e,t){if(e.byteLength>t)throw new yp("Message length too long")}var wp,vp=e=>{var t=uc(e),r=Bs(t);return hc(e,r),vp.bytes=t,r};function kp(e,t){var r,n,o,i=null!==(r=(t=null!=t?t:{}).lengthEncoder)&&void 0!==r?r:vp,s=null!==(n=null===(o=t)||void 0===o?void 0:o.maxDataLength)&&void 0!==n?n:hp;function*a(e){mp(e,s);var t=i(e.byteLength);t instanceof Uint8Array?yield t:yield*t,e instanceof Uint8Array?yield e:yield*e}return bp(e)?ee((function*(){var t,r=!1,n=!1;try{for(var o,i=M(e);r=!(o=yield V(i.next())).done;r=!1){var s=o.value;yield*_(M(a(s)))}}catch(e){n=!0,t=e}finally{try{r&&null!=i.return&&(yield V(i.return()))}finally{if(n)throw t}}}))():function*(){for(var t of e)yield*a(t)}()}vp.bytes=0,kp.single=(e,t)=>{var r,n,o,i=null!==(r=(t=null!=t?t:{}).lengthEncoder)&&void 0!==r?r:vp;return mp(e,null!==(n=null===(o=t)||void 0===o?void 0:o.maxDataLength)&&void 0!==n?n:hp),new Ns(i(e.byteLength),e)},function(e){e[e.LENGTH=0]="LENGTH",e[e.DATA=1]="DATA"}(wp||(wp={}));var Sp=e=>{var t=pc(e);return Sp.bytes=uc(t),t};function Op(e,t){var r,n,o,i=new Ns,s=wp.LENGTH,a=-1,c=null!==(r=null==t?void 0:t.lengthDecoder)&&void 0!==r?r:Sp,u=null!==(n=null==t?void 0:t.maxLengthLength)&&void 0!==n?n:8,l=null!==(o=null==t?void 0:t.maxDataLength)&&void 0!==o?o:hp;function*d(){for(;i.byteLength>0;){if(s===wp.LENGTH)try{if((a=c(i))<0)throw new pp("Invalid message length");if(a>l)throw new yp("Message length too long");var e=c.bytes;i.consume(e),null!=(null==t?void 0:t.onLength)&&t.onLength(a),s=wp.DATA}catch(e){if(e instanceof RangeError){if(i.byteLength>u)throw new fp("Message length length too long");break}throw e}if(s===wp.DATA){if(i.byteLength<a)break;var r=i.sublist(0,a);i.consume(a),null!=(null==t?void 0:t.onData)&&t.onData(r),yield r,s=wp.LENGTH}}}return bp(e)?ee((function*(){var t,r=!1,n=!1;try{for(var o,s=M(e);r=!(o=yield V(s.next())).done;r=!1){var a=o.value;i.append(a),yield*_(M(d()))}}catch(e){n=!0,t=e}finally{try{r&&null!=s.return&&(yield V(s.return()))}finally{if(n)throw t}}if(i.byteLength>0)throw new gp("Unexpected end of input")}))():function*(){for(var t of e)i.append(t),yield*d();if(i.byteLength>0)throw new gp("Unexpected end of input")}()}Sp.bytes=0,Op.fromReader=(e,t)=>{var r=1;return Op(ee((function*(){for(;;)try{var{done:t,value:n}=yield V(e.next(r));if(!0===t)return;null!=n&&(yield n)}catch(e){if("ERR_UNDER_READ"===e.code)return{done:!0,value:null};throw e}finally{r=1}}))(),Z(Z({},null!=t?t:{}),{},{onLength:e=>{r=e}}))};class Ap extends dp{constructor(e){var t,r,n,o,i,s,a=e.onEnd;switch(e.onEnd=e=>{this.log.trace('readable and writeable ends closed with status "%s"',this.status),Promise.resolve(G((function*(){if(null==t.timeline.abort&&null===t.timeline.reset)try{yield tp(t.receiveFinAck.promise,{milliseconds:t.finAckTimeout})}catch(e){t.log.error("error receiving FIN_ACK",e)}}))).then((()=>{this.incomingData.end(),null==a||a(e)})).catch((e=>{this.log.error("error ending stream",e)})).finally((()=>{this.channel.close()}))},super(e),t=this,W(this,"channel",void 0),W(this,"incomingData",void 0),W(this,"maxBufferedAmount",void 0),W(this,"bufferedAmountLowEventTimeout",void 0),W(this,"maxMessageSize",void 0),W(this,"receiveFinAck",void 0),W(this,"finAckTimeout",void 0),W(this,"openTimeout",void 0),W(this,"closeController",void 0),this.channel=e.channel,this.channel.binaryType="arraybuffer",this.incomingData=Qd(),this.bufferedAmountLowEventTimeout=null!==(r=e.bufferedAmountLowEventTimeout)&&void 0!==r?r:3e4,this.maxBufferedAmount=null!==(n=e.maxBufferedAmount)&&void 0!==n?n:2097152,this.maxMessageSize=(null!==(o=e.maxMessageSize)&&void 0!==o?o:Kh)-qh,this.receiveFinAck=sl(),this.finAckTimeout=null!==(i=e.closeTimeout)&&void 0!==i?i:5e3,this.openTimeout=null!==(s=e.openTimeout)&&void 0!==s?s:5e3,this.closeController=new AbortController,this.channel.readyState){case"open":this.timeline.open=(new Date).getTime();break;case"closed":case"closing":void 0!==this.timeline.close&&0!==this.timeline.close||(this.timeline.close=Date.now());break;case"connecting":break;default:throw this.log.error("unknown datachannel state %s",this.channel.readyState),new d.StreamStateError("Unknown datachannel state")}this.channel.onopen=e=>{this.timeline.open=(new Date).getTime()},this.channel.onclose=e=>{this.log.trace("received onclose event"),this.closeController.abort(),this.receiveFinAck.resolve(),this.close().catch((e=>{this.log.error("error closing stream after channel closed",e)}))},this.channel.onerror=e=>{this.log.trace("received onerror event"),this.closeController.abort();var t=e.error;this.abort(t)},this.channel.onmessage=function(){var e=G((function*(e){var{data:r}=e;null!==r&&0!==r.byteLength&&t.incomingData.push(new Uint8Array(r,0,r.byteLength))}));return function(t){return e.apply(this,arguments)}}();var c=this;Promise.resolve().then(G((function*(){var e,r=!1,n=!1;try{for(var o,i=M(Op(t.incomingData));r=!(o=yield i.next()).done;r=!1){var s=o.value,a=c.processIncomingProtobuf(s);null!=a&&c.sourcePush(new Ns(a))}}catch(t){n=!0,e=t}finally{try{r&&null!=i.return&&(yield i.return())}finally{if(n)throw e}}}))).catch((e=>{this.log.error("error processing incoming data channel messages",e)}))}sendNewStream(){}_sendMessage(e){var t=arguments,r=this;return G((function*(){var n=!(t.length>1&&void 0!==t[1])||t[1];if("closed"===r.channel.readyState||"closing"===r.channel.readyState)throw new d.StreamStateError("Invalid datachannel state - ".concat(r.channel.readyState));if("open"!==r.channel.readyState){var o=AbortSignal.timeout(r.openTimeout),i=vd([r.closeController.signal,o]);try{r.log('channel state is "%s" and not "open", waiting for "open" event before sending data',r.channel.readyState),yield dh(r.channel,"open",i)}finally{i.clear()}r.log('channel state is now "%s", sending data',r.channel.readyState)}if(n&&r.channel.bufferedAmount>r.maxBufferedAmount){var s=AbortSignal.timeout(r.bufferedAmountLowEventTimeout),a=vd([r.closeController.signal,s]);try{r.log('channel buffer is %d, wait for "bufferedamountlow" event',r.channel.bufferedAmount),yield dh(r.channel,"bufferedamountlow",a)}catch(e){if(s.aborted)throw new d.TimeoutError("Timed out waiting for DataChannel buffer to clear after ".concat(r.bufferedAmountLowEventTimeout,"ms"));throw e}finally{a.clear()}}try{r.log.trace('sending message, channel state "%s"',r.channel.readyState),r.channel.send(e.subarray())}catch(e){r.log.error("error while sending message",e)}}))()}sendData(e){var t=this;return G((function*(){var r=e.byteLength;for(e=e.sublist();e.byteLength>0;){var n=Math.min(e.byteLength,t.maxMessageSize),o=e.subarray(0,n),i=Bh.encode({message:o}),s=kp.single(i);t.log.trace("sending %d/%d bytes on channel",o.byteLength,r),yield t._sendMessage(s),e.consume(n)}t.log.trace('finished sending data, channel state "%s"',t.channel.readyState)}))()}sendReset(){var e=this;return G((function*(){try{yield e._sendFlag(Bh.Flag.RESET)}catch(t){e.log.error("failed to send reset - %e",t)}finally{e.channel.close()}}))()}sendCloseWrite(e){var t=this;return G((function*(){if("open"===t.channel.readyState){if(yield t._sendFlag(Bh.Flag.FIN)){t.log.trace("awaiting FIN_ACK");try{yield cl(t.receiveFinAck.promise,null==e?void 0:e.signal,{errorMessage:"sending close-write was aborted before FIN_ACK was received",errorName:"FinAckNotReceivedError"})}catch(e){t.log.error("failed to await FIN_ACK",e)}}else t.log.trace("sending FIN failed, not awaiting FIN_ACK");t.receiveFinAck.resolve()}else t.receiveFinAck.resolve()}))()}sendCloseRead(){var e=this;return G((function*(){"open"===e.channel.readyState&&(yield e._sendFlag(Bh.Flag.STOP_SENDING))}))()}processIncomingProtobuf(e){var t=Bh.decode(e);if(void 0!==t.flag&&(this.log.trace('incoming flag %s, write status "%s", read status "%s"',t.flag,this.writeStatus,this.readStatus),t.flag===Bh.Flag.FIN&&(this.remoteCloseWrite(),this.log.trace("sending FIN_ACK"),this._sendFlag(Bh.Flag.FIN_ACK).catch((e=>{this.log.error("error sending FIN_ACK immediately",e)}))),t.flag===Bh.Flag.RESET&&this.reset(),t.flag===Bh.Flag.STOP_SENDING&&this.remoteCloseRead(),t.flag===Bh.Flag.FIN_ACK&&(this.log.trace("received FIN_ACK"),this.receiveFinAck.resolve())),"ready"===this.readStatus)return t.message}_sendFlag(e){var t=this;return G((function*(){if("open"!==t.channel.readyState)return t.log.trace('not sending flag %s because channel is "%s" and not "open"',e.toString(),t.channel.readyState),!1;t.log.trace("sending flag %s",e.toString());var r=Bh.encode({flag:e}),n=kp.single(r);try{return yield t._sendMessage(n,!1),!0}catch(r){t.log.error("could not send flag %s - %e",e.toString(),r)}return!1}))()}}function Ip(e){var{channel:t,direction:r,handshake:n}=e;return new Ap(Z({id:"".concat(t.id),log:e.logger.forComponent("libp2p:webrtc:stream:".concat(!0===n?"handshake":r,":").concat(t.id))},e))}class xp{constructor(e,t){var r,n;W(this,"protocol",void 0),W(this,"peerConnection",void 0),W(this,"bufferedStreams",[]),W(this,"metrics",void 0),W(this,"dataChannelOptions",void 0),W(this,"components",void 0),W(this,"log",void 0),this.components=e,this.peerConnection=t.peerConnection,this.metrics=t.metrics,this.protocol=null!==(r=t.protocol)&&void 0!==r?r:Lh,this.dataChannelOptions=null!==(n=t.dataChannelOptions)&&void 0!==n?n:{},this.log=e.logger.forComponent("libp2p:webrtc:muxerfactory"),this.peerConnection.ondatachannel=t=>{var{channel:r}=t;if(this.log.trace('incoming early datachannel with channel id %d and label "%s"',r.id),"init"===r.label)return this.log.trace("closing early init channel"),void r.close();var n={},o=Ip(Z({channel:r,direction:"inbound",onEnd:e=>{n.onEnd(e)},logger:e.logger},this.dataChannelOptions));n.stream=o,n.channel=r,n.onEnd=()=>{this.bufferedStreams=this.bufferedStreams.filter((e=>e.stream.id!==o.id))},this.bufferedStreams.push(n)}}createStreamMuxer(e){return new Ep(this.components,Z(Z({},e),{},{peerConnection:this.peerConnection,dataChannelOptions:this.dataChannelOptions,metrics:this.metrics,streams:this.bufferedStreams,protocol:this.protocol}))}}var Pp=new WeakSet;class Ep{constructor(e,t){var r,n;H(this,Pp),W(this,"init",void 0),W(this,"streams",void 0),W(this,"protocol",void 0),W(this,"log",void 0),W(this,"peerConnection",void 0),W(this,"dataChannelOptions",void 0),W(this,"metrics",void 0),W(this,"logger",void 0),W(this,"source",op()),W(this,"sink",ip),this.init=t,this.log=e.logger.forComponent("libp2p:webrtc:muxer"),this.logger=e.logger,this.streams=t.streams.map((e=>e.stream)),this.peerConnection=t.peerConnection,this.protocol=null!==(r=t.protocol)&&void 0!==r?r:Lh,this.metrics=t.metrics,this.dataChannelOptions=null!==(n=t.dataChannelOptions)&&void 0!==n?n:{},this.peerConnection.ondatachannel=e=>{var r,n,{channel:o}=e;if(this.log.trace("incoming datachannel with channel id %d",o.id),"init"===o.label)return this.log.trace("closing init channel"),void o.close();var i=o.id,s=Ip(Z({channel:o,direction:"inbound",onEnd:()=>{L(Pp,this,Cp).call(this,s,o),this.log("incoming channel %s ended",i)},logger:this.logger},this.dataChannelOptions));this.streams.push(s),null===(r=this.metrics)||void 0===r||r.increment({incoming_stream:!0}),null==t||null===(n=t.onIncomingStream)||void 0===n||n.call(t,s)},this.init.streams.length>0&&queueMicrotask((()=>{this.init.streams.forEach((e=>{var t,r,n;e.onEnd=()=>{this.log("incoming early channel %s ended with state %s",e.channel.id,e.channel.readyState),L(Pp,this,Cp).call(this,e.stream,e.channel)},null===(t=this.metrics)||void 0===t||t.increment({incoming_stream:!0}),null===(r=this.init)||void 0===r||null===(n=r.onIncomingStream)||void 0===n||n.call(r,e.stream)}))}))}close(e){var t=this;return G((function*(){try{yield Promise.all(t.streams.map(function(){var t=G((function*(t){return t.close(e)}));return function(e){return t.apply(this,arguments)}}()))}catch(e){t.abort(e)}}))()}abort(e){for(var t of this.streams)t.abort(e)}newStream(){var e,t=this.peerConnection.createDataChannel(""),r=t.id;this.log.trace("opened outgoing datachannel with channel id %s",r);var n=Ip(Z({channel:t,direction:"outbound",onEnd:()=>{L(Pp,this,Cp).call(this,n,t),this.log("outgoing channel %s ended",r)},logger:this.logger},this.dataChannelOptions));return this.streams.push(n),null===(e=this.metrics)||void 0===e||e.increment({outgoing_stream:!0}),n}}function Cp(e,t){var r,n,o;this.log.trace("stream %s %s %s onEnd",e.direction,e.id,e.protocol),function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e4,n=arguments.length>3?arguments[3]:void 0;"open"===e.readyState&&Promise.resolve().then(G((function*(){if(e.bufferedAmount>0){n.log("%s drain channel with %d buffered bytes",t,e.bufferedAmount);var o=sl(),i=!1;e.bufferedAmountLowThreshold=0;var s=()=>{i||(n.log("%s drain channel closed before drain",t),o.resolve())};e.addEventListener("close",s,{once:!0}),e.addEventListener("bufferedamountlow",(()=>{i=!0,e.removeEventListener("close",s),o.resolve()})),yield tp(o.promise,{milliseconds:r})}}))).then(G((function*(){"open"===e.readyState&&e.close()}))).catch((e=>{n.log.error("error closing outbound stream",e)}))}(t,"".concat(e.direction," ").concat(e.id," ").concat(e.protocol),this.dataChannelOptions.drainTimeout,{log:this.log}),this.streams=this.streams.filter((t=>t.id!==e.id)),null===(r=this.metrics)||void 0===r||r.increment({stream_end:!0}),null===(n=this.init)||void 0===n||null===(o=n.onStreamEnd)||void 0===o||o.call(n,e)}var Bp,Tp=globalThis.RTCPeerConnection,Dp=globalThis.RTCSessionDescription,Rp=globalThis.RTCIceCandidate;class jp extends Error{constructor(e){super("WebRTC transport error: ".concat(e)),this.name="WebRTCTransportError"}}class Np extends jp{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"SDP handshake failed"),this.name="SDPHandshakeFailedError"}}class Up extends jp{constructor(e,t){super('Invalid fingerprint "'.concat(e,'" within ').concat(t)),this.name="WebRTC/InvalidFingerprintError"}}class Kp extends jp{constructor(e){super("A method (".concat(e,") was called though it has been intentionally left unimplemented.")),this.name="WebRTC/UnimplementedError"}}class qp extends jp{constructor(e){super("unsupported hash algorithm code: ".concat(e," please see the codes at https://github.com/multiformats/multicodec/blob/master/table.csv ")),this.name="WebRTC/UnsupportedHashAlgorithmError"}}!function(e){var t,r;!function(e){e.SDP_OFFER="SDP_OFFER",e.SDP_ANSWER="SDP_ANSWER",e.ICE_CANDIDATE="ICE_CANDIDATE"}(e.Type||(e.Type={})),function(e){e[e.SDP_OFFER=0]="SDP_OFFER",e[e.SDP_ANSWER=1]="SDP_ANSWER",e[e.ICE_CANDIDATE=2]="ICE_CANDIDATE"}(t||(t={})),function(e){e.codec=()=>Xc(t)}(e.Type||(e.Type={})),e.codec=()=>(null==r&&(r=eu((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&r.fork(),null!=t.type&&(r.uint32(8),e.Type.codec().encode(t.type,r)),null!=t.data&&(r.uint32(18),r.string(t.data)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n={},o=null==r?t.len:t.pos+r;t.pos<o;){var i=t.uint32();switch(i>>>3){case 1:n.type=e.Type.codec().decode(t);break;case 2:n.data=t.string();break;default:t.skipType(7&i)}}return n}))),r),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(Bp||(Bp={}));var Lp=function(){var e=G((function*(e,t,r){try{var n=sl();for(!function(e,t){e[np?"oniceconnectionstatechange":"onconnectionstatechange"]=r=>{switch(_p(e)){case"connected":t.resolve();break;case"failed":case"disconnected":case"closed":t.reject(new d.ConnectionFailedError("RTCPeerConnection was closed"))}}}(e,n);;){var o,i=yield Promise.race([n.promise,t.read({signal:r.signal}).catch((()=>{}))]);if(null==i){var s;null===(s=r.signal)||void 0===s||s.throwIfAborted();break}if(i.type!==Bp.Type.ICE_CANDIDATE)throw new d.InvalidMessageError("ICE candidate message expected");var a=JSON.parse(null!==(o=i.data)&&void 0!==o?o:"null");if(""!==a&&null!==a){var c=new Rp(a);r.log.trace("%s received new ICE candidate %o",r.direction,a);try{var u;null===(u=r.onProgress)||void 0===u||u.call(r,new uh("webrtc:add-ice-candidate",c.candidate)),yield e.addIceCandidate(c)}catch(e){r.log.error("%s bad candidate received",r.direction,a,e)}}else{var l;null===(l=r.onProgress)||void 0===l||l.call(r,new uh("webrtc:end-of-ice-candidates")),r.log.trace("end-of-candidates received")}}}catch(t){var h;if(r.log.error("%s error parsing ICE candidate",r.direction,t),!0===(null===(h=r.signal)||void 0===h?void 0:h.aborted)&&"connected"!==_p(e))throw t}}));return function(t,r,n){return e.apply(this,arguments)}}();function _p(e){return np?e.iceConnectionState:e.connectionState}function Mp(){return Mp=G((function*(t){var{rtcConfiguration:n,dataChannel:o,signal:i,metrics:s,multiaddr:a,connectionManager:c,transportManager:u,log:l,logger:h,onProgress:p}=t,{baseAddr:y}=function(t){var n=t.toString().split("/webrtc/");if(2!==n.length)throw new d.InvalidParametersError("webrtc protocol was not present in multiaddr");if(!n[0].includes("/p2p-circuit"))throw new d.InvalidParametersError("p2p-circuit protocol was not present in multiaddr");var o=e.multiaddr(n[0]),i=e.multiaddr("/"+n[1]).getPeerId();if(null==i)throw new d.InvalidParametersError("destination peer id was missing");var s=o.protos().pop();if(void 0===s)throw new d.InvalidParametersError("invalid multiaddr");"p2p"!==s.name&&(o=o.encapsulate("/p2p/".concat(i)));return{baseAddr:o,peerId:r.peerIdFromString(i)}}(a);null==s||s.dialerEvents.increment({open:!0}),l.trace("dialing base address: %a",y);var f=y.getPeerId();if(null==f)throw new d.InvalidParametersError("Relay peer was missing");var g,b=c.getConnections(r.peerIdFromString(f)),m=!1;0===b.length?(null==p||p(new uh("webrtc:dial-relay")),g=yield u.dial(y,{signal:i,onProgress:p}),m=!0):(null==p||p(new uh("webrtc:reuse-relay-connection")),g=b[0]);try{null==p||p(new uh("webrtc:open-signaling-stream"));var w=yield g.newStream(_h,{signal:i,runOnLimitedConnection:!0}),v=ml(w).pb(Bp),k=new Tp(n),S=new xp({logger:h},{peerConnection:k,dataChannelOptions:o});try{var O=k.createDataChannel("init");k.onicecandidate=e=>{var t,{candidate:r}=e,n=JSON.stringify(null!==(t=null==r?void 0:r.toJSON())&&void 0!==t?t:null);l.trace("initiator sending ICE candidate %o",r),v.write({type:Bp.Type.ICE_CANDIDATE,data:n},{signal:i}).catch((e=>{l.error("error sending ICE candidate",e)}))},k.onicecandidateerror=e=>{l.error("initiator ICE candidate error",e)};var A=yield k.createOffer().catch((e=>{throw l.error("could not execute createOffer",e),new Np("Failed to set createOffer")}));l.trace("initiator send SDP offer %s",A.sdp),null==p||p(new uh("webrtc:send-sdp-offer")),yield v.write({type:Bp.Type.SDP_OFFER,data:A.sdp},{signal:i}),yield k.setLocalDescription(A).catch((e=>{throw l.error("could not execute setLocalDescription",e),new Np("Failed to set localDescription")})),null==p||p(new uh("webrtc:read-sdp-answer")),l.trace("initiator read SDP answer");var I=yield v.read({signal:i});if(I.type!==Bp.Type.SDP_ANSWER)throw new Np("Remote should send an SDP answer");l.trace("initiator received SDP answer %s",I.data);var x=new Dp({type:"answer",sdp:I.data});return yield k.setRemoteDescription(x).catch((e=>{throw l.error("could not execute setRemoteDescription",e),new Np("Failed to set remoteDescription")})),l.trace("initiator read candidates until connected"),null==p||p(new uh("webrtc:read-ice-candidates")),yield Lp(k,v,{direction:"initiator",signal:i,log:l,onProgress:p}),l.trace("initiator connected, closing init channel"),O.close(),null==p||p(new uh("webrtc:close-signaling-stream")),l.trace("closing signaling channel"),yield w.close({signal:i}),l.trace("initiator connected to remote address %s",a),{remoteAddress:a,peerConnection:k,muxerFactory:S}}catch(e){throw l.error("outgoing signaling error",e),k.close(),w.abort(e),e}finally{k.onicecandidate=null,k.onicecandidateerror=null}}finally{if(m)try{yield g.close({signal:i})}catch(e){g.abort(e)}}})),Mp.apply(this,arguments)}var Fp=Hl(bd.matchers[0],ql("p2p-circuit"));class zp extends d.TypedEventEmitter{constructor(e,t){super(),W(this,"transportManager",void 0),W(this,"shutdownController",void 0),W(this,"events",void 0),this.transportManager=e.transportManager,this.events=e.events,this.shutdownController=t.shutdownController,this.onTransportListening=this.onTransportListening.bind(this)}listen(){var e=this;return G((function*(){e.events.addEventListener("transport:listening",e.onTransportListening)}))()}onTransportListening(e){e.detail.getAddrs().filter((e=>Fp.exactMatch(e))).map((e=>e.encapsulate("/webrtc"))).length>0&&this.safeDispatchEvent("listening")}getAddrs(){return this.transportManager.getListeners().filter((e=>!(e instanceof zp))).map((e=>e.getAddrs().filter((e=>Fp.exactMatch(e))).map((e=>e.encapsulate("/webrtc"))))).flat()}updateAnnounceAddrs(){}close(){var e=this;return G((function*(){e.events.removeEventListener("transport:listening",e.onTransportListening),e.shutdownController.abort(),queueMicrotask((()=>{e.safeDispatchEvent("close")}))}))()}}function Gp(){return Gp=G((function*(t){var{peerConnection:r,stream:n,signal:o,connection:i,log:s}=t;s.trace("new inbound signaling stream");var a=ml(n).pb(Bp);try{r.onicecandidate=e=>{var t,{candidate:r}=e,n=JSON.stringify(null!==(t=null==r?void 0:r.toJSON())&&void 0!==t?t:null);s.trace("recipient sending ICE candidate %s",n),a.write({type:Bp.Type.ICE_CANDIDATE,data:n},{signal:o}).catch((e=>{s.error("error sending ICE candidate",e)}))},s.trace("recipient read SDP offer");var c,u=yield a.read({signal:o});if(u.type!==Bp.Type.SDP_OFFER)throw new Np("expected message type SDP_OFFER, received: ".concat(null!==(c=u.type)&&void 0!==c?c:"undefined"," "));s.trace("recipient received SDP offer %s",u.data);var l=new Dp({type:"offer",sdp:u.data});yield r.setRemoteDescription(l).catch((e=>{throw s.error("could not execute setRemoteDescription",e),new Np("Failed to set remoteDescription")}));var d=yield r.createAnswer().catch((e=>{throw s.error("could not execute createAnswer",e),new Np("Failed to create answer")}));s.trace("recipient send SDP answer %s",d.sdp),yield a.write({type:Bp.Type.SDP_ANSWER,data:d.sdp},{signal:o}),yield r.setLocalDescription(d).catch((e=>{throw s.error("could not execute setLocalDescription",e),new Np("Failed to set localDescription")})),s.trace("recipient read candidates until connected"),yield Lp(r,a,{direction:"recipient",signal:o,log:s})}catch(e){if("connected"!==_p(r))throw s.error("error while handling signaling stream from peer %a",i.remoteAddr,e),r.close(),e;s("error while handling signaling stream from peer %a, ignoring as the RTCPeerConnection is already connected",i.remoteAddr,e)}var h=e.multiaddr("/webrtc/p2p/".concat(i.remoteAddr.getPeerId()));return s.trace("recipient connected to remote address %s",h),{remoteAddress:h}})),Gp.apply(this,arguments)}class Vp{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};W(this,"components",void 0),W(this,"init",void 0),W(this,"log",void 0),W(this,"_started",!1),W(this,"metrics",void 0),W(this,"shutdownController",void 0),W(this,d.transportSymbol,!0),W(this,Symbol.toStringTag,"@libp2p/webrtc"),W(this,d.serviceCapabilities,["@libp2p/transport"]),W(this,d.serviceDependencies,["@libp2p/identify","@libp2p/circuit-relay-v2-transport"]),this.components=e,this.init=t,this.log=e.logger.forComponent("libp2p:webrtc"),this.shutdownController=new AbortController,d.setMaxListeners(1/0,this.shutdownController.signal),null!=e.metrics&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_webrtc_dialer_events_total",{label:"event",help:"Total count of WebRTC dialer events by type"}),listenerEvents:e.metrics.registerCounterGroup("libp2p_webrtc_listener_events_total",{label:"event",help:"Total count of WebRTC listener events by type"})})}isStarted(){return this._started}start(){var e=this;return G((function*(){yield e.components.registrar.handle(_h,(t=>{var r=e.components.upgrader.createInboundAbortSignal(e.shutdownController.signal);e._onProtocol(t,r).catch((r=>{e.log.error("failed to handle incoming connect from %p",t.connection.remotePeer,r)})).finally((()=>{r.clear()}))}),{runOnLimitedConnection:!0}),e._started=!0}))()}stop(){var e=this;return G((function*(){yield e.components.registrar.unhandle(_h),e._started=!1}))()}createListener(e){return new zp(this.components,{shutdownController:this.shutdownController})}listenFilter(e){return e.filter(wd.exactMatch)}dialFilter(e){return this.listenFilter(e)}dial(e,t){var r=this;return G((function*(){var n;r.log.trace("dialing address: %a",e);var{remoteAddress:o,peerConnection:i,muxerFactory:s}=yield function(e){return Mp.apply(this,arguments)}({rtcConfiguration:yield sp(r.init.rtcConfiguration),dataChannel:r.init.dataChannel,multiaddr:e,dataChannelOptions:r.init.dataChannel,signal:t.signal,connectionManager:r.components.connectionManager,transportManager:r.components.transportManager,log:r.log,logger:r.components.logger,onProgress:t.onProgress}),a=new cp(r.components,{peerConnection:i,timeline:{open:Date.now()},remoteAddr:o,metrics:null===(n=r.metrics)||void 0===n?void 0:n.dialerEvents}),c=yield t.upgrader.upgradeOutbound(a,{skipProtection:!0,skipEncryption:!0,muxerFactory:s,onProgress:t.onProgress,signal:t.signal});return r._closeOnShutdown(i,a),c}))()}_onProtocol(e,t){var r=this;return G((function*(){var{connection:n,stream:o}=e,i=new Tp(yield sp(r.init.rtcConfiguration)),s=new xp(r.components,{peerConnection:i,dataChannelOptions:r.init.dataChannel});try{var a,{remoteAddress:c}=yield function(e){return Gp.apply(this,arguments)}({peerConnection:i,connection:n,stream:o,signal:t,log:r.log});yield o.close({signal:t});var u=new cp(r.components,{peerConnection:i,timeline:{open:(new Date).getTime()},remoteAddr:c,metrics:null===(a=r.metrics)||void 0===a?void 0:a.listenerEvents});yield r.components.upgrader.upgradeInbound(u,{skipEncryption:!0,skipProtection:!0,muxerFactory:s,signal:t}),r._closeOnShutdown(i,u)}catch(e){throw r.log.error("incoming signaling error",e),i.close(),o.abort(e),e}}))()}_closeOnShutdown(e,t){var r=()=>{t.close().catch((e=>{this.log.error("could not close WebRTCMultiaddrConnection",e)}))};this.shutdownController.signal.addEventListener("abort",r),e.addEventListener("close",(()=>{this.shutdownController.signal.removeEventListener("abort",r)}))}}var Hp,Wp={};!function(){return Hp||(Hp=1,function(e){!function(){var t="object"==typeof globalThis?globalThis:"object"==typeof o.commonjsGlobal?o.commonjsGlobal:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),r=n(e);function n(e,t){return function(r,n){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0!==t.Reflect&&(r=n(t.Reflect,r)),function(e,t){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,o=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",i=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",s="function"==typeof Object.create,a={__proto__:[]}instanceof Array,c=!s&&!a,u={create:s?function(){return de(Object.create(null))}:a?function(){return de({__proto__:null})}:function(){return de({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},l=Object.getPrototypeOf(Function),d="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),h="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:ue(),p="function"==typeof WeakMap?WeakMap:le(),y=n?Symbol.for("@reflect-metadata:registry"):void 0,f=oe(),g=ie(f);function b(e,t,r,n){if(K(r)){if(!H(e))throw new TypeError;if(!J(t))throw new TypeError;return P(e,t)}if(!H(e))throw new TypeError;if(!_(t))throw new TypeError;if(!_(n)&&!K(n)&&!q(n))throw new TypeError;return q(n)&&(n=void 0),E(e,t,r=V(r),n)}function m(e,t){function r(r,n){if(!_(r))throw new TypeError;if(!K(n)&&!$(n))throw new TypeError;R(e,t,r,n)}return r}function w(e,t,r,n){if(!_(r))throw new TypeError;return K(n)||(n=V(n)),R(e,t,r,n)}function v(e,t,r){if(!_(t))throw new TypeError;return K(r)||(r=V(r)),C(e,t,r)}function k(e,t,r){if(!_(t))throw new TypeError;return K(r)||(r=V(r)),B(e,t,r)}function S(e,t,r){if(!_(t))throw new TypeError;return K(r)||(r=V(r)),T(e,t,r)}function O(e,t,r){if(!_(t))throw new TypeError;return K(r)||(r=V(r)),D(e,t,r)}function A(e,t){if(!_(e))throw new TypeError;return K(t)||(t=V(t)),j(e,t)}function I(e,t){if(!_(e))throw new TypeError;return K(t)||(t=V(t)),N(e,t)}function x(e,t,r){if(!_(t))throw new TypeError;if(K(r)||(r=V(r)),!_(t))throw new TypeError;K(r)||(r=V(r));var n=ae(t,r,!1);return!K(n)&&n.OrdinaryDeleteMetadata(e,t,r)}function P(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!K(n)&&!q(n)){if(!J(n))throw new TypeError;t=n}}return t}function E(e,t,r,n){for(var o=e.length-1;o>=0;--o){var i=(0,e[o])(t,r,n);if(!K(i)&&!q(i)){if(!_(i))throw new TypeError;n=i}}return n}function C(e,t,r){if(B(e,t,r))return!0;var n=re(t);return!q(n)&&C(e,n,r)}function B(e,t,r){var n=ae(t,r,!1);return!K(n)&&z(n.OrdinaryHasOwnMetadata(e,t,r))}function T(e,t,r){if(B(e,t,r))return D(e,t,r);var n=re(t);return q(n)?void 0:T(e,n,r)}function D(e,t,r){var n=ae(t,r,!1);if(!K(n))return n.OrdinaryGetOwnMetadata(e,t,r)}function R(e,t,r,n){ae(r,n,!0).OrdinaryDefineOwnMetadata(e,t,r,n)}function j(e,t){var r=N(e,t),n=re(e);if(null===n)return r;var o=j(n,t);if(o.length<=0)return r;if(r.length<=0)return o;for(var i=new h,s=[],a=0,c=r;a<c.length;a++){var u=c[a];i.has(u)||(i.add(u),s.push(u))}for(var l=0,d=o;l<d.length;l++){u=d[l];i.has(u)||(i.add(u),s.push(u))}return s}function N(e,t){var r=ae(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function U(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function K(e){return void 0===e}function q(e){return null===e}function L(e){return"symbol"==typeof e}function _(e){return"object"==typeof e?null!==e:"function"==typeof e}function M(e,t){switch(U(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r="string",n=Z(e,o);if(void 0!==n){var i=n.call(e,r);if(_(i))throw new TypeError;return i}return F(e)}function F(e,t){var r,n,o=e.toString;if(W(o)&&!_(n=o.call(e)))return n;if(W(r=e.valueOf)&&!_(n=r.call(e)))return n;throw new TypeError}function z(e){return!!e}function G(e){return""+e}function V(e){var t=M(e);return L(t)?t:G(t)}function H(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function W(e){return"function"==typeof e}function J(e){return"function"==typeof e}function $(e){switch(U(e)){case 3:case 4:return!0;default:return!1}}function Y(e,t){return e===t||e!=e&&t!=t}function Z(e,t){var r=e[t];if(null!=r){if(!W(r))throw new TypeError;return r}}function Q(e){var t=Z(e,i);if(!W(t))throw new TypeError;var r=t.call(e);if(!_(r))throw new TypeError;return r}function X(e){return e.value}function ee(e){var t=e.next();return!t.done&&t}function te(e){var t=e.return;t&&t.call(e)}function re(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===l)return t;if(t!==l)return t;var r=e.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return t;var o=n.constructor;return"function"!=typeof o||o===e?t:o}function ne(){var e,r,n,o;K(y)||void 0===t.Reflect||y in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=se(t.Reflect));var i=new p,s={registerProvider:a,getProvider:u,setProvider:f};return s;function a(t){if(!Object.isExtensible(s))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case K(r):r=t;break;case r===t:break;case K(n):n=t;break;case n===t:break;default:void 0===o&&(o=new h),o.add(t)}}function c(t,i){if(!K(r)){if(r.isProviderFor(t,i))return r;if(!K(n)){if(n.isProviderFor(t,i))return r;if(!K(o))for(var s=Q(o);;){var a=ee(s);if(!a)return;var c=X(a);if(c.isProviderFor(t,i))return te(s),c}}}if(!K(e)&&e.isProviderFor(t,i))return e}function u(e,t){var r,n=i.get(e);return K(n)||(r=n.get(t)),K(r)?(K(r=c(e,t))||(K(n)&&(n=new d,i.set(e,n)),n.set(t,r)),r):r}function l(e){if(K(e))throw new TypeError;return r===e||n===e||!K(o)&&o.has(e)}function f(e,t,r){if(!l(r))throw new Error("Metadata provider not registered.");var n=u(e,t);if(n!==r){if(!K(n))return!1;var o=i.get(e);K(o)&&(o=new d,i.set(e,o)),o.set(t,r)}return!0}}function oe(){var e;return!K(y)&&_(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[y]),K(e)&&(e=ne()),!K(y)&&_(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,y,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function ie(e){var t=new p,r={isProviderFor:function(e,r){var n=t.get(e);return!K(n)&&n.has(r)},OrdinaryDefineOwnMetadata:s,OrdinaryHasOwnMetadata:o,OrdinaryGetOwnMetadata:i,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:c};return f.registerProvider(r),r;function n(n,o,i){var s=t.get(n),a=!1;if(K(s)){if(!i)return;s=new d,t.set(n,s),a=!0}var c=s.get(o);if(K(c)){if(!i)return;if(c=new d,s.set(o,c),!e.setProvider(n,o,r))throw s.delete(o),a&&t.delete(n),new Error("Wrong provider for target.")}return c}function o(e,t,r){var o=n(t,r,!1);return!K(o)&&z(o.has(e))}function i(e,t,r){var o=n(t,r,!1);if(!K(o))return o.get(e)}function s(e,t,r,o){n(r,o,!0).set(e,t)}function a(e,t){var r=[],o=n(e,t,!1);if(K(o))return r;for(var i=Q(o.keys()),s=0;;){var a=ee(i);if(!a)return r.length=s,r;var c=X(a);try{r[s]=c}catch(e){try{te(i)}finally{throw e}}s++}}function c(e,r,o){var i=n(r,o,!1);if(K(i))return!1;if(!i.delete(e))return!1;if(0===i.size){var s=t.get(r);K(s)||(s.delete(o),0===s.size&&t.delete(s))}return!0}}function se(e){var t=e.defineMetadata,r=e.hasOwnMetadata,n=e.getOwnMetadata,o=e.getOwnMetadataKeys,i=e.deleteMetadata,s=new p;return{isProviderFor:function(e,t){var r=s.get(e);return!(K(r)||!r.has(t))||!!o(e,t).length&&(K(r)&&(r=new h,s.set(e,r)),r.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:o,OrdinaryDeleteMetadata:i}}function ae(e,t,r){var n=f.getProvider(e,t);if(!K(n))return n;if(r){if(f.setProvider(e,t,g))return g;throw new Error("Illegal state.")}}function ce(){var e={},t=[],r=function(){function e(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return e.prototype["@@iterator"]=function(){return this},e.prototype[i]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}(),n=function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var n=this._keys.length,o=r+1;o<n;o++)this._keys[o-1]=this._keys[o],this._values[o-1]=this._values[o];return this._keys.length--,this._values.length--,Y(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new r(this._keys,this._values,o)},t.prototype.values=function(){return new r(this._keys,this._values,s)},t.prototype.entries=function(){return new r(this._keys,this._values,a)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[i]=function(){return this.entries()},t.prototype._find=function(e,t){if(!Y(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(Y(this._keys[r],e)){this._cacheIndex=r;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();return n;function o(e,t){return e}function s(e,t){return t}function a(e,t){return[e,t]}}function ue(){return function(){function e(){this._map=new d}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[i]=function(){return this.keys()},e}()}function le(){var e=16,t=u.create(),n=o();return function(){function e(){this._key=o()}return e.prototype.has=function(e){var t=i(e,!1);return void 0!==t&&u.has(t,this._key)},e.prototype.get=function(e){var t=i(e,!1);return void 0!==t?u.get(t,this._key):void 0},e.prototype.set=function(e,t){return i(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=i(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=o()},e}();function o(){var e;do{e="@@WeakMap@@"+c()}while(u.has(t,e));return t[e]=!0,e}function i(e,t){if(!r.call(e,n)){if(!t)return;Object.defineProperty(e,n,{value:u.create()})}return e[n]}function s(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function a(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):s(t,e),t}return s(new Array(e),e)}function c(){var t=a(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var r="",n=0;n<e;++n){var o=t[n];4!==n&&6!==n&&8!==n||(r+="-"),o<16&&(r+="0"),r+=o.toString(16).toLowerCase()}return r}}function de(e){return e.__=void 0,delete e.__,e}e("decorate",b),e("metadata",m),e("defineMetadata",w),e("hasMetadata",v),e("hasOwnMetadata",k),e("getMetadata",S),e("getOwnMetadata",O),e("getMetadataKeys",A),e("getOwnMetadataKeys",I),e("deleteMetadata",x)}(r,t),void 0===t.Reflect&&(t.Reflect=e)}()}(e||(e={}))),Wp;var e}();var Jp,$p={};var Yp=function(){if(Jp)return $p;Jp=1;class e{static isArrayBuffer(e){return"[object ArrayBuffer]"===Object.prototype.toString.call(e)}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(t,r){var n=e.toUint8Array(t),o=e.toUint8Array(r);if(n.length!==o.byteLength)return!1;for(var i=0;i<n.length;i++)if(n[i]!==o[i])return!1;return!0}static concat(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];e=!Array.isArray(r[0])||r[1]instanceof Function?Array.isArray(r[0])&&r[1]instanceof Function?r[0]:r[r.length-1]instanceof Function?r.slice(0,r.length-1):r:r[0];var o=0;for(var i of e)o+=i.byteLength;var s=new Uint8Array(o),a=0;for(var c of e){var u=this.toUint8Array(c);s.set(u,a),a+=u.length}return r[r.length-1]instanceof Function?this.toView(s,r[r.length-1]):s.buffer}}var t="string",r=/^[0-9a-f\s]+$/i,n=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,o=/^[a-zA-Z0-9-_]+$/;class i{static fromString(e){for(var t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length),n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r.buffer}static toString(t){for(var r=e.toUint8Array(t),n="",o=0;o<r.length;o++)n+=String.fromCharCode(r[o]);return decodeURIComponent(escape(n))}}class s{static toString(t){for(var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.toArrayBuffer(t),o=new DataView(n),i="",s=0;s<n.byteLength;s+=2){var a=o.getUint16(s,r);i+=String.fromCharCode(a)}return i}static fromString(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new ArrayBuffer(2*e.length),n=new DataView(r),o=0;o<e.length;o++)n.setUint16(2*o,e.charCodeAt(o),t);return r}}class a{static isHex(e){return typeof e===t&&r.test(e)}static isBase64(e){return typeof e===t&&n.test(e)}static isBase64Url(e){return typeof e===t&&o.test(e)}static ToString(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8",n=e.toUint8Array(t);switch(r.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return s.toString(n,!0);case"utf16":case"utf16be":return s.toString(n);default:throw new Error("Unknown type of encoding '".concat(r,"'"))}}static FromString(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return s.fromString(e,!0);case"utf16":case"utf16be":return s.fromString(e);default:throw new Error("Unknown type of encoding '".concat(t,"'"))}}static ToBase64(t){var r=e.toUint8Array(t);if("undefined"!=typeof btoa){var n=this.ToString(r,"binary");return btoa(n)}return Buffer.from(r).toString("base64")}static FromBase64(e){var t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!a.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return"undefined"!=typeof atob?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){var t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!a.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.DEFAULT_UTF8_ENCODING;switch(t){case"ascii":return this.FromBinary(e);case"utf8":return i.fromString(e);case"utf16":case"utf16be":return s.fromString(e);case"utf16le":case"usc2":return s.fromString(e,!0);default:throw new Error("Unknown type of encoding '".concat(t,"'"))}}static ToUtf8String(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.DEFAULT_UTF8_ENCODING;switch(t){case"ascii":return this.ToBinary(e);case"utf8":return i.toString(e);case"utf16":case"utf16be":return s.toString(e);case"utf16le":case"usc2":return s.toString(e,!0);default:throw new Error("Unknown type of encoding '".concat(t,"'"))}}static FromBinary(e){for(var t=e.length,r=new Uint8Array(t),n=0;n<t;n++)r[n]=e.charCodeAt(n);return r.buffer}static ToBinary(t){for(var r=e.toUint8Array(t),n="",o=0;o<r.length;o++)n+=String.fromCharCode(r[o]);return n}static ToHex(t){for(var r=e.toUint8Array(t),n="",o=r.length,i=0;i<o;i++){var s=r[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(e){var t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!a.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t="0".concat(t));for(var r=new Uint8Array(t.length/2),n=0;n<t.length;n+=2){var o=t.slice(n,n+2);r[n/2]=parseInt(o,16)}return r.buffer}static ToUtf16String(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return s.toString(e,t)}static FromUtf16String(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return s.fromString(e,t)}static Base64Padding(e){var t=4-e.length%4;if(t<4)for(var r=0;r<t;r++)e+="=";return e}static formatString(e){return(null==e?void 0:e.replace(/[\n\r\t ]/g,""))||""}}return a.DEFAULT_UTF8_ENCODING="utf8",$p.BufferSourceConverter=e,$p.Convert=a,$p.assign=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var o=arguments[0],i=1;i<arguments.length;i++){var s=arguments[i];for(var a in s)o[a]=s[a]}return o},$p.combine=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=t.map((e=>e.byteLength)).reduce(((e,t)=>e+t)),o=new Uint8Array(n),i=0;return t.map((e=>new Uint8Array(e))).forEach((e=>{for(var t of e)o[i++]=t})),o.buffer},$p.isEqual=function(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;for(var r=new Uint8Array(e),n=new Uint8Array(t),o=0;o<e.byteLength;o++)if(r[o]!==n[o])return!1;return!0},$p}();function Zp(e,t){var r=0;if(1===e.length)return e[0];for(var n=e.length-1;n>=0;n--)r+=e[e.length-1-n]*Math.pow(2,t*n);return r}function Qp(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n=e,o=0,i=Math.pow(2,t),s=1;s<8;s++){if(e<i){var a=void 0;if(r<0)a=new ArrayBuffer(s),o=s;else{if(r<s)return new ArrayBuffer(0);a=new ArrayBuffer(r),o=r}for(var c=new Uint8Array(a),u=s-1;u>=0;u--){var l=Math.pow(2,u*t);c[o-u-1]=Math.floor(n/l),n-=c[o-u-1]*l}return a}i*=Math.pow(2,t)}return new ArrayBuffer(0)}function Xp(){for(var e=0,t=0,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];for(var i of n)e+=i.length;var s=new ArrayBuffer(e),a=new Uint8Array(s);for(var c of n)a.set(c,t),t+=c.length;return a}function ey(){var e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){var t=255===e[0]&&128&e[1],r=0===e[0]&&!(128&e[1]);(t||r)&&this.warnings.push("Needlessly long format")}for(var n=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(n),i=0;i<this.valueHex.byteLength;i++)o[i]=0;o[0]=128&e[0];for(var s=Zp(o,8),a=new ArrayBuffer(this.valueHex.byteLength),c=new Uint8Array(a),u=0;u<this.valueHex.byteLength;u++)c[u]=e[u];return c[0]&=127,Zp(c,8)-s}function ty(e,t){var r=e.toString(10);if(t<r.length)return"";for(var n=t-r.length,o=new Array(n),i=0;i<n;i++)o[i]="0";return o.join("").concat(r)}var ry=["name","optional","primitiveSchema"],ny=["value"],oy=["isHexOnly"],iy=["value","isIndefiniteForm"],sy=["value"],ay=["isConstructed"],cy=["idBlock","lenBlock"],uy=["unusedBits","isConstructed"],ly=["idBlock","lenBlock"],dy=["value"],hy=["valueDec","isFirstSid"],py=["value"],yy=["valueDec"],fy=["value"],gy=["value","valueDate"],by=["value"],my=["value","local"];function wy(){if("undefined"==typeof BigInt)throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function vy(e){for(var t=0,r=0,n=0;n<e.length;n++){t+=e[n].byteLength}for(var o=new Uint8Array(t),i=0;i<e.length;i++){var s=e[i];o.set(new Uint8Array(s),r),r+=s.byteLength}return o.buffer}function ky(e,t,r,n){return t instanceof Uint8Array?t.byteLength?r<0?(e.error="Wrong parameter: inputOffset less than zero",!1):n<0?(e.error="Wrong parameter: inputLength less than zero",!1):!(t.byteLength-r-n<0)||(e.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):(e.error="Wrong parameter: inputBuffer has zero length",!1):(e.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class Sy{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return vy(this.items)}}var Oy=[new Uint8Array([1])],Ay="0123456789",Iy="name",xy="valueHexView",Py="",Ey=new ArrayBuffer(0),Cy=new Uint8Array(0),By="EndOfContent",Ty="OCTET STRING",Dy="BIT STRING";function Ry(e){var t;return t=class extends e{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}constructor(){var e;super(...arguments);var t=(arguments.length<=0?void 0:arguments[0])||{};this.isHexOnly=null!==(e=t.isHexOnly)&&void 0!==e&&e,this.valueHexView=t.valueHex?Yp.BufferSourceConverter.toUint8Array(t.valueHex):Cy}fromBER(e,t,r){var n=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!ky(this,n,t,r))return-1;var o=t+r;return this.valueHexView=n.subarray(t,o),this.valueHexView.length?(this.blockLength=r,o):(this.warnings.push("Zero buffer length"),t)}toBER(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isHexOnly?e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Ey)}toJSON(){return Z(Z({},super.toJSON()),{},{isHexOnly:this.isHexOnly,valueHex:Yp.Convert.ToHex(this.valueHexView)})}},t.NAME="hexBlock",t}class jy{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor(){var{blockLength:e=0,error:t=Py,warnings:r=[],valueBeforeDecode:n=Cy}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.blockLength=e,this.error=t,this.warnings=r,this.valueBeforeDecodeView=Yp.BufferSourceConverter.toUint8Array(n)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:Yp.Convert.ToHex(this.valueBeforeDecodeView)}}}jy.NAME="baseBlock";class Ny extends jy{fromBER(e,t,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}Ny.NAME="valueBlock";class Uy extends(Ry(jy)){constructor(){var e,t,r,n,{idBlock:o={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),o?(this.isHexOnly=null!==(e=o.isHexOnly)&&void 0!==e&&e,this.valueHexView=o.valueHex?Yp.BufferSourceConverter.toUint8Array(o.valueHex):Cy,this.tagClass=null!==(t=o.tagClass)&&void 0!==t?t:-1,this.tagNumber=null!==(r=o.tagNumber)&&void 0!==r?r:-1,this.isConstructed=null!==(n=o.isConstructed)&&void 0!==n&&n):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",Ey}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){var r=new Uint8Array(1);if(!e){var n=this.tagNumber;t|=n&=31,r[0]=t}return r.buffer}if(!this.isHexOnly){var o=Qp(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=31|t,!e){for(var c=0;c<s-1;c++)a[c+1]=128|i[c];a[s]=i[s-1]}return a.buffer}var u=new Uint8Array(this.valueHexView.byteLength+1);if(u[0]=31|t,!e){for(var l=this.valueHexView,d=0;d<l.length-1;d++)u[d+1]=128|l[d];u[this.valueHexView.byteLength]=l[l.length-1]}return u.buffer}fromBER(e,t,r){var n=Yp.BufferSourceConverter.toUint8Array(e);if(!ky(this,n,t,r))return-1;var o=n.subarray(t,t+r);if(0===o.length)return this.error="Zero buffer length",-1;switch(192&o[0]){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=!(32&~o[0]),this.isHexOnly=!1;var i=31&o[0];if(31!==i)this.tagNumber=i,this.blockLength=1;else{for(var s=1,a=this.valueHexView=new Uint8Array(255),c=255;128&o[s];){if(a[s-1]=127&o[s],++s>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(s===c){c+=255;for(var u=new Uint8Array(c),l=0;l<a.length;l++)u[l]=a[l];a=this.valueHexView=new Uint8Array(c)}}this.blockLength=s+1,a[s-1]=127&o[s];for(var d=new Uint8Array(s),h=0;h<s;h++)d[h]=a[h];(a=this.valueHexView=new Uint8Array(s)).set(d),this.blockLength<=9?this.tagNumber=Zp(a,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(1===this.tagClass&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return Z(Z({},super.toJSON()),{},{tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed})}}Uy.NAME="identificationBlock";class Ky extends jy{constructor(){var e,t,r,{lenBlock:n={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.isIndefiniteForm=null!==(e=n.isIndefiniteForm)&&void 0!==e&&e,this.longFormUsed=null!==(t=n.longFormUsed)&&void 0!==t&&t,this.length=null!==(r=n.length)&&void 0!==r?r:0}fromBER(e,t,r){var n=Yp.BufferSourceConverter.toUint8Array(e);if(!ky(this,n,t,r))return-1;var o=n.subarray(t,t+r);if(0===o.length)return this.error="Zero buffer length",-1;if(255===o[0])return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=128===o[0],this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(128&o[0]),!1===this.longFormUsed)return this.length=o[0],this.blockLength=1,t+this.blockLength;var i=127&o[0];if(i>8)return this.error="Too big integer",-1;if(i+1>o.length)return this.error="End of input reached before message was fully decoded",-1;var s=t+1,a=n.subarray(s,s+i);return 0===a[i-1]&&this.warnings.push("Needlessly long encoded length"),this.length=Zp(a,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,t+this.blockLength}toBER(){var e,t,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),!1===r&&((t=new Uint8Array(e))[0]=128),e;if(this.longFormUsed){var n=Qp(this.length,8);if(n.byteLength>127)return this.error="Too big length",Ey;if(e=new ArrayBuffer(n.byteLength+1),r)return e;var o=new Uint8Array(n);(t=new Uint8Array(e))[0]=128|n.byteLength;for(var i=0;i<n.byteLength;i++)t[i+1]=o[i];return e}return e=new ArrayBuffer(1),!1===r&&((t=new Uint8Array(e))[0]=this.length),e}toJSON(){return Z(Z({},super.toJSON()),{},{isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length})}}Ky.NAME="lengthBlock";var qy,Ly,_y,My,Fy,zy={};class Gy extends jy{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{name:t=Py,optional:r=!1,primitiveSchema:n}=e,o=Q(e,ry),i=arguments.length>1?arguments[1]:void 0;super(o),this.name=t,this.optional=r,n&&(this.primitiveSchema=n),this.idBlock=new Uy(o),this.lenBlock=new Ky(o),this.valueBlock=i?new i(o):new Ny(o)}fromBER(e,t,r){var n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}toBER(e,t){var r=t||new Sy;t||Vy(this);var n=this.idBlock.toBER(e);if(r.write(n),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{var o=this.valueBlock.toBER(e);this.lenBlock.length=o.byteLength;var i=this.lenBlock.toBER(e);r.write(i),r.write(o)}return t?Ey:r.final()}toJSON(){var e=Z(Z({},super.toJSON()),{},{idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional});return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(){return"ascii"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ascii")?this.onAsciiEncoding():Yp.Convert.ToHex(this.toBER())}onAsciiEncoding(){var e=this.constructor.NAME,t=Yp.Convert.ToHex(this.valueBlock.valueBeforeDecodeView);return"".concat(e," : ").concat(t)}isEqual(e){return this===e||e instanceof this.constructor&&function(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=new Uint8Array(e),n=new Uint8Array(t),o=0;o<r.length;o++)if(r[o]!==n[o])return!1;return!0}(this.toBER(),e.toBER())}}function Vy(e){var t;if(e instanceof zy.Constructed)for(var r of e.valueBlock.value)Vy(r)&&(e.lenBlock.isIndefiniteForm=!0);return!!(null===(t=e.lenBlock)||void 0===t?void 0:t.isIndefiniteForm)}Gy.NAME="BaseBlock";class Hy extends Gy{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{value:t=Py}=e;super(Q(e,ny),arguments.length>1?arguments[1]:void 0),t&&this.fromString(t)}fromBER(e,t,r){var n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}onAsciiEncoding(){return"".concat(this.constructor.NAME," : '").concat(this.valueBlock.value,"'")}}Hy.NAME="BaseStringBlock";class Wy extends(Ry(Ny)){constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{isHexOnly:t=!0}=e;super(Q(e,oy)),this.isHexOnly=t}}Wy.NAME="PrimitiveValueBlock";class Jy extends Gy{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Wy),this.idBlock.isConstructed=!1}}function $y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,n=t,o=new Gy({},Ny),i=new jy;if(!ky(i,e,t,r))return o.error=i.error,{offset:-1,result:o};if(!e.subarray(t,t+r).length)return o.error="Zero buffer length",{offset:-1,result:o};var s=o.idBlock.fromBER(e,t,r);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),-1===s)return o.error=o.idBlock.error,{offset:-1,result:o};if(t=s,r-=o.idBlock.blockLength,s=o.lenBlock.fromBER(e,t,r),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),-1===s)return o.error=o.lenBlock.error,{offset:-1,result:o};if(t=s,r-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};var a=Gy;if(1===o.idBlock.tagClass){if(o.idBlock.tagNumber>=37&&!1===o.idBlock.isHexOnly)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};a=zy.EndOfContent;break;case 1:a=zy.Boolean;break;case 2:a=zy.Integer;break;case 3:a=zy.BitString;break;case 4:a=zy.OctetString;break;case 5:a=zy.Null;break;case 6:a=zy.ObjectIdentifier;break;case 10:a=zy.Enumerated;break;case 12:a=zy.Utf8String;break;case 13:a=zy.RelativeObjectIdentifier;break;case 14:a=zy.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:a=zy.Sequence;break;case 17:a=zy.Set;break;case 18:a=zy.NumericString;break;case 19:a=zy.PrintableString;break;case 20:a=zy.TeletexString;break;case 21:a=zy.VideotexString;break;case 22:a=zy.IA5String;break;case 23:a=zy.UTCTime;break;case 24:a=zy.GeneralizedTime;break;case 25:a=zy.GraphicString;break;case 26:a=zy.VisibleString;break;case 27:a=zy.GeneralString;break;case 28:a=zy.UniversalString;break;case 29:a=zy.CharacterString;break;case 30:a=zy.BmpString;break;case 31:a=zy.DATE;break;case 32:a=zy.TimeOfDay;break;case 33:a=zy.DateTime;break;case 34:a=zy.Duration;break;default:var c=o.idBlock.isConstructed?new zy.Constructed:new zy.Primitive;c.idBlock=o.idBlock,c.lenBlock=o.lenBlock,c.warnings=o.warnings,o=c}}else a=o.idBlock.isConstructed?zy.Constructed:zy.Primitive;return o=function(e,t){if(e instanceof t)return e;var r=new t;return r.idBlock=e.idBlock,r.lenBlock=e.lenBlock,r.warnings=e.warnings,r.valueBeforeDecodeView=e.valueBeforeDecodeView,r}(o,a),s=o.fromBER(e,t,o.lenBlock.isIndefiniteForm?r:o.lenBlock.length),o.valueBeforeDecodeView=e.subarray(n,n+o.blockLength),{offset:s,result:o}}function Yy(e){if(!e.byteLength){var t=new Gy({},Ny);return t.error="Input buffer has zero length",{offset:-1,result:t}}return $y(Yp.BufferSourceConverter.toUint8Array(e).slice(),0,e.byteLength)}function Zy(e,t){return e?1:t}qy=Jy,zy.Primitive=qy,Jy.NAME="PRIMITIVE";class Qy extends Ny{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{value:t=[],isIndefiniteForm:r=!1}=e;super(Q(e,iy)),this.value=t,this.isIndefiniteForm=r}fromBER(e,t,r){var n=Yp.BufferSourceConverter.toUint8Array(e);if(!ky(this,n,t,r))return-1;if(this.valueBeforeDecodeView=n.subarray(t,t+r),0===this.valueBeforeDecodeView.length)return this.warnings.push("Zero buffer length"),t;for(var o=t;Zy(this.isIndefiniteForm,r)>0;){var i=$y(n,o,r);if(-1===i.offset)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(o=i.offset,this.blockLength+=i.result.blockLength,r-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===By)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===By?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){for(var r=t||new Sy,n=0;n<this.value.length;n++)this.value[n].toBER(e,r);return t?Ey:r.final()}toJSON(){var e=Z(Z({},super.toJSON()),{},{isIndefiniteForm:this.isIndefiniteForm,value:[]});for(var t of this.value)e.value.push(t.toJSON());return e}}Qy.NAME="ConstructedValueBlock";class Xy extends Gy{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Qy),this.idBlock.isConstructed=!0}fromBER(e,t,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;var n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}onAsciiEncoding(){var e=[];for(var t of this.valueBlock.value)e.push(t.toString("ascii").split("\n").map((e=>" ".concat(e))).join("\n"));var r=3===this.idBlock.tagClass?"[".concat(this.idBlock.tagNumber,"]"):this.constructor.NAME;return e.length?"".concat(r," :\n").concat(e.join("\n")):"".concat(r," :")}}Ly=Xy,zy.Constructed=Ly,Xy.NAME="CONSTRUCTED";class ef extends Ny{fromBER(e,t,r){return t}toBER(e){return Ey}}ef.override="EndOfContentValueBlock";class tf extends Gy{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},ef),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}_y=tf,zy.EndOfContent=_y,tf.NAME=By;class rf extends Gy{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Ny),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,r){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=r,t+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+r}toBER(e,t){var r=new ArrayBuffer(2);if(!e){var n=new Uint8Array(r);n[0]=5,n[1]=0}return t&&t.write(r),r}onAsciiEncoding(){return"".concat(this.constructor.NAME)}}My=rf,zy.Null=My,rf.NAME="NULL";class nf extends(Ry(Ny)){get value(){for(var e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{value:t}=e,r=Q(e,sy);super(r),r.valueHex?this.valueHexView=Yp.BufferSourceConverter.toUint8Array(r.valueHex):this.valueHexView=new Uint8Array(1),t&&(this.value=t)}fromBER(e,t,r){var n=Yp.BufferSourceConverter.toUint8Array(e);return ky(this,n,t,r)?(this.valueHexView=n.subarray(t,t+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,ey.call(this),this.blockLength=r,t+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return Z(Z({},super.toJSON()),{},{value:this.value})}}nf.NAME="BooleanValueBlock";let of=class extends Gy{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},nf),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return"".concat(this.constructor.NAME," : ").concat(this.getValue)}};Fy=of,zy.Boolean=Fy,of.NAME="BOOLEAN";class sf extends(Ry(Qy)){constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{isConstructed:t=!1}=e;super(Q(e,ay)),this.isConstructed=t}fromBER(e,t,r){var n=0;if(this.isConstructed){if(this.isHexOnly=!1,-1===(n=Qy.prototype.fromBER.call(this,e,t,r)))return n;for(var o=0;o<this.value.length;o++){var i=this.value[o].constructor.NAME;if(i===By){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==Ty)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,n=super.fromBER(e,t,r),this.blockLength=r;return n}toBER(e,t){return this.isConstructed?Qy.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return Z(Z({},super.toJSON()),{},{isConstructed:this.isConstructed})}}var af;sf.NAME="OctetStringValueBlock";let cf=class extends Gy{constructor(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{idBlock:n={},lenBlock:o={}}=r,i=Q(r,cy);null!==(e=i.isConstructed)&&void 0!==e||(i.isConstructed=!!(null===(t=i.value)||void 0===t?void 0:t.length)),super(Z({idBlock:Z({isConstructed:i.isConstructed},n),lenBlock:Z(Z({},o),{},{isIndefiniteForm:!!i.isIndefiniteForm})},i),sf),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,0===r)return 0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){var n=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+r);try{if(n.byteLength){var o=$y(n,0,n.byteLength);-1!==o.offset&&o.offset===r&&(this.valueBlock.value=[o.result])}}catch(e){}}return super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Xy.prototype.onAsciiEncoding.call(this);var e=this.constructor.NAME,t=Yp.Convert.ToHex(this.valueBlock.valueHexView);return"".concat(e," : ").concat(t)}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;var e=[];for(var t of this.valueBlock.value)t instanceof af&&e.push(t.valueBlock.valueHexView);return Yp.BufferSourceConverter.concat(e)}};af=cf,zy.OctetString=af,cf.NAME=Ty;class uf extends(Ry(Qy)){constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{unusedBits:t=0,isConstructed:r=!1}=e;super(Q(e,uy)),this.unusedBits=t,this.isConstructed=r,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,r){if(!r)return t;var n=-1;if(this.isConstructed){if(-1===(n=Qy.prototype.fromBER.call(this,e,t,r)))return n;for(var o of this.value){var i=o.constructor.NAME;if(i===By){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(i!==Dy)return this.error="BIT STRING may consists of BIT STRINGs only",-1;var s=o.valueBlock;if(this.unusedBits>0&&s.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=s.unusedBits}return n}var a=Yp.BufferSourceConverter.toUint8Array(e);if(!ky(this,a,t,r))return-1;var c=a.subarray(t,t+r);if(this.unusedBits=c[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){var u=c.subarray(1);try{if(u.byteLength){var l=$y(u,0,u.byteLength);-1!==l.offset&&l.offset===r-1&&(this.value=[l.result])}}catch(e){}}return this.valueHexView=c.subarray(1),this.blockLength=c.length,t+r}toBER(e,t){if(this.isConstructed)return Qy.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Ey;var r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return Z(Z({},super.toJSON()),{},{unusedBits:this.unusedBits,isConstructed:this.isConstructed})}}var lf;uf.NAME="BitStringValueBlock";let df=class extends Gy{constructor(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{idBlock:n={},lenBlock:o={}}=r,i=Q(r,ly);null!==(e=i.isConstructed)&&void 0!==e||(i.isConstructed=!!(null===(t=i.value)||void 0===t?void 0:t.length)),super(Z({idBlock:Z({isConstructed:i.isConstructed},n),lenBlock:Z(Z({},o),{},{isIndefiniteForm:!!i.isIndefiniteForm})},i),uf),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Xy.prototype.onAsciiEncoding.call(this);var e=[],t=this.valueBlock.valueHexView;for(var r of t)e.push(r.toString(2).padStart(8,"0"));var n=e.join(""),o=this.constructor.NAME,i=n.substring(0,n.length-this.valueBlock.unusedBits);return"".concat(o," : ").concat(i)}};var hf,pf,yf,ff,gf,bf,mf;function wf(e,t){for(var r=new Uint8Array([0]),n=new Uint8Array(e),o=new Uint8Array(t),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,u=0,l=0,d=c<s?s:c;d>=0;d--,l++){if(!0==l<a.length)u=i[s-l]+a[c-l]+r[0];else u=i[s-l]+r[0];if(r[0]=u/10,!0==l>=i.length)i=Xp(new Uint8Array([u%10]),i);else i[s-l]=u%10}return r[0]>0&&(i=Xp(r,i)),i}function vf(e){if(e>=Oy.length)for(var t=Oy.length;t<=e;t++){for(var r=new Uint8Array([0]),n=Oy[t-1].slice(0),o=n.length-1;o>=0;o--){var i=new Uint8Array([(n[o]<<1)+r[0]]);r[0]=i[0]/10,n[o]=i[0]%10}r[0]>0&&(n=Xp(r,n)),Oy.push(n)}return Oy[e]}function kf(e,t){for(var r,n=0,o=new Uint8Array(e),i=new Uint8Array(t),s=o.slice(0),a=s.length-1,c=i.slice(0),u=c.length-1,l=0,d=u;d>=0;d--,l++)if(!0==(r=s[a-l]-c[u-l]-n)<0)n=1,s[a-l]=r+10;else n=0,s[a-l]=r;if(n>0)for(var h=a-u+1;h>=0;h--,l++){if(!((r=s[a-l]-n)<0)){n=0,s[a-l]=r;break}n=1,s[a-l]=r+10}return s.slice()}lf=df,zy.BitString=lf,df.NAME=Dy;class Sf extends(Ry(Ny)){setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=ey.call(this)))}constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{value:t}=e,r=Q(e,dy);super(r),this._valueDec=0,r.valueHex&&this.setValueHex(),void 0!==t&&(this.valueDec=t)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(function(e){for(var t=e<0?-1*e:e,r=128,n=1;n<8;n++){if(t<=r){if(e<0){var o=Qp(r-t,8,n);return new Uint8Array(o)[0]|=128,o}var i=Qp(t,8,n),s=new Uint8Array(i);if(128&s[0]){var a=i.slice(0),c=new Uint8Array(a);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(var u=0;u<a.byteLength;u++)s[u+1]=c[u];s[0]=0}return i}r*=Math.pow(2,8)}return new ArrayBuffer(0)}(e))}get valueDec(){return this._valueDec}fromDER(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=this.fromBER(e,t,r);if(-1===o)return o;var i=this.valueHexView;return 0===i[0]&&128&i[1]?this.valueHexView=i.subarray(1):0!==n&&i.length<n&&(n-i.length>1&&(n=i.length+1),this.valueHexView=i.subarray(n-i.length)),o}toDER(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.valueHexView;switch(!0){case!!(128&t[0]):var r=new Uint8Array(this.valueHexView.length+1);r[0]=0,r.set(t,1),this.valueHexView=r;break;case 0===t[0]&&!(128&t[1]):this.valueHexView=this.valueHexView.subarray(1)}return this.toBER(e)}fromBER(e,t,r){var n=super.fromBER(e,t,r);return-1===n||this.setValueHex(),n}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return Z(Z({},super.toJSON()),{},{valueDec:this.valueDec})}toString(){for(var e,t=8*this.valueHexView.length-1,r=new Uint8Array(8*this.valueHexView.length/3),n=0,o=this.valueHexView,i="",s=!1,a=o.byteLength-1;a>=0;a--){e=o[a];for(var c=0;c<8;c++){if(!(1&~e))if(n===t)r=kf(vf(n),r),i="-";else r=wf(r,vf(n));n++,e>>=1}}for(var u=0;u<r.length;u++)r[u]&&(s=!0),s&&(i+=Ay.charAt(r[u]));return!1===s&&(i+=Ay.charAt(0)),i}}hf=Sf,Sf.NAME="IntegerValueBlock",Object.defineProperty(hf.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});class Of extends Gy{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Sf),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return wy(),BigInt(this.valueBlock.toString())}static fromBigInt(e){wy();var t=BigInt(e),r=new Sy,n=t.toString(16).replace(/^-/,""),o=new Uint8Array(Yp.Convert.FromHex(n));if(t<0){var i=new Uint8Array(o.length+(128&o[0]?1:0));i[0]|=128;var s=BigInt("0x".concat(Yp.Convert.ToHex(i)))+t,a=Yp.BufferSourceConverter.toUint8Array(Yp.Convert.FromHex(s.toString(16)));a[0]|=128,r.write(a)}else 128&o[0]&&r.write(new Uint8Array([0])),r.write(o);return new pf({valueHex:r.final()})}convertToDER(){var e=new pf({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new pf({valueHex:0===this.valueBlock.valueHexView[0]?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return"".concat(this.constructor.NAME," : ").concat(this.valueBlock.toString())}}pf=Of,zy.Integer=pf,Of.NAME="INTEGER";class Af extends Of{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}yf=Af,zy.Enumerated=yf,Af.NAME="ENUMERATED";class If extends(Ry(Ny)){constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{valueDec:t=-1,isFirstSid:r=!1}=e;super(Q(e,hy)),this.valueDec=t,this.isFirstSid=r}fromBER(e,t,r){if(!r)return t;var n=Yp.BufferSourceConverter.toUint8Array(e);if(!ky(this,n,t,r))return-1;var o=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(var i=0;i<r&&(this.valueHexView[i]=127&o[i],this.blockLength++,128&o[i]);i++);for(var s=new Uint8Array(this.blockLength),a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,128&o[this.blockLength-1]?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Zp(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){wy();for(var t=BigInt(e).toString(2);t.length%7;)t="0"+t;for(var r=new Uint8Array(t.length/7),n=0;n<r.length;n++)r[n]=parseInt(t.slice(7*n,7*n+7),2)+(n+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);for(var t=this.valueHexView,r=new Uint8Array(this.blockLength),n=0;n<this.blockLength-1;n++)r[n]=128|t[n];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}var o=Qp(this.valueDec,7);if(0===o.byteLength)return this.error="Error during encoding SID value",Ey;var i=new Uint8Array(o.byteLength);if(!e){for(var s=new Uint8Array(o),a=o.byteLength-1,c=0;c<a;c++)i[c]=128|s[c];i[a]=s[a]}return i}toString(){var e="";if(this.isHexOnly)e=Yp.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){var t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return Z(Z({},super.toJSON()),{},{valueDec:this.valueDec,isFirstSid:this.isFirstSid})}}If.NAME="sidBlock";class xf extends Ny{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{value:t=Py}=e;super(Q(e,py)),this.value=[],t&&this.fromString(t)}fromBER(e,t,r){for(var n=t;r>0;){var o=new If;if(-1===(n=o.fromBER(e,n,r)))return this.blockLength=0,this.error=o.error,n;0===this.value.length&&(o.isFirstSid=!0),this.blockLength+=o.blockLength,r-=o.blockLength,this.value.push(o)}return n}toBER(e){for(var t=[],r=0;r<this.value.length;r++){var n=this.value[r].toBER(e);if(0===n.byteLength)return this.error=this.value[r].error,Ey;t.push(n)}return vy(t)}fromString(e){this.value=[];var t=0,r=0,n="",o=!1;do{if(n=-1===(r=e.indexOf(".",t))?e.substring(t):e.substring(t,r),t=r+1,o){var i=this.value[0],s=0;switch(i.valueDec){case 0:break;case 1:s=40;break;case 2:s=80;break;default:return void(this.value=[])}var a=parseInt(n,10);if(isNaN(a))return;i.valueDec=a+s,o=!1}else{var c=new If;if(n>Number.MAX_SAFE_INTEGER){wy();var u=BigInt(n);c.valueBigInt=u}else if(c.valueDec=parseInt(n,10),isNaN(c.valueDec))return;this.value.length||(c.isFirstSid=!0,o=!0),this.value.push(c)}}while(-1!==r)}toString(){for(var e="",t=!1,r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;var n=this.value[r].toString();0!==r&&(e="".concat(e,".")),t?(n="{".concat(n,"}"),this.value[r].isFirstSid?e="2.{".concat(n," - 80}"):e+=n):e+=n}return e}toJSON(){for(var e=Z(Z({},super.toJSON()),{},{value:this.toString(),sidArray:[]}),t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}xf.NAME="ObjectIdentifierValueBlock";class Pf extends Gy{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},xf),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return"".concat(this.constructor.NAME," : ").concat(this.valueBlock.toString()||"empty")}toJSON(){return Z(Z({},super.toJSON()),{},{value:this.getValue()})}}ff=Pf,zy.ObjectIdentifier=ff,Pf.NAME="OBJECT IDENTIFIER";class Ef extends(Ry(jy)){constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{valueDec:t=0}=e;super(Q(e,yy)),this.valueDec=t}fromBER(e,t,r){if(0===r)return t;var n=Yp.BufferSourceConverter.toUint8Array(e);if(!ky(this,n,t,r))return-1;var o=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(var i=0;i<r&&(this.valueHexView[i]=127&o[i],this.blockLength++,128&o[i]);i++);for(var s=new Uint8Array(this.blockLength),a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,128&o[this.blockLength-1]?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Zp(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);for(var t=this.valueHexView,r=new Uint8Array(this.blockLength),n=0;n<this.blockLength-1;n++)r[n]=128|t[n];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}var o=Qp(this.valueDec,7);if(0===o.byteLength)return this.error="Error during encoding SID value",Ey;var i=new Uint8Array(o.byteLength);if(!e){for(var s=new Uint8Array(o),a=o.byteLength-1,c=0;c<a;c++)i[c]=128|s[c];i[a]=s[a]}return i.buffer}toString(){return this.isHexOnly?Yp.Convert.ToHex(this.valueHexView):this.valueDec.toString()}toJSON(){return Z(Z({},super.toJSON()),{},{valueDec:this.valueDec})}}Ef.NAME="relativeSidBlock";class Cf extends Ny{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{value:t=Py}=e;super(Q(e,fy)),this.value=[],t&&this.fromString(t)}fromBER(e,t,r){for(var n=t;r>0;){var o=new Ef;if(-1===(n=o.fromBER(e,n,r)))return this.blockLength=0,this.error=o.error,n;this.blockLength+=o.blockLength,r-=o.blockLength,this.value.push(o)}return n}toBER(e,t){for(var r=[],n=0;n<this.value.length;n++){var o=this.value[n].toBER(e);if(0===o.byteLength)return this.error=this.value[n].error,Ey;r.push(o)}return vy(r)}fromString(e){this.value=[];var t=0,r=0,n="";do{n=-1===(r=e.indexOf(".",t))?e.substring(t):e.substring(t,r),t=r+1;var o=new Ef;if(o.valueDec=parseInt(n,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(-1!==r);return!0}toString(){for(var e="",t=!1,r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;var n=this.value[r].toString();0!==r&&(e="".concat(e,".")),e+=t?n="{".concat(n,"}"):n}return e}toJSON(){for(var e=Z(Z({},super.toJSON()),{},{value:this.toString(),sidArray:[]}),t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}Cf.NAME="RelativeObjectIdentifierValueBlock";class Bf extends Gy{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Cf),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return"".concat(this.constructor.NAME," : ").concat(this.valueBlock.toString()||"empty")}toJSON(){return Z(Z({},super.toJSON()),{},{value:this.getValue()})}}gf=Bf,zy.RelativeObjectIdentifier=gf,Bf.NAME="RelativeObjectIdentifier";class Tf extends Xy{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}bf=Tf,zy.Sequence=bf,Tf.NAME="SEQUENCE";let Df=class extends Xy{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};mf=Df,zy.Set=mf,Df.NAME="SET";class Rf extends(Ry(Ny)){constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(J({},($(e),e))),this.isHexOnly=!0,this.value=Py}toJSON(){return Z(Z({},super.toJSON()),{},{value:this.value})}}Rf.NAME="StringValueBlock";class jf extends Rf{}jf.NAME="SimpleStringValueBlock";class Nf extends Hy{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(J({},($(e),e)),jf)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,Yp.BufferSourceConverter.toUint8Array(e))}fromString(e){for(var t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(t),n=0;n<t;n++)r[n]=e.charCodeAt(n);this.valueBlock.value=e}}Nf.NAME="SIMPLE STRING";class Uf extends Nf{fromBuffer(e){this.valueBlock.valueHexView=Yp.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=Yp.Convert.ToUtf8String(e)}catch(t){this.warnings.push('Error during "decodeURIComponent": '.concat(t,", using raw string")),this.valueBlock.value=Yp.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(Yp.Convert.FromUtf8String(e)),this.valueBlock.value=e}}var Kf,qf,Lf,_f,Mf,Ff,zf,Gf,Vf,Hf,Wf,Jf,$f,Yf,Zf,Qf,Xf,eg,tg;Uf.NAME="Utf8StringValueBlock";class rg extends Uf{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Kf=rg,zy.Utf8String=Kf,rg.NAME="UTF8String";class ng extends Nf{fromBuffer(e){this.valueBlock.value=Yp.Convert.ToUtf16String(e),this.valueBlock.valueHexView=Yp.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(Yp.Convert.FromUtf16String(e))}}ng.NAME="BmpStringValueBlock";class og extends ng{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(J({},($(e),e))),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}qf=og,zy.BmpString=qf,og.NAME="BMPString";class ig extends Nf{fromBuffer(e){for(var t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(t),n=0;n<r.length;n+=4)r[n]=r[n+3],r[n+1]=r[n+2],r[n+2]=0,r[n+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){for(var t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(4*t),n=0;n<t;n++){var o=Qp(e.charCodeAt(n),8),i=new Uint8Array(o);if(!(i.length>4))for(var s=4-i.length,a=i.length-1;a>=0;a--)r[4*n+a+s]=i[a]}this.valueBlock.value=e}}ig.NAME="UniversalStringValueBlock";class sg extends ig{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(J({},($(e),e))),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Lf=sg,zy.UniversalString=Lf,sg.NAME="UniversalString";class ag extends Nf{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}_f=ag,zy.NumericString=_f,ag.NAME="NumericString";class cg extends Nf{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Mf=cg,zy.PrintableString=Mf,cg.NAME="PrintableString";class ug extends Nf{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Ff=ug,zy.TeletexString=Ff,ug.NAME="TeletexString";class lg extends Nf{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}zf=lg,zy.VideotexString=zf,lg.NAME="VideotexString";class dg extends Nf{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Gf=dg,zy.IA5String=Gf,dg.NAME="IA5String";class hg extends Nf{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Vf=hg,zy.GraphicString=Vf,hg.NAME="GraphicString";class pg extends Nf{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Hf=pg,zy.VisibleString=Hf,pg.NAME="VisibleString";class yg extends Nf{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Wf=yg,zy.GeneralString=Wf,yg.NAME="GeneralString";class fg extends Nf{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Jf=fg,zy.CharacterString=Jf,fg.NAME="CharacterString";class gg extends pg{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{value:t,valueDate:r}=e;if(super(Q(e,gy)),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,t){this.fromString(t),this.valueBlock.valueHexView=new Uint8Array(t.length);for(var n=0;n<t.length;n++)this.valueBlock.valueHexView[n]=t.charCodeAt(n)}r&&(this.fromDate(r),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,Yp.BufferSourceConverter.toUint8Array(e)))}toBuffer(){for(var e=this.toString(),t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){var t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(null!==t){var r=parseInt(t[1],10);this.year=r>=50?1900+r:2e3+r,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}else this.error="Wrong input string for conversion"}toString(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"iso";if("iso"===e){var t=new Array(7);return t[0]=ty(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=ty(this.month,2),t[2]=ty(this.day,2),t[3]=ty(this.hour,2),t[4]=ty(this.minute,2),t[5]=ty(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return"".concat(this.constructor.NAME," : ").concat(this.toDate().toISOString())}toJSON(){return Z(Z({},super.toJSON()),{},{year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second})}}$f=gg,zy.UTCTime=$f,gg.NAME="UTCTime";class bg extends gg{constructor(){var e;super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),null!==(e=this.millisecond)&&void 0!==e||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){var e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){var t,r=!1,n="",o="",i=0,s=0,a=0;if("Z"===e[e.length-1])n=e.substring(0,e.length-1),r=!0;else{var c=new Number(e[e.length-1]);if(isNaN(c.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(-1!==n.indexOf("+"))throw new Error("Wrong input string for conversion");if(-1!==n.indexOf("-"))throw new Error("Wrong input string for conversion")}else{var u=1,l=n.indexOf("+"),d="";if(-1===l&&(l=n.indexOf("-"),u=-1),-1!==l){if(d=n.substring(l+1),n=n.substring(0,l),2!==d.length&&4!==d.length)throw new Error("Wrong input string for conversion");var h=parseInt(d.substring(0,2),10);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");if(s=u*h,4===d.length){if(h=parseInt(d.substring(2,4),10),isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");a=u*h}}}var p=n.indexOf(".");if(-1===p&&(p=n.indexOf(",")),-1!==p){var y=new Number("0".concat(n.substring(p)));if(isNaN(y.valueOf()))throw new Error("Wrong input string for conversion");i=y.valueOf(),o=n.substring(0,p)}else o=n;switch(!0){case 8===o.length:if(t=/(\d{4})(\d{2})(\d{2})/gi,-1!==p)throw new Error("Wrong input string for conversion");break;case 10===o.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,-1!==p){var f=60*i;this.minute=Math.floor(f),f=60*(f-this.minute),this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case 12===o.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==p){var g=60*i;this.second=Math.floor(g),g=1e3*(g-this.second),this.millisecond=Math.floor(g)}break;case 14===o.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==p){var b=1e3*i;this.millisecond=Math.floor(b)}break;default:throw new Error("Wrong input string for conversion")}var m=t.exec(o);if(null===m)throw new Error("Wrong input string for conversion");for(var w=1;w<m.length;w++)switch(w){case 1:this.year=parseInt(m[w],10);break;case 2:this.month=parseInt(m[w],10);break;case 3:this.day=parseInt(m[w],10);break;case 4:this.hour=parseInt(m[w],10)+s;break;case 5:this.minute=parseInt(m[w],10)+a;break;case 6:this.second=parseInt(m[w],10);break;default:throw new Error("Wrong input string for conversion")}if(!1===r){var v=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=v.getUTCFullYear(),this.month=v.getUTCMonth(),this.day=v.getUTCDay(),this.hour=v.getUTCHours(),this.minute=v.getUTCMinutes(),this.second=v.getUTCSeconds(),this.millisecond=v.getUTCMilliseconds()}}toString(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"iso";if("iso"===e){var t=[];return t.push(ty(this.year,4)),t.push(ty(this.month,2)),t.push(ty(this.day,2)),t.push(ty(this.hour,2)),t.push(ty(this.minute,2)),t.push(ty(this.second,2)),0!==this.millisecond&&(t.push("."),t.push(ty(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return Z(Z({},super.toJSON()),{},{millisecond:this.millisecond})}}Yf=bg,zy.GeneralizedTime=Yf,bg.NAME="GeneralizedTime";class mg extends rg{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Zf=mg,zy.DATE=Zf,mg.NAME="DATE";class wg extends rg{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Qf=wg,zy.TimeOfDay=Qf,wg.NAME="TimeOfDay";class vg extends rg{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Xf=vg,zy.DateTime=Xf,vg.NAME="DateTime";class kg extends rg{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}eg=kg,zy.Duration=eg,kg.NAME="Duration";class Sg extends rg{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}tg=Sg,zy.TIME=tg,Sg.NAME="TIME";class Og{constructor(){var{name:e=Py,optional:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.name=e,this.optional=t}}class Ag extends Og{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{value:t=[]}=e;super(Q(e,by)),this.value=t}}class Ig extends Og{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{value:t=new Og,local:r=!1}=e;super(Q(e,my)),this.value=t,this.local=r}}function xg(e,t,r){if(r instanceof Ag){for(var n of r.value){if(xg(e,t,n).verified)return{verified:!0,result:e}}var o={verified:!1,result:{error:"Wrong values for Choice type"}};return r.hasOwnProperty(Iy)&&(o.name=r.name),o}if(r instanceof Og)return r.hasOwnProperty(Iy)&&(e[r.name]=t),{verified:!0,result:e};if(e instanceof Object==!1)return{verified:!1,result:{error:"Wrong root object"}};if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(r instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("idBlock"in r==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("fromBER"in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("toBER"in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};var i=r.idBlock.toBER(!1);if(0===i.byteLength)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(-1===r.idBlock.fromBER(i,0,i.byteLength))return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(!1===r.idBlock.hasOwnProperty("tagClass"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty("tagNumber"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty("isConstructed"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if(!("isHexOnly"in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(r.idBlock.isHexOnly){if(xy in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};var s=r.idBlock.valueHexView,a=t.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:e};for(var c=0;c<s.length;c++)if(s[c]!==a[1])return{verified:!1,result:e}}if(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,Py),r.name&&(e[r.name]=t)),r instanceof zy.Constructed){var u=0,l={verified:!1,result:{error:"Unknown error"}},d=r.valueBlock.value.length;if(d>0&&r.valueBlock.value[0]instanceof Ig&&(d=t.valueBlock.value.length),0===d)return{verified:!0,result:e};if(0===t.valueBlock.value.length&&0!==r.valueBlock.value.length){for(var h=!0,p=0;p<r.valueBlock.value.length;p++)h=h&&(r.valueBlock.value[p].optional||!1);return h?{verified:!0,result:e}:(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,Py),r.name&&delete e[r.name]),e.error="Inconsistent object length",{verified:!1,result:e})}for(var y=0;y<d;y++)if(y-u>=t.valueBlock.value.length){if(!1===r.valueBlock.value[y].optional){var f={verified:!1,result:e};return e.error="Inconsistent length between ASN.1 data and schema",r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,Py),r.name&&(delete e[r.name],f.name=r.name)),f}}else if(r.valueBlock.value[0]instanceof Ig){if(!1===(l=xg(e,t.valueBlock.value[y],r.valueBlock.value[0].value)).verified){if(!r.valueBlock.value[0].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,Py),r.name&&delete e[r.name]),l;u++}if(Iy in r.valueBlock.value[0]&&r.valueBlock.value[0].name.length>0){var g={};void 0===(g="local"in r.valueBlock.value[0]&&r.valueBlock.value[0].local?t:e)[r.valueBlock.value[0].name]&&(g[r.valueBlock.value[0].name]=[]),g[r.valueBlock.value[0].name].push(t.valueBlock.value[y])}}else if(!1===(l=xg(e,t.valueBlock.value[y-u],r.valueBlock.value[y])).verified){if(!r.valueBlock.value[y].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,Py),r.name&&delete e[r.name]),l;u++}if(!1===l.verified){var b={verified:!1,result:e};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,Py),r.name&&(delete e[r.name],b.name=r.name)),b}return{verified:!0,result:e}}if(r.primitiveSchema&&xy in t.valueBlock){var m=$y(t.valueBlock.valueHexView);if(-1===m.offset){var w={verified:!1,result:m.result};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,Py),r.name&&(delete e[r.name],w.name=r.name)),w}return xg(e,m.result,r.primitiveSchema)}return{verified:!0,result:e}}var Pg,Eg,Cg=Object.freeze({__proto__:null,Any:Og,BaseBlock:Gy,BaseStringBlock:Hy,BitString:df,BmpString:og,Boolean:of,CharacterString:fg,Choice:Ag,Constructed:Xy,DATE:mg,DateTime:vg,Duration:kg,EndOfContent:tf,Enumerated:Af,GeneralString:yg,GeneralizedTime:bg,GraphicString:hg,HexBlock:Ry,IA5String:dg,Integer:Of,Null:rf,NumericString:ag,ObjectIdentifier:Pf,OctetString:cf,Primitive:Jy,PrintableString:cg,RawData:class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=Yp.BufferSourceConverter.toUint8Array(e)}constructor(){var{data:e=Cy}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.dataView=Yp.BufferSourceConverter.toUint8Array(e)}fromBER(e,t,r){var n=t+r;return this.dataView=Yp.BufferSourceConverter.toUint8Array(e).subarray(t,n),n}toBER(e){return this.dataView.slice().buffer}},RelativeObjectIdentifier:Bf,Repeated:Ig,Sequence:Tf,Set:Df,TIME:Sg,TeletexString:ug,TimeOfDay:wg,UTCTime:gg,UniversalString:sg,Utf8String:rg,ValueBlock:Ny,VideotexString:lg,ViewWriter:Sy,VisibleString:pg,compareSchema:xg,fromBER:Yy,verifySchema:function(e,t){if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};var r=$y(Yp.BufferSourceConverter.toUint8Array(e));return-1===r.offset?{verified:!1,result:r.result}:xg(r.result,r.result,t)}});!function(e){e[e.Sequence=0]="Sequence",e[e.Set=1]="Set",e[e.Choice=2]="Choice"}(Pg||(Pg={})),function(e){e[e.Any=1]="Any",e[e.Boolean=2]="Boolean",e[e.OctetString=3]="OctetString",e[e.BitString=4]="BitString",e[e.Integer=5]="Integer",e[e.Enumerated=6]="Enumerated",e[e.ObjectIdentifier=7]="ObjectIdentifier",e[e.Utf8String=8]="Utf8String",e[e.BmpString=9]="BmpString",e[e.UniversalString=10]="UniversalString",e[e.NumericString=11]="NumericString",e[e.PrintableString=12]="PrintableString",e[e.TeletexString=13]="TeletexString",e[e.VideotexString=14]="VideotexString",e[e.IA5String=15]="IA5String",e[e.GraphicString=16]="GraphicString",e[e.VisibleString=17]="VisibleString",e[e.GeneralString=18]="GeneralString",e[e.CharacterString=19]="CharacterString",e[e.UTCTime=20]="UTCTime",e[e.GeneralizedTime=21]="GeneralizedTime",e[e.DATE=22]="DATE",e[e.TimeOfDay=23]="TimeOfDay",e[e.DateTime=24]="DateTime",e[e.Duration=25]="Duration",e[e.TIME=26]="TIME",e[e.Null=27]="Null"}(Eg||(Eg={}));class Bg{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if("number"==typeof e)this.fromNumber(e);else{if(!Yp.BufferSourceConverter.isBufferSource(e))throw TypeError("Unsupported type of 'params' argument for BitString");this.unusedBits=t,this.value=Yp.BufferSourceConverter.toArrayBuffer(e)}}fromASN(e){if(!(e instanceof df))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new df({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new df({name:e})}toNumber(){var e="",t=new Uint8Array(this.value);for(var r of t)e+=r.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){var t=e.toString(2),r=t.length+7>>3;this.unusedBits=(r<<3)-t.length;var n=new Uint8Array(r);t=t.padStart(r<<3,"0").split("").reverse().join("");for(var o=0;o<r;)n[o]=parseInt(t.slice(o<<3,8+(o<<3)),2),o++;this.value=n.buffer}}class Tg{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){"number"==typeof e?this.buffer=new ArrayBuffer(e):Yp.BufferSourceConverter.isBufferSource(e)?this.buffer=Yp.BufferSourceConverter.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof cf))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new cf({valueHex:this.buffer})}toSchema(e){return new cf({name:e})}}var Dg={fromASN:e=>e instanceof rf?null:e.valueBeforeDecodeView,toASN:e=>{if(null===e)return new rf;var t=Yy(e);if(t.result.error)throw new Error(t.result.error);return t.result}},Rg={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new Of({value:+e})},jg={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new Af({value:e})},Ng={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new Of({valueHex:e})},Ug={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new df({valueHex:e})},Kg={fromASN:e=>e.valueBlock.toString(),toASN:e=>new Pf({value:e})},qg={fromASN:e=>e.valueBlock.value,toASN:e=>new of({value:e})},Lg={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new cf({valueHex:e})},_g={fromASN:e=>new Tg(e.getValue()),toASN:e=>e.toASN()};function Mg(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}var Fg=Mg(rg),zg=Mg(og),Gg=Mg(sg),Vg=Mg(ag),Hg=Mg(cg),Wg=Mg(ug),Jg=Mg(lg),$g=Mg(dg),Yg=Mg(hg),Zg=Mg(pg),Qg=Mg(yg),Xg=Mg(fg),eb={fromASN:e=>e.toDate(),toASN:e=>new gg({valueDate:e})},tb={fromASN:e=>e.toDate(),toASN:e=>new bg({valueDate:e})},rb={fromASN:()=>null,toASN:()=>new rf};function nb(e){switch(e){case Eg.Any:return Dg;case Eg.BitString:return Ug;case Eg.BmpString:return zg;case Eg.Boolean:return qg;case Eg.CharacterString:return Xg;case Eg.Enumerated:return jg;case Eg.GeneralString:return Qg;case Eg.GeneralizedTime:return tb;case Eg.GraphicString:return Yg;case Eg.IA5String:return $g;case Eg.Integer:return Rg;case Eg.Null:return rb;case Eg.NumericString:return Vg;case Eg.ObjectIdentifier:return Kg;case Eg.OctetString:return Lg;case Eg.PrintableString:return Hg;case Eg.TeletexString:return Wg;case Eg.UTCTime:return eb;case Eg.UniversalString:return Gg;case Eg.Utf8String:return Fg;case Eg.VideotexString:return Jg;case Eg.VisibleString:return Zg;default:return null}}function ob(e){return"function"==typeof e&&e.prototype?!(!e.prototype.toASN||!e.prototype.fromASN)||ob(e.prototype):!!(e&&"object"==typeof e&&"toASN"in e&&"fromASN"in e)}function ib(e){var t;if(e){var r=Object.getPrototypeOf(e);return(null===(t=null==r?void 0:r.prototype)||void 0===t?void 0:t.constructor)===Array||ib(r)}return!1}function sb(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;for(var r=new Uint8Array(e),n=new Uint8Array(t),o=0;o<e.byteLength;o++)if(r[o]!==n[o])return!1;return!0}var ab=new class{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.items.get(e);if(!r)throw new Error("Cannot get schema for '".concat(e.prototype.constructor.name,"' target"));if(t&&!r.schema)throw new Error("Schema '".concat(e.prototype.constructor.name,"' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'."));return r}cache(e){var t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){var t={type:Pg.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(t,r),t.items=Object.assign({},t.items,r.items)),t}create(e,t){var r=this.items.get(e)||this.createDefault(e),n=[];for(var o in r.items){var i=r.items[o],s=t?o:"",a=void 0;if("number"==typeof i.type){var c=Eg[i.type],u=Cg[c];if(!u)throw new Error("Cannot get ASN1 class by name '".concat(c,"'"));a=new u({name:s})}else if(ob(i.type)){a=(new i.type).toSchema(s)}else if(i.optional){this.get(i.type).type===Pg.Choice?a=new Og({name:s}):(a=this.create(i.type,!1)).name=s}else a=new Og({name:s});var l=!!i.optional||void 0!==i.defaultValue;if(i.repeated)a.name="",a=new("set"===i.repeated?Df:Tf)({name:"",value:[new Ig({name:s,value:a})]});if(null!==i.context&&void 0!==i.context)if(i.implicit)if("number"==typeof i.type||ob(i.type)){var d=i.repeated?Xy:Jy;n.push(new d({name:s,optional:l,idBlock:{tagClass:3,tagNumber:i.context}}))}else{this.cache(i.type);var h=!!i.repeated,p=h?a:this.get(i.type,!0).schema;p="valueBlock"in p?p.valueBlock.value:p.value,n.push(new Xy({name:h?"":s,optional:l,idBlock:{tagClass:3,tagNumber:i.context},value:p}))}else n.push(new Xy({optional:l,idBlock:{tagClass:3,tagNumber:i.context},value:[a]}));else a.optional=l,n.push(a)}switch(r.type){case Pg.Sequence:return new Tf({value:n,name:""});case Pg.Set:return new Df({value:n,name:""});case Pg.Choice:return new Ag({value:n,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){var t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}},cb=e=>t=>{var r;ab.has(t)?r=ab.get(t):(r=ab.createDefault(t),ab.set(t,r)),Object.assign(r,e)},ub=e=>(t,r)=>{var n;ab.has(t.constructor)?n=ab.get(t.constructor):(n=ab.createDefault(t.constructor),ab.set(t.constructor,n));var o=Object.assign({},e);if("number"==typeof o.type&&!o.converter){var i=nb(e.type);if(!i)throw new Error("Cannot get default converter for property '".concat(r,"' of ").concat(t.constructor.name));o.converter=i}n.items[r]=o};class lb extends Error{constructor(){super(...arguments),this.schemas=[]}}class db{static parse(e,t){var r=Yy(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,t)}static fromASN(e,t){var r,n=this;try{if(ob(t))return(new t).fromASN(e);var o=ab.get(t);ab.cache(t);var i=o.schema;if(e.constructor===Xy&&o.type!==Pg.Choice)for(var s in i=new Xy({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:o.schema.valueBlock.value}),o.items)delete e[s];var a=xg({},e,i);if(!a.verified)throw new lb("Data does not match to ".concat(t.name," ASN1 schema. ").concat(a.result.error));var c=new t;if(ib(t)){if(!("value"in e.valueBlock)||!Array.isArray(e.valueBlock.value))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");var u=o.itemType;if("number"==typeof u){var l=nb(u);if(!l)throw new Error("Cannot get default converter for array item of ".concat(t.name," ASN1 schema"));return t.from(e.valueBlock.value,(e=>l.fromASN(e)))}return t.from(e.valueBlock.value,(e=>this.fromASN(e,u)))}var d=function(){var e=a.result[h];if(!e)return 1;var t=o.items[h],i=t.type;if("number"==typeof i||ob(i)){var s=null!==(r=t.converter)&&void 0!==r?r:ob(i)?new i:null;if(!s)throw new Error("Converter is empty");if(t.repeated)if(t.implicit){var u=new("sequence"===t.repeated?Tf:Df);u.valueBlock=e.valueBlock;var l=Yy(u.toBER(!1));if(-1===l.offset)throw new Error("Cannot parse the child item. ".concat(l.result.error));if(!("value"in l.result.valueBlock)||!Array.isArray(l.result.valueBlock.value))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");var d=l.result.valueBlock.value;c[h]=Array.from(d,(e=>s.fromASN(e)))}else c[h]=Array.from(e,(e=>s.fromASN(e)));else{var p=e;if(t.implicit){var y;if(ob(i))y=(new i).toSchema("");else{var f=Eg[i],g=Cg[f];if(!g)throw new Error("Cannot get '".concat(f,"' class from asn1js module"));y=new g}y.valueBlock=p.valueBlock,p=Yy(y.toBER(!1)).result}c[h]=s.fromASN(p)}}else if(t.repeated){if(!Array.isArray(e))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[h]=Array.from(e,(e=>n.fromASN(e,i)))}else c[h]=n.fromASN(e,i)};for(var h in o.items)d();return c}catch(e){throw e instanceof lb&&e.schemas.push(t.name),e}}}class hb{static serialize(e){return e instanceof Gy?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&"object"==typeof e&&ob(e))return e.toASN();if(!e||"object"!=typeof e)throw new TypeError("Parameter 1 should be type of Object.");var t=e.constructor,r=ab.get(t);ab.cache(t);var n,o=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if("number"==typeof r.itemType){var i=nb(r.itemType);if(!i)throw new Error("Cannot get default converter for array item of ".concat(t.name," ASN1 schema"));o=e.map((e=>i.toASN(e)))}else o=e.map((e=>this.toAsnItem({type:r.itemType},"[]",t,e)))}else for(var s in r.items){var a=r.items[s],c=e[s];if(!(void 0===c||a.defaultValue===c||"object"==typeof a.defaultValue&&"object"==typeof c&&sb(this.serialize(a.defaultValue),this.serialize(c)))){var u=hb.toAsnItem(a,s,t,c);if("number"==typeof a.context)if(a.implicit)if(a.repeated||"number"!=typeof a.type&&!ob(a.type))o.push(new Xy({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:u.valueBlock.value}));else{var l={};l.valueHex=u instanceof rf?u.valueBeforeDecodeView:u.valueBlock.toBER(),o.push(new Jy(Z({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context}},l)))}else o.push(new Xy({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:[u]}));else a.repeated?o=o.concat(u):o.push(u)}}switch(r.type){case Pg.Sequence:n=new Tf({value:o});break;case Pg.Set:n=new Df({value:o});break;case Pg.Choice:if(!o[0])throw new Error("Schema '".concat(t.name,"' has wrong data. Choice cannot be empty."));n=o[0]}return n}static toAsnItem(e,t,r,n){var o;if("number"==typeof e.type){var i=e.converter;if(!i)throw new Error("Property '".concat(t,"' doesn't have converter for type ").concat(Eg[e.type]," in schema '").concat(r.name,"'"));if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");var s=Array.from(n,(e=>i.toASN(e)));o=new("sequence"===e.repeated?Tf:Df)({value:s})}else o=i.toASN(n)}else if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");var a=Array.from(n,(e=>this.toASN(e)));o=new("sequence"===e.repeated?Tf:Df)({value:a})}else o=this.toASN(n);return o}}class pb extends Array{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if("number"==typeof e)super(e);else for(var t of(super(),e))this.push(t)}}class yb{static serialize(e){return hb.serialize(e)}static parse(e,t){return db.parse(e,t)}static toString(e){var t=Yy(Yp.BufferSourceConverter.isBufferSource(e)?Yp.BufferSourceConverter.toArrayBuffer(e):yb.serialize(e));if(-1===t.offset)throw new Error("Cannot decode ASN.1 data. ".concat(t.result.error));return t.result.toString()}}var fb,gb,bb,mb=function(e,t){return mb=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},mb(e,t)};function wb(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}mb(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function vb(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s}function kb(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function Sb(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function Ob(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ab(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function Ib(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ab(arguments[t]));return e}function xb(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}"function"==typeof SuppressedError&&SuppressedError;class Pb{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){var t=e.split(".");if(4!==t.length)throw new Error("Invalid IPv4 address");return t.map((e=>{var t=parseInt(e,10);if(isNaN(t)||t<0||t>255)throw new Error("Invalid IPv4 address part");return t}))}static parseIPv6(e){var t=this.expandIPv6(e).split(":");if(8!==t.length)throw new Error("Invalid IPv6 address");return t.reduce(((e,t)=>{var r=parseInt(t,16);if(isNaN(r)||r<0||r>65535)throw new Error("Invalid IPv6 address part");return e.push(r>>8&255),e.push(255&r),e}),[])}static expandIPv6(e){if(!e.includes("::"))return e;var t=e.split("::");if(t.length>2)throw new Error("Invalid IPv6 address");var r=t[0]?t[0].split(":"):[],n=t[1]?t[1].split(":"):[],o=8-(r.length+n.length);if(o<0)throw new Error("Invalid IPv6 address");return[...r,...Array(o).fill("0"),...n].join(":")}static formatIPv6(e){for(var t=[],r=0;r<16;r+=2)t.push((e[r]<<8|e[r+1]).toString(16));return this.compressIPv6(t.join(":"))}static compressIPv6(e){for(var t=e.split(":"),r=-1,n=0,o=-1,i=0,s=0;s<t.length;s++)"0"===t[s]?(-1===o&&(o=s),i++):(i>n&&(r=o,n=i),o=-1,i=0);if(i>n&&(r=o,n=i),n>1){var a=t.slice(0,r).join(":"),c=t.slice(r+n).join(":");return"".concat(a,"::").concat(c)}return e}static parseCIDR(e){var[t,r]=e.split("/"),n=parseInt(r,10);if(this.isIPv4(t)){if(n<0||n>32)throw new Error("Invalid IPv4 prefix length");return[this.parseIPv4(t),n]}if(n<0||n>128)throw new Error("Invalid IPv6 prefix length");return[this.parseIPv6(t),n]}static decodeIP(e){if(64===e.length&&0===parseInt(e,16))return"::/0";if(16!==e.length)return e;var t=parseInt(e.slice(8),16).toString(2).split("").reduce(((e,t)=>e+ +t),0),r=e.slice(0,8).replace(/(.{2})/g,(e=>"".concat(parseInt(e,16),".")));return r=r.slice(0,-1),"".concat(r,"/").concat(t)}static toString(e){var t=new Uint8Array(e);if(4===t.length)return Array.from(t).join(".");if(16===t.length)return this.formatIPv6(t);if(8===t.length||32===t.length){var r=t.length/2,n=t.slice(0,r),o=t.slice(r);if(t.every((e=>0===e)))return 8===t.length?"0.0.0.0/0":"::/0";var i=o.reduce(((e,t)=>e+(t.toString(2).match(/1/g)||[]).length),0);if(8===t.length){var s=Array.from(n).join(".");return"".concat(s,"/").concat(i)}var a=this.formatIPv6(n);return"".concat(a,"/").concat(i)}return this.decodeIP(Yp.Convert.ToHex(e))}static fromString(e){if(e.includes("/")){for(var[t,r]=this.parseCIDR(e),n=new Uint8Array(t.length),o=r,i=0;i<n.length;i++)o>=8?(n[i]=255,o-=8):o>0&&(n[i]=255<<8-o,o=0);var s=new Uint8Array(2*t.length);return s.set(t,0),s.set(n,t.length),s.buffer}var a=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(a).buffer}}var Eb=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};vb([ub({type:Eg.TeletexString})],Eb.prototype,"teletexString",void 0),vb([ub({type:Eg.PrintableString})],Eb.prototype,"printableString",void 0),vb([ub({type:Eg.UniversalString})],Eb.prototype,"universalString",void 0),vb([ub({type:Eg.Utf8String})],Eb.prototype,"utf8String",void 0),vb([ub({type:Eg.BmpString})],Eb.prototype,"bmpString",void 0),Eb=vb([cb({type:Pg.Choice})],Eb);var Cb=class extends Eb{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?Yp.Convert.ToHex(this.anyValue):super.toString())}};vb([ub({type:Eg.IA5String})],Cb.prototype,"ia5String",void 0),vb([ub({type:Eg.Any})],Cb.prototype,"anyValue",void 0),Cb=vb([cb({type:Pg.Choice})],Cb);class Bb{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.type="",this.value=new Cb,Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],Bb.prototype,"type",void 0),vb([ub({type:Cb})],Bb.prototype,"value",void 0);var Tb=fb=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,fb.prototype)}};Tb=fb=vb([cb({type:Pg.Set,itemType:Bb})],Tb);var Db=gb=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,gb.prototype)}};Db=gb=vb([cb({type:Pg.Sequence,itemType:Tb})],Db);var Rb=bb=class extends Db{constructor(e){super(e),Object.setPrototypeOf(this,bb.prototype)}};Rb=bb=vb([cb({type:Pg.Sequence})],Rb);var jb={fromASN:e=>Pb.toString(Lg.fromASN(e)),toASN:e=>Lg.toASN(Pb.fromString(e))};class Nb{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],Nb.prototype,"typeId",void 0),vb([ub({type:Eg.Any,context:0})],Nb.prototype,"value",void 0);class Ub{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.partyName=new Eb,Object.assign(this,e)}}vb([ub({type:Eb,optional:!0,context:0,implicit:!0})],Ub.prototype,"nameAssigner",void 0),vb([ub({type:Eb,context:1,implicit:!0})],Ub.prototype,"partyName",void 0);var Kb=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:Nb,context:0,implicit:!0})],Kb.prototype,"otherName",void 0),vb([ub({type:Eg.IA5String,context:1,implicit:!0})],Kb.prototype,"rfc822Name",void 0),vb([ub({type:Eg.IA5String,context:2,implicit:!0})],Kb.prototype,"dNSName",void 0),vb([ub({type:Eg.Any,context:3,implicit:!0})],Kb.prototype,"x400Address",void 0),vb([ub({type:Rb,context:4,implicit:!1})],Kb.prototype,"directoryName",void 0),vb([ub({type:Ub,context:5})],Kb.prototype,"ediPartyName",void 0),vb([ub({type:Eg.IA5String,context:6,implicit:!0})],Kb.prototype,"uniformResourceIdentifier",void 0),vb([ub({type:Eg.OctetString,context:7,implicit:!0,converter:jb})],Kb.prototype,"iPAddress",void 0),vb([ub({type:Eg.ObjectIdentifier,context:8,implicit:!0})],Kb.prototype,"registeredID",void 0),Kb=vb([cb({type:Pg.Choice})],Kb);var qb,Lb="1.3.6.1.5.5.7",_b="".concat(Lb,".1"),Mb="".concat(Lb,".3"),Fb="".concat(Lb,".48"),zb="".concat(Fb,".1"),Gb="".concat(Fb,".2"),Vb="".concat(Fb,".3"),Hb="".concat(Fb,".5"),Wb="2.5.29",Jb="".concat(_b,".1");class $b{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.accessMethod="",this.accessLocation=new Kb,Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],$b.prototype,"accessMethod",void 0),vb([ub({type:Kb})],$b.prototype,"accessLocation",void 0);var Yb=qb=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,qb.prototype)}};Yb=qb=vb([cb({type:Pg.Sequence,itemType:$b})],Yb);var Zb="".concat(Wb,".35");class Qb extends Tg{}class Xb{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e&&Object.assign(this,e)}}vb([ub({type:Qb,context:0,optional:!0,implicit:!0})],Xb.prototype,"keyIdentifier",void 0),vb([ub({type:Kb,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Xb.prototype,"authorityCertIssuer",void 0),vb([ub({type:Eg.Integer,context:2,optional:!0,implicit:!0,converter:Ng})],Xb.prototype,"authorityCertSerialNumber",void 0);var em,tm="".concat(Wb,".19");class rm{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.cA=!1,Object.assign(this,e)}}vb([ub({type:Eg.Boolean,defaultValue:!1})],rm.prototype,"cA",void 0),vb([ub({type:Eg.Integer,optional:!0})],rm.prototype,"pathLenConstraint",void 0);var nm,om=em=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,em.prototype)}};om=em=vb([cb({type:Pg.Sequence,itemType:Kb})],om);var im,sm=nm=class extends om{constructor(e){super(e),Object.setPrototypeOf(this,nm.prototype)}};sm=nm=vb([cb({type:Pg.Sequence})],sm);var am="".concat(Wb,".32"),cm=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};vb([ub({type:Eg.IA5String})],cm.prototype,"ia5String",void 0),vb([ub({type:Eg.VisibleString})],cm.prototype,"visibleString",void 0),vb([ub({type:Eg.BmpString})],cm.prototype,"bmpString",void 0),vb([ub({type:Eg.Utf8String})],cm.prototype,"utf8String",void 0),cm=vb([cb({type:Pg.Choice})],cm);class um{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.organization=new cm,this.noticeNumbers=[],Object.assign(this,e)}}vb([ub({type:cm})],um.prototype,"organization",void 0),vb([ub({type:Eg.Integer,repeated:"sequence"})],um.prototype,"noticeNumbers",void 0);class lm{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}}vb([ub({type:um,optional:!0})],lm.prototype,"noticeRef",void 0),vb([ub({type:cm,optional:!0})],lm.prototype,"explicitText",void 0);var dm=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:Eg.IA5String})],dm.prototype,"cPSuri",void 0),vb([ub({type:lm})],dm.prototype,"userNotice",void 0),dm=vb([cb({type:Pg.Choice})],dm);class hm{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],hm.prototype,"policyQualifierId",void 0),vb([ub({type:Eg.Any})],hm.prototype,"qualifier",void 0);class pm{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.policyIdentifier="",Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],pm.prototype,"policyIdentifier",void 0),vb([ub({type:hm,repeated:"sequence",optional:!0})],pm.prototype,"policyQualifiers",void 0);var ym=im=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,im.prototype)}};ym=im=vb([cb({type:Pg.Sequence,itemType:pm})],ym);var fm=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.value=e}};vb([ub({type:Eg.Integer})],fm.prototype,"value",void 0),fm=vb([cb({type:Pg.Choice})],fm);var gm,bm=class extends fm{};bm=vb([cb({type:Pg.Choice})],bm);var mm,wm="".concat(Wb,".31");!function(e){e[e.unused=1]="unused",e[e.keyCompromise=2]="keyCompromise",e[e.cACompromise=4]="cACompromise",e[e.affiliationChanged=8]="affiliationChanged",e[e.superseded=16]="superseded",e[e.cessationOfOperation=32]="cessationOfOperation",e[e.certificateHold=64]="certificateHold",e[e.privilegeWithdrawn=128]="privilegeWithdrawn",e[e.aACompromise=256]="aACompromise"}(mm||(mm={}));class vm extends Bg{toJSON(){var e=[],t=this.toNumber();return t&mm.aACompromise&&e.push("aACompromise"),t&mm.affiliationChanged&&e.push("affiliationChanged"),t&mm.cACompromise&&e.push("cACompromise"),t&mm.certificateHold&&e.push("certificateHold"),t&mm.cessationOfOperation&&e.push("cessationOfOperation"),t&mm.keyCompromise&&e.push("keyCompromise"),t&mm.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&mm.superseded&&e.push("superseded"),t&mm.unused&&e.push("unused"),e}toString(){return"[".concat(this.toJSON().join(", "),"]")}}var km=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:Kb,context:0,repeated:"sequence",implicit:!0})],km.prototype,"fullName",void 0),vb([ub({type:Tb,context:1,implicit:!0})],km.prototype,"nameRelativeToCRLIssuer",void 0),km=vb([cb({type:Pg.Choice})],km);class Sm{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}}vb([ub({type:km,context:0,optional:!0})],Sm.prototype,"distributionPoint",void 0),vb([ub({type:vm,context:1,optional:!0,implicit:!0})],Sm.prototype,"reasons",void 0),vb([ub({type:Kb,context:2,optional:!0,repeated:"sequence",implicit:!0})],Sm.prototype,"cRLIssuer",void 0);var Om,Am=gm=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,gm.prototype)}};Am=gm=vb([cb({type:Pg.Sequence,itemType:Sm})],Am);var Im,xm=Om=class extends Am{constructor(e){super(e),Object.setPrototypeOf(this,Om.prototype)}};xm=Om=vb([cb({type:Pg.Sequence,itemType:Sm})],xm);class Pm{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.onlyContainsUserCerts=Pm.ONLY,this.onlyContainsCACerts=Pm.ONLY,this.indirectCRL=Pm.ONLY,this.onlyContainsAttributeCerts=Pm.ONLY,Object.assign(this,e)}}Pm.ONLY=!1,vb([ub({type:km,context:0,optional:!0})],Pm.prototype,"distributionPoint",void 0),vb([ub({type:Eg.Boolean,context:1,defaultValue:Pm.ONLY,implicit:!0})],Pm.prototype,"onlyContainsUserCerts",void 0),vb([ub({type:Eg.Boolean,context:2,defaultValue:Pm.ONLY,implicit:!0})],Pm.prototype,"onlyContainsCACerts",void 0),vb([ub({type:vm,context:3,optional:!0,implicit:!0})],Pm.prototype,"onlySomeReasons",void 0),vb([ub({type:Eg.Boolean,context:4,defaultValue:Pm.ONLY,implicit:!0})],Pm.prototype,"indirectCRL",void 0),vb([ub({type:Eg.Boolean,context:5,defaultValue:Pm.ONLY,implicit:!0})],Pm.prototype,"onlyContainsAttributeCerts",void 0),function(e){e[e.unspecified=0]="unspecified",e[e.keyCompromise=1]="keyCompromise",e[e.cACompromise=2]="cACompromise",e[e.affiliationChanged=3]="affiliationChanged",e[e.superseded=4]="superseded",e[e.cessationOfOperation=5]="cessationOfOperation",e[e.certificateHold=6]="certificateHold",e[e.removeFromCRL=8]="removeFromCRL",e[e.privilegeWithdrawn=9]="privilegeWithdrawn",e[e.aACompromise=10]="aACompromise"}(Im||(Im={}));var Em,Cm=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Im.unspecified;this.reason=Im.unspecified,this.reason=e}toJSON(){return Im[this.reason]}toString(){return this.toJSON()}};vb([ub({type:Eg.Enumerated})],Cm.prototype,"reason",void 0),Cm=vb([cb({type:Pg.Choice})],Cm);var Bm="".concat(Wb,".37"),Tm=Em=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,Em.prototype)}};Tm=Em=vb([cb({type:Pg.Sequence,itemType:Eg.ObjectIdentifier})],Tm);var Dm="".concat(Mb,".1"),Rm="".concat(Mb,".2"),jm="".concat(Mb,".3"),Nm="".concat(Mb,".4"),Um="".concat(Mb,".8"),Km="".concat(Mb,".9"),qm=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ArrayBuffer(0);this.value=e}};vb([ub({type:Eg.Integer,converter:Ng})],qm.prototype,"value",void 0),qm=vb([cb({type:Pg.Choice})],qm);var Lm,_m=class{constructor(e){this.value=new Date,e&&(this.value=e)}};vb([ub({type:Eg.GeneralizedTime})],_m.prototype,"value",void 0),_m=vb([cb({type:Pg.Choice})],_m);var Mm=Lm=class extends om{constructor(e){super(e),Object.setPrototypeOf(this,Lm.prototype)}};Mm=Lm=vb([cb({type:Pg.Sequence})],Mm);var Fm,zm,Gm="".concat(Wb,".15");!function(e){e[e.digitalSignature=1]="digitalSignature",e[e.nonRepudiation=2]="nonRepudiation",e[e.keyEncipherment=4]="keyEncipherment",e[e.dataEncipherment=8]="dataEncipherment",e[e.keyAgreement=16]="keyAgreement",e[e.keyCertSign=32]="keyCertSign",e[e.cRLSign=64]="cRLSign",e[e.encipherOnly=128]="encipherOnly",e[e.decipherOnly=256]="decipherOnly"}(Fm||(Fm={}));class Vm extends Bg{toJSON(){var e=this.toNumber(),t=[];return e&Fm.cRLSign&&t.push("crlSign"),e&Fm.dataEncipherment&&t.push("dataEncipherment"),e&Fm.decipherOnly&&t.push("decipherOnly"),e&Fm.digitalSignature&&t.push("digitalSignature"),e&Fm.encipherOnly&&t.push("encipherOnly"),e&Fm.keyAgreement&&t.push("keyAgreement"),e&Fm.keyCertSign&&t.push("keyCertSign"),e&Fm.keyEncipherment&&t.push("keyEncipherment"),e&Fm.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return"[".concat(this.toJSON().join(", "),"]")}}class Hm{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.base=new Kb,this.minimum=0,Object.assign(this,e)}}vb([ub({type:Kb})],Hm.prototype,"base",void 0),vb([ub({type:Eg.Integer,context:0,defaultValue:0,implicit:!0})],Hm.prototype,"minimum",void 0),vb([ub({type:Eg.Integer,context:1,optional:!0,implicit:!0})],Hm.prototype,"maximum",void 0);var Wm,Jm=zm=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,zm.prototype)}};Jm=zm=vb([cb({type:Pg.Sequence,itemType:Hm})],Jm);class $m{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}}vb([ub({type:Jm,context:0,optional:!0,implicit:!0})],$m.prototype,"permittedSubtrees",void 0),vb([ub({type:Jm,context:1,optional:!0,implicit:!0})],$m.prototype,"excludedSubtrees",void 0);class Ym{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}}vb([ub({type:Eg.Integer,context:0,implicit:!0,optional:!0,converter:Ng})],Ym.prototype,"requireExplicitPolicy",void 0),vb([ub({type:Eg.Integer,context:1,implicit:!0,optional:!0,converter:Ng})],Ym.prototype,"inhibitPolicyMapping",void 0);class Zm{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],Zm.prototype,"issuerDomainPolicy",void 0),vb([ub({type:Eg.ObjectIdentifier})],Zm.prototype,"subjectDomainPolicy",void 0);var Qm,Xm=Wm=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,Wm.prototype)}};Xm=Wm=vb([cb({type:Pg.Sequence,itemType:Zm})],Xm);var ew="".concat(Wb,".17"),tw=Qm=class extends om{constructor(e){super(e),Object.setPrototypeOf(this,Qm.prototype)}};tw=Qm=vb([cb({type:Pg.Sequence})],tw);let rw=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.type="",this.values=[],Object.assign(this,e)}};var nw;vb([ub({type:Eg.ObjectIdentifier})],rw.prototype,"type",void 0),vb([ub({type:Eg.Any,repeated:"set"})],rw.prototype,"values",void 0);var ow=nw=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,nw.prototype)}};ow=nw=vb([cb({type:Pg.Sequence,itemType:rw})],ow);var iw,sw,aw="".concat(Wb,".14");class cw extends Qb{}class uw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}}vb([ub({type:Eg.GeneralizedTime,context:0,implicit:!0,optional:!0})],uw.prototype,"notBefore",void 0),vb([ub({type:Eg.GeneralizedTime,context:1,implicit:!0,optional:!0})],uw.prototype,"notAfter",void 0),function(e){e[e.keyUpdateAllowed=1]="keyUpdateAllowed",e[e.newExtensions=2]="newExtensions",e[e.pKIXCertificate=4]="pKIXCertificate"}(iw||(iw={}));class lw extends Bg{toJSON(){var e=[],t=this.toNumber();return t&iw.pKIXCertificate&&e.push("pKIXCertificate"),t&iw.newExtensions&&e.push("newExtensions"),t&iw.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return"[".concat(this.toJSON().join(", "),"]")}}class dw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.entrustVers="",this.entrustInfoFlags=new lw,Object.assign(this,e)}}vb([ub({type:Eg.GeneralString})],dw.prototype,"entrustVers",void 0),vb([ub({type:lw})],dw.prototype,"entrustInfoFlags",void 0);var hw=sw=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,sw.prototype)}};hw=sw=vb([cb({type:Pg.Sequence,itemType:$b})],hw);class pw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof pw&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Yp.isEqual(e.parameters,this.parameters)||e.parameters===this.parameters)}}vb([ub({type:Eg.ObjectIdentifier})],pw.prototype,"algorithm",void 0),vb([ub({type:Eg.Any,optional:!0})],pw.prototype,"parameters",void 0);class yw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.algorithm=new pw,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:pw})],yw.prototype,"algorithm",void 0),vb([ub({type:Eg.BitString})],yw.prototype,"subjectPublicKey",void 0);var fw,gw=class{constructor(e){if(e)if("string"==typeof e||"number"==typeof e||e instanceof Date){var t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){var e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};vb([ub({type:Eg.UTCTime})],gw.prototype,"utcTime",void 0),vb([ub({type:Eg.GeneralizedTime})],gw.prototype,"generalTime",void 0),gw=vb([cb({type:Pg.Choice})],gw);class bw{constructor(e){this.notBefore=new gw(new Date),this.notAfter=new gw(new Date),e&&(this.notBefore=new gw(e.notBefore),this.notAfter=new gw(e.notAfter))}}vb([ub({type:gw})],bw.prototype,"notBefore",void 0),vb([ub({type:gw})],bw.prototype,"notAfter",void 0);let mw=class e{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.extnID="",this.critical=e.CRITICAL,this.extnValue=new Tg,Object.assign(this,t)}};mw.CRITICAL=!1,vb([ub({type:Eg.ObjectIdentifier})],mw.prototype,"extnID",void 0),vb([ub({type:Eg.Boolean,defaultValue:mw.CRITICAL})],mw.prototype,"critical",void 0),vb([ub({type:Tg})],mw.prototype,"extnValue",void 0);var ww,vw=fw=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,fw.prototype)}};vw=fw=vb([cb({type:Pg.Sequence,itemType:mw})],vw),function(e){e[e.v1=0]="v1",e[e.v2=1]="v2",e[e.v3=2]="v3"}(ww||(ww={}));class kw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=ww.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new pw,this.issuer=new Rb,this.validity=new bw,this.subject=new Rb,this.subjectPublicKeyInfo=new yw,Object.assign(this,e)}}vb([ub({type:Eg.Integer,context:0,defaultValue:ww.v1})],kw.prototype,"version",void 0),vb([ub({type:Eg.Integer,converter:Ng})],kw.prototype,"serialNumber",void 0),vb([ub({type:pw})],kw.prototype,"signature",void 0),vb([ub({type:Rb})],kw.prototype,"issuer",void 0),vb([ub({type:bw})],kw.prototype,"validity",void 0),vb([ub({type:Rb})],kw.prototype,"subject",void 0),vb([ub({type:yw})],kw.prototype,"subjectPublicKeyInfo",void 0),vb([ub({type:Eg.BitString,context:1,implicit:!0,optional:!0})],kw.prototype,"issuerUniqueID",void 0),vb([ub({type:Eg.BitString,context:2,implicit:!0,optional:!0})],kw.prototype,"subjectUniqueID",void 0),vb([ub({type:vw,context:3,optional:!0})],kw.prototype,"extensions",void 0);class Sw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.tbsCertificate=new kw,this.signatureAlgorithm=new pw,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:kw})],Sw.prototype,"tbsCertificate",void 0),vb([ub({type:pw})],Sw.prototype,"signatureAlgorithm",void 0),vb([ub({type:Eg.BitString})],Sw.prototype,"signatureValue",void 0);class Ow{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.userCertificate=new ArrayBuffer(0),this.revocationDate=new gw,Object.assign(this,e)}}vb([ub({type:Eg.Integer,converter:Ng})],Ow.prototype,"userCertificate",void 0),vb([ub({type:gw})],Ow.prototype,"revocationDate",void 0),vb([ub({type:mw,optional:!0,repeated:"sequence"})],Ow.prototype,"crlEntryExtensions",void 0);class Aw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.signature=new pw,this.issuer=new Rb,this.thisUpdate=new gw,Object.assign(this,e)}}vb([ub({type:Eg.Integer,optional:!0})],Aw.prototype,"version",void 0),vb([ub({type:pw})],Aw.prototype,"signature",void 0),vb([ub({type:Rb})],Aw.prototype,"issuer",void 0),vb([ub({type:gw})],Aw.prototype,"thisUpdate",void 0),vb([ub({type:gw,optional:!0})],Aw.prototype,"nextUpdate",void 0),vb([ub({type:Ow,repeated:"sequence",optional:!0})],Aw.prototype,"revokedCertificates",void 0),vb([ub({type:mw,optional:!0,context:0,repeated:"sequence"})],Aw.prototype,"crlExtensions",void 0);class Iw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.tbsCertList=new Aw,this.signatureAlgorithm=new pw,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Aw})],Iw.prototype,"tbsCertList",void 0),vb([ub({type:pw})],Iw.prototype,"signatureAlgorithm",void 0),vb([ub({type:Eg.BitString})],Iw.prototype,"signature",void 0);class xw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.issuer=new Rb,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Rb})],xw.prototype,"issuer",void 0),vb([ub({type:Eg.Integer,converter:Ng})],xw.prototype,"serialNumber",void 0);var Pw,Ew=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:cw,context:0,implicit:!0})],Ew.prototype,"subjectKeyIdentifier",void 0),vb([ub({type:xw})],Ew.prototype,"issuerAndSerialNumber",void 0),Ew=vb([cb({type:Pg.Choice})],Ew),function(e){e[e.v0=0]="v0",e[e.v1=1]="v1",e[e.v2=2]="v2",e[e.v3=3]="v3",e[e.v4=4]="v4",e[e.v5=5]="v5"}(Pw||(Pw={}));var Cw=class extends pw{};Cw=vb([cb({type:Pg.Sequence})],Cw);var Bw=class extends pw{};Bw=vb([cb({type:Pg.Sequence})],Bw);var Tw=class extends pw{};Tw=vb([cb({type:Pg.Sequence})],Tw);var Dw=class extends pw{};Dw=vb([cb({type:Pg.Sequence})],Dw);var Rw=class extends pw{};Rw=vb([cb({type:Pg.Sequence})],Rw);var jw=class extends pw{};jw=vb([cb({type:Pg.Sequence})],jw);let Nw=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.attrType="",this.attrValues=[],Object.assign(this,e)}};var Uw;vb([ub({type:Eg.ObjectIdentifier})],Nw.prototype,"attrType",void 0),vb([ub({type:Eg.Any,repeated:"set"})],Nw.prototype,"attrValues",void 0);class Kw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=Pw.v0,this.sid=new Ew,this.digestAlgorithm=new Cw,this.signatureAlgorithm=new Bw,this.signature=new Tg,Object.assign(this,e)}}vb([ub({type:Eg.Integer})],Kw.prototype,"version",void 0),vb([ub({type:Ew})],Kw.prototype,"sid",void 0),vb([ub({type:Cw})],Kw.prototype,"digestAlgorithm",void 0),vb([ub({type:Nw,repeated:"set",context:0,implicit:!0,optional:!0})],Kw.prototype,"signedAttrs",void 0),vb([ub({type:Bw})],Kw.prototype,"signatureAlgorithm",void 0),vb([ub({type:Tg})],Kw.prototype,"signature",void 0),vb([ub({type:Nw,repeated:"set",context:1,implicit:!0,optional:!0})],Kw.prototype,"unsignedAttrs",void 0);var qw=Uw=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,Uw.prototype)}};qw=Uw=vb([cb({type:Pg.Set,itemType:Kw})],qw);var Lw=class extends gw{};Lw=vb([cb({type:Pg.Choice})],Lw);var _w,Mw=class extends Kw{};Mw=vb([cb({type:Pg.Sequence})],Mw);class Fw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.acIssuer=new Kb,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}vb([ub({type:Kb})],Fw.prototype,"acIssuer",void 0),vb([ub({type:Eg.Integer})],Fw.prototype,"acSerial",void 0),vb([ub({type:rw,repeated:"sequence"})],Fw.prototype,"attrs",void 0);var zw,Gw=_w=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,_w.prototype)}};Gw=_w=vb([cb({type:Pg.Sequence,itemType:Eg.ObjectIdentifier})],Gw);class Vw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.permitUnSpecified=!0,Object.assign(this,e)}}vb([ub({type:Eg.Integer,optional:!0})],Vw.prototype,"pathLenConstraint",void 0),vb([ub({type:Gw,implicit:!0,context:0,optional:!0})],Vw.prototype,"permittedAttrs",void 0),vb([ub({type:Gw,implicit:!0,context:1,optional:!0})],Vw.prototype,"excludedAttrs",void 0),vb([ub({type:Eg.Boolean,defaultValue:!0})],Vw.prototype,"permitUnSpecified",void 0);class Hw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.issuer=new om,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:om})],Hw.prototype,"issuer",void 0),vb([ub({type:Eg.Integer,converter:Ng})],Hw.prototype,"serial",void 0),vb([ub({type:Eg.BitString,optional:!0})],Hw.prototype,"issuerUID",void 0),function(e){e[e.publicKey=0]="publicKey",e[e.publicKeyCert=1]="publicKeyCert",e[e.otherObjectTypes=2]="otherObjectTypes"}(zw||(zw={}));class Ww{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.digestedObjectType=zw.publicKey,this.digestAlgorithm=new pw,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.Enumerated})],Ww.prototype,"digestedObjectType",void 0),vb([ub({type:Eg.ObjectIdentifier,optional:!0})],Ww.prototype,"otherObjectTypeID",void 0),vb([ub({type:pw})],Ww.prototype,"digestAlgorithm",void 0),vb([ub({type:Eg.BitString})],Ww.prototype,"objectDigest",void 0);class Jw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}}vb([ub({type:om,optional:!0})],Jw.prototype,"issuerName",void 0),vb([ub({type:Hw,context:0,implicit:!0,optional:!0})],Jw.prototype,"baseCertificateID",void 0),vb([ub({type:Ww,context:1,implicit:!0,optional:!0})],Jw.prototype,"objectDigestInfo",void 0);var $w,Yw,Zw,Qw=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:Kb,repeated:"sequence"})],Qw.prototype,"v1Form",void 0),vb([ub({type:Jw,context:0,implicit:!0})],Qw.prototype,"v2Form",void 0),Qw=vb([cb({type:Pg.Choice})],Qw);class Xw{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}vb([ub({type:Eg.GeneralizedTime})],Xw.prototype,"notBeforeTime",void 0),vb([ub({type:Eg.GeneralizedTime})],Xw.prototype,"notAfterTime",void 0);class ev{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}}vb([ub({type:Hw,implicit:!0,context:0,optional:!0})],ev.prototype,"baseCertificateID",void 0),vb([ub({type:om,implicit:!0,context:1,optional:!0})],ev.prototype,"entityName",void 0),vb([ub({type:Ww,implicit:!0,context:2,optional:!0})],ev.prototype,"objectDigestInfo",void 0),function(e){e[e.v2=1]="v2"}($w||($w={}));class tv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=$w.v2,this.holder=new ev,this.issuer=new Qw,this.signature=new pw,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Xw,this.attributes=[],Object.assign(this,e)}}vb([ub({type:Eg.Integer})],tv.prototype,"version",void 0),vb([ub({type:ev})],tv.prototype,"holder",void 0),vb([ub({type:Qw})],tv.prototype,"issuer",void 0),vb([ub({type:pw})],tv.prototype,"signature",void 0),vb([ub({type:Eg.Integer,converter:Ng})],tv.prototype,"serialNumber",void 0),vb([ub({type:Xw})],tv.prototype,"attrCertValidityPeriod",void 0),vb([ub({type:rw,repeated:"sequence"})],tv.prototype,"attributes",void 0),vb([ub({type:Eg.BitString,optional:!0})],tv.prototype,"issuerUniqueID",void 0),vb([ub({type:vw,optional:!0})],tv.prototype,"extensions",void 0);class rv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.acinfo=new tv,this.signatureAlgorithm=new pw,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:tv})],rv.prototype,"acinfo",void 0),vb([ub({type:pw})],rv.prototype,"signatureAlgorithm",void 0),vb([ub({type:Eg.BitString})],rv.prototype,"signatureValue",void 0),function(e){e[e.unmarked=1]="unmarked",e[e.unclassified=2]="unclassified",e[e.restricted=4]="restricted",e[e.confidential=8]="confidential",e[e.secret=16]="secret",e[e.topSecret=32]="topSecret"}(Yw||(Yw={}));class nv extends Bg{}class ov{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier,implicit:!0,context:0})],ov.prototype,"type",void 0),vb([ub({type:Eg.Any,implicit:!0,context:1})],ov.prototype,"value",void 0);class iv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.policyId="",this.classList=new nv(Yw.unclassified),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],iv.prototype,"policyId",void 0),vb([ub({type:nv,defaultValue:new nv(Yw.unclassified)})],iv.prototype,"classList",void 0),vb([ub({type:ov,repeated:"set"})],iv.prototype,"securityCategories",void 0);class sv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}}vb([ub({type:Tg})],sv.prototype,"cotets",void 0),vb([ub({type:Eg.ObjectIdentifier})],sv.prototype,"oid",void 0),vb([ub({type:Eg.Utf8String})],sv.prototype,"string",void 0);class av{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.values=[],Object.assign(this,e)}}vb([ub({type:om,implicit:!0,context:0,optional:!0})],av.prototype,"policyAuthority",void 0),vb([ub({type:sv,repeated:"sequence"})],av.prototype,"values",void 0);class cv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.targetCertificate=new Hw,Object.assign(this,e)}}vb([ub({type:Hw})],cv.prototype,"targetCertificate",void 0),vb([ub({type:Kb,optional:!0})],cv.prototype,"targetName",void 0),vb([ub({type:Ww,optional:!0})],cv.prototype,"certDigestInfo",void 0);var uv=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:Kb,context:0,implicit:!0})],uv.prototype,"targetName",void 0),vb([ub({type:Kb,context:1,implicit:!0})],uv.prototype,"targetGroup",void 0),vb([ub({type:cv,context:2,implicit:!0})],uv.prototype,"targetCert",void 0),uv=vb([cb({type:Pg.Choice})],uv);var lv,dv=Zw=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,Zw.prototype)}};dv=Zw=vb([cb({type:Pg.Sequence,itemType:uv})],dv);var hv,pv=lv=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,lv.prototype)}};pv=lv=vb([cb({type:Pg.Sequence,itemType:dv})],pv);class yv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}}vb([ub({type:om,implicit:!0,context:0,optional:!0})],yv.prototype,"roleAuthority",void 0),vb([ub({type:Kb,implicit:!0,context:1})],yv.prototype,"roleName",void 0);class fv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.service=new Kb,this.ident=new Kb,Object.assign(this,e)}}vb([ub({type:Kb})],fv.prototype,"service",void 0),vb([ub({type:Kb})],fv.prototype,"ident",void 0),vb([ub({type:Tg,optional:!0})],fv.prototype,"authInfo",void 0);class gv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],gv.prototype,"otherCertFormat",void 0),vb([ub({type:Eg.Any})],gv.prototype,"otherCert",void 0);var bv=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:Sw})],bv.prototype,"certificate",void 0),vb([ub({type:rv,context:2,implicit:!0})],bv.prototype,"v2AttrCert",void 0),vb([ub({type:gv,context:3,implicit:!0})],bv.prototype,"other",void 0),bv=vb([cb({type:Pg.Choice})],bv);var mv=hv=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,hv.prototype)}};mv=hv=vb([cb({type:Pg.Set,itemType:bv})],mv);class wv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],wv.prototype,"contentType",void 0),vb([ub({type:Eg.Any,context:0})],wv.prototype,"content",void 0);var vv=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:Tg})],vv.prototype,"single",void 0),vb([ub({type:Eg.Any})],vv.prototype,"any",void 0),vv=vb([cb({type:Pg.Choice})],vv);class kv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.eContentType="",Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],kv.prototype,"eContentType",void 0),vb([ub({type:vv,context:0,optional:!0})],kv.prototype,"eContent",void 0);var Sv,Ov=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:Tg,context:0,implicit:!0,optional:!0})],Ov.prototype,"value",void 0),vb([ub({type:Tg,converter:_g,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Ov.prototype,"constructedValue",void 0),Ov=vb([cb({type:Pg.Choice})],Ov);class Av{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.contentType="",this.contentEncryptionAlgorithm=new Dw,Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],Av.prototype,"contentType",void 0),vb([ub({type:Dw})],Av.prototype,"contentEncryptionAlgorithm",void 0),vb([ub({type:Ov,optional:!0})],Av.prototype,"encryptedContent",void 0);class Iv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.keyAttrId="",Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],Iv.prototype,"keyAttrId",void 0),vb([ub({type:Eg.Any,optional:!0})],Iv.prototype,"keyAttr",void 0);class xv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.subjectKeyIdentifier=new cw,Object.assign(this,e)}}vb([ub({type:cw})],xv.prototype,"subjectKeyIdentifier",void 0),vb([ub({type:Eg.GeneralizedTime,optional:!0})],xv.prototype,"date",void 0),vb([ub({type:Iv,optional:!0})],xv.prototype,"other",void 0);var Pv=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:xv,context:0,implicit:!0,optional:!0})],Pv.prototype,"rKeyId",void 0),vb([ub({type:xw,optional:!0})],Pv.prototype,"issuerAndSerialNumber",void 0),Pv=vb([cb({type:Pg.Choice})],Pv);class Ev{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.rid=new Pv,this.encryptedKey=new Tg,Object.assign(this,e)}}vb([ub({type:Pv})],Ev.prototype,"rid",void 0),vb([ub({type:Tg})],Ev.prototype,"encryptedKey",void 0);var Cv=Sv=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,Sv.prototype)}};Cv=Sv=vb([cb({type:Pg.Sequence,itemType:Ev})],Cv);class Bv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.algorithm=new pw,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:pw})],Bv.prototype,"algorithm",void 0),vb([ub({type:Eg.BitString})],Bv.prototype,"publicKey",void 0);var Tv=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:cw,context:0,implicit:!0,optional:!0})],Tv.prototype,"subjectKeyIdentifier",void 0),vb([ub({type:Bv,context:1,implicit:!0,optional:!0})],Tv.prototype,"originatorKey",void 0),vb([ub({type:xw,optional:!0})],Tv.prototype,"issuerAndSerialNumber",void 0),Tv=vb([cb({type:Pg.Choice})],Tv);class Dv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=Pw.v3,this.originator=new Tv,this.keyEncryptionAlgorithm=new Tw,this.recipientEncryptedKeys=new Cv,Object.assign(this,e)}}vb([ub({type:Eg.Integer})],Dv.prototype,"version",void 0),vb([ub({type:Tv,context:0})],Dv.prototype,"originator",void 0),vb([ub({type:Tg,context:1,optional:!0})],Dv.prototype,"ukm",void 0),vb([ub({type:Tw})],Dv.prototype,"keyEncryptionAlgorithm",void 0),vb([ub({type:Cv})],Dv.prototype,"recipientEncryptedKeys",void 0);var Rv=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:cw,context:0,implicit:!0})],Rv.prototype,"subjectKeyIdentifier",void 0),vb([ub({type:xw})],Rv.prototype,"issuerAndSerialNumber",void 0),Rv=vb([cb({type:Pg.Choice})],Rv);class jv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=Pw.v0,this.rid=new Rv,this.keyEncryptionAlgorithm=new Tw,this.encryptedKey=new Tg,Object.assign(this,e)}}vb([ub({type:Eg.Integer})],jv.prototype,"version",void 0),vb([ub({type:Rv})],jv.prototype,"rid",void 0),vb([ub({type:Tw})],jv.prototype,"keyEncryptionAlgorithm",void 0),vb([ub({type:Tg})],jv.prototype,"encryptedKey",void 0);class Nv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.keyIdentifier=new Tg,Object.assign(this,e)}}vb([ub({type:Tg})],Nv.prototype,"keyIdentifier",void 0),vb([ub({type:Eg.GeneralizedTime,optional:!0})],Nv.prototype,"date",void 0),vb([ub({type:Iv,optional:!0})],Nv.prototype,"other",void 0);class Uv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=Pw.v4,this.kekid=new Nv,this.keyEncryptionAlgorithm=new Tw,this.encryptedKey=new Tg,Object.assign(this,e)}}vb([ub({type:Eg.Integer})],Uv.prototype,"version",void 0),vb([ub({type:Nv})],Uv.prototype,"kekid",void 0),vb([ub({type:Tw})],Uv.prototype,"keyEncryptionAlgorithm",void 0),vb([ub({type:Tg})],Uv.prototype,"encryptedKey",void 0);class Kv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=Pw.v0,this.keyEncryptionAlgorithm=new Tw,this.encryptedKey=new Tg,Object.assign(this,e)}}vb([ub({type:Eg.Integer})],Kv.prototype,"version",void 0),vb([ub({type:jw,context:0,optional:!0})],Kv.prototype,"keyDerivationAlgorithm",void 0),vb([ub({type:Tw})],Kv.prototype,"keyEncryptionAlgorithm",void 0),vb([ub({type:Tg})],Kv.prototype,"encryptedKey",void 0);class qv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],qv.prototype,"oriType",void 0),vb([ub({type:Eg.Any})],qv.prototype,"oriValue",void 0);var Lv,_v=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:jv,optional:!0})],_v.prototype,"ktri",void 0),vb([ub({type:Dv,context:1,implicit:!0,optional:!0})],_v.prototype,"kari",void 0),vb([ub({type:Uv,context:2,implicit:!0,optional:!0})],_v.prototype,"kekri",void 0),vb([ub({type:Kv,context:3,implicit:!0,optional:!0})],_v.prototype,"pwri",void 0),vb([ub({type:qv,context:4,implicit:!0,optional:!0})],_v.prototype,"ori",void 0),_v=vb([cb({type:Pg.Choice})],_v);var Mv,Fv=Lv=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,Lv.prototype)}};Fv=Lv=vb([cb({type:Pg.Set,itemType:_v})],Fv);class zv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],zv.prototype,"otherRevInfoFormat",void 0),vb([ub({type:Eg.Any})],zv.prototype,"otherRevInfo",void 0);var Gv=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.other=new zv,Object.assign(this,e)}};vb([ub({type:zv,context:1,implicit:!0})],Gv.prototype,"other",void 0),Gv=vb([cb({type:Pg.Choice})],Gv);var Vv,Hv=Mv=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,Mv.prototype)}};Hv=Mv=vb([cb({type:Pg.Set,itemType:Gv})],Hv);class Wv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}}vb([ub({type:mv,context:0,implicit:!0,optional:!0})],Wv.prototype,"certs",void 0),vb([ub({type:Hv,context:1,implicit:!0,optional:!0})],Wv.prototype,"crls",void 0);var Jv=Vv=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,Vv.prototype)}};Jv=Vv=vb([cb({type:Pg.Set,itemType:Nw})],Jv);class $v{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=Pw.v0,this.recipientInfos=new Fv,this.encryptedContentInfo=new Av,Object.assign(this,e)}}vb([ub({type:Eg.Integer})],$v.prototype,"version",void 0),vb([ub({type:Wv,context:0,implicit:!0,optional:!0})],$v.prototype,"originatorInfo",void 0),vb([ub({type:Fv})],$v.prototype,"recipientInfos",void 0),vb([ub({type:Av})],$v.prototype,"encryptedContentInfo",void 0),vb([ub({type:Jv,context:1,implicit:!0,optional:!0})],$v.prototype,"unprotectedAttrs",void 0);var Yv,Zv="1.2.840.113549.1.7.2",Qv=Yv=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,Yv.prototype)}};Qv=Yv=vb([cb({type:Pg.Set,itemType:Cw})],Qv);class Xv{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=Pw.v0,this.digestAlgorithms=new Qv,this.encapContentInfo=new kv,this.signerInfos=new qw,Object.assign(this,e)}}vb([ub({type:Eg.Integer})],Xv.prototype,"version",void 0),vb([ub({type:Qv})],Xv.prototype,"digestAlgorithms",void 0),vb([ub({type:kv})],Xv.prototype,"encapContentInfo",void 0),vb([ub({type:mv,context:0,implicit:!0,optional:!0})],Xv.prototype,"certificates",void 0),vb([ub({type:Hv,context:1,implicit:!0,optional:!0})],Xv.prototype,"crls",void 0),vb([ub({type:qw})],Xv.prototype,"signerInfos",void 0);var ek="1.2.840.10045.2.1",tk="1.2.840.10045.4.1",rk="1.2.840.10045.4.3.1",nk="1.2.840.10045.4.3.2",ok="1.2.840.10045.4.3.3",ik="1.2.840.10045.4.3.4",sk="1.2.840.10045.3.1.7",ak="1.3.132.0.34",ck="1.3.132.0.35";function uk(e){return new pw({algorithm:e})}var lk=uk(tk);uk(rk);var dk=uk(nk),hk=uk(ok),pk=uk(ik),yk=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:Eg.ObjectIdentifier})],yk.prototype,"fieldType",void 0),vb([ub({type:Eg.Any})],yk.prototype,"parameters",void 0),yk=vb([cb({type:Pg.Sequence})],yk);var fk,gk=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:Eg.OctetString})],gk.prototype,"a",void 0),vb([ub({type:Eg.OctetString})],gk.prototype,"b",void 0),vb([ub({type:Eg.BitString,optional:!0})],gk.prototype,"seed",void 0),gk=vb([cb({type:Pg.Sequence})],gk),function(e){e[e.ecpVer1=1]="ecpVer1"}(fk||(fk={}));var bk=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=fk.ecpVer1,Object.assign(this,e)}};vb([ub({type:Eg.Integer})],bk.prototype,"version",void 0),vb([ub({type:yk})],bk.prototype,"fieldID",void 0),vb([ub({type:gk})],bk.prototype,"curve",void 0),vb([ub({type:class extends Tg{}})],bk.prototype,"base",void 0),vb([ub({type:Eg.Integer,converter:Ng})],bk.prototype,"order",void 0),vb([ub({type:Eg.Integer,optional:!0})],bk.prototype,"cofactor",void 0),bk=vb([cb({type:Pg.Sequence})],bk);var mk=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,e)}};vb([ub({type:Eg.ObjectIdentifier})],mk.prototype,"namedCurve",void 0),vb([ub({type:Eg.Null})],mk.prototype,"implicitCurve",void 0),vb([ub({type:bk})],mk.prototype,"specifiedCurve",void 0),mk=vb([cb({type:Pg.Choice})],mk);class wk{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=1,this.privateKey=new Tg,Object.assign(this,e)}}vb([ub({type:Eg.Integer})],wk.prototype,"version",void 0),vb([ub({type:Tg})],wk.prototype,"privateKey",void 0),vb([ub({type:mk,context:0,optional:!0})],wk.prototype,"parameters",void 0),vb([ub({type:Eg.BitString,context:1,optional:!0})],wk.prototype,"publicKey",void 0);class vk{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.Integer,converter:Ng})],vk.prototype,"r",void 0),vb([ub({type:Eg.Integer,converter:Ng})],vk.prototype,"s",void 0);var kk="1.2.840.113549.1.1",Sk="".concat(kk,".1"),Ok="".concat(kk,".7"),Ak="".concat(kk,".9"),Ik="".concat(kk,".10"),xk="".concat(kk,".2"),Pk="".concat(kk,".4"),Ek="".concat(kk,".5"),Ck="".concat(kk,".14"),Bk="".concat(kk,".11"),Tk="".concat(kk,".12"),Dk="".concat(kk,".13"),Rk="".concat(kk,".15"),jk="".concat(kk,".16"),Nk="1.3.14.3.2.26",Uk="2.16.840.1.101.3.4.2.4",Kk="2.16.840.1.101.3.4.2.1",qk="2.16.840.1.101.3.4.2.2",Lk="2.16.840.1.101.3.4.2.3",_k="".concat(kk,".8");function Mk(e){return new pw({algorithm:e,parameters:null})}Mk("1.2.840.113549.2.2"),Mk("1.2.840.113549.2.5");var Fk=Mk(Nk);Mk(Uk),Mk(Kk),Mk(qk),Mk(Lk),Mk("2.16.840.1.101.3.4.2.5"),Mk("2.16.840.1.101.3.4.2.6");var zk,Gk=new pw({algorithm:_k,parameters:yb.serialize(Fk)}),Vk=new pw({algorithm:Ak,parameters:yb.serialize(Lg.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Mk(Sk),Mk(xk),Mk(Pk),Mk(Ek),Mk(Rk),Mk(jk),Mk(Tk),Mk(Dk),Mk(Rk),Mk(jk);class Hk{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.hashAlgorithm=new pw(Fk),this.maskGenAlgorithm=new pw({algorithm:_k,parameters:yb.serialize(Fk)}),this.pSourceAlgorithm=new pw(Vk),Object.assign(this,e)}}vb([ub({type:pw,context:0,defaultValue:Fk})],Hk.prototype,"hashAlgorithm",void 0),vb([ub({type:pw,context:1,defaultValue:Gk})],Hk.prototype,"maskGenAlgorithm",void 0),vb([ub({type:pw,context:2,defaultValue:Vk})],Hk.prototype,"pSourceAlgorithm",void 0),new pw({algorithm:Ok,parameters:yb.serialize(new Hk)});class Wk{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.hashAlgorithm=new pw(Fk),this.maskGenAlgorithm=new pw({algorithm:_k,parameters:yb.serialize(Fk)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}vb([ub({type:pw,context:0,defaultValue:Fk})],Wk.prototype,"hashAlgorithm",void 0),vb([ub({type:pw,context:1,defaultValue:Gk})],Wk.prototype,"maskGenAlgorithm",void 0),vb([ub({type:Eg.Integer,context:2,defaultValue:20})],Wk.prototype,"saltLength",void 0),vb([ub({type:Eg.Integer,context:3,defaultValue:1})],Wk.prototype,"trailerField",void 0),new pw({algorithm:Ik,parameters:yb.serialize(new Wk)});class Jk{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.digestAlgorithm=new pw,this.digest=new Tg,Object.assign(this,e)}}vb([ub({type:pw})],Jk.prototype,"digestAlgorithm",void 0),vb([ub({type:Tg})],Jk.prototype,"digest",void 0);class $k{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.Integer,converter:Ng})],$k.prototype,"prime",void 0),vb([ub({type:Eg.Integer,converter:Ng})],$k.prototype,"exponent",void 0),vb([ub({type:Eg.Integer,converter:Ng})],$k.prototype,"coefficient",void 0);var Yk,Zk=zk=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,zk.prototype)}};Zk=zk=vb([cb({type:Pg.Sequence,itemType:$k})],Zk);class Qk{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.Integer})],Qk.prototype,"version",void 0),vb([ub({type:Eg.Integer,converter:Ng})],Qk.prototype,"modulus",void 0),vb([ub({type:Eg.Integer,converter:Ng})],Qk.prototype,"publicExponent",void 0),vb([ub({type:Eg.Integer,converter:Ng})],Qk.prototype,"privateExponent",void 0),vb([ub({type:Eg.Integer,converter:Ng})],Qk.prototype,"prime1",void 0),vb([ub({type:Eg.Integer,converter:Ng})],Qk.prototype,"prime2",void 0),vb([ub({type:Eg.Integer,converter:Ng})],Qk.prototype,"exponent1",void 0),vb([ub({type:Eg.Integer,converter:Ng})],Qk.prototype,"exponent2",void 0),vb([ub({type:Eg.Integer,converter:Ng})],Qk.prototype,"coefficient",void 0),vb([ub({type:Zk,optional:!0})],Qk.prototype,"otherPrimeInfos",void 0);class Xk{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.Integer,converter:Ng})],Xk.prototype,"modulus",void 0),vb([ub({type:Eg.Integer,converter:Ng})],Xk.prototype,"publicExponent",void 0),function(e){e[e.Transient=0]="Transient",e[e.Singleton=1]="Singleton",e[e.ResolutionScoped=2]="ResolutionScoped",e[e.ContainerScoped=3]="ContainerScoped"}(Yk||(Yk={}));var eS=Yk;function tS(e){return!!e.useClass}function rS(e){return!!e.useFactory}var nS=function(){function e(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return e.prototype.createProxy=function(e){var t,r=this,n=!1;return new Proxy({},this.createHandler((function(){return n||(t=e(r.wrap()),n=!0),t})))},e.prototype.createHandler=function(e){var t={};return this.reflectMethods.forEach((function(r){t[r]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t[0]=e(),Reflect[r].apply(void 0,Ib(t))}})),t},e}();function oS(e){return"string"==typeof e||"symbol"==typeof e}function iS(e){return"object"==typeof e&&"token"in e&&"transform"in e}function sS(e){return!!e.useToken}function aS(e){return null!=e.useValue}var cS=function(){function e(){this._registryMap=new Map}return e.prototype.entries=function(){return this._registryMap.entries()},e.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},e.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},e.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},e.prototype.setAll=function(e,t){this._registryMap.set(e,t)},e.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},e.prototype.clear=function(){this._registryMap.clear()},e.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},e}(),uS=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return wb(t,e),t}(cS),lS=function(){this.scopedResolutions=new Map};function dS(e,t,r){var n,o,i=Ab(e.toString().match(/constructor\(([\w, ]+)\)/)||[],2)[1],s=function(e,t){return null===e?"at position #"+t:'"'+e.split(",")[t].trim()+'" at position #'+t}(void 0===i?null:i,t);return n="Cannot inject the dependency "+s+' of "'+e.name+'" constructor. Reason:',void 0===o&&(o=" "),Ib([n],r.message.split("\n").map((function(e){return o+e}))).join("\n")}var hS,pS=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return wb(t,e),t}(cS),yS=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return wb(t,e),t}(cS),fS=function(){this.preResolution=new pS,this.postResolution=new yS},gS=new Map,bS=function(){function e(e){this.parent=e,this._registry=new uS,this.interceptors=new fS,this.disposed=!1,this.disposables=new Set}return e.prototype.register=function(e,t,r){var n;if(void 0===r&&(r={lifecycle:eS.Transient}),this.ensureNotDisposed(),n=function(e){return tS(e)||aS(e)||sS(e)||rS(e)}(t)?t:{useClass:t},sS(n))for(var o=[e],i=n;null!=i;){var s=i.useToken;if(o.includes(s))throw new Error("Token registration cycle detected! "+Ib(o,[s]).join(" -> "));o.push(s);var a=this._registry.get(s);i=a&&sS(a.provider)?a.provider:null}if((r.lifecycle===eS.Singleton||r.lifecycle==eS.ContainerScoped||r.lifecycle==eS.ResolutionScoped)&&(aS(n)||rS(n)))throw new Error('Cannot use lifecycle "'+eS[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:n,options:r}),this},e.prototype.registerType=function(e,t){return this.ensureNotDisposed(),oS(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},e.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},e.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),oS(e)){if(oS(t))return this.register(e,{useToken:t},{lifecycle:eS.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:eS.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return t&&!oS(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:eS.Singleton})},e.prototype.resolve=function(e,t,r){void 0===t&&(t=new lS),void 0===r&&(r=!1),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&oS(e)){if(r)return;throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"Single"),n){var o=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,o,"Single"),o}if(function(e){return"function"==typeof e||e instanceof nS}(e)){o=this.construct(e,t);return this.executePostResolutionInterceptor(e,o,"Single"),o}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},e.prototype.executePreResolutionInterceptor=function(e,t){var r,n;if(this.interceptors.preResolution.has(e)){var o=[];try{for(var i=Ob(this.interceptors.preResolution.getAll(e)),s=i.next();!s.done;s=i.next()){var a=s.value;"Once"!=a.options.frequency&&o.push(a),a.callback(e,t)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(e,o)}},e.prototype.executePostResolutionInterceptor=function(e,t,r){var n,o;if(this.interceptors.postResolution.has(e)){var i=[];try{for(var s=Ob(this.interceptors.postResolution.getAll(e)),a=s.next();!a.done;a=s.next()){var c=a.value;"Once"!=c.options.frequency&&i.push(c),c.callback(e,t,r)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}this.interceptors.postResolution.setAll(e,i)}},e.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===eS.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var r,n=e.options.lifecycle===eS.Singleton,o=e.options.lifecycle===eS.ContainerScoped,i=n||o;return r=aS(e.provider)?e.provider.useValue:sS(e.provider)?i?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):tS(e.provider)?i?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):rS(e.provider)?e.provider.useFactory(this):this.construct(e.provider,t),e.options.lifecycle===eS.ResolutionScoped&&t.scopedResolutions.set(e,r),r},e.prototype.resolveAll=function(e,t,r){var n=this;void 0===t&&(t=new lS),void 0===r&&(r=!1),this.ensureNotDisposed();var o=this.getAllRegistrations(e);if(!o&&oS(e)){if(r)return[];throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"All"),o){var i=o.map((function(e){return n.resolveRegistration(e,t)}));return this.executePostResolutionInterceptor(e,i,"All"),i}var s=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,s,"All"),s},e.prototype.isRegistered=function(e,t){return void 0===t&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},e.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},e.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var r=Ob(this._registry.entries()),n=r.next();!n.done;n=r.next()){var o=Ab(n.value,2),i=o[0],s=o[1];this._registry.setAll(i,s.filter((function(e){return!aS(e.provider)})).map((function(e){return e.instance=void 0,e})))}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.createChildContainer=function(){var t,r;this.ensureNotDisposed();var n=new e(this);try{for(var o=Ob(this._registry.entries()),i=o.next();!i.done;i=o.next()){var s=Ab(i.value,2),a=s[0],c=s[1];c.some((function(e){return e.options.lifecycle===eS.ContainerScoped}))&&n._registry.setAll(a,c.map((function(e){return e.options.lifecycle===eS.ContainerScoped?{provider:e.provider,options:e.options}:e})))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return n},e.prototype.beforeResolution=function(e,t,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:r})},e.prototype.afterResolution=function(e,t,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:r})},e.prototype.dispose=function(){return kb(this,void 0,void 0,(function(){var e;return Sb(this,(function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach((function(t){var r=t.dispose();r&&e.push(r)})),[4,Promise.all(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},e.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},e.prototype.construct=function(e,t){var r=this;if(e instanceof nS)return e.createProxy((function(e){return r.resolve(e,t)}));var n,o=function(){var n=gS.get(e);if(!n||0===n.length){if(0===e.length)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=n.map(r.resolveParams(t,e));return new(e.bind.apply(e,Ib([void 0],o)))}();return"function"!=typeof(n=o).dispose||n.dispose.length>0||this.disposables.add(o),o},e.prototype.resolveParams=function(e,t){var r=this;return function(n,o){var i,s,a,c;try{return"object"==typeof(c=n)&&"token"in c&&"multiple"in c?iS(n)?n.multiple?(i=r.resolve(n.transform)).transform.apply(i,Ib([r.resolveAll(n.token,new lS,n.isOptional)],n.transformArgs)):(s=r.resolve(n.transform)).transform.apply(s,Ib([r.resolve(n.token,e,n.isOptional)],n.transformArgs)):n.multiple?r.resolveAll(n.token,new lS,n.isOptional):r.resolve(n.token,e,n.isOptional):iS(n)?(a=r.resolve(n.transform,e)).transform.apply(a,Ib([r.resolve(n.token,e)],n.transformArgs)):r.resolve(n,e)}catch(e){throw new Error(dS(t,o,e))}}},e.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},e}(),mS=new bS;function wS(e){return function(e){gS.set(e,function(e){var t=Reflect.getMetadata("design:paramtypes",e)||[],r=Reflect.getOwnMetadata("injectionTokens",e)||{};return Object.keys(r).forEach((function(e){t[+e]=r[e]})),t}(e))}}if("undefined"==typeof Reflect||!Reflect.getMetadata)throw new Error("tsyringe requires a reflect polyfill. Please add 'import \"reflect-metadata\"' to the top of your entry point.");class vS{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.attrId="",this.attrValues=[],Object.assign(e)}}vb([ub({type:Eg.ObjectIdentifier})],vS.prototype,"attrId",void 0),vb([ub({type:Eg.Any,repeated:"set"})],vS.prototype,"attrValues",void 0);var kS,SS=hS=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,hS.prototype)}};SS=hS=vb([cb({type:Pg.Sequence,itemType:vS})],SS);var OS=kS=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,kS.prototype)}};OS=kS=vb([cb({type:Pg.Sequence,itemType:wv})],OS);class AS{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],AS.prototype,"certId",void 0),vb([ub({type:Eg.Any,context:0})],AS.prototype,"certValue",void 0);class IS{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],IS.prototype,"crlId",void 0),vb([ub({type:Eg.Any,context:0})],IS.prototype,"crltValue",void 0);class xS extends Tg{}let PS=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.encryptionAlgorithm=new pw,this.encryptedData=new xS,Object.assign(this,e)}};var ES,CS;vb([ub({type:pw})],PS.prototype,"encryptionAlgorithm",void 0),vb([ub({type:xS})],PS.prototype,"encryptedData",void 0),function(e){e[e.v1=0]="v1"}(CS||(CS={}));class BS extends Tg{}var TS=ES=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,ES.prototype)}};TS=ES=vb([cb({type:Pg.Sequence,itemType:rw})],TS);class DS{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=CS.v1,this.privateKeyAlgorithm=new pw,this.privateKey=new BS,Object.assign(this,e)}}vb([ub({type:Eg.Integer})],DS.prototype,"version",void 0),vb([ub({type:pw})],DS.prototype,"privateKeyAlgorithm",void 0),vb([ub({type:BS})],DS.prototype,"privateKey",void 0),vb([ub({type:TS,implicit:!0,context:0,optional:!0})],DS.prototype,"attributes",void 0);var RS=class extends DS{};RS=vb([cb({type:Pg.Sequence})],RS);var jS,NS=class extends PS{};NS=vb([cb({type:Pg.Sequence})],NS);class US{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],US.prototype,"secretTypeId",void 0),vb([ub({type:Eg.Any,context:0})],US.prototype,"secretValue",void 0);class KS{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.mac=new Jk,this.macSalt=new Tg,this.iterations=1,Object.assign(this,e)}}vb([ub({type:Jk})],KS.prototype,"mac",void 0),vb([ub({type:Tg})],KS.prototype,"macSalt",void 0),vb([ub({type:Eg.Integer,defaultValue:1})],KS.prototype,"iterations",void 0);class qS{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=3,this.authSafe=new wv,this.macData=new KS,Object.assign(this,e)}}vb([ub({type:Eg.Integer})],qS.prototype,"version",void 0),vb([ub({type:wv})],qS.prototype,"authSafe",void 0),vb([ub({type:KS,optional:!0})],qS.prototype,"macData",void 0);class LS{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:Eg.ObjectIdentifier})],LS.prototype,"bagId",void 0),vb([ub({type:Eg.Any,context:0})],LS.prototype,"bagValue",void 0),vb([ub({type:vS,repeated:"set",optional:!0})],LS.prototype,"bagAttributes",void 0);var _S,MS,FS,zS=jS=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,jS.prototype)}};zS=jS=vb([cb({type:Pg.Sequence,itemType:LS})],zS);var GS="1.2.840.113549.1.9",VS="".concat(GS,".7"),HS="".concat(GS,".14"),WS=class extends Eb{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}toString(){return this.ia5String||super.toString()}};vb([ub({type:Eg.IA5String})],WS.prototype,"ia5String",void 0),WS=vb([cb({type:Pg.Choice})],WS);var JS=class extends wv{};JS=vb([cb({type:Pg.Sequence})],JS);var $S=class extends qS{};$S=vb([cb({type:Pg.Sequence})],$S);var YS=class extends PS{};YS=vb([cb({type:Pg.Sequence})],YS);var ZS=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.value=e}toString(){return this.value}};vb([ub({type:Eg.IA5String})],ZS.prototype,"value",void 0),ZS=vb([cb({type:Pg.Choice})],ZS);var QS=class extends WS{};QS=vb([cb({type:Pg.Choice})],QS);var XS=class extends Eb{};XS=vb([cb({type:Pg.Choice})],XS);var eO=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;this.value=e}};vb([ub({type:Eg.GeneralizedTime})],eO.prototype,"value",void 0),eO=vb([cb({type:Pg.Choice})],eO);var tO=class extends Eb{};tO=vb([cb({type:Pg.Choice})],tO);var rO=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"M";this.value=e}toString(){return this.value}};vb([ub({type:Eg.PrintableString})],rO.prototype,"value",void 0),rO=vb([cb({type:Pg.Choice})],rO);var nO=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.value=e}toString(){return this.value}};vb([ub({type:Eg.PrintableString})],nO.prototype,"value",void 0),nO=vb([cb({type:Pg.Choice})],nO);var oO=class extends nO{};oO=vb([cb({type:Pg.Choice})],oO);var iO=class extends Eb{};iO=vb([cb({type:Pg.Choice})],iO);var sO=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.value=e}toString(){return this.value}};vb([ub({type:Eg.ObjectIdentifier})],sO.prototype,"value",void 0),sO=vb([cb({type:Pg.Choice})],sO);var aO=class extends gw{};aO=vb([cb({type:Pg.Choice})],aO);var cO=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.value=e}toString(){return this.value.toString()}};vb([ub({type:Eg.Integer})],cO.prototype,"value",void 0),cO=vb([cb({type:Pg.Choice})],cO);var uO=class extends Kw{};uO=vb([cb({type:Pg.Sequence})],uO);var lO=class extends Eb{};lO=vb([cb({type:Pg.Choice})],lO);var dO=_S=class extends vw{constructor(e){super(e),Object.setPrototypeOf(this,_S.prototype)}};dO=_S=vb([cb({type:Pg.Sequence})],dO);var hO=MS=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,MS.prototype)}};hO=MS=vb([cb({type:Pg.Set,itemType:Nw})],hO);var pO=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.value=e}toString(){return this.value}};vb([ub({type:Eg.BmpString})],pO.prototype,"value",void 0),pO=vb([cb({type:Pg.Choice})],pO);var yO=class extends pw{};yO=vb([cb({type:Pg.Sequence})],yO);var fO,gO=FS=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,FS.prototype)}};gO=FS=vb([cb({type:Pg.Sequence,itemType:yO})],gO);var bO=fO=class extends pb{constructor(e){super(e),Object.setPrototypeOf(this,fO.prototype)}};bO=fO=vb([cb({type:Pg.Sequence,itemType:rw})],bO);class mO{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.version=0,this.subject=new Rb,this.subjectPKInfo=new yw,this.attributes=new bO,Object.assign(this,e)}}vb([ub({type:Eg.Integer})],mO.prototype,"version",void 0),vb([ub({type:Rb})],mO.prototype,"subject",void 0),vb([ub({type:yw})],mO.prototype,"subjectPKInfo",void 0),vb([ub({type:bO,implicit:!0,context:0})],mO.prototype,"attributes",void 0);class wO{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.certificationRequestInfo=new mO,this.signatureAlgorithm=new pw,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}vb([ub({type:mO})],wO.prototype,"certificationRequestInfo",void 0),vb([ub({type:pw})],wO.prototype,"signatureAlgorithm",void 0),vb([ub({type:Eg.BitString})],wO.prototype,"signature",void 0);var vO="crypto.algorithm";var kO,SO="crypto.algorithmProvider";mS.registerSingleton(SO,class{getAlgorithms(){return mS.resolveAll(vO)}toAsnAlgorithm(e){for(var t of(Z({},e),this.getAlgorithms())){var r=t.toAsnAlgorithm(e);if(r)return r}if(/^[0-9.]+$/.test(e.name)){var n=new pw({algorithm:e.name});if("parameters"in e){var o=e;n.parameters=o.parameters}return n}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(var t of this.getAlgorithms()){var r=t.toWebAlgorithm(e);if(r)return r}return{name:e.algorithm,parameters:e.parameters}}});var OO="1.3.36.3.3.2.8.1.1",AO="".concat(OO,".1"),IO="".concat(OO,".2"),xO="".concat(OO,".3"),PO="".concat(OO,".4"),EO="".concat(OO,".5"),CO="".concat(OO,".6"),BO="".concat(OO,".7"),TO="".concat(OO,".8"),DO="".concat(OO,".9"),RO="".concat(OO,".10"),jO="".concat(OO,".11"),NO="".concat(OO,".12"),UO="".concat(OO,".13"),KO="".concat(OO,".14"),qO="brainpoolP160r1",LO="brainpoolP160t1",_O="brainpoolP192r1",MO="brainpoolP192t1",FO="brainpoolP224r1",zO="brainpoolP224t1",GO="brainpoolP256r1",VO="brainpoolP256t1",HO="brainpoolP320r1",WO="brainpoolP320t1",JO="brainpoolP384r1",$O="brainpoolP384t1",YO="brainpoolP512r1",ZO="brainpoolP512t1",QO="ECDSA",XO=kO=class{toAsnAlgorithm(e){if(e.name.toLowerCase()===QO.toLowerCase())if("hash"in e)switch(("string"==typeof e.hash?e.hash:e.hash.name).toLowerCase()){case"sha-1":return lk;case"sha-256":return dk;case"sha-384":return hk;case"sha-512":return pk}else if("namedCurve"in e){var t="";switch(e.namedCurve){case"P-256":t=sk;break;case"K-256":t=kO.SECP256K1;break;case"P-384":t=ak;break;case"P-521":t=ck;break;case qO:t=AO;break;case LO:t=IO;break;case _O:t=xO;break;case MO:t=PO;break;case FO:t=EO;break;case zO:t=CO;break;case GO:t=BO;break;case VO:t=TO;break;case HO:t=DO;break;case WO:t=RO;break;case JO:t=jO;break;case $O:t=NO;break;case YO:t=UO;break;case ZO:t=KO}if(t)return new pw({algorithm:ek,parameters:yb.serialize(new mk({namedCurve:t}))})}return null}toWebAlgorithm(e){switch(e.algorithm){case tk:return{name:QO,hash:{name:"SHA-1"}};case nk:return{name:QO,hash:{name:"SHA-256"}};case ok:return{name:QO,hash:{name:"SHA-384"}};case ik:return{name:QO,hash:{name:"SHA-512"}};case ek:if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(yb.parse(e.parameters,mk).namedCurve){case sk:return{name:QO,namedCurve:"P-256"};case kO.SECP256K1:return{name:QO,namedCurve:"K-256"};case ak:return{name:QO,namedCurve:"P-384"};case ck:return{name:QO,namedCurve:"P-521"};case AO:return{name:QO,namedCurve:qO};case IO:return{name:QO,namedCurve:LO};case xO:return{name:QO,namedCurve:_O};case PO:return{name:QO,namedCurve:MO};case EO:return{name:QO,namedCurve:FO};case CO:return{name:QO,namedCurve:zO};case BO:return{name:QO,namedCurve:GO};case TO:return{name:QO,namedCurve:VO};case DO:return{name:QO,namedCurve:HO};case RO:return{name:QO,namedCurve:WO};case jO:return{name:QO,namedCurve:JO};case NO:return{name:QO,namedCurve:$O};case UO:return{name:QO,namedCurve:YO};case KO:return{name:QO,namedCurve:ZO}}}return null}};XO.SECP256K1="1.3.132.0.10",XO=kO=vb([wS()],XO),mS.registerSingleton(vO,XO);var eA,tA=Symbol("name"),rA=Symbol("value");class nA{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";for(var n in this[tA]=e,this[rA]=r,t)this[n]=t[n]}}nA.NAME=tA,nA.VALUE=rA;class oA{static toString(e){var t=this.items[e];return t||e}}oA.items={[Nk]:"sha1",[Uk]:"sha224",[Kk]:"sha256",[qk]:"sha384",[Lk]:"sha512",[Sk]:"rsaEncryption",[Ek]:"sha1WithRSAEncryption",[Ck]:"sha224WithRSAEncryption",[Bk]:"sha256WithRSAEncryption",[Tk]:"sha384WithRSAEncryption",[Dk]:"sha512WithRSAEncryption",[ek]:"ecPublicKey",[tk]:"ecdsaWithSHA1",[rk]:"ecdsaWithSHA224",[nk]:"ecdsaWithSHA256",[ok]:"ecdsaWithSHA384",[ik]:"ecdsaWithSHA512",[Dm]:"TLS WWW server authentication",[Rm]:"TLS WWW client authentication",[jm]:"Code Signing",[Nm]:"E-mail Protection",[Um]:"Time Stamping",[Km]:"OCSP Signing",[Zv]:"Signed Data"};class iA{static serialize(e){return this.serializeObj(e).join("\n")}static pad(){return"".padStart(2*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)," ")}static serializeObj(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[],n=this.pad(t++),o="",i=e[nA.VALUE];for(var s in i&&(o=" ".concat(i)),r.push("".concat(n).concat(e[nA.NAME],":").concat(o)),n=this.pad(t),e)if("symbol"!=typeof s){var a=e[s],c=s?"".concat(s,": "):"";if("string"==typeof a||"number"==typeof a||"boolean"==typeof a)r.push("".concat(n).concat(c).concat(a));else if(a instanceof Date)r.push("".concat(n).concat(c).concat(a.toUTCString()));else if(Array.isArray(a))for(var u of a)u[nA.NAME]=s,r.push(...this.serializeObj(u,t));else if(a instanceof nA)a[nA.NAME]=s,r.push(...this.serializeObj(a,t));else if(Yp.BufferSourceConverter.isBufferSource(a))s?(r.push("".concat(n).concat(c)),r.push(...this.serializeBufferSource(a,t+1))):r.push(...this.serializeBufferSource(a,t));else{if(!("toTextObject"in a))throw new TypeError("Cannot serialize data in text format. Unsupported type.");var l=a.toTextObject();l[nA.NAME]=s,r.push(...this.serializeObj(l,t))}}return r}static serializeBufferSource(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.pad(t),n=Yp.BufferSourceConverter.toUint8Array(e),o=[],i=0;i<n.length;){for(var s=[],a=0;a<16&&i<n.length;a++){8===a&&s.push("");var c=n[i++].toString(16).padStart(2,"0");s.push(c)}o.push("".concat(r).concat(s.join(" ")))}return o}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}iA.oidSerializer=oA,iA.algorithmSerializer=class{static toTextObject(e){var t=new nA("Algorithm Identifier",{},oA.toString(e.algorithm));if(e.parameters)if(e.algorithm===ek){var r=(new XO).toWebAlgorithm(e);r&&"namedCurve"in r?t["Named Curve"]=r.namedCurve:t.Parameters=e.parameters}else t.Parameters=e.parameters;return t}};class sA{constructor(){if(1===arguments.length){var e=arguments.length<=0?void 0:arguments[0];this.rawData=yb.serialize(e),this.onInit(e)}else{var t=yb.parse(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1]);this.rawData=Yp.BufferSourceConverter.toArrayBuffer(arguments.length<=0?void 0:arguments[0]),this.onInit(t)}}equal(e){return e instanceof sA&&Yp.isEqual(e.rawData,this.rawData)}toString(){switch(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"text"){case"asn":return yb.toString(this.rawData);case"text":return iA.serialize(this.toTextObject());case"hex":return Yp.Convert.ToHex(this.rawData);case"base64":return Yp.Convert.ToBase64(this.rawData);case"base64url":return Yp.Convert.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){var e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new nA(this.getTextName(),{},e)}}sA.NAME="ASN";class aA extends sA{constructor(){super(Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0])?Yp.BufferSourceConverter.toArrayBuffer(arguments.length<=0?void 0:arguments[0]):yb.serialize(new mw({extnID:arguments.length<=0?void 0:arguments[0],critical:arguments.length<=1?void 0:arguments[1],extnValue:new Tg(Yp.BufferSourceConverter.toArrayBuffer(arguments.length<=2?void 0:arguments[2]))})),mw)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){var e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){var e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[nA.NAME]===aA.NAME&&(e[nA.NAME]=oA.toString(this.type)),e}}class cA{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&void 0!==e.extractable}constructor(){this.items=new Map,this[eA]="CryptoProvider","undefined"!=typeof self&&"undefined"!=typeof crypto?this.set(cA.DEFAULT,crypto):"undefined"!=typeof global&&global.crypto&&global.crypto.subtle&&this.set(cA.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,t){return this.items.forEach(e,t)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:cA.DEFAULT,t=this.items.get(e.toLowerCase());if(!t)throw new Error("Cannot get Crypto by name '".concat(e,"'"));return t}set(e,t){if("string"==typeof e){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(cA.DEFAULT,e);return this}}eA=Symbol.toStringTag,cA.DEFAULT="default";var uA=new cA,lA=/^[0-2](?:\.[1-9][0-9]*)+$/;class dA{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.items={},e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return t=e,new RegExp(lA).test(t)?e:this.get(e);var t}register(e,t){this.items[e]=t,this.items[t]=e}}var hA=new dA;function pA(e,t){return"\\".concat(Yp.Convert.ToHex(Yp.Convert.FromUtf8String(t)).toUpperCase())}hA.register("CN","2.5.4.3"),hA.register("L","2.5.4.7"),hA.register("ST","2.5.4.8"),hA.register("O","2.5.4.10"),hA.register("OU","2.5.4.11"),hA.register("C","2.5.4.6"),hA.register("DC","0.9.2342.19200300.100.1.25"),hA.register("E","1.2.840.113549.1.9.1"),hA.register("G","2.5.4.42"),hA.register("I","2.5.4.43"),hA.register("SN","2.5.4.4"),hA.register("T","2.5.4.12");class yA{static isASCII(e){for(var t=0;t<e.length;t++){if(e.charCodeAt(t)>255)return!1}return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(var r in this.extraNames=new dA,this.asn=new Rb,t)if(Object.prototype.hasOwnProperty.call(t,r)){var n=t[r];this.extraNames.register(r,n)}"string"==typeof e?this.asn=this.fromString(e):e instanceof Rb?this.asn=e:Yp.BufferSourceConverter.isBufferSource(e)?this.asn=yb.parse(e,Rb):this.asn=this.fromJSON(e)}getField(e){var t=this.extraNames.findId(e)||hA.findId(e),r=[];for(var n of this.asn)for(var o of n)o.type===t&&r.push(o.value.toString());return r}getName(e){return this.extraNames.get(e)||hA.get(e)}toString(){return this.asn.map((e=>e.map((e=>{var t=this.getName(e.type)||e.type,r=e.value.anyValue?"#".concat(Yp.Convert.ToHex(e.value.anyValue)):e.value.toString().replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,pA);return"".concat(t,"=").concat(r)})).join("+"))).join(", ")}toJSON(){var e,t=[];for(var r of this.asn){var n={};for(var o of r){var i=this.getName(o.type)||o.type;null!==(e=n[i])&&void 0!==e||(n[i]=[]),n[i].push(o.value.anyValue?"#".concat(Yp.Convert.ToHex(o.value.anyValue)):o.value.toString())}t.push(n)}return t}fromString(e){for(var t=new Rb,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g,n=null,o=",";n=r.exec("".concat(e,","));){var[,i,s]=n,a=s[s.length-1];","!==a&&"+"!==a||(s=s.slice(0,s.length-1),n[3]=a);var c=n[3];i=this.getTypeOid(i);var u=this.createAttribute(i,s);"+"===o?t[t.length-1].push(u):t.push(new Tb([u])),o=c}return t}fromJSON(e){var t=new Rb;for(var r of e){var n=new Tb;for(var o in r){var i=this.getTypeOid(o),s=r[o];for(var a of s){var c=this.createAttribute(i,a);n.push(c)}}t.push(n)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error("Cannot get OID for name type '".concat(e,"'"));return e}createAttribute(e,t){var r=new Bb({type:e});if("object"==typeof t)for(var n in t)switch(n){case"ia5String":r.value.ia5String=t[n];break;case"utf8String":r.value.utf8String=t[n];break;case"universalString":r.value.universalString=t[n];break;case"bmpString":r.value.bmpString=t[n];break;case"printableString":r.value.printableString=t[n]}else if("#"===t[0])r.value.anyValue=Yp.Convert.FromHex(t.slice(1));else{var o=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?r.value.ia5String=o:yA.isPrintableString(o)?r.value.printableString=o:r.value.utf8String=o}return r}processStringValue(e){var t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/gi,"\n").replace(/\\0d/gi,"\r").replace(/\\0g/gi,"\t").replace(/\\(.)/g,"$1")}toArrayBuffer(){return yb.serialize(this.asn)}getThumbprint(){var e=arguments,t=this;return G((function*(){var r,n,o="SHA-1";return e.length>=1&&!(null===(r=e.length<=0?void 0:e[0])||void 0===r?void 0:r.subtle)?(o=(e.length<=0?void 0:e[0])||o,n=(e.length<=1?void 0:e[1])||uA.get()):n=(e.length<=0?void 0:e[0])||uA.get(),yield n.subtle.digest(o,t.toArrayBuffer())}))()}}var fA="Cannot initialize GeneralName from ASN.1 data.",gA="".concat(fA," Unsupported string format in use."),bA="".concat(fA," Value doesn't match to GUID regular expression."),mA=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,wA="1.3.6.1.4.1.311.25.1",vA="1.3.6.1.4.1.311.20.2.3",kA="dns",SA="dn",OA="email",AA="ip",IA="url",xA="guid",PA="upn",EA="id";class CA extends sA{constructor(){var e;if(2===arguments.length)switch(arguments.length<=0?void 0:arguments[0]){case SA:var t=new yA(arguments.length<=1?void 0:arguments[1]).toArrayBuffer(),r=yb.parse(t,Rb);e=new Kb({directoryName:r});break;case kA:e=new Kb({dNSName:arguments.length<=1?void 0:arguments[1]});break;case OA:e=new Kb({rfc822Name:arguments.length<=1?void 0:arguments[1]});break;case xA:var n=new RegExp(mA,"i").exec(arguments.length<=1?void 0:arguments[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");var o=n.slice(1).map(((e,t)=>t<3?Yp.Convert.ToHex(new Uint8Array(Yp.Convert.FromHex(e)).reverse()):e)).join("");e=new Kb({otherName:new Nb({typeId:wA,value:yb.serialize(new Tg(Yp.Convert.FromHex(o)))})});break;case AA:e=new Kb({iPAddress:arguments.length<=1?void 0:arguments[1]});break;case EA:e=new Kb({registeredID:arguments.length<=1?void 0:arguments[1]});break;case PA:e=new Kb({otherName:new Nb({typeId:vA,value:yb.serialize(Fg.toASN(arguments.length<=1?void 0:arguments[1]))})});break;case IA:e=new Kb({uniformResourceIdentifier:arguments.length<=1?void 0:arguments[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else e=Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0])?yb.parse(arguments.length<=0?void 0:arguments[0],Kb):arguments.length<=0?void 0:arguments[0];super(e)}onInit(e){if(null!=e.dNSName)this.type=kA,this.value=e.dNSName;else if(null!=e.rfc822Name)this.type=OA,this.value=e.rfc822Name;else if(null!=e.iPAddress)this.type=AA,this.value=e.iPAddress;else if(null!=e.uniformResourceIdentifier)this.type=IA,this.value=e.uniformResourceIdentifier;else if(null!=e.registeredID)this.type=EA,this.value=e.registeredID;else if(null!=e.directoryName)this.type=SA,this.value=new yA(e.directoryName).toString();else{if(null==e.otherName)throw new Error(gA);if(e.otherName.typeId===wA){this.type=xA;var t=yb.parse(e.otherName.value,Tg),r=new RegExp(mA,"i").exec(Yp.Convert.ToHex(t));if(!r)throw new Error(bA);this.value=r.slice(1).map(((e,t)=>t<3?Yp.Convert.ToHex(new Uint8Array(Yp.Convert.FromHex(e)).reverse()):e)).join("-")}else{if(e.otherName.typeId!==vA)throw new Error(gA);this.type=PA,this.value=yb.parse(e.otherName.value,Eb).toString()}}}toJSON(){return{type:this.type,value:this.value}}toTextObject(){var e;switch(this.type){case SA:case kA:case xA:case AA:case EA:case PA:case IA:e=this.type.toUpperCase();break;case OA:e="Email";break;default:throw new Error("Unsupported GeneralName type")}var t=this.value;return this.type===EA&&(t=oA.toString(t)),new nA(e,void 0,t)}}class BA extends sA{constructor(e){var t;if(e instanceof om)t=e;else if(Array.isArray(e)){var r=[];for(var n of e)if(n instanceof Kb)r.push(n);else{var o=yb.parse(new CA(n.type,n.value).rawData,Kb);r.push(o)}t=new om(r)}else{if(!Yp.BufferSourceConverter.isBufferSource(e))throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");t=yb.parse(e,om)}super(t)}onInit(e){var t=[];for(var r of e){var n=null;try{n=new CA(r)}catch(e){continue}t.push(n)}this.items=t}toJSON(){return this.items.map((e=>e.toJSON()))}toTextObject(){var e=super.toTextObjectEmpty();for(var t of this.items){var r=t.toTextObject(),n=e[r[nA.NAME]];Array.isArray(n)||(n=[],e[r[nA.NAME]]=n),n.push(r)}return e}}BA.NAME="GeneralNames";var TA,DA,RA="-{5}",jA="\\n",NA="[^".concat(jA,"]+"),UA="".concat(RA,"BEGIN (").concat(NA,"(?=").concat(RA,"))").concat(RA),KA="".concat(RA,"END \\1").concat(RA),qA="\\n",LA="[^:".concat(jA,"]+"),_A="(?:[^".concat(jA,"]+").concat(qA,"(?: +[^").concat(jA,"]+").concat(qA,")*)"),MA="(?:".concat("[a-zA-Z0-9=+/]+").concat(qA,")+"),FA="".concat(UA).concat(qA,"(?:((?:").concat(LA,": ").concat(_A,")+))?").concat(qA,"?(").concat(MA,")").concat(KA);class zA{static isPem(e){return"string"==typeof e&&new RegExp(FA,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");for(var t=new RegExp(FA,"g"),r=[],n=null;n=t.exec(e);){var o=n[3].replace(new RegExp("[".concat(jA,"]+"),"g"),""),i={type:n[1],headers:[],rawData:Yp.Convert.FromBase64(o)},s=n[2];if(s){var a=s.split(new RegExp(qA,"g")),c=null;for(var u of a){var[l,d]=u.split(/:(.*)/);if(void 0===d){if(!c)throw new Error("Cannot parse PEM string. Incorrect header value");c.value+=l.trim()}else c&&i.headers.push(c),c={key:l,value:d.trim()}}c&&i.headers.push(c)}r.push(i)}return r}static decode(e){return this.decodeWithHeaders(e).map((e=>e.rawData))}static decodeFirst(e){var t=this.decode(e);if(!t.length)throw new RangeError("PEM string doesn't contain any objects");return t[0]}static encode(e,t){if(Array.isArray(e)){var r=new Array;return t?e.forEach((e=>{if(!Yp.BufferSourceConverter.isBufferSource(e))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");r.push(this.encodeStruct({type:t,rawData:Yp.BufferSourceConverter.toArrayBuffer(e)}))})):e.forEach((e=>{if(!("type"in e))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(e))})),r.join("\n")}if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:Yp.BufferSourceConverter.toArrayBuffer(e)})}static encodeStruct(e){var t,r=e.type.toLocaleUpperCase(),n=[];if(n.push("-----BEGIN ".concat(r,"-----")),null===(t=e.headers)||void 0===t?void 0:t.length){for(var o of e.headers)n.push("".concat(o.key,": ").concat(o.value));n.push("")}for(var i,s=Yp.Convert.ToBase64(e.rawData),a=0,c=Array();a<s.length&&(s.length-a<64?i=s.substring(a):(i=s.substring(a,a+64),a+=64),0!==i.length)&&(c.push(i),!(i.length<64)););return n.push(...c),n.push("-----END ".concat(r,"-----")),n.join("\n")}}zA.CertificateTag="CERTIFICATE",zA.CrlTag="CRL",zA.CertificateRequestTag="CERTIFICATE REQUEST",zA.PublicKeyTag="PUBLIC KEY",zA.PrivateKeyTag="PRIVATE KEY";class GA extends sA{static isAsnEncoded(e){return Yp.BufferSourceConverter.isBufferSource(e)||"string"==typeof e}static toArrayBuffer(e){if("string"==typeof e){if(zA.isPem(e))return zA.decode(e)[0];if(Yp.Convert.isHex(e))return Yp.Convert.FromHex(e);if(Yp.Convert.isBase64(e))return Yp.Convert.FromBase64(e);if(Yp.Convert.isBase64Url(e))return Yp.Convert.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}var t=Yp.Convert.ToBinary(e);return zA.isPem(t)?zA.decode(t)[0]:Yp.Convert.isHex(t)?Yp.Convert.FromHex(t):Yp.Convert.isBase64(t)?Yp.Convert.FromBase64(t):Yp.Convert.isBase64Url(t)?Yp.Convert.FromBase64Url(t):Yp.BufferSourceConverter.toArrayBuffer(e)}constructor(){GA.isAsnEncoded(arguments.length<=0?void 0:arguments[0])?super(GA.toArrayBuffer(arguments.length<=0?void 0:arguments[0]),arguments.length<=1?void 0:arguments[1]):super(arguments.length<=0?void 0:arguments[0])}toString(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"pem";return"pem"===e?zA.encode(this.rawData,this.tag):super.toString(e)}}class VA extends GA{static create(e){var t=arguments;return G((function*(){var r=t.length>1&&void 0!==t[1]?t[1]:uA.get();if(e instanceof VA)return e;if(cA.isCryptoKey(e)){if("public"!==e.type)throw new TypeError("Public key is required");var n=yield r.subtle.exportKey("spki",e);return new VA(n)}if(e.publicKey)return e.publicKey;if(Yp.BufferSourceConverter.isBufferSource(e))return new VA(e);throw new TypeError("Unsupported PublicKeyType")}))()}constructor(e){GA.isAsnEncoded(e)?super(e,yw):super(e),this.tag=zA.PublicKeyTag}export(){var e=arguments,t=this;return G((function*(){var r,n=["verify"],o=Z({hash:"SHA-256"},t.algorithm);e.length>1?(o=(e.length<=0?void 0:e[0])||o,n=(e.length<=1?void 0:e[1])||n,r=(e.length<=2?void 0:e[2])||uA.get()):r=(e.length<=0?void 0:e[0])||uA.get();var i=t.rawData,s=yb.parse(t.rawData,yw);return s.algorithm.algorithm===Ik&&(i=function(e,t){return e.algorithm=new pw({algorithm:Sk,parameters:null}),t=yb.serialize(e),t}(s,i)),r.subtle.importKey("spki",i,o,!0,n)}))()}onInit(e){var t=mS.resolve(SO),r=this.algorithm=t.toWebAlgorithm(e.algorithm);if(e.algorithm.algorithm===Sk){var n=yb.parse(e.subjectPublicKey,Xk),o=Yp.BufferSourceConverter.toUint8Array(n.modulus);r.publicExponent=Yp.BufferSourceConverter.toUint8Array(n.publicExponent),r.modulusLength=(o[0]?o:o.slice(1)).byteLength<<3}}getThumbprint(){var e=arguments,t=this;return G((function*(){var r,n,o="SHA-1";return e.length>=1&&!(null===(r=e.length<=0?void 0:e[0])||void 0===r?void 0:r.subtle)?(o=(e.length<=0?void 0:e[0])||o,n=(e.length<=1?void 0:e[1])||uA.get()):n=(e.length<=0?void 0:e[0])||uA.get(),yield n.subtle.digest(o,t.rawData)}))()}getKeyIdentifier(){var e=arguments,t=this;return G((function*(){var r,n="SHA-1";1===e.length?"string"==typeof(e.length<=0?void 0:e[0])?(n=e.length<=0?void 0:e[0],r=uA.get()):r=e.length<=0?void 0:e[0]:2===e.length?(n=e.length<=0?void 0:e[0],r=e.length<=1?void 0:e[1]):r=uA.get();var o=yb.parse(t.rawData,yw);return yield r.subtle.digest(n,o.subjectPublicKey)}))()}toTextObject(){var e=this.toTextObjectEmpty(),t=yb.parse(this.rawData,yw);if(e.Algorithm=iA.serializeAlgorithm(t.algorithm),t.algorithm.algorithm===ek)e["EC Point"]=t.subjectPublicKey;else e["Raw Data"]=t.subjectPublicKey;return e}}class HA extends aA{static create(e){var t=arguments;return G((function*(){var r=t.length>1&&void 0!==t[1]&&t[1],n=t.length>2&&void 0!==t[2]?t[2]:uA.get();if("name"in e&&"serialNumber"in e)return new HA(e,r);var o=yield VA.create(e,n),i=yield o.getKeyIdentifier(n);return new HA(Yp.Convert.ToHex(i),r)}))()}constructor(){if(Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0]))super(arguments.length<=0?void 0:arguments[0]);else if("string"==typeof(arguments.length<=0?void 0:arguments[0])){var e=new Xb({keyIdentifier:new Qb(Yp.Convert.FromHex(arguments.length<=0?void 0:arguments[0]))});super(Zb,arguments.length<=1?void 0:arguments[1],yb.serialize(e))}else{var t=arguments.length<=0?void 0:arguments[0],r=t.name instanceof BA?yb.parse(t.name.rawData,om):t.name,n=new Xb({authorityCertIssuer:r,authorityCertSerialNumber:Yp.Convert.FromHex(t.serialNumber)});super(Zb,arguments.length<=1?void 0:arguments[1],yb.serialize(n))}}onInit(e){super.onInit(e);var t=yb.parse(e.extnValue,Xb);t.keyIdentifier&&(this.keyId=Yp.Convert.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?Yp.Convert.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){var e=this.toTextObjectWithoutValue(),t=yb.parse(this.value,Xb);return t.authorityCertIssuer&&(e["Authority Issuer"]=new BA(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}HA.NAME="Authority Key Identifier";class WA extends aA{constructor(){if(Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0])){super(arguments.length<=0?void 0:arguments[0]);var e=yb.parse(this.value,rm);this.ca=e.cA,this.pathLength=e.pathLenConstraint}else{var t=new rm({cA:arguments.length<=0?void 0:arguments[0],pathLenConstraint:arguments.length<=1?void 0:arguments[1]});super(tm,arguments.length<=2?void 0:arguments[2],yb.serialize(t)),this.ca=arguments.length<=0?void 0:arguments[0],this.pathLength=arguments.length<=1?void 0:arguments[1]}}toTextObject(){var e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),void 0!==this.pathLength&&(e["Path Length"]=this.pathLength),e}}WA.NAME="Basic Constraints",function(e){e.serverAuth="1.3.6.1.5.5.7.3.1",e.clientAuth="1.3.6.1.5.5.7.3.2",e.codeSigning="1.3.6.1.5.5.7.3.3",e.emailProtection="1.3.6.1.5.5.7.3.4",e.timeStamping="1.3.6.1.5.5.7.3.8",e.ocspSigning="1.3.6.1.5.5.7.3.9"}(TA||(TA={}));class JA extends aA{constructor(){if(Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0])){super(arguments.length<=0?void 0:arguments[0]);var e=yb.parse(this.value,Tm);this.usages=e.map((e=>e))}else{var t=new Tm(arguments.length<=0?void 0:arguments[0]);super(Bm,arguments.length<=1?void 0:arguments[1],yb.serialize(t)),this.usages=arguments.length<=0?void 0:arguments[0]}}toTextObject(){var e=this.toTextObjectWithoutValue();return e[""]=this.usages.map((e=>oA.toString(e))).join(", "),e}}JA.NAME="Extended Key Usages",function(e){e[e.digitalSignature=1]="digitalSignature",e[e.nonRepudiation=2]="nonRepudiation",e[e.keyEncipherment=4]="keyEncipherment",e[e.dataEncipherment=8]="dataEncipherment",e[e.keyAgreement=16]="keyAgreement",e[e.keyCertSign=32]="keyCertSign",e[e.cRLSign=64]="cRLSign",e[e.encipherOnly=128]="encipherOnly",e[e.decipherOnly=256]="decipherOnly"}(DA||(DA={}));class $A extends aA{constructor(){if(Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0])){super(arguments.length<=0?void 0:arguments[0]);var e=yb.parse(this.value,Vm);this.usages=e.toNumber()}else{var t=new Vm(arguments.length<=0?void 0:arguments[0]);super(Gm,arguments.length<=1?void 0:arguments[1],yb.serialize(t)),this.usages=arguments.length<=0?void 0:arguments[0]}}toTextObject(){var e=this.toTextObjectWithoutValue(),t=yb.parse(this.value,Vm);return e[""]=t.toJSON().join(", "),e}}$A.NAME="Key Usages";class YA extends aA{static create(e){var t=arguments;return G((function*(){var r=t.length>1&&void 0!==t[1]&&t[1],n=t.length>2&&void 0!==t[2]?t[2]:uA.get(),o=yield VA.create(e,n),i=yield o.getKeyIdentifier(n);return new YA(Yp.Convert.ToHex(i),r)}))()}constructor(){if(Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0])){super(arguments.length<=0?void 0:arguments[0]);var e=yb.parse(this.value,cw);this.keyId=Yp.Convert.ToHex(e)}else{var t="string"==typeof(arguments.length<=0?void 0:arguments[0])?Yp.Convert.FromHex(arguments.length<=0?void 0:arguments[0]):arguments.length<=0?void 0:arguments[0],r=new cw(t);super(aw,arguments.length<=1?void 0:arguments[1],yb.serialize(r)),this.keyId=Yp.Convert.ToHex(t)}}toTextObject(){var e=this.toTextObjectWithoutValue(),t=yb.parse(this.value,cw);return e[""]=t,e}}YA.NAME="Subject Key Identifier";class ZA extends aA{constructor(){Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0])?super(arguments.length<=0?void 0:arguments[0]):super(ew,arguments.length<=1?void 0:arguments[1],new BA((arguments.length<=0?void 0:arguments[0])||[]).rawData)}onInit(e){super.onInit(e);var t=yb.parse(e.extnValue,tw);this.names=new BA(t)}toTextObject(){var e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(var r in t)e[r]=t[r];return e}}ZA.NAME="Subject Alternative Name";class QA{static register(e,t){this.items.set(e,t)}static create(e){var t=new aA(e),r=this.items.get(t.type);return r?new r(e):t}}QA.items=new Map;class XA extends aA{constructor(){var e;if(Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0])){super(arguments.length<=0?void 0:arguments[0]);var t=yb.parse(this.value,ym);this.policies=t.map((e=>e.policyIdentifier))}else{var r=arguments.length<=0?void 0:arguments[0],n=null!==(e=arguments.length<=1?void 0:arguments[1])&&void 0!==e&&e,o=new ym(r.map((e=>new pm({policyIdentifier:e}))));super(am,n,yb.serialize(o)),this.policies=r}}toTextObject(){var e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map((e=>new nA("",{},oA.toString(e)))),e}}XA.NAME="Certificate Policies",QA.register(am,XA);class eI extends aA{constructor(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];if(Yp.BufferSourceConverter.isBufferSource(r[0]))super(r[0]);else if(Array.isArray(r[0])&&"string"==typeof r[0][0]){var o=r[0].map((e=>new Sm({distributionPoint:new km({fullName:[new Kb({uniformResourceIdentifier:e})]})}))),i=new Am(o);super(wm,r[1],yb.serialize(i))}else{var s=new Am(r[0]);super(wm,r[1],yb.serialize(s))}null!==(e=this.distributionPoints)&&void 0!==e||(this.distributionPoints=[])}onInit(e){super.onInit(e);var t=yb.parse(e.extnValue,Am);this.distributionPoints=t}toTextObject(){var e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map((e=>{var t,r={};return e.distributionPoint&&(r[""]=null===(t=e.distributionPoint.fullName)||void 0===t?void 0:t.map((e=>new CA(e).toString())).join(", ")),e.reasons&&(r.Reasons=e.reasons.toString()),e.cRLIssuer&&(r["CRL Issuer"]=e.cRLIssuer.map((e=>e.toString())).join(", ")),r})),e}}eI.NAME="CRL Distribution Points";class tI extends aA{constructor(){var e,t,r,n;if(Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0]))super(arguments.length<=0?void 0:arguments[0]);else if((arguments.length<=0?void 0:arguments[0])instanceof Yb){var o=new Yb(arguments.length<=0?void 0:arguments[0]);super(Jb,arguments.length<=1?void 0:arguments[1],yb.serialize(o))}else{var i=arguments.length<=0?void 0:arguments[0],s=new Yb;nI(s,i,zb,"ocsp"),nI(s,i,Gb,"caIssuers"),nI(s,i,Vb,"timeStamping"),nI(s,i,Hb,"caRepository"),super(Jb,arguments.length<=1?void 0:arguments[1],yb.serialize(s))}null!==(e=this.ocsp)&&void 0!==e||(this.ocsp=[]),null!==(t=this.caIssuers)&&void 0!==t||(this.caIssuers=[]),null!==(r=this.timeStamping)&&void 0!==r||(this.timeStamping=[]),null!==(n=this.caRepository)&&void 0!==n||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],yb.parse(e.extnValue,Yb).forEach((e=>{switch(e.accessMethod){case zb:this.ocsp.push(new CA(e.accessLocation));break;case Gb:this.caIssuers.push(new CA(e.accessLocation));break;case Vb:this.timeStamping.push(new CA(e.accessLocation));break;case Hb:this.caRepository.push(new CA(e.accessLocation))}}))}toTextObject(){var e=this.toTextObjectWithoutValue();return this.ocsp.length&&rI(e,"OCSP",this.ocsp),this.caIssuers.length&&rI(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&rI(e,"Time Stamping",this.timeStamping),this.caRepository.length&&rI(e,"CA Repository",this.caRepository),e}}function rI(e,t,r){if(1===r.length)e[t]=r[0].toTextObject();else{var n=new nA("");r.forEach(((e,t)=>{var r=e.toTextObject(),o="".concat(r[nA.NAME]," ").concat(t+1),i=n[o];Array.isArray(i)||(i=[],n[o]=i),i.push(r)})),e[t]=n}}function nI(e,t,r,n){var o=t[n];o&&(Array.isArray(o)?o:[o]).forEach((t=>{"string"==typeof t&&(t=new CA("url",t)),e.push(new $b({accessMethod:r,accessLocation:yb.parse(t.rawData,Kb)}))}))}tI.NAME="Authority Info Access";class oI extends sA{constructor(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];if(Yp.BufferSourceConverter.isBufferSource(r[0]))e=Yp.BufferSourceConverter.toArrayBuffer(r[0]);else{var o=r[0],i=Array.isArray(r[1])?r[1].map((e=>Yp.BufferSourceConverter.toArrayBuffer(e))):[];e=yb.serialize(new rw({type:o,values:i}))}super(e,rw)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){var e=this.toTextObjectWithoutValue();return e.Value=this.values.map((e=>new nA("",{"":e}))),e}toTextObjectWithoutValue(){var e=this.toTextObjectEmpty();return e[nA.NAME]===oI.NAME&&(e[nA.NAME]=oA.toString(this.type)),e}}oI.NAME="Attribute";class iI extends oI{constructor(){var e;if(Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0]))super(arguments.length<=0?void 0:arguments[0]);else{var t=new lO({printableString:arguments.length<=0?void 0:arguments[0]});super(VS,[yb.serialize(t)])}null!==(e=this.password)&&void 0!==e||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){var t=yb.parse(this.values[0],lO);this.password=t.toString()}}toTextObject(){var e=this.toTextObjectWithoutValue();return e[nA.VALUE]=this.password,e}}iI.NAME="Challenge Password";class sI extends oI{constructor(){var e;if(Yp.BufferSourceConverter.isBufferSource(arguments.length<=0?void 0:arguments[0]))super(arguments.length<=0?void 0:arguments[0]);else{var t=arguments.length<=0?void 0:arguments[0],r=new vw;for(var n of t)r.push(yb.parse(n.rawData,mw));super(HS,[yb.serialize(r)])}null!==(e=this.items)&&void 0!==e||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){var t=yb.parse(this.values[0],vw);this.items=t.map((e=>QA.create(yb.serialize(e))))}}toTextObject(){var e=this.toTextObjectWithoutValue(),t=this.items.map((e=>e.toTextObject()));for(var r of t)e[r[nA.NAME]]=r;return e}}sI.NAME="Extensions";class aI{static register(e,t){this.items.set(e,t)}static create(e){var t=new oI(e),r=this.items.get(t.type);return r?new r(e):t}}aI.items=new Map;var cI,uI="crypto.signatureFormatter";var lI=cI=class{static createPssParams(e,t){var r=cI.getHashAlgorithm(e);return r?new Wk({hashAlgorithm:r,maskGenAlgorithm:new pw({algorithm:_k,parameters:yb.serialize(r)}),saltLength:t}):null}static getHashAlgorithm(e){var t=mS.resolve(SO);return"string"==typeof e?t.toAsnAlgorithm({name:e}):"object"==typeof e&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if(!("hash"in e))return new pw({algorithm:Sk,parameters:null});var t;if("string"==typeof e.hash)t=e.hash;else{if(!e.hash||"object"!=typeof e.hash||!("name"in e.hash)||"string"!=typeof e.hash.name)throw new Error("Cannot get hash algorithm name");t=e.hash.name.toUpperCase()}switch(t.toLowerCase()){case"sha-1":return new pw({algorithm:Ek,parameters:null});case"sha-256":return new pw({algorithm:Bk,parameters:null});case"sha-384":return new pw({algorithm:Tk,parameters:null});case"sha-512":return new pw({algorithm:Dk,parameters:null})}break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e)||"number"!=typeof e.saltLength)throw new Error("Cannot get 'saltLength' from 'alg' argument");var r=cI.createPssParams(e.hash,e.saltLength);if(!r)throw new Error("Cannot create PSS parameters");return new pw({algorithm:Ik,parameters:yb.serialize(r)})}return new pw({algorithm:Ik,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Sk:return{name:"RSASSA-PKCS1-v1_5"};case Ek:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Bk:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Tk:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Dk:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Ik:if(e.parameters){var t=yb.parse(e.parameters,Wk);return{name:"RSA-PSS",hash:mS.resolve(SO).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}return{name:"RSA-PSS"}}return null}};lI=cI=vb([wS()],lI),mS.registerSingleton(vO,lI);var dI=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new pw({algorithm:Nk});case"sha-256":return new pw({algorithm:Kk});case"sha-384":return new pw({algorithm:qk});case"sha-512":return new pw({algorithm:Lk})}return null}toWebAlgorithm(e){switch(e.algorithm){case Nk:return{name:"SHA-1"};case Kk:return{name:"SHA-256"};case qk:return{name:"SHA-384"};case Lk:return{name:"SHA-512"}}return null}};dI=vb([wS()],dI),mS.registerSingleton(vO,dI);class hI{addPadding(e,t){var r=Yp.BufferSourceConverter.toUint8Array(t),n=new Uint8Array(e);return n.set(r,e-r.length),n}removePadding(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=Yp.BufferSourceConverter.toUint8Array(e),n=0;n<r.length;n++)if(r[n]){r=r.slice(n);break}if(t&&r[0]>127){var o=new Uint8Array(r.length+1);return o.set(r,1),o.buffer}return r.buffer}toAsnSignature(e,t){if("ECDSA"===e.name){var r=e.namedCurve,n=hI.namedCurveSize.get(r)||hI.defaultNamedCurveSize,o=new vk,i=Yp.BufferSourceConverter.toUint8Array(t);return o.r=this.removePadding(i.slice(0,n),!0),o.s=this.removePadding(i.slice(n,n+n),!0),yb.serialize(o)}return null}toWebSignature(e,t){if("ECDSA"===e.name){var r=yb.parse(t,vk),n=e.namedCurve,o=hI.namedCurveSize.get(n)||hI.defaultNamedCurveSize,i=this.addPadding(o,this.removePadding(r.r)),s=this.addPadding(o,this.removePadding(r.s));return Yp.combine(i,s)}return null}}hI.namedCurveSize=new Map,hI.defaultNamedCurveSize=32;var pI,yI="1.3.101.110",fI="1.3.101.111",gI="1.3.101.112",bI="1.3.101.113",mI=class{toAsnAlgorithm(e){var t=null;switch(e.name.toLowerCase()){case"ed25519":t=gI;break;case"x25519":t=yI;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=gI;break;case"ed448":t=bI}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=yI;break;case"x448":t=fI}}return t?new pw({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case gI:return{name:"Ed25519"};case bI:return{name:"EdDSA",namedCurve:"Ed448"};case yI:return{name:"X25519"};case fI:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};mI=vb([wS()],mI),mS.registerSingleton(vO,mI);(class extends GA{constructor(e){GA.isAsnEncoded(e)?super(e,wO):super(e),this.tag=zA.CertificateRequestTag}onInit(e){this.tbs=yb.serialize(e.certificationRequestInfo),this.publicKey=new VA(e.certificationRequestInfo.subjectPKInfo);var t=mS.resolve(SO);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map((e=>aI.create(yb.serialize(e))));var r=this.getAttribute(HS);this.extensions=[],r instanceof sI&&(this.extensions=r.items),this.subjectName=new yA(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(var t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter((t=>t.type===e))}getExtension(e){for(var t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter((t=>t.type===e))}verify(){var e=arguments,t=this;return G((function*(){var r=e.length>0&&void 0!==e[0]?e[0]:uA.get(),n=Z(Z({},t.publicKey.algorithm),t.signatureAlgorithm),o=yield t.publicKey.export(n,["verify"],r),i=mS.resolveAll(uI).reverse(),s=null;for(var a of i)if(s=a.toWebSignature(n,t.signature))break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return yield r.subtle.verify(t.signatureAlgorithm,o,s,t.tbs)}))()}toTextObject(){var e=this.toTextObjectEmpty(),t=yb.parse(this.rawData,wO),r=t.certificationRequestInfo,n=new nA("",{Version:"".concat(ww[r.version]," (").concat(r.version,")"),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){var o=new nA("");for(var i of this.attributes){var s=i.toTextObject();o[s[nA.NAME]]=s}n.Attributes=o}return e.Data=n,e.Signature=new nA("",{Algorithm:iA.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}).NAME="PKCS#10 Certificate Request";class wI extends GA{constructor(e){GA.isAsnEncoded(e)?super(e,Sw):super(e),this.tag=zA.CertificateTag}onInit(e){var t=e.tbsCertificate;this.tbs=yb.serialize(t),this.serialNumber=Yp.Convert.ToHex(t.serialNumber),this.subjectName=new yA(t.subject),this.subject=new yA(t.subject).toString(),this.issuerName=new yA(t.issuer),this.issuer=this.issuerName.toString();var r=mS.resolve(SO);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;var n=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!n)throw new Error("Cannot get 'notBefore' value");this.notBefore=n;var o=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!o)throw new Error("Cannot get 'notAfter' value");this.notAfter=o,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map((e=>QA.create(yb.serialize(e))))),this.publicKey=new VA(t.subjectPublicKeyInfo)}getExtension(e){for(var t of this.extensions)if("string"==typeof e){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter((t=>"string"==typeof e?t.type===e:t instanceof e))}verify(){var e=arguments,t=this;return G((function*(){var r,n,o=e.length>0&&void 0!==e[0]?e[0]:{},i=e.length>1&&void 0!==e[1]?e[1]:uA.get(),s=o.publicKey;try{if(s)if("publicKey"in s)r=Z(Z({},s.publicKey.algorithm),t.signatureAlgorithm),n=yield s.publicKey.export(r,["verify"],i);else if(s instanceof VA)r=Z(Z({},s.algorithm),t.signatureAlgorithm),n=yield s.export(r,["verify"],i);else if(Yp.BufferSourceConverter.isBufferSource(s)){var a=new VA(s);r=Z(Z({},a.algorithm),t.signatureAlgorithm),n=yield a.export(r,["verify"],i)}else r=Z(Z({},s.algorithm),t.signatureAlgorithm),n=s;else r=Z(Z({},t.publicKey.algorithm),t.signatureAlgorithm),n=yield t.publicKey.export(r,["verify"],i)}catch(e){return!1}var c=mS.resolveAll(uI).reverse(),u=null;for(var l of c)if(u=l.toWebSignature(r,t.signature))break;if(!u)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");var d=yield i.subtle.verify(t.signatureAlgorithm,n,u,t.tbs);if(o.signatureOnly)return d;var h=(o.date||new Date).getTime();return d&&t.notBefore.getTime()<h&&h<t.notAfter.getTime()}))()}getThumbprint(){var e=arguments,t=this;return G((function*(){for(var r,n="SHA-1",o=e.length,i=new Array(o),s=0;s<o;s++)i[s]=e[s];return i[0]&&(i[0].subtle?r=i[0]:(n=i[0]||n,r=i[1])),null!=r||(r=uA.get()),yield r.subtle.digest(n,t.rawData)}))()}isSelfSigned(){var e=arguments,t=this;return G((function*(){var r=e.length>0&&void 0!==e[0]?e[0]:uA.get();return t.subject===t.issuer&&(yield t.verify({signatureOnly:!0},r))}))()}toTextObject(){var e=this.toTextObjectEmpty(),t=yb.parse(this.rawData,Sw),r=t.tbsCertificate,n=new nA("",{Version:"".concat(ww[r.version]," (").concat(r.version,")"),"Serial Number":r.serialNumber,"Signature Algorithm":iA.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new nA("",{"Not Before":r.validity.notBefore.getTime(),"Not After":r.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(r.issuerUniqueID&&(n["Issuer Unique ID"]=r.issuerUniqueID),r.subjectUniqueID&&(n["Subject Unique ID"]=r.subjectUniqueID),this.extensions.length){var o=new nA("");for(var i of this.extensions){var s=i.toTextObject();o[s[nA.NAME]]=s}n.Extensions=o}return e.Data=n,e.Signature=new nA("",{Algorithm:iA.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}wI.NAME="Certificate";class vI{static createSelfSigned(e){var t=arguments,r=this;return G((function*(){var n=t.length>1&&void 0!==t[1]?t[1]:uA.get();if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return r.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},n)}))()}static create(e){var t=arguments;return G((function*(){var r,n,o=t.length>1&&void 0!==t[1]?t[1]:uA.get();n=e.publicKey instanceof VA?e.publicKey.rawData:"publicKey"in e.publicKey?e.publicKey.publicKey.rawData:Yp.BufferSourceConverter.isBufferSource(e.publicKey)?e.publicKey:yield o.subtle.exportKey("spki",e.publicKey);var i=e.serialNumber?Yp.BufferSourceConverter.toUint8Array(Yp.Convert.FromHex(e.serialNumber)):o.getRandomValues(new Uint8Array(16));i[0]>127&&(i[0]&=127),i.length>1&&0===i[0]&&(i[1]|=128);var s=e.notBefore||new Date,a=e.notAfter||new Date(s.getTime()+31536e6),c=new Sw({tbsCertificate:new kw({version:ww.v3,serialNumber:i,validity:new bw({notBefore:s,notAfter:a}),extensions:new vw((null===(r=e.extensions)||void 0===r?void 0:r.map((e=>yb.parse(e.rawData,mw))))||[]),subjectPublicKeyInfo:yb.parse(n,yw)})});if(e.subject){var u=e.subject instanceof yA?e.subject:new yA(e.subject);c.tbsCertificate.subject=yb.parse(u.toArrayBuffer(),Rb)}if(e.issuer){var l=e.issuer instanceof yA?e.issuer:new yA(e.issuer);c.tbsCertificate.issuer=yb.parse(l.toArrayBuffer(),Rb)}var d={hash:"SHA-256"},h="signingKey"in e?Z(Z(Z({},d),e.signingAlgorithm),e.signingKey.algorithm):Z(Z({},d),e.signingAlgorithm),p=mS.resolve(SO);c.tbsCertificate.signature=c.signatureAlgorithm=p.toAsnAlgorithm(h);var y=yb.serialize(c.tbsCertificate),f="signingKey"in e?yield o.subtle.sign(h,e.signingKey,y):e.signature,g=mS.resolveAll(uI).reverse(),b=null;for(var m of g)if(b=m.toAsnSignature(h,f))break;if(!b)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=b,new wI(yb.serialize(c))}))()}}!function(e){e[e.unspecified=0]="unspecified",e[e.keyCompromise=1]="keyCompromise",e[e.cACompromise=2]="cACompromise",e[e.affiliationChanged=3]="affiliationChanged",e[e.superseded=4]="superseded",e[e.cessationOfOperation=5]="cessationOfOperation",e[e.certificateHold=6]="certificateHold",e[e.removeFromCRL=8]="removeFromCRL",e[e.privilegeWithdrawn=9]="privilegeWithdrawn",e[e.aACompromise=10]="aACompromise"}(pI||(pI={})),QA.register(tm,WA),QA.register(Bm,JA),QA.register(Gm,$A),QA.register(aw,YA),QA.register(Zb,HA),QA.register(ew,ZA),QA.register(wm,eI),QA.register(Jb,tI),aI.register(VS,iI),aI.register(HS,sI),mS.registerSingleton(uI,class{toAsnSignature(e,t){return Yp.BufferSourceConverter.toArrayBuffer(t)}toWebSignature(e,t){return Yp.BufferSourceConverter.toArrayBuffer(t)}}),mS.registerSingleton(uI,hI),hI.namedCurveSize.set("P-256",32),hI.namedCurveSize.set("K-256",32),hI.namedCurveSize.set("P-384",48),hI.namedCurveSize.set("P-521",66);var kI="/",SI=(new TextEncoder).encode(kI),OI=SI[0];let AI=class e{constructor(e,t){if(W(this,"_buf",void 0),"string"==typeof e)this._buf=ya(e);else{if(!(e instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=e}if(null==t&&(t=!0),t&&this.clean(),0===this._buf.byteLength||this._buf[0]!==OI)throw new Error("Invalid key")}toString(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"utf8";return fa(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return"Key(".concat(this.toString(),")")}static withNamespaces(t){return new e(t.join(kI))}static random(){return new e(Math.random().toString().substring(2))}static asKey(t){return t instanceof Uint8Array||"string"==typeof t?new e(t):"function"==typeof t.uint8Array?new e(t.uint8Array()):null}clean(){if(null!=this._buf&&0!==this._buf.byteLength||(this._buf=SI),this._buf[0]!==OI){var e=new Uint8Array(this._buf.byteLength+1);e.fill(OI,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===OI;)this._buf=this._buf.subarray(0,-1)}less(e){for(var t=this.list(),r=e.list(),n=0;n<t.length;n++){if(r.length<n+1)return!1;var o=t[n],i=r[n];if(o<i)return!0;if(o>i)return!1}return t.length<r.length}reverse(){return e.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){var e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(kI).slice(1)}type(){return function(e){var t=e.split(":");if(t.length<2)return"";return t.slice(0,-1).join(":")}(this.baseNamespace())}name(){return e=this.baseNamespace(),(t=e.split(":"))[t.length-1];var e,t}instance(t){return new e(this.toString()+":"+t)}path(){var t=this.parent().toString();return t.endsWith(kI)||(t+=kI),t+=this.type(),new e(t)}parent(){var t=this.list();return 1===t.length?new e(kI):new e(t.slice(0,-1).join(kI))}child(t){return this.toString()===kI?t:t.toString()===kI?this:new e(this.toString()+t.toString(),!1)}isAncestorOf(e){return e.toString()!==this.toString()&&e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()!==this.toString()&&this.toString().startsWith(e.toString())}isTopLevel(){return 1===this.list().length}concat(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return e.withNamespaces([...this.namespaces(),...(o=r.map((e=>e.namespaces())),[].concat(...o))]);var o}};class II extends d.TypedEventEmitter{listen(){return G((function*(){throw new Kp("WebRTCTransport.createListener")}))()}getAddrs(){return[]}updateAnnounceAddrs(){}close(){return G((function*(){}))()}}function xI(){var e,t=sl(),r=!1;return{sink:(e=G((function*(e){if(r)throw new Error("already piped");r=!0,t.resolve(e)})),function(t){return e.apply(this,arguments)}),source:ee((function*(){var e=yield V(t.promise);yield*_(M(e))}))()}}var PI,EI=65535,CI=Boolean(null===(PI=globalThis.process)||void 0===PI||null===(PI=PI.env)||void 0===PI?void 0:PI.DUMP_SESSION_KEYS);function BI(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function TI(e){if("boolean"!=typeof e)throw new Error("boolean expected, not ".concat(e))}function DI(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function RI(e){if(!BI(e))throw new Error("Uint8Array expected");for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(r.length>0&&!r.includes(e.length))throw new Error("Uint8Array expected of length "+r+", got length="+e.length)}function jI(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function NI(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function UI(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var n=0;n<t.length;n++)t[n].fill(0)}var KI=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function qI(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!BI(e))throw new Error("Uint8Array expected, got "+typeof e);e=zI(e)}return e}var LI=(e,t)=>{function r(r){if(RI(r),!KI)throw new Error("Non little-endian hardware is not yet supported");for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];if(void 0!==e.nonceLength){var s=o[0];if(!s)throw new Error("nonce / iv required");e.varSizeNonce?RI(s):RI(s,e.nonceLength)}var a=e.tagLength;a&&void 0!==o[1]&&RI(o[1]);var c=t(r,...o),u=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");RI(t)}},l=!1;return{encrypt(e,t){if(l)throw new Error("cannot encrypt() twice with same key + nonce");return l=!0,RI(e),u(c.encrypt.length,t),c.encrypt(e,t)},decrypt(e,t){if(RI(e),a&&e.length<a)throw new Error("invalid ciphertext length: smaller than tagLength="+a);return u(c.decrypt.length,t),c.decrypt(e,t)}}}return Object.assign(r,e),r};function _I(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(r&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function MI(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);var o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i);e.setUint32(t+4,s,n),e.setUint32(t+0,a,n)}function FI(e,t,r){TI(r);var n,o=new Uint8Array(16),i=(n=o,new DataView(n.buffer,n.byteOffset,n.byteLength));return MI(i,0,BigInt(t),r),MI(i,8,BigInt(e),r),o}function zI(e){return Uint8Array.from(e)}var GI=e=>Uint8Array.from(e.split("").map((e=>e.charCodeAt(0)))),VI=GI("expand 16-byte k"),HI=GI("expand 32-byte k"),WI=NI(VI),JI=NI(HI);function $I(e,t){return e<<t|e>>>32-t}function YI(e){return e.byteOffset%4==0}var ZI=2**32-1,QI=new Uint32Array;function XI(e,t){var{allowShortKeys:r,extendNonceFn:n,counterLength:o,counterRight:i,rounds:s}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return DI(o),DI(s),TI(i),TI(r),function(t,a,c,u){var l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;RI(t),RI(a),RI(c);var d=c.length;if(void 0===u&&(u=new Uint8Array(d)),RI(u),DI(l),l<0||l>=ZI)throw new Error("arx: counter overflow");if(u.length<d)throw new Error("arx: output (".concat(u.length,") is shorter than data (").concat(d,")"));var h,p,y=[],f=t.length;if(32===f)y.push(h=zI(t)),p=JI;else{if(16!==f||!r)throw new Error("arx: invalid 32-byte key, got length=".concat(f));(h=new Uint8Array(32)).set(t),h.set(t,16),p=WI,y.push(h)}YI(a)||y.push(a=zI(a));var g=NI(h);if(n){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");n(p,g,NI(a.subarray(0,16)),g),a=a.subarray(16)}var b=16-o;if(b!==a.length)throw new Error("arx: nonce must be ".concat(b," or 16 bytes"));if(12!==b){var m=new Uint8Array(12);m.set(a,i?0:12-a.length),a=m,y.push(a)}var w=NI(a);return function(e,t,r,n,o,i,s,a){for(var c=o.length,u=new Uint8Array(64),l=NI(u),d=YI(o)&&YI(i),h=d?NI(o):QI,p=d?NI(i):QI,y=0;y<c;s++){if(e(t,r,n,l,s,a),s>=ZI)throw new Error("arx: counter overflow");var f=Math.min(64,c-y);if(d&&64===f){var g=y/4;if(y%4!=0)throw new Error("arx: invalid block position");for(var b,m=0;m<16;m++)p[b=g+m]=h[b]^l[m];y+=64}else{for(var w,v=0;v<f;v++)i[w=y+v]=o[w]^u[v];y+=f}}}(e,p,g,w,c,u,l,s),UI(...y),u}}var ex=(e,t)=>255&e[t++]|(255&e[t++])<<8;class tx{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,RI(e=qI(e),32);var t=ex(e,0),r=ex(e,2),n=ex(e,4),o=ex(e,6),i=ex(e,8),s=ex(e,10),a=ex(e,12),c=ex(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|r<<3),this.r[2]=7939&(r>>>10|n<<6),this.r[3]=8191&(n>>>7|o<<9),this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,this.r[6]=8191&(i>>>14|s<<2),this.r[7]=8065&(s>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(var u=0;u<8;u++)this.pad[u]=ex(e,16+2*u)}process(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2]?0:2048,{h:n,r:o}=this,i=o[0],s=o[1],a=o[2],c=o[3],u=o[4],l=o[5],d=o[6],h=o[7],p=o[8],y=o[9],f=ex(e,t+0),g=ex(e,t+2),b=ex(e,t+4),m=ex(e,t+6),w=ex(e,t+8),v=ex(e,t+10),k=ex(e,t+12),S=ex(e,t+14),O=n[0]+(8191&f),A=n[1]+(8191&(f>>>13|g<<3)),I=n[2]+(8191&(g>>>10|b<<6)),x=n[3]+(8191&(b>>>7|m<<9)),P=n[4]+(8191&(m>>>4|w<<12)),E=n[5]+(w>>>1&8191),C=n[6]+(8191&(w>>>14|v<<2)),B=n[7]+(8191&(v>>>11|k<<5)),T=n[8]+(8191&(k>>>8|S<<8)),D=n[9]+(S>>>5|r),R=0,j=R+O*i+A*(5*y)+I*(5*p)+x*(5*h)+P*(5*d);R=j>>>13,j&=8191;var N=(R+=(j+=E*(5*l)+C*(5*u)+B*(5*c)+T*(5*a)+D*(5*s))>>>13)+O*s+A*i+I*(5*y)+x*(5*p)+P*(5*h);R=N>>>13,N&=8191,R+=(N+=E*(5*d)+C*(5*l)+B*(5*u)+T*(5*c)+D*(5*a))>>>13,N&=8191;var U=R+O*a+A*s+I*i+x*(5*y)+P*(5*p);R=U>>>13,U&=8191,R+=(U+=E*(5*h)+C*(5*d)+B*(5*l)+T*(5*u)+D*(5*c))>>>13,U&=8191;var K=R+O*c+A*a+I*s+x*i+P*(5*y);R=K>>>13,K&=8191,R+=(K+=E*(5*p)+C*(5*h)+B*(5*d)+T*(5*l)+D*(5*u))>>>13,K&=8191;var q=R+O*u+A*c+I*a+x*s+P*i;R=q>>>13,q&=8191,R+=(q+=E*(5*y)+C*(5*p)+B*(5*h)+T*(5*d)+D*(5*l))>>>13,q&=8191;var L=R+O*l+A*u+I*c+x*a+P*s;R=L>>>13,L&=8191,R+=(L+=E*i+C*(5*y)+B*(5*p)+T*(5*h)+D*(5*d))>>>13,L&=8191;var _=R+O*d+A*l+I*u+x*c+P*a;R=_>>>13,_&=8191,R+=(_+=E*s+C*i+B*(5*y)+T*(5*p)+D*(5*h))>>>13,_&=8191;var M=R+O*h+A*d+I*l+x*u+P*c;R=M>>>13,M&=8191,R+=(M+=E*a+C*s+B*i+T*(5*y)+D*(5*p))>>>13,M&=8191;var F=R+O*p+A*h+I*d+x*l+P*u;R=F>>>13,F&=8191,R+=(F+=E*c+C*a+B*s+T*i+D*(5*y))>>>13,F&=8191;var z=R+O*y+A*p+I*h+x*d+P*l;R=z>>>13,z&=8191,R+=(z+=E*u+C*c+B*a+T*s+D*i)>>>13,z&=8191,j=8191&(R=(R=(R<<2)+R|0)+(j&=8191)|0),N+=R>>>=13,n[0]=j,n[1]=N,n[2]=U,n[3]=K,n[4]=q,n[5]=L,n[6]=_,n[7]=M,n[8]=F,n[9]=z}finalize(){var{h:e,pad:t}=this,r=new Uint16Array(10),n=e[1]>>>13;e[1]&=8191;for(var o=2;o<10;o++)e[o]+=n,n=e[o]>>>13,e[o]&=8191;e[0]+=5*n,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,r[0]=e[0]+5,n=r[0]>>>13,r[0]&=8191;for(var i=1;i<10;i++)r[i]=e[i]+n,n=r[i]>>>13,r[i]&=8191;r[9]-=8192;for(var s=(1^n)-1,a=0;a<10;a++)r[a]&=s;s=~s;for(var c=0;c<10;c++)e[c]=e[c]&s|r[c];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);var u=e[0]+t[0];e[0]=65535&u;for(var l=1;l<8;l++)u=(e[l]+t[l]|0)+(u>>>16)|0,e[l]=65535&u;UI(r)}update(e){jI(this),RI(e=qI(e));for(var{buffer:t,blockLen:r}=this,n=e.length,o=0;o<n;){var i=Math.min(r-this.pos,n-o);if(i!==r)t.set(e.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===r&&(this.process(t,0,!1),this.pos=0);else for(;r<=n-o;o+=r)this.process(e,o)}return this}destroy(){UI(this.h,this.r,this.buffer,this.pad)}digestInto(e){jI(this),function(e,t){RI(e);var r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;var{buffer:t,h:r}=this,{pos:n}=this;if(n){for(t[n++]=1;n<16;n++)t[n]=0;this.process(t,0,!0)}this.finalize();for(var o=0,i=0;i<8;i++)e[o++]=r[i]>>>0,e[o++]=r[i]>>>8;return e}digest(){var{buffer:e,outputLen:t}=this;this.digestInto(e);var r=e.slice(0,t);return this.destroy(),r}}var rx,nx,ox,ix=(nx=(e,t)=>rx(t).update(qI(e)).digest(),ox=(rx=e=>new tx(e))(new Uint8Array(32)),nx.outputLen=ox.outputLen,nx.blockLen=ox.blockLen,nx.create=e=>rx(e),nx);function sx(e,t,r,n,o){for(var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:20,s=e[0],a=e[1],c=e[2],u=e[3],l=t[0],d=t[1],h=t[2],p=t[3],y=t[4],f=t[5],g=t[6],b=t[7],m=o,w=r[0],v=r[1],k=r[2],S=s,O=a,A=c,I=u,x=l,P=d,E=h,C=p,B=y,T=f,D=g,R=b,j=m,N=w,U=v,K=k,q=0;q<i;q+=2)j=$I(j^(S=S+x|0),16),x=$I(x^(B=B+j|0),12),j=$I(j^(S=S+x|0),8),x=$I(x^(B=B+j|0),7),N=$I(N^(O=O+P|0),16),P=$I(P^(T=T+N|0),12),N=$I(N^(O=O+P|0),8),P=$I(P^(T=T+N|0),7),U=$I(U^(A=A+E|0),16),E=$I(E^(D=D+U|0),12),U=$I(U^(A=A+E|0),8),E=$I(E^(D=D+U|0),7),K=$I(K^(I=I+C|0),16),C=$I(C^(R=R+K|0),12),K=$I(K^(I=I+C|0),8),C=$I(C^(R=R+K|0),7),K=$I(K^(S=S+P|0),16),P=$I(P^(D=D+K|0),12),K=$I(K^(S=S+P|0),8),P=$I(P^(D=D+K|0),7),j=$I(j^(O=O+E|0),16),E=$I(E^(R=R+j|0),12),j=$I(j^(O=O+E|0),8),E=$I(E^(R=R+j|0),7),N=$I(N^(A=A+C|0),16),C=$I(C^(B=B+N|0),12),N=$I(N^(A=A+C|0),8),C=$I(C^(B=B+N|0),7),U=$I(U^(I=I+x|0),16),x=$I(x^(T=T+U|0),12),U=$I(U^(I=I+x|0),8),x=$I(x^(T=T+U|0),7);var L=0;n[L++]=s+S|0,n[L++]=a+O|0,n[L++]=c+A|0,n[L++]=u+I|0,n[L++]=l+x|0,n[L++]=d+P|0,n[L++]=h+E|0,n[L++]=p+C|0,n[L++]=y+B|0,n[L++]=f+T|0,n[L++]=g+D|0,n[L++]=b+R|0,n[L++]=m+j|0,n[L++]=w+N|0,n[L++]=v+U|0,n[L++]=k+K|0}var ax=XI(sx,{counterRight:!1,counterLength:4,allowShortKeys:!1}),cx=new Uint8Array(16),ux=(e,t)=>{e.update(t);var r=t.length%16;r&&e.update(cx.subarray(r))},lx=new Uint8Array(32);function dx(e,t,r,n,o){var i=e(t,r,lx),s=ix.create(i);o&&ux(s,o),ux(s,n);var a=FI(n.length,o?o.length:0,!0);s.update(a);var c=s.digest();return UI(i,a),c}var hx,px=LI({blockSize:64,nonceLength:12,tagLength:16},(hx=ax,(e,t,r)=>{var n=16;return{encrypt(o,i){var s=o.length;(i=_I(s+n,i,!1)).set(o);var a=i.subarray(0,-16);hx(e,t,a,a,1);var c=dx(hx,e,t,a,r);return i.set(c,s),UI(c),i},decrypt(o,i){i=_I(o.length-n,i,!1);var s=o.subarray(0,-16),a=o.subarray(-16),c=dx(hx,e,t,s,r);if(!function(e,t){if(e.length!==t.length)return!1;for(var r=0,n=0;n<e.length;n++)r|=e[n]^t[n];return 0===r}(a,c))throw new Error("invalid tag");return i.set(o.subarray(0,-16)),hx(e,t,i,i,1),UI(c),i}}}));var yx=Uint8Array.from([0]),fx=Uint8Array.of();var gx={hashSHA256:e=>su(e.subarray()),getHKDF(e,t){var r=function(e,t,r){return jn(e),void 0===r&&(r=new Uint8Array(e.outputLen)),vu(e,Yn(r),Yn(t))}(su,t,e),n=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32;jn(e),Dn(n);var o=e.outputLen;if(n>255*o)throw new Error("Length should be <= 255*HashLen");var i=Math.ceil(n/o);void 0===r&&(r=fx);for(var s=new Uint8Array(i*o),a=vu.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen),l=0;l<i;l++)yx[0]=l+1,c.update(0===l?fx:u).update(r).update(yx).digestInto(u),s.set(u,o*l),a._cloneInto(c);return a.destroy(),c.destroy(),Un(u,yx),s.slice(0,n)}(su,r,void 0,96),o=n;return[o.subarray(0,32),o.subarray(32,64),o.subarray(64,96)]},generateX25519KeyPair(){var e=Ri.utils.randomPrivateKey();return{publicKey:Ri.getPublicKey(e),privateKey:e}},generateX25519KeyPairFromSeed:e=>({publicKey:Ri.getPublicKey(e),privateKey:e}),generateX25519SharedKey:(e,t)=>Ri.getSharedSecret(e.subarray(),t.subarray()),chaCha20Poly1305Encrypt:(e,t,r,n)=>px(n,t,r).encrypt(e.subarray()),chaCha20Poly1305Decrypt:(e,t,r,n,o)=>px(n,t,r).decrypt(e.subarray(),o)},bx=gx;var mx=e=>{var t=Bs(2);return t[0]=e>>8,t[1]=e,t};mx.bytes=2;var wx=e=>{if(e.length<2)throw RangeError("Could not decode int16BE");if(e instanceof Uint8Array){var t=0;return t+=e[0]<<8,t+=e[1]}return e.getUint16(0)};function vx(e,t){t.enabled&&CI&&(e?(t("LOCAL_STATIC_PUBLIC_KEY ".concat(fa(e.publicKey,"hex"))),t("LOCAL_STATIC_PRIVATE_KEY ".concat(fa(e.privateKey,"hex")))):t("Missing local static keys."))}function kx(e,t){t.enabled&&CI&&(e?(t("LOCAL_PUBLIC_EPHEMERAL_KEY ".concat(fa(e.publicKey,"hex"))),t("LOCAL_PRIVATE_EPHEMERAL_KEY ".concat(fa(e.privateKey,"hex")))):t("Missing local ephemeral keys."))}function Sx(e,t){t.enabled&&CI&&t(e?"REMOTE_EPHEMERAL_PUBLIC_KEY ".concat(fa(e.subarray(),"hex")):"Missing remote ephemeral keys.")}function Ox(e,t,r){r.enabled&&CI&&(r("CIPHER_STATE_1 ".concat(e.n.getUint64()," ").concat(e.k&&fa(e.k,"hex"))),r("CIPHER_STATE_2 ".concat(t.n.getUint64()," ").concat(t.k&&fa(t.k,"hex"))))}wx.bytes=2;class Ax extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Invalid crypto exchange"),W(this,"code",void 0),this.code=Ax.code}}W(Ax,"code","ERR_INVALID_CRYPTO_EXCHANGE");class Ix{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;W(this,"n",void 0),W(this,"bytes",void 0),W(this,"view",void 0),this.n=e,this.bytes=Cs(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,e,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>4294967295)throw new Error("Cipherstate has reached maximum n, a new handshake must be performed")}}var xx,Px,Ex=Cs(0);class Cx{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;W(this,"k",void 0),W(this,"n",void 0),W(this,"crypto",void 0),this.crypto=e,this.k=t,this.n=new Ix(r)}hasKey(){return Boolean(this.k)}encryptWithAd(e,t){if(!this.hasKey())return t;this.n.assertValue();var r=this.crypto.encrypt(t,this.n.getBytes(),e,this.k);return this.n.increment(),r}decryptWithAd(e,t,r){if(!this.hasKey())return t;this.n.assertValue();var n=this.crypto.decrypt(t,this.n.getBytes(),e,this.k,r);return this.n.increment(),n}}class Bx{constructor(e,t){W(this,"cs",void 0),W(this,"ck",void 0),W(this,"h",void 0),W(this,"crypto",void 0),this.crypto=e;var r=p.fromString(t,"utf-8");this.h=function(e,t){if(t.length<=32){var r=Cs(32);return r.set(t),r}return e.hash(t)}(e,r),this.ck=this.h,this.cs=new Cx(e)}mixKey(e){var[t,r]=this.crypto.hkdf(this.ck,e);this.ck=t,this.cs=new Cx(this.crypto,r)}mixHash(e){this.h=this.crypto.hash(new Ns(this.h,e))}encryptAndHash(e){var t=this.cs.encryptWithAd(this.h,e);return this.mixHash(t),t}decryptAndHash(e){var t=this.cs.decryptWithAd(this.h,e);return this.mixHash(e),t}split(){var[e,t]=this.crypto.hkdf(this.ck,Ex);return[new Cx(this.crypto,e),new Cx(this.crypto,t)]}}class Tx{constructor(e){W(this,"ss",void 0),W(this,"s",void 0),W(this,"e",void 0),W(this,"rs",void 0),W(this,"re",void 0),W(this,"initiator",void 0),W(this,"crypto",void 0);var{crypto:t,protocolName:r,prologue:n,initiator:o,s:i,e:s,rs:a,re:c}=e;this.crypto=t,this.ss=new Bx(t,r),this.ss.mixHash(n),this.initiator=o,this.s=i,this.e=s,this.rs=a,this.re=c}writeE(){if(this.e)throw new Error("ephemeral keypair is already set");var e=this.crypto.generateKeypair();return this.ss.mixHash(e.publicKey),this.e=e,e.publicKey}writeS(){if(!this.s)throw new Error("static keypair is not set");return this.ss.encryptAndHash(this.s.publicKey)}writeEE(){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.re))}writeES(){if(this.initiator){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}else{if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}}writeSE(){if(this.initiator){if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}else{if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}}readE(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(this.re)throw new Error("remote ephemeral public key is already set");if(e.byteLength<t+32)throw new Error("message is not long enough");this.re=e.sublist(t,t+32),this.ss.mixHash(this.re)}readS(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(this.rs)throw new Error("remote static public key is already set");var r=32+(this.ss.cs.hasKey()?16:0);if(e.byteLength<t+r)throw new Error("message is not long enough");var n=e.sublist(t,t+r);return this.rs=this.ss.decryptAndHash(n),r}readEE(){this.writeEE()}readES(){this.writeES()}readSE(){this.writeSE()}}class Dx extends Tx{writeMessageA(e){return new Ns(this.writeE(),this.ss.encryptAndHash(e))}writeMessageB(e){var t=this.writeE();this.writeEE();var r=this.writeS();return this.writeES(),new Ns(t,r,this.ss.encryptAndHash(e))}writeMessageC(e){var t=this.writeS();return this.writeSE(),new Ns(t,this.ss.encryptAndHash(e))}readMessageA(e){try{return this.readE(e),this.ss.decryptAndHash(e.sublist(32))}catch(e){throw new Ax("handshake stage 0 validation fail: ".concat(e.message))}}readMessageB(e){try{this.readE(e),this.readEE();var t=this.readS(e,32);return this.readES(),this.ss.decryptAndHash(e.sublist(32+t))}catch(e){throw new Ax("handshake stage 1 validation fail: ".concat(e.message))}}readMessageC(e){try{var t=this.readS(e);return this.readSE(),this.ss.decryptAndHash(e.sublist(t))}catch(e){throw new Ax("handshake stage 2 validation fail: ".concat(e.message))}}}function Rx(e,t,r){return jx.apply(this,arguments)}function jx(){return(jx=G((function*(e,t,r){var n=yield e.sign(Kx(t));return Px.encode({identityKey:$u(e.publicKey),identitySig:n,extensions:r})}))).apply(this,arguments)}function Nx(e,t,r){return Ux.apply(this,arguments)}function Ux(){return(Ux=G((function*(e,t,r){try{var n=Px.decode(e),o=Ju(n.identityKey);if(!1===(null==r?void 0:r.equals(o)))throw new Error("Payload identity key ".concat(o," does not match expected remote identity key ").concat(r));if(!t)throw new Error("Remote static does not exist");var i=Kx(t);if(!(yield o.verify(i,n.identitySig)))throw new Error("Invalid payload signature");return n}catch(e){throw new d.UnexpectedPeerError(e.message)}}))).apply(this,arguments)}function Kx(e){var t=ya("noise-libp2p-static-key:");return e instanceof Uint8Array?Ts([t,e],t.length+e.length):(e.prepend(t),e)}function qx(){return qx=G((function*(e,t){var{log:r,connection:n,crypto:o,privateKey:i,prologue:s,s:a,remoteIdentityKey:c,extensions:u}=e,l=yield Rx(i,a.publicKey,u),d=new Dx({crypto:o,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!0,prologue:s,s:a});vx(d.s,r),r.trace("Stage 0 - Initiator starting to send first message."),yield n.write(d.writeMessageA(Ex),t),r.trace("Stage 0 - Initiator finished sending first message."),kx(d.e,r),r.trace("Stage 1 - Initiator waiting to receive first message from responder...");var h,p,y=d.readMessageB(yield n.read(t));r.trace("Stage 1 - Initiator received the message."),Sx(d.re,r),h=d.rs,(p=r).enabled&&CI&&p(h?"REMOTE_STATIC_PUBLIC_KEY ".concat(fa(h.subarray(),"hex")):"Missing remote static public key."),r.trace("Initiator going to check remote's signature...");var f=yield Nx(y,d.rs,c);r.trace("All good with the signature!"),r.trace("Stage 2 - Initiator sending third handshake message."),yield n.write(d.writeMessageC(l),t),r.trace("Stage 2 - Initiator sent message with signed payload.");var[g,b]=d.ss.split();return Ox(g,b,r),{payload:f,encrypt:e=>g.encryptWithAd(Ex,e),decrypt:(e,t)=>b.decryptWithAd(Ex,e,t)}})),qx.apply(this,arguments)}function Lx(){return Lx=G((function*(e,t){var{log:r,connection:n,crypto:o,privateKey:i,prologue:s,s:a,remoteIdentityKey:c,extensions:u}=e,l=yield Rx(i,a.publicKey,u),d=new Dx({crypto:o,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!1,prologue:s,s:a});vx(d.s,r),r.trace("Stage 0 - Responder waiting to receive first message."),d.readMessageA(yield n.read(t)),r.trace("Stage 0 - Responder received first message."),Sx(d.re,r),r.trace("Stage 1 - Responder sending out first message with signed payload and static key."),yield n.write(d.writeMessageB(l),t),r.trace("Stage 1 - Responder sent the second handshake message with signed payload."),kx(d.e,r),r.trace("Stage 2 - Responder waiting for third handshake message...");var h=d.readMessageC(yield n.read(t));r.trace("Stage 2 - Responder received the message, finished handshake.");var p=yield Nx(h,d.rs,c),[y,f]=d.ss.split();return Ox(y,f,r),{payload:p,encrypt:e=>f.encryptWithAd(Ex,e),decrypt:(e,t)=>y.decryptWithAd(Ex,e,t)}})),Lx.apply(this,arguments)}!function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.webtransportCerthashes)for(var n of e.webtransportCerthashes)t.uint32(10),t.bytes(n);if(null!=e.streamMuxers)for(var o of e.streamMuxers)t.uint32(18),t.string(o);!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={webtransportCerthashes:[],streamMuxers:[]},o=null==t?e.len:e.pos+t;e.pos<o;){var i=e.uint32();switch(i>>>3){case 1:var s;if(null!=(null===(s=r.limits)||void 0===s?void 0:s.webtransportCerthashes)&&n.webtransportCerthashes.length===r.limits.webtransportCerthashes)throw new tu('Decode error - map field "webtransportCerthashes" had too many elements');n.webtransportCerthashes.push(e.bytes());break;case 2:var a;if(null!=(null===(a=r.limits)||void 0===a?void 0:a.streamMuxers)&&n.streamMuxers.length===r.limits.streamMuxers)throw new tu('Decode error - map field "streamMuxers" had too many elements');n.streamMuxers.push(e.string());break;default:e.skipType(7&i)}}return n}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(xx||(xx={})),function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.identityKey&&e.identityKey.byteLength>0&&(t.uint32(10),t.bytes(e.identityKey)),null!=e.identitySig&&e.identitySig.byteLength>0&&(t.uint32(18),t.bytes(e.identitySig)),null!=e.extensions&&(t.uint32(34),xx.codec().encode(e.extensions,t)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={identityKey:Cs(0),identitySig:Cs(0)},o=null==t?e.len:e.pos+t;e.pos<o;){var i=e.uint32();switch(i>>>3){case 1:n.identityKey=e.bytes();break;case 2:n.identitySig=e.bytes();break;case 4:var s;n.extensions=xx.codec().decode(e,e.uint32(),{limits:null===(s=r.limits)||void 0===s?void 0:s.extensions});break;default:e.skipType(7&i)}}return n}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(Px||(Px={}));class _x{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};W(this,"protocol","/noise"),W(this,"crypto",void 0),W(this,"prologue",void 0),W(this,"staticKey",void 0),W(this,"extensions",void 0),W(this,"metrics",void 0),W(this,"components",void 0),W(this,Symbol.toStringTag,"@chainsafe/libp2p-noise"),W(this,d.serviceCapabilities,["@libp2p/connection-encryption","@chainsafe/libp2p-noise"]);var{staticNoiseKey:r,extensions:n,crypto:o,prologueBytes:i}=t,{metrics:s}=e;this.components=e;var a=null!=o?o:bx;this.crypto=function(e){return{generateKeypair:e.generateX25519KeyPair,dh:(t,r)=>e.generateX25519SharedKey(t.privateKey,r).subarray(0,32),encrypt:e.chaCha20Poly1305Encrypt,decrypt:e.chaCha20Poly1305Decrypt,hash:e.hashSHA256,hkdf:e.getHKDF}}(a),this.extensions=Z({webtransportCerthashes:[]},n),this.metrics=s?function(e){return{xxHandshakeSuccesses:e.registerCounter("libp2p_noise_xxhandshake_successes_total",{help:"Total count of noise xxHandshakes successes_"}),xxHandshakeErrors:e.registerCounter("libp2p_noise_xxhandshake_error_total",{help:"Total count of noise xxHandshakes errors"}),encryptedPackets:e.registerCounter("libp2p_noise_encrypted_packets_total",{help:"Total count of noise encrypted packets successfully"}),decryptedPackets:e.registerCounter("libp2p_noise_decrypted_packets_total",{help:"Total count of noise decrypted packets"}),decryptErrors:e.registerCounter("libp2p_noise_decrypt_errors_total",{help:"Total count of noise decrypt errors"})}}(s):void 0,this.staticKey=r?a.generateX25519KeyPairFromSeed(r):a.generateX25519KeyPair(),this.prologue=null!=i?i:Cs(0)}secureOutbound(e,t){var n=this;return G((function*(){var o,i,s=bl(e,{lengthEncoder:mx,lengthDecoder:wx,maxDataLength:EI}),a=yield n.performHandshakeInitiator(s,n.components.privateKey,null==t||null===(o=t.remotePeer)||void 0===o?void 0:o.publicKey,t),c=yield n.createSecureConnection(s,a);e.source=c.source,e.sink=c.sink;var u=Ju(a.payload.identityKey);return{conn:e,remoteExtensions:a.payload.extensions,remotePeer:r.peerIdFromPublicKey(u),streamMuxer:!0===(null==t?void 0:t.skipStreamMuxerNegotiation)?void 0:n.getStreamMuxer(null===(i=a.payload.extensions)||void 0===i?void 0:i.streamMuxers)}}))()}getStreamMuxer(e){if(null!=e&&0!==e.length){var t=this.components.upgrader.getStreamMuxers();if(null!=t)for(var r of e){var n=t.get(r);if(null!=n)return n}if(e.length)throw new d.InvalidCryptoExchangeError("Early muxer negotiation was requested but the initiator and responder had no common muxers")}}secureInbound(e,t){var n=this;return G((function*(){var o,i,s=bl(e,{lengthEncoder:mx,lengthDecoder:wx,maxDataLength:EI}),a=yield n.performHandshakeResponder(s,n.components.privateKey,null==t||null===(o=t.remotePeer)||void 0===o?void 0:o.publicKey,t),c=yield n.createSecureConnection(s,a);e.source=c.source,e.sink=c.sink;var u=Ju(a.payload.identityKey);return{conn:e,remoteExtensions:a.payload.extensions,remotePeer:r.peerIdFromPublicKey(u),streamMuxer:!0===(null==t?void 0:t.skipStreamMuxerNegotiation)?void 0:n.getStreamMuxer(null===(i=a.payload.extensions)||void 0===i?void 0:i.streamMuxers)}}))()}performHandshakeInitiator(e,t,r,n){var o=this;return G((function*(){var i,s=!0===(null==n?void 0:n.skipStreamMuxerNegotiation)?[]:[...o.components.upgrader.getStreamMuxers().keys()];try{var a;i=yield function(e,t){return qx.apply(this,arguments)}({connection:e,privateKey:t,remoteIdentityKey:r,log:o.components.logger.forComponent("libp2p:noise:xxhandshake"),crypto:o.crypto,prologue:o.prologue,s:o.staticKey,extensions:Z({streamMuxers:s,webtransportCerthashes:[]},o.extensions)},n),null===(a=o.metrics)||void 0===a||a.xxHandshakeSuccesses.increment()}catch(e){var c;throw null===(c=o.metrics)||void 0===c||c.xxHandshakeErrors.increment(),e}return i}))()}performHandshakeResponder(e,t,r,n){var o=this;return G((function*(){var i,s=!0===(null==n?void 0:n.skipStreamMuxerNegotiation)?[]:[...o.components.upgrader.getStreamMuxers().keys()];try{var a;i=yield function(e,t){return Lx.apply(this,arguments)}({connection:e,privateKey:t,remoteIdentityKey:r,log:o.components.logger.forComponent("libp2p:noise:xxhandshake"),crypto:o.crypto,prologue:o.prologue,s:o.staticKey,extensions:Z({streamMuxers:s,webtransportCerthashes:[]},o.extensions)},n),null===(a=o.metrics)||void 0===a||a.xxHandshakeSuccesses.increment()}catch(e){var c;throw null===(c=o.metrics)||void 0===c||c.xxHandshakeErrors.increment(),e}return i}))()}createSecureConnection(e,t){var r=this;return G((function*(){var n,o,[i,s]=(n=xI(),o=xI(),[{source:n.source,sink:o.sink},{source:o.source,sink:n.sink}]),a=e.unwrap();return yield rh(i,function(e,t){return function(){var r=ee((function*(r){var n,o=!1,i=!1;try{for(var s,a=M(r);o=!(s=yield V(a.next())).done;o=!1)for(var c=s.value,u=0;u<c.length;u+=65519){var l=u+65519;l>c.length&&(l=c.length);var d=void 0;d=c instanceof Uint8Array?e.encrypt(c.subarray(u,l)):e.encrypt(c.sublist(u,l)),null==t||t.encryptedPackets.increment(),yield new Ns(mx(d.byteLength),d)}}catch(e){i=!0,n=e}finally{try{o&&null!=a.return&&(yield V(a.return()))}finally{if(i)throw n}}}));return function(e){return r.apply(this,arguments)}}()}(t,r.metrics),a,(e=>Op(e,{lengthDecoder:wx})),function(e,t){return function(){var r=ee((function*(r){var n,o=!1,i=!1;try{for(var s,a=M(r);o=!(s=yield V(a.next())).done;o=!1)for(var c=s.value,u=0;u<c.length;u+=EI){var l=u+EI;if(l>c.length&&(l=c.length),l-16<u)throw new Error("Invalid chunk");var d=c.sublist(u,l),h=c.subarray(u,l-16);try{var p=e.decrypt(d,h);null==t||t.decryptedPackets.increment(),yield p}catch(e){throw null==t||t.decryptErrors.increment(),e}}}catch(e){i=!0,n=e}finally{try{o&&null!=a.return&&(yield V(a.return()))}finally{if(i)throw n}}}));return function(e){return r.apply(this,arguments)}}()}(t,r.metrics),i),s}))()}}function Mx(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new _x(t,e)}var Fx=Object.values(ua).map((e=>e.decoder)).reduce(((e,t)=>e.or(t))),zx=re(/^a=fingerprint:(?:\w+-[0-9]+)\s((:?[0-9a-fA-F]{2})+)$/m,{fingerprint:1});function Gx(e){var t=e.stringTuples().filter((e=>466===e[0])).map((e=>e[1]))[0];if(void 0===t||""===t)throw new d.InvalidParametersError("Couldn't find a certhash component of multiaddr: ".concat(e.toString()));return t}function Vx(e){var t=function(e){return ts(Fx.decode(e))}(Gx(e)),r=function(e){switch(e){case 17:return"sha-1";case 18:return"sha-256";case 19:return"sha-512";default:throw new qp(e)}}(t.code),n=t.digest.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),""),o=n.match(/.{1,2}/g);if(null==o)throw new Up(n,e.toString());return"".concat(r," ").concat(o.join(":").toUpperCase())}function Hx(e,t){if(void 0===e.sdp)throw new d.InvalidParametersError("Can't munge a missing SDP");var r=e.sdp.includes("\r\n")?"\r\n":"\n";return e.sdp=e.sdp.replace(/\na=ice-ufrag:[^\n]*\n/,"\na=ice-ufrag:"+t+r).replace(/\na=ice-pwd:[^\n]*\n/,"\na=ice-pwd:"+t+r),e}var Wx=ya("libp2p-webrtc-noise:");var Jx,$x=np?"iceconnectionstatechange":"connectionstatechange";function Yx(){return Yx=G((function*(t,r,n){var o=t.createDataChannel("",{negotiated:!0,id:0});try{var i,s,a;if("client"===n.role){n.log.trace("client creating local offer");var c=yield t.createOffer();n.log.trace("client created local offer %s",c.sdp);var u=Hx(c,r);n.log.trace("client setting local offer %s",u.sdp),yield t.setLocalDescription(u);var l=function(e,t){var{host:r,port:n,family:o}=e.toOptions(),i=Vx(e);return{type:"answer",sdp:"v=0\no=- 0 0 IN IP".concat(o," ").concat(r,"\ns=-\nt=0 0\na=ice-lite\nm=application ").concat(n," UDP/DTLS/SCTP webrtc-datachannel\nc=IN IP").concat(o," ").concat(r,"\na=mid:0\na=ice-options:ice2\na=ice-ufrag:").concat(t,"\na=ice-pwd:").concat(t,"\na=fingerprint:").concat(i,"\na=setup:passive\na=sctp-port:5000\na=max-message-size:").concat(Kh,"\na=candidate:1467250027 1 UDP 1467250027 ").concat(r," ").concat(n," typ host\na=end-of-candidates\n")}}(n.remoteAddr,r);n.log.trace("client setting server description %s",l.sdp),yield t.setRemoteDescription(l)}else{var d=function(e,t){var{host:r,port:n,family:o}=e.toOptions();return{type:"offer",sdp:"v=0\no=- 0 0 IN IP".concat(o," ").concat(r,"\ns=-\nc=IN IP").concat(o," ").concat(r,"\nt=0 0\na=ice-options:ice2,trickle\nm=application ").concat(n," UDP/DTLS/SCTP webrtc-datachannel\na=mid:0\na=setup:active\na=ice-ufrag:").concat(t,"\na=ice-pwd:").concat(t,"\na=fingerprint:sha-256 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00\na=sctp-port:5000\na=max-message-size:").concat(Kh,"\na=candidate:1467250027 1 UDP 1467250027 ").concat(r," ").concat(n," typ host\na=end-of-candidates\n")}}(n.remoteAddr,r);n.log.trace("server setting client %s %s",d.type,d.sdp),yield t.setRemoteDescription(d),n.log.trace("server creating local answer");var h=yield t.createAnswer();n.log.trace("server created local answer");var p=Hx(h,r);n.log.trace("server setting local description %s",h.sdp),yield t.setLocalDescription(p)}if("open"!==o.readyState&&(n.log.trace("%s wait for handshake channel to open, starting status %s",n.role,o.readyState),yield dh(o,"open",n.signal)),n.log.trace("%s handshake channel opened",n.role),"server"===n.role){var y,f,g=null!==(y=null===(f=t.remoteFingerprint())||void 0===f?void 0:f.value)&&void 0!==y?y:"";n.remoteAddr=n.remoteAddr.encapsulate(function(t){var r=t.split(":").map((e=>parseInt(e,16))),n=Uint8Array.from(r),o=es(sa.code,n);return e.multiaddr("/certhash/".concat(Ys.encode(o.bytes)))}(g))}var b=function(e){var t;if(null!=e){var r=e.match(zx);return null==r||null===(t=r.groups)||void 0===t?void 0:t.fingerprint}}(null===(i=t.localDescription)||void 0===i?void 0:i.sdp);if(null==b)throw new jp("Could not get fingerprint from local description sdp");n.log.trace("%s performing noise handshake",n.role);var m=function(e,t,r){var n=ya(e.trim().toLowerCase().replaceAll(":",""),"hex"),o=es(sa.code,n),i=Fx.decode(Gx(t)),s=Wx.byteLength+o.bytes.byteLength+i.byteLength;return Ts("server"===r?[Wx,i,o.bytes]:[Wx,o.bytes,i],s)}(b,n.remoteAddr,n.role),w=Mx({prologueBytes:m})(n),v=Ip(Z({channel:o,direction:"outbound",handshake:!0,logger:n.logger},null!==(s=n.dataChannel)&&void 0!==s?s:{})),k=new cp(n,{peerConnection:t,remoteAddr:n.remoteAddr,timeline:{open:Date.now()},metrics:n.events});t.addEventListener($x,(()=>{switch(t.connectionState){case"failed":case"disconnected":case"closed":k.close().catch((e=>{n.log.error("error closing connection",e),k.abort(e)}))}})),null===(a=n.events)||void 0===a||a.increment({peer_connection:!0});var S=new xp(n,{peerConnection:t,metrics:n.events,dataChannelOptions:n.dataChannel});if("client"===n.role)return n.log.trace("%s secure inbound",n.role),yield w.secureInbound(v,{remotePeer:n.remotePeerId,signal:n.signal,skipStreamMuxerNegotiation:!0}),n.log.trace("%s upgrade outbound",n.role),yield n.upgrader.upgradeOutbound(k,{skipProtection:!0,skipEncryption:!0,muxerFactory:S,signal:n.signal});n.log.trace("%s secure outbound",n.role);var O=yield w.secureOutbound(v,{remotePeer:n.remotePeerId,signal:n.signal,skipStreamMuxerNegotiation:!0});k.remoteAddr=k.remoteAddr.encapsulate("/p2p/".concat(O.remotePeer)),n.log.trace("%s upgrade inbound",n.role),yield n.upgrader.upgradeInbound(k,{skipProtection:!0,skipEncryption:!0,muxerFactory:S,signal:n.signal})}catch(e){throw o.close(),e}})),Yx.apply(this,arguments)}function Zx(){return(Zx=G((function*(e,t,r,n){null==n&&(n=yield RTCPeerConnection.generateCertificate({name:"ECDSA",namedCurve:"P-256"}));var o="function"==typeof r?yield r():r;return new RTCPeerConnection(Z(Z({},null!=o?o:{}),{},{certificates:[n]}))}))).apply(this,arguments)}function Qx(e){return Xx.apply(this,arguments)}function Xx(){return(Xx=G((function*(e){var t=yield Zu(e),r=yield crypto.subtle.exportKey("pkcs8",t.privateKey);return["-----BEGIN PRIVATE KEY-----",...fa(new Uint8Array(r),"base64pad").split(/(.{64})/).filter(Boolean),"-----END PRIVATE KEY-----"].join("\n")}))).apply(this,arguments)}class eP{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(W(this,"log",void 0),W(this,"metrics",void 0),W(this,"components",void 0),W(this,"init",void 0),W(this,"certificate",void 0),W(this,"privateKey",void 0),W(this,"emitter",void 0),W(this,"renewCertificateTask",void 0),W(this,d.transportSymbol,!0),W(this,Symbol.toStringTag,"@libp2p/webrtc-direct"),W(this,d.serviceCapabilities,["@libp2p/transport"]),this.log=e.logger.forComponent("libp2p:webrtc-direct"),this.components=e,this.init=t,this.emitter=new d.TypedEventEmitter,null!=t.certificateLifespan&&null!=t.certificateRenewalThreshold&&t.certificateRenewalThreshold>=t.certificateLifespan)throw new d.InvalidParametersError("Certificate renewal threshold must be less than certificate lifespan");null!=e.metrics&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_webrtc-direct_dialer_events_total",{label:"event",help:"Total count of WebRTC-direct dial events by type"})})}start(){var e=this;return G((function*(){e.certificate=yield e.getCertificate()}))()}stop(){var e=this;return G((function*(){null!=e.renewCertificateTask&&clearTimeout(e.renewCertificateTask),e.certificate=void 0}))()}dial(e,t){var n=this;return G((function*(){var o,i;n.log("dial %a",e),t.signal.throwIfAborted();var s=e.getPeerId();null!=s&&(i=r.peerIdFromString(s));var a=function(){return"libp2p+webrtc+v1/"+[...Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:32)].map((()=>Uh.at(Math.floor(Math.random()*Uh.length)))).join("")}(),c=yield function(e,t,r,n){return Zx.apply(this,arguments)}("client",a,"function"==typeof n.init.rtcConfiguration?yield n.init.rtcConfiguration():null!==(o=n.init.rtcConfiguration)&&void 0!==o?o:{});try{var u;return yield function(e,t,r){return Yx.apply(this,arguments)}(c,a,{role:"client",log:n.log,logger:n.components.logger,metrics:n.components.metrics,events:null===(u=n.metrics)||void 0===u?void 0:u.dialerEvents,signal:t.signal,remoteAddr:e,dataChannel:n.init.dataChannel,upgrader:t.upgrader,peerId:n.components.peerId,remotePeerId:i,privateKey:n.components.privateKey})}catch(e){throw c.close(),e}}))()}createListener(e){if(null==this.certificate)throw new d.NotStartedError;return new II(this.components,Z(Z(Z({},this.init),e),{},{certificate:this.certificate,emitter:this.emitter}))}listenFilter(e){return e.filter(yd.exactMatch)}dialFilter(e){return this.listenFilter(e)}getCertificate(e){var t=this;return G((function*(){if(function(e){if(null==e)return!1;return"string"==typeof e.privateKey&&"string"==typeof e.pem&&"string"==typeof e.certhash}(t.init.certificate))return t.log("using provided TLS certificate"),t.init.certificate;var r=yield t.loadOrCreatePrivateKey(),{pem:n,certhash:o}=yield t.loadOrCreateCertificate(r,e);return{privateKey:yield Qx(r),pem:n,certhash:o}}))()}loadOrCreatePrivateKey(){var e=this;return G((function*(){var t;if(null!=e.privateKey)return e.privateKey;var r=null!==(t=e.init.certificateKeychainName)&&void 0!==t?t:"webrtc-direct-certificate-private-key",n=e.getKeychain();try{if(null==n)throw e.log("no keychain configured - not checking for stored private key"),new d.NotFoundError;e.log.trace("checking for stored private key"),e.privateKey=yield n.exportKey(r)}catch(t){if("NotFoundError"!==t.name)throw t;e.log.trace("generating private key"),e.privateKey=yield function(e,t){return Wu.apply(this,arguments)}("ECDSA","P-256"),null!=n?(e.log.trace("storing private key"),yield n.importKey(r,e.privateKey)):e.log("no keychain configured - not storing private key")}return e.privateKey}))()}loadOrCreateCertificate(e,t){var r=this;return G((function*(){var n,o,i;if(null!=r.certificate&&!0!==t)return r.certificate;var s=new AI(null!==(n=r.init.certificateDatastoreKey)&&void 0!==n?n:"/libp2p/webrtc-direct/certificate"),a=yield Zu(e);try{if(!0===t)throw r.log.trace("forcing renewal of TLS certificate"),new d.NotFoundError;r.log.trace("checking for stored TLS certificate"),i=yield r.loadCertificate(s,a)}catch(e){if("NotFoundError"!==e.name)throw e;r.log.trace("generating new TLS certificate"),i=yield r.createCertificate(s,a)}var c=i.notAfter.getTime()-(null!==(o=r.init.certificateRenewalThreshold)&&void 0!==o?o:Mh)-Date.now();return c<0&&(c=100),r.log("will renew TLS certificate after %d ms",c),r.renewCertificateTask=setTimeout((()=>{r.log("renewing TLS certificate"),r.getCertificate(!0).then((e=>{r.certificate=e,r.emitter.safeDispatchEvent("certificate:renew",{detail:e})})).catch((e=>{r.log.error("could not renew certificate - %e",e)}))}),c),{pem:i.toString("pem"),certhash:Ys.encode((yield sa.digest(new Uint8Array(i.rawData))).bytes)}}))()}loadCertificate(e,t){var r=this;return G((function*(){var n,o=yield r.components.datastore.get(e),i=new wI(o),s=i.notAfter.getTime()-(null!==(n=r.init.certificateRenewalThreshold)&&void 0!==n?n:Mh);if(Date.now()>s)throw r.log("stored TLS certificate has expired"),new d.NotFoundError;r.log("loaded certificate, expires in %d ms",s);var a=yield i.publicKey.export(crypto),c=yield crypto.subtle.exportKey("raw",a),u=yield crypto.subtle.exportKey("raw",t.publicKey);if(!Es(new Uint8Array(c,0,c.byteLength),new Uint8Array(u,0,u.byteLength)))throw r.log("stored TLS certificate public key did not match public key from private key"),new d.NotFoundError;return r.log("loaded certificate, expiry time is %o",s),i}))()}createCertificate(e,t){var r=this;return G((function*(){var n,o=new Date,i=new Date(Date.now()+(null!==(n=r.init.certificateLifespan)&&void 0!==n?n:12096e5));o.setMilliseconds(0),i.setMilliseconds(0);var s=yield vI.createSelfSigned({serialNumber:(100000n*BigInt(Math.random().toString().replace(".",""))).toString(16),name:"CN=example.com, C=US, L=CA, O=example, ST=CA",notBefore:o,notAfter:i,keys:t,extensions:[new WA(!1,void 0,!0)]},crypto);return null!=r.getKeychain()?(r.log.trace("storing TLS certificate"),yield r.components.datastore.put(e,ya(s.toString("pem")))):r.log("no keychain is configured so not storing TLS certificate since the private key will not be reused"),s}))()}getKeychain(){try{return this.components.keychain}catch(e){}}}function tP(e){return t=>new Vp(t,e)}function rP(e){if(null!=e[Symbol.asyncIterator])return G((function*(){var t,r=!1,n=!1;try{for(var o,i=M(e);r=!(o=yield i.next()).done;r=!1)o.value}catch(e){n=!0,t=e}finally{try{r&&null!=i.return&&(yield i.return())}finally{if(n)throw t}}}))();for(var t of e);}var nP=null!==(Jx=globalThis.CustomEvent)&&void 0!==Jx?Jx:Event;function oP(){return oP=ee((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(r,n){var o=null!==(r=t.concurrency)&&void 0!==r?r:1/0;o<1&&(o=1/0);var i,s=null!==(n=t.ordered)&&void 0!==n&&n,a=new EventTarget,c=[],u=sl(),l=sl(),d=!1,h=!1;function p(){var e;return s?null===(e=c[0])||void 0===e?void 0:e.done:Boolean(c.find((e=>e.done)))}function*y(){for(;c.length>0&&c[0].done;){var e=c[0];if(c.shift(),!e.ok)throw h=!0,u.resolve(),e.err;yield e.value,u.resolve()}}function*f(){for(;p();)for(var e=0;e<c.length;e++)if(c[e].done){var t=c[e];if(c.splice(e,1),e--,!t.ok)throw h=!0,u.resolve(),t.err;yield t.value,u.resolve()}}for(a.addEventListener("task-complete",(()=>{l.resolve()})),Promise.resolve().then(G((function*(){try{var t,r=!1,n=!1;try{for(var s,l=function*(){var e=s.value;if(c.length===o&&(u=sl(),yield u.promise),h)return 1;var t={done:!1};c.push(t),e().then((e=>{t.done=!0,t.ok=!0,t.value=e,a.dispatchEvent(new nP("task-complete"))}),(e=>{t.done=!0,t.err=e,a.dispatchEvent(new nP("task-complete"))}))},p=M(e);(r=!(s=yield p.next()).done)&&!(yield*l());r=!1);}catch(e){n=!0,t=e}finally{try{r&&null!=p.return&&(yield p.return())}finally{if(n)throw t}}d=!0,a.dispatchEvent(new nP("task-complete"))}catch(e){i=e,a.dispatchEvent(new nP("task-complete"))}})));;){if(p()||(l=sl(),yield V(l.promise)),null!=i)throw i;if(s?yield*_(M(y())):yield*_(M(f())),null!=i)throw i;if(d&&0===c.length)break}}()})),oP.apply(this,arguments)}var iP;!function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.protocolVersion&&(t.uint32(42),t.string(e.protocolVersion)),null!=e.agentVersion&&(t.uint32(50),t.string(e.agentVersion)),null!=e.publicKey&&(t.uint32(10),t.bytes(e.publicKey)),null!=e.listenAddrs)for(var n of e.listenAddrs)t.uint32(18),t.bytes(n);if(null!=e.observedAddr&&(t.uint32(34),t.bytes(e.observedAddr)),null!=e.protocols)for(var o of e.protocols)t.uint32(26),t.string(o);null!=e.signedPeerRecord&&(t.uint32(66),t.bytes(e.signedPeerRecord)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={listenAddrs:[],protocols:[]},o=null==t?e.len:e.pos+t;e.pos<o;){var i=e.uint32();switch(i>>>3){case 5:n.protocolVersion=e.string();break;case 6:n.agentVersion=e.string();break;case 1:n.publicKey=e.bytes();break;case 2:var s;if(null!=(null===(s=r.limits)||void 0===s?void 0:s.listenAddrs)&&n.listenAddrs.length===r.limits.listenAddrs)throw new tu('Decode error - map field "listenAddrs" had too many elements');n.listenAddrs.push(e.bytes());break;case 4:n.observedAddr=e.bytes();break;case 3:var a;if(null!=(null===(a=r.limits)||void 0===a?void 0:a.protocols)&&n.protocols.length===r.limits.protocols)throw new tu('Decode error - map field "protocols" had too many elements');n.protocols.push(e.string());break;case 8:n.signedPeerRecord=e.bytes();break;default:e.skipType(7&i)}}return n}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(iP||(iP={}));var sP={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnLimitedConnection:!0,concurrency:32};function aP(e,t,r,n,o){return cP.apply(this,arguments)}function cP(){return cP=G((function*(t,n,o,i,s){if(o("received identify from %p",i.remotePeer),null==s)throw new d.InvalidMessageError("message was null or undefined");var a,c={};if(s.listenAddrs.length>0&&(c.addresses=s.listenAddrs.map((t=>({isCertified:!1,multiaddr:e.multiaddr(t)})))),s.protocols.length>0&&(c.protocols=s.protocols),null!=s.publicKey){var u=Ju(s.publicKey);if(!r.peerIdFromPublicKey(u).equals(i.remotePeer))throw new d.InvalidMessageError("public key did not match remote PeerId");c.publicKey=u}if(null!=s.signedPeerRecord){o.trace("received signedPeerRecord from %p",i.remotePeer);var l,h=s.signedPeerRecord,p=yield el.openAndCertify(h,il.DOMAIN),y=il.createFromProtobuf(p.payload),f=r.peerIdFromCID(p.publicKey.toCID());if(!y.peerId.equals(f))throw new d.InvalidMessageError("signing key does not match PeerId in the PeerRecord");if(!i.remotePeer.equals(y.peerId))throw new d.InvalidMessageError("signing key does not match remote PeerId");try{l=yield t.get(y.peerId)}catch(e){if("NotFoundError"!==e.name)throw e}if(null!=l&&(c.metadata=l.metadata,null!=l.peerRecordEnvelope)){var g=yield el.createFromProtobuf(l.peerRecordEnvelope),b=il.createFromProtobuf(g.payload);b.seqNumber>=y.seqNumber&&(o("sequence number was lower or equal to existing sequence number - stored: %d received: %d",b.seqNumber,y.seqNumber),y=b,h=l.peerRecordEnvelope)}c.peerRecordEnvelope=h,c.addresses=y.multiaddrs.map((e=>({isCertified:!0,multiaddr:e}))),a={seq:y.seqNumber,addresses:y.multiaddrs}}else o("%p did not send a signed peer record",i.remotePeer);if(o.trace("patching %p with",i.remotePeer,c),yield t.patch(i.remotePeer,c),null!=s.agentVersion||null!=s.protocolVersion){var m={};null!=s.agentVersion&&(m.AgentVersion=ya(s.agentVersion)),null!=s.protocolVersion&&(m.ProtocolVersion=ya(s.protocolVersion)),o.trace("merging %p metadata",i.remotePeer,m),yield t.merge(i.remotePeer,{metadata:m})}var w={peerId:i.remotePeer,protocolVersion:s.protocolVersion,agentVersion:s.agentVersion,publicKey:s.publicKey,listenAddrs:s.listenAddrs.map((t=>e.multiaddr(t))),observedAddr:null==s.observedAddr?void 0:e.multiaddr(s.observedAddr),protocols:s.protocols,signedPeerRecord:a,connection:i};return n.safeDispatchEvent("peer:identify",{detail:w}),w})),cP.apply(this,arguments)}class uP{constructor(e,t){var r,n,o,i,s,a,c,u,l;W(this,"host",void 0),W(this,"protocol",void 0),W(this,"started",void 0),W(this,"timeout",void 0),W(this,"peerId",void 0),W(this,"privateKey",void 0),W(this,"peerStore",void 0),W(this,"registrar",void 0),W(this,"addressManager",void 0),W(this,"maxInboundStreams",void 0),W(this,"maxOutboundStreams",void 0),W(this,"maxMessageSize",void 0),W(this,"maxObservedAddresses",void 0),W(this,"events",void 0),W(this,"runOnLimitedConnection",void 0),W(this,"log",void 0),this.protocol=t.protocol,this.started=!1,this.peerId=e.peerId,this.privateKey=e.privateKey,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.events=e.events,this.log=t.log,this.timeout=null!==(r=t.timeout)&&void 0!==r?r:sP.timeout,this.maxInboundStreams=null!==(n=t.maxInboundStreams)&&void 0!==n?n:sP.maxInboundStreams,this.maxOutboundStreams=null!==(o=t.maxOutboundStreams)&&void 0!==o?o:sP.maxOutboundStreams,this.maxMessageSize=null!==(i=t.maxMessageSize)&&void 0!==i?i:sP.maxMessageSize,this.maxObservedAddresses=null!==(s=t.maxObservedAddresses)&&void 0!==s?s:sP.maxObservedAddresses,this.runOnLimitedConnection=null!==(a=t.runOnLimitedConnection)&&void 0!==a?a:sP.runOnLimitedConnection,this.host={protocolVersion:"".concat(null!==(c=t.protocolPrefix)&&void 0!==c?c:sP.protocolPrefix,"/").concat("0.1.0"),agentVersion:(u=e.nodeInfo,l=t.agentVersion,null!=l?l:u.userAgent)}}isStarted(){return this.started}start(){var e=this;return G((function*(){e.started||(yield e.peerStore.merge(e.peerId,{metadata:{AgentVersion:ya(e.host.agentVersion),ProtocolVersion:ya(e.host.protocolVersion)}}),yield e.registrar.handle(e.protocol,(t=>{e.handleProtocol(t).catch((t=>{e.log.error(t)}))}),{maxInboundStreams:e.maxInboundStreams,maxOutboundStreams:e.maxOutboundStreams,runOnLimitedConnection:e.runOnLimitedConnection}),e.started=!0)}))()}stop(){var e=this;return G((function*(){yield e.registrar.unhandle(e.protocol),e.started=!1}))()}}class lP extends uP{constructor(e){var t,r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,Z(Z({},o),{},{protocol:"/".concat(null!==(t=o.protocolPrefix)&&void 0!==t?t:sP.protocolPrefix,"/").concat("id/push","/").concat("1.0.0"),log:e.logger.forComponent("libp2p:identify-push")})),W(this,"connectionManager",void 0),W(this,"concurrency",void 0),W(this,d.serviceCapabilities,["@libp2p/identify-push"]),this.connectionManager=e.connectionManager,this.concurrency=null!==(r=o.concurrency)&&void 0!==r?r:sP.concurrency,(null!==(n=o.runOnSelfUpdate)&&void 0!==n?n:sP.runOnSelfUpdate)&&e.events.addEventListener("self:peer:update",(e=>{this.push().catch((e=>{this.log.error(e)}))}))}push(){var t=this;return G((function*(){var r,n;if(t.isStarted()){var o=t.addressManager.getAddresses().map((t=>t.decapsulateCode(e.protocols("p2p").code))),i=new il({peerId:t.peerId,multiaddrs:o}),s=yield el.seal(i,t.privateKey),a=t.registrar.getProtocols(),c=yield t.peerStore.get(t.peerId),u=fa(null!==(r=c.metadata.get("AgentVersion"))&&void 0!==r?r:ya(t.host.agentVersion)),l=fa(null!==(n=c.metadata.get("ProtocolVersion"))&&void 0!==n?n:ya(t.host.protocolVersion)),h=t;yield rP(function(e){return oP.apply(this,arguments)}(function(){return p.apply(this,arguments)}(),{concurrency:t.concurrency}))}function p(){return p=ee((function*(){var e=function*(e){if(!(yield V(h.peerStore.get(e.remotePeer))).protocols.includes(h.protocol))return 1;yield G((function*(){var t,r=AbortSignal.timeout(h.timeout);d.setMaxListeners(1/0,r);try{var n=ml(t=yield e.newStream(h.protocol,{signal:r,runOnLimitedConnection:h.runOnLimitedConnection}),{maxDataLength:h.maxMessageSize}).pb(iP);yield n.write({listenAddrs:o.map((e=>e.bytes)),signedPeerRecord:s.marshal(),protocols:a,agentVersion:u,protocolVersion:l},{signal:r}),yield t.close({signal:r})}catch(e){var i;h.log.error("could not push identify update to peer",e),null===(i=t)||void 0===i||i.abort(e)}}))};for(var t of h.connectionManager.getConnections())yield*e(t)})),p.apply(this,arguments)}}))()}handleProtocol(e){var t=this;return G((function*(){var{connection:r,stream:n}=e;try{if(t.peerId.equals(r.remotePeer))throw new Error("received push from ourselves?");var o={signal:AbortSignal.timeout(t.timeout)},i=ml(n,{maxDataLength:t.maxMessageSize}).pb(iP),s=yield i.read(o);yield n.close(o),yield aP(t.peerStore,t.events,t.log,r,s)}catch(e){return t.log.error("received invalid message",e),void n.abort(e)}t.log.trace("handled push from %p",r.remotePeer)}))()}}var dP=4,hP=16,pP=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function yP(e,t){t.length===hP&&e.length===dP&&function(e,t,r){var n=0;for(var o of e)if(!(n<t)){if(n>r)break;if(255!==o)return!1;n++}return!0}(t,0,11)&&(t=t.slice(12)),t.length===dP&&e.length===hP&&function(e,t,r,n){var o=0;for(var i of e)if(!(o<r)){if(o>n)break;if(i!==t[o])return!1;o++}return!0}(e,pP,0,11)&&(e=e.slice(12));var r=e.length;if(r!=t.length)throw new Error("Failed to mask ip");for(var n=new Uint8Array(r),o=0;o<r;o++)n[o]=e[o]&t[o];return n}function fP(e,t){if(t!==8*dP&&t!==8*hP)throw new Error("Invalid CIDR mask");if(e<0||e>t)throw new Error("Invalid CIDR mask");for(var r=t/8,n=new Uint8Array(r),o=0;o<r;o++)e>=8?(n[o]=255,e-=8):(n[o]=255-(255>>e),e=0);return n}class gP{constructor(e,t){if(null==t)({network:this.network,mask:this.mask}=function(e){var[t,r]=e.split("/");if(!t||!r)throw new Error("Failed to parse given CIDR: "+e);var n=dP,o=Dl(t);if(null==o&&(n=hP,null==(o=Rl(t))))throw new Error("Failed to parse given CIDR: "+e);var i=parseInt(r,10);if(Number.isNaN(i)||String(i).length!==r.length||i<0||i>8*n)throw new Error("Failed to parse given CIDR: "+e);var s=fP(i,8*n);return{network:yP(o,s),mask:s}}(e));else{var r=jl(e);if(null==r)throw new Error("Failed to parse network");t=String(t);var n=parseInt(t,10);if(Number.isNaN(n)||String(n).length!==t.length||n<0||n>8*r.length){var o=jl(t);if(null==o)throw new Error("Failed to parse mask");this.mask=o}else this.mask=fP(n,8*r.length);this.network=yP(r,this.mask)}}contains(e){return function(e,t){if("string"==typeof t&&(t=jl(t)),null==t)throw new Error("Invalid ip");if(t.length!==e.network.length)return!1;for(var r=0;r<t.length;r++)if((e.network[r]&e.mask[r])!==(t[r]&e.mask[r]))return!1;return!0}({network:this.network,mask:this.mask},e)}toString(){var e=function(e){var t=0;for(var[r,n]of e.entries()){if(255!==n){for(;128&n;)t++,n<<=1;if(128&n)return-1;for(var o=r+1;o<e.length;o++)if(0!=e[o])return-1;break}t+=8}return t}(this.mask),t=-1!==e?String(e):function(e){var t="0x";for(var r of e)t+=(r>>4).toString(16)+(15&r).toString(16);return t}(this.mask);return function(e){switch(e.length){case dP:return e.join(".");case hP:for(var t=[],r=0;r<e.length;r++)r%2==0&&t.push(e[r].toString(16).padStart(2,"0")+e[r+1].toString(16).padStart(2,"0"));return t.join(":");default:throw new Error("Invalid ip length")}}(this.network)+"/"+t}}function bP(e){try{var[[t,r]]=e.stringTuples();if(null==r)return!1;if(41===t)return n=r,new gP("2000::/3").contains(n)}catch(e){}var n;return!1}var mP,wP={};var vP=(mP||(mP=1,function(){var e,t,r,n,o,i,s,a;a=function(e){return[(e&255<<24)>>>24,(e&255<<16)>>>16,(65280&e)>>>8,255&e].join(".")},s=function(e){var r,n,o,i,s,a;for(r=[],o=i=0;i<=3&&0!==e.length;o=++i){if(o>0){if("."!==e[0])throw new Error("Invalid IP");e=e.substring(1)}s=(a=t(e))[0],n=a[1],e=e.substring(n),r.push(s)}if(0!==e.length)throw new Error("Invalid IP");switch(r.length){case 1:if(r[0]>4294967295)throw new Error("Invalid IP");return r[0]>>>0;case 2:if(r[0]>255||r[1]>16777215)throw new Error("Invalid IP");return(r[0]<<24|r[1])>>>0;case 3:if(r[0]>255||r[1]>255||r[2]>65535)throw new Error("Invalid IP");return(r[0]<<24|r[1]<<16|r[2])>>>0;case 4:if(r[0]>255||r[1]>255||r[2]>255||r[3]>255)throw new Error("Invalid IP");return(r[0]<<24|r[1]<<16|r[2]<<8|r[3])>>>0;default:throw new Error("Invalid IP")}},n=(r=function(e){return e.charCodeAt(0)})("0"),i=r("a"),o=r("A"),t=function(e){var t,s,a,c,u;for(c=0,t=10,s="9",a=0,e.length>1&&"0"===e[a]&&("x"===e[a+1]||"X"===e[a+1]?(a+=2,t=16):"0"<=e[a+1]&&e[a+1]<="9"&&(a++,t=8,s="7")),u=a;a<e.length;){if("0"<=e[a]&&e[a]<=s)c=c*t+(r(e[a])-n)>>>0;else{if(16!==t)break;if("a"<=e[a]&&e[a]<="f")c=c*t+(10+r(e[a])-i)>>>0;else{if(!("A"<=e[a]&&e[a]<="F"))break;c=c*t+(10+r(e[a])-o)>>>0}}if(c>4294967295)throw new Error("too large");a++}if(a===u)throw new Error("empty octet");return[c,a]},e=function(){function e(e,t){var r,n,o;if("string"!=typeof e)throw new Error("Missing `net' parameter");if(t||(o=e.split("/",2),e=o[0],t=o[1]),t||(t=32),"string"==typeof t&&t.indexOf(".")>-1){try{this.maskLong=s(t)}catch(e){throw new Error("Invalid mask: "+t)}for(r=n=32;n>=0;r=--n)if(this.maskLong===4294967295<<32-r>>>0){this.bitmask=r;break}}else{if(!t&&0!==t)throw new Error("Invalid mask: empty");this.bitmask=parseInt(t,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(s(e)&this.maskLong)>>>0}catch(t){throw new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+t);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return e.prototype.contains=function(t){return"string"==typeof t&&(t.indexOf("/")>0||4!==t.split(".").length)&&(t=new e(t)),t instanceof e?this.contains(t.base)&&this.contains(t.broadcast||t.last):(s(t)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},e.prototype.next=function(t){return null==t&&(t=1),new e(a(this.netLong+this.size*t),this.mask)},e.prototype.forEach=function(e){var t,r,n;for(n=s(this.first),r=s(this.last),t=0;n<=r;)e(a(n),n,t),t++,n++},e.prototype.toString=function(){return this.base+"/"+this.bitmask},e}(),wP.ip2long=s,wP.long2ip=a,wP.Netmask=e}.call(wP)),wP),kP=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map((e=>new vP.Netmask(e)));function SP(e){for(var t of kP)if(t.contains(e))return!0;return!1}function OP(e){return Nl(e)?SP(e):/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(e)?function(e){var t=e.split(":");if(t.length<2)return!1;var r=t[t.length-1].padStart(4,"0"),n=t[t.length-2].padStart(4,"0");return SP("".concat(parseInt(n.substring(0,2),16),".").concat(parseInt(n.substring(2),16),".").concat(parseInt(r.substring(0,2),16),".").concat(parseInt(r.substring(2),16)))}(e):function(e){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)}(e)?function(e){var t=e.split(":");return SP(t[t.length-1])}(e):Ul(e)?function(e){return/^::$/.test(e)||/^::1$/.test(e)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(e)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(e)||/^ff([0-9a-fA-F]{2,2}):/i.test(e)}(e):void 0}function AP(e){try{var t;if(!function(e){try{var[[t]]=e.stringTuples();return 4===t||41===t}catch(e){}return!1}(e))return!1;var[[,r]]=e.stringTuples();return null!=r&&(null!==(t=OP(r))&&void 0!==t&&t)}catch(e){}return!0}class IP extends uP{constructor(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,Z(Z({},n),{},{protocol:"/".concat(null!==(t=n.protocolPrefix)&&void 0!==t?t:sP.protocolPrefix,"/").concat("id","/").concat("1.0.0"),log:e.logger.forComponent("libp2p:identify")})),W(this,d.serviceCapabilities,["@libp2p/identify"]),(null!==(r=n.runOnConnectionOpen)&&void 0!==r?r:sP.runOnConnectionOpen)&&e.events.addEventListener("connection:open",(e=>{var t=e.detail;this.identify(t).catch((e=>{e.name!==d.UnsupportedProtocolError.name&&this.log.error("error during identify trigged by connection:open",e)}))}))}_identify(e){var t=arguments,r=this;return G((function*(){var n,o=t.length>1&&void 0!==t[1]?t[1]:{};if(null==o.signal){var i=AbortSignal.timeout(r.timeout);d.setMaxListeners(1/0,i),o=Z(Z({},o),{},{signal:i})}try{var s=ml(n=yield e.newStream(r.protocol,Z(Z({},o),{},{runOnLimitedConnection:r.runOnLimitedConnection})),{maxDataLength:r.maxMessageSize}).pb(iP),a=yield s.read(o);return yield n.close(o),a}catch(e){var c;throw null===(c=n)||void 0===c||c.abort(e),e}}))()}identify(e){var t=arguments,n=this;return G((function*(){var o=t.length>1&&void 0!==t[1]?t[1]:{},i=yield n._identify(e,o),{publicKey:s,protocols:a,observedAddr:c}=i;if(null==s)throw new d.InvalidMessageError("public key was missing from identify message");var u=Ju(s),l=r.peerIdFromCID(u.toCID());if(!e.remotePeer.equals(l))throw new d.InvalidMessageError("identified peer does not match the expected peer");if(n.peerId.equals(l))throw new d.InvalidMessageError("identified peer is our own peer id?");return n.maybeAddObservedAddress(c),n.log("identify completed for peer %p and protocols %o",l,a),aP(n.peerStore,n.events,n.log,e,i)}))()}maybeAddObservedAddress(t){var r=function(t){if(null!=t&&t.length>0)try{return e.multiaddr(t)}catch(e){}}(t);null!=r&&(this.log.trace("our observed address was %a",r),AP(r)?this.log.trace("our observed address was private"):41!==r.stringTuples()[0][0]||bP(r)?sd.exactMatch(r)||(this.log.trace("storing the observed address"),this.addressManager.addObservedAddr(r)):this.log.trace("our observed address was IPv6 but not a global unicast address"))}handleProtocol(t){var r=this;return G((function*(){var{connection:n,stream:o}=t,i=AbortSignal.timeout(r.timeout);d.setMaxListeners(1/0,i);try{var s=yield r.peerStore.get(r.peerId),a=r.addressManager.getAddresses().map((t=>t.decapsulateCode(e.protocols("p2p").code))),c=s.peerRecordEnvelope;if(a.length>0&&null==c){var u=new il({peerId:r.peerId,multiaddrs:a});c=(yield el.seal(u,r.privateKey)).marshal().subarray()}var l=n.remoteAddr.bytes;rd.matches(n.remoteAddr)||(l=void 0);var h=ml(o).pb(iP);yield h.write({protocolVersion:r.host.protocolVersion,agentVersion:r.host.agentVersion,publicKey:$u(r.privateKey.publicKey),listenAddrs:a.map((e=>e.bytes)),signedPeerRecord:c,observedAddr:l,protocols:s.protocols},{signal:i}),yield o.close({signal:i})}catch(e){r.log.error("could not respond to identify request",e),o.abort(e)}}))()}}function xP(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new IP(t,e)}function PP(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new lP(t,e)}class EP extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"The frame was invalid"),this.name="InvalidFrameError"}}W(EP,"name","InvalidFrameError");class CP extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unrequested ping error"),this.name="UnrequestedPingError"}}W(CP,"name","UnrequestedPingError");class BP extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unrequested ping error"),this.name="NotMatchingPingError"}}W(BP,"name","NotMatchingPingError");class TP extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Invalid state"),this.name="InvalidStateError"}}W(TP,"name","InvalidStateError");class DP extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Strean already exists"),this.name="StreamAlreadyExistsError"}}W(DP,"name","StreamAlreadyExistsError");class RP extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Decode invalid version"),this.name="DecodeInvalidVersionError"}}W(RP,"name","DecodeInvalidVersionError");class jP extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Both clients"),this.name="BothClientsError"}}W(jP,"name","BothClientsError");class NP extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Receive window exceeded"),this.name="ReceiveWindowExceededError"}}W(NP,"name","ReceiveWindowExceededError");var UP,KP,qP=new Set([EP.name,CP.name,BP.name,DP.name,RP.name,jP.name,NP.name]),LP=262144,_P={enableKeepAlive:!0,keepAliveInterval:3e4,maxInboundStreams:1e3,maxOutboundStreams:1e3,initialStreamWindowSize:LP,maxStreamWindowSize:16777216,maxMessageSize:65536};!function(e){e[e.Data=0]="Data",e[e.WindowUpdate=1]="WindowUpdate",e[e.Ping=2]="Ping",e[e.GoAway=3]="GoAway"}(UP||(UP={})),function(e){e[e.SYN=1]="SYN",e[e.ACK=2]="ACK",e[e.FIN=4]="FIN",e[e.RST=8]="RST"}(KP||(KP={})),Object.values(KP).filter((e=>"string"!=typeof e));var MP;!function(e){e[e.NormalTermination=0]="NormalTermination",e[e.ProtocolError=1]="ProtocolError",e[e.InternalError=2]="InternalError"}(MP||(MP={}));var FP=2**24;let zP=class{constructor(e){W(this,"source",void 0),W(this,"buffer",void 0),W(this,"frameInProgress",void 0),this.source=function(e){if(void 0!==e[Symbol.iterator]){var t=e[Symbol.iterator]();return t.return=void 0,{[Symbol.iterator]:()=>t}}if(void 0!==e[Symbol.asyncIterator]){var r=e[Symbol.asyncIterator]();return r.return=void 0,{[Symbol.asyncIterator]:()=>r}}throw new Error("a source must be either an iterable or an async iterable")}(e),this.buffer=new Ns,this.frameInProgress=!1}emitFrames(){var e=this;return ee((function*(){var t,r=!1,n=!1;try{for(var o,i=M(e.source);r=!(o=yield V(i.next())).done;r=!1){var s=o.value;for(e.buffer.append(s);;){var a=e.readHeader();if(void 0===a)break;var{type:c,length:u}=a;c===UP.Data?(e.frameInProgress=!0,yield{header:a,readData:e.readBytes.bind(e,u)}):yield{header:a}}}}catch(e){n=!0,t=e}finally{try{r&&null!=i.return&&(yield V(i.return()))}finally{if(n)throw t}}}))()}readHeader(){if(this.frameInProgress)throw new TP("decoding frame already in progress");if(!(this.buffer.length<12)){var e=function(e){if(0!==e[0])throw new EP("Invalid frame version");return{type:e[1],flag:(e[2]<<8)+e[3],streamID:e[4]*FP+(e[5]<<16)+(e[6]<<8)+e[7],length:e[8]*FP+(e[9]<<16)+(e[10]<<8)+e[11]}}(this.buffer.subarray(0,12));return this.buffer.consume(12),e}}readBytes(e){var t=this;return G((function*(){if(t.buffer.length<e){var r,n=!1,o=!1;try{for(var i,s=M(t.source);n=!(i=yield s.next()).done;n=!1){var a=i.value;if(t.buffer.append(a),t.buffer.length>=e)break}}catch(e){o=!0,r=e}finally{try{n&&null!=s.return&&(yield s.return())}finally{if(o)throw r}}}var c=t.buffer.sublist(0,e);return t.buffer.consume(e),t.frameInProgress=!1,c}))()}};function GP(e){var t=new Uint8Array(12);return t[1]=e.type,t[2]=e.flag>>>8,t[3]=e.flag,t[4]=e.streamID>>>24,t[5]=e.streamID>>>16,t[6]=e.streamID>>>8,t[7]=e.streamID,t[8]=e.length>>>24,t[9]=e.length>>>16,t[10]=e.length>>>8,t[11]=e.length,t}var VP;!function(e){e[e.Init=0]="Init",e[e.SYNSent=1]="SYNSent",e[e.SYNReceived=2]="SYNReceived",e[e.Established=3]="Established",e[e.Finished=4]="Finished"}(VP||(VP={}));class HP extends dp{constructor(e){super(Z(Z({},e),{},{onEnd:t=>{var r;this.state=VP.Finished,null===(r=e.onEnd)||void 0===r||r.call(e,t)}})),W(this,"name",void 0),W(this,"state",void 0),W(this,"config",void 0),W(this,"_id",void 0),W(this,"sendWindowCapacity",void 0),W(this,"sendWindowCapacityUpdate",void 0),W(this,"recvWindow",void 0),W(this,"recvWindowCapacity",void 0),W(this,"epochStart",void 0),W(this,"getRTT",void 0),W(this,"sendFrame",void 0),this.config=e.config,this._id=parseInt(e.id,10),this.name=e.name,this.state=e.state,this.sendWindowCapacity=LP,this.recvWindow=this.config.initialStreamWindowSize,this.recvWindowCapacity=this.recvWindow,this.epochStart=Date.now(),this.getRTT=e.getRTT,this.sendFrame=e.sendFrame,this.source=Jd(this.source,(()=>{this.sendWindowUpdate()}))}sendNewStream(){return G((function*(){}))()}sendData(e){var t=arguments,r=this;return G((function*(){var n=t.length>1&&void 0!==t[1]?t[1]:{};for(e=e.sublist();0!==e.byteLength;){var o,i;if(0===r.sendWindowCapacity)if(null===(o=r.log)||void 0===o||o.trace("wait for send window capacity, status %s",r.status),yield r.waitForSendWindowCapacity(n),"closed"===r.status||"aborted"===r.status||"reset"===r.status)return void(null===(i=r.log)||void 0===i||i.trace("%s while waiting for send window capacity",r.status));var s=Math.min(r.sendWindowCapacity,r.config.maxMessageSize-12,e.length),a=r.getSendFlags();r.sendFrame({type:UP.Data,flag:a,streamID:r._id,length:s},e.sublist(0,s)),r.sendWindowCapacity-=s,e.consume(s)}}))()}sendReset(){var e=this;return G((function*(){e.sendFrame({type:UP.WindowUpdate,flag:KP.RST,streamID:e._id,length:0})}))()}sendCloseWrite(){var e=this;return G((function*(){var t=e.getSendFlags()|KP.FIN;e.sendFrame({type:UP.WindowUpdate,flag:t,streamID:e._id,length:0})}))()}sendCloseRead(){return G((function*(){}))()}waitForSendWindowCapacity(){var e=arguments,t=this;return G((function*(){var r,n=e.length>0&&void 0!==e[0]?e[0]:{};if(!(t.sendWindowCapacity>0)){var o,i,s=()=>{"open"===t.status||"closing"===t.status?i(new d.AbortError("Stream aborted")):o()};null===(r=n.signal)||void 0===r||r.addEventListener("abort",s);try{yield new Promise(((e,r)=>{t.sendWindowCapacityUpdate=()=>{e()},i=r,o=e}))}finally{var a;null===(a=n.signal)||void 0===a||a.removeEventListener("abort",s)}}}))()}handleWindowUpdate(e){var t;null===(t=this.log)||void 0===t||t.trace("stream received window update id=%s",this._id),this.processFlags(e.flag);var r,n=this.sendWindowCapacity;(this.sendWindowCapacity+=e.length,0===n&&e.length>0)&&(null===(r=this.sendWindowCapacityUpdate)||void 0===r||r.call(this))}handleData(e,t){var r=this;return G((function*(){var n;if(null===(n=r.log)||void 0===n||n.trace("stream received data id=%s",r._id),r.processFlags(e.flag),r.recvWindowCapacity<e.length)throw new NP("Receive window exceeded");var o=yield t();r.recvWindowCapacity-=e.length,r.sourcePush(o)}))()}processFlags(e){(e&KP.ACK)===KP.ACK&&this.state===VP.SYNSent&&(this.state=VP.Established),(e&KP.FIN)===KP.FIN&&this.remoteCloseWrite(),(e&KP.RST)===KP.RST&&this.reset()}getSendFlags(){switch(this.state){case VP.Init:return this.state=VP.SYNSent,KP.SYN;case VP.SYNReceived:return this.state=VP.Established,KP.ACK;default:return 0}}sendWindowUpdate(){var e=this.getSendFlags(),t=Date.now(),r=this.getRTT();if(0===e&&r>-1&&t-this.epochStart<4*r&&(this.recvWindow=Math.min(2*this.recvWindow,this.config.maxStreamWindowSize)),!(this.recvWindowCapacity>=this.recvWindow&&0===e)){var n=this.recvWindow-this.recvWindowCapacity;this.recvWindowCapacity=this.recvWindow,this.epochStart=t,this.sendFrame({type:UP.WindowUpdate,flag:e,streamID:this._id,length:n})}}}var WP="/yamux/1.0.0";class JP{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};W(this,"protocol",WP),W(this,"_components",void 0),W(this,"_init",void 0),W(this,Symbol.toStringTag,"@chainsafe/libp2p-yamux"),W(this,d.serviceCapabilities,["@libp2p/stream-multiplexing"]),this._components=e,this._init=t}createStreamMuxer(e){return new $P(this._components,Z(Z({},this._init),e))}}class $P{constructor(e,t){var r,n=this;W(this,"protocol",WP),W(this,"source",void 0),W(this,"sink",void 0),W(this,"config",void 0),W(this,"log",void 0),W(this,"logger",void 0),W(this,"closeController",void 0),W(this,"nextStreamID",void 0),W(this,"_streams",void 0),W(this,"nextPingID",void 0),W(this,"activePing",void 0),W(this,"rtt",void 0),W(this,"client",void 0),W(this,"localGoAway",void 0),W(this,"remoteGoAway",void 0),W(this,"numInboundStreams",void 0),W(this,"numOutboundStreams",void 0),W(this,"onIncomingStream",void 0),W(this,"onStreamEnd",void 0),this.client="outbound"===t.direction,this.config=Z(Z({},_P),t),this.logger=e.logger,this.log=this.logger.forComponent("libp2p:yamux"),function(e){if(e.keepAliveInterval<=0)throw new d.InvalidParametersError("keep-alive interval must be positive");if(e.maxInboundStreams<0)throw new d.InvalidParametersError("max inbound streams must be larger or equal 0");if(e.maxOutboundStreams<0)throw new d.InvalidParametersError("max outbound streams must be larger or equal 0");if(e.initialStreamWindowSize<LP)throw new d.InvalidParametersError("InitialStreamWindowSize must be larger or equal 256 kB");if(e.maxStreamWindowSize<e.initialStreamWindowSize)throw new d.InvalidParametersError("MaxStreamWindowSize must be larger than the InitialStreamWindowSize");if(e.maxStreamWindowSize>2**32-1)throw new d.InvalidParametersError("MaxStreamWindowSize must be less than equal MAX_UINT32");if(e.maxMessageSize<1024)throw new d.InvalidParametersError("MaxMessageSize must be greater than a kilobyte")}(this.config),this.closeController=new AbortController,d.setMaxListeners(1/0,this.closeController.signal),this.onIncomingStream=t.onIncomingStream,this.onStreamEnd=t.onStreamEnd,this._streams=new Map,this.source=Qd({onEnd:()=>{var e;null===(e=this.log)||void 0===e||e.trace("muxer source ended"),this._streams.forEach((e=>{e.destroy()}))}}),this.sink=function(){var e=G((function*(e){var t,r,o,i=()=>{var t,r=up(e);if(null!=r.return){var o=r.return();null!=(t=o)&&"function"==typeof t.then&&o.catch((e=>{var t;null===(t=n.log)||void 0===t||t.call(n,"could not cause sink source to return",e)}))}};try{var s=new zP(e);try{n.closeController.signal.addEventListener("abort",i);var a,c=!1,u=!1;try{for(var l,d=M(s.emitFrames());c=!(l=yield d.next()).done;c=!1){var h=l.value;yield n.handleFrame(h.header,h.readData)}}catch(e){u=!0,a=e}finally{try{c&&null!=d.return&&(yield d.return())}finally{if(u)throw a}}}finally{n.closeController.signal.removeEventListener("abort",i)}r=MP.NormalTermination}catch(e){var p,y;if(qP.has(e.name))null===(p=n.log)||void 0===p||p.error("protocol error in sink",e),r=MP.ProtocolError;else null===(y=n.log)||void 0===y||y.error("internal error in sink",e),r=MP.InternalError;o=e}null===(t=n.log)||void 0===t||t.trace("muxer sink ended"),null!=o?n.abort(o,r):yield n.close({reason:r})}));return function(t){return e.apply(this,arguments)}}(),this.numInboundStreams=0,this.numOutboundStreams=0,this.nextStreamID=this.client?1:2,this.nextPingID=0,this.rtt=-1,null===(r=this.log)||void 0===r||r.trace("muxer created"),this.config.enableKeepAlive&&this.keepAliveLoop().catch((e=>{var t;return null===(t=this.log)||void 0===t?void 0:t.error("keepalive error: %s",e)})),this.ping().catch((e=>{var t;return null===(t=this.log)||void 0===t?void 0:t.error("ping error: %s",e)}))}get streams(){return Array.from(this._streams.values())}newStream(e){var t;if(void 0!==this.remoteGoAway)throw new d.MuxerClosedError("Muxer closed remotely");if(void 0!==this.localGoAway)throw new d.MuxerClosedError("Muxer closed locally");var r=this.nextStreamID;if(this.nextStreamID+=2,this.numOutboundStreams>=this.config.maxOutboundStreams)throw new d.TooManyOutboundProtocolStreamsError("max outbound streams exceeded");null===(t=this.log)||void 0===t||t.trace("new outgoing stream id=%s",r);var n=this._newStream(r,e,VP.Init,"outbound");return this._streams.set(r,n),this.numOutboundStreams++,n.sendWindowUpdate(),n}ping(){var e=this;return G((function*(){if(void 0!==e.remoteGoAway)throw new d.MuxerClosedError("Muxer closed remotely");if(void 0!==e.localGoAway)throw new d.MuxerClosedError("Muxer closed locally");if(void 0===e.activePing){var t=()=>{};e.activePing={id:e.nextPingID++,promise:new Promise(((r,n)=>{var o=()=>{n(new d.MuxerClosedError("Muxer closed locally"))};e.closeController.signal.addEventListener("abort",o,{once:!0}),t=()=>{e.closeController.signal.removeEventListener("abort",o),r()}})),resolve:t};var r=Date.now();e.sendPing(e.activePing.id);try{yield e.activePing.promise}finally{delete e.activePing}var n=Date.now();e.rtt=n-r}else yield e.activePing.promise;return e.rtt}))()}getRTT(){return this.rtt}close(){var e=arguments,t=this;return G((function*(){var r,n,o,i=e.length>0&&void 0!==e[0]?e[0]:{};if(!t.closeController.signal.aborted){var s=null!==(r=null===(n=i)||void 0===n?void 0:n.reason)&&void 0!==r?r:MP.NormalTermination;if(null===(o=t.log)||void 0===o||o.trace("muxer close reason=%s",s),null==i.signal){var a=AbortSignal.timeout(500);d.setMaxListeners(1/0,a),i=Z(Z({},i),{},{signal:a})}try{yield Promise.all([...t._streams.values()].map(function(){var e=G((function*(e){return e.close(i)}));return function(t){return e.apply(this,arguments)}}())),t.sendGoAway(s),t._closeMuxer()}catch(e){t.abort(e)}}}))()}abort(e,t){var r;if(!this.closeController.signal.aborted){for(var n of(t=null!=t?t:MP.InternalError,null===(r=this.log)||void 0===r||r.error("muxer abort reason=%s error=%s",t,e),this._streams.values()))n.abort(e);this.sendGoAway(t),this._closeMuxer()}}isClosed(){return this.closeController.signal.aborted}_closeMuxer(){this.closeController.abort(),this.source.end()}_newStream(e,t,r,n){if(null!=this._streams.get(e))throw new d.InvalidParametersError("Stream already exists with that id");var o=new HP({id:e.toString(),name:t,state:r,direction:n,sendFrame:this.sendFrame.bind(this),onEnd:()=>{var t;this.closeStream(e),null===(t=this.onStreamEnd)||void 0===t||t.call(this,o)},log:this.logger.forComponent("libp2p:yamux:".concat(n,":").concat(e)),config:this.config,getRTT:this.getRTT.bind(this)});return o}closeStream(e){this.client===(e%2==0)?this.numInboundStreams--:this.numOutboundStreams--,this._streams.delete(e)}keepAliveLoop(){var e=this;return G((function*(){var t,r=new Promise(((t,r)=>{e.closeController.signal.addEventListener("abort",r,{once:!0})}));null===(t=e.log)||void 0===t||t.trace("muxer keepalive enabled interval=%s",e.config.keepAliveInterval);for(var n,o=function*(){var t;try{yield Promise.race([r,new Promise((r=>{t=setTimeout(r,e.config.keepAliveInterval)}))]),e.ping().catch((t=>{var r;return null===(r=e.log)||void 0===r?void 0:r.error("ping error: %s",t)}))}catch(e){return clearInterval(t),{v:void 0}}};;)if(n=yield*o())return n.v}))()}handleFrame(e,t){var r=this;return G((function*(){var n,{streamID:o,type:i,length:s}=e;if(null===(n=r.log)||void 0===n||n.trace("received frame %o",e),0===o)switch(i){case UP.Ping:return void r.handlePing(e);case UP.GoAway:return void r.handleGoAway(s);default:throw new EP("Invalid frame type")}else switch(e.type){case UP.Data:case UP.WindowUpdate:return void(yield r.handleStreamMessage(e,t));default:throw new EP("Invalid frame type")}}))()}handlePing(e){if(e.flag===KP.SYN){var t;null===(t=this.log)||void 0===t||t.trace("received ping request pingId=%s",e.length),this.sendPing(e.length,KP.ACK)}else{if(e.flag!==KP.ACK)throw new EP("Invalid frame flag");var r;null===(r=this.log)||void 0===r||r.trace("received ping response pingId=%s",e.length),this.handlePingResponse(e.length)}}handlePingResponse(e){if(void 0===this.activePing)throw new CP("ping not requested");if(this.activePing.id!==e)throw new BP("ping doesn't match our id");this.activePing.resolve()}handleGoAway(e){var t,r;for(var n of(null===(t=this.log)||void 0===t||t.trace("received GoAway reason=%s",null!==(r=MP[e])&&void 0!==r?r:"unknown"),this.remoteGoAway=e,this._streams.values()))n.reset();this._closeMuxer()}handleStreamMessage(e,t){var r=this;return G((function*(){var{streamID:n,flag:o,type:i}=e;(o&KP.SYN)===KP.SYN&&r.incomingStream(n);var s=r._streams.get(n);if(void 0!==s)switch(i){case UP.WindowUpdate:return void s.handleWindowUpdate(e);case UP.Data:if(void 0===t)throw new Error("unreachable");return void(yield s.handleData(e,t));default:throw new Error("unreachable")}else if(i===UP.Data){var a;if(null===(a=r.log)||void 0===a||a.call(r,"discarding data for stream id=%s",n),void 0===t)throw new Error("unreachable");yield t()}else{var c;null===(c=r.log)||void 0===c||c.trace("frame for missing stream id=%s",n)}}))()}incomingStream(e){var t,r;if(this.client!==(e%2==0))throw new d.InvalidParametersError("Both endpoints are clients");if(!this._streams.has(e))if(null===(t=this.log)||void 0===t||t.trace("new incoming stream id=%s",e),void 0===this.localGoAway){var n;if(this.numInboundStreams>=this.config.maxInboundStreams)return null===(n=this.log)||void 0===n||n.call(this,"maxIncomingStreams exceeded, forcing stream reset"),void this.sendFrame({type:UP.WindowUpdate,flag:KP.RST,streamID:e,length:0});var o=this._newStream(e,void 0,VP.SYNReceived,"inbound");this.numInboundStreams++,this._streams.set(e,o),null===(r=this.onIncomingStream)||void 0===r||r.call(this,o)}else this.sendFrame({type:UP.WindowUpdate,flag:KP.RST,streamID:e,length:0})}sendFrame(e,t){var r;if(null===(r=this.log)||void 0===r||r.trace("sending frame %o",e),e.type===UP.Data){if(void 0===t)throw new EP("Invalid frame");this.source.push(new Ns(GP(e),t))}else this.source.push(GP(e))}sendPing(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:KP.SYN;n===KP.SYN?null===(t=this.log)||void 0===t||t.trace("sending ping request pingId=%s",e):null===(r=this.log)||void 0===r||r.trace("sending ping response pingId=%s",e);this.sendFrame({type:UP.Ping,flag:n,streamID:0,length:e})}sendGoAway(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:MP.NormalTermination;null===(e=this.log)||void 0===e||e.call(this,"sending GoAway reason=%s",MP[t]),this.localGoAway=t,this.sendFrame({type:UP.GoAway,flag:0,streamID:0,length:t})}}function YP(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new JP(t,e)}class ZP{constructor(e){var t,r,n,o,i,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};W(this,"protocol",void 0),W(this,"components",void 0),W(this,"started",void 0),W(this,"timeout",void 0),W(this,"maxInboundStreams",void 0),W(this,"maxOutboundStreams",void 0),W(this,"runOnLimitedConnection",void 0),W(this,"log",void 0),W(this,Symbol.toStringTag,"@libp2p/ping"),W(this,d.serviceCapabilities,["@libp2p/ping"]),this.components=e,this.log=e.logger.forComponent("libp2p:ping"),this.started=!1,this.protocol="/".concat(null!==(t=s.protocolPrefix)&&void 0!==t?t:"ipfs","/").concat("ping","/").concat("1.0.0"),this.timeout=null!==(r=s.timeout)&&void 0!==r?r:1e4,this.maxInboundStreams=null!==(n=s.maxInboundStreams)&&void 0!==n?n:2,this.maxOutboundStreams=null!==(o=s.maxOutboundStreams)&&void 0!==o?o:1,this.runOnLimitedConnection=null===(i=s.runOnLimitedConnection)||void 0===i||i,this.handleMessage=this.handleMessage.bind(this)}start(){var e=this;return G((function*(){yield e.components.registrar.handle(e.protocol,e.handleMessage,{maxInboundStreams:e.maxInboundStreams,maxOutboundStreams:e.maxOutboundStreams,runOnLimitedConnection:e.runOnLimitedConnection}),e.started=!0}))()}stop(){var e=this;return G((function*(){yield e.components.registrar.unhandle(e.protocol),e.started=!1}))()}isStarted(){return this.started}handleMessage(e){var t=this;this.log("incoming ping from %p",e.connection.remotePeer);var{stream:r}=e,n=Date.now(),o=pl(r),i=!1;Promise.resolve().then(G((function*(){for(;;){var e=AbortSignal.timeout(t.timeout);d.setMaxListeners(1/0,e),e.addEventListener("abort",(()=>{null==r||r.abort(new d.TimeoutError("ping timeout"))}));var n=yield o.read({bytes:32,signal:e});yield o.write(n,{signal:e}),i=!0}}))).catch((t=>{i&&"UnexpectedEOFError"===t.name&&"ready"!==r.readStatus||(this.log.error("incoming ping from %p failed with error - %e",e.connection.remotePeer,t),null==r||r.abort(t))})).finally((()=>{var t=Date.now()-n;this.log("incoming ping from %p complete in %dms",e.connection.remotePeer,t);var o=AbortSignal.timeout(this.timeout);d.setMaxListeners(1/0,o),r.close({signal:o}).catch((t=>{this.log.error("error closing ping stream from %p - %e",e.connection.remotePeer,t),null==r||r.abort(t)}))}))}ping(e){var t=arguments,r=this;return G((function*(){var o=t.length>1&&void 0!==t[1]?t[1]:{};r.log("pinging %p",e);var i,s=Date.now(),a=n.randomBytes(32),c=yield r.components.connectionManager.openConnection(e,o);if(null==o.signal){var u=AbortSignal.timeout(r.timeout);o=Z(Z({},o),{},{signal:u})}try{var l=pl(i=yield c.newStream(r.protocol,Z(Z({},o),{},{runOnLimitedConnection:r.runOnLimitedConnection}))),[,h]=yield Promise.all([l.write(a,o),l.read(Z(Z({},o),{},{bytes:32}))]),p=Date.now()-s;if(!Es(a,h.subarray()))throw new d.ProtocolError("Received wrong ping ack after ".concat(p,"ms"));return r.log("ping %p complete in %dms",c.remotePeer,p),p}catch(e){var y;throw r.log.error("error while pinging %p",c.remotePeer,e),null===(y=i)||void 0===y||y.abort(e),e}finally{null!=i&&(yield i.close(o))}}))()}}function QP(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new ZP(t,e)}const XP=4091;let eE=class{constructor(e,t={}){this.sink=e,this.options=t,this.bytesWritten=0,this.abortController=new AbortController,this.backpressureHistory=[],this.isBackpressure=!1,this.writeQueue=[],this.isProcessingQueue=!1,this.listeners=new Map,this.options=t?{chunkSize:t.chunkSize??XP,bufferSize:t.bufferSize??5242880,retries:t.retries??3}:{chunkSize:XP,bufferSize:5242880,retries:3},this.options.chunkSize&&this.options.chunkSize>XP&&(this.options.chunkSize=XP);const r=Qd({objectMode:!1});r._originalPush=r.push.bind(r),r._originalNext=r.next.bind(r),r._queueSize=0,Object.defineProperty(r,"next",{value:async()=>{const e=await r._originalNext();return!e.done&&e.value&&(r._queueSize-=e.value.byteLength),e},writable:!1,configurable:!1}),Object.defineProperty(r,"push",{value:e=>(r._queueSize+=e.byteLength,r._originalPush(e)),writable:!1,configurable:!1}),this.p=r,this.startPipeline()}get queueSize(){return this.p._queueSize}async safeNext(){const e=await this.p.next();return!e.done&&e.value&&(this.p._queueSize-=e.value.byteLength),e}handleError(e){this.dispatchEvent(new CustomEvent("error",{detail:e})),this.abort(e.message)}startPipeline(){rh(this.p,this.createTransform(),this.sink).catch((e=>this.handleError(e)))}createTransform(){return async function*(e){for await(const t of e)yield t}}async write(e){if(!this.abortController.signal.aborted)return new Promise(((t,r)=>{this.writeQueue.push((async()=>{try{const r=await this.convertToBuffer(e);await this.writeChunks(r),t()}catch(e){r(e)}})),this.processQueue()}))}async convertToBuffer(e){return e instanceof Blob?e.arrayBuffer():"string"==typeof e?(new TextEncoder).encode(e).buffer:e}async writeChunks(e){for(let t=0;t<e.byteLength;t+=this.options.chunkSize){const r=Math.min(t+this.options.chunkSize,e.byteLength),n=new Uint8Array(r-t);n.set(new Uint8Array(e.slice(t,r))),await this.retryableWrite(n),this.updateProgress(n.byteLength)}}async retryableWrite(e,t=0){try{await this.monitorBackpressure(),await new Promise(((t,r)=>{try{this.p.push(e)}catch(e){r(e)}t()}))}catch(r){if(t<this.options.retries){const r=this.calculateRetryDelay(t);return await new Promise((e=>setTimeout(e,r))),this.retryableWrite(e,t+1)}throw r}}async monitorBackpressure(){for(;;){const e=this.queueSize;e>0&&this.backpressureHistory.push(e),this.backpressureHistory.length>10&&this.backpressureHistory.shift();const t=this.backpressureHistory.reduce(((e,t)=>e+t),0)/10,r=Math.min(.8*this.options.bufferSize,1.5*t);if(e<r||0===e)return void(this.isBackpressure&&(this.isBackpressure=!1,this.dispatchEvent(new CustomEvent("backpressure",{detail:{currentSize:e,averageSize:t,threshold:r,waitingTime:0}}))));this.isBackpressure||(this.isBackpressure=!0,this.dispatchEvent(new CustomEvent("backpressure",{detail:{currentSize:e,averageSize:t,threshold:r,waitingTime:0}})));const n=Math.min(10,50*Math.pow(2,e/r));if(await new Promise((e=>setTimeout(e,n))),this.abortController.signal.aborted)break}}calculateRetryDelay(e){return Math.min(10*Math.pow(2,e)+100*Math.random(),100)}async processQueue(){if(!this.isProcessingQueue&&!this.abortController.signal.aborted){for(this.isProcessingQueue=!0;this.writeQueue.length>0&&!this.abortController.signal.aborted;){await this.monitorBackpressure();const e=this.writeQueue.shift();try{await e()}catch(e){continue}}this.isProcessingQueue=!1}}updateProgress(e){this.bytesWritten+=e,this.dispatchEvent(new CustomEvent("progress",{detail:{loaded:this.bytesWritten}}))}async end(){this.p.end(),await(this.sink.return?.()),this.cleanup()}abort(e="User aborted"){this.abortController.abort(e),this.cleanup(),this.dispatchEvent(new CustomEvent("abort",{detail:e}))}cleanup(){this.p.end(),this.abortController.abort(),this.writeQueue=[]}addEventListener(e,t){const r=this.listeners.get(e)||[];r.push(t),this.listeners.set(e,r)}dispatchEvent(e){(this.listeners.get(e.type)||[]).forEach((t=>t(e)))}dispatchBackpressureEvent(e){this.dispatchEvent(new CustomEvent("backpressure",{detail:e}))}};var tE=o.minimalExports.Reader,rE=o.minimalExports.Writer,nE=o.minimalExports.util,oE=o.minimalExports.roots.default||(o.minimalExports.roots.default={}),iE=oE.oidfetch=(()=>{var e,t={};return t.pb=((e={}).InitRequset=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=rE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof tE||(e=tE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new oE.oidfetch.pb.InitRequset;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof tE||(e=new tE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof oE.oidfetch.pb.InitRequset?e:new oE.oidfetch.pb.InitRequset},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/oidfetch.pb.InitRequset"},e}(),e.InitReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.type=0,e.prototype.oid=nE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=rE.create()),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(8).int32(e.type),null!=e.oid&&Object.hasOwnProperty.call(e,"oid")&&t.uint32(18).bytes(e.oid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof tE||(e=tE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new oE.oidfetch.pb.InitReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.type=e.int32();break;case 2:n.oid=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof tE||(e=new tE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.type&&e.hasOwnProperty("type")&&!nE.isInteger(e.type)?"type: integer expected":null!=e.oid&&e.hasOwnProperty("oid")&&!(e.oid&&"number"==typeof e.oid.length||nE.isString(e.oid))?"oid: buffer expected":null},e.fromObject=function(e){if(e instanceof oE.oidfetch.pb.InitReply)return e;var t=new oE.oidfetch.pb.InitReply;return null!=e.type&&(t.type=0|e.type),null!=e.oid&&("string"==typeof e.oid?nE.base64.decode(e.oid,t.oid=nE.newBuffer(nE.base64.length(e.oid)),0):e.oid.length>=0&&(t.oid=e.oid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.type=0,t.bytes===String?r.oid="":(r.oid=[],t.bytes!==Array&&(r.oid=nE.newBuffer(r.oid)))),null!=e.type&&e.hasOwnProperty("type")&&(r.type=e.type),null!=e.oid&&e.hasOwnProperty("oid")&&(r.oid=t.bytes===String?nE.base64.encode(e.oid,0,e.oid.length):t.bytes===Array?Array.prototype.slice.call(e.oid):e.oid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/oidfetch.pb.InitReply"},e}(),e.FetchRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.cid=nE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=rE.create()),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(10).bytes(e.cid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof tE||(e=tE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new oE.oidfetch.pb.FetchRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.cid=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof tE||(e=new tE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.cid&&e.hasOwnProperty("cid")&&!(e.cid&&"number"==typeof e.cid.length||nE.isString(e.cid))?"cid: buffer expected":null},e.fromObject=function(e){if(e instanceof oE.oidfetch.pb.FetchRequest)return e;var t=new oE.oidfetch.pb.FetchRequest;return null!=e.cid&&("string"==typeof e.cid?nE.base64.decode(e.cid,t.cid=nE.newBuffer(nE.base64.length(e.cid)),0):e.cid.length>=0&&(t.cid=e.cid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.cid="":(r.cid=[],t.bytes!==Array&&(r.cid=nE.newBuffer(r.cid)))),null!=e.cid&&e.hasOwnProperty("cid")&&(r.cid=t.bytes===String?nE.base64.encode(e.cid,0,e.cid.length):t.bytes===Array?Array.prototype.slice.call(e.cid):e.cid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/oidfetch.pb.FetchRequest"},e}(),e.FetchReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.data=nE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=rE.create()),null!=e.data&&Object.hasOwnProperty.call(e,"data")&&t.uint32(10).bytes(e.data),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof tE||(e=tE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new oE.oidfetch.pb.FetchReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.data=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof tE||(e=new tE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.data&&e.hasOwnProperty("data")&&!(e.data&&"number"==typeof e.data.length||nE.isString(e.data))?"data: buffer expected":null},e.fromObject=function(e){if(e instanceof oE.oidfetch.pb.FetchReply)return e;var t=new oE.oidfetch.pb.FetchReply;return null!=e.data&&("string"==typeof e.data?nE.base64.decode(e.data,t.data=nE.newBuffer(nE.base64.length(e.data)),0):e.data.length>=0&&(t.data=e.data)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.data="":(r.data=[],t.bytes!==Array&&(r.data=nE.newBuffer(r.data)))),null!=e.data&&e.hasOwnProperty("data")&&(r.data=t.bytes===String?nE.base64.encode(e.data,0,e.data.length):t.bytes===Array?Array.prototype.slice.call(e.data):e.data),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/oidfetch.pb.FetchReply"},e}(),e.ErrorInformRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.error="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=rE.create()),null!=e.error&&Object.hasOwnProperty.call(e,"error")&&t.uint32(10).string(e.error),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof tE||(e=tE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new oE.oidfetch.pb.ErrorInformRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.error=e.string():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof tE||(e=new tE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.error&&e.hasOwnProperty("error")&&!nE.isString(e.error)?"error: string expected":null},e.fromObject=function(e){if(e instanceof oE.oidfetch.pb.ErrorInformRequest)return e;var t=new oE.oidfetch.pb.ErrorInformRequest;return null!=e.error&&(t.error=String(e.error)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.error=""),null!=e.error&&e.hasOwnProperty("error")&&(r.error=e.error),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/oidfetch.pb.ErrorInformRequest"},e}(),e.ErrorInformReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=rE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof tE||(e=tE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new oE.oidfetch.pb.ErrorInformReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof tE||(e=new tE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof oE.oidfetch.pb.ErrorInformReply?e:new oE.oidfetch.pb.ErrorInformReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/oidfetch.pb.ErrorInformReply"},e}(),e),t})();var sE;!function(e){var t,r,n,o,i;(t=e.MessageType||(e.MessageType={})).DIAL="DIAL",t.DIAL_RESPONSE="DIAL_RESPONSE",function(e){e[e.DIAL=0]="DIAL",e[e.DIAL_RESPONSE=1]="DIAL_RESPONSE"}(r||(r={})),function(e){e.codec=()=>Xc(r)}(e.MessageType||(e.MessageType={})),(n=e.ResponseStatus||(e.ResponseStatus={})).OK="OK",n.E_DIAL_ERROR="E_DIAL_ERROR",n.E_DIAL_REFUSED="E_DIAL_REFUSED",n.E_BAD_REQUEST="E_BAD_REQUEST",n.E_INTERNAL_ERROR="E_INTERNAL_ERROR",function(e){e[e.OK=0]="OK",e[e.E_DIAL_ERROR=100]="E_DIAL_ERROR",e[e.E_DIAL_REFUSED=101]="E_DIAL_REFUSED",e[e.E_BAD_REQUEST=200]="E_BAD_REQUEST",e[e.E_INTERNAL_ERROR=300]="E_INTERNAL_ERROR"}(o||(o={})),function(e){e.codec=()=>Xc(o)}(e.ResponseStatus||(e.ResponseStatus={})),function(e){var t;e.codec=()=>(null==t&&(t=eu((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.id&&(t.uint32(10),t.bytes(e.id)),null!=e.addrs)for(var n of e.addrs)t.uint32(18),t.bytes(n);!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={addrs:[]},o=null==t?e.len:e.pos+t;e.pos<o;){var i=e.uint32();switch(i>>>3){case 1:n.id=e.bytes();break;case 2:var s;if(null!=(null===(s=r.limits)||void 0===s?void 0:s.addrs)&&n.addrs.length===r.limits.addrs)throw new tu('Decode error - map field "addrs" had too many elements');n.addrs.push(e.bytes());break;default:e.skipType(7&i)}}return n}))),t),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(e.PeerInfo||(e.PeerInfo={})),function(t){var r;t.codec=()=>(null==r&&(r=eu((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&r.fork(),null!=t.peer&&(r.uint32(10),e.PeerInfo.codec().encode(t.peer,r)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o={},i=null==r?t.len:t.pos+r;t.pos<i;){var s,a=t.uint32();if(a>>>3==1)o.peer=e.PeerInfo.codec().decode(t,t.uint32(),{limits:null===(s=n.limits)||void 0===s?void 0:s.peer});else t.skipType(7&a)}return o}))),r),t.encode=e=>Zc(e,t.codec()),t.decode=(e,r)=>Cc(e,t.codec(),r)}(e.Dial||(e.Dial={})),function(t){var r;t.codec=()=>(null==r&&(r=eu((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&r.fork(),null!=t.status&&(r.uint32(8),e.ResponseStatus.codec().encode(t.status,r)),null!=t.statusText&&(r.uint32(18),r.string(t.statusText)),null!=t.addr&&(r.uint32(26),r.bytes(t.addr)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n={},o=null==r?t.len:t.pos+r;t.pos<o;){var i=t.uint32();switch(i>>>3){case 1:n.status=e.ResponseStatus.codec().decode(t);break;case 2:n.statusText=t.string();break;case 3:n.addr=t.bytes();break;default:t.skipType(7&i)}}return n}))),r),t.encode=e=>Zc(e,t.codec()),t.decode=(e,r)=>Cc(e,t.codec(),r)}(e.DialResponse||(e.DialResponse={})),e.codec=()=>(null==i&&(i=eu((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&r.fork(),null!=t.type&&(r.uint32(8),e.MessageType.codec().encode(t.type,r)),null!=t.dial&&(r.uint32(18),e.Dial.codec().encode(t.dial,r)),null!=t.dialResponse&&(r.uint32(26),e.DialResponse.codec().encode(t.dialResponse,r)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o={},i=null==r?t.len:t.pos+r;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:o.type=e.MessageType.codec().decode(t);break;case 2:var a;o.dial=e.Dial.codec().decode(t,t.uint32(),{limits:null===(a=n.limits)||void 0===a?void 0:a.dial});break;case 3:var c;o.dialResponse=e.DialResponse.codec().decode(t,t.uint32(),{limits:null===(c=n.limits)||void 0===c?void 0:c.dialResponse});break;default:t.skipType(7&s)}}return o}))),i),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(sE||(sE={}));class aE{constructor(e,t){var r,n,o,i,s,a;W(this,"components",void 0),W(this,"protocol",void 0),W(this,"timeout",void 0),W(this,"maxInboundStreams",void 0),W(this,"maxOutboundStreams",void 0),W(this,"maxMessageSize",void 0),W(this,"started",void 0),W(this,"log",void 0),W(this,"topologyId",void 0),W(this,"dialResults",void 0),W(this,"findPeers",void 0),W(this,"addressFilter",void 0),W(this,"connectionThreshold",void 0),W(this,Symbol.toStringTag,"@libp2p/autonat"),W(this,d.serviceCapabilities,["@libp2p/autonat"]),this.components=e,this.log=e.logger.forComponent("libp2p:auto-nat"),this.started=!1,this.protocol="/".concat(null!==(r=t.protocolPrefix)&&void 0!==r?r:"libp2p","/").concat("autonat","/").concat("1.0.0"),this.timeout=null!==(n=t.timeout)&&void 0!==n?n:3e4,this.maxInboundStreams=null!==(o=t.maxInboundStreams)&&void 0!==o?o:2,this.maxOutboundStreams=null!==(i=t.maxOutboundStreams)&&void 0!==i?i:20,this.connectionThreshold=null!==(s=t.connectionThreshold)&&void 0!==s?s:80,this.maxMessageSize=null!==(a=t.maxMessageSize)&&void 0!==a?a:8192,this.dialResults=new Map,this.findPeers=function(e,t,r){var n,o;function i(){var s,a={signal:o.signal};if(null!=(null===(s=r)||void 0===s?void 0:s.timeout)){var c=vd([o.signal,AbortSignal.timeout(r.timeout)]);d.setMaxListeners(1/0,c),a.signal=c}Promise.resolve().then(G((function*(){yield e(a)}))).catch((()=>{})).finally((()=>{o.signal.aborted||(n=setTimeout(i,t))}))}var s=!1;return{setInterval:e=>{t!==e&&(t=e,null!=n&&(clearTimeout(n),n=setTimeout(i,t)))},setTimeout:e=>{null!=r||(r={}),r.timeout=e},start:()=>{var e;s||(s=!0,o=new AbortController,d.setMaxListeners(1/0,o.signal),!0===(null===(e=r)||void 0===e?void 0:e.runImmediately)?queueMicrotask((()=>{i()})):n=setTimeout(i,t))},stop:()=>{var e;clearTimeout(n),null===(e=o)||void 0===e||e.abort(),s=!1}}}(this.findRandomPeers.bind(this),6e4),this.addressFilter=zd(1024)}get[d.serviceDependencies](){return["@libp2p/identify"]}isStarted(){return this.started}start(){var e=this;return G((function*(){e.started||(yield e.components.registrar.handle(e.protocol,(t=>{e.handleIncomingAutonatStream(t).catch((t=>{e.log.error("error handling incoming autonat stream - %e",t)}))}),{maxInboundStreams:e.maxInboundStreams,maxOutboundStreams:e.maxOutboundStreams}),e.topologyId=yield e.components.registrar.register(e.protocol,{onConnect:(t,r)=>{e.verifyExternalAddresses(r).catch((t=>{e.log.error("could not verify addresses - %e",t)}))}}),e.findPeers.start(),e.started=!0)}))()}stop(){var e=this;return G((function*(){yield e.components.registrar.unhandle(e.protocol),null!=e.topologyId&&(yield e.components.registrar.unhandle(e.topologyId)),e.dialResults.clear(),e.findPeers.stop(),e.started=!1}))()}allAddressesAreVerified(){return this.components.addressManager.getAddressesWithMetadata().every((e=>e.expires>Date.now()||e.verified))}findRandomPeers(e){var t=this;return G((function*(){if(!t.allAddressesAreVerified()){var r=vd([AbortSignal.timeout(1e4),null==e?void 0:e.signal]);try{t.log("starting random walk to find peers to run AutoNAT");var n,o=!1,i=!1;try{for(var s,a=M(t.components.randomWalk.walk({signal:r}));o=!(s=yield a.next()).done;o=!1){var c=s.value;if(yield t.components.connectionManager.isDialable(c.multiaddrs)){try{t.log.trace("dial random peer %p",c.id),yield t.components.connectionManager.openConnection(c.multiaddrs,{signal:r})}catch(e){}if(t.allAddressesAreVerified())return void t.log("stopping random walk, all addresses are verified");if(!t.hasConnectionCapacity())return void t.log("stopping random walk, too close to max connections")}else t.log.trace("random peer %p was not dialable %s",c.id,c.multiaddrs.map((e=>e.toString())).join(", "))}}catch(e){i=!0,n=e}finally{try{o&&null!=a.return&&(yield a.return())}finally{if(i)throw n}}}catch(e){}}}))()}handleIncomingAutonatStream(e){var t=this;return G((function*(){var r=AbortSignal.timeout(t.timeout);d.setMaxListeners(1/0,r);var n=ml(e.stream,{maxDataLength:t.maxMessageSize}).pb(sE);try{var o=yield n.read({signal:r}),i=yield t.handleAutonatMessage(o,e.connection,{signal:r});yield n.write(i,{signal:r}),yield n.unwrap().unwrap().close({signal:r})}catch(r){t.log.error("error handling incoming autonat stream - %e",r),e.stream.abort(r)}}))()}handleAutonatMessage(t,n,o){var i=this;return G((function*(){var s,a=i.components.addressManager.getAddresses().map((e=>e.toOptions().host)),c=t.dial;if(null==c)return i.log.error("dial was missing from message"),{type:sE.MessageType.DIAL_RESPONSE,dialResponse:{status:sE.ResponseStatus.E_BAD_REQUEST,statusText:"No Dial message found in message"}};var u=c.peer;if(null==(null==u?void 0:u.id))return i.log.error("PeerId missing from message"),{type:sE.MessageType.DIAL_RESPONSE,dialResponse:{status:sE.ResponseStatus.E_BAD_REQUEST,statusText:"missing peer info"}};try{var l=ts(u.id);s=r.peerIdFromMultihash(l)}catch(e){return i.log.error("invalid PeerId - %e",e),{type:sE.MessageType.DIAL_RESPONSE,dialResponse:{status:sE.ResponseStatus.E_BAD_REQUEST,statusText:"bad peer id"}}}if(i.log("incoming request from %p",s),!n.remotePeer.equals(s))return i.log("target peer %p did not equal sending peer %p",s,n.remotePeer),{type:sE.MessageType.DIAL_RESPONSE,dialResponse:{status:sE.ResponseStatus.E_BAD_REQUEST,statusText:"peer id mismatch"}};var d=u.addrs.map((t=>e.multiaddr(t))).filter((e=>{var t=e.toOptions();return!AP(e)&&(t.host!==n.remoteAddr.toOptions().host?(i.log.trace("not dialing %a - target host did not match remote host %a",e,n.remoteAddr),!1):!a.includes(t.host)&&(null!=i.components.transportManager.dialTransportForMultiaddr(e)||(i.log.trace("not dialing %a - transport unsupported",e),!1)))})).map((e=>(null==e.getPeerId()&&(e=e.encapsulate("/p2p/".concat(s.toString()))),e)));if(0===d.length)return i.log("refused to dial all multiaddrs for %p from message",s),{type:sE.MessageType.DIAL_RESPONSE,dialResponse:{status:sE.ResponseStatus.E_DIAL_REFUSED,statusText:"no dialable addresses"}};i.log("dial multiaddrs %s for peer %p",d.map((e=>e.toString())).join(", "),s);var h="",p=d[0];for(var y of d){var f=void 0;p=y;try{if(!(f=yield i.components.connectionManager.openConnection(y,o)).remoteAddr.equals(y))throw i.log.error("tried to dial %a but dialed %a",y,f.remoteAddr),new Error("Unexpected remote address");return i.log("successfully dialed %p via %a",s,y),{type:sE.MessageType.DIAL_RESPONSE,dialResponse:{status:sE.ResponseStatus.OK,addr:f.remoteAddr.decapsulateCode(e.protocols("p2p").code).bytes}}}catch(e){i.log.error("could not dial %p - %e",s,e),h=e.message}finally{null!=f&&(yield f.close())}}return{type:sE.MessageType.DIAL_RESPONSE,dialResponse:{status:sE.ResponseStatus.E_DIAL_ERROR,statusText:h,addr:p.bytes}}}))()}getFirstUnverifiedMultiaddr(e,t){var r=this.components.addressManager.getAddressesWithMetadata().sort(((e,t)=>"observed"===e.type&&"observed"!==t.type?1:"observed"===t.type&&"observed"!==e.type?-1:0)).filter((e=>{if(!(e.expires<Date.now()))return!1;if(6===e.multiaddr.toOptions().family){if(!t)return!1;if(!bP(e.multiaddr))return!1}return!AP(e.multiaddr)}));for(var n of r){var o=n.multiaddr.toString(),i=this.dialResults.get(o);if(null!=i){if(i.networkSegments.includes(e)){this.log.trace("%a already has a network segment result from %s",i.multiaddr,e);continue}if(i.queue.size>10){this.log.trace("%a already has enough peers queued",i.multiaddr);continue}}if(null==i){var s,a,c=n.expires<Date.now();if(c)null===(s=(a=this.addressFilter).remove)||void 0===s||s.call(a,o);if(this.addressFilter.has(o))continue;this.addressFilter.add(o),this.log.trace("creating dial result %s %s",c?"to revalidate":"for",o),i={multiaddr:n.multiaddr,success:0,failure:0,networkSegments:[],verifyingPeers:new Td,queue:new mh({concurrency:3,maxSize:50}),type:n.type,lastVerified:n.lastVerified},this.dialResults.set(o,i)}return i}}removeOutdatedMultiaddrResults(){var e=new Set(this.components.addressManager.getAddressesWithMetadata().filter((e=>{var{expires:t}=e;return t<Date.now()})).map((e=>{var{multiaddr:t}=e;return t.toString()})));for(var t of this.dialResults.keys())e.has(t)||(this.log.trace("remove results for %a",t),this.dialResults.delete(t))}verifyExternalAddresses(e){var t=this;return G((function*(){if(t.isStarted()){t.removeOutdatedMultiaddrResults();var r=(yield t.components.peerStore.get(e.remotePeer)).addresses.some((e=>{var{multiaddr:t}=e;return 6===t.toOptions().family})),n=t.getNetworkSegment(e.remoteAddr),o=t.getFirstUnverifiedMultiaddr(n,r);null!=o?t.hasConnectionCapacity()?o.queue.add(function(){var r=G((function*(r){yield t.askPeerToVerify(e,n,r)}));return function(e){return r.apply(this,arguments)}}(),{peerId:e.remotePeer,multiaddr:o.multiaddr}).catch((r=>{null==(null==o?void 0:o.result)&&t.log.error("error from %p verifying address %a - %e",e.remotePeer,null==o?void 0:o.multiaddr,r)})):null!=o.lastVerified?(t.log("automatically re-verifying %a because we are too close to the connection limit",o.multiaddr),t.confirmAddress(o)):t.log("skipping verifying %a because we are too close to the connection limit",o.multiaddr):t.log.trace("no unverified public addresses found for peer %p to verify, not requesting verification",e.remotePeer)}}))()}askPeerToVerify(e,t,r){var n=this;return G((function*(){var o=n.dialResults.get(r.multiaddr.toString());if(null!=o){var i=AbortSignal.timeout(n.timeout);d.setMaxListeners(1/0,i),n.log.trace("asking %p to verify multiaddr %s",e.remotePeer,r.multiaddr);var s=yield e.newStream(n.protocol,{signal:i});try{var a=ml(s).pb(sE),[,c]=yield Promise.all([a.write({type:sE.MessageType.DIAL,dial:{peer:{id:n.components.peerId.toMultihash().bytes,addrs:[r.multiaddr.bytes]}}},{signal:i}),a.read({signal:i})]);if(c.type!==sE.MessageType.DIAL_RESPONSE||null==c.dialResponse)return void n.log("invalid autonat response from %p - %j",e.remotePeer,c);var u=c.dialResponse.status;if(n.log.trace("autonat response from %p for %a is %s",e.remotePeer,r.multiaddr,u),u!==sE.ResponseStatus.OK&&u!==sE.ResponseStatus.E_DIAL_ERROR)return;if(null==(o=n.dialResults.get(r.multiaddr.toString())))return void n.log.trace("peer reported %a as %s but there is no result object",r.multiaddr,c.dialResponse.status);if(o.networkSegments.includes(t))return void n.log.trace("%a results included network segment %s",r.multiaddr,t);if(null!=o.result)return void n.log.trace("already resolved result for %a, ignoring response from",r.multiaddr,e.remotePeer);if(o.verifyingPeers.has(e.remotePeer))return void n.log.trace("peer %p has already verified %a, ignoring response",e.remotePeer,r.multiaddr);if(o.verifyingPeers.add(e.remotePeer),o.networkSegments.push(t),u===sE.ResponseStatus.OK){if(o.success++,"observed"!==o.type)return void n.confirmAddress(o)}else u===sE.ResponseStatus.E_DIAL_ERROR&&o.failure++;n.log("%a success %d failure %d",o.multiaddr,o.success,o.failure),4===o.success&&n.confirmAddress(o),8===o.failure&&n.unconfirmAddress(o)}finally{try{yield s.close({signal:i})}catch(e){s.abort(e)}}}else n.log("%a was verified while %p was queued",r.multiaddr,e.remotePeer)}))()}hasConnectionCapacity(){return this.components.connectionManager.getConnections().length/this.components.connectionManager.getMaxConnections()*100<this.connectionThreshold}confirmAddress(e){this.log("%s address %a is externally dialable",e.type,e.multiaddr),this.components.addressManager.confirmObservedAddr(e.multiaddr),this.dialResults.delete(e.multiaddr.toString()),e.result=!0,e.queue.abort()}unconfirmAddress(e){this.log("%s address %a is not externally dialable",e.type,e.multiaddr),this.components.addressManager.removeObservedAddr(e.multiaddr),this.dialResults.delete(e.multiaddr.toString()),e.result=!1,e.queue.abort()}getNetworkSegment(e){var t=e.toOptions();return 4===t.family?t.host.split(".")[0].padStart(3,"0"):t.host.split(":")[0].padStart(4,"0")}}function cE(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new aE(t,e)}var uE=()=>{var e=new Error("Delay aborted");return e.name="AbortError",e},lE=new WeakMap;var dE,hE=function(){var{clearTimeout:e,setTimeout:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(r){var n,o,i,{value:s,signal:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=a&&a.aborted)return Promise.reject(uE());var c=null!=e?e:clearTimeout,u=()=>{c(n),i(uE())},l=new Promise(((e,c)=>{o=()=>{a&&a.removeEventListener("abort",u),e(s)},i=c,n=(null!=t?t:setTimeout)(o,r)}));return a&&a.addEventListener("abort",u,{once:!0}),lE.set(l,(()=>{c(n),n=null,o()})),l}}();function pE(e,t){return!md.matches(e)&&(null!=t.dialTransportForMultiaddr(e)&&(!!Zl.matches(e)||!!nd.matches(e)&&!1===OP(e.toOptions().host)))}!function(e){var t,r;!function(e){e.UNUSED="UNUSED",e.CONNECT="CONNECT",e.SYNC="SYNC"}(e.Type||(e.Type={})),function(e){e[e.UNUSED=0]="UNUSED",e[e.CONNECT=100]="CONNECT",e[e.SYNC=300]="SYNC"}(t||(t={})),function(e){e.codec=()=>Xc(t)}(e.Type||(e.Type={})),e.codec=()=>(null==r&&(r=eu((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.type&&(r.uint32(8),e.Type.codec().encode(t.type,r)),null!=t.observedAddresses)for(var o of t.observedAddresses)r.uint32(18),r.bytes(o);!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o={observedAddresses:[]},i=null==r?t.len:t.pos+r;t.pos<i;){var s=t.uint32();switch(s>>>3){case 1:o.type=e.Type.codec().decode(t);break;case 2:var a;if(null!=(null===(a=n.limits)||void 0===a?void 0:a.observedAddresses)&&o.observedAddresses.length===n.limits.observedAddresses)throw new tu('Decode error - map field "observedAddresses" had too many elements');o.observedAddresses.push(t.bytes());break;default:t.skipType(7&s)}}return o}))),r),e.encode=t=>Zc(t,e.codec()),e.decode=(t,r)=>Cc(t,e.codec(),r)}(dE||(dE={}));var yE=5e3,fE=3,gE=1,bE=1;class mE{constructor(e,t){var r,n,o,i;W(this,"started",void 0),W(this,"timeout",void 0),W(this,"retries",void 0),W(this,"maxInboundStreams",void 0),W(this,"maxOutboundStreams",void 0),W(this,"peerStore",void 0),W(this,"registrar",void 0),W(this,"connectionManager",void 0),W(this,"addressManager",void 0),W(this,"transportManager",void 0),W(this,"topologyId",void 0),W(this,"log",void 0),W(this,Symbol.toStringTag,"@libp2p/dcutr"),W(this,d.serviceDependencies,["@libp2p/identify"]),this.log=e.logger.forComponent("libp2p:dcutr"),this.started=!1,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.connectionManager=e.connectionManager,this.transportManager=e.transportManager,this.timeout=null!==(r=t.timeout)&&void 0!==r?r:yE,this.retries=null!==(n=t.retries)&&void 0!==n?n:fE,this.maxInboundStreams=null!==(o=t.maxInboundStreams)&&void 0!==o?o:gE,this.maxOutboundStreams=null!==(i=t.maxOutboundStreams)&&void 0!==i?i:bE}isStarted(){return this.started}start(){var e=this;return G((function*(){e.started||(e.topologyId=yield e.registrar.register(wE,{notifyOnLimitedConnection:!0,onConnect:(t,r)=>{md.exactMatch(r.remoteAddr)&&"inbound"===r.direction&&e.upgradeInbound(r).catch((t=>{e.log.error("error during outgoing DCUtR attempt",t)}))}}),yield e.registrar.handle(wE,(t=>{e.handleIncomingUpgrade(t.stream,t.connection).catch((r=>{e.log.error("error during incoming DCUtR attempt",r),t.stream.abort(r)}))}),{maxInboundStreams:e.maxInboundStreams,maxOutboundStreams:e.maxOutboundStreams,runOnLimitedConnection:!0}),e.started=!0)}))()}stop(){var e=this;return G((function*(){yield e.registrar.unhandle(wE),null!=e.topologyId&&e.registrar.unregister(e.topologyId),e.started=!1}))()}upgradeInbound(e){var t=this;return G((function*(){if(!(yield t.attemptUnilateralConnectionUpgrade(e)))for(var r,n=0;n<t.retries;n++){var o={signal:AbortSignal.timeout(t.timeout)};try{var i=ml(r=yield e.newStream([wE],{signal:o.signal,runOnLimitedConnection:!0}),{maxDataLength:4096}).pb(dE);t.log("B sending connect to %p",e.remotePeer);var s=Date.now();yield i.write({type:dE.Type.CONNECT,observedAddresses:t.addressManager.getAddresses().map((e=>e.bytes))},o),t.log("B receiving connect from %p",e.remotePeer);var a=yield i.read(o);if(a.type!==dE.Type.CONNECT)throw t.log("A sent wrong message type"),new d.InvalidMessageError("DCUtR message type was incorrect");var c=t.getDialableMultiaddrs(a.observedAddresses);if(0===c.length)throw t.log("A did not have any dialable multiaddrs"),new d.InvalidMessageError("DCUtR connect message had no multiaddrs");var u=Date.now()-s;t.log("A sending sync, rtt %dms",u),yield i.write({type:dE.Type.SYNC,observedAddresses:[]},o),t.log("A waiting for half RTT"),yield hE(u/2),t.log("B dialing",c);var l=yield t.connectionManager.openConnection(c,{signal:o.signal,priority:100,force:!0,initiator:!1});t.log("DCUtR to %p succeeded to address %a, closing relayed connection",e.remotePeer,l.remoteAddr),yield e.close(o);break}catch(e){var h;if(t.log.error("error while attempting DCUtR on attempt %d of %d",n+1,t.retries,e),null===(h=r)||void 0===h||h.abort(e),n===t.retries)throw e}finally{null!=r&&(yield r.close(o))}}}))()}attemptUnilateralConnectionUpgrade(e){var t=this;return G((function*(){var r=(yield t.peerStore.get(e.remotePeer)).addresses.map((t=>{var r=t.multiaddr;return null==r.getPeerId()?r.encapsulate("/p2p/".concat(e.remotePeer)):r})).filter((e=>pE(e,t.transportManager)));if(r.length>0){var n=AbortSignal.timeout(t.timeout);try{t.log("attempting unilateral connection upgrade to %a",r);var o=yield t.connectionManager.openConnection(r,{signal:n,force:!0});if(md.exactMatch(o.remoteAddr))throw new Error("Could not open a new, non-limited, connection");return t.log("unilateral connection upgrade to %p succeeded via %a, closing relayed connection",e.remotePeer,o.remoteAddr),yield e.close({signal:n}),!0}catch(n){t.log.error("unilateral connection upgrade to %p on addresses %a failed",e.remotePeer,r,n)}}else t.log("peer %p has no public addresses, not attempting unilateral connection upgrade",e.remotePeer);return!1}))()}handleIncomingUpgrade(e,t){var r=this;return G((function*(){var n={signal:AbortSignal.timeout(r.timeout)};try{var o=ml(e,{maxDataLength:4096}).pb(dE);r.log("A receiving connect");var i=yield o.read(n);if(i.type!==dE.Type.CONNECT)throw r.log("B sent wrong message type"),new d.InvalidMessageError("DCUtR message type was incorrect");if(0===i.observedAddresses.length)throw r.log("B sent no multiaddrs"),new d.InvalidMessageError("DCUtR connect message had no multiaddrs");var s=r.getDialableMultiaddrs(i.observedAddresses);if(0===s.length)throw r.log("B had no dialable multiaddrs"),new d.InvalidMessageError("DCUtR connect message had no dialable multiaddrs");if(r.log("A sending connect"),yield o.write({type:dE.Type.CONNECT,observedAddresses:r.addressManager.getAddresses().map((e=>e.bytes))}),r.log("A receiving sync"),(yield o.read(n)).type!==dE.Type.SYNC)throw new d.InvalidMessageError("DCUtR message type was incorrect");r.log("A dialing",s);var a=yield r.connectionManager.openConnection(s,{signal:n.signal,priority:100,force:!0});r.log("DCUtR to %p succeeded via %a, closing relayed connection",t.remotePeer,a.remoteAddr),yield t.close(n)}catch(n){r.log.error("incoming DCUtR from %p failed",t.remotePeer,n),e.abort(n)}finally{yield e.close(n)}}))()}getDialableMultiaddrs(t){var r=[];for(var n of t)if(null!=n&&0!==n.length)try{var o=e.multiaddr(n);if(!pE(o,this.transportManager))continue;r.push(o)}catch(e){}return r}}var wE="/libp2p/dcutr";function vE(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new mE(t,e)}var kE=o.minimalExports.Reader,SE=o.minimalExports.Writer,OE=o.minimalExports.util,AE=o.minimalExports.roots.default||(o.minimalExports.roots.default={}),IE=AE.dcnet=(()=>{var e,t={};return t.pb=((e={}).StoreThreadRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadId=OE.newBuffer([]),e.prototype.userPubkey=OE.newBuffer([]),e.prototype.serviceKeyEncrypt=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.threadId&&Object.hasOwnProperty.call(e,"threadId")&&t.uint32(10).bytes(e.threadId),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(18).bytes(e.userPubkey),null!=e.serviceKeyEncrypt&&Object.hasOwnProperty.call(e,"serviceKeyEncrypt")&&t.uint32(26).bytes(e.serviceKeyEncrypt),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.StoreThreadRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadId=e.bytes();break;case 2:n.userPubkey=e.bytes();break;case 3:n.serviceKeyEncrypt=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.threadId&&e.hasOwnProperty("threadId")&&!(e.threadId&&"number"==typeof e.threadId.length||OE.isString(e.threadId))?"threadId: buffer expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.serviceKeyEncrypt&&e.hasOwnProperty("serviceKeyEncrypt")&&!(e.serviceKeyEncrypt&&"number"==typeof e.serviceKeyEncrypt.length||OE.isString(e.serviceKeyEncrypt))?"serviceKeyEncrypt: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.StoreThreadRequest)return e;var t=new AE.dcnet.pb.StoreThreadRequest;return null!=e.threadId&&("string"==typeof e.threadId?OE.base64.decode(e.threadId,t.threadId=OE.newBuffer(OE.base64.length(e.threadId)),0):e.threadId.length>=0&&(t.threadId=e.threadId)),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.serviceKeyEncrypt&&("string"==typeof e.serviceKeyEncrypt?OE.base64.decode(e.serviceKeyEncrypt,t.serviceKeyEncrypt=OE.newBuffer(OE.base64.length(e.serviceKeyEncrypt)),0):e.serviceKeyEncrypt.length>=0&&(t.serviceKeyEncrypt=e.serviceKeyEncrypt)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadId="":(r.threadId=[],t.bytes!==Array&&(r.threadId=OE.newBuffer(r.threadId))),t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.serviceKeyEncrypt="":(r.serviceKeyEncrypt=[],t.bytes!==Array&&(r.serviceKeyEncrypt=OE.newBuffer(r.serviceKeyEncrypt)))),null!=e.threadId&&e.hasOwnProperty("threadId")&&(r.threadId=t.bytes===String?OE.base64.encode(e.threadId,0,e.threadId.length):t.bytes===Array?Array.prototype.slice.call(e.threadId):e.threadId),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.serviceKeyEncrypt&&e.hasOwnProperty("serviceKeyEncrypt")&&(r.serviceKeyEncrypt=t.bytes===String?OE.base64.encode(e.serviceKeyEncrypt,0,e.serviceKeyEncrypt.length):t.bytes===Array?Array.prototype.slice.call(e.serviceKeyEncrypt):e.serviceKeyEncrypt),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.StoreThreadRequest"},e}(),e.StoreThreadReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.status=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.status&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.StoreThreadReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.status=e.int32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.status&&e.hasOwnProperty("status")&&!OE.isInteger(e.status)?"status: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.StoreThreadReply)return e;var t=new AE.dcnet.pb.StoreThreadReply;return null!=e.status&&(t.status=0|e.status),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.status=0),null!=e.status&&e.hasOwnProperty("status")&&(r.status=e.status),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.StoreThreadReply"},e}(),e.StroeFileToPeerRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.cid=OE.newBuffer([]),e.prototype.size=OE.Long?OE.Long.fromBits(0,0,!0):0,e.prototype.userPubkey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(10).bytes(e.cid),null!=e.size&&Object.hasOwnProperty.call(e,"size")&&t.uint32(16).uint64(e.size),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(26).bytes(e.userPubkey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.StroeFileToPeerRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.cid=e.bytes();break;case 2:n.size=e.uint64();break;case 3:n.userPubkey=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.cid&&e.hasOwnProperty("cid")&&!(e.cid&&"number"==typeof e.cid.length||OE.isString(e.cid))?"cid: buffer expected":null!=e.size&&e.hasOwnProperty("size")&&!(OE.isInteger(e.size)||e.size&&OE.isInteger(e.size.low)&&OE.isInteger(e.size.high))?"size: integer|Long expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.StroeFileToPeerRequest)return e;var t=new AE.dcnet.pb.StroeFileToPeerRequest;return null!=e.cid&&("string"==typeof e.cid?OE.base64.decode(e.cid,t.cid=OE.newBuffer(OE.base64.length(e.cid)),0):e.cid.length>=0&&(t.cid=e.cid)),null!=e.size&&(OE.Long?(t.size=OE.Long.fromValue(e.size)).unsigned=!0:"string"==typeof e.size?t.size=parseInt(e.size,10):"number"==typeof e.size?t.size=e.size:"object"==typeof e.size&&(t.size=new OE.LongBits(e.size.low>>>0,e.size.high>>>0).toNumber(!0))),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(t.bytes===String?r.cid="":(r.cid=[],t.bytes!==Array&&(r.cid=OE.newBuffer(r.cid))),OE.Long){var n=new OE.Long(0,0,!0);r.size=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.size=t.longs===String?"0":0;t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey)))}return null!=e.cid&&e.hasOwnProperty("cid")&&(r.cid=t.bytes===String?OE.base64.encode(e.cid,0,e.cid.length):t.bytes===Array?Array.prototype.slice.call(e.cid):e.cid),null!=e.size&&e.hasOwnProperty("size")&&("number"==typeof e.size?r.size=t.longs===String?String(e.size):e.size:r.size=t.longs===String?OE.Long.prototype.toString.call(e.size):t.longs===Number?new OE.LongBits(e.size.low>>>0,e.size.high>>>0).toNumber(!0):e.size),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.StroeFileToPeerRequest"},e}(),e.StroeFileToPeerReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.status=0,e.prototype.receivesize=OE.Long?OE.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.status&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),null!=e.receivesize&&Object.hasOwnProperty.call(e,"receivesize")&&t.uint32(16).int64(e.receivesize),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.StroeFileToPeerReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.status=e.int32();break;case 2:n.receivesize=e.int64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.status&&e.hasOwnProperty("status")&&!OE.isInteger(e.status)?"status: integer expected":null!=e.receivesize&&e.hasOwnProperty("receivesize")&&!(OE.isInteger(e.receivesize)||e.receivesize&&OE.isInteger(e.receivesize.low)&&OE.isInteger(e.receivesize.high))?"receivesize: integer|Long expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.StroeFileToPeerReply)return e;var t=new AE.dcnet.pb.StroeFileToPeerReply;return null!=e.status&&(t.status=0|e.status),null!=e.receivesize&&(OE.Long?(t.receivesize=OE.Long.fromValue(e.receivesize)).unsigned=!1:"string"==typeof e.receivesize?t.receivesize=parseInt(e.receivesize,10):"number"==typeof e.receivesize?t.receivesize=e.receivesize:"object"==typeof e.receivesize&&(t.receivesize=new OE.LongBits(e.receivesize.low>>>0,e.receivesize.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(r.status=0,OE.Long){var n=new OE.Long(0,0,!1);r.receivesize=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.receivesize=t.longs===String?"0":0;return null!=e.status&&e.hasOwnProperty("status")&&(r.status=e.status),null!=e.receivesize&&e.hasOwnProperty("receivesize")&&("number"==typeof e.receivesize?r.receivesize=t.longs===String?String(e.receivesize):e.receivesize:r.receivesize=t.longs===String?OE.Long.prototype.toString.call(e.receivesize):t.longs===Number?new OE.LongBits(e.receivesize.low>>>0,e.receivesize.high>>>0).toNumber():e.receivesize),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.StroeFileToPeerReply"},e}(),e.OnlineStatusCheckRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.challenge=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.challenge&&Object.hasOwnProperty.call(e,"challenge")&&t.uint32(10).bytes(e.challenge),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.OnlineStatusCheckRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.challenge=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.challenge&&e.hasOwnProperty("challenge")&&!(e.challenge&&"number"==typeof e.challenge.length||OE.isString(e.challenge))?"challenge: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.OnlineStatusCheckRequest)return e;var t=new AE.dcnet.pb.OnlineStatusCheckRequest;return null!=e.challenge&&("string"==typeof e.challenge?OE.base64.decode(e.challenge,t.challenge=OE.newBuffer(OE.base64.length(e.challenge)),0):e.challenge.length>=0&&(t.challenge=e.challenge)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.challenge="":(r.challenge=[],t.bytes!==Array&&(r.challenge=OE.newBuffer(r.challenge)))),null!=e.challenge&&e.hasOwnProperty("challenge")&&(r.challenge=t.bytes===String?OE.base64.encode(e.challenge,0,e.challenge.length):t.bytes===Array?Array.prototype.slice.call(e.challenge):e.challenge),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.OnlineStatusCheckRequest"},e}(),e.OnlineStatusCheckReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.teereport=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.teereport&&Object.hasOwnProperty.call(e,"teereport")&&t.uint32(10).bytes(e.teereport),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.OnlineStatusCheckReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.teereport=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.teereport&&e.hasOwnProperty("teereport")&&!(e.teereport&&"number"==typeof e.teereport.length||OE.isString(e.teereport))?"teereport: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.OnlineStatusCheckReply)return e;var t=new AE.dcnet.pb.OnlineStatusCheckReply;return null!=e.teereport&&("string"==typeof e.teereport?OE.base64.decode(e.teereport,t.teereport=OE.newBuffer(OE.base64.length(e.teereport)),0):e.teereport.length>=0&&(t.teereport=e.teereport)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.teereport="":(r.teereport=[],t.bytes!==Array&&(r.teereport=OE.newBuffer(r.teereport)))),null!=e.teereport&&e.hasOwnProperty("teereport")&&(r.teereport=t.bytes===String?OE.base64.encode(e.teereport,0,e.teereport.length):t.bytes===Array?Array.prototype.slice.call(e.teereport):e.teereport),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.OnlineStatusCheckReply"},e}(),e.CheckPeerStatusRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}var t;return e.prototype.sreq=null,e.prototype.teereport=null,Object.defineProperty(e.prototype,"payload",{get:OE.oneOfGetter(t=["sreq","teereport"]),set:OE.oneOfSetter(t)}),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.sreq&&Object.hasOwnProperty.call(e,"sreq")&&AE.dcnet.pb.CheckPeerStatusRequest.Sreq.encode(e.sreq,t.uint32(10).fork()).ldelim(),null!=e.teereport&&Object.hasOwnProperty.call(e,"teereport")&&t.uint32(18).bytes(e.teereport),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.CheckPeerStatusRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.sreq=AE.dcnet.pb.CheckPeerStatusRequest.Sreq.decode(e,e.uint32());break;case 2:n.teereport=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var t={};if(null!=e.sreq&&e.hasOwnProperty("sreq")){t.payload=1;var r=AE.dcnet.pb.CheckPeerStatusRequest.Sreq.verify(e.sreq);if(r)return"sreq."+r}if(null!=e.teereport&&e.hasOwnProperty("teereport")){if(1===t.payload)return"payload: multiple values";if(t.payload=1,!(e.teereport&&"number"==typeof e.teereport.length||OE.isString(e.teereport)))return"teereport: buffer expected"}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.CheckPeerStatusRequest)return e;var t=new AE.dcnet.pb.CheckPeerStatusRequest;if(null!=e.sreq){if("object"!=typeof e.sreq)throw TypeError(".dcnet.pb.CheckPeerStatusRequest.sreq: object expected");t.sreq=AE.dcnet.pb.CheckPeerStatusRequest.Sreq.fromObject(e.sreq)}return null!=e.teereport&&("string"==typeof e.teereport?OE.base64.decode(e.teereport,t.teereport=OE.newBuffer(OE.base64.length(e.teereport)),0):e.teereport.length>=0&&(t.teereport=e.teereport)),t},e.toObject=function(e,t){t||(t={});var r={};return null!=e.sreq&&e.hasOwnProperty("sreq")&&(r.sreq=AE.dcnet.pb.CheckPeerStatusRequest.Sreq.toObject(e.sreq,t),t.oneofs&&(r.payload="sreq")),null!=e.teereport&&e.hasOwnProperty("teereport")&&(r.teereport=t.bytes===String?OE.base64.encode(e.teereport,0,e.teereport.length):t.bytes===Array?Array.prototype.slice.call(e.teereport):e.teereport,t.oneofs&&(r.payload="teereport")),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.CheckPeerStatusRequest"},e.Sreq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.pubkey=OE.newBuffer([]),e.prototype.peerid=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.pubkey&&Object.hasOwnProperty.call(e,"pubkey")&&t.uint32(10).bytes(e.pubkey),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(18).bytes(e.peerid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.CheckPeerStatusRequest.Sreq;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.pubkey=e.bytes();break;case 2:n.peerid=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.pubkey&&e.hasOwnProperty("pubkey")&&!(e.pubkey&&"number"==typeof e.pubkey.length||OE.isString(e.pubkey))?"pubkey: buffer expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.CheckPeerStatusRequest.Sreq)return e;var t=new AE.dcnet.pb.CheckPeerStatusRequest.Sreq;return null!=e.pubkey&&("string"==typeof e.pubkey?OE.base64.decode(e.pubkey,t.pubkey=OE.newBuffer(OE.base64.length(e.pubkey)),0):e.pubkey.length>=0&&(t.pubkey=e.pubkey)),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.pubkey="":(r.pubkey=[],t.bytes!==Array&&(r.pubkey=OE.newBuffer(r.pubkey))),t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid)))),null!=e.pubkey&&e.hasOwnProperty("pubkey")&&(r.pubkey=t.bytes===String?OE.base64.encode(e.pubkey,0,e.pubkey.length):t.bytes===Array?Array.prototype.slice.call(e.pubkey):e.pubkey),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.CheckPeerStatusRequest.Sreq"},e}(),e}(),e.CheckPeerStatusReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}var t;return e.prototype.challenge=null,e.prototype.body=null,Object.defineProperty(e.prototype,"payload",{get:OE.oneOfGetter(t=["challenge","body"]),set:OE.oneOfSetter(t)}),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.challenge&&Object.hasOwnProperty.call(e,"challenge")&&t.uint32(10).bytes(e.challenge),null!=e.body&&Object.hasOwnProperty.call(e,"body")&&AE.dcnet.pb.CheckPeerStatusReply.Body.encode(e.body,t.uint32(18).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.CheckPeerStatusReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.challenge=e.bytes();break;case 2:n.body=AE.dcnet.pb.CheckPeerStatusReply.Body.decode(e,e.uint32());break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var t={};if(null!=e.challenge&&e.hasOwnProperty("challenge")&&(t.payload=1,!(e.challenge&&"number"==typeof e.challenge.length||OE.isString(e.challenge))))return"challenge: buffer expected";if(null!=e.body&&e.hasOwnProperty("body")){if(1===t.payload)return"payload: multiple values";t.payload=1;var r=AE.dcnet.pb.CheckPeerStatusReply.Body.verify(e.body);if(r)return"body."+r}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.CheckPeerStatusReply)return e;var t=new AE.dcnet.pb.CheckPeerStatusReply;if(null!=e.challenge&&("string"==typeof e.challenge?OE.base64.decode(e.challenge,t.challenge=OE.newBuffer(OE.base64.length(e.challenge)),0):e.challenge.length>=0&&(t.challenge=e.challenge)),null!=e.body){if("object"!=typeof e.body)throw TypeError(".dcnet.pb.CheckPeerStatusReply.body: object expected");t.body=AE.dcnet.pb.CheckPeerStatusReply.Body.fromObject(e.body)}return t},e.toObject=function(e,t){t||(t={});var r={};return null!=e.challenge&&e.hasOwnProperty("challenge")&&(r.challenge=t.bytes===String?OE.base64.encode(e.challenge,0,e.challenge.length):t.bytes===Array?Array.prototype.slice.call(e.challenge):e.challenge,t.oneofs&&(r.payload="challenge")),null!=e.body&&e.hasOwnProperty("body")&&(r.body=AE.dcnet.pb.CheckPeerStatusReply.Body.toObject(e.body,t),t.oneofs&&(r.payload="body")),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.CheckPeerStatusReply"},e.Body=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.peerid=OE.newBuffer([]),e.prototype.status=0,e.prototype.teereport=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(10).bytes(e.peerid),null!=e.status&&Object.hasOwnProperty.call(e,"status")&&t.uint32(16).int32(e.status),null!=e.teereport&&Object.hasOwnProperty.call(e,"teereport")&&t.uint32(26).bytes(e.teereport),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.CheckPeerStatusReply.Body;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.peerid=e.bytes();break;case 2:n.status=e.int32();break;case 3:n.teereport=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.status&&e.hasOwnProperty("status")&&!OE.isInteger(e.status)?"status: integer expected":null!=e.teereport&&e.hasOwnProperty("teereport")&&!(e.teereport&&"number"==typeof e.teereport.length||OE.isString(e.teereport))?"teereport: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.CheckPeerStatusReply.Body)return e;var t=new AE.dcnet.pb.CheckPeerStatusReply.Body;return null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.status&&(t.status=0|e.status),null!=e.teereport&&("string"==typeof e.teereport?OE.base64.decode(e.teereport,t.teereport=OE.newBuffer(OE.base64.length(e.teereport)),0):e.teereport.length>=0&&(t.teereport=e.teereport)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),r.status=0,t.bytes===String?r.teereport="":(r.teereport=[],t.bytes!==Array&&(r.teereport=OE.newBuffer(r.teereport)))),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.status&&e.hasOwnProperty("status")&&(r.status=e.status),null!=e.teereport&&e.hasOwnProperty("teereport")&&(r.teereport=t.bytes===String?OE.base64.encode(e.teereport,0,e.teereport.length):t.bytes===Array?Array.prototype.slice.call(e.teereport):e.teereport),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.CheckPeerStatusReply.Body"},e}(),e}(),e.LocalFileCheckRequest=function(){function e(e){if(this.keys=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.keys=OE.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=SE.create()),null!=e.keys&&e.keys.length)for(var r=0;r<e.keys.length;++r)t.uint32(10).string(e.keys[r]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.LocalFileCheckRequest;e.pos<r;){var o=e.uint32();o>>>3==1?(n.keys&&n.keys.length||(n.keys=[]),n.keys.push(e.string())):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.keys&&e.hasOwnProperty("keys")){if(!Array.isArray(e.keys))return"keys: array expected";for(var t=0;t<e.keys.length;++t)if(!OE.isString(e.keys[t]))return"keys: string[] expected"}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.LocalFileCheckRequest)return e;var t=new AE.dcnet.pb.LocalFileCheckRequest;if(e.keys){if(!Array.isArray(e.keys))throw TypeError(".dcnet.pb.LocalFileCheckRequest.keys: array expected");t.keys=[];for(var r=0;r<e.keys.length;++r)t.keys[r]=String(e.keys[r])}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.keys=[]),e.keys&&e.keys.length){r.keys=[];for(var n=0;n<e.keys.length;++n)r.keys[n]=e.keys[n]}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.LocalFileCheckRequest"},e}(),e.LocalFileCheckReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.failkey="",e.prototype.teereport=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).int32(e.flag),null!=e.failkey&&Object.hasOwnProperty.call(e,"failkey")&&t.uint32(18).string(e.failkey),null!=e.teereport&&Object.hasOwnProperty.call(e,"teereport")&&t.uint32(26).bytes(e.teereport),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.LocalFileCheckReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.int32();break;case 2:n.failkey=e.string();break;case 3:n.teereport=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.failkey&&e.hasOwnProperty("failkey")&&!OE.isString(e.failkey)?"failkey: string expected":null!=e.teereport&&e.hasOwnProperty("teereport")&&!(e.teereport&&"number"==typeof e.teereport.length||OE.isString(e.teereport))?"teereport: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.LocalFileCheckReply)return e;var t=new AE.dcnet.pb.LocalFileCheckReply;return null!=e.flag&&(t.flag=0|e.flag),null!=e.failkey&&(t.failkey=String(e.failkey)),null!=e.teereport&&("string"==typeof e.teereport?OE.base64.decode(e.teereport,t.teereport=OE.newBuffer(OE.base64.length(e.teereport)),0):e.teereport.length>=0&&(t.teereport=e.teereport)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,r.failkey="",t.bytes===String?r.teereport="":(r.teereport=[],t.bytes!==Array&&(r.teereport=OE.newBuffer(r.teereport)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.failkey&&e.hasOwnProperty("failkey")&&(r.failkey=e.failkey),null!=e.teereport&&e.hasOwnProperty("teereport")&&(r.teereport=t.bytes===String?OE.base64.encode(e.teereport,0,e.teereport.length):t.bytes===Array?Array.prototype.slice.call(e.teereport):e.teereport),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.LocalFileCheckReply"},e}(),e.LocalAccountInfoCheckRequest=function(){function e(e){if(this.accounthashs=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.accounthashs=OE.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=SE.create()),null!=e.accounthashs&&e.accounthashs.length)for(var r=0;r<e.accounthashs.length;++r)t.uint32(10).bytes(e.accounthashs[r]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.LocalAccountInfoCheckRequest;e.pos<r;){var o=e.uint32();o>>>3==1?(n.accounthashs&&n.accounthashs.length||(n.accounthashs=[]),n.accounthashs.push(e.bytes())):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.accounthashs&&e.hasOwnProperty("accounthashs")){if(!Array.isArray(e.accounthashs))return"accounthashs: array expected";for(var t=0;t<e.accounthashs.length;++t)if(!(e.accounthashs[t]&&"number"==typeof e.accounthashs[t].length||OE.isString(e.accounthashs[t])))return"accounthashs: buffer[] expected"}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.LocalAccountInfoCheckRequest)return e;var t=new AE.dcnet.pb.LocalAccountInfoCheckRequest;if(e.accounthashs){if(!Array.isArray(e.accounthashs))throw TypeError(".dcnet.pb.LocalAccountInfoCheckRequest.accounthashs: array expected");t.accounthashs=[];for(var r=0;r<e.accounthashs.length;++r)"string"==typeof e.accounthashs[r]?OE.base64.decode(e.accounthashs[r],t.accounthashs[r]=OE.newBuffer(OE.base64.length(e.accounthashs[r])),0):e.accounthashs[r].length>=0&&(t.accounthashs[r]=e.accounthashs[r])}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.accounthashs=[]),e.accounthashs&&e.accounthashs.length){r.accounthashs=[];for(var n=0;n<e.accounthashs.length;++n)r.accounthashs[n]=t.bytes===String?OE.base64.encode(e.accounthashs[n],0,e.accounthashs[n].length):t.bytes===Array?Array.prototype.slice.call(e.accounthashs[n]):e.accounthashs[n]}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.LocalAccountInfoCheckRequest"},e}(),e.LocalAccountInfoCheckReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.failkey=OE.newBuffer([]),e.prototype.teereport=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).int32(e.flag),null!=e.failkey&&Object.hasOwnProperty.call(e,"failkey")&&t.uint32(18).bytes(e.failkey),null!=e.teereport&&Object.hasOwnProperty.call(e,"teereport")&&t.uint32(26).bytes(e.teereport),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.LocalAccountInfoCheckReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.int32();break;case 2:n.failkey=e.bytes();break;case 3:n.teereport=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.failkey&&e.hasOwnProperty("failkey")&&!(e.failkey&&"number"==typeof e.failkey.length||OE.isString(e.failkey))?"failkey: buffer expected":null!=e.teereport&&e.hasOwnProperty("teereport")&&!(e.teereport&&"number"==typeof e.teereport.length||OE.isString(e.teereport))?"teereport: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.LocalAccountInfoCheckReply)return e;var t=new AE.dcnet.pb.LocalAccountInfoCheckReply;return null!=e.flag&&(t.flag=0|e.flag),null!=e.failkey&&("string"==typeof e.failkey?OE.base64.decode(e.failkey,t.failkey=OE.newBuffer(OE.base64.length(e.failkey)),0):e.failkey.length>=0&&(t.failkey=e.failkey)),null!=e.teereport&&("string"==typeof e.teereport?OE.base64.decode(e.teereport,t.teereport=OE.newBuffer(OE.base64.length(e.teereport)),0):e.teereport.length>=0&&(t.teereport=e.teereport)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.failkey="":(r.failkey=[],t.bytes!==Array&&(r.failkey=OE.newBuffer(r.failkey))),t.bytes===String?r.teereport="":(r.teereport=[],t.bytes!==Array&&(r.teereport=OE.newBuffer(r.teereport)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.failkey&&e.hasOwnProperty("failkey")&&(r.failkey=t.bytes===String?OE.base64.encode(e.failkey,0,e.failkey.length):t.bytes===Array?Array.prototype.slice.call(e.failkey):e.failkey),null!=e.teereport&&e.hasOwnProperty("teereport")&&(r.teereport=t.bytes===String?OE.base64.encode(e.teereport,0,e.teereport.length):t.bytes===Array?Array.prototype.slice.call(e.teereport):e.teereport),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.LocalAccountInfoCheckReply"},e}(),e.AccountInfoSyncRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.accounthash=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.prikeyencrypthash=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.accounthash&&Object.hasOwnProperty.call(e,"accounthash")&&t.uint32(10).bytes(e.accounthash),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.prikeyencrypthash&&Object.hasOwnProperty.call(e,"prikeyencrypthash")&&t.uint32(26).bytes(e.prikeyencrypthash),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AccountInfoSyncRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.accounthash=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.prikeyencrypthash=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.accounthash&&e.hasOwnProperty("accounthash")&&!(e.accounthash&&"number"==typeof e.accounthash.length||OE.isString(e.accounthash))?"accounthash: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.prikeyencrypthash&&e.hasOwnProperty("prikeyencrypthash")&&!(e.prikeyencrypthash&&"number"==typeof e.prikeyencrypthash.length||OE.isString(e.prikeyencrypthash))?"prikeyencrypthash: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AccountInfoSyncRequest)return e;var t=new AE.dcnet.pb.AccountInfoSyncRequest;return null!=e.accounthash&&("string"==typeof e.accounthash?OE.base64.decode(e.accounthash,t.accounthash=OE.newBuffer(OE.base64.length(e.accounthash)),0):e.accounthash.length>=0&&(t.accounthash=e.accounthash)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.prikeyencrypthash&&("string"==typeof e.prikeyencrypthash?OE.base64.decode(e.prikeyencrypthash,t.prikeyencrypthash=OE.newBuffer(OE.base64.length(e.prikeyencrypthash)),0):e.prikeyencrypthash.length>=0&&(t.prikeyencrypthash=e.prikeyencrypthash)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.accounthash="":(r.accounthash=[],t.bytes!==Array&&(r.accounthash=OE.newBuffer(r.accounthash))),r.blockheight=0,t.bytes===String?r.prikeyencrypthash="":(r.prikeyencrypthash=[],t.bytes!==Array&&(r.prikeyencrypthash=OE.newBuffer(r.prikeyencrypthash)))),null!=e.accounthash&&e.hasOwnProperty("accounthash")&&(r.accounthash=t.bytes===String?OE.base64.encode(e.accounthash,0,e.accounthash.length):t.bytes===Array?Array.prototype.slice.call(e.accounthash):e.accounthash),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.prikeyencrypthash&&e.hasOwnProperty("prikeyencrypthash")&&(r.prikeyencrypthash=t.bytes===String?OE.base64.encode(e.prikeyencrypthash,0,e.prikeyencrypthash.length):t.bytes===Array?Array.prototype.slice.call(e.prikeyencrypthash):e.prikeyencrypthash),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AccountInfoSyncRequest"},e}(),e.AccountInfoSyncReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AccountInfoSyncReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.AccountInfoSyncReply?e:new AE.dcnet.pb.AccountInfoSyncReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AccountInfoSyncReply"},e}(),e.SetEncryptKeyWithScanRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.encryptPrivkey=OE.newBuffer([]),e.prototype.mapkey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.encryptPrivkey&&Object.hasOwnProperty.call(e,"encryptPrivkey")&&t.uint32(10).bytes(e.encryptPrivkey),null!=e.mapkey&&Object.hasOwnProperty.call(e,"mapkey")&&t.uint32(18).bytes(e.mapkey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetEncryptKeyWithScanRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.encryptPrivkey=e.bytes();break;case 2:n.mapkey=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.encryptPrivkey&&e.hasOwnProperty("encryptPrivkey")&&!(e.encryptPrivkey&&"number"==typeof e.encryptPrivkey.length||OE.isString(e.encryptPrivkey))?"encryptPrivkey: buffer expected":null!=e.mapkey&&e.hasOwnProperty("mapkey")&&!(e.mapkey&&"number"==typeof e.mapkey.length||OE.isString(e.mapkey))?"mapkey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SetEncryptKeyWithScanRequest)return e;var t=new AE.dcnet.pb.SetEncryptKeyWithScanRequest;return null!=e.encryptPrivkey&&("string"==typeof e.encryptPrivkey?OE.base64.decode(e.encryptPrivkey,t.encryptPrivkey=OE.newBuffer(OE.base64.length(e.encryptPrivkey)),0):e.encryptPrivkey.length>=0&&(t.encryptPrivkey=e.encryptPrivkey)),null!=e.mapkey&&("string"==typeof e.mapkey?OE.base64.decode(e.mapkey,t.mapkey=OE.newBuffer(OE.base64.length(e.mapkey)),0):e.mapkey.length>=0&&(t.mapkey=e.mapkey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.encryptPrivkey="":(r.encryptPrivkey=[],t.bytes!==Array&&(r.encryptPrivkey=OE.newBuffer(r.encryptPrivkey))),t.bytes===String?r.mapkey="":(r.mapkey=[],t.bytes!==Array&&(r.mapkey=OE.newBuffer(r.mapkey)))),null!=e.encryptPrivkey&&e.hasOwnProperty("encryptPrivkey")&&(r.encryptPrivkey=t.bytes===String?OE.base64.encode(e.encryptPrivkey,0,e.encryptPrivkey.length):t.bytes===Array?Array.prototype.slice.call(e.encryptPrivkey):e.encryptPrivkey),null!=e.mapkey&&e.hasOwnProperty("mapkey")&&(r.mapkey=t.bytes===String?OE.base64.encode(e.mapkey,0,e.mapkey.length):t.bytes===Array?Array.prototype.slice.call(e.mapkey):e.mapkey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetEncryptKeyWithScanRequest"},e}(),e.SetEncryptKeyWithScanReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetEncryptKeyWithScanReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.SetEncryptKeyWithScanReply?e:new AE.dcnet.pb.SetEncryptKeyWithScanReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetEncryptKeyWithScanReply"},e}(),e.GetEncryptKeyWithScanRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.mapkey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.mapkey&&Object.hasOwnProperty.call(e,"mapkey")&&t.uint32(10).bytes(e.mapkey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetEncryptKeyWithScanRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.mapkey=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.mapkey&&e.hasOwnProperty("mapkey")&&!(e.mapkey&&"number"==typeof e.mapkey.length||OE.isString(e.mapkey))?"mapkey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetEncryptKeyWithScanRequest)return e;var t=new AE.dcnet.pb.GetEncryptKeyWithScanRequest;return null!=e.mapkey&&("string"==typeof e.mapkey?OE.base64.decode(e.mapkey,t.mapkey=OE.newBuffer(OE.base64.length(e.mapkey)),0):e.mapkey.length>=0&&(t.mapkey=e.mapkey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.mapkey="":(r.mapkey=[],t.bytes!==Array&&(r.mapkey=OE.newBuffer(r.mapkey)))),null!=e.mapkey&&e.hasOwnProperty("mapkey")&&(r.mapkey=t.bytes===String?OE.base64.encode(e.mapkey,0,e.mapkey.length):t.bytes===Array?Array.prototype.slice.call(e.mapkey):e.mapkey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetEncryptKeyWithScanRequest"},e}(),e.GetEncryptKeyWithScanReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.encryptPrivkey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.encryptPrivkey&&Object.hasOwnProperty.call(e,"encryptPrivkey")&&t.uint32(10).bytes(e.encryptPrivkey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetEncryptKeyWithScanReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.encryptPrivkey=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.encryptPrivkey&&e.hasOwnProperty("encryptPrivkey")&&!(e.encryptPrivkey&&"number"==typeof e.encryptPrivkey.length||OE.isString(e.encryptPrivkey))?"encryptPrivkey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetEncryptKeyWithScanReply)return e;var t=new AE.dcnet.pb.GetEncryptKeyWithScanReply;return null!=e.encryptPrivkey&&("string"==typeof e.encryptPrivkey?OE.base64.decode(e.encryptPrivkey,t.encryptPrivkey=OE.newBuffer(OE.base64.length(e.encryptPrivkey)),0):e.encryptPrivkey.length>=0&&(t.encryptPrivkey=e.encryptPrivkey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.encryptPrivkey="":(r.encryptPrivkey=[],t.bytes!==Array&&(r.encryptPrivkey=OE.newBuffer(r.encryptPrivkey)))),null!=e.encryptPrivkey&&e.hasOwnProperty("encryptPrivkey")&&(r.encryptPrivkey=t.bytes===String?OE.base64.encode(e.encryptPrivkey,0,e.encryptPrivkey.length):t.bytes===Array?Array.prototype.slice.call(e.encryptPrivkey):e.encryptPrivkey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetEncryptKeyWithScanReply"},e}(),e.RequestRandEncryptKeyRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.enclaveid=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.enclaveid&&Object.hasOwnProperty.call(e,"enclaveid")&&t.uint32(10).bytes(e.enclaveid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.RequestRandEncryptKeyRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.enclaveid=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.enclaveid&&e.hasOwnProperty("enclaveid")&&!(e.enclaveid&&"number"==typeof e.enclaveid.length||OE.isString(e.enclaveid))?"enclaveid: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.RequestRandEncryptKeyRequest)return e;var t=new AE.dcnet.pb.RequestRandEncryptKeyRequest;return null!=e.enclaveid&&("string"==typeof e.enclaveid?OE.base64.decode(e.enclaveid,t.enclaveid=OE.newBuffer(OE.base64.length(e.enclaveid)),0):e.enclaveid.length>=0&&(t.enclaveid=e.enclaveid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.enclaveid="":(r.enclaveid=[],t.bytes!==Array&&(r.enclaveid=OE.newBuffer(r.enclaveid)))),null!=e.enclaveid&&e.hasOwnProperty("enclaveid")&&(r.enclaveid=t.bytes===String?OE.base64.encode(e.enclaveid,0,e.enclaveid.length):t.bytes===Array?Array.prototype.slice.call(e.enclaveid):e.enclaveid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.RequestRandEncryptKeyRequest"},e}(),e.RequestRandEncryptKeyReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.encryptKey=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.encryptKey&&Object.hasOwnProperty.call(e,"encryptKey")&&t.uint32(10).bytes(e.encryptKey),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(18).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.RequestRandEncryptKeyReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.encryptKey=e.bytes();break;case 2:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.encryptKey&&e.hasOwnProperty("encryptKey")&&!(e.encryptKey&&"number"==typeof e.encryptKey.length||OE.isString(e.encryptKey))?"encryptKey: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.RequestRandEncryptKeyReply)return e;var t=new AE.dcnet.pb.RequestRandEncryptKeyReply;return null!=e.encryptKey&&("string"==typeof e.encryptKey?OE.base64.decode(e.encryptKey,t.encryptKey=OE.newBuffer(OE.base64.length(e.encryptKey)),0):e.encryptKey.length>=0&&(t.encryptKey=e.encryptKey)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.encryptKey="":(r.encryptKey=[],t.bytes!==Array&&(r.encryptKey=OE.newBuffer(r.encryptKey))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.encryptKey&&e.hasOwnProperty("encryptKey")&&(r.encryptKey=t.bytes===String?OE.base64.encode(e.encryptKey,0,e.encryptKey.length):t.bytes===Array?Array.prototype.slice.call(e.encryptKey):e.encryptKey),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.RequestRandEncryptKeyReply"},e}(),e.GetEncryptKeyRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.peerId=OE.newBuffer([]),e.prototype.teereport=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.peerId&&Object.hasOwnProperty.call(e,"peerId")&&t.uint32(10).bytes(e.peerId),null!=e.teereport&&Object.hasOwnProperty.call(e,"teereport")&&t.uint32(18).bytes(e.teereport),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetEncryptKeyRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.peerId=e.bytes();break;case 2:n.teereport=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.peerId&&e.hasOwnProperty("peerId")&&!(e.peerId&&"number"==typeof e.peerId.length||OE.isString(e.peerId))?"peerId: buffer expected":null!=e.teereport&&e.hasOwnProperty("teereport")&&!(e.teereport&&"number"==typeof e.teereport.length||OE.isString(e.teereport))?"teereport: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetEncryptKeyRequest)return e;var t=new AE.dcnet.pb.GetEncryptKeyRequest;return null!=e.peerId&&("string"==typeof e.peerId?OE.base64.decode(e.peerId,t.peerId=OE.newBuffer(OE.base64.length(e.peerId)),0):e.peerId.length>=0&&(t.peerId=e.peerId)),null!=e.teereport&&("string"==typeof e.teereport?OE.base64.decode(e.teereport,t.teereport=OE.newBuffer(OE.base64.length(e.teereport)),0):e.teereport.length>=0&&(t.teereport=e.teereport)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.peerId="":(r.peerId=[],t.bytes!==Array&&(r.peerId=OE.newBuffer(r.peerId))),t.bytes===String?r.teereport="":(r.teereport=[],t.bytes!==Array&&(r.teereport=OE.newBuffer(r.teereport)))),null!=e.peerId&&e.hasOwnProperty("peerId")&&(r.peerId=t.bytes===String?OE.base64.encode(e.peerId,0,e.peerId.length):t.bytes===Array?Array.prototype.slice.call(e.peerId):e.peerId),null!=e.teereport&&e.hasOwnProperty("teereport")&&(r.teereport=t.bytes===String?OE.base64.encode(e.teereport,0,e.teereport.length):t.bytes===Array?Array.prototype.slice.call(e.teereport):e.teereport),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetEncryptKeyRequest"},e}(),e.GetEncryptKeyReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.encryptKey=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.encryptKey&&Object.hasOwnProperty.call(e,"encryptKey")&&t.uint32(10).bytes(e.encryptKey),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(18).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetEncryptKeyReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.encryptKey=e.bytes();break;case 2:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.encryptKey&&e.hasOwnProperty("encryptKey")&&!(e.encryptKey&&"number"==typeof e.encryptKey.length||OE.isString(e.encryptKey))?"encryptKey: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetEncryptKeyReply)return e;var t=new AE.dcnet.pb.GetEncryptKeyReply;return null!=e.encryptKey&&("string"==typeof e.encryptKey?OE.base64.decode(e.encryptKey,t.encryptKey=OE.newBuffer(OE.base64.length(e.encryptKey)),0):e.encryptKey.length>=0&&(t.encryptKey=e.encryptKey)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.encryptKey="":(r.encryptKey=[],t.bytes!==Array&&(r.encryptKey=OE.newBuffer(r.encryptKey))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.encryptKey&&e.hasOwnProperty("encryptKey")&&(r.encryptKey=t.bytes===String?OE.base64.encode(e.encryptKey,0,e.encryptKey.length):t.bytes===Array?Array.prototype.slice.call(e.encryptKey):e.encryptKey),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetEncryptKeyReply"},e}(),e.GetPeersWithSidRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.sid="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.sid&&Object.hasOwnProperty.call(e,"sid")&&t.uint32(10).string(e.sid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetPeersWithSidRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.sid=e.string():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.sid&&e.hasOwnProperty("sid")&&!OE.isString(e.sid)?"sid: string expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetPeersWithSidRequest)return e;var t=new AE.dcnet.pb.GetPeersWithSidRequest;return null!=e.sid&&(t.sid=String(e.sid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.sid=""),null!=e.sid&&e.hasOwnProperty("sid")&&(r.sid=e.sid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetPeersWithSidRequest"},e}(),e.GetPeersWithSidReply=function(){function e(e){if(this.peerids=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.peerids=OE.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=SE.create()),null!=e.peerids&&e.peerids.length)for(var r=0;r<e.peerids.length;++r)t.uint32(10).string(e.peerids[r]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetPeersWithSidReply;e.pos<r;){var o=e.uint32();o>>>3==1?(n.peerids&&n.peerids.length||(n.peerids=[]),n.peerids.push(e.string())):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.peerids&&e.hasOwnProperty("peerids")){if(!Array.isArray(e.peerids))return"peerids: array expected";for(var t=0;t<e.peerids.length;++t)if(!OE.isString(e.peerids[t]))return"peerids: string[] expected"}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetPeersWithSidReply)return e;var t=new AE.dcnet.pb.GetPeersWithSidReply;if(e.peerids){if(!Array.isArray(e.peerids))throw TypeError(".dcnet.pb.GetPeersWithSidReply.peerids: array expected");t.peerids=[];for(var r=0;r<e.peerids.length;++r)t.peerids[r]=String(e.peerids[r])}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.peerids=[]),e.peerids&&e.peerids.length){r.peerids=[];for(var n=0;n<e.peerids.length;++n)r.peerids[n]=e.peerids[n]}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetPeersWithSidReply"},e}(),e.GetPeersWithAccountHashRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.accounthash=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.accounthash&&Object.hasOwnProperty.call(e,"accounthash")&&t.uint32(10).bytes(e.accounthash),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetPeersWithAccountHashRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.accounthash=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.accounthash&&e.hasOwnProperty("accounthash")&&!(e.accounthash&&"number"==typeof e.accounthash.length||OE.isString(e.accounthash))?"accounthash: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetPeersWithAccountHashRequest)return e;var t=new AE.dcnet.pb.GetPeersWithAccountHashRequest;return null!=e.accounthash&&("string"==typeof e.accounthash?OE.base64.decode(e.accounthash,t.accounthash=OE.newBuffer(OE.base64.length(e.accounthash)),0):e.accounthash.length>=0&&(t.accounthash=e.accounthash)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.accounthash="":(r.accounthash=[],t.bytes!==Array&&(r.accounthash=OE.newBuffer(r.accounthash)))),null!=e.accounthash&&e.hasOwnProperty("accounthash")&&(r.accounthash=t.bytes===String?OE.base64.encode(e.accounthash,0,e.accounthash.length):t.bytes===Array?Array.prototype.slice.call(e.accounthash):e.accounthash),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetPeersWithAccountHashRequest"},e}(),e.GetPeersWithAccountHashReply=function(){function e(e){if(this.peerids=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.peerids=OE.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=SE.create()),null!=e.peerids&&e.peerids.length)for(var r=0;r<e.peerids.length;++r)t.uint32(10).string(e.peerids[r]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetPeersWithAccountHashReply;e.pos<r;){var o=e.uint32();o>>>3==1?(n.peerids&&n.peerids.length||(n.peerids=[]),n.peerids.push(e.string())):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.peerids&&e.hasOwnProperty("peerids")){if(!Array.isArray(e.peerids))return"peerids: array expected";for(var t=0;t<e.peerids.length;++t)if(!OE.isString(e.peerids[t]))return"peerids: string[] expected"}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetPeersWithAccountHashReply)return e;var t=new AE.dcnet.pb.GetPeersWithAccountHashReply;if(e.peerids){if(!Array.isArray(e.peerids))throw TypeError(".dcnet.pb.GetPeersWithAccountHashReply.peerids: array expected");t.peerids=[];for(var r=0;r<e.peerids.length;++r)t.peerids[r]=String(e.peerids[r])}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.peerids=[]),e.peerids&&e.peerids.length){r.peerids=[];for(var n=0;n<e.peerids.length;++n)r.peerids[n]=e.peerids[n]}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetPeersWithAccountHashReply"},e}(),e.AccountDealBackupRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.pubkey=OE.newBuffer([]),e.prototype.accountencrypt=OE.newBuffer([]),e.prototype.accounthashencrypt=OE.newBuffer([]),e.prototype.prikeyencrypt2=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.randkeyencrypt=OE.newBuffer([]),e.prototype.loginkeyrandencrypt=OE.newBuffer([]),e.prototype.peerid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.pubkey&&Object.hasOwnProperty.call(e,"pubkey")&&t.uint32(10).bytes(e.pubkey),null!=e.accountencrypt&&Object.hasOwnProperty.call(e,"accountencrypt")&&t.uint32(18).bytes(e.accountencrypt),null!=e.accounthashencrypt&&Object.hasOwnProperty.call(e,"accounthashencrypt")&&t.uint32(26).bytes(e.accounthashencrypt),null!=e.prikeyencrypt2&&Object.hasOwnProperty.call(e,"prikeyencrypt2")&&t.uint32(34).bytes(e.prikeyencrypt2),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(40).uint32(e.blockheight),null!=e.randkeyencrypt&&Object.hasOwnProperty.call(e,"randkeyencrypt")&&t.uint32(50).bytes(e.randkeyencrypt),null!=e.loginkeyrandencrypt&&Object.hasOwnProperty.call(e,"loginkeyrandencrypt")&&t.uint32(58).bytes(e.loginkeyrandencrypt),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(66).bytes(e.peerid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(74).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(82).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AccountDealBackupRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.pubkey=e.bytes();break;case 2:n.accountencrypt=e.bytes();break;case 3:n.accounthashencrypt=e.bytes();break;case 4:n.prikeyencrypt2=e.bytes();break;case 5:n.blockheight=e.uint32();break;case 6:n.randkeyencrypt=e.bytes();break;case 7:n.loginkeyrandencrypt=e.bytes();break;case 8:n.peerid=e.bytes();break;case 9:n.signature=e.bytes();break;case 10:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.pubkey&&e.hasOwnProperty("pubkey")&&!(e.pubkey&&"number"==typeof e.pubkey.length||OE.isString(e.pubkey))?"pubkey: buffer expected":null!=e.accountencrypt&&e.hasOwnProperty("accountencrypt")&&!(e.accountencrypt&&"number"==typeof e.accountencrypt.length||OE.isString(e.accountencrypt))?"accountencrypt: buffer expected":null!=e.accounthashencrypt&&e.hasOwnProperty("accounthashencrypt")&&!(e.accounthashencrypt&&"number"==typeof e.accounthashencrypt.length||OE.isString(e.accounthashencrypt))?"accounthashencrypt: buffer expected":null!=e.prikeyencrypt2&&e.hasOwnProperty("prikeyencrypt2")&&!(e.prikeyencrypt2&&"number"==typeof e.prikeyencrypt2.length||OE.isString(e.prikeyencrypt2))?"prikeyencrypt2: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.randkeyencrypt&&e.hasOwnProperty("randkeyencrypt")&&!(e.randkeyencrypt&&"number"==typeof e.randkeyencrypt.length||OE.isString(e.randkeyencrypt))?"randkeyencrypt: buffer expected":null!=e.loginkeyrandencrypt&&e.hasOwnProperty("loginkeyrandencrypt")&&!(e.loginkeyrandencrypt&&"number"==typeof e.loginkeyrandencrypt.length||OE.isString(e.loginkeyrandencrypt))?"loginkeyrandencrypt: buffer expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AccountDealBackupRequest)return e;var t=new AE.dcnet.pb.AccountDealBackupRequest;return null!=e.pubkey&&("string"==typeof e.pubkey?OE.base64.decode(e.pubkey,t.pubkey=OE.newBuffer(OE.base64.length(e.pubkey)),0):e.pubkey.length>=0&&(t.pubkey=e.pubkey)),null!=e.accountencrypt&&("string"==typeof e.accountencrypt?OE.base64.decode(e.accountencrypt,t.accountencrypt=OE.newBuffer(OE.base64.length(e.accountencrypt)),0):e.accountencrypt.length>=0&&(t.accountencrypt=e.accountencrypt)),null!=e.accounthashencrypt&&("string"==typeof e.accounthashencrypt?OE.base64.decode(e.accounthashencrypt,t.accounthashencrypt=OE.newBuffer(OE.base64.length(e.accounthashencrypt)),0):e.accounthashencrypt.length>=0&&(t.accounthashencrypt=e.accounthashencrypt)),null!=e.prikeyencrypt2&&("string"==typeof e.prikeyencrypt2?OE.base64.decode(e.prikeyencrypt2,t.prikeyencrypt2=OE.newBuffer(OE.base64.length(e.prikeyencrypt2)),0):e.prikeyencrypt2.length>=0&&(t.prikeyencrypt2=e.prikeyencrypt2)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.randkeyencrypt&&("string"==typeof e.randkeyencrypt?OE.base64.decode(e.randkeyencrypt,t.randkeyencrypt=OE.newBuffer(OE.base64.length(e.randkeyencrypt)),0):e.randkeyencrypt.length>=0&&(t.randkeyencrypt=e.randkeyencrypt)),null!=e.loginkeyrandencrypt&&("string"==typeof e.loginkeyrandencrypt?OE.base64.decode(e.loginkeyrandencrypt,t.loginkeyrandencrypt=OE.newBuffer(OE.base64.length(e.loginkeyrandencrypt)),0):e.loginkeyrandencrypt.length>=0&&(t.loginkeyrandencrypt=e.loginkeyrandencrypt)),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.pubkey="":(r.pubkey=[],t.bytes!==Array&&(r.pubkey=OE.newBuffer(r.pubkey))),t.bytes===String?r.accountencrypt="":(r.accountencrypt=[],t.bytes!==Array&&(r.accountencrypt=OE.newBuffer(r.accountencrypt))),t.bytes===String?r.accounthashencrypt="":(r.accounthashencrypt=[],t.bytes!==Array&&(r.accounthashencrypt=OE.newBuffer(r.accounthashencrypt))),t.bytes===String?r.prikeyencrypt2="":(r.prikeyencrypt2=[],t.bytes!==Array&&(r.prikeyencrypt2=OE.newBuffer(r.prikeyencrypt2))),r.blockheight=0,t.bytes===String?r.randkeyencrypt="":(r.randkeyencrypt=[],t.bytes!==Array&&(r.randkeyencrypt=OE.newBuffer(r.randkeyencrypt))),t.bytes===String?r.loginkeyrandencrypt="":(r.loginkeyrandencrypt=[],t.bytes!==Array&&(r.loginkeyrandencrypt=OE.newBuffer(r.loginkeyrandencrypt))),t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.pubkey&&e.hasOwnProperty("pubkey")&&(r.pubkey=t.bytes===String?OE.base64.encode(e.pubkey,0,e.pubkey.length):t.bytes===Array?Array.prototype.slice.call(e.pubkey):e.pubkey),null!=e.accountencrypt&&e.hasOwnProperty("accountencrypt")&&(r.accountencrypt=t.bytes===String?OE.base64.encode(e.accountencrypt,0,e.accountencrypt.length):t.bytes===Array?Array.prototype.slice.call(e.accountencrypt):e.accountencrypt),null!=e.accounthashencrypt&&e.hasOwnProperty("accounthashencrypt")&&(r.accounthashencrypt=t.bytes===String?OE.base64.encode(e.accounthashencrypt,0,e.accounthashencrypt.length):t.bytes===Array?Array.prototype.slice.call(e.accounthashencrypt):e.accounthashencrypt),null!=e.prikeyencrypt2&&e.hasOwnProperty("prikeyencrypt2")&&(r.prikeyencrypt2=t.bytes===String?OE.base64.encode(e.prikeyencrypt2,0,e.prikeyencrypt2.length):t.bytes===Array?Array.prototype.slice.call(e.prikeyencrypt2):e.prikeyencrypt2),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.randkeyencrypt&&e.hasOwnProperty("randkeyencrypt")&&(r.randkeyencrypt=t.bytes===String?OE.base64.encode(e.randkeyencrypt,0,e.randkeyencrypt.length):t.bytes===Array?Array.prototype.slice.call(e.randkeyencrypt):e.randkeyencrypt),null!=e.loginkeyrandencrypt&&e.hasOwnProperty("loginkeyrandencrypt")&&(r.loginkeyrandencrypt=t.bytes===String?OE.base64.encode(e.loginkeyrandencrypt,0,e.loginkeyrandencrypt.length):t.bytes===Array?Array.prototype.slice.call(e.loginkeyrandencrypt):e.loginkeyrandencrypt),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AccountDealBackupRequest"},e}(),e.AccountDealBackupReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AccountDealBackupReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.AccountDealBackupReply?e:new AE.dcnet.pb.AccountDealBackupReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AccountDealBackupReply"},e}(),e.GetHostIDRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetHostIDRequest;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.GetHostIDRequest?e:new AE.dcnet.pb.GetHostIDRequest},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetHostIDRequest"},e}(),e.GetHostIDReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.peerID=OE.newBuffer([]),e.prototype.reqAddr=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.peerID&&Object.hasOwnProperty.call(e,"peerID")&&t.uint32(10).bytes(e.peerID),null!=e.reqAddr&&Object.hasOwnProperty.call(e,"reqAddr")&&t.uint32(18).bytes(e.reqAddr),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetHostIDReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.peerID=e.bytes();break;case 2:n.reqAddr=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.peerID&&e.hasOwnProperty("peerID")&&!(e.peerID&&"number"==typeof e.peerID.length||OE.isString(e.peerID))?"peerID: buffer expected":null!=e.reqAddr&&e.hasOwnProperty("reqAddr")&&!(e.reqAddr&&"number"==typeof e.reqAddr.length||OE.isString(e.reqAddr))?"reqAddr: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetHostIDReply)return e;var t=new AE.dcnet.pb.GetHostIDReply;return null!=e.peerID&&("string"==typeof e.peerID?OE.base64.decode(e.peerID,t.peerID=OE.newBuffer(OE.base64.length(e.peerID)),0):e.peerID.length>=0&&(t.peerID=e.peerID)),null!=e.reqAddr&&("string"==typeof e.reqAddr?OE.base64.decode(e.reqAddr,t.reqAddr=OE.newBuffer(OE.base64.length(e.reqAddr)),0):e.reqAddr.length>=0&&(t.reqAddr=e.reqAddr)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.peerID="":(r.peerID=[],t.bytes!==Array&&(r.peerID=OE.newBuffer(r.peerID))),t.bytes===String?r.reqAddr="":(r.reqAddr=[],t.bytes!==Array&&(r.reqAddr=OE.newBuffer(r.reqAddr)))),null!=e.peerID&&e.hasOwnProperty("peerID")&&(r.peerID=t.bytes===String?OE.base64.encode(e.peerID,0,e.peerID.length):t.bytes===Array?Array.prototype.slice.call(e.peerID):e.peerID),null!=e.reqAddr&&e.hasOwnProperty("reqAddr")&&(r.reqAddr=t.bytes===String?OE.base64.encode(e.reqAddr,0,e.reqAddr.length):t.bytes===Array?Array.prototype.slice.call(e.reqAddr):e.reqAddr),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetHostIDReply"},e}(),e.ReportLocalMultilAddrRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.addr="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.addr&&Object.hasOwnProperty.call(e,"addr")&&t.uint32(10).string(e.addr),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ReportLocalMultilAddrRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.addr=e.string():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.addr&&e.hasOwnProperty("addr")&&!OE.isString(e.addr)?"addr: string expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ReportLocalMultilAddrRequest)return e;var t=new AE.dcnet.pb.ReportLocalMultilAddrRequest;return null!=e.addr&&(t.addr=String(e.addr)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.addr=""),null!=e.addr&&e.hasOwnProperty("addr")&&(r.addr=e.addr),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ReportLocalMultilAddrRequest"},e}(),e.ReportLocalMultilAddrReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ReportLocalMultilAddrReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.ReportLocalMultilAddrReply?e:new AE.dcnet.pb.ReportLocalMultilAddrReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ReportLocalMultilAddrReply"},e}(),e.GetTokenRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}var t;return e.prototype.key=null,e.prototype.signature=null,Object.defineProperty(e.prototype,"payload",{get:OE.oneOfGetter(t=["key","signature"]),set:OE.oneOfSetter(t)}),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.key&&Object.hasOwnProperty.call(e,"key")&&t.uint32(10).string(e.key),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(18).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetTokenRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.key=e.string();break;case 2:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var t={};if(null!=e.key&&e.hasOwnProperty("key")&&(t.payload=1,!OE.isString(e.key)))return"key: string expected";if(null!=e.signature&&e.hasOwnProperty("signature")){if(1===t.payload)return"payload: multiple values";if(t.payload=1,!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature)))return"signature: buffer expected"}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetTokenRequest)return e;var t=new AE.dcnet.pb.GetTokenRequest;return null!=e.key&&(t.key=String(e.key)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return null!=e.key&&e.hasOwnProperty("key")&&(r.key=e.key,t.oneofs&&(r.payload="key")),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature,t.oneofs&&(r.payload="signature")),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetTokenRequest"},e}(),e.GetTokenReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}var t;return e.prototype.challenge=null,e.prototype.token=null,Object.defineProperty(e.prototype,"payload",{get:OE.oneOfGetter(t=["challenge","token"]),set:OE.oneOfSetter(t)}),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.challenge&&Object.hasOwnProperty.call(e,"challenge")&&t.uint32(10).bytes(e.challenge),null!=e.token&&Object.hasOwnProperty.call(e,"token")&&t.uint32(18).string(e.token),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetTokenReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.challenge=e.bytes();break;case 2:n.token=e.string();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var t={};if(null!=e.challenge&&e.hasOwnProperty("challenge")&&(t.payload=1,!(e.challenge&&"number"==typeof e.challenge.length||OE.isString(e.challenge))))return"challenge: buffer expected";if(null!=e.token&&e.hasOwnProperty("token")){if(1===t.payload)return"payload: multiple values";if(t.payload=1,!OE.isString(e.token))return"token: string expected"}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetTokenReply)return e;var t=new AE.dcnet.pb.GetTokenReply;return null!=e.challenge&&("string"==typeof e.challenge?OE.base64.decode(e.challenge,t.challenge=OE.newBuffer(OE.base64.length(e.challenge)),0):e.challenge.length>=0&&(t.challenge=e.challenge)),null!=e.token&&(t.token=String(e.token)),t},e.toObject=function(e,t){t||(t={});var r={};return null!=e.challenge&&e.hasOwnProperty("challenge")&&(r.challenge=t.bytes===String?OE.base64.encode(e.challenge,0,e.challenge.length):t.bytes===Array?Array.prototype.slice.call(e.challenge):e.challenge,t.oneofs&&(r.payload="challenge")),null!=e.token&&e.hasOwnProperty("token")&&(r.token=e.token,t.oneofs&&(r.payload="token")),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetTokenReply"},e}(),e.CreateThreadRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=OE.newBuffer([]),e.prototype.keys=null,e.prototype.blockheight=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.keys&&Object.hasOwnProperty.call(e,"keys")&&AE.dcnet.pb.Keys.encode(e.keys,t.uint32(18).fork()).ldelim(),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(24).uint32(e.blockheight),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(34).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(42).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.CreateThreadRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.keys=AE.dcnet.pb.Keys.decode(e,e.uint32());break;case 3:n.blockheight=e.uint32();break;case 4:n.signature=e.bytes();break;case 5:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||OE.isString(e.threadID)))return"threadID: buffer expected";if(null!=e.keys&&e.hasOwnProperty("keys")){var t=AE.dcnet.pb.Keys.verify(e.keys);if(t)return"keys."+t}return null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.CreateThreadRequest)return e;var t=new AE.dcnet.pb.CreateThreadRequest;if(null!=e.threadID&&("string"==typeof e.threadID?OE.base64.decode(e.threadID,t.threadID=OE.newBuffer(OE.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.keys){if("object"!=typeof e.keys)throw TypeError(".dcnet.pb.CreateThreadRequest.keys: object expected");t.keys=AE.dcnet.pb.Keys.fromObject(e.keys)}return null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=OE.newBuffer(r.threadID))),r.keys=null,r.blockheight=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?OE.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.keys&&e.hasOwnProperty("keys")&&(r.keys=AE.dcnet.pb.Keys.toObject(e.keys,t)),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.CreateThreadRequest"},e}(),e.Keys=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadKeyEncrpt=OE.newBuffer([]),e.prototype.logKeyEncrpt=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.threadKeyEncrpt&&Object.hasOwnProperty.call(e,"threadKeyEncrpt")&&t.uint32(10).bytes(e.threadKeyEncrpt),null!=e.logKeyEncrpt&&Object.hasOwnProperty.call(e,"logKeyEncrpt")&&t.uint32(18).bytes(e.logKeyEncrpt),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.Keys;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadKeyEncrpt=e.bytes();break;case 2:n.logKeyEncrpt=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.threadKeyEncrpt&&e.hasOwnProperty("threadKeyEncrpt")&&!(e.threadKeyEncrpt&&"number"==typeof e.threadKeyEncrpt.length||OE.isString(e.threadKeyEncrpt))?"threadKeyEncrpt: buffer expected":null!=e.logKeyEncrpt&&e.hasOwnProperty("logKeyEncrpt")&&!(e.logKeyEncrpt&&"number"==typeof e.logKeyEncrpt.length||OE.isString(e.logKeyEncrpt))?"logKeyEncrpt: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.Keys)return e;var t=new AE.dcnet.pb.Keys;return null!=e.threadKeyEncrpt&&("string"==typeof e.threadKeyEncrpt?OE.base64.decode(e.threadKeyEncrpt,t.threadKeyEncrpt=OE.newBuffer(OE.base64.length(e.threadKeyEncrpt)),0):e.threadKeyEncrpt.length>=0&&(t.threadKeyEncrpt=e.threadKeyEncrpt)),null!=e.logKeyEncrpt&&("string"==typeof e.logKeyEncrpt?OE.base64.decode(e.logKeyEncrpt,t.logKeyEncrpt=OE.newBuffer(OE.base64.length(e.logKeyEncrpt)),0):e.logKeyEncrpt.length>=0&&(t.logKeyEncrpt=e.logKeyEncrpt)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadKeyEncrpt="":(r.threadKeyEncrpt=[],t.bytes!==Array&&(r.threadKeyEncrpt=OE.newBuffer(r.threadKeyEncrpt))),t.bytes===String?r.logKeyEncrpt="":(r.logKeyEncrpt=[],t.bytes!==Array&&(r.logKeyEncrpt=OE.newBuffer(r.logKeyEncrpt)))),null!=e.threadKeyEncrpt&&e.hasOwnProperty("threadKeyEncrpt")&&(r.threadKeyEncrpt=t.bytes===String?OE.base64.encode(e.threadKeyEncrpt,0,e.threadKeyEncrpt.length):t.bytes===Array?Array.prototype.slice.call(e.threadKeyEncrpt):e.threadKeyEncrpt),null!=e.logKeyEncrpt&&e.hasOwnProperty("logKeyEncrpt")&&(r.logKeyEncrpt=t.bytes===String?OE.base64.encode(e.logKeyEncrpt,0,e.logKeyEncrpt.length):t.bytes===Array?Array.prototype.slice.call(e.logKeyEncrpt):e.logKeyEncrpt),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.Keys"},e}(),e.ThreadInfoReply=function(){function e(e){if(this.logs=[],this.addrs=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=OE.newBuffer([]),e.prototype.logs=OE.emptyArray,e.prototype.addrs=OE.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=SE.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.logs&&e.logs.length)for(var r=0;r<e.logs.length;++r)AE.dcnet.pb.LogInfo.encode(e.logs[r],t.uint32(26).fork()).ldelim();if(null!=e.addrs&&e.addrs.length)for(var n=0;n<e.addrs.length;++n)t.uint32(34).bytes(e.addrs[n]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ThreadInfoReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 3:n.logs&&n.logs.length||(n.logs=[]),n.logs.push(AE.dcnet.pb.LogInfo.decode(e,e.uint32()));break;case 4:n.addrs&&n.addrs.length||(n.addrs=[]),n.addrs.push(e.bytes());break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||OE.isString(e.threadID)))return"threadID: buffer expected";if(null!=e.logs&&e.hasOwnProperty("logs")){if(!Array.isArray(e.logs))return"logs: array expected";for(var t=0;t<e.logs.length;++t){var r=AE.dcnet.pb.LogInfo.verify(e.logs[t]);if(r)return"logs."+r}}if(null!=e.addrs&&e.hasOwnProperty("addrs")){if(!Array.isArray(e.addrs))return"addrs: array expected";for(var n=0;n<e.addrs.length;++n)if(!(e.addrs[n]&&"number"==typeof e.addrs[n].length||OE.isString(e.addrs[n])))return"addrs: buffer[] expected"}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ThreadInfoReply)return e;var t=new AE.dcnet.pb.ThreadInfoReply;if(null!=e.threadID&&("string"==typeof e.threadID?OE.base64.decode(e.threadID,t.threadID=OE.newBuffer(OE.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),e.logs){if(!Array.isArray(e.logs))throw TypeError(".dcnet.pb.ThreadInfoReply.logs: array expected");t.logs=[];for(var r=0;r<e.logs.length;++r){if("object"!=typeof e.logs[r])throw TypeError(".dcnet.pb.ThreadInfoReply.logs: object expected");t.logs[r]=AE.dcnet.pb.LogInfo.fromObject(e.logs[r])}}if(e.addrs){if(!Array.isArray(e.addrs))throw TypeError(".dcnet.pb.ThreadInfoReply.addrs: array expected");t.addrs=[];for(var n=0;n<e.addrs.length;++n)"string"==typeof e.addrs[n]?OE.base64.decode(e.addrs[n],t.addrs[n]=OE.newBuffer(OE.base64.length(e.addrs[n])),0):e.addrs[n].length>=0&&(t.addrs[n]=e.addrs[n])}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.logs=[],r.addrs=[]),t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=OE.newBuffer(r.threadID)))),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?OE.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),e.logs&&e.logs.length){r.logs=[];for(var n=0;n<e.logs.length;++n)r.logs[n]=AE.dcnet.pb.LogInfo.toObject(e.logs[n],t)}if(e.addrs&&e.addrs.length){r.addrs=[];for(var o=0;o<e.addrs.length;++o)r.addrs[o]=t.bytes===String?OE.base64.encode(e.addrs[o],0,e.addrs[o].length):t.bytes===Array?Array.prototype.slice.call(e.addrs[o]):e.addrs[o]}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ThreadInfoReply"},e}(),e.LogInfo=function(){function e(e){if(this.addrs=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.ID=OE.newBuffer([]),e.prototype.pubKey=OE.newBuffer([]),e.prototype.privKey=OE.newBuffer([]),e.prototype.addrs=OE.emptyArray,e.prototype.head=OE.newBuffer([]),e.prototype.counter=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=SE.create()),null!=e.ID&&Object.hasOwnProperty.call(e,"ID")&&t.uint32(10).bytes(e.ID),null!=e.pubKey&&Object.hasOwnProperty.call(e,"pubKey")&&t.uint32(18).bytes(e.pubKey),null!=e.privKey&&Object.hasOwnProperty.call(e,"privKey")&&t.uint32(26).bytes(e.privKey),null!=e.addrs&&e.addrs.length)for(var r=0;r<e.addrs.length;++r)t.uint32(34).bytes(e.addrs[r]);return null!=e.head&&Object.hasOwnProperty.call(e,"head")&&t.uint32(42).bytes(e.head),null!=e.counter&&Object.hasOwnProperty.call(e,"counter")&&t.uint32(50).bytes(e.counter),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.LogInfo;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.ID=e.bytes();break;case 2:n.pubKey=e.bytes();break;case 3:n.privKey=e.bytes();break;case 4:n.addrs&&n.addrs.length||(n.addrs=[]),n.addrs.push(e.bytes());break;case 5:n.head=e.bytes();break;case 6:n.counter=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.ID&&e.hasOwnProperty("ID")&&!(e.ID&&"number"==typeof e.ID.length||OE.isString(e.ID)))return"ID: buffer expected";if(null!=e.pubKey&&e.hasOwnProperty("pubKey")&&!(e.pubKey&&"number"==typeof e.pubKey.length||OE.isString(e.pubKey)))return"pubKey: buffer expected";if(null!=e.privKey&&e.hasOwnProperty("privKey")&&!(e.privKey&&"number"==typeof e.privKey.length||OE.isString(e.privKey)))return"privKey: buffer expected";if(null!=e.addrs&&e.hasOwnProperty("addrs")){if(!Array.isArray(e.addrs))return"addrs: array expected";for(var t=0;t<e.addrs.length;++t)if(!(e.addrs[t]&&"number"==typeof e.addrs[t].length||OE.isString(e.addrs[t])))return"addrs: buffer[] expected"}return null!=e.head&&e.hasOwnProperty("head")&&!(e.head&&"number"==typeof e.head.length||OE.isString(e.head))?"head: buffer expected":null!=e.counter&&e.hasOwnProperty("counter")&&!(e.counter&&"number"==typeof e.counter.length||OE.isString(e.counter))?"counter: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.LogInfo)return e;var t=new AE.dcnet.pb.LogInfo;if(null!=e.ID&&("string"==typeof e.ID?OE.base64.decode(e.ID,t.ID=OE.newBuffer(OE.base64.length(e.ID)),0):e.ID.length>=0&&(t.ID=e.ID)),null!=e.pubKey&&("string"==typeof e.pubKey?OE.base64.decode(e.pubKey,t.pubKey=OE.newBuffer(OE.base64.length(e.pubKey)),0):e.pubKey.length>=0&&(t.pubKey=e.pubKey)),null!=e.privKey&&("string"==typeof e.privKey?OE.base64.decode(e.privKey,t.privKey=OE.newBuffer(OE.base64.length(e.privKey)),0):e.privKey.length>=0&&(t.privKey=e.privKey)),e.addrs){if(!Array.isArray(e.addrs))throw TypeError(".dcnet.pb.LogInfo.addrs: array expected");t.addrs=[];for(var r=0;r<e.addrs.length;++r)"string"==typeof e.addrs[r]?OE.base64.decode(e.addrs[r],t.addrs[r]=OE.newBuffer(OE.base64.length(e.addrs[r])),0):e.addrs[r].length>=0&&(t.addrs[r]=e.addrs[r])}return null!=e.head&&("string"==typeof e.head?OE.base64.decode(e.head,t.head=OE.newBuffer(OE.base64.length(e.head)),0):e.head.length>=0&&(t.head=e.head)),null!=e.counter&&("string"==typeof e.counter?OE.base64.decode(e.counter,t.counter=OE.newBuffer(OE.base64.length(e.counter)),0):e.counter.length>=0&&(t.counter=e.counter)),t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.addrs=[]),t.defaults&&(t.bytes===String?r.ID="":(r.ID=[],t.bytes!==Array&&(r.ID=OE.newBuffer(r.ID))),t.bytes===String?r.pubKey="":(r.pubKey=[],t.bytes!==Array&&(r.pubKey=OE.newBuffer(r.pubKey))),t.bytes===String?r.privKey="":(r.privKey=[],t.bytes!==Array&&(r.privKey=OE.newBuffer(r.privKey))),t.bytes===String?r.head="":(r.head=[],t.bytes!==Array&&(r.head=OE.newBuffer(r.head))),t.bytes===String?r.counter="":(r.counter=[],t.bytes!==Array&&(r.counter=OE.newBuffer(r.counter)))),null!=e.ID&&e.hasOwnProperty("ID")&&(r.ID=t.bytes===String?OE.base64.encode(e.ID,0,e.ID.length):t.bytes===Array?Array.prototype.slice.call(e.ID):e.ID),null!=e.pubKey&&e.hasOwnProperty("pubKey")&&(r.pubKey=t.bytes===String?OE.base64.encode(e.pubKey,0,e.pubKey.length):t.bytes===Array?Array.prototype.slice.call(e.pubKey):e.pubKey),null!=e.privKey&&e.hasOwnProperty("privKey")&&(r.privKey=t.bytes===String?OE.base64.encode(e.privKey,0,e.privKey.length):t.bytes===Array?Array.prototype.slice.call(e.privKey):e.privKey),e.addrs&&e.addrs.length){r.addrs=[];for(var n=0;n<e.addrs.length;++n)r.addrs[n]=t.bytes===String?OE.base64.encode(e.addrs[n],0,e.addrs[n].length):t.bytes===Array?Array.prototype.slice.call(e.addrs[n]):e.addrs[n]}return null!=e.head&&e.hasOwnProperty("head")&&(r.head=t.bytes===String?OE.base64.encode(e.head,0,e.head.length):t.bytes===Array?Array.prototype.slice.call(e.head):e.head),null!=e.counter&&e.hasOwnProperty("counter")&&(r.counter=t.bytes===String?OE.base64.encode(e.counter,0,e.counter.length):t.bytes===Array?Array.prototype.slice.call(e.counter):e.counter),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.LogInfo"},e}(),e.ThreadIDRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(10).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ThreadIDRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.vaccount=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ThreadIDRequest)return e;var t=new AE.dcnet.pb.ThreadIDRequest;return null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ThreadIDRequest"},e}(),e.ThreadIDReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ThreadIDReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.threadID=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||OE.isString(e.threadID))?"threadID: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ThreadIDReply)return e;var t=new AE.dcnet.pb.ThreadIDReply;return null!=e.threadID&&("string"==typeof e.threadID?OE.base64.decode(e.threadID,t.threadID=OE.newBuffer(OE.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=OE.newBuffer(r.threadID)))),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?OE.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ThreadIDReply"},e}(),e.AddThreadToPeerRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.keys=null,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.keys&&Object.hasOwnProperty.call(e,"keys")&&AE.dcnet.pb.Keys.encode(e.keys,t.uint32(26).fork()).ldelim(),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(34).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(42).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddThreadToPeerRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.keys=AE.dcnet.pb.Keys.decode(e,e.uint32());break;case 4:n.signature=e.bytes();break;case 5:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||OE.isString(e.threadID)))return"threadID: buffer expected";if(null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight))return"blockheight: integer expected";if(null!=e.keys&&e.hasOwnProperty("keys")){var t=AE.dcnet.pb.Keys.verify(e.keys);if(t)return"keys."+t}return null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddThreadToPeerRequest)return e;var t=new AE.dcnet.pb.AddThreadToPeerRequest;if(null!=e.threadID&&("string"==typeof e.threadID?OE.base64.decode(e.threadID,t.threadID=OE.newBuffer(OE.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.keys){if("object"!=typeof e.keys)throw TypeError(".dcnet.pb.AddThreadToPeerRequest.keys: object expected");t.keys=AE.dcnet.pb.Keys.fromObject(e.keys)}return null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=OE.newBuffer(r.threadID))),r.blockheight=0,r.keys=null,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?OE.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.keys&&e.hasOwnProperty("keys")&&(r.keys=AE.dcnet.pb.Keys.toObject(e.keys,t)),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddThreadToPeerRequest"},e}(),e.AddThreadToPeerReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.status=0,e.prototype.count=OE.Long?OE.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.status&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),null!=e.count&&Object.hasOwnProperty.call(e,"count")&&t.uint32(16).int64(e.count),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddThreadToPeerReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.status=e.int32();break;case 2:n.count=e.int64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.status&&e.hasOwnProperty("status")&&!OE.isInteger(e.status)?"status: integer expected":null!=e.count&&e.hasOwnProperty("count")&&!(OE.isInteger(e.count)||e.count&&OE.isInteger(e.count.low)&&OE.isInteger(e.count.high))?"count: integer|Long expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddThreadToPeerReply)return e;var t=new AE.dcnet.pb.AddThreadToPeerReply;return null!=e.status&&(t.status=0|e.status),null!=e.count&&(OE.Long?(t.count=OE.Long.fromValue(e.count)).unsigned=!1:"string"==typeof e.count?t.count=parseInt(e.count,10):"number"==typeof e.count?t.count=e.count:"object"==typeof e.count&&(t.count=new OE.LongBits(e.count.low>>>0,e.count.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(r.status=0,OE.Long){var n=new OE.Long(0,0,!1);r.count=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.count=t.longs===String?"0":0;return null!=e.status&&e.hasOwnProperty("status")&&(r.status=e.status),null!=e.count&&e.hasOwnProperty("count")&&("number"==typeof e.count?r.count=t.longs===String?String(e.count):e.count:r.count=t.longs===String?OE.Long.prototype.toString.call(e.count):t.longs===Number?new OE.LongBits(e.count.low>>>0,e.count.high>>>0).toNumber():e.count),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddThreadToPeerReply"},e}(),e.GetThreadRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(18).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThreadRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||OE.isString(e.threadID))?"threadID: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThreadRequest)return e;var t=new AE.dcnet.pb.GetThreadRequest;return null!=e.threadID&&("string"==typeof e.threadID?OE.base64.decode(e.threadID,t.threadID=OE.newBuffer(OE.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=OE.newBuffer(r.threadID))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?OE.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThreadRequest"},e}(),e.DeleteThreadRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(26).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(34).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteThreadRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.signature=e.bytes();break;case 4:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||OE.isString(e.threadID))?"threadID: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeleteThreadRequest)return e;var t=new AE.dcnet.pb.DeleteThreadRequest;return null!=e.threadID&&("string"==typeof e.threadID?OE.base64.decode(e.threadID,t.threadID=OE.newBuffer(OE.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=OE.newBuffer(r.threadID))),r.blockheight=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?OE.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteThreadRequest"},e}(),e.DeleteThreadReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteThreadReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.DeleteThreadReply?e:new AE.dcnet.pb.DeleteThreadReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteThreadReply"},e}(),e.StroeFileRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.cid=OE.newBuffer([]),e.prototype.filesize=OE.Long?OE.Long.fromBits(0,0,!0):0,e.prototype.blockheight=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(10).bytes(e.cid),null!=e.filesize&&Object.hasOwnProperty.call(e,"filesize")&&t.uint32(16).uint64(e.filesize),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(24).uint32(e.blockheight),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(34).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(42).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.StroeFileRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.cid=e.bytes();break;case 2:n.filesize=e.uint64();break;case 3:n.blockheight=e.uint32();break;case 4:n.signature=e.bytes();break;case 5:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.cid&&e.hasOwnProperty("cid")&&!(e.cid&&"number"==typeof e.cid.length||OE.isString(e.cid))?"cid: buffer expected":null!=e.filesize&&e.hasOwnProperty("filesize")&&!(OE.isInteger(e.filesize)||e.filesize&&OE.isInteger(e.filesize.low)&&OE.isInteger(e.filesize.high))?"filesize: integer|Long expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.StroeFileRequest)return e;var t=new AE.dcnet.pb.StroeFileRequest;return null!=e.cid&&("string"==typeof e.cid?OE.base64.decode(e.cid,t.cid=OE.newBuffer(OE.base64.length(e.cid)),0):e.cid.length>=0&&(t.cid=e.cid)),null!=e.filesize&&(OE.Long?(t.filesize=OE.Long.fromValue(e.filesize)).unsigned=!0:"string"==typeof e.filesize?t.filesize=parseInt(e.filesize,10):"number"==typeof e.filesize?t.filesize=e.filesize:"object"==typeof e.filesize&&(t.filesize=new OE.LongBits(e.filesize.low>>>0,e.filesize.high>>>0).toNumber(!0))),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(t.bytes===String?r.cid="":(r.cid=[],t.bytes!==Array&&(r.cid=OE.newBuffer(r.cid))),OE.Long){var n=new OE.Long(0,0,!0);r.filesize=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.filesize=t.longs===String?"0":0;r.blockheight=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))}return null!=e.cid&&e.hasOwnProperty("cid")&&(r.cid=t.bytes===String?OE.base64.encode(e.cid,0,e.cid.length):t.bytes===Array?Array.prototype.slice.call(e.cid):e.cid),null!=e.filesize&&e.hasOwnProperty("filesize")&&("number"==typeof e.filesize?r.filesize=t.longs===String?String(e.filesize):e.filesize:r.filesize=t.longs===String?OE.Long.prototype.toString.call(e.filesize):t.longs===Number?new OE.LongBits(e.filesize.low>>>0,e.filesize.high>>>0).toNumber(!0):e.filesize),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.StroeFileRequest"},e}(),e.StroeFileReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.status=0,e.prototype.receivesize=OE.Long?OE.Long.fromBits(0,0,!0):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.status&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),null!=e.receivesize&&Object.hasOwnProperty.call(e,"receivesize")&&t.uint32(16).uint64(e.receivesize),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.StroeFileReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.status=e.int32();break;case 2:n.receivesize=e.uint64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.status&&e.hasOwnProperty("status")&&!OE.isInteger(e.status)?"status: integer expected":null!=e.receivesize&&e.hasOwnProperty("receivesize")&&!(OE.isInteger(e.receivesize)||e.receivesize&&OE.isInteger(e.receivesize.low)&&OE.isInteger(e.receivesize.high))?"receivesize: integer|Long expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.StroeFileReply)return e;var t=new AE.dcnet.pb.StroeFileReply;return null!=e.status&&(t.status=0|e.status),null!=e.receivesize&&(OE.Long?(t.receivesize=OE.Long.fromValue(e.receivesize)).unsigned=!0:"string"==typeof e.receivesize?t.receivesize=parseInt(e.receivesize,10):"number"==typeof e.receivesize?t.receivesize=e.receivesize:"object"==typeof e.receivesize&&(t.receivesize=new OE.LongBits(e.receivesize.low>>>0,e.receivesize.high>>>0).toNumber(!0))),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(r.status=0,OE.Long){var n=new OE.Long(0,0,!0);r.receivesize=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.receivesize=t.longs===String?"0":0;return null!=e.status&&e.hasOwnProperty("status")&&(r.status=e.status),null!=e.receivesize&&e.hasOwnProperty("receivesize")&&("number"==typeof e.receivesize?r.receivesize=t.longs===String?String(e.receivesize):e.receivesize:r.receivesize=t.longs===String?OE.Long.prototype.toString.call(e.receivesize):t.longs===Number?new OE.LongBits(e.receivesize.low>>>0,e.receivesize.high>>>0).toNumber(!0):e.receivesize),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.StroeFileReply"},e}(),e.DeleteFileRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.cid=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(10).bytes(e.cid),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(26).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(34).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteFileRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.cid=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.signature=e.bytes();break;case 4:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.cid&&e.hasOwnProperty("cid")&&!(e.cid&&"number"==typeof e.cid.length||OE.isString(e.cid))?"cid: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeleteFileRequest)return e;var t=new AE.dcnet.pb.DeleteFileRequest;return null!=e.cid&&("string"==typeof e.cid?OE.base64.decode(e.cid,t.cid=OE.newBuffer(OE.base64.length(e.cid)),0):e.cid.length>=0&&(t.cid=e.cid)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.cid="":(r.cid=[],t.bytes!==Array&&(r.cid=OE.newBuffer(r.cid))),r.blockheight=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.cid&&e.hasOwnProperty("cid")&&(r.cid=t.bytes===String?OE.base64.encode(e.cid,0,e.cid.length):t.bytes===Array?Array.prototype.slice.call(e.cid):e.cid),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteFileRequest"},e}(),e.DeleteFileReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=!1,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).bool(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteFileReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.bool():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&"boolean"!=typeof e.flag?"flag: boolean expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeleteFileReply)return e;var t=new AE.dcnet.pb.DeleteFileReply;return null!=e.flag&&(t.flag=Boolean(e.flag)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=!1),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteFileReply"},e}(),e.StoreFolderRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.cid=OE.newBuffer([]),e.prototype.foldersize=OE.Long?OE.Long.fromBits(0,0,!0):0,e.prototype.filecount=0,e.prototype.blockheight=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(10).bytes(e.cid),null!=e.foldersize&&Object.hasOwnProperty.call(e,"foldersize")&&t.uint32(16).uint64(e.foldersize),null!=e.filecount&&Object.hasOwnProperty.call(e,"filecount")&&t.uint32(24).uint32(e.filecount),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(32).uint32(e.blockheight),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(42).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(50).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.StoreFolderRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.cid=e.bytes();break;case 2:n.foldersize=e.uint64();break;case 3:n.filecount=e.uint32();break;case 4:n.blockheight=e.uint32();break;case 5:n.signature=e.bytes();break;case 6:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.cid&&e.hasOwnProperty("cid")&&!(e.cid&&"number"==typeof e.cid.length||OE.isString(e.cid))?"cid: buffer expected":null!=e.foldersize&&e.hasOwnProperty("foldersize")&&!(OE.isInteger(e.foldersize)||e.foldersize&&OE.isInteger(e.foldersize.low)&&OE.isInteger(e.foldersize.high))?"foldersize: integer|Long expected":null!=e.filecount&&e.hasOwnProperty("filecount")&&!OE.isInteger(e.filecount)?"filecount: integer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.StoreFolderRequest)return e;var t=new AE.dcnet.pb.StoreFolderRequest;return null!=e.cid&&("string"==typeof e.cid?OE.base64.decode(e.cid,t.cid=OE.newBuffer(OE.base64.length(e.cid)),0):e.cid.length>=0&&(t.cid=e.cid)),null!=e.foldersize&&(OE.Long?(t.foldersize=OE.Long.fromValue(e.foldersize)).unsigned=!0:"string"==typeof e.foldersize?t.foldersize=parseInt(e.foldersize,10):"number"==typeof e.foldersize?t.foldersize=e.foldersize:"object"==typeof e.foldersize&&(t.foldersize=new OE.LongBits(e.foldersize.low>>>0,e.foldersize.high>>>0).toNumber(!0))),null!=e.filecount&&(t.filecount=e.filecount>>>0),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(t.bytes===String?r.cid="":(r.cid=[],t.bytes!==Array&&(r.cid=OE.newBuffer(r.cid))),OE.Long){var n=new OE.Long(0,0,!0);r.foldersize=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.foldersize=t.longs===String?"0":0;r.filecount=0,r.blockheight=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))}return null!=e.cid&&e.hasOwnProperty("cid")&&(r.cid=t.bytes===String?OE.base64.encode(e.cid,0,e.cid.length):t.bytes===Array?Array.prototype.slice.call(e.cid):e.cid),null!=e.foldersize&&e.hasOwnProperty("foldersize")&&("number"==typeof e.foldersize?r.foldersize=t.longs===String?String(e.foldersize):e.foldersize:r.foldersize=t.longs===String?OE.Long.prototype.toString.call(e.foldersize):t.longs===Number?new OE.LongBits(e.foldersize.low>>>0,e.foldersize.high>>>0).toNumber(!0):e.foldersize),null!=e.filecount&&e.hasOwnProperty("filecount")&&(r.filecount=e.filecount),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.StoreFolderRequest"},e}(),e.StoreFolderReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.status=0,e.prototype.receivecount=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.status&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),null!=e.receivecount&&Object.hasOwnProperty.call(e,"receivecount")&&t.uint32(16).uint32(e.receivecount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.StoreFolderReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.status=e.int32();break;case 2:n.receivecount=e.uint32();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.status&&e.hasOwnProperty("status")&&!OE.isInteger(e.status)?"status: integer expected":null!=e.receivecount&&e.hasOwnProperty("receivecount")&&!OE.isInteger(e.receivecount)?"receivecount: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.StoreFolderReply)return e;var t=new AE.dcnet.pb.StoreFolderReply;return null!=e.status&&(t.status=0|e.status),null!=e.receivecount&&(t.receivecount=e.receivecount>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.status=0,r.receivecount=0),null!=e.status&&e.hasOwnProperty("status")&&(r.status=e.status),null!=e.receivecount&&e.hasOwnProperty("receivecount")&&(r.receivecount=e.receivecount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.StoreFolderReply"},e}(),e.AccountDealRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.accountencrypt=OE.newBuffer([]),e.prototype.accounthashencrypt=OE.newBuffer([]),e.prototype.prikeyencrypt2=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.loginkeyrandencrypt=OE.newBuffer([]),e.prototype.peerid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.accountencrypt&&Object.hasOwnProperty.call(e,"accountencrypt")&&t.uint32(10).bytes(e.accountencrypt),null!=e.accounthashencrypt&&Object.hasOwnProperty.call(e,"accounthashencrypt")&&t.uint32(18).bytes(e.accounthashencrypt),null!=e.prikeyencrypt2&&Object.hasOwnProperty.call(e,"prikeyencrypt2")&&t.uint32(26).bytes(e.prikeyencrypt2),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(32).uint32(e.blockheight),null!=e.loginkeyrandencrypt&&Object.hasOwnProperty.call(e,"loginkeyrandencrypt")&&t.uint32(42).bytes(e.loginkeyrandencrypt),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(50).bytes(e.peerid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(58).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(66).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AccountDealRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.accountencrypt=e.bytes();break;case 2:n.accounthashencrypt=e.bytes();break;case 3:n.prikeyencrypt2=e.bytes();break;case 4:n.blockheight=e.uint32();break;case 5:n.loginkeyrandencrypt=e.bytes();break;case 6:n.peerid=e.bytes();break;case 7:n.signature=e.bytes();break;case 8:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.accountencrypt&&e.hasOwnProperty("accountencrypt")&&!(e.accountencrypt&&"number"==typeof e.accountencrypt.length||OE.isString(e.accountencrypt))?"accountencrypt: buffer expected":null!=e.accounthashencrypt&&e.hasOwnProperty("accounthashencrypt")&&!(e.accounthashencrypt&&"number"==typeof e.accounthashencrypt.length||OE.isString(e.accounthashencrypt))?"accounthashencrypt: buffer expected":null!=e.prikeyencrypt2&&e.hasOwnProperty("prikeyencrypt2")&&!(e.prikeyencrypt2&&"number"==typeof e.prikeyencrypt2.length||OE.isString(e.prikeyencrypt2))?"prikeyencrypt2: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.loginkeyrandencrypt&&e.hasOwnProperty("loginkeyrandencrypt")&&!(e.loginkeyrandencrypt&&"number"==typeof e.loginkeyrandencrypt.length||OE.isString(e.loginkeyrandencrypt))?"loginkeyrandencrypt: buffer expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AccountDealRequest)return e;var t=new AE.dcnet.pb.AccountDealRequest;return null!=e.accountencrypt&&("string"==typeof e.accountencrypt?OE.base64.decode(e.accountencrypt,t.accountencrypt=OE.newBuffer(OE.base64.length(e.accountencrypt)),0):e.accountencrypt.length>=0&&(t.accountencrypt=e.accountencrypt)),null!=e.accounthashencrypt&&("string"==typeof e.accounthashencrypt?OE.base64.decode(e.accounthashencrypt,t.accounthashencrypt=OE.newBuffer(OE.base64.length(e.accounthashencrypt)),0):e.accounthashencrypt.length>=0&&(t.accounthashencrypt=e.accounthashencrypt)),null!=e.prikeyencrypt2&&("string"==typeof e.prikeyencrypt2?OE.base64.decode(e.prikeyencrypt2,t.prikeyencrypt2=OE.newBuffer(OE.base64.length(e.prikeyencrypt2)),0):e.prikeyencrypt2.length>=0&&(t.prikeyencrypt2=e.prikeyencrypt2)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.loginkeyrandencrypt&&("string"==typeof e.loginkeyrandencrypt?OE.base64.decode(e.loginkeyrandencrypt,t.loginkeyrandencrypt=OE.newBuffer(OE.base64.length(e.loginkeyrandencrypt)),0):e.loginkeyrandencrypt.length>=0&&(t.loginkeyrandencrypt=e.loginkeyrandencrypt)),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.accountencrypt="":(r.accountencrypt=[],t.bytes!==Array&&(r.accountencrypt=OE.newBuffer(r.accountencrypt))),t.bytes===String?r.accounthashencrypt="":(r.accounthashencrypt=[],t.bytes!==Array&&(r.accounthashencrypt=OE.newBuffer(r.accounthashencrypt))),t.bytes===String?r.prikeyencrypt2="":(r.prikeyencrypt2=[],t.bytes!==Array&&(r.prikeyencrypt2=OE.newBuffer(r.prikeyencrypt2))),r.blockheight=0,t.bytes===String?r.loginkeyrandencrypt="":(r.loginkeyrandencrypt=[],t.bytes!==Array&&(r.loginkeyrandencrypt=OE.newBuffer(r.loginkeyrandencrypt))),t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.accountencrypt&&e.hasOwnProperty("accountencrypt")&&(r.accountencrypt=t.bytes===String?OE.base64.encode(e.accountencrypt,0,e.accountencrypt.length):t.bytes===Array?Array.prototype.slice.call(e.accountencrypt):e.accountencrypt),null!=e.accounthashencrypt&&e.hasOwnProperty("accounthashencrypt")&&(r.accounthashencrypt=t.bytes===String?OE.base64.encode(e.accounthashencrypt,0,e.accounthashencrypt.length):t.bytes===Array?Array.prototype.slice.call(e.accounthashencrypt):e.accounthashencrypt),null!=e.prikeyencrypt2&&e.hasOwnProperty("prikeyencrypt2")&&(r.prikeyencrypt2=t.bytes===String?OE.base64.encode(e.prikeyencrypt2,0,e.prikeyencrypt2.length):t.bytes===Array?Array.prototype.slice.call(e.prikeyencrypt2):e.prikeyencrypt2),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.loginkeyrandencrypt&&e.hasOwnProperty("loginkeyrandencrypt")&&(r.loginkeyrandencrypt=t.bytes===String?OE.base64.encode(e.loginkeyrandencrypt,0,e.loginkeyrandencrypt.length):t.bytes===Array?Array.prototype.slice.call(e.loginkeyrandencrypt):e.loginkeyrandencrypt),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AccountDealRequest"},e}(),e.AccountDealReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AccountDealReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.AccountDealReply?e:new AE.dcnet.pb.AccountDealReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AccountDealReply"},e}(),e.AccountLoginRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.accounthashencrypt=OE.newBuffer([]),e.prototype.pubkeyencrypt=OE.newBuffer([]),e.prototype.loginkeyrandencrypt=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.accounthashencrypt&&Object.hasOwnProperty.call(e,"accounthashencrypt")&&t.uint32(10).bytes(e.accounthashencrypt),null!=e.pubkeyencrypt&&Object.hasOwnProperty.call(e,"pubkeyencrypt")&&t.uint32(18).bytes(e.pubkeyencrypt),null!=e.loginkeyrandencrypt&&Object.hasOwnProperty.call(e,"loginkeyrandencrypt")&&t.uint32(26).bytes(e.loginkeyrandencrypt),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AccountLoginRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.accounthashencrypt=e.bytes();break;case 2:n.pubkeyencrypt=e.bytes();break;case 3:n.loginkeyrandencrypt=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.accounthashencrypt&&e.hasOwnProperty("accounthashencrypt")&&!(e.accounthashencrypt&&"number"==typeof e.accounthashencrypt.length||OE.isString(e.accounthashencrypt))?"accounthashencrypt: buffer expected":null!=e.pubkeyencrypt&&e.hasOwnProperty("pubkeyencrypt")&&!(e.pubkeyencrypt&&"number"==typeof e.pubkeyencrypt.length||OE.isString(e.pubkeyencrypt))?"pubkeyencrypt: buffer expected":null!=e.loginkeyrandencrypt&&e.hasOwnProperty("loginkeyrandencrypt")&&!(e.loginkeyrandencrypt&&"number"==typeof e.loginkeyrandencrypt.length||OE.isString(e.loginkeyrandencrypt))?"loginkeyrandencrypt: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AccountLoginRequest)return e;var t=new AE.dcnet.pb.AccountLoginRequest;return null!=e.accounthashencrypt&&("string"==typeof e.accounthashencrypt?OE.base64.decode(e.accounthashencrypt,t.accounthashencrypt=OE.newBuffer(OE.base64.length(e.accounthashencrypt)),0):e.accounthashencrypt.length>=0&&(t.accounthashencrypt=e.accounthashencrypt)),null!=e.pubkeyencrypt&&("string"==typeof e.pubkeyencrypt?OE.base64.decode(e.pubkeyencrypt,t.pubkeyencrypt=OE.newBuffer(OE.base64.length(e.pubkeyencrypt)),0):e.pubkeyencrypt.length>=0&&(t.pubkeyencrypt=e.pubkeyencrypt)),null!=e.loginkeyrandencrypt&&("string"==typeof e.loginkeyrandencrypt?OE.base64.decode(e.loginkeyrandencrypt,t.loginkeyrandencrypt=OE.newBuffer(OE.base64.length(e.loginkeyrandencrypt)),0):e.loginkeyrandencrypt.length>=0&&(t.loginkeyrandencrypt=e.loginkeyrandencrypt)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.accounthashencrypt="":(r.accounthashencrypt=[],t.bytes!==Array&&(r.accounthashencrypt=OE.newBuffer(r.accounthashencrypt))),t.bytes===String?r.pubkeyencrypt="":(r.pubkeyencrypt=[],t.bytes!==Array&&(r.pubkeyencrypt=OE.newBuffer(r.pubkeyencrypt))),t.bytes===String?r.loginkeyrandencrypt="":(r.loginkeyrandencrypt=[],t.bytes!==Array&&(r.loginkeyrandencrypt=OE.newBuffer(r.loginkeyrandencrypt)))),null!=e.accounthashencrypt&&e.hasOwnProperty("accounthashencrypt")&&(r.accounthashencrypt=t.bytes===String?OE.base64.encode(e.accounthashencrypt,0,e.accounthashencrypt.length):t.bytes===Array?Array.prototype.slice.call(e.accounthashencrypt):e.accounthashencrypt),null!=e.pubkeyencrypt&&e.hasOwnProperty("pubkeyencrypt")&&(r.pubkeyencrypt=t.bytes===String?OE.base64.encode(e.pubkeyencrypt,0,e.pubkeyencrypt.length):t.bytes===Array?Array.prototype.slice.call(e.pubkeyencrypt):e.pubkeyencrypt),null!=e.loginkeyrandencrypt&&e.hasOwnProperty("loginkeyrandencrypt")&&(r.loginkeyrandencrypt=t.bytes===String?OE.base64.encode(e.loginkeyrandencrypt,0,e.loginkeyrandencrypt.length):t.bytes===Array?Array.prototype.slice.call(e.loginkeyrandencrypt):e.loginkeyrandencrypt),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AccountLoginRequest"},e}(),e.AccountLoginReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.prikeyencrypt2=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.prikeyencrypt2&&Object.hasOwnProperty.call(e,"prikeyencrypt2")&&t.uint32(10).bytes(e.prikeyencrypt2),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AccountLoginReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.prikeyencrypt2=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.prikeyencrypt2&&e.hasOwnProperty("prikeyencrypt2")&&!(e.prikeyencrypt2&&"number"==typeof e.prikeyencrypt2.length||OE.isString(e.prikeyencrypt2))?"prikeyencrypt2: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AccountLoginReply)return e;var t=new AE.dcnet.pb.AccountLoginReply;return null!=e.prikeyencrypt2&&("string"==typeof e.prikeyencrypt2?OE.base64.decode(e.prikeyencrypt2,t.prikeyencrypt2=OE.newBuffer(OE.base64.length(e.prikeyencrypt2)),0):e.prikeyencrypt2.length>=0&&(t.prikeyencrypt2=e.prikeyencrypt2)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.prikeyencrypt2="":(r.prikeyencrypt2=[],t.bytes!==Array&&(r.prikeyencrypt2=OE.newBuffer(r.prikeyencrypt2)))),null!=e.prikeyencrypt2&&e.hasOwnProperty("prikeyencrypt2")&&(r.prikeyencrypt2=t.bytes===String?OE.base64.encode(e.prikeyencrypt2,0,e.prikeyencrypt2.length):t.bytes===Array?Array.prototype.slice.call(e.prikeyencrypt2):e.prikeyencrypt2),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AccountLoginReply"},e}(),e.TransferAccountRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.accounthashencrypt=OE.newBuffer([]),e.prototype.recvpubkey=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.peerid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.accounthashencrypt&&Object.hasOwnProperty.call(e,"accounthashencrypt")&&t.uint32(10).bytes(e.accounthashencrypt),null!=e.recvpubkey&&Object.hasOwnProperty.call(e,"recvpubkey")&&t.uint32(18).bytes(e.recvpubkey),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(24).uint32(e.blockheight),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(34).bytes(e.peerid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(42).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.TransferAccountRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.accounthashencrypt=e.bytes();break;case 2:n.recvpubkey=e.bytes();break;case 3:n.blockheight=e.uint32();break;case 4:n.peerid=e.bytes();break;case 5:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.accounthashencrypt&&e.hasOwnProperty("accounthashencrypt")&&!(e.accounthashencrypt&&"number"==typeof e.accounthashencrypt.length||OE.isString(e.accounthashencrypt))?"accounthashencrypt: buffer expected":null!=e.recvpubkey&&e.hasOwnProperty("recvpubkey")&&!(e.recvpubkey&&"number"==typeof e.recvpubkey.length||OE.isString(e.recvpubkey))?"recvpubkey: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.TransferAccountRequest)return e;var t=new AE.dcnet.pb.TransferAccountRequest;return null!=e.accounthashencrypt&&("string"==typeof e.accounthashencrypt?OE.base64.decode(e.accounthashencrypt,t.accounthashencrypt=OE.newBuffer(OE.base64.length(e.accounthashencrypt)),0):e.accounthashencrypt.length>=0&&(t.accounthashencrypt=e.accounthashencrypt)),null!=e.recvpubkey&&("string"==typeof e.recvpubkey?OE.base64.decode(e.recvpubkey,t.recvpubkey=OE.newBuffer(OE.base64.length(e.recvpubkey)),0):e.recvpubkey.length>=0&&(t.recvpubkey=e.recvpubkey)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.accounthashencrypt="":(r.accounthashencrypt=[],t.bytes!==Array&&(r.accounthashencrypt=OE.newBuffer(r.accounthashencrypt))),t.bytes===String?r.recvpubkey="":(r.recvpubkey=[],t.bytes!==Array&&(r.recvpubkey=OE.newBuffer(r.recvpubkey))),r.blockheight=0,t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.accounthashencrypt&&e.hasOwnProperty("accounthashencrypt")&&(r.accounthashencrypt=t.bytes===String?OE.base64.encode(e.accounthashencrypt,0,e.accounthashencrypt.length):t.bytes===Array?Array.prototype.slice.call(e.accounthashencrypt):e.accounthashencrypt),null!=e.recvpubkey&&e.hasOwnProperty("recvpubkey")&&(r.recvpubkey=t.bytes===String?OE.base64.encode(e.recvpubkey,0,e.recvpubkey.length):t.bytes===Array?Array.prototype.slice.call(e.recvpubkey):e.recvpubkey),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.TransferAccountRequest"},e}(),e.TransferAccountReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.TransferAccountReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.TransferAccountReply?e:new AE.dcnet.pb.TransferAccountReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.TransferAccountReply"},e}(),e.SetUserDefaultDBRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dbinfocrypt=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.peerid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.dbinfocrypt&&Object.hasOwnProperty.call(e,"dbinfocrypt")&&t.uint32(10).bytes(e.dbinfocrypt),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(26).bytes(e.peerid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(34).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(42).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetUserDefaultDBRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.dbinfocrypt=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.peerid=e.bytes();break;case 4:n.signature=e.bytes();break;case 5:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.dbinfocrypt&&e.hasOwnProperty("dbinfocrypt")&&!(e.dbinfocrypt&&"number"==typeof e.dbinfocrypt.length||OE.isString(e.dbinfocrypt))?"dbinfocrypt: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SetUserDefaultDBRequest)return e;var t=new AE.dcnet.pb.SetUserDefaultDBRequest;return null!=e.dbinfocrypt&&("string"==typeof e.dbinfocrypt?OE.base64.decode(e.dbinfocrypt,t.dbinfocrypt=OE.newBuffer(OE.base64.length(e.dbinfocrypt)),0):e.dbinfocrypt.length>=0&&(t.dbinfocrypt=e.dbinfocrypt)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.dbinfocrypt="":(r.dbinfocrypt=[],t.bytes!==Array&&(r.dbinfocrypt=OE.newBuffer(r.dbinfocrypt))),r.blockheight=0,t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.dbinfocrypt&&e.hasOwnProperty("dbinfocrypt")&&(r.dbinfocrypt=t.bytes===String?OE.base64.encode(e.dbinfocrypt,0,e.dbinfocrypt.length):t.bytes===Array?Array.prototype.slice.call(e.dbinfocrypt):e.dbinfocrypt),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetUserDefaultDBRequest"},e}(),e.SetUserDefaultDBReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetUserDefaultDBReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.SetUserDefaultDBReply?e:new AE.dcnet.pb.SetUserDefaultDBReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetUserDefaultDBReply"},e}(),e.AddSubPubkeyRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.subpubkey=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.peerid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.subpubkey&&Object.hasOwnProperty.call(e,"subpubkey")&&t.uint32(10).bytes(e.subpubkey),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(26).bytes(e.peerid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(34).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(42).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddSubPubkeyRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.subpubkey=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.peerid=e.bytes();break;case 4:n.signature=e.bytes();break;case 5:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.subpubkey&&e.hasOwnProperty("subpubkey")&&!(e.subpubkey&&"number"==typeof e.subpubkey.length||OE.isString(e.subpubkey))?"subpubkey: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddSubPubkeyRequest)return e;var t=new AE.dcnet.pb.AddSubPubkeyRequest;return null!=e.subpubkey&&("string"==typeof e.subpubkey?OE.base64.decode(e.subpubkey,t.subpubkey=OE.newBuffer(OE.base64.length(e.subpubkey)),0):e.subpubkey.length>=0&&(t.subpubkey=e.subpubkey)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.subpubkey="":(r.subpubkey=[],t.bytes!==Array&&(r.subpubkey=OE.newBuffer(r.subpubkey))),r.blockheight=0,t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.subpubkey&&e.hasOwnProperty("subpubkey")&&(r.subpubkey=t.bytes===String?OE.base64.encode(e.subpubkey,0,e.subpubkey.length):t.bytes===Array?Array.prototype.slice.call(e.subpubkey):e.subpubkey),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddSubPubkeyRequest"},e}(),e.AddSubPubkeyReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddSubPubkeyReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.AddSubPubkeyReply?e:new AE.dcnet.pb.AddSubPubkeyReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddSubPubkeyReply"},e}(),e.DeleteSubPubkeyRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.subpubkey=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.peerid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.subpubkey&&Object.hasOwnProperty.call(e,"subpubkey")&&t.uint32(10).bytes(e.subpubkey),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(26).bytes(e.peerid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(34).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(42).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteSubPubkeyRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.subpubkey=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.peerid=e.bytes();break;case 4:n.signature=e.bytes();break;case 5:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.subpubkey&&e.hasOwnProperty("subpubkey")&&!(e.subpubkey&&"number"==typeof e.subpubkey.length||OE.isString(e.subpubkey))?"subpubkey: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeleteSubPubkeyRequest)return e;var t=new AE.dcnet.pb.DeleteSubPubkeyRequest;return null!=e.subpubkey&&("string"==typeof e.subpubkey?OE.base64.decode(e.subpubkey,t.subpubkey=OE.newBuffer(OE.base64.length(e.subpubkey)),0):e.subpubkey.length>=0&&(t.subpubkey=e.subpubkey)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.subpubkey="":(r.subpubkey=[],t.bytes!==Array&&(r.subpubkey=OE.newBuffer(r.subpubkey))),r.blockheight=0,t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.subpubkey&&e.hasOwnProperty("subpubkey")&&(r.subpubkey=t.bytes===String?OE.base64.encode(e.subpubkey,0,e.subpubkey.length):t.bytes===Array?Array.prototype.slice.call(e.subpubkey):e.subpubkey),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteSubPubkeyRequest"},e}(),e.DeleteSubPubkeyReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteSubPubkeyReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.DeleteSubPubkeyReply?e:new AE.dcnet.pb.DeleteSubPubkeyReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteSubPubkeyReply"},e}(),e.BindAccessPeerToUserRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.blockheight=0,e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(8).uint32(e.blockheight),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(18).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.BindAccessPeerToUserRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.blockheight=e.uint32();break;case 2:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.BindAccessPeerToUserRequest)return e;var t=new AE.dcnet.pb.BindAccessPeerToUserRequest;return null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.blockheight=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.BindAccessPeerToUserRequest"},e}(),e.BindAccessPeerToUserReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.BindAccessPeerToUserReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.BindAccessPeerToUserReply?e:new AE.dcnet.pb.BindAccessPeerToUserReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.BindAccessPeerToUserReply"},e}(),e.ValidTokenRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ValidTokenRequest;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.ValidTokenRequest?e:new AE.dcnet.pb.ValidTokenRequest},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ValidTokenRequest"},e}(),e.ValidTokenReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ValidTokenReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.ValidTokenReply?e:new AE.dcnet.pb.ValidTokenReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ValidTokenReply"},e}(),e.AddLogToThreadRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=OE.newBuffer([]),e.prototype.logID=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.peerid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.logID&&Object.hasOwnProperty.call(e,"logID")&&t.uint32(18).bytes(e.logID),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(24).uint32(e.blockheight),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(34).bytes(e.peerid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(42).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(50).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddLogToThreadRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.logID=e.bytes();break;case 3:n.blockheight=e.uint32();break;case 4:n.peerid=e.bytes();break;case 5:n.signature=e.bytes();break;case 6:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||OE.isString(e.threadID))?"threadID: buffer expected":null!=e.logID&&e.hasOwnProperty("logID")&&!(e.logID&&"number"==typeof e.logID.length||OE.isString(e.logID))?"logID: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddLogToThreadRequest)return e;var t=new AE.dcnet.pb.AddLogToThreadRequest;return null!=e.threadID&&("string"==typeof e.threadID?OE.base64.decode(e.threadID,t.threadID=OE.newBuffer(OE.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.logID&&("string"==typeof e.logID?OE.base64.decode(e.logID,t.logID=OE.newBuffer(OE.base64.length(e.logID)),0):e.logID.length>=0&&(t.logID=e.logID)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=OE.newBuffer(r.threadID))),t.bytes===String?r.logID="":(r.logID=[],t.bytes!==Array&&(r.logID=OE.newBuffer(r.logID))),r.blockheight=0,t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?OE.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.logID&&e.hasOwnProperty("logID")&&(r.logID=t.bytes===String?OE.base64.encode(e.logID,0,e.logID.length):t.bytes===Array?Array.prototype.slice.call(e.logID):e.logID),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddLogToThreadRequest"},e}(),e.AddLogToThreadReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddLogToThreadReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.AddLogToThreadReply?e:new AE.dcnet.pb.AddLogToThreadReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddLogToThreadReply"},e}(),e.AddThreadSpaceRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.space=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.space&&Object.hasOwnProperty.call(e,"space")&&t.uint32(24).uint32(e.space),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(34).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(42).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddThreadSpaceRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.space=e.uint32();break;case 4:n.signature=e.bytes();break;case 5:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||OE.isString(e.threadID))?"threadID: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.space&&e.hasOwnProperty("space")&&!OE.isInteger(e.space)?"space: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddThreadSpaceRequest)return e;var t=new AE.dcnet.pb.AddThreadSpaceRequest;return null!=e.threadID&&("string"==typeof e.threadID?OE.base64.decode(e.threadID,t.threadID=OE.newBuffer(OE.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.space&&(t.space=e.space>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=OE.newBuffer(r.threadID))),r.blockheight=0,r.space=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?OE.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.space&&e.hasOwnProperty("space")&&(r.space=e.space),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddThreadSpaceRequest"},e}(),e.AddThreadSpaceReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddThreadSpaceReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.AddThreadSpaceReply?e:new AE.dcnet.pb.AddThreadSpaceReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddThreadSpaceReply"},e}(),e.GetThreadUsedSpaceRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=OE.newBuffer([]),e.prototype.randnum=OE.Long?OE.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.randnum&&Object.hasOwnProperty.call(e,"randnum")&&t.uint32(16).int64(e.randnum),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThreadUsedSpaceRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.randnum=e.int64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||OE.isString(e.threadID))?"threadID: buffer expected":null!=e.randnum&&e.hasOwnProperty("randnum")&&!(OE.isInteger(e.randnum)||e.randnum&&OE.isInteger(e.randnum.low)&&OE.isInteger(e.randnum.high))?"randnum: integer|Long expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThreadUsedSpaceRequest)return e;var t=new AE.dcnet.pb.GetThreadUsedSpaceRequest;return null!=e.threadID&&("string"==typeof e.threadID?OE.base64.decode(e.threadID,t.threadID=OE.newBuffer(OE.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.randnum&&(OE.Long?(t.randnum=OE.Long.fromValue(e.randnum)).unsigned=!1:"string"==typeof e.randnum?t.randnum=parseInt(e.randnum,10):"number"==typeof e.randnum?t.randnum=e.randnum:"object"==typeof e.randnum&&(t.randnum=new OE.LongBits(e.randnum.low>>>0,e.randnum.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=OE.newBuffer(r.threadID))),OE.Long){var n=new OE.Long(0,0,!1);r.randnum=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.randnum=t.longs===String?"0":0;return null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?OE.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.randnum&&e.hasOwnProperty("randnum")&&("number"==typeof e.randnum?r.randnum=t.longs===String?String(e.randnum):e.randnum:r.randnum=t.longs===String?OE.Long.prototype.toString.call(e.randnum):t.longs===Number?new OE.LongBits(e.randnum.low>>>0,e.randnum.high>>>0).toNumber():e.randnum),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThreadUsedSpaceRequest"},e}(),e.GetThreadUsedSpaceReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.usedsize=OE.Long?OE.Long.fromBits(0,0,!0):0,e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.usedsize&&Object.hasOwnProperty.call(e,"usedsize")&&t.uint32(8).uint64(e.usedsize),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(18).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThreadUsedSpaceReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.usedsize=e.uint64();break;case 2:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.usedsize&&e.hasOwnProperty("usedsize")&&!(OE.isInteger(e.usedsize)||e.usedsize&&OE.isInteger(e.usedsize.low)&&OE.isInteger(e.usedsize.high))?"usedsize: integer|Long expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThreadUsedSpaceReply)return e;var t=new AE.dcnet.pb.GetThreadUsedSpaceReply;return null!=e.usedsize&&(OE.Long?(t.usedsize=OE.Long.fromValue(e.usedsize)).unsigned=!0:"string"==typeof e.usedsize?t.usedsize=parseInt(e.usedsize,10):"number"==typeof e.usedsize?t.usedsize=e.usedsize:"object"==typeof e.usedsize&&(t.usedsize=new OE.LongBits(e.usedsize.low>>>0,e.usedsize.high>>>0).toNumber(!0))),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(OE.Long){var n=new OE.Long(0,0,!0);r.usedsize=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.usedsize=t.longs===String?"0":0;t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))}return null!=e.usedsize&&e.hasOwnProperty("usedsize")&&("number"==typeof e.usedsize?r.usedsize=t.longs===String?String(e.usedsize):e.usedsize:r.usedsize=t.longs===String?OE.Long.prototype.toString.call(e.usedsize):t.longs===Number?new OE.LongBits(e.usedsize.low>>>0,e.usedsize.high>>>0).toNumber(!0):e.usedsize),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThreadUsedSpaceReply"},e}(),e.TeeReportVerifyRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.teereport=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.teereport&&Object.hasOwnProperty.call(e,"teereport")&&t.uint32(10).bytes(e.teereport),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.TeeReportVerifyRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.teereport=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.teereport&&e.hasOwnProperty("teereport")&&!(e.teereport&&"number"==typeof e.teereport.length||OE.isString(e.teereport))?"teereport: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.TeeReportVerifyRequest)return e;var t=new AE.dcnet.pb.TeeReportVerifyRequest;return null!=e.teereport&&("string"==typeof e.teereport?OE.base64.decode(e.teereport,t.teereport=OE.newBuffer(OE.base64.length(e.teereport)),0):e.teereport.length>=0&&(t.teereport=e.teereport)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.teereport="":(r.teereport=[],t.bytes!==Array&&(r.teereport=OE.newBuffer(r.teereport)))),null!=e.teereport&&e.hasOwnProperty("teereport")&&(r.teereport=t.bytes===String?OE.base64.encode(e.teereport,0,e.teereport.length):t.bytes===Array?Array.prototype.slice.call(e.teereport):e.teereport),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.TeeReportVerifyRequest"},e}(),e.TeeReportVerifyReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.report=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.report&&Object.hasOwnProperty.call(e,"report")&&t.uint32(10).bytes(e.report),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(18).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.TeeReportVerifyReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.report=e.bytes();break;case 2:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.report&&e.hasOwnProperty("report")&&!(e.report&&"number"==typeof e.report.length||OE.isString(e.report))?"report: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.TeeReportVerifyReply)return e;var t=new AE.dcnet.pb.TeeReportVerifyReply;return null!=e.report&&("string"==typeof e.report?OE.base64.decode(e.report,t.report=OE.newBuffer(OE.base64.length(e.report)),0):e.report.length>=0&&(t.report=e.report)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.report="":(r.report=[],t.bytes!==Array&&(r.report=OE.newBuffer(r.report))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.report&&e.hasOwnProperty("report")&&(r.report=t.bytes===String?OE.base64.encode(e.report,0,e.report.length):t.bytes===Array?Array.prototype.slice.call(e.report):e.report),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.TeeReportVerifyReply"},e}(),e.SendMsgToUserBoxRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.msg=null,e.prototype.AuthSignature=OE.newBuffer([]),e.prototype.PeerId=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.msg&&Object.hasOwnProperty.call(e,"msg")&&AE.dcnet.pb.UserMsg.encode(e.msg,t.uint32(10).fork()).ldelim(),null!=e.AuthSignature&&Object.hasOwnProperty.call(e,"AuthSignature")&&t.uint32(18).bytes(e.AuthSignature),null!=e.PeerId&&Object.hasOwnProperty.call(e,"PeerId")&&t.uint32(26).bytes(e.PeerId),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SendMsgToUserBoxRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.msg=AE.dcnet.pb.UserMsg.decode(e,e.uint32());break;case 2:n.AuthSignature=e.bytes();break;case 3:n.PeerId=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.msg&&e.hasOwnProperty("msg")){var t=AE.dcnet.pb.UserMsg.verify(e.msg);if(t)return"msg."+t}return null!=e.AuthSignature&&e.hasOwnProperty("AuthSignature")&&!(e.AuthSignature&&"number"==typeof e.AuthSignature.length||OE.isString(e.AuthSignature))?"AuthSignature: buffer expected":null!=e.PeerId&&e.hasOwnProperty("PeerId")&&!(e.PeerId&&"number"==typeof e.PeerId.length||OE.isString(e.PeerId))?"PeerId: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SendMsgToUserBoxRequest)return e;var t=new AE.dcnet.pb.SendMsgToUserBoxRequest;if(null!=e.msg){if("object"!=typeof e.msg)throw TypeError(".dcnet.pb.SendMsgToUserBoxRequest.msg: object expected");t.msg=AE.dcnet.pb.UserMsg.fromObject(e.msg)}return null!=e.AuthSignature&&("string"==typeof e.AuthSignature?OE.base64.decode(e.AuthSignature,t.AuthSignature=OE.newBuffer(OE.base64.length(e.AuthSignature)),0):e.AuthSignature.length>=0&&(t.AuthSignature=e.AuthSignature)),null!=e.PeerId&&("string"==typeof e.PeerId?OE.base64.decode(e.PeerId,t.PeerId=OE.newBuffer(OE.base64.length(e.PeerId)),0):e.PeerId.length>=0&&(t.PeerId=e.PeerId)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.msg=null,t.bytes===String?r.AuthSignature="":(r.AuthSignature=[],t.bytes!==Array&&(r.AuthSignature=OE.newBuffer(r.AuthSignature))),t.bytes===String?r.PeerId="":(r.PeerId=[],t.bytes!==Array&&(r.PeerId=OE.newBuffer(r.PeerId)))),null!=e.msg&&e.hasOwnProperty("msg")&&(r.msg=AE.dcnet.pb.UserMsg.toObject(e.msg,t)),null!=e.AuthSignature&&e.hasOwnProperty("AuthSignature")&&(r.AuthSignature=t.bytes===String?OE.base64.encode(e.AuthSignature,0,e.AuthSignature.length):t.bytes===Array?Array.prototype.slice.call(e.AuthSignature):e.AuthSignature),null!=e.PeerId&&e.hasOwnProperty("PeerId")&&(r.PeerId=t.bytes===String?OE.base64.encode(e.PeerId,0,e.PeerId.length):t.bytes===Array?Array.prototype.slice.call(e.PeerId):e.PeerId),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SendMsgToUserBoxRequest"},e}(),e.SendMsgToUserBoxReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SendMsgToUserBoxReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SendMsgToUserBoxReply)return e;var t=new AE.dcnet.pb.SendMsgToUserBoxReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SendMsgToUserBoxReply"},e}(),e.GetToUserBoxAuthRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.msgSignature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.msgSignature&&Object.hasOwnProperty.call(e,"msgSignature")&&t.uint32(10).bytes(e.msgSignature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetToUserBoxAuthRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.msgSignature=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.msgSignature&&e.hasOwnProperty("msgSignature")&&!(e.msgSignature&&"number"==typeof e.msgSignature.length||OE.isString(e.msgSignature))?"msgSignature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetToUserBoxAuthRequest)return e;var t=new AE.dcnet.pb.GetToUserBoxAuthRequest;return null!=e.msgSignature&&("string"==typeof e.msgSignature?OE.base64.decode(e.msgSignature,t.msgSignature=OE.newBuffer(OE.base64.length(e.msgSignature)),0):e.msgSignature.length>=0&&(t.msgSignature=e.msgSignature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.msgSignature="":(r.msgSignature=[],t.bytes!==Array&&(r.msgSignature=OE.newBuffer(r.msgSignature)))),null!=e.msgSignature&&e.hasOwnProperty("msgSignature")&&(r.msgSignature=t.bytes===String?OE.base64.encode(e.msgSignature,0,e.msgSignature.length):t.bytes===Array?Array.prototype.slice.call(e.msgSignature):e.msgSignature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetToUserBoxAuthRequest"},e}(),e.GetToUserBoxAuthReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(10).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetToUserBoxAuthReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.signature=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetToUserBoxAuthReply)return e;var t=new AE.dcnet.pb.GetToUserBoxAuthReply;return null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetToUserBoxAuthReply"},e}(),e.GetMaxKeyFromUserBoxRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.appId=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(10).bytes(e.appId),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetMaxKeyFromUserBoxRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.appId=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetMaxKeyFromUserBoxRequest)return e;var t=new AE.dcnet.pb.GetMaxKeyFromUserBoxRequest;return null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId)))),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetMaxKeyFromUserBoxRequest"},e}(),e.GetMaxKeyFromUserBoxReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.maxkey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.maxkey&&Object.hasOwnProperty.call(e,"maxkey")&&t.uint32(10).bytes(e.maxkey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetMaxKeyFromUserBoxReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.maxkey=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.maxkey&&e.hasOwnProperty("maxkey")&&!(e.maxkey&&"number"==typeof e.maxkey.length||OE.isString(e.maxkey))?"maxkey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetMaxKeyFromUserBoxReply)return e;var t=new AE.dcnet.pb.GetMaxKeyFromUserBoxReply;return null!=e.maxkey&&("string"==typeof e.maxkey?OE.base64.decode(e.maxkey,t.maxkey=OE.newBuffer(OE.base64.length(e.maxkey)),0):e.maxkey.length>=0&&(t.maxkey=e.maxkey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.maxkey="":(r.maxkey=[],t.bytes!==Array&&(r.maxkey=OE.newBuffer(r.maxkey)))),null!=e.maxkey&&e.hasOwnProperty("maxkey")&&(r.maxkey=t.bytes===String?OE.base64.encode(e.maxkey,0,e.maxkey.length):t.bytes===Array?Array.prototype.slice.call(e.maxkey):e.maxkey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetMaxKeyFromUserBoxReply"},e}(),e.GetMsgFromUserBoxRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.appId=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.seekKey=OE.newBuffer([]),e.prototype.limit=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(10).bytes(e.appId),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.seekKey&&Object.hasOwnProperty.call(e,"seekKey")&&t.uint32(26).bytes(e.seekKey),null!=e.limit&&Object.hasOwnProperty.call(e,"limit")&&t.uint32(32).uint32(e.limit),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetMsgFromUserBoxRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.appId=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.seekKey=e.bytes();break;case 4:n.limit=e.uint32();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.seekKey&&e.hasOwnProperty("seekKey")&&!(e.seekKey&&"number"==typeof e.seekKey.length||OE.isString(e.seekKey))?"seekKey: buffer expected":null!=e.limit&&e.hasOwnProperty("limit")&&!OE.isInteger(e.limit)?"limit: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetMsgFromUserBoxRequest)return e;var t=new AE.dcnet.pb.GetMsgFromUserBoxRequest;return null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.seekKey&&("string"==typeof e.seekKey?OE.base64.decode(e.seekKey,t.seekKey=OE.newBuffer(OE.base64.length(e.seekKey)),0):e.seekKey.length>=0&&(t.seekKey=e.seekKey)),null!=e.limit&&(t.limit=e.limit>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),r.blockheight=0,t.bytes===String?r.seekKey="":(r.seekKey=[],t.bytes!==Array&&(r.seekKey=OE.newBuffer(r.seekKey))),r.limit=0),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.seekKey&&e.hasOwnProperty("seekKey")&&(r.seekKey=t.bytes===String?OE.base64.encode(e.seekKey,0,e.seekKey.length):t.bytes===Array?Array.prototype.slice.call(e.seekKey):e.seekKey),null!=e.limit&&e.hasOwnProperty("limit")&&(r.limit=e.limit),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetMsgFromUserBoxRequest"},e}(),e.GetMsgFromUserBoxReply=function(){function e(e){if(this.msgs=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.msgs=OE.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=SE.create()),null!=e.msgs&&e.msgs.length)for(var r=0;r<e.msgs.length;++r)AE.dcnet.pb.UserMsg.encode(e.msgs[r],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetMsgFromUserBoxReply;e.pos<r;){var o=e.uint32();o>>>3==1?(n.msgs&&n.msgs.length||(n.msgs=[]),n.msgs.push(AE.dcnet.pb.UserMsg.decode(e,e.uint32()))):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.msgs&&e.hasOwnProperty("msgs")){if(!Array.isArray(e.msgs))return"msgs: array expected";for(var t=0;t<e.msgs.length;++t){var r=AE.dcnet.pb.UserMsg.verify(e.msgs[t]);if(r)return"msgs."+r}}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetMsgFromUserBoxReply)return e;var t=new AE.dcnet.pb.GetMsgFromUserBoxReply;if(e.msgs){if(!Array.isArray(e.msgs))throw TypeError(".dcnet.pb.GetMsgFromUserBoxReply.msgs: array expected");t.msgs=[];for(var r=0;r<e.msgs.length;++r){if("object"!=typeof e.msgs[r])throw TypeError(".dcnet.pb.GetMsgFromUserBoxReply.msgs: object expected");t.msgs[r]=AE.dcnet.pb.UserMsg.fromObject(e.msgs[r])}}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.msgs=[]),e.msgs&&e.msgs.length){r.msgs=[];for(var n=0;n<e.msgs.length;++n)r.msgs[n]=AE.dcnet.pb.UserMsg.toObject(e.msgs[n],t)}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetMsgFromUserBoxReply"},e}(),e.UserMsg=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.messageId=OE.newBuffer([]),e.prototype.senderPubkey=OE.newBuffer([]),e.prototype.receiverPubkey=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.encryptMsg=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.messageId&&Object.hasOwnProperty.call(e,"messageId")&&t.uint32(10).bytes(e.messageId),null!=e.senderPubkey&&Object.hasOwnProperty.call(e,"senderPubkey")&&t.uint32(18).bytes(e.senderPubkey),null!=e.receiverPubkey&&Object.hasOwnProperty.call(e,"receiverPubkey")&&t.uint32(26).bytes(e.receiverPubkey),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(34).bytes(e.appId),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(40).uint32(e.blockheight),null!=e.encryptMsg&&Object.hasOwnProperty.call(e,"encryptMsg")&&t.uint32(50).bytes(e.encryptMsg),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(58).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.UserMsg;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.messageId=e.bytes();break;case 2:n.senderPubkey=e.bytes();break;case 3:n.receiverPubkey=e.bytes();break;case 4:n.appId=e.bytes();break;case 5:n.blockheight=e.uint32();break;case 6:n.encryptMsg=e.bytes();break;case 7:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.messageId&&e.hasOwnProperty("messageId")&&!(e.messageId&&"number"==typeof e.messageId.length||OE.isString(e.messageId))?"messageId: buffer expected":null!=e.senderPubkey&&e.hasOwnProperty("senderPubkey")&&!(e.senderPubkey&&"number"==typeof e.senderPubkey.length||OE.isString(e.senderPubkey))?"senderPubkey: buffer expected":null!=e.receiverPubkey&&e.hasOwnProperty("receiverPubkey")&&!(e.receiverPubkey&&"number"==typeof e.receiverPubkey.length||OE.isString(e.receiverPubkey))?"receiverPubkey: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.encryptMsg&&e.hasOwnProperty("encryptMsg")&&!(e.encryptMsg&&"number"==typeof e.encryptMsg.length||OE.isString(e.encryptMsg))?"encryptMsg: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.UserMsg)return e;var t=new AE.dcnet.pb.UserMsg;return null!=e.messageId&&("string"==typeof e.messageId?OE.base64.decode(e.messageId,t.messageId=OE.newBuffer(OE.base64.length(e.messageId)),0):e.messageId.length>=0&&(t.messageId=e.messageId)),null!=e.senderPubkey&&("string"==typeof e.senderPubkey?OE.base64.decode(e.senderPubkey,t.senderPubkey=OE.newBuffer(OE.base64.length(e.senderPubkey)),0):e.senderPubkey.length>=0&&(t.senderPubkey=e.senderPubkey)),null!=e.receiverPubkey&&("string"==typeof e.receiverPubkey?OE.base64.decode(e.receiverPubkey,t.receiverPubkey=OE.newBuffer(OE.base64.length(e.receiverPubkey)),0):e.receiverPubkey.length>=0&&(t.receiverPubkey=e.receiverPubkey)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.encryptMsg&&("string"==typeof e.encryptMsg?OE.base64.decode(e.encryptMsg,t.encryptMsg=OE.newBuffer(OE.base64.length(e.encryptMsg)),0):e.encryptMsg.length>=0&&(t.encryptMsg=e.encryptMsg)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.messageId="":(r.messageId=[],t.bytes!==Array&&(r.messageId=OE.newBuffer(r.messageId))),t.bytes===String?r.senderPubkey="":(r.senderPubkey=[],t.bytes!==Array&&(r.senderPubkey=OE.newBuffer(r.senderPubkey))),t.bytes===String?r.receiverPubkey="":(r.receiverPubkey=[],t.bytes!==Array&&(r.receiverPubkey=OE.newBuffer(r.receiverPubkey))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),r.blockheight=0,t.bytes===String?r.encryptMsg="":(r.encryptMsg=[],t.bytes!==Array&&(r.encryptMsg=OE.newBuffer(r.encryptMsg))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.messageId&&e.hasOwnProperty("messageId")&&(r.messageId=t.bytes===String?OE.base64.encode(e.messageId,0,e.messageId.length):t.bytes===Array?Array.prototype.slice.call(e.messageId):e.messageId),null!=e.senderPubkey&&e.hasOwnProperty("senderPubkey")&&(r.senderPubkey=t.bytes===String?OE.base64.encode(e.senderPubkey,0,e.senderPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.senderPubkey):e.senderPubkey),null!=e.receiverPubkey&&e.hasOwnProperty("receiverPubkey")&&(r.receiverPubkey=t.bytes===String?OE.base64.encode(e.receiverPubkey,0,e.receiverPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.receiverPubkey):e.receiverPubkey),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.encryptMsg&&e.hasOwnProperty("encryptMsg")&&(r.encryptMsg=t.bytes===String?OE.base64.encode(e.encryptMsg,0,e.encryptMsg.length):t.bytes===Array?Array.prototype.slice.call(e.encryptMsg):e.encryptMsg),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.UserMsg"},e}(),e.ReportSpamMsgRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.msg=null,e.prototype.blockheight=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.msg&&Object.hasOwnProperty.call(e,"msg")&&AE.dcnet.pb.UserMsg.encode(e.msg,t.uint32(10).fork()).ldelim(),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(26).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(34).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ReportSpamMsgRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.msg=AE.dcnet.pb.UserMsg.decode(e,e.uint32());break;case 2:n.blockheight=e.uint32();break;case 3:n.signature=e.bytes();break;case 4:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.msg&&e.hasOwnProperty("msg")){var t=AE.dcnet.pb.UserMsg.verify(e.msg);if(t)return"msg."+t}return null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ReportSpamMsgRequest)return e;var t=new AE.dcnet.pb.ReportSpamMsgRequest;if(null!=e.msg){if("object"!=typeof e.msg)throw TypeError(".dcnet.pb.ReportSpamMsgRequest.msg: object expected");t.msg=AE.dcnet.pb.UserMsg.fromObject(e.msg)}return null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.msg=null,r.blockheight=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.msg&&e.hasOwnProperty("msg")&&(r.msg=AE.dcnet.pb.UserMsg.toObject(e.msg,t)),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ReportSpamMsgRequest"},e}(),e.ReportSpamMsgReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ReportSpamMsgReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.ReportSpamMsgReply?e:new AE.dcnet.pb.ReportSpamMsgReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ReportSpamMsgReply"},e}(),e.GetUserClientPeersRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserClientPeersRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.userPubkey=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserClientPeersRequest)return e;var t=new AE.dcnet.pb.GetUserClientPeersRequest;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey)))),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserClientPeersRequest"},e}(),e.GetUserClientPeersReply=function(){function e(e){if(this.peers=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.peers=OE.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=SE.create()),null!=e.peers&&e.peers.length)for(var r=0;r<e.peers.length;++r)t.uint32(10).string(e.peers[r]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserClientPeersReply;e.pos<r;){var o=e.uint32();o>>>3==1?(n.peers&&n.peers.length||(n.peers=[]),n.peers.push(e.string())):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.peers&&e.hasOwnProperty("peers")){if(!Array.isArray(e.peers))return"peers: array expected";for(var t=0;t<e.peers.length;++t)if(!OE.isString(e.peers[t]))return"peers: string[] expected"}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserClientPeersReply)return e;var t=new AE.dcnet.pb.GetUserClientPeersReply;if(e.peers){if(!Array.isArray(e.peers))throw TypeError(".dcnet.pb.GetUserClientPeersReply.peers: array expected");t.peers=[];for(var r=0;r<e.peers.length;++r)t.peers[r]=String(e.peers[r])}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.peers=[]),e.peers&&e.peers.length){r.peers=[];for(var n=0;n<e.peers.length;++n)r.peers[n]=e.peers[n]}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserClientPeersReply"},e}(),e.AddThemeObjRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.commentSpace=0,e.prototype.allowSpace=0,e.prototype.userPubkey=OE.newBuffer([]),e.prototype.openFlag=0,e.prototype.signature=OE.newBuffer([]),e.prototype.CCount=0,e.prototype.UpCount=0,e.prototype.DownCount=0,e.prototype.TCount=0,e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(24).uint32(e.blockheight),null!=e.commentSpace&&Object.hasOwnProperty.call(e,"commentSpace")&&t.uint32(32).uint32(e.commentSpace),null!=e.allowSpace&&Object.hasOwnProperty.call(e,"allowSpace")&&t.uint32(40).uint32(e.allowSpace),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(50).bytes(e.userPubkey),null!=e.openFlag&&Object.hasOwnProperty.call(e,"openFlag")&&t.uint32(56).uint32(e.openFlag),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(66).bytes(e.signature),null!=e.CCount&&Object.hasOwnProperty.call(e,"CCount")&&t.uint32(72).uint32(e.CCount),null!=e.UpCount&&Object.hasOwnProperty.call(e,"UpCount")&&t.uint32(80).uint32(e.UpCount),null!=e.DownCount&&Object.hasOwnProperty.call(e,"DownCount")&&t.uint32(88).uint32(e.DownCount),null!=e.TCount&&Object.hasOwnProperty.call(e,"TCount")&&t.uint32(96).uint32(e.TCount),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(106).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddThemeObjRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.blockheight=e.uint32();break;case 4:n.commentSpace=e.uint32();break;case 5:n.allowSpace=e.uint32();break;case 6:n.userPubkey=e.bytes();break;case 7:n.openFlag=e.uint32();break;case 8:n.signature=e.bytes();break;case 9:n.CCount=e.uint32();break;case 10:n.UpCount=e.uint32();break;case 11:n.DownCount=e.uint32();break;case 12:n.TCount=e.uint32();break;case 13:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.commentSpace&&e.hasOwnProperty("commentSpace")&&!OE.isInteger(e.commentSpace)?"commentSpace: integer expected":null!=e.allowSpace&&e.hasOwnProperty("allowSpace")&&!OE.isInteger(e.allowSpace)?"allowSpace: integer expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.openFlag&&e.hasOwnProperty("openFlag")&&!OE.isInteger(e.openFlag)?"openFlag: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.CCount&&e.hasOwnProperty("CCount")&&!OE.isInteger(e.CCount)?"CCount: integer expected":null!=e.UpCount&&e.hasOwnProperty("UpCount")&&!OE.isInteger(e.UpCount)?"UpCount: integer expected":null!=e.DownCount&&e.hasOwnProperty("DownCount")&&!OE.isInteger(e.DownCount)?"DownCount: integer expected":null!=e.TCount&&e.hasOwnProperty("TCount")&&!OE.isInteger(e.TCount)?"TCount: integer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddThemeObjRequest)return e;var t=new AE.dcnet.pb.AddThemeObjRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.commentSpace&&(t.commentSpace=e.commentSpace>>>0),null!=e.allowSpace&&(t.allowSpace=e.allowSpace>>>0),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.openFlag&&(t.openFlag=e.openFlag>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.CCount&&(t.CCount=e.CCount>>>0),null!=e.UpCount&&(t.UpCount=e.UpCount>>>0),null!=e.DownCount&&(t.DownCount=e.DownCount>>>0),null!=e.TCount&&(t.TCount=e.TCount>>>0),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),r.blockheight=0,r.commentSpace=0,r.allowSpace=0,t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),r.openFlag=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),r.CCount=0,r.UpCount=0,r.DownCount=0,r.TCount=0,t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.commentSpace&&e.hasOwnProperty("commentSpace")&&(r.commentSpace=e.commentSpace),null!=e.allowSpace&&e.hasOwnProperty("allowSpace")&&(r.allowSpace=e.allowSpace),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.openFlag&&e.hasOwnProperty("openFlag")&&(r.openFlag=e.openFlag),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.CCount&&e.hasOwnProperty("CCount")&&(r.CCount=e.CCount),null!=e.UpCount&&e.hasOwnProperty("UpCount")&&(r.UpCount=e.UpCount),null!=e.DownCount&&e.hasOwnProperty("DownCount")&&(r.DownCount=e.DownCount),null!=e.TCount&&e.hasOwnProperty("TCount")&&(r.TCount=e.TCount),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddThemeObjRequest"},e}(),e.AddThemeObjReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddThemeObjReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddThemeObjReply)return e;var t=new AE.dcnet.pb.AddThemeObjReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddThemeObjReply"},e}(),e.AddThemeSpaceRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.addspace=0,e.prototype.userPubkey=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(24).uint32(e.blockheight),null!=e.addspace&&Object.hasOwnProperty.call(e,"addspace")&&t.uint32(32).uint32(e.addspace),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(42).bytes(e.userPubkey),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(50).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(58).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddThemeSpaceRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.blockheight=e.uint32();break;case 4:n.addspace=e.uint32();break;case 5:n.userPubkey=e.bytes();break;case 6:n.signature=e.bytes();break;case 7:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.addspace&&e.hasOwnProperty("addspace")&&!OE.isInteger(e.addspace)?"addspace: integer expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddThemeSpaceRequest)return e;var t=new AE.dcnet.pb.AddThemeSpaceRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.addspace&&(t.addspace=e.addspace>>>0),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),r.blockheight=0,r.addspace=0,t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.addspace&&e.hasOwnProperty("addspace")&&(r.addspace=e.addspace),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddThemeSpaceRequest"},e}(),e.AddThemeSpaceReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddThemeSpaceReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddThemeSpaceReply)return e;var t=new AE.dcnet.pb.AddThemeSpaceReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddThemeSpaceReply"},e}(),e.SetCacheKeyRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.expire=0,e.prototype.blockheight=0,e.prototype.value=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.expire&&Object.hasOwnProperty.call(e,"expire")&&t.uint32(8).uint32(e.expire),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.value&&Object.hasOwnProperty.call(e,"value")&&t.uint32(26).bytes(e.value),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(34).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetCacheKeyRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.expire=e.uint32();break;case 2:n.blockheight=e.uint32();break;case 3:n.value=e.bytes();break;case 4:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.expire&&e.hasOwnProperty("expire")&&!OE.isInteger(e.expire)?"expire: integer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.value&&e.hasOwnProperty("value")&&!(e.value&&"number"==typeof e.value.length||OE.isString(e.value))?"value: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SetCacheKeyRequest)return e;var t=new AE.dcnet.pb.SetCacheKeyRequest;return null!=e.expire&&(t.expire=e.expire>>>0),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.value&&("string"==typeof e.value?OE.base64.decode(e.value,t.value=OE.newBuffer(OE.base64.length(e.value)),0):e.value.length>=0&&(t.value=e.value)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.expire=0,r.blockheight=0,t.bytes===String?r.value="":(r.value=[],t.bytes!==Array&&(r.value=OE.newBuffer(r.value))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.expire&&e.hasOwnProperty("expire")&&(r.expire=e.expire),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.value&&e.hasOwnProperty("value")&&(r.value=t.bytes===String?OE.base64.encode(e.value,0,e.value.length):t.bytes===Array?Array.prototype.slice.call(e.value):e.value),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetCacheKeyRequest"},e}(),e.SetCacheKeyReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.cacheKey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.cacheKey&&Object.hasOwnProperty.call(e,"cacheKey")&&t.uint32(18).bytes(e.cacheKey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetCacheKeyReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.cacheKey=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.cacheKey&&e.hasOwnProperty("cacheKey")&&!(e.cacheKey&&"number"==typeof e.cacheKey.length||OE.isString(e.cacheKey))?"cacheKey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SetCacheKeyReply)return e;var t=new AE.dcnet.pb.SetCacheKeyReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.cacheKey&&("string"==typeof e.cacheKey?OE.base64.decode(e.cacheKey,t.cacheKey=OE.newBuffer(OE.base64.length(e.cacheKey)),0):e.cacheKey.length>=0&&(t.cacheKey=e.cacheKey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.cacheKey="":(r.cacheKey=[],t.bytes!==Array&&(r.cacheKey=OE.newBuffer(r.cacheKey)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.cacheKey&&e.hasOwnProperty("cacheKey")&&(r.cacheKey=t.bytes===String?OE.base64.encode(e.cacheKey,0,e.cacheKey.length):t.bytes===Array?Array.prototype.slice.call(e.cacheKey):e.cacheKey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetCacheKeyReply"},e}(),e.GetCacheValueRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.key=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.key&&Object.hasOwnProperty.call(e,"key")&&t.uint32(10).bytes(e.key),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetCacheValueRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.key=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.key&&e.hasOwnProperty("key")&&!(e.key&&"number"==typeof e.key.length||OE.isString(e.key))?"key: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetCacheValueRequest)return e;var t=new AE.dcnet.pb.GetCacheValueRequest;return null!=e.key&&("string"==typeof e.key?OE.base64.decode(e.key,t.key=OE.newBuffer(OE.base64.length(e.key)),0):e.key.length>=0&&(t.key=e.key)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.key="":(r.key=[],t.bytes!==Array&&(r.key=OE.newBuffer(r.key)))),null!=e.key&&e.hasOwnProperty("key")&&(r.key=t.bytes===String?OE.base64.encode(e.key,0,e.key.length):t.bytes===Array?Array.prototype.slice.call(e.key):e.key),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetCacheValueRequest"},e}(),e.GetCacheValueReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.value=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.value&&Object.hasOwnProperty.call(e,"value")&&t.uint32(10).bytes(e.value),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetCacheValueReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.value=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&!(e.value&&"number"==typeof e.value.length||OE.isString(e.value))?"value: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetCacheValueReply)return e;var t=new AE.dcnet.pb.GetCacheValueReply;return null!=e.value&&("string"==typeof e.value?OE.base64.decode(e.value,t.value=OE.newBuffer(OE.base64.length(e.value)),0):e.value.length>=0&&(t.value=e.value)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.value="":(r.value=[],t.bytes!==Array&&(r.value=OE.newBuffer(r.value)))),null!=e.value&&e.hasOwnProperty("value")&&(r.value=t.bytes===String?OE.base64.encode(e.value,0,e.value.length):t.bytes===Array?Array.prototype.slice.call(e.value):e.value),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetCacheValueReply"},e}(),e.GetThemeSpaceRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.userPubkey=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(24).uint32(e.blockheight),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(34).bytes(e.userPubkey),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(42).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(50).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThemeSpaceRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.blockheight=e.uint32();break;case 4:n.userPubkey=e.bytes();break;case 5:n.signature=e.bytes();break;case 6:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThemeSpaceRequest)return e;var t=new AE.dcnet.pb.GetThemeSpaceRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),r.blockheight=0,t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThemeSpaceRequest"},e}(),e.GetThemeSpaceReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.space=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.space&&Object.hasOwnProperty.call(e,"space")&&t.uint32(8).uint32(e.space),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThemeSpaceReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.space=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.space&&e.hasOwnProperty("space")&&!OE.isInteger(e.space)?"space: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThemeSpaceReply)return e;var t=new AE.dcnet.pb.GetThemeSpaceReply;return null!=e.space&&(t.space=e.space>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.space=0),null!=e.space&&e.hasOwnProperty("space")&&(r.space=e.space),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThemeSpaceReply"},e}(),e.DeleteThemeObjRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.userPubkey=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(24).uint32(e.blockheight),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(34).bytes(e.userPubkey),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(42).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(50).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteThemeObjRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.blockheight=e.uint32();break;case 4:n.userPubkey=e.bytes();break;case 5:n.signature=e.bytes();break;case 6:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeleteThemeObjRequest)return e;var t=new AE.dcnet.pb.DeleteThemeObjRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),r.blockheight=0,t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteThemeObjRequest"},e}(),e.DeleteThemeObjReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteThemeObjReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeleteThemeObjReply)return e;var t=new AE.dcnet.pb.DeleteThemeObjReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteThemeObjReply"},e}(),e.PublishCommentToThemeRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.userPubkey=OE.newBuffer([]),e.prototype.commentCid=OE.newBuffer([]),e.prototype.comment=OE.newBuffer([]),e.prototype.commentSize=0,e.prototype.status=0,e.prototype.refercommentkey=OE.newBuffer([]),e.prototype.CCount=0,e.prototype.UpCount=0,e.prototype.DownCount=0,e.prototype.TCount=0,e.prototype.type=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.prototype.timestamp=OE.Long?OE.Long.fromBits(0,0,!0):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(32).uint32(e.blockheight),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(42).bytes(e.userPubkey),null!=e.commentCid&&Object.hasOwnProperty.call(e,"commentCid")&&t.uint32(50).bytes(e.commentCid),null!=e.comment&&Object.hasOwnProperty.call(e,"comment")&&t.uint32(58).bytes(e.comment),null!=e.commentSize&&Object.hasOwnProperty.call(e,"commentSize")&&t.uint32(64).uint32(e.commentSize),null!=e.status&&Object.hasOwnProperty.call(e,"status")&&t.uint32(72).uint32(e.status),null!=e.refercommentkey&&Object.hasOwnProperty.call(e,"refercommentkey")&&t.uint32(82).bytes(e.refercommentkey),null!=e.CCount&&Object.hasOwnProperty.call(e,"CCount")&&t.uint32(88).uint32(e.CCount),null!=e.UpCount&&Object.hasOwnProperty.call(e,"UpCount")&&t.uint32(96).uint32(e.UpCount),null!=e.DownCount&&Object.hasOwnProperty.call(e,"DownCount")&&t.uint32(104).uint32(e.DownCount),null!=e.TCount&&Object.hasOwnProperty.call(e,"TCount")&&t.uint32(112).uint32(e.TCount),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(120).uint32(e.type),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(130).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(138).bytes(e.vaccount),null!=e.timestamp&&Object.hasOwnProperty.call(e,"timestamp")&&t.uint32(144).uint64(e.timestamp),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.PublishCommentToThemeRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.blockheight=e.uint32();break;case 5:n.userPubkey=e.bytes();break;case 6:n.commentCid=e.bytes();break;case 7:n.comment=e.bytes();break;case 8:n.commentSize=e.uint32();break;case 9:n.status=e.uint32();break;case 10:n.refercommentkey=e.bytes();break;case 11:n.CCount=e.uint32();break;case 12:n.UpCount=e.uint32();break;case 13:n.DownCount=e.uint32();break;case 14:n.TCount=e.uint32();break;case 15:n.type=e.uint32();break;case 16:n.signature=e.bytes();break;case 17:n.vaccount=e.bytes();break;case 18:n.timestamp=e.uint64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.commentCid&&e.hasOwnProperty("commentCid")&&!(e.commentCid&&"number"==typeof e.commentCid.length||OE.isString(e.commentCid))?"commentCid: buffer expected":null!=e.comment&&e.hasOwnProperty("comment")&&!(e.comment&&"number"==typeof e.comment.length||OE.isString(e.comment))?"comment: buffer expected":null!=e.commentSize&&e.hasOwnProperty("commentSize")&&!OE.isInteger(e.commentSize)?"commentSize: integer expected":null!=e.status&&e.hasOwnProperty("status")&&!OE.isInteger(e.status)?"status: integer expected":null!=e.refercommentkey&&e.hasOwnProperty("refercommentkey")&&!(e.refercommentkey&&"number"==typeof e.refercommentkey.length||OE.isString(e.refercommentkey))?"refercommentkey: buffer expected":null!=e.CCount&&e.hasOwnProperty("CCount")&&!OE.isInteger(e.CCount)?"CCount: integer expected":null!=e.UpCount&&e.hasOwnProperty("UpCount")&&!OE.isInteger(e.UpCount)?"UpCount: integer expected":null!=e.DownCount&&e.hasOwnProperty("DownCount")&&!OE.isInteger(e.DownCount)?"DownCount: integer expected":null!=e.TCount&&e.hasOwnProperty("TCount")&&!OE.isInteger(e.TCount)?"TCount: integer expected":null!=e.type&&e.hasOwnProperty("type")&&!OE.isInteger(e.type)?"type: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null!=e.timestamp&&e.hasOwnProperty("timestamp")&&!(OE.isInteger(e.timestamp)||e.timestamp&&OE.isInteger(e.timestamp.low)&&OE.isInteger(e.timestamp.high))?"timestamp: integer|Long expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.PublishCommentToThemeRequest)return e;var t=new AE.dcnet.pb.PublishCommentToThemeRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.commentCid&&("string"==typeof e.commentCid?OE.base64.decode(e.commentCid,t.commentCid=OE.newBuffer(OE.base64.length(e.commentCid)),0):e.commentCid.length>=0&&(t.commentCid=e.commentCid)),null!=e.comment&&("string"==typeof e.comment?OE.base64.decode(e.comment,t.comment=OE.newBuffer(OE.base64.length(e.comment)),0):e.comment.length>=0&&(t.comment=e.comment)),null!=e.commentSize&&(t.commentSize=e.commentSize>>>0),null!=e.status&&(t.status=e.status>>>0),null!=e.refercommentkey&&("string"==typeof e.refercommentkey?OE.base64.decode(e.refercommentkey,t.refercommentkey=OE.newBuffer(OE.base64.length(e.refercommentkey)),0):e.refercommentkey.length>=0&&(t.refercommentkey=e.refercommentkey)),null!=e.CCount&&(t.CCount=e.CCount>>>0),null!=e.UpCount&&(t.UpCount=e.UpCount>>>0),null!=e.DownCount&&(t.DownCount=e.DownCount>>>0),null!=e.TCount&&(t.TCount=e.TCount>>>0),null!=e.type&&(t.type=e.type>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),null!=e.timestamp&&(OE.Long?(t.timestamp=OE.Long.fromValue(e.timestamp)).unsigned=!0:"string"==typeof e.timestamp?t.timestamp=parseInt(e.timestamp,10):"number"==typeof e.timestamp?t.timestamp=e.timestamp:"object"==typeof e.timestamp&&(t.timestamp=new OE.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0))),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.blockheight=0,t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.commentCid="":(r.commentCid=[],t.bytes!==Array&&(r.commentCid=OE.newBuffer(r.commentCid))),t.bytes===String?r.comment="":(r.comment=[],t.bytes!==Array&&(r.comment=OE.newBuffer(r.comment))),r.commentSize=0,r.status=0,t.bytes===String?r.refercommentkey="":(r.refercommentkey=[],t.bytes!==Array&&(r.refercommentkey=OE.newBuffer(r.refercommentkey))),r.CCount=0,r.UpCount=0,r.DownCount=0,r.TCount=0,r.type=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount))),OE.Long){var n=new OE.Long(0,0,!0);r.timestamp=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.timestamp=t.longs===String?"0":0;return null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.commentCid&&e.hasOwnProperty("commentCid")&&(r.commentCid=t.bytes===String?OE.base64.encode(e.commentCid,0,e.commentCid.length):t.bytes===Array?Array.prototype.slice.call(e.commentCid):e.commentCid),null!=e.comment&&e.hasOwnProperty("comment")&&(r.comment=t.bytes===String?OE.base64.encode(e.comment,0,e.comment.length):t.bytes===Array?Array.prototype.slice.call(e.comment):e.comment),null!=e.commentSize&&e.hasOwnProperty("commentSize")&&(r.commentSize=e.commentSize),null!=e.status&&e.hasOwnProperty("status")&&(r.status=e.status),null!=e.refercommentkey&&e.hasOwnProperty("refercommentkey")&&(r.refercommentkey=t.bytes===String?OE.base64.encode(e.refercommentkey,0,e.refercommentkey.length):t.bytes===Array?Array.prototype.slice.call(e.refercommentkey):e.refercommentkey),null!=e.CCount&&e.hasOwnProperty("CCount")&&(r.CCount=e.CCount),null!=e.UpCount&&e.hasOwnProperty("UpCount")&&(r.UpCount=e.UpCount),null!=e.DownCount&&e.hasOwnProperty("DownCount")&&(r.DownCount=e.DownCount),null!=e.TCount&&e.hasOwnProperty("TCount")&&(r.TCount=e.TCount),null!=e.type&&e.hasOwnProperty("type")&&(r.type=e.type),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),null!=e.timestamp&&e.hasOwnProperty("timestamp")&&("number"==typeof e.timestamp?r.timestamp=t.longs===String?String(e.timestamp):e.timestamp:r.timestamp=t.longs===String?OE.Long.prototype.toString.call(e.timestamp):t.longs===Number?new OE.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0):e.timestamp),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.PublishCommentToThemeRequest"},e}(),e.PublishCommentToThemeReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.PublishCommentToThemeReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.PublishCommentToThemeReply)return e;var t=new AE.dcnet.pb.PublishCommentToThemeReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.PublishCommentToThemeReply"},e}(),e.SetKeyValueRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.userPubkey=OE.newBuffer([]),e.prototype.contentCid=OE.newBuffer([]),e.prototype.content=OE.newBuffer([]),e.prototype.contentSize=0,e.prototype.type=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(32).uint32(e.blockheight),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(42).bytes(e.userPubkey),null!=e.contentCid&&Object.hasOwnProperty.call(e,"contentCid")&&t.uint32(50).bytes(e.contentCid),null!=e.content&&Object.hasOwnProperty.call(e,"content")&&t.uint32(58).bytes(e.content),null!=e.contentSize&&Object.hasOwnProperty.call(e,"contentSize")&&t.uint32(64).uint32(e.contentSize),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(72).uint32(e.type),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(82).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(90).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetKeyValueRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.blockheight=e.uint32();break;case 5:n.userPubkey=e.bytes();break;case 6:n.contentCid=e.bytes();break;case 7:n.content=e.bytes();break;case 8:n.contentSize=e.uint32();break;case 9:n.type=e.uint32();break;case 10:n.signature=e.bytes();break;case 11:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.contentCid&&e.hasOwnProperty("contentCid")&&!(e.contentCid&&"number"==typeof e.contentCid.length||OE.isString(e.contentCid))?"contentCid: buffer expected":null!=e.content&&e.hasOwnProperty("content")&&!(e.content&&"number"==typeof e.content.length||OE.isString(e.content))?"content: buffer expected":null!=e.contentSize&&e.hasOwnProperty("contentSize")&&!OE.isInteger(e.contentSize)?"contentSize: integer expected":null!=e.type&&e.hasOwnProperty("type")&&!OE.isInteger(e.type)?"type: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SetKeyValueRequest)return e;var t=new AE.dcnet.pb.SetKeyValueRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.contentCid&&("string"==typeof e.contentCid?OE.base64.decode(e.contentCid,t.contentCid=OE.newBuffer(OE.base64.length(e.contentCid)),0):e.contentCid.length>=0&&(t.contentCid=e.contentCid)),null!=e.content&&("string"==typeof e.content?OE.base64.decode(e.content,t.content=OE.newBuffer(OE.base64.length(e.content)),0):e.content.length>=0&&(t.content=e.content)),null!=e.contentSize&&(t.contentSize=e.contentSize>>>0),null!=e.type&&(t.type=e.type>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.blockheight=0,t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.contentCid="":(r.contentCid=[],t.bytes!==Array&&(r.contentCid=OE.newBuffer(r.contentCid))),t.bytes===String?r.content="":(r.content=[],t.bytes!==Array&&(r.content=OE.newBuffer(r.content))),r.contentSize=0,r.type=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.contentCid&&e.hasOwnProperty("contentCid")&&(r.contentCid=t.bytes===String?OE.base64.encode(e.contentCid,0,e.contentCid.length):t.bytes===Array?Array.prototype.slice.call(e.contentCid):e.contentCid),null!=e.content&&e.hasOwnProperty("content")&&(r.content=t.bytes===String?OE.base64.encode(e.content,0,e.content.length):t.bytes===Array?Array.prototype.slice.call(e.content):e.content),null!=e.contentSize&&e.hasOwnProperty("contentSize")&&(r.contentSize=e.contentSize),null!=e.type&&e.hasOwnProperty("type")&&(r.type=e.type),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetKeyValueRequest"},e}(),e.SetKeyValueReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.timestamp=OE.Long?OE.Long.fromBits(0,0,!0):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.timestamp&&Object.hasOwnProperty.call(e,"timestamp")&&t.uint32(16).uint64(e.timestamp),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetKeyValueReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.timestamp=e.uint64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.timestamp&&e.hasOwnProperty("timestamp")&&!(OE.isInteger(e.timestamp)||e.timestamp&&OE.isInteger(e.timestamp.low)&&OE.isInteger(e.timestamp.high))?"timestamp: integer|Long expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SetKeyValueReply)return e;var t=new AE.dcnet.pb.SetKeyValueReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.timestamp&&(OE.Long?(t.timestamp=OE.Long.fromValue(e.timestamp)).unsigned=!0:"string"==typeof e.timestamp?t.timestamp=parseInt(e.timestamp,10):"number"==typeof e.timestamp?t.timestamp=e.timestamp:"object"==typeof e.timestamp&&(t.timestamp=new OE.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0))),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(r.flag=0,OE.Long){var n=new OE.Long(0,0,!0);r.timestamp=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.timestamp=t.longs===String?"0":0;return null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.timestamp&&e.hasOwnProperty("timestamp")&&("number"==typeof e.timestamp?r.timestamp=t.longs===String?String(e.timestamp):e.timestamp:r.timestamp=t.longs===String?OE.Long.prototype.toString.call(e.timestamp):t.longs===Number?new OE.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0):e.timestamp),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetKeyValueReply"},e}(),e.ConfigThemeObjAuthRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.userPubkey=OE.newBuffer([]),e.prototype.contentCid=OE.newBuffer([]),e.prototype.content=OE.newBuffer([]),e.prototype.contentSize=0,e.prototype.type=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(32).uint32(e.blockheight),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(42).bytes(e.userPubkey),null!=e.contentCid&&Object.hasOwnProperty.call(e,"contentCid")&&t.uint32(50).bytes(e.contentCid),null!=e.content&&Object.hasOwnProperty.call(e,"content")&&t.uint32(58).bytes(e.content),null!=e.contentSize&&Object.hasOwnProperty.call(e,"contentSize")&&t.uint32(64).uint32(e.contentSize),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(72).uint32(e.type),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(82).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(90).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ConfigThemeObjAuthRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.blockheight=e.uint32();break;case 5:n.userPubkey=e.bytes();break;case 6:n.contentCid=e.bytes();break;case 7:n.content=e.bytes();break;case 8:n.contentSize=e.uint32();break;case 9:n.type=e.uint32();break;case 10:n.signature=e.bytes();break;case 11:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.contentCid&&e.hasOwnProperty("contentCid")&&!(e.contentCid&&"number"==typeof e.contentCid.length||OE.isString(e.contentCid))?"contentCid: buffer expected":null!=e.content&&e.hasOwnProperty("content")&&!(e.content&&"number"==typeof e.content.length||OE.isString(e.content))?"content: buffer expected":null!=e.contentSize&&e.hasOwnProperty("contentSize")&&!OE.isInteger(e.contentSize)?"contentSize: integer expected":null!=e.type&&e.hasOwnProperty("type")&&!OE.isInteger(e.type)?"type: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ConfigThemeObjAuthRequest)return e;var t=new AE.dcnet.pb.ConfigThemeObjAuthRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.contentCid&&("string"==typeof e.contentCid?OE.base64.decode(e.contentCid,t.contentCid=OE.newBuffer(OE.base64.length(e.contentCid)),0):e.contentCid.length>=0&&(t.contentCid=e.contentCid)),null!=e.content&&("string"==typeof e.content?OE.base64.decode(e.content,t.content=OE.newBuffer(OE.base64.length(e.content)),0):e.content.length>=0&&(t.content=e.content)),null!=e.contentSize&&(t.contentSize=e.contentSize>>>0),null!=e.type&&(t.type=e.type>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.blockheight=0,t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.contentCid="":(r.contentCid=[],t.bytes!==Array&&(r.contentCid=OE.newBuffer(r.contentCid))),t.bytes===String?r.content="":(r.content=[],t.bytes!==Array&&(r.content=OE.newBuffer(r.content))),r.contentSize=0,r.type=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.contentCid&&e.hasOwnProperty("contentCid")&&(r.contentCid=t.bytes===String?OE.base64.encode(e.contentCid,0,e.contentCid.length):t.bytes===Array?Array.prototype.slice.call(e.contentCid):e.contentCid),null!=e.content&&e.hasOwnProperty("content")&&(r.content=t.bytes===String?OE.base64.encode(e.content,0,e.content.length):t.bytes===Array?Array.prototype.slice.call(e.content):e.content),null!=e.contentSize&&e.hasOwnProperty("contentSize")&&(r.contentSize=e.contentSize),null!=e.type&&e.hasOwnProperty("type")&&(r.type=e.type),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ConfigThemeObjAuthRequest"},e}(),e.ConfigThemeObjAuthReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ConfigThemeObjAuthReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ConfigThemeObjAuthReply)return e;var t=new AE.dcnet.pb.ConfigThemeObjAuthReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ConfigThemeObjAuthReply"},e}(),e.AddUserOffChainSpaceRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.peerid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(26).bytes(e.peerid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(34).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(42).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddUserOffChainSpaceRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.userPubkey=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.peerid=e.bytes();break;case 4:n.signature=e.bytes();break;case 5:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddUserOffChainSpaceRequest)return e;var t=new AE.dcnet.pb.AddUserOffChainSpaceRequest;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),r.blockheight=0,t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddUserOffChainSpaceRequest"},e}(),e.AddUserOffChainSpaceReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddUserOffChainSpaceReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.AddUserOffChainSpaceReply?e:new AE.dcnet.pb.AddUserOffChainSpaceReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddUserOffChainSpaceReply"},e}(),e.ReportMaliciousCommentRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.commentBlockheight=0,e.prototype.commentCid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(32).uint32(e.blockheight),null!=e.commentBlockheight&&Object.hasOwnProperty.call(e,"commentBlockheight")&&t.uint32(40).uint32(e.commentBlockheight),null!=e.commentCid&&Object.hasOwnProperty.call(e,"commentCid")&&t.uint32(50).bytes(e.commentCid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(58).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(66).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ReportMaliciousCommentRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.blockheight=e.uint32();break;case 5:n.commentBlockheight=e.uint32();break;case 6:n.commentCid=e.bytes();break;case 7:n.signature=e.bytes();break;case 8:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.commentBlockheight&&e.hasOwnProperty("commentBlockheight")&&!OE.isInteger(e.commentBlockheight)?"commentBlockheight: integer expected":null!=e.commentCid&&e.hasOwnProperty("commentCid")&&!(e.commentCid&&"number"==typeof e.commentCid.length||OE.isString(e.commentCid))?"commentCid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ReportMaliciousCommentRequest)return e;var t=new AE.dcnet.pb.ReportMaliciousCommentRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.commentBlockheight&&(t.commentBlockheight=e.commentBlockheight>>>0),null!=e.commentCid&&("string"==typeof e.commentCid?OE.base64.decode(e.commentCid,t.commentCid=OE.newBuffer(OE.base64.length(e.commentCid)),0):e.commentCid.length>=0&&(t.commentCid=e.commentCid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.blockheight=0,r.commentBlockheight=0,t.bytes===String?r.commentCid="":(r.commentCid=[],t.bytes!==Array&&(r.commentCid=OE.newBuffer(r.commentCid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.commentBlockheight&&e.hasOwnProperty("commentBlockheight")&&(r.commentBlockheight=e.commentBlockheight),null!=e.commentCid&&e.hasOwnProperty("commentCid")&&(r.commentCid=t.bytes===String?OE.base64.encode(e.commentCid,0,e.commentCid.length):t.bytes===Array?Array.prototype.slice.call(e.commentCid):e.commentCid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ReportMaliciousCommentRequest"},e}(),e.ReportMaliciousCommentReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ReportMaliciousCommentReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ReportMaliciousCommentReply)return e;var t=new AE.dcnet.pb.ReportMaliciousCommentReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ReportMaliciousCommentReply"},e}(),e.SetObjCommentPublicRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.commentBlockheight=0,e.prototype.commentCid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(32).uint32(e.blockheight),null!=e.commentBlockheight&&Object.hasOwnProperty.call(e,"commentBlockheight")&&t.uint32(40).uint32(e.commentBlockheight),null!=e.commentCid&&Object.hasOwnProperty.call(e,"commentCid")&&t.uint32(50).bytes(e.commentCid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(58).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(66).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetObjCommentPublicRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.blockheight=e.uint32();break;case 5:n.commentBlockheight=e.uint32();break;case 6:n.commentCid=e.bytes();break;case 7:n.signature=e.bytes();break;case 8:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.commentBlockheight&&e.hasOwnProperty("commentBlockheight")&&!OE.isInteger(e.commentBlockheight)?"commentBlockheight: integer expected":null!=e.commentCid&&e.hasOwnProperty("commentCid")&&!(e.commentCid&&"number"==typeof e.commentCid.length||OE.isString(e.commentCid))?"commentCid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SetObjCommentPublicRequest)return e;var t=new AE.dcnet.pb.SetObjCommentPublicRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.commentBlockheight&&(t.commentBlockheight=e.commentBlockheight>>>0),null!=e.commentCid&&("string"==typeof e.commentCid?OE.base64.decode(e.commentCid,t.commentCid=OE.newBuffer(OE.base64.length(e.commentCid)),0):e.commentCid.length>=0&&(t.commentCid=e.commentCid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.blockheight=0,r.commentBlockheight=0,t.bytes===String?r.commentCid="":(r.commentCid=[],t.bytes!==Array&&(r.commentCid=OE.newBuffer(r.commentCid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.commentBlockheight&&e.hasOwnProperty("commentBlockheight")&&(r.commentBlockheight=e.commentBlockheight),null!=e.commentCid&&e.hasOwnProperty("commentCid")&&(r.commentCid=t.bytes===String?OE.base64.encode(e.commentCid,0,e.commentCid.length):t.bytes===Array?Array.prototype.slice.call(e.commentCid):e.commentCid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetObjCommentPublicRequest"},e}(),e.SetObjCommentPublicReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetObjCommentPublicReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SetObjCommentPublicReply)return e;var t=new AE.dcnet.pb.SetObjCommentPublicReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetObjCommentPublicReply"},e}(),e.DeleteSelfCommentRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.userPubkey=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.commentBlockheight=0,e.prototype.commentCid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(26).bytes(e.userPubkey),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(34).bytes(e.themeAuthor),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(40).uint32(e.blockheight),null!=e.commentBlockheight&&Object.hasOwnProperty.call(e,"commentBlockheight")&&t.uint32(48).uint32(e.commentBlockheight),null!=e.commentCid&&Object.hasOwnProperty.call(e,"commentCid")&&t.uint32(58).bytes(e.commentCid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(66).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(74).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteSelfCommentRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.userPubkey=e.bytes();break;case 4:n.themeAuthor=e.bytes();break;case 5:n.blockheight=e.uint32();break;case 6:n.commentBlockheight=e.uint32();break;case 7:n.commentCid=e.bytes();break;case 8:n.signature=e.bytes();break;case 9:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.commentBlockheight&&e.hasOwnProperty("commentBlockheight")&&!OE.isInteger(e.commentBlockheight)?"commentBlockheight: integer expected":null!=e.commentCid&&e.hasOwnProperty("commentCid")&&!(e.commentCid&&"number"==typeof e.commentCid.length||OE.isString(e.commentCid))?"commentCid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeleteSelfCommentRequest)return e;var t=new AE.dcnet.pb.DeleteSelfCommentRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.commentBlockheight&&(t.commentBlockheight=e.commentBlockheight>>>0),null!=e.commentCid&&("string"==typeof e.commentCid?OE.base64.decode(e.commentCid,t.commentCid=OE.newBuffer(OE.base64.length(e.commentCid)),0):e.commentCid.length>=0&&(t.commentCid=e.commentCid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.blockheight=0,r.commentBlockheight=0,t.bytes===String?r.commentCid="":(r.commentCid=[],t.bytes!==Array&&(r.commentCid=OE.newBuffer(r.commentCid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.commentBlockheight&&e.hasOwnProperty("commentBlockheight")&&(r.commentBlockheight=e.commentBlockheight),null!=e.commentCid&&e.hasOwnProperty("commentCid")&&(r.commentCid=t.bytes===String?OE.base64.encode(e.commentCid,0,e.commentCid.length):t.bytes===Array?Array.prototype.slice.call(e.commentCid):e.commentCid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteSelfCommentRequest"},e}(),e.DeleteSelfCommentReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteSelfCommentReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeleteSelfCommentReply)return e;var t=new AE.dcnet.pb.DeleteSelfCommentReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteSelfCommentReply"},e}(),e.DeleteCommentToObjRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.userPubkey=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.commentBlockheight=0,e.prototype.commentCid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(26).bytes(e.userPubkey),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(34).bytes(e.themeAuthor),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(40).uint32(e.blockheight),null!=e.commentBlockheight&&Object.hasOwnProperty.call(e,"commentBlockheight")&&t.uint32(48).uint32(e.commentBlockheight),null!=e.commentCid&&Object.hasOwnProperty.call(e,"commentCid")&&t.uint32(58).bytes(e.commentCid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(66).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(74).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteCommentToObjRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.userPubkey=e.bytes();break;case 4:n.themeAuthor=e.bytes();break;case 5:n.blockheight=e.uint32();break;case 6:n.commentBlockheight=e.uint32();break;case 7:n.commentCid=e.bytes();break;case 8:n.signature=e.bytes();break;case 9:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.commentBlockheight&&e.hasOwnProperty("commentBlockheight")&&!OE.isInteger(e.commentBlockheight)?"commentBlockheight: integer expected":null!=e.commentCid&&e.hasOwnProperty("commentCid")&&!(e.commentCid&&"number"==typeof e.commentCid.length||OE.isString(e.commentCid))?"commentCid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeleteCommentToObjRequest)return e;var t=new AE.dcnet.pb.DeleteCommentToObjRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.commentBlockheight&&(t.commentBlockheight=e.commentBlockheight>>>0),null!=e.commentCid&&("string"==typeof e.commentCid?OE.base64.decode(e.commentCid,t.commentCid=OE.newBuffer(OE.base64.length(e.commentCid)),0):e.commentCid.length>=0&&(t.commentCid=e.commentCid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.blockheight=0,r.commentBlockheight=0,t.bytes===String?r.commentCid="":(r.commentCid=[],t.bytes!==Array&&(r.commentCid=OE.newBuffer(r.commentCid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.commentBlockheight&&e.hasOwnProperty("commentBlockheight")&&(r.commentBlockheight=e.commentBlockheight),null!=e.commentCid&&e.hasOwnProperty("commentCid")&&(r.commentCid=t.bytes===String?OE.base64.encode(e.commentCid,0,e.commentCid.length):t.bytes===Array?Array.prototype.slice.call(e.commentCid):e.commentCid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteCommentToObjRequest"},e}(),e.DeleteCommentToObjReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeleteCommentToObjReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeleteCommentToObjReply)return e;var t=new AE.dcnet.pb.DeleteCommentToObjReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeleteCommentToObjReply"},e}(),e.IsThemeExistRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.IsThemeExistRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.IsThemeExistRequest)return e;var t=new AE.dcnet.pb.IsThemeExistRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.IsThemeExistRequest"},e}(),e.IsThemeExistReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.IsThemeExistReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.IsThemeExistReply)return e;var t=new AE.dcnet.pb.IsThemeExistReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.IsThemeExistReply"},e}(),e.GetThemeObjRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.startHeight=0,e.prototype.direction=0,e.prototype.offset=0,e.prototype.limit=0,e.prototype.seekKey=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(10).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(18).bytes(e.themeAuthor),null!=e.startHeight&&Object.hasOwnProperty.call(e,"startHeight")&&t.uint32(24).uint32(e.startHeight),null!=e.direction&&Object.hasOwnProperty.call(e,"direction")&&t.uint32(32).uint32(e.direction),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(40).uint32(e.offset),null!=e.limit&&Object.hasOwnProperty.call(e,"limit")&&t.uint32(48).uint32(e.limit),null!=e.seekKey&&Object.hasOwnProperty.call(e,"seekKey")&&t.uint32(58).bytes(e.seekKey),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(66).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThemeObjRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.appId=e.bytes();break;case 2:n.themeAuthor=e.bytes();break;case 3:n.startHeight=e.uint32();break;case 4:n.direction=e.uint32();break;case 5:n.offset=e.uint32();break;case 6:n.limit=e.uint32();break;case 7:n.seekKey=e.bytes();break;case 8:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.startHeight&&e.hasOwnProperty("startHeight")&&!OE.isInteger(e.startHeight)?"startHeight: integer expected":null!=e.direction&&e.hasOwnProperty("direction")&&!OE.isInteger(e.direction)?"direction: integer expected":null!=e.offset&&e.hasOwnProperty("offset")&&!OE.isInteger(e.offset)?"offset: integer expected":null!=e.limit&&e.hasOwnProperty("limit")&&!OE.isInteger(e.limit)?"limit: integer expected":null!=e.seekKey&&e.hasOwnProperty("seekKey")&&!(e.seekKey&&"number"==typeof e.seekKey.length||OE.isString(e.seekKey))?"seekKey: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThemeObjRequest)return e;var t=new AE.dcnet.pb.GetThemeObjRequest;return null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.startHeight&&(t.startHeight=e.startHeight>>>0),null!=e.direction&&(t.direction=e.direction>>>0),null!=e.offset&&(t.offset=e.offset>>>0),null!=e.limit&&(t.limit=e.limit>>>0),null!=e.seekKey&&("string"==typeof e.seekKey?OE.base64.decode(e.seekKey,t.seekKey=OE.newBuffer(OE.base64.length(e.seekKey)),0):e.seekKey.length>=0&&(t.seekKey=e.seekKey)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.startHeight=0,r.direction=0,r.offset=0,r.limit=0,t.bytes===String?r.seekKey="":(r.seekKey=[],t.bytes!==Array&&(r.seekKey=OE.newBuffer(r.seekKey))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.startHeight&&e.hasOwnProperty("startHeight")&&(r.startHeight=e.startHeight),null!=e.direction&&e.hasOwnProperty("direction")&&(r.direction=e.direction),null!=e.offset&&e.hasOwnProperty("offset")&&(r.offset=e.offset),null!=e.limit&&e.hasOwnProperty("limit")&&(r.limit=e.limit),null!=e.seekKey&&e.hasOwnProperty("seekKey")&&(r.seekKey=t.bytes===String?OE.base64.encode(e.seekKey,0,e.seekKey.length):t.bytes===Array?Array.prototype.slice.call(e.seekKey):e.seekKey),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThemeObjRequest"},e}(),e.GetThemeObjReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.objsCid=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.objsCid&&Object.hasOwnProperty.call(e,"objsCid")&&t.uint32(18).bytes(e.objsCid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThemeObjReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.objsCid=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.objsCid&&e.hasOwnProperty("objsCid")&&!(e.objsCid&&"number"==typeof e.objsCid.length||OE.isString(e.objsCid))?"objsCid: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThemeObjReply)return e;var t=new AE.dcnet.pb.GetThemeObjReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.objsCid&&("string"==typeof e.objsCid?OE.base64.decode(e.objsCid,t.objsCid=OE.newBuffer(OE.base64.length(e.objsCid)),0):e.objsCid.length>=0&&(t.objsCid=e.objsCid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.objsCid="":(r.objsCid=[],t.bytes!==Array&&(r.objsCid=OE.newBuffer(r.objsCid)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.objsCid&&e.hasOwnProperty("objsCid")&&(r.objsCid=t.bytes===String?OE.base64.encode(e.objsCid,0,e.objsCid.length):t.bytes===Array?Array.prototype.slice.call(e.objsCid):e.objsCid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThemeObjReply"},e}(),e.SyncThemeObjRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.theme=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(10).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(18).bytes(e.themeAuthor),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(26).bytes(e.theme),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SyncThemeObjRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.appId=e.bytes();break;case 2:n.themeAuthor=e.bytes();break;case 3:n.theme=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SyncThemeObjRequest)return e;var t=new AE.dcnet.pb.SyncThemeObjRequest;return null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme)))),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SyncThemeObjRequest"},e}(),e.SyncThemeObjReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.addThemReqRawData=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.addThemReqRawData&&Object.hasOwnProperty.call(e,"addThemReqRawData")&&t.uint32(18).bytes(e.addThemReqRawData),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SyncThemeObjReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.addThemReqRawData=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.addThemReqRawData&&e.hasOwnProperty("addThemReqRawData")&&!(e.addThemReqRawData&&"number"==typeof e.addThemReqRawData.length||OE.isString(e.addThemReqRawData))?"addThemReqRawData: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SyncThemeObjReply)return e;var t=new AE.dcnet.pb.SyncThemeObjReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.addThemReqRawData&&("string"==typeof e.addThemReqRawData?OE.base64.decode(e.addThemReqRawData,t.addThemReqRawData=OE.newBuffer(OE.base64.length(e.addThemReqRawData)),0):e.addThemReqRawData.length>=0&&(t.addThemReqRawData=e.addThemReqRawData)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.addThemReqRawData="":(r.addThemReqRawData=[],t.bytes!==Array&&(r.addThemReqRawData=OE.newBuffer(r.addThemReqRawData)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.addThemReqRawData&&e.hasOwnProperty("addThemReqRawData")&&(r.addThemReqRawData=t.bytes===String?OE.base64.encode(e.addThemReqRawData,0,e.addThemReqRawData.length):t.bytes===Array?Array.prototype.slice.call(e.addThemReqRawData):e.addThemReqRawData),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SyncThemeObjReply"},e}(),e.GetThemeCommentsRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.startHeight=0,e.prototype.direction=0,e.prototype.offset=0,e.prototype.limit=0,e.prototype.seekKey=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.prototype.aesKey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.startHeight&&Object.hasOwnProperty.call(e,"startHeight")&&t.uint32(32).uint32(e.startHeight),null!=e.direction&&Object.hasOwnProperty.call(e,"direction")&&t.uint32(40).uint32(e.direction),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(48).uint32(e.offset),null!=e.limit&&Object.hasOwnProperty.call(e,"limit")&&t.uint32(56).uint32(e.limit),null!=e.seekKey&&Object.hasOwnProperty.call(e,"seekKey")&&t.uint32(66).bytes(e.seekKey),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(74).bytes(e.vaccount),null!=e.aesKey&&Object.hasOwnProperty.call(e,"aesKey")&&t.uint32(82).bytes(e.aesKey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThemeCommentsRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.startHeight=e.uint32();break;case 5:n.direction=e.uint32();break;case 6:n.offset=e.uint32();break;case 7:n.limit=e.uint32();break;case 8:n.seekKey=e.bytes();break;case 9:n.vaccount=e.bytes();break;case 10:n.aesKey=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.startHeight&&e.hasOwnProperty("startHeight")&&!OE.isInteger(e.startHeight)?"startHeight: integer expected":null!=e.direction&&e.hasOwnProperty("direction")&&!OE.isInteger(e.direction)?"direction: integer expected":null!=e.offset&&e.hasOwnProperty("offset")&&!OE.isInteger(e.offset)?"offset: integer expected":null!=e.limit&&e.hasOwnProperty("limit")&&!OE.isInteger(e.limit)?"limit: integer expected":null!=e.seekKey&&e.hasOwnProperty("seekKey")&&!(e.seekKey&&"number"==typeof e.seekKey.length||OE.isString(e.seekKey))?"seekKey: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null!=e.aesKey&&e.hasOwnProperty("aesKey")&&!(e.aesKey&&"number"==typeof e.aesKey.length||OE.isString(e.aesKey))?"aesKey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThemeCommentsRequest)return e;var t=new AE.dcnet.pb.GetThemeCommentsRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.startHeight&&(t.startHeight=e.startHeight>>>0),null!=e.direction&&(t.direction=e.direction>>>0),null!=e.offset&&(t.offset=e.offset>>>0),null!=e.limit&&(t.limit=e.limit>>>0),null!=e.seekKey&&("string"==typeof e.seekKey?OE.base64.decode(e.seekKey,t.seekKey=OE.newBuffer(OE.base64.length(e.seekKey)),0):e.seekKey.length>=0&&(t.seekKey=e.seekKey)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),null!=e.aesKey&&("string"==typeof e.aesKey?OE.base64.decode(e.aesKey,t.aesKey=OE.newBuffer(OE.base64.length(e.aesKey)),0):e.aesKey.length>=0&&(t.aesKey=e.aesKey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.startHeight=0,r.direction=0,r.offset=0,r.limit=0,t.bytes===String?r.seekKey="":(r.seekKey=[],t.bytes!==Array&&(r.seekKey=OE.newBuffer(r.seekKey))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount))),t.bytes===String?r.aesKey="":(r.aesKey=[],t.bytes!==Array&&(r.aesKey=OE.newBuffer(r.aesKey)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.startHeight&&e.hasOwnProperty("startHeight")&&(r.startHeight=e.startHeight),null!=e.direction&&e.hasOwnProperty("direction")&&(r.direction=e.direction),null!=e.offset&&e.hasOwnProperty("offset")&&(r.offset=e.offset),null!=e.limit&&e.hasOwnProperty("limit")&&(r.limit=e.limit),null!=e.seekKey&&e.hasOwnProperty("seekKey")&&(r.seekKey=t.bytes===String?OE.base64.encode(e.seekKey,0,e.seekKey.length):t.bytes===Array?Array.prototype.slice.call(e.seekKey):e.seekKey),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),null!=e.aesKey&&e.hasOwnProperty("aesKey")&&(r.aesKey=t.bytes===String?OE.base64.encode(e.aesKey,0,e.aesKey.length):t.bytes===Array?Array.prototype.slice.call(e.aesKey):e.aesKey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThemeCommentsRequest"},e}(),e.GetThemeCommentsReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.commentsCid=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.commentsCid&&Object.hasOwnProperty.call(e,"commentsCid")&&t.uint32(18).bytes(e.commentsCid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThemeCommentsReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.commentsCid=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.commentsCid&&e.hasOwnProperty("commentsCid")&&!(e.commentsCid&&"number"==typeof e.commentsCid.length||OE.isString(e.commentsCid))?"commentsCid: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThemeCommentsReply)return e;var t=new AE.dcnet.pb.GetThemeCommentsReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.commentsCid&&("string"==typeof e.commentsCid?OE.base64.decode(e.commentsCid,t.commentsCid=OE.newBuffer(OE.base64.length(e.commentsCid)),0):e.commentsCid.length>=0&&(t.commentsCid=e.commentsCid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.commentsCid="":(r.commentsCid=[],t.bytes!==Array&&(r.commentsCid=OE.newBuffer(r.commentsCid)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.commentsCid&&e.hasOwnProperty("commentsCid")&&(r.commentsCid=t.bytes===String?OE.base64.encode(e.commentsCid,0,e.commentsCid.length):t.bytes===Array?Array.prototype.slice.call(e.commentsCid):e.commentsCid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThemeCommentsReply"},e}(),e.GetValuesWithIndexRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.startHeight=0,e.prototype.direction=0,e.prototype.offset=0,e.prototype.limit=0,e.prototype.seekKey=OE.newBuffer([]),e.prototype.indexKey=OE.newBuffer([]),e.prototype.indexValue=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.startHeight&&Object.hasOwnProperty.call(e,"startHeight")&&t.uint32(32).uint32(e.startHeight),null!=e.direction&&Object.hasOwnProperty.call(e,"direction")&&t.uint32(40).uint32(e.direction),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(48).uint32(e.offset),null!=e.limit&&Object.hasOwnProperty.call(e,"limit")&&t.uint32(56).uint32(e.limit),null!=e.seekKey&&Object.hasOwnProperty.call(e,"seekKey")&&t.uint32(66).bytes(e.seekKey),null!=e.indexKey&&Object.hasOwnProperty.call(e,"indexKey")&&t.uint32(74).bytes(e.indexKey),null!=e.indexValue&&Object.hasOwnProperty.call(e,"indexValue")&&t.uint32(82).bytes(e.indexValue),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(90).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetValuesWithIndexRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.startHeight=e.uint32();break;case 5:n.direction=e.uint32();break;case 6:n.offset=e.uint32();break;case 7:n.limit=e.uint32();break;case 8:n.seekKey=e.bytes();break;case 9:n.indexKey=e.bytes();break;case 10:n.indexValue=e.bytes();break;case 11:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.startHeight&&e.hasOwnProperty("startHeight")&&!OE.isInteger(e.startHeight)?"startHeight: integer expected":null!=e.direction&&e.hasOwnProperty("direction")&&!OE.isInteger(e.direction)?"direction: integer expected":null!=e.offset&&e.hasOwnProperty("offset")&&!OE.isInteger(e.offset)?"offset: integer expected":null!=e.limit&&e.hasOwnProperty("limit")&&!OE.isInteger(e.limit)?"limit: integer expected":null!=e.seekKey&&e.hasOwnProperty("seekKey")&&!(e.seekKey&&"number"==typeof e.seekKey.length||OE.isString(e.seekKey))?"seekKey: buffer expected":null!=e.indexKey&&e.hasOwnProperty("indexKey")&&!(e.indexKey&&"number"==typeof e.indexKey.length||OE.isString(e.indexKey))?"indexKey: buffer expected":null!=e.indexValue&&e.hasOwnProperty("indexValue")&&!(e.indexValue&&"number"==typeof e.indexValue.length||OE.isString(e.indexValue))?"indexValue: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetValuesWithIndexRequest)return e;var t=new AE.dcnet.pb.GetValuesWithIndexRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.startHeight&&(t.startHeight=e.startHeight>>>0),null!=e.direction&&(t.direction=e.direction>>>0),null!=e.offset&&(t.offset=e.offset>>>0),null!=e.limit&&(t.limit=e.limit>>>0),null!=e.seekKey&&("string"==typeof e.seekKey?OE.base64.decode(e.seekKey,t.seekKey=OE.newBuffer(OE.base64.length(e.seekKey)),0):e.seekKey.length>=0&&(t.seekKey=e.seekKey)),null!=e.indexKey&&("string"==typeof e.indexKey?OE.base64.decode(e.indexKey,t.indexKey=OE.newBuffer(OE.base64.length(e.indexKey)),0):e.indexKey.length>=0&&(t.indexKey=e.indexKey)),null!=e.indexValue&&("string"==typeof e.indexValue?OE.base64.decode(e.indexValue,t.indexValue=OE.newBuffer(OE.base64.length(e.indexValue)),0):e.indexValue.length>=0&&(t.indexValue=e.indexValue)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.startHeight=0,r.direction=0,r.offset=0,r.limit=0,t.bytes===String?r.seekKey="":(r.seekKey=[],t.bytes!==Array&&(r.seekKey=OE.newBuffer(r.seekKey))),t.bytes===String?r.indexKey="":(r.indexKey=[],t.bytes!==Array&&(r.indexKey=OE.newBuffer(r.indexKey))),t.bytes===String?r.indexValue="":(r.indexValue=[],t.bytes!==Array&&(r.indexValue=OE.newBuffer(r.indexValue))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.startHeight&&e.hasOwnProperty("startHeight")&&(r.startHeight=e.startHeight),null!=e.direction&&e.hasOwnProperty("direction")&&(r.direction=e.direction),null!=e.offset&&e.hasOwnProperty("offset")&&(r.offset=e.offset),null!=e.limit&&e.hasOwnProperty("limit")&&(r.limit=e.limit),null!=e.seekKey&&e.hasOwnProperty("seekKey")&&(r.seekKey=t.bytes===String?OE.base64.encode(e.seekKey,0,e.seekKey.length):t.bytes===Array?Array.prototype.slice.call(e.seekKey):e.seekKey),null!=e.indexKey&&e.hasOwnProperty("indexKey")&&(r.indexKey=t.bytes===String?OE.base64.encode(e.indexKey,0,e.indexKey.length):t.bytes===Array?Array.prototype.slice.call(e.indexKey):e.indexKey),null!=e.indexValue&&e.hasOwnProperty("indexValue")&&(r.indexValue=t.bytes===String?OE.base64.encode(e.indexValue,0,e.indexValue.length):t.bytes===Array?Array.prototype.slice.call(e.indexValue):e.indexValue),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetValuesWithIndexRequest"},e}(),e.GetValuesWithIndexReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.keyValues=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.keyValues&&Object.hasOwnProperty.call(e,"keyValues")&&t.uint32(18).bytes(e.keyValues),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetValuesWithIndexReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.keyValues=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.keyValues&&e.hasOwnProperty("keyValues")&&!(e.keyValues&&"number"==typeof e.keyValues.length||OE.isString(e.keyValues))?"keyValues: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetValuesWithIndexReply)return e;var t=new AE.dcnet.pb.GetValuesWithIndexReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.keyValues&&("string"==typeof e.keyValues?OE.base64.decode(e.keyValues,t.keyValues=OE.newBuffer(OE.base64.length(e.keyValues)),0):e.keyValues.length>=0&&(t.keyValues=e.keyValues)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.keyValues="":(r.keyValues=[],t.bytes!==Array&&(r.keyValues=OE.newBuffer(r.keyValues)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.keyValues&&e.hasOwnProperty("keyValues")&&(r.keyValues=t.bytes===String?OE.base64.encode(e.keyValues,0,e.keyValues.length):t.bytes===Array?Array.prototype.slice.call(e.keyValues):e.keyValues),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetValuesWithIndexReply"},e}(),e.GetThemeAuthListRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.startHeight=0,e.prototype.direction=0,e.prototype.offset=0,e.prototype.limit=0,e.prototype.seekKey=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.startHeight&&Object.hasOwnProperty.call(e,"startHeight")&&t.uint32(32).uint32(e.startHeight),null!=e.direction&&Object.hasOwnProperty.call(e,"direction")&&t.uint32(40).uint32(e.direction),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(48).uint32(e.offset),null!=e.limit&&Object.hasOwnProperty.call(e,"limit")&&t.uint32(56).uint32(e.limit),null!=e.seekKey&&Object.hasOwnProperty.call(e,"seekKey")&&t.uint32(66).bytes(e.seekKey),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(74).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThemeAuthListRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.startHeight=e.uint32();break;case 5:n.direction=e.uint32();break;case 6:n.offset=e.uint32();break;case 7:n.limit=e.uint32();break;case 8:n.seekKey=e.bytes();break;case 9:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.startHeight&&e.hasOwnProperty("startHeight")&&!OE.isInteger(e.startHeight)?"startHeight: integer expected":null!=e.direction&&e.hasOwnProperty("direction")&&!OE.isInteger(e.direction)?"direction: integer expected":null!=e.offset&&e.hasOwnProperty("offset")&&!OE.isInteger(e.offset)?"offset: integer expected":null!=e.limit&&e.hasOwnProperty("limit")&&!OE.isInteger(e.limit)?"limit: integer expected":null!=e.seekKey&&e.hasOwnProperty("seekKey")&&!(e.seekKey&&"number"==typeof e.seekKey.length||OE.isString(e.seekKey))?"seekKey: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThemeAuthListRequest)return e;var t=new AE.dcnet.pb.GetThemeAuthListRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.startHeight&&(t.startHeight=e.startHeight>>>0),null!=e.direction&&(t.direction=e.direction>>>0),null!=e.offset&&(t.offset=e.offset>>>0),null!=e.limit&&(t.limit=e.limit>>>0),null!=e.seekKey&&("string"==typeof e.seekKey?OE.base64.decode(e.seekKey,t.seekKey=OE.newBuffer(OE.base64.length(e.seekKey)),0):e.seekKey.length>=0&&(t.seekKey=e.seekKey)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.startHeight=0,r.direction=0,r.offset=0,r.limit=0,t.bytes===String?r.seekKey="":(r.seekKey=[],t.bytes!==Array&&(r.seekKey=OE.newBuffer(r.seekKey))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.startHeight&&e.hasOwnProperty("startHeight")&&(r.startHeight=e.startHeight),null!=e.direction&&e.hasOwnProperty("direction")&&(r.direction=e.direction),null!=e.offset&&e.hasOwnProperty("offset")&&(r.offset=e.offset),null!=e.limit&&e.hasOwnProperty("limit")&&(r.limit=e.limit),null!=e.seekKey&&e.hasOwnProperty("seekKey")&&(r.seekKey=t.bytes===String?OE.base64.encode(e.seekKey,0,e.seekKey.length):t.bytes===Array?Array.prototype.slice.call(e.seekKey):e.seekKey),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThemeAuthListRequest"},e}(),e.GetThemeAuthListReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.authListCid=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.authListCid&&Object.hasOwnProperty.call(e,"authListCid")&&t.uint32(18).bytes(e.authListCid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThemeAuthListReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.authListCid=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.authListCid&&e.hasOwnProperty("authListCid")&&!(e.authListCid&&"number"==typeof e.authListCid.length||OE.isString(e.authListCid))?"authListCid: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThemeAuthListReply)return e;var t=new AE.dcnet.pb.GetThemeAuthListReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.authListCid&&("string"==typeof e.authListCid?OE.base64.decode(e.authListCid,t.authListCid=OE.newBuffer(OE.base64.length(e.authListCid)),0):e.authListCid.length>=0&&(t.authListCid=e.authListCid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.authListCid="":(r.authListCid=[],t.bytes!==Array&&(r.authListCid=OE.newBuffer(r.authListCid)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.authListCid&&e.hasOwnProperty("authListCid")&&(r.authListCid=t.bytes===String?OE.base64.encode(e.authListCid,0,e.authListCid.length):t.bytes===Array?Array.prototype.slice.call(e.authListCid):e.authListCid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThemeAuthListReply"},e}(),e.GetUserThemeConfigInfoRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.UserPubkey=OE.newBuffer([]),e.prototype.Vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.UserPubkey&&Object.hasOwnProperty.call(e,"UserPubkey")&&t.uint32(34).bytes(e.UserPubkey),null!=e.Vaccount&&Object.hasOwnProperty.call(e,"Vaccount")&&t.uint32(42).bytes(e.Vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserThemeConfigInfoRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.UserPubkey=e.bytes();break;case 5:n.Vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&!(e.UserPubkey&&"number"==typeof e.UserPubkey.length||OE.isString(e.UserPubkey))?"UserPubkey: buffer expected":null!=e.Vaccount&&e.hasOwnProperty("Vaccount")&&!(e.Vaccount&&"number"==typeof e.Vaccount.length||OE.isString(e.Vaccount))?"Vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserThemeConfigInfoRequest)return e;var t=new AE.dcnet.pb.GetUserThemeConfigInfoRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.UserPubkey&&("string"==typeof e.UserPubkey?OE.base64.decode(e.UserPubkey,t.UserPubkey=OE.newBuffer(OE.base64.length(e.UserPubkey)),0):e.UserPubkey.length>=0&&(t.UserPubkey=e.UserPubkey)),null!=e.Vaccount&&("string"==typeof e.Vaccount?OE.base64.decode(e.Vaccount,t.Vaccount=OE.newBuffer(OE.base64.length(e.Vaccount)),0):e.Vaccount.length>=0&&(t.Vaccount=e.Vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),t.bytes===String?r.UserPubkey="":(r.UserPubkey=[],t.bytes!==Array&&(r.UserPubkey=OE.newBuffer(r.UserPubkey))),t.bytes===String?r.Vaccount="":(r.Vaccount=[],t.bytes!==Array&&(r.Vaccount=OE.newBuffer(r.Vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&(r.UserPubkey=t.bytes===String?OE.base64.encode(e.UserPubkey,0,e.UserPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.UserPubkey):e.UserPubkey),null!=e.Vaccount&&e.hasOwnProperty("Vaccount")&&(r.Vaccount=t.bytes===String?OE.base64.encode(e.Vaccount,0,e.Vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.Vaccount):e.Vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserThemeConfigInfoRequest"},e}(),e.GetUserThemeConfigInfoReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.authInfo=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.authInfo&&Object.hasOwnProperty.call(e,"authInfo")&&t.uint32(18).bytes(e.authInfo),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserThemeConfigInfoReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.authInfo=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.authInfo&&e.hasOwnProperty("authInfo")&&!(e.authInfo&&"number"==typeof e.authInfo.length||OE.isString(e.authInfo))?"authInfo: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserThemeConfigInfoReply)return e;var t=new AE.dcnet.pb.GetUserThemeConfigInfoReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.authInfo&&("string"==typeof e.authInfo?OE.base64.decode(e.authInfo,t.authInfo=OE.newBuffer(OE.base64.length(e.authInfo)),0):e.authInfo.length>=0&&(t.authInfo=e.authInfo)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.authInfo="":(r.authInfo=[],t.bytes!==Array&&(r.authInfo=OE.newBuffer(r.authInfo)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.authInfo&&e.hasOwnProperty("authInfo")&&(r.authInfo=t.bytes===String?OE.base64.encode(e.authInfo,0,e.authInfo.length):t.bytes===Array?Array.prototype.slice.call(e.authInfo):e.authInfo),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserThemeConfigInfoReply"},e}(),e.GetUserCommentsRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.appId=OE.newBuffer([]),e.prototype.UserPubkey=OE.newBuffer([]),e.prototype.startHeight=0,e.prototype.direction=0,e.prototype.offset=0,e.prototype.limit=0,e.prototype.seekKey=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.prototype.aesKey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(10).bytes(e.appId),null!=e.UserPubkey&&Object.hasOwnProperty.call(e,"UserPubkey")&&t.uint32(18).bytes(e.UserPubkey),null!=e.startHeight&&Object.hasOwnProperty.call(e,"startHeight")&&t.uint32(24).uint32(e.startHeight),null!=e.direction&&Object.hasOwnProperty.call(e,"direction")&&t.uint32(32).uint32(e.direction),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(40).uint32(e.offset),null!=e.limit&&Object.hasOwnProperty.call(e,"limit")&&t.uint32(48).uint32(e.limit),null!=e.seekKey&&Object.hasOwnProperty.call(e,"seekKey")&&t.uint32(58).bytes(e.seekKey),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(66).bytes(e.vaccount),null!=e.aesKey&&Object.hasOwnProperty.call(e,"aesKey")&&t.uint32(74).bytes(e.aesKey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserCommentsRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.appId=e.bytes();break;case 2:n.UserPubkey=e.bytes();break;case 3:n.startHeight=e.uint32();break;case 4:n.direction=e.uint32();break;case 5:n.offset=e.uint32();break;case 6:n.limit=e.uint32();break;case 7:n.seekKey=e.bytes();break;case 8:n.vaccount=e.bytes();break;case 9:n.aesKey=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&!(e.UserPubkey&&"number"==typeof e.UserPubkey.length||OE.isString(e.UserPubkey))?"UserPubkey: buffer expected":null!=e.startHeight&&e.hasOwnProperty("startHeight")&&!OE.isInteger(e.startHeight)?"startHeight: integer expected":null!=e.direction&&e.hasOwnProperty("direction")&&!OE.isInteger(e.direction)?"direction: integer expected":null!=e.offset&&e.hasOwnProperty("offset")&&!OE.isInteger(e.offset)?"offset: integer expected":null!=e.limit&&e.hasOwnProperty("limit")&&!OE.isInteger(e.limit)?"limit: integer expected":null!=e.seekKey&&e.hasOwnProperty("seekKey")&&!(e.seekKey&&"number"==typeof e.seekKey.length||OE.isString(e.seekKey))?"seekKey: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null!=e.aesKey&&e.hasOwnProperty("aesKey")&&!(e.aesKey&&"number"==typeof e.aesKey.length||OE.isString(e.aesKey))?"aesKey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserCommentsRequest)return e;var t=new AE.dcnet.pb.GetUserCommentsRequest;return null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.UserPubkey&&("string"==typeof e.UserPubkey?OE.base64.decode(e.UserPubkey,t.UserPubkey=OE.newBuffer(OE.base64.length(e.UserPubkey)),0):e.UserPubkey.length>=0&&(t.UserPubkey=e.UserPubkey)),null!=e.startHeight&&(t.startHeight=e.startHeight>>>0),null!=e.direction&&(t.direction=e.direction>>>0),null!=e.offset&&(t.offset=e.offset>>>0),null!=e.limit&&(t.limit=e.limit>>>0),null!=e.seekKey&&("string"==typeof e.seekKey?OE.base64.decode(e.seekKey,t.seekKey=OE.newBuffer(OE.base64.length(e.seekKey)),0):e.seekKey.length>=0&&(t.seekKey=e.seekKey)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),null!=e.aesKey&&("string"==typeof e.aesKey?OE.base64.decode(e.aesKey,t.aesKey=OE.newBuffer(OE.base64.length(e.aesKey)),0):e.aesKey.length>=0&&(t.aesKey=e.aesKey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.UserPubkey="":(r.UserPubkey=[],t.bytes!==Array&&(r.UserPubkey=OE.newBuffer(r.UserPubkey))),r.startHeight=0,r.direction=0,r.offset=0,r.limit=0,t.bytes===String?r.seekKey="":(r.seekKey=[],t.bytes!==Array&&(r.seekKey=OE.newBuffer(r.seekKey))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount))),t.bytes===String?r.aesKey="":(r.aesKey=[],t.bytes!==Array&&(r.aesKey=OE.newBuffer(r.aesKey)))),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&(r.UserPubkey=t.bytes===String?OE.base64.encode(e.UserPubkey,0,e.UserPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.UserPubkey):e.UserPubkey),null!=e.startHeight&&e.hasOwnProperty("startHeight")&&(r.startHeight=e.startHeight),null!=e.direction&&e.hasOwnProperty("direction")&&(r.direction=e.direction),null!=e.offset&&e.hasOwnProperty("offset")&&(r.offset=e.offset),null!=e.limit&&e.hasOwnProperty("limit")&&(r.limit=e.limit),null!=e.seekKey&&e.hasOwnProperty("seekKey")&&(r.seekKey=t.bytes===String?OE.base64.encode(e.seekKey,0,e.seekKey.length):t.bytes===Array?Array.prototype.slice.call(e.seekKey):e.seekKey),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),null!=e.aesKey&&e.hasOwnProperty("aesKey")&&(r.aesKey=t.bytes===String?OE.base64.encode(e.aesKey,0,e.aesKey.length):t.bytes===Array?Array.prototype.slice.call(e.aesKey):e.aesKey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserCommentsRequest"},e}(),e.GetUserCommentsReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.commentsCid=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.commentsCid&&Object.hasOwnProperty.call(e,"commentsCid")&&t.uint32(18).bytes(e.commentsCid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserCommentsReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.commentsCid=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.commentsCid&&e.hasOwnProperty("commentsCid")&&!(e.commentsCid&&"number"==typeof e.commentsCid.length||OE.isString(e.commentsCid))?"commentsCid: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserCommentsReply)return e;var t=new AE.dcnet.pb.GetUserCommentsReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.commentsCid&&("string"==typeof e.commentsCid?OE.base64.decode(e.commentsCid,t.commentsCid=OE.newBuffer(OE.base64.length(e.commentsCid)),0):e.commentsCid.length>=0&&(t.commentsCid=e.commentsCid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.commentsCid="":(r.commentsCid=[],t.bytes!==Array&&(r.commentsCid=OE.newBuffer(r.commentsCid)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.commentsCid&&e.hasOwnProperty("commentsCid")&&(r.commentsCid=t.bytes===String?OE.base64.encode(e.commentsCid,0,e.commentsCid.length):t.bytes===Array?Array.prototype.slice.call(e.commentsCid):e.commentsCid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserCommentsReply"},e}(),e.GetValueWithKeyRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.UserPubkey=OE.newBuffer([]),e.prototype.Key=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.UserPubkey&&Object.hasOwnProperty.call(e,"UserPubkey")&&t.uint32(34).bytes(e.UserPubkey),null!=e.Key&&Object.hasOwnProperty.call(e,"Key")&&t.uint32(42).bytes(e.Key),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(50).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetValueWithKeyRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.UserPubkey=e.bytes();break;case 5:n.Key=e.bytes();break;case 6:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&!(e.UserPubkey&&"number"==typeof e.UserPubkey.length||OE.isString(e.UserPubkey))?"UserPubkey: buffer expected":null!=e.Key&&e.hasOwnProperty("Key")&&!(e.Key&&"number"==typeof e.Key.length||OE.isString(e.Key))?"Key: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetValueWithKeyRequest)return e;var t=new AE.dcnet.pb.GetValueWithKeyRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.UserPubkey&&("string"==typeof e.UserPubkey?OE.base64.decode(e.UserPubkey,t.UserPubkey=OE.newBuffer(OE.base64.length(e.UserPubkey)),0):e.UserPubkey.length>=0&&(t.UserPubkey=e.UserPubkey)),null!=e.Key&&("string"==typeof e.Key?OE.base64.decode(e.Key,t.Key=OE.newBuffer(OE.base64.length(e.Key)),0):e.Key.length>=0&&(t.Key=e.Key)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),t.bytes===String?r.UserPubkey="":(r.UserPubkey=[],t.bytes!==Array&&(r.UserPubkey=OE.newBuffer(r.UserPubkey))),t.bytes===String?r.Key="":(r.Key=[],t.bytes!==Array&&(r.Key=OE.newBuffer(r.Key))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&(r.UserPubkey=t.bytes===String?OE.base64.encode(e.UserPubkey,0,e.UserPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.UserPubkey):e.UserPubkey),null!=e.Key&&e.hasOwnProperty("Key")&&(r.Key=t.bytes===String?OE.base64.encode(e.Key,0,e.Key.length):t.bytes===Array?Array.prototype.slice.call(e.Key):e.Key),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetValueWithKeyRequest"},e}(),e.GetValueWithKeyReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.value=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.value&&Object.hasOwnProperty.call(e,"value")&&t.uint32(18).bytes(e.value),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetValueWithKeyReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.value=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.value&&e.hasOwnProperty("value")&&!(e.value&&"number"==typeof e.value.length||OE.isString(e.value))?"value: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetValueWithKeyReply)return e;var t=new AE.dcnet.pb.GetValueWithKeyReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.value&&("string"==typeof e.value?OE.base64.decode(e.value,t.value=OE.newBuffer(OE.base64.length(e.value)),0):e.value.length>=0&&(t.value=e.value)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.value="":(r.value=[],t.bytes!==Array&&(r.value=OE.newBuffer(r.value)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.value&&e.hasOwnProperty("value")&&(r.value=t.bytes===String?OE.base64.encode(e.value,0,e.value.length):t.bytes===Array?Array.prototype.slice.call(e.value):e.value),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetValueWithKeyReply"},e}(),e.GetValuesWithKeysRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.UserPubkey=OE.newBuffer([]),e.prototype.Keys=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.UserPubkey&&Object.hasOwnProperty.call(e,"UserPubkey")&&t.uint32(34).bytes(e.UserPubkey),null!=e.Keys&&Object.hasOwnProperty.call(e,"Keys")&&t.uint32(42).bytes(e.Keys),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(50).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetValuesWithKeysRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.UserPubkey=e.bytes();break;case 5:n.Keys=e.bytes();break;case 6:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&!(e.UserPubkey&&"number"==typeof e.UserPubkey.length||OE.isString(e.UserPubkey))?"UserPubkey: buffer expected":null!=e.Keys&&e.hasOwnProperty("Keys")&&!(e.Keys&&"number"==typeof e.Keys.length||OE.isString(e.Keys))?"Keys: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetValuesWithKeysRequest)return e;var t=new AE.dcnet.pb.GetValuesWithKeysRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.UserPubkey&&("string"==typeof e.UserPubkey?OE.base64.decode(e.UserPubkey,t.UserPubkey=OE.newBuffer(OE.base64.length(e.UserPubkey)),0):e.UserPubkey.length>=0&&(t.UserPubkey=e.UserPubkey)),null!=e.Keys&&("string"==typeof e.Keys?OE.base64.decode(e.Keys,t.Keys=OE.newBuffer(OE.base64.length(e.Keys)),0):e.Keys.length>=0&&(t.Keys=e.Keys)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),t.bytes===String?r.UserPubkey="":(r.UserPubkey=[],t.bytes!==Array&&(r.UserPubkey=OE.newBuffer(r.UserPubkey))),t.bytes===String?r.Keys="":(r.Keys=[],t.bytes!==Array&&(r.Keys=OE.newBuffer(r.Keys))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&(r.UserPubkey=t.bytes===String?OE.base64.encode(e.UserPubkey,0,e.UserPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.UserPubkey):e.UserPubkey),null!=e.Keys&&e.hasOwnProperty("Keys")&&(r.Keys=t.bytes===String?OE.base64.encode(e.Keys,0,e.Keys.length):t.bytes===Array?Array.prototype.slice.call(e.Keys):e.Keys),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetValuesWithKeysRequest"},e}(),e.GetValuesWithKeysReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.keyValues=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.keyValues&&Object.hasOwnProperty.call(e,"keyValues")&&t.uint32(18).bytes(e.keyValues),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetValuesWithKeysReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.keyValues=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.keyValues&&e.hasOwnProperty("keyValues")&&!(e.keyValues&&"number"==typeof e.keyValues.length||OE.isString(e.keyValues))?"keyValues: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetValuesWithKeysReply)return e;var t=new AE.dcnet.pb.GetValuesWithKeysReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.keyValues&&("string"==typeof e.keyValues?OE.base64.decode(e.keyValues,t.keyValues=OE.newBuffer(OE.base64.length(e.keyValues)),0):e.keyValues.length>=0&&(t.keyValues=e.keyValues)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.keyValues="":(r.keyValues=[],t.bytes!==Array&&(r.keyValues=OE.newBuffer(r.keyValues)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.keyValues&&e.hasOwnProperty("keyValues")&&(r.keyValues=t.bytes===String?OE.base64.encode(e.keyValues,0,e.keyValues.length):t.bytes===Array?Array.prototype.slice.call(e.keyValues):e.keyValues),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetValuesWithKeysReply"},e}(),e.PushThemeFunOptRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.opt=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.opt&&Object.hasOwnProperty.call(e,"opt")&&AE.dcnet.pb.CommentFunOpt.encode(e.opt,t.uint32(10).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.PushThemeFunOptRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.opt=AE.dcnet.pb.CommentFunOpt.decode(e,e.uint32()):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.opt&&e.hasOwnProperty("opt")){var t=AE.dcnet.pb.CommentFunOpt.verify(e.opt);if(t)return"opt."+t}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.PushThemeFunOptRequest)return e;var t=new AE.dcnet.pb.PushThemeFunOptRequest;if(null!=e.opt){if("object"!=typeof e.opt)throw TypeError(".dcnet.pb.PushThemeFunOptRequest.opt: object expected");t.opt=AE.dcnet.pb.CommentFunOpt.fromObject(e.opt)}return t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.opt=null),null!=e.opt&&e.hasOwnProperty("opt")&&(r.opt=AE.dcnet.pb.CommentFunOpt.toObject(e.opt,t)),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.PushThemeFunOptRequest"},e}(),e.PushThemeFunOptReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.PushThemeFunOptReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.PushThemeFunOptReply?e:new AE.dcnet.pb.PushThemeFunOptReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.PushThemeFunOptReply"},e}(),e.PullCommentFunOptsRequest=function(){function e(e){if(this.seqs=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.prototype.limit=0,e.prototype.seqs=OE.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),null!=e.limit&&Object.hasOwnProperty.call(e,"limit")&&t.uint32(16).uint32(e.limit),null!=e.seqs&&e.seqs.length)for(var r=0;r<e.seqs.length;++r)AE.dcnet.pb.peerSeqno.encode(e.seqs[r],t.uint32(26).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.PullCommentFunOptsRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.userPubkey=e.bytes();break;case 2:n.limit=e.uint32();break;case 3:n.seqs&&n.seqs.length||(n.seqs=[]),n.seqs.push(AE.dcnet.pb.peerSeqno.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey)))return"userPubkey: buffer expected";if(null!=e.limit&&e.hasOwnProperty("limit")&&!OE.isInteger(e.limit))return"limit: integer expected";if(null!=e.seqs&&e.hasOwnProperty("seqs")){if(!Array.isArray(e.seqs))return"seqs: array expected";for(var t=0;t<e.seqs.length;++t){var r=AE.dcnet.pb.peerSeqno.verify(e.seqs[t]);if(r)return"seqs."+r}}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.PullCommentFunOptsRequest)return e;var t=new AE.dcnet.pb.PullCommentFunOptsRequest;if(null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.limit&&(t.limit=e.limit>>>0),e.seqs){if(!Array.isArray(e.seqs))throw TypeError(".dcnet.pb.PullCommentFunOptsRequest.seqs: array expected");t.seqs=[];for(var r=0;r<e.seqs.length;++r){if("object"!=typeof e.seqs[r])throw TypeError(".dcnet.pb.PullCommentFunOptsRequest.seqs: object expected");t.seqs[r]=AE.dcnet.pb.peerSeqno.fromObject(e.seqs[r])}}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.seqs=[]),t.defaults&&(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),r.limit=0),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.limit&&e.hasOwnProperty("limit")&&(r.limit=e.limit),e.seqs&&e.seqs.length){r.seqs=[];for(var n=0;n<e.seqs.length;++n)r.seqs[n]=AE.dcnet.pb.peerSeqno.toObject(e.seqs[n],t)}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.PullCommentFunOptsRequest"},e}(),e.peerSeqno=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.peerid=OE.newBuffer([]),e.prototype.seqno=OE.Long?OE.Long.fromBits(0,0,!0):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(10).bytes(e.peerid),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(16).uint64(e.seqno),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.peerSeqno;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.peerid=e.bytes();break;case 2:n.seqno=e.uint64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.seqno&&e.hasOwnProperty("seqno")&&!(OE.isInteger(e.seqno)||e.seqno&&OE.isInteger(e.seqno.low)&&OE.isInteger(e.seqno.high))?"seqno: integer|Long expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.peerSeqno)return e;var t=new AE.dcnet.pb.peerSeqno;return null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.seqno&&(OE.Long?(t.seqno=OE.Long.fromValue(e.seqno)).unsigned=!0:"string"==typeof e.seqno?t.seqno=parseInt(e.seqno,10):"number"==typeof e.seqno?t.seqno=e.seqno:"object"==typeof e.seqno&&(t.seqno=new OE.LongBits(e.seqno.low>>>0,e.seqno.high>>>0).toNumber(!0))),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),OE.Long){var n=new OE.Long(0,0,!0);r.seqno=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.seqno=t.longs===String?"0":0;return null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.seqno&&e.hasOwnProperty("seqno")&&("number"==typeof e.seqno?r.seqno=t.longs===String?String(e.seqno):e.seqno:r.seqno=t.longs===String?OE.Long.prototype.toString.call(e.seqno):t.longs===Number?new OE.LongBits(e.seqno.low>>>0,e.seqno.high>>>0).toNumber(!0):e.seqno),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.peerSeqno"},e}(),e.PullCommentFunOptsReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.funcOptsCid=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.funcOptsCid&&Object.hasOwnProperty.call(e,"funcOptsCid")&&t.uint32(18).bytes(e.funcOptsCid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.PullCommentFunOptsReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.funcOptsCid=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.funcOptsCid&&e.hasOwnProperty("funcOptsCid")&&!(e.funcOptsCid&&"number"==typeof e.funcOptsCid.length||OE.isString(e.funcOptsCid))?"funcOptsCid: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.PullCommentFunOptsReply)return e;var t=new AE.dcnet.pb.PullCommentFunOptsReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.funcOptsCid&&("string"==typeof e.funcOptsCid?OE.base64.decode(e.funcOptsCid,t.funcOptsCid=OE.newBuffer(OE.base64.length(e.funcOptsCid)),0):e.funcOptsCid.length>=0&&(t.funcOptsCid=e.funcOptsCid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.funcOptsCid="":(r.funcOptsCid=[],t.bytes!==Array&&(r.funcOptsCid=OE.newBuffer(r.funcOptsCid)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.funcOptsCid&&e.hasOwnProperty("funcOptsCid")&&(r.funcOptsCid=t.bytes===String?OE.base64.encode(e.funcOptsCid,0,e.funcOptsCid.length):t.bytes===Array?Array.prototype.slice.call(e.funcOptsCid):e.funcOptsCid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.PullCommentFunOptsReply"},e}(),e.CommentFunOpt=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.prototype.seqno=OE.Long?OE.Long.fromBits(0,0,!0):0,e.prototype.peerid=OE.newBuffer([]),e.prototype.opType=0,e.prototype.opReq=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(16).uint64(e.seqno),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(26).bytes(e.peerid),null!=e.opType&&Object.hasOwnProperty.call(e,"opType")&&t.uint32(32).uint32(e.opType),null!=e.opReq&&Object.hasOwnProperty.call(e,"opReq")&&t.uint32(42).bytes(e.opReq),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.CommentFunOpt;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.userPubkey=e.bytes();break;case 2:n.seqno=e.uint64();break;case 3:n.peerid=e.bytes();break;case 4:n.opType=e.uint32();break;case 5:n.opReq=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.seqno&&e.hasOwnProperty("seqno")&&!(OE.isInteger(e.seqno)||e.seqno&&OE.isInteger(e.seqno.low)&&OE.isInteger(e.seqno.high))?"seqno: integer|Long expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.opType&&e.hasOwnProperty("opType")&&!OE.isInteger(e.opType)?"opType: integer expected":null!=e.opReq&&e.hasOwnProperty("opReq")&&!(e.opReq&&"number"==typeof e.opReq.length||OE.isString(e.opReq))?"opReq: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.CommentFunOpt)return e;var t=new AE.dcnet.pb.CommentFunOpt;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.seqno&&(OE.Long?(t.seqno=OE.Long.fromValue(e.seqno)).unsigned=!0:"string"==typeof e.seqno?t.seqno=parseInt(e.seqno,10):"number"==typeof e.seqno?t.seqno=e.seqno:"object"==typeof e.seqno&&(t.seqno=new OE.LongBits(e.seqno.low>>>0,e.seqno.high>>>0).toNumber(!0))),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.opType&&(t.opType=e.opType>>>0),null!=e.opReq&&("string"==typeof e.opReq?OE.base64.decode(e.opReq,t.opReq=OE.newBuffer(OE.base64.length(e.opReq)),0):e.opReq.length>=0&&(t.opReq=e.opReq)),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),OE.Long){var n=new OE.Long(0,0,!0);r.seqno=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.seqno=t.longs===String?"0":0;t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),r.opType=0,t.bytes===String?r.opReq="":(r.opReq=[],t.bytes!==Array&&(r.opReq=OE.newBuffer(r.opReq)))}return null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.seqno&&e.hasOwnProperty("seqno")&&("number"==typeof e.seqno?r.seqno=t.longs===String?String(e.seqno):e.seqno:r.seqno=t.longs===String?OE.Long.prototype.toString.call(e.seqno):t.longs===Number?new OE.LongBits(e.seqno.low>>>0,e.seqno.high>>>0).toNumber(!0):e.seqno),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.opType&&e.hasOwnProperty("opType")&&(r.opType=e.opType),null!=e.opReq&&e.hasOwnProperty("opReq")&&(r.opReq=t.bytes===String?OE.base64.encode(e.opReq,0,e.opReq.length):t.bytes===Array?Array.prototype.slice.call(e.opReq):e.opReq),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.CommentFunOpt"},e}(),e.ExchangeThemeEdgesRequest=function(){function e(e){if(this.userSeqEdges=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userSeqEdges=OE.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=SE.create()),null!=e.userSeqEdges&&e.userSeqEdges.length)for(var r=0;r<e.userSeqEdges.length;++r)AE.dcnet.pb.UserCommentSeqEdge.encode(e.userSeqEdges[r],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ExchangeThemeEdgesRequest;e.pos<r;){var o=e.uint32();o>>>3==1?(n.userSeqEdges&&n.userSeqEdges.length||(n.userSeqEdges=[]),n.userSeqEdges.push(AE.dcnet.pb.UserCommentSeqEdge.decode(e,e.uint32()))):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.userSeqEdges&&e.hasOwnProperty("userSeqEdges")){if(!Array.isArray(e.userSeqEdges))return"userSeqEdges: array expected";for(var t=0;t<e.userSeqEdges.length;++t){var r=AE.dcnet.pb.UserCommentSeqEdge.verify(e.userSeqEdges[t]);if(r)return"userSeqEdges."+r}}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ExchangeThemeEdgesRequest)return e;var t=new AE.dcnet.pb.ExchangeThemeEdgesRequest;if(e.userSeqEdges){if(!Array.isArray(e.userSeqEdges))throw TypeError(".dcnet.pb.ExchangeThemeEdgesRequest.userSeqEdges: array expected");t.userSeqEdges=[];for(var r=0;r<e.userSeqEdges.length;++r){if("object"!=typeof e.userSeqEdges[r])throw TypeError(".dcnet.pb.ExchangeThemeEdgesRequest.userSeqEdges: object expected");t.userSeqEdges[r]=AE.dcnet.pb.UserCommentSeqEdge.fromObject(e.userSeqEdges[r])}}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.userSeqEdges=[]),e.userSeqEdges&&e.userSeqEdges.length){r.userSeqEdges=[];for(var n=0;n<e.userSeqEdges.length;++n)r.userSeqEdges[n]=AE.dcnet.pb.UserCommentSeqEdge.toObject(e.userSeqEdges[n],t)}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ExchangeThemeEdgesRequest"},e}(),e.ExchangeThemeEdgesReply=function(){function e(e){if(this.userSeqEdges=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userSeqEdges=OE.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=SE.create()),null!=e.userSeqEdges&&e.userSeqEdges.length)for(var r=0;r<e.userSeqEdges.length;++r)AE.dcnet.pb.UserCommentSeqEdge.encode(e.userSeqEdges[r],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ExchangeThemeEdgesReply;e.pos<r;){var o=e.uint32();o>>>3==1?(n.userSeqEdges&&n.userSeqEdges.length||(n.userSeqEdges=[]),n.userSeqEdges.push(AE.dcnet.pb.UserCommentSeqEdge.decode(e,e.uint32()))):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.userSeqEdges&&e.hasOwnProperty("userSeqEdges")){if(!Array.isArray(e.userSeqEdges))return"userSeqEdges: array expected";for(var t=0;t<e.userSeqEdges.length;++t){var r=AE.dcnet.pb.UserCommentSeqEdge.verify(e.userSeqEdges[t]);if(r)return"userSeqEdges."+r}}return null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ExchangeThemeEdgesReply)return e;var t=new AE.dcnet.pb.ExchangeThemeEdgesReply;if(e.userSeqEdges){if(!Array.isArray(e.userSeqEdges))throw TypeError(".dcnet.pb.ExchangeThemeEdgesReply.userSeqEdges: array expected");t.userSeqEdges=[];for(var r=0;r<e.userSeqEdges.length;++r){if("object"!=typeof e.userSeqEdges[r])throw TypeError(".dcnet.pb.ExchangeThemeEdgesReply.userSeqEdges: object expected");t.userSeqEdges[r]=AE.dcnet.pb.UserCommentSeqEdge.fromObject(e.userSeqEdges[r])}}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.userSeqEdges=[]),e.userSeqEdges&&e.userSeqEdges.length){r.userSeqEdges=[];for(var n=0;n<e.userSeqEdges.length;++n)r.userSeqEdges[n]=AE.dcnet.pb.UserCommentSeqEdge.toObject(e.userSeqEdges[n],t)}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ExchangeThemeEdgesReply"},e}(),e.UserCommentSeqEdge=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.prototype.seqedge=OE.Long?OE.Long.fromBits(0,0,!0):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),null!=e.seqedge&&Object.hasOwnProperty.call(e,"seqedge")&&t.uint32(16).uint64(e.seqedge),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.UserCommentSeqEdge;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.userPubkey=e.bytes();break;case 2:n.seqedge=e.uint64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.seqedge&&e.hasOwnProperty("seqedge")&&!(OE.isInteger(e.seqedge)||e.seqedge&&OE.isInteger(e.seqedge.low)&&OE.isInteger(e.seqedge.high))?"seqedge: integer|Long expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.UserCommentSeqEdge)return e;var t=new AE.dcnet.pb.UserCommentSeqEdge;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.seqedge&&(OE.Long?(t.seqedge=OE.Long.fromValue(e.seqedge)).unsigned=!0:"string"==typeof e.seqedge?t.seqedge=parseInt(e.seqedge,10):"number"==typeof e.seqedge?t.seqedge=e.seqedge:"object"==typeof e.seqedge&&(t.seqedge=new OE.LongBits(e.seqedge.low>>>0,e.seqedge.high>>>0).toNumber(!0))),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),OE.Long){var n=new OE.Long(0,0,!0);r.seqedge=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.seqedge=t.longs===String?"0":0;return null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.seqedge&&e.hasOwnProperty("seqedge")&&("number"==typeof e.seqedge?r.seqedge=t.longs===String?String(e.seqedge):e.seqedge:r.seqedge=t.longs===String?OE.Long.prototype.toString.call(e.seqedge):t.longs===Number?new OE.LongBits(e.seqedge.low>>>0,e.seqedge.high>>>0).toNumber(!0):e.seqedge),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.UserCommentSeqEdge"},e}(),e.DownloadUserCommentsRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.teereport=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.teereport&&Object.hasOwnProperty.call(e,"teereport")&&t.uint32(34).bytes(e.teereport),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DownloadUserCommentsRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.userPubkey=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 4:n.teereport=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.teereport&&e.hasOwnProperty("teereport")&&!(e.teereport&&"number"==typeof e.teereport.length||OE.isString(e.teereport))?"teereport: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DownloadUserCommentsRequest)return e;var t=new AE.dcnet.pb.DownloadUserCommentsRequest;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.teereport&&("string"==typeof e.teereport?OE.base64.decode(e.teereport,t.teereport=OE.newBuffer(OE.base64.length(e.teereport)),0):e.teereport.length>=0&&(t.teereport=e.teereport)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),r.blockheight=0,t.bytes===String?r.teereport="":(r.teereport=[],t.bytes!==Array&&(r.teereport=OE.newBuffer(r.teereport)))),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.teereport&&e.hasOwnProperty("teereport")&&(r.teereport=t.bytes===String?OE.base64.encode(e.teereport,0,e.teereport.length):t.bytes===Array?Array.prototype.slice.call(e.teereport):e.teereport),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DownloadUserCommentsRequest"},e}(),e.DownloadUserCommentsReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DownloadUserCommentsReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DownloadUserCommentsReply)return e;var t=new AE.dcnet.pb.DownloadUserCommentsReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DownloadUserCommentsReply"},e}(),e.UserCommentsDownloadReadyRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.prototype.commentsCid=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.teereport=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),null!=e.commentsCid&&Object.hasOwnProperty.call(e,"commentsCid")&&t.uint32(18).bytes(e.commentsCid),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(24).uint32(e.blockheight),null!=e.teereport&&Object.hasOwnProperty.call(e,"teereport")&&t.uint32(34).bytes(e.teereport),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.UserCommentsDownloadReadyRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.userPubkey=e.bytes();break;case 2:n.commentsCid=e.bytes();break;case 3:n.blockheight=e.uint32();break;case 4:n.teereport=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.commentsCid&&e.hasOwnProperty("commentsCid")&&!(e.commentsCid&&"number"==typeof e.commentsCid.length||OE.isString(e.commentsCid))?"commentsCid: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.teereport&&e.hasOwnProperty("teereport")&&!(e.teereport&&"number"==typeof e.teereport.length||OE.isString(e.teereport))?"teereport: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.UserCommentsDownloadReadyRequest)return e;var t=new AE.dcnet.pb.UserCommentsDownloadReadyRequest;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.commentsCid&&("string"==typeof e.commentsCid?OE.base64.decode(e.commentsCid,t.commentsCid=OE.newBuffer(OE.base64.length(e.commentsCid)),0):e.commentsCid.length>=0&&(t.commentsCid=e.commentsCid)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.teereport&&("string"==typeof e.teereport?OE.base64.decode(e.teereport,t.teereport=OE.newBuffer(OE.base64.length(e.teereport)),0):e.teereport.length>=0&&(t.teereport=e.teereport)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.commentsCid="":(r.commentsCid=[],t.bytes!==Array&&(r.commentsCid=OE.newBuffer(r.commentsCid))),r.blockheight=0,t.bytes===String?r.teereport="":(r.teereport=[],t.bytes!==Array&&(r.teereport=OE.newBuffer(r.teereport)))),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.commentsCid&&e.hasOwnProperty("commentsCid")&&(r.commentsCid=t.bytes===String?OE.base64.encode(e.commentsCid,0,e.commentsCid.length):t.bytes===Array?Array.prototype.slice.call(e.commentsCid):e.commentsCid),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.teereport&&e.hasOwnProperty("teereport")&&(r.teereport=t.bytes===String?OE.base64.encode(e.teereport,0,e.teereport.length):t.bytes===Array?Array.prototype.slice.call(e.teereport):e.teereport),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.UserCommentsDownloadReadyRequest"},e}(),e.UserCommentsDownloadReadyReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.UserCommentsDownloadReadyReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.UserCommentsDownloadReadyReply?e:new AE.dcnet.pb.UserCommentsDownloadReadyReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.UserCommentsDownloadReadyReply"},e}(),e.DeviceStatusReportRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.seqno=0,e.prototype.deviceID=OE.newBuffer([]),e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.userPubkey=OE.newBuffer([]),e.prototype.type=0,e.prototype.contentHash=OE.newBuffer([]),e.prototype.content=OE.newBuffer([]),e.prototype.contentSize=0,e.prototype.blockheight=0,e.prototype.groups=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.prototype.rawReq=OE.newBuffer([]),e.prototype.resendcount=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(8).uint32(e.seqno),null!=e.deviceID&&Object.hasOwnProperty.call(e,"deviceID")&&t.uint32(18).bytes(e.deviceID),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(26).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(34).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(42).bytes(e.themeAuthor),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(50).bytes(e.userPubkey),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(56).uint32(e.type),null!=e.contentHash&&Object.hasOwnProperty.call(e,"contentHash")&&t.uint32(66).bytes(e.contentHash),null!=e.content&&Object.hasOwnProperty.call(e,"content")&&t.uint32(74).bytes(e.content),null!=e.contentSize&&Object.hasOwnProperty.call(e,"contentSize")&&t.uint32(80).uint32(e.contentSize),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(88).uint32(e.blockheight),null!=e.groups&&Object.hasOwnProperty.call(e,"groups")&&t.uint32(98).bytes(e.groups),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(106).bytes(e.signature),null!=e.rawReq&&Object.hasOwnProperty.call(e,"rawReq")&&t.uint32(114).bytes(e.rawReq),null!=e.resendcount&&Object.hasOwnProperty.call(e,"resendcount")&&t.uint32(120).uint32(e.resendcount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeviceStatusReportRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.seqno=e.uint32();break;case 2:n.deviceID=e.bytes();break;case 3:n.theme=e.bytes();break;case 4:n.appId=e.bytes();break;case 5:n.themeAuthor=e.bytes();break;case 6:n.userPubkey=e.bytes();break;case 7:n.type=e.uint32();break;case 8:n.contentHash=e.bytes();break;case 9:n.content=e.bytes();break;case 10:n.contentSize=e.uint32();break;case 11:n.blockheight=e.uint32();break;case 12:n.groups=e.bytes();break;case 13:n.signature=e.bytes();break;case 14:n.rawReq=e.bytes();break;case 15:n.resendcount=e.uint32();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.seqno&&e.hasOwnProperty("seqno")&&!OE.isInteger(e.seqno)?"seqno: integer expected":null!=e.deviceID&&e.hasOwnProperty("deviceID")&&!(e.deviceID&&"number"==typeof e.deviceID.length||OE.isString(e.deviceID))?"deviceID: buffer expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.type&&e.hasOwnProperty("type")&&!OE.isInteger(e.type)?"type: integer expected":null!=e.contentHash&&e.hasOwnProperty("contentHash")&&!(e.contentHash&&"number"==typeof e.contentHash.length||OE.isString(e.contentHash))?"contentHash: buffer expected":null!=e.content&&e.hasOwnProperty("content")&&!(e.content&&"number"==typeof e.content.length||OE.isString(e.content))?"content: buffer expected":null!=e.contentSize&&e.hasOwnProperty("contentSize")&&!OE.isInteger(e.contentSize)?"contentSize: integer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.groups&&e.hasOwnProperty("groups")&&!(e.groups&&"number"==typeof e.groups.length||OE.isString(e.groups))?"groups: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.rawReq&&e.hasOwnProperty("rawReq")&&!(e.rawReq&&"number"==typeof e.rawReq.length||OE.isString(e.rawReq))?"rawReq: buffer expected":null!=e.resendcount&&e.hasOwnProperty("resendcount")&&!OE.isInteger(e.resendcount)?"resendcount: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeviceStatusReportRequest)return e;var t=new AE.dcnet.pb.DeviceStatusReportRequest;return null!=e.seqno&&(t.seqno=e.seqno>>>0),null!=e.deviceID&&("string"==typeof e.deviceID?OE.base64.decode(e.deviceID,t.deviceID=OE.newBuffer(OE.base64.length(e.deviceID)),0):e.deviceID.length>=0&&(t.deviceID=e.deviceID)),null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.type&&(t.type=e.type>>>0),null!=e.contentHash&&("string"==typeof e.contentHash?OE.base64.decode(e.contentHash,t.contentHash=OE.newBuffer(OE.base64.length(e.contentHash)),0):e.contentHash.length>=0&&(t.contentHash=e.contentHash)),null!=e.content&&("string"==typeof e.content?OE.base64.decode(e.content,t.content=OE.newBuffer(OE.base64.length(e.content)),0):e.content.length>=0&&(t.content=e.content)),null!=e.contentSize&&(t.contentSize=e.contentSize>>>0),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.groups&&("string"==typeof e.groups?OE.base64.decode(e.groups,t.groups=OE.newBuffer(OE.base64.length(e.groups)),0):e.groups.length>=0&&(t.groups=e.groups)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.rawReq&&("string"==typeof e.rawReq?OE.base64.decode(e.rawReq,t.rawReq=OE.newBuffer(OE.base64.length(e.rawReq)),0):e.rawReq.length>=0&&(t.rawReq=e.rawReq)),null!=e.resendcount&&(t.resendcount=e.resendcount>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.seqno=0,t.bytes===String?r.deviceID="":(r.deviceID=[],t.bytes!==Array&&(r.deviceID=OE.newBuffer(r.deviceID))),t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),r.type=0,t.bytes===String?r.contentHash="":(r.contentHash=[],t.bytes!==Array&&(r.contentHash=OE.newBuffer(r.contentHash))),t.bytes===String?r.content="":(r.content=[],t.bytes!==Array&&(r.content=OE.newBuffer(r.content))),r.contentSize=0,r.blockheight=0,t.bytes===String?r.groups="":(r.groups=[],t.bytes!==Array&&(r.groups=OE.newBuffer(r.groups))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.rawReq="":(r.rawReq=[],t.bytes!==Array&&(r.rawReq=OE.newBuffer(r.rawReq))),r.resendcount=0),null!=e.seqno&&e.hasOwnProperty("seqno")&&(r.seqno=e.seqno),null!=e.deviceID&&e.hasOwnProperty("deviceID")&&(r.deviceID=t.bytes===String?OE.base64.encode(e.deviceID,0,e.deviceID.length):t.bytes===Array?Array.prototype.slice.call(e.deviceID):e.deviceID),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.type&&e.hasOwnProperty("type")&&(r.type=e.type),null!=e.contentHash&&e.hasOwnProperty("contentHash")&&(r.contentHash=t.bytes===String?OE.base64.encode(e.contentHash,0,e.contentHash.length):t.bytes===Array?Array.prototype.slice.call(e.contentHash):e.contentHash),null!=e.content&&e.hasOwnProperty("content")&&(r.content=t.bytes===String?OE.base64.encode(e.content,0,e.content.length):t.bytes===Array?Array.prototype.slice.call(e.content):e.content),null!=e.contentSize&&e.hasOwnProperty("contentSize")&&(r.contentSize=e.contentSize),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.groups&&e.hasOwnProperty("groups")&&(r.groups=t.bytes===String?OE.base64.encode(e.groups,0,e.groups.length):t.bytes===Array?Array.prototype.slice.call(e.groups):e.groups),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.rawReq&&e.hasOwnProperty("rawReq")&&(r.rawReq=t.bytes===String?OE.base64.encode(e.rawReq,0,e.rawReq.length):t.bytes===Array?Array.prototype.slice.call(e.rawReq):e.rawReq),null!=e.resendcount&&e.hasOwnProperty("resendcount")&&(r.resendcount=e.resendcount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeviceStatusReportRequest"},e}(),e.DeviceStatusReportReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeviceStatusReportReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeviceStatusReportReply)return e;var t=new AE.dcnet.pb.DeviceStatusReportReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeviceStatusReportReply"},e}(),e.GetThemeDevicesStatusRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.direction=0,e.prototype.offset=0,e.prototype.limit=0,e.prototype.seekKey=OE.newBuffer([]),e.prototype.groups=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.direction&&Object.hasOwnProperty.call(e,"direction")&&t.uint32(32).uint32(e.direction),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(40).uint32(e.offset),null!=e.limit&&Object.hasOwnProperty.call(e,"limit")&&t.uint32(48).uint32(e.limit),null!=e.seekKey&&Object.hasOwnProperty.call(e,"seekKey")&&t.uint32(58).bytes(e.seekKey),null!=e.groups&&Object.hasOwnProperty.call(e,"groups")&&t.uint32(66).bytes(e.groups),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThemeDevicesStatusRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.direction=e.uint32();break;case 5:n.offset=e.uint32();break;case 6:n.limit=e.uint32();break;case 7:n.seekKey=e.bytes();break;case 8:n.groups=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.direction&&e.hasOwnProperty("direction")&&!OE.isInteger(e.direction)?"direction: integer expected":null!=e.offset&&e.hasOwnProperty("offset")&&!OE.isInteger(e.offset)?"offset: integer expected":null!=e.limit&&e.hasOwnProperty("limit")&&!OE.isInteger(e.limit)?"limit: integer expected":null!=e.seekKey&&e.hasOwnProperty("seekKey")&&!(e.seekKey&&"number"==typeof e.seekKey.length||OE.isString(e.seekKey))?"seekKey: buffer expected":null!=e.groups&&e.hasOwnProperty("groups")&&!(e.groups&&"number"==typeof e.groups.length||OE.isString(e.groups))?"groups: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThemeDevicesStatusRequest)return e;var t=new AE.dcnet.pb.GetThemeDevicesStatusRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.direction&&(t.direction=e.direction>>>0),null!=e.offset&&(t.offset=e.offset>>>0),null!=e.limit&&(t.limit=e.limit>>>0),null!=e.seekKey&&("string"==typeof e.seekKey?OE.base64.decode(e.seekKey,t.seekKey=OE.newBuffer(OE.base64.length(e.seekKey)),0):e.seekKey.length>=0&&(t.seekKey=e.seekKey)),null!=e.groups&&("string"==typeof e.groups?OE.base64.decode(e.groups,t.groups=OE.newBuffer(OE.base64.length(e.groups)),0):e.groups.length>=0&&(t.groups=e.groups)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.direction=0,r.offset=0,r.limit=0,t.bytes===String?r.seekKey="":(r.seekKey=[],t.bytes!==Array&&(r.seekKey=OE.newBuffer(r.seekKey))),t.bytes===String?r.groups="":(r.groups=[],t.bytes!==Array&&(r.groups=OE.newBuffer(r.groups)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.direction&&e.hasOwnProperty("direction")&&(r.direction=e.direction),null!=e.offset&&e.hasOwnProperty("offset")&&(r.offset=e.offset),null!=e.limit&&e.hasOwnProperty("limit")&&(r.limit=e.limit),null!=e.seekKey&&e.hasOwnProperty("seekKey")&&(r.seekKey=t.bytes===String?OE.base64.encode(e.seekKey,0,e.seekKey.length):t.bytes===Array?Array.prototype.slice.call(e.seekKey):e.seekKey),null!=e.groups&&e.hasOwnProperty("groups")&&(r.groups=t.bytes===String?OE.base64.encode(e.groups,0,e.groups.length):t.bytes===Array?Array.prototype.slice.call(e.groups):e.groups),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThemeDevicesStatusRequest"},e}(),e.GetThemeDevicesStatusReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.statuslistCid=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.statuslistCid&&Object.hasOwnProperty.call(e,"statuslistCid")&&t.uint32(18).bytes(e.statuslistCid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetThemeDevicesStatusReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.statuslistCid=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.statuslistCid&&e.hasOwnProperty("statuslistCid")&&!(e.statuslistCid&&"number"==typeof e.statuslistCid.length||OE.isString(e.statuslistCid))?"statuslistCid: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetThemeDevicesStatusReply)return e;var t=new AE.dcnet.pb.GetThemeDevicesStatusReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.statuslistCid&&("string"==typeof e.statuslistCid?OE.base64.decode(e.statuslistCid,t.statuslistCid=OE.newBuffer(OE.base64.length(e.statuslistCid)),0):e.statuslistCid.length>=0&&(t.statuslistCid=e.statuslistCid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.statuslistCid="":(r.statuslistCid=[],t.bytes!==Array&&(r.statuslistCid=OE.newBuffer(r.statuslistCid)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.statuslistCid&&e.hasOwnProperty("statuslistCid")&&(r.statuslistCid=t.bytes===String?OE.base64.encode(e.statuslistCid,0,e.statuslistCid.length):t.bytes===Array?Array.prototype.slice.call(e.statuslistCid):e.statuslistCid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetThemeDevicesStatusReply"},e}(),e.GetDeviceAuthRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetDeviceAuthRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetDeviceAuthRequest)return e;var t=new AE.dcnet.pb.GetDeviceAuthRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetDeviceAuthRequest"},e}(),e.GetDeviceAuthReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.blockheight=0,e.prototype.authGroups=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.authGroups&&Object.hasOwnProperty.call(e,"authGroups")&&t.uint32(26).bytes(e.authGroups),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(34).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetDeviceAuthReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.blockheight=e.uint32();break;case 3:n.authGroups=e.bytes();break;case 4:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.authGroups&&e.hasOwnProperty("authGroups")&&!(e.authGroups&&"number"==typeof e.authGroups.length||OE.isString(e.authGroups))?"authGroups: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetDeviceAuthReply)return e;var t=new AE.dcnet.pb.GetDeviceAuthReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.authGroups&&("string"==typeof e.authGroups?OE.base64.decode(e.authGroups,t.authGroups=OE.newBuffer(OE.base64.length(e.authGroups)),0):e.authGroups.length>=0&&(t.authGroups=e.authGroups)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,r.blockheight=0,t.bytes===String?r.authGroups="":(r.authGroups=[],t.bytes!==Array&&(r.authGroups=OE.newBuffer(r.authGroups))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.authGroups&&e.hasOwnProperty("authGroups")&&(r.authGroups=t.bytes===String?OE.base64.encode(e.authGroups,0,e.authGroups.length):t.bytes===Array?Array.prototype.slice.call(e.authGroups):e.authGroups),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetDeviceAuthReply"},e}(),e.GetDeviceStatusListRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.deviceId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.UserPubkey=OE.newBuffer([]),e.prototype.seqno=0,e.prototype.startHeight=0,e.prototype.direction=0,e.prototype.offset=0,e.prototype.limit=0,e.prototype.seekKey=OE.newBuffer([]),e.prototype.authgroupspermission=OE.newBuffer([]),e.prototype.authBlockheight=0,e.prototype.authPeerid=OE.newBuffer([]),e.prototype.authSignature=OE.newBuffer([]),e.prototype.aesKey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.deviceId&&Object.hasOwnProperty.call(e,"deviceId")&&t.uint32(26).bytes(e.deviceId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(34).bytes(e.themeAuthor),null!=e.UserPubkey&&Object.hasOwnProperty.call(e,"UserPubkey")&&t.uint32(42).bytes(e.UserPubkey),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(48).uint32(e.seqno),null!=e.startHeight&&Object.hasOwnProperty.call(e,"startHeight")&&t.uint32(56).uint32(e.startHeight),null!=e.direction&&Object.hasOwnProperty.call(e,"direction")&&t.uint32(64).uint32(e.direction),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(72).uint32(e.offset),null!=e.limit&&Object.hasOwnProperty.call(e,"limit")&&t.uint32(80).uint32(e.limit),null!=e.seekKey&&Object.hasOwnProperty.call(e,"seekKey")&&t.uint32(90).bytes(e.seekKey),null!=e.authgroupspermission&&Object.hasOwnProperty.call(e,"authgroupspermission")&&t.uint32(98).bytes(e.authgroupspermission),null!=e.authBlockheight&&Object.hasOwnProperty.call(e,"authBlockheight")&&t.uint32(104).uint32(e.authBlockheight),null!=e.authPeerid&&Object.hasOwnProperty.call(e,"authPeerid")&&t.uint32(114).bytes(e.authPeerid),null!=e.authSignature&&Object.hasOwnProperty.call(e,"authSignature")&&t.uint32(122).bytes(e.authSignature),null!=e.aesKey&&Object.hasOwnProperty.call(e,"aesKey")&&t.uint32(130).bytes(e.aesKey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetDeviceStatusListRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.deviceId=e.bytes();break;case 4:n.themeAuthor=e.bytes();break;case 5:n.UserPubkey=e.bytes();break;case 6:n.seqno=e.uint32();break;case 7:n.startHeight=e.uint32();break;case 8:n.direction=e.uint32();break;case 9:n.offset=e.uint32();break;case 10:n.limit=e.uint32();break;case 11:n.seekKey=e.bytes();break;case 12:n.authgroupspermission=e.bytes();break;case 13:n.authBlockheight=e.uint32();break;case 14:n.authPeerid=e.bytes();break;case 15:n.authSignature=e.bytes();break;case 16:n.aesKey=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.deviceId&&e.hasOwnProperty("deviceId")&&!(e.deviceId&&"number"==typeof e.deviceId.length||OE.isString(e.deviceId))?"deviceId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&!(e.UserPubkey&&"number"==typeof e.UserPubkey.length||OE.isString(e.UserPubkey))?"UserPubkey: buffer expected":null!=e.seqno&&e.hasOwnProperty("seqno")&&!OE.isInteger(e.seqno)?"seqno: integer expected":null!=e.startHeight&&e.hasOwnProperty("startHeight")&&!OE.isInteger(e.startHeight)?"startHeight: integer expected":null!=e.direction&&e.hasOwnProperty("direction")&&!OE.isInteger(e.direction)?"direction: integer expected":null!=e.offset&&e.hasOwnProperty("offset")&&!OE.isInteger(e.offset)?"offset: integer expected":null!=e.limit&&e.hasOwnProperty("limit")&&!OE.isInteger(e.limit)?"limit: integer expected":null!=e.seekKey&&e.hasOwnProperty("seekKey")&&!(e.seekKey&&"number"==typeof e.seekKey.length||OE.isString(e.seekKey))?"seekKey: buffer expected":null!=e.authgroupspermission&&e.hasOwnProperty("authgroupspermission")&&!(e.authgroupspermission&&"number"==typeof e.authgroupspermission.length||OE.isString(e.authgroupspermission))?"authgroupspermission: buffer expected":null!=e.authBlockheight&&e.hasOwnProperty("authBlockheight")&&!OE.isInteger(e.authBlockheight)?"authBlockheight: integer expected":null!=e.authPeerid&&e.hasOwnProperty("authPeerid")&&!(e.authPeerid&&"number"==typeof e.authPeerid.length||OE.isString(e.authPeerid))?"authPeerid: buffer expected":null!=e.authSignature&&e.hasOwnProperty("authSignature")&&!(e.authSignature&&"number"==typeof e.authSignature.length||OE.isString(e.authSignature))?"authSignature: buffer expected":null!=e.aesKey&&e.hasOwnProperty("aesKey")&&!(e.aesKey&&"number"==typeof e.aesKey.length||OE.isString(e.aesKey))?"aesKey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetDeviceStatusListRequest)return e;var t=new AE.dcnet.pb.GetDeviceStatusListRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.deviceId&&("string"==typeof e.deviceId?OE.base64.decode(e.deviceId,t.deviceId=OE.newBuffer(OE.base64.length(e.deviceId)),0):e.deviceId.length>=0&&(t.deviceId=e.deviceId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.UserPubkey&&("string"==typeof e.UserPubkey?OE.base64.decode(e.UserPubkey,t.UserPubkey=OE.newBuffer(OE.base64.length(e.UserPubkey)),0):e.UserPubkey.length>=0&&(t.UserPubkey=e.UserPubkey)),null!=e.seqno&&(t.seqno=e.seqno>>>0),null!=e.startHeight&&(t.startHeight=e.startHeight>>>0),null!=e.direction&&(t.direction=e.direction>>>0),null!=e.offset&&(t.offset=e.offset>>>0),null!=e.limit&&(t.limit=e.limit>>>0),null!=e.seekKey&&("string"==typeof e.seekKey?OE.base64.decode(e.seekKey,t.seekKey=OE.newBuffer(OE.base64.length(e.seekKey)),0):e.seekKey.length>=0&&(t.seekKey=e.seekKey)),null!=e.authgroupspermission&&("string"==typeof e.authgroupspermission?OE.base64.decode(e.authgroupspermission,t.authgroupspermission=OE.newBuffer(OE.base64.length(e.authgroupspermission)),0):e.authgroupspermission.length>=0&&(t.authgroupspermission=e.authgroupspermission)),null!=e.authBlockheight&&(t.authBlockheight=e.authBlockheight>>>0),null!=e.authPeerid&&("string"==typeof e.authPeerid?OE.base64.decode(e.authPeerid,t.authPeerid=OE.newBuffer(OE.base64.length(e.authPeerid)),0):e.authPeerid.length>=0&&(t.authPeerid=e.authPeerid)),null!=e.authSignature&&("string"==typeof e.authSignature?OE.base64.decode(e.authSignature,t.authSignature=OE.newBuffer(OE.base64.length(e.authSignature)),0):e.authSignature.length>=0&&(t.authSignature=e.authSignature)),null!=e.aesKey&&("string"==typeof e.aesKey?OE.base64.decode(e.aesKey,t.aesKey=OE.newBuffer(OE.base64.length(e.aesKey)),0):e.aesKey.length>=0&&(t.aesKey=e.aesKey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.deviceId="":(r.deviceId=[],t.bytes!==Array&&(r.deviceId=OE.newBuffer(r.deviceId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),t.bytes===String?r.UserPubkey="":(r.UserPubkey=[],t.bytes!==Array&&(r.UserPubkey=OE.newBuffer(r.UserPubkey))),r.seqno=0,r.startHeight=0,r.direction=0,r.offset=0,r.limit=0,t.bytes===String?r.seekKey="":(r.seekKey=[],t.bytes!==Array&&(r.seekKey=OE.newBuffer(r.seekKey))),t.bytes===String?r.authgroupspermission="":(r.authgroupspermission=[],t.bytes!==Array&&(r.authgroupspermission=OE.newBuffer(r.authgroupspermission))),r.authBlockheight=0,t.bytes===String?r.authPeerid="":(r.authPeerid=[],t.bytes!==Array&&(r.authPeerid=OE.newBuffer(r.authPeerid))),t.bytes===String?r.authSignature="":(r.authSignature=[],t.bytes!==Array&&(r.authSignature=OE.newBuffer(r.authSignature))),t.bytes===String?r.aesKey="":(r.aesKey=[],t.bytes!==Array&&(r.aesKey=OE.newBuffer(r.aesKey)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.deviceId&&e.hasOwnProperty("deviceId")&&(r.deviceId=t.bytes===String?OE.base64.encode(e.deviceId,0,e.deviceId.length):t.bytes===Array?Array.prototype.slice.call(e.deviceId):e.deviceId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&(r.UserPubkey=t.bytes===String?OE.base64.encode(e.UserPubkey,0,e.UserPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.UserPubkey):e.UserPubkey),null!=e.seqno&&e.hasOwnProperty("seqno")&&(r.seqno=e.seqno),null!=e.startHeight&&e.hasOwnProperty("startHeight")&&(r.startHeight=e.startHeight),null!=e.direction&&e.hasOwnProperty("direction")&&(r.direction=e.direction),null!=e.offset&&e.hasOwnProperty("offset")&&(r.offset=e.offset),null!=e.limit&&e.hasOwnProperty("limit")&&(r.limit=e.limit),null!=e.seekKey&&e.hasOwnProperty("seekKey")&&(r.seekKey=t.bytes===String?OE.base64.encode(e.seekKey,0,e.seekKey.length):t.bytes===Array?Array.prototype.slice.call(e.seekKey):e.seekKey),null!=e.authgroupspermission&&e.hasOwnProperty("authgroupspermission")&&(r.authgroupspermission=t.bytes===String?OE.base64.encode(e.authgroupspermission,0,e.authgroupspermission.length):t.bytes===Array?Array.prototype.slice.call(e.authgroupspermission):e.authgroupspermission),null!=e.authBlockheight&&e.hasOwnProperty("authBlockheight")&&(r.authBlockheight=e.authBlockheight),null!=e.authPeerid&&e.hasOwnProperty("authPeerid")&&(r.authPeerid=t.bytes===String?OE.base64.encode(e.authPeerid,0,e.authPeerid.length):t.bytes===Array?Array.prototype.slice.call(e.authPeerid):e.authPeerid),null!=e.authSignature&&e.hasOwnProperty("authSignature")&&(r.authSignature=t.bytes===String?OE.base64.encode(e.authSignature,0,e.authSignature.length):t.bytes===Array?Array.prototype.slice.call(e.authSignature):e.authSignature),null!=e.aesKey&&e.hasOwnProperty("aesKey")&&(r.aesKey=t.bytes===String?OE.base64.encode(e.aesKey,0,e.aesKey.length):t.bytes===Array?Array.prototype.slice.call(e.aesKey):e.aesKey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetDeviceStatusListRequest"},e}(),e.GetDeviceStatusListReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.statuslistCid=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.statuslistCid&&Object.hasOwnProperty.call(e,"statuslistCid")&&t.uint32(18).bytes(e.statuslistCid),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetDeviceStatusListReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.statuslistCid=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.statuslistCid&&e.hasOwnProperty("statuslistCid")&&!(e.statuslistCid&&"number"==typeof e.statuslistCid.length||OE.isString(e.statuslistCid))?"statuslistCid: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetDeviceStatusListReply)return e;var t=new AE.dcnet.pb.GetDeviceStatusListReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.statuslistCid&&("string"==typeof e.statuslistCid?OE.base64.decode(e.statuslistCid,t.statuslistCid=OE.newBuffer(OE.base64.length(e.statuslistCid)),0):e.statuslistCid.length>=0&&(t.statuslistCid=e.statuslistCid)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.statuslistCid="":(r.statuslistCid=[],t.bytes!==Array&&(r.statuslistCid=OE.newBuffer(r.statuslistCid)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.statuslistCid&&e.hasOwnProperty("statuslistCid")&&(r.statuslistCid=t.bytes===String?OE.base64.encode(e.statuslistCid,0,e.statuslistCid.length):t.bytes===Array?Array.prototype.slice.call(e.statuslistCid):e.statuslistCid),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetDeviceStatusListReply"},e}(),e.ReEncryptFileRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.cid=OE.newBuffer([]),e.prototype.encDecryptKey=OE.newBuffer([]),e.prototype.encSecretkey=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(10).bytes(e.cid),null!=e.encDecryptKey&&Object.hasOwnProperty.call(e,"encDecryptKey")&&t.uint32(18).bytes(e.encDecryptKey),null!=e.encSecretkey&&Object.hasOwnProperty.call(e,"encSecretkey")&&t.uint32(26).bytes(e.encSecretkey),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(32).uint32(e.blockheight),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(42).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(50).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ReEncryptFileRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.cid=e.bytes();break;case 2:n.encDecryptKey=e.bytes();break;case 3:n.encSecretkey=e.bytes();break;case 4:n.blockheight=e.uint32();break;case 5:n.signature=e.bytes();break;case 6:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.cid&&e.hasOwnProperty("cid")&&!(e.cid&&"number"==typeof e.cid.length||OE.isString(e.cid))?"cid: buffer expected":null!=e.encDecryptKey&&e.hasOwnProperty("encDecryptKey")&&!(e.encDecryptKey&&"number"==typeof e.encDecryptKey.length||OE.isString(e.encDecryptKey))?"encDecryptKey: buffer expected":null!=e.encSecretkey&&e.hasOwnProperty("encSecretkey")&&!(e.encSecretkey&&"number"==typeof e.encSecretkey.length||OE.isString(e.encSecretkey))?"encSecretkey: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ReEncryptFileRequest)return e;var t=new AE.dcnet.pb.ReEncryptFileRequest;return null!=e.cid&&("string"==typeof e.cid?OE.base64.decode(e.cid,t.cid=OE.newBuffer(OE.base64.length(e.cid)),0):e.cid.length>=0&&(t.cid=e.cid)),null!=e.encDecryptKey&&("string"==typeof e.encDecryptKey?OE.base64.decode(e.encDecryptKey,t.encDecryptKey=OE.newBuffer(OE.base64.length(e.encDecryptKey)),0):e.encDecryptKey.length>=0&&(t.encDecryptKey=e.encDecryptKey)),null!=e.encSecretkey&&("string"==typeof e.encSecretkey?OE.base64.decode(e.encSecretkey,t.encSecretkey=OE.newBuffer(OE.base64.length(e.encSecretkey)),0):e.encSecretkey.length>=0&&(t.encSecretkey=e.encSecretkey)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.cid="":(r.cid=[],t.bytes!==Array&&(r.cid=OE.newBuffer(r.cid))),t.bytes===String?r.encDecryptKey="":(r.encDecryptKey=[],t.bytes!==Array&&(r.encDecryptKey=OE.newBuffer(r.encDecryptKey))),t.bytes===String?r.encSecretkey="":(r.encSecretkey=[],t.bytes!==Array&&(r.encSecretkey=OE.newBuffer(r.encSecretkey))),r.blockheight=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.cid&&e.hasOwnProperty("cid")&&(r.cid=t.bytes===String?OE.base64.encode(e.cid,0,e.cid.length):t.bytes===Array?Array.prototype.slice.call(e.cid):e.cid),null!=e.encDecryptKey&&e.hasOwnProperty("encDecryptKey")&&(r.encDecryptKey=t.bytes===String?OE.base64.encode(e.encDecryptKey,0,e.encDecryptKey.length):t.bytes===Array?Array.prototype.slice.call(e.encDecryptKey):e.encDecryptKey),null!=e.encSecretkey&&e.hasOwnProperty("encSecretkey")&&(r.encSecretkey=t.bytes===String?OE.base64.encode(e.encSecretkey,0,e.encSecretkey.length):t.bytes===Array?Array.prototype.slice.call(e.encSecretkey):e.encSecretkey),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ReEncryptFileRequest"},e}(),e.ReEncryptFileReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.cid=OE.newBuffer([]),e.prototype.fileSize=OE.Long?OE.Long.fromBits(0,0,!0):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.cid&&Object.hasOwnProperty.call(e,"cid")&&t.uint32(10).bytes(e.cid),null!=e.fileSize&&Object.hasOwnProperty.call(e,"fileSize")&&t.uint32(16).uint64(e.fileSize),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ReEncryptFileReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.cid=e.bytes();break;case 2:n.fileSize=e.uint64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.cid&&e.hasOwnProperty("cid")&&!(e.cid&&"number"==typeof e.cid.length||OE.isString(e.cid))?"cid: buffer expected":null!=e.fileSize&&e.hasOwnProperty("fileSize")&&!(OE.isInteger(e.fileSize)||e.fileSize&&OE.isInteger(e.fileSize.low)&&OE.isInteger(e.fileSize.high))?"fileSize: integer|Long expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ReEncryptFileReply)return e;var t=new AE.dcnet.pb.ReEncryptFileReply;return null!=e.cid&&("string"==typeof e.cid?OE.base64.decode(e.cid,t.cid=OE.newBuffer(OE.base64.length(e.cid)),0):e.cid.length>=0&&(t.cid=e.cid)),null!=e.fileSize&&(OE.Long?(t.fileSize=OE.Long.fromValue(e.fileSize)).unsigned=!0:"string"==typeof e.fileSize?t.fileSize=parseInt(e.fileSize,10):"number"==typeof e.fileSize?t.fileSize=e.fileSize:"object"==typeof e.fileSize&&(t.fileSize=new OE.LongBits(e.fileSize.low>>>0,e.fileSize.high>>>0).toNumber(!0))),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(t.bytes===String?r.cid="":(r.cid=[],t.bytes!==Array&&(r.cid=OE.newBuffer(r.cid))),OE.Long){var n=new OE.Long(0,0,!0);r.fileSize=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.fileSize=t.longs===String?"0":0;return null!=e.cid&&e.hasOwnProperty("cid")&&(r.cid=t.bytes===String?OE.base64.encode(e.cid,0,e.cid.length):t.bytes===Array?Array.prototype.slice.call(e.cid):e.cid),null!=e.fileSize&&e.hasOwnProperty("fileSize")&&("number"==typeof e.fileSize?r.fileSize=t.longs===String?String(e.fileSize):e.fileSize:r.fileSize=t.longs===String?OE.Long.prototype.toString.call(e.fileSize):t.longs===Number?new OE.LongBits(e.fileSize.low>>>0,e.fileSize.high>>>0).toNumber(!0):e.fileSize),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ReEncryptFileReply"},e}(),e.RequestRandDataRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.extradata=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.extradata&&Object.hasOwnProperty.call(e,"extradata")&&t.uint32(26).bytes(e.extradata),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(42).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.RequestRandDataRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.userPubkey=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.extradata=e.bytes();break;case 5:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.extradata&&e.hasOwnProperty("extradata")&&!(e.extradata&&"number"==typeof e.extradata.length||OE.isString(e.extradata))?"extradata: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.RequestRandDataRequest)return e;var t=new AE.dcnet.pb.RequestRandDataRequest;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.extradata&&("string"==typeof e.extradata?OE.base64.decode(e.extradata,t.extradata=OE.newBuffer(OE.base64.length(e.extradata)),0):e.extradata.length>=0&&(t.extradata=e.extradata)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),r.blockheight=0,t.bytes===String?r.extradata="":(r.extradata=[],t.bytes!==Array&&(r.extradata=OE.newBuffer(r.extradata))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.extradata&&e.hasOwnProperty("extradata")&&(r.extradata=t.bytes===String?OE.base64.encode(e.extradata,0,e.extradata.length):t.bytes===Array?Array.prototype.slice.call(e.extradata):e.extradata),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.RequestRandDataRequest"},e}(),e.RequestRandDataReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.prototype.randdata=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.extradata=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),null!=e.randdata&&Object.hasOwnProperty.call(e,"randdata")&&t.uint32(18).bytes(e.randdata),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(24).uint32(e.blockheight),null!=e.extradata&&Object.hasOwnProperty.call(e,"extradata")&&t.uint32(34).bytes(e.extradata),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(42).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.RequestRandDataReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.userPubkey=e.bytes();break;case 2:n.randdata=e.bytes();break;case 3:n.blockheight=e.uint32();break;case 4:n.extradata=e.bytes();break;case 5:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.randdata&&e.hasOwnProperty("randdata")&&!(e.randdata&&"number"==typeof e.randdata.length||OE.isString(e.randdata))?"randdata: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.extradata&&e.hasOwnProperty("extradata")&&!(e.extradata&&"number"==typeof e.extradata.length||OE.isString(e.extradata))?"extradata: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.RequestRandDataReply)return e;var t=new AE.dcnet.pb.RequestRandDataReply;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.randdata&&("string"==typeof e.randdata?OE.base64.decode(e.randdata,t.randdata=OE.newBuffer(OE.base64.length(e.randdata)),0):e.randdata.length>=0&&(t.randdata=e.randdata)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.extradata&&("string"==typeof e.extradata?OE.base64.decode(e.extradata,t.extradata=OE.newBuffer(OE.base64.length(e.extradata)),0):e.extradata.length>=0&&(t.extradata=e.extradata)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.randdata="":(r.randdata=[],t.bytes!==Array&&(r.randdata=OE.newBuffer(r.randdata))),r.blockheight=0,t.bytes===String?r.extradata="":(r.extradata=[],t.bytes!==Array&&(r.extradata=OE.newBuffer(r.extradata))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.randdata&&e.hasOwnProperty("randdata")&&(r.randdata=t.bytes===String?OE.base64.encode(e.randdata,0,e.randdata.length):t.bytes===Array?Array.prototype.slice.call(e.randdata):e.randdata),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.extradata&&e.hasOwnProperty("extradata")&&(r.extradata=t.bytes===String?OE.base64.encode(e.extradata,0,e.extradata.length):t.bytes===Array?Array.prototype.slice.call(e.extradata):e.extradata),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.RequestRandDataReply"},e}(),e.DeductUserOffChainOpTimesRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.deductType=0,e.prototype.rawReq=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.deductType&&Object.hasOwnProperty.call(e,"deductType")&&t.uint32(24).uint32(e.deductType),null!=e.rawReq&&Object.hasOwnProperty.call(e,"rawReq")&&t.uint32(34).bytes(e.rawReq),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeductUserOffChainOpTimesRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.userPubkey=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.deductType=e.uint32();break;case 4:n.rawReq=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.deductType&&e.hasOwnProperty("deductType")&&!OE.isInteger(e.deductType)?"deductType: integer expected":null!=e.rawReq&&e.hasOwnProperty("rawReq")&&!(e.rawReq&&"number"==typeof e.rawReq.length||OE.isString(e.rawReq))?"rawReq: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeductUserOffChainOpTimesRequest)return e;var t=new AE.dcnet.pb.DeductUserOffChainOpTimesRequest;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.deductType&&(t.deductType=e.deductType>>>0),null!=e.rawReq&&("string"==typeof e.rawReq?OE.base64.decode(e.rawReq,t.rawReq=OE.newBuffer(OE.base64.length(e.rawReq)),0):e.rawReq.length>=0&&(t.rawReq=e.rawReq)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),r.blockheight=0,r.deductType=0,t.bytes===String?r.rawReq="":(r.rawReq=[],t.bytes!==Array&&(r.rawReq=OE.newBuffer(r.rawReq)))),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.deductType&&e.hasOwnProperty("deductType")&&(r.deductType=e.deductType),null!=e.rawReq&&e.hasOwnProperty("rawReq")&&(r.rawReq=t.bytes===String?OE.base64.encode(e.rawReq,0,e.rawReq.length):t.bytes===Array?Array.prototype.slice.call(e.rawReq):e.rawReq),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeductUserOffChainOpTimesRequest"},e}(),e.DeductUserOffChainOpTimesReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeductUserOffChainOpTimesReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeductUserOffChainOpTimesReply)return e;var t=new AE.dcnet.pb.DeductUserOffChainOpTimesReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeductUserOffChainOpTimesReply"},e}(),e.DeductUserAIProxyOpTimesRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.theme=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(34).bytes(e.theme),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeductUserAIProxyOpTimesRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.userPubkey=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.theme=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeductUserAIProxyOpTimesRequest)return e;var t=new AE.dcnet.pb.DeductUserAIProxyOpTimesRequest;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme)))),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeductUserAIProxyOpTimesRequest"},e}(),e.DeductUserAIProxyOpTimesReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DeductUserAIProxyOpTimesReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DeductUserAIProxyOpTimesReply)return e;var t=new AE.dcnet.pb.DeductUserAIProxyOpTimesReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DeductUserAIProxyOpTimesReply"},e}(),e.GetAIProxyConfigFromPeerRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.UserPubkey=OE.newBuffer([]),e.prototype.edges=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.UserPubkey&&Object.hasOwnProperty.call(e,"UserPubkey")&&t.uint32(34).bytes(e.UserPubkey),null!=e.edges&&Object.hasOwnProperty.call(e,"edges")&&t.uint32(42).bytes(e.edges),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetAIProxyConfigFromPeerRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.UserPubkey=e.bytes();break;case 5:n.edges=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&!(e.UserPubkey&&"number"==typeof e.UserPubkey.length||OE.isString(e.UserPubkey))?"UserPubkey: buffer expected":null!=e.edges&&e.hasOwnProperty("edges")&&!(e.edges&&"number"==typeof e.edges.length||OE.isString(e.edges))?"edges: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetAIProxyConfigFromPeerRequest)return e;var t=new AE.dcnet.pb.GetAIProxyConfigFromPeerRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.UserPubkey&&("string"==typeof e.UserPubkey?OE.base64.decode(e.UserPubkey,t.UserPubkey=OE.newBuffer(OE.base64.length(e.UserPubkey)),0):e.UserPubkey.length>=0&&(t.UserPubkey=e.UserPubkey)),null!=e.edges&&("string"==typeof e.edges?OE.base64.decode(e.edges,t.edges=OE.newBuffer(OE.base64.length(e.edges)),0):e.edges.length>=0&&(t.edges=e.edges)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),t.bytes===String?r.UserPubkey="":(r.UserPubkey=[],t.bytes!==Array&&(r.UserPubkey=OE.newBuffer(r.UserPubkey))),t.bytes===String?r.edges="":(r.edges=[],t.bytes!==Array&&(r.edges=OE.newBuffer(r.edges)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.UserPubkey&&e.hasOwnProperty("UserPubkey")&&(r.UserPubkey=t.bytes===String?OE.base64.encode(e.UserPubkey,0,e.UserPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.UserPubkey):e.UserPubkey),null!=e.edges&&e.hasOwnProperty("edges")&&(r.edges=t.bytes===String?OE.base64.encode(e.edges,0,e.edges.length):t.bytes===Array?Array.prototype.slice.call(e.edges):e.edges),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetAIProxyConfigFromPeerRequest"},e}(),e.GetAIProxyConfigFromPeerReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.configInfo=OE.newBuffer([]),e.prototype.edges=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.configInfo&&Object.hasOwnProperty.call(e,"configInfo")&&t.uint32(18).bytes(e.configInfo),null!=e.edges&&Object.hasOwnProperty.call(e,"edges")&&t.uint32(26).bytes(e.edges),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetAIProxyConfigFromPeerReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.configInfo=e.bytes();break;case 3:n.edges=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.configInfo&&e.hasOwnProperty("configInfo")&&!(e.configInfo&&"number"==typeof e.configInfo.length||OE.isString(e.configInfo))?"configInfo: buffer expected":null!=e.edges&&e.hasOwnProperty("edges")&&!(e.edges&&"number"==typeof e.edges.length||OE.isString(e.edges))?"edges: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetAIProxyConfigFromPeerReply)return e;var t=new AE.dcnet.pb.GetAIProxyConfigFromPeerReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.configInfo&&("string"==typeof e.configInfo?OE.base64.decode(e.configInfo,t.configInfo=OE.newBuffer(OE.base64.length(e.configInfo)),0):e.configInfo.length>=0&&(t.configInfo=e.configInfo)),null!=e.edges&&("string"==typeof e.edges?OE.base64.decode(e.edges,t.edges=OE.newBuffer(OE.base64.length(e.edges)),0):e.edges.length>=0&&(t.edges=e.edges)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.configInfo="":(r.configInfo=[],t.bytes!==Array&&(r.configInfo=OE.newBuffer(r.configInfo))),t.bytes===String?r.edges="":(r.edges=[],t.bytes!==Array&&(r.edges=OE.newBuffer(r.edges)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.configInfo&&e.hasOwnProperty("configInfo")&&(r.configInfo=t.bytes===String?OE.base64.encode(e.configInfo,0,e.configInfo.length):t.bytes===Array?Array.prototype.slice.call(e.configInfo):e.configInfo),null!=e.edges&&e.hasOwnProperty("edges")&&(r.edges=t.bytes===String?OE.base64.encode(e.edges,0,e.edges.length):t.bytes===Array?Array.prototype.slice.call(e.edges):e.edges),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetAIProxyConfigFromPeerReply"},e}(),e.GetAIProxyConfigRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetAIProxyConfigRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetAIProxyConfigRequest)return e;var t=new AE.dcnet.pb.GetAIProxyConfigRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetAIProxyConfigRequest"},e}(),e.GetAIProxyConfigReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.proxyConfigCid=OE.newBuffer([]),e.prototype.aeskey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.proxyConfigCid&&Object.hasOwnProperty.call(e,"proxyConfigCid")&&t.uint32(18).bytes(e.proxyConfigCid),null!=e.aeskey&&Object.hasOwnProperty.call(e,"aeskey")&&t.uint32(26).bytes(e.aeskey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetAIProxyConfigReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.proxyConfigCid=e.bytes();break;case 3:n.aeskey=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.proxyConfigCid&&e.hasOwnProperty("proxyConfigCid")&&!(e.proxyConfigCid&&"number"==typeof e.proxyConfigCid.length||OE.isString(e.proxyConfigCid))?"proxyConfigCid: buffer expected":null!=e.aeskey&&e.hasOwnProperty("aeskey")&&!(e.aeskey&&"number"==typeof e.aeskey.length||OE.isString(e.aeskey))?"aeskey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetAIProxyConfigReply)return e;var t=new AE.dcnet.pb.GetAIProxyConfigReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.proxyConfigCid&&("string"==typeof e.proxyConfigCid?OE.base64.decode(e.proxyConfigCid,t.proxyConfigCid=OE.newBuffer(OE.base64.length(e.proxyConfigCid)),0):e.proxyConfigCid.length>=0&&(t.proxyConfigCid=e.proxyConfigCid)),null!=e.aeskey&&("string"==typeof e.aeskey?OE.base64.decode(e.aeskey,t.aeskey=OE.newBuffer(OE.base64.length(e.aeskey)),0):e.aeskey.length>=0&&(t.aeskey=e.aeskey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.proxyConfigCid="":(r.proxyConfigCid=[],t.bytes!==Array&&(r.proxyConfigCid=OE.newBuffer(r.proxyConfigCid))),t.bytes===String?r.aeskey="":(r.aeskey=[],t.bytes!==Array&&(r.aeskey=OE.newBuffer(r.aeskey)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.proxyConfigCid&&e.hasOwnProperty("proxyConfigCid")&&(r.proxyConfigCid=t.bytes===String?OE.base64.encode(e.proxyConfigCid,0,e.proxyConfigCid.length):t.bytes===Array?Array.prototype.slice.call(e.proxyConfigCid):e.proxyConfigCid),null!=e.aeskey&&e.hasOwnProperty("aeskey")&&(r.aeskey=t.bytes===String?OE.base64.encode(e.aeskey,0,e.aeskey.length):t.bytes===Array?Array.prototype.slice.call(e.aeskey):e.aeskey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetAIProxyConfigReply"},e}(),e.GetUserOwnAIProxyAuthRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserOwnAIProxyAuthRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserOwnAIProxyAuthRequest)return e;var t=new AE.dcnet.pb.GetUserOwnAIProxyAuthRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserOwnAIProxyAuthRequest"},e}(),e.GetUserOwnAIProxyAuthReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.authInfo=OE.newBuffer([]),e.prototype.configs=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.authInfo&&Object.hasOwnProperty.call(e,"authInfo")&&t.uint32(18).bytes(e.authInfo),null!=e.configs&&Object.hasOwnProperty.call(e,"configs")&&t.uint32(26).bytes(e.configs),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserOwnAIProxyAuthReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.authInfo=e.bytes();break;case 3:n.configs=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.authInfo&&e.hasOwnProperty("authInfo")&&!(e.authInfo&&"number"==typeof e.authInfo.length||OE.isString(e.authInfo))?"authInfo: buffer expected":null!=e.configs&&e.hasOwnProperty("configs")&&!(e.configs&&"number"==typeof e.configs.length||OE.isString(e.configs))?"configs: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserOwnAIProxyAuthReply)return e;var t=new AE.dcnet.pb.GetUserOwnAIProxyAuthReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.authInfo&&("string"==typeof e.authInfo?OE.base64.decode(e.authInfo,t.authInfo=OE.newBuffer(OE.base64.length(e.authInfo)),0):e.authInfo.length>=0&&(t.authInfo=e.authInfo)),null!=e.configs&&("string"==typeof e.configs?OE.base64.decode(e.configs,t.configs=OE.newBuffer(OE.base64.length(e.configs)),0):e.configs.length>=0&&(t.configs=e.configs)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.authInfo="":(r.authInfo=[],t.bytes!==Array&&(r.authInfo=OE.newBuffer(r.authInfo))),t.bytes===String?r.configs="":(r.configs=[],t.bytes!==Array&&(r.configs=OE.newBuffer(r.configs)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.authInfo&&e.hasOwnProperty("authInfo")&&(r.authInfo=t.bytes===String?OE.base64.encode(e.authInfo,0,e.authInfo.length):t.bytes===Array?Array.prototype.slice.call(e.authInfo):e.authInfo),null!=e.configs&&e.hasOwnProperty("configs")&&(r.configs=t.bytes===String?OE.base64.encode(e.configs,0,e.configs.length):t.bytes===Array?Array.prototype.slice.call(e.configs):e.configs),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserOwnAIProxyAuthReply"},e}(),e.DoAIProxyCallRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.configKey=OE.newBuffer([]),e.prototype.path=OE.newBuffer([]),e.prototype.reqBody=OE.newBuffer([]),e.prototype.modelConfig=OE.newBuffer([]),e.prototype.forceRefresh=0,e.prototype.headers=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(32).uint32(e.blockheight),null!=e.configKey&&Object.hasOwnProperty.call(e,"configKey")&&t.uint32(42).bytes(e.configKey),null!=e.path&&Object.hasOwnProperty.call(e,"path")&&t.uint32(50).bytes(e.path),null!=e.reqBody&&Object.hasOwnProperty.call(e,"reqBody")&&t.uint32(58).bytes(e.reqBody),null!=e.modelConfig&&Object.hasOwnProperty.call(e,"modelConfig")&&t.uint32(66).bytes(e.modelConfig),null!=e.forceRefresh&&Object.hasOwnProperty.call(e,"forceRefresh")&&t.uint32(72).uint32(e.forceRefresh),null!=e.headers&&Object.hasOwnProperty.call(e,"headers")&&t.uint32(82).bytes(e.headers),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(90).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DoAIProxyCallRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.blockheight=e.uint32();break;case 5:n.configKey=e.bytes();break;case 6:n.path=e.bytes();break;case 7:n.reqBody=e.bytes();break;case 8:n.modelConfig=e.bytes();break;case 9:n.forceRefresh=e.uint32();break;case 10:n.headers=e.bytes();break;case 11:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.configKey&&e.hasOwnProperty("configKey")&&!(e.configKey&&"number"==typeof e.configKey.length||OE.isString(e.configKey))?"configKey: buffer expected":null!=e.path&&e.hasOwnProperty("path")&&!(e.path&&"number"==typeof e.path.length||OE.isString(e.path))?"path: buffer expected":null!=e.reqBody&&e.hasOwnProperty("reqBody")&&!(e.reqBody&&"number"==typeof e.reqBody.length||OE.isString(e.reqBody))?"reqBody: buffer expected":null!=e.modelConfig&&e.hasOwnProperty("modelConfig")&&!(e.modelConfig&&"number"==typeof e.modelConfig.length||OE.isString(e.modelConfig))?"modelConfig: buffer expected":null!=e.forceRefresh&&e.hasOwnProperty("forceRefresh")&&!OE.isInteger(e.forceRefresh)?"forceRefresh: integer expected":null!=e.headers&&e.hasOwnProperty("headers")&&!(e.headers&&"number"==typeof e.headers.length||OE.isString(e.headers))?"headers: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DoAIProxyCallRequest)return e;var t=new AE.dcnet.pb.DoAIProxyCallRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.configKey&&("string"==typeof e.configKey?OE.base64.decode(e.configKey,t.configKey=OE.newBuffer(OE.base64.length(e.configKey)),0):e.configKey.length>=0&&(t.configKey=e.configKey)),null!=e.path&&("string"==typeof e.path?OE.base64.decode(e.path,t.path=OE.newBuffer(OE.base64.length(e.path)),0):e.path.length>=0&&(t.path=e.path)),null!=e.reqBody&&("string"==typeof e.reqBody?OE.base64.decode(e.reqBody,t.reqBody=OE.newBuffer(OE.base64.length(e.reqBody)),0):e.reqBody.length>=0&&(t.reqBody=e.reqBody)),null!=e.modelConfig&&("string"==typeof e.modelConfig?OE.base64.decode(e.modelConfig,t.modelConfig=OE.newBuffer(OE.base64.length(e.modelConfig)),0):e.modelConfig.length>=0&&(t.modelConfig=e.modelConfig)),null!=e.forceRefresh&&(t.forceRefresh=e.forceRefresh>>>0),null!=e.headers&&("string"==typeof e.headers?OE.base64.decode(e.headers,t.headers=OE.newBuffer(OE.base64.length(e.headers)),0):e.headers.length>=0&&(t.headers=e.headers)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.blockheight=0,t.bytes===String?r.configKey="":(r.configKey=[],t.bytes!==Array&&(r.configKey=OE.newBuffer(r.configKey))),t.bytes===String?r.path="":(r.path=[],t.bytes!==Array&&(r.path=OE.newBuffer(r.path))),t.bytes===String?r.reqBody="":(r.reqBody=[],t.bytes!==Array&&(r.reqBody=OE.newBuffer(r.reqBody))),t.bytes===String?r.modelConfig="":(r.modelConfig=[],t.bytes!==Array&&(r.modelConfig=OE.newBuffer(r.modelConfig))),r.forceRefresh=0,t.bytes===String?r.headers="":(r.headers=[],t.bytes!==Array&&(r.headers=OE.newBuffer(r.headers))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.configKey&&e.hasOwnProperty("configKey")&&(r.configKey=t.bytes===String?OE.base64.encode(e.configKey,0,e.configKey.length):t.bytes===Array?Array.prototype.slice.call(e.configKey):e.configKey),null!=e.path&&e.hasOwnProperty("path")&&(r.path=t.bytes===String?OE.base64.encode(e.path,0,e.path.length):t.bytes===Array?Array.prototype.slice.call(e.path):e.path),null!=e.reqBody&&e.hasOwnProperty("reqBody")&&(r.reqBody=t.bytes===String?OE.base64.encode(e.reqBody,0,e.reqBody.length):t.bytes===Array?Array.prototype.slice.call(e.reqBody):e.reqBody),null!=e.modelConfig&&e.hasOwnProperty("modelConfig")&&(r.modelConfig=t.bytes===String?OE.base64.encode(e.modelConfig,0,e.modelConfig.length):t.bytes===Array?Array.prototype.slice.call(e.modelConfig):e.modelConfig),null!=e.forceRefresh&&e.hasOwnProperty("forceRefresh")&&(r.forceRefresh=e.forceRefresh),null!=e.headers&&e.hasOwnProperty("headers")&&(r.headers=t.bytes===String?OE.base64.encode(e.headers,0,e.headers.length):t.bytes===Array?Array.prototype.slice.call(e.headers):e.headers),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DoAIProxyCallRequest"},e}(),e.DoAIProxyCallReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.content=OE.newBuffer([]),e.prototype.err=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.content&&Object.hasOwnProperty.call(e,"content")&&t.uint32(18).bytes(e.content),null!=e.err&&Object.hasOwnProperty.call(e,"err")&&t.uint32(26).bytes(e.err),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.DoAIProxyCallReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.content=e.bytes();break;case 3:n.err=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.content&&e.hasOwnProperty("content")&&!(e.content&&"number"==typeof e.content.length||OE.isString(e.content))?"content: buffer expected":null!=e.err&&e.hasOwnProperty("err")&&!(e.err&&"number"==typeof e.err.length||OE.isString(e.err))?"err: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.DoAIProxyCallReply)return e;var t=new AE.dcnet.pb.DoAIProxyCallReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.content&&("string"==typeof e.content?OE.base64.decode(e.content,t.content=OE.newBuffer(OE.base64.length(e.content)),0):e.content.length>=0&&(t.content=e.content)),null!=e.err&&("string"==typeof e.err?OE.base64.decode(e.err,t.err=OE.newBuffer(OE.base64.length(e.err)),0):e.err.length>=0&&(t.err=e.err)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.content="":(r.content=[],t.bytes!==Array&&(r.content=OE.newBuffer(r.content))),t.bytes===String?r.err="":(r.err=[],t.bytes!==Array&&(r.err=OE.newBuffer(r.err)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.content&&e.hasOwnProperty("content")&&(r.content=t.bytes===String?OE.base64.encode(e.content,0,e.content.length):t.bytes===Array?Array.prototype.slice.call(e.content):e.content),null!=e.err&&e.hasOwnProperty("err")&&(r.err=t.bytes===String?OE.base64.encode(e.err,0,e.err.length):t.bytes===Array?Array.prototype.slice.call(e.err):e.err),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.DoAIProxyCallReply"},e}(),e.CreateAIProxyCallTaskRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.configKey=OE.newBuffer([]),e.prototype.path=OE.newBuffer([]),e.prototype.reqBody=OE.newBuffer([]),e.prototype.continueReqs=OE.newBuffer([]),e.prototype.modelConfig=OE.newBuffer([]),e.prototype.forceRefresh=0,e.prototype.headers=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(10).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(18).bytes(e.appId),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(26).bytes(e.themeAuthor),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(32).uint32(e.blockheight),null!=e.configKey&&Object.hasOwnProperty.call(e,"configKey")&&t.uint32(42).bytes(e.configKey),null!=e.path&&Object.hasOwnProperty.call(e,"path")&&t.uint32(50).bytes(e.path),null!=e.reqBody&&Object.hasOwnProperty.call(e,"reqBody")&&t.uint32(58).bytes(e.reqBody),null!=e.continueReqs&&Object.hasOwnProperty.call(e,"continueReqs")&&t.uint32(66).bytes(e.continueReqs),null!=e.modelConfig&&Object.hasOwnProperty.call(e,"modelConfig")&&t.uint32(74).bytes(e.modelConfig),null!=e.forceRefresh&&Object.hasOwnProperty.call(e,"forceRefresh")&&t.uint32(80).uint32(e.forceRefresh),null!=e.headers&&Object.hasOwnProperty.call(e,"headers")&&t.uint32(90).bytes(e.headers),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(98).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.CreateAIProxyCallTaskRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.theme=e.bytes();break;case 2:n.appId=e.bytes();break;case 3:n.themeAuthor=e.bytes();break;case 4:n.blockheight=e.uint32();break;case 5:n.configKey=e.bytes();break;case 6:n.path=e.bytes();break;case 7:n.reqBody=e.bytes();break;case 8:n.continueReqs=e.bytes();break;case 9:n.modelConfig=e.bytes();break;case 10:n.forceRefresh=e.uint32();break;case 11:n.headers=e.bytes();break;case 12:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.configKey&&e.hasOwnProperty("configKey")&&!(e.configKey&&"number"==typeof e.configKey.length||OE.isString(e.configKey))?"configKey: buffer expected":null!=e.path&&e.hasOwnProperty("path")&&!(e.path&&"number"==typeof e.path.length||OE.isString(e.path))?"path: buffer expected":null!=e.reqBody&&e.hasOwnProperty("reqBody")&&!(e.reqBody&&"number"==typeof e.reqBody.length||OE.isString(e.reqBody))?"reqBody: buffer expected":null!=e.continueReqs&&e.hasOwnProperty("continueReqs")&&!(e.continueReqs&&"number"==typeof e.continueReqs.length||OE.isString(e.continueReqs))?"continueReqs: buffer expected":null!=e.modelConfig&&e.hasOwnProperty("modelConfig")&&!(e.modelConfig&&"number"==typeof e.modelConfig.length||OE.isString(e.modelConfig))?"modelConfig: buffer expected":null!=e.forceRefresh&&e.hasOwnProperty("forceRefresh")&&!OE.isInteger(e.forceRefresh)?"forceRefresh: integer expected":null!=e.headers&&e.hasOwnProperty("headers")&&!(e.headers&&"number"==typeof e.headers.length||OE.isString(e.headers))?"headers: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.CreateAIProxyCallTaskRequest)return e;var t=new AE.dcnet.pb.CreateAIProxyCallTaskRequest;return null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.configKey&&("string"==typeof e.configKey?OE.base64.decode(e.configKey,t.configKey=OE.newBuffer(OE.base64.length(e.configKey)),0):e.configKey.length>=0&&(t.configKey=e.configKey)),null!=e.path&&("string"==typeof e.path?OE.base64.decode(e.path,t.path=OE.newBuffer(OE.base64.length(e.path)),0):e.path.length>=0&&(t.path=e.path)),null!=e.reqBody&&("string"==typeof e.reqBody?OE.base64.decode(e.reqBody,t.reqBody=OE.newBuffer(OE.base64.length(e.reqBody)),0):e.reqBody.length>=0&&(t.reqBody=e.reqBody)),null!=e.continueReqs&&("string"==typeof e.continueReqs?OE.base64.decode(e.continueReqs,t.continueReqs=OE.newBuffer(OE.base64.length(e.continueReqs)),0):e.continueReqs.length>=0&&(t.continueReqs=e.continueReqs)),null!=e.modelConfig&&("string"==typeof e.modelConfig?OE.base64.decode(e.modelConfig,t.modelConfig=OE.newBuffer(OE.base64.length(e.modelConfig)),0):e.modelConfig.length>=0&&(t.modelConfig=e.modelConfig)),null!=e.forceRefresh&&(t.forceRefresh=e.forceRefresh>>>0),null!=e.headers&&("string"==typeof e.headers?OE.base64.decode(e.headers,t.headers=OE.newBuffer(OE.base64.length(e.headers)),0):e.headers.length>=0&&(t.headers=e.headers)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),r.blockheight=0,t.bytes===String?r.configKey="":(r.configKey=[],t.bytes!==Array&&(r.configKey=OE.newBuffer(r.configKey))),t.bytes===String?r.path="":(r.path=[],t.bytes!==Array&&(r.path=OE.newBuffer(r.path))),t.bytes===String?r.reqBody="":(r.reqBody=[],t.bytes!==Array&&(r.reqBody=OE.newBuffer(r.reqBody))),t.bytes===String?r.continueReqs="":(r.continueReqs=[],t.bytes!==Array&&(r.continueReqs=OE.newBuffer(r.continueReqs))),t.bytes===String?r.modelConfig="":(r.modelConfig=[],t.bytes!==Array&&(r.modelConfig=OE.newBuffer(r.modelConfig))),r.forceRefresh=0,t.bytes===String?r.headers="":(r.headers=[],t.bytes!==Array&&(r.headers=OE.newBuffer(r.headers))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.configKey&&e.hasOwnProperty("configKey")&&(r.configKey=t.bytes===String?OE.base64.encode(e.configKey,0,e.configKey.length):t.bytes===Array?Array.prototype.slice.call(e.configKey):e.configKey),null!=e.path&&e.hasOwnProperty("path")&&(r.path=t.bytes===String?OE.base64.encode(e.path,0,e.path.length):t.bytes===Array?Array.prototype.slice.call(e.path):e.path),null!=e.reqBody&&e.hasOwnProperty("reqBody")&&(r.reqBody=t.bytes===String?OE.base64.encode(e.reqBody,0,e.reqBody.length):t.bytes===Array?Array.prototype.slice.call(e.reqBody):e.reqBody),null!=e.continueReqs&&e.hasOwnProperty("continueReqs")&&(r.continueReqs=t.bytes===String?OE.base64.encode(e.continueReqs,0,e.continueReqs.length):t.bytes===Array?Array.prototype.slice.call(e.continueReqs):e.continueReqs),null!=e.modelConfig&&e.hasOwnProperty("modelConfig")&&(r.modelConfig=t.bytes===String?OE.base64.encode(e.modelConfig,0,e.modelConfig.length):t.bytes===Array?Array.prototype.slice.call(e.modelConfig):e.modelConfig),null!=e.forceRefresh&&e.hasOwnProperty("forceRefresh")&&(r.forceRefresh=e.forceRefresh),null!=e.headers&&e.hasOwnProperty("headers")&&(r.headers=t.bytes===String?OE.base64.encode(e.headers,0,e.headers.length):t.bytes===Array?Array.prototype.slice.call(e.headers):e.headers),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.CreateAIProxyCallTaskRequest"},e}(),e.CreateAIProxyCallTaskReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.taskId=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.taskId&&Object.hasOwnProperty.call(e,"taskId")&&t.uint32(18).bytes(e.taskId),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.CreateAIProxyCallTaskReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.taskId=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.taskId&&e.hasOwnProperty("taskId")&&!(e.taskId&&"number"==typeof e.taskId.length||OE.isString(e.taskId))?"taskId: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.CreateAIProxyCallTaskReply)return e;var t=new AE.dcnet.pb.CreateAIProxyCallTaskReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.taskId&&("string"==typeof e.taskId?OE.base64.decode(e.taskId,t.taskId=OE.newBuffer(OE.base64.length(e.taskId)),0):e.taskId.length>=0&&(t.taskId=e.taskId)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.taskId="":(r.taskId=[],t.bytes!==Array&&(r.taskId=OE.newBuffer(r.taskId)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.taskId&&e.hasOwnProperty("taskId")&&(r.taskId=t.bytes===String?OE.base64.encode(e.taskId,0,e.taskId.length):t.bytes===Array?Array.prototype.slice.call(e.taskId):e.taskId),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.CreateAIProxyCallTaskReply"},e}(),e.GetAIProxyCallTaskResultRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.taskId=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.taskId&&Object.hasOwnProperty.call(e,"taskId")&&t.uint32(10).bytes(e.taskId),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetAIProxyCallTaskResultRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.taskId=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.taskId&&e.hasOwnProperty("taskId")&&!(e.taskId&&"number"==typeof e.taskId.length||OE.isString(e.taskId))?"taskId: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetAIProxyCallTaskResultRequest)return e;var t=new AE.dcnet.pb.GetAIProxyCallTaskResultRequest;return null!=e.taskId&&("string"==typeof e.taskId?OE.base64.decode(e.taskId,t.taskId=OE.newBuffer(OE.base64.length(e.taskId)),0):e.taskId.length>=0&&(t.taskId=e.taskId)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.taskId="":(r.taskId=[],t.bytes!==Array&&(r.taskId=OE.newBuffer(r.taskId)))),null!=e.taskId&&e.hasOwnProperty("taskId")&&(r.taskId=t.bytes===String?OE.base64.encode(e.taskId,0,e.taskId.length):t.bytes===Array?Array.prototype.slice.call(e.taskId):e.taskId),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetAIProxyCallTaskResultRequest"},e}(),e.GetAIProxyCallTaskResultReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.content=OE.newBuffer([]),e.prototype.err=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.content&&Object.hasOwnProperty.call(e,"content")&&t.uint32(18).bytes(e.content),null!=e.err&&Object.hasOwnProperty.call(e,"err")&&t.uint32(26).bytes(e.err),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetAIProxyCallTaskResultReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.content=e.bytes();break;case 3:n.err=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.content&&e.hasOwnProperty("content")&&!(e.content&&"number"==typeof e.content.length||OE.isString(e.content))?"content: buffer expected":null!=e.err&&e.hasOwnProperty("err")&&!(e.err&&"number"==typeof e.err.length||OE.isString(e.err))?"err: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetAIProxyCallTaskResultReply)return e;var t=new AE.dcnet.pb.GetAIProxyCallTaskResultReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.content&&("string"==typeof e.content?OE.base64.decode(e.content,t.content=OE.newBuffer(OE.base64.length(e.content)),0):e.content.length>=0&&(t.content=e.content)),null!=e.err&&("string"==typeof e.err?OE.base64.decode(e.err,t.err=OE.newBuffer(OE.base64.length(e.err)),0):e.err.length>=0&&(t.err=e.err)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0,t.bytes===String?r.content="":(r.content=[],t.bytes!==Array&&(r.content=OE.newBuffer(r.content))),t.bytes===String?r.err="":(r.err=[],t.bytes!==Array&&(r.err=OE.newBuffer(r.err)))),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.content&&e.hasOwnProperty("content")&&(r.content=t.bytes===String?OE.base64.encode(e.content,0,e.content.length):t.bytes===Array?Array.prototype.slice.call(e.content):e.content),null!=e.err&&e.hasOwnProperty("err")&&(r.err=t.bytes===String?OE.base64.encode(e.err,0,e.err.length):t.bytes===Array?Array.prototype.slice.call(e.err):e.err),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetAIProxyCallTaskResultReply"},e}(),e.ArchiveDeviceStatusRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.deviceID=OE.newBuffer([]),e.prototype.themeAuthor=OE.newBuffer([]),e.prototype.theme=OE.newBuffer([]),e.prototype.appId=OE.newBuffer([]),e.prototype.startSeqno=0,e.prototype.endSeqno=0,e.prototype.blockheight=0,e.prototype.encSecretkey=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.deviceID&&Object.hasOwnProperty.call(e,"deviceID")&&t.uint32(10).bytes(e.deviceID),null!=e.themeAuthor&&Object.hasOwnProperty.call(e,"themeAuthor")&&t.uint32(18).bytes(e.themeAuthor),null!=e.theme&&Object.hasOwnProperty.call(e,"theme")&&t.uint32(26).bytes(e.theme),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(34).bytes(e.appId),null!=e.startSeqno&&Object.hasOwnProperty.call(e,"startSeqno")&&t.uint32(40).uint32(e.startSeqno),null!=e.endSeqno&&Object.hasOwnProperty.call(e,"endSeqno")&&t.uint32(48).uint32(e.endSeqno),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(56).uint32(e.blockheight),null!=e.encSecretkey&&Object.hasOwnProperty.call(e,"encSecretkey")&&t.uint32(66).bytes(e.encSecretkey),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(74).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ArchiveDeviceStatusRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.deviceID=e.bytes();break;case 2:n.themeAuthor=e.bytes();break;case 3:n.theme=e.bytes();break;case 4:n.appId=e.bytes();break;case 5:n.startSeqno=e.uint32();break;case 6:n.endSeqno=e.uint32();break;case 7:n.blockheight=e.uint32();break;case 8:n.encSecretkey=e.bytes();break;case 9:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.deviceID&&e.hasOwnProperty("deviceID")&&!(e.deviceID&&"number"==typeof e.deviceID.length||OE.isString(e.deviceID))?"deviceID: buffer expected":null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&!(e.themeAuthor&&"number"==typeof e.themeAuthor.length||OE.isString(e.themeAuthor))?"themeAuthor: buffer expected":null!=e.theme&&e.hasOwnProperty("theme")&&!(e.theme&&"number"==typeof e.theme.length||OE.isString(e.theme))?"theme: buffer expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.startSeqno&&e.hasOwnProperty("startSeqno")&&!OE.isInteger(e.startSeqno)?"startSeqno: integer expected":null!=e.endSeqno&&e.hasOwnProperty("endSeqno")&&!OE.isInteger(e.endSeqno)?"endSeqno: integer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.encSecretkey&&e.hasOwnProperty("encSecretkey")&&!(e.encSecretkey&&"number"==typeof e.encSecretkey.length||OE.isString(e.encSecretkey))?"encSecretkey: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ArchiveDeviceStatusRequest)return e;var t=new AE.dcnet.pb.ArchiveDeviceStatusRequest;return null!=e.deviceID&&("string"==typeof e.deviceID?OE.base64.decode(e.deviceID,t.deviceID=OE.newBuffer(OE.base64.length(e.deviceID)),0):e.deviceID.length>=0&&(t.deviceID=e.deviceID)),null!=e.themeAuthor&&("string"==typeof e.themeAuthor?OE.base64.decode(e.themeAuthor,t.themeAuthor=OE.newBuffer(OE.base64.length(e.themeAuthor)),0):e.themeAuthor.length>=0&&(t.themeAuthor=e.themeAuthor)),null!=e.theme&&("string"==typeof e.theme?OE.base64.decode(e.theme,t.theme=OE.newBuffer(OE.base64.length(e.theme)),0):e.theme.length>=0&&(t.theme=e.theme)),null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.startSeqno&&(t.startSeqno=e.startSeqno>>>0),null!=e.endSeqno&&(t.endSeqno=e.endSeqno>>>0),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.encSecretkey&&("string"==typeof e.encSecretkey?OE.base64.decode(e.encSecretkey,t.encSecretkey=OE.newBuffer(OE.base64.length(e.encSecretkey)),0):e.encSecretkey.length>=0&&(t.encSecretkey=e.encSecretkey)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.deviceID="":(r.deviceID=[],t.bytes!==Array&&(r.deviceID=OE.newBuffer(r.deviceID))),t.bytes===String?r.themeAuthor="":(r.themeAuthor=[],t.bytes!==Array&&(r.themeAuthor=OE.newBuffer(r.themeAuthor))),t.bytes===String?r.theme="":(r.theme=[],t.bytes!==Array&&(r.theme=OE.newBuffer(r.theme))),t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),r.startSeqno=0,r.endSeqno=0,r.blockheight=0,t.bytes===String?r.encSecretkey="":(r.encSecretkey=[],t.bytes!==Array&&(r.encSecretkey=OE.newBuffer(r.encSecretkey))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.deviceID&&e.hasOwnProperty("deviceID")&&(r.deviceID=t.bytes===String?OE.base64.encode(e.deviceID,0,e.deviceID.length):t.bytes===Array?Array.prototype.slice.call(e.deviceID):e.deviceID),null!=e.themeAuthor&&e.hasOwnProperty("themeAuthor")&&(r.themeAuthor=t.bytes===String?OE.base64.encode(e.themeAuthor,0,e.themeAuthor.length):t.bytes===Array?Array.prototype.slice.call(e.themeAuthor):e.themeAuthor),null!=e.theme&&e.hasOwnProperty("theme")&&(r.theme=t.bytes===String?OE.base64.encode(e.theme,0,e.theme.length):t.bytes===Array?Array.prototype.slice.call(e.theme):e.theme),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.startSeqno&&e.hasOwnProperty("startSeqno")&&(r.startSeqno=e.startSeqno),null!=e.endSeqno&&e.hasOwnProperty("endSeqno")&&(r.endSeqno=e.endSeqno),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.encSecretkey&&e.hasOwnProperty("encSecretkey")&&(r.encSecretkey=t.bytes===String?OE.base64.encode(e.encSecretkey,0,e.encSecretkey.length):t.bytes===Array?Array.prototype.slice.call(e.encSecretkey):e.encSecretkey),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ArchiveDeviceStatusRequest"},e}(),e.ArchiveDeviceStatusReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.prototype.statusCid=OE.newBuffer([]),e.prototype.statusCount=0,e.prototype.statusSize=OE.Long?OE.Long.fromBits(0,0,!0):0,e.prototype.blockheight=0,e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),null!=e.statusCid&&Object.hasOwnProperty.call(e,"statusCid")&&t.uint32(18).bytes(e.statusCid),null!=e.statusCount&&Object.hasOwnProperty.call(e,"statusCount")&&t.uint32(24).uint32(e.statusCount),null!=e.statusSize&&Object.hasOwnProperty.call(e,"statusSize")&&t.uint32(32).uint64(e.statusSize),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(40).uint32(e.blockheight),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(50).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.ArchiveDeviceStatusReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.flag=e.uint32();break;case 2:n.statusCid=e.bytes();break;case 3:n.statusCount=e.uint32();break;case 4:n.statusSize=e.uint64();break;case 5:n.blockheight=e.uint32();break;case 6:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null!=e.statusCid&&e.hasOwnProperty("statusCid")&&!(e.statusCid&&"number"==typeof e.statusCid.length||OE.isString(e.statusCid))?"statusCid: buffer expected":null!=e.statusCount&&e.hasOwnProperty("statusCount")&&!OE.isInteger(e.statusCount)?"statusCount: integer expected":null!=e.statusSize&&e.hasOwnProperty("statusSize")&&!(OE.isInteger(e.statusSize)||e.statusSize&&OE.isInteger(e.statusSize.low)&&OE.isInteger(e.statusSize.high))?"statusSize: integer|Long expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.ArchiveDeviceStatusReply)return e;var t=new AE.dcnet.pb.ArchiveDeviceStatusReply;return null!=e.flag&&(t.flag=e.flag>>>0),null!=e.statusCid&&("string"==typeof e.statusCid?OE.base64.decode(e.statusCid,t.statusCid=OE.newBuffer(OE.base64.length(e.statusCid)),0):e.statusCid.length>=0&&(t.statusCid=e.statusCid)),null!=e.statusCount&&(t.statusCount=e.statusCount>>>0),null!=e.statusSize&&(OE.Long?(t.statusSize=OE.Long.fromValue(e.statusSize)).unsigned=!0:"string"==typeof e.statusSize?t.statusSize=parseInt(e.statusSize,10):"number"==typeof e.statusSize?t.statusSize=e.statusSize:"object"==typeof e.statusSize&&(t.statusSize=new OE.LongBits(e.statusSize.low>>>0,e.statusSize.high>>>0).toNumber(!0))),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(r.flag=0,t.bytes===String?r.statusCid="":(r.statusCid=[],t.bytes!==Array&&(r.statusCid=OE.newBuffer(r.statusCid))),r.statusCount=0,OE.Long){var n=new OE.Long(0,0,!0);r.statusSize=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.statusSize=t.longs===String?"0":0;r.blockheight=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))}return null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),null!=e.statusCid&&e.hasOwnProperty("statusCid")&&(r.statusCid=t.bytes===String?OE.base64.encode(e.statusCid,0,e.statusCid.length):t.bytes===Array?Array.prototype.slice.call(e.statusCid):e.statusCid),null!=e.statusCount&&e.hasOwnProperty("statusCount")&&(r.statusCount=e.statusCount),null!=e.statusSize&&e.hasOwnProperty("statusSize")&&("number"==typeof e.statusSize?r.statusSize=t.longs===String?String(e.statusSize):e.statusSize:r.statusSize=t.longs===String?OE.Long.prototype.toString.call(e.statusSize):t.longs===Number?new OE.LongBits(e.statusSize.low>>>0,e.statusSize.high>>>0).toNumber(!0):e.statusSize),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.ArchiveDeviceStatusReply"},e}(),e.AddUserOffChainOpTimesRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.peerid=OE.newBuffer([]),e.prototype.times=0,e.prototype.signature=OE.newBuffer([]),e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(16).uint32(e.blockheight),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(26).bytes(e.peerid),null!=e.times&&Object.hasOwnProperty.call(e,"times")&&t.uint32(32).uint32(e.times),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(42).bytes(e.signature),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(50).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddUserOffChainOpTimesRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.userPubkey=e.bytes();break;case 2:n.blockheight=e.uint32();break;case 3:n.peerid=e.bytes();break;case 4:n.times=e.uint32();break;case 5:n.signature=e.bytes();break;case 6:n.vaccount=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.times&&e.hasOwnProperty("times")&&!OE.isInteger(e.times)?"times: integer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddUserOffChainOpTimesRequest)return e;var t=new AE.dcnet.pb.AddUserOffChainOpTimesRequest;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.times&&(t.times=e.times>>>0),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey))),r.blockheight=0,t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),r.times=0,t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature))),t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.times&&e.hasOwnProperty("times")&&(r.times=e.times),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddUserOffChainOpTimesRequest"},e}(),e.AddUserOffChainOpTimesReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.flag=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).uint32(e.flag),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.AddUserOffChainOpTimesReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.flag=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!OE.isInteger(e.flag)?"flag: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.AddUserOffChainOpTimesReply)return e;var t=new AE.dcnet.pb.AddUserOffChainOpTimesReply;return null!=e.flag&&(t.flag=e.flag>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.flag=0),null!=e.flag&&e.hasOwnProperty("flag")&&(r.flag=e.flag),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.AddUserOffChainOpTimesReply"},e}(),e.GetUserOffChainOpTimesRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.userPubkey=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.userPubkey&&Object.hasOwnProperty.call(e,"userPubkey")&&t.uint32(10).bytes(e.userPubkey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserOffChainOpTimesRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.userPubkey=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&!(e.userPubkey&&"number"==typeof e.userPubkey.length||OE.isString(e.userPubkey))?"userPubkey: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserOffChainOpTimesRequest)return e;var t=new AE.dcnet.pb.GetUserOffChainOpTimesRequest;return null!=e.userPubkey&&("string"==typeof e.userPubkey?OE.base64.decode(e.userPubkey,t.userPubkey=OE.newBuffer(OE.base64.length(e.userPubkey)),0):e.userPubkey.length>=0&&(t.userPubkey=e.userPubkey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.userPubkey="":(r.userPubkey=[],t.bytes!==Array&&(r.userPubkey=OE.newBuffer(r.userPubkey)))),null!=e.userPubkey&&e.hasOwnProperty("userPubkey")&&(r.userPubkey=t.bytes===String?OE.base64.encode(e.userPubkey,0,e.userPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.userPubkey):e.userPubkey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserOffChainOpTimesRequest"},e}(),e.GetUserOffChainOpTimesReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.usedtimes=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.usedtimes&&Object.hasOwnProperty.call(e,"usedtimes")&&t.uint32(8).uint32(e.usedtimes),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserOffChainOpTimesReply;e.pos<r;){var o=e.uint32();o>>>3==1?n.usedtimes=e.uint32():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.usedtimes&&e.hasOwnProperty("usedtimes")&&!OE.isInteger(e.usedtimes)?"usedtimes: integer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserOffChainOpTimesReply)return e;var t=new AE.dcnet.pb.GetUserOffChainOpTimesReply;return null!=e.usedtimes&&(t.usedtimes=e.usedtimes>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.usedtimes=0),null!=e.usedtimes&&e.hasOwnProperty("usedtimes")&&(r.usedtimes=e.usedtimes),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserOffChainOpTimesReply"},e}(),e.GetUserOffChainUsedInfoRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.vaccount=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.vaccount&&Object.hasOwnProperty.call(e,"vaccount")&&t.uint32(10).bytes(e.vaccount),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserOffChainUsedInfoRequest;e.pos<r;){var o=e.uint32();o>>>3==1?n.vaccount=e.bytes():e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.vaccount&&e.hasOwnProperty("vaccount")&&!(e.vaccount&&"number"==typeof e.vaccount.length||OE.isString(e.vaccount))?"vaccount: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserOffChainUsedInfoRequest)return e;var t=new AE.dcnet.pb.GetUserOffChainUsedInfoRequest;return null!=e.vaccount&&("string"==typeof e.vaccount?OE.base64.decode(e.vaccount,t.vaccount=OE.newBuffer(OE.base64.length(e.vaccount)),0):e.vaccount.length>=0&&(t.vaccount=e.vaccount)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.vaccount="":(r.vaccount=[],t.bytes!==Array&&(r.vaccount=OE.newBuffer(r.vaccount)))),null!=e.vaccount&&e.hasOwnProperty("vaccount")&&(r.vaccount=t.bytes===String?OE.base64.encode(e.vaccount,0,e.vaccount.length):t.bytes===Array?Array.prototype.slice.call(e.vaccount):e.vaccount),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserOffChainUsedInfoRequest"},e}(),e.GetUserOffChainUsedInfoReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.usedtimes=0,e.prototype.usedspace=OE.Long?OE.Long.fromBits(0,0,!0):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.usedtimes&&Object.hasOwnProperty.call(e,"usedtimes")&&t.uint32(8).uint32(e.usedtimes),null!=e.usedspace&&Object.hasOwnProperty.call(e,"usedspace")&&t.uint32(16).uint64(e.usedspace),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.GetUserOffChainUsedInfoReply;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.usedtimes=e.uint32();break;case 2:n.usedspace=e.uint64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.usedtimes&&e.hasOwnProperty("usedtimes")&&!OE.isInteger(e.usedtimes)?"usedtimes: integer expected":null!=e.usedspace&&e.hasOwnProperty("usedspace")&&!(OE.isInteger(e.usedspace)||e.usedspace&&OE.isInteger(e.usedspace.low)&&OE.isInteger(e.usedspace.high))?"usedspace: integer|Long expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.GetUserOffChainUsedInfoReply)return e;var t=new AE.dcnet.pb.GetUserOffChainUsedInfoReply;return null!=e.usedtimes&&(t.usedtimes=e.usedtimes>>>0),null!=e.usedspace&&(OE.Long?(t.usedspace=OE.Long.fromValue(e.usedspace)).unsigned=!0:"string"==typeof e.usedspace?t.usedspace=parseInt(e.usedspace,10):"number"==typeof e.usedspace?t.usedspace=e.usedspace:"object"==typeof e.usedspace&&(t.usedspace=new OE.LongBits(e.usedspace.low>>>0,e.usedspace.high>>>0).toNumber(!0))),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(r.usedtimes=0,OE.Long){var n=new OE.Long(0,0,!0);r.usedspace=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.usedspace=t.longs===String?"0":0;return null!=e.usedtimes&&e.hasOwnProperty("usedtimes")&&(r.usedtimes=e.usedtimes),null!=e.usedspace&&e.hasOwnProperty("usedspace")&&("number"==typeof e.usedspace?r.usedspace=t.longs===String?String(e.usedspace):e.usedspace:r.usedspace=t.longs===String?OE.Long.prototype.toString.call(e.usedspace):t.longs===Number?new OE.LongBits(e.usedspace.low>>>0,e.usedspace.high>>>0).toNumber(!0):e.usedspace),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.GetUserOffChainUsedInfoReply"},e}(),e.SetAppInfoRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.appId=OE.newBuffer([]),e.prototype.ownerAccount=OE.newBuffer([]),e.prototype.rewardAccount=OE.newBuffer([]),e.prototype.domain=OE.newBuffer([]),e.prototype.blockheight=0,e.prototype.peerid=OE.newBuffer([]),e.prototype.fid=OE.newBuffer([]),e.prototype.signature=OE.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),null!=e.appId&&Object.hasOwnProperty.call(e,"appId")&&t.uint32(10).bytes(e.appId),null!=e.ownerAccount&&Object.hasOwnProperty.call(e,"ownerAccount")&&t.uint32(18).bytes(e.ownerAccount),null!=e.rewardAccount&&Object.hasOwnProperty.call(e,"rewardAccount")&&t.uint32(26).bytes(e.rewardAccount),null!=e.domain&&Object.hasOwnProperty.call(e,"domain")&&t.uint32(34).bytes(e.domain),null!=e.blockheight&&Object.hasOwnProperty.call(e,"blockheight")&&t.uint32(40).uint32(e.blockheight),null!=e.peerid&&Object.hasOwnProperty.call(e,"peerid")&&t.uint32(50).bytes(e.peerid),null!=e.fid&&Object.hasOwnProperty.call(e,"fid")&&t.uint32(58).bytes(e.fid),null!=e.signature&&Object.hasOwnProperty.call(e,"signature")&&t.uint32(66).bytes(e.signature),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetAppInfoRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.appId=e.bytes();break;case 2:n.ownerAccount=e.bytes();break;case 3:n.rewardAccount=e.bytes();break;case 4:n.domain=e.bytes();break;case 5:n.blockheight=e.uint32();break;case 6:n.peerid=e.bytes();break;case 7:n.fid=e.bytes();break;case 8:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.appId&&e.hasOwnProperty("appId")&&!(e.appId&&"number"==typeof e.appId.length||OE.isString(e.appId))?"appId: buffer expected":null!=e.ownerAccount&&e.hasOwnProperty("ownerAccount")&&!(e.ownerAccount&&"number"==typeof e.ownerAccount.length||OE.isString(e.ownerAccount))?"ownerAccount: buffer expected":null!=e.rewardAccount&&e.hasOwnProperty("rewardAccount")&&!(e.rewardAccount&&"number"==typeof e.rewardAccount.length||OE.isString(e.rewardAccount))?"rewardAccount: buffer expected":null!=e.domain&&e.hasOwnProperty("domain")&&!(e.domain&&"number"==typeof e.domain.length||OE.isString(e.domain))?"domain: buffer expected":null!=e.blockheight&&e.hasOwnProperty("blockheight")&&!OE.isInteger(e.blockheight)?"blockheight: integer expected":null!=e.peerid&&e.hasOwnProperty("peerid")&&!(e.peerid&&"number"==typeof e.peerid.length||OE.isString(e.peerid))?"peerid: buffer expected":null!=e.fid&&e.hasOwnProperty("fid")&&!(e.fid&&"number"==typeof e.fid.length||OE.isString(e.fid))?"fid: buffer expected":null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||OE.isString(e.signature))?"signature: buffer expected":null},e.fromObject=function(e){if(e instanceof AE.dcnet.pb.SetAppInfoRequest)return e;var t=new AE.dcnet.pb.SetAppInfoRequest;return null!=e.appId&&("string"==typeof e.appId?OE.base64.decode(e.appId,t.appId=OE.newBuffer(OE.base64.length(e.appId)),0):e.appId.length>=0&&(t.appId=e.appId)),null!=e.ownerAccount&&("string"==typeof e.ownerAccount?OE.base64.decode(e.ownerAccount,t.ownerAccount=OE.newBuffer(OE.base64.length(e.ownerAccount)),0):e.ownerAccount.length>=0&&(t.ownerAccount=e.ownerAccount)),null!=e.rewardAccount&&("string"==typeof e.rewardAccount?OE.base64.decode(e.rewardAccount,t.rewardAccount=OE.newBuffer(OE.base64.length(e.rewardAccount)),0):e.rewardAccount.length>=0&&(t.rewardAccount=e.rewardAccount)),null!=e.domain&&("string"==typeof e.domain?OE.base64.decode(e.domain,t.domain=OE.newBuffer(OE.base64.length(e.domain)),0):e.domain.length>=0&&(t.domain=e.domain)),null!=e.blockheight&&(t.blockheight=e.blockheight>>>0),null!=e.peerid&&("string"==typeof e.peerid?OE.base64.decode(e.peerid,t.peerid=OE.newBuffer(OE.base64.length(e.peerid)),0):e.peerid.length>=0&&(t.peerid=e.peerid)),null!=e.fid&&("string"==typeof e.fid?OE.base64.decode(e.fid,t.fid=OE.newBuffer(OE.base64.length(e.fid)),0):e.fid.length>=0&&(t.fid=e.fid)),null!=e.signature&&("string"==typeof e.signature?OE.base64.decode(e.signature,t.signature=OE.newBuffer(OE.base64.length(e.signature)),0):e.signature.length>=0&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.appId="":(r.appId=[],t.bytes!==Array&&(r.appId=OE.newBuffer(r.appId))),t.bytes===String?r.ownerAccount="":(r.ownerAccount=[],t.bytes!==Array&&(r.ownerAccount=OE.newBuffer(r.ownerAccount))),t.bytes===String?r.rewardAccount="":(r.rewardAccount=[],t.bytes!==Array&&(r.rewardAccount=OE.newBuffer(r.rewardAccount))),t.bytes===String?r.domain="":(r.domain=[],t.bytes!==Array&&(r.domain=OE.newBuffer(r.domain))),r.blockheight=0,t.bytes===String?r.peerid="":(r.peerid=[],t.bytes!==Array&&(r.peerid=OE.newBuffer(r.peerid))),t.bytes===String?r.fid="":(r.fid=[],t.bytes!==Array&&(r.fid=OE.newBuffer(r.fid))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=OE.newBuffer(r.signature)))),null!=e.appId&&e.hasOwnProperty("appId")&&(r.appId=t.bytes===String?OE.base64.encode(e.appId,0,e.appId.length):t.bytes===Array?Array.prototype.slice.call(e.appId):e.appId),null!=e.ownerAccount&&e.hasOwnProperty("ownerAccount")&&(r.ownerAccount=t.bytes===String?OE.base64.encode(e.ownerAccount,0,e.ownerAccount.length):t.bytes===Array?Array.prototype.slice.call(e.ownerAccount):e.ownerAccount),null!=e.rewardAccount&&e.hasOwnProperty("rewardAccount")&&(r.rewardAccount=t.bytes===String?OE.base64.encode(e.rewardAccount,0,e.rewardAccount.length):t.bytes===Array?Array.prototype.slice.call(e.rewardAccount):e.rewardAccount),null!=e.domain&&e.hasOwnProperty("domain")&&(r.domain=t.bytes===String?OE.base64.encode(e.domain,0,e.domain.length):t.bytes===Array?Array.prototype.slice.call(e.domain):e.domain),null!=e.blockheight&&e.hasOwnProperty("blockheight")&&(r.blockheight=e.blockheight),null!=e.peerid&&e.hasOwnProperty("peerid")&&(r.peerid=t.bytes===String?OE.base64.encode(e.peerid,0,e.peerid.length):t.bytes===Array?Array.prototype.slice.call(e.peerid):e.peerid),null!=e.fid&&e.hasOwnProperty("fid")&&(r.fid=t.bytes===String?OE.base64.encode(e.fid,0,e.fid.length):t.bytes===Array?Array.prototype.slice.call(e.fid):e.fid),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?OE.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetAppInfoRequest"},e}(),e.SetAppInfoReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=SE.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof kE||(e=kE.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new AE.dcnet.pb.SetAppInfoReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof kE||(e=new kE(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof AE.dcnet.pb.SetAppInfoReply?e:new AE.dcnet.pb.SetAppInfoReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/dcnet.pb.SetAppInfoReply"},e}(),e.Service=function(){function e(e,t,r){o.minimalExports.rpc.Service.call(this,e,t,r)}return(e.prototype=Object.create(o.minimalExports.rpc.Service.prototype)).constructor=e,e.create=function(e,t,r){return new this(e,t,r)},Object.defineProperty(e.prototype.storeThreadToPeer=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.StoreThreadRequest,AE.dcnet.pb.StoreThreadReply,t,r)},"name",{value:"StoreThreadToPeer"}),Object.defineProperty(e.prototype.storeFileToPeer=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.StroeFileToPeerRequest,AE.dcnet.pb.StroeFileToPeerReply,t,r)},"name",{value:"StoreFileToPeer"}),Object.defineProperty(e.prototype.accountBindBackup=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AccountDealBackupRequest,AE.dcnet.pb.AccountDealBackupReply,t,r)},"name",{value:"AccountBindBackup"}),Object.defineProperty(e.prototype.accountInfoModifyBackup=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AccountDealBackupRequest,AE.dcnet.pb.AccountDealBackupReply,t,r)},"name",{value:"AccountInfoModifyBackup"}),Object.defineProperty(e.prototype.onlineStatusCheck=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.OnlineStatusCheckRequest,AE.dcnet.pb.OnlineStatusCheckReply,t,r)},"name",{value:"OnlineStatusCheck"}),Object.defineProperty(e.prototype.teeReportVerify=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.TeeReportVerifyRequest,AE.dcnet.pb.TeeReportVerifyReply,t,r)},"name",{value:"TeeReportVerify"}),Object.defineProperty(e.prototype.checkPeerStatus=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.CheckPeerStatusRequest,AE.dcnet.pb.CheckPeerStatusReply,t,r)},"name",{value:"CheckPeerStatus"}),Object.defineProperty(e.prototype.localFileCheck=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.LocalFileCheckRequest,AE.dcnet.pb.LocalFileCheckReply,t,r)},"name",{value:"LocalFileCheck"}),Object.defineProperty(e.prototype.getPeersWithSid=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetPeersWithSidRequest,AE.dcnet.pb.GetPeersWithSidReply,t,r)},"name",{value:"GetPeersWithSid"}),Object.defineProperty(e.prototype.getPeersWithAccountHash=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetPeersWithAccountHashRequest,AE.dcnet.pb.GetPeersWithAccountHashReply,t,r)},"name",{value:"GetPeersWithAccountHash"}),Object.defineProperty(e.prototype.localAccountInfoCheck=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.LocalAccountInfoCheckRequest,AE.dcnet.pb.LocalAccountInfoCheckReply,t,r)},"name",{value:"LocalAccountInfoCheck"}),Object.defineProperty(e.prototype.accountInfoSync=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AccountInfoSyncRequest,AE.dcnet.pb.AccountInfoSyncReply,t,r)},"name",{value:"AccountInfoSync"}),Object.defineProperty(e.prototype.setEncryptKeyWithScan=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.SetEncryptKeyWithScanRequest,AE.dcnet.pb.SetEncryptKeyWithScanReply,t,r)},"name",{value:"SetEncryptKeyWithScan"}),Object.defineProperty(e.prototype.getEncryptKeyWithScan=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetEncryptKeyWithScanRequest,AE.dcnet.pb.GetEncryptKeyWithScanReply,t,r)},"name",{value:"GetEncryptKeyWithScan"}),Object.defineProperty(e.prototype.requestRandEncryptKey=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.RequestRandEncryptKeyRequest,AE.dcnet.pb.RequestRandEncryptKeyReply,t,r)},"name",{value:"RequestRandEncryptKey"}),Object.defineProperty(e.prototype.getEncryptKey=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetEncryptKeyRequest,AE.dcnet.pb.GetEncryptKeyReply,t,r)},"name",{value:"GetEncryptKey"}),Object.defineProperty(e.prototype.reportLocalMultilAddr=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.ReportLocalMultilAddrRequest,AE.dcnet.pb.ReportLocalMultilAddrReply,t,r)},"name",{value:"ReportLocalMultilAddr"}),Object.defineProperty(e.prototype.getHostID=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetHostIDRequest,AE.dcnet.pb.GetHostIDReply,t,r)},"name",{value:"GetHostID"}),Object.defineProperty(e.prototype.getToken=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetTokenRequest,AE.dcnet.pb.GetTokenReply,t,r)},"name",{value:"GetToken"}),Object.defineProperty(e.prototype.createThread=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.CreateThreadRequest,AE.dcnet.pb.ThreadInfoReply,t,r)},"name",{value:"CreateThread"}),Object.defineProperty(e.prototype.requestThreadID=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.ThreadIDRequest,AE.dcnet.pb.ThreadIDReply,t,r)},"name",{value:"RequestThreadID"}),Object.defineProperty(e.prototype.addLogToThread=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AddLogToThreadRequest,AE.dcnet.pb.AddLogToThreadReply,t,r)},"name",{value:"AddLogToThread"}),Object.defineProperty(e.prototype.getThreadUsedSpace=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetThreadUsedSpaceRequest,AE.dcnet.pb.GetThreadUsedSpaceReply,t,r)},"name",{value:"GetThreadUsedSpace"}),Object.defineProperty(e.prototype.addThreadToPeer=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AddThreadToPeerRequest,AE.dcnet.pb.AddThreadToPeerReply,t,r)},"name",{value:"AddThreadToPeer"}),Object.defineProperty(e.prototype.getThread=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetThreadRequest,AE.dcnet.pb.ThreadInfoReply,t,r)},"name",{value:"GetThread"}),Object.defineProperty(e.prototype.deleteThread=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DeleteThreadRequest,AE.dcnet.pb.DeleteThreadReply,t,r)},"name",{value:"DeleteThread"}),Object.defineProperty(e.prototype.addThreadSpace=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AddThreadSpaceRequest,AE.dcnet.pb.AddThreadSpaceReply,t,r)},"name",{value:"AddThreadSpace"}),Object.defineProperty(e.prototype.storeFile=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.StroeFileRequest,AE.dcnet.pb.StroeFileReply,t,r)},"name",{value:"StoreFile"}),Object.defineProperty(e.prototype.storeFolder=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.StoreFolderRequest,AE.dcnet.pb.StoreFolderReply,t,r)},"name",{value:"StoreFolder"}),Object.defineProperty(e.prototype.deleteFile=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DeleteFileRequest,AE.dcnet.pb.DeleteFileReply,t,r)},"name",{value:"DeleteFile"}),Object.defineProperty(e.prototype.accountBind=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AccountDealRequest,AE.dcnet.pb.AccountDealReply,t,r)},"name",{value:"AccountBind"}),Object.defineProperty(e.prototype.accountInfoModify=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AccountDealRequest,AE.dcnet.pb.AccountDealReply,t,r)},"name",{value:"AccountInfoModify"}),Object.defineProperty(e.prototype.accountLogin=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AccountLoginRequest,AE.dcnet.pb.AccountLoginReply,t,r)},"name",{value:"AccountLogin"}),Object.defineProperty(e.prototype.transferAccount=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.TransferAccountRequest,AE.dcnet.pb.TransferAccountReply,t,r)},"name",{value:"TransferAccount"}),Object.defineProperty(e.prototype.addSubPubkey=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AddSubPubkeyRequest,AE.dcnet.pb.AddSubPubkeyReply,t,r)},"name",{value:"AddSubPubkey"}),Object.defineProperty(e.prototype.deleteSubPubkey=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DeleteSubPubkeyRequest,AE.dcnet.pb.DeleteSubPubkeyReply,t,r)},"name",{value:"DeleteSubPubkey"}),Object.defineProperty(e.prototype.bindAccessPeerToUser=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.BindAccessPeerToUserRequest,AE.dcnet.pb.BindAccessPeerToUserReply,t,r)},"name",{value:"BindAccessPeerToUser"}),Object.defineProperty(e.prototype.setUserDefaultDB=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.SetUserDefaultDBRequest,AE.dcnet.pb.SetUserDefaultDBReply,t,r)},"name",{value:"SetUserDefaultDB"}),Object.defineProperty(e.prototype.sendMsgToUserBox=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.SendMsgToUserBoxRequest,AE.dcnet.pb.SendMsgToUserBoxReply,t,r)},"name",{value:"SendMsgToUserBox"}),Object.defineProperty(e.prototype.getToUserBoxAuth=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetToUserBoxAuthRequest,AE.dcnet.pb.GetToUserBoxAuthReply,t,r)},"name",{value:"GetToUserBoxAuth"}),Object.defineProperty(e.prototype.getMaxKeyFromUserBox=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetMaxKeyFromUserBoxRequest,AE.dcnet.pb.GetMaxKeyFromUserBoxReply,t,r)},"name",{value:"GetMaxKeyFromUserBox"}),Object.defineProperty(e.prototype.getMsgFromUserBox=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetMsgFromUserBoxRequest,AE.dcnet.pb.GetMsgFromUserBoxReply,t,r)},"name",{value:"GetMsgFromUserBox"}),Object.defineProperty(e.prototype.reportSpamMsg=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.ReportSpamMsgRequest,AE.dcnet.pb.ReportSpamMsgReply,t,r)},"name",{value:"ReportSpamMsg"}),Object.defineProperty(e.prototype.validToken=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.ValidTokenRequest,AE.dcnet.pb.ValidTokenReply,t,r)},"name",{value:"ValidToken"}),Object.defineProperty(e.prototype.getUserClientPeers=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetUserClientPeersRequest,AE.dcnet.pb.GetUserClientPeersReply,t,r)},"name",{value:"GetUserClientPeers"}),Object.defineProperty(e.prototype.setCacheKey=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.SetCacheKeyRequest,AE.dcnet.pb.SetCacheKeyReply,t,r)},"name",{value:"SetCacheKey"}),Object.defineProperty(e.prototype.getCacheValue=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetCacheValueRequest,AE.dcnet.pb.GetCacheValueReply,t,r)},"name",{value:"GetCacheValue"}),Object.defineProperty(e.prototype.addThemeObj=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AddThemeObjRequest,AE.dcnet.pb.AddThemeObjReply,t,r)},"name",{value:"AddThemeObj"}),Object.defineProperty(e.prototype.addThemeSpace=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AddThemeSpaceRequest,AE.dcnet.pb.AddThemeSpaceReply,t,r)},"name",{value:"AddThemeSpace"}),Object.defineProperty(e.prototype.getThemeSpace=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetThemeSpaceRequest,AE.dcnet.pb.GetThemeSpaceReply,t,r)},"name",{value:"GetThemeSpace"}),Object.defineProperty(e.prototype.deleteThemeObj=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DeleteThemeObjRequest,AE.dcnet.pb.DeleteThemeObjReply,t,r)},"name",{value:"DeleteThemeObj"}),Object.defineProperty(e.prototype.reportMaliciousComment=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.ReportMaliciousCommentRequest,AE.dcnet.pb.ReportMaliciousCommentReply,t,r)},"name",{value:"ReportMaliciousComment"}),Object.defineProperty(e.prototype.setObjCommentPublic=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.SetObjCommentPublicRequest,AE.dcnet.pb.SetObjCommentPublicReply,t,r)},"name",{value:"SetObjCommentPublic"}),Object.defineProperty(e.prototype.addUserOffChainSpace=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AddUserOffChainSpaceRequest,AE.dcnet.pb.AddUserOffChainSpaceReply,t,r)},"name",{value:"AddUserOffChainSpace"}),Object.defineProperty(e.prototype.publishCommentToTheme=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.PublishCommentToThemeRequest,AE.dcnet.pb.PublishCommentToThemeReply,t,r)},"name",{value:"PublishCommentToTheme"}),Object.defineProperty(e.prototype.configThemeObjAuth=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.ConfigThemeObjAuthRequest,AE.dcnet.pb.ConfigThemeObjAuthReply,t,r)},"name",{value:"ConfigThemeObjAuth"}),Object.defineProperty(e.prototype.setKeyValue=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.SetKeyValueRequest,AE.dcnet.pb.SetKeyValueReply,t,r)},"name",{value:"SetKeyValue"}),Object.defineProperty(e.prototype.deleteSelfComment=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DeleteSelfCommentRequest,AE.dcnet.pb.DeleteSelfCommentReply,t,r)},"name",{value:"DeleteSelfComment"}),Object.defineProperty(e.prototype.deleteCommentToObj=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DeleteCommentToObjRequest,AE.dcnet.pb.DeleteCommentToObjReply,t,r)},"name",{value:"DeleteCommentToObj"}),Object.defineProperty(e.prototype.isThemeExist=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.IsThemeExistRequest,AE.dcnet.pb.IsThemeExistReply,t,r)},"name",{value:"IsThemeExist"}),Object.defineProperty(e.prototype.getThemeObj=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetThemeObjRequest,AE.dcnet.pb.GetThemeObjReply,t,r)},"name",{value:"GetThemeObj"}),Object.defineProperty(e.prototype.getThemeComments=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetThemeCommentsRequest,AE.dcnet.pb.GetThemeCommentsReply,t,r)},"name",{value:"GetThemeComments"}),Object.defineProperty(e.prototype.getUserThemeConfigInfo=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetUserThemeConfigInfoRequest,AE.dcnet.pb.GetUserThemeConfigInfoReply,t,r)},"name",{value:"GetUserThemeConfigInfo"}),Object.defineProperty(e.prototype.getThemeAuthList=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetThemeAuthListRequest,AE.dcnet.pb.GetThemeAuthListReply,t,r)},"name",{value:"GetThemeAuthList"}),Object.defineProperty(e.prototype.getUserComments=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetUserCommentsRequest,AE.dcnet.pb.GetUserCommentsReply,t,r)},"name",{value:"GetUserComments"}),Object.defineProperty(e.prototype.getValueWithKey=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetValueWithKeyRequest,AE.dcnet.pb.GetValueWithKeyReply,t,r)},"name",{value:"GetValueWithKey"}),Object.defineProperty(e.prototype.getValuesWithKeys=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetValuesWithKeysRequest,AE.dcnet.pb.GetValuesWithKeysReply,t,r)},"name",{value:"GetValuesWithKeys"}),Object.defineProperty(e.prototype.getValuesWithIndex=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetValuesWithIndexRequest,AE.dcnet.pb.GetValuesWithIndexReply,t,r)},"name",{value:"GetValuesWithIndex"}),Object.defineProperty(e.prototype.sendCommentToPeer=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.PublishCommentToThemeRequest,AE.dcnet.pb.PublishCommentToThemeReply,t,r)},"name",{value:"SendCommentToPeer"}),Object.defineProperty(e.prototype.pushThemeFunOpt=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.PushThemeFunOptRequest,AE.dcnet.pb.PushThemeFunOptReply,t,r)},"name",{value:"PushThemeFunOpt"}),Object.defineProperty(e.prototype.pullCommentFunOpts=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.PullCommentFunOptsRequest,AE.dcnet.pb.PullCommentFunOptsReply,t,r)},"name",{value:"PullCommentFunOpts"}),Object.defineProperty(e.prototype.exchangeThemeEdges=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.ExchangeThemeEdgesRequest,AE.dcnet.pb.ExchangeThemeEdgesReply,t,r)},"name",{value:"ExchangeThemeEdges"}),Object.defineProperty(e.prototype.downloadUserComments=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DownloadUserCommentsRequest,AE.dcnet.pb.DownloadUserCommentsReply,t,r)},"name",{value:"DownloadUserComments"}),Object.defineProperty(e.prototype.userCommentsDownloadReady=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.UserCommentsDownloadReadyRequest,AE.dcnet.pb.UserCommentsDownloadReadyReply,t,r)},"name",{value:"UserCommentsDownloadReady"}),Object.defineProperty(e.prototype.syncThemeObj=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.SyncThemeObjRequest,AE.dcnet.pb.SyncThemeObjReply,t,r)},"name",{value:"SyncThemeObj"}),Object.defineProperty(e.prototype.deviceStatusReport=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DeviceStatusReportRequest,AE.dcnet.pb.DeviceStatusReportReply,t,r)},"name",{value:"DeviceStatusReport"}),Object.defineProperty(e.prototype.archiveDeviceStatus=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.ArchiveDeviceStatusRequest,AE.dcnet.pb.ArchiveDeviceStatusReply,t,r)},"name",{value:"ArchiveDeviceStatus"}),Object.defineProperty(e.prototype.sendDeviceStatusToPeer=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DeviceStatusReportRequest,AE.dcnet.pb.DeviceStatusReportReply,t,r)},"name",{value:"SendDeviceStatusToPeer"}),Object.defineProperty(e.prototype.getThemeDevicesStatus=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetThemeDevicesStatusRequest,AE.dcnet.pb.GetThemeDevicesStatusReply,t,r)},"name",{value:"GetThemeDevicesStatus"}),Object.defineProperty(e.prototype.getDeviceAuth=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetDeviceAuthRequest,AE.dcnet.pb.GetDeviceAuthReply,t,r)},"name",{value:"GetDeviceAuth"}),Object.defineProperty(e.prototype.getDeviceStatusList=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetDeviceStatusListRequest,AE.dcnet.pb.GetDeviceStatusListReply,t,r)},"name",{value:"GetDeviceStatusList"}),Object.defineProperty(e.prototype.addUserOffChainOpTimes=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.AddUserOffChainOpTimesRequest,AE.dcnet.pb.AddUserOffChainOpTimesReply,t,r)},"name",{value:"AddUserOffChainOpTimes"}),Object.defineProperty(e.prototype.getUserOffChainOpTimes=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetUserOffChainOpTimesRequest,AE.dcnet.pb.GetUserOffChainOpTimesReply,t,r)},"name",{value:"GetUserOffChainOpTimes"}),Object.defineProperty(e.prototype.getUserOffChainUsedInfo=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetUserOffChainUsedInfoRequest,AE.dcnet.pb.GetUserOffChainUsedInfoReply,t,r)},"name",{value:"GetUserOffChainUsedInfo"}),Object.defineProperty(e.prototype.reEncryptFile=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.ReEncryptFileRequest,AE.dcnet.pb.ReEncryptFileReply,t,r)},"name",{value:"ReEncryptFile"}),Object.defineProperty(e.prototype.requestRandData=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.RequestRandDataRequest,AE.dcnet.pb.RequestRandDataReply,t,r)},"name",{value:"RequestRandData"}),Object.defineProperty(e.prototype.getAIProxyConfigFromPeer=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetAIProxyConfigFromPeerRequest,AE.dcnet.pb.GetAIProxyConfigFromPeerReply,t,r)},"name",{value:"GetAIProxyConfigFromPeer"}),Object.defineProperty(e.prototype.getAIProxyConfig=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetAIProxyConfigRequest,AE.dcnet.pb.GetAIProxyConfigReply,t,r)},"name",{value:"GetAIProxyConfig"}),Object.defineProperty(e.prototype.doAIProxyCall=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DoAIProxyCallRequest,AE.dcnet.pb.DoAIProxyCallReply,t,r)},"name",{value:"DoAIProxyCall"}),Object.defineProperty(e.prototype.createAIProxyCallTask=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.CreateAIProxyCallTaskRequest,AE.dcnet.pb.CreateAIProxyCallTaskReply,t,r)},"name",{value:"CreateAIProxyCallTask"}),Object.defineProperty(e.prototype.getAIProxyCallTaskResult=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetAIProxyCallTaskResultRequest,AE.dcnet.pb.GetAIProxyCallTaskResultReply,t,r)},"name",{value:"GetAIProxyCallTaskResult"}),Object.defineProperty(e.prototype.getUserOwnAIProxyAuth=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.GetUserOwnAIProxyAuthRequest,AE.dcnet.pb.GetUserOwnAIProxyAuthReply,t,r)},"name",{value:"GetUserOwnAIProxyAuth"}),Object.defineProperty(e.prototype.deductUserOffChainOpTimes=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DeductUserOffChainOpTimesRequest,AE.dcnet.pb.DeductUserOffChainOpTimesReply,t,r)},"name",{value:"DeductUserOffChainOpTimes"}),Object.defineProperty(e.prototype.deductUserAIProxyOpTimes=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.DeductUserAIProxyOpTimesRequest,AE.dcnet.pb.DeductUserAIProxyOpTimesReply,t,r)},"name",{value:"DeductUserAIProxyOpTimes"}),Object.defineProperty(e.prototype.setAppInfo=function e(t,r){return this.rpcCall(e,AE.dcnet.pb.SetAppInfoRequest,AE.dcnet.pb.SetAppInfoReply,t,r)},"name",{value:"SetAppInfo"}),e}(),e),t})();class xE{constructor(){this.waitingPromises=[],this.closed=!1,this.abortController=new AbortController}setData(e){if(this.closed)throw new Error("DataSource is closed");const t=this.waitingPromises;this.waitingPromises=[],t.forEach((({resolve:t})=>t(e)))}close(){if(this.closed)return;this.closed=!0,this.abortController.abort();const e=new Error("DataSource has been closed");this.waitingPromises.forEach((({reject:t})=>t(e))),this.waitingPromises=[]}async waitForData(){if(this.closed)throw new Error("DataSource is closed");return new Promise(((e,t)=>{this.closed?t(new Error("DataSource is closed")):(this.waitingPromises.push({resolve:e,reject:t}),this.abortController.signal.addEventListener("abort",(()=>{t(new Error("DataSource has been closed"))})))}))}isClosed(){return this.closed}getDataSource(){if(this.closed)throw new Error("DataSource is closed");return{[Symbol.asyncIterator]:()=>({next:async()=>{try{if(this.closed)return{done:!0,value:void 0};return{done:!1,value:await this.waitForData()}}catch(e){return{done:!0,value:void 0}}}})}}}class PE{constructor(e,t,r,n){this.grpcClient=new b.Libp2pGrpcClient(e,t,r,n),this.token=r}async GetToken(e,t,r){let n="";try{let o=null;const i=new xE,s=new IE.pb.GetTokenRequest({});s.key=e+"_"+t;const a=IE.pb.GetTokenRequest.encode(s).finish(),c=async e=>{const t=IE.pb.GetTokenReply.decode(e);if(t.challenge){const e=t.challenge,n=await r(e),o=new IE.pb.GetTokenRequest({});o.signature=n;const s=IE.pb.GetTokenRequest.encode(o).finish();i.setData(s)}else t.token&&(n=t.token,i.close())},u=()=>i.getDataSource(),l=async()=>{i.close()},d=async e=>{o=e instanceof Error?e:new Error(String(e)),i.close()};if(await this.grpcClient.Call("/dcnet.pb.Service/GetToken",a,3e4,"bidirectional",c,u,l,d),o)throw o;return this.token=n,this.grpcClient.setToken(n),n}catch(e){throw e}}async ValidToken(){try{const e=new IE.pb.ValidTokenRequest({}),t=IE.pb.ValidTokenRequest.encode(e).finish(),r=await this.grpcClient.unaryCall("/dcnet.pb.Service/ValidToken",t,3e4);return IE.pb.ValidTokenReply.decode(r),!0}catch(e){throw e}}}class EE{constructor(e,t,r,n){this.protocol=n,this.p2pNode=e,this.peerAddr=r,this.token="",this.blockstore=t}async GetToken(e,t,r,n){try{if(null==this.p2pNode)throw new Error("p2pNode is null");if(n||(n=this.peerAddr),!t||0==t.length)throw new Error("pubkey is empty");const o=new PE(this.p2pNode,n,this.token,this.protocol),i=await o.GetToken(e,t,r);return this.token=i,i}catch(e){return""}}async ClearToken(){this.token=""}async ValidToken(e){try{if(null==this.p2pNode)throw new Error("p2pNode is null");e||(e=this.peerAddr);const t=new PE(this.p2pNode,e,this.token,this.protocol);await t.ValidToken()}catch(e){throw e}}async refreshToken(e,t,r,n){return this.ClearToken(),await this.GetToken(e,t,r,n)}}const CE="undefined"!=typeof globalThis?globalThis.walletOpenOrgin:"",BE="undefined"!=typeof globalThis?globalThis.walletOpenVersion:"";let TE="",DE="";TE="/v0_0_19",DE="https://wallet.dcnetio.com",CE&&(DE=CE||"https://wallet.dcnetio.com"),BE&&(TE=BE&&BE.startsWith("/")?BE:"/"+BE);const RE=DE,jE=DE+TE,NE="walletWindow",UE="/dc/thread/0.0.1",KE=1e3,qE=10485760,LE=1e3;var _E,ME;exports.Direction=void 0,(_E=exports.Direction||(exports.Direction={}))[_E.Forward=0]="Forward",_E[_E.Reverse=1]="Reverse",exports.CommentType=void 0,(ME=exports.CommentType||(exports.CommentType={}))[ME.Comment=0]="Comment",ME[ME.Up=1]="Up",ME[ME.Down=2]="Down",ME[ME.Transfer=3]="Transfer",ME[ME.KeyValue=4]="KeyValue";class FE{}FE.Handshake=0,FE.Data=1,FE.ACK=2,FE.Close=3;class zE{}zE.File=1,zE.ThreadDB=2,zE.Record=3;const GE=new AbortController,{signal:VE}=GE;class HE{constructor(t){this._connectToObjNodes=async e=>{const t=await this.dcChain.getObjNodes(e);if(!t)return[null,null];return[await this._connectPeers(t),t]},this.connectToPeer=async e=>await this._connectPeers([e]),this._connectPeers=e=>new Promise(((t,r)=>{const n=this,o=e.length;let i=0;async function s(s){if(!e[s])return;const[a,c]=await n.dcChain.getDcNodeWebrtcDirectAddr(e[s]);if(!a)return i++,void(i>=o&&r("no nodeAddr return"));try{if(n.dcNodeClient?.libp2p){await(n.dcNodeClient?.libp2p.dial(a,{signal:AbortSignal.timeout(KE)}))?t(a):(i++,i>=o&&r("dial nodeAddr failed"))}}catch(e){e&&"object"==typeof e&&"message"in e?(i++,i>=o&&r(e.message)):(i++,i>=o&&r(e))}}for(let e=0;e<o;e++)s(e)})),this.connectToUserDcPeer=async e=>{const t=await this.dcChain.getAccountPeers(e);if(!t||0==t.length)return null;if(!this.dcNodeClient||!this.dcNodeClient?.libp2p)return null;const r=await this._connectPeers(t);if(!r)return null;return new EE(this.dcNodeClient?.libp2p,this.dcNodeClient.blockstore,r,UE)},this.connectToUserAllDcPeers=async e=>{const t=await this.dcChain.getAccountPeers(e);if(!t||0==t.length)return null;let r=[];for(let e=0;e<t.length;e++){const n=t[e];if(n)try{if(!this.dcNodeClient||!this.dcNodeClient?.libp2p)return null;const e=await this._connectPeers([n]);if(!e)return null;const t=new EE(this.dcNodeClient?.libp2p,this.dcNodeClient.blockstore,e,UE);r.push(t)}catch(e){}}return r},this._connectNodeAddrs=t=>new Promise(((r,n)=>{const o=this,i=t.length;let s=0;async function a(n){if(!t[n])return s++,void(s>=i&&r(null));const a=t[n].split(","),c=e.multiaddr(a[1]);try{if(o.dcNodeClient?.libp2p){if(await o.dcNodeClient.libp2p.dial(c,{signal:AbortSignal.timeout(KE)}))return void r(c)}s++,s>=i&&r(null)}catch(e){s++,s>=i&&r(null)}}for(let e=0;e<i;e++)a(e)})),this._createHeliaNode=async()=>{const e=new u.IDBDatastore("helia-meta");await e.open();const t=new l.IDBBlockstore("helia-blocks");await t.open();let r=await zr("ed25519_privateKey");r||(r=await n.keys.generateKeyPair("Ed25519"),await Fr("ed25519_privateKey",r));const o=await f.createLibp2p({privateKey:r,datastore:e,transports:[e=>new eP(e,i),jh(),tP()],connectionEncrypters:[Mx()],connectionGater:{denyDialMultiaddr:()=>!1},connectionManager:{maxParallelDials:30,maxConnections:30,inboundConnectionThreshold:30},streamMuxers:[YP({maxStreamWindowSize:262144,maxMessageSize:16384,keepAliveInterval:15e3,maxInboundStreams:30,maxOutboundStreams:50,initialStreamWindowSize:262144,enableKeepAlive:!0})],services:{autoNAT:cE(),dcutr:vE(),identify:xP(),identifyPush:PP(),ping:QP(),autoRelay:e=>({enabled:!0,maxListeners:2,peerSource:e.peerStore})},addresses:{listen:["/webrtc-direct","/p2p-circuit","/webrtc"]}});var i;const s=await y.createHelia({blockBrokers:[g.bitswap({maxInboundStreams:64,maxOutboundStreams:128})],datastore:e,blockstore:t,libp2p:o});return this.dcNodeClient=s,s},this._getConnectedPeerId=async()=>{if(this.defaultPeerId)return this.defaultPeerId;{const e=localStorage.getItem("defaultPeerId");return e?(this.defaultPeerId=e,e):""}},this._getNodeAddr=async t=>{let[r,n]=await this.dcChain.getDcNodeWebrtcDirectAddr(t);if(r){if(e.isName(r)){const e=await r.resolve();r=e[0]?e[0]:null}return r||void 0}},this.getDefaultDcNodeAddr=async()=>{const e=await this._getConnectedPeerId();if(e){let t=await this._getNodeAddr(e);if(t)try{if(await(this.dcNodeClient?.libp2p.dial(t,{signal:AbortSignal.timeout(KE)})))return t}catch(e){}localStorage.removeItem("defaultPeerId")}const t=await this.dcChain.getDcNodeList();if(!t)return;const r=await this._getConnectDcNodeList(t);if(!r)return;const n=r.getPeerId();return n&&localStorage.setItem("defaultPeerId",n.toString()),r},this._getConnectDcNodeList=async e=>{if(e.length>this.connectLength){let t=this._getRamdomNodeList(e,this.connectLength);const r=await this._connectNodeAddrs(t);if(!r){const r=e.filter((e=>-1===t.indexOf(e)));return this._getConnectDcNodeList(r)}return r}{let t=await this._connectNodeAddrs(e);if(!t)return;return t}},this._getRamdomNodeList=(e,t)=>{const r=e.length,n=[];for(let o=0;o<t;o++){const t=Math.floor(Math.random()*r);n.push(e[t])}return n},this.dcChain=t,this.connectLength=5}async createTransferStream(e,t,r,n,o){const i=await e.dial(r,{signal:AbortSignal.timeout(KE)}),s=await i.newStream("/dc/transfer/1.0.0");try{const e=new eE(s.sink),r=[];let i,a=null,c=!1;const u=this.chunkGenerator(s);let l=!0;for(;;){let s;if(l){let e;const t=new Promise((t=>{e=setTimeout((()=>t("timeout")),5e3)})),r=await Promise.race([u.next(),t]);if("timeout"===r)break;e&&clearTimeout(e),s=r,l=!1}else s=await u.next();if(s.done)break;const d=s.value;i=d instanceof Ns?d.subarray():d,r.push(i);const h=Ur(...r);if(a=null,a=this.parseMessage(h),a){if(3===a.type)break;if(c){const n=iE.pb.FetchRequest.decode(a.payload),o=(new TextDecoder).decode(n.cid),i=fs.parse(o);try{const n=await t.get(i),o=new iE.pb.FetchReply({data:n}),s=iE.pb.FetchReply.encode(o).finish(),a=this.assembleCustomMessage({type:FE.ACK,version:1,payload:s});await e.write(a),r.length=0}catch(e){}}else{if(!iE.pb.InitRequset.decode(a.payload))continue;r.length=0;const t=(new TextEncoder).encode(o),i=new iE.pb.InitReply({type:n,oid:t}),s=iE.pb.InitReply.encode(i).finish(),u=this.assembleCustomMessage({type:FE.ACK,version:1,payload:s});await e.write(u),c=!0}}}}catch(e){throw e}finally{s.close()}}async*chunkGenerator(e){const t=e.source[Symbol.asyncIterator]();for(;;)try{const{done:e,value:r}=await t.next();if(e)break;const n=r instanceof Ns?r.subarray():r;yield n}catch(e){}}assembleCustomMessage(e){const t=e.payload.byteLength,r=new Uint8Array(7+t);return r[0]=e.type,r[1]=e.version>>8&255,r[2]=255&e.version,r[3]=t>>24&255,r[4]=t>>16&255,r[5]=t>>8&255,r[6]=255&t,r.set(e.payload,7),r}parseMessage(e){if(e.length<7)return null;const t=e[0],r=e[1]<<8|e[2],n=e[3]<<24|e[4]<<16|e[5]<<8|e[6];if(e.length<7+n)return null;return{type:t,version:r,payload:e.slice(7,7+n)}}}var WE=4091;class JE{constructor(e){var t,r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(this.sink=e,this.options=o,this.bytesWritten=0,this.abortController=new AbortController,this.backpressureHistory=[],this.isBackpressure=!1,this.writeQueue=[],this.isProcessingQueue=!1,this.lastBackpressureCheck=0,this.bytesDrained=0,this.lastDrainEventAt=0,this.stallStartAt=0,this.lastBytesDrainedSeen=0,this.lastBpWarnAt=0,this.listeners=new Map,o)?this.options={chunkSize:null!==(t=o.chunkSize)&&void 0!==t?t:WE,bufferSize:null!==(r=o.bufferSize)&&void 0!==r?r:5242880,retries:null!==(n=o.retries)&&void 0!==n?n:3}:this.options={chunkSize:WE,bufferSize:5242880,retries:3};this.options.chunkSize&&this.options.chunkSize>WE&&(this.options.chunkSize=WE);var i=Qd({objectMode:!1});i._originalPush=i.push.bind(i),i._originalNext=i.next.bind(i),i._queueSize=0,Object.defineProperty(i,"push",{value:e=>(i._queueSize+=e.byteLength,i._originalPush(e)),writable:!1,configurable:!1}),this.p=i,this.startPipeline(),this.startWatchdog()}get queueSize(){return this.p._queueSize}getAverageQueueSize(){var e=Date.now(),t=this.queueSize;return e-this.lastBackpressureCheck>100&&(t>0&&(this.backpressureHistory.push(t),this.backpressureHistory.length>5&&this.backpressureHistory.shift()),this.lastBackpressureCheck=e),0===this.backpressureHistory.length?t:this.backpressureHistory.reduce(((e,t)=>e+t),0)/this.backpressureHistory.length}handleError(e){this.dispatchEvent(new CustomEvent("error",{detail:e})),this.abort(e.message)}startPipeline(){rh(this.p,this.createTransform(),this.sink).catch((e=>this.handleError(e)))}createTransform(){var e=this;return function(){var t=ee((function*(t){var r,n=!1,o=!1;try{for(var i,s=M(t);n=!(i=yield V(s.next())).done;n=!1){var a=i.value;yield a;try{var c;null!=(null===(c=e.p)||void 0===c?void 0:c._queueSize)&&(e.p._queueSize=Math.max(0,e.p._queueSize-a.byteLength)),e.bytesDrained+=a.byteLength;var u=Date.now();u-e.lastDrainEventAt>250&&(e.lastDrainEventAt=u,e.dispatchEvent(new CustomEvent("drain",{detail:{drained:e.bytesDrained,queueSize:e.queueSize}}))),e.lastBytesDrainedSeen=e.bytesDrained}catch(e){}}}catch(e){o=!0,r=e}finally{try{n&&null!=s.return&&(yield V(s.return()))}finally{if(o)throw r}}}));return function(e){return t.apply(this,arguments)}}()}startWatchdog(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1500;this.watchdogTimer||(this.watchdogTimer=setInterval((()=>{if(!this.abortController.signal.aborted){var e=.7*this.options.bufferSize,r=this.queueSize,n=Date.now();r>=e?this.lastBytesDrainedSeen===this.bytesDrained?(this.stallStartAt||(this.stallStartAt=n),n-this.stallStartAt>=t&&(this.dispatchEvent(new CustomEvent("stalled",{detail:{queueSize:r,drained:this.bytesDrained,sinceMs:n-this.stallStartAt}})),this.stallStartAt=n)):(this.stallStartAt=0,this.lastBytesDrainedSeen=this.bytesDrained):this.stallStartAt=0}}),e))}write(e){var t=this;return G((function*(){if(!t.abortController.signal.aborted)return new Promise(((r,n)=>{var o=function(){var o=G((function*(){try{var o=yield t.convertToBuffer(e);yield t.writeChunks(o),r()}catch(e){n(e)}}));return function(){return o.apply(this,arguments)}}();t.writeQueue.push(o),t.processQueue()}))}))()}convertToBuffer(e){return G((function*(){return e instanceof Blob?e.arrayBuffer():"string"==typeof e?(new TextEncoder).encode(e).buffer:e}))()}writeChunks(e){var t=this;return G((function*(){for(var r=0;r<e.byteLength;r+=t.options.chunkSize){var n=Math.min(r+t.options.chunkSize,e.byteLength),o=new Uint8Array(n-r);o.set(new Uint8Array(e.slice(r,n))),yield t.retryableWrite(o),t.updateProgress(o.byteLength)}}))()}retryableWrite(e){var t=arguments,r=this;return G((function*(){var n=t.length>1&&void 0!==t[1]?t[1]:0;try{r.queueSize>.7*r.options.bufferSize&&(yield r.monitorBackpressure()),yield new Promise(((t,n)=>{try{r.p.push(e)}catch(e){n(e)}t()}))}catch(t){if(n<r.options.retries){var o=r.calculateRetryDelay(n);return yield new Promise((e=>setTimeout(e,o))),r.retryableWrite(e,n+1)}throw t}}))()}monitorBackpressure(){var e=this;return G((function*(){var t=e.queueSize,r=.7*e.options.bufferSize,n=.9*e.options.bufferSize;if(t<r)e.isBackpressure&&(e.isBackpressure=!1,e.dispatchBackpressureEvent({currentSize:t,averageSize:e.getAverageQueueSize(),threshold:r,waitingTime:0}));else{e.isBackpressure||(e.isBackpressure=!0,e.dispatchBackpressureEvent({currentSize:t,averageSize:e.getAverageQueueSize(),threshold:r,waitingTime:0}));var o,i=t/e.options.bufferSize;o=t>=n?50+Math.min(200,100*i):Math.min(20,30*i);for(var s=0;e.queueSize>=r&&s<3&&!e.abortController.signal.aborted;)yield new Promise((e=>setTimeout(e,o))),s++,o=Math.min(1.5*o,100);if(e.queueSize>=r){var a=Date.now();a-e.lastBpWarnAt>1e3&&(e.lastBpWarnAt=a)}}}))()}calculateRetryDelay(e){return Math.min(10*Math.pow(2,e)+100*Math.random(),100)}processQueue(){var e=this;return G((function*(){if(!e.isProcessingQueue&&!e.abortController.signal.aborted){for(e.isProcessingQueue=!0;e.writeQueue.length>0&&!e.abortController.signal.aborted;){e.queueSize>.5*e.options.bufferSize&&(yield e.monitorBackpressure());var t=e.writeQueue.shift();yield t()}e.isProcessingQueue=!1}}))()}updateProgress(e){this.bytesWritten+=e,this.dispatchEvent(new CustomEvent("progress",{detail:{loaded:this.bytesWritten}}))}end(){var e=this;return G((function*(){var t,r;e.p.end(),yield null===(t=(r=e.sink).return)||void 0===t?void 0:t.call(r),e.cleanup()}))()}abort(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"User aborted";this.abortController.abort(e),this.cleanup(),this.dispatchEvent(new CustomEvent("abort",{detail:e}))}cleanup(){this.p.end(),this.abortController.abort(),this.writeQueue=[],this.watchdogTimer&&(clearInterval(this.watchdogTimer),this.watchdogTimer=void 0)}flush(){var e=arguments,t=this;return G((function*(){var r=e.length>0&&void 0!==e[0]?e[0]:1e4,n=Date.now();if(!(t.queueSize<=0)||t.isProcessingQueue||0!==t.writeQueue.length)for(;;){if(t.abortController.signal.aborted)return;if(t.queueSize<=0&&!t.isProcessingQueue&&0===t.writeQueue.length)return;if(Date.now()-n>r)return;yield new Promise((e=>setTimeout(e,10)))}}))()}addEventListener(e,t){var r=this.listeners.get(e)||[];r.push(t),this.listeners.set(e,r)}dispatchEvent(e){(this.listeners.get(e.type)||[]).forEach((t=>t(e)))}dispatchBackpressureEvent(e){this.dispatchEvent(new CustomEvent("backpressure",{detail:e}))}}var $E=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(255!==r[s])throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function d(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,o=0;e[t]===c;)n++,t++;for(var i=(e.length-t)*u+1>>>0,s=new Uint8Array(i);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var d=0,h=i-1;(0!==l||d<o)&&-1!==h;h--,d++)l+=a*s[h]>>>0,s[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=d,t++}if(" "!==e[t]){for(var p=i-o;p!==i&&0===s[p];)p++;for(var y=new Uint8Array(n+(i-p)),f=n;p!==i;)y[f++]=s[p++];return y}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*l+1>>>0,u=new Uint8Array(s);o!==i;){for(var d=t[o],h=0,p=s-1;(0!==d||h<n)&&-1!==p;p--,h++)d+=256*u[p]>>>0,u[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");n=h,o++}for(var y=s-n;y!==s&&0===u[y];)y++;for(var f=c.repeat(r);y<s;++y)f+=e.charAt(u[y]);return f},decodeUnsafe:d,decode:function(e){var r=d(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}},YE=$E;let ZE=class{constructor(e,t,r){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}},QE=class{constructor(e,t,r){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseDecode",void 0),W(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t;var n=t.codePointAt(0);if(void 0===n)throw new Error("Invalid prefix character");this.prefixCodePoint=n,this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return eC(this,e)}},XE=class{constructor(e){W(this,"decoders",void 0),this.decoders=e}or(e){return eC(this,e)}decode(e){var t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}};function eC(e,t){var r,n;return new XE(Z(Z({},null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e}),null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}))}let tC=class{constructor(e,t,r,n){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseEncode",void 0),W(this,"baseDecode",void 0),W(this,"encoder",void 0),W(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new ZE(e,t,r),this.decoder=new QE(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function rC(e){var{name:t,prefix:r,encode:n,decode:o}=e;return new tC(t,r,n,o)}function nC(e){var{name:t,prefix:r,alphabet:n}=e,{encode:o,decode:i}=YE(n,t);return rC({prefix:r,name:t,encode:o,decode:e=>function(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}(i(e))})}function oC(e){var{name:t,prefix:r,bitsPerChar:n,alphabet:o}=e;return rC({prefix:r,name:t,encode:e=>function(e,t,r){for(var n="="===t[t.length-1],o=(1<<r)-1,i="",s=0,a=0,c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)i+=t[o&a>>(s-=r)];if(0!==s&&(i+=t[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}(e,o,n),decode:e=>function(e,t,r,n){for(var o={},i=0;i<t.length;++i)o[t[i]]=i;for(var s=e.length;"="===e[s-1];)--s;for(var a=new Uint8Array(s*r/8|0),c=0,u=0,l=0,d=0;d<s;++d){var h=o[e[d]];if(void 0===h)throw new SyntaxError("Non-".concat(n," character"));u=u<<r|h,(c+=r)>=8&&(c-=8,a[l++]=255&u>>c)}if(c>=r||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return a}(e,o,n,t)})}var iC=nC({prefix:"9",name:"base10",alphabet:"0123456789"}),sC=Object.freeze({__proto__:null,base10:iC}),aC=oC({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),cC=oC({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),uC=Object.freeze({__proto__:null,base16:aC,base16upper:cC}),lC=oC({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),dC=Object.freeze({__proto__:null,base2:lC}),hC=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),pC=hC.reduce(((e,t,r)=>(e[r]=t,e)),[]),yC=hC.reduce(((e,t,r)=>{var n=t.codePointAt(0);if(null==n)throw new Error("Invalid character: ".concat(t));return e[n]=r,e}),[]);var fC=rC({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=pC[t]),"")},decode:function(e){var t=[];for(var r of e){var n=r.codePointAt(0);if(null==n)throw new Error("Invalid character: ".concat(r));var o=yC[n];if(null==o)throw new Error("Non-base256emoji character: ".concat(r));t.push(o)}return new Uint8Array(t)}}),gC=Object.freeze({__proto__:null,base256emoji:fC}),bC=oC({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mC=oC({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wC=oC({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vC=oC({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),kC=oC({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),SC=oC({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),OC=oC({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),AC=oC({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),IC=oC({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),xC=Object.freeze({__proto__:null,base32:bC,base32hex:kC,base32hexpad:OC,base32hexpadupper:AC,base32hexupper:SC,base32pad:wC,base32padupper:vC,base32upper:mC,base32z:IC}),PC=nC({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),EC=nC({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),CC=Object.freeze({__proto__:null,base36:PC,base36upper:EC}),BC=nC({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),TC=nC({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),DC=Object.freeze({__proto__:null,base58btc:BC,base58flickr:TC}),RC=oC({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),jC=oC({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),NC=oC({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),UC=oC({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),KC=Object.freeze({__proto__:null,base64:RC,base64pad:jC,base64url:NC,base64urlpad:UC}),qC=oC({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),LC=Object.freeze({__proto__:null,base8:qC}),_C=rC({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),MC=Object.freeze({__proto__:null,identity:_C});new TextEncoder,new TextDecoder;var FC=Z(Z(Z(Z(Z(Z(Z(Z(Z(Z({},MC),dC),LC),sC),uC),xC),CC),DC),KC),gC);function zC(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var GC=zC("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),VC=zC("ascii","a",(e=>{for(var t="a",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{for(var t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length),r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),HC=Z({utf8:GC,"utf-8":GC,hex:FC.base16,latin1:VC,ascii:VC,binary:VC},FC);let WC=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4096;this.dynamicTable=[],this.dynamicTableSize=0,this.maxDynamicTableSize=e,this.staticTable=[["",""],[":authority",""],[":method","GET"],[":method","POST"],[":path","/"],[":path","/index.html"],[":scheme","http"],[":scheme","https"],[":status","200"],[":status","204"],[":status","206"],[":status","304"],[":status","400"],[":status","404"],[":status","500"],["accept-charset",""],["accept-encoding","gzip, deflate"],["accept-language",""],["accept-ranges",""],["accept",""],["access-control-allow-origin",""],["age",""],["allow",""],["authorization",""],["cache-control",""],["content-disposition",""],["content-encoding",""],["content-language",""],["content-length",""],["content-location",""],["content-range",""],["content-type",""],["cookie",""],["date",""],["etag",""],["expect",""],["expires",""],["from",""],["host",""],["if-match",""],["if-modified-since",""],["if-none-match",""],["if-range",""],["if-unmodified-since",""],["last-modified",""],["link",""],["location",""],["max-forwards",""],["proxy-authenticate",""],["proxy-authorization",""],["range",""],["referer",""],["refresh",""],["retry-after",""],["server",""],["set-cookie",""],["strict-transport-security",""],["transfer-encoding",""],["user-agent",""],["vary",""],["via",""],["www-authenticate",""]],this.huffmanTable=this.buildHuffmanTable()}encode(e){var t=[];for(var[r,n]of Object.entries(e)){var o=this.findInStaticTable(r,n);if(-1===o){var i=this.findInDynamicTable(r,n);-1===i?this.encodeLiteral(t,r,n):t.push(...this.encodeInteger(i+this.staticTable.length,7,128))}else t.push(...this.encodeInteger(o,7,128))}return new Uint8Array(t)}encodeInteger(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=[],o=(1<<t)-1;if(e<o)return n.push(r|e),n;for(n.push(r|o),e-=o;e>=128;)n.push(127&e|128),e>>=7;return n.push(e),n}encodeString(e){var t=[],r=(new TextEncoder).encode(e),n=this.huffmanEncode(r);return n.length<r.length?(t.push(...this.encodeInteger(n.length,7,128)),t.push(...n)):(t.push(...this.encodeInteger(r.length,7,0)),t.push(...r)),t}findInStaticTable(e,t){for(var r=1;r<this.staticTable.length;r++)if(this.staticTable[r][0]===e&&this.staticTable[r][1]===t)return r;return-1}findInDynamicTable(e,t){for(var r=0;r<this.dynamicTable.length;r++)if(this.dynamicTable[r][0]===e&&this.dynamicTable[r][1]===t)return r;return-1}encodeLiteral(e,t,r){var n=this.findInStaticTable(t,"");-1!==n?e.push(...this.encodeInteger(n,6,64)):(e.push(64),e.push(...this.encodeString(t))),e.push(...this.encodeString(r)),this.addToDynamicTable(t,r)}addToDynamicTable(e,t){for(var r=e.length+t.length+32;this.dynamicTableSize+r>this.maxDynamicTableSize&&this.dynamicTable.length>0;){var n=this.dynamicTable.pop();n&&(this.dynamicTableSize-=n[0].length+n[1].length+32)}r<=this.maxDynamicTableSize&&(this.dynamicTable.unshift([e,t]),this.dynamicTableSize+=r),this.dynamicTable.push([e,t])}getIndexedHeader(e){return e<=this.staticTable.length-1?this.staticTable[e]:this.dynamicTable[e-this.staticTable.length]}buildHuffmanTable(){return{codes:new Uint32Array([8184,8388568,268435426,268435427,268435428,268435429,268435430,268435431,268435432,16777194,1073741820,268435433,268435434,1073741821,268435435,268435436,268435437,268435438,268435439,268435440,268435441,268435442,1073741822,268435443,268435444,268435445,268435446,268435447,268435448,268435449,268435450,268435451,20,1016,1017,4090,8185,21,248,2042,1018,1019,249,2043,250,22,23,24,0,1,2,25,26,27,28,29,30,31,92,251,32764,32,4091,1020,8186,33,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,252,115,253,8187,524272,8188,16380,34,32765,3,35,4,36,5,37,38,39,6,116,117,40,41,42,7,43,118,44,8,9,45,119,120,121,122,123,32766,2044,16381,8189,268435452,1048550,4194258,1048551,1048552,4194259,4194260,4194261,8388569,4194262,8388570,8388571,8388572,8388573,8388574,16777195,8388575,16777196,16777197,4194263,8388576,16777198,8388577,8388578,8388579,8388580,2097116,4194264,8388581,4194265,8388582,8388583,16777199,4194266,2097117,1048553,4194267,4194268,8388584,8388585,2097118,8388586,4194269,4194270,16777200,2097119,4194271,8388587,8388588,2097120,2097121,4194272,2097122,8388589,4194273,8388590,8388591,1048554,4194274,4194275,4194276,8388592,4194277,4194278,8388593,67108832,67108833,1048555,524273,4194279,8388594,4194280,33554412,67108834,67108835,67108836,134217694,134217695,67108837,16777201,33554413,524274,2097123,67108838,134217696,134217697,67108839,134217698,16777202,2097124,2097125,67108840,67108841,268435453,134217699,134217700,134217701,1048556,16777203,1048557,2097126,4194281,2097127,2097128,8388595,4194282,4194283,33554414,33554415,16777204,16777205,67108842,8388596,67108843,134217702,67108844,67108845,134217703,134217704,134217705,134217706,134217707,268435454,134217708,134217709,134217710,134217711,134217712,67108846]),lengths:new Uint8Array([13,23,28,28,28,28,28,28,28,24,30,28,28,30,28,28,28,28,28,28,28,28,30,28,28,28,28,28,28,28,28,28,6,10,10,12,13,6,8,11,10,10,8,11,8,6,6,6,5,5,5,6,6,6,6,6,6,6,7,8,15,6,12,10,13,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,7,8,13,19,13,14,6,15,5,6,5,6,5,6,6,6,5,7,7,6,6,6,5,6,7,6,5,5,6,7,7,7,7,7,15,11,14,13,28,20,22,20,20,22,22,22,23,22,23,23,23,23,23,24,23,24,24,22,23,24,23,23,23,23,21,22,23,22,23,23,24,22,21,20,22,22,23,23,21,23,22,22,24,21,22,23,23,21,21,22,21,23,22,23,23,20,22,22,22,23,22,22,23,26,26,20,19,22,23,22,25,26,26,26,27,27,26,24,25,19,21,26,27,27,26,27,24,21,21,26,26,28,27,27,27,20,24,20,21,22,21,21,23,22,22,25,25,24,24,26,23,26,27,26,26,27,27,27,27,27,28,27,27,27,27,27,26])}}decode(e){for(var t="",r=0,n=0,o=0;o<e.length;o++){for(r=r<<8|e[o],n+=8;n>=5;){var i=this.findSymbol(r,n);if(!i)break;var[s,a]=i;t+=String.fromCharCode(s),r&=(1<<n-a)-1,n-=a}}if(n>0){var c=(1<<n)-1;if((r&c)!==c)throw new Error("Invalid Huffman padding")}return t}findSymbol(e,t){for(var r=0;r<this.huffmanTable.codes.length;r++){var n=this.huffmanTable.lengths[r];if(!(t<n))if((e>>t-n&(1<<n)-1)===this.huffmanTable.codes[r])return[r,n]}return null}huffmanEncode(e){for(var t=[],r=0,n=0,o=0;o<e.length;o++){var i=e[o],s=this.huffmanTable.codes[i],a=this.huffmanTable.lengths[i];for(n+=a,r=r<<a|s;n>=8;)n-=8,t.push(r>>n&255)}return n>0&&(r=r<<8-n|(1<<8-n)-1,t.push(255&r)),new Uint8Array(t)}decodeHeaderFields(e){for(var t=new Map,r=0;r<e.length;){var n=e[r];if(128&n){var[o,i,s]=this.decodeIndexedHeader(e,r);o&&i&&t.set(o,i),r=s}else if(64&n){var[a,c,u]=this.decodeLiteralHeaderWithIndexing(e,r);a&&c&&t.set(a,c),r=u}else if(32&n)r++;else if(16&n){var[l,d,h]=this.decodeLiteralHeaderWithoutIndexing(e,r);l&&d&&t.set(l,d),r=h}else{var[p,y,f]=this.decodeLiteralHeaderWithoutIndexing(e,r);p&&y&&t.set(p,y),r=f}}return t}decodeInteger(e,t,r){var n=(1<<r)-1,o=t,i=e[t]&n;if(i<n)return[i,o+1];o++;for(var s=0;o<e.length;){var a=e[o++];if(i+=(127&a)<<s,s+=7,!(128&a))break}return[i,o]}decodeLiteralString(e,t){if(t>=e.length)return["",t];var r=!!(128&e[t]),[n,o]=this.decodeInteger(e,t,7);if(o+n>e.length)return["",o];var i,s=e.slice(o,o+n);if(r)try{i=this.decode(s)}catch(e){i=""}else try{i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8",r=HC[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}(s)}catch(e){i=""}return[i,o+n]}decodeIndexedHeader(e,t){var[r,n]=this.decodeInteger(e,t,7);if(r<=0)return["","",n];var o=this.staticTable[r];return o?[o[0],o[1],n]:["","",n]}decodeLiteralHeaderWithIndexing(e,t){var r,[n,o]=this.decodeInteger(e,t,6);if(t=o,n>0){var i=this.staticTable[n];r=i?i[0]:""}else{var[s,a]=this.decodeLiteralString(e,t);r=s,t=a}var[c,u]=this.decodeLiteralString(e,t);return[r,c,u]}decodeLiteralHeaderWithoutIndexing(e,t){return this.decodeLiteralHeaderWithIndexing(e,t)}huffmanDecodeToString(e){return this.decode(e)}},JC=class{static encodeSettingsFrame(e){var t=6*e.payload.length,r=new Uint8Array(9+t);return $C(r,{length:t,type:e.type,flags:e.flags,streamId:e.streamId}),function(e,t){var r=9;t.forEach((t=>{!function(e,t,r){e[r]=t>>8&255,e[r+1]=255&t}(e,t.identifier,r),r+=2,YC(e,t.value,r),r+=4}))}(r,e.payload),r}static encodeSettingsAckFrame(){var e=new Uint8Array(9);return $C(e,{length:0,type:4,flags:1,streamId:0}),e}};function $C(e,t){var r,n=null!==(r=t.length)&&void 0!==r?r:0;e[0]=n>>16&255,e[1]=n>>8&255,e[2]=255&n,e[3]=t.type,e[4]=t.flags,YC(e,2147483647&t.streamId,5)}function YC(e,t,r){e[r]=t>>24&255,e[r+1]=t>>16&255,e[r+2]=t>>8&255,e[r+3]=255&t}var ZC=1,QC=2,XC=3,eB=4,tB=5,rB=6,nB={[ZC]:4096,[QC]:1,[XC]:100,[eB]:16384,[tB]:16384,[rB]:8192};let oB=class e{static createPreface(){return(new TextEncoder).encode("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n")}static createPongFrame(t){return e.createFrame(6,1,0,t)}static createSettingsFrame(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.createOriginSettingsFrame(t);return JC.encodeSettingsFrame(r)}static createSettingsAckFrame(){return JC.encodeSettingsAckFrame()}static createWindowUpdateFrame(t,r){if(r<=0||r>2147483647)throw new Error("Window size increment must be between 1 and 2^31-1");var n=new Uint8Array(4);return n[0]=r>>24&127,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=255&r,e.createFrame(8,0,t,n)}static createDataFrames(t,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16384,i=[],s=r.length,a=new Uint8Array(5+s);a[0]=0,a[1]=s>>24&255,a[2]=s>>16&255,a[3]=s>>8&255,a[4]=255&s,a.set(r,5);for(var c=o-9,u=0;u<a.length;u+=c){var l=a.length-u,d=Math.min(c,l),h=a.slice(u,u+d),p=u+d>=a.length&&n,y=e.createFrame(0,p?1:0,t,h);i.push(y)}return i}static createDataFrame(t,r){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=r.length,i=new Uint8Array(5+o);i[0]=0,i[1]=o>>24&255,i[2]=o>>16&255,i[3]=o>>8&255,i[4]=255&o,i.set(r,5);var s=n?1:0;return e.createFrame(0,s,t,i)}static createHeadersFrame(t,r){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3?arguments[3]:void 0,i={":path":r,":method":"POST",":scheme":"http",":authority":"localhost","content-type":"application/grpc+proto","user-agent":"grpc-web-client/0.1",accept:"application/grpc+proto","grpc-timeout":"3600S"};o&&(i.authorization="Bearer ".concat(o));var s=(new WC).encode(i),a=n?4:0;return e.createFrame(1,a,t,s)}static createResponseHeadersFrame(t,r){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=(new WC).encode(r),i=n?4:0;return e.createFrame(1,i,t,o)}static createTrailersFrame(t,r){var n=(new WC).encode(r);return e.createFrame(1,5,t,n)}static createOriginSettingsFrame(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Z(Z({},nB),e);return function(e){for(var[t,r]of Object.entries(e))switch(Number(t)){case ZC:if(r<0)throw new Error("HEADER_TABLE_SIZE must be non-negative");break;case QC:if(0!==r&&1!==r)throw new Error("ENABLE_PUSH must be 0 or 1");break;case eB:if(r<0||r>2147483647)throw new Error("INITIAL_WINDOW_SIZE must be between 0 and 2^31-1");break;case tB:if(r<16384||r>16777215)throw new Error("MAX_FRAME_SIZE must be between 16,384 and 16,777,215");break;case XC:case rB:if(r<0)throw new Error("Parameter ".concat(t," must be non-negative"))}}(t),{type:4,flags:0,streamId:0,payload:iB(t)}}static createOriginSettingsAckFrame(){return{type:4,flags:1,streamId:0,payload:[]}}static createFrame(e,t,r,n){var o=n?n.length:0,i=new Uint8Array(9+o);return i[0]=o>>16&255,i[1]=o>>8&255,i[2]=255&o,i[3]=e,i[4]=t,i[5]=r>>24&255,i[6]=r>>16&255,i[7]=r>>8&255,i[8]=255&r,n&&o>0&&i.set(n,9),i}};function iB(e){var t=[];for(var[r,n]of Object.entries(e))t.push({identifier:Number(r),value:n});return t}var sB=o.minimalExports.Reader,aB=o.minimalExports.Writer,cB=o.minimalExports.util,uB=o.minimalExports.roots.default||(o.minimalExports.roots.default={}),lB=uB.net=(()=>{var e,t={};return t.pb=((e={}).Log=function(){function e(e){if(this.addrs=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.ID=cB.newBuffer([]),e.prototype.pubKey=cB.newBuffer([]),e.prototype.addrs=cB.emptyArray,e.prototype.head=cB.newBuffer([]),e.prototype.counter=cB.Long?cB.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=aB.create()),null!=e.ID&&Object.hasOwnProperty.call(e,"ID")&&t.uint32(10).bytes(e.ID),null!=e.pubKey&&Object.hasOwnProperty.call(e,"pubKey")&&t.uint32(18).bytes(e.pubKey),null!=e.addrs&&e.addrs.length)for(var r=0;r<e.addrs.length;++r)t.uint32(26).bytes(e.addrs[r]);return null!=e.head&&Object.hasOwnProperty.call(e,"head")&&t.uint32(34).bytes(e.head),null!=e.counter&&Object.hasOwnProperty.call(e,"counter")&&t.uint32(40).int64(e.counter),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.Log;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.ID=e.bytes();break;case 2:n.pubKey=e.bytes();break;case 3:n.addrs&&n.addrs.length||(n.addrs=[]),n.addrs.push(e.bytes());break;case 4:n.head=e.bytes();break;case 5:n.counter=e.int64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.ID&&e.hasOwnProperty("ID")&&!(e.ID&&"number"==typeof e.ID.length||cB.isString(e.ID)))return"ID: buffer expected";if(null!=e.pubKey&&e.hasOwnProperty("pubKey")&&!(e.pubKey&&"number"==typeof e.pubKey.length||cB.isString(e.pubKey)))return"pubKey: buffer expected";if(null!=e.addrs&&e.hasOwnProperty("addrs")){if(!Array.isArray(e.addrs))return"addrs: array expected";for(var t=0;t<e.addrs.length;++t)if(!(e.addrs[t]&&"number"==typeof e.addrs[t].length||cB.isString(e.addrs[t])))return"addrs: buffer[] expected"}return null!=e.head&&e.hasOwnProperty("head")&&!(e.head&&"number"==typeof e.head.length||cB.isString(e.head))?"head: buffer expected":null!=e.counter&&e.hasOwnProperty("counter")&&!(cB.isInteger(e.counter)||e.counter&&cB.isInteger(e.counter.low)&&cB.isInteger(e.counter.high))?"counter: integer|Long expected":null},e.fromObject=function(e){if(e instanceof uB.net.pb.Log)return e;var t=new uB.net.pb.Log;if(null!=e.ID&&("string"==typeof e.ID?cB.base64.decode(e.ID,t.ID=cB.newBuffer(cB.base64.length(e.ID)),0):e.ID.length>=0&&(t.ID=e.ID)),null!=e.pubKey&&("string"==typeof e.pubKey?cB.base64.decode(e.pubKey,t.pubKey=cB.newBuffer(cB.base64.length(e.pubKey)),0):e.pubKey.length>=0&&(t.pubKey=e.pubKey)),e.addrs){if(!Array.isArray(e.addrs))throw TypeError(".net.pb.Log.addrs: array expected");t.addrs=[];for(var r=0;r<e.addrs.length;++r)"string"==typeof e.addrs[r]?cB.base64.decode(e.addrs[r],t.addrs[r]=cB.newBuffer(cB.base64.length(e.addrs[r])),0):e.addrs[r].length>=0&&(t.addrs[r]=e.addrs[r])}return null!=e.head&&("string"==typeof e.head?cB.base64.decode(e.head,t.head=cB.newBuffer(cB.base64.length(e.head)),0):e.head.length>=0&&(t.head=e.head)),null!=e.counter&&(cB.Long?(t.counter=cB.Long.fromValue(e.counter)).unsigned=!1:"string"==typeof e.counter?t.counter=parseInt(e.counter,10):"number"==typeof e.counter?t.counter=e.counter:"object"==typeof e.counter&&(t.counter=new cB.LongBits(e.counter.low>>>0,e.counter.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.addrs=[]),t.defaults)if(t.bytes===String?r.ID="":(r.ID=[],t.bytes!==Array&&(r.ID=cB.newBuffer(r.ID))),t.bytes===String?r.pubKey="":(r.pubKey=[],t.bytes!==Array&&(r.pubKey=cB.newBuffer(r.pubKey))),t.bytes===String?r.head="":(r.head=[],t.bytes!==Array&&(r.head=cB.newBuffer(r.head))),cB.Long){var n=new cB.Long(0,0,!1);r.counter=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.counter=t.longs===String?"0":0;if(null!=e.ID&&e.hasOwnProperty("ID")&&(r.ID=t.bytes===String?cB.base64.encode(e.ID,0,e.ID.length):t.bytes===Array?Array.prototype.slice.call(e.ID):e.ID),null!=e.pubKey&&e.hasOwnProperty("pubKey")&&(r.pubKey=t.bytes===String?cB.base64.encode(e.pubKey,0,e.pubKey.length):t.bytes===Array?Array.prototype.slice.call(e.pubKey):e.pubKey),e.addrs&&e.addrs.length){r.addrs=[];for(var o=0;o<e.addrs.length;++o)r.addrs[o]=t.bytes===String?cB.base64.encode(e.addrs[o],0,e.addrs[o].length):t.bytes===Array?Array.prototype.slice.call(e.addrs[o]):e.addrs[o]}return null!=e.head&&e.hasOwnProperty("head")&&(r.head=t.bytes===String?cB.base64.encode(e.head,0,e.head.length):t.bytes===Array?Array.prototype.slice.call(e.head):e.head),null!=e.counter&&e.hasOwnProperty("counter")&&("number"==typeof e.counter?r.counter=t.longs===String?String(e.counter):e.counter:r.counter=t.longs===String?cB.Long.prototype.toString.call(e.counter):t.longs===Number?new cB.LongBits(e.counter.low>>>0,e.counter.high>>>0).toNumber():e.counter),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.Log"},e.Record=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.recordNode=cB.newBuffer([]),e.prototype.eventNode=cB.newBuffer([]),e.prototype.headerNode=cB.newBuffer([]),e.prototype.bodyNode=cB.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.recordNode&&Object.hasOwnProperty.call(e,"recordNode")&&t.uint32(10).bytes(e.recordNode),null!=e.eventNode&&Object.hasOwnProperty.call(e,"eventNode")&&t.uint32(18).bytes(e.eventNode),null!=e.headerNode&&Object.hasOwnProperty.call(e,"headerNode")&&t.uint32(26).bytes(e.headerNode),null!=e.bodyNode&&Object.hasOwnProperty.call(e,"bodyNode")&&t.uint32(34).bytes(e.bodyNode),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.Log.Record;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.recordNode=e.bytes();break;case 2:n.eventNode=e.bytes();break;case 3:n.headerNode=e.bytes();break;case 4:n.bodyNode=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.recordNode&&e.hasOwnProperty("recordNode")&&!(e.recordNode&&"number"==typeof e.recordNode.length||cB.isString(e.recordNode))?"recordNode: buffer expected":null!=e.eventNode&&e.hasOwnProperty("eventNode")&&!(e.eventNode&&"number"==typeof e.eventNode.length||cB.isString(e.eventNode))?"eventNode: buffer expected":null!=e.headerNode&&e.hasOwnProperty("headerNode")&&!(e.headerNode&&"number"==typeof e.headerNode.length||cB.isString(e.headerNode))?"headerNode: buffer expected":null!=e.bodyNode&&e.hasOwnProperty("bodyNode")&&!(e.bodyNode&&"number"==typeof e.bodyNode.length||cB.isString(e.bodyNode))?"bodyNode: buffer expected":null},e.fromObject=function(e){if(e instanceof uB.net.pb.Log.Record)return e;var t=new uB.net.pb.Log.Record;return null!=e.recordNode&&("string"==typeof e.recordNode?cB.base64.decode(e.recordNode,t.recordNode=cB.newBuffer(cB.base64.length(e.recordNode)),0):e.recordNode.length>=0&&(t.recordNode=e.recordNode)),null!=e.eventNode&&("string"==typeof e.eventNode?cB.base64.decode(e.eventNode,t.eventNode=cB.newBuffer(cB.base64.length(e.eventNode)),0):e.eventNode.length>=0&&(t.eventNode=e.eventNode)),null!=e.headerNode&&("string"==typeof e.headerNode?cB.base64.decode(e.headerNode,t.headerNode=cB.newBuffer(cB.base64.length(e.headerNode)),0):e.headerNode.length>=0&&(t.headerNode=e.headerNode)),null!=e.bodyNode&&("string"==typeof e.bodyNode?cB.base64.decode(e.bodyNode,t.bodyNode=cB.newBuffer(cB.base64.length(e.bodyNode)),0):e.bodyNode.length>=0&&(t.bodyNode=e.bodyNode)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.recordNode="":(r.recordNode=[],t.bytes!==Array&&(r.recordNode=cB.newBuffer(r.recordNode))),t.bytes===String?r.eventNode="":(r.eventNode=[],t.bytes!==Array&&(r.eventNode=cB.newBuffer(r.eventNode))),t.bytes===String?r.headerNode="":(r.headerNode=[],t.bytes!==Array&&(r.headerNode=cB.newBuffer(r.headerNode))),t.bytes===String?r.bodyNode="":(r.bodyNode=[],t.bytes!==Array&&(r.bodyNode=cB.newBuffer(r.bodyNode)))),null!=e.recordNode&&e.hasOwnProperty("recordNode")&&(r.recordNode=t.bytes===String?cB.base64.encode(e.recordNode,0,e.recordNode.length):t.bytes===Array?Array.prototype.slice.call(e.recordNode):e.recordNode),null!=e.eventNode&&e.hasOwnProperty("eventNode")&&(r.eventNode=t.bytes===String?cB.base64.encode(e.eventNode,0,e.eventNode.length):t.bytes===Array?Array.prototype.slice.call(e.eventNode):e.eventNode),null!=e.headerNode&&e.hasOwnProperty("headerNode")&&(r.headerNode=t.bytes===String?cB.base64.encode(e.headerNode,0,e.headerNode.length):t.bytes===Array?Array.prototype.slice.call(e.headerNode):e.headerNode),null!=e.bodyNode&&e.hasOwnProperty("bodyNode")&&(r.bodyNode=t.bytes===String?cB.base64.encode(e.bodyNode,0,e.bodyNode.length):t.bytes===Array?Array.prototype.slice.call(e.bodyNode):e.bodyNode),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.Log.Record"},e}(),e}(),e.GetLogsRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.body=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.body&&Object.hasOwnProperty.call(e,"body")&&uB.net.pb.GetLogsRequest.Body.encode(e.body,t.uint32(18).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.GetLogsRequest;e.pos<r;){var o=e.uint32();o>>>3==2?n.body=uB.net.pb.GetLogsRequest.Body.decode(e,e.uint32()):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.body&&e.hasOwnProperty("body")){var t=uB.net.pb.GetLogsRequest.Body.verify(e.body);if(t)return"body."+t}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.GetLogsRequest)return e;var t=new uB.net.pb.GetLogsRequest;if(null!=e.body){if("object"!=typeof e.body)throw TypeError(".net.pb.GetLogsRequest.body: object expected");t.body=uB.net.pb.GetLogsRequest.Body.fromObject(e.body)}return t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.body=null),null!=e.body&&e.hasOwnProperty("body")&&(r.body=uB.net.pb.GetLogsRequest.Body.toObject(e.body,t)),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.GetLogsRequest"},e.Body=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=cB.newBuffer([]),e.prototype.serviceKey=cB.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.serviceKey&&Object.hasOwnProperty.call(e,"serviceKey")&&t.uint32(18).bytes(e.serviceKey),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.GetLogsRequest.Body;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.serviceKey=e.bytes();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||cB.isString(e.threadID))?"threadID: buffer expected":null!=e.serviceKey&&e.hasOwnProperty("serviceKey")&&!(e.serviceKey&&"number"==typeof e.serviceKey.length||cB.isString(e.serviceKey))?"serviceKey: buffer expected":null},e.fromObject=function(e){if(e instanceof uB.net.pb.GetLogsRequest.Body)return e;var t=new uB.net.pb.GetLogsRequest.Body;return null!=e.threadID&&("string"==typeof e.threadID?cB.base64.decode(e.threadID,t.threadID=cB.newBuffer(cB.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.serviceKey&&("string"==typeof e.serviceKey?cB.base64.decode(e.serviceKey,t.serviceKey=cB.newBuffer(cB.base64.length(e.serviceKey)),0):e.serviceKey.length>=0&&(t.serviceKey=e.serviceKey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=cB.newBuffer(r.threadID))),t.bytes===String?r.serviceKey="":(r.serviceKey=[],t.bytes!==Array&&(r.serviceKey=cB.newBuffer(r.serviceKey)))),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?cB.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.serviceKey&&e.hasOwnProperty("serviceKey")&&(r.serviceKey=t.bytes===String?cB.base64.encode(e.serviceKey,0,e.serviceKey.length):t.bytes===Array?Array.prototype.slice.call(e.serviceKey):e.serviceKey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.GetLogsRequest.Body"},e}(),e}(),e.GetLogsReply=function(){function e(e){if(this.logs=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.logs=cB.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=aB.create()),null!=e.logs&&e.logs.length)for(var r=0;r<e.logs.length;++r)uB.net.pb.Log.encode(e.logs[r],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.GetLogsReply;e.pos<r;){var o=e.uint32();o>>>3==1?(n.logs&&n.logs.length||(n.logs=[]),n.logs.push(uB.net.pb.Log.decode(e,e.uint32()))):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.logs&&e.hasOwnProperty("logs")){if(!Array.isArray(e.logs))return"logs: array expected";for(var t=0;t<e.logs.length;++t){var r=uB.net.pb.Log.verify(e.logs[t]);if(r)return"logs."+r}}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.GetLogsReply)return e;var t=new uB.net.pb.GetLogsReply;if(e.logs){if(!Array.isArray(e.logs))throw TypeError(".net.pb.GetLogsReply.logs: array expected");t.logs=[];for(var r=0;r<e.logs.length;++r){if("object"!=typeof e.logs[r])throw TypeError(".net.pb.GetLogsReply.logs: object expected");t.logs[r]=uB.net.pb.Log.fromObject(e.logs[r])}}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.logs=[]),e.logs&&e.logs.length){r.logs=[];for(var n=0;n<e.logs.length;++n)r.logs[n]=uB.net.pb.Log.toObject(e.logs[n],t)}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.GetLogsReply"},e}(),e.PushLogRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.body=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.body&&Object.hasOwnProperty.call(e,"body")&&uB.net.pb.PushLogRequest.Body.encode(e.body,t.uint32(18).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.PushLogRequest;e.pos<r;){var o=e.uint32();o>>>3==2?n.body=uB.net.pb.PushLogRequest.Body.decode(e,e.uint32()):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.body&&e.hasOwnProperty("body")){var t=uB.net.pb.PushLogRequest.Body.verify(e.body);if(t)return"body."+t}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.PushLogRequest)return e;var t=new uB.net.pb.PushLogRequest;if(null!=e.body){if("object"!=typeof e.body)throw TypeError(".net.pb.PushLogRequest.body: object expected");t.body=uB.net.pb.PushLogRequest.Body.fromObject(e.body)}return t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.body=null),null!=e.body&&e.hasOwnProperty("body")&&(r.body=uB.net.pb.PushLogRequest.Body.toObject(e.body,t)),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.PushLogRequest"},e.Body=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=cB.newBuffer([]),e.prototype.serviceKey=cB.newBuffer([]),e.prototype.readKey=cB.newBuffer([]),e.prototype.log=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.serviceKey&&Object.hasOwnProperty.call(e,"serviceKey")&&t.uint32(18).bytes(e.serviceKey),null!=e.readKey&&Object.hasOwnProperty.call(e,"readKey")&&t.uint32(26).bytes(e.readKey),null!=e.log&&Object.hasOwnProperty.call(e,"log")&&uB.net.pb.Log.encode(e.log,t.uint32(34).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.PushLogRequest.Body;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.serviceKey=e.bytes();break;case 3:n.readKey=e.bytes();break;case 4:n.log=uB.net.pb.Log.decode(e,e.uint32());break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||cB.isString(e.threadID)))return"threadID: buffer expected";if(null!=e.serviceKey&&e.hasOwnProperty("serviceKey")&&!(e.serviceKey&&"number"==typeof e.serviceKey.length||cB.isString(e.serviceKey)))return"serviceKey: buffer expected";if(null!=e.readKey&&e.hasOwnProperty("readKey")&&!(e.readKey&&"number"==typeof e.readKey.length||cB.isString(e.readKey)))return"readKey: buffer expected";if(null!=e.log&&e.hasOwnProperty("log")){var t=uB.net.pb.Log.verify(e.log);if(t)return"log."+t}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.PushLogRequest.Body)return e;var t=new uB.net.pb.PushLogRequest.Body;if(null!=e.threadID&&("string"==typeof e.threadID?cB.base64.decode(e.threadID,t.threadID=cB.newBuffer(cB.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.serviceKey&&("string"==typeof e.serviceKey?cB.base64.decode(e.serviceKey,t.serviceKey=cB.newBuffer(cB.base64.length(e.serviceKey)),0):e.serviceKey.length>=0&&(t.serviceKey=e.serviceKey)),null!=e.readKey&&("string"==typeof e.readKey?cB.base64.decode(e.readKey,t.readKey=cB.newBuffer(cB.base64.length(e.readKey)),0):e.readKey.length>=0&&(t.readKey=e.readKey)),null!=e.log){if("object"!=typeof e.log)throw TypeError(".net.pb.PushLogRequest.Body.log: object expected");t.log=uB.net.pb.Log.fromObject(e.log)}return t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=cB.newBuffer(r.threadID))),t.bytes===String?r.serviceKey="":(r.serviceKey=[],t.bytes!==Array&&(r.serviceKey=cB.newBuffer(r.serviceKey))),t.bytes===String?r.readKey="":(r.readKey=[],t.bytes!==Array&&(r.readKey=cB.newBuffer(r.readKey))),r.log=null),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?cB.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.serviceKey&&e.hasOwnProperty("serviceKey")&&(r.serviceKey=t.bytes===String?cB.base64.encode(e.serviceKey,0,e.serviceKey.length):t.bytes===Array?Array.prototype.slice.call(e.serviceKey):e.serviceKey),null!=e.readKey&&e.hasOwnProperty("readKey")&&(r.readKey=t.bytes===String?cB.base64.encode(e.readKey,0,e.readKey.length):t.bytes===Array?Array.prototype.slice.call(e.readKey):e.readKey),null!=e.log&&e.hasOwnProperty("log")&&(r.log=uB.net.pb.Log.toObject(e.log,t)),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.PushLogRequest.Body"},e}(),e}(),e.PushLogReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.PushLogReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof uB.net.pb.PushLogReply?e:new uB.net.pb.PushLogReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.PushLogReply"},e}(),e.GetRecordsRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.body=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.body&&Object.hasOwnProperty.call(e,"body")&&uB.net.pb.GetRecordsRequest.Body.encode(e.body,t.uint32(18).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.GetRecordsRequest;e.pos<r;){var o=e.uint32();o>>>3==2?n.body=uB.net.pb.GetRecordsRequest.Body.decode(e,e.uint32()):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.body&&e.hasOwnProperty("body")){var t=uB.net.pb.GetRecordsRequest.Body.verify(e.body);if(t)return"body."+t}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.GetRecordsRequest)return e;var t=new uB.net.pb.GetRecordsRequest;if(null!=e.body){if("object"!=typeof e.body)throw TypeError(".net.pb.GetRecordsRequest.body: object expected");t.body=uB.net.pb.GetRecordsRequest.Body.fromObject(e.body)}return t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.body=null),null!=e.body&&e.hasOwnProperty("body")&&(r.body=uB.net.pb.GetRecordsRequest.Body.toObject(e.body,t)),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.GetRecordsRequest"},e.Body=function(){function e(e){if(this.logs=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=cB.newBuffer([]),e.prototype.serviceKey=cB.newBuffer([]),e.prototype.logs=cB.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=aB.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.serviceKey&&Object.hasOwnProperty.call(e,"serviceKey")&&t.uint32(18).bytes(e.serviceKey),null!=e.logs&&e.logs.length)for(var r=0;r<e.logs.length;++r)uB.net.pb.GetRecordsRequest.Body.LogEntry.encode(e.logs[r],t.uint32(26).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.GetRecordsRequest.Body;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.serviceKey=e.bytes();break;case 3:n.logs&&n.logs.length||(n.logs=[]),n.logs.push(uB.net.pb.GetRecordsRequest.Body.LogEntry.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||cB.isString(e.threadID)))return"threadID: buffer expected";if(null!=e.serviceKey&&e.hasOwnProperty("serviceKey")&&!(e.serviceKey&&"number"==typeof e.serviceKey.length||cB.isString(e.serviceKey)))return"serviceKey: buffer expected";if(null!=e.logs&&e.hasOwnProperty("logs")){if(!Array.isArray(e.logs))return"logs: array expected";for(var t=0;t<e.logs.length;++t){var r=uB.net.pb.GetRecordsRequest.Body.LogEntry.verify(e.logs[t]);if(r)return"logs."+r}}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.GetRecordsRequest.Body)return e;var t=new uB.net.pb.GetRecordsRequest.Body;if(null!=e.threadID&&("string"==typeof e.threadID?cB.base64.decode(e.threadID,t.threadID=cB.newBuffer(cB.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.serviceKey&&("string"==typeof e.serviceKey?cB.base64.decode(e.serviceKey,t.serviceKey=cB.newBuffer(cB.base64.length(e.serviceKey)),0):e.serviceKey.length>=0&&(t.serviceKey=e.serviceKey)),e.logs){if(!Array.isArray(e.logs))throw TypeError(".net.pb.GetRecordsRequest.Body.logs: array expected");t.logs=[];for(var r=0;r<e.logs.length;++r){if("object"!=typeof e.logs[r])throw TypeError(".net.pb.GetRecordsRequest.Body.logs: object expected");t.logs[r]=uB.net.pb.GetRecordsRequest.Body.LogEntry.fromObject(e.logs[r])}}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.logs=[]),t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=cB.newBuffer(r.threadID))),t.bytes===String?r.serviceKey="":(r.serviceKey=[],t.bytes!==Array&&(r.serviceKey=cB.newBuffer(r.serviceKey)))),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?cB.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.serviceKey&&e.hasOwnProperty("serviceKey")&&(r.serviceKey=t.bytes===String?cB.base64.encode(e.serviceKey,0,e.serviceKey.length):t.bytes===Array?Array.prototype.slice.call(e.serviceKey):e.serviceKey),e.logs&&e.logs.length){r.logs=[];for(var n=0;n<e.logs.length;++n)r.logs[n]=uB.net.pb.GetRecordsRequest.Body.LogEntry.toObject(e.logs[n],t)}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.GetRecordsRequest.Body"},e.LogEntry=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.logID=cB.newBuffer([]),e.prototype.offset=cB.newBuffer([]),e.prototype.limit=0,e.prototype.counter=cB.Long?cB.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.logID&&Object.hasOwnProperty.call(e,"logID")&&t.uint32(10).bytes(e.logID),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(18).bytes(e.offset),null!=e.limit&&Object.hasOwnProperty.call(e,"limit")&&t.uint32(24).int32(e.limit),null!=e.counter&&Object.hasOwnProperty.call(e,"counter")&&t.uint32(32).int64(e.counter),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.GetRecordsRequest.Body.LogEntry;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.logID=e.bytes();break;case 2:n.offset=e.bytes();break;case 3:n.limit=e.int32();break;case 4:n.counter=e.int64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.logID&&e.hasOwnProperty("logID")&&!(e.logID&&"number"==typeof e.logID.length||cB.isString(e.logID))?"logID: buffer expected":null!=e.offset&&e.hasOwnProperty("offset")&&!(e.offset&&"number"==typeof e.offset.length||cB.isString(e.offset))?"offset: buffer expected":null!=e.limit&&e.hasOwnProperty("limit")&&!cB.isInteger(e.limit)?"limit: integer expected":null!=e.counter&&e.hasOwnProperty("counter")&&!(cB.isInteger(e.counter)||e.counter&&cB.isInteger(e.counter.low)&&cB.isInteger(e.counter.high))?"counter: integer|Long expected":null},e.fromObject=function(e){if(e instanceof uB.net.pb.GetRecordsRequest.Body.LogEntry)return e;var t=new uB.net.pb.GetRecordsRequest.Body.LogEntry;return null!=e.logID&&("string"==typeof e.logID?cB.base64.decode(e.logID,t.logID=cB.newBuffer(cB.base64.length(e.logID)),0):e.logID.length>=0&&(t.logID=e.logID)),null!=e.offset&&("string"==typeof e.offset?cB.base64.decode(e.offset,t.offset=cB.newBuffer(cB.base64.length(e.offset)),0):e.offset.length>=0&&(t.offset=e.offset)),null!=e.limit&&(t.limit=0|e.limit),null!=e.counter&&(cB.Long?(t.counter=cB.Long.fromValue(e.counter)).unsigned=!1:"string"==typeof e.counter?t.counter=parseInt(e.counter,10):"number"==typeof e.counter?t.counter=e.counter:"object"==typeof e.counter&&(t.counter=new cB.LongBits(e.counter.low>>>0,e.counter.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(t.bytes===String?r.logID="":(r.logID=[],t.bytes!==Array&&(r.logID=cB.newBuffer(r.logID))),t.bytes===String?r.offset="":(r.offset=[],t.bytes!==Array&&(r.offset=cB.newBuffer(r.offset))),r.limit=0,cB.Long){var n=new cB.Long(0,0,!1);r.counter=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.counter=t.longs===String?"0":0;return null!=e.logID&&e.hasOwnProperty("logID")&&(r.logID=t.bytes===String?cB.base64.encode(e.logID,0,e.logID.length):t.bytes===Array?Array.prototype.slice.call(e.logID):e.logID),null!=e.offset&&e.hasOwnProperty("offset")&&(r.offset=t.bytes===String?cB.base64.encode(e.offset,0,e.offset.length):t.bytes===Array?Array.prototype.slice.call(e.offset):e.offset),null!=e.limit&&e.hasOwnProperty("limit")&&(r.limit=e.limit),null!=e.counter&&e.hasOwnProperty("counter")&&("number"==typeof e.counter?r.counter=t.longs===String?String(e.counter):e.counter:r.counter=t.longs===String?cB.Long.prototype.toString.call(e.counter):t.longs===Number?new cB.LongBits(e.counter.low>>>0,e.counter.high>>>0).toNumber():e.counter),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.GetRecordsRequest.Body.LogEntry"},e}(),e}(),e}(),e.GetRecordsReply=function(){function e(e){if(this.logs=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.logs=cB.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=aB.create()),null!=e.logs&&e.logs.length)for(var r=0;r<e.logs.length;++r)uB.net.pb.GetRecordsReply.LogEntry.encode(e.logs[r],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.GetRecordsReply;e.pos<r;){var o=e.uint32();o>>>3==1?(n.logs&&n.logs.length||(n.logs=[]),n.logs.push(uB.net.pb.GetRecordsReply.LogEntry.decode(e,e.uint32()))):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.logs&&e.hasOwnProperty("logs")){if(!Array.isArray(e.logs))return"logs: array expected";for(var t=0;t<e.logs.length;++t){var r=uB.net.pb.GetRecordsReply.LogEntry.verify(e.logs[t]);if(r)return"logs."+r}}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.GetRecordsReply)return e;var t=new uB.net.pb.GetRecordsReply;if(e.logs){if(!Array.isArray(e.logs))throw TypeError(".net.pb.GetRecordsReply.logs: array expected");t.logs=[];for(var r=0;r<e.logs.length;++r){if("object"!=typeof e.logs[r])throw TypeError(".net.pb.GetRecordsReply.logs: object expected");t.logs[r]=uB.net.pb.GetRecordsReply.LogEntry.fromObject(e.logs[r])}}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.logs=[]),e.logs&&e.logs.length){r.logs=[];for(var n=0;n<e.logs.length;++n)r.logs[n]=uB.net.pb.GetRecordsReply.LogEntry.toObject(e.logs[n],t)}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.GetRecordsReply"},e.LogEntry=function(){function e(e){if(this.records=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.logID=cB.newBuffer([]),e.prototype.records=cB.emptyArray,e.prototype.log=null,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=aB.create()),null!=e.logID&&Object.hasOwnProperty.call(e,"logID")&&t.uint32(10).bytes(e.logID),null!=e.records&&e.records.length)for(var r=0;r<e.records.length;++r)uB.net.pb.Log.Record.encode(e.records[r],t.uint32(18).fork()).ldelim();return null!=e.log&&Object.hasOwnProperty.call(e,"log")&&uB.net.pb.Log.encode(e.log,t.uint32(26).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.GetRecordsReply.LogEntry;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.logID=e.bytes();break;case 2:n.records&&n.records.length||(n.records=[]),n.records.push(uB.net.pb.Log.Record.decode(e,e.uint32()));break;case 3:n.log=uB.net.pb.Log.decode(e,e.uint32());break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.logID&&e.hasOwnProperty("logID")&&!(e.logID&&"number"==typeof e.logID.length||cB.isString(e.logID)))return"logID: buffer expected";if(null!=e.records&&e.hasOwnProperty("records")){if(!Array.isArray(e.records))return"records: array expected";for(var t=0;t<e.records.length;++t){var r=uB.net.pb.Log.Record.verify(e.records[t]);if(r)return"records."+r}}if(null!=e.log&&e.hasOwnProperty("log")){var n=uB.net.pb.Log.verify(e.log);if(n)return"log."+n}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.GetRecordsReply.LogEntry)return e;var t=new uB.net.pb.GetRecordsReply.LogEntry;if(null!=e.logID&&("string"==typeof e.logID?cB.base64.decode(e.logID,t.logID=cB.newBuffer(cB.base64.length(e.logID)),0):e.logID.length>=0&&(t.logID=e.logID)),e.records){if(!Array.isArray(e.records))throw TypeError(".net.pb.GetRecordsReply.LogEntry.records: array expected");t.records=[];for(var r=0;r<e.records.length;++r){if("object"!=typeof e.records[r])throw TypeError(".net.pb.GetRecordsReply.LogEntry.records: object expected");t.records[r]=uB.net.pb.Log.Record.fromObject(e.records[r])}}if(null!=e.log){if("object"!=typeof e.log)throw TypeError(".net.pb.GetRecordsReply.LogEntry.log: object expected");t.log=uB.net.pb.Log.fromObject(e.log)}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.records=[]),t.defaults&&(t.bytes===String?r.logID="":(r.logID=[],t.bytes!==Array&&(r.logID=cB.newBuffer(r.logID))),r.log=null),null!=e.logID&&e.hasOwnProperty("logID")&&(r.logID=t.bytes===String?cB.base64.encode(e.logID,0,e.logID.length):t.bytes===Array?Array.prototype.slice.call(e.logID):e.logID),e.records&&e.records.length){r.records=[];for(var n=0;n<e.records.length;++n)r.records[n]=uB.net.pb.Log.Record.toObject(e.records[n],t)}return null!=e.log&&e.hasOwnProperty("log")&&(r.log=uB.net.pb.Log.toObject(e.log,t)),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.GetRecordsReply.LogEntry"},e}(),e}(),e.PushRecordRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.body=null,e.prototype.counter=cB.Long?cB.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.body&&Object.hasOwnProperty.call(e,"body")&&uB.net.pb.PushRecordRequest.Body.encode(e.body,t.uint32(18).fork()).ldelim(),null!=e.counter&&Object.hasOwnProperty.call(e,"counter")&&t.uint32(24).int64(e.counter),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.PushRecordRequest;e.pos<r;){var o=e.uint32();switch(o>>>3){case 2:n.body=uB.net.pb.PushRecordRequest.Body.decode(e,e.uint32());break;case 3:n.counter=e.int64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.body&&e.hasOwnProperty("body")){var t=uB.net.pb.PushRecordRequest.Body.verify(e.body);if(t)return"body."+t}return null!=e.counter&&e.hasOwnProperty("counter")&&!(cB.isInteger(e.counter)||e.counter&&cB.isInteger(e.counter.low)&&cB.isInteger(e.counter.high))?"counter: integer|Long expected":null},e.fromObject=function(e){if(e instanceof uB.net.pb.PushRecordRequest)return e;var t=new uB.net.pb.PushRecordRequest;if(null!=e.body){if("object"!=typeof e.body)throw TypeError(".net.pb.PushRecordRequest.body: object expected");t.body=uB.net.pb.PushRecordRequest.Body.fromObject(e.body)}return null!=e.counter&&(cB.Long?(t.counter=cB.Long.fromValue(e.counter)).unsigned=!1:"string"==typeof e.counter?t.counter=parseInt(e.counter,10):"number"==typeof e.counter?t.counter=e.counter:"object"==typeof e.counter&&(t.counter=new cB.LongBits(e.counter.low>>>0,e.counter.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if(r.body=null,cB.Long){var n=new cB.Long(0,0,!1);r.counter=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.counter=t.longs===String?"0":0;return null!=e.body&&e.hasOwnProperty("body")&&(r.body=uB.net.pb.PushRecordRequest.Body.toObject(e.body,t)),null!=e.counter&&e.hasOwnProperty("counter")&&("number"==typeof e.counter?r.counter=t.longs===String?String(e.counter):e.counter:r.counter=t.longs===String?cB.Long.prototype.toString.call(e.counter):t.longs===Number?new cB.LongBits(e.counter.low>>>0,e.counter.high>>>0).toNumber():e.counter),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.PushRecordRequest"},e.Body=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=cB.newBuffer([]),e.prototype.logID=cB.newBuffer([]),e.prototype.record=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.logID&&Object.hasOwnProperty.call(e,"logID")&&t.uint32(18).bytes(e.logID),null!=e.record&&Object.hasOwnProperty.call(e,"record")&&uB.net.pb.Log.Record.encode(e.record,t.uint32(26).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.PushRecordRequest.Body;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.logID=e.bytes();break;case 3:n.record=uB.net.pb.Log.Record.decode(e,e.uint32());break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||cB.isString(e.threadID)))return"threadID: buffer expected";if(null!=e.logID&&e.hasOwnProperty("logID")&&!(e.logID&&"number"==typeof e.logID.length||cB.isString(e.logID)))return"logID: buffer expected";if(null!=e.record&&e.hasOwnProperty("record")){var t=uB.net.pb.Log.Record.verify(e.record);if(t)return"record."+t}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.PushRecordRequest.Body)return e;var t=new uB.net.pb.PushRecordRequest.Body;if(null!=e.threadID&&("string"==typeof e.threadID?cB.base64.decode(e.threadID,t.threadID=cB.newBuffer(cB.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.logID&&("string"==typeof e.logID?cB.base64.decode(e.logID,t.logID=cB.newBuffer(cB.base64.length(e.logID)),0):e.logID.length>=0&&(t.logID=e.logID)),null!=e.record){if("object"!=typeof e.record)throw TypeError(".net.pb.PushRecordRequest.Body.record: object expected");t.record=uB.net.pb.Log.Record.fromObject(e.record)}return t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=cB.newBuffer(r.threadID))),t.bytes===String?r.logID="":(r.logID=[],t.bytes!==Array&&(r.logID=cB.newBuffer(r.logID))),r.record=null),null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?cB.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.logID&&e.hasOwnProperty("logID")&&(r.logID=t.bytes===String?cB.base64.encode(e.logID,0,e.logID.length):t.bytes===Array?Array.prototype.slice.call(e.logID):e.logID),null!=e.record&&e.hasOwnProperty("record")&&(r.record=uB.net.pb.Log.Record.toObject(e.record,t)),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.PushRecordRequest.Body"},e}(),e}(),e.PushRecordReply=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.PushRecordReply;e.pos<r;){var o=e.uint32();e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null},e.fromObject=function(e){return e instanceof uB.net.pb.PushRecordReply?e:new uB.net.pb.PushRecordReply},e.toObject=function(){return{}},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.PushRecordReply"},e}(),e.ExchangeEdgesRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.body=null,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.body&&Object.hasOwnProperty.call(e,"body")&&uB.net.pb.ExchangeEdgesRequest.Body.encode(e.body,t.uint32(18).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.ExchangeEdgesRequest;e.pos<r;){var o=e.uint32();o>>>3==2?n.body=uB.net.pb.ExchangeEdgesRequest.Body.decode(e,e.uint32()):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.body&&e.hasOwnProperty("body")){var t=uB.net.pb.ExchangeEdgesRequest.Body.verify(e.body);if(t)return"body."+t}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.ExchangeEdgesRequest)return e;var t=new uB.net.pb.ExchangeEdgesRequest;if(null!=e.body){if("object"!=typeof e.body)throw TypeError(".net.pb.ExchangeEdgesRequest.body: object expected");t.body=uB.net.pb.ExchangeEdgesRequest.Body.fromObject(e.body)}return t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.body=null),null!=e.body&&e.hasOwnProperty("body")&&(r.body=uB.net.pb.ExchangeEdgesRequest.Body.toObject(e.body,t)),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.ExchangeEdgesRequest"},e.Body=function(){function e(e){if(this.threads=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threads=cB.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=aB.create()),null!=e.threads&&e.threads.length)for(var r=0;r<e.threads.length;++r)uB.net.pb.ExchangeEdgesRequest.Body.ThreadEntry.encode(e.threads[r],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.ExchangeEdgesRequest.Body;e.pos<r;){var o=e.uint32();o>>>3==1?(n.threads&&n.threads.length||(n.threads=[]),n.threads.push(uB.net.pb.ExchangeEdgesRequest.Body.ThreadEntry.decode(e,e.uint32()))):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.threads&&e.hasOwnProperty("threads")){if(!Array.isArray(e.threads))return"threads: array expected";for(var t=0;t<e.threads.length;++t){var r=uB.net.pb.ExchangeEdgesRequest.Body.ThreadEntry.verify(e.threads[t]);if(r)return"threads."+r}}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.ExchangeEdgesRequest.Body)return e;var t=new uB.net.pb.ExchangeEdgesRequest.Body;if(e.threads){if(!Array.isArray(e.threads))throw TypeError(".net.pb.ExchangeEdgesRequest.Body.threads: array expected");t.threads=[];for(var r=0;r<e.threads.length;++r){if("object"!=typeof e.threads[r])throw TypeError(".net.pb.ExchangeEdgesRequest.Body.threads: object expected");t.threads[r]=uB.net.pb.ExchangeEdgesRequest.Body.ThreadEntry.fromObject(e.threads[r])}}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.threads=[]),e.threads&&e.threads.length){r.threads=[];for(var n=0;n<e.threads.length;++n)r.threads[n]=uB.net.pb.ExchangeEdgesRequest.Body.ThreadEntry.toObject(e.threads[n],t)}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.ExchangeEdgesRequest.Body"},e.ThreadEntry=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=cB.newBuffer([]),e.prototype.addressEdge=cB.Long?cB.Long.fromBits(0,0,!0):0,e.prototype.headsEdge=cB.Long?cB.Long.fromBits(0,0,!0):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.addressEdge&&Object.hasOwnProperty.call(e,"addressEdge")&&t.uint32(16).uint64(e.addressEdge),null!=e.headsEdge&&Object.hasOwnProperty.call(e,"headsEdge")&&t.uint32(24).uint64(e.headsEdge),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.ExchangeEdgesRequest.Body.ThreadEntry;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.addressEdge=e.uint64();break;case 3:n.headsEdge=e.uint64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||cB.isString(e.threadID))?"threadID: buffer expected":null!=e.addressEdge&&e.hasOwnProperty("addressEdge")&&!(cB.isInteger(e.addressEdge)||e.addressEdge&&cB.isInteger(e.addressEdge.low)&&cB.isInteger(e.addressEdge.high))?"addressEdge: integer|Long expected":null!=e.headsEdge&&e.hasOwnProperty("headsEdge")&&!(cB.isInteger(e.headsEdge)||e.headsEdge&&cB.isInteger(e.headsEdge.low)&&cB.isInteger(e.headsEdge.high))?"headsEdge: integer|Long expected":null},e.fromObject=function(e){if(e instanceof uB.net.pb.ExchangeEdgesRequest.Body.ThreadEntry)return e;var t=new uB.net.pb.ExchangeEdgesRequest.Body.ThreadEntry;return null!=e.threadID&&("string"==typeof e.threadID?cB.base64.decode(e.threadID,t.threadID=cB.newBuffer(cB.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.addressEdge&&(cB.Long?(t.addressEdge=cB.Long.fromValue(e.addressEdge)).unsigned=!0:"string"==typeof e.addressEdge?t.addressEdge=parseInt(e.addressEdge,10):"number"==typeof e.addressEdge?t.addressEdge=e.addressEdge:"object"==typeof e.addressEdge&&(t.addressEdge=new cB.LongBits(e.addressEdge.low>>>0,e.addressEdge.high>>>0).toNumber(!0))),null!=e.headsEdge&&(cB.Long?(t.headsEdge=cB.Long.fromValue(e.headsEdge)).unsigned=!0:"string"==typeof e.headsEdge?t.headsEdge=parseInt(e.headsEdge,10):"number"==typeof e.headsEdge?t.headsEdge=e.headsEdge:"object"==typeof e.headsEdge&&(t.headsEdge=new cB.LongBits(e.headsEdge.low>>>0,e.headsEdge.high>>>0).toNumber(!0))),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=cB.newBuffer(r.threadID))),cB.Long){var n=new cB.Long(0,0,!0);r.addressEdge=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.addressEdge=t.longs===String?"0":0;if(cB.Long){var o=new cB.Long(0,0,!0);r.headsEdge=t.longs===String?o.toString():t.longs===Number?o.toNumber():o}else r.headsEdge=t.longs===String?"0":0}return null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?cB.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.addressEdge&&e.hasOwnProperty("addressEdge")&&("number"==typeof e.addressEdge?r.addressEdge=t.longs===String?String(e.addressEdge):e.addressEdge:r.addressEdge=t.longs===String?cB.Long.prototype.toString.call(e.addressEdge):t.longs===Number?new cB.LongBits(e.addressEdge.low>>>0,e.addressEdge.high>>>0).toNumber(!0):e.addressEdge),null!=e.headsEdge&&e.hasOwnProperty("headsEdge")&&("number"==typeof e.headsEdge?r.headsEdge=t.longs===String?String(e.headsEdge):e.headsEdge:r.headsEdge=t.longs===String?cB.Long.prototype.toString.call(e.headsEdge):t.longs===Number?new cB.LongBits(e.headsEdge.low>>>0,e.headsEdge.high>>>0).toNumber(!0):e.headsEdge),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.ExchangeEdgesRequest.Body.ThreadEntry"},e}(),e}(),e}(),e.ExchangeEdgesReply=function(){function e(e){if(this.edges=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.edges=cB.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=aB.create()),null!=e.edges&&e.edges.length)for(var r=0;r<e.edges.length;++r)uB.net.pb.ExchangeEdgesReply.ThreadEdges.encode(e.edges[r],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.ExchangeEdgesReply;e.pos<r;){var o=e.uint32();o>>>3==1?(n.edges&&n.edges.length||(n.edges=[]),n.edges.push(uB.net.pb.ExchangeEdgesReply.ThreadEdges.decode(e,e.uint32()))):e.skipType(7&o)}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.edges&&e.hasOwnProperty("edges")){if(!Array.isArray(e.edges))return"edges: array expected";for(var t=0;t<e.edges.length;++t){var r=uB.net.pb.ExchangeEdgesReply.ThreadEdges.verify(e.edges[t]);if(r)return"edges."+r}}return null},e.fromObject=function(e){if(e instanceof uB.net.pb.ExchangeEdgesReply)return e;var t=new uB.net.pb.ExchangeEdgesReply;if(e.edges){if(!Array.isArray(e.edges))throw TypeError(".net.pb.ExchangeEdgesReply.edges: array expected");t.edges=[];for(var r=0;r<e.edges.length;++r){if("object"!=typeof e.edges[r])throw TypeError(".net.pb.ExchangeEdgesReply.edges: object expected");t.edges[r]=uB.net.pb.ExchangeEdgesReply.ThreadEdges.fromObject(e.edges[r])}}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.edges=[]),e.edges&&e.edges.length){r.edges=[];for(var n=0;n<e.edges.length;++n)r.edges[n]=uB.net.pb.ExchangeEdgesReply.ThreadEdges.toObject(e.edges[n],t)}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.ExchangeEdgesReply"},e.ThreadEdges=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.threadID=cB.newBuffer([]),e.prototype.exists=!1,e.prototype.addressEdge=cB.Long?cB.Long.fromBits(0,0,!0):0,e.prototype.headsEdge=cB.Long?cB.Long.fromBits(0,0,!0):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=aB.create()),null!=e.threadID&&Object.hasOwnProperty.call(e,"threadID")&&t.uint32(10).bytes(e.threadID),null!=e.exists&&Object.hasOwnProperty.call(e,"exists")&&t.uint32(16).bool(e.exists),null!=e.addressEdge&&Object.hasOwnProperty.call(e,"addressEdge")&&t.uint32(24).uint64(e.addressEdge),null!=e.headsEdge&&Object.hasOwnProperty.call(e,"headsEdge")&&t.uint32(32).uint64(e.headsEdge),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof sB||(e=sB.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new uB.net.pb.ExchangeEdgesReply.ThreadEdges;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.threadID=e.bytes();break;case 2:n.exists=e.bool();break;case 3:n.addressEdge=e.uint64();break;case 4:n.headsEdge=e.uint64();break;default:e.skipType(7&o)}}return n},e.decodeDelimited=function(e){return e instanceof sB||(e=new sB(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.threadID&&e.hasOwnProperty("threadID")&&!(e.threadID&&"number"==typeof e.threadID.length||cB.isString(e.threadID))?"threadID: buffer expected":null!=e.exists&&e.hasOwnProperty("exists")&&"boolean"!=typeof e.exists?"exists: boolean expected":null!=e.addressEdge&&e.hasOwnProperty("addressEdge")&&!(cB.isInteger(e.addressEdge)||e.addressEdge&&cB.isInteger(e.addressEdge.low)&&cB.isInteger(e.addressEdge.high))?"addressEdge: integer|Long expected":null!=e.headsEdge&&e.hasOwnProperty("headsEdge")&&!(cB.isInteger(e.headsEdge)||e.headsEdge&&cB.isInteger(e.headsEdge.low)&&cB.isInteger(e.headsEdge.high))?"headsEdge: integer|Long expected":null},e.fromObject=function(e){if(e instanceof uB.net.pb.ExchangeEdgesReply.ThreadEdges)return e;var t=new uB.net.pb.ExchangeEdgesReply.ThreadEdges;return null!=e.threadID&&("string"==typeof e.threadID?cB.base64.decode(e.threadID,t.threadID=cB.newBuffer(cB.base64.length(e.threadID)),0):e.threadID.length>=0&&(t.threadID=e.threadID)),null!=e.exists&&(t.exists=Boolean(e.exists)),null!=e.addressEdge&&(cB.Long?(t.addressEdge=cB.Long.fromValue(e.addressEdge)).unsigned=!0:"string"==typeof e.addressEdge?t.addressEdge=parseInt(e.addressEdge,10):"number"==typeof e.addressEdge?t.addressEdge=e.addressEdge:"object"==typeof e.addressEdge&&(t.addressEdge=new cB.LongBits(e.addressEdge.low>>>0,e.addressEdge.high>>>0).toNumber(!0))),null!=e.headsEdge&&(cB.Long?(t.headsEdge=cB.Long.fromValue(e.headsEdge)).unsigned=!0:"string"==typeof e.headsEdge?t.headsEdge=parseInt(e.headsEdge,10):"number"==typeof e.headsEdge?t.headsEdge=e.headsEdge:"object"==typeof e.headsEdge&&(t.headsEdge=new cB.LongBits(e.headsEdge.low>>>0,e.headsEdge.high>>>0).toNumber(!0))),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(t.bytes===String?r.threadID="":(r.threadID=[],t.bytes!==Array&&(r.threadID=cB.newBuffer(r.threadID))),r.exists=!1,cB.Long){var n=new cB.Long(0,0,!0);r.addressEdge=t.longs===String?n.toString():t.longs===Number?n.toNumber():n}else r.addressEdge=t.longs===String?"0":0;if(cB.Long){var o=new cB.Long(0,0,!0);r.headsEdge=t.longs===String?o.toString():t.longs===Number?o.toNumber():o}else r.headsEdge=t.longs===String?"0":0}return null!=e.threadID&&e.hasOwnProperty("threadID")&&(r.threadID=t.bytes===String?cB.base64.encode(e.threadID,0,e.threadID.length):t.bytes===Array?Array.prototype.slice.call(e.threadID):e.threadID),null!=e.exists&&e.hasOwnProperty("exists")&&(r.exists=e.exists),null!=e.addressEdge&&e.hasOwnProperty("addressEdge")&&("number"==typeof e.addressEdge?r.addressEdge=t.longs===String?String(e.addressEdge):e.addressEdge:r.addressEdge=t.longs===String?cB.Long.prototype.toString.call(e.addressEdge):t.longs===Number?new cB.LongBits(e.addressEdge.low>>>0,e.addressEdge.high>>>0).toNumber(!0):e.addressEdge),null!=e.headsEdge&&e.hasOwnProperty("headsEdge")&&("number"==typeof e.headsEdge?r.headsEdge=t.longs===String?String(e.headsEdge):e.headsEdge:r.headsEdge=t.longs===String?cB.Long.prototype.toString.call(e.headsEdge):t.longs===Number?new cB.LongBits(e.headsEdge.low>>>0,e.headsEdge.high>>>0).toNumber(!0):e.headsEdge),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.minimalExports.util.toJSONOptions)},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/net.pb.ExchangeEdgesReply.ThreadEdges"},e}(),e}(),e.Service=function(){function e(e,t,r){o.minimalExports.rpc.Service.call(this,e,t,r)}return(e.prototype=Object.create(o.minimalExports.rpc.Service.prototype)).constructor=e,e.create=function(e,t,r){return new this(e,t,r)},Object.defineProperty(e.prototype.getLogs=function e(t,r){return this.rpcCall(e,uB.net.pb.GetLogsRequest,uB.net.pb.GetLogsReply,t,r)},"name",{value:"GetLogs"}),Object.defineProperty(e.prototype.pushLog=function e(t,r){return this.rpcCall(e,uB.net.pb.PushLogRequest,uB.net.pb.PushLogReply,t,r)},"name",{value:"PushLog"}),Object.defineProperty(e.prototype.getRecords=function e(t,r){return this.rpcCall(e,uB.net.pb.GetRecordsRequest,uB.net.pb.GetRecordsReply,t,r)},"name",{value:"GetRecords"}),Object.defineProperty(e.prototype.pushRecord=function e(t,r){return this.rpcCall(e,uB.net.pb.PushRecordRequest,uB.net.pb.PushRecordReply,t,r)},"name",{value:"PushRecord"}),Object.defineProperty(e.prototype.exchangeEdges=function e(t,r){return this.rpcCall(e,uB.net.pb.ExchangeEdgesRequest,uB.net.pb.ExchangeEdgesReply,t,r)},"name",{value:"ExchangeEdges"}),e}(),e),t})(),dB=0,hB=1,pB=3,yB=4,fB=6,gB=7,bB=8,mB=1,wB=1;var vB=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(255!==r[s])throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function d(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,o=0;e[t]===c;)n++,t++;for(var i=(e.length-t)*u+1>>>0,s=new Uint8Array(i);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var d=0,h=i-1;(0!==l||d<o)&&-1!==h;h--,d++)l+=a*s[h]>>>0,s[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=d,t++}if(" "!==e[t]){for(var p=i-o;p!==i&&0===s[p];)p++;for(var y=new Uint8Array(n+(i-p)),f=n;p!==i;)y[f++]=s[p++];return y}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*l+1>>>0,u=new Uint8Array(s);o!==i;){for(var d=t[o],h=0,p=s-1;(0!==d||h<n)&&-1!==p;p--,h++)d+=256*u[p]>>>0,u[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");n=h,o++}for(var y=s-n;y!==s&&0===u[y];)y++;for(var f=c.repeat(r);y<s;++y)f+=e.charAt(u[y]);return f},decodeUnsafe:d,decode:function(e){var r=d(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}},kB=vB;let SB=class{constructor(e,t,r){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}},OB=class{constructor(e,t,r){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseDecode",void 0),W(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t;var n=t.codePointAt(0);if(void 0===n)throw new Error("Invalid prefix character");this.prefixCodePoint=n,this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return IB(this,e)}},AB=class{constructor(e){W(this,"decoders",void 0),this.decoders=e}or(e){return IB(this,e)}decode(e){var t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}};function IB(e,t){var r,n;return new AB(Z(Z({},null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e}),null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}))}let xB=class{constructor(e,t,r,n){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseEncode",void 0),W(this,"baseDecode",void 0),W(this,"encoder",void 0),W(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new SB(e,t,r),this.decoder=new OB(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function PB(e){var{name:t,prefix:r,encode:n,decode:o}=e;return new xB(t,r,n,o)}function EB(e){var{name:t,prefix:r,alphabet:n}=e,{encode:o,decode:i}=kB(n,t);return PB({prefix:r,name:t,encode:o,decode:e=>function(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}(i(e))})}function CB(e){var{name:t,prefix:r,bitsPerChar:n,alphabet:o}=e;return PB({prefix:r,name:t,encode:e=>function(e,t,r){for(var n="="===t[t.length-1],o=(1<<r)-1,i="",s=0,a=0,c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)i+=t[o&a>>(s-=r)];if(0!==s&&(i+=t[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}(e,o,n),decode:e=>function(e,t,r,n){for(var o={},i=0;i<t.length;++i)o[t[i]]=i;for(var s=e.length;"="===e[s-1];)--s;for(var a=new Uint8Array(s*r/8|0),c=0,u=0,l=0,d=0;d<s;++d){var h=o[e[d]];if(void 0===h)throw new SyntaxError("Non-".concat(n," character"));u=u<<r|h,(c+=r)>=8&&(c-=8,a[l++]=255&u>>c)}if(c>=r||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return a}(e,o,n,t)})}var BB=EB({prefix:"9",name:"base10",alphabet:"0123456789"}),TB=Object.freeze({__proto__:null,base10:BB}),DB=CB({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),RB=CB({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),jB=Object.freeze({__proto__:null,base16:DB,base16upper:RB}),NB=CB({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),UB=Object.freeze({__proto__:null,base2:NB}),KB=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),qB=KB.reduce(((e,t,r)=>(e[r]=t,e)),[]),LB=KB.reduce(((e,t,r)=>{var n=t.codePointAt(0);if(null==n)throw new Error("Invalid character: ".concat(t));return e[n]=r,e}),[]);var _B=PB({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=qB[t]),"")},decode:function(e){var t=[];for(var r of e){var n=r.codePointAt(0);if(null==n)throw new Error("Invalid character: ".concat(r));var o=LB[n];if(null==o)throw new Error("Non-base256emoji character: ".concat(r));t.push(o)}return new Uint8Array(t)}}),MB=Object.freeze({__proto__:null,base256emoji:_B}),FB=CB({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),zB=CB({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),GB=CB({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),VB=CB({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),HB=CB({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),WB=CB({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),JB=CB({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$B=CB({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),YB=CB({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),ZB=Object.freeze({__proto__:null,base32:FB,base32hex:HB,base32hexpad:JB,base32hexpadupper:$B,base32hexupper:WB,base32pad:GB,base32padupper:VB,base32upper:zB,base32z:YB}),QB=EB({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),XB=EB({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),eT=Object.freeze({__proto__:null,base36:QB,base36upper:XB}),tT=EB({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),rT=EB({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),nT=Object.freeze({__proto__:null,base58btc:tT,base58flickr:rT}),oT=CB({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),iT=CB({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),sT=CB({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),aT=CB({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),cT=Object.freeze({__proto__:null,base64:oT,base64pad:iT,base64url:sT,base64urlpad:aT}),uT=CB({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),lT=Object.freeze({__proto__:null,base8:uT}),dT=PB({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),hT=Object.freeze({__proto__:null,identity:dT});new TextEncoder,new TextDecoder;var pT=Z(Z(Z(Z(Z(Z(Z(Z(Z(Z({},hT),UB),lT),TB),jB),ZB),eT),nT),cT),MB);function yT(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var fT=yT("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),gT=yT("ascii","a",(e=>{for(var t="a",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{for(var t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length),r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),bT=Z({utf8:fT,"utf-8":fT,hex:pT.base16,latin1:gT,ascii:gT,binary:gT},pT);let mT=class{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4096;this.dynamicTable=[],this.dynamicTableSize=0,this.maxDynamicTableSize=e,this.staticTable=[["",""],[":authority",""],[":method","GET"],[":method","POST"],[":path","/"],[":path","/index.html"],[":scheme","http"],[":scheme","https"],[":status","200"],[":status","204"],[":status","206"],[":status","304"],[":status","400"],[":status","404"],[":status","500"],["accept-charset",""],["accept-encoding","gzip, deflate"],["accept-language",""],["accept-ranges",""],["accept",""],["access-control-allow-origin",""],["age",""],["allow",""],["authorization",""],["cache-control",""],["content-disposition",""],["content-encoding",""],["content-language",""],["content-length",""],["content-location",""],["content-range",""],["content-type",""],["cookie",""],["date",""],["etag",""],["expect",""],["expires",""],["from",""],["host",""],["if-match",""],["if-modified-since",""],["if-none-match",""],["if-range",""],["if-unmodified-since",""],["last-modified",""],["link",""],["location",""],["max-forwards",""],["proxy-authenticate",""],["proxy-authorization",""],["range",""],["referer",""],["refresh",""],["retry-after",""],["server",""],["set-cookie",""],["strict-transport-security",""],["transfer-encoding",""],["user-agent",""],["vary",""],["via",""],["www-authenticate",""]],this.huffmanTable=this.buildHuffmanTable()}encode(e){var t=[];for(var[r,n]of Object.entries(e)){var o=this.findInStaticTable(r,n);if(-1===o){var i=this.findInDynamicTable(r,n);-1===i?this.encodeLiteral(t,r,n):t.push(...this.encodeInteger(i+this.staticTable.length,7,128))}else t.push(...this.encodeInteger(o,7,128))}return new Uint8Array(t)}encodeInteger(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=[],o=(1<<t)-1;if(e<o)return n.push(r|e),n;for(n.push(r|o),e-=o;e>=128;)n.push(127&e|128),e>>=7;return n.push(e),n}encodeString(e){var t=[],r=(new TextEncoder).encode(e),n=this.huffmanEncode(r);return n.length<r.length?(t.push(...this.encodeInteger(n.length,7,128)),t.push(...n)):(t.push(...this.encodeInteger(r.length,7,0)),t.push(...r)),t}findInStaticTable(e,t){for(var r=1;r<this.staticTable.length;r++)if(this.staticTable[r][0]===e&&this.staticTable[r][1]===t)return r;return-1}findInDynamicTable(e,t){for(var r=0;r<this.dynamicTable.length;r++)if(this.dynamicTable[r][0]===e&&this.dynamicTable[r][1]===t)return r;return-1}encodeLiteral(e,t,r){var n=this.findInStaticTable(t,"");-1!==n?e.push(...this.encodeInteger(n,6,64)):(e.push(64),e.push(...this.encodeString(t))),e.push(...this.encodeString(r)),this.addToDynamicTable(t,r)}addToDynamicTable(e,t){for(var r=e.length+t.length+32;this.dynamicTableSize+r>this.maxDynamicTableSize&&this.dynamicTable.length>0;){var n=this.dynamicTable.pop();n&&(this.dynamicTableSize-=n[0].length+n[1].length+32)}r<=this.maxDynamicTableSize&&(this.dynamicTable.unshift([e,t]),this.dynamicTableSize+=r),this.dynamicTable.push([e,t])}getIndexedHeader(e){return e<=this.staticTable.length-1?this.staticTable[e]:this.dynamicTable[e-this.staticTable.length]}buildHuffmanTable(){return{codes:new Uint32Array([8184,8388568,268435426,268435427,268435428,268435429,268435430,268435431,268435432,16777194,1073741820,268435433,268435434,1073741821,268435435,268435436,268435437,268435438,268435439,268435440,268435441,268435442,1073741822,268435443,268435444,268435445,268435446,268435447,268435448,268435449,268435450,268435451,20,1016,1017,4090,8185,21,248,2042,1018,1019,249,2043,250,22,23,24,0,1,2,25,26,27,28,29,30,31,92,251,32764,32,4091,1020,8186,33,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,252,115,253,8187,524272,8188,16380,34,32765,3,35,4,36,5,37,38,39,6,116,117,40,41,42,7,43,118,44,8,9,45,119,120,121,122,123,32766,2044,16381,8189,268435452,1048550,4194258,1048551,1048552,4194259,4194260,4194261,8388569,4194262,8388570,8388571,8388572,8388573,8388574,16777195,8388575,16777196,16777197,4194263,8388576,16777198,8388577,8388578,8388579,8388580,2097116,4194264,8388581,4194265,8388582,8388583,16777199,4194266,2097117,1048553,4194267,4194268,8388584,8388585,2097118,8388586,4194269,4194270,16777200,2097119,4194271,8388587,8388588,2097120,2097121,4194272,2097122,8388589,4194273,8388590,8388591,1048554,4194274,4194275,4194276,8388592,4194277,4194278,8388593,67108832,67108833,1048555,524273,4194279,8388594,4194280,33554412,67108834,67108835,67108836,134217694,134217695,67108837,16777201,33554413,524274,2097123,67108838,134217696,134217697,67108839,134217698,16777202,2097124,2097125,67108840,67108841,268435453,134217699,134217700,134217701,1048556,16777203,1048557,2097126,4194281,2097127,2097128,8388595,4194282,4194283,33554414,33554415,16777204,16777205,67108842,8388596,67108843,134217702,67108844,67108845,134217703,134217704,134217705,134217706,134217707,268435454,134217708,134217709,134217710,134217711,134217712,67108846]),lengths:new Uint8Array([13,23,28,28,28,28,28,28,28,24,30,28,28,30,28,28,28,28,28,28,28,28,30,28,28,28,28,28,28,28,28,28,6,10,10,12,13,6,8,11,10,10,8,11,8,6,6,6,5,5,5,6,6,6,6,6,6,6,7,8,15,6,12,10,13,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,7,8,13,19,13,14,6,15,5,6,5,6,5,6,6,6,5,7,7,6,6,6,5,6,7,6,5,5,6,7,7,7,7,7,15,11,14,13,28,20,22,20,20,22,22,22,23,22,23,23,23,23,23,24,23,24,24,22,23,24,23,23,23,23,21,22,23,22,23,23,24,22,21,20,22,22,23,23,21,23,22,22,24,21,22,23,23,21,21,22,21,23,22,23,23,20,22,22,22,23,22,22,23,26,26,20,19,22,23,22,25,26,26,26,27,27,26,24,25,19,21,26,27,27,26,27,24,21,21,26,26,28,27,27,27,20,24,20,21,22,21,21,23,22,22,25,25,24,24,26,23,26,27,26,26,27,27,27,27,27,28,27,27,27,27,27,26])}}decode(e){for(var t="",r=0,n=0,o=0;o<e.length;o++){for(r=r<<8|e[o],n+=8;n>=5;){var i=this.findSymbol(r,n);if(!i)break;var[s,a]=i;t+=String.fromCharCode(s),r&=(1<<n-a)-1,n-=a}}if(n>0){var c=(1<<n)-1;if((r&c)!==c)throw new Error("Invalid Huffman padding")}return t}findSymbol(e,t){for(var r=0;r<this.huffmanTable.codes.length;r++){var n=this.huffmanTable.lengths[r];if(!(t<n))if((e>>t-n&(1<<n)-1)===this.huffmanTable.codes[r])return[r,n]}return null}huffmanEncode(e){for(var t=[],r=0,n=0,o=0;o<e.length;o++){var i=e[o],s=this.huffmanTable.codes[i],a=this.huffmanTable.lengths[i];for(n+=a,r=r<<a|s;n>=8;)n-=8,t.push(r>>n&255)}return n>0&&(r=r<<8-n|(1<<8-n)-1,t.push(255&r)),new Uint8Array(t)}decodeHeaderFields(e){for(var t=new Map,r=0;r<e.length;){var n=e[r];if(128&n){var[o,i,s]=this.decodeIndexedHeader(e,r);o&&i&&t.set(o,i),r=s}else if(64&n){var[a,c,u]=this.decodeLiteralHeaderWithIndexing(e,r);a&&c&&t.set(a,c),r=u}else if(32&n)r++;else if(16&n){var[l,d,h]=this.decodeLiteralHeaderWithoutIndexing(e,r);l&&d&&t.set(l,d),r=h}else{var[p,y,f]=this.decodeLiteralHeaderWithoutIndexing(e,r);p&&y&&t.set(p,y),r=f}}return t}decodeInteger(e,t,r){var n=(1<<r)-1,o=t,i=e[t]&n;if(i<n)return[i,o+1];o++;for(var s=0;o<e.length;){var a=e[o++];if(i+=(127&a)<<s,s+=7,!(128&a))break}return[i,o]}decodeLiteralString(e,t){if(t>=e.length)return["",t];var r=!!(128&e[t]),[n,o]=this.decodeInteger(e,t,7);if(o+n>e.length)return["",o];var i,s=e.slice(o,o+n);if(r)try{i=this.decode(s)}catch(e){i=""}else try{i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8",r=bT[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}(s)}catch(e){i=""}return[i,o+n]}decodeIndexedHeader(e,t){var[r,n]=this.decodeInteger(e,t,7);if(r<=0)return["","",n];var o=this.staticTable[r];return o?[o[0],o[1],n]:["","",n]}decodeLiteralHeaderWithIndexing(e,t){var r,[n,o]=this.decodeInteger(e,t,6);if(t=o,n>0){var i=this.staticTable[n];r=i?i[0]:""}else{var[s,a]=this.decodeLiteralString(e,t);r=s,t=a}var[c,u]=this.decodeLiteralString(e,t);return[r,c,u]}decodeLiteralHeaderWithoutIndexing(e,t){return this.decodeLiteralHeaderWithIndexing(e,t)}huffmanDecodeToString(e){return this.decode(e)}};class wT{static encodeSettingsFrame(e){var t=6*e.payload.length,r=new Uint8Array(9+t);return vT(r,{length:t,type:e.type,flags:e.flags,streamId:e.streamId}),function(e,t){var r=9;t.forEach((t=>{!function(e,t,r){e[r]=t>>8&255,e[r+1]=255&t}(e,t.identifier,r),r+=2,kT(e,t.value,r),r+=4}))}(r,e.payload),r}static encodeSettingsAckFrame(){var e=new Uint8Array(9);return vT(e,{length:0,type:4,flags:1,streamId:0}),e}}function vT(e,t){var r,n=null!==(r=t.length)&&void 0!==r?r:0;e[0]=n>>16&255,e[1]=n>>8&255,e[2]=255&n,e[3]=t.type,e[4]=t.flags,kT(e,2147483647&t.streamId,5)}function kT(e,t,r){e[r]=t>>24&255,e[r+1]=t>>16&255,e[r+2]=t>>8&255,e[r+3]=255&t}var ST=1,OT=2,AT=3,IT=4,xT=5,PT=6,ET={[ST]:4096,[OT]:1,[AT]:100,[IT]:16384,[xT]:16384,[PT]:8192};class CT{static createPreface(){return(new TextEncoder).encode("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n")}static createPongFrame(e){return CT.createFrame(6,1,0,e)}static createSettingsFrame(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=CT.createOriginSettingsFrame(e);return wT.encodeSettingsFrame(t)}static createSettingsAckFrame(){return wT.encodeSettingsAckFrame()}static createWindowUpdateFrame(e,t){if(t<=0||t>2147483647)throw new Error("Window size increment must be between 1 and 2^31-1");var r=new Uint8Array(4);return r[0]=t>>24&127,r[1]=t>>16&255,r[2]=t>>8&255,r[3]=255&t,CT.createFrame(8,0,e,r)}static createDataFrames(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16384,o=[],i=t.length,s=new Uint8Array(5+i);s[0]=0,s[1]=i>>24&255,s[2]=i>>16&255,s[3]=i>>8&255,s[4]=255&i,s.set(t,5);for(var a=n-9,c=0;c<s.length;c+=a){var u=s.length-c,l=Math.min(a,u),d=s.slice(c,c+l),h=c+l>=s.length&&r,p=CT.createFrame(0,h?1:0,e,d);o.push(p)}return o}static createDataFrame(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=t.length,o=new Uint8Array(5+n);o[0]=0,o[1]=n>>24&255,o[2]=n>>16&255,o[3]=n>>8&255,o[4]=255&n,o.set(t,5);var i=r?1:0;return CT.createFrame(0,i,e,o)}static createHeadersFrame(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0,o={":path":t,":method":"POST",":scheme":"http",":authority":"localhost","content-type":"application/grpc+proto","user-agent":"grpc-web-client/0.1",accept:"application/grpc+proto","grpc-timeout":"3600S"};n&&(o.authorization="Bearer ".concat(n));var i=(new mT).encode(o),s=r?4:0;return CT.createFrame(1,s,e,i)}static createResponseHeadersFrame(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=(new mT).encode(t),o=r?4:0;return CT.createFrame(1,o,e,n)}static createTrailersFrame(e,t){var r=(new mT).encode(t);return CT.createFrame(1,5,e,r)}static createOriginSettingsFrame(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Z(Z({},ET),e);return function(e){for(var[t,r]of Object.entries(e))switch(Number(t)){case ST:if(r<0)throw new Error("HEADER_TABLE_SIZE must be non-negative");break;case OT:if(0!==r&&1!==r)throw new Error("ENABLE_PUSH must be 0 or 1");break;case IT:if(r<0||r>2147483647)throw new Error("INITIAL_WINDOW_SIZE must be between 0 and 2^31-1");break;case xT:if(r<16384||r>16777215)throw new Error("MAX_FRAME_SIZE must be between 16,384 and 16,777,215");break;case AT:case PT:if(r<0)throw new Error("Parameter ".concat(t," must be non-negative"))}}(t),{type:4,flags:0,streamId:0,payload:BT(t)}}static createOriginSettingsAckFrame(){return{type:4,flags:1,streamId:0,payload:[]}}static createFrame(e,t,r,n){var o=n?n.length:0,i=new Uint8Array(9+o);return i[0]=o>>16&255,i[1]=o>>8&255,i[2]=255&o,i[3]=e,i[4]=t,i[5]=r>>24&255,i[6]=r>>16&255,i[7]=r>>8&255,i[8]=255&r,n&&o>0&&i.set(n,9),i}}function BT(e){var t=[];for(var[r,n]of Object.entries(e))t.push({identifier:Number(r),value:n});return t}class TT{constructor(e,t){var r;this.buffer=new Uint8Array(0),this.settingsAckReceived=!1,this.peerSettingsReceived=!1,this.connectionWindowSize=4<<20,this.streams=new Map,this.defaultStreamWindowSize=4<<20,this.sendConnWindow=65535,this.sendStreamWindows=new Map,this.peerInitialStreamWindow=65535,this.sendWindowWaiters=[],this.endFlag=!1,this.writer=e,this.compatibilityMode=null!==(r=null==t?void 0:t.compatibilityMode)&&void 0!==r&&r}processStream(e){var t=this;return G((function*(){try{var r,n=!1,o=!1;try{for(var i,s=M(e.source);n=!(i=yield s.next()).done;n=!1){var a=i.value.subarray(),c=new Uint8Array(t.buffer.length+a.length);for(c.set(t.buffer),c.set(a,t.buffer.length),t.buffer=c;t.buffer.length>=9;){if(t.buffer.length>=24&&t.isHttp2Preface(t.buffer)){t.buffer=t.buffer.slice(24);var u=CT.createSettingsFrame();t.writer.write(u);break}var l=t._parseFrameHeader(t.buffer),d=9+l.length;if(t.buffer.length<d)break;var h=t.buffer.slice(0,d);yield t._handleFrame(l,h),t.buffer=t.buffer.slice(d)}}}catch(e){o=!0,r=e}finally{try{n&&null!=s.return&&(yield s.return())}finally{if(o)throw r}}}catch(e){throw e}finally{if(!t.compatibilityMode&&!t.endFlag){t.endFlag=!0;try{var p;null===(p=t.onEnd)||void 0===p||p.call(t)}catch(e){}}}}))()}isHttp2Preface(e){var t=(new TextEncoder).encode("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n");if(e.length<t.length)return!1;for(var r=0;r<t.length;r++)if(e[r]!==t[r])return!1;return!0}waitForSettingsAck(){return new Promise(((e,t)=>{if(this.settingsAckReceived)e();else var r=setInterval((()=>{this.settingsAckReceived&&(clearInterval(r),clearTimeout(n),e())}),100),n=setTimeout((()=>{clearInterval(r),t(new Error("Settings ACK timeout"))}),3e4)}))}waitForPeerSettings(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3e4;return new Promise(((t,r)=>{if(this.peerSettingsReceived)t();else var n=setInterval((()=>{this.peerSettingsReceived&&(clearInterval(n),clearTimeout(o),t())}),100),o=setTimeout((()=>{clearInterval(n),r(new Error("Peer SETTINGS timeout"))}),e)}))}registerOutboundStream(e){this.sendStreamWindows.has(e)||this.sendStreamWindows.set(e,this.peerInitialStreamWindow)}getSendWindows(e){var t,r=null!==(t=this.sendStreamWindows.get(e))&&void 0!==t?t:0;return{conn:this.sendConnWindow,stream:r}}consumeSendWindow(e,t){var r;this.sendConnWindow=Math.max(0,this.sendConnWindow-t);var n=null!==(r=this.sendStreamWindows.get(e))&&void 0!==r?r:0;this.sendStreamWindows.set(e,Math.max(0,n-t))}unsafeForceExtendSendWindow(e,t){var r;if(!(this.compatibilityMode||t<=0)){this.sendConnWindow=Math.min(2147483647,this.sendConnWindow+t);var n=null!==(r=this.sendStreamWindows.get(e))&&void 0!==r?r:0;this.sendStreamWindows.set(e,Math.min(2147483647,n+t))}}waitForSendWindow(e){var t=arguments,r=this;return G((function*(){var n=t.length>1&&void 0!==t[1]?t[1]:1,o=t.length>2&&void 0!==t[2]?t[2]:3e4,i=Date.now();return new Promise(((t,s)=>{var a=null,c=!1,u=()=>{var{conn:u,stream:l}=r.getSendWindows(e);return u>=n&&l>=n?(c||(c=!0,a&&(clearInterval(a),a=null),t()),!0):Date.now()-i>o&&(c||(c=!0,a&&(clearInterval(a),a=null),s(new Error("Send window wait timeout"))),!0)};if(!u()){r.sendWindowWaiters.push((()=>{u()})),a=setInterval((()=>{u()&&a&&(clearInterval(a),a=null)}),50)}}))}))()}_handleFrame(e,t){var r=this;return G((function*(){switch(e.type){case yB:if((e.flags&mB)===mB)r.settingsAckReceived=!0;else{for(var n,o=t.slice(9),i=0,s=0;s<o.length;s+=6){var a=o[s]<<8|o[s+1],c=o[s+2]<<24|o[s+3]<<16|o[s+4]<<8|o[s+5];4===a?(r.defaultStreamWindowSize=c,i=c-r.peerInitialStreamWindow,r.peerInitialStreamWindow=c):3===a&&(n=c)}if(!r.compatibilityMode&&0!==i)for(var[u,l]of r.sendStreamWindows.entries()){var d=Math.max(0,l+i);r.sendStreamWindows.set(u,d)}try{if(r.onSettingsParsed&&(void 0!==n||0!==i)){var h={};void 0!==n&&(h.maxConcurrentStreams=n),0!==i&&(h.initialWindowSize=r.peerInitialStreamWindow),r.onSettingsParsed(h)}}catch(e){}r.onSettings&&r.onSettings(e),r.peerSettingsReceived=!0,r.sendWindowWaiters.splice(0).forEach((e=>{try{e()}catch(e){}}))}break;case dB:r.onData&&r.onData(t.slice(9),e);try{if(0!==e.streamId){var p=CT.createWindowUpdateFrame(e.streamId,e.length);r.writer.write(p)}var y=CT.createWindowUpdateFrame(0,e.length);r.writer.write(y)}catch(e){}if((e.flags&wB)===wB)return r.endFlag=!0,void(r.onEnd&&r.onEnd());break;case hB:if(r.onHeaders&&r.onHeaders(t.slice(9),e),(e.flags&wB)===wB)return r.endFlag=!0,void(r.onEnd&&r.onEnd());break;case bB:r.handleWindowUpdateFrame(e,t,e.streamId);try{var f=r.parseWindowUpdateFrame(t,e).windowSizeIncrement;if(0===e.streamId)r.sendConnWindow+=f;else{var g,b=null!==(g=r.sendStreamWindows.get(e.streamId))&&void 0!==g?g:r.peerInitialStreamWindow;r.sendStreamWindows.set(e.streamId,b+f)}r.sendWindowWaiters.splice(0).forEach((e=>{try{e()}catch(e){}}))}catch(e){}break;case fB:r._handlePingFrame(e,t);break;case gB:var m;try{var w=t.subarray(9);if(w.length>=8){var v=new DataView(w.buffer,w.byteOffset,w.byteLength);m={lastStreamId:2147483647&v.getUint32(0,!1),errorCode:v.getUint32(4,!1)}}else m={}}catch(e){}try{var k;null===(k=r.onGoaway)||void 0===k||k.call(r,null!=m?m:{})}catch(e){}r.endFlag=!0;try{var S;null===(S=r.onEnd)||void 0===S||S.call(r)}catch(e){}break;case pB:r.endFlag=!0,r.onEnd&&r.onEnd()}}))()}_parseFrameHeader(e){return{length:e[0]<<16|e[1]<<8|e[2],type:e[3],flags:e[4],streamId:e[5]<<24|e[6]<<16|e[7]<<8|e[8],payload:e.slice(0,9)}}_handlePingFrame(e,t){if(8!==e.length)throw new Error("PING frame must have a length of 8 bytes");if(!(e.flags&mB)){var r=CT.createPongFrame(t.slice(9));try{this.writer.write(r)}catch(e){throw e}}}waitForEndOfStream(e){return new Promise(((t,r)=>{if(this.endFlag)t();else{var n=null;e>0&&(n=setTimeout((()=>{clearInterval(o),r(new Error("End of stream timeout"))}),e));var o=setInterval((()=>{this.endFlag&&(null!==n&&clearTimeout(n),clearInterval(o),t())}),100),i=this.onEnd;this.onEnd=()=>{this.endFlag||(this.endFlag=!0),null!==n&&clearTimeout(n),clearInterval(o),t(),i&&i()}}}))}parseWindowUpdateFrame(e,t){if(4!==t.length)throw new Error("WINDOW_UPDATE frame must have a length of 4 bytes");var r=new Uint8Array(e.slice(9)),n=(127&r[0])<<24|r[1]<<16|r[2]<<8|r[3];if(0===n)throw new Error("WINDOW_UPDATE increment must not be zero");return{windowSizeIncrement:n}}handleWindowUpdateFrame(e,t,r){try{var n=this.parseWindowUpdateFrame(t,e);return this.connectionWindowSize+=n.windowSizeIncrement,n}catch(e){throw e}}}var DT=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(255!==r[s])throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function d(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,o=0;e[t]===c;)n++,t++;for(var i=(e.length-t)*u+1>>>0,s=new Uint8Array(i);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var d=0,h=i-1;(0!==l||d<o)&&-1!==h;h--,d++)l+=a*s[h]>>>0,s[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=d,t++}if(" "!==e[t]){for(var p=i-o;p!==i&&0===s[p];)p++;for(var y=new Uint8Array(n+(i-p)),f=n;p!==i;)y[f++]=s[p++];return y}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*l+1>>>0,u=new Uint8Array(s);o!==i;){for(var d=t[o],h=0,p=s-1;(0!==d||h<n)&&-1!==p;p--,h++)d+=256*u[p]>>>0,u[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");n=h,o++}for(var y=s-n;y!==s&&0===u[y];)y++;for(var f=c.repeat(r);y<s;++y)f+=e.charAt(u[y]);return f},decodeUnsafe:d,decode:function(e){var r=d(e);if(r)return r;throw new Error("Non-".concat(t," character"))}}},RT=DT;let jT=class{constructor(e,t,r){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseEncode",void 0),this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}},NT=class{constructor(e,t,r){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseDecode",void 0),W(this,"prefixCodePoint",void 0),this.name=e,this.prefix=t;var n=t.codePointAt(0);if(void 0===n)throw new Error("Invalid prefix character");this.prefixCodePoint=n,this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return KT(this,e)}};class UT{constructor(e){W(this,"decoders",void 0),this.decoders=e}or(e){return KT(this,e)}decode(e){var t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}function KT(e,t){var r,n;return new UT(Z(Z({},null!==(r=e.decoders)&&void 0!==r?r:{[e.prefix]:e}),null!==(n=t.decoders)&&void 0!==n?n:{[t.prefix]:t}))}class qT{constructor(e,t,r,n){W(this,"name",void 0),W(this,"prefix",void 0),W(this,"baseEncode",void 0),W(this,"baseDecode",void 0),W(this,"encoder",void 0),W(this,"decoder",void 0),this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new jT(e,t,r),this.decoder=new NT(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function LT(e){var{name:t,prefix:r,encode:n,decode:o}=e;return new qT(t,r,n,o)}function _T(e){var{name:t,prefix:r,alphabet:n}=e,{encode:o,decode:i}=RT(n,t);return LT({prefix:r,name:t,encode:o,decode:e=>function(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}(i(e))})}function MT(e){var{name:t,prefix:r,bitsPerChar:n,alphabet:o}=e;return LT({prefix:r,name:t,encode:e=>function(e,t,r){for(var n="="===t[t.length-1],o=(1<<r)-1,i="",s=0,a=0,c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)i+=t[o&a>>(s-=r)];if(0!==s&&(i+=t[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}(e,o,n),decode:e=>function(e,t,r,n){for(var o={},i=0;i<t.length;++i)o[t[i]]=i;for(var s=e.length;"="===e[s-1];)--s;for(var a=new Uint8Array(s*r/8|0),c=0,u=0,l=0,d=0;d<s;++d){var h=o[e[d]];if(void 0===h)throw new SyntaxError("Non-".concat(n," character"));u=u<<r|h,(c+=r)>=8&&(c-=8,a[l++]=255&u>>c)}if(c>=r||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return a}(e,o,n,t)})}var FT=_T({prefix:"9",name:"base10",alphabet:"0123456789"}),zT=Object.freeze({__proto__:null,base10:FT}),GT=MT({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),VT=MT({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),HT=Object.freeze({__proto__:null,base16:GT,base16upper:VT}),WT=MT({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),JT=Object.freeze({__proto__:null,base2:WT}),$T=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),YT=$T.reduce(((e,t,r)=>(e[r]=t,e)),[]),ZT=$T.reduce(((e,t,r)=>{var n=t.codePointAt(0);if(null==n)throw new Error("Invalid character: ".concat(t));return e[n]=r,e}),[]);var QT=LT({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=YT[t]),"")},decode:function(e){var t=[];for(var r of e){var n=r.codePointAt(0);if(null==n)throw new Error("Invalid character: ".concat(r));var o=ZT[n];if(null==o)throw new Error("Non-base256emoji character: ".concat(r));t.push(o)}return new Uint8Array(t)}}),XT=Object.freeze({__proto__:null,base256emoji:QT}),eD=MT({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),tD=MT({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),rD=MT({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),nD=MT({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),oD=MT({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),iD=MT({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),sD=MT({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),aD=MT({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),cD=MT({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),uD=Object.freeze({__proto__:null,base32:eD,base32hex:oD,base32hexpad:sD,base32hexpadupper:aD,base32hexupper:iD,base32pad:rD,base32padupper:nD,base32upper:tD,base32z:cD}),lD=_T({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),dD=_T({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),hD=Object.freeze({__proto__:null,base36:lD,base36upper:dD}),pD=_T({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),yD=_T({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),fD=Object.freeze({__proto__:null,base58btc:pD,base58flickr:yD}),gD=MT({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bD=MT({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),mD=MT({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wD=MT({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),vD=Object.freeze({__proto__:null,base64:gD,base64pad:bD,base64url:mD,base64urlpad:wD}),kD=MT({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),SD=Object.freeze({__proto__:null,base8:kD}),OD=LT({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),AD=Object.freeze({__proto__:null,identity:OD});new TextEncoder,new TextDecoder;var ID=Z(Z(Z(Z(Z(Z(Z(Z(Z(Z({},AD),JT),SD),zT),HT),uD),hD),fD),vD),XT);function xD(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var PD=xD("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),ED=xD("ascii","a",(e=>{for(var t="a",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{for(var t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length),r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),CD=Z({utf8:PD,"utf-8":PD,hex:ID.base16,latin1:ED,ascii:ED,binary:ED},ID);class BD{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4096;this.dynamicTable=[],this.dynamicTableSize=0,this.maxDynamicTableSize=e,this.staticTable=[["",""],[":authority",""],[":method","GET"],[":method","POST"],[":path","/"],[":path","/index.html"],[":scheme","http"],[":scheme","https"],[":status","200"],[":status","204"],[":status","206"],[":status","304"],[":status","400"],[":status","404"],[":status","500"],["accept-charset",""],["accept-encoding","gzip, deflate"],["accept-language",""],["accept-ranges",""],["accept",""],["access-control-allow-origin",""],["age",""],["allow",""],["authorization",""],["cache-control",""],["content-disposition",""],["content-encoding",""],["content-language",""],["content-length",""],["content-location",""],["content-range",""],["content-type",""],["cookie",""],["date",""],["etag",""],["expect",""],["expires",""],["from",""],["host",""],["if-match",""],["if-modified-since",""],["if-none-match",""],["if-range",""],["if-unmodified-since",""],["last-modified",""],["link",""],["location",""],["max-forwards",""],["proxy-authenticate",""],["proxy-authorization",""],["range",""],["referer",""],["refresh",""],["retry-after",""],["server",""],["set-cookie",""],["strict-transport-security",""],["transfer-encoding",""],["user-agent",""],["vary",""],["via",""],["www-authenticate",""]],this.huffmanTable=this.buildHuffmanTable()}encode(e){var t=[];for(var[r,n]of Object.entries(e)){var o=this.findInStaticTable(r,n);if(-1===o){var i=this.findInDynamicTable(r,n);-1===i?this.encodeLiteral(t,r,n):t.push(...this.encodeInteger(i+this.staticTable.length,7,128))}else t.push(...this.encodeInteger(o,7,128))}return new Uint8Array(t)}encodeInteger(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=[],o=(1<<t)-1;if(e<o)return n.push(r|e),n;for(n.push(r|o),e-=o;e>=128;)n.push(127&e|128),e>>=7;return n.push(e),n}encodeString(e){var t=[],r=(new TextEncoder).encode(e),n=this.huffmanEncode(r);return n.length<r.length?(t.push(...this.encodeInteger(n.length,7,128)),t.push(...n)):(t.push(...this.encodeInteger(r.length,7,0)),t.push(...r)),t}findInStaticTable(e,t){for(var r=1;r<this.staticTable.length;r++)if(this.staticTable[r][0]===e&&this.staticTable[r][1]===t)return r;return-1}findInDynamicTable(e,t){for(var r=0;r<this.dynamicTable.length;r++)if(this.dynamicTable[r][0]===e&&this.dynamicTable[r][1]===t)return r;return-1}encodeLiteral(e,t,r){var n=this.findInStaticTable(t,"");-1!==n?e.push(...this.encodeInteger(n,6,64)):(e.push(64),e.push(...this.encodeString(t))),e.push(...this.encodeString(r)),this.addToDynamicTable(t,r)}addToDynamicTable(e,t){for(var r=e.length+t.length+32;this.dynamicTableSize+r>this.maxDynamicTableSize&&this.dynamicTable.length>0;){var n=this.dynamicTable.pop();n&&(this.dynamicTableSize-=n[0].length+n[1].length+32)}r<=this.maxDynamicTableSize&&(this.dynamicTable.unshift([e,t]),this.dynamicTableSize+=r),this.dynamicTable.push([e,t])}getIndexedHeader(e){return e<=this.staticTable.length-1?this.staticTable[e]:this.dynamicTable[e-this.staticTable.length]}buildHuffmanTable(){return{codes:new Uint32Array([8184,8388568,268435426,268435427,268435428,268435429,268435430,268435431,268435432,16777194,1073741820,268435433,268435434,1073741821,268435435,268435436,268435437,268435438,268435439,268435440,268435441,268435442,1073741822,268435443,268435444,268435445,268435446,268435447,268435448,268435449,268435450,268435451,20,1016,1017,4090,8185,21,248,2042,1018,1019,249,2043,250,22,23,24,0,1,2,25,26,27,28,29,30,31,92,251,32764,32,4091,1020,8186,33,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,252,115,253,8187,524272,8188,16380,34,32765,3,35,4,36,5,37,38,39,6,116,117,40,41,42,7,43,118,44,8,9,45,119,120,121,122,123,32766,2044,16381,8189,268435452,1048550,4194258,1048551,1048552,4194259,4194260,4194261,8388569,4194262,8388570,8388571,8388572,8388573,8388574,16777195,8388575,16777196,16777197,4194263,8388576,16777198,8388577,8388578,8388579,8388580,2097116,4194264,8388581,4194265,8388582,8388583,16777199,4194266,2097117,1048553,4194267,4194268,8388584,8388585,2097118,8388586,4194269,4194270,16777200,2097119,4194271,8388587,8388588,2097120,2097121,4194272,2097122,8388589,4194273,8388590,8388591,1048554,4194274,4194275,4194276,8388592,4194277,4194278,8388593,67108832,67108833,1048555,524273,4194279,8388594,4194280,33554412,67108834,67108835,67108836,134217694,134217695,67108837,16777201,33554413,524274,2097123,67108838,134217696,134217697,67108839,134217698,16777202,2097124,2097125,67108840,67108841,268435453,134217699,134217700,134217701,1048556,16777203,1048557,2097126,4194281,2097127,2097128,8388595,4194282,4194283,33554414,33554415,16777204,16777205,67108842,8388596,67108843,134217702,67108844,67108845,134217703,134217704,134217705,134217706,134217707,268435454,134217708,134217709,134217710,134217711,134217712,67108846]),lengths:new Uint8Array([13,23,28,28,28,28,28,28,28,24,30,28,28,30,28,28,28,28,28,28,28,28,30,28,28,28,28,28,28,28,28,28,6,10,10,12,13,6,8,11,10,10,8,11,8,6,6,6,5,5,5,6,6,6,6,6,6,6,7,8,15,6,12,10,13,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,7,8,13,19,13,14,6,15,5,6,5,6,5,6,6,6,5,7,7,6,6,6,5,6,7,6,5,5,6,7,7,7,7,7,15,11,14,13,28,20,22,20,20,22,22,22,23,22,23,23,23,23,23,24,23,24,24,22,23,24,23,23,23,23,21,22,23,22,23,23,24,22,21,20,22,22,23,23,21,23,22,22,24,21,22,23,23,21,21,22,21,23,22,23,23,20,22,22,22,23,22,22,23,26,26,20,19,22,23,22,25,26,26,26,27,27,26,24,25,19,21,26,27,27,26,27,24,21,21,26,26,28,27,27,27,20,24,20,21,22,21,21,23,22,22,25,25,24,24,26,23,26,27,26,26,27,27,27,27,27,28,27,27,27,27,27,26])}}decode(e){for(var t="",r=0,n=0,o=0;o<e.length;o++){for(r=r<<8|e[o],n+=8;n>=5;){var i=this.findSymbol(r,n);if(!i)break;var[s,a]=i;t+=String.fromCharCode(s),r&=(1<<n-a)-1,n-=a}}if(n>0){var c=(1<<n)-1;if((r&c)!==c)throw new Error("Invalid Huffman padding")}return t}findSymbol(e,t){for(var r=0;r<this.huffmanTable.codes.length;r++){var n=this.huffmanTable.lengths[r];if(!(t<n))if((e>>t-n&(1<<n)-1)===this.huffmanTable.codes[r])return[r,n]}return null}huffmanEncode(e){for(var t=[],r=0,n=0,o=0;o<e.length;o++){var i=e[o],s=this.huffmanTable.codes[i],a=this.huffmanTable.lengths[i];for(n+=a,r=r<<a|s;n>=8;)n-=8,t.push(r>>n&255)}return n>0&&(r=r<<8-n|(1<<8-n)-1,t.push(255&r)),new Uint8Array(t)}decodeHeaderFields(e){for(var t=new Map,r=0;r<e.length;){var n=e[r];if(128&n){var[o,i,s]=this.decodeIndexedHeader(e,r);o&&i&&t.set(o,i),r=s}else if(64&n){var[a,c,u]=this.decodeLiteralHeaderWithIndexing(e,r);a&&c&&t.set(a,c),r=u}else if(32&n)r++;else if(16&n){var[l,d,h]=this.decodeLiteralHeaderWithoutIndexing(e,r);l&&d&&t.set(l,d),r=h}else{var[p,y,f]=this.decodeLiteralHeaderWithoutIndexing(e,r);p&&y&&t.set(p,y),r=f}}return t}decodeInteger(e,t,r){var n=(1<<r)-1,o=t,i=e[t]&n;if(i<n)return[i,o+1];o++;for(var s=0;o<e.length;){var a=e[o++];if(i+=(127&a)<<s,s+=7,!(128&a))break}return[i,o]}decodeLiteralString(e,t){if(t>=e.length)return["",t];var r=!!(128&e[t]),[n,o]=this.decodeInteger(e,t,7);if(o+n>e.length)return["",o];var i,s=e.slice(o,o+n);if(r)try{i=this.decode(s)}catch(e){i=""}else try{i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8",r=CD[t];if(null==r)throw new Error('Unsupported encoding "'.concat(t,'"'));return r.encoder.encode(e).substring(1)}(s)}catch(e){i=""}return[i,o+n]}decodeIndexedHeader(e,t){var[r,n]=this.decodeInteger(e,t,7);if(r<=0)return["","",n];var o=this.staticTable[r];return o?[o[0],o[1],n]:["","",n]}decodeLiteralHeaderWithIndexing(e,t){var r,[n,o]=this.decodeInteger(e,t,6);if(t=o,n>0){var i=this.staticTable[n];r=i?i[0]:""}else{var[s,a]=this.decodeLiteralString(e,t);r=s,t=a}var[c,u]=this.decodeLiteralString(e,t);return[r,c,u]}decodeLiteralHeaderWithoutIndexing(e,t){return this.decodeLiteralHeaderWithIndexing(e,t)}huffmanDecodeToString(e){return this.decode(e)}}var TD="abandon\nability\nable\nabout\nabove\nabsent\nabsorb\nabstract\nabsurd\nabuse\naccess\naccident\naccount\naccuse\nachieve\nacid\nacoustic\nacquire\nacross\nact\naction\nactor\nactress\nactual\nadapt\nadd\naddict\naddress\nadjust\nadmit\nadult\nadvance\nadvice\naerobic\naffair\nafford\nafraid\nagain\nage\nagent\nagree\nahead\naim\nair\nairport\naisle\nalarm\nalbum\nalcohol\nalert\nalien\nall\nalley\nallow\nalmost\nalone\nalpha\nalready\nalso\nalter\nalways\namateur\namazing\namong\namount\namused\nanalyst\nanchor\nancient\nanger\nangle\nangry\nanimal\nankle\nannounce\nannual\nanother\nanswer\nantenna\nantique\nanxiety\nany\napart\napology\nappear\napple\napprove\napril\narch\narctic\narea\narena\nargue\narm\narmed\narmor\narmy\naround\narrange\narrest\narrive\narrow\nart\nartefact\nartist\nartwork\nask\naspect\nassault\nasset\nassist\nassume\nasthma\nathlete\natom\nattack\nattend\nattitude\nattract\nauction\naudit\naugust\naunt\nauthor\nauto\nautumn\naverage\navocado\navoid\nawake\naware\naway\nawesome\nawful\nawkward\naxis\nbaby\nbachelor\nbacon\nbadge\nbag\nbalance\nbalcony\nball\nbamboo\nbanana\nbanner\nbar\nbarely\nbargain\nbarrel\nbase\nbasic\nbasket\nbattle\nbeach\nbean\nbeauty\nbecause\nbecome\nbeef\nbefore\nbegin\nbehave\nbehind\nbelieve\nbelow\nbelt\nbench\nbenefit\nbest\nbetray\nbetter\nbetween\nbeyond\nbicycle\nbid\nbike\nbind\nbiology\nbird\nbirth\nbitter\nblack\nblade\nblame\nblanket\nblast\nbleak\nbless\nblind\nblood\nblossom\nblouse\nblue\nblur\nblush\nboard\nboat\nbody\nboil\nbomb\nbone\nbonus\nbook\nboost\nborder\nboring\nborrow\nboss\nbottom\nbounce\nbox\nboy\nbracket\nbrain\nbrand\nbrass\nbrave\nbread\nbreeze\nbrick\nbridge\nbrief\nbright\nbring\nbrisk\nbroccoli\nbroken\nbronze\nbroom\nbrother\nbrown\nbrush\nbubble\nbuddy\nbudget\nbuffalo\nbuild\nbulb\nbulk\nbullet\nbundle\nbunker\nburden\nburger\nburst\nbus\nbusiness\nbusy\nbutter\nbuyer\nbuzz\ncabbage\ncabin\ncable\ncactus\ncage\ncake\ncall\ncalm\ncamera\ncamp\ncan\ncanal\ncancel\ncandy\ncannon\ncanoe\ncanvas\ncanyon\ncapable\ncapital\ncaptain\ncar\ncarbon\ncard\ncargo\ncarpet\ncarry\ncart\ncase\ncash\ncasino\ncastle\ncasual\ncat\ncatalog\ncatch\ncategory\ncattle\ncaught\ncause\ncaution\ncave\nceiling\ncelery\ncement\ncensus\ncentury\ncereal\ncertain\nchair\nchalk\nchampion\nchange\nchaos\nchapter\ncharge\nchase\nchat\ncheap\ncheck\ncheese\nchef\ncherry\nchest\nchicken\nchief\nchild\nchimney\nchoice\nchoose\nchronic\nchuckle\nchunk\nchurn\ncigar\ncinnamon\ncircle\ncitizen\ncity\ncivil\nclaim\nclap\nclarify\nclaw\nclay\nclean\nclerk\nclever\nclick\nclient\ncliff\nclimb\nclinic\nclip\nclock\nclog\nclose\ncloth\ncloud\nclown\nclub\nclump\ncluster\nclutch\ncoach\ncoast\ncoconut\ncode\ncoffee\ncoil\ncoin\ncollect\ncolor\ncolumn\ncombine\ncome\ncomfort\ncomic\ncommon\ncompany\nconcert\nconduct\nconfirm\ncongress\nconnect\nconsider\ncontrol\nconvince\ncook\ncool\ncopper\ncopy\ncoral\ncore\ncorn\ncorrect\ncost\ncotton\ncouch\ncountry\ncouple\ncourse\ncousin\ncover\ncoyote\ncrack\ncradle\ncraft\ncram\ncrane\ncrash\ncrater\ncrawl\ncrazy\ncream\ncredit\ncreek\ncrew\ncricket\ncrime\ncrisp\ncritic\ncrop\ncross\ncrouch\ncrowd\ncrucial\ncruel\ncruise\ncrumble\ncrunch\ncrush\ncry\ncrystal\ncube\nculture\ncup\ncupboard\ncurious\ncurrent\ncurtain\ncurve\ncushion\ncustom\ncute\ncycle\ndad\ndamage\ndamp\ndance\ndanger\ndaring\ndash\ndaughter\ndawn\nday\ndeal\ndebate\ndebris\ndecade\ndecember\ndecide\ndecline\ndecorate\ndecrease\ndeer\ndefense\ndefine\ndefy\ndegree\ndelay\ndeliver\ndemand\ndemise\ndenial\ndentist\ndeny\ndepart\ndepend\ndeposit\ndepth\ndeputy\nderive\ndescribe\ndesert\ndesign\ndesk\ndespair\ndestroy\ndetail\ndetect\ndevelop\ndevice\ndevote\ndiagram\ndial\ndiamond\ndiary\ndice\ndiesel\ndiet\ndiffer\ndigital\ndignity\ndilemma\ndinner\ndinosaur\ndirect\ndirt\ndisagree\ndiscover\ndisease\ndish\ndismiss\ndisorder\ndisplay\ndistance\ndivert\ndivide\ndivorce\ndizzy\ndoctor\ndocument\ndog\ndoll\ndolphin\ndomain\ndonate\ndonkey\ndonor\ndoor\ndose\ndouble\ndove\ndraft\ndragon\ndrama\ndrastic\ndraw\ndream\ndress\ndrift\ndrill\ndrink\ndrip\ndrive\ndrop\ndrum\ndry\nduck\ndumb\ndune\nduring\ndust\ndutch\nduty\ndwarf\ndynamic\neager\neagle\nearly\nearn\nearth\neasily\neast\neasy\necho\necology\neconomy\nedge\nedit\neducate\neffort\negg\neight\neither\nelbow\nelder\nelectric\nelegant\nelement\nelephant\nelevator\nelite\nelse\nembark\nembody\nembrace\nemerge\nemotion\nemploy\nempower\nempty\nenable\nenact\nend\nendless\nendorse\nenemy\nenergy\nenforce\nengage\nengine\nenhance\nenjoy\nenlist\nenough\nenrich\nenroll\nensure\nenter\nentire\nentry\nenvelope\nepisode\nequal\nequip\nera\nerase\nerode\nerosion\nerror\nerupt\nescape\nessay\nessence\nestate\neternal\nethics\nevidence\nevil\nevoke\nevolve\nexact\nexample\nexcess\nexchange\nexcite\nexclude\nexcuse\nexecute\nexercise\nexhaust\nexhibit\nexile\nexist\nexit\nexotic\nexpand\nexpect\nexpire\nexplain\nexpose\nexpress\nextend\nextra\neye\neyebrow\nfabric\nface\nfaculty\nfade\nfaint\nfaith\nfall\nfalse\nfame\nfamily\nfamous\nfan\nfancy\nfantasy\nfarm\nfashion\nfat\nfatal\nfather\nfatigue\nfault\nfavorite\nfeature\nfebruary\nfederal\nfee\nfeed\nfeel\nfemale\nfence\nfestival\nfetch\nfever\nfew\nfiber\nfiction\nfield\nfigure\nfile\nfilm\nfilter\nfinal\nfind\nfine\nfinger\nfinish\nfire\nfirm\nfirst\nfiscal\nfish\nfit\nfitness\nfix\nflag\nflame\nflash\nflat\nflavor\nflee\nflight\nflip\nfloat\nflock\nfloor\nflower\nfluid\nflush\nfly\nfoam\nfocus\nfog\nfoil\nfold\nfollow\nfood\nfoot\nforce\nforest\nforget\nfork\nfortune\nforum\nforward\nfossil\nfoster\nfound\nfox\nfragile\nframe\nfrequent\nfresh\nfriend\nfringe\nfrog\nfront\nfrost\nfrown\nfrozen\nfruit\nfuel\nfun\nfunny\nfurnace\nfury\nfuture\ngadget\ngain\ngalaxy\ngallery\ngame\ngap\ngarage\ngarbage\ngarden\ngarlic\ngarment\ngas\ngasp\ngate\ngather\ngauge\ngaze\ngeneral\ngenius\ngenre\ngentle\ngenuine\ngesture\nghost\ngiant\ngift\ngiggle\nginger\ngiraffe\ngirl\ngive\nglad\nglance\nglare\nglass\nglide\nglimpse\nglobe\ngloom\nglory\nglove\nglow\nglue\ngoat\ngoddess\ngold\ngood\ngoose\ngorilla\ngospel\ngossip\ngovern\ngown\ngrab\ngrace\ngrain\ngrant\ngrape\ngrass\ngravity\ngreat\ngreen\ngrid\ngrief\ngrit\ngrocery\ngroup\ngrow\ngrunt\nguard\nguess\nguide\nguilt\nguitar\ngun\ngym\nhabit\nhair\nhalf\nhammer\nhamster\nhand\nhappy\nharbor\nhard\nharsh\nharvest\nhat\nhave\nhawk\nhazard\nhead\nhealth\nheart\nheavy\nhedgehog\nheight\nhello\nhelmet\nhelp\nhen\nhero\nhidden\nhigh\nhill\nhint\nhip\nhire\nhistory\nhobby\nhockey\nhold\nhole\nholiday\nhollow\nhome\nhoney\nhood\nhope\nhorn\nhorror\nhorse\nhospital\nhost\nhotel\nhour\nhover\nhub\nhuge\nhuman\nhumble\nhumor\nhundred\nhungry\nhunt\nhurdle\nhurry\nhurt\nhusband\nhybrid\nice\nicon\nidea\nidentify\nidle\nignore\nill\nillegal\nillness\nimage\nimitate\nimmense\nimmune\nimpact\nimpose\nimprove\nimpulse\ninch\ninclude\nincome\nincrease\nindex\nindicate\nindoor\nindustry\ninfant\ninflict\ninform\ninhale\ninherit\ninitial\ninject\ninjury\ninmate\ninner\ninnocent\ninput\ninquiry\ninsane\ninsect\ninside\ninspire\ninstall\nintact\ninterest\ninto\ninvest\ninvite\ninvolve\niron\nisland\nisolate\nissue\nitem\nivory\njacket\njaguar\njar\njazz\njealous\njeans\njelly\njewel\njob\njoin\njoke\njourney\njoy\njudge\njuice\njump\njungle\njunior\njunk\njust\nkangaroo\nkeen\nkeep\nketchup\nkey\nkick\nkid\nkidney\nkind\nkingdom\nkiss\nkit\nkitchen\nkite\nkitten\nkiwi\nknee\nknife\nknock\nknow\nlab\nlabel\nlabor\nladder\nlady\nlake\nlamp\nlanguage\nlaptop\nlarge\nlater\nlatin\nlaugh\nlaundry\nlava\nlaw\nlawn\nlawsuit\nlayer\nlazy\nleader\nleaf\nlearn\nleave\nlecture\nleft\nleg\nlegal\nlegend\nleisure\nlemon\nlend\nlength\nlens\nleopard\nlesson\nletter\nlevel\nliar\nliberty\nlibrary\nlicense\nlife\nlift\nlight\nlike\nlimb\nlimit\nlink\nlion\nliquid\nlist\nlittle\nlive\nlizard\nload\nloan\nlobster\nlocal\nlock\nlogic\nlonely\nlong\nloop\nlottery\nloud\nlounge\nlove\nloyal\nlucky\nluggage\nlumber\nlunar\nlunch\nluxury\nlyrics\nmachine\nmad\nmagic\nmagnet\nmaid\nmail\nmain\nmajor\nmake\nmammal\nman\nmanage\nmandate\nmango\nmansion\nmanual\nmaple\nmarble\nmarch\nmargin\nmarine\nmarket\nmarriage\nmask\nmass\nmaster\nmatch\nmaterial\nmath\nmatrix\nmatter\nmaximum\nmaze\nmeadow\nmean\nmeasure\nmeat\nmechanic\nmedal\nmedia\nmelody\nmelt\nmember\nmemory\nmention\nmenu\nmercy\nmerge\nmerit\nmerry\nmesh\nmessage\nmetal\nmethod\nmiddle\nmidnight\nmilk\nmillion\nmimic\nmind\nminimum\nminor\nminute\nmiracle\nmirror\nmisery\nmiss\nmistake\nmix\nmixed\nmixture\nmobile\nmodel\nmodify\nmom\nmoment\nmonitor\nmonkey\nmonster\nmonth\nmoon\nmoral\nmore\nmorning\nmosquito\nmother\nmotion\nmotor\nmountain\nmouse\nmove\nmovie\nmuch\nmuffin\nmule\nmultiply\nmuscle\nmuseum\nmushroom\nmusic\nmust\nmutual\nmyself\nmystery\nmyth\nnaive\nname\nnapkin\nnarrow\nnasty\nnation\nnature\nnear\nneck\nneed\nnegative\nneglect\nneither\nnephew\nnerve\nnest\nnet\nnetwork\nneutral\nnever\nnews\nnext\nnice\nnight\nnoble\nnoise\nnominee\nnoodle\nnormal\nnorth\nnose\nnotable\nnote\nnothing\nnotice\nnovel\nnow\nnuclear\nnumber\nnurse\nnut\noak\nobey\nobject\noblige\nobscure\nobserve\nobtain\nobvious\noccur\nocean\noctober\nodor\noff\noffer\noffice\noften\noil\nokay\nold\nolive\nolympic\nomit\nonce\none\nonion\nonline\nonly\nopen\nopera\nopinion\noppose\noption\norange\norbit\norchard\norder\nordinary\norgan\norient\noriginal\norphan\nostrich\nother\noutdoor\nouter\noutput\noutside\noval\noven\nover\nown\nowner\noxygen\noyster\nozone\npact\npaddle\npage\npair\npalace\npalm\npanda\npanel\npanic\npanther\npaper\nparade\nparent\npark\nparrot\nparty\npass\npatch\npath\npatient\npatrol\npattern\npause\npave\npayment\npeace\npeanut\npear\npeasant\npelican\npen\npenalty\npencil\npeople\npepper\nperfect\npermit\nperson\npet\nphone\nphoto\nphrase\nphysical\npiano\npicnic\npicture\npiece\npig\npigeon\npill\npilot\npink\npioneer\npipe\npistol\npitch\npizza\nplace\nplanet\nplastic\nplate\nplay\nplease\npledge\npluck\nplug\nplunge\npoem\npoet\npoint\npolar\npole\npolice\npond\npony\npool\npopular\nportion\nposition\npossible\npost\npotato\npottery\npoverty\npowder\npower\npractice\npraise\npredict\nprefer\nprepare\npresent\npretty\nprevent\nprice\npride\nprimary\nprint\npriority\nprison\nprivate\nprize\nproblem\nprocess\nproduce\nprofit\nprogram\nproject\npromote\nproof\nproperty\nprosper\nprotect\nproud\nprovide\npublic\npudding\npull\npulp\npulse\npumpkin\npunch\npupil\npuppy\npurchase\npurity\npurpose\npurse\npush\nput\npuzzle\npyramid\nquality\nquantum\nquarter\nquestion\nquick\nquit\nquiz\nquote\nrabbit\nraccoon\nrace\nrack\nradar\nradio\nrail\nrain\nraise\nrally\nramp\nranch\nrandom\nrange\nrapid\nrare\nrate\nrather\nraven\nraw\nrazor\nready\nreal\nreason\nrebel\nrebuild\nrecall\nreceive\nrecipe\nrecord\nrecycle\nreduce\nreflect\nreform\nrefuse\nregion\nregret\nregular\nreject\nrelax\nrelease\nrelief\nrely\nremain\nremember\nremind\nremove\nrender\nrenew\nrent\nreopen\nrepair\nrepeat\nreplace\nreport\nrequire\nrescue\nresemble\nresist\nresource\nresponse\nresult\nretire\nretreat\nreturn\nreunion\nreveal\nreview\nreward\nrhythm\nrib\nribbon\nrice\nrich\nride\nridge\nrifle\nright\nrigid\nring\nriot\nripple\nrisk\nritual\nrival\nriver\nroad\nroast\nrobot\nrobust\nrocket\nromance\nroof\nrookie\nroom\nrose\nrotate\nrough\nround\nroute\nroyal\nrubber\nrude\nrug\nrule\nrun\nrunway\nrural\nsad\nsaddle\nsadness\nsafe\nsail\nsalad\nsalmon\nsalon\nsalt\nsalute\nsame\nsample\nsand\nsatisfy\nsatoshi\nsauce\nsausage\nsave\nsay\nscale\nscan\nscare\nscatter\nscene\nscheme\nschool\nscience\nscissors\nscorpion\nscout\nscrap\nscreen\nscript\nscrub\nsea\nsearch\nseason\nseat\nsecond\nsecret\nsection\nsecurity\nseed\nseek\nsegment\nselect\nsell\nseminar\nsenior\nsense\nsentence\nseries\nservice\nsession\nsettle\nsetup\nseven\nshadow\nshaft\nshallow\nshare\nshed\nshell\nsheriff\nshield\nshift\nshine\nship\nshiver\nshock\nshoe\nshoot\nshop\nshort\nshoulder\nshove\nshrimp\nshrug\nshuffle\nshy\nsibling\nsick\nside\nsiege\nsight\nsign\nsilent\nsilk\nsilly\nsilver\nsimilar\nsimple\nsince\nsing\nsiren\nsister\nsituate\nsix\nsize\nskate\nsketch\nski\nskill\nskin\nskirt\nskull\nslab\nslam\nsleep\nslender\nslice\nslide\nslight\nslim\nslogan\nslot\nslow\nslush\nsmall\nsmart\nsmile\nsmoke\nsmooth\nsnack\nsnake\nsnap\nsniff\nsnow\nsoap\nsoccer\nsocial\nsock\nsoda\nsoft\nsolar\nsoldier\nsolid\nsolution\nsolve\nsomeone\nsong\nsoon\nsorry\nsort\nsoul\nsound\nsoup\nsource\nsouth\nspace\nspare\nspatial\nspawn\nspeak\nspecial\nspeed\nspell\nspend\nsphere\nspice\nspider\nspike\nspin\nspirit\nsplit\nspoil\nsponsor\nspoon\nsport\nspot\nspray\nspread\nspring\nspy\nsquare\nsqueeze\nsquirrel\nstable\nstadium\nstaff\nstage\nstairs\nstamp\nstand\nstart\nstate\nstay\nsteak\nsteel\nstem\nstep\nstereo\nstick\nstill\nsting\nstock\nstomach\nstone\nstool\nstory\nstove\nstrategy\nstreet\nstrike\nstrong\nstruggle\nstudent\nstuff\nstumble\nstyle\nsubject\nsubmit\nsubway\nsuccess\nsuch\nsudden\nsuffer\nsugar\nsuggest\nsuit\nsummer\nsun\nsunny\nsunset\nsuper\nsupply\nsupreme\nsure\nsurface\nsurge\nsurprise\nsurround\nsurvey\nsuspect\nsustain\nswallow\nswamp\nswap\nswarm\nswear\nsweet\nswift\nswim\nswing\nswitch\nsword\nsymbol\nsymptom\nsyrup\nsystem\ntable\ntackle\ntag\ntail\ntalent\ntalk\ntank\ntape\ntarget\ntask\ntaste\ntattoo\ntaxi\nteach\nteam\ntell\nten\ntenant\ntennis\ntent\nterm\ntest\ntext\nthank\nthat\ntheme\nthen\ntheory\nthere\nthey\nthing\nthis\nthought\nthree\nthrive\nthrow\nthumb\nthunder\nticket\ntide\ntiger\ntilt\ntimber\ntime\ntiny\ntip\ntired\ntissue\ntitle\ntoast\ntobacco\ntoday\ntoddler\ntoe\ntogether\ntoilet\ntoken\ntomato\ntomorrow\ntone\ntongue\ntonight\ntool\ntooth\ntop\ntopic\ntopple\ntorch\ntornado\ntortoise\ntoss\ntotal\ntourist\ntoward\ntower\ntown\ntoy\ntrack\ntrade\ntraffic\ntragic\ntrain\ntransfer\ntrap\ntrash\ntravel\ntray\ntreat\ntree\ntrend\ntrial\ntribe\ntrick\ntrigger\ntrim\ntrip\ntrophy\ntrouble\ntruck\ntrue\ntruly\ntrumpet\ntrust\ntruth\ntry\ntube\ntuition\ntumble\ntuna\ntunnel\nturkey\nturn\nturtle\ntwelve\ntwenty\ntwice\ntwin\ntwist\ntwo\ntype\ntypical\nugly\numbrella\nunable\nunaware\nuncle\nuncover\nunder\nundo\nunfair\nunfold\nunhappy\nuniform\nunique\nunit\nuniverse\nunknown\nunlock\nuntil\nunusual\nunveil\nupdate\nupgrade\nuphold\nupon\nupper\nupset\nurban\nurge\nusage\nuse\nused\nuseful\nuseless\nusual\nutility\nvacant\nvacuum\nvague\nvalid\nvalley\nvalve\nvan\nvanish\nvapor\nvarious\nvast\nvault\nvehicle\nvelvet\nvendor\nventure\nvenue\nverb\nverify\nversion\nvery\nvessel\nveteran\nviable\nvibrant\nvicious\nvictory\nvideo\nview\nvillage\nvintage\nviolin\nvirtual\nvirus\nvisa\nvisit\nvisual\nvital\nvivid\nvocal\nvoice\nvoid\nvolcano\nvolume\nvote\nvoyage\nwage\nwagon\nwait\nwalk\nwall\nwalnut\nwant\nwarfare\nwarm\nwarrior\nwash\nwasp\nwaste\nwater\nwave\nway\nwealth\nweapon\nwear\nweasel\nweather\nweb\nwedding\nweekend\nweird\nwelcome\nwest\nwet\nwhale\nwhat\nwheat\nwheel\nwhen\nwhere\nwhip\nwhisper\nwide\nwidth\nwife\nwild\nwill\nwin\nwindow\nwine\nwing\nwink\nwinner\nwinter\nwire\nwisdom\nwise\nwish\nwitness\nwolf\nwoman\nwonder\nwood\nwool\nword\nwork\nworld\nworry\nworth\nwrap\nwreck\nwrestle\nwrist\nwrite\nwrong\nyard\nyear\nyellow\nyou\nyoung\nyouth\nzebra\nzero\nzone\nzoo".split("\n"),DD=To;function RD(e,t){let r=0,n=t.value;for(let t=0;t<4;t++)r=r<<8|e[n],n++,n>=e.length&&(n=0);return t.value=n,r>>>0}function jD(e,t,r){let n=e>>>0,o=t>>>0;return n^=r.p[0],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[1],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[2],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[3],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[4],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[5],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[6],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[7],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[8],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[9],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[10],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[11],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[12],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[13],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[14],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[15],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[16],o^=r.p[17],[o>>>0,n>>>0]}function ND(e,t){let r=0;for(let n=0;n<18;n++){let o=0;for(let t=0;t<4;t++)o=o<<8|e[r],r++,r>=e.length&&(r=0);t.p[n]^=o>>>0}let n=0,o=0;for(let e=0;e<18;e+=2)[n,o]=jD(n,o,t),t.p[e]=n,t.p[e+1]=o;for(let e=0;e<256;e+=2)[n,o]=jD(n,o,t),t.s0[e]=n,t.s0[e+1]=o;for(let e=0;e<256;e+=2)[n,o]=jD(n,o,t),t.s1[e]=n,t.s1[e+1]=o;for(let e=0;e<256;e+=2)[n,o]=jD(n,o,t),t.s2[e]=n,t.s2[e+1]=o;for(let e=0;e<256;e+=2)[n,o]=jD(n,o,t),t.s3[e]=n,t.s3[e+1]=o}const UD=Uint32Array.from([3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946]),KD=Uint32Array.from([1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055]),qD=Uint32Array.from([3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504]),LD=Uint32Array.from([976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]),_D=Uint32Array.from([608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731]);class MD extends Error{constructor(e){super(`crypto/blowfish: invalid key size ${e}`),this.name="KeySizeError"}}class FD{constructor(){this.p=new Uint32Array(18),this.s0=new Uint32Array(256),this.s1=new Uint32Array(256),this.s2=new Uint32Array(256),this.s3=new Uint32Array(256)}blockSize(){return 8}encrypt(e,t){if(8!==t.length||8!==e.length)throw new Error("Invalid buffer size");let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],n=t[4]<<24|t[5]<<16|t[6]<<8|t[7];[r,n]=jD(r>>>0,n>>>0,this),e[0]=r>>>24&255,e[1]=r>>>16&255,e[2]=r>>>8&255,e[3]=255&r,e[4]=n>>>24&255,e[5]=n>>>16&255,e[6]=n>>>8&255,e[7]=255&n}decrypt(e,t){if(8!==t.length||8!==e.length)throw new Error("Invalid buffer size");let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],n=t[4]<<24|t[5]<<16|t[6]<<8|t[7];[r,n]=function(e,t,r){let n=e>>>0,o=t>>>0;return n^=r.p[17],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[16],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[15],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[14],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[13],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[12],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[11],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[10],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[9],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[8],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[7],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[6],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[5],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[4],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[3],o^=(r.s0[n>>>24&255]+r.s1[n>>>16&255]^r.s2[n>>>8&255])+r.s3[255&n]^r.p[2],n^=(r.s0[o>>>24&255]+r.s1[o>>>16&255]^r.s2[o>>>8&255])+r.s3[255&o]^r.p[1],o^=r.p[0],[o>>>0,n>>>0]}(r>>>0,n>>>0,this),e[0]=r>>>24&255,e[1]=r>>>16&255,e[2]=r>>>8&255,e[3]=255&r,e[4]=n>>>24&255,e[5]=n>>>16&255,e[6]=n>>>8&255,e[7]=255&n}}function zD(e){e.p.set(_D),e.s0.set(UD),e.s1.set(KD),e.s2.set(qD),e.s3.set(LD)}function GD(e,t){if(0===t.length)return function(e){if(e.length<1||e.length>56)throw new MD(e.length);const t=new FD;return zD(t),ND(e,t),t}(e);if(e.length<1)throw new MD(e.length);const r=new FD;return zD(r),function(e,t,r){const n={value:0},o={value:0};for(let t=0;t<18;t++)r.p[t]^=RD(e,n);let i=0,s=0;for(let e=0;e<18;e+=2)i^=RD(t,o),s^=RD(t,o),[i,s]=jD(i,s,r),r.p[e]=i,r.p[e+1]=s;for(let e=0;e<256;e+=2)i^=RD(t,o),s^=RD(t,o),[i,s]=jD(i,s,r),r.s0[e]=i,r.s0[e+1]=s;for(let e=0;e<256;e+=2)i^=RD(t,o),s^=RD(t,o),[i,s]=jD(i,s,r),r.s1[e]=i,r.s1[e+1]=s;for(let e=0;e<256;e+=2)i^=RD(t,o),s^=RD(t,o),[i,s]=jD(i,s,r),r.s2[e]=i,r.s2[e+1]=s;for(let e=0;e<256;e+=2)i^=RD(t,o),s^=RD(t,o),[i,s]=jD(i,s,r),r.s3[e]=i,r.s3[e+1]=s}(e,t,r),r}const VD=new Uint8Array([79,114,112,104,101,97,110,66,101,104,111,108,100,101,114,83,99,114,121,68,111,117,98,116]),HD="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function WD(e){let t="",r=0;for(;r<e.length;){const n=((r<e.length?e[r++]:0)<<16)+((r<e.length?e[r++]:0)<<8)+(r<e.length?e[r++]:0);t+=HD[n>>18&63],t+=HD[n>>12&63],t+=HD[n>>6&63],t+=HD[63&n]}const n=e.length%3;return 1===n?t=t.slice(0,-2):2===n&&(t=t.slice(0,-1)),(new TextEncoder).encode(t)}async function JD(e,t,r){const n=function(e){const t=(new TextDecoder).decode(e),r=new Uint8Array(Math.floor(3*t.length/4));let n=0;const o=e=>{const t=HD.indexOf(e);if(-1===t)throw new Error("Invalid character in input");return t};for(let e=0;e<t.length;e+=4){const i=o(t[e])<<18|o(t[e+1])<<12|(e+2<t.length?o(t[e+2]):0)<<6|(e+3<t.length?o(t[e+3]):0);r[n++]=i>>16&255,e+2<t.length&&(r[n++]=i>>8&255),e+3<t.length&&(r[n++]=255&i)}return r.slice(0,n)}(r),o=new Uint8Array([...e,0]),i=GD(o,n),s=1<<t;for(let e=0;e<s;e++)ND(o,i),ND(n,i);return i}async function $D(e,t,r){if(16!==r.length)throw new Error("Salt must be exactly 16 bytes");const n=WD(r),o=await async function(e,t,r){const n=new Uint8Array(VD),o=await JD(e,t,r);for(let e=0;e<24;e+=8)for(let t=0;t<64;t++){const t=n.slice(e,e+8),r=new Uint8Array(8);o.encrypt(r,t),n.set(r,e)}return WD(n.slice(0,23))}(e,t,n);return{hash:o,salt:r,cost:t,major:"2",minor:"a"}}const YD={ETHEREUM:"m/44'/60'/0'/0/0",BITCOIN:"m/44'/0'/0'/0/0",FILECOIN:"m/44'/461'/0'/0/0",POLKADOT:"m/44'/354'/0'/0'/0'",SOLANA:"m/44'/501'/0'/0'",COSMOS:"m/44'/118'/0'/0/0"};class ZD{mnemonicToEntropy(e){if(!m.validateMnemonic(e,TD))throw new Error("无效的助记词");return m.mnemonicToEntropy(e,TD)}async seedFromMnemonic(e,t){const r=this.mnemonicToEntropy(e);if(r.length<16||r.length>32||r.length%4!=0)throw new Error("无效的熵长度");const n=ZD.SCHNORRKEL_SEED_PREFIX+t,o=(new TextEncoder).encode(n),i=await crypto.subtle.importKey("raw",r,{name:"PBKDF2"},!1,["deriveBits"]),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:o,iterations:2048,hash:"SHA-512"},i,512);return new Uint8Array(s)}async getEd25519KeyFromMnemonic(e,t=""){const r=await this.seedFromMnemonic(e,t),n=this.newKeyFromSeed(r.slice(0,32)),o=new Is(n.privateKey);return ZD.clearSensitiveData(r),ZD.clearSensitiveData(n.privateKey),o}newKeyFromSeed(e){if(e.length!==ZD.SEED_SIZE)throw new Error(`ed25519: bad seed length: ${e.length}`);const t=DD(e).slice(0,32);t[0]&=248,t[31]&=127,t[31]|=64;const r=Di.getPublicKey(e),n=new Uint8Array(ZD.PRIVATE_KEY_SIZE);return n.set(e),n.set(r,32),{privateKey:n,publicKey:r}}static generateMnemonic(e=256){return m.generateMnemonic(TD,e)}static validateMnemonic(e){return m.validateMnemonic(e,TD)}static async getMasterKeyFromMnemonic(e,t=""){if(!this.validateMnemonic(e))throw new Error("Invalid mnemonic");const r=await m.mnemonicToSeed(e,t);return w.HDKey.fromMasterSeed(r)}static async deriveKey(e,t="m/44'/60'/0'/0/0",r=""){const n=(await this.getMasterKeyFromMnemonic(e,r)).derive(t);if(!n.privateKey||!n.publicKey)throw new Error("Failed to derive key");return{privateKey:n.privateKey,publicKey:n.publicKey}}static async deriveKeyForChain(e,t,r=""){return await this.deriveKey(e,YD[t],r)}static clearSensitiveData(e){e.fill(0)}}async function QD(e){try{if("Ed25519"===e.type&&null!=e.publicKey)return As.formEd25519PublicKey(e.publicKey);throw new Error("Unable to extract public key from PeerId")}catch(e){throw new Error(`Failed to extract public key: ${e.message}`)}}async function XD(t){try{const n=("string"==typeof t?e.multiaddr(t):t).getPeerId();if(!n)throw new Error("No PeerId found in multiaddr");return r.peerIdFromString(n)}catch(e){throw new Error(`Failed to extract PeerId: ${e.message}`)}}async function eR(e){return{key:await window.crypto.subtle.importKey("raw",e,{name:"AES-GCM"},!0,["encrypt","decrypt"]),raw:e}}async function tR(e,t){try{const r=await Nr((new TextEncoder).encode(t)),n=r.slice(16,32),o=(await $D(r,12,n)).hash,i=(new TextEncoder).encode(e),s=new Uint8Array(o.length+i.length);s.set(o),s.set(i,o.length);const a=await Nr(s);return await eR(a)}catch(e){throw new Error(`Failed to generate symmetric key: ${e.message}`)}}async function rR(e,t="pkcs8"){let r;if("string"==typeof e)if(e.startsWith("-----BEGIN")){const t="-----BEGIN PRIVATE KEY-----",n="-----END PRIVATE KEY-----",o=e.replace(t,"").replace(n,"").replace(/\s+/g,"");r=Uint8Array.from(atob(o),(e=>e.charCodeAt(0)))}else r=Uint8Array.from(atob(e),(e=>e.charCodeAt(0)));else r=e;const n="pkcs8"===t||e instanceof Uint8Array?t:"pkcs8";return crypto.subtle.importKey(n,r,{name:"Ed25519",namedCurve:"Ed25519"},!0,["sign"])}ZD.SEED_SIZE=32,ZD.PRIVATE_KEY_SIZE=64,ZD.PUBLIC_KEY_SIZE=32,ZD.SCHNORRKEL_SEED_PREFIX="mnemonic";const{Word32Array:nR,AES:oR,pad:iR,mode:sR,Base64:aR}=Ir;class cR extends Error{constructor(){super("invalid key"),this.name="InvalidKeyError"}}class uR{constructor(e){this._raw=e}static newRandom(){const e=a.randomBytes(32);return new uR(e)}static new(){return uR.newRandom()}static fromBytes(e){if(32!==e.length)throw new cR;return new uR(e)}static fromString(e){try{const t=ye.decode(e);return uR.fromBytes(t)}catch(e){throw new Error(`Failed to decode key: ${e instanceof Error?e.message:String(e)}`)}}async toSymKey(){return eR(this._raw)}static fromSymKey(e){return new uR(e.raw)}get raw(){return this._raw}bytes(){return this._raw}marshalBinary(){return this._raw}toString(){try{return ye.encode(this.raw)}catch(e){throw new Error(`Failed to encode key: ${e instanceof Error?e.message:String(e)}`)}}async encrypt(e,t){let r=a.randomBytes(12);t&&12===t.length&&(r=t);const n={name:"AES-GCM",iv:crypto.getRandomValues(r),tagLength:128},o=await this.toSymKey(),i=await crypto.subtle.encrypt(n,o.key,e),s=new Uint8Array(r.length+i.byteLength);return s.set(r,0),s.set(new Uint8Array(i),r.length),s}async decrypt(e){if(e.length<=28)return e;const t=e.subarray(0,12),r=new nR(t),n=e.subarray(e.length-16,e.length),o=new nR(n),i=e.subarray(12,e.length-16),s=new nR(i),a=new nR(this._raw);return oR.decrypt(s.toString(aR),a,{iv:r,padding:iR.NoPadding,mode:sR.GCM,kdfSalt:o}).toUint8Array()}}uR.keyBytes=32;class lR{constructor(e,t){this.sk=e,t&&(this.rk=t)}static new(e,t){if(!e)throw new Error("service-key must not be null");return new lR(e,t)}static newRandom(){return new lR(uR.new(),uR.new())}static newRandomService(){return new lR(uR.new())}static fromBytes(e){if(e.length!==uR.keyBytes&&e.length!==2*uR.keyBytes)throw new Error("invalid key");const t=uR.fromBytes(e.slice(0,uR.keyBytes));if(e.length===2*uR.keyBytes){const r=uR.fromBytes(e.slice(uR.keyBytes));return new lR(t,r)}return new lR(t)}static fromString(e){const t=ye.decode(e);return lR.fromBytes(t)}service(){return this.sk}read(){return this.rk}defined(){return null!==this.sk}canRead(){return null!==this.rk}toBytes(){return this.rk&&this.sk?new Uint8Array([...this.sk.bytes(),...this.rk.bytes()]):this.sk?this.sk.bytes():new Uint8Array(0)}toString(){return ye.encode(this.toBytes())}}class dR{static fromBytes(e){try{const t=ts(e),n=r.peerIdFromMultihash(t);if(null==n)throw new Error("Invalid Peer ID");return n}catch(e){throw new Error("Invalid Peer ID")}}static toBytes(e){const t=r.peerIdFromString(e);if(null==t)throw new Error("Invalid Peer ID");return t.toMultihash().bytes}}class hR{static fromBytes(t){try{return e.multiaddr(t)}catch{throw new Error("Invalid multiaddr bytes")}}static toBytes(e){return e.bytes}static addrsFromProtobuf(t){const r=[];for(const n of t)try{const t=e.multiaddr(n);r.push(t)}catch(e){continue}return r}static addrsToProtobuf(e){const t=[];for(const r of e)t.push(r.bytes);return t}}class pR{static fromBytes(e){try{return fs.decode(e)}catch{return fs.parse("bafkqaaa")}}static toBytes(e){return null==e?new Uint8Array:e.bytes}}class yR{static fromBytes(e){return v.ThreadID.fromBytes(e).toString()}static toBytes(e){return v.ThreadID.fromString(e).toBytes()}}class fR{static async publicFromBytes(e){try{return n.keys.publicKeyFromProtobuf(e)}catch{throw new Error("Invalid public key")}}static async privateFromBytes(e){try{return n.keys.privateKeyFromProtobuf(e)}catch{throw new Error("Invalid private key")}}static async toBytes(e){try{return n.keys.privateKeyToProtobuf(e)}catch{throw new Error("Invalid private key")}}static async publicToBytes(e){try{return n.keys.publicKeyToProtobuf(e)}catch{throw new Error("Invalid public key")}}}class gR{static fromBytes(e){return lR.fromBytes(e).toString()}static toBytes(e){return lR.fromString(e).toBytes()}}class bR{constructor(e,t){this.libp2p=e,this.protocol=t}setNetwork(e){this.net=e}start(){this.libp2p.handle(this.protocol,(async({stream:e})=>{try{const t=new BD;let r="";const n=new JE(e.sink),o=new TT(n);o.onData=async(e,t)=>{const o=e.subarray(5);"/net.pb.Service/GetLogs"===r&&this.getLogs(t.streamId,o,n)},o.onSettings=async()=>{const e=oB.createSettingsAckFrame();n.write(e)},o.onHeaders=(e,n)=>{const o=t.decodeHeaderFields(e);r=o.get(":path")},o.processStream(e)}catch(e){}}))}stop(){this.libp2p.stop()}_parseFrameHeader(e){if(e.length<9)throw new Error("Invalid frame header length");return{length:e[0]<<16|e[1]<<8|e[2],type:e[3],flags:e[4],streamId:e[5]<<24|e[6]<<16|e[7]<<8|e[8],payload:e.slice(0,9)}}async getLogs(e,t,r){const n=lB.pb.GetLogsRequest.decode(t);let o;if(n.body?.threadID){const e=yR.fromBytes(n.body?.threadID);o=v.ThreadID.fromString(e)}if(n.body?.serviceKey){gR.fromBytes(n.body?.serviceKey)}if(!this.net)return;if(!o)return;const[i,s]=await this.net.getPbLogs(o),a=new lB.pb.GetLogsReply;a.logs=i;const c=oB.createResponseHeadersFrame(e,{":status":"200","content-type":"application/grpc"},!0);await r.write(c);const u=lB.pb.GetLogsReply.encode(a).finish(),l=oB.createDataFrame(e,u,!1);await r.write(l);const d=oB.createTrailersFrame(e,{"grpc-status":"0","grpc-message":"Operation completed successfully"});await r.write(d),await r.end()}}var mR;exports.LogLevel=void 0,(mR=exports.LogLevel||(exports.LogLevel={}))[mR.DEBUG=0]="DEBUG",mR[mR.INFO=1]="INFO",mR[mR.WARN=2]="WARN",mR[mR.ERROR=3]="ERROR";let wR={level:exports.LogLevel.INFO,enableTimestamp:!0,enableModuleName:!0};function vR(e){wR={...wR,...e}}function kR(e){return{debug(t,...r){if(wR.level<=exports.LogLevel.DEBUG){SR("DEBUG",e)}},info(t,...r){if(wR.level<=exports.LogLevel.INFO){SR("INFO",e)}},warn(t,...r){if(wR.level<=exports.LogLevel.WARN){SR("WARN",e)}},error(t,...r){if(wR.level<=exports.LogLevel.ERROR){SR("ERROR",e)}}}}function SR(e,t){let r="";return wR.enableTimestamp&&(r+=`[${(new Date).toISOString()}] `),wR.enableModuleName&&(r+=`[${t}] `),r+=`[${e}] `,r}const OR=kR("ModuleSystem");var AR;exports.CoreModuleName=void 0,(AR=exports.CoreModuleName||(exports.CoreModuleName={})).FILE="file",AR.AUTH="auth",AR.COMMENT="comment",AR.DATABASE="database",AR.MESSAGE="message",AR.KEYVALUE="keyvalue",AR.CACHE="cache",AR.CLIENT="client",AR.AIPROXY="aiproxy",AR.UTIL="util";class IR{constructor(e){this.modules=new Map,this.initialized=!1,this.context=e}registerModule(e){return this.modules.has(e.moduleName)?(OR.warn(`模块 ${e.moduleName} 已存在,无法重复注册`),!1):(this.modules.set(e.moduleName,e),!0)}getModule(e){return this.modules.get(e)}async initializeAll(){OR.info("开始初始化所有模块...");const e=[exports.CoreModuleName.AUTH,exports.CoreModuleName.FILE,exports.CoreModuleName.DATABASE,exports.CoreModuleName.COMMENT,exports.CoreModuleName.MESSAGE,exports.CoreModuleName.KEYVALUE,exports.CoreModuleName.CLIENT,exports.CoreModuleName.CACHE,exports.CoreModuleName.AIPROXY,exports.CoreModuleName.UTIL];for(const t of e){const e=this.modules.get(t);if(e)try{if(!await e.initialize(this.context))return OR.error(`核心模块 ${t} 初始化失败`),!1;OR.info(`核心模块 ${t} 初始化成功`)}catch(e){return OR.error(`核心模块 ${t} 初始化出错:`,e),!1}}for(const[t,r]of this.modules.entries())if(!e.includes(t)){OR.info(`初始化扩展模块: ${t}`);try{if(!await r.initialize(this.context))return OR.error(`扩展模块 ${t} 初始化失败`),!1}catch(e){return OR.error(`扩展模块 ${t} 初始化出错:`,e),!1}}return this.initialized=!0,OR.info("所有模块初始化完成"),!0}async shutdownAll(){OR.info("开始关闭所有模块...");const e=Array.from(this.modules.entries());for(let t=e.length-1;t>=0;t--){const[r,n]=e[t];try{OR.info(`关闭模块: ${r}`),await n.shutdown()}catch(e){OR.error(`关闭模块 ${r} 时出错:`,e)}}this.initialized=!1,OR.info("所有模块已关闭")}isInitialized(){return this.initialized}getRegisteredModules(){return Array.from(this.modules.keys())}}const xR=3,PR=4,ER=5,CR=6,BR=7,TR=8,DR=9,RR=10;class jR{constructor(e,t,r){this.client=e,this.dcNodeClient=t,this.context=r}async storeFile(e,t,r,n,o,i){const s=Kr(e),a=qr(t||0),c=qr(1),u=(new TextEncoder).encode(n),l=(new TextEncoder).encode(r),d=new Uint8Array([...l,...s,...a,...c,...u]),h=await this.context.sign(d);try{if(null==this.client.p2pNode)throw new Error("p2pNode is null");const n=new IE.pb.StroeFileRequest({});n.cid=(new TextEncoder).encode(r),n.filesize=e,n.blockheight=t,n.signature=h;const i=IE.pb.StroeFileRequest.encode(n).finish(),s=async e=>{const t=IE.pb.StroeFileReply.decode(e);let r=exports.UploadStatus.UPLOADING;switch(t.status){case xR:r=exports.UploadStatus.UPLOADING;break;case PR:r=exports.UploadStatus.PULLERROR;break;case ER:case CR:r=exports.UploadStatus.OK;break;case BR:r=exports.UploadStatus.ABNORMAL;break;case TR:r=exports.UploadStatus.FILESIZEERROR;break;case DR:r=exports.UploadStatus.FILECOUNTERROR;break;case RR:r=exports.UploadStatus.NOSPACE}o&&o(r,Number(t.receivesize))},a=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);return void await a.Call("/dcnet.pb.Service/StoreFile",i,1e5,"server-streaming",s)}catch(e){throw e}}async storeFolder(e,t,r,n){try{if(null==this.client.p2pNode)throw new Error("p2pNode is null");const o=new IE.pb.StoreFolderRequest({cid:(new TextEncoder).encode(e),filecount:t.fileCount,foldersize:t.fileSize,blockheight:t.blockHeight,signature:t.signature});if(t.vaccount)try{o.vaccount=t.vaccount.pubKeyRaw}catch(e){throw new Error("Failed to parse virtual account: "+e.message)}const i=IE.pb.StoreFolderRequest.encode(o).finish(),s=async e=>{try{const n=IE.pb.StoreFolderReply.decode(e);let o=exports.UploadStatus.UPLOADING;switch(n.status){case xR:o=exports.UploadStatus.UPLOADING;break;case PR:o=exports.UploadStatus.PULLERROR;break;case ER:case CR:o=exports.UploadStatus.OK;break;case BR:o=exports.UploadStatus.ABNORMAL;break;case TR:o=exports.UploadStatus.FILESIZEERROR;break;case DR:o=exports.UploadStatus.FILECOUNTERROR;break;case RR:o=exports.UploadStatus.NOSPACE}null!==r&&r(o,t.fileCount,n.receivecount)}catch(e){n&&n(new Error("Failed to decode StoreFolderReply: "+e.message))}},a=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);await a.Call("/dcnet.pb.Service/StoreFolder",i,1e5,"server-streaming",s)}catch(e){n&&n(new Error("StoreFolder failed: "+(e instanceof Error?e.message:String(e))))}}}async function NR(e,t){try{if(""===t||e.length<=28)return e;const r=e.slice(0,12),n=e.slice(12),o="string"==typeof t?ye.decode(t):t,i=await window.crypto.subtle.importKey("raw",o,{name:"AES-GCM",length:256},!1,["decrypt"]),s=[{tagLength:128,name:"标准模式"},{tagLength:96,name:"96位标签模式"},{tagLength:64,name:"64位标签模式"}];for(const e of s)try{const t=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:r,tagLength:e.tagLength},i,n);return new Uint8Array(t)}catch(e){continue}throw new Error("decrypt failed")}catch(e){throw e}}var UR;!function(e){e[e.Filetype=1]="Filetype",e[e.Threaddbtype=2]="Threaddbtype"}(UR||(UR={}));const KR=0,qR=1;var LR,_R,MR;!function(e){e[e.PUBLIC=0]="PUBLIC",e[e.PRIVATE=1]="PRIVATE",e[e.AUTH=2]="AUTH",e[e.AUTH_WRITE=3]="AUTH_WRITE",e[e.REPORTED=4]="REPORTED"}(LR||(LR={})),function(e){e[e.QUERY=8]="QUERY",e[e.ADMIN=4]="ADMIN"}(_R||(_R={})),exports.ThemePermission=void 0,(MR=exports.ThemePermission||(exports.ThemePermission={}))[MR.NONE=0]="NONE",MR[MR.APPLY=1]="APPLY",MR[MR.READ=2]="READ",MR[MR.WRITE=3]="WRITE",MR[MR.ADMIN=4]="ADMIN",MR[MR.ONLY_WRITE=5]="ONLY_WRITE",MR[MR.DEVICE=6]="DEVICE",MR[MR.NOT_EXIST=7]="NOT_EXIST",MR[MR.QUERY=8]="QUERY";class FR{constructor(e){this.position=0,this.fileInfo=e.fileInfo,this.fs=e.fs,this.cid=e.cid,this.decryptKey=e.decryptKey,this.encryptChunkSize=e.encryptChunkSize}getSize(){return this.fileInfo.size}seek(e){e<0?e=0:e>this.fileInfo.size&&(e=this.fileInfo.size),this.position=e}getPosition(){return this.position}async read(e){const t=this.position;if(t>=this.fileInfo.size)return new Uint8Array(0);const r=this.fileInfo.size-t,n=Math.min(e,r);let o;return o=this.decryptKey?await this.readEncrypted(t,n):await this.readPlain(t,n),this.position==t&&(this.position=t+o.length),o}async readPlain(e,t){try{const r=e+this.fileInfo.headerSize;return await S(this.fs.cat(this.cid,{offset:r,length:t}))}catch(e){return new Uint8Array(0)}}async readEncrypted(e,t){const r=3<<20,n=Math.floor(e/r),o=e%r,i=e+t,s=Math.floor(i/r)-n+1,a=Math.min(s*r,o+t);let c=new Uint8Array(a),u=this.fileInfo.headerSize+n*this.encryptChunkSize;const l=s*this.encryptChunkSize;try{const e=await S(this.fs.cat(this.cid,{offset:u,length:l}));if(0===e.length)return new Uint8Array(0);let r=0;for(let t=0;t<s;t++){const n=t*this.encryptChunkSize;if(n>=e.byteLength)break;const o=Math.min((t+1)*this.encryptChunkSize,e.length),i=e.slice(n,o);if(0===i.byteLength)continue;const s=await NR(i,this.decryptKey),a=Math.min(s.length,c.length-r);c.set(s.subarray(0,a),r),r+=a}let n=new Uint8Array(t);return n.set(c.subarray(o,o+t),0),n}catch(e){return new Uint8Array(0)}}createReadableStream(e){let t=void 0!==e?.start?e.start:this.position,r=new Uint8Array(0),n=t;t<0?t=0:t>this.fileInfo.size&&(t=this.fileInfo.size);const o=e?.end??this.fileInfo.size,i=262144,s=async e=>{const o=Math.min(e,this.fileInfo.size-t);if(!(o<=0))try{let e;e=this.decryptKey?await this.readEncrypted(t,o):await this.readPlain(t,o),r=e,n=t}catch(e){r=new Uint8Array(0)}},a=async e=>{if(t>=this.fileInfo.size)return new Uint8Array(0);const o=this.fileInfo.size-t,i=Math.min(e,o);let s;if(t>=n&&t+i<=n+r.length){const e=t-n;s=r.slice(e,e+i)}else s=this.decryptKey?await this.readEncrypted(t,i):await this.readPlain(t,i);return t+=s.length,s};return new ReadableStream({start:async e=>{try{await s(i)}catch(e){}},pull:async e=>{try{if(t>=o)return void e.close();const c=Math.min(65536,o-t);if(t>=n&&t+c<=n+r.length){const a=t-n,u=r.slice(a,a+c);t+=u.length,e.enqueue(u);t+131072>n+r.length&&t<o&&s(i).catch((e=>{}))}else{await s(Math.max(i,c));const o=t-n;if(o>=0&&o<r.length){const n=r.slice(o,Math.min(o+c,r.length));t+=n.length,e.enqueue(n)}else{const t=await a(c);t.length>0?e.enqueue(t):e.close()}}}catch(t){e.error(t)}},cancel:()=>{r=new Uint8Array(0)}})}}class zR extends Error{constructor(e,t,r=400){super(t),this.code=e,this.statusCode=r,this.name=e}}const GR={INVALID_TOKEN:new zR("INVALID_TOKEN","invalid token",401),USER_NOT_BIND_TO_PEER:new zR("USER_NOT_BIND_TO_PEER","user not bind to this peer"),NO_USER_INFO:new zR("NO_USER_INFO","no user info found"),NO_DC_PEER_CONNECTED:new zR("NO_DC_PEER_CONNECTED","no dc peer connected"),FAIL_TO_GET_BLOCKHEIGHT:new zR("FAIL_TO_GET_BLOCKHEIGHT","fail to get blockheight"),FAIL_TO_GET_TOKEN:new zR("FAIL_TO_GET_TOKEN","fail to get token"),NO_CHAIN_UTIL:new zR("NO_CHAIN_UTIL","no chain util found")};class VR{constructor(e){this.client=e}async bindAccessPeerToUser(e,t,r){if(null==this.client.p2pNode)throw new Error("p2pNode is null");const n=(new TextEncoder).encode(r),o=qr(t||0),i=(new TextEncoder).encode("add_request_peer_id_to_user"),s=new Uint8Array([...i,...o,...n]),a=await e.sign(s),c=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),u=new IE.pb.BindAccessPeerToUserRequest({});u.blockheight=t,u.signature=a;const l=IE.pb.BindAccessPeerToUserRequest.encode(u).finish(),d=await c.unaryCall("/dcnet.pb.Service/BindAccessPeerToUser",l,3e4);return IE.pb.BindAccessPeerToUserReply.decode(d),!0}async accountBind(e,t,r){if(null==this.client.p2pNode)throw new Error("p2pNode is null");const n=new IE.pb.AccountDealRequest({});n.accounthashencrypt=e.accounthashencrypt,n.accountencrypt=e.accountencrypt,n.prikeyencrypt2=e.prikeyencrypt2,n.blockheight=e.blockheight,n.loginkeyrandencrypt=e.loginkeyrandencrypt,n.peerid=e.peerid,n.signature=e.signature;const o=IE.pb.AccountDealRequest.encode(n).finish();let i=null;if(t){const e=new ZD;i=await e.getEd25519KeyFromMnemonic(t,"")}else i=r.privateKey||null;if(!i)throw new Error("No private key available for binding");const s=i.publicKey;if(!await this.client.GetToken(r.appInfo.appId||"",s.string(),(async e=>i?i.sign(e):await r.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const a=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),c=await a.unaryCall("/dcnet.pb.Service/AccountBind",o,3e4);return IE.pb.AccountDealReply.decode(c),!0}async accountInfoModify(e){if(null==this.client.p2pNode)throw new Error("p2pNode is null");const t=new IE.pb.AccountDealRequest({});t.accounthashencrypt=e.accounthashencrypt,t.accountencrypt=e.accountencrypt,t.prikeyencrypt2=e.prikeyencrypt2,t.blockheight=e.blockheight,t.loginkeyrandencrypt=e.loginkeyrandencrypt,t.peerid=e.peerid,t.signature=e.signature;const r=IE.pb.AccountDealRequest.encode(t).finish(),n=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),o=await n.unaryCall("/dcnet.pb.Service/AccountInfoModify",r,3e4);return IE.pb.AccountDealReply.decode(o),!0}async addSubPubkey(e){if(null==this.client.p2pNode)throw new Error("p2pNode is null");const t=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),r=new IE.pb.AddSubPubkeyRequest({});r.subpubkey=e.subpubkey,r.blockheight=e.blockheight,r.peerid=e.peerid,r.signature=e.signature;const n=IE.pb.AddSubPubkeyRequest.encode(r).finish(),o=await t.unaryCall("/dcnet.pb.Service/AddSubPubkey",n,3e4);return IE.pb.AddSubPubkeyReply.decode(o),!0}async setUserDefaultDB(e,t,r,n,o){if(null==this.client.p2pNode)throw new Error("p2pNode is null");try{const i=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),s=new IE.pb.SetUserDefaultDBRequest;s.dbinfocrypt=e,s.blockheight=t,s.peerid=(new TextEncoder).encode(r),s.signature=n,o&&(s.vaccount=(new TextEncoder).encode(o));const a=IE.pb.SetUserDefaultDBRequest.encode(s).finish();try{return void await i.unaryCall("/dcnet.pb.Service/SetUserDefaultDB",a,3e4)}catch(e){throw e}}catch(e){throw e}}}const{Buffer:HR}=Rr,WR="$$dcfile$$",JR=3145728,$R=new AbortController,{signal:YR}=$R;class ZR extends Error{constructor(e){super(e),this.name="FileError"}}const QR={ErrNoDcPeerConnected:new ZR("no dc peer connected"),ErrNoFileChose:new ZR("no file choose"),ErrNoPeerIdIsNull:new ZR("peerId is null"),ErrNoNeedUpload:new ZR("no need upload"),ErrPublicKeyIsNull:new ZR("publickey is null")};class XR{constructor(e,t,r,n,o){this.connectedDc={},this.getFileFromDc=async(e,t,r,n)=>{if(r!==qR){const[r,o]=await(this.dc?._connectToObjNodes(e));if(!r&&o)return null;if(!o)try{const r=new Promise((e=>setTimeout(e,5e3,"Timeout"))),o=this.getFileFromDcContent(e,t,n),i=await Promise.race([r,o]);return"Timeout"===i?null:i||null}catch(e){return null}}return this.getFileFromDcContent(e,t,n)},this.getFileFromDcContent=async(e,t,r)=>{const n=k.unixfs(this.dcNodeClient);let o=!1,i=new Uint8Array(0),s=new Uint8Array(0);const a=3145756,c={offset:0,length:32};let u=0;try{for(;;){if(!o&&!r){const r=await S(n.cat(fs.parse(e),c));if(u+=r.length,!(r.length>0)){if(i.length>0)if(""!=t){s=Mr(s,await NR(i,t))}else s=Mr(s,i);break}if(i=Mr(i,r),i.length<32){c.offset=i.length,c.length=32-i.length;continue}o=!0,_r(i.subarray(0,10),HR.from("$$dcfile$$"))&&(i=i.subarray(32,i.length));continue}c.offset=u,c.length=a;const l=await S(n.cat(fs.parse(e),c));if(l.length>0&&(u+=l.length),!(l.length>0)){if(i.length>0)if(""!=t){s=Mr(s,await NR(i,t))}else s=Mr(s,i);break}for(i=Mr(i,l);i.length>=a;){const e=i.subarray(0,a);if(i=i.subarray(a,i.length),""==t){s=Mr(s,e);continue}s=Mr(s,await NR(e,t))}}return s}catch(e){return null}},this.dc=e,this.connectedDc=t,this.chainUtil=r,this.dcNodeClient=n,this.context=o}async _processHeader(e,t,r,n){if(n){const n=await crypto.subtle.digest("SHA-256",e),o=new Uint8Array(n),i=(new TextEncoder).encode(WR),s=o.slice(10,24),a=function(e){const t=new ArrayBuffer(8),r=new DataView(t),n="number"==typeof e?BigInt(e):e;return r.setBigUint64(0,n,!1),new Uint8Array(t)}(t),c=new Uint8Array(a);return new Uint8Array([...i,...s,...c,...r])}return r}async _uploadLargeFileAdvanced(e,t={offset:0,chunkHashes:[]},r,n){const o=k.unixfs(this.dcNodeClient);let i=t.offset||0;t.chunkHashes;const s=this;return await o.addByteStream(async function*(){for(;i<e.size;){const t=e.slice(i,i+JR),o=await t.arrayBuffer();let a=new Uint8Array(o);n&&(a=await n.encrypt(a)),r&&0===i&&(a=await s._processHeader(r,e.size,a,!0)),i+=JR,yield a}}(),{rawLeaves:!1,leafType:"file",shardSplitThresholdBytes:262144})}async isAccessPeerIdBinded(){const e=await this.chainUtil.refreshUserInfo(this.context.getPubkeyRaw());if(e.requestPeers&&e.requestPeers.length>0)for(const t of e.requestPeers)if(t===this.connectedDc.nodeAddr?.getPeerId())return!0;return!1}async addFile(e,t,r,n){if(!this.connectedDc?.client)return[null,QR.ErrNoDcPeerConnected];if(!this.connectedDc||!this.connectedDc.nodeAddr)return[null,QR.ErrNoDcPeerConnected];const o=await this.chainUtil.getBlockHeight(),i=this.connectedDc.nodeAddr?.getPeerId();if(!i)return[null,QR.ErrNoPeerIdIsNull];let s="";try{if(!await this.isAccessPeerIdBinded()){const e=new VR(this.connectedDc.client);await e.bindAccessPeerToUser(this.context,o||0,i);let t=0;for(;!await this.isAccessPeerIdBinded();){if(t+=1,t>30)return[null,new ZR("No access auth to peer")];await Lr(1e3)}}}catch(e){return[null,e]}try{e.size;const n=t&&t.length>0?uR.fromString(t):null,a=k.unixfs(this.dcNodeClient),c=this.context.getPubkeyRaw();let u=await(this.dc?._getNodeAddr(i));if(!u)return[null,QR.ErrNoDcPeerConnected];const l=await this._uploadLargeFileAdvanced(e,{offset:0,chunkHashes:[]},c,n);if(!l)return[s,QR.ErrNoFileChose];s=l.toString();const d=await a.stat(l),h=(d.unixfs?.fileSize(),Number(d.localDagSize)),p=new jR(this.connectedDc.client,this.dcNodeClient,this.context);let y=0,f=!1,g=null;for(p.storeFile(h,o||0,s,i,((e,t)=>{f=!0,y=e,r(e,t)}),(async e=>{f=!0,g=e}));!f;)await Lr(100);if(g)return[null,g];if(y===exports.UploadStatus.ERROR||y===exports.UploadStatus.ABNORMAL||y===exports.UploadStatus.NOSPACE||y===exports.UploadStatus.FILECOUNTERROR||y===exports.UploadStatus.FILESIZEERROR||y===exports.UploadStatus.PULLERROR)return[null,QR.ErrNoNeedUpload];await this.dc.createTransferStream(this.dcNodeClient.libp2p,this.dcNodeClient.blockstore,u,zE.File,s)}catch(e){throw e}return[s,null]}async addFolder(e,t,r,n){if(!this.connectedDc?.client)return[null,QR.ErrNoDcPeerConnected];if(!this.connectedDc||!this.connectedDc.nodeAddr)return[null,QR.ErrNoDcPeerConnected];const o=await this.chainUtil.getBlockHeight(),i=this.connectedDc.nodeAddr?.getPeerId();if(!i)return[null,QR.ErrNoPeerIdIsNull];let s=await(this.dc?._getNodeAddr(i));if(!s)return[null,QR.ErrNoDcPeerConnected];try{if(!await this.isAccessPeerIdBinded()){const e=new VR(this.connectedDc.client);await e.bindAccessPeerToUser(this.context,o||0,i);let t=0;for(;!await this.isAccessPeerIdBinded();){if(t+=1,t>30)return[null,new ZR("No access auth to peer")];await Lr(1e3)}}}catch(e){return[null,e]}try{const a=k.unixfs(this.dcNodeClient);let c=this.context.getPubkeyRaw();const u=await crypto.subtle.digest("SHA-256",c),l=new Uint8Array(u),d=this.extractRootFolderName(e),h=Array.from(e).filter((e=>"dc_ownuser"!==e.name)),p=d+"/dc_ownuser";h.push(new File([l],"dc_ownuser",{type:"text/plain"}));const y=Array.from(h).map((e=>({path:"dc_ownuser"===e.name?p:e.webkitRelativePath,content:this.fileToStream(e,t)}))),f=a.addAll(y);let g=null,b=0;for await(const{path:e,size:t,cid:r}of f)e===d&&(g=r,b=Number(t));if(!g)return[null,new Error("Failed to find root directory CID")];const m=await this.countDirectoryBlocks(g),w=g.toString(),v=b,S=(new TextEncoder).encode(i),O=Kr(v),A=qr(o||0),I=qr(1);let x=(new TextEncoder).encode(w);x=Mr(x,O),x=Mr(x,A),x=Mr(x,I),x=Mr(x,S);const P={signature:await this.context.sign(x),blockHeight:o||0,fileSize:v,fileCount:m,pubkey:this.context.getPubkeyRaw(),vaccount:""};n&&(P.vaccount=n);let E=this.connectedDc.client;if(null===E)return["",new Error("ErrConnectToAccountPeersFail")];if(null===E.peerAddr)return["",new Error("ErrConnectToAccountPeersFail")];if(!this.context.publicKey)return[null,QR.ErrPublicKeyIsNull];""==E.token&&await E.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),this.context.sign);const C=new jR(this.connectedDc.client,this.dcNodeClient,this.context);let B=!1,T=0,D=null;for(C.storeFolder(g.toString(),P,((e,t,n)=>{B=!0,T=e,r(e,t,n)}),(async e=>{B=!0,D=e}));!B;)await Lr(100);return D?(r(exports.UploadStatus.ERROR,0,0),[null,D]):T===exports.UploadStatus.ERROR||T===exports.UploadStatus.ABNORMAL||T===exports.UploadStatus.NOSPACE||T===exports.UploadStatus.FILECOUNTERROR||T===exports.UploadStatus.FILESIZEERROR||T===exports.UploadStatus.PULLERROR?[null,QR.ErrNoNeedUpload]:(await this.dc.createTransferStream(this.dcNodeClient.libp2p,this.dcNodeClient.blockstore,s,zE.File,w),[w,null])}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}createCustomFileList(e,t="upload"){const r=e instanceof Map?e:new Map(Object.entries(e)),n=[];r.forEach(((e,r)=>{const o=r.startsWith(t)?r:`${t}/${r}`;let i;i="string"==typeof e?new Blob([e],{type:"text/plain"}):new Blob([e]);const s=Object.defineProperty(new File([i],r.split("/").pop()||"unnamed",{type:"application/octet-stream"}),"webkitRelativePath",{value:o,writable:!1});n.push(s)}));const o={length:n.length,item:e=>e<0||e>=n.length?null:n[e],[Symbol.iterator](){let e=0;return{next:()=>e<n.length?{value:n[e++],done:!1}:{value:null,done:!0}}}};n.forEach(((e,t)=>{o[t]=e}));return o}fileToStream(e,t){const r=t?uR.fromString(t):null,{readable:n,writable:o}=new TransformStream,i=o.getWriter(),s=new FileReader,a=3<<20;let c=0;return(async()=>{try{for(;c<e.size;){const t=e.slice(c,c+a),n=await new Promise(((e,r)=>{s.onload=()=>e(s.result),s.onerror=r,s.readAsArrayBuffer(t)})),o=new Uint8Array(n);if(r&&"dc_ownuser"!==e.name){const e=await r.encrypt(o);await i.write(e)}else await i.write(o);c+=a}}catch(e){}finally{await i.close()}})().catch((e=>{})),n}async countDirectoryBlocks(e){try{const t=k.unixfs(this.dcNodeClient);let r=0;const n=await t.stat(e);r+=Number(n.blocks||0);for await(const n of t.ls(e)){const{cid:e,type:o}=n,i=await t.stat(e);if("directory"===o){r+=await this.countDirectoryBlocks(e)}else r+=Number(i.blocks||0)}return r}catch(e){throw e}}extractRootFolderName(e){if(0===e.length)return"root";return(e[0].webkitRelativePath||e[0].name).split("/")[0]||"root"}async createFolderInIpfs(e){const t=k.unixfs(this.dcNodeClient);return await t.addDirectory({path:e})}calculateFolderSize(e){let t=0;for(let r=0;r<e.length;r++)t+=e[r].size;return t}async addFileToMfsFolder(e,t,r,n){let o=null;const i=`${t}/${r}`;try{if(!await this.readFile(i))return[null,new Error("Could not open file")];""!==n&&(o=uR.fromString(n));const{readable:t,writable:s}=new TransformStream,a=s.getWriter();(async()=>{try{const e=await fetch(i).then((e=>e.blob())),t=new FileReader,r=1024;let n=0;for(;n<e.size;){const i=e.slice(n,n+r),s=await new Promise(((e,r)=>{t.onload=()=>e(t.result),t.onerror=r,t.readAsArrayBuffer(i)})),c=new Uint8Array(s);if(o){const e=await o.encrypt(c);await a.write(e)}else await a.write(c);n+=r}}catch(e){}finally{await a.close()}})();const c=k.unixfs(this.dcNodeClient),u=await c.addByteStream(this.streamToAsyncIterable(t),{rawLeaves:!1,leafType:"file",shardSplitThresholdBytes:262144});return await e.addChild(r,u),await e.flush(),[u.toString(),null]}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}async*streamToAsyncIterable(e){const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{t.releaseLock()}}async readFile(e){try{const t=await fetch(e);return await t.blob()}catch(e){return null}}async*chunkGenerator(e){const t=e.source[Symbol.asyncIterator]();for(;;)try{const{done:e,value:r}=await t.next();if(e)break;const n=r instanceof Ns?r.subarray():r;yield n}catch(e){}}assembleCustomMessage(e){const t=e.payload.byteLength,r=new Uint8Array(7+t);return r[0]=e.type,r[1]=e.version>>8&255,r[2]=255&e.version,r[3]=t>>24&255,r[4]=t>>16&255,r[5]=t>>8&255,r[6]=255&t,r.set(e.payload,7),r}parseMessage(e){if(e.length<7)return null;const t=e[0],r=e[1]<<8|e[2],n=e[3]<<24|e[4]<<16|e[5]<<8|e[6];if(e.length<7+n)return null;return{type:t,version:r,payload:e.slice(7,7+n)}}async getFolderFileListWithContent(e,t,r=!0){const[n,o]=await this.getFolderFileList(e,KR,r);if(o||!n)return[null,o];for(let e=0;e<n.length;e++){const r=n[e];if(0===r?.Type){if("dc_ownuser"==r?.Name)continue;const e=await this.getFileFromDc(r.Hash,t,qR,!0);if(!e)return[null,QR.ErrNoFileChose];r.Content=e}}return[n,null]}async getFolderFileList(e,t,r=!0){try{const n=fs.parse(e);if(t!==qR){const[t,r]=await(this.dc?._connectToObjNodes(e));if(!t&&r)return[null,QR.ErrNoDcPeerConnected]}const o=k.unixfs(this.dcNodeClient),i=[],s=async(e,t="")=>{for await(const n of o.ls(e)){const{name:e,cid:a,type:c}=n;if("."===e||".."===e||"dc_ownuser"===e)continue;const u=t?`${t}/${e}`:e,l=await o.stat(a),d={Name:e,Type:"directory"===c?1:0,Size:"directory"===c?0:Number(l.fileSize||0),Hash:a.toString(),Path:u};i.push(d),"directory"===c&&r&&await s(a,u)}};return await s(n),[i,null]}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}async createSeekableFileStream(e,t,r){if(r!==qR){const[t,r]=await(this.dc?._connectToObjNodes(e));if(!t&&r)return null}const n=k.unixfs(this.dcNodeClient);try{const r=await S(n.cat(fs.parse(e),{offset:0,length:32})),o=_r(r.subarray(0,10),HR.from(WR)),i=this.readUint64BE(r,24);return new FR({fileInfo:{size:i,hasHeader:o,headerSize:o?32:0},fs:n,cid:fs.parse(e),decryptKey:t||"",encryptChunkSize:3145756})}catch(e){return null}}readUint64BE(e,t){return(e[t]*2**24+65536*e[t+1]+256*e[t+2]+e[t+3])*2**32+(e[t+4]*2**24+65536*e[t+5]+256*e[t+6]+e[t+7])}}const ej=kR("FileCacheManager");class tj{constructor(e=1e5){this.seekableFileStreamCache=new Map,this.cacheCleanupInterval=null,this.CACHE_TIMEOUT=e,this.startCacheCleanupTask()}getCachedFileStream(e,t){const r=`${e}_${t}`,n=this.seekableFileStreamCache.get(r);return n?(ej.info(`使用缓存的SeekableFileStream: ${r}`),n.lastAccessTime=Date.now(),n.stream):null}cacheFileStream(e,t,r){const n=`${e}_${t}`;ej.info(`创建新的SeekableFileStream缓存: ${n}`),this.seekableFileStreamCache.set(n,{stream:r,lastAccessTime:Date.now()})}clearFileCache(e){if(e){let t=e.split("/")[3];const r=t.split("_");if(r.length>1){t=r[0];const e=`${t}_${r[1]}`;this.seekableFileStreamCache.delete(e),ej.info(`清理特定缓存: ${e}`)}}else this.seekableFileStreamCache.clear(),ej.info("清理所有文件缓存")}startCacheCleanupTask(){this.cacheCleanupInterval&&clearInterval(this.cacheCleanupInterval),this.cacheCleanupInterval=setInterval((()=>{const e=Date.now();let t=0;for(const[r,n]of this.seekableFileStreamCache.entries())e-n.lastAccessTime>this.CACHE_TIMEOUT&&(ej.info(`缓存超时,释放资源: ${r}`),this.seekableFileStreamCache.delete(r),t++);(t>0||this.seekableFileStreamCache.size>0)&&ej.info(`文件缓存清理: 移除 ${t} 项,剩余 ${this.seekableFileStreamCache.size} 项`)}),5e3)}stopCacheCleanupTask(){this.cacheCleanupInterval&&(clearInterval(this.cacheCleanupInterval),this.cacheCleanupInterval=null)}getCacheStats(){return{total:this.seekableFileStreamCache.size,keys:Array.from(this.seekableFileStreamCache.keys())}}}const rj=kR("ServiceWorker");let nj=null;async function oj(e,t=""){if(!("serviceWorker"in navigator))return Promise.reject("Service Worker not supported");if("https:"!==location.protocol&&"localhost"!==location.hostname)return rj.error("ServiceWorker 仅支持 https 或 localhost"),null;if("https:"!=window.location.protocol&&"localhost"!=window.location.hostname)return rj.error("ServiceWorker 仅支持https协议"),null;const r=new URL(t||"/sw.js",location.origin).href,n=await navigator.serviceWorker.register(r);return nj&&navigator.serviceWorker.removeEventListener("message",nj),nj=async t=>{if(t.data&&"ipfs-fetch"===t.data.type){const r=t.ports?.[0];if(!r)return void rj.warn("SW 未提供 MessagePort");r.postMessage({success:!0,message:"Request received",status:999});try{await ij(t.data,r,e)}catch(e){rj.error("handleIpfsRequest 处理异常:",e),r.postMessage({success:!1,error:String(e)})}}},navigator.serviceWorker.addEventListener("message",nj),await navigator.serviceWorker.ready,navigator.serviceWorker.controller||await new Promise((e=>{navigator.serviceWorker.addEventListener("controllerchange",(()=>e()),{once:!0})})),n}async function ij(e,t,r){const{id:n,pathname:o,range:i}=e;let s=0;try{let e=o.split("/")[3],n="";const a=e.split("_");a.length>1&&(e=a[0],n=a[1]);let c=null;const u=3145728;let l=0,d=0;if(r){if(i)try{const t=await r.getSeekableFileStream(e,n);if(s=t.getSize(),t){const e=i.match(/bytes=(\d+)-(\d+)?/);e&&(l=parseInt(e[1]),d=e[2]?parseInt(e[2]):l+u-1,d>=s&&(d=s-1),rj.info(`处理范围请求: ${l}-${d}, 总大小: ${t.getSize()}`),t.seek(l),c=await t.read(d-l+1),d>=t.getSize()-1&&(rj.info(`文件读取完成,清理缓存: ${o}`),r.clearFileCache(o)))}}catch(e){return rj.error("文件流操作失败:",e),r.clearFileCache(o),void t.postMessage({success:!1,error:e instanceof Error?e.message:"File stream operation failed"})}else{const[t,i]=await r.getFile(e,n);c=t,s=c?c.length:0,r.clearFileCache(o)}if(!c)return void t.postMessage({success:!1,error:"no data"});if(c&&c.buffer){const e={success:!0,status:i?206:200,headers:{"Content-Range":i?`bytes ${l}-${d}/${s}`:void 0,"Accept-Ranges":"bytes","Cache-Control":"no-cache","Content-Length":c.length}};t.postMessage({...e,data:c.buffer},[c.buffer]),c=null}else t.postMessage({success:!1,error:"Missing data buffer"})}else t.postMessage({success:!1,error:"File operations not available"})}catch(e){rj.error("处理IPFS请求失败:",e),r&&o&&r.clearFileCache(o),t.postMessage({success:!1,error:e instanceof Error?e.message:"Unknown error"})}}const sj=kR("FileModule");class aj{constructor(e){this.moduleName=exports.CoreModuleName.FILE,this.initialized=!1,this.swUrl=e}async initialize(e){try{this.fileManager=new XR(e.dcutil,e.connectedDc,e.dcChain,e.dcNodeClient,e),this.fileCacheManager=new tj;try{sj.info("Service Worker 已开始注册");await oj(this,this.swUrl||"")?(sj.info("Service Worker 注册成功"),e.swInited=!0):(sj.warn("Service Worker 注册失败"),e.swInited=!1)}catch(t){sj.warn("Service Worker 注册失败:",t),e.swInited=!1}return this.initialized=!0,!0}catch(e){return sj.error("文件模块初始化失败:",e),!1}}async shutdown(){this.fileCacheManager&&(this.clearFileCache(),this.fileCacheManager.stopCacheCleanupTask()),this.initialized=!1}async getSeekableFileStream(e,t){try{this.assertInitialized();const r=this.fileCacheManager.getCachedFileStream(e,t);if(r)return r;const n=await this.fileManager.createSeekableFileStream(e,t);if(!n)throw new Error(`获取文件流失败: ${e}`);return this.fileCacheManager.cacheFileStream(e,t,n),n}catch(t){throw sj.error(`获取文件流失败: ${e}`,t),new Error(`获取文件流失败: ${t instanceof Error?t.message:String(t)}`)}}clearFileCache(e){try{this.assertInitialized(),this.fileCacheManager.clearFileCache(e)}catch(e){sj.error("清理文件缓存失败",e)}}getCacheStats(){try{this.assertInitialized();return[this.fileCacheManager.getCacheStats(),null]}catch(e){return[null,e]}}async getFile(e,t){try{this.assertInitialized();return[await this.fileManager.getFileFromDc(e,t),null]}catch(t){throw sj.error(`获取文件失败: ${e}`,t),[null,new Error(`获取文件失败: ${t instanceof Error?t.message:String(t)}`)]}}async createFileStream(e,t){try{this.assertInitialized();const r=await this.fileManager.createSeekableFileStream(e,t);return r?r.createReadableStream():null}catch(t){return sj.error(`创建文件流失败: ${e}`,t),null}}async addFile(e,t,r){try{if(this.assertInitialized(),!e)throw new Error("文件不能为空");return await this.fileManager.addFile(e,t,r)}catch(t){return sj.error(`添加文件失败: ${e?.name}`,t),[null,new Error(`添加文件失败: ${t instanceof Error?t.message:String(t)}`)]}}async addFolder(e,t,r){try{if(this.assertInitialized(),!e||0===e.length)throw new Error("文件夹不能为空");return await this.fileManager.addFolder(e,t,r)}catch(e){return sj.error("添加文件夹失败",e),[null,new Error(`添加文件夹失败: ${e instanceof Error?e.message:String(e)}`)]}}async getFolderFileListWithContent(e,t,r=!0){const[n,o]=await this.fileManager.getFolderFileListWithContent(e,t,r);return[n,o]}async getFolderFileList(e,t,r=!0){const[n,o]=await this.fileManager.getFolderFileList(e,t,r);return[n,o]}createCustomFileList(e,t="upload"){try{if(this.assertInitialized(),!e||0===e.size)return[null,new Error("文件夹不能为空")];return[this.fileManager.createCustomFileList(e,t),null]}catch(e){return sj.error("创建自定义文件列表失败:",e),[null,new Error("文件模块未初始化")]}}assertInitialized(){if(!this.initialized)throw new Error("文件模块未初始化")}}class cj extends Error{constructor(e){super(e),this.name="AccountError"}}const uj={ErrNoDcPeerConnected:new cj("no dc peer connected"),ErrNodeAddrIsNull:new cj("nodeAddr is null"),ErrChainUtilIsNull:new cj("chainUtil is null"),ErrAccountLogin:new cj("account login error"),ErrNoAccountPeerConnected:new cj("no account peer connected"),ErrAccountPrivateSignIsNull:new cj("account privatekey sign is null"),ErrAccountPublicKeyIsNull:new cj("account publickey is null")};class lj{constructor(e){this.getAccountNodeAddr=async()=>{if(!this.context.connectedDc.client)return[null,uj.ErrNoDcPeerConnected];if(!this.chainUtil)return[null,uj.ErrChainUtilIsNull];if(!this.context)return[null,uj.ErrAccountPrivateSignIsNull];const e=this.context.getPubkeyRaw(),t=await this.chainUtil.getAccountPeers(e);if(t&&t.length>0){const e=await(this.dc?._connectPeers(t));if(e)return[e,null]}return[null,uj.ErrNoAccountPeerConnected]},this.getUserInfoWithNft=async e=>{if(!this.context.connectedDc.client)return[null,uj.ErrNoDcPeerConnected];if(!this.chainUtil)return[null,uj.ErrChainUtilIsNull];return[await this.chainUtil.getUserInfoWithNft(e),null]},this.bindAccessPeerToUser=async e=>{if(!this.context.connectedDc.client)return[!1,uj.ErrNoDcPeerConnected];if(!this.chainUtil)return[null,uj.ErrChainUtilIsNull];if(!this.context)return[null,uj.ErrAccountPrivateSignIsNull];const t=e.getPeerId();if(!t)return[null,uj.ErrNoAccountPeerConnected];const r=await this.chainUtil.getBlockHeight(),n=new VR(this.context.connectedDc.client);await n.bindAccessPeerToUser(this.context,r||0,t.toString());return[!0,null]},this.dc=e.dcutil,this.chainUtil=e.dcChain,this.context=e}async bindNFTAccount(e,t,n,o,i){if(!this.context.connectedDc.client)return[exports.NFTBindStatus.DcPeerNotConnected,uj.ErrNoDcPeerConnected];if(!this.context.connectedDc.nodeAddr)return[exports.NFTBindStatus.DcPeerNotConnected,uj.ErrNodeAddrIsNull];try{const s=this.context.connectedDc.nodeAddr.getPeerId();if(!s)return[exports.NFTBindStatus.DcPeerNotConnected,uj.ErrNodeAddrIsNull];const a=r.peerIdFromString(s),[c,u]=await this.generateAccountDealRequest(e,t,n,a,o,i);if(u!==exports.NFTBindStatus.Success)return[u,new cj(`Failed to generate account request: ${u}`)];const l=new VR(this.context.connectedDc.client);return await l.accountBind(c,i,this.context),[exports.NFTBindStatus.Success,null]}catch(e){const t=e instanceof Error?e.message:String(e);return t.includes("user already binded")?[exports.NFTBindStatus.UserBinded,e instanceof Error?e:new Error(t)]:t.includes("account already binded")?[exports.NFTBindStatus.NftAccountBinded,e instanceof Error?e:new Error(t)]:t.includes("user space expired")?[exports.NFTBindStatus.SpaceExpired,e instanceof Error?e:new Error(t)]:t.includes("no enough user space")?[exports.NFTBindStatus.NoLeftSpace,e instanceof Error?e:new Error(t)]:[exports.NFTBindStatus.Error,e instanceof Error?e:new Error(t)]}}async generateAccountDealRequest(e,t,r,n,o,i){try{if(o&&!i)return[null,exports.NFTBindStatus.Error];let s="";if(o)s=`mnemonic:${i}`;else{if(!this.context.privateKey)return[null,exports.NFTBindStatus.Error];s=`privatekey:${this.context.privateKey.string()}`}const a=(new TextEncoder).encode(e),c=await crypto.subtle.digest("SHA-256",a),u=new Uint8Array(c),l=await QD(n);if(!l)return[null,exports.NFTBindStatus.Error];const d=new ZD;let h;if(h=o&&i?await d.getEd25519KeyFromMnemonic(i,""):this.context.privateKey,!h)return[null,exports.NFTBindStatus.Error];const p=h.publicKey,y=await p.encrypt((new TextEncoder).encode(e));if(!y)return[null,exports.NFTBindStatus.EncryptError];const f=await l.encrypt(u);if(!f)return[null,exports.NFTBindStatus.EncryptError];const g=await tR(e,t);if(!g)return[null,exports.NFTBindStatus.EncryptError];const b=uR.fromSymKey(g),m=await b.encrypt((new TextEncoder).encode(s));if(!m)return[null,exports.NFTBindStatus.EncryptError];const w=await l.encrypt(m);if(!w)return[null,exports.NFTBindStatus.EncryptError];if(!this.chainUtil)return[null,exports.NFTBindStatus.BlockchainError];const v=await this.chainUtil.getBlockHeight();if(void 0===v)return[null,exports.NFTBindStatus.BlockchainError];const k=new Uint8Array(32);crypto.getRandomValues(k);const S=(new TextEncoder).encode(t),O=new Uint8Array(await crypto.subtle.digest("SHA-256",S.slice(0,2))),A=new Uint8Array(u.length+2+(new TextEncoder).encode(r).length);A.set(u,0),A.set(O.slice(-2),u.length),A.set((new TextEncoder).encode(r),u.length+2);const I=await crypto.subtle.digest("SHA-256",A),x=new Uint8Array(I),P=new Uint8Array(x.length+k.length);P.set(x,0),P.set(k,x.length);const E=await l.encrypt(P);if(!E)return[null,exports.NFTBindStatus.EncryptError];const C=(new TextEncoder).encode(n.toString()),B=new Uint8Array(await crypto.subtle.digest("SHA-256",m)),T=qr(v),D=new Uint8Array(u.length+y.length+B.length+T.length+C.length);let R,j=0;if(D.set(u,j),j+=u.length,D.set(y,j),j+=y.length,D.set(B,j),j+=B.length,D.set(T,j),j+=T.length,D.set(C,j),R=null!=h?h.sign(D):await this.context.sign(D),!R)return[null,exports.NFTBindStatus.SignError];return[{accounthashencrypt:f,accountencrypt:y,prikeyencrypt2:w,blockheight:v,loginkeyrandencrypt:E,peerid:C,signature:R},exports.NFTBindStatus.Success]}catch(e){return[null,exports.NFTBindStatus.Error]}}async isNftAccountBindSuccess(e,t){try{if(!this.chainUtil||!this.chainUtil.dcchainapi)return!1;const r=(new TextEncoder).encode(e),n=await Nr(r),o="0x"+Buffer.from(n).toString("hex");return(await(this.chainUtil.dcchainapi?.query).dcNode.nftToWalletAccount(o)).toString()==(0===t.indexOf("0x")?t:"0x"+t)}catch(e){return!1}}async isNftAccountBinded(e){try{if(!this.chainUtil||!this.chainUtil.dcchainapi)return!1;const t=(new TextEncoder).encode(e),r=await Nr(t),n="0x"+Buffer.from(r).toString("hex");if(!(await(this.chainUtil.dcchainapi?.query).dcNode.nftToWalletAccount(n)).toString())return!1}catch(e){return!1}return!0}async generateAppAccount(e,t){if(!t)return[null,new cj("Mnemonic is required")];if(!e)return[null,new cj("App ID is required")];if(!this.context.connectedDc.nodeAddr)return[null,new cj("No connected node")];let r;try{const n=new ZD;r=await n.getEd25519KeyFromMnemonic(t,e);const o=r.publicKey;if(await this.isAppAccountExists(o.toString()))return[r.string(),null];const i=await(this.chainUtil?.getBlockHeight());if(void 0===i)return[null,new cj("Failed to get blockchain height")];const s=this.context.connectedDc.nodeAddr.getPeerId();if(!s)return[null,new cj("No connected peer ID")];const a=(new TextEncoder).encode(s),c=qr(i),u=new Uint8Array(o.raw.length+c.length+a.length);let l=0;u.set(o.raw,l),l+=o.raw.length,u.set(c,l),l+=c.length,u.set(a,l);const d=await n.getEd25519KeyFromMnemonic(t,""),h=d.sign(u);if(!h)return[null,new cj("Failed to sign with parent private key")];if(!this.context.connectedDc.client)throw[null,uj.ErrNoAccountPeerConnected];if(""==this.context.connectedDc.client.token){if(!await this.context.connectedDc.client.GetToken(this.context.appInfo.appId||"",d.publicKey.string(),(async e=>d.sign(e))))return[null,new cj("Failed to get token")]}const p={subpubkey:o.raw,blockheight:i,peerid:a,signature:h},y=new VR(this.context.connectedDc.client);await y.addSubPubkey(p);let f=0;for(;;){try{if(await this.isAppAccountExists(o.toString()))break}catch(e){}if(await new Promise((e=>setTimeout(e,1e3))),f++,f>30){try{if(await this.isAppAccountExists(o.toString()))break}catch(e){}return[null,new cj("Wait app account create timeout")]}}return[r.string(),null]}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}async isAppAccountExists(e){try{const t=0===e.indexOf("0x")?e:"0x"+e;return!!await(this.context.dcChain?.getUserInfoWithAccount(t))}catch(e){return!1}}async setUserDefaultDB(e,t,r,n,o){if(!this.context.publicKey)throw uj.ErrAccountPublicKeyIsNull;if(!this.context.connectedDc.client)throw uj.ErrNoDcPeerConnected;if(!this.context.connectedDc.nodeAddr)throw uj.ErrNodeAddrIsNull;const i=e+"|"+t+"|"+r+"|"+n,s=await this.context.publicKey.encrypt((new TextEncoder).encode(i)),a=await(this.chainUtil?.getBlockHeight());if(void 0===a)throw new cj("Failed to get blockchain height");if(""==this.context.connectedDc.client.token){if(!await this.context.connectedDc.client.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),(async e=>this.context.sign(e))))throw new cj("Failed to get token")}const c=new VR(this.context.connectedDc.client),u=this.context.connectedDc.nodeAddr.getPeerId()||"",l=(new TextEncoder).encode(u),d=qr(a),h=new Uint8Array(s.length+d.length+l.length);let p=0;h.set(s,p),p+=s.length,h.set(d,p),p+=d.length,h.set(l,p);const y=await this.context.sign(h);await c.setUserDefaultDB(s,a||0,u,y,o)}async nftAccountPasswordModify(e,t,n,o,i){if(!this.context.publicKey)return uj.ErrAccountPublicKeyIsNull;const[s,a]=await this.getUserInfoWithNft(e);if(a)return a;if(!s||!s.peers||0===s.peers.length){if(!o&&!this.context.privateKey)return new Error("Cannot bind account without mnemonic or private key");const[r,s]=await this.bindNFTAccount(e,t,n,o,i);return s||(r!==exports.NFTBindStatus.Success?new Error(`Bind failed with status: ${r}`):null)}const c=s.peers;for(const s of c)try{const a=r.peerIdFromString(s);if(!await this.dc.connectToPeer(s))continue;const c=await this.dc._getNodeAddr(s);if(!c)continue;const u=new EE(this.context.dcNodeClient.libp2p,this.context.dcNodeClient.blockstore,c,UE);let l,d="";if(o&&i){const e=new ZD,t=await e.getEd25519KeyFromMnemonic(i,"");d=t.publicKey.string(),l=async e=>t.sign(e)}else{if(!this.context.publicKey)continue;d=this.context.publicKey.string(),l=async e=>this.context.sign(e)}await u.refreshToken(this.context.appInfo.appId||"",d,l);const[h,p]=await this.generateAccountDealRequest(e,t,n,a,o,i);if(p!==exports.NFTBindStatus.Success||!h)continue;const y=new VR(u);return await y.accountInfoModify(h),null}catch(e){continue}return new Error("Failed to modify password on any peer")}}class dj{constructor(e){this.client=e}async accountLogin(e,t,r){const n=await this._accountDoLogin(e,t,r,this.client.peerAddr);let o="";return n.startsWith("mnemonic:")?(o=n.slice(9),o):""}async _accountDoLogin(e,t,r,o){if(null==this.client.p2pNode||null==this.client.p2pNode.peerId)throw new Error("p2pNode is null or node privateKey is null");const i=await n.keys.generateKeyPair("Ed25519"),s=i.raw,a=i.publicKey,c=As.formEd25519PublicKey(a),u=await XD(o);this.client.p2pNode.peerId.publicKey;const l=await async function(e,t,r,n,o){try{const i=await QD(e),s=(new TextEncoder).encode(t),a=await Nr(s),c=await ks.encrypt(i.raw,a),u=o.raw,l=await ks.encrypt(i.raw,u),d=function(e){return crypto.getRandomValues(new Uint8Array(e))}(32),h=(new TextEncoder).encode(r).slice(0,2),p=(await Nr(h)).slice(-2),y=Ur(a,p,(new TextEncoder).encode(n)),f=Ur(await Nr(y),d);return{accounthashencrypt:c,pubkeyencrypt:l,loginkeyrandencrypt:await ks.encrypt(i.raw,f)}}catch(e){throw new Error(`Failed to generate login request: ${e.message}`)}}(u,e,t,r,c),d=await this._accountloginApi(l.accounthashencrypt,l.pubkeyencrypt,l.loginkeyrandencrypt,o),h=await ks.decrypt(s,d),p=await tR(e,t);return fa(await NR(h,p.raw))}async _accountloginApi(e,t,r,n){try{const o=new b.Libp2pGrpcClient(this.client.p2pNode,n||this.client.peerAddr,this.client.token,this.client.protocol),i=new IE.pb.AccountLoginRequest({});i.accounthashencrypt=e,i.pubkeyencrypt=t,i.loginkeyrandencrypt=r;const s=IE.pb.AccountLoginRequest.encode(i).finish(),a=await o.unaryCall("/dcnet.pb.Service/AccountLogin",s,3e4),c=IE.pb.AccountLoginReply.decode(a);return c.prikeyencrypt2}catch(e){throw e}}}const hj="undefined"!=typeof window?window.location.origin:"",pj="undefined"!=typeof window?window.location.href:"",yj="dcwallet_opener";class fj extends Error{constructor(e){super(e),this.name="WalletError"}}class gj{constructor(e){this.walletWindow=null,this.iframeId="dcIframeId",this.walletIframeId="dcWalletIframeId",this.channelPort2=null,this.iframeLoaded=!1,this.waitForWalletLoaded=async(e,t)=>{const r=localStorage.getItem(yj);let n=1;return"true"==r&&(n=3),new Promise((r=>{let o=new MessageChannel;const i=e=>{"walletLoaded"===e.data.type&&(clearInterval(u),clearTimeout(l),o.port1.close(),window.removeEventListener("message",c),r(!0))};o.port1.onmessage=i;const s={type:"checkWalletLoaded",origin:hj};let a=!1;const c=t=>{if(t.origin!==RE)return;if(null!=t.source&&t.source!=e)return;const n=t.data;n.type&&"walletLoaded"===n.type&&(a=!0,localStorage.setItem(yj,"true"),clearInterval(u),clearTimeout(l),o.port1.close(),window.removeEventListener("message",c),r(!0))};window.addEventListener("message",c);const u=setInterval((()=>{if(a)clearInterval(u),o.port1.close();else if(n>0)n--;else try{e?.postMessage(s,RE,[o.port2])}catch(e){o&&o.port1.close(),o=new MessageChannel,o.port1.onmessage=i}}),500),l=setTimeout((()=>{clearInterval(u),o.port1.close(),window.removeEventListener("message",c),r(!1)}),t)}))},this.isIframeOpen=()=>{if("iframe"==("undefined"!=typeof globalThis?globalThis.walletOpenType:""))return!0;return-1!==navigator.userAgent.toLowerCase().indexOf("micromessenger")},this.exitLogin=()=>new Promise(((e,t)=>{this.sendMessageToIframe({type:"exit"},6e4).then((r=>{if(!r||!r.data||!r.data.data)return void t(new fj("exitLogin response is null"));const n=r.data?.data,o=n.message;!1!==n.success?e(o):t(new fj("exitLogin messageData is null"))})).catch((e=>{t(e)}))})),this.decrypt=e=>new Promise(((t,r)=>{const n={type:"decrypt",data:{message:e}};this.sendMessageToIframe(n,6e4).then((e=>{if(!e||!e.data||!e.data.data)return void r(new fj("decrypt response is null"));const n=e.data?.data,o=n.message;!1!==n.success&&o?t(o):r(new fj("decrypt messageData is null"))})).catch((e=>{r(e)}))})),this.sign=e=>new Promise(((t,r)=>{const n={type:"sign",data:{message:e}};this.sendMessageToIframe(n,6e4).then((e=>{if(!e||!e.data||!e.data.data)return void r(new fj("sign response is null"));const n=e.data?.data,o=n.message;!1!==n.success&&o?t(o):r(new fj("sign messageData is null"))})).catch((e=>{r(e)}))})),this.context=e}async init(){return!("undefined"!=typeof globalThis&&void 0!==globalThis.walletOpenType)&&-1!==hj.indexOf(RE)||new Promise((async(e,t)=>{Date.now();let r=document.getElementById(this.iframeId);r||(r=document.createElement("iframe"),r.id=this.iframeId,document.body.appendChild(r)),r.credentialless=!0,window.addEventListener("message",(e=>{this.listenFromWallet(e)}));if(globalThis&&globalThis.iframeLoaded){const t=await this.initConfig(this);t&&(this.iframeLoaded=!0),e(t)}else r.onload=async()=>{const t=await this.initConfig(this);t&&(this.iframeLoaded=!0),e(t)}}))}async initConfig(e){return new Promise(((t,r)=>{const n={type:"init",data:{appId:this.context.appInfo.appId,appName:this.context.appInfo.appName,appIcon:this.context.appInfo.appIcon,appVersion:this.context.appInfo.appVersion,appUrl:pj}};e.sendMessageToIframe(n,5e4).then((e=>{if(!e||!e.data||!e.data.data)return void t(!1);const r=e.data?.data;!1!==r.success?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}async openWalletIframe(){return new Promise(((e,t)=>{if(document.getElementById(this.walletIframeId))return void e(!0);const r=document.createElement("iframe");r.id=this.walletIframeId,r.src=`${jE}?origin=${hj}`,r.credentialless=!0,r.onload=async()=>{},r.onerror=t=>{e(!1)},r.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin"),r.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",r.style.cssText="\n z-index: 2147483647;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: #fff;\n border: none;\n display: block;\n\n isolation: isolate;\n transform: translateZ(0);\n ",r.allowFullscreen=!0,document.body.appendChild(r),e(!0)}))}async removeWalletIframe(){const e=document.getElementById(this.walletIframeId);e&&document.body.removeChild(e)}async openConnect(e={}){return new Promise((async(t,r)=>{try{await this.initCommChannel()}catch(e){r(e)}if(this.isIframeOpen()){if(!await this.openWalletIframe())return void r(new fj("openWalletIframe error"))}else{const e=jE+"?origin="+hj;this.walletWindow=window.open(e,NE)}const n="undefined"!=typeof globalThis&&void 0!==globalThis.shouldReturnUserInfo,o={type:"connect",data:{origin:hj,accountInfo:e||{},shouldReturnUserInfo:n||!1,attach:""}};this.sendMessageToIframe(o,6e5).then((e=>{if(!e||!e.data||!e.data.data)return void r(new fj("openConnect response is null"));const n=e.data?.data,o=n.message;!1!==n.success&&o.appAccount?t(o):r(new fj("openConnect appAccount is null"))})).catch((e=>{r(new fj("openConnect error"))}))}))}async signMessage(e){return new Promise((async(t,r)=>{if(!this.context)return void r(new fj("未连接钱包"));try{await this.initCommChannel()}catch(e){r(e)}if(this.isIframeOpen()){if(!await this.openWalletIframe())return void r(new fj("openWalletIframe error"))}else{const e=jE+"?origin="+hj;this.walletWindow=window.open(e,NE)}this.initCommChannel();const n={type:"signMessage",data:e};this.sendMessageToIframe(n,6e4).then((e=>{if(!e||!e.data||!e.data.data)return void r(new fj("signMessage response is null"));const n=e.data?.data,o=n.message;!1!==n.success&&o?t(o):r(new fj("signMessage messageData is null"))})).catch((e=>{r(e)}))}))}async signEIP712Message(e){return new Promise((async(t,r)=>{if(!this.context)return void r(new fj("未连接钱包"));try{await this.initCommChannel()}catch(e){r(e)}if(this.isIframeOpen()){if(!await this.openWalletIframe())return void r(new fj("openWalletIframe error"))}else{const e=jE+"?origin="+hj;this.walletWindow=window.open(e,NE)}this.initCommChannel();const n={type:"signEIP712Message",data:e};this.sendMessageToIframe(n,6e4).then((e=>{if(!e||!e.data||!e.data.data)return void r(new fj("signEIP712Message response is null"));const n=e.data?.data,o=n.message;!1!==n.success&&o?t(o):r(new fj("signEIP712Message messageData is null"))})).catch((e=>{r(e)}))}))}async listenFromWallet(e){try{const t=e.data;if(!t.type)return;if("walletLoaded"===t.type){if(e.origin!==RE)return;if(this.channelPort2){const e={type:"channelPort2",origin:hj};if(this.walletWindow)try{this.walletWindow.postMessage(e,RE,[this.channelPort2])}catch(e){}else{const t=document.getElementById(this.walletIframeId);if(t)try{t.contentWindow?.postMessage(e,RE,[this.channelPort2])}catch(e){}}}}}catch(e){}}async initCommChannel(){const e=document.getElementById(this.iframeId);if(e){const t={code:"0",type:"channelPort1"};try{let r=0;for(;!this.iframeLoaded;)if(await new Promise((e=>setTimeout(e,100))),r++,r>100)throw new Error("iframe加载超时");const n=new MessageChannel;e.contentWindow?.postMessage(t,RE,[n.port1]),this.channelPort2=n.port2}catch(e){throw e}}}async sendMessageToIframe(e,t){const r=document.getElementById(this.iframeId);if(r){const n=new MessageChannel;return new Promise(((o,i)=>{const s=setTimeout((()=>{this.isIframeOpen()&&this.removeWalletIframe(),i("timeout")}),t);n.port1.onmessage=e=>{clearTimeout(s),n.port1.close(),e.data&&"initConfigResponse"!==e.data.type&&this.isIframeOpen()&&this.removeWalletIframe(),o(e)};try{r.contentWindow?.postMessage(e,RE,[n.port2])}catch(e){clearTimeout(s),n.port1.close(),this.isIframeOpen()&&this.removeWalletIframe(),i(e)}}))}return null}}class bj{constructor(e,t,r){this.client=e,this.dcNodeClient=t,this.context=r}async addUserOffChainSpace(e,t,r,n){const o=new IE.pb.AddUserOffChainSpaceRequest({});o.userPubkey=(new TextEncoder).encode(e),o.blockheight=t,o.peerid=(new TextEncoder).encode(r),o.signature=n;const i=IE.pb.AddUserOffChainSpaceRequest.encode(o).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/AddUserOffChainSpace",i,3e4);IE.pb.AddUserOffChainSpaceReply.decode(t);return!0}catch(e){if(-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(this.context.appInfo.appId||"",this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/AddUserOffChainSpace",i,3e4);IE.pb.AddUserOffChainSpaceReply.decode(t);return!0}throw e}}async getUserOffChainUsedInfo(e=""){const t=new IE.pb.GetUserOffChainUsedInfoRequest({});t.vaccount=(new TextEncoder).encode(e);const r=IE.pb.GetUserOffChainUsedInfoRequest.encode(t).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/GetUserOffChainUsedInfo",r,3e4);return IE.pb.GetUserOffChainUsedInfoReply.decode(t)}catch(e){if(-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(this.context.appInfo.appId||"",this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/GetUserOffChainUsedInfo",r,3e4);return IE.pb.GetUserOffChainUsedInfoReply.decode(t)}throw e}}async addUserOffChainOpTimes(e,t,r,n,o,i){const s=new IE.pb.AddUserOffChainOpTimesRequest({});s.userPubkey=(new TextEncoder).encode(e),s.blockheight=t,s.peerid=(new TextEncoder).encode(r),s.times=n,s.vaccount=(new TextEncoder).encode(i),s.signature=o;const a=IE.pb.AddUserOffChainOpTimesRequest.encode(s).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/AddUserOffChainOpTimes",a,3e4);IE.pb.AddUserOffChainOpTimesReply.decode(t);return!0}catch(e){if(-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(this.context.appInfo.appId||"",this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/AddUserOffChainOpTimes",a,3e4);IE.pb.AddUserOffChainOpTimesReply.decode(t);return!0}throw e}}async addThemeObj(e,t,r,n,o,i,s){const a=new IE.pb.AddThemeObjRequest({});a.theme=(new TextEncoder).encode(t),a.appId=(new TextEncoder).encode(e),a.blockheight=r,a.commentSpace=n,a.userPubkey=(new TextEncoder).encode(o),a.openFlag=i,a.signature=s;const c=IE.pb.AddThemeObjRequest.encode(a).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/AddThemeObj",c,3e4);return IE.pb.AddThemeObjReply.decode(t).flag}catch(t){if(-1!=t.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(e||"",o,(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const t=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),r=await t.unaryCall("/dcnet.pb.Service/AddThemeObj",c,3e4);return IE.pb.AddThemeObjReply.decode(r).flag}throw t}}async deleteThemeObj(e,t,r,n,o){const i=new IE.pb.DeleteThemeObjRequest({});i.theme=(new TextEncoder).encode(t),i.appId=(new TextEncoder).encode(e),i.blockheight=r,i.userPubkey=(new TextEncoder).encode(n),i.signature=o;const s=IE.pb.DeleteThemeObjRequest.encode(i).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/DeleteThemeObj",s,3e4);return IE.pb.DeleteThemeObjReply.decode(t).flag}catch(t){if(-1!=t.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(e||"",n,(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const t=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),r=await t.unaryCall("/dcnet.pb.Service/DeleteThemeObj",s,3e4);return IE.pb.DeleteThemeObjReply.decode(r).flag}throw t}}async addThemeSpace(e,t,r,n,o,i){const s=new IE.pb.AddThemeSpaceRequest({});s.theme=(new TextEncoder).encode(t),s.appId=(new TextEncoder).encode(e),s.blockheight=r,s.addspace=n,s.userPubkey=(new TextEncoder).encode(o),s.signature=i;const a=IE.pb.AddThemeSpaceRequest.encode(s).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/AddThemeSpace",a,3e4);return IE.pb.AddThemeSpaceReply.decode(t).flag}catch(t){if(-1!=t.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(e||"",o,(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const t=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),r=await t.unaryCall("/dcnet.pb.Service/AddThemeSpace",a,3e4);return IE.pb.AddThemeSpaceReply.decode(r).flag}throw t}}async publishCommentToTheme(e,t,r,n,o,i,s,a,c,u,l){const d=new IE.pb.PublishCommentToThemeRequest({});d.theme=(new TextEncoder).encode(t),d.appId=(new TextEncoder).encode(e),d.themeAuthor=(new TextEncoder).encode(r),d.blockheight=n,d.userPubkey=(new TextEncoder).encode(o),d.type=i,d.commentCid=(new TextEncoder).encode(s),d.comment=(new TextEncoder).encode(a),d.commentSize=d.comment.length,d.refercommentkey=(new TextEncoder).encode(c),void 0!==l&&(d.type=l),d.signature=u;const h=IE.pb.PublishCommentToThemeRequest.encode(d).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/PublishCommentToTheme",h,3e4);return IE.pb.PublishCommentToThemeReply.decode(t).flag}catch(t){if(-1!=t.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(e||"",o,(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const t=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),r=await t.unaryCall("/dcnet.pb.Service/PublishCommentToTheme",h,3e4);return IE.pb.PublishCommentToThemeReply.decode(r).flag}throw t}}async configThemeObjAuth(e,t,r,n,o,i,s,a,c,u,l){const d=new IE.pb.ConfigThemeObjAuthRequest({});d.appId=(new TextEncoder).encode(t),d.themeAuthor=(new TextEncoder).encode(r),d.theme=(new TextEncoder).encode(e),d.blockheight=n,d.content=(new TextEncoder).encode(s),d.contentCid=(new TextEncoder).encode(i),d.contentSize=a,d.signature=u,d.type=c,d.userPubkey=(new TextEncoder).encode(o),l&&(d.vaccount=(new TextEncoder).encode(l));const h=IE.pb.ConfigThemeObjAuthRequest.encode(d).finish(),p=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);try{const e=await p.unaryCall("/dcnet.pb.Service/ConfigThemeObjAuth",h,3e4);return IE.pb.ConfigThemeObjAuthReply.decode(e).flag}catch(e){if(-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(t||"",this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=await p.unaryCall("/dcnet.pb.Service/ConfigThemeObjAuth",h,3e4);return IE.pb.GetUserCommentsReply.decode(e).flag}throw e}}async deleteSelfComment(e,t,r,n,o,i,s,a){const c=new IE.pb.DeleteSelfCommentRequest({});c.theme=(new TextEncoder).encode(t),c.appId=(new TextEncoder).encode(e),c.themeAuthor=(new TextEncoder).encode(r),c.blockheight=n,c.userPubkey=(new TextEncoder).encode(o),c.commentCid=(new TextEncoder).encode(i),c.commentBlockheight=s,c.signature=a;const u=IE.pb.DeleteSelfCommentRequest.encode(c).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/DeleteSelfComment",u,3e4);return IE.pb.DeleteSelfCommentReply.decode(t).flag}catch(t){if(-1!=t.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(e||"",o,(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const t=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),r=await t.unaryCall("/dcnet.pb.Service/DeleteSelfComment",u,3e4);return IE.pb.DeleteSelfCommentReply.decode(r).flag}throw t}}async deleteCommentToObj(e,t,r,n,o,i,s,a){const c=new IE.pb.DeleteCommentToObjRequest({});c.theme=(new TextEncoder).encode(t),c.appId=(new TextEncoder).encode(e),c.themeAuthor=(new TextEncoder).encode(r),c.blockheight=n,c.userPubkey=(new TextEncoder).encode(o),c.commentCid=(new TextEncoder).encode(i),c.commentBlockheight=s,c.signature=a;const u=IE.pb.DeleteCommentToObjRequest.encode(c).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/DeleteCommentToObj",u,3e4);return IE.pb.DeleteCommentToObjReply.decode(t).flag}catch(t){if(-1!=t.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(e||"",o,(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const t=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),r=await t.unaryCall("/dcnet.pb.Service/DeleteCommentToObj",u,3e4);return IE.pb.DeleteCommentToObjReply.decode(r).flag}throw t}}async isThemeExist(e,t,r){const n=new IE.pb.IsThemeExistRequest({});n.appId=(new TextEncoder).encode(e),n.theme=(new TextEncoder).encode(t),n.themeAuthor=(new TextEncoder).encode(r);const o=IE.pb.IsThemeExistRequest.encode(n).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/IsThemeExist",o,3e4);return 0==IE.pb.IsThemeExistReply.decode(t).flag}catch(e){throw e}}async getThemeObj(e,t,r,n,o,i,s){const a=new IE.pb.GetThemeObjRequest({});a.appId=(new TextEncoder).encode(e),a.themeAuthor=(new TextEncoder).encode(t),a.startHeight=r,a.direction=n,a.offset=o,a.limit=i,a.seekKey=(new TextEncoder).encode(s);const c=IE.pb.GetThemeObjRequest.encode(a).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/GetThemeObj",c,3e4),r=IE.pb.GetThemeObjReply.decode(t);return r.objsCid?fa(r.objsCid):""}catch(t){if(-1!=t.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(e||"",this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const t=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),r=await t.unaryCall("/dcnet.pb.Service/GetThemeObj",c,3e4),n=IE.pb.GetThemeObjReply.decode(r);return n.objsCid?fa(n.objsCid):""}throw t}}async getThemeComments(e,t,r,n,o,i,s,a,c,u){const l=new IE.pb.GetThemeCommentsRequest({});l.appId=(new TextEncoder).encode(e),l.theme=(new TextEncoder).encode(t),l.themeAuthor=(new TextEncoder).encode(r),l.startHeight=n,l.direction=o,l.offset=i,l.limit=s,l.seekKey=(new TextEncoder).encode(a),l.aesKey=(new TextEncoder).encode(c),u&&(l.vaccount=(new TextEncoder).encode(u));const d=IE.pb.GetThemeCommentsRequest.encode(l).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/GetThemeComments",d,3e4),r=IE.pb.GetThemeCommentsReply.decode(t);return r.commentsCid?fa(r.commentsCid):""}catch(t){if(-1!=t.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(e||"",this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const t=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),r=await t.unaryCall("/dcnet.pb.Service/GetThemeComments",d,3e4),n=IE.pb.GetThemeCommentsReply.decode(r);return n.commentsCid?fa(n.commentsCid):""}throw t}}async getUserComments(e,t,r,n,o,i,s,a){const c=new IE.pb.GetUserCommentsRequest({});c.appId=(new TextEncoder).encode(e),c.UserPubkey=(new TextEncoder).encode(t),c.startHeight=r,c.direction=n,c.offset=o,c.limit=i,c.seekKey=(new TextEncoder).encode(s),c.aesKey=(new TextEncoder).encode(a);const u=IE.pb.GetUserCommentsRequest.encode(c).finish(),l=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);try{const e=await l.unaryCall("/dcnet.pb.Service/GetUserComments",u,3e4),t=IE.pb.GetUserCommentsReply.decode(e);return t.commentsCid?fa(t.commentsCid):""}catch(e){if(-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(this.context.appInfo.appId||"",this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=await l.unaryCall("/dcnet.pb.Service/GetUserComments",u,3e4),t=IE.pb.GetUserCommentsReply.decode(e);return t.commentsCid?fa(t.commentsCid):""}throw e}}}class mj{constructor(e){this.text=e,this.position=0,this.lines=e.split(/\r?\n/),this.currentLine=0}readLine(){if(this.currentLine>=this.lines.length)return{line:new Uint8Array(0),isPrefix:!1,error:new Error("EOF")};const e=this.lines[this.currentLine];this.currentLine++;return{line:(new TextEncoder).encode(e),isPrefix:!1,error:null}}}function wj(e){let t=new Uint8Array(0),r=!0,n=null;for(;r&&null===n;){const o=e.readLine();if(r=o.isPrefix,n=o.error,o.line.length>0){const e=new Uint8Array(t.length+o.line.length);e.set(t),e.set(o.line,t.length),t=e}}return{line:t,error:n}}const{Buffer:vj}=Rr,kj=new AbortController,{signal:Sj}=kj;class Oj extends Error{constructor(e){super(e),this.name="CommentError"}}const Aj={ErrNoDcPeerConnected:new Oj("no dc peer connected"),ErrNodeAddrIsNull:new Oj("nodeAddr is null"),ErrNoFileChose:new Oj("no file choose"),ErrNoPeerIdIsNull:new Oj("peerId is null"),ErrAddThemeObj:new Oj("add theme obj error"),ErrDeleteThemeObj:new Oj("delete theme obj error"),ErrPublishCommentToTheme:new Oj("publish comment error"),ErrCommentSpaceNotConfig:new Oj("comment space not config"),ErrCommentDataSync:new Oj("comment data sync"),ErrPublicKeyIsNull:new Oj("publickey is null"),ErrCommentKeyInvalid:new Oj("comment key invalid")};class Ij{constructor(e){this.connectedDc={},this.handleThemeObj=async e=>{const t=new mj(e);let r=[];for(;;){const{line:e,error:n}=wj(t);if(n&&"EOF"!==n.message)break;if(e){const t=(new TextDecoder).decode(e);if(!t)break;const n=ye.decode(t),o=IE.pb.AddThemeObjRequest.decode(n);r.push({theme:fa(o.theme),appId:fa(o.appId),blockheight:o.blockheight,commentSpace:o.commentSpace,allowSpace:o.allowSpace,userPubkey:fa(o.userPubkey),openFlag:o.openFlag,signature:an(o.signature),CCount:o.CCount,UpCount:o.UpCount,DownCount:o.DownCount,TCount:o.TCount,vaccount:fa(o.vaccount)})}}return r},this.handleThemeComments=async(e,t)=>{const r=new mj(e);let n=[];if(!this.context.getPublicKey())return[];for(;;){const{line:e,error:o}=wj(r);if(o&&"EOF"!==o.message)break;if(e){const r=(new TextDecoder).decode(e);if(!r)break;const o=ye.decode(r),i=await t.decrypt(o),s=IE.pb.PublishCommentToThemeRequest.decode(i);n.push({theme:fa(s.theme),appId:fa(s.appId),themeAuthor:fa(s.themeAuthor),blockheight:s.blockheight,userPubkey:fa(s.userPubkey),commentCid:fa(s.commentCid),comment:fa(s.comment),commentSize:s.commentSize,status:s.status,refercommentkey:fa(s.refercommentkey),CCount:s.CCount,UpCount:s.UpCount,DownCount:s.DownCount,TCount:s.TCount,type:s.type,signature:an(s.signature),vaccount:an(s.vaccount)})}}return n},this.dc=e.dcutil,this.connectedDc=e.connectedDc,this.dcNodeClient=e.dcNodeClient,this.chainUtil=e.dcChain,this.context=e}async addUserOffChainSpace(){try{if(!this.context.AccountBackupDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.AccountBackupDc?.nodeAddr)return[null,Aj.ErrNodeAddrIsNull];const e=this.context.AccountBackupDc.nodeAddr,t=await XD(e),r=await this.chainUtil.getBlockHeight()||0,n=qr(r||0),o=(new TextEncoder).encode(t.toString()),i=new Uint8Array(o.length+n.length);i.set(o,0),i.set(n,o.length);const s=await this.context.sign(i),a=this.context.getPublicKey(),c=new bj(this.context.AccountBackupDc.client,this.dcNodeClient,this.context);await c.addUserOffChainSpace(a.string(),r||0,t.toString(),s);return[!0,null]}catch(e){throw e}}async addThemeObj(e,t,r,n){try{if(!this.context.AccountBackupDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.publicKey)return[null,Aj.ErrPublicKeyIsNull];""==this.context.AccountBackupDc.client.token&&await this.context.AccountBackupDc.client.GetToken(e,this.context.publicKey.string(),this.context.sign);const o=await this.chainUtil.getBlockHeight()||0,i=qr(o||0),s=qr(n),a=qr(r),c=(new TextEncoder).encode(t),u=(new TextEncoder).encode(e),l=new Uint8Array([...c,...u,...i,...s,...a]),d=await this.context.sign(l),h=this.context.getPublicKey(),p=new bj(this.context.AccountBackupDc.client,this.dcNodeClient,this.context);let y=await p.addThemeObj(e,t,o||0,n,h.string(),r,d);return 0===y?[y,null]:1!=y&&2!==y||(await this.addUserOffChainSpace(),y=await p.addThemeObj(e,t,o||0,n,h.string(),r,d),0!==y)?3===y?[null,Aj.ErrCommentDataSync]:[null,Aj.ErrAddThemeObj]:[y,null]}catch(e){throw e}}async deleteThemeObj(e,t){try{if(!this.context.AccountBackupDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.publicKey)return[null,Aj.ErrPublicKeyIsNull];""==this.context.AccountBackupDc.client.token&&await this.context.AccountBackupDc.client.GetToken(e,this.context.publicKey.string(),this.context.sign);const r=await this.chainUtil.getBlockHeight()||0,n=qr(r||0),o=(new TextEncoder).encode(t),i=(new TextEncoder).encode(e),s=new Uint8Array([...o,...i,...n]),a=await this.context.sign(s),c=this.context.getPublicKey(),u=new bj(this.context.AccountBackupDc.client,this.dcNodeClient,this.context);let l=await u.deleteThemeObj(e,t,r||0,c.string(),a);return 0===l?[l,null]:1!=l&&2!==l||(await this.addUserOffChainSpace(),l=await u.deleteThemeObj(e,t,r||0,c.string(),a),0!==l)?3===l?[null,Aj.ErrCommentDataSync]:[null,Aj.ErrDeleteThemeObj]:[l,null]}catch(e){throw e}}async isThemeExist(e,t,r){try{if(!this.connectedDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.publicKey)return[null,Aj.ErrPublicKeyIsNull];let n=this.context.AccountBackupDc.client;if(!n||r!=this.context.publicKey.string()){const e=As.edPubkeyFromStr(r),t=await this.dc.connectToUserDcPeer(e.raw);if(!t)return[null,Aj.ErrNoPeerIdIsNull];n=t}""==n.token&&await n.GetToken(e,this.context.publicKey.string(),this.context.sign);uR.new();const o=new bj(n,this.dcNodeClient,this.context);return[await o.isThemeExist(e,t,r),null]}catch(e){return[null,e]}}async getUserOffChainUsedInfo(e=""){try{if(!this.context.AccountBackupDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.AccountBackupDc?.nodeAddr)return[null,Aj.ErrNoDcPeerConnected];const t=new bj(this.context.AccountBackupDc.client,this.dcNodeClient,this.context);return[await t.getUserOffChainUsedInfo(e),null]}catch(e){return[null,e]}}async addUserOffChainOpTimes(e,t=""){try{if(!this.context.AccountBackupDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.AccountBackupDc?.nodeAddr)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.publicKey)return[null,Aj.ErrPublicKeyIsNull];""==this.context.AccountBackupDc.client.token&&await this.context.AccountBackupDc.client.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),this.context.sign);let r=await this.chainUtil.getBlockHeight()||0;const n=qr(r),o=qr(e),i=this.context.AccountBackupDc?.nodeAddr.getPeerId()||"",s=(new TextEncoder).encode(i),a=new Uint8Array([...s,...o,...n]),c=await this.context.sign(a),u=this.context.getPublicKey(),l=new bj(this.context.AccountBackupDc.client,this.dcNodeClient,this.context);try{return[await l.addUserOffChainOpTimes(u.string(),r,i,e,c,t),null]}catch(e){return[!1,e]}}catch(e){return[!1,e]}}async addThemeSpace(e,t,r){try{if(!this.context.AccountBackupDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.publicKey)return[null,Aj.ErrPublicKeyIsNull];""==this.context.AccountBackupDc.client.token&&await this.context.AccountBackupDc.client.GetToken(e,this.context.publicKey.string(),this.context.sign);const n=await this.chainUtil.getBlockHeight()||0,o=qr(n||0),i=qr(r),s=(new TextEncoder).encode(t),a=(new TextEncoder).encode(e),c=new Uint8Array([...s,...a,...o,...i]),u=await this.context.sign(c),l=this.context.getPublicKey(),d=new bj(this.context.AccountBackupDc.client,this.dcNodeClient,this.context);return[await d.addThemeSpace(e,t,n||0,r,l.string(),u),null]}catch(e){throw e}}async publishCommentToTheme(e,t,r,n,o,i,s){try{if(!this.context.AccountBackupDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.publicKey)return[null,Aj.ErrPublicKeyIsNull];""==this.context.AccountBackupDc.client.token&&await this.context.AccountBackupDc.client.GetToken(e,this.context.publicKey.string(),this.context.sign);const a=await this.chainUtil.getBlockHeight()||0,c=qr(a||0),u=qr(n),l=(new TextEncoder).encode(o),d=await Nr(l),h=ye.encode(d),p=(new TextEncoder).encode(t),y=(new TextEncoder).encode(e),f=(new TextEncoder).encode(r),g=(new TextEncoder).encode(h),b=(new TextEncoder).encode(i),m=new Uint8Array([...p,...y,...f,...c,...g,...b,...u]),w=await this.context.sign(m),v=this.context.getPublicKey(),k=new bj(this.context.AccountBackupDc.client,this.dcNodeClient,this.context);let S=await k.publishCommentToTheme(e,t,r,a||0,v.string(),n,h,o,i,w,s);if(0===S){const e=await this.chainUtil.getBlockHeight()||0;return[`${e}/${h}`,null]}if((1==S||2===S)&&(await this.addUserOffChainSpace(),S=await k.publishCommentToTheme(e,t,r,a||0,v.string(),n,h,o,i,w),0===S)){const e=await this.chainUtil.getBlockHeight()||0;return[`${e}/${h}`,null]}return[null,Aj.ErrPublishCommentToTheme]}catch(e){throw e}}async deleteSelfComment(e,t,r,n){try{if(!this.context.AccountBackupDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.publicKey)return[null,Aj.ErrPublicKeyIsNull];""==this.context.AccountBackupDc.client.token&&await this.context.AccountBackupDc.client.GetToken(e,this.context.publicKey.string(),this.context.sign);const o=n.split("/");if(o.length<2)return[null,Aj.ErrCommentKeyInvalid];const i=await this.chainUtil.getBlockHeight()||0,s=o[1],a=function(e){try{const t=parseInt(e,10);if(isNaN(t))throw new Error("invalid syntax");if(t<0)throw new Error("invalid syntax for uint");if(t>4294967295)throw new Error("value out of range");return t>>>0}catch(e){throw e}}(o[0]),c=qr(i||0),u=(new TextEncoder).encode(t),l=(new TextEncoder).encode(e),d=(new TextEncoder).encode(r),h=(new TextEncoder).encode(s),p=new Uint8Array([...u,...l,...d,...c,...h]),y=await this.context.sign(p),f=this.context.getPublicKey(),g=new bj(this.context.AccountBackupDc.client,this.dcNodeClient,this.context);let b=-1,m=-1,w=null,v=null;try{b=await g.deleteSelfComment(e,t,r,i||0,f.string(),s,a,y)}catch(e){w=new Oj("deleteSelfComment error"+(e&&e.message))}try{m=await g.deleteCommentToObj(e,t,r,i||0,f.string(),s,a,y)}catch(e){v=new Oj("deleteCommentToObj error"+(e&&e.message))}return 0!==b?[b,w||new Oj("deleteSelfComment error")]:0!==m?[m,v||new Oj("deleteCommentToObj error")]:[0,null]}catch(e){throw e}}async getThemeObj(e,t,r,n,o,i,s){try{if(!this.connectedDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.publicKey)return[null,Aj.ErrPublicKeyIsNull];let a=this.context.AccountBackupDc.client;if(!a||t!=this.context.publicKey.string()){const e=As.edPubkeyFromStr(t),r=await this.dc.connectToUserDcPeer(e.raw);if(!r)return[null,Aj.ErrNoPeerIdIsNull];a=r}""==a.token&&await a.GetToken(e,this.context.publicKey.string(),this.context.sign);const c=new bj(a,this.dcNodeClient,this.context),u=await c.getThemeObj(e,t,r||0,n||0,o||0,i||0,s||""),l=new XR(this.dc,this.connectedDc,this.chainUtil,this.dcNodeClient,this.context),d=vj.from(u).toString(),h=await l.getFileFromDc(d,"",qR,!1);if(!h)return[[],null];const p=fa(h);return[await this.handleThemeObj(p),null]}catch(e){throw e}}async getThemeComments(e,t,r,n,o,i,s,a,c){try{if(!this.connectedDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.publicKey)return[null,Aj.ErrPublicKeyIsNull];let u=this.context.AccountBackupDc.client;if(!u||r!=this.context.publicKey.string()){const e=As.edPubkeyFromStr(r),t=await this.dc.connectToUserDcPeer(e.raw);if(!t)return[null,Aj.ErrNoPeerIdIsNull];u=t}""==u.token&&await u.GetToken(e,this.context.publicKey.string(),this.context.sign);const l=uR.new(),d=new bj(u,this.dcNodeClient,this.context),h=await d.getThemeComments(e,t,r,n||0,o||0,i||0,s||0,a||"",l?l.toString():"",c);if(!h)return[[],null];const p=new XR(this.dc,this.connectedDc,this.chainUtil,this.dcNodeClient,this.context),y=vj.from(h).toString(),f=await p.getFileFromDc(y,"",qR,!1);if(!f)return[[],null];const g=fa(f);return[await this.handleThemeComments(g,l)||null,null]}catch(e){throw e}}async configAuth(e,t,r,n,o,i,s){if(r.endsWith("_authlist")||(r+="_authlist"),!this.context.publicKey)return[null,Aj.ErrPublicKeyIsNull];let a=this.context.publicKey.string(),c=this.context.AccountBackupDc.client;if(t!=a){const e=As.edPubkeyFromStr(t),r=await this.dc.connectToUserDcPeer(e.raw);if(!r)return[null,Aj.ErrNoPeerIdIsNull];c=r}if(!c)return[null,new Error("ErrConnectToAccountPeersFail")];if(null===c.peerAddr)return[null,new Error("ErrConnectToAccountPeersFail")];""==c.token&&await c.GetToken(e,this.context.publicKey.string(),this.context.sign);const u=As.edPubkeyFromStr(t);let l;try{l=As.edPubkeyFromStr(n).string()}catch(e){l=n}const d=`${l}:${o}:${i}`,h=(new TextEncoder).encode(d),p=await Nr(h),y=ye.encode(p);let f;try{f=await this.chainUtil.getBlockHeight()||0}catch(e){return[null,new Error("ErrGetBlockHeightFail")]}const g=h.length,b=qr(f||0),m=qr(exports.CommentType.Comment),w=(new TextEncoder).encode(r),v=(new TextEncoder).encode(e),k=(new TextEncoder).encode(u.string()),S=(new TextEncoder).encode(y);let O=new Uint8Array([...w,...v,...k,...b,...S,...m]);const A=await this.context.sign(O),I=new bj(c,this.dcNodeClient,this.context);try{const n=await I.configThemeObjAuth(r,e,t,f,a,y,d,g,exports.CommentType.Comment,A,s);return 0!==n?[n,new Error(`configThemeObjAuth fail, resFlag: ${n}`)]:[0,null]}catch(e){return[null,e]}}async getAuthList(e,t,r,n){r.endsWith("_authlist")||(r+="_authlist");let o="",i=[],s=[];try{for(;;){const a=new Ij(this.context),c=await a.getThemeComments(e,r,t,0,exports.Direction.Forward,0,1e3,o||"",n);if(c[0]&&0==c[0].length)return[s,i,null];const u=c[0];if(!u||0==u.length)break;for(let e=0;e<u.length;e++){i.push(u[e]);const t=u[e].comment,r=t.split(":");if(r.length<2)continue;const n=r[0],o=parseInt(r[1]),a=t.substring(n.length+r[1].length+2);s.push({pubkey:n,permission:o,remark:a})}if(u.length<1e3)break;o=`${u[u.length-1].blockheight}/${u[u.length-1].commentCid}`}}catch(e){return[s,i,e]}return[s,i,null]}async getUserComments(e,t,r,n,o,i,s){try{if(!this.connectedDc?.client)return[null,Aj.ErrNoDcPeerConnected];if(!this.context.publicKey)return[null,Aj.ErrPublicKeyIsNull];""==this.connectedDc.client.token&&await this.connectedDc.client.GetToken(e,this.context.publicKey.string(),this.context.sign);let a=this.context.AccountBackupDc.client;if(t!=this.context.publicKey.string()){const e=As.edPubkeyFromStr(t),r=await this.dc.connectToUserDcPeer(e.raw);if(!r)return[null,Aj.ErrNoPeerIdIsNull];a=r}if(!a)return[null,new Error("ErrConnectToAccountPeersFail")];""==a.token&&await a.GetToken(e,this.context.publicKey.string(),this.context.sign);const c=uR.new(),u=new bj(this.connectedDc.client,this.dcNodeClient,this.context),l=await u.getUserComments(e,t,r||0,n||0,o||0,i||0,s||"",c?c.toString():"");if(!l)return[[],null];const d=new XR(this.dc,this.connectedDc,this.chainUtil,this.dcNodeClient,this.context),h=vj.from(l).toString(),p=await d.getFileFromDc(h,"",qR,!1);if(!p)return[[],null];const y=fa(p);return[await this.handleThemeComments(y,c)||null,null]}catch(e){throw e}}}const xj=kR("AuthModule");class Pj{constructor(){this.moduleName=exports.CoreModuleName.AUTH,this.initialized=!1,this.tokenTask=!1}async initialize(e){return this.context=e,(async()=>{try{xj.info("真正的认证模块初始化开始");const e=new gj(this.context);this.walletManager=e,await e.init(),this.initialized=!0,xj.info("真正的认证模块初始化完成")}catch(e){xj.error("真正的认证模块初始化失败:",e),this.initialized=!1}})(),!0}async shutdown(){this.stopTokenKeepValidTask(),this.initialized=!1}async accountLoginWithWalletCall(e={}){try{if(this.assertInitialized(),!this.context.connectedDc?.client)throw new Error("dcClient is null");const t=await this.walletManager.openConnect(e);this.context.privateKey=null,t&&t.accountInfo&&t.accountInfo.nftAccount&&(this.context.accountInfo=t.accountInfo);const r=new As(t.appAccount);this.context.publicKey=r,this.context.ethAddress=t.ethAccount;if(!await(this.context.connectedDc?.client.GetToken(this.context.appInfo.appId||"",r.string(),(e=>this.signWithWallet(e)))))throw new Error("GetToken error");await this.getAccountBackupDc(),this.context.AccountBackupDc?.client&&await(this.context.AccountBackupDc?.client.GetToken(this.context.appInfo.appId||"",r.string(),(e=>this.signWithWallet(e))));const[n,o]=await this.getUserInfoWithAccount("0x"+r.toString());if(o)throw o;if(null==n)throw GR.USER_NOT_BIND_TO_PEER;const i=new Ij(this.context),[s,a]=await i.getUserOffChainUsedInfo();if(a)throw a;const c=s?n.offchainSpace-Number(s.usedspace):n.offchainSpace,u=s?n.offchainOptimes-Number(s.usedtimes):n.offchainOptimes;if(xj.info(`用户线下评论空间剩余: ${c} / ${n.offchainSpace}, 线下操作次数剩余: ${u} / ${n.offchainOptimes}`),c<qE||u<LE){if(c<qE){const[e,t]=await i.addUserOffChainSpace();if(t||!e)throw t||new Error("addUserOffChainSpace error")}if(u<LE){const[e,t]=await i.addUserOffChainOpTimes(2e4);if(t||!e)throw t||new Error("addUserOffChainSpace error")}}return t}catch(e){throw e}}async accountLoginWithWallet(e){try{const t=await this.accountLoginWithWalletCall(e);return this.context.userInfo=t,[t,null]}catch(e){return[null,e]}}exitLogin(){this.walletManager.exitLogin()}async accountLogin(e,t,r){try{if(this.assertInitialized(),!this.context.connectedDc?.client)throw new Error("dcClient is null");let n=this.context.connectedDc?.client||null;const o=await(this.context.dcChain?.getUserWalletAccount(e));if(!o)throw new Error("getUserWalletAccount error");const i=As.edPubkeyFromStr(o),s=await this.context.dcutil.connectToUserDcPeer(i.raw);if(!s)throw new Error("connect to user dc peer failed");n=s,this.context.AccountBackupDc.client=n;const a=new dj(n),c=await a.accountLogin(e,t,r);if(c){if(this.context.privateKey=null,this.context.publicKey=void 0,n.token="",this.context.connectedDc.client.token="",this.context.appInfo?.appId){const e=new lj(this.context),t=await e.generateAppAccount(this.context.appInfo?.appId,c);if(null===t[0])throw t[1]||new Error("generateAppAccount error");Is.unmarshalString(t[0])}return this.context.userInfo={nftAccount:e,appAccount:i.raw,ethAccount:"",chainId:"",chainName:""},[c,null]}return["",new Error("accountLogin failed")]}catch(e){return["",e]}}async nftAccountPasswordModify(e,t,r,n){try{this.assertInitialized();const o=new lj(this.context),i=!!n;return await o.nftAccountPasswordModify(e,t,r,i,n)}catch(e){return e}}async signWithWallet(e){if(this.walletManager){if(!this.context.privateKey){return await this.walletManager.sign(e)}const t=this.context.privateKey?.sign(e);return t}throw new Error("walletManager is null")}async sign(e){try{return[await this.signWithWallet(e),null]}catch(e){return[null,e]}}async decryptWithWallet(e){try{if(!this.walletManager)throw new Error("walletManager is null");return[await this.walletManager.decrypt(e),null]}catch(e){return[null,e]}}async signMessageWithWallet(e){if(!this.walletManager)throw new Error("walletManager is null");try{return[await this.walletManager.signMessage(e),null]}catch(e){return[null,e]}}async signEIP712MessageWithWallet(e){if(!this.walletManager)throw new Error("walletManager is null");try{return[await this.walletManager.signEIP712Message(e),null]}catch(e){return[null,e]}}async bindNFTAccount(e,t,r,n){try{if(this.assertInitialized(),!this.context.connectedDc?.client)throw new Error("dcClient is null");const o=new lj(this.context);return[(await o.bindNFTAccount(e,t,r,!0,n))[0],null]}catch(e){return[null,e]}}async generateAppAccount(e,t){try{this.assertInitialized();const r=new lj(this.context),[n,o]=await r.generateAppAccount(e,t);return null!==o?[null,o]:[n,null]}catch(e){return[null,e]}}async isNftAccountBindSuccess(e,t){try{this.assertInitialized();const r=new lj(this.context);return[await r.isNftAccountBindSuccess(e,t),null]}catch(e){return[null,e]}}async isNftAccountBinded(e){try{this.assertInitialized();const t=new lj(this.context);return[await t.isNftAccountBinded(e),null]}catch(e){return[null,e]}}async getUserInfoWithAccount(e){try{this.assertInitialized();return[await this.context.dcChain.getUserInfoWithAccount(e),null]}catch(e){return[null,e]}}async getAccountBackupDc(){const e=new lj(this.context),t=await e.getAccountNodeAddr();if(t&&t[0]){const e=t[0];this.context.AccountBackupDc.nodeAddr=e,this.context.AccountBackupDc.client=await this.newDcClient(e)}}async newDcClient(e){if(!e)return;return new EE(this.context.dcNodeClient.libp2p,this.context.dcNodeClient.blockstore,e,UE)}async startDcPeerTokenKeepValidTask(){try{if(this.assertInitialized(),this.tokenTask)return[!0,null];this.tokenTask=!0;const e=6e4;let t=0,r=0;return xj.info("开始定时验证Token有效性任务"),(async()=>{for(;this.tokenTask;){r++;try{(""==this.context.connectedDc.client?.token||r>=300)&&await this.getTokenWithDCConnectInfo(this.context.connectedDc),(""==this.context.AccountBackupDc.client?.token||r>=300)&&await this.getTokenWithDCConnectInfo(this.context.AccountBackupDc),r>=300&&(r=0,t++)}catch(e){xj.error("Token验证任务执行失败:",e)}await Lr(e)}})(),[!0,null]}catch(e){return[!1,e]}}stopTokenKeepValidTask(){this.tokenTask=!1}async getTokenWithDCConnectInfo(e){try{if(this.assertInitialized(),!e.client)return;if(!e.client?.p2pNode||"started"!==e.client?.p2pNode.status)try{const t=e.client?.peerAddr;if(!t)return void xj.error("nodeAddr is null");xj.info("重新创建DC客户端"),e.client=await this.newDcClient(t)}catch(e){return void xj.error("重新连接失败",e)}}catch(e){return void xj.error("连接检查失败",e)}if(!e.client?.token)try{if(!this.context.publicKey)return;return xj.info("获取新Token"),void await(e.client?.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),this.context.sign))}catch(e){return void xj.error("获取token失败",e)}try{xj.debug("验证Token有效性"),await(e.client?.ValidToken())}catch(t){if(t?.message&&t.message.endsWith(GR.INVALID_TOKEN.message)){if(!this.context.publicKey)return;xj.info("刷新Token"),await(e.client?.refreshToken(this.context.appInfo.appId||"",this.context.publicKey.string(),this.context.sign))}else{let t;xj.info("需要重连节点");try{const r=await(this.context.dcutil?._getNodeAddr(e.nodeAddr?.getPeerId()));if(!r)return void xj.error("无法获取节点地址");if(t=await this.newDcClient(r),!t)return void xj.error("创建客户端失败")}catch(t){return void xj.error(`获取客户端失败, err: ${t?.message}, PEERID: ${e.nodeAddr?.getPeerId()}`)}t&&(e.client=t);try{if(!this.context.publicKey)return;xj.info("获取新Token"),await(e.client?.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),this.context.sign))}catch(t){xj.error(`获取token失败, err: ${t?.message}, PEERID: ${e.nodeAddr?.getPeerId()}`)}}}}async getUserInfoWithNft(e){try{this.assertInitialized();const t=new lj(this.context),r=await t.getUserInfoWithNft(e);return xj.info("获取用户信息成功:",r),r}catch(e){return[null,e]}}async ifEnoughUserSpace(e){try{this.assertInitialized();const t=this.context.getPubkeyRaw();return[await this.context.dcChain.ifEnoughUserSpace(t,e),null]}catch(e){return[null,e]}}async refreshUserInfo(){try{this.assertInitialized();const e=this.context.getPubkeyRaw();if(!e)throw new Error("用户未登录!");return[await this.context.dcChain.refreshUserInfo(e),null]}catch(e){return[null,e]}}async setUserDefaultDB(e,t,r,n,o){try{this.assertInitialized();const i=new lj(this.context);return await i.setUserDefaultDB(e,t,r,n,o),null}catch(e){return e}}async assertInitialized(e=3e4){const t=Date.now();for(;!this.initialized;){if(Date.now()-t>e)throw new Error("认证模块未初始化(超时)");await new Promise((e=>setTimeout(e,100)))}}}const Ej=kR("CommentModule");class Cj{constructor(){this.moduleName=exports.CoreModuleName.COMMENT,this.initialized=!1}async initialize(e){try{return this.context=e,this.commentManager=new Ij(e),this.initialized=!0,!0}catch(e){return Ej.error("评论模块初始化失败:",e),!1}}async shutdown(){this.initialized=!1}async addUserOffChainSpace(){try{this.assertInitialized();const e=await this.commentManager.addUserOffChainSpace();return e[1]||Ej.info("添加用户评论空间成功"),e}catch(e){return Ej.error("添加用户评论空间失败:",e),[null,e]}}async addUserOffChainOpTimes(e,t){try{this.assertInitialized();const r=await this.commentManager.addUserOffChainOpTimes(e,t);return r[1]||Ej.info("添加用户操作次数成功"),r}catch(e){return Ej.error("添加用户操作次数失败:",e),[null,e]}}async addThemeObj(e,t,r){try{this.assertInitialized();const n=await this.commentManager.addThemeObj(this.context.appInfo?.appId||"",e,t,r||52428800);return n[1]||Ej.info(`为主题 ${e} 开通评论功能成功`),n}catch(t){return Ej.error(`为主题 ${e} 开通评论功能失败:`,t),[null,t]}}async isThemeExist(e,t,r){try{this.assertInitialized();return await this.commentManager.isThemeExist(e,t,r)}catch(e){return Ej.error(`判断主题 ${t} 是否存在失败:`,e),[null,e]}}async addThemeSpace(e,t){try{this.assertInitialized();const r=await this.commentManager.addThemeSpace(this.context.appInfo?.appId||"",e,t);return r[1]||Ej.info(`为主题 ${e} 增加 ${t} 字节评论空间成功`),r}catch(t){return Ej.error(`为主题 ${e} 增加评论空间失败:`,t),[null,t]}}async publishCommentToTheme(e,t,r,n,o,i){try{this.assertInitialized();const s=await this.commentManager.publishCommentToTheme(this.context.appInfo?.appId||"",e,t,r,n,i||"",o);return s[1]||Ej.info(`发布评论到主题 ${e} 成功`),s}catch(t){return Ej.error(`发布评论到主题 ${e} 失败:`,t),[null,t]}}async deleteSelfComment(e,t,r){try{this.assertInitialized();const n=await this.commentManager.deleteSelfComment(this.context.appInfo?.appId||"",e,t,r);return n[1]||Ej.info(`删除评论 ${r} 成功`),n}catch(e){return Ej.error(`删除评论 ${r} 失败:`,e),[null,e]}}async getThemeObj(e,t,r,n,o,i){try{this.assertInitialized();const s=await this.commentManager.getThemeObj(this.context.appInfo?.appId||"",e,t||0,r||0,n||0,o||100,i||"");return s[1]||Ej.info(`获取作者 ${e} 的主题对象列表成功`),s}catch(t){return Ej.error(`获取作者 ${e} 的主题对象列表失败:`,t),[null,t]}}async getThemeComments(e,t,r,n,o,i,s){try{this.assertInitialized();const a=await this.commentManager.getThemeComments(this.context.appInfo?.appId||"",e,t,r||0,n||0,o||0,i||100,s||"");return a[1]||Ej.info(`获取主题 ${e} 的评论列表成功`),a}catch(t){return Ej.error(`获取主题 ${e} 的评论列表失败:`,t),[null,t]}}async configAuth(e,t,r,n,o,i){try{return this.assertInitialized(),await this.commentManager.configAuth(this.context.appInfo?.appId||"",e,t,r,n,o,i)}catch(e){return Ej.error(`配置主题 ${t} 的授权信息失败:`,e),[null,e]}}async getAuthList(e,t,r){try{return this.assertInitialized(),await this.commentManager.getAuthList(this.context.appInfo?.appId||"",e,t,r)}catch(e){return Ej.error(`获取主题 ${t} 的授权列表失败:`,e),[null,null,e]}}async getUserComments(e,t,r,n,o,i){try{this.assertInitialized();const s=await this.commentManager.getUserComments(this.context.appInfo?.appId||"",e,t||0,r||0,n||0,o||100,i||"");return s[1]||Ej.info(`获取用户 ${e} 的评论列表成功`),s}catch(t){return Ej.error(`获取用户 ${e} 的评论列表失败:`,t),[null,t]}}assertInitialized(){if(!this.initialized)throw new Error("评论模块未初始化")}}class Bj{constructor(e){this.store=e,this.txn=null}async*queryKeys(e,t){const{filters:r=[],prefix:n}=e,o={prefix:n};for await(const{key:e}of this.store.query(o)){let t=!0;for(const n of r)if(!n(e)){t=!1;break}t&&(yield e)}}async*query(e,t){try{const t=this.store.query(e);if(!t||"function"!=typeof t[Symbol.asyncIterator])return;let r=0;for await(const e of t)r++,e&&e.key&&(yield e)}catch(e){throw e}}async*queryExtended(e){const{prefix:t,filters:r=[]}=e,n={};void 0!==t&&(n.prefix=t);for await(const e of this.store.query(n)){let t=!0;for(const n of r)if(!n(e)){t=!1;break}t&&(yield{key:e.key.toString(),value:e.value,size:e.value.length})}}async*putMany(e,t){const r=this.batch();for await(const t of e){const e=t.key;r.put(e,t.value),yield e}await r.commit()}async*getMany(e,t){for await(const t of e)try{const e=await this.get(t);yield{key:t,value:e}}catch(e){}}async*deleteMany(e,t){const r=this.batch();for await(const t of e)r.delete(t),yield t;await r.commit()}async put(e,t){return this.store.put(e,t)}async get(e){return this.store.get(e)}async has(e){return this.store.has(e)}async delete(e){return this.store.delete(e)}batch(){return this.store.batch()}async newTransactionExtended(e){const t=this.store,r={put:async(t,r)=>{if(e)throw new Error("Transaction is read-only");return await this.store.put(t,r),t},get:async e=>this.store.get(e),has:async e=>this.store.has(e),delete:async t=>{if(e)throw new Error("Transaction is read-only");await this.store.delete(t)},query:async function*(e){for await(const r of t.query(e))yield{key:r.key.toString(),value:r.value,size:r.value.length}}.bind(this),queryExtended:async function*(e){const{prefix:r,filters:n=[]}=e,o={};void 0!==r&&(o.prefix=r);for await(const e of t.query(o)){let t=!0;for(const r of n)if(!r(e)){t=!1;break}t&&(yield{key:e.key.toString(),value:e.value,size:e.value.length})}}.bind(this),commit:async()=>Promise.resolve(),discard:async()=>Promise.resolve()};return r}}async function Tj(e,t,r){const n={prefix:t.toString()},o=await e.queryKeys(n),i=new Set;for await(const e of o)i.add(r(e));return Array.from(i).map((e=>function(e){try{return v.ThreadID.fromString(e)}catch{return}}(e))).filter(Boolean)}async function Dj(e,t,n){const o={prefix:t.toString()},i=e.queryKeys(o),s=new Set;for await(const e of i)s.add(n(e));return(await Promise.all(Array.from(s).map((async e=>{try{return await async function(e){try{return r.peerIdFromString(e)}catch{throw new Error("Invalid log ID format")}}(e)}catch{return null}})))).filter(Boolean)}function Rj(e,t){return t.child(new AI(e.toString()))}function jj(e,t,r){return r.child(new AI(e.toString())).child(new AI(t.toString()))}function Nj(e){return e<=0?new Error("Invalid varint"):null}function Uj(e){let t=0,r=0;for(let n=0;n<e.length;n++){const o=e[n];if(o<128)return n>9||9===n&&o>1?[0,-(n+1)]:[t|o<<r,n+1];t|=(127&o)<<r,r+=7}return[0,0]}function Kj(e){const[t,r,n]=function(e){const[t,r]=Uj(e);return[t,r,Nj(r)]}(e);if(n)return n;if(1!==t)return new Error(`expected 1 as the id version number, got: ${t}`);const[o,i]=Uj(e.subarray(r)),s=Nj(i);if(s)return s;if(0!==o&&1!==o)return new Error(`expected Raw or AccessControlled as the id variant, got: ${o}`);return 0===e.subarray(r+i).length?new Error("expected random id bytes but there are none"):null}const qj=new AI("/thread/keys"),Lj=new AI("/pub"),_j=new AI("/priv"),Mj=new AI("/read"),Fj=new AI("/service");class zj{constructor(e){this.ds=e}async pubKey(e,t){const r=jj(e,t,qj).child(Lj);try{const e=await this.ds.get(r);return n.keys.publicKeyFromRaw(e)}catch(e){if("ERR_NOT_FOUND"===e.code)return;throw new Error(`Error getting public key: ${e.message}`)}}async addPubKey(e,t,n){if(!n)throw new Error("Public key is null");if(!r.peerIdFromPublicKey(n).equals(t))throw new Error("Log ID doesn't match provided public key");const o=n.raw,i=jj(e,t,qj).child(Lj);await this.ds.put(i,o)}async privKey(e,t){const r=jj(e,t,qj).child(_j);try{const e=await this.ds.get(r);return n.keys.privateKeyFromRaw(e)}catch(e){if("ERR_NOT_FOUND"===e.code)return null;throw new Error(`Error getting private key: ${e.message}`)}}async addPrivKey(e,t,n){if(!n)throw new Error("Private key is null");if(!(await r.peerIdFromPrivateKey(n)).equals(t))throw new Error("Peer ID doesn't match private key");const o=n.raw,i=jj(e,t,qj).child(_j);await this.ds.put(i,o)}async readKey(e){const t=Rj(e,qj).child(Mj);try{const e=await this.ds.get(t);return await eR(e)}catch(e){if("ERR_NOT_FOUND"===e.code)return;throw new Error(`Error getting read key: ${e.message}`)}}async addReadKey(e,t){if(!t)throw new Error("Read key is null");const r=t.raw,n=Rj(e,qj).child(Mj);await this.ds.put(n,r)}async serviceKey(e){const t=Rj(e,qj).child(Fj);try{const e=await this.ds.get(t);return await eR(e)}catch(e){if("ERR_NOT_FOUND"===e.code)return;throw new Error(`Error getting service key: ${e.message}`)}}async addServiceKey(e,t){if(!t)throw new Error("Service key is null");const r=Rj(e,qj).child(Fj);await this.ds.put(r,t.raw)}async clearKeys(e){return this.clearKeysInternal(Rj(e,qj))}async clearLogKeys(e,t){const r=jj(e,t,qj);await this.ds.delete(r.child(_j)),await this.ds.delete(r.child(Lj))}async clearKeysInternal(e){const t={prefix:e.toString()};for await(const e of this.ds.query(t))await this.ds.delete(e.key)}async logsWithKeys(e){const t=qj.child(new AI(e.toString()));return Dj(this.ds,t,(e=>e.parent().name()))}async threadsFromKeys(){return Tj(this.ds,qj,(e=>e.parent().parent().name()))}async dumpKeys(){const e={data:{public:{},private:{},read:{},service:{}}},t={prefix:qj.toString()},r=this.ds.query(t);for await(const t of r){const r=new AI(t.key.toString()).list();if(r.length<4)throw new Error(`Invalid keybook key: ${t.key}`);const n=`/${r[r.length-1]}`;switch(n){case Lj.toString():this.processPublicKeyEntry(r,t.value,e);break;case _j.toString():this.processPrivateKeyEntry(r,t.value,e);break;case Mj.toString():this.processReadKeyEntry(r,t.value,e);break;case Fj.toString():this.processServiceKeyEntry(r,t.value,e);break;default:throw new Error(`Invalid key suffix: ${n}`)}}return e}processPublicKeyEntry(e,t,r){const[n,o]=e.slice(2,4);if(!n||!o)throw new Error(`Invalid namespaces for public key: ${e.join("/")}`);const i=function(e){var t,r;if(32===e.byteLength)return Za(e);if(33===e.byteLength)return Vu(e);var n=va(e),o=null===(t=n[1])||void 0===t?void 0:t[0];if(o===Pa||o===Ea||o===Ca)return Fa(n);if("1.2.840.113549.1.1.1"===(null===(r=n[0])||void 0===r?void 0:r[0]))return pu(n,e);throw new d.InvalidParametersError("Could not extract public key from raw bytes")}(t);r.data.public[n]||(r.data.public[n]={}),r.data.public[n][o]=i}processPrivateKeyEntry(e,t,r){const[n,o]=e.slice(2,4);if(!n||!o)throw new Error(`Invalid namespaces for private key: ${e.join("/")}`);const i=Yu(t);r.data.private[n]||(r.data.private[n]={}),r.data.private[n][o]=i}processReadKeyEntry(e,t,r){const[n]=e.slice(2,3);r.data.read[n]=Buffer.from(t)}processServiceKeyEntry(e,t,r){const[n]=e.slice(2,3);if(!n)throw new Error(`Invalid namespaces for service key: ${e.join("/")}`);r.data.service[n]=Buffer.from(t)}async restoreKeys(e){if(0===Object.keys(e.data.public).length&&0===Object.keys(e.data.private).length&&0===Object.keys(e.data.read).length&&0===Object.keys(e.data.service).length)throw new Error("Empty dump data");await this.clearKeysInternal(qj);for(const t in e.data.public)for(const n in e.data.public[t]){const o=e.data.public[t][n];o&&await this.addPubKey(v.ThreadID.fromString(t),r.peerIdFromPublicKey(o),o)}for(const t in e.data.private)for(const n in e.data.private[t]){const o=e.data.private[t][n];o&&await this.addPrivKey(v.ThreadID.fromString(t),r.peerIdFromPrivateKey(o),o)}for(const t in e.data.read){const r=e.data.read[t];if(!r)continue;const n=await eR(r);await this.addReadKey(v.ThreadID.fromString(t),n)}for(const t in e.data.service){const r=e.data.service[t];if(!r)continue;const n=await eR(r);await this.addServiceKey(v.ThreadID.fromString(t),n)}}}var Gj,Vj;class Hj extends U.Message{constructor(e){super(),Gj.set(this,[]),U.Message.initialize(this,Array.isArray(e)?e:[],0,-1,[3],xb(this,Gj,"f")),Array.isArray(e)||"object"!=typeof e||("threadID"in e&&null!=e.threadID&&(this.threadID=e.threadID),"peerID"in e&&null!=e.peerID&&(this.peerID=e.peerID),"addrs"in e&&null!=e.addrs&&(this.addrs=e.addrs))}get threadID(){return U.Message.getFieldWithDefault(this,1,new Uint8Array)}set threadID(e){U.Message.setField(this,1,e)}get peerID(){return U.Message.getFieldWithDefault(this,2,new Uint8Array)}set peerID(e){U.Message.setField(this,2,e)}get addrs(){return U.Message.getRepeatedWrapperField(this,Hj.AddrEntry,3)}set addrs(e){U.Message.setRepeatedWrapperField(this,3,e)}static fromObject(e){const t=new Hj({});return null!=e.threadID&&(t.threadID=e.threadID),null!=e.peerID&&(t.peerID=e.peerID),null!=e.addrs&&(t.addrs=e.addrs.map((e=>Hj.AddrEntry.fromObject(e)))),t}toObject(){const e={};return null!=this.threadID&&(e.threadID=this.threadID),null!=this.peerID&&(e.peerID=this.peerID),null!=this.addrs&&(e.addrs=this.addrs.map((e=>e.toObject()))),e}serialize(e){const t=e||new U.BinaryWriter;if(this.threadID.length&&t.writeBytes(1,this.threadID),this.peerID.length&&t.writeBytes(2,this.peerID),this.addrs.length&&t.writeRepeatedMessage(3,this.addrs,(e=>e.serialize(t))),!e)return t.getResultBuffer()}static deserialize(e){const t=e instanceof U.BinaryReader?e:new U.BinaryReader(e),r=new Hj;for(;t.nextField()&&!t.isEndGroup();)switch(t.getFieldNumber()){case 1:r.threadID=t.readBytes();break;case 2:r.peerID=t.readBytes();break;case 3:t.readMessage(r.addrs,(()=>U.Message.addToRepeatedWrapperField(r,3,Hj.AddrEntry.deserialize(t),Hj.AddrEntry)));break;default:t.skipField()}return r}serializeBinary(){return this.serialize()}static deserializeBinary(e){return Hj.deserialize(e)}}Gj=new WeakMap,function(e){var t;class r extends U.Message{constructor(e){super(),t.set(this,[]),U.Message.initialize(this,Array.isArray(e)?e:[],0,-1,[],xb(this,t,"f")),Array.isArray(e)||"object"!=typeof e||("addr"in e&&null!=e.addr&&(this.addr=e.addr),"expiry"in e&&null!=e.expiry&&(this.expiry=e.expiry),"ttl"in e&&null!=e.ttl&&(this.ttl=e.ttl))}get addr(){return U.Message.getFieldWithDefault(this,1,new Uint8Array)}set addr(e){U.Message.setField(this,1,e)}get expiry(){return U.Message.getFieldWithDefault(this,2,0)}set expiry(e){U.Message.setField(this,2,e)}get ttl(){return U.Message.getFieldWithDefault(this,3,0)}set ttl(e){U.Message.setField(this,3,e)}static fromObject(e){const t=new r({});return null!=e.addr&&(t.addr=e.addr),null!=e.expiry&&(t.expiry=e.expiry),null!=e.ttl&&(t.ttl=e.ttl),t}toObject(){const e={};return null!=this.addr&&(e.addr=this.addr),null!=this.expiry&&(e.expiry=this.expiry),null!=this.ttl&&(e.ttl=this.ttl),e}serialize(e){const t=e||new U.BinaryWriter;if(this.addr.length&&t.writeBytes(1,this.addr),0!=this.expiry&&t.writeInt64(2,this.expiry),0!=this.ttl&&t.writeInt64(3,this.ttl),!e)return t.getResultBuffer()}static deserialize(e){const t=e instanceof U.BinaryReader?e:new U.BinaryReader(e),n=new r;for(;t.nextField()&&!t.isEndGroup();)switch(t.getFieldNumber()){case 1:n.addr=t.readBytes();break;case 2:n.expiry=t.readInt64();break;case 3:n.ttl=t.readInt64();break;default:t.skipField()}return n}serializeBinary(){return this.serialize()}static deserializeBinary(e){return r.deserialize(e)}}t=new WeakMap,e.AddrEntry=r}(Hj||(Hj={}));class Wj extends U.Message{constructor(e){super(),Vj.set(this,[]),U.Message.initialize(this,Array.isArray(e)?e:[],0,-1,[1],xb(this,Vj,"f")),Array.isArray(e)||"object"!=typeof e||"heads"in e&&null!=e.heads&&(this.heads=e.heads)}get heads(){return U.Message.getRepeatedWrapperField(this,Wj.HeadEntry,1)}set heads(e){U.Message.setRepeatedWrapperField(this,1,e)}static fromObject(e){const t=new Wj({});return null!=e.heads&&(t.heads=e.heads.map((e=>Wj.HeadEntry.fromObject(e)))),t}toObject(){const e={};return null!=this.heads&&(e.heads=this.heads.map((e=>e.toObject()))),e}serialize(e){const t=e||new U.BinaryWriter;if(this.heads.length&&t.writeRepeatedMessage(1,this.heads,(e=>e.serialize(t))),!e)return t.getResultBuffer()}static deserialize(e){const t=e instanceof U.BinaryReader?e:new U.BinaryReader(e),r=new Wj;for(;t.nextField()&&!t.isEndGroup();)if(1===t.getFieldNumber())t.readMessage(r.heads,(()=>U.Message.addToRepeatedWrapperField(r,1,Wj.HeadEntry.deserialize(t),Wj.HeadEntry)));else t.skipField();return r}serializeBinary(){return this.serialize()}static deserializeBinary(e){return Wj.deserialize(e)}}Vj=new WeakMap,function(e){var t;class r extends U.Message{constructor(e){super(),t.set(this,[]),U.Message.initialize(this,Array.isArray(e)?e:[],0,-1,[],xb(this,t,"f")),Array.isArray(e)||"object"!=typeof e||("cid"in e&&null!=e.cid&&(this.cid=e.cid),"counter"in e&&null!=e.counter&&(this.counter=e.counter))}get cid(){return U.Message.getFieldWithDefault(this,1,new Uint8Array)}set cid(e){U.Message.setField(this,1,e)}get counter(){return U.Message.getFieldWithDefault(this,2,0)}set counter(e){U.Message.setField(this,2,e)}static fromObject(e){const t=new r({});return null!=e.cid&&(t.cid=e.cid),null!=e.counter&&(t.counter=e.counter),t}toObject(){const e={};return null!=this.cid&&(e.cid=this.cid),null!=this.counter&&(e.counter=this.counter),e}serialize(e){const t=e||new U.BinaryWriter;if(this.cid.length&&t.writeBytes(1,this.cid),0!=this.counter&&t.writeInt64(2,this.counter),!e)return t.getResultBuffer()}static deserialize(e){const t=e instanceof U.BinaryReader?e:new U.BinaryReader(e),n=new r;for(;t.nextField()&&!t.isEndGroup();)switch(t.getFieldNumber()){case 1:n.cid=t.readBytes();break;case 2:n.counter=t.readInt64();break;default:t.skipField()}return n}serializeBinary(){return this.serialize()}static deserializeBinary(e){return r.deserialize(e)}}t=new WeakMap,e.HeadEntry=r}(Wj||(Wj={}));const{Buffer:Jj}=Rr,$j=2n**64n;var Yj;!function(e){e[e.Override=0]="Override",e[e.Extend=1]="Extend"}(Yj||(Yj={}));class Zj{constructor(e,t){this.opts=t,this.ds=e,this.cache=new A.LRUCache({max:t.CacheSize||0})}async addAddr(e,t,r,n){if(n<=0)return;const o=this.cleanAddrs([r]);await this.setAddrs(e,t,o,n)}async addAddrs(e,t,r,n){if(n<=0)return;const o=this.cleanAddrs(r);await this.setAddrs(e,t,o,n)}cleanAddrs(t){return t.reduce(((t,r)=>{try{if(!r)return t;const n="string"==typeof r?e.multiaddr(r):e.isMultiaddr(r)?r:null;return n?[...t,n]:t}catch{return t}}),[])}async setAddr(e,t,r,n){if(n<=0)return;const o=this.cleanAddrs([r]);await this.setAddrs(e,t,o,n)}async setAddrs(e,t,r,n){let o=()=>{};try{const i=await this.loadRecord(e,t.toString(),!0,!1);o=await i.lock.acquire();const s=Date.now()+n,a=new Array(r.length).fill(!1);e:for(const[e,t]of r.entries())for(const r of i.data.addrs)if(0===N.compare(t.bytes,r.addr)){a[e]=!0,r.ttl=n,r.expiry=s;continue e}const c=r.filter(((e,t)=>!a[t])).map((e=>new Hj.AddrEntry({addr:e.bytes,expiry:s,ttl:n})));i.data.addrs.push(...c),i.dirty=!0,await this.cleanRecord(i),await this.flushRecord(i),await this.invalidateEdge(e)}finally{o()}}async updateAddrs(e,t,r,n){let o=()=>{};try{const i=await this.loadRecord(e,t.toString(),!0,!1);o=await i.lock.acquire();const s=Date.now()+n;for(const e of i.data.addrs)e.ttl===r&&(e.ttl=n,e.expiry=s,i.dirty=!0);await this.cleanRecord(i),await this.flushRecord(i),await this.invalidateEdge(e)}finally{o()}}async addrs(t,r){let n=()=>{};try{const o=await this.loadRecord(t,r.toString(),!0,!0);n=await o.lock.acquire();const i=[];for(const t of o.data.addrs)i.push(e.multiaddr(t.addr));return i}finally{n()}}async clearAddrs(e,t){this.cache.delete({threadID:e,peerID:t.toString()});const r=this.genDSKey(e,t.toString());try{await this.ds.delete(r),await this.invalidateEdge(e)}catch(e){throw new Error(`Failed to clear addresses for log ${t.toString()}: ${e.message}`)}}async logsWithAddrs(e){try{return await Dj(this.ds,Zj.logBookBase.child(new AI(e.toString())),(e=>e.name()))}catch(e){throw new Error(`Error while retrieving logs with addresses: ${e.message}`)}}async threadsFromAddrs(){try{return await Tj(this.ds,Zj.logBookBase,(e=>e.parent().name()))}catch(e){throw new Error(`Error while retrieving thread from addresses: ${e.message}`)}}async addrsEdge(e,t){const r=Rj(e,Zj.logBookEdge);for(let n=1;n<=3;n++)try{return await this.calculateEdge(e,r,t)}catch(e){if("TX_CONFLICT"!==e.code)throw e;await this.randomDelay(n)}throw new Error("Edge computation failed")}async calculateEdge(e,t,r){return this.withTransaction((async n=>{try{const e=await n.get(t);if(e)return this.decodeStoredEdge(e)}catch(e){if("ERR_NOT_FOUND"!==e.code)throw e}const o=await this.collectAddrs(n,e,r);if(0===o.length)throw new Error("Thread not found");const i=this.computeAddrsEdge(o),s=Jj.alloc(8);return this.writeEdgeValue(s,i),await n.put(t,s),i}))}async collectAddrs(e,t,r){const n={prefix:Rj(t,Zj.logBookBase).toString()},o=e.query(n),i=Date.now(),s=[];for await(const e of o){const t=e.key,n={key:t instanceof AI?t:new AI(t.toString()),value:e.value},{tid:o,pid:a,record:c}=this.decodeAddrEntry(n,!0);if(c&&(!r||a.toString()!=r))for(const e of c.addrs)e.expiry>i&&s.push({peerID:a,addr:e.addr})}return s}async withTransaction(e){const t=await this.ds.newTransactionExtended(!1);try{const r=await e(t);return await t.commit(),r}catch(e){throw t.discard(),e}}decodeStoredEdge(e){const t=Jj.from(e),r=t;if(t.length>=8&&"function"==typeof r.readBigUInt64BE)return r.readBigUInt64BE(0);if(t.length>=4)return BigInt(t.readUInt32BE(0));throw new Error("Corrupted head edge value")}writeEdgeValue(e,t){const r=e;"function"!=typeof r.writeBigUInt64BE?e.writeUInt32BE(Number(0xffffffffn&t),0):r.writeBigUInt64BE(t,0)}randomDelay(e){const t=50*e+30*Math.random();return new Promise((e=>setTimeout(e,t)))}async loadRecord(e,t,r,n){const o={threadID:e,peerID:t};if(this.cache.has(o)){const e=this.cache.get(o);return await this.cleanRecord(e),n&&await this.flushRecord(e),e}const i=this.genDSKey(e,t);try{const e=await this.ds.get(i),t=Hj.deserialize(e),s={lock:new Qj,data:t,dirty:!1};return await this.cleanRecord(s),n&&await this.flushRecord(s),r?(this.cache.set(o,s),s):s}catch(r){if("ERR_NOT_FOUND"===r.code){const r=(new TextEncoder).encode(t);return{lock:new Qj,data:Hj.fromObject({threadID:e.toBytes(),peerID:r,addrs:[]}),dirty:!1}}throw r}}async cleanRecord(e){const t=Date.now(),r=e.data.addrs.filter((e=>e.expiry>t)),n=r.length!==e.data.addrs.length;return e.data.addrs=r.sort(((e,t)=>e.expiry-t.expiry)),n}async flushRecord(e){const t=v.ThreadID.fromBytes(e.data.threadID),r=(new TextDecoder).decode(e.data.peerID);if(0===e.data.addrs.length)await this.ds.delete(this.genDSKey(t,r));else{const n=e.data.serialize();await this.ds.put(this.genDSKey(t,r),n)}e.dirty=!1}genDSKey(e,t){const r=new AI(e.toString()),n=new AI(t);return Zj.logBookBase.child(r).child(n)}async invalidateEdge(e){var t=Rj(e,Zj.logBookEdge);return this.ds.delete(t)}async traverse(e){const t={};let r=this.ds.query({prefix:Zj.logBookBase.toString()});for await(const n of r){const{tid:r,pid:o,record:i}=this.decodeAddrEntry(n,e),s=r.toString();t[s]||(t[s]={}),t[s][o.toString()]=i}return t}decodeAddrEntry(e,t){const n="string"==typeof e.key?e.key:e.key.toString(),o=n.split("/");if(o.length<3)throw new Error(`bad addressbook key detected: ${n}`);const i=o[o.length-2],s=o[o.length-1],a=v.ThreadID.fromString(i),c=r.peerIdFromString(s);if(t){return{tid:a,pid:c,record:Hj.deserialize(e.value)}}return{tid:a,pid:c}}computeAddrsEdge(e){const t=e.map((e=>({peerIDBytes:this.decodePeerId(e.peerID.toString(),new TextEncoder),addr:e.addr})));t.sort(((e,t)=>{const r=N.compare(e.peerIDBytes,t.peerIDBytes);return 0!==r?r:N.compare(e.addr,t.addr)}));let r=14695981039346656037n;for(const e of t)r=this.fnv1a64(e.peerIDBytes,r),r=this.fnv1a64(e.addr,r);return r}decodePeerId(e,t){if(!e)return new Uint8Array;try{return ua.base58btc.baseDecode(e)}catch(r){return t.encode(e)}}fnv1a64(e,t){let r=t;for(const t of e)r^=BigInt(t),r=1099511628211n*r%$j;return r}async dumpAddrs(){const t={},r=await this.traverse(!0);for(const[n,o]of Object.entries(r)){const r={};for(const[t,n]of Object.entries(o))if(n.addrs.length>0){const o=n.addrs.map((t=>({addr:e.multiaddr(t.addr),expires:new Date(t.expiry)})));r[t]=o.map((e=>({addr:e.addr,expires:e.expires})))}t[n]=r}return{data:t}}async restoreAddrs(t){if(0===Object.keys(t.data).length)throw new Error("Empty dump");const n=await this.traverse(!1);for(const[e,t]of Object.entries(n))for(const n of Object.keys(t))await this.clearAddrs(v.ThreadID.fromString(e),r.peerIdFromString(n));const o=new Date;for(const[n,i]of Object.entries(t.data))for(const[t,s]of Object.entries(i))for(const i of s){const s=i.expires.getTime()-o.getTime();s>0&&await this.setAddrs(v.ThreadID.fromString(n),r.peerIdFromString(t),[e.multiaddr(i.addr)],s)}}}Zj.logBookBase=new AI("/thread/addrs"),Zj.logBookEdge=new AI("/thread/addrs:edge");let Qj=class{constructor(){this.queue=[],this.locked=!1}async acquire(){for(;this.locked;)await new Promise((e=>this.queue.push(e)));return this.locked=!0,()=>{this.locked=!1;const e=this.queue.shift();e?.()}}};async function Xj(){return{counter:0}}function eN(e){return JSON.stringify({heads:e.heads.map((e=>({id:e.id?.toString(),counter:e.counter})))})}function tN(e){return{heads:JSON.parse(e).heads.map((e=>({id:fs.parse(e.id),counter:Number(e.counter)})))}}const{Buffer:rN}=Rr,nN=new AI("/thread/heads"),oN=new AI("/thread/heads:edge"),iN=2n**64n;class sN{constructor(e){this.ds=e}async addHead(e,t,r){return this.addHeads(e,t,[r])}async addHeads(e,t,r){return this.withTransaction((async n=>{const o=jj(e,t,nN);let i=await this.getHeadsRecord(n,o);i||(i={heads:[]});const s={heads:this.mergeHeads(i,r)};await this.saveRecord(n,o,s),await this.invalidateEdge(n,e)}))}async setHead(e,t,r){return this.setHeads(e,t,[r])}async setHeads(e,t,r){const n=await this.ds.newTransactionExtended(!1);try{const o=jj(e,t,nN),i={heads:[]};for(const e of r)e.id&&i.heads.push({id:e.id,counter:e.counter});const s=eN(i),a=(new TextEncoder).encode(s);await n.put(o,a),await this.invalidateEdge(n,e),await n.commit()}catch(e){throw n.discard(),new Error(`Error when setting heads: ${e.message}`)}}async heads(e,t){const r=jj(e,t,nN);try{const e=await this.ds.get(r);if(!e)return[];return tN((new TextDecoder).decode(e)).heads.map((e=>({...e.id?{id:e.id}:{},counter:e.counter})))}catch(e){if("ERR_NOT_FOUND"===e.code)return[];throw new Error(`Error when getting current heads from log ${r}: ${e.message}`)}}async clearHeads(e,t){const r=await this.ds.newTransactionExtended(!1);try{const n=jj(e,t,nN);await r.delete(n),await this.invalidateEdge(r,e),await r.commit()}catch(e){throw r.discard(),new Error(`Error when clearing heads: ${e.message}`)}}async withTransaction(e){const t=await this.ds.newTransactionExtended(!1);try{const r=await e(t);return await t.commit(),r}catch(e){throw t.discard(),e}}async getHeadsRecord(e,t){try{const r=await e.get(t);return r?tN((new TextDecoder).decode(r)):null}catch(e){if("ERR_NOT_FOUND"===e.code)return null;throw e}}mergeHeads(e,t){const r=new Set(e.heads.map((e=>e.id?.toString())));return[...e.heads,...t.filter((e=>!r.has(e.id?.toString())))]}async saveRecord(e,t,r){const n=eN(r),o=(new TextEncoder).encode(n);await e.put(t,o)}async headsEdge(e,t=3){const r=Rj(e,oN);for(let n=1;n<=t;n++)try{return await this.calculateEdge(e,r)}catch(e){if("TX_CONFLICT"!==e.code)throw e;await this.randomDelay(n)}throw new Error("Edge computation failed")}async calculateEdge(e,t){return this.withTransaction((async r=>{try{const e=await r.get(t);if(e)return this.decodeStoredEdge(e)}catch(e){if("ERR_NOT_FOUND"!==e.code)throw e}const n=await this.collectHeads(r,e);if(0===n.length)throw new Error("Thread not found");const o=this.computeHeadsEdge(n),i=rN.alloc(8);return this.writeEdgeValue(i,o),await r.put(t,i),o}))}async collectHeads(e,t){const r={prefix:Rj(t,nN).toString()},n=e.query(r),o=[];for await(const e of n){const t=e.key,r=(t instanceof AI?t:new AI(t)).namespaces(),n=r[r.length-1];if(!n)continue;const i=tN((new TextDecoder).decode(e.value));for(const e of i.heads)0!==e.counter&&o.push({logId:n,head:{...e.id?{id:e.id}:{},counter:e.counter}})}return o}computeHeadsEdge(e){const t=[...e].sort(((e,t)=>e.logId===t.logId?this.compareCidBytes(e.head.id?.bytes,t.head.id?.bytes):e.logId.localeCompare(t.logId))),r=new TextEncoder;let n=14695981039346656037n;for(const e of t){const t=this.decodeLogId(e.logId,r);n=this.fnv1a64(t,n);const o=e.head.id?.bytes??new Uint8Array;n=this.fnv1a64(o,n)}return n}compareCidBytes(e,t){const r=e??new Uint8Array,n=t??new Uint8Array,o=Math.min(r.length,n.length);for(let e=0;e<o;e++)if(r[e]!==n[e])return r[e]-n[e];return r.length-n.length}decodeLogId(e,t){if(!e)return new Uint8Array;try{return ua.base58btc.baseDecode(e)}catch(r){return t.encode(e)}}fnv1a64(e,t){let r=t;for(const t of e)r^=BigInt(t),r=1099511628211n*r%iN;return r}async invalidateEdge(e,t){const r=Rj(t,oN);await e.delete(r)}decodeStoredEdge(e){const t=rN.from(e),r=t;if(t.length>=8&&"function"==typeof r.readBigUInt64BE)return r.readBigUInt64BE(0);if(t.length>=4)return BigInt(t.readUInt32BE(0));throw new Error("Corrupted head edge value")}writeEdgeValue(e,t){const r=e;"function"!=typeof r.writeBigUInt64BE?e.writeUInt32BE(Number(0xffffffffn&t),0):r.writeBigUInt64BE(t,0)}randomDelay(e){const t=50*e+30*Math.random();return new Promise((e=>setTimeout(e,t)))}async dumpHeads(){return{data:await this.traverse(!0)}}async restoreHeads(e){if(0===Object.keys(e.data).length)throw new Error("Empty dump");const t=await this.traverse(!1);for(const e in t)for(const r in t[e])await this.clearHeads(e,r);for(const t in e.data)for(const r in e.data[t])await this.setHeads(t,r,e.data[t][r])}async traverse(e){const t={},r=this.ds.query({prefix:nN.toString()});for await(const n of r){const{tid:r,lid:o,heads:i}=await this.decodeHeadEntry(n,e);t[r]||(t[r]={}),t[r][o]=i}return t}async decodeHeadEntry(e,t){const r=e.key.namespaces();if(r.length<3)throw new Error(`bad headbook key detected: ${e.key}`);const n=r[r.length-2],o=r[r.length-1];let i=[];if(t){i=tN((new TextDecoder).decode(e.value)).heads.map((e=>({...e.id?{id:e.id}:{},counter:e.counter})))}return{tid:n,lid:o,heads:i}}}const aN=new AI("/thread/meta");class cN{constructor(e){this.ds=e}async getInt64(e,t){return this.getValue(e,t)}async putInt64(e,t,r){return this.setValue(e,t,r)}async getString(e,t){return this.getValue(e,t)}async putString(e,t,r){return this.setValue(e,t,r)}async getBool(e,t){return this.getValue(e,t)}async putBool(e,t,r){return this.setValue(e,t,r)}async getBytes(e,t){const r=this.keyMeta(e,t);try{return await this.ds.get(r)}catch(e){if("ERR_NOT_FOUND"===e.code)return null;throw new Error(`Error getting metadata: ${e.message}`)}}async putBytes(e,t,r){const n=this.keyMeta(e,t);try{await this.ds.put(n,r)}catch(e){throw new Error(`Error setting metadata: ${e.message}`)}}keyMeta(e,t){const r=e.toString();return aN.child(new AI(r)).child(new AI(t))}async getValue(e,t){const r=this.keyMeta(e,t);try{const e=await this.ds.get(r);return this.decodeValue(e)}catch(e){if("ERR_NOT_FOUND"===e.code)return null;throw new Error(`Error getting metadata: ${e.message}`)}}async setValue(e,t,r){const n=this.keyMeta(e,t),o=this.encodeValue(r);try{await this.ds.put(n,o)}catch(e){throw new Error(`Error setting metadata: ${e.message}`)}}async clearMetadata(e){const t=aN.child(new AI(e.toString())).toString();return this.clearKeys(t)}async dumpMeta(){const e={data:{bool:{},int64:{},string:{},bytes:{}}},t=this.ds.query({prefix:aN.toString()});try{for await(const r of t){const t=new AI(r.key.toString()).list();if(t.length<4)throw new Error(`Bad metabook key: ${r.key}`);const[,,n,o]=t,i={t:this.parseThreadID(n),k:o},s=await this.decodeAnyValue(r.value);this.storeDecodedValue(e,i,s)}}catch(e){throw new Error(`Error dumping metadata: ${e.message}`)}return e}async restoreMeta(e){if(0===Object.keys(e.data.bool).length+Object.keys(e.data.int64).length+Object.keys(e.data.string).length+Object.keys(e.data.bytes).length)throw new Error("Empty metadata dump");await this.clearKeys(aN.toString());const t=[...Object.entries(e.data.bool),...Object.entries(e.data.int64),...Object.entries(e.data.string),...Object.entries(e.data.bytes)];for(const[e,r]of t){const t=JSON.parse(e);await this.setValue(t.t,t.k,r)}}async clearKeys(e){const t=this.ds.queryKeys({prefix:e});try{for await(const e of t)await this.ds.delete(e)}catch(e){throw new Error(`Error clearing keys: ${e.message}`)}}decodeValue(e){try{const t=new TextDecoder;return JSON.parse(t.decode(e))}catch(e){throw new Error(`Value decoding failed: ${e.message}`)}}encodeValue(e){try{return(new TextEncoder).encode(JSON.stringify(e))}catch(e){throw new Error(`Value encoding failed: ${e.message}`)}}parseThreadID(e){try{return v.ThreadID.fromString(e)}catch(t){throw new Error(`Invalid thread ID: ${e}`)}}storeDecodedValue(e,t,r){switch(typeof r){case"boolean":e.data.bool[t.t.toString()]=e.data.bool[t.t.toString()]||{},e.data.bool[t.t.toString()][t.k]=r;break;case"number":e.data.int64[t.t.toString()]=e.data.int64[t.t.toString()]||{},e.data.int64[t.t.toString()][t.k]=r;break;case"string":e.data.string[t.t.toString()]=e.data.string[t.t.toString()]||{},e.data.string[t.t.toString()][t.k]=r;break;default:if(!(r instanceof Uint8Array))throw new Error(`Unsupported value type for key: ${t.k}`);e.data.bytes[t.t.toString()]=e.data.bytes[t.t.toString()]||{},e.data.bytes[t.t.toString()][t.k]=r}}async decodeAnyValue(e){try{return this.decodeValue(e)}catch{return e}}}const uN=500,lN={code:406,name:"thread",version:"0.0.1",resolvable:!1,path:!1,size:-1},dN=-1;[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,dN,"ip6zone"],[43,8,"ipcidr"],[53,dN,"dns",!0],[54,dN,"dns4",!0],[55,dN,"dns6",!0],[56,dN,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,dN,"unix",!1,!0],[421,dN,"ipfs"],[421,dN,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,dN,"garlic64"],[448,0,"tls"],[449,dN,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,dN,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,dN,"http-path"],[777,dN,"memory"]].forEach((t=>{const r=function(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(o)}}(...t);try{e.registry.getProtocol(r.code)||e.registry.addProtocol(r)}catch(t){e.registry.addProtocol(r)}}));try{e.registry.getProtocol(lN.code)||e.registry.addProtocol(lN)}catch(t){e.registry.addProtocol(lN)}class hN{constructor(e,t,r){this.record=e,this._threadID=t,this._logID=r}value(){return this.record}threadID(){return this._threadID}logID(){return this._logID}}class pN{constructor(e){Object.assign(this,e)}}class yN{constructor(e,t){this.id=t,this.addr=e}getMultiaddrString(){const e=this.addr.toString(),t=this.id.toString();return e+"/"+lN.name+"/"+t}}class fN{constructor(e,t,r,n){this.id=e,this.logs=t,this.addrs=r,this.key=n||void 0}getFirstPrivKeyLog(){for(const e of this.logs)if(e.privKey)return e}}const gN={ErrDBNotFound:new Error("db not found"),ErrDBExists:new Error("db already exists"),ErrInvalidName:new Error("invalid name"),ErrThreadReadKeyRequired:new Error("thread read key required"),ErrorThreadIDValidation:new Error("thread id validation error"),ErrThreadNotFound:new Error("thread not found"),ErrLogNotFound:new Error("log not found"),ErrLogExists:new Error("log already exists"),ErrP2pNetworkNotInit:new Error("p2p network not initialized"),ErrNoDbManager:new Error("no db manager"),ErrNoDcPeerConnected:new Error("no dc peer connected"),ErrInvalidCollectionSchema:new Error("the collection schema _id property must be a string"),ErrCannotIndexIDField:new Error("cannot create custom index "),ErrCollectionNotFound:new Error("collection not found"),ErrNodeAddrIsNull:new Error("node address is null"),ErrNoThreadOnDc:new Error("no thread on dc"),ErrNoDcNodeClient:new Error("no dc node client"),ErrFileNotFound:new Error("file not found")},bN=36e5,mN=new AI("/db"),wN={dsPrefix:mN,dsName:mN.child(new AI("name")),dsSchemas:mN.child(new AI("schema")),dsIndexes:mN.child(new AI("index")),dsValidators:mN.child(new AI("validator")),dsFilters:mN.child(new AI("filter")),dsVerno:mN.child(new AI("verno"))},vN="_id";var kN;!function(e){e[e.Create=0]="Create",e[e.Save=1]="Save",e[e.Delete=2]="Delete"}(kN||(kN={}));const SN=2**53-1,ON="/managed";class AN{constructor(e,t,r,n){this.keyBook=e,this.addrBook=t,this.headBook=r,this.metadata=n,this.mutex=new I.Mutex}async close(){const e=[],t=async(t,r)=>{if(r&&"function"==typeof r.close)try{await r.close()}catch(r){e.push(new Error(`${t} error: ${r}`))}};if(await t("keybook",this.keyBook),await t("addressbook",this.addrBook),await t("headbook",this.headBook),await t("threadmetadata",this.metadata),e.length>0)throw new Error(`failed while closing logstore; err(s): ${e.map((e=>e.message)).join(", ")}`)}async threads(){return this.mutex.runExclusive((async()=>{const e=new Set;(await this.keyBook.threadsFromKeys()).forEach((t=>e.add(t)));return(await this.addrBook.threadsFromAddrs()).forEach((t=>e.add(t))),Array.from(e)}))}async addThread(e){if(!e.key?.service())throw new Error("a service-key is required to add a thread");const t=await this.keyBook.serviceKey(e.id),r=await(e.key.service()?.toSymKey());if(t){if(!r||!_r(r.raw,t.raw))throw new Error("service-key mismatch")}else{if(!r)throw new Error("service-key is required");await this.keyBook.addServiceKey(e.id,r)}if(e.key.canRead()){const t=await this.keyBook.readKey(e.id),r=await(e.key.read()?.toSymKey());if(t){if(!r||!_r(r.raw,t.raw))throw new Error("read-key mismatch")}else{if(!r)throw new Error("read-key is required");await this.keyBook.addReadKey(e.id,r)}}}async getThread(e){const t=await this.keyBook.serviceKey(e);if(!t)throw gN.ErrThreadNotFound;const r=await this.keyBook.readKey(e),n=await this.getLogIDs(e),o=[];for(const t of n)try{const r=await this.getLog(e,t);o.push(r)}catch(e){}let i=new lR(uR.fromSymKey(t));r&&(i=new lR(uR.fromSymKey(t),uR.fromSymKey(r)));return new fN(e,o,[],i)}async getLogIDs(e){const t=new Set;(await this.keyBook.logsWithKeys(e)).forEach((e=>t.add(e)));return(await this.addrBook.logsWithAddrs(e)).forEach((e=>t.add(e))),t}async deleteThread(e){await this.keyBook.clearKeys(e),await this.metadata.clearMetadata(e);const t=await this.getLogIDs(e);for(const r of t)await this.addrBook.clearAddrs(e,r),await this.headBook.clearHeads(e,r)}async addLog(e,t){if(t.privKey){if(await this.keyBook.privKey(e,t.id))throw gN.ErrLogExists;await this.keyBook.addPrivKey(e,t.id,t.privKey)}if(!t.pubKey)throw new Error("public key is required");await this.keyBook.addPubKey(e,t.id,t.pubKey),await this.addrBook.addAddrs(e,t.id,t.addrs,SN),t.head&&await this.headBook.setHead(e,t.id,t.head),(t.managed||t.privKey)&&await this.metadata.putBool(e,t.id.toString()+ON,!0)}async getLog(e,t){return this.getLogInternal(e,t)}async getLogInternal(e,t){const r=await this.keyBook.pubKey(e,t);if(!r)throw gN.ErrLogNotFound;const n=await this.keyBook.privKey(e,t),o=await this.addrBook.addrs(e,t),i=await this.headBook.heads(e,t),s=await this.metadata.getBool(e,t.toString()+ON);return{id:t,pubKey:r,...n?{privKey:n}:{},addrs:o,...i.length>0?{head:i[0]}:{},managed:s||!1}}async getManagedLogs(e){const t=await this.keyBook.logsWithKeys(e),r=[];for(const n of t){const t=await this.getLog(e,n);(t.managed||t.privKey)&&r.push(t)}return r}async deleteLog(e,t){return this.mutex.runExclusive((async()=>{await this.keyBook.clearLogKeys(e,t),await this.addrBook.clearAddrs(e,t),await this.headBook.clearHeads(e,t)}))}}const IN={ErrNoSuchLink:new Error("no such link found"),ErrNonLink:new Error("non-link found at given path"),ErrInvalidLink:new Error("link value should have been bytes"),ErrInvalidKeys:new Error("map keys must be strings"),ErrArrayOutOfRange:new Error("array index out of range"),ErrNoLinks:new Error("tried to resolve through object that had no links"),ErrEmptyLink:new Error("link value was empty"),ErrInvalidMultibase:new Error("invalid multibase on IPLD link"),ErrNonStringLink:new Error("link should have been a string")};class xN{constructor(e,t){this._data=e,this._cid=t}data(){return this._data}cid(){return this._cid}}class PN{constructor(e,t,r,n,o){this._obj=e,this._tree=t,this._links=r,this._raw=n,this._cid=o}resolve(e){let t=this._obj;for(let r=0;r<e.length;r++){const n=e[r];if("object"!=typeof t||null===t)return[null,null,IN.ErrNoLinks];if(Array.isArray(t)){const e=parseInt(n);if(isNaN(e))return[null,null,new Error("array index was not a number")];if(e<0||e>=t.length)return[null,null,IN.ErrArrayOutOfRange];t=t[e]}else{if(DN(t))return[{cid:t},e.slice(r),null];{const e=t[n];if(void 0===e)return[null,null,IN.ErrNoSuchLink];t=e}}}if(DN(t))return[{cid:t},null,null];try{return[this.convertToJSONIsh(t),null,null]}catch(e){return[null,null,e]}}resolveLink(e){try{const[t,r,n]=this.resolve(e);return n?[null,null,n]:t&&t.cid&&DN(t.cid)?[t,r,null]:[null,r,IN.ErrNonLink]}catch(e){return[null,null,e]}}tree(e,t){if(""===e&&-1===t)return[...this._tree];const r=[];for(const n of this._tree){if(!n.startsWith(e))continue;const o=n.substring(e.length).replace(/^\/+/,"");if(""===o)continue;if(t<0){r.push(o);continue}o.split("/").length<=t&&r.push(o)}return r}links(){return[...this._links]}rawData(){return new Uint8Array(this._raw)}data(){return new Uint8Array(this._raw)}cid(){return this._cid}loggable(){return{node_type:"cbor",cid:this.cid.toString()}}size(){return this._raw.length}stat(){return{}}toString(){return this.cid.toString()}toJSON(){return this.convertToJSONIsh(this._obj)}copy(){const e=[...this._links],t=new Uint8Array(this._raw),r=[...this._tree];return new PN(this.copyObj(this._obj),r,e,t,this._cid)}copyObj(e){if(null==e)return e;if(Array.isArray(e))return e.map((e=>this.copyObj(e)));if("object"==typeof e){if(DN(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=this.copyObj(n);return t}return e}convertToJSONIsh(e){if(null==e)return e;if(Array.isArray(e))return 0===e.length?[]:e.map((e=>this.convertToJSONIsh(e)));if("object"==typeof e){if(DN(e))return{"/":e.toString()};const t={};for(const[r,n]of Object.entries(e))t[r]=this.convertToJSONIsh(n);return t}return e}}async function EN(e,t="sha2-256"){const r=K.decode(e);return await CN(r)}async function CN(e){try{const t=K.encode(e),r=await sa.digest(t),n=fs.createV1(K.code,r),o=new xN(t,n),i=structuredClone(e)||BN(e);return await async function(e,t){try{const[r,n]=await async function(e){const t=[],r=[];return await TN(e,"",((e,n)=>(""!==e&&t.push(e.substring(1)),n&&DN(n)&&r.push(n),null))),[t,r]}(t);return new PN(t,r,n,e.data(),e.cid())}catch(e){throw new Error(`Failed to create node: ${e instanceof Error?e.message:String(e)}`)}}(o,i)}catch(e){throw new Error(`Failed to wrap object: ${e instanceof Error?e.message:String(e)}`)}}function BN(e){if(null==e)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e).buffer;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(Array.isArray(e))return e.map((e=>BN(e)));if("object"==typeof e&&!DN(e)){const t={};for(const[r,n]of Object.entries(e))t[r]=BN(n);return t}return e}async function TN(e,t,r){const n=r(t,e);if(n)throw n;if(null!=e)if(Array.isArray(e))for(let n=0;n<e.length;n++){const o=`${t}/${n}`;await TN(e[n],o,r)}else if("object"==typeof e&&!DN(e))for(const[n,o]of Object.entries(e)){const e=`${t}/${n}`;await TN(o,e,r)}}function DN(e){return null!==fs.asCID(e)}async function RN(e,t){const r=await t.encrypt(e.data());return await CN(r)}async function jN(e){try{const t=e,r=await CN(t);return new UN(r,t)}catch(e){throw new Error(`Failed to decode node into event: ${e instanceof Error?e.message:String(e)}`)}}async function NN(e,t){try{const r=await t.getBlock(e);return r instanceof UN?r:await jN(r)}catch(e){throw new Error(`Failed to get event from record: ${e instanceof Error?e.message:String(e)}`)}}let UN=class{constructor(e,t,r,n){this._node=e,this._obj=t,r&&(this._header=r),n&&(this._body=n)}cid(){return this._node.cid()}headerCID(){return this._obj.header}async getHeader(e,t){if(!this._header){const t=await e.get(this._obj.header),r=await CN(t);this._header=new KN(r)}try{if(!this._header.isLoaded()&&t){const e=K.decode(this._header.node().data());if(!e)throw new Error("Failed to decode block");let r=e;try{r=K.decode(e)}catch(e){}const n=await t.decrypt(r),o=K.decode(n);this._header.setObj(o)}}catch(e){throw new Error(`Failed to decode header: ${e instanceof Error?e.message:String(e)}`)}return this._header}bodyCID(){return this._obj.body}async getBody(e,t){let r=null;if(t){const n=await this.getHeader(e,t);r=await n.key()}if(!this._body){const t=await e.get(this._obj.body);this._body=await CN(t)}return r?async function(e,t){let r,n=e;if("function"==typeof e.data)n=K.decode(e.data());else try{n=K.decode(e)}catch(t){n=e}if(n instanceof Uint8Array)r=n;else try{r=K.decode(n._data)}catch(e){r=n._data}let o=r;return t&&(o=await t.decrypt(r)),EN(o)}(this._body,r):this._body}data(){return this._node.data()}links(){return this._node.links()}size(){return this._node.size()}};class KN{constructor(e,t=null){this._node=e,this._obj=t}isLoaded(){return null!==this._obj}setObj(e){this._obj=e}node(){return this._node}cid(){return this._node.cid()}links(){return this._node.links()}async key(){if(!this._obj)throw new Error("EventHeader object not loaded");if(!this._obj.key)throw new Error("Key is undefined");return uR.fromBytes(this._obj.key)}data(){return this._node.data()}size(){return this._node.size()}}async function qN(e,t,r,n=!1){const o=await e.get(t),i=await r.decrypt(o),s=K.decode(i);n||(s.block=t);const a=await CN(o);return new FN(a,s,void 0,r)}async function LN(e){if(!e.pubKey)throw new Error("Missing required fields in LogInfo: pubKey");const t=await fR.publicToBytes(e.pubKey),r=e.id.toString();return{ID:dR.toBytes(r),pubKey:t,addrs:e.addrs?e.addrs.map((e=>e.bytes)):[],head:e.head?.id?e.head.id.bytes:void 0,counter:e.head?.counter}}async function _N(t){if(!t.ID||!t.pubKey)throw new Error("Missing required fields in Log: ID or pubKey");return{id:dR.fromBytes(t.ID),pubKey:await fR.publicFromBytes(t.pubKey),addrs:(t.addrs||[]).map((t=>e.multiaddr(t))),managed:!0,head:{id:t.head&&t.head.length>0?fs.decode(t.head):void 0,counter:t.counter?Number(t.counter):0}}}async function MN(e,t){if(!t)throw new Error("解密密钥是必需的");const r=K.decode(e.recordNode),n=await t.decrypt(r),o=K.decode(n),i=await EN(e.recordNode);o.block=i.cid();const s=await EN(e.eventNode),a=await EN(e.headerNode),c=await EN(e.bodyNode),u=K.decode(s.rawData()),l=new KN(a),d=new UN(s,u,l,c);return new FN(i,o,d)}class FN{constructor(e,t,r,n){this._node=e,this._obj=t,r&&(this._block=r),this._key=n}key(){return this._key}cid(){return this._node.cid()}rawData(){return this._node.rawData()}blockID(){return this._obj.block}async getBlock(e){if(this._block)return this._block;const t=await e.get(this._obj.block);return this._block=await CN(t),this._block}prevID(){return this._obj.prev}sig(){return this._obj.sig}pubKey(){return this._obj.pubKey}links(){return this._node.links()}size(){return this._node.size()}data(){return this._node.data()}async verify(e){if(!this._block)return new Error("块未加载");let t;if(this.prevID()&&null!==fs.asCID(this.prevID())){const e=this._block.cid().bytes,r=this.prevID().bytes;t=new Uint8Array(e.length+r.length),t.set(e),t.set(r,e.length)}else t=this.pubKey();return await e.verify(t,this.sig())?void 0:new Error("签名无效")}}var zN=null;try{zN=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(e){}function GN(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function VN(e){return!0===(e&&e.__isLong__)}function HN(e){var t=Math.clz32(e&-e);return e?31-t:t}GN.prototype.__isLong__,Object.defineProperty(GN.prototype,"__isLong__",{value:!0}),GN.isLong=VN;var WN={},JN={};function $N(e,t){var r,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=JN[e])?n:(r=ZN(e,0,!0),o&&(JN[e]=r),r):(o=-128<=(e|=0)&&e<128)&&(n=WN[e])?n:(r=ZN(e,e<0?-1:0,!1),o&&(WN[e]=r),r)}function YN(e,t){if(isNaN(e))return t?sU:iU;if(t){if(e<0)return sU;if(e>=rU)return dU}else{if(e<=-nU)return hU;if(e+1>=nU)return lU}return e<0?YN(-e,t).neg():ZN(e%tU|0,e/tU|0,t)}function ZN(e,t,r){return new GN(e,t,r)}GN.fromInt=$N,GN.fromNumber=YN,GN.fromBits=ZN;var QN=Math.pow;function XN(e,t,r){if(0===e.length)throw Error("empty string");if("number"==typeof t?(r=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?sU:iU;if((r=r||10)<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return XN(e.substring(1),t,r).neg();for(var o=YN(QN(r,8)),i=iU,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),c=parseInt(e.substring(s,s+a),r);if(a<8){var u=YN(QN(r,a));i=i.mul(u).add(YN(c))}else i=(i=i.mul(o)).add(YN(c))}return i.unsigned=t,i}function eU(e,t){return"number"==typeof e?YN(e,t):"string"==typeof e?XN(e,t):ZN(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}GN.fromString=XN,GN.fromValue=eU;var tU=4294967296,rU=tU*tU,nU=rU/2,oU=$N(1<<24),iU=$N(0);GN.ZERO=iU;var sU=$N(0,!0);GN.UZERO=sU;var aU=$N(1);GN.ONE=aU;var cU=$N(1,!0);GN.UONE=cU;var uU=$N(-1);GN.NEG_ONE=uU;var lU=ZN(-1,2147483647,!1);GN.MAX_VALUE=lU;var dU=ZN(-1,-1,!0);GN.MAX_UNSIGNED_VALUE=dU;var hU=ZN(0,-2147483648,!1);GN.MIN_VALUE=hU;var pU=GN.prototype;pU.toInt=function(){return this.unsigned?this.low>>>0:this.low},pU.toNumber=function(){return this.unsigned?(this.high>>>0)*tU+(this.low>>>0):this.high*tU+(this.low>>>0)},pU.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(hU)){var t=YN(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var o=YN(QN(e,6),this.unsigned),i=this,s="";;){var a=i.div(o),c=(i.sub(a.mul(o)).toInt()>>>0).toString(e);if((i=a).isZero())return c+s;for(;c.length<6;)c="0"+c;s=""+c+s}},pU.getHighBits=function(){return this.high},pU.getHighBitsUnsigned=function(){return this.high>>>0},pU.getLowBits=function(){return this.low},pU.getLowBitsUnsigned=function(){return this.low>>>0},pU.getNumBitsAbs=function(){if(this.isNegative())return this.eq(hU)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},pU.isSafeInteger=function(){var e=this.high>>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},pU.isZero=function(){return 0===this.high&&0===this.low},pU.eqz=pU.isZero,pU.isNegative=function(){return!this.unsigned&&this.high<0},pU.isPositive=function(){return this.unsigned||this.high>=0},pU.isOdd=function(){return!(1&~this.low)},pU.isEven=function(){return!(1&this.low)},pU.equals=function(e){return VN(e)||(e=eU(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},pU.eq=pU.equals,pU.notEquals=function(e){return!this.eq(e)},pU.neq=pU.notEquals,pU.ne=pU.notEquals,pU.lessThan=function(e){return this.comp(e)<0},pU.lt=pU.lessThan,pU.lessThanOrEqual=function(e){return this.comp(e)<=0},pU.lte=pU.lessThanOrEqual,pU.le=pU.lessThanOrEqual,pU.greaterThan=function(e){return this.comp(e)>0},pU.gt=pU.greaterThan,pU.greaterThanOrEqual=function(e){return this.comp(e)>=0},pU.gte=pU.greaterThanOrEqual,pU.ge=pU.greaterThanOrEqual,pU.compare=function(e){if(VN(e)||(e=eU(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},pU.comp=pU.compare,pU.negate=function(){return!this.unsigned&&this.eq(hU)?hU:this.not().add(aU)},pU.neg=pU.negate,pU.add=function(e){VN(e)||(e=eU(e));var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,a=e.low>>>16,c=0,u=0,l=0,d=0;return l+=(d+=o+(65535&e.low))>>>16,u+=(l+=n+a)>>>16,c+=(u+=r+s)>>>16,c+=t+i,ZN((l&=65535)<<16|(d&=65535),(c&=65535)<<16|(u&=65535),this.unsigned)},pU.subtract=function(e){return VN(e)||(e=eU(e)),this.add(e.neg())},pU.sub=pU.subtract,pU.multiply=function(e){if(this.isZero())return this;if(VN(e)||(e=eU(e)),zN)return ZN(zN.mul(this.low,this.high,e.low,e.high),zN.get_high(),this.unsigned);if(e.isZero())return this.unsigned?sU:iU;if(this.eq(hU))return e.isOdd()?hU:iU;if(e.eq(hU))return this.isOdd()?hU:iU;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(oU)&&e.lt(oU))return YN(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,a=e.low>>>16,c=65535&e.low,u=0,l=0,d=0,h=0;return d+=(h+=o*c)>>>16,l+=(d+=n*c)>>>16,d&=65535,l+=(d+=o*a)>>>16,u+=(l+=r*c)>>>16,l&=65535,u+=(l+=n*a)>>>16,l&=65535,u+=(l+=o*s)>>>16,u+=t*c+r*a+n*s+o*i,ZN((d&=65535)<<16|(h&=65535),(u&=65535)<<16|(l&=65535),this.unsigned)},pU.mul=pU.multiply,pU.divide=function(e){if(VN(e)||(e=eU(e)),e.isZero())throw Error("division by zero");var t,r,n;if(zN)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?ZN((this.unsigned?zN.div_u:zN.div_s)(this.low,this.high,e.low,e.high),zN.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?sU:iU;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return sU;if(e.gt(this.shru(1)))return cU;n=sU}else{if(this.eq(hU))return e.eq(aU)||e.eq(uU)?hU:e.eq(hU)?aU:(t=this.shr(1).div(e).shl(1)).eq(iU)?e.isNegative()?aU:uU:(r=this.sub(e.mul(t)),n=t.add(r.div(e)));if(e.eq(hU))return this.unsigned?sU:iU;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=iU}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(t)/Math.LN2),i=o<=48?1:QN(2,o-48),s=YN(t),a=s.mul(e);a.isNegative()||a.gt(r);)a=(s=YN(t-=i,this.unsigned)).mul(e);s.isZero()&&(s=aU),n=n.add(s),r=r.sub(a)}return n},pU.div=pU.divide,pU.modulo=function(e){return VN(e)||(e=eU(e)),zN?ZN((this.unsigned?zN.rem_u:zN.rem_s)(this.low,this.high,e.low,e.high),zN.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},pU.mod=pU.modulo,pU.rem=pU.modulo,pU.not=function(){return ZN(~this.low,~this.high,this.unsigned)},pU.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},pU.clz=pU.countLeadingZeros,pU.countTrailingZeros=function(){return this.low?HN(this.low):HN(this.high)+32},pU.ctz=pU.countTrailingZeros,pU.and=function(e){return VN(e)||(e=eU(e)),ZN(this.low&e.low,this.high&e.high,this.unsigned)},pU.or=function(e){return VN(e)||(e=eU(e)),ZN(this.low|e.low,this.high|e.high,this.unsigned)},pU.xor=function(e){return VN(e)||(e=eU(e)),ZN(this.low^e.low,this.high^e.high,this.unsigned)},pU.shiftLeft=function(e){return VN(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?ZN(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):ZN(0,this.low<<e-32,this.unsigned)},pU.shl=pU.shiftLeft,pU.shiftRight=function(e){return VN(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?ZN(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):ZN(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},pU.shr=pU.shiftRight,pU.shiftRightUnsigned=function(e){return VN(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?ZN(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):ZN(32===e?this.high:this.high>>>e-32,0,this.unsigned)},pU.shru=pU.shiftRightUnsigned,pU.shr_u=pU.shiftRightUnsigned,pU.rotateLeft=function(e){var t;return VN(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?ZN(this.high,this.low,this.unsigned):e<32?(t=32-e,ZN(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),ZN(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},pU.rotl=pU.rotateLeft,pU.rotateRight=function(e){var t;return VN(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?ZN(this.high,this.low,this.unsigned):e<32?(t=32-e,ZN(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),ZN(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},pU.rotr=pU.rotateRight,pU.toSigned=function(){return this.unsigned?ZN(this.low,this.high,!1):this},pU.toUnsigned=function(){return this.unsigned?this:ZN(this.low,this.high,!0)},pU.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},pU.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},pU.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},GN.fromBytes=function(e,t,r){return r?GN.fromBytesLE(e,t):GN.fromBytesBE(e,t)},GN.fromBytesLE=function(e,t){return new GN(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},GN.fromBytesBE=function(e,t){return new GN(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},"function"==typeof BigInt&&(GN.fromBigInt=function(e,t){return ZN(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},GN.fromValue=function(e,t){return"bigint"==typeof e?GN.fromBigInt(e,t):eU(e,t)},pU.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<<BigInt(32)|e});const{Buffer:yU}=Rr;class fU{constructor(e,t,r,n,o){this.grpcClient=new b.Libp2pGrpcClient(e,t,r,o),this.token=r,this.net=n}async requestThreadID(){try{const e=new IE.pb.ThreadIDRequest({}),t=IE.pb.ThreadIDRequest.encode(e).finish(),r=await this.grpcClient.unaryCall("/dcnet.pb.Service/RequestThreadID",t,3e4);return fa(IE.pb.ThreadIDReply.decode(r).threadID)}catch(e){throw e}}async createThread(e,t){try{if(null==this.grpcClient.node||null==this.grpcClient.node.peerId)throw new Error("p2pNode is null or node privateKey is null");if(null==t.threadKey)throw new Error("threadKey is null");const r=await XD(this.grpcClient.peerAddr),n=await QD(r),o=new IE.pb.CreateThreadRequest({});o.threadID=(new TextEncoder).encode(e),o.keys=await this.getThreadKeys(n,{threadKey:t.threadKey,logKey:t.logKey}),o.blockheight=t.blockHeight,o.signature=t.signature;const i=IE.pb.CreateThreadRequest.encode(o).finish(),s=await this.grpcClient.unaryCall("/dcnet.pb.Service/CreateThread",i,3e4),a=IE.pb.ThreadInfoReply.decode(s);return await this.threadInfoFromProto(a)}catch(e){throw e}}async addLogToThread(e,t,r){try{if(null==this.grpcClient.node||null==this.grpcClient.node.peerId)throw new Error("p2pNode is null or node privateKey is null");const n=this.grpcClient.node.peerId,o=(await QD(n),new IE.pb.AddLogToThreadRequest({}));o.threadID=(new TextEncoder).encode(e),o.logID=(new TextEncoder).encode(t),o.peerid=(new TextEncoder).encode(n.toString()),o.blockheight=r.blockHeight,o.signature=r.signature;const i=IE.pb.AddLogToThreadRequest.encode(o).finish();await this.grpcClient.unaryCall("/dcnet.pb.Service/AddLogToThread",i,3e4)}catch(e){if(e.message.includes("log has binded to thread"))return;throw e}}async threadInfoFromProto(t){if(!t.threadID)throw new Error("Missing required field: threadID");const r=v.ThreadID.fromString((new TextDecoder).decode(t.threadID)),n=t.logs?await Promise.all(t.logs.map((async e=>{if(!e.ID||!e.pubKey)throw new Error("Missing required fields in LogInfo: id or pubKey");const t=dR.fromBytes(e.ID),r=As.publicKeyFromProto(e.pubKey);let n;64==e.privKey?.length&&(n=Is.privateKeyFromProto(e.privKey));const o=e.addrs?.map((e=>hR.fromBytes(e)))||[],i=e.head?pR.fromBytes(e.head):null;let s=-1;if(e.counter&&e.counter.length>0){const t=yU.from(e.counter);s=Number(t.readBigUInt64BE(0))}return{id:t,pubKey:r,...n?{privKey:n}:{},addrs:o,managed:!0,head:{id:i||fs.parse(""),counter:s}}}))):[],o=[];if(t.addrs&&t.addrs.length>0)for(const n of t.addrs)try{let t=this.removeThreadProtocol(n),i=e.multiaddr(t);const s=new yN(i,r);o.push(s)}catch(e){}return new fN(r,n,o)}removeThreadProtocol(e){let t=0;for(;t<e.length;){const r=pc(e,t);if(r==lN.code)return e.slice(0,t);const n=uc(r),o=gU(r),i=this.sizeForAddr(o,e.slice(t+n));if(0!==i){if(e.slice(t+n,t+n+i),t+=i+n,t>e.length)throw new Error("invalid multiaddr");if(!0===o.path)break}else t+=n}return e}sizeForAddr(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=pc(t instanceof Uint8Array?t:Uint8Array.from(t));return e+uc(e)}}async getThreadKeys(e,t){try{const r=await e.encrypt(t.threadKey.toBytes());let n;n=t.logKey?t.logKey instanceof Is?await e.encrypt(As.publicKeyToProto(t.logKey.publicKey)):t.logKey instanceof As?await e.encrypt(As.publicKeyToProto(t.logKey)):await e.encrypt(t.logKey.raw):await e.encrypt(new Uint8Array(0));return new IE.pb.Keys({threadKeyEncrpt:r,logKeyEncrpt:n})}catch(e){throw e}}async getRecordsFromPeer(e,t){try{const r=lB.pb.GetRecordsRequest.encode(e).finish(),n=await this.grpcClient.unaryCall("/net.pb.Service/GetRecords",r,9e5),o=lB.pb.GetRecordsReply.decode(n),i={};for(const e of o.logs||[]){if(!e.logID)continue;const r=dR.fromBytes(e.logID).toString(),n=e.records||[],o=new Array(n.length),s=8;let a=Date.now();const c=10;for(let e=0;e<n.length;e+=c){const r=Math.min(e+c,n.length),i=[];for(let s=e;s<r;s++)i.push(MN(n[s],t).then((e=>{o[s]=e})));await Promise.all(i),Date.now()-a>=s&&(await new Promise((e=>setTimeout(e,0))),a=Date.now())}const u=this.sortRecordsChain(o);i[r]={records:u,counter:e.log?.counter||0}}return i}catch(e){throw e}}sortRecordsChain(e){if(e.length<=1)return e;const t=[],r=new Map;let n=null;for(const t of e){const e=t.blockID().toString();r.set(e,t)}for(const t of e){const e=t.prevID();if(!e||!r.has(e.toString())){n=t;break}}n||(n=e[0]?e[0]:null);let o=n;const i=new Set;for(;o&&!i.has(o.blockID().toString());){t.push(o),i.add(o.blockID().toString());const r=o.blockID().toString();let n=null;for(const t of e){if(i.has(t.blockID().toString()))continue;const e=t.prevID();if(e&&e.toString()===r){n=t;break}}o=n}if(t.length!==e.length)for(const r of e)i.has(r.blockID().toString())||t.push(r);return t}async pushRecordToPeer(e,t,r,n,o){const i=new lB.pb.PushRecordRequest.Body;i.threadID=yR.toBytes(e.toString()),i.logID=dR.toBytes(t.toString()),i.record=await async function(e,t){let r=await t.getBlock(e);const n=t,o=n.key?n.key():void 0;if(o){const n=K.decode(t.data()),i=await o.decrypt(n),s=K.decode(i),a=await e.get(s.block);r=await EN(a)}let i;if(r instanceof UN)i=r;else{const e=K.decode(r.data());i=new UN(r,e)}const s=await i.getHeader(e),a=await i.getBody(e),c=new lB.pb.Log.Record;return c.recordNode=t.data(),c.eventNode=i.data(),c.headerNode=s.data(),c.bodyNode=a.data(),c}(this.net.bstore,r);const s=new lB.pb.PushRecordRequest;s.body=i,s.counter=n;const a=lB.pb.PushRecordRequest.encode(s).finish();await this.grpcClient.unaryCall("/net.pb.Service/PushRecord",a,3e4)}async pushLogToPeer(e,t,r){try{const n=setTimeout((()=>{throw new Error("Getting log information timed out")}),1e4),o=await r.getLog(e,t);clearTimeout(n);const i=new lB.pb.PushLogRequest.Body;i.threadID=yR.toBytes(e.toString()),i.log=await LN(o);const s=new lB.pb.PushLogRequest;s.body=i;const a=lB.pb.PushLogRequest.encode(s).finish();await this.grpcClient.unaryCall("/net.pb.Service/PushLog",a,3e4)}catch(e){throw new Error(`Error pushing missing log: ${e instanceof Error?e.message:String(e)}`)}}async exchangeEdges(e){try{const t=lB.pb.ExchangeEdgesRequest.encode(e).finish(),r=await this.grpcClient.unaryCall("/net.pb.Service/ExchangeEdges",t,3e4);return lB.pb.ExchangeEdgesReply.decode(r)}catch(e){throw e}}async getLogs(e,t){try{const r=new lB.pb.GetLogsRequest.Body;r.threadID=e.toBytes(),r.serviceKey=t;const n=new lB.pb.GetLogsRequest;n.body=r;const o=lB.pb.GetLogsRequest.encode(n).finish(),i=await this.grpcClient.unaryCall("/net.pb.Service/GetLogs",o,3e4);return lB.pb.GetLogsReply.decode(i)}catch(e){throw e}}async getThreadFromPeer(e){try{const t=new IE.pb.GetThreadRequest;t.threadID=e.toBytes();const r=IE.pb.GetThreadRequest.encode(t).finish(),n=await this.grpcClient.unaryCall("/dcnet.pb.Service/GetThread",r,3e4),o=IE.pb.ThreadInfoReply.decode(n);return await this.threadInfoFromProto(o)}catch(e){throw e}}}function gU(t){const r=e.registry.getProtocol(t);return{code:r.code,size:r.size??0,name:r.name,resolvable:Boolean(r.resolvable),path:Boolean(r.path)}}class bU{constructor(e,t,r,n){this.net=r,this.logstore=n,this.dc=t,this.client=e}async requestThreadID(e){try{if(null==this.client.p2pNode)throw new Error("p2pNode is null");e||(e=this.client.peerAddr);const t=new fU(this.client.p2pNode,e,this.client.token,this.net,this.client.protocol);return await t.requestThreadID()}catch(e){throw e}}async createThread(e,t){try{if(null==this.client.p2pNode||null==this.client.p2pNode.peerId)throw new Error("p2pNode is null or node privateKey is null");await QD(this.client.p2pNode.peerId);const r=new fU(this.client.p2pNode,this.client.peerAddr,this.client.token,this.net,this.client.protocol);await r.createThread(e,t);return e}catch(e){throw e}}async pushRecordToPeer(e,t,r,n){try{if(null==this.client.p2pNode)throw new Error("p2pNode is null");const o=new fU(this.client.p2pNode,this.client.peerAddr,this.client.token,this.net,this.client.protocol);await o.pushRecordToPeer(e,t,r,n,this.logstore),await this.dc.createTransferStream(this.client.p2pNode,this.client.blockstore,this.client.peerAddr,zE.Record,r.cid().toString())}catch(e){throw e}}async pushLogToPeer(e,t,r){try{if(null==this.client.p2pNode)throw new Error("p2pNode is null");const n=new fU(this.client.p2pNode,this.client.peerAddr,this.client.token,this.net,this.client.protocol);await n.pushLogToPeer(e,t,this.logstore),await this.dc.createTransferStream(this.client.p2pNode,this.client.blockstore,this.client.peerAddr,zE.Record,r.cid().toString())}catch(e){return e}return null}async exchangeEdges(e){try{if(null==this.client.p2pNode)throw new Error("p2pNode is null");const t={threads:[]};t.threads=[];for(const r of e)try{const{addrEdge:e,headsEdge:n}=await this.localEdges(r);t.threads.push({threadID:r.toBytes(),headsEdge:GN.fromString(n.toString(),!0),addressEdge:GN.fromString(e.toString(),!0)})}catch(e){"No address edge"!==e.message&&"No heads edge"!==e.message||t.threads.push({threadID:r.toBytes(),headsEdge:0,addressEdge:0})}if(0===t.threads.length)return;const r=new lB.pb.ExchangeEdgesRequest;r.body=t;const n=new fU(this.client.p2pNode,this.client.peerAddr,this.client.token,this.net,this.client.protocol),o=3e4,i=new AbortController,s=setTimeout((()=>i.abort()),o);try{const e=await n.exchangeEdges(r);for(const t of e.edges||[]){if(!t.threadID)continue;const e=v.ThreadID.fromBytes(t.threadID);let r=0,n=0;try{const t=await this.localEdges(e);r=Number(t.addrEdge)||0,n=Number(t.headsEdge)||0}catch(e){if("No address edge"!==e.message&&"No heads edge"!==e.message)continue}let o=!1;const i=Number(t.addressEdge)||0;0!==i&&i!==r&&(await this.scheduleUpdateLogs(e),o=!0);const s=Number(t.headsEdge)||0;0!==s&&s!==n&&(await this.scheduleUpdateRecords(e),o=!0),o&&await this.pushLogsHeadToPeer(e)}}catch(t){if("UNIMPLEMENTED"===t.code){for(const t of e)await this.scheduleUpdateRecords(t);return}if("UNAVAILABLE"===t.code)return;throw t}finally{clearTimeout(s)}}catch(e){throw new Error(`Exchange edges failed: ${e instanceof Error?e.message:String(e)}`)}}async pushLogsHeadToPeer(e){const t=await this.logstore.getManagedLogs(e),r=await this.logstore.keyBook.serviceKey(e);if(!r)return;const n=uR.fromSymKey(r);for(const r of t){const t=await this.logstore.headBook.heads(e,r.id);let o;if(t.length>0&&(o=t.reduce(((e,t)=>e.counter>t.counter?e:t)),o.id&&o.counter>0)){const t=await qN(this.net.getDagService(),o.id,n,!0);t&&await this.pushRecordToPeer(e,r.id,t,o.counter)}}}async localEdges(e){let t=0n,r=0n;try{const t=await this.logstore.metadata.getString(e,"local_log_no_record_flag");r=t&&t?.length>0?await this.logstore.addrBook.addrsEdge(e,t):await this.logstore.addrBook.addrsEdge(e)}catch(e){}try{t=await this.logstore.headBook.headsEdge(e)}catch(e){throw e.message.includes("Thread not found")?new Error("No heads edge"):new Error(`Heads edge: ${e.message}`)}return{addrEdge:r,headsEdge:t}}edgeToBigInt(e){return null==e?0n:"number"==typeof e?BigInt(e>>>0):GN.isLong(e)?BigInt(e.toString()):0n}async scheduleUpdateLogs(e){const t=await this.getLogs(e);return await this.net.createExternalLogsIfNotExist(e,t)}async scheduleUpdateRecords(e){await this.net.updateRecordsFromPeer(e,null,this)}async buildGetRecordsRequest(e,t,r){try{const n=await this.logstore.keyBook.serviceKey(e);if(!n)throw new Error("A service-key is required to request records");const o=Object.entries(t).map((([e,t])=>{const n=t?.id||void 0;return{logID:dR.toBytes(e),limit:r,counter:t.counter,offset:n?pR.toBytes(n):null}})),i={threadID:yR.toBytes(e.toString()),serviceKey:n.raw,logs:o},s=new lB.pb.GetRecordsRequest;return s.body=i,{req:s,serviceKey:n}}catch(e){throw e}}async getLogs(e){try{const t=await this.logstore.keyBook.serviceKey(e);if(!t)throw new Error("A service-key is required to request logs");const r=new fU(this.client.p2pNode,this.client.peerAddr,this.client.token,this.net,this.client.protocol),n=await r.getLogs(e,t.raw);if(!n.logs)return[];return await Promise.all(n.logs.map((async e=>await _N(e))))}catch(e){throw e}}async getRecordsFromPeer(e,t){if(!t)throw new Error("A service-key is required to request logs");const r=new fU(this.client.p2pNode,this.client.peerAddr,this.client.token,this.net,this.client.protocol),n=await r.getRecordsFromPeer(e,uR.fromSymKey(t));return 0===Object.keys(n).length?{}:n}async getThreadFromPeer(e,t,r={}){const n=new fU(this.client.p2pNode,this.client.peerAddr,this.client.token,this.net,this.client.protocol);return await n.getThreadFromPeer(e)}}var mU,wU={exports:{}};var vU=(mU||(mU=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function i(e,t,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,i||e,s),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,o=[];if(0===this._eventsCount)return o;for(n in e=this._events)t.call(e,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s},a.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},a.prototype.emit=function(e,t,n,o,i,s){var a=r?r+e:e;if(!this._events[a])return!1;var c,u,l=this._events[a],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,o),!0;case 5:return l.fn.call(l.context,t,n,o,i),!0;case 6:return l.fn.call(l.context,t,n,o,i,s),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,p=l.length;for(u=0;u<p;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,o);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(e,t,r){return i(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return i(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,n,o){var i=r?r+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||n&&a.context!==n||s(this,i);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||o&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[i]=1===u.length?u[0]:u:s(this,i)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a}(wU)),wU.exports),kU=o.getDefaultExportFromCjs(vU);class SU{constructor(){this.bus=new kU}send(e){return new Promise(((t,r)=>{const n=setTimeout((()=>r(new Error("Event send timeout"))),SU.busTimeout);this.bus.emit("event",e,(()=>{clearTimeout(n),t()}))}))}listen(){return new OU(this.bus)}discard(){this.bus.removeAllListeners()}}SU.busTimeout=15e3;class OU{constructor(e){this.bus=e,this.handler=e=>this.onEvent(e),e.on("event",this.handler)}onEvent(e){}discard(){this.bus.off("event",this.handler)}}class AU{constructor(e,t,r){if(this.net=e,this.app=t,this.threadInfo=r,!r.key?.canRead())throw new Error(`Read key not found for thread ${r.id}`);this.token=this.generateRandomBytes(32)}get threadId(){return this.threadInfo.id}get threadKey(){return this.threadInfo.key}async createNetRecord(e,t){return this.net.createRecord(this.threadId,e,{...void 0!==t?{threadToken:t}:{},apiToken:this.token})}async validate(e){try{return void await this.net.validate(this.threadId,e)}catch(e){return e}}async validateNetRecordBody(e,t){return this.app.validateNetRecordBody(e,t)}async handleNetRecord(e){return this.app.handleNetRecord(e,this.threadKey)}async getNetRecordCreateTime(e){return this.app.getNetRecordCreateTime(e,this.threadKey)}generateRandomBytes(e){return crypto.getRandomValues(new Uint8Array(e))}}class IU{constructor(){this._locked=!1,this._queue=[]}async acquire(){return new Promise((e=>{this._locked?this._queue.push(e):(this._locked=!0,e())}))}release(){if(this._queue.length>0){this._queue.shift()()}else this._locked=!1}}const{Buffer:xU}=Rr;function PU(e,t,r){return new hN(e,t,r)}class EU{constructor(e,t,r,n,o,i,s,a){this.cachePeers={},this.threadMutexes={},this.pushQueue=[],this.pushWorkerStarted=!1,this.sign=async e=>{if(!this.context)throw new Error("privKey is null");return this.context.sign(e)},this.logstore=o,this.hostID=r.peerId.toString(),this.context=a,this.bstore=i,this.dagService=s,this.libp2p=r,this.server=n,this.server.setNetwork(this),this.connectors={},this.dcChain=t,this.dc=e}getDagService(){return this.dagService}async getClient(t){try{let r=!0;const n=this.cachePeers[t.toString()];let o=n||null,i=exports.PeerStatus.PeerStatusOnline;if(n||(r=!1,[o,i]=await this.dcChain.getDcNodeWebrtcDirectAddr(t.toString())),!o)throw new Error("peerAddr is null");if(i!==exports.PeerStatus.PeerStatusOnline)throw new Error("peerStatus is not online");if(!this.context.publicKey)throw new Error("publicKey is null");const s=e.multiaddr(o),a=new EE(this.libp2p,this.bstore,s,UE);if(!await a.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),(e=>this.sign(e)))){if(r){let r=null;if([o,r]=await this.dcChain.getDcNodeWebrtcDirectAddr(t.toString()),delete this.cachePeers[t.toString()],!o)throw new Error("peerAddr is null");const n=e.multiaddr(o),i=new EE(this.libp2p,this.bstore,n,UE);if(await i.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),(e=>this.sign(e))))return this.cachePeers[t.toString()]=o,[i,null]}throw new Error("get token is null")}return this.cachePeers[t.toString()]=o,[a,null]}catch(e){return[null,e]}}getMutexForThread(e){return this.threadMutexes[e]||(this.threadMutexes[e]=new IU),this.threadMutexes[e]}async getPeers(e){const t=await this.dcChain.getObjNodes(e.toString());if(!t)return;const n=[];for(const e of t){const t=xU.from(e.slice(2),"hex").toString("utf8"),o=r.peerIdFromString(t);o&&n.push(o)}return n}async createThread(e,t){if(!this.context.publicKey)throw new Error("Identity creation failed.");const r=this.context.publicKey;await this.ensureUniqueLog(e,t.logKey,r);const n=t.threadKey||this.generateRandomKey(),o=new fN(e,[],[],n);await this.logstore.addThread(o);const i=await this.createLog(e,t.logKey,r);return o.logs.push(i),o}async addThread(e,t={}){try{const n=e.id.toString();if(!n)throw new Error("Invalid thread address");const o=v.ThreadID.fromString(n);let i=await this.validate(o,t.token);i||(i=this.context.publicKey);const s=e.addr.getPeerId();if(!s)throw new Error("Invalid peer address");const a=r.peerIdFromString(s),c=a.toString()===this.hostID;await this.ensureUniqueLog(o,t.logKey,i);const u=new fN(o,[],[],t.threadKey);if(await this.logstore.addThread(u),t.threadKey&&t.threadKey.canRead()||t.logKey){const e=await this.createLog(o,t.logKey,i);u.logs.push(e)}return c&&await this.updateLogsFromPeer(o,a),this.getThreadWithAddrs(o)}catch(e){throw new Error(`Failed to add thread: ${e instanceof Error?e.message:String(e)}`)}}async getThread(e,t={}){try{return await this.validate(e,t.token),this.getThreadWithAddrs(e)}catch(t){throw new Error(`Error getting thread ${e.toString()}: ${t instanceof Error?t.message:String(t)}`)}}async getThreadFromPeer(e,t,r={}){try{const[n,o]=await this.getClient(t);if(!n)throw new Error("Failed to get client");const i=new bU(n,this.dc,this,this.logstore);try{return i.getThreadFromPeer(e,t,r)}catch(e){throw new Error(`Error getting thread from peer: ${e instanceof Error?e.message:String(e)}`)}}catch(e){throw new Error(`Error getting thread from peer: ${e instanceof Error?e.message:String(e)}`)}}async deleteThread(e,t={}){try{await this.validate(e,t.token);const[r,n]=this.getConnectorProtected(e,t.apiToken);if(!n)throw new Error("Cannot delete thread: thread in use");const o=this.getMutexForThread(e.toString());await o.acquire();try{await this.logstore.deleteThread(e),delete this.connectors[e.toString()]}finally{o.release()}}catch(e){throw new Error(`Failed to delete thread: ${e instanceof Error?e.message:String(e)}`)}}async validate(e,t){if(!Kj(e.toBytes()))throw new Error("Invalid thread ID.");if(t)return t.pubKey()}async ensureUniqueLog(e,t,n){try{const o=await this.logstore.getThread(e);let i;if(t)if(t instanceof As)i=r.peerIdFromPublicKey(t);else{if(!(t instanceof Is))throw new Error("Invalid log key");i=r.peerIdFromPrivateKey(t)}else{if(!n)throw new Error("Either key or identity must be provided");try{const t=await this.logstore.metadata.getBytes(e,n.toString());if(!t||0===t.length){if(n.equals(this.context.publicKey)){const e=o.getFirstPrivKeyLog();if(e&&e.privKey)throw new Error("Thread exists")}return}const s=(new TextDecoder).decode(t);i=r.peerIdFromString(s)}catch(e){throw e}}try{if(await this.logstore.getLog(e,i))throw new Error("Log exists")}catch(e){if(e.message===gN.ErrLogNotFound.message)return;throw e}}catch(e){if(e.message===gN.ErrThreadNotFound.message)return;throw e}}async getThreadWithAddrs(e){try{const t=await this.logstore.getThread(e),r=this.libp2p.getMultiaddrs(),n=[];for(const e of r){const r=e.encapsulate(`/p2p/${this.libp2p.peerId.toString()}`),o=new yN(r,t.id);n.push(o)}return t.addrs=n,t}catch(e){throw e}}async pullThread(e,t,n){try{let t={};try{t=n.multiPeersFlag?await this.pullThreadDeal(e,n.multiPeersFlag):await this.pullThreadDeal(e,!1)}catch(t){throw new Error(`Error pulling thread ${e.toString()}: ${t instanceof Error?t.message:String(t)}`)}const[o,i]=this.getConnector(e),s=[];for(const[n,a]of Object.entries(t)){const t=r.peerIdFromString(n),c=a;if(i){const r=10;let n=[],i=0;const a=async(e,t)=>{try{const t=await e.getBlock(this.bstore),r=t instanceof UN?t:await jN(t),n=await r.getHeader(this.bstore),o=await r.getBody(this.bstore);await this.addMany([r,n,o])}catch(e){}};for(let e=0;e<c.records.length;e++){const t=a(c.records[e],e).finally((()=>{i++;const e=n.indexOf(t);e>-1&&n.splice(e,1)}));n.push(t),n.length>=r&&await Promise.race(n)}await Promise.all(n);let u=c.counter-c.records.length+1;for(let r=0;r<c.records.length;r++){const n=c.records[r],i=await n.getBlock(this.bstore),a=i instanceof UN?i:await jN(i),l=await a.getHeader(this.bstore),d=await a.getBody(this.bstore);await this.addMany([a,l,d]);const h=PU(n,e,t),p=u+r,y=await o.getNetRecordCreateTime(h);s.push({record:n,counter:p,createtime:y,logid:t})}}else await this.putRecords(e,t,c.records,c.counter)}s.sort(((e,t)=>e.createtime<t.createtime?-1:e.createtime>t.createtime?1:0));for(const t of s)await this.putRecords(e,t.logid,[t.record],t.counter)}catch(e){throw e}}async addMany(e){for(const t of e)await this.bstore.put(t.cid(),t.data())}async pullThreadDeal(e,t=!1){try{let[r,n]=await this.threadOffsets(e);try{const t=await this.getPeers(e);t&&t.length>0&&(n=t)}catch(e){}const o={};for(;;){const i=await this.getRecords(n,e,r,uN,t);let s=!1;for(const[e,t]of Object.entries(i))if(t.records.length>0){o[e]||(o[e]={records:[],counter:0});const n=o[e];for(const e of t.records)n.records.push(e);n.counter=t.counter;const i=t.records[t.records.length-1];r[e]={id:i.cid(),counter:t.counter},t.records.length>=uN&&(s=!0)}if(!s)break}return o}catch(e){throw e}}async createLog(t,o,i){let s,a,c;if(o)if(o instanceof Is)s=o,a=o.publicKey,c=r.peerIdFromPrivateKey(o);else{if(!(o instanceof As))throw new Error("Invalid key type.");a=o,c=r.peerIdFromPublicKey(o)}else{const e=await n.keys.generateKeyPair("Ed25519");s=new Is(e.raw),a=e.publicKey,c=r.peerIdFromPrivateKey(s)}const u={privKey:s,pubKey:a,id:c,addrs:[e.multiaddr(`/p2p/${this.hostID}`)],managed:!0,head:{counter:0}};await this.logstore.metadata.putString(t,"local_log_no_record_flag",`${c.toString()}`),await this.logstore.addLog(t,u);const l=(new TextEncoder).encode(c.toString());return await this.logstore.metadata.putBytes(t,i?.toString()||"",l),u}generateRandomKey(){return new lR(uR.new(),uR.new())}addConnector(e,t){this.connectors[e.toString()]=t}getConnector(e){const t=this.connectors[e.toString()];return[t||null,!!t]}async threadOffsets(e){const t=await this.logstore.getThread(e),r={},n=[];for(const e of t.logs){let t=!1;e.head?.id&&(t=await this.isKnown(e.head.id)),t&&e.head?r[e.id.toString()]=e.head:r[e.id.toString()]=await Xj(),e.addrs&&e.addrs.length>0&&n.push(...e.addrs)}return[r,await this.uniquePeers(n)]}async updateLogsFromPeer(e,t){try{const[r,n]=await this.getClient(t);if(!r)return;const o=new bU(r,this.dc,this,this.logstore);await o.scheduleUpdateLogs(e)}catch(t){throw new Error(`Getting records for thread ${e} failed: ${t instanceof Error?t.message:String(t)}`)}}async updateRecordsFromPeer(e,t,n){try{const[o,i]=await this.threadOffsets(e),{req:s,serviceKey:a}=await this.buildGetRecordsRequest(e,o,uN);let c={};if(n)c=await this.getRecordsWithDbClient(n,s,a);else{if(!t)throw new Error("A peer-id is required to request records");c=await this.getRecordsFromPeer(t,s,a)}for(const[t,n]of Object.entries(c))try{const o=r.peerIdFromString(t);await this.putRecords(e,o,n.records,n.counter)}catch(r){throw new Error(`Putting records from log ${t} (thread ${e}) failed: ${r instanceof Error?r.message:String(r)}`)}for(const[o,i]of Object.entries(c))try{const s=r.peerIdFromString(o);if((await this.currentHead(e,s)).counter<=i.counter&&i.records.length===uN)return this.updateRecordsFromPeer(e,t,n)}catch(e){}}catch(t){throw new Error(`Getting records for thread ${e} failed: ${t instanceof Error?t.message:String(t)}`)}}async getRecordsFromPeer(e,t,r){try{const[n,o]=await this.getClient(e);if(!n)return{};const i=new bU(n,this.dc,this,this.logstore);return await i.getRecordsFromPeer(t,r)}catch(e){throw e}}async getRecordsWithDbClient(e,t,r){try{return await e.getRecordsFromPeer(t,r)}catch(e){throw e}}async putRecords(e,t,r,n){const[o,i]=await this.loadRecords(e,t,r,n);if(0===o.length)return;const s=this.getMutexForThread(e.toString());await s.acquire();try{const r=await this.currentHead(e,t);let n=!0,s=i;if(r?.id?.toString()!=i?.id?.toString()){n=!1,s=r;for(let e=0;e<o.length;e++)if(o[e].value().cid().equals(r.id)){o.splice(0,e+1),n=!0;break}if(!n)return}const[a,c]=this.getConnector(e);let u,l=null,d=!1,h=s.counter;if(c){const t=await this.logstore.keyBook.readKey(e);t&&(l=uR.fromSymKey(t)),l&&(d=!0)}for(const r of o){if(d){const e=await r.value().getBlock(this.bstore);let t;t=e instanceof UN?e:await jN(e);const n=await t.getBody(this.bstore,l||void 0);u=await fR.publicFromBytes(r.value().pubKey());try{await a.validateNetRecordBody(n,u)}catch(e){const r=await t.getHeader(this.bstore),n=await t.getBody(this.bstore);throw this.bstore.deleteMany([t.cid(),r.cid(),n.cid()]),e}}if(h++,await this.logstore.headBook.setHead(e,t,{id:r.value().cid(),counter:h}),await this.setThreadLogPoint(e,t,h,r.value().cid()),c)try{await a.handleNetRecord(r)}catch(e){continue}await this.bstore.put(r.value().cid(),r.value().data())}}finally{s.release()}}async loadRecords(e,t,r,n){if(0===r.length)throw new Error("Cannot load empty record chain");const o=await this.currentHead(e,t),i=r[r.length-1];if(void 0===n){if(await this.isKnown(i.cid())||""!=i.cid().toString())return[[],o]}else if(n<=o.counter)return[[],o];let s=[],a=!1;for(let e=r.length-1;e>=0;e--){const t=r[e];if(""==t.cid().toString()||t.cid().equals(o.id)){a=!0;break}s.push(t)}if(!a&&s.length>0){let t=s[s.length-1].prevID();for(;t&&""!=i.cid().toString()&&!t.equals(o.id);){const r=await this.getRecord(e,t);s.push(r),t=r.prevID()}}if(0===s.length)return[[],o];const c=[];for(let r=s.length-1;r>=0;r--){const n=s[r],o=await n.getBlock(this.bstore);let i;i=o instanceof UN?o:await jN(o);const a=await i.getHeader(this.bstore),u=await i.getBody(this.bstore);await this.addMany([i,a,u]),c.push(PU(n,e,t))}return[c,o]}async isKnown(e){return await this.bstore.has(e)}async getRecord(e,t){const r=await this.logstore.keyBook.serviceKey(e);if(!r)throw new Error("A service-key is required to get records");const n=uR.fromSymKey(r);return await qN(this.dagService,t,n)}async setThreadLogPoint(e,t,r,n){if(r%1e4!=0)return;const o=`${t.toString()}/${r}`;await this.logstore.metadata.putBytes(e,o,n.bytes)}async currentHead(e,t){const r=await this.logstore.headBook.heads(e,t);return r.length>0?r[0]:await Xj()}async uniquePeers(e){const t=new Map;for(const r of e)try{const[e,n]=await this.callablePeer(r);if(!n)continue;t.set(e.toString(),e)}catch(e){}return Array.from(t.values())}async callablePeer(e){const t=e.getPeerId();if(!t)throw new Error("Address does not contain peer ID");const n=r.peerIdFromString(t);return n.toString()===this.hostID?[n,!1]:[n,!0]}async getRecords(e,t,r,n,o=!1){try{const{req:i,serviceKey:s}=await this.buildGetRecordsRequest(t,r,n),a=new CU;let c=null;for(const t of e)try{c=setTimeout((()=>{throw new Error(`Timeout getting records from peer ${t}`)}),9e5);const[e,r]=await this.getClient(t);if(!e)throw new Error(`Error getting records from peer ${t},no client,errinfo: ${r}`);const n=new bU(e,this.dc,this,this.logstore),u=await n.getRecordsFromPeer(i,s);let l=0;for(const[e,t]of Object.entries(u))l+=t.records.length;for(const[e,t]of Object.entries(u))await a.batchUpdate(e,t);if(!o)break}catch(e){continue}finally{c&&clearTimeout(c)}return a.list()}catch(e){throw e}}async buildGetRecordsRequest(e,t,r){try{const n=await this.logstore.keyBook.serviceKey(e);if(!n)throw new Error("A service-key is required to request records");const o=Object.entries(t).map((([e,t])=>({logID:dR.toBytes(e),limit:r,counter:t.counter,offset:t.id?pR.toBytes(t.id):new Uint8Array}))),i={threadID:yR.toBytes(e.toString()),serviceKey:n.raw,logs:o},s=new lB.pb.GetRecordsRequest;return s.body=i,{req:s,serviceKey:n}}catch(e){throw e}}async connectApp(e,t){if(!t.isDefined())throw new Error("Invalid thread ID");let r,n;try{r=await this.getThreadWithAddrs(t)}catch(e){throw new Error(`Error getting thread ${t.toString()}: ${e instanceof Error?e.message:String(e)}`)}try{n=new AU(this,e,r)}catch(e){throw new Error(`Error making connector ${t.toString()}: ${e instanceof Error?e.message:String(e)}`)}return this.addConnector(t,n),n}async getPbLogs(e){try{const t=await this.logstore.getThread(e),r=[];for(const e of t.logs)r.push(await LN(e));return[r,t]}catch(t){throw new Error(`Failed to get logs for thread ${e}: ${t instanceof Error?t.message:String(t)}`)}}async preLoadLogs(e,t){try{const r=[];for(let e=0;e<t.length;e++)r.push(await _N(t[e]));await this.createExternalLogsIfNotExistForPreload(e,r)}catch(e){throw new Error(`Failed to preload logs: ${e instanceof Error?e.message:String(e)}`)}}async createExternalLogsIfNotExist(e,t){const r=this.getMutexForThread(e.toString());await r.acquire();try{for(const r of t)try{if(0===(await this.logstore.headBook.heads(e,r.id)).length)r.head=await Xj(),await this.logstore.addLog(e,r);else{try{await this.logstore.getLog(e,r.id)}catch(t){await this.logstore.addLog(e,r)}await this.logstore.addrBook.addAddrs(e,r.id,r.addrs,SN)}}catch(e){continue}}finally{r.release()}}async createExternalLogsIfNotExistForPreload(e,t){const r=this.getMutexForThread(e.toString());await r.acquire();try{for(const r of t)try{0===(await this.logstore.headBook.heads(e,r.id)).length?await this.logstore.addLog(e,r):await this.logstore.addrBook.addAddrs(e,r.id,r.addrs,SN)}catch(e){continue}}finally{r.release()}}async createRecord(e,t,r={}){try{if(void 0===this.context.publicKey)throw new Error("No identity provided for creating record");const n=this.context.publicKey,[o,i]=this.getConnectorProtected(e,r.apiToken);if(!i)throw new Error("Cannot create record: thread in use");o&&await o.validateNetRecordBody(t,n);const s=await this.getOrCreateLog(e,n),a=PU(await this.newRecord(e,s,t,n),e,s.id);s.head||(s.head={counter:0});const c={id:a.value().cid(),counter:s.head.counter+1};return await this.logstore.headBook.setHead(e,s.id,c),await this.setThreadLogPoint(e,s.id,s.head?.counter+1,a.value().cid()),this.server&&this.pushRecord(e,s.id,a.value(),s.head.counter+1),a}catch(e){throw e}}async getOrCreateLog(e,t){if(!t)throw new Error("No identity provided");const n=await this.logstore.metadata.getBytes(e,t.toString());if(!n&&t.equals(this.context.publicKey)){const t=(await this.logstore.getThread(e)).getFirstPrivKeyLog();if(t)return t}else if(n){const t=(new TextDecoder).decode(n),o=r.peerIdFromString(t);return this.logstore.getLog(e,o)}return this.createLog(e,void 0,t)}async newRecord(e,t,r,n){const o=await this.logstore.keyBook.serviceKey(e);if(!o)throw new Error("No service key for thread");if(!this.context.publicKey)throw new Error("No identity provided for creating record");const i=await this.logstore.headBook.heads(e,t.id),s=uR.fromSymKey(o),a=await this.logstore.keyBook.readKey(e),c=a?uR.fromSymKey(a):null;if(!c)throw new Error("No read key for thread");const u=await async function(e,t,r){const n=uR.new();if(!t.rawData)throw new Error("Node data is undefined");const o=new xN(t.rawData(),t.cid()),i=await RN(o,n),s={key:n.bytes()},a=await CN(s),c=await RN(a,r),u={body:i.cid(),header:c.cid()},l=await CN(u);return e&&(await e.put(l.cid(),l.data()),await e.put(c.cid(),c.data()),await e.put(i.cid(),i.data())),new UN(l,u,new KN(c,s),i)}(this.bstore,r,c);let l;await this.bstore.put(u.cid(),u.data()),i&&i.length>0&&(l=i[0].id);return await async function(e,t){const r=await fR.publicToBytes(t.pubKey);let n;if(t.prev&&null!==fs.asCID(t.prev)){const e=t.block.cid().bytes,r=t.prev.bytes;n=new Uint8Array(e.length+r.length),n.set(e),n.set(r,e.length)}else n=r;const o=await t.key.sign(n),i={block:t.block.cid(),sig:o,pubKey:r};t.prev&&(i.prev=t.prev);const s=await CN(i),a=await RN(s,t.serviceKey);return e&&await e.put(a.cid(),a.data()),new FN(a,i,t.block,t.serviceKey)}(this.bstore,{block:u,prev:l,key:t.privKey,pubKey:this.context.publicKey,serviceKey:s})}startPushWorker(){if(this.pushWorkerStarted)return;this.pushWorkerStarted=!0;const e=e=>new Promise((t=>setTimeout(t,e)));let t=!1;(async()=>{for(;;)try{const r=this.pushQueue.shift();if(!r){await e(1e3);continue}try{await this._doPushRecord(r.tid,r.lid,r.rec,r.counter),t||(await this.logstore.metadata.putString(r.tid,"local_log_no_record_flag",""),t=!0)}catch(t){await e(200)}}catch(t){await e(500)}})().catch((e=>{this.pushWorkerStarted=!1,this.startPushWorker()}))}async _doPushRecord(e,t,r,n){try{const o=[],i=await this.logstore.getThread(e);for(const e of i.logs)e.addrs&&e.addrs.length>0&&o.push(...e.addrs);const s=await this.getPeers(e);if(!s)throw new Error(`No peers for thread ${e}`);for(const o of s){if(!o||""===o.toString())continue;let i=null;try{const[s,a]=await this.getClient(o);if(!s)continue;i=new bU(s,this.dc,this,this.logstore),await i.pushRecordToPeer(e,t,r,n)}catch(o){if(o instanceof Error&&i&&o.message===gN.ErrLogNotFound.message)try{await(this.context.dbManager?.addLogToThreadStart(null,e,t));await i.pushLogToPeer(e,t,r)||await i.pushRecordToPeer(e,t,r,n)}catch(e){}}}}catch(e){throw new Error(`Failed to push record: ${e instanceof Error?e.message:String(e)}`)}}async pushRecord(e,t,r,n){this.pushQueue.push({tid:e,lid:t,rec:r,counter:n}),this.startPushWorker()}async exchange(e){try{const t=await this.logstore.getThread(e),r=[];for(const e of t.logs)r.push(...e.addrs);let n=await this.uniquePeers(r);const o=await this.getPeers(e);o&&o.length>0&&(n=o);for(const t of n){await this.exchangeWithPeer(t,e);break}}catch(e){throw new Error(`Exchange failed: ${e instanceof Error?e.message:String(e)}`)}}async exchangeWithPeer(e,t){try{const[r,n]=await this.getClient(e);if(!r)return;const o=new bU(r,this.dc,this,this.logstore);await o.exchangeEdges([t])}catch(e){throw e}}getConnectorProtected(e,t){const[r,n]=this.getConnector(e);return n?t&&r?.token&&this.bytesEqual(t,r.token)?[r,!0]:[void 0,!1]:[void 0,!0]}bytesEqual(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}}class CU{constructor(){this.records=new Map,this.counters=new Map,this.mutex=new IU}async updateHeadCounter(e,t){await this.mutex.acquire();try{t>(this.counters.get(e)||0)&&this.counters.set(e,t)}finally{this.mutex.release()}}async store(e,t){await this.mutex.acquire();try{let r=this.records.get(e);r||(r=new Map,this.records.set(e,r));const n=t.cid().toString();r.set(n,t)}finally{this.mutex.release()}}async batchUpdate(e,t){await this.mutex.acquire();try{const r=this.counters.get(e)||0;t.counter>r&&this.counters.set(e,t.counter);let n=this.records.get(e);n||(n=new Map,this.records.set(e,n)),t.records.forEach((e=>{const t=e.cid().toString();n.set(t,e)}))}finally{this.mutex.release()}}list(){const e={};return this.records.forEach(((t,r)=>{const n=Array.from(t.values());e[r]={records:n,counter:this.counters.get(r)||0}})),e}}const{Buffer:BU}=Rr,TU=wN.dsPrefix.child(new AI("dispatcher"));class DU{constructor(e){this.store=e,this.reducers=[],this.lock={lock:()=>{},unlock:()=>{}},this.lastID=0}getStore(){return this.store}register(e){this.lock.lock(),this.lastID++,this.reducers.push(e),this.lock.unlock()}async dispatch(e){this.lock.lock();const t=await this.store.newTransactionExtended(!1);try{for(const r of e){const e=this.getKey(r),n=BU.from(Vr(r));await t.put(e,n)}await t.commit()}catch(e){throw t.discard(),e}finally{this.lock.unlock()}this.reducers.map((async t=>{await t.reduce(e)}))}async*query(e){return this.store.query(e)}getKey(e){const t=e.timestamp,r=e.collection,n=e.instanceID;return TU.child(new AI(t.toString())).child(new AI(r.toString())).child(new AI(n.toString()))}}class RU{constructor(){this.ands=[],this.ors=[],this.sort=new UU,this.seek="",this.limit=0,this.skip=0,this.index="",this.ands=[],this.ors=[],this.sort=new UU,this.seek="",this.limit=0,this.skip=0,this.index=""}validate(){if(!this)return null;for(const e of this.ands){const t=e.validate();if(t)return t}for(const e of this.ors){const t=e.validate();if(t)return t}return null}and(e){return new jU(e)}or(e){return this.ors.push(e),this}useIndex(e){return this.index=e,this}orderBy(e){return this.sort.fieldPath=e,this.sort.desc=!1,this}orderByDesc(e){return this.sort.fieldPath=e,this.sort.desc=!0,this}orderById(){return this.sort.fieldPath="_id",this.sort.desc=!1,this}orderByIdDesc(){return this.sort.fieldPath="_id",this.sort.desc=!0,this}seekId(e){return this.seek=e,this}limitTo(e){return this.limit=e,this}skipNum(e){return this.skip=e,this}match(e){if(!this)throw new Error("query can't be null");let t=!0;for(const r of this.ands)try{const n=qU(e,r.fieldPath),o=r.match(n);if(t=t&&o,!t)break}catch(e){return!1}if(t)return!0;for(const t of this.ors)try{if(t.match(e))return!0}catch(e){return!1}return!1}}class jU{constructor(e,t,r){this.operation=KU.eq,this.value=new NU,this.query=null,this.fieldPath=e,this.operation=t,this.value=r}validate(){if(!this)return null;let e=0;return null!==this.value.bool&&e++,null!==this.value.string&&e++,null!==this.value.float&&e++,1!==e?new Error("value type should describe exactly one type"):null}eq(e){return this.createCriterion(KU.eq,e)}ne(e){return this.createCriterion(KU.ne,e)}gt(e){return this.createCriterion(KU.gt,e)}lt(e){return this.createCriterion(KU.lt,e)}ge(e){return this.createCriterion(KU.ge,e)}le(e){return this.createCriterion(KU.le,e)}createCriterion(e,t){return this.operation=e,this.value=function(e){const t=new NU;"string"==typeof e?t.string=e:"boolean"==typeof e?t.bool=e:"number"==typeof e&&(t.float=e);return t}(t),this.query||(this.query=new RU),this.query.ands.push(this),this.query}match(e){try{const t=function(e,t){if(null!==t.string){return("string"==typeof e?e:"").localeCompare(t.string)}if(null!==t.bool){return("boolean"==typeof e&&e)===t.bool?0:-1}if(null!==t.float){const r="number"==typeof e?e:0;return r===t.float?0:r<t.float?-1:1}throw new Error("no underlying value for criterion was provided")}(e,this.value);switch(this.operation){case KU.eq:return 0===t;case KU.ne:return 0!==t;case KU.gt:return t>0;case KU.lt:return t<0;case KU.le:return t<=0;case KU.ge:return t>=0;default:throw new Error("invalid operation")}}catch(e){return!1}}}class NU{constructor(){this.string=null,this.bool=null,this.float=null}}class UU{constructor(){this.fieldPath="",this.desc=!1}}var KU;function qU(e,t){const r=t.split(".");let n=e;for(const e of r){if(!n||"object"!=typeof n)return;n=n[e]}return n}!function(e){e[e.eq=0]="eq",e[e.ne=1]="ne",e[e.gt=2]="gt",e[e.lt=3]="lt",e[e.ge=4]="ge",e[e.le=5]="le",e[e.fn=6]="fn"}(KU||(KU={}));class LU extends Error{constructor(e){super(e),this.name="IndexError"}}new LU("unique constraint violation");const _U=new LU("value not indexable"),MU=new LU("can't create unique index (duplicate instances exist)"),FU=new LU("index not found"),zU=new AI("_index"),GU=["string","number","integer","boolean"];class VU extends Error{constructor(){super("sorting field doesn't correspond to instance type"),this.name="InvalidSortingFieldError"}}new VU;class HU extends Error{constructor(e){super(e),this.name="ThreadDBError"}}const WU=new HU("collection schema does not contain path"),JU=new HU("collection not found");new HU("collection already registered");const $U=new HU("instance not found"),YU=new HU("read only transaction"),ZU=new HU("instance doesn't correspond to schema");new HU("invalid collection schema"),new HU("invalid collection name");const QU=new HU("invalid instance: missing _id attribute"),XU=new HU("can't commit discarded/committed txn"),eK=new HU("can't create already existing instance"),tK=mN.child(new AI("collection")),rK="_validate",nK="_filter";class oK{constructor(e=200){this.timeout=e,this.context={},this.functions={},this.timeoutId=null}runScript(e){try{const t=new Function("context",`\n with(context) { \n ${e}; \n return context; \n }\n `);let r=!1;return this.timeoutId=window.setTimeout((()=>{}),this.timeout),this.context=t(this.context)||this.context,r=!0,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),!0}catch(e){throw this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),new Error(`Script execution error: ${e instanceof Error?e.message:String(e)}`)}}getGlobal(e){return this.context[e]}call(e,...t){const r=this.context[e];if("function"!=typeof r)throw new Error(`${e} is not a function`);try{let e=!1;this.timeoutId=window.setTimeout((()=>{}),this.timeout);const n=r.apply(this.context,t);return e=!0,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),n}catch(e){throw this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),new Error(`Function execution error: ${e instanceof Error?e.message:String(e)}`)}}}class iK{constructor(e,t,r,n,o){this.name=e,this.schema=t,this.db=r,this.rawWriteValidator=n,this.rawReadFilter=o,this.writeValidator=null,this.readFilter=null,this.indexes=new Map,this.schemaValidator=new E({allErrors:!0}),this.vm=new oK(200),n&&this.compileAndLoadValidator(n,rK,["writer","event","instance"]),o&&this.compileAndLoadValidator(o,nK,["reader","instance"])}compileAndLoadValidator(e,t,r){try{const n=`function ${t}(${r.join(",")}) {${e}}`;this.vm.runScript(n);if("function"!=typeof this.vm.getGlobal(t))throw new Error(`${t} is not a function`);t===rK?this.writeValidator=(e,t,r)=>this.vm.call(rK,e,t,r):t===nK&&(this.readFilter=(e,t)=>this.vm.call(nK,e,t))}catch(e){throw new Error(`Failed to compile ${t}: ${e instanceof Error?e.message:String(e)}`)}}baseKey(){return tK.child(new AI(this.name))}getName(){return this.name}getSchema(){return(new TextEncoder).encode(JSON.stringify(this.schema))}getWriteValidator(){return(new TextEncoder).encode(this.rawWriteValidator||"")}getReadFilter(){return(new TextEncoder).encode(this.rawReadFilter||"")}async readTxn(e,t){return this.db.readTxn(this,e,t)}async writeTxn(e,t){return this.db.writeTxn(this,e,t)}async findByID(e,t){let r=null;return await this.readTxn((async t=>{r=await t.findByID(e)}),t),r}async create(e,t){let r="";return await this.writeTxn((async t=>{const n=await t.create(e);n.length>0&&(r=n[0])}),t),r}async createMany(e,t){let r=[];return await this.writeTxn((async t=>{r=await t.create(...e)}),t),r}async delete(e,t){await this.writeTxn((async t=>{await t.delete(e)}),t)}async deleteMany(e,t){await this.writeTxn((async t=>{await t.delete(...e)}),t)}async save(e,t){await this.writeTxn((async t=>{await t.save(e)}),t)}async saveMany(e,t){await this.writeTxn((async t=>{await t.save(...e)}),t)}async verify(e,t){await this.writeTxn((async t=>{await t.verify(e)}),t)}async verifyMany(e,t){await this.writeTxn((async t=>{await t.verify(...e)}),t)}async has(e,t){let r=!1;return await this.readTxn((async t=>{r=await t.has(e)}),t),r}async hasMany(e,t){let r=!1;return await this.readTxn((async t=>{r=await t.has(...e)}),t),r}async find(e,t){let r=[];return await this.readTxn((async t=>{r=await t.find(e)}),t),r}async modifiedSince(e,t){let r=[];return await this.readTxn((async t=>{r=await t.modifiedSince(e)}),t),r}validInstance(e){try{const t=JSON.parse((new TextDecoder).decode(e)),r=this.schemaValidator.compile(this.schema);if(!r(t)&&r.errors&&r.errors.length>0){let e="";for(let t=0;t<r.errors.length;t++){const n=r.errors[t];e+=`${n?.schemaPath}: ${n?.message}`,t!==r.errors.length-1&&(e+="; ")}throw new Error(`${ZU.message}: ${e}`)}}catch(e){if(e instanceof Error&&e.message.includes(ZU.message))throw e;throw new Error(`Error validating instance: ${e instanceof Error?e.message:String(e)}`)}}async validWrite(e,t){if(this.writeValidator)try{const r=e?e.toString():null,n=await t.marshal(),o=JSON.parse((new TextDecoder).decode(n));let i=null;try{const e=this.baseKey().child(new AI(t.instanceID)),r=await this.db.datastore.get(e);r&&(i=JSON.parse((new TextDecoder).decode(r)))}catch(e){if("ERR_NOT_FOUND"!==e.code)throw e}if(!0!==this.writeValidator(r,o,i))throw new Error("Write validation failed")}catch(e){throw new Error(`Write validation error: ${e instanceof Error?e.message:String(e)}`)}}async filterRead(e,t){if(!this.readFilter)return t;try{const r=e?e.toString():null,n=JSON.parse((new TextDecoder).decode(t)),o=this.readFilter(r,n);return null===o?null:(new TextEncoder).encode(Vr(o))}catch(e){throw new Error(`Read filter error: ${e instanceof Error?e.message:String(e)}`)}}getIndexes(){if(0===this.indexes.size)return[];const e=[];return this.indexes.forEach(((t,r)=>{r!==vN&&e.push(t)})),e}async addIndex(e,t){if(e.path!==vN||!this.indexes.has(vN))try{const r=function(e,t){const r=t.split(".");let n=e;for(const t of r){if(n=cK(n,e.definitions)[t],!n)throw WU}return n}(this.schema,e.path);let n=!1;for(const e of GU)if(r?.type===e){n=!0;break}if(!n)throw _U;const o=this.indexes.get(e.path);if(o&&o.unique===e.unique)return;if(e.unique&&e.path!==vN){const r=new Map,n=await this.find(new RU,t);for(const t of n){const n=qU(t,e.path);if(void 0!==n){if(r.has(n))throw MU;r.set(n,!0)}}}this.indexes.set(e.path,e),await this.saveIndexes()}catch(e){throw e}}async dropIndex(e){if(e===vN)throw new Error(`${vN} index cannot be dropped`);this.indexes.delete(e),await this.saveIndexes()}async saveIndexes(){try{const e={};this.indexes.forEach(((t,r)=>{e[r]=t}));const t=(new TextEncoder).encode(JSON.stringify(e));await this.db.datastore.put(wN.dsIndexes.child(new AI(this.name)),t)}catch(e){throw new Error(`Failed to save indexes: ${e instanceof Error?e.message:String(e)}`)}}async indexAdd(e,t,r){for(const[n,o]of this.indexes.entries())try{const i=K.decode(r);await this.indexUpdate(n,o,e,t,i,!1)}catch(e){throw e}}async indexDelete(e,t,r){for(const[n,o]of this.indexes.entries())try{await this.indexUpdate(n,o,e,t,r,!0)}catch(e){throw e}}async indexUpdate(e,t,r,n,o,i){try{const s=function(e,t){const r=JSON.parse((new TextDecoder).decode(t)),n=qU(r,e);if(void 0===n)throw _U;return new AI(String(n))}(e,o),a=zU.child(this.baseKey()).child(new AI(e)).child(new AI(s.toString().substring(1)));let c=null;try{c=await r.get(a)}catch(e){if("ERR_NOT_FOUND"!==e.code)throw e}const u=new sK;if(c){const e=JSON.parse((new TextDecoder).decode(c));u.fromArray(e)}if(i?u.remove(n):(t.unique&&u.remove(n),u.add(n)),0===u.size())await r.delete(a);else{const e=(new TextEncoder).encode(JSON.stringify(u.toArray()));await r.put(a,e)}}catch(e){if(e===_U)return;throw e}}}class sK{constructor(){this.keys=[]}add(e){const t=e.uint8Array();let r=this.binarySearch(t);r<this.keys.length&&this.bytesEqual(this.keys[r],t)||this.keys.splice(r,0,t)}remove(e){const t=e.uint8Array();let r=this.binarySearch(t);r<this.keys.length&&this.keys[r]&&this.bytesEqual(this.keys[r],t)&&this.keys.splice(r,1)}in(e){const t=e.uint8Array(),r=this.binarySearch(t);return r<this.keys.length&&void 0!==this.keys[r]&&this.bytesEqual(this.keys[r],t)}size(){return this.keys.length}toArray(){return[...this.keys]}fromArray(e){this.keys=[...e]}binarySearch(e){let t=0,r=this.keys.length-1;for(;t<=r;){const n=Math.floor((t+r)/2),o=this.bytesCompare(this.keys[n],e);if(o<0)t=n+1;else{if(!(o>0))return n;r=n-1}}return t}bytesCompare(e,t){const r=Math.min(e.length,t.length);for(let n=0;n<r;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return e.length<t.length?-1:e.length>t.length?1:0}bytesEqual(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}}class aK{constructor(e,t,r=!1){this.collection=e,this.token=t,this.readonly=r,this.actions=[],this.discarded=!1,this.committed=!1}async create(...e){const t=new Array(e.length);for(let r=0;r<e.length;r++){if(this.readonly)throw YU;const n=e[r].slice(0);let o=await uK(n);if(""===o){const e=lK(n);o=e.id;const i=e.data;this.collection.validInstance(i),t[r]=o;const s=this.collection.baseKey().child(new AI(o));try{if(await this.collection.db.datastore.has(s))throw eK}catch(e){if(e!==eK)throw new Error(`Error checking if instance exists: ${e instanceof Error?e.message:String(e)}`);throw e}const{data:a}=dK(i);this.actions.push({type:kN.Create,instanceID:o,collectionName:this.collection.name,current:a})}}return t}async verify(...e){try{const t=await(this.token?.pubKey());if(!t)throw new Error("Identity not found");const r=await this.createSaveActions(t,...e),{events:n}=await this.createEvents(r);if(0===n.length)return;for(const e of n)await this.collection.validWrite(t,e)}catch(e){throw new Error(`Verification failed: ${e instanceof Error?e.message:String(e)}`)}}async save(...e){try{const t=await(this.token?.pubKey())||null,r=await this.createSaveActions(t,...e);this.actions.push(...r)}catch(e){throw new Error(`Save failed: ${e instanceof Error?e.message:String(e)}`)}}async createSaveActions(e,...t){const r=[];for(let n=0;n<t.length;n++){if(this.readonly)throw YU;const o=t[n].slice(0);this.collection.validInstance(o);const{data:i}=dK(o),s=await uK(i);if(""===s)throw QU;const a=this.collection.baseKey().child(new AI(s));let c;try{c=await this.collection.db.datastore.get(a)}catch(e){if("ERR_NOT_FOUND"!==e.code)throw e;c=(new TextEncoder).encode("{}")}if(c.length>0&&null!==e){c=await this.collection.filterRead(e,c)||c}r.push({type:kN.Save,instanceID:s,collectionName:this.collection.name,previous:c,current:i})}return r}async delete(...e){for(let t=0;t<e.length;t++){if(this.readonly)throw YU;const r=this.collection.baseKey().child(new AI(e[t]));await this.collection.db.datastore.has(r)&&this.actions.push({type:kN.Delete,instanceID:e[t],collectionName:this.collection.name})}}async has(...e){const t=await(this.collection.db.connector?.validate(this.token));if(t)throw t;const r=await(this.token?.pubKey());for(let t=0;t<e.length;t++){const n=this.collection.baseKey().child(new AI(e[t]));if(!await this.collection.db.datastore.has(n))return!1;{if(!this.collection.readFilter)continue;const e=await this.collection.db.datastore.get(n);if(!await this.collection.filterRead(r,e))return!1}}return!0}async findByID(e){const t=await(this.collection.db.connector?.validate(this.token));if(t)throw t;const r=this.collection.baseKey().child(new AI(e));let n;try{n=await this.collection.db.datastore.get(r)}catch(e){if("ERR_NOT_FOUND"===e.code)throw $U;throw e}const o=await(this.token?.pubKey()),i=await this.collection.filterRead(o,n);if(!i)throw $U;let s;try{s=JSON.parse((new TextDecoder).decode(i))}catch(e){s={}}return s}async find(e){try{const t=await(this.collection.db.connector?.validate(this.token));if(t)throw t;e||(e=new RU);const r=e.validate();if(r)throw new Error(`Invalid query: ${r.message}`);const n=await this.collection.db.datastore.newTransactionExtended(!0);try{const t=await this.newIterator(n,this.collection.baseKey(),e);try{const r=await(this.token?.pubKey()),n=[];let o=0;for(;;){const i=await t.next();if(!i||!1==!i.done)break;let s=null;try{s=await this.collection.filterRead(r,i.value)}catch(e){throw new Error(`Filter read error: ${e instanceof Error?e.message:String(e)}`)}if(s&&(o++,o>e.skip)){let e;try{e=JSON.parse((new TextDecoder).decode(s))}catch(t){e={}}n.push({instanceID:i.instanceID,key:i.key,value:s,marshaledValue:e})}if(e.limit>0&&n.length===e.limit)break}e.sort.fieldPath&&e.sort.fieldPath!==vN&&n.sort(((t,r)=>{const n=qU(t.marshaledValue||{},e.sort.fieldPath),o=qU(r.marshaledValue||{},e.sort.fieldPath);if(void 0===n||void 0===o)return void 0===n&&void 0===o?0:void 0===n?-1:1;try{let t=function(e,t){if(e===t)return 0;if(typeof e!=typeof t)throw new Error("Cannot compare different types");if("string"==typeof e)return e.localeCompare(t);if("number"==typeof e)return e-t;if("boolean"==typeof e)return e===t?0:e?1:-1;throw new Error("Cannot compare values of type "+typeof e)}(n,o);return e.sort.desc&&(t*=-1),t}catch(e){return 0}}));return n.map((e=>e.marshaledValue))}finally{t&&"function"==typeof t.close&&await t.close()}}finally{n.discard()}}catch(e){throw new Error(`Find operation failed: ${e instanceof Error?e.message:String(e)}`)}}async newIterator(e,t,r){const n={prefix:t.toString()};r.index&&(n.index=r.index),r.seek&&(n.start=t.child(new AI(r.seek)).toString());const o=await e.query(n);return{async next(){const e=await o.next();if(e.done)return{done:!0};if(e.value&&r&&e.value.value)try{const t=JSON.parse((new TextDecoder).decode(e.value.value));if(!r.match(t))return this.next()}catch(e){}return{done:!1,key:e.value.key,instanceID:new AI(e.value.key).name(),value:e.value.value}},async close(){o&&"function"==typeof o.return&&await o.return()}}}async modifiedSince(e){const t=await this.collection.db.datastore.newTransactionExtended(!0);try{const r=e=>{const t=e.key.toString();return new AI(t).type()===this.collection.name},n=e.toString(),o=t.queryExtended({prefix:TU.toString(),filters:[r],seekPrefix:TU.child(new AI(n)).toString()}),i=new Set;for await(const e of o){const t=new AI(e.key).name();i.add(t)}return Array.from(i)}finally{t.discard()}}async commit(){try{const{events:e,node:t}=await this.createEvents(this.actions);if(!t)return;await(this.collection.db.connector?.createNetRecord(t,this.token)),await(this.collection.db.dispatcher?.dispatch(e)),this.committed=!0}catch(e){throw new Error(`Commit failed: ${e instanceof Error?e.message:String(e)}`)}}discard(){this.discarded=!0}refreshCollection(){const e=this.collection.db.collections.get(this.collection.name);if(!e)throw JU;this.collection=e}async createEvents(e){if(this.discarded||this.committed)throw XU;try{const[t,r]=await this.collection.db.eventcodec.create(e);return 0===t.length&&r?{events:[],node:null}:{events:t,node:r}}catch(e){throw new Error(`Error creating events: ${e instanceof Error?e.message:String(e)}`)}}}function cK(e,t){if(!e)return{};let r=e.properties||{};if(e.$ref){const n=e.$ref.split("/");if(n.length>0){const e=n[n.length-1],o=t?.[e];o&&(r=o.properties||{})}}return r}async function uK(e){try{const t=JSON.parse((new TextDecoder).decode(e));return t._id?t._id:""}catch(e){throw new Error(`Error getting instance ID: ${e instanceof Error?e.message:String(e)}`)}}function lK(e){const t=Sh();try{const r=JSON.parse((new TextDecoder).decode(e));return r._id=t,{id:t,data:(new TextEncoder).encode(JSON.stringify(r))}}catch(e){throw new Error(`Error setting instance ID: ${e instanceof Error?e.message:String(e)}`)}}function dK(e){const t=1000000n*BigInt(Date.now())+BigInt(Math.floor(1e6*Math.random()));try{const r=JSON.parse((new TextDecoder).decode(e));r["_mod"]=t;return{time:t,data:(new TextEncoder).encode(Vr(r))}}catch(e){throw new Error(`设置 _mod 字段失败: ${e instanceof Error?e.message:String(e)}`)}}let hK=class{constructor(e,t){this.keyCache=[],this.txn=e,this.query=t,this.nextKeys=async()=>[]}async nextSync(){if(""===this.query.index){const e={result:{entry:{},error:null}};let t=!1;for await(const r of this.iter.next())try{const n=JSON.parse((new TextDecoder).decode(r.value));if(t=this.query.match(n),e.result.error)break;if(t)return{result:r,marshaledValue:n}}catch(t){e.result.error=t;break}return t?e:null}if(0===this.keyCache.length)try{const e=await this.nextKeys();if(0===e.length)return{result:{entry:{},error:null}};this.keyCache=[...this.keyCache,...e]}catch(e){return{result:{entry:{},error:e}}}const e=this.keyCache[0];this.keyCache=this.keyCache.slice(1);try{const t=await this.txn.get(e);return{result:{entry:{key:e.toString(),value:t},error:null}}}catch(e){return{result:{entry:{},error:e}}}}async close(){this.iter&&"function"==typeof this.iter.close&&await this.iter.close()}};function pK(e){try{return JSON.parse(e),!0}catch{return!1}}function yK(e){if(!e)return[];try{return JSON.parse((new TextDecoder).decode(e))}catch{return[]}}const fK={name:P.name,code:P.code,encode:P.encode,decode:P.decode};class gK{async create(e){const t=this.convertActions(e),r={patches:t},n=await CN(r);return[this.wrapEvents(t),n]}async reduce(e,t,r,n){const o=await t.newTransactionExtended(!1);try{const t=[];for(const i of this.sortEvents(e)){const e=await this.parseEvent(i);await this.processEvent(e,r,o,n),t.push({type:e.patch.type,collection:e.collectionName||"default",instanceID:e.iD})}return await o.commit(),t}catch(e){throw o.discard(),this.wrapError(e)}}async eventsFromBytes(e){let t=await K.decode(e);if(t&&"object"==typeof t&&"patches"in t&&Array.isArray(t.patches))return this.wrapEvents(t.patches);throw new Error("Invalid block format: expected RecordEvents with patches array")}convertActions(e){const t=BigInt(1e6*Date.now()+Math.floor(1e6*Math.random()));return e.map((e=>({timestamp:t,iD:e.instanceID,collectionName:e.collectionName||"default",patch:e.current?{type:e.type,instanceID:e.instanceID,jSONPatch:e.current}:{type:e.type,instanceID:e.instanceID,jSONPatch:new Uint8Array}})))}wrapEvents(e){return e&&0!==e.length?e.map((e=>({collection:e.collectionName||"default",instanceID:e.iD||e.patch.instanceID,timestamp:e.timestamp,payload:e.patch.jSONPatch?e.patch.jSONPatch:new Uint8Array,marshal:async()=>this.marshalPatchEvent(e)}))):[]}async marshalPatchEvent(e){return P.encode({t:e.timestamp,i:e.iD||e.iD,c:e.collectionName,op:{type:e.patch.type,id:e.patch.instanceID,patch:e.patch.jSONPatch?e.patch.jSONPatch:new Uint8Array}})}sortEvents(e){return[...e].sort(((e,t)=>e.timestamp<t.timestamp?-1:e.timestamp>t.timestamp?1:0))}async parseEvent(e){const t=P.decode(await e.marshal());return{timestamp:t.t,iD:t.i,collectionName:t.c,patch:{type:t.op.type,instanceID:t.op.id,jSONPatch:t.op.patch?P.encode(t.op.patch):new Uint8Array}}}async processEvent(e,t,r,n){const o=t.child(new AI(e.collectionName||"default")).child(new AI(e.iD)),i=await r.get(o).catch((()=>{})),s=e.patch.type===kN.Delete?void 0:e.patch.jSONPatch;if(await n(e.collectionName||"default",o,r,i,s),e.patch.type===kN.Delete)await r.delete(o);else if(s){const e=K.decode(s);if(!e)throw new Error("Failed to decode JSON patch");await r.put(o,e)}}wrapError(e){return new Error(`JSONPATCHER_ERROR: ${e.message}`)}}gK.ENCODER_SETTINGS={codec:fK,hasher:sa,cidVersion:1};const bK=wN.dsPrefix.child(new AI("collection"));class mK extends Error{constructor(e){super(`Collection ${e} already exists`),this.name="CollectionExistsError"}}class wK{constructor(e,t,r,n){this.connector=null,this.dispatcher=null,this.collections=new Map,this.localEventsBus=null,this.writeQueue=Promise.resolve(),this.datastore=e,this.name=n.name||"unnamed",this.eventcodec=n.eventCodec||new gK,this.webLock="webLock_db_"+r}static async newDB(e,t,r,n){const o=n||new pN;o.eventCodec||(o.eventCodec=new gK);const i=new wK(e,t,r.toString(),o);i.name="",i.dispatcher=new DU(e),i.localEventsBus=new SU;try{await i.loadName()}catch(e){throw new Error("Failed to load DB name")}const s=i.name;o.name?i.name=o.name:""===s&&(i.name="unnamed"),await i.saveName(s),await i.reCreateCollections(),i.dispatcher.register(i);try{const e=await t.connectApp(i,r);i.connector=e}catch(e){throw new Error(`Failed to connect app: ${e instanceof Error?e.message:String(e)}`)}if(o.collections&&o.collections.length>0)for(const e of o.collections)try{await i.newCollection(e)}catch(e){throw new Error(`Failed to create collection: ${e instanceof Error?e.message:String(e)}`)}return i}async getDBInfo(e){try{const t=await(this.connector?.net.getThread(this.connector?.threadId,{token:e?.token}));return{id:this.connector?this.connector.threadId.toString():"",name:this.name,addrs:t?t.addrs.map((e=>e.toString())):[],key:t?t.key?.toString():""}}catch(e){throw new Error(`Failed to get DB info: ${e instanceof Error?e.message:String(e)}`)}}async saveName(e){if(this.name!==e){if(!this.name.match(/^[a-zA-Z0-9_-]+$/))throw new Error("Invalid name");await this.datastore.put(wN.dsName,(new TextEncoder).encode(this.name))}}async loadName(){try{const e=await this.datastore.get(wN.dsName);e&&(this.name=(new TextDecoder).decode(e))}catch(e){}}async saveVerno(e){await this.datastore.put(wN.dsVerno,(new TextEncoder).encode(e.toString()))}async loadVerno(){try{const e=await this.datastore.get(wN.dsVerno);if(e)return parseInt((new TextDecoder).decode(e))}catch(e){}return 0}async initCollections(e){for(const t of e)await this.newCollection(t)}async upgradeCollections(e){for(const t of e)await this.newCollection(t,!0)}async newCollection(e,t=!1){if(this.collections.has(e.name)&&!t)throw new mK(e.name);const r=new iK(e.name,e.schema,this);await r.addIndex({path:"_id",unique:!0});for(const t of e.indexes||[])await r.addIndex(t);return this.saveCollection(r),r}async saveCollection(e){try{await this.datastore.put(wN.dsSchemas.child(new AI(e.name)),e.getSchema()),e.rawWriteValidator&&await this.datastore.put(wN.dsValidators.child(new AI(e.name)),(new TextEncoder).encode(e.rawWriteValidator)),e.rawReadFilter&&await this.datastore.put(wN.dsFilters.child(new AI(e.name)),(new TextEncoder).encode(e.rawReadFilter)),this.collections.set(e.name,e)}catch(t){throw new Error(`Failed to save collection ${e.name}: ${t instanceof Error?t.message:String(t)}`)}}async reCreateCollections(){try{const e=this.datastore.query({prefix:wN.dsSchemas.toString()});try{for await(const t of e){const e=t.key.name(),r=JSON.parse((new TextDecoder).decode(t.value));let n,o;try{const t=await this.datastore.get(wN.dsValidators.child(new AI(e)));n=(new TextDecoder).decode(t)}catch(e){if("ERR_NOT_FOUND"!==e.code)throw e}try{const t=await this.datastore.get(wN.dsFilters.child(new AI(e)));o=(new TextDecoder).decode(t)}catch(e){if("ERR_NOT_FOUND"!==e.code)throw e}const i=new iK(e,r,this);try{const t=await this.datastore.get(wN.dsIndexes.child(new AI(e))),r=JSON.parse((new TextDecoder).decode(t));for(const[e,t]of Object.entries(r))e&&i.indexes.set(e,t)}catch(e){if("ERR_NOT_FOUND"!==e.code)throw e}this.collections.set(i.name,i)}}catch(e){throw new Error(`Error re-creating collections: ${e instanceof Error?e.message:String(e)}`)}}catch(e){throw new Error(`Error re-creating collections: ${e instanceof Error?e.message:String(e)}`)}}getCollection(e){const t=this.collections.get(e);if(!t)throw new Error(`Collection ${e} not found`);return t}async close(){}async reduce(e){try{const t=(await this.eventcodec.reduce(e,this.datastore,bK,this.defaultIndexFunc())).map((e=>({collectionName:e.collection,type:e.type,instanceID:e.instanceID})));this.notifyStateChanged(t)}catch(e){throw new Error(`Error reducing events: ${e instanceof Error?e.message:String(e)}`)}}defaultIndexFunc(){return async(e,t,r,n,o)=>{const i=this.collections.get(e);if(!i)throw new Error(`collection (${e}) not found`);n&&await i.indexDelete(r,t,n),o&&await i.indexAdd(r,t,o)}}notifyStateChanged(e){this.localEventsBus}async notifyTxnEvents(e,t){try{await(this.localEventsBus?.send({node:e,token:t}))}catch(e){throw new Error(`Failed to notify transaction events: ${e instanceof Error?e.message:String(e)}`)}}async dispatch(e){for(const t of e)await this.reduce([t])}async validateNetRecordBody(e,t){try{const t=await this.eventcodec.eventsFromBytes(e.data());if(0===t.length)return;for(const e of t){if(!this.collections.get(e.collection))return gN.ErrCollectionNotFound}return}catch(e){return e}}async handleNetRecord(e,t){let r;try{if(!this.connector)return new Error("no connector");r=await NN(this.connector?.net.bstore,e.value())}catch(t){try{const t=await this.getBlockWithRetry(e.value());r=await jN(t)}catch(e){return e}}try{const e=await r.getBody(this.connector?.net,t.read()),n=await this.eventcodec.eventsFromBytes(e.rawData());await this.dispatch(n)}catch(e){return new Error(`error when processing event: ${e instanceof Error?e.message:String(e)}`)}}async getNetRecordCreateTime(e,t){let r,n,o;if(!this.connector)throw new Error("no connector");try{r=await NN(this.connector?.net.bstore,e.value())}catch(t){try{const t=await this.getBlockWithRetry(e.value());r=await jN(t)}catch(e){throw new Error(`Error when decoding block to event: ${e instanceof Error?e.message:String(e)}`)}}try{n=await r.getBody(this.connector?.net.bstore,t.read())}catch(t){throw new Error(`Error when getting body of event on thread ${this.connector?.threadId}/${e.logID()}: ${t instanceof Error?t.message:String(t)}`)}try{o=await this.eventcodec.eventsFromBytes(n.data())}catch(e){throw new Error(`Error when unmarshaling event from bytes: ${e instanceof Error?e.message:String(e)}`)}if(0===o.length)throw new Error("No events found in record");return o[0].timestamp}async getBlockWithRetry(e){let t=500;if(!this.connector)throw new Error("no connector");for(let r=1;r<=3;r++)try{return await e.getBlock(this.connector?.net.bstore)}catch(e){await new Promise((e=>setTimeout(e,t))),t*=2}}async readTxn(e,t,r){const n=new aK(e,r,!0);try{await t(n)}finally{n.discard()}}async writeTxn(e,t,r){const n=this.writeQueue,o=new Promise(((o,i)=>{n.catch((()=>{})).finally((async()=>{const n=new aK(e,r,!1);try{await t(n),await n.commit(),o()}catch(e){i(e)}finally{n.discard()}}))}));return this.writeQueue=o.catch((()=>Promise.resolve())),o}}function vK(e,t){var r=0;if(null!=e[Symbol.asyncIterator])return ee((function*(){var n,o=!1,i=!1;try{for(var s,a=M(e);o=!(s=yield V(a.next())).done;o=!1){var c=s.value;(yield V(t(c,r++)))&&(yield c)}}catch(e){i=!0,n=e}finally{try{o&&null!=a.return&&(yield V(a.return()))}finally{if(i)throw n}}}))();var n=Hd(e),{value:o,done:i}=n.next();if(!0===i)return function*(){}();var s=t(o,r++);if("function"==typeof s.then)return ee((function*(){for(var e of((yield V(s))&&(yield o),n))(yield V(t(e,r++)))&&(yield e)}))();var a=t;return function*(){for(var e of(!0===s&&(yield o),n))a(e,r++)&&(yield e)}()}function kK(e){if(null!=e[Symbol.asyncIterator])return G((function*(){var t,r=[],n=!1,o=!1;try{for(var i,s=M(e);n=!(i=yield s.next()).done;n=!1){var a=i.value;r.push(a)}}catch(e){o=!0,t=e}finally{try{n&&null!=s.return&&(yield s.return())}finally{if(o)throw t}}return r}))();var t=[];for(var r of e)t.push(r);return t}function SK(e,t){return null!=e[Symbol.asyncIterator]?ee((function*(){var r=yield V(kK(e));yield*_(M(r.sort(t)))}))():function*(){var r=kK(e);yield*r.sort(t)}()}function OK(e,t){return null!=e[Symbol.asyncIterator]?ee((function*(){var r=0;if(!(t<1)){var n,o=!1,i=!1;try{for(var s,a=M(e);o=!(s=yield V(a.next())).done;o=!1){var c=s.value;if(yield c,++r===t)return}}catch(e){i=!0,n=e}finally{try{o&&null!=a.return&&(yield V(a.return()))}finally{if(i)throw n}}}}))():function*(){var r=0;if(!(t<1))for(var n of e)if(yield n,++r===t)return}()}class AK{put(e,t,r){return Promise.reject(new Error(".put is not implemented"))}get(e,t){return Promise.reject(new Error(".get is not implemented"))}has(e,t){return Promise.reject(new Error(".has is not implemented"))}delete(e,t){return Promise.reject(new Error(".delete is not implemented"))}putMany(e){var t=this;return ee((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){var n,o=!1,i=!1;try{for(var s,a=M(e);o=!(s=yield V(a.next())).done;o=!1){var{key:c,value:u}=s.value;yield V(t.put(c,u,r)),yield c}}catch(e){i=!0,n=e}finally{try{o&&null!=a.return&&(yield V(a.return()))}finally{if(i)throw n}}}()})).apply(this,arguments)}getMany(e){var t=this;return ee((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){var n,o=!1,i=!1;try{for(var s,a=M(e);o=!(s=yield V(a.next())).done;o=!1){var c=s.value;yield{key:c,value:yield V(t.get(c,r))}}}catch(e){i=!0,n=e}finally{try{o&&null!=a.return&&(yield V(a.return()))}finally{if(i)throw n}}}()})).apply(this,arguments)}deleteMany(e){var t=this;return ee((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){var n,o=!1,i=!1;try{for(var s,a=M(e);o=!(s=yield V(a.next())).done;o=!1){var c=s.value;yield V(t.delete(c,r)),yield c}}catch(e){i=!0,n=e}finally{try{o&&null!=a.return&&(yield V(a.return()))}finally{if(i)throw n}}}()})).apply(this,arguments)}batch(){var e,t=this,r=[],n=[];return{put(e,t){r.push({key:e,value:t})},delete(e){n.push(e)},commit:(e=G((function*(e){yield rP(t.putMany(r,e)),r=[],yield rP(t.deleteMany(n,e)),n=[]})),function(t){return e.apply(this,arguments)})}}_all(e,t){return ee((function*(){throw new Error("._all is not implemented")}))()}_allKeys(e,t){return ee((function*(){throw new Error("._allKeys is not implemented")}))()}query(e,t){var r=this._all(e,t);if(null!=e.prefix){var n=e.prefix;r=vK(r,(e=>e.key.toString().startsWith(n)))}if(Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>vK(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>SK(e,t)),r)),null!=e.offset){var o=0,i=e.offset;r=vK(r,(()=>o++>=i))}return null!=e.limit&&(r=OK(r,e.limit)),r}queryKeys(e,t){var r=this._allKeys(e,t);if(null!=e.prefix){var n=e.prefix;r=vK(r,(e=>e.toString().startsWith(n)))}if(Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>vK(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>SK(e,t)),r)),null!=e.offset){var o=e.offset,i=0;r=vK(r,(()=>i++>=o))}return null!=e.limit&&(r=OK(r,e.limit)),r}}class IK extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Open failed"),W(this,"name",IK.name),W(this,"code",IK.code)}}W(IK,"name","OpenFailedError"),W(IK,"code","ERR_OPEN_FAILED");class xK extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Close failed"),W(this,"name",xK.name),W(this,"code",xK.code)}}W(xK,"name","CloseFailedError"),W(xK,"code","ERR_CLOSE_FAILED");class PK extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Put failed"),W(this,"name",PK.name),W(this,"code",PK.code)}}W(PK,"name","PutFailedError"),W(PK,"code","ERR_PUT_FAILED");class EK extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Get failed"),W(this,"name",EK.name),W(this,"code",EK.code)}}W(EK,"name","GetFailedError"),W(EK,"code","ERR_GET_FAILED");class CK extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Delete failed"),W(this,"name",CK.name),W(this,"code",CK.code)}}W(CK,"name","DeleteFailedError"),W(CK,"code","ERR_DELETE_FAILED");class BK extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Has failed"),W(this,"name",BK.name),W(this,"code",BK.code)}}W(BK,"name","HasFailedError"),W(BK,"code","ERR_HAS_FAILED");class TK extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not Found"),W(this,"name",TK.name),W(this,"code",TK.code)}}W(TK,"name","NotFoundError"),W(TK,"code","ERR_NOT_FOUND");class DK extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Aborted"),W(this,"name",DK.name),W(this,"code",DK.code)}}W(DK,"name","AbortError"),W(DK,"code","ERR_ABORTED"),new AI("SHARDING");var RK,jK,NK=1e3,UK=60*NK,KK=60*UK,qK=24*KK,LK=7*qK,_K=365.25*qK;function MK(e,t){try{if("string"==typeof e&&e.length>0)return function(e){if((e=String(e)).length>100)throw new Error("Value exceeds the maximum length of 100 characters.");var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return NaN;var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*_K;case"weeks":case"week":case"w":return r*LK;case"days":case"day":case"d":return r*qK;case"hours":case"hour":case"hrs":case"hr":case"h":return r*KK;case"minutes":case"minute":case"mins":case"min":case"m":return r*UK;case"seconds":case"second":case"secs":case"sec":case"s":return r*NK;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error("The unit ".concat(n," was matched, but no matching case exists."))}}(e);if("number"==typeof e&&isFinite(e))return null!=t&&t.long?function(e){var t=Math.abs(e);if(t>=qK)return FK(e,t,qK,"day");if(t>=KK)return FK(e,t,KK,"hour");if(t>=UK)return FK(e,t,UK,"minute");if(t>=NK)return FK(e,t,NK,"second");return"".concat(e," ms")}(e):function(e){var t=Math.abs(e);if(t>=qK)return"".concat(Math.round(e/qK),"d");if(t>=KK)return"".concat(Math.round(e/KK),"h");if(t>=UK)return"".concat(Math.round(e/UK),"m");if(t>=NK)return"".concat(Math.round(e/NK),"s");return"".concat(e,"ms")}(e);throw new Error("Value is not a string or number.")}catch(t){var r=function(e){return"object"==typeof e&&null!==e&&"message"in e}(t)?"".concat(t.message,". value=").concat(JSON.stringify(e)):"An unknown error has occured.";throw new Error(r)}}function FK(e,t,r,n){var o=t>=1.5*r;return"".concat(Math.round(e/r)," ").concat(n).concat(o?"s":"")}var zK=function(){try{return localStorage}catch(e){}}();var GK=null!==(RK=null!==(jK=console.debug)&&void 0!==jK?jK:console.log)&&void 0!==RK?RK:()=>{};var VK=function(e){function t(e){var n,o,i,s=null;function a(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];if(a.enabled){var i=a,s=Number(new Date),c=s-(n||s);i.diff=c,i.prev=n,i.curr=s,n=s,r[0]=t.coerce(r[0]),"string"!=typeof r[0]&&r.unshift("%O");var u=0;r[0]=r[0].replace(/%([a-zA-Z%])/g,((e,n)=>{if("%%"===e)return"%";u++;var o=t.formatters[n];if("function"==typeof o){var s=r[u];e=o.call(i,s),r.splice(u,1),u--}return e})),t.formatArgs.call(i,r),(i.log||t.log).apply(i,r)}}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){var n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){var t;return e instanceof Error?null!==(t=e.stack)&&void 0!==t?t:e.message:e},t.disable=function(){var e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){var r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;var r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=MK,t.destroy=function(){},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){for(var r=0,n=0;n<e.length;n++)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.setupFormatters(t.formatters),t.enable(t.load()),t}({formatArgs:function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+MK(this.diff),this.useColors){var t="color: "+this.color;e.splice(1,0,t,"color: inherit");var r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(n=r))})),e.splice(n,0,t)}},save:function(e){try{e?null==zK||zK.setItem("debug",e):null==zK||zK.removeItem("debug")}catch(e){}},load:function(){var e;try{e=null==zK?void 0:zK.getItem("debug")}catch(e){}return!e&&void 0!==globalThis.process&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e},useColors:function(){var e,t,r,n;return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||null==(null===(e=navigator.userAgent)||void 0===e?void 0:e.toLowerCase().match(/(edge|trident)\/(\d+)/)))&&("undefined"!=typeof document&&(null===(t=document.documentElement)||void 0===t||null===(t=t.style)||void 0===t?void 0:t.WebkitAppearance)||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&null!=(null===(r=navigator.userAgent)||void 0===r?void 0:r.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&(null===(n=navigator.userAgent)||void 0===n?void 0:n.toLowerCase().match(/applewebkit\/(\d+)/)))},setupFormatters:function(e){e.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},colors:["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],storage:zK,log:GK});function HK(e){if(null!=e&&0!==(e=e.trim()).length)return e}VK.formatters.b=e=>null==e?"undefined":us.baseEncode(e),VK.formatters.t=e=>null==e?"undefined":ye.baseEncode(e),VK.formatters.m=e=>null==e?"undefined":Js.baseEncode(e),VK.formatters.p=e=>null==e?"undefined":e.toString(),VK.formatters.c=e=>null==e?"undefined":e.toString(),VK.formatters.k=e=>null==e?"undefined":e.toString(),VK.formatters.a=e=>null==e?"undefined":e.toString(),VK.formatters.e=e=>{var t,r;return null==e?"undefined":null!==(t=null!==(r=HK(e.stack))&&void 0!==r?r:HK(e.message))&&void 0!==t?t:e.toString()},function(e){var t=function(e){var t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}("".concat(e,":trace"));VK.enabled("".concat(e,":trace"))&&null!=VK.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=VK("".concat(e,":trace"))),Object.assign(VK(e),{error:VK("".concat(e,":error")),trace:t})}("datastore:core:tiered");class WK extends AK{constructor(e,t){super(),this.child=e,this.transform=t}async put(e,t,r){return this.child.put(this.transform.convert(e),t,r)}async get(e,t){return this.child.get(this.transform.convert(e))}async has(e,t){return this.child.has(this.transform.convert(e),t)}async delete(e,t){return this.child.delete(this.transform.convert(e),t)}async beginTransaction(){const e=await this.getTransaction();return new JK(e,this.transform)}async newTransactionExtended(e){const t=await this.getTransaction();return new JK(t,this.transform)}async getTransaction(){if("function"==typeof this.child.newTransactionExtended)return this.child.newTransactionExtended(!1);throw new Error("Transactions not supported by underlying datastore")}async*query(e){const t=this.queryExtended(e);for await(const e of t)yield{key:new AI(e.key),value:e.value}}async*queryExtended(e){const t=this.transformQuery(e);for await(const e of this.child.query(t)){const t=this.transform.invert(new AI(e.key.toString()));t&&(yield{...e,key:t.toString()})}}transformQuery(e){return $K.process(e,this.transform)}}class JK{constructor(e,t){this.txn=e,this.transform=t}async put(e,t){return this.txn.put(this.transform.convert(e),t)}async delete(e){return this.txn.delete(this.transform.convert(e))}async get(e){return this.txn.get(this.transform.convert(e))}async has(e){return this.txn.has(this.transform.convert(e))}async commit(){return this.txn.commit()}discard(){this.txn.discard()}async*query(e){yield*this.queryExtended(e)}async*queryExtended(e){const t=$K.process(e,this.transform);for await(const e of this.txn.queryExtended(t)){const t=this.transform.invert(new AI(e.key));t&&(yield{...e,key:t.toString()})}}}class $K{static process(e,t){const r=structuredClone(e);return r.prefix&&(r.prefix=t.convert(new AI(r.prefix)).toString()),r.filters&&(r.filters=r.filters.map((e=>this.transformFilter(e,t)))),r}static transformFilter(e,t){if(function(e){return"key"===e.$type&&"string"==typeof e.key}(e)){const r=t.convert(new AI(e.key)).toString(),n=function(e){return e.key.toString()===r};return Object.assign(n,{key:r,$type:"key"}),n}if(function(e){return"prefix"===e.$type&&"string"==typeof e.prefix}(e)){const r=t.convert(new AI(e.prefix)).toString(),n=function(e){return e.key.toString().startsWith(r)};return Object.assign(n,{prefix:r,$type:"prefix"}),n}throw new Error("Unsupported filter type")}static createKeyFilter(e){return t=>t.key.toString()===e}static createPrefixFilter(e){return t=>t.key.toString().startsWith(e)}}class YK{constructor(e){this.prefix=new AI(e)}convert(e){return new AI(this.prefix.toString()+e.toString())}invert(e){const t=e.toString(),r=this.prefix.toString();if(!t.startsWith(r))throw new Error("Invalid prefix");return new AI(t.slice(r.length))}}class ZK{constructor(e){this.value=e}static async issue(e,t){const r=await rR(e.privateKey.raw);return new ZK(await new C.SignJWT({sub:t.toString(),iss:e.getPublic().toString()}).setProtectedHeader({alg:"EdDSA"}).setIssuedAt().sign(r))}async pubKey(){if(this.value)try{const e=B.jwtDecode(this.value);if(!e.sub)throw new Error("Token subject is missing");try{return As.unmarshalString(e.sub)}catch(e){throw new Error(`Failed to unmarshal public key: ${e instanceof Error?e.message:String(e)}`)}}catch(e){throw e instanceof Error&&e.message.includes("Invalid token")?new Error("Invalid token format"):new Error("Token not found or invalid")}}async validate(e){try{const t=await rR(e.raw,"raw"),{payload:r}=await C.jwtVerify(this.value,t);return this.parsePubKey(r.sub)}catch{return}}parsePubKey(e){return new As(ye.decode(e))}get defined(){return this.value.length>0}}new Headers;const QK=new Error("无效的查询条件格式");function XK(e){const t={condition:"",ors:[],sort:{},seek:"",limit:0,skip:0,index:""};""===e&&(e="{}");try{return Object.assign(t,JSON.parse(e)),eq(t)}catch(e){throw new Error(`解析查询JSON失败: ${e instanceof Error?e.message:String(e)}`)}}function eq(e){try{const t=function(e){if(!e)return[];const t=e.split(" and "),r=[];for(const e of t)try{const t=nq(e);if(!t||3!==t.length)continue;const n=tq(t[2]),o=new jU(t[0],oq(t[1]),n);r.push(o)}catch(e){continue}return r}(e.condition),r=new RU;return r.ands=t,r.sort=e.sort,r.seek=e.seek,r.limit=e.limit,r.skip=e.skip,r.index=e.index,r.ors=[],r.ors=e.ors?.map((e=>eq(e)))||[],0===r.limit&&(r.limit=-1),r}catch(e){throw new Error(`转换查询对象失败: ${e instanceof Error?e.message:String(e)}`)}}function tq(e){const t=new NU;if("'"===e[0]||'"'===e[0]){const r=e.substring(1,e.length-1);t.string=r}else if("true"===e||"false"===e){const r="true"===e;t.bool=r}else{const r=parseFloat(e);if(isNaN(r))throw new Error(`无效的数字格式: ${e}`);t.float=r}return t}const rq=["!=",">=","<=","=","<>",">","<"];function nq(e){for(const t of rq){const r=e.indexOf(t);if(r>0){const n=e.indexOf("'"),o=e.indexOf('"');if(n>0&&r>n||o>0&&r>o)continue;const i=new Array(3);return i[0]=e.substring(0,r).trim(),i[1]=t.trim(),i[2]=e.substring(r+t.length).trim(),i}}throw QK}function oq(e){switch(e.trim()){case"=":default:return KU.eq;case"!=":case"<>":return KU.ne;case">":return KU.gt;case"<":return KU.lt;case">=":return KU.ge;case"<=":return KU.le}}var iq,sq,aq={exports:{}};var cq,uq,lq,dq,hq,pq,yq,fq,gq,bq=TextEncoder,mq=TextDecoder,wq=Object.freeze({__proto__:null,TextDecoder:mq,TextEncoder:bq}),vq=o.getDefaultExportFromNamespaceIfNotNamed(wq);function kq(){if(uq)return cq;uq=1;var{TextEncoder:e,TextDecoder:t}=vq,r=new t,n=new e;return cq={decodeText:e=>r.decode(e),encodeText:e=>n.encode(e),concat:function(e,t){var r=new Uint8Array(t),n=0;for(var o of e)r.set(o,n),n+=o.length;return r}},cq}function Sq(){if(pq)return hq;pq=1;return hq={rfc4648:e=>t=>({encode:r=>((e,t,r)=>{for(var n="="===t[t.length-1],o=(1<<r)-1,i="",s=0,a=0,c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)i+=t[o&a>>(s-=r)];if(s&&(i+=t[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i})(r,t,e),decode:r=>((e,t,r)=>{for(var n={},o=0;o<t.length;++o)n[t[o]]=o;for(var i=e.length;"="===e[i-1];)--i;for(var s=new Uint8Array(i*r/8|0),a=0,c=0,u=0,l=0;l<i;++l){var d=n[e[l]];if(void 0===d)throw new SyntaxError("Invalid character "+e[l]);c=c<<r|d,(a+=r)>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(r,t,e)})},hq}function Oq(){if(fq)return yq;fq=1;var e=(sq||(sq=1,iq=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var o=e.charAt(n),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=n}var s=e.length,a=e.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var r=0;if(" "!==e[r]){for(var n=0,o=0;e[r]===a;)n++,r++;for(var i=(e.length-r)*c+1>>>0,u=new Uint8Array(i);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var d=0,h=i-1;(0!==l||d<o)&&-1!==h;h--,d++)l+=s*u[h]>>>0,u[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=d,r++}if(" "!==e[r]){for(var p=i-o;p!==i&&0===u[p];)p++;for(var y=new Uint8Array(n+(i-p)),f=n;p!==i;)y[f++]=u[p++];return y}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var d=t[o],h=0,p=c-1;(0!==d||h<n)&&-1!==p;p--,h++)d+=256*l[p]>>>0,l[p]=d%s>>>0,d=d/s>>>0;if(0!==d)throw new Error("Non-zero carry");n=h,o++}for(var y=c-n;y!==c&&0===l[y];)y++;for(var f=a.repeat(r);y<c;++y)f+=e.charAt(l[y]);return f},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}),iq),t=function(){if(dq)return lq;dq=1;var{encodeText:e}=kq();return lq=class{constructor(t,r,n,o){this.name=t,this.code=r,this.codeBuf=e(this.code),this.alphabet=o,this.codec=n(o)}encode(e){return this.codec.encode(e)}decode(e){for(var t of e)if(this.alphabet&&this.alphabet.indexOf(t)<0)throw new Error("invalid character '".concat(t,"' in '").concat(e,"'"));return this.codec.decode(e)}},lq}(),{rfc4648:r}=Sq(),{decodeText:n,encodeText:o}=kq(),i=[["identity","\0",()=>({encode:n,decode:o}),""],["base2","0",r(1),"01"],["base8","7",r(3),"01234567"],["base10","9",e,"0123456789"],["base16","f",r(4),"0123456789abcdef"],["base16upper","F",r(4),"0123456789ABCDEF"],["base32hex","v",r(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",r(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",r(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",r(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",r(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",r(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",r(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",r(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",r(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",e,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",e,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",e,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",e,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],s=i.reduce(((e,r)=>(e[r[0]]=new t(r[0],r[1],r[2],r[3]),e)),{}),a=i.reduce(((e,t)=>(e[t[1]]=s[t[0]],e)),{});return yq={names:s,codes:a}}var Aq=(gq||(gq=1,function(e,t){var r=Oq(),{encodeText:n,decodeText:o,concat:i}=kq();function s(e){if(Object.prototype.hasOwnProperty.call(r.names,e))return r.names[e];if(Object.prototype.hasOwnProperty.call(r.codes,e))return r.codes[e];throw new Error("Unsupported encoding: ".concat(e))}t=e.exports=function(e,t){if(!t)throw new Error("requires an encoded Uint8Array");var{name:r,codeBuf:n}=s(e);return function(e,t){var r=s(e);r.decode(o(t))}(r,t),i([n,t],n.length+t.length)},t.encode=function(e,t){var r=s(e),o=n(r.encode(t));return i([r.codeBuf,o],r.codeBuf.length+o.length)},t.decode=function(e){e instanceof Uint8Array&&(e=o(e));var t=e[0];return["f","F","v","V","t","T","b","B","c","C","h","k","K"].includes(t)&&(e=e.toLowerCase()),s(e[0]).decode(e.substring(1))},t.isEncoded=function(e){if(e instanceof Uint8Array&&(e=o(e)),"[object String]"!==Object.prototype.toString.call(e))return!1;try{return s(e[0]).name}catch(e){return!1}},t.encoding=s,t.encodingFromData=function(e){return e instanceof Uint8Array&&(e=o(e)),s(e[0])},t.names=Object.freeze(r.names),t.codes=Object.freeze(r.codes)}(aq,aq.exports)),aq.exports),Iq=o.getDefaultExportFromCjs(Aq);class xq{constructor(e,t="utf-8"){this.buffer="",this.isEOF=!1,this.reader=e.getReader(),this.textDecoder=new TextDecoder(t)}async readLine(){if(this.isEOF&&0===this.buffer.length)return null;const e=this.buffer.indexOf("\n");if(-1!==e){const t=this.buffer.substring(0,e);return this.buffer=this.buffer.substring(e+1),t}if(!this.isEOF){const{value:e,done:t}=await this.reader.read();if(t){if(this.isEOF=!0,this.buffer.length>0){const e=this.buffer;return this.buffer="",e}return null}return this.buffer+=this.textDecoder.decode(e,{stream:!0}),this.readLine()}if(this.buffer.length>0){const e=this.buffer;return this.buffer="",e}return null}release(){this.reader.releaseLock()}}const{Buffer:Pq}=Rr,Eq=new AI("/manager");function Cq(e,t){if(null==e.p2pNode||null==e.p2pNode.peerId)throw new Error("p2pNode is null or node privateKey is null");return new fU(e.p2pNode,e.peerAddr,e.token,t,e.protocol)}class Bq{constructor(e,t,r,n,o={},i,s,a){this.store=e,this.network=t,this.dc=r,this.storagePrefix=s,this.opts=o,this.dbs=new Map,this.lock=new Tq,this.chainUtil=i,this.connectedDc=n,this.context=a}async loadDbs(){try{const e={prefix:Eq.toString(),keysOnly:!0},t=this.store.query(e),r=new Map;for await(const e of t)try{const t=e.key.toString().split("/");if(t.length<3)continue;const n=v.ThreadID.fromString(t[2]||"");if(r.has(n.toString()))continue;r.set(n.toString(),!0);const[o,i,s]=await this.wrapDB(this.store,n,this.opts,"",[]);if(s)continue;const a=await wK.newDB(o,this.network,n,i);this.dbs.set(n.toString(),a)}catch(e){}}catch(e){throw e}}async getLogKey(e){const t=`${this.storagePrefix}_${e.toString()}_logkey`;try{const e=await this.store.get(new AI(t));if(e){return Is.fromString(Pq.from(e).toString("hex"))}{const e=await this.newLogKey();return this.store.put(new AI(t),Pq.from(e.raw)),e}}catch(e){if("ERR_NOT_FOUND"===e.code){const e=await this.newLogKey();return this.store.put(new AI(t),Pq.from(e.raw)),e}throw new Error(`Failed to get/create log key: ${e}`)}}async newLogKey(){try{const e=await n.keys.generateKeyPair("Ed25519");return new Is(e.raw)}catch(e){throw new Error(`Failed to generate log key: ${e}`)}}static fromAddr(e){try{const t=e.toString().split("/"),r=t.indexOf(lN.name);if(-1===r||r===t.length-1)throw new Error("thread protocol not found in multiaddr");const n=t[r+1]||"";return v.ThreadID.fromString(n)}catch(e){throw new Error(`Failed to extract ID from multiaddr: ${e.message}`)}}toAddr(){try{return e.multiaddr(`/${lN.name}/${this.toString()}`)}catch(e){throw new Error(`Failed to create multiaddr: ${e.message}`)}}async newDBFromAddr(e,t,r={}){const n=e.id;if(this.dbs.has(n.toString()))throw gN.ErrDBExists;if(r.name&&!Dq(r.name))throw gN.ErrInvalidName;if(t.defined()&&!t.canRead())throw gN.ErrThreadReadKeyRequired;await this.network.addThread(e,{token:r.token,logKey:r.logKey,threadKey:t});const o=r.collections||[],i=r.name||"",[s,a,c]=await this.wrapDB(this.store,n,this.opts,i,o);if(c)throw new Error(`wrapping db: ${c.message}`);const u=await wK.newDB(s,this.network,n,a);return this.dbs.set(n.toString(),u),r.block?await this.network.pullThread(n,bN,{token:r.token}):this.pullThreadBackground(n,r.token),u}async pullThreadBackground(e,t){try{await this.network.pullThread(e,bN,{token:t})}catch(e){}}async preloadDBFromDC(t,n,o,i,s,a,c,u){if(!this)throw gN.ErrNoDbManager;let l,d,h;try{l=await this.decodeThreadId(t)}catch(e){throw e}try{d=await this.getLogKey(l)}catch(e){throw e}try{h=r.peerIdFromPrivateKey(d)}catch(e){throw e}await this.dc._connectToObjNodes(l.toString()).catch((e=>{}));const p=Rq(3e4);try{await this.addLogToThreadStart(p,l,h)}catch(e){}let y,f;try{const e=uR.fromString(a),t=uR.fromString(s);y=new lR(e,t)}catch(e){throw e}let g=!1;if(i.length>10)try{const t=e.multiaddr(i);try{await(this.dc.dcNodeClient?.libp2p.dial(t,{signal:AbortSignal.timeout(3e3)}))&&(g=!0,f=e.multiaddr(i))}catch(e){}}catch(e){}if(g)this.dc._connectToObjNodes(l.toString()).catch((e=>{}));else try{const[e,t]=await(this.dc?._connectToObjNodes(l.toString()));if(!e&&t)throw gN.ErrNoThreadOnDc;const r=this.dc.dcNodeClient?.libp2p.getConnections(undefined);if(!r||0==r.length)throw gN.ErrNoThreadOnDc}catch(e){throw e}let b=[];try{b=JSON.parse(u)}catch(e){throw e}const m={name:o,collections:b.map((e=>({name:e.name,schema:e.schema,indexes:e.indexes||[]}))),key:y,logKey:d,block:c};try{await this.deleteDB(l,!0)}catch(e){if(e!==gN.ErrDBNotFound&&e!==gN.ErrThreadNotFound)throw e}if(null==this.dc.dcNodeClient)throw gN.ErrNoDcNodeClient;const w=Rq(6e5),v=new XR(this.dc,this.connectedDc,this.chainUtil,this.dc.dcNodeClient,this.context),k=await v.createSeekableFileStream(n,"");if(null==k)throw gN.ErrFileNotFound;const S=new yN(f,l);await this.preloadDBFromReader(w,k.createReadableStream(),S,y,m)}async preloadDBFromReader(e,t,r,n,o={}){let i,s,a,c;try{i=Bq.fromAddr(r.addr)}catch(e){throw e}if(this.dbs.has(i.toString()))throw gN.ErrDBExists;if(o.name&&!Dq(o.name))throw gN.ErrInvalidName;if(n.defined()&&!n.canRead())throw gN.ErrThreadReadKeyRequired;try{await this.network.addThread(r,{threadKey:n,logKey:o.logKey,token:o.token})}catch(e){throw e}try{const e=o.collections||[],t=o.name||"";[s,a]=await this.wrapDB(this.store,i,this.opts,t,e)}catch(e){throw e}try{c=await wK.newDB(s,this.network,i,a)}catch(e){throw e}this.dbs.set(i.toString(),c);const u=n.read();if(!u)throw new Error(`read key not found for thread ${i}`);const l=new xq(t);new TextDecoder;let d="";try{const e=await l.readLine();e&&(d=e)}catch(e){throw e}if(""==d)throw new Error(`empty state value for thread ${i}`);d=d.slice(32);const h=d.split(";"),p=[];for(const e of h)try{const t=Aq.decode(e),r=lB.pb.Log.decode(t);p.push(r)}catch(e){continue}try{await this.network.preLoadLogs(i,p)}catch(e){throw await this.deleteDB(i,!1),e}try{await this.importDBStateFromReader(i,l,u)}catch(e){throw await this.deleteDB(i,!1),e}}async exportDBToFile(e,t,r,n){let o,i,s="";[o,i]=await this.network.getPbLogs(t);for(let e=0;o&&e<o.length;e++){if(!o[e])continue;const t=o[e],r=lB.pb.Log.encode(t).finish(),n=Iq.encode("base64",r);s=0===e?n.toString():`${s};${n.toString()}`}let a=s+"\n";const c=this.dbs.get(t.toString());if(!c)throw gN.ErrDBNotFound;const u=await c.datastore.newTransactionExtended(!0);try{const e=new RU,o=new AI("/"),s=await async function(e,t,r){const n=new hK(e,r);let o;o=r.index?zU.child(t).child(new AI(r.index)):t;const i={query:{prefix:o.toString()}};r.sort.fieldPath===vN&&(r.sort.desc?i.orders=[{orderByKeyDescending:!0}]:i.orders=[{orderByKey:!0}]),r.seek&&(i.seekPrefix=o.child(new AI(r.seek)).toString());try{const t=await e.queryExtended(i);if(n.iter=t,!r.index)return n.nextKeys=async()=>[],n;let s=!0;return n.nextKeys=async()=>{const e=[];for(;e.length<100;){const t=await n.iter.nextSync();if(!t){if(s)throw FU;return e}s=!1;const i=new AI(t.result.entry.key),a=o.name(),c=i.name();let u=c;if(pK(c)){const e=JSON.parse(c);u=null!==e?e:c}else u=c;try{const n=JSON.stringify({[a]:u}),o=JSON.parse(n);if(r.match(o)){const r=yK(t.result.entry.value);for(const t of r)e.push(new AI((new TextDecoder).decode(t)))}}catch(e){continue}}return e},n}catch(e){throw e}}(u,o,e);for await(const e of s.iter.next()){if(e.error)throw e.error;let t;if(n){const r=await n.encrypt(e.entry.value),o=Iq.encode("base64",r);t=`${e.entry.key}|${o.toString()}`}else{const r=Iq.encode("base64",e.entry.value);t=`${e.entry.key}|${r.toString()}`}a+=t+"\n"}s.close(),u.discard();const c=new Blob([a],{type:"text/plain"}),l=URL.createObjectURL(c),d=document.createElement("a");return d.href=l,d.download=r||`db-export-${t.toString().substring(0,8)}.txt`,document.body.appendChild(d),d.click(),setTimeout((()=>{document.body.removeChild(d),URL.revokeObjectURL(l)}),100),i}catch(e){throw u.discard(),e}}async importDBStateFromReader(e,t,r){let n;if(n=this.dbs.get(e.toString()),!n)throw gN.ErrDBNotFound;const o=n.defaultIndexFunc();new TextDecoder;let i="";for(;i=await t.readLine(),i;){let e;try{e=await n.datastore.newTransactionExtended(!1)}catch(e){throw new Error(`创建事务错误: ${e instanceof Error?e.message:String(e)}`)}try{const t=i.split("|");if(2!==t.length)throw e.discard(),new Error("无效的记录格式");const n=t[0],s=t[1]||"";let a;try{a=Aq.decode(s)}catch(t){throw await e.discard(),new Error(`multibase解码失败: ${t instanceof Error?t.message:String(t)}`)}let c=a;if(r)try{c=await r.decrypt(a)}catch(t){throw await e.discard(),new Error(`解密值失败: ${t instanceof Error?t.message:String(t)}`)}const u=new AI(n||"");try{if(await e.has(u)){e.discard();continue}}catch(t){throw e.discard(),new Error(`检查键存在性失败: ${t instanceof Error?t.message:String(t)}`)}try{await e.put(u,c)}catch(t){throw e.discard(),new Error(`存储值失败: ${t instanceof Error?t.message:String(t)}`)}const l=n?.split("/");if(!l||l.length<2)throw e.discard(),new Error("无效的键格式: 未找到集合名称");const d=l[l.length-2]||"";try{await o(d,u,e,c)}catch(t){throw e.discard(),new Error(`应用索引失败: ${t instanceof Error?t.message:String(t)}`)}try{await e.commit()}catch(t){throw e.discard(),new Error(`提交事务失败: ${t instanceof Error?t.message:String(t)}`)}}catch(t){try{e.discard()}catch{}throw t}}}async wrapDB(e,t,r,n,o){if(!await this.validateThreadId(t.toString()))return[null,null,new Error("Invalid Thread ID")];const i=Eq.child(new AI(t.toString())).toString(),s=function(e,t){return new WK(e,t)}(e,new YK(i));return[s,{name:n,collections:[...r.collections||[],...o],eventCodec:r.eventCodec,debug:r.debug},null]}async listDBs(){const e=new Map;for(const[t,r]of this.dbs){const n=v.ThreadID.fromString(t);await this.network.getThread(n),e.set(n,r)}return e}async ifSyncDBToDCSuccess(e){try{const[t,n]=await this.chainUtil.objectState(e);return!(!t||n)&&new Promise((n=>{const o=setTimeout((()=>n(!1)),2e4);(async()=>{for(const i of Object.keys(t.peers))try{const s=r.peerIdFromString(i),a=v.ThreadID.fromString(e),c=await this.network.getThreadFromPeer(a,s,{}),u=await this.network.getThread(a);if(this.compareThreadSync(u,c,t))return clearTimeout(o),void n(!0)}catch{continue}n(!1)})()}))}catch{return!1}}compareThreadSync(e,t,r){for(const n of e.logs){if(!r.logs.has(n.id.toString()))continue;if(!n.head)continue;const e=t.logs.find((e=>e.id===n.id));if(!e?.head)return!1;if(!e||n.head.counter>e.head.counter)return!1}return!0}async ifDbInitSuccess(e){try{const t=await this.getLogKey(e),n=r.peerIdFromPrivateKey(t),[o,i]=await this.chainUtil.objectState(e.toString());if(!o||i)return!1;return!!o&&o?.logs.has(n.toString())}catch{return!1}}async syncDBFromDC(t,n,o,i,s,a,c,u){try{const t=await this.decodeThreadId(n),l=await this.getLogKey(t);r.peerIdFromPrivateKey(l);await this.dc._connectToObjNodes(n);const d=uR.fromString(a),h=uR.fromString(s),p=new lR(d,h);let y,f,g;if(i.length>0)try{y=await(this.dc.dcNodeClient?.libp2p.dial(e.multiaddr(i),{signal:AbortSignal.timeout(KE)}))}catch(e){e.message}if(y)f=y?.remotePeer,g=y.remoteAddr;else{const[e,t]=await this.dc._connectToObjNodes(n);if(!e)throw new Error("connect to obj nodes failed");g=e}const b={name:o,collections:u.map((e=>({name:e.name,schema:e.schema,indexes:e.indexes||[]}))),key:p,logKey:l,block:c};try{await this.deleteDB(t,!1)}catch(e){const t=e.message;if(t!=gN.ErrDBNotFound.message&&t!=gN.ErrThreadNotFound.message)throw e}const m=new yN(g,t);return await this.newDBFromAddr(m,p,b),null}catch(e){const t=e.message;return t==gN.ErrorThreadIDValidation.message?t:e}}async getDBRecordsCount(e){let t=0;try{const r=await this.decodeThreadId(e),n=await this.network.getThread(r);if(!n)return t;for(const e of n.logs)e.head&&t<e.head.counter&&(t=e.head.counter)}catch(e){}return t}async addLogToThread(e,t,r){let n;try{n=await this.chainUtil.getBlockHeight()||0}catch(e){throw e}const o=qr(n||0),i=(new TextEncoder).encode(this.connectedDc.nodeAddr?.getPeerId()||""),s=new Uint8Array([...(new TextEncoder).encode(t.toString()),...(new TextEncoder).encode(r.toString()),...o,...i]);let a;try{a=await this.context.sign(s)}catch(e){throw e}if(!this.connectedDc?.client)throw gN.ErrNoDcPeerConnected;const c={token:new ZK(this.connectedDc.client.token),blockHeight:n,signature:a},u=Cq(this.connectedDc.client,this.network);await u.addLogToThread(t.toString(),r.toString(),c)}async addLogToThreadStart(e,t,r){e||(e=Rq(3e4));const n=new AbortController,o=e?.signal||n.signal,[i,s]=await this.chainUtil.objectState(t.toString());if(i&&!s){const e=this.context.getPublicKey();let t=!1;for(const r of i.users){if(r.replace("0x","")===e.toString()){t=!0;break}}if(!t)throw new Error("user not in the thread");if(!!i&&i.logs.has(r.toString()))return}let a=null;if(e.deadline){const t=e.deadline.getTime()-Date.now();t>0&&(a=setTimeout((()=>{n.abort()}),t))}let c=0;let u=!1;try{await this.addLogToThread(e,t,r)}catch(e){}let l=!1;const d=async()=>{if(o.aborted||l)a&&clearTimeout(a);else{if(await this.ifDbInitSuccess(t))return a&&clearTimeout(a),u=!0,void(l=!0);if(c>=10){try{await this.addLogToThread(e,t,r)}catch(e){}c=0}else c++;setTimeout(d,1e3)}};d(),await new Promise((e=>{const t=setInterval((()=>{u&&(clearInterval(t),e())}),1e3);o.addEventListener("abort",(()=>{clearInterval(t),e()}))}))}async newDB(e,t,n,o){if(!this.connectedDc?.client)return["",gN.ErrNoDcPeerConnected];try{const i=Cq(this.connectedDc.client,this.network),s=await i.requestThreadID(),a=await this.decodeThreadId(s),c=await this.getLogKey(a),u=(c.publicKey,r.peerIdFromPrivateKey(c)),l=uR.fromString(n),d=uR.fromString(t),h=new lR(l,d),p=await this.chainUtil.getBlockHeight()||0,y=qr(p||0);if(!this.connectedDc?.nodeAddr)return["",gN.ErrNodeAddrIsNull];const f=await XD(this.connectedDc.nodeAddr),g=(new TextEncoder).encode(f.toString()),b=Kr(50<<20),m=(new TextEncoder).encode(s),w=qr(UR.Threaddbtype),v=new Uint8Array([...m,...b,...y,...w,...g]),k=await this.context.sign(v),S={threadKey:h,logKey:c,token:new ZK(this.connectedDc.client.token),blockHeight:p,signature:k},O=await i.createThread(a.toString(),S),A={name:e,collections:o.map((e=>({name:e.name,schema:e.schema,indexes:e.indexes||[]}))),key:h,logKey:c,block:!0},I=[];for(const e of O.addrs)try{await this.newDBFromAddr(e,h,A);break}catch(e){I.push(e.message)}if(I.length===O.addrs.length)throw new Error(`create db failed:${I.join(",")}`);const x=Rq(3e4);return await this.addLogToThreadStart(x,a,u),[a.toString(),null]}catch(e){return["",e]}}async refreshDBFromDC(e){try{const t=await this.decodeThreadId(e);return await this.network.pullThread(t,600,{multiPeersFlag:!0}),null}catch(e){return e}}async syncDBToDC(e){if(!this.network)return gN.ErrP2pNetworkNotInit;try{const t=await this.decodeThreadId(e);return await this.network.exchange(t),null}catch(e){return e}}async upgradeCollections(e,t){try{const r=await this.decodeThreadId(e),n=this.dbs.get(r.toString());return n?(await n.upgradeCollections(t),null):gN.ErrDBNotFound}catch(e){return e}}async decodeThreadId(e){if(!e)throw new Error("Thread ID is empty");try{if(!/^[a-zA-Z0-9]+$/.test(e))throw gN.ErrorThreadIDValidation;const t=v.ThreadID.fromString(e);if(t.toBytes().length<32)throw new Error("Thread ID too short");return t}catch(e){if(e.message===gN.ErrorThreadIDValidation.message)throw e;throw new Error("Failed to decode thread ID: $errMsg}")}}async validateThreadId(e){try{return await this.decodeThreadId(e),!0}catch{return!1}}async close(){for(const e of this.dbs.values())await e.close();this.dbs.clear()}async getDB(e,t){try{await this.network.getThread(e,{token:t?.token})}catch(e){throw e}const r=this.dbs.get(e.toString());if(!r)throw gN.ErrDBNotFound;return r}async getDBInfo(e,t){let r=null;try{const n=this.dbs.get(e.toString());if(!n)throw gN.ErrDBNotFound;if(r=await n.getDBInfo(t),!r||null===r)throw new Error(`No info available for db ${e}`)}catch(e){return[null,e]}return[r,null]}async deleteDB(e,t,r){try{await this.network.getThread(e,{token:r?.token})}catch(e){throw e}const n=this.dbs.get(e.toString());if(!n)throw gN.ErrDBNotFound;try{await n.close()}catch(e){throw e}if(t)try{await this.network.deleteThread(e,{token:r?.token,apiToken:n.connector?.token})}catch(e){throw e}try{await this.deleteThreadNamespace(e)}catch(e){throw e}this.dbs.delete(e.toString())}async deleteThreadNamespace(e){const t={prefix:Eq.child(new AI(e.toString())).toString(),keysOnly:!0},r=this.store.query(t);for await(const e of r)await this.store.delete(e.key)}async create(e,t,r){try{const e=JSON.parse(r);e&&"object"==typeof e&&"_mod"in e&&(delete e._mod,r=JSON.stringify(e))}catch(e){throw new Error("Invalid instance JSON format")}try{const n=v.ThreadID.fromString(e),o=(await this.getDB(n)).getCollection(t);if(!o)throw new Error("Collection does not exist");const i=await o.create(Pq.from(r));return i?i.toString():""}catch(e){throw e}}async delete(e,t,r){try{const n=v.ThreadID.fromString(e),o=(await this.getDB(n)).getCollection(t);if(!o)throw new Error("Collection does not exist");await o.delete(r)}catch(e){throw e}}async save(e,t,r){try{const n=v.ThreadID.fromString(e);try{const e=JSON.parse(r);e&&"object"==typeof e&&"_mod"in e&&(delete e._mod,r=JSON.stringify(e))}catch(e){throw new Error("Invalid instance JSON format")}const o=(await this.getDB(n)).getCollection(t);if(!o)throw new Error("Collection does not exist");await o.save(Pq.from(r))}catch(e){throw e}}async deleteMany(e,t,r){try{const n=v.ThreadID.fromString(e),o=(await this.getDB(n)).getCollection(t);if(!o)throw new Error("Collection does not exist");let i=[];if(""===(r=r.trim()))return;if("["!==r[0])i=r.split(",");else try{i=JSON.parse(r)}catch(e){i=[r]}const s=i.length;for(let e=0;e<s;e+=100){const t=i.slice(e,Math.min(e+100,s));await o.deleteMany(t)}}catch(e){throw e}}async has(e,t,r){try{const n=v.ThreadID.fromString(e),o=(await this.getDB(n)).getCollection(t);return!!o&&await o.has(r)}catch(e){return!1}}async find(e,t,r){try{r||(r="{}");const n=XK(r),o=v.ThreadID.fromString(e),i=(await this.getDB(o)).getCollection(t);if(!i)throw new Error("Collection does not exist");const s=await i.find(n);if(Array.isArray(s))return Vr(s);{const e=s;return Pq.concat([Pq.from("["),Pq.concat(e.map(((t,r)=>Pq.concat([t,r<e.length-1?Pq.from(","):Pq.from("")])))),Pq.from("]")]).toString()}}catch(e){throw e}}async findByID(e,t,r){try{const n=v.ThreadID.fromString(e),o=(await this.getDB(n)).getCollection(t);if(!o)throw new Error("Collection does not exist");const i=await o.findByID(r);return i instanceof Pq?i.toString():Vr(i)}catch(e){throw e}}async modifiedSince(e,t,r){try{const n=v.ThreadID.fromString(e),o=(await this.getDB(n)).getCollection(t);if(!o)throw new Error("Collection does not exist");const i=await o.modifiedSince(r);return JSON.stringify(i)}catch(e){throw e}}}class Tq{constructor(){this.locks=new Map}async acquire(e,t){for(;this.locks.has(e);)await this.locks.get(e);let r;const n=new Promise((e=>r=e));this.locks.set(e,n);try{return await t()}catch(e){throw e}finally{this.locks.delete(e),r()}}}function Dq(e){return/^[a-zA-Z0-9_-]+$/.test(e)}function Rq(e){const t={deadline:new Date(Date.now()+e)};return 0===e&&(t.deadline=void 0),"undefined"!=typeof AbortController&&(t.signal=(new AbortController).signal),t}const jq=kR("DatabaseModule");class Nq{constructor(){this.moduleName=exports.CoreModuleName.DATABASE,this.initialized=!1}async initialize(e){try{return this.context=e,this.initialized=!0,!0}catch(e){return jq.error("数据库模块初始化失败:",e),!1}}async shutdown(){this.initialized=!1}async resetDBManager(){this.context.dbManager=void 0}async initDBManager(){try{if(this.assertInitialized(),this.context.dbManager)return null;const e=await async function(e){const t=new u.IDBDatastore(e);return await t.open(),new Bj(t)}(this.context.appInfo?.appName),t=await async function(e){return new zj(e)}(e),r=await async function(e,t){t||(t={CacheSize:1024,GCPurgeInterval:72e5,GCInitialDelay:6e4});const r=new Zj(e,t);return t.CacheSize>0?r.cache=new A.LRUCache({max:t.CacheSize}):r.cache=new A.LRUCache({max:0}),r}(e),n=new sN(e),o=function(e){return new cN(e)}(e),i=new AN(t,r,n,o),s=x.dagCbor(this.context.dcNodeClient);if(!this.context.publicKey)throw new Error("公钥未初始化");const a=new EU(this.context.dcutil,this.context.dcChain,this.context.dcNodeClient.libp2p,this.context.grpcServer,i,this.context.dcNodeClient.blockstore,s,this.context),c=new Bq(e,a,this.context.dcutil,this.context.connectedDc,{},this.context.dcChain,"dc-",this.context);return await c.loadDbs(),this.context.dbManager=c,jq.info("数据库管理器初始化成功"),null}catch(e){return jq.error("初始化数据库管理器失败:",e),e}}async newDB(e,t,r,n){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");const[o,i]=await this.context.dbManager.newDB(e,t,r,n);if(i)throw jq.error("创建数据库失败:",i),i;return jq.info(`创建数据库 ${e} 成功,线程ID: ${o}`),[o,null]}catch(t){return jq.error(`创建数据库 ${e} 失败:`,t),[null,t instanceof Error?t:new Error(String(t))]}}async loadVerno(e){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");const t=v.fromString(e),r=await this.context.dbManager.getDB(t);if(!r)return jq.error("数据库信息为空"),0;return await r.loadVerno()}catch(e){return jq.error("加载数据库版本号失败:",e),0}}async saveVerno(e,t){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");const r=v.fromString(e),n=await this.context.dbManager.getDB(r);return n?(await n.saveVerno(t),0):(jq.error("数据库信息为空"),-1)}catch(e){return jq.error("加载数据库版本号失败:",e),-1}}async syncDbFromDC(e,t,r,n,o,i,s){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");const a=Rq(6e4);return await this.context.dbManager.syncDBFromDC(a,e,t,r,n,o,i,s),jq.info(`从DC同步数据库 ${t} 成功`),null}catch(e){return jq.error(`从DC同步数据库 ${t} 失败:`,e),e instanceof Error?e:new Error(String(e))}}async refreshDBFromDC(e,t){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");return await this.context.dbManager.refreshDBFromDC(e),null}catch(t){return jq.error(`刷新数据库 ${e} 失败:`,t),t}}async syncDBToDC(e){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");return await this.context.dbManager.syncDBToDC(e),jq.info(`同步数据库 ${e} 到DC成功`),null}catch(t){return jq.error(`同步数据库 ${e} 到DC失败:`,t),t}}async upgradeCollections(e,t){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");return await this.context.dbManager.upgradeCollections(e,t),null}catch(e){return e}}async close(){try{if(this.assertInitialized(),!this.context.dbManager)throw new Error("数据库管理器未初始化");return await this.context.dbManager.close(),jq.info("数据库管理器关闭成功"),null}catch(e){return jq.error("关闭数据库管理器失败:",e),e instanceof Error?e:new Error(String(e))}}async getDBInfo(e){try{if(!e||0==e.length)return[null,new Error("数据库ID不能为空")];if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)return[null,new Error("数据库管理器未初始化")];const t=v.fromString(e),[r,n]=await this.context.dbManager.getDBInfo(t);return[r,n]}catch(e){return jq.error("获取数据库信息失败:",e),[null,e instanceof Error?e:new Error(String(e))]}}async create(e,t,r){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");const n=await this.context.dbManager.create(e,t,r);return jq.info(`创建实例成功,ID: ${n}`),[n,null]}catch(e){return jq.error("创建实例失败:",e),[null,e instanceof Error?e:new Error(String(e))]}}async delete(e,t,r){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");return await this.context.dbManager.delete(e,t,r),jq.info(`删除实例成功,ID: ${r}`),null}catch(e){return jq.error("删除实例失败:",e),e instanceof Error?e:new Error(String(e))}}async save(e,t,r){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");return await this.context.dbManager.save(e,t,r),jq.info("更新实例成功"),null}catch(e){return jq.error("更新实例失败:",e),e instanceof Error?e:new Error(String(e))}}async deleteMany(e,t,r){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");return await this.context.dbManager.deleteMany(e,t,r),jq.info("删除多个实例成功"),null}catch(e){return jq.error("删除多个实例失败:",e),e instanceof Error?e:new Error(String(e))}}async has(e,t,r){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");return await this.context.dbManager.has(e,t,r)}catch(e){return jq.error("检查实例是否存在失败:",e),!1}}async find(e,t,r){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");return[await this.context.dbManager.find(e,t,r),null]}catch(e){return jq.error("查询实例失败:",e),[null,e instanceof Error?e:new Error(String(e))]}}async findByID(e,t,r){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");return[await this.context.dbManager.findByID(e,t,r),null]}catch(e){return jq.error("通过ID查询实例失败:",e),[null,e instanceof Error?e:new Error(String(e))]}}async modifiedSince(e,t,r){try{if(this.assertInitialized(),await this.initDBManager(),!this.context.dbManager)throw new Error("数据库管理器未初始化");return[await this.context.dbManager.modifiedSince(e,t,r),null]}catch(e){return jq.error("查询修改时间大于指定时间的实例ID失败:",e),[null,e instanceof Error?e:new Error(String(e))]}}assertInitialized(){if(!this.initialized)throw new Error("数据库模块未初始化")}}class Uq{constructor(e,t,r){this.sendMsgToUserBox=async e=>{const t=this.client.peerAddr.getPeerId();if(!t)throw new Error("peerId is undefined");if(!this.receiverClient)throw new Error("receiverClient is undefined");const r=await this.getToUserBoxAuth(e.signature),n=new IE.pb.SendMsgToUserBoxRequest({});n.msg=e,n.AuthSignature=r,n.PeerId=(new TextEncoder).encode(t.toString());const o=IE.pb.SendMsgToUserBoxRequest.encode(n).finish(),i=new b.Libp2pGrpcClient(this.receiverClient.p2pNode,this.receiverClient.peerAddr,this.receiverClient.token,this.receiverClient.protocol);try{const e=await i.unaryCall("/dcnet.pb.Service/SendMsgToUserBox",o,3e4);return IE.pb.SendMsgToUserBoxReply.decode(e).flag}catch(e){if(-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.receiverClient.GetToken(this.context.appInfo.appId||"",this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=await i.unaryCall("/dcnet.pb.Service/SendMsgToUserBox",o,3e4);return IE.pb.SendMsgToUserBoxReply.decode(e).flag}throw e}},this.getToUserBoxAuth=async e=>{const t=new IE.pb.GetToUserBoxAuthRequest({});t.msgSignature=e;const r=IE.pb.GetToUserBoxAuthRequest.encode(t).finish(),n=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);try{const e=await n.unaryCall("/dcnet.pb.Service/GetToUserBoxAuth",r,3e4);return IE.pb.GetToUserBoxAuthReply.decode(e).signature}catch(e){if(-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(this.context.appInfo.appId||"",this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=await n.unaryCall("/dcnet.pb.Service/GetToUserBoxAuth",r,3e4);return IE.pb.GetToUserBoxAuthReply.decode(e).signature}throw e}},this.client=e,this.context=t,this.receiverClient=r}async getMaxKeyFromUserBox(e){const t=new IE.pb.GetMaxKeyFromUserBoxRequest;t.appId=(new TextEncoder).encode(e);const r=IE.pb.GetMaxKeyFromUserBoxRequest.encode(t).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/GetMaxKeyFromUserBox",r,3e4),n=IE.pb.GetMaxKeyFromUserBoxReply.decode(t);return n.maxkey?fa(n.maxkey):""}catch(t){if(-1!=t.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(e,this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const t=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),n=await t.unaryCall("/dcnet.pb.Service/GetMaxKeyFromUserBox",r,3e4),o=IE.pb.GetMaxKeyFromUserBoxReply.decode(n);return o.maxkey?fa(o.maxkey):""}if(-1!=t.message.indexOf("datastore: key not found"))return"";throw t}}async getMsgFromUserBox(e,t,r){const n=new IE.pb.GetMsgFromUserBoxRequest;n.appId=(new TextEncoder).encode(e),n.blockheight=0,n.seekKey=(new TextEncoder).encode(t),n.limit=r;const o=IE.pb.GetMsgFromUserBoxRequest.encode(n).finish();try{const e=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),t=await e.unaryCall("/dcnet.pb.Service/GetMsgFromUserBox",o,3e4);return IE.pb.GetMsgFromUserBoxReply.decode(t).toJSON()}catch(t){if(-1!=t.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(e,this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const t=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),r=await t.unaryCall("/dcnet.pb.Service/getMsgFromUserBox",o,3e4);return IE.pb.GetMsgFromUserBoxReply.decode(r).toJSON()}throw t}}}let Kq=class extends Error{constructor(e){super(e),this.name="DCError"}};const qq={ErrNoDcPeerConnected:new Kq("no dc peer connected"),ErrGetUserInfoError:new Kq("get user info error"),ErrNoAccountPeerConnected:new Kq("no account peer connected"),ErrNoReceiverPeerConnected:new Kq("no receiver peer connected")};class Lq{constructor(e,t,r){this.sendMsgToUserBox=async(e,t,r)=>{try{if(!this.context.AccountBackupDc.client)return[null,qq.ErrNoAccountPeerConnected];const n=As.edPubkeyFromStr(t),o=await this.context.getPublicKey(),i=await this.generateMsqBoxReq(e,n,r);let s=await this.dc.connectToUserDcPeer(n.raw);if(!s)return[null,qq.ErrNoReceiverPeerConnected];const a=await s.GetToken(e,o.string(),(e=>this.context.sign(e)));s.token=a;const c=new Uq(this.context.AccountBackupDc.client,this.context,s);return[await c.sendMsgToUserBox(i),null]}catch(e){throw e}},this.getMsgFromUserBox=async(e,t=100)=>{try{if(!this.context.AccountBackupDc.client)return[null,qq.ErrNoAccountPeerConnected];const r=await this.context.getPublicKey(),n=r.string(),o=await this.dc.connectToUserAllDcPeers(r.raw);if(!o)return[null,qq.ErrNoDcPeerConnected];let i=[];for(const r of o)if(r){const o=r.peerAddr.getPeerId()||"",s=this.context.getPublicKey().string();if(!r.token){const t=await r.GetToken(e,s,(e=>this.context.sign(e)));r.token=t}const a=new Uq(r,this.context);let c=await a.getMaxKeyFromUserBox(e);const u=localStorage.getItem("userBoxMaxKey_"+s)||"";let l=u?JSON.parse(u):{};if(c){(l[n]||{})[o]=c}let d=!0;for(;d;)try{const r=await a.getMsgFromUserBox(e,c,t),n=r&&r.msgs?r.msgs:[];n.map((e=>{e&&e.messageId&&i.push(e)})),n.length<t&&(c&&localStorage.setItem("userBoxMaxKey_"+s,JSON.stringify(l)),d=!1)}catch(e){}}return[i,null]}catch(e){return[null,e]}},this.generateMsqBoxReq=async(e,t,r)=>{const n=`${r}${1e6*Date.now()}`,o=(new TextEncoder).encode(n),i=await sa.digest(o),s=T.CID.create(1,85,i),a=(new TextEncoder).encode(s.toString()),c=(new TextEncoder).encode(e),u=await this.context.getPublicKey(),l=(new TextEncoder).encode(u.string()),d=(new TextEncoder).encode(t.string()),h=await this.chainUtil.getBlockHeight()||0,p=qr(h),y=(new TextEncoder).encode(r),f=await t.encrypt(y),g=new Uint8Array([...a,...d,...c,...p,...f]),b=await this.context.sign(g),m=new IE.pb.UserMsg({});return m.appId=(new TextEncoder).encode(e),m.blockheight=h,m.encryptMsg=f,m.messageId=a,m.receiverPubkey=d,m.senderPubkey=l,m.signature=b,m},this.dc=e,this.chainUtil=t,this.context=r}}const _q=kR("MessageModule");class Mq{constructor(){this.moduleName=exports.CoreModuleName.MESSAGE,this.initialized=!1}async initialize(e){try{return this.context=e,this.messageManager=new Lq(e.dcutil,e.dcChain,e),this.initialized=!0,!0}catch(e){return _q.error("消息模块初始化失败:",e),!1}}async shutdown(){this.initialized=!1}async sendMsgToUserBox(e,t){try{this.assertInitialized();const r=await this.messageManager.sendMsgToUserBox(this.context.appInfo?.appId||"",e,t);return _q.info(`发送消息到用户 ${e} 成功`),r}catch(t){return _q.error(`发送消息到用户 ${e} 失败:`,t),[null,t]}}async getMsgFromUserBox(e){try{this.assertInitialized();const t=await this.messageManager.getMsgFromUserBox(this.context.appInfo?.appId||"",e);return _q.info("获取用户消息成功"),t}catch(e){return _q.error("获取用户消息失败:",e),[null,e]}}assertInitialized(){if(!this.initialized)throw new Error("消息模块未初始化")}}class Fq{constructor(e,t){this.client=e,this.context=t}async configThemeObjAuth(e,t,r,n,o,i,s,a,c,u,l){const d=new IE.pb.ConfigThemeObjAuthRequest({});d.appId=(new TextEncoder).encode(t),d.themeAuthor=(new TextEncoder).encode(r),d.theme=(new TextEncoder).encode(e),d.blockheight=n,d.content=(new TextEncoder).encode(s),d.contentCid=(new TextEncoder).encode(i),d.contentSize=a,d.signature=u,d.type=c,d.userPubkey=(new TextEncoder).encode(o),l&&(d.vaccount=(new TextEncoder).encode(l));const h=IE.pb.ConfigThemeObjAuthRequest.encode(d).finish(),p=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);try{const e=await p.unaryCall("/dcnet.pb.Service/ConfigThemeObjAuth",h,3e4);return IE.pb.ConfigThemeObjAuthReply.decode(e).flag}catch(e){if(-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(t,this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=await p.unaryCall("/dcnet.pb.Service/ConfigThemeObjAuth",h,3e4);return IE.pb.GetUserCommentsReply.decode(e).flag}throw e}}async setKeyValue(e,t,r,n,o,i,s,a,c,u,l){const d=new IE.pb.SetKeyValueRequest({});d.appId=(new TextEncoder).encode(t),d.themeAuthor=(new TextEncoder).encode(r),d.theme=(new TextEncoder).encode(e),d.blockheight=n,d.content=(new TextEncoder).encode(s),d.contentCid=(new TextEncoder).encode(i),d.contentSize=a,d.signature=u,d.type=c,d.userPubkey=(new TextEncoder).encode(o),l&&(d.vaccount=(new TextEncoder).encode(l));const h=IE.pb.SetKeyValueRequest.encode(d).finish(),p=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);try{const e=await p.unaryCall("/dcnet.pb.Service/SetKeyValue",h,3e4),t=IE.pb.SetKeyValueReply.decode(e);return[t.flag,t.timestamp]}catch(e){if(-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(t,this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=await p.unaryCall("/dcnet.pb.Service/SetKeyValue",h,3e4),r=IE.pb.SetKeyValueReply.decode(e);return[r.flag,r.timestamp]}throw e}}async getValueWithKey(e,t,r,n,o,i){const s=new IE.pb.GetValueWithKeyRequest({});s.appId=(new TextEncoder).encode(t),s.themeAuthor=(new TextEncoder).encode(r),s.theme=(new TextEncoder).encode(e),s.UserPubkey=(new TextEncoder).encode(n),s.Key=(new TextEncoder).encode(o),i&&(s.vaccount=(new TextEncoder).encode(i));const a=IE.pb.GetValueWithKeyRequest.encode(s).finish(),c=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);try{const e=await c.unaryCall("/dcnet.pb.Service/GetValueWithKey",a,3e4),t=IE.pb.GetValueWithKeyReply.decode(e);return 0==t.flag?t.value:null}catch(e){if(-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(t,this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=await c.unaryCall("/dcnet.pb.Service/GetValueWithKey",a,3e4),r=IE.pb.GetValueWithKeyReply.decode(e);return 0==r.flag?r.value:null}throw e}}async getValuesWithKeys(e,t,r,n,o,i){const s=new IE.pb.GetValuesWithKeysRequest({});s.appId=(new TextEncoder).encode(t),s.themeAuthor=(new TextEncoder).encode(r),s.theme=(new TextEncoder).encode(e),s.UserPubkey=(new TextEncoder).encode(n),s.Keys=(new TextEncoder).encode(o),i&&(s.vaccount=(new TextEncoder).encode(i));const a=IE.pb.GetValuesWithKeysRequest.encode(s).finish(),c=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);try{const e=await c.unaryCall("/dcnet.pb.Service/GetValuesWithKeys",a,3e4),t=IE.pb.GetValuesWithKeysReply.decode(e);return 0==t.flag?t.keyValues:null}catch(e){if(-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(t,this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=await c.unaryCall("/dcnet.pb.Service/GetValuesWithKeys",a,3e4),r=IE.pb.GetValuesWithKeysReply.decode(e);return 0==r.flag?r.keyValues:null}throw e}}async getValuesWithIndex(e,t,r,n,o,i,s=exports.Direction.Forward,a,c,u){const l=new IE.pb.GetValuesWithIndexRequest({});l.appId=(new TextEncoder).encode(e),l.themeAuthor=(new TextEncoder).encode(t),l.theme=(new TextEncoder).encode(r),l.indexKey=(new TextEncoder).encode(n),l.indexValue=(new TextEncoder).encode(o),l.seekKey=(new TextEncoder).encode(i),l.direction=s,l.offset=a,l.limit=c,u&&(l.vaccount=(new TextEncoder).encode(u));const d=IE.pb.GetValuesWithIndexRequest.encode(l).finish(),h=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);try{const e=await h.unaryCall("/dcnet.pb.Service/GetValuesWithIndex",d,3e4),t=IE.pb.GetValuesWithIndexReply.decode(e);return 0==t.flag?t.keyValues:null}catch(t){if(-1!=t.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(e,this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const t=await h.unaryCall("/dcnet.pb.Service/GetValuesWithIndex",d,3e4),r=IE.pb.GetValuesWithIndexReply.decode(t);return 0==r.flag?r.keyValues:null}throw t}}}var zq;!function(e){e[e.Auth=1]="Auth",e[e.Public=2]="Public"}(zq||(zq={}));class Gq extends Error{constructor(e){super(e),this.name="KeyValueError"}}const Vq={ErrNoDcPeerConnected:new Gq("no dc peer connected"),ErrPublicKeyIsNull:new Gq("publickey is null")};class Hq{constructor(e,t,r,n){this.appId=e,this.dbname=t,this.themeAuthor=r,this.manager=n}async set(e,t,r="",n=""){return this.manager.setKeyValue(this.appId,this.themeAuthor,this.dbname,e,t,r,n)}async get(e,t,r){if(!t){const[t,n]=await this.getWithIndex("indexkey_keyself_"+e,"",1,"",exports.Direction.Reverse,0,r);if(n)return[null,n];if(!t)return[null,null];const o=JSON.parse(t);if(!Array.isArray(o))return[t,null];if(0==o.length)return[null,null];let i="";try{i=o[0][e]}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}return i&&0!=i.length||(i=o[0]),[i,null]}return this.manager.getValueWithKey(this.appId,this.themeAuthor,this.dbname,t,e,r)}async getBatch(e,t,r){return t||(t=this.themeAuthor),this.manager.getValuesWithKeys(this.appId,this.themeAuthor,this.dbname,t,e,r)}async getWithIndex(e,t,r=1e3,n="",o=exports.Direction.Forward,i=0,s=""){return this.manager.getWithIndex(this.appId,this.themeAuthor,this.dbname,e,t,n,o,i,r,s)}async configAuth(e,t,r,n){return this.manager.doConfigAuth(this.appId,this.themeAuthor,this.dbname,e,t,r,n)}async getAuthList(e){return this.manager.getAuthList(this.appId,this.themeAuthor,this.dbname,e)}}class Wq{constructor(e,t,r){this.dc=e,this.chainUtil=t,this.context=r}async createStore(e,t,r,n){if(!this.context.publicKey)return[null,Vq.ErrPublicKeyIsNull];if(""===e&&(e="DCAPP"),r<100<<20&&(r=100<<20),t.startsWith("keyvalue_")||(t="keyvalue_"+t),n===zq.Public&&!t.endsWith("_pub"))return[null,new Error("vaCreateStoreTheme failed, public theme must end with '_pub'")];try{const n=new Ij(this.context),o=await n.addThemeObj(e,t,LR.AUTH,r||52428800);if(0!==o[0]||null!==o[1])return[null,new Error(`vaCreateStoreTheme failed, resFlag: ${o}`)];return[new Hq(e,t,this.context.publicKey.string(),this),null]}catch(e){return[null,e]}}async getKeyValueDB(e,t,r){const n=new Ij(this.context);t.startsWith("keyvalue_")||(t="keyvalue_"+t);const[o,i]=await n.isThemeExist(e,t,r);if(i)return[null,i];if(!o)return[null,new Error(`Theme ${t} does not exist for appId ${e}`)];return[new Hq(e,t,r,this),null]}async doConfigAuth(e,t,r,n,o,i,s){if(!this.context.publicKey)return[null,Vq.ErrPublicKeyIsNull];r.startsWith("keyvalue_")||(r="keyvalue_"+r),r.endsWith("_authlist")||(r+="_authlist");let a=this.context.getPublicKey().string(),c=this.context.AccountBackupDc?.client||null;if(c||(c=await this.dc.connectToUserDcPeer(this.context.publicKey.raw)),null===c)return[null,new Error("ErrConnectToAccountPeersFail")];if(null===c.peerAddr)return[null,new Error("ErrConnectToAccountPeersFail")];""==c.token&&await c.GetToken(e,this.context.publicKey.string(),this.context.sign);const u=As.edPubkeyFromStr(t);let l,d=!0,h=null;try{h=As.edPubkeyFromStr(n)}catch(e){d=!1}l=d&&null!==h?h.string():n;const p=`${l}:${o}:${i}`,y=(new TextEncoder).encode(p),f=await Nr(y),g=ye.encode(f);let b;try{b=await this.chainUtil.getBlockHeight()||0}catch(e){return[null,new Error("ErrGetBlockHeightFail")]}const m=y.length,w=qr(b||0),v=qr(exports.CommentType.Comment),k=(new TextEncoder).encode(r),S=(new TextEncoder).encode(e),O=(new TextEncoder).encode(u.string()),A=(new TextEncoder).encode(g);let I=new Uint8Array([...k,...S,...O,...w,...A,...v]);const x=await this.context.sign(I),P=new Fq(c,this.context);try{const n=await P.configThemeObjAuth(r,e,t,b,a,g,p,m,exports.CommentType.Comment,x,s);return 0!==n?[n,new Error(`configThemeObjAuth fail, resFlag: ${n}`)]:[0,null]}catch(e){return[null,e]}}async getAuthList(e,t,r,n){r.startsWith("keyvalue_")||(r="keyvalue_"+r),r.endsWith("_authlist")||(r+="_authlist");let o="",i=[],s=[];try{for(;;){const a=new Ij(this.context),c=await a.getThemeComments(e,r,t,0,exports.Direction.Forward,0,1e3,o||"",n);if(c[0]&&0==c[0].length)break;const u=c[0];if(!u||0==u.length)break;for(let e=0;e<u.length;e++){i.push(u[e]);const t=u[e].comment,r=t.split(":");if(r.length<2)continue;const n=r[0],o=parseInt(r[1]),a=t.substring(r[0].length+2);s.push({pubkey:n,permission:o,remark:a})}if(u.length<1e3)break;o=`${u[u.length-1].blockheight}/${u[u.length-1].commentCid}`}}catch(e){return[s,i,e]}return[s,i,null]}async setKeyValue(e,t,r,n,o,i,s){if(!this.context.publicKey)return[null,null,Vq.ErrPublicKeyIsNull];r.startsWith("keyvalue_")||(r="keyvalue_"+r);let a=this.context.getPublicKey().string(),c=this.context.AccountBackupDc?.client||null;if(c||(c=await this.dc.connectToUserDcPeer(this.context.publicKey.raw)),null===c)return[null,null,new Error("ErrConnectToAccountPeersFail")];if(null===c.peerAddr)return[null,null,new Error("ErrConnectToAccountPeersFail")];""==c.token&&await c.GetToken(e,this.context.publicKey.string(),this.context.sign);let u=`${n}:${o}`;""!=i&&(u=`$$i_start$$${i}$$i_end$$${u}`);const l=(new TextEncoder).encode(u),d=await Nr(l),h=ye.encode(d),p=l.length,y=await this.chainUtil.getBlockHeight()||0,f=qr(y||0),g=(new TextEncoder).encode(r),b=(new TextEncoder).encode(t),m=(new TextEncoder).encode(e),w=(new TextEncoder).encode(h),v=qr(exports.CommentType.KeyValue),k=new Uint8Array([...g,...m,...b,...f,...w,...v]),S=await this.context.sign(k),O=new Fq(c,this.context);try{const[n,o]=await O.setKeyValue(r,e,t,y,a,h,u,p,exports.CommentType.KeyValue,S,s);return 0!==n?[null,o,new Error(`setKeyValue fail, resFlag:${n}`)]:[!0,o,null]}catch(e){return[null,null,e]}}async getValueWithKey(e,t,r,n,o,i){if(!this.context.publicKey)return[null,Vq.ErrPublicKeyIsNull];r.startsWith("keyvalue_")||(r="keyvalue_"+r);let s=this.context.AccountBackupDc.client||null;if(t!=this.context.publicKey.string()){const e=As.edPubkeyFromStr(t);if(s=await this.dc.connectToUserDcPeer(e.raw),!s)return[null,Vq.ErrNoDcPeerConnected]}if(null===s)return[null,new Error("ErrConnectToAccountPeersFail")];if(null===s.peerAddr)return[null,new Error("ErrConnectToAccountPeersFail")];""==s.token&&await s.GetToken(e,this.context.publicKey.string(),this.context.sign);const a=new Fq(s,this.context);try{const s=await a.getValueWithKey(r,e,t,n,o,i);if(null==s)return[null,new Error(`vaGetValueWithKeyForVAccount fail, resFlag:${s}`)];return[(new TextDecoder).decode(s),null]}catch(e){return[null,e]}}async getValuesWithKeys(e,t,r,n,o,i){if(!this.context.publicKey)return[null,Vq.ErrPublicKeyIsNull];r.startsWith("keyvalue_")||(r="keyvalue_"+r);let s=this.context.AccountBackupDc.client||null;if(t!=this.context.publicKey.string()){const e=As.edPubkeyFromStr(t);if(s=await this.dc.connectToUserDcPeer(e.raw),!s)return[null,Vq.ErrNoDcPeerConnected]}if(null===s)return[null,new Error("ErrConnectToAccountPeersFail")];if(null===s.peerAddr)return[null,new Error("ErrConnectToAccountPeersFail")];""==s.token&&await s.GetToken(e,this.context.publicKey.string(),this.context.sign);const a=new Fq(s,this.context);try{const s=await a.getValuesWithKeys(r,e,t,n,o,i);if(null==s)return[null,new Error(`vaGetValuesWithKeysForVAccount fail, resFlag:${s}`)];return[(new TextDecoder).decode(s),null]}catch(e){return[null,e]}}async getWithIndex(e,t,r,n,o,i,s=exports.Direction.Forward,a,c,u){if(!this.context.publicKey)return[null,Vq.ErrPublicKeyIsNull];r.startsWith("keyvalue_")||(r="keyvalue_"+r);let l=this.context.AccountBackupDc.client||null;if(t!=this.context.publicKey.string()){const r=As.edPubkeyFromStr(t);if(l=await this.dc.connectToUserDcPeer(r.raw),!l)return[null,Vq.ErrNoDcPeerConnected];await l.GetToken(e,this.context.publicKey.string(),this.context.sign)}if(null===l)return[null,new Error("ErrConnectToAccountPeersFail")];if(null===l.peerAddr)return[null,new Error("ErrConnectToAccountPeersFail")];""==l.token&&await l.GetToken(e,this.context.publicKey.string(),this.context.sign);const d=new Fq(l,this.context);try{const l=await d.getValuesWithIndex(e,t,r,n,o,i,s,a,c,u);if(null==l)return[null,new Error(`vaGetValuesWithKeysForVAccount fail, resFlag:${l}`)];return[(new TextDecoder).decode(l),null]}catch(e){return[null,e]}}}const Jq=kR("KeyValueModule");class $q{constructor(){this.moduleName=exports.CoreModuleName.KEYVALUE,this.initialized=!1,this.context={}}async initialize(e){try{return this.context=e,this.keyValueManager=new Wq(e.dcutil,e.dcChain,e),this.initialized=!0,!0}catch(e){return Jq.error("键值存储模块初始化失败:",e),!1}}async shutdown(){this.initialized=!1}async createStore(e,t,r,n){const o=this.assertInitialized();if(o)return[null,o];try{const[o,i]=await this.keyValueManager.createStore(e,t,r,n);return[o,i]}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}async getStore(e,t,r){const n=this.assertInitialized();if(n)return[null,n];try{const[n,o]=await this.keyValueManager.getKeyValueDB(e,t,r);return[n,o]}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}async configAuth(e,t,r,n,o){const i=this.assertInitialized();if(i)return[null,i];try{return await e.configAuth(t,r,n,o)}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}async getAuthList(e,t){const r=this.assertInitialized();if(r)return[null,null,r];try{return await e.getAuthList(t)}catch(e){return[null,null,e instanceof Error?e:new Error(String(e))]}}async set(e,t,r,n,o){const i=this.assertInitialized();if(i)return[null,null,i];try{let i="";try{if(n&&""!=n){const e=JSON.parse(n);for(const t of e){let e="";e="number"===t.type?Hr(t.value):t.value,i+=`${t.key}:${e}$$$`}}}catch(e){Jq.error("设置索引,解析失败:",e)}return await e.set(t,r,i,o)}catch(e){return[null,null,e instanceof Error?e:new Error(String(e))]}}async getValueSetByCurrentUser(e,t,r){return this.context.publicKey?this.get(e,t,this.context.publicKey.string(),r):[null,new Error("当前用户公钥未设置")]}async get(e,t,r,n){const o=this.assertInitialized();if(o)return[null,o];try{return await e.get(t,r,n)}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}async getValues(e,t,r,n){const o=this.assertInitialized();if(o)return[null,o];const i=r.limit?r.limit:10,s=r.seekKey?r.seekKey:"",a=r.direction?r.direction:exports.Direction.Forward,c=r.offset?r.offset:0;try{return await e.getWithIndex("indexkey_dckv",t,i,s,a,c,n)}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}async getBatch(e,t,r="",n=""){const o=this.assertInitialized();if(o)return[null,o];try{return await e.getBatch(t,r,n)}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}async getWithIndex(e,t,r,n,o){const i=this.assertInitialized();if(i)return[null,i];const s=n.limit?n.limit:10,a=n.seekKey?n.seekKey:"",c=n.direction?n.direction:exports.Direction.Forward,u=n.offset?n.offset:0;let l="";"number"===n.type&&(l=Hr(r));try{return await e.getWithIndex(t,l,s,a,c,u,o)}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}async getWithTimeOrder(e,t,r,n){const o=this.assertInitialized();if(o)return[null,o];let i="";t>0&&(i=Hr(1e3*t),i=i.padStart(20,"0"));const s=r.limit?r.limit:10,a=r.seekKey?r.seekKey:"",c=r.direction?r.direction:exports.Direction.Forward,u=r.offset?r.offset:0;try{return await e.getWithIndex("indexkey_timestamp",i,s,a,c,u,n)}catch(e){return[null,e instanceof Error?e:new Error(String(e))]}}assertInitialized(){if(!this.initialized)return Error("键值存储模块未初始化")}}class Yq{constructor(e,t){this.client=e}async getHostID(e){try{if(null==this.client.p2pNode)throw new Error("p2pNode is null");e||(e=this.client.peerAddr);const t=new IE.pb.GetHostIDRequest({}),r=IE.pb.GetHostIDRequest.encode(t).finish(),n=new b.Libp2pGrpcClient(this.client.p2pNode,e||this.client.peerAddr,this.client.token,this.client.protocol),o=await n.unaryCall("/dcnet.pb.Service/GetHostID",r,3e4),i=IE.pb.GetHostIDReply.decode(o),s=us.encode(i.peerID),a=fa(i.reqAddr);return{peerID:s,reqAddr:a}}catch(e){throw e}}}class Zq extends Error{constructor(e){super(e),this.name="DCError"}}const Qq={ErrNoDcPeerConnected:new Zq("no dc peer connected")};class Xq{constructor(e){this.connectedDc={},this.connectedDc=e}async getHostID(e){if(!this.connectedDc?.client)return[null,Qq.ErrNoDcPeerConnected];const t=new Yq(this.connectedDc.client);return[await t.getHostID(e),null]}}const eL=kR("ClientModule");class tL{constructor(){this.moduleName=exports.CoreModuleName.CLIENT,this.initialized=!1}async initialize(e){try{return this.clientManager=new Xq(e.connectedDc),this.initialized=!0,!0}catch(e){return eL.error("消息模块初始化失败:",e),!1}}async shutdown(){this.initialized=!1}async getHostID(){try{this.assertInitialized();const e=await this.clientManager.getHostID();return e[0]?eL.info(`获取hostID成功: ${e[0].peerID}, 公网地址: ${e[0].reqAddr}`):eL.error("获取hostID失败:",e[1]),e}catch(e){return eL.error("获取hostID时发生错误:",e),[null,e]}}assertInitialized(){if(!this.initialized)throw new Error("消息模块未初始化")}}class rL{constructor(e,t,r){this.client=r,this.context=e,this.dc=t}async getCacheValue(e,t){try{if(null==this.client.p2pNode)throw new Error("p2pNode is null");e?e.equals(this.client.peerAddr)||(await this.dc.connectToPeer(e.toString()),this.client=new EE(this.client.p2pNode,this.client.blockstore,e,this.client.protocol),await this.client.GetToken(this.context.appInfo.appId,this.context.publicKey.string(),this.context.sign,e)):e=this.client.peerAddr;const r=new IE.pb.GetCacheValueRequest({});r.key=(new TextEncoder).encode(t);const n=IE.pb.GetCacheValueRequest.encode(r).finish(),o=new b.Libp2pGrpcClient(this.client.p2pNode,e||this.client.peerAddr,this.client.token,this.client.protocol),i=await o.unaryCall("/dcnet.pb.Service/GetCacheValue",n,3e4),s=IE.pb.GetCacheValueReply.decode(i);return fa(s.value)}catch(e){throw e}}async setCacheKey(e,t,r,n,o){try{if(null==this.client.p2pNode)throw new Error("p2pNode is null");o||(o=this.client.peerAddr);const i=new IE.pb.SetCacheKeyRequest({});i.value=(new TextEncoder).encode(e),i.blockheight=t,i.expire=r,i.signature=n;const s=IE.pb.SetCacheKeyRequest.encode(i).finish(),a=new b.Libp2pGrpcClient(this.client.p2pNode,o||this.client.peerAddr,this.client.token,this.client.protocol),c=await a.unaryCall("/dcnet.pb.Service/SetCacheKey",s,3e4),u=IE.pb.SetCacheKeyReply.decode(c);if(u.cacheKey){return fa(u.cacheKey)}throw new Error("SetCacheKey failed,flag: "+u.flag)}catch(e){throw e}}}class nL extends Error{constructor(e){super(e),this.name="CacheError"}}const oL={ErrNoDcPeerConnected:new nL("no dc peer connected"),ErrKeyNotValid:new nL("key not valid"),ErrNodeAddrIsNull:new nL("nodeAddr is null"),ErrChainUtilIsNull:new nL("chainUtil is null"),ErrAccountPrivateSignIsNull:new nL("account privatekey sign is null")};class iL{constructor(e,t,r){this.setCacheKey=async(e,t,r)=>{if(!this.context?.AccountBackupDc.client)return[null,oL.ErrNoDcPeerConnected];if(!this.chainUtil)return[null,oL.ErrChainUtilIsNull];if(!this.context)return[null,oL.ErrAccountPrivateSignIsNull];const n=await this.chainUtil.getBlockHeight(),o=(new TextEncoder).encode(e),i=await Nr(o),s=qr(n||0),a=qr(t),c=new Uint8Array(a.length+s.length);c.set(a,0),c.set(s,a.length);const u=new Uint8Array(c.length+i.length);u.set(c,0),u.set(i,c.length);const l=await this.context.sign(u),d=new rL(this.context,this.dc,this.context?.AccountBackupDc.client);return[await d.setCacheKey(e,n||0,t,l),null]},this.dc=e,this.chainUtil=t,this.context=r}async getCacheValue(e,t){if(!this.context?.connectedDc?.client)return[null,oL.ErrNoDcPeerConnected];const r=e.split("/");if(2!=r.length)return[null,oL.ErrKeyNotValid];if(!this.context?.connectedDc.client)return[null,oL.ErrNoDcPeerConnected];const n=r[0],o=r[1];try{let e;if(this.context?.connectedDc.nodeAddr){const t=this.context.connectedDc.nodeAddr.getPeerId()||"";e=t&&t===n?this.context.connectedDc.nodeAddr:await(this.dc?._getNodeAddr(n))}else e=await(this.dc?._getNodeAddr(n));if(!e)return[null,oL.ErrNodeAddrIsNull];const t=new rL(this.context,this.dc,this.context.connectedDc.client);return[await t.getCacheValue(e,o),null]}catch(e){return[null,e]}}}const sL=kR("CacheModule");class aL{constructor(){this.moduleName=exports.CoreModuleName.CACHE,this.initialized=!1}async initialize(e){try{return this.cacheManager=new iL(e.dcutil,e.dcChain,e),this.initialized=!0,!0}catch(e){return sL.error("键值存储模块初始化失败:",e),!1}}async shutdown(){this.initialized=!1}async getCacheValue(e){try{this.assertInitialized();const t=await this.cacheManager.getCacheValue(e);return t[0]?(sL.info(`获取缓存键 ${e} 成功`),[t[0],null]):(sL.info(`缓存键 ${e} 不存在`),[null,null])}catch(t){return sL.error(`获取缓存键 ${e} 失败:`,t),[null,t instanceof Error?t:new Error(String(t))]}}async setCacheKey(e,t){try{this.assertInitialized();const r=t||86400,n=await this.cacheManager.setCacheKey(e,r);return sL.info(`设置缓存值成功,过期时间: ${r}秒`),n}catch(e){return sL.error("设置缓存值失败:",e),[null,e instanceof Error?e:new Error(String(e))]}}assertInitialized(){if(!this.initialized)throw new Error("键值存储模块未初始化")}}class cL{constructor(e,t){this.client=e,this.context=t}async GetAIProxyConfig(e,t,r){const n=new IE.pb.GetAIProxyConfigRequest({});n.appId=(new TextEncoder).encode(e),n.themeAuthor=(new TextEncoder).encode(t),n.theme=(new TextEncoder).encode(r);const o=IE.pb.GetAIProxyConfigRequest.encode(n).finish(),i=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);try{const e=await i.unaryCall("/dcnet.pb.Service/GetAIProxyConfig",o,3e4),t=IE.pb.GetAIProxyConfigReply.decode(e);if(0!=t.flag)throw new Error(GR.INVALID_TOKEN.message+" flag:"+t.flag);const r=(new TextDecoder).decode(t.proxyConfigCid);return[r,(new TextDecoder).decode(t.aeskey),null]}catch(e){if("object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message&&-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(this.context.appInfo.appId||"",this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=await i.unaryCall("/dcnet.pb.Service/GetAIProxyConfig",o,3e4),t=IE.pb.GetAIProxyConfigReply.decode(e);if(0!=t.flag)throw new Error(GR.INVALID_TOKEN.message+" flag:"+t.flag);return[(new TextDecoder).decode(t.proxyConfigCid),(new TextDecoder).decode(t.aeskey),null]}throw e}}async GetUserOwnAIProxyAuth(e,t,r){const n=new IE.pb.GetUserOwnAIProxyAuthRequest({});n.appId=(new TextEncoder).encode(e),n.themeAuthor=(new TextEncoder).encode(t),n.theme=(new TextEncoder).encode(r);const o=IE.pb.GetUserOwnAIProxyAuthRequest.encode(n).finish(),i=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);try{const e=await i.unaryCall("/dcnet.pb.Service/GetUserOwnAIProxyAuth",o,3e4),t=IE.pb.GetUserOwnAIProxyAuthReply.decode(e);if(0!=t.flag)throw new Error(GR.INVALID_TOKEN.message+" flag:"+t.flag);return[(new TextDecoder).decode(t.authInfo),null]}catch(e){if("object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message&&-1!=e.message.indexOf(GR.INVALID_TOKEN.message)){if(!await this.client.GetToken(this.context.appInfo.appId||"",this.context.getPublicKey().string(),(e=>this.context.sign(e))))throw new Error(GR.INVALID_TOKEN.message);const e=await i.unaryCall("/dcnet.pb.Service/GetUserOwnAIProxyAuth",o,3e4),t=IE.pb.GetUserOwnAIProxyAuthReply.decode(e);if(0!=t.flag)return["",new Error(GR.INVALID_TOKEN.message+" flag:"+t.flag)];return[(new TextDecoder).decode(t.authInfo),null]}return["",e instanceof Error?e:new Error(String(e))]}}async DoAIProxyCall(e,t,r,n,o,i,s,a,c,u,l,d,h=null){const p=new IE.pb.DoAIProxyCallRequest({});p.appId=(new TextEncoder).encode(t),p.themeAuthor=(new TextEncoder).encode(r),p.theme=(new TextEncoder).encode(n),p.configKey=(new TextEncoder).encode(o),p.path=(new TextEncoder).encode(i),p.headers=(new TextEncoder).encode(s),p.reqBody=(new TextEncoder).encode(a),p.modelConfig=(new TextEncoder).encode(c),p.forceRefresh=u,p.blockheight=l,p.signature=d;const y=IE.pb.DoAIProxyCallRequest.encode(p).finish(),f=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol);let g=!1,m=null,w=!1,v=!1;const k=()=>{m&&(clearTimeout(m),m=null)},S=()=>{k(),m=setTimeout((()=>{w||v||!g||(v=!0,h&&h(exports.AIStreamResponseFlag.STREAM_HANG,"","数据流超时:超过30秒未收到响应数据"))}),6e4)},O=()=>!!e.signal?.aborted&&(v=!0,k(),!0),A=async e=>{if(!(v||w||O())){g=!0,S();try{const t=IE.pb.DoAIProxyCallReply.decode(e);t.flag==exports.AIStreamResponseFlag.CONNECTION_CLOSED&&(w=!0,k()),h&&h(t.flag,(new TextDecoder).decode(t.content),(new TextDecoder).decode(t.err))}catch(e){h&&h(exports.AIStreamResponseFlag.OTHER_ERROR,"",e instanceof Error?e.message:String(e))}}},I=async()=>{k(),v||O()||w||(w=!0,h&&h(exports.AIStreamResponseFlag.CONNECTION_CLOSED,"",""))},x=async e=>{v||O()||w||h&&h(exports.AIStreamResponseFlag.OTHER_ERROR,"",e instanceof Error?e.message:String(e))};let P=null;if(e.signal){if(e.signal.aborted)return v=!0,k(),exports.AIStreamResponseFlag.EXTERNAL_EXIT;P=()=>{v=!0,k(),P&&e.signal&&e.signal.removeEventListener("abort",P),h&&h(exports.AIStreamResponseFlag.EXTERNAL_EXIT,"","调用被用户中止")},e.signal.addEventListener("abort",P)}try{return S(),await f.Call("/dcnet.pb.Service/DoAIProxyCall",y,36e5,"server-streaming",A,void 0,I,x,e),0}catch(t){if(w=!0,k(),v)return exports.AIStreamResponseFlag.STREAM_HANG;if(e.signal?.aborted)return exports.AIStreamResponseFlag.EXTERNAL_EXIT;throw t}finally{k(),P&&e.signal&&e.signal.removeEventListener("abort",P)}}}class uL extends Error{constructor(e){super(e),this.name="AIProxyError"}}const lL={ErrNoDcPeerConnected:new uL("no dc peer connected"),ErrKeyNotValid:new uL("key not valid"),ErrNodeAddrIsNull:new uL("nodeAddr is null"),ErrChainUtilIsNull:new uL("chainUtil is null"),ErrAccountPrivateSignIsNull:new uL("account privatekey sign is null"),ErrAccountPublicKeyIsNull:new uL("account publickey is null")};class dL{constructor(e,t,r,n){this.handleAllConfig=async(e,t)=>{const r=new mj(e);let n=[],o=[];if(!this.context.getPublicKey())return null;const i=uR.fromString(t);for(;;){const{line:e,error:t}=wj(r);if(t&&"EOF"!==t.message)break;if(e){const t=(new TextDecoder).decode(e);if(!t)break;const r=ye.decode(t),s=await i.decrypt(r),a=(new TextDecoder).decode(s);if(!a)continue;if(a.startsWith("$$auth$$:")){try{const e=a.split("$$auth$$:")[1];if(!e)continue;const t=e.split(":");if(t.length<2)continue;const r=t[0]||"",n=t[1]||"",i=e.substring(r.length+n.length+2),s=JSON.parse(i);o.push({UserPubkey:r,permission:parseInt(n),authConfig:s})}catch(e){}continue}const c=a.split(":");if(c.length<2)continue;const u=a.substring((c[0]||"").length+1);try{const e=u.split("$$$dckv_extra$$$"),t=e[0]||"{}",r=JSON.parse(t);if(e.length>1){const t=e[1]||"{}",n=JSON.parse(t);n&&(n.dc_timestamp&&(r.timestamp=n.dc_timestamp),n.dc_opuser&&(r.userPubkey=n.dc_opuser))}n.push(r)}catch(e){}}}return[o,n]},this.dc=e,this.dcNodeClient=t,this.chainUtil=r,this.context=n}async createProxyConfig(e,t){""===e&&(e="DCAPP");t.startsWith("keyvalue_")||(t="keyvalue_"+t);try{const r=new Ij(this.context);return await r.addThemeObj(e,t,LR.AUTH,104857600)}catch(e){return[null,e]}}async deleteProxyConfig(e,t){""===e&&(e="DCAPP"),t.startsWith("keyvalue_")||(t="keyvalue_"+t);try{const r=new Ij(this.context);return await r.deleteThemeObj(e,t)}catch(e){return[null,e]}}async configAIProxy(e,t,r,n,o,i){if(!this.context.publicKey)return[null,lL.ErrNoDcPeerConnected];const s=await this.chainUtil.getBlockHeight()||0;let a=this.context.getPublicKey().string();r.startsWith("keyvalue_")||(r="keyvalue_"+r);let c=this.context.AccountBackupDc?.client||null;if(c||(c=await this.dc.connectToUserDcPeer(this.context.publicKey.raw)),!c)return[null,lL.ErrNoDcPeerConnected];if(await c.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),this.context.sign),null===c)return[null,lL.ErrNoDcPeerConnected];""==c.token&&await c.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),this.context.sign);let u="";const l=n;if(o){o.blockheight=s;u=`${l}:${JSON.stringify(o)}`}else u=`${l}`;const d=(new TextEncoder).encode(u),h=await Nr(d),p=ye.encode(h),y=d.length,f=qr(s||0),g=(new TextEncoder).encode(r),b=(new TextEncoder).encode(t),m=(new TextEncoder).encode(e),w=(new TextEncoder).encode(p),v=qr(exports.CommentType.KeyValue),k=new Uint8Array([...g,...m,...b,...f,...w,...v]),S=await this.context.sign(k),O=new Fq(c,this.context);try{const[n,o]=await O.setKeyValue(r,e,t,s,a,p,u,y,exports.CommentType.KeyValue,S,i);return 0!==n?[null,new Error(`configAIProxy fail, resFlag:${n}`)]:[!0,null]}catch(e){return[!1,e]}}async configAuth(e,t,r,n,o,i,s){if(!this.context.publicKey)return[null,lL.ErrAccountPublicKeyIsNull];r.startsWith("keyvalue_")||(r="keyvalue_"+r),r.endsWith("_authlist")||(r+="_authlist");let a=this.context.getPublicKey().string(),c=this.context.AccountBackupDc?.client||null;if(c||(c=await this.dc.connectToUserDcPeer(this.context.publicKey.raw)),null===c)return[null,new Error("ErrConnectToAccountPeersFail")];if(null===c.peerAddr)return[null,new Error("ErrConnectToAccountPeersFail")];""==c.token&&await c.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),this.context.sign);const u=As.edPubkeyFromStr(t);let l,d=!0,h=null;try{h=As.edPubkeyFromStr(n)}catch(e){d=!1}l=d&&h?h.string():n;const p=`${l}:${o}:${JSON.stringify(i)}`,y=(new TextEncoder).encode(p),f=await Nr(y),g=ye.encode(f);let b;try{b=await this.chainUtil.getBlockHeight()||0}catch(e){return[null,new Error("ErrGetBlockHeightFail")]}const m=y.length,w=qr(b||0),v=qr(exports.CommentType.Comment),k=(new TextEncoder).encode(r),S=(new TextEncoder).encode(e),O=(new TextEncoder).encode(u.string()),A=(new TextEncoder).encode(g);let I=new Uint8Array([...k,...S,...O,...w,...A,...v]);const x=await this.context.sign(I),P=new Fq(c,this.context);try{const n=await P.configThemeObjAuth(r,e,t,b,a,g,p,m,exports.CommentType.Comment,x);if(0!==n)return[null,new Error(`configThemeObjAuth fail, resFlag: ${n}`)]}catch(e){return[null,e]}return[0,null]}async GetAIProxyConfig(e,t,r,n){if(!this.context.publicKey)return[null,null,lL.ErrAccountPublicKeyIsNull];r.startsWith("keyvalue_")||(r="keyvalue_"+r);let o=this.context.AccountBackupDc.client||null;if(t!=this.context.publicKey.string()){const e=As.edPubkeyFromStr(t);if(o=await this.dc.connectToUserDcPeer(e.raw),!o)return[null,null,lL.ErrNoDcPeerConnected]}if(null===o)return[null,null,new Error("ErrConnectToAccountPeersFail")];if(null===o.peerAddr)return[null,null,new Error("ErrConnectToAccountPeersFail")];""==o.token&&await o.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),this.context.sign);try{const n=new cL(o,this.context),[i,s,a]=await n.GetAIProxyConfig(e,t,r);if(a)return[null,null,a];const c=new XR(this.dc,this.context.AccountBackupDc,this.chainUtil,this.dcNodeClient,this.context),u=i,l=await c.getFileFromDc(u,"",qR,!1);if(!l)return[[],[],null];const d=fa(l),h=await this.handleAllConfig(d,s);if(!h)return[[],[],null];const[p,y]=h;return[p,y,null]}catch(e){return[null,null,e]}}async GetUserOwnAIProxyAuth(e,t,r){if(!this.context.publicKey)return[null,new Error("ErrConnectToAccountPeersFail")];r.startsWith("keyvalue_")||(r="keyvalue_"+r);let n=this.context.AccountBackupDc?.client||null;if(t!=this.context.publicKey.string()){const e=As.edPubkeyFromStr(t);if(n=await this.dc.connectToUserDcPeer(e.raw),!n)return[null,lL.ErrNoDcPeerConnected]}if(null===n)return[null,new Error("ErrConnectToAccountPeersFail")];if(null===n.peerAddr)return[null,new Error("ErrConnectToAccountPeersFail")];""==n.token&&await n.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),this.context.sign);const o=new cL(n,this.context),[i,s]=await o.GetUserOwnAIProxyAuth(e,t,r);if(s)return[null,s];try{return[JSON.parse(i),s]}catch(s){return[null,s]}}async DoAIProxyCall(e,t,r,n,o,i,s,a=null,c,u,l){n.startsWith("keyvalue_")||(n="keyvalue_"+n);const d=await this.chainUtil.getBlockHeight()||0,h=qr(d||0),p=s?1:0,y=qr(p),f=(new TextEncoder).encode(r),g=(new TextEncoder).encode(n),b=(new TextEncoder).encode(t),m=(new TextEncoder).encode(o),w=(new TextEncoder).encode(u),v=(new TextEncoder).encode(c),k=(new TextEncoder).encode(i),S=(new TextEncoder).encode(l),O=new Uint8Array([...g,...b,...f,...h,...m,...w,...k,...y,...S,...v]);if(!this.context.AccountBackupDc.client)throw new Error("ErrConnectToAccountPeersFail");if(!this.context.publicKey)throw new Error("ErrConnectToAccountPeersFail");""==this.context.AccountBackupDc.client.token&&await this.context.AccountBackupDc.client.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),this.context.sign);const A=await this.context.sign(O),I=new cL(this.context.AccountBackupDc.client,this.context);return await I.DoAIProxyCall(e,t,r,n,o,u||"",c||"",i,l||"",p,d,A,a)}}const hL=kR("KeyValueModule");class pL{constructor(){this.moduleName=exports.CoreModuleName.AIPROXY,this.initialized=!1,this.aiCallConfig=null}async initialize(e){try{return this.aiProxyManager=new dL(e.dcutil,e.dcNodeClient,e.dcChain,e),this.initialized=!0,!0}catch(e){return hL.error("AI代理模块初始化失败:",e),!1}}async shutdown(){this.initialized=!1}async createProxyConfig(e,t){try{return this.assertInitialized(),this.aiProxyManager.createProxyConfig(e,t)}catch(e){return Promise.resolve([null,e])}}async deleteProxyConfig(e,t){try{return this.assertInitialized(),this.aiProxyManager.deleteProxyConfig(e,t)}catch(e){return Promise.resolve([null,e])}}configAIProxy(e,t,r,n,o,i){try{return this.assertInitialized(),this.aiProxyManager.configAIProxy(e,t,r,n,o,i)}catch(e){return Promise.resolve([null,e])}}async configAuth(e,t,r,n,o,i,s){try{return this.assertInitialized(),this.aiProxyManager.configAuth(e,t,r,n,o,i,s)}catch(e){return Promise.resolve([null,e])}}async GetAIProxyConfig(e,t,r,n){try{return this.assertInitialized(),this.aiProxyManager.GetAIProxyConfig(e,t,r,n)}catch(e){return Promise.resolve([null,null,e])}}async GetUserOwnAIProxyAuth(e,t,r){try{return this.assertInitialized(),this.aiProxyManager.GetUserOwnAIProxyAuth(e,t,r)}catch(e){return Promise.resolve([null,e])}}async DoAIProxyCall(e,t,r,n,o,i,s,a,c,u,l){try{if(this.assertInitialized(),!(null!=this.aiCallConfig||o&&i&&s&&a))throw new Error("AI调用配置未设置");let d="";if(c?d=JSON.stringify(c):this.aiCallConfig?.headers&&(d=JSON.stringify(this.aiCallConfig.headers)),s||(s=this.aiCallConfig?.theme),!s)throw new Error("配置主题不能为空");if(o||(o=this.aiCallConfig?.appId),!o)throw new Error("应用ID不能为空");if(i||(i=this.aiCallConfig?.themeAuthor),!i)throw new Error("主题作者公钥不能为空");if(a||(a=this.aiCallConfig?.service),!a)throw new Error("服务名称不能为空");return[await this.aiProxyManager.DoAIProxyCall(e,o,i,s,a,t,r,n,d,u||this.aiCallConfig?.path,l||this.aiCallConfig?.model),null]}catch(e){return hL.error("AI代理调用失败:",e),[null,e instanceof Error?e:new Error(String(e))]}}async SetAICallConfig(e){try{return this.assertInitialized(),this.aiCallConfig=e,null}catch(e){return hL.error("设置AI调用配置失败:",e),e}}assertInitialized(){if(!this.initialized)throw new Error("键值存储模块未初始化")}}class yL{constructor(e){this.client=e}async setAppInfo(e,t,r,n,o,i,s,a){if(null==this.client.p2pNode)throw new Error("p2pNode is null");try{const c=new b.Libp2pGrpcClient(this.client.p2pNode,this.client.peerAddr,this.client.token,this.client.protocol),u=new IE.pb.SetAppInfoRequest;u.appId=e,u.ownerAccount=t,u.rewardAccount=r,u.domain=n,u.blockheight=o,u.peerid=(new TextEncoder).encode(i),u.fid=(new TextEncoder).encode(s),u.signature=a;const l=IE.pb.SetAppInfoRequest.encode(u).finish();try{return void await c.unaryCall("/dcnet.pb.Service/SetAppInfo",l,3e4)}catch(e){throw e}}catch(e){throw e}}}class fL{constructor(e){this.connectedDc={},this.connectedDc=e.connectedDc,this.dc=e.dcutil,this.chainUtil=e.dcChain,this.context=e}async setAppInfo(e,t,r,n,o=""){if(!this.context.publicKey||!this.context.ethAddress)throw GR.NO_USER_INFO;if(!this.connectedDc.client)throw GR.NO_DC_PEER_CONNECTED;if(!this.connectedDc.nodeAddr)throw GR.NO_DC_PEER_CONNECTED;const i=await(this.chainUtil?.getBlockHeight());if(void 0===i)throw GR.FAIL_TO_GET_BLOCKHEIGHT;let s=this.context.publicKey.bytes();r&&r.length>10&&(s=As.unmarshalString(r).bytes());let a=fn(this.context.ethAddress.slice(2));if(n&&n.length>10&&(a=fn(n.slice(2))),""==this.connectedDc.client.token){if(!await this.connectedDc.client.GetToken(this.context.appInfo.appId||"",this.context.publicKey.string(),(async e=>this.context.sign(e))))throw GR.FAIL_TO_GET_TOKEN}const c=new yL(this.connectedDc.client),u=this.connectedDc.nodeAddr.getPeerId()||"",l=(new TextEncoder).encode(u),d=(new TextEncoder).encode(e),h=(new TextEncoder).encode(t),p=qr(i),y=new Uint8Array(d.length+h.length+s.length+a.length+p.length+l.length+o.length);let f=0;y.set(d,f),f+=d.length,y.set(s,f),f+=s.length,y.set(a,f),f+=a.length,y.set(h,f),f+=h.length,y.set(p,f),f+=p.length,y.set(l,f),f+=l.length,y.set((new TextEncoder).encode(o),f);const g=await this.context.sign(y);await c.setAppInfo(d,s,a,h,i,u,o,g)}async getAppInfo(e){if(!this.connectedDc.client)throw GR.NO_DC_PEER_CONNECTED;if(!this.chainUtil)throw GR.NO_CHAIN_UTIL;return await this.chainUtil.getAPPInfo(e)}}const gL=kR("UtilModule");class bL{constructor(){this.moduleName=exports.CoreModuleName.UTIL,this.initialized=!1}async initialize(e){try{return this.context=e,this.utilManager=new fL(e),this.initialized=!0,!0}catch(e){return gL.error("工具模块初始化失败:",e),!1}}createSymmetricKey(){return uR.new()}createThreadKey(){return new lR(uR.new(),uR.new())}async setAppInfo(e,t="",r,n,o){if(!this.initialized)return[null,new Error("UtilModule not initialized")];try{if(!e)throw new Error("appId are required");if(!this.context.publicKey||!this.context.ethAddress)throw GR.NO_USER_INFO;(!n||n.length<10)&&(n=this.context.publicKey.string()),(!o||o.length<10)&&(o=this.context.ethAddress);const[i,s]=await this.getAppInfo(e);return i&&!s&&i.owner==n&&i.rewarder==o&&i.domain==r&&i.fid==t||await this.utilManager.setAppInfo(e,r,n,o,t),[!0,null]}catch(e){return[null,e]}}async getAppInfo(e){if(!this.initialized)return[null,new Error("UtilModule not initialized")];try{return[await this.utilManager.getAppInfo(e),null]}catch(e){return[null,e]}}async shutdown(){this.initialized=!1}async handleIpfsRequest(e,t,r){if(this.initialized)try{await ij(e,t,r)}catch(e){gL.error("页面处理IPFS请求失败:",e)}}}const mL=kR("DC");function wL(e){return!!e&&"object"==typeof e&&"kind"in e}const vL=new class{constructor(){this.entities=new WeakMap,this.columns=new WeakMap,this.indexes=new WeakMap}registerEntity(e,t={},r){const n=t.name??r??e.name,o={target:e,name:n,options:{...t,name:n}};return this.entities.set(e,o),o}registerColumn(e,t,r={}){const n=this.columns.get(e)??new Map,o={target:e,propertyKey:t,options:r,resolvedName:r.name??String(t)};return n.set(t,o),this.columns.set(e,n),o}registerIndex(e,t){if(!t.fields||0===t.fields.length)throw new Error("@Index requires at least one field");const r=t.fields.map((e=>"string"==typeof e?{field:e,order:"asc"}:{field:e.field,order:e.order??"asc"})),n=t.name??this.defaultIndexName(r),o=this.indexes.get(e)??[],i=this.makeIndexKey(n,r),s=o.some((e=>this.makeIndexKey(e.name,e.fields)===i));if(!s){const i={target:e,name:n,fields:r,...void 0!==t.unique?{unique:t.unique}:{},...void 0!==t.ttlSeconds?{ttlSeconds:t.ttlSeconds}:{}};o.push(i),this.indexes.set(e,o)}}getEntity(e){const t="function"==typeof e?e:e?.constructor;return this.entities.get(t)}getColumns(e){const t="function"==typeof e?e:e?.constructor,r=this.columns.get(t);return r?Array.from(r.values()):[]}getIndexes(e){const t="function"==typeof e?e:e?.constructor;return this.indexes.get(t)??[]}getSchema(e){return{entity:this.getEntity(e),columns:this.getColumns(e),indexes:this.getIndexes(e)}}defaultIndexName(e){return`idx_${e.map((e=>`${e.field}_${e.order}`)).join("_")}`}makeIndexKey(e,t){return`${e}|${t.map((e=>`${e.field}:${e.order}`)).join(",")}`}};const kL="$$$dckv_extra$$$";function SL(e){const t=e.indexOf(kL);return t>=0?[e.slice(0,t),e.slice(t+16)]:[e,""]}function OL(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function AL(e){const t=e.trimStart(),r=t.indexOf(":");return r>0&&r<64&&"{"!==t[0]&&"["!==t[0]&&'"'!==t[0]?t.slice(r+1).trim():e}function IL(e,t){switch(t??(e instanceof Date?"date":typeof e)){case"date":return{type:"number",value:String(e instanceof Date?e.getTime():Number(e))};case"boolean":return{type:"number",value:String(e?1:0)};case"number":return{type:"number",value:String(e??0)};case"json":return{type:"json",value:JSON.stringify(e)};default:return{type:"string",value:String(e??"")}}}globalThis.process||(globalThis.process={env:{}}),"undefined"==typeof Promise||Promise.withResolvers||(Promise.withResolvers=function(){let e,t;return{promise:new Promise(((r,n)=>{e=r,t=n})),resolve:e,reject:t}}),exports.AIProxyModule=pL,exports.AuthModule=Pj,exports.BaseEntity=class{constructor(){}getPrimaryKey(){const e=this,t=e.id??e.key??e.pk;if(null==t)throw new Error(`${this.constructor.name}: primary key (id/key/pk) is required`);if("string"==typeof t){const e=t.trim();if(0===e.length)throw new Error(`${this.constructor.name}: primary key (string) cannot be empty`);return e}if("number"==typeof t){if(Number.isNaN(t))throw new Error(`${this.constructor.name}: primary key (number) cannot be NaN`);return String(t)}return"bigint"==typeof t?t.toString():String(t)}touch(e,t=Date.now()){return this.dc_timestamp=t,void 0!==e&&(this.dc_opuser=e),this}setOpUser(e){return this.dc_opuser=e,this}validate(){}static from(e){const t=new this;return Object.assign(t,e),t}toJSON(){const e={};for(const t of Object.keys(this))e[t]=this[t];return e}},exports.CacheModule=aL,exports.ClientModule=tL,exports.Column=function(e={}){return function(t,r){if(wL(r)&&("field"===r.kind||"accessor"===r.kind)){const t=r,n=t.name;return void t.addInitializer?.((function(){const t=this?.constructor;if(!t)return;const r=vL.registerColumn(t,n,e);(e.index||e.unique)&&vL.registerIndex(t,{name:`idx_${String(r.resolvedName)}`,fields:[String(r.resolvedName)],...void 0!==e.unique?{unique:e.unique}:{}})}))}const n=t,o=r,i=n?.constructor,s=vL.registerColumn(i,o,e);(e.index||e.unique)&&vL.registerIndex(i,{name:`idx_${String(s.resolvedName)}`,fields:[String(s.resolvedName)],...void 0!==e.unique?{unique:e.unique}:{}})}},exports.CommentModule=Cj,exports.DC=class{constructor(e){this.dbThreadId="",this.ethAddress="",this.connectedDc={},this.AccountBackupDc={},this.Identity="",this.Blockheight=0,this.shouldReturnUserInfo=!1,this.userInfo=null,this.swUrl="",this.swInited=!1,this.initialized=!1,this.init=async e=>{if(this.initialized)return mL.warn("DC已经初始化,跳过重复初始化"),!0;e&&await e(0);let t=!1;try{if(mL.info("尝试连接主链: "+this.blockChainAddr),t=await this.dcChain.create(this.blockChainAddr),!t&&(mL.info("主链连接失败,尝试备用链: "+this.backChainAddr),t=await this.dcChain.create(this.backChainAddr),!t))return mL.error("dcchainapi 初始化失败: 无法连接任何链"),!1;e&&await e(1),mL.info("链节点连接成功"),this.dcNodeClient=await(this.dcutil?._createHeliaNode()),mL.info("Helia节点创建成功"),this.grpcServer=new bR(this.dcNodeClient.libp2p,UE),this.grpcServer.start(),mL.info("GRPC服务器启动成功");let r=await(this.dcutil?.getDefaultDcNodeAddr());if(!r)return mL.error("获取DC节点地址失败"),!1;mL.info("获取DC节点地址成功: "+r.toString());try{await(this.dcNodeClient?.libp2p.dial(r,{signal:AbortSignal.timeout(5e3)}));mL.info("连接到DC节点成功"),this.connectedDc.nodeAddr=r,this.connectedDc.client=await this.newDcClient(r),e&&await e(2);if(!await this.moduleSystem.initializeAll())return mL.error("模块初始化失败"),!1;this.initialized=!0,e&&await e(3);const t=crypto.getRandomValues(new Uint8Array(32));this.privateKey=Is.fromSeed(t);const n=this.privateKey.publicKey;if(this.publicKey=n,this.auth){-1===("undefined"!=typeof window?window.location.origin:"").indexOf(RE)&&this.auth.startDcPeerTokenKeepValidTask()}return e&&await e(4),!0}catch(e){return mL.error("连接到DC节点失败:",e),!1}}catch(e){return mL.error("DC初始化失败:",e),!1}},this.sign=async e=>{if(!this.auth)return new Uint8Array;return this.auth.signWithWallet(e)},this.newDcClient=async e=>{if(e)try{return new EE(this.dcNodeClient.libp2p,this.dcNodeClient.blockstore,e,UE)}catch(e){throw mL.error("创建DC客户端失败:",e),e}},this.blockChainAddr=e.wssUrl,this.backChainAddr=e.backWssUrl,this.swUrl=e.swUrl||"",this.dcChain=new Ps,this.dcutil=new HE(this.dcChain),this.appInfo=e.appInfo||{},this.accountInfo={},void 0!==e.logLevel&&vR({level:e.logLevel}),this.moduleSystem=new IR(this),this.registerCoreModules(e.names||[])}registerCoreModules(e=[]){if(e&&e.length>0)for(const t of e){const e=this.moduleSystem.getModule(t);e?this.moduleSystem.registerModule(e):mL.warn(`模块 ${t} 不存在,跳过注册`)}else this.moduleSystem.registerModule(new aj(this.swUrl||"")),this.moduleSystem.registerModule(new Pj),this.moduleSystem.registerModule(new Cj),this.moduleSystem.registerModule(new Nq),this.moduleSystem.registerModule(new Mq),this.moduleSystem.registerModule(new $q),this.moduleSystem.registerModule(new tL),this.moduleSystem.registerModule(new aL),this.moduleSystem.registerModule(new pL),this.moduleSystem.registerModule(new bL);mL.info("核心模块注册完成")}registerModule(e){return this.moduleSystem.registerModule(e)}setAppInfo(e){this.appInfo=e}setAccountInfo(e){this.accountInfo=e}setShouldReturnUserInfo(e){this.shouldReturnUserInfo=e}async initUserDB(e,t,r){const n="user_threaddb";let o=null;try{if(this.assertInitialized(),!this.auth)return[null,new Error("用户模块不存在")];const[i,s]=await this.auth.refreshUserInfo();if(s)return[null,s];if(!i)return[null,new Error("用户信息不存在")];if(o=i,!r&&o&&o.dbConfig)try{const[r,i]=await this.auth.decryptWithWallet(o.dbConfigRaw);if(i||!r)return[null,i];const s=(new TextDecoder).decode(r),a=s?s.split("|"):[];if(a&&a.length>=3){const r=a[0]||"",o=a[1]||"",i=a[2]||"";a[3],a[4];if(!this.db)return[null,new Error("数据库模块不存在")];const[s,c]=await this.db.getDBInfo(r);if(null!=s&&!c){if(t){if(await this.db.loadVerno(r)!=t){const n=await this.db.upgradeCollections(r,e);if(n)return[null,n];await this.db.saveVerno(r,t)}await this.db.upgradeCollections(r,e)}return this.db.refreshDBFromDC(r),setTimeout((()=>{this.db&&this.db.syncDBToDC(r)}),5e3),this.dbThreadId=s.id,[s,null]}if(""!=r){await this.db.syncDbFromDC(r,n,"",o,i,!0,e);const[t,s]=await this.db.getDBInfo(r);return null==t||s?[null,s||new Error("获取DB失败")]:(this.dbThreadId=t.id,[t,null])}}}catch(e){return[null,e]}if(!this.util)return[null,new Error("util模块不存在")];if(!this.db)return[null,new Error("数据库模块不存在")];const a=this.util.createSymmetricKey(),c=this.util.createSymmetricKey(),[u,l]=await this.db.newDB(n,a.toString(),c.toString(),e);if(l||!u)return[null,l];if(u){if(!await this.setUserDefaultDB(this,u,a.toString(),c.toString()))return[null,new Error("设置用户去中心DB失败")]}if(!this.db)return[null,new Error("数据库模块不存在")];const[d,h]=await this.db.getDBInfo(u);return null==d||h?(this.dbThreadId="",[null,h]):(this.dbThreadId=d.id,[d,null])}catch(e){return[null,e]}}async setUserDefaultDB(e,t,r,n,o){try{if(!e.auth)return!1;await e.auth.setUserDefaultDB(t,r,n,o||"")}catch(e){return!1}return await this.checkSetUserDefaultDB(e)}async checkSetUserDefaultDB(e){return new Promise((async t=>{let r=0,n=setInterval((async()=>{if(r++,r>20&&(n&&clearInterval(n),r=0,t(!1)),e.auth){const[o,i]=await e.auth.refreshUserInfo();!i&&o&&o.dbConfig&&(n&&clearInterval(n),r=0,t(!0))}}),1e3)}))}async shutdown(){mL.info("开始关闭DC..."),await this.moduleSystem.shutdownAll(),this.grpcServer&&(this.grpcServer.stop(),mL.info("GRPC服务器已停止")),this.dcNodeClient&&this.dcNodeClient.libp2p&&(await this.dcNodeClient.libp2p.stop(),mL.info("libp2p连接已关闭")),this.initialized=!1,mL.info("DC已成功关闭")}async exit(){this.AccountBackupDc={},this.publicKey=void 0,this.dbThreadId="",this.ethAddress="",this.auth&&this.auth.exitLogin(),mL.info("DC已退出并清理资源")}setPublicKey(e){this.publicKey=e}getPublicKey(){if(!this.publicKey)throw new Error("公钥未初始化");return this.publicKey}getPubkeyRaw(){if(!this.publicKey)throw new Error("公钥未初始化");return this.publicKey.raw}isInitialized(){return this.initialized}getRegisteredModules(){return this.moduleSystem.getRegisteredModules()}getModule(e){try{this.assertInitialized();const t=this.moduleSystem.getModule(e);if(!t)throw new Error(`模块 ${e} 不存在或未注册`);return t}catch(e){return null}}assertInitialized(){if(!this.initialized)throw new Error("DC未初始化,请先调用init()方法")}get file(){return this.getModule(exports.CoreModuleName.FILE)}get auth(){return this.getModule(exports.CoreModuleName.AUTH)}get comment(){return this.getModule(exports.CoreModuleName.COMMENT)}get db(){return this.getModule(exports.CoreModuleName.DATABASE)}get message(){return this.getModule(exports.CoreModuleName.MESSAGE)}get keyValue(){return this.getModule(exports.CoreModuleName.KEYVALUE)}get client(){return this.getModule(exports.CoreModuleName.CLIENT)}get cache(){return this.getModule(exports.CoreModuleName.CACHE)}get aiproxy(){return this.getModule(exports.CoreModuleName.AIPROXY)}get util(){return this.getModule(exports.CoreModuleName.UTIL)}},exports.DatabaseModule=Nq,exports.Ed25519PrivKey=Is,exports.Ed25519PubKey=As,exports.Entity=function(e={}){return function(t,r){if(wL(r)&&"class"===r.kind){const n=t;return void vL.registerEntity(n,e,r.name?String(r.name):void 0)}const n=t;vL.registerEntity(n,e,n.name)}},exports.EntityRepository=class{constructor(e,t,r){this.entityCtor=e,this.ops=t,this.db=r}async save(e,t){e.validate();const r=e.getPrimaryKey();delete e.dc_timestamp,delete e.dc_opuser;const n=JSON.stringify(e.toJSON()),o=function(e,t){const r=vL.getColumns(t),n=new Map;r.forEach((e=>{e.options?.type&&n.set(e.resolvedName,e.options.type)}));const o=vL.getIndexes(t),i=[];for(const t of o)if(t.fields.length)if(1===t.fields.length){const[r]=t.fields;if(!r)continue;const o=r.field,s=e[o],{type:a,value:c}=IL(s,n.get(o));i.push({key:o,type:a,value:c})}else{const r=t.name,n=t.fields.map((t=>e[t.field]));i.push({key:r,type:"json",value:JSON.stringify(n)})}return JSON.stringify(i)}(e,this.entityCtor),[i,s,a]=await this.ops.set(this.db,r,n,o,t);if(a)throw a;if(!i)throw new Error(`${this.entityCtor.name}.save failed`);return e.dc_timestamp=s||0,e.dc_timestamp}async deleteById(e,t){const r=e,[n,o,i]=await this.ops.set(this.db,r,"","",t);if(i)throw i;if(!n)throw new Error(`${this.entityCtor.name}.deleteById failed`)}async update(e,t,r){const n=e,[o,i]=await this.ops.getValueSetByCurrentUser(this.db,n,r);if(i||!o)return null;const[s,a]=SL(o),c=OL(s);if(!c)return null;if(a){const e=OL(a);e&&Object.assign(c,e)}const u=new this.entityCtor;Object.assign(u,c),Object.assign(u,t);const l=await this.save(u,r);return u.dc_timestamp=l,u}async query(e,t={}){let r;r="string"==typeof e?function(e){const t=e.match(/^(\w+)\s*(>=|<=|=|>|<|!=)\s*(.+)$/);if(!t)throw new Error("不支持的查询字符串格式: "+e);return{field:t[1],operator:t[2],value:t[3]}}(e):e;const{indexKey:n,indexValue:o,options:i,fullScan:s}=function(e){const{field:t,operator:r,value:n}=e;let o,i,s;switch(r){case"=":return{indexKey:t,indexValue:String(n),options:{}};case">":case">=":o=exports.Direction.Forward,i=String(n),s=1e3;break;case"<":case"<=":o=exports.Direction.Reverse,i=String(n),s=1e3;break;case"!=":return{indexKey:"",indexValue:"",options:{},fullScan:!0};default:throw new Error("不支持的操作符: "+r)}return{indexKey:t,indexValue:"",options:{direction:o,seekKey:i,limit:s}}}(r),a={...i,...t};let c;c=s?await this.find():await this.findByIndex(n,o,a);const{field:u,operator:l,value:d}=r;return c.filter((e=>{const t=e[u];switch(l){case"=":return t==d;case"!=":return t!=d;case">":return t>d;case"<":return t<d;case">=":return t>=d;case"<=":return t<=d;default:return!1}}))}async find(e={}){return this.getValues("",e)}async findById(e,t,r){const n=e,[o,i]=await this.ops.get(this.db,n,t,r);if(i||!o)return null;const[s,a]=SL(o),c=OL(s);if(!c)return null;if(a){const e=OL(a);e&&Object.assign(c,e)}const u=new this.entityCtor;return Object.assign(u,c),u}async findByIndex(e,t,r={}){const[n,o]=await this.ops.getWithIndex(this.db,e,t,function(e){return{...void 0!==e.type?{type:e.type}:{},...void 0!==e.limit?{limit:e.limit}:{},...void 0!==e.seekKey?{seekKey:e.seekKey}:{},...void 0!==e.direction?{direction:e.direction}:{},...void 0!==e.offset?{offset:e.offset}:{}}}(r),r.vaccount);if(o||!n)return[];const i=function(e){const t=OL(e);if(!Array.isArray(t))return[];const r=[];for(const e of t)if("string"==typeof e)r.push(e);else if(e&&"object"==typeof e)for(const t of Object.values(e))null!=t&&r.push(String(t));return r}(n),s=[];for(let e of i){e=AL(e);const[t,r]=SL(e),n=OL(t);if(!n)continue;if(r){const e=OL(r);e&&Object.assign(n,e)}const o=new this.entityCtor;Object.assign(o,n),s.push(o)}return s}async findOneByIndex(e,t,r={}){return(await this.findByIndex(e,t,{...r,limit:1}))[0]??null}async getValues(e,t={}){const[r,n]=await this.ops.getValues(this.db,e,function(e){return{...void 0!==e.limit?{limit:e.limit}:{},...void 0!==e.seekKey?{seekKey:e.seekKey}:{},...void 0!==e.direction?{direction:e.direction}:{},...void 0!==e.offset?{offset:e.offset}:{}}}(t),t.vaccount);if(n||!r)return[];const o=OL(r)??[],i=[];for(const e of o){let t=String(e);if("string"!=typeof e)for(const[r,n]of Object.entries(e)){t=String(n);break}const[r,n]=SL(t),o=OL(r);if(!o)continue;if(n){const e=OL(n);e&&Object.assign(o,e)}const s=new this.entityCtor;Object.assign(s,o),i.push(s)}return i}},exports.Errors=GR,exports.FileModule=aj,exports.Index=function(e,t){return function(r,n){if(wL(n)){const o=n;if("class"===o.kind){const n=r,i="string"==typeof e?{name:e,fields:t??[]}:e;if(!i.fields||0===i.fields.length)throw new Error(`@Index on class ${o.name?.toString()??n.name} requires fields`);return void vL.registerIndex(n,i)}if("field"===o.kind||"accessor"===o.kind){const t=o.name,r="string"==typeof e?{name:e,fields:[String(t)]}:{...e??{},fields:e?.fields?.length?e.fields:[String(t)]};return void o.addInitializer?.((function(){const e=this?.constructor;e&&vL.registerIndex(e,{...r.name?{name:r.name}:{},fields:r.fields,...void 0!==r.unique?{unique:r.unique}:{},...void 0!==r.ttlSeconds?{ttlSeconds:r.ttlSeconds}:{}})}))}}if("string"==typeof n||"symbol"==typeof n){const t=r,o=n,i=t?.constructor,s="string"==typeof e?{name:e,fields:[String(o)]}:{...e??{},fields:e?.fields?.length?e.fields:[String(o)]};vL.registerIndex(i,{...s.name?{name:s.name}:{},fields:s.fields,...void 0!==s.unique?{unique:s.unique}:{},...void 0!==s.ttlSeconds?{ttlSeconds:s.ttlSeconds}:{}})}else{const n=r,o="string"==typeof e?{name:e,fields:t??[]}:e;if(!o.fields||0===o.fields.length)throw new Error(`@Index on class ${n.name} requires fields`);vL.registerIndex(n,{...o.name?{name:o.name}:{},fields:o.fields,...void 0!==o.unique?{unique:o.unique}:{},...void 0!==o.ttlSeconds?{ttlSeconds:o.ttlSeconds}:{}})}}},exports.KeyManager=ZD,exports.KeyValueModule=$q,exports.MessageModule=Mq,exports.ModuleSystem=IR,exports.OffChainOpTimes=2e4,exports.OffChainOpTimesLimit=LE,exports.OffChainSpaceLimit=qE,exports.UtilModule=bL,exports.composeCompositeIndexValue=function(e){return JSON.stringify(e)},exports.configureLogger=vR,exports.createLogger=kR,exports.dc_protocol=UE,exports.dial_timeout=KE,exports.extractSchemasFromSources=async function(e){const{parse:t,t:r,traverse:n}=await async function(){globalThis.process||(globalThis.process={env:{}});const[e,t,r]=await Promise.all([import("@babel/parser"),import("@babel/types"),import("@babel/traverse")]),n=e.parse??e.default?.parse??e.default;if("function"!=typeof n)throw new Error("Failed to resolve @babel/parser.parse as a function");const o=t.default??t,i=r.default?.default??r.default??r.traverse??r;if("function"!=typeof i)throw new Error("Failed to resolve @babel/traverse as a function");return{parse:n,t:o,traverse:i}}(),o=[];function i(e){const r={sourceType:"module",errorRecovery:!0,plugins:["typescript"]};try{return t(e,{...r,plugins:[["decorators",{decoratorsBeforeExport:!0}],"classProperties","classPrivateProperties",...r.plugins]})}catch{return t(e,{...r,plugins:["decorators-legacy","classProperties","classPrivateProperties",...r.plugins]})}}function s(e){if(e){if(r.isStringLiteral(e)||r.isNumericLiteral(e)||r.isBooleanLiteral(e))return e.value;if(r.isNullLiteral(e))return null;if(!r.isIdentifier(e)||"undefined"!==e.name){if(r.isObjectExpression(e)){const t={};for(const n of e.properties)if(r.isObjectProperty(n)){const e=r.isIdentifier(n.key)?n.key.name:r.isStringLiteral(n.key)?n.key.value:void 0;if(!e)continue;t[e]=s(n.value)}return t}return r.isArrayExpression(e)?e.elements.map((e=>s(e))):void 0}}}function a(e,t){const r=[],n=Array.isArray(e)?e:e?[e]:[];if(0===n.length&&t)return[{field:t,order:"asc"}];for(const e of n)"string"==typeof e?r.push({field:e,order:"asc"}):e&&"object"==typeof e&&"string"==typeof e.field&&r.push({field:e.field,order:"desc"===e.order?"desc":"asc"});return r}function c(e){return`idx_${e.map((e=>e.field+("desc"===e.order?"_desc":""))).join("_")}`}function u(e,t){const r=t.map((e=>`${e.field}:${e.order}`)).join(",");return`${e??c(t)}|${r}`}function l(e){const t=e.expression;return r.isIdentifier(t)?t.name:r.isCallExpression(t)&&r.isIdentifier(t.callee)?t.callee.name:void 0}function d(e){const t=e.expression;return r.isCallExpression(t)?t.arguments.map((e=>s(e))):[]}const h=e=>{const t=e.node,n=t.id&&t.id.name||"AnonymousClass",i=t.decorators??[];let s=n,h={};for(const e of i){if("Entity"===l(e)){const[t]=d(e);t&&"object"==typeof t&&(h=t,"string"==typeof t.name&&(s=t.name))}}const p=[],y=[];for(const e of t.body.body){const t=r.isClassProperty?.(e)||r.isPropertyDefinition?.(e),n=r.isClassPrivateProperty?.(e);if(!t&&!n)continue;const o=e.key,i=r.isIdentifier(o)?o.name:r.isStringLiteral(o)?o.value:void 0;if(!i)continue;let s;const u=[],h=e.decorators??[];for(const e of h){const t=l(e),r=d(e);"Column"===t?s=r[0]&&"object"==typeof r[0]?r[0]:{}:"Index"===t&&u.push(r)}const f=s?.name??i;if(p.push({name:f,...void 0!==s?.type?{type:s.type}:{},...void 0!==s?.required?{required:!!s.required}:{},...void 0!==s?.unique?{unique:!!s.unique}:{},...void 0!==s?.index?{index:!!s.index}:{},...void 0!==s?.default?{default:s.default}:{}}),s?.index||s?.unique){const e=[{field:f,order:"asc"}];y.push({name:c(e),fields:e,...s?.unique?{unique:!0}:{}})}for(const e of u){let t,r,n,o;0===e.length?r=[f]:"string"==typeof e[0]?(t=e[0],r=e[1]??[f]):"object"==typeof e[0]&&(t=e[0].name,r=e[0].fields??[f],n=e[0].unique,o=e[0].ttlSeconds);const i=a(r,f);if(0===i.length)continue;const s=t??c(i);y.push({name:s,fields:i,...void 0!==n?{unique:!!n}:{},...void 0!==o?{ttlSeconds:o}:{}})}}const f=[];for(const e of i){if("Index"!==l(e))continue;const t=d(e);let r,n,o,i;if(0===t.length)continue;"string"==typeof t[0]?(r=t[0],n=t[1]??[]):"object"==typeof t[0]&&(r=t[0].name,n=t[0].fields??[],o=t[0].unique,i=t[0].ttlSeconds);const s=a(n);if(0===s.length)continue;const u=r??c(s);f.push({name:u,fields:s,...void 0!==o?{unique:!!o}:{},...void 0!==i?{ttlSeconds:i}:{}})}const g=[...y,...f],b=new Map;for(const e of g){const t=u(e.name,e.fields);b.has(t)||b.set(t,e)}const m={entityName:h?.name??s,...void 0!==h?.namespace?{namespace:h.namespace}:{},...void 0!==h?.ttlSeconds?{ttlSeconds:h.ttlSeconds}:{},...void 0!==h?.versioned?{versioned:h.versioned}:{},columns:p,indexes:Array.from(b.values())};o.push(m)};for(const[,t]of Object.entries(e)){n(i(t),{ClassDeclaration(e){h(e)},ClassExpression(e){h(e)}})}return o},exports.getColumns=function(e){return vL.getColumns(e)},exports.getEntityName=function(e){return vL.getEntity(e)?.name},exports.getEntitySchema=function(e){return vL.getSchema(e)},exports.getIndexes=function(e){return vL.getIndexes(e)},exports.isServiceWorkerActive=async function(){if(!("serviceWorker"in navigator))return!1;try{return!!(await navigator.serviceWorker.ready).active}catch(e){return rj.error("检查Service Worker状态失败:",e),!1}},exports.keyExpire=86400,exports.metadata=vL,exports.registerServiceWorker=oj,exports.updateServiceWorker=async function(){if(!("serviceWorker"in navigator))return!1;try{const e=await navigator.serviceWorker.getRegistration();return!!e&&(await e.update(),rj.info("Service Worker 已更新"),!0)}catch(e){return rj.error("更新Service Worker失败:",e),!1}},exports.walletOrigin=RE,exports.walletUrl=jE,exports.walletWindowName=NE;
|