spacewave 0.57.16 → 0.57.17
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/THIRD_PARTY_NOTICES.txt +3 -3
- package/dist/build.json +1 -1
- package/dist/chunks/{json-CzK0YV3M.mjs → json-D4YdjcVu.mjs} +1 -1
- package/dist/chunks/{node.pb-C9x5fxb1.mjs → node.pb-BccNR73d.mjs} +1 -1
- package/dist/engine-worker.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/examples/task-board/package.json +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ This project is dual licensed under MIT and Apache-2.0.
|
|
|
6
6
|
MIT: https://www.opensource.org/licenses/mit
|
|
7
7
|
Apache-2.0: https://www.apache.org/licenses/license-2.0
|
|
8
8
|
|
|
9
|
-
@aptre/protobuf-es-lite 1.1.
|
|
9
|
+
@aptre/protobuf-es-lite 1.1.4
|
|
10
10
|
=============================
|
|
11
11
|
|
|
12
12
|
Apache License
|
|
@@ -2601,7 +2601,7 @@ Apache License
|
|
|
2601
2601
|
See the License for the specific language governing permissions and
|
|
2602
2602
|
limitations under the License.
|
|
2603
2603
|
|
|
2604
|
-
github.com/klauspost/compress/internal v1.20.2-0.
|
|
2604
|
+
github.com/klauspost/compress/internal v1.20.2-0.20260928201310-179d9a25ce9d
|
|
2605
2605
|
============================================================================
|
|
2606
2606
|
|
|
2607
2607
|
Copyright (c) 2012 The Go Authors. All rights reserved.
|
|
@@ -2909,7 +2909,7 @@ The above copyright notice and this permission notice shall be included in all c
|
|
|
2909
2909
|
|
|
2910
2910
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2911
2911
|
|
|
2912
|
-
github.com/klauspost/compress/s2 v1.20.2-0.
|
|
2912
|
+
github.com/klauspost/compress/s2 v1.20.2-0.20260928201310-179d9a25ce9d
|
|
2913
2913
|
======================================================================
|
|
2914
2914
|
|
|
2915
2915
|
Copyright (c) 2011 The Snappy-Go Authors. All rights reserved.
|
package/dist/build.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);const t=`ERR_RPC_ABORT`;function n(e){return typeof e==`object`&&e.message===t}var r=class extends Error{rpcService;rpcMethod;rpcError;constructor(e,t,n){super(n),this.name=`RemoteRPCError`,this.rpcService=e,this.rpcMethod=t,this.rpcError=n}};function i(e,t){if(t||=`error`,!e)return Error(t);if(typeof e==`string`)return Error(e);let n=e;if(n.message)return n;if(e.toString){let t=e.toString();if(t)return Error(t)}return Error(t)}function a(){let e={};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e}var o=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw Error(`Max size for a FixedFIFO should be a power of two`);this.buffer=Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]===void 0&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},s=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new o(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength==null?1:e.byteLength}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new o(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}},c=class extends Error{type;code;constructor(e,t){super(e??`The operation was aborted`),this.type=`aborted`,this.code=t??`ABORT_ERR`}};function l(e={}){return u(e=>{let t=e.shift();if(t==null)return{done:!0};if(t.error!=null)throw t.error;return{done:t.done===!0,value:t.value}},e)}function u(e,t){t??={};let n=t.onEnd,r=new s,i,o,l,u=a(),ee=async()=>{try{return r.isEmpty()?l?{done:!0}:await new Promise((t,n)=>{o=a=>{o=null,r.push(a);try{t(e(r))}catch(e){n(e)}return i}}):e(r)}finally{r.isEmpty()&&queueMicrotask(()=>{u.resolve(),u=a()})}},d=e=>o==null?(r.push(e),i):o(e),te=e=>(r=new s,o==null?(r.push({error:e}),i):o({error:e})),ne=e=>{if(l)return i;if(t?.objectMode!==!0&&e?.byteLength==null)throw Error(`objectMode was not true but tried to push non-Uint8Array value`);return d({done:!1,value:e})},f=e=>l?i:(l=!0,e==null?d({done:!0}):te(e)),re=()=>(r=new s,f(),{done:!0}),ie=e=>(f(e),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:ee,return:re,throw:ie,push:ne,end:f,get readableLength(){return r.size},onEmpty:async e=>{let t=e?.signal;if(t?.throwIfAborted(),r.isEmpty())return;let n,i;t!=null&&(n=new Promise((e,n)=>{i=()=>{n(new c)},t.addEventListener(`abort`,i)}));try{await Promise.race([u.promise,n])}finally{i!=null&&t!=null&&t?.removeEventListener(`abort`,i)}}},n==null)return i;let p=i;return i={[Symbol.asyncIterator](){return this},next(){return p.next()},throw(e){return p.throw(e),n!=null&&(n(e),n=void 0),{done:!0}},return(){return p.return(),n!=null&&(n(),n=void 0),{done:!0}},push:ne,end(e){return p.end(e),n!=null&&(n(e),n=void 0),i},get readableLength(){return p.readableLength},onEmpty:e=>p.onEmpty(e)},i}var ee=class extends Error{type;code;constructor(e,t,n){super(e??`The operation was aborted`),this.type=`aborted`,this.name=n??`AbortError`,this.code=t??`ABORT_ERR`}};async function d(e,t,n){if(t==null)return e;if(t.aborted)return e.catch(()=>{}),Promise.reject(new ee(n?.errorMessage,n?.errorCode,n?.errorName));let r,i=new ee(n?.errorMessage,n?.errorCode,n?.errorName);try{return await Promise.race([e,new Promise((e,n)=>{r=()=>{n(i)},t.addEventListener(`abort`,r)})])}finally{r!=null&&t.removeEventListener(`abort`,r)}}var te=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=a(),this.haveNext=a()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult??await this.haveNext.promise,this.nextResult==null)throw Error(`HaveNext promise resolved but nextResult was undefined`);let e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=a(),e}async throw(e){return this.ended=!0,this.error=e,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,t){await this._push(e,t)}async end(e,t){e==null?await this._push(void 0,t):await this.throw(e)}async _push(e,t){if(e!=null&&this.ended)throw this.error??Error(`Cannot push value onto an ended pushable`);for(;this.nextResult!=null;)await this.readNext.promise;e==null?(this.ended=!0,this.nextResult={done:!0,value:void 0}):this.nextResult={done:!1,value:e},this.haveNext.resolve(),this.haveNext=a(),await d(this.readNext.promise,t?.signal,t)}};function ne(){return new te}function f(e){return e[Symbol.asyncIterator]!=null}async function re(e,t,n){try{await Promise.all(e.map(async e=>{for await(let r of e)await t.push(r,{signal:n}),n.throwIfAborted()})),await t.end(void 0,{signal:n})}catch(e){await t.end(e,{signal:n}).catch(()=>{})}}async function*ie(e){let t=new AbortController,n=ne();re(e,n,t.signal).catch(()=>{});try{yield*n}finally{t.abort()}}function*p(e){for(let t of e)yield*t}function ae(...e){let t=[];for(let n of e)f(n)||t.push(n);return t.length===e.length?p(t):ie(e)}function m(e,...t){if(e==null)throw Error(`Empty pipeline`);if(le(e)){let t=e;e=()=>t.source}else if(ce(e)||se(e)){let t=e;e=()=>t}let n=[e,...t];if(n.length>1&&le(n[n.length-1])&&(n[n.length-1]=n[n.length-1].sink),n.length>2)for(let e=1;e<n.length-1;e++)le(n[e])&&(n[e]=ue(n[e]));return oe(...n)}const oe=(...e)=>{let t;for(;e.length>0;)t=e.shift()(t);return t},se=e=>e?.[Symbol.asyncIterator]!=null,ce=e=>e?.[Symbol.iterator]!=null,le=e=>e!=null&&e.sink!=null&&e.source!=null,ue=e=>t=>{let n=e.sink(t);if(n?.then!=null){let t=l({objectMode:!0});n.then(()=>{t.end()},e=>{t.end(e)});let r,i=e.source;if(se(i))r=async function*(){yield*i,t.end()};else if(ce(i))r=function*(){yield*i,t.end()};else throw Error(`Unknown duplex source type - must be Iterable or AsyncIterable`);return ae(t,r())}return e.source};function h(e,t){if(!e)throw Error(t)}function g(e){if(typeof e!=`number`)throw Error(`invalid int 32: `+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw Error(`invalid int 32: `+e)}function de(e){if(typeof e!=`number`)throw Error(`invalid uint 32: `+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw Error(`invalid uint 32: `+e)}function fe(e){if(typeof e!=`number`)throw Error(`invalid float 32: `+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw Error(`invalid float 32: `+e)}function pe(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(n&15)<<28,t=(n&112)>>4,!(n&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}throw Error(`invalid varint`)}function me(e,t,n){for(let r=0;r<28;r+=7){let i=e>>>r,a=!(!(i>>>7)&&t==0),o=(a?i|128:i)&255;if(n.push(o),!a)return}let r=e>>>28&15|(t&7)<<4,i=!!(t>>3);if(n.push((i?r|128:r)&255),i){for(let e=3;e<31;e+=7){let r=t>>>e,i=!!(r>>>7),a=(i?r|128:r)&255;if(n.push(a),!i)return}n.push(t>>>31&1)}}const _=4294967296;function he(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=_&&(i+=r/_|0,r%=_)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?be(r,i):ye(r,i)}function ge(e,t){let n=ye(e,t),r=n.hi&2147483648;r&&(n=be(n.lo,n.hi));let i=_e(n.lo,n.hi);return r?`-`+i:i}function _e(e,t){if({lo:e,hi:t}=ve(e,t),t<=2097151)return String(_*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+xe(o)+xe(a)}function ve(e,t){return{lo:e>>>0,hi:t>>>0}}function ye(e,t){return{lo:e|0,hi:t|0}}function be(e,t){return t=~t,e?e=~e+1:t+=1,ye(e,t)}const xe=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function Se(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function Ce(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}function we(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(typeof process!=`object`||typeof process.env!=`object`||process.env.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`int64 invalid: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`uint64 invalid: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}let t=e=>h(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>h(/^[0-9]+$/.test(e),`uint64 invalid: ${e}`);return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),t(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),n(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),t(e),he(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),n(e),he(e)},dec(e,t){return ge(e,t)},uDec(e,t){return _e(e,t)}}}const v=we();var y;(function(e){e[e.DOUBLE=1]=`DOUBLE`,e[e.FLOAT=2]=`FLOAT`,e[e.INT64=3]=`INT64`,e[e.UINT64=4]=`UINT64`,e[e.INT32=5]=`INT32`,e[e.FIXED64=6]=`FIXED64`,e[e.FIXED32=7]=`FIXED32`,e[e.BOOL=8]=`BOOL`,e[e.STRING=9]=`STRING`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`,e[e.DATE=100]=`DATE`})(y||={});var b;(function(e){e[e.BIGINT=0]=`BIGINT`,e[e.STRING=1]=`STRING`})(b||={});function x(e,t,n){if(t===n)return!0;if(t==null||n==null)return t===n;if(e==y.BYTES){if(!(t instanceof Uint8Array)||!(n instanceof Uint8Array)||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}if(e==y.DATE){let e=Oe(t,!1),r=Oe(n,!1);return e==null||r==null?e===r:e!=null&&r!=null&&+e==+r}switch(e){case y.UINT64:case y.FIXED64:case y.INT64:case y.SFIXED64:case y.SINT64:return t==n}return!1}function S(e,t){switch(e){case y.BOOL:return!1;case y.UINT64:case y.FIXED64:case y.INT64:case y.SFIXED64:case y.SINT64:return t==0?v.zero:`0`;case y.DOUBLE:case y.FLOAT:return 0;case y.BYTES:return new Uint8Array;case y.STRING:return``;case y.DATE:return null;default:return 0}}const Te=+new Date(0);function Ee(e,t){if(t==null)return!0;switch(e){case y.DATE:return+t===Te;case y.BOOL:return t===!1;case y.STRING:return t===``;case y.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return t==0}}function C(e,t,n,r=b.BIGINT){return t==null?S(e,r):e===y.BYTES?De(t,n):Ee(e,t)?S(e,r):e===y.DATE?Oe(t,n):t}function De(e,t){return!t&&e instanceof Uint8Array?e:new Uint8Array(e)}function Oe(e,t){if(e instanceof Date)return t?new Date(e.getTime()):e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function ke(e,t){let n=je(e);return t?n:Ie(Fe(n))}function Ae(e){return ke(e,!1)}function je(e){let t=!1,n=[];for(let r=0;r<e.length;r++){let i=e.charAt(r);switch(i){case`_`:t=!0;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n.push(i),t=!1;break;default:t&&(t=!1,i=i.toUpperCase()),n.push(i)}}return n.join(``)}const Me=new Set([`constructor`,`toString`,`toJSON`,`valueOf`,`__proto__`,`prototype`]),Ne=new Set([`__proto__`]),Pe=e=>`${e}$`,Fe=e=>Ne.has(e)?Pe(e):e,Ie=e=>Me.has(e)?Pe(e):e;function Le(e){return typeof e==`string`&&!!e.length&&!Me.has(e)}function w(e){if(typeof e!=`string`)throw Error(`illegal non-string object key: `+typeof e);if(!Le(e))throw Error(`illegal object key: `+e)}var Re=class{_fields;_normalizer;all;numbersAsc;jsonNames;numbers;members;constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){let e={};for(let t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){let e={};for(let t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||=this._normalizer(this._fields),this.all}byNumber(){return this.numbersAsc||=this.list().concat().sort((e,t)=>e.no-t.no),this.numbersAsc}byMember(){if(!this.members){this.members=[];let e=this.members,t;for(let n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}};function ze(e,t){return new Re(e,e=>Ue(e,t))}function Be(e,t){let n=e.localName;if(!t)return!1;if(e.repeated)return!!t[n]?.length;if(e.oneof)return t[e.oneof.localName]?.case===n;switch(e.kind){case`enum`:case`scalar`:return e.opt||e.req?t[n]!=null:e.kind==`enum`?t[n]!==e.T.values[0].no:!Ee(e.T,t[n]);case`message`:return t[n]!=null;case`map`:return t[n]!=null&&!!Object.keys(t[n]).length}}const Ve=je;function T(e){return e instanceof Function?e():e}var He=class{kind=`oneof`;name;localName;repeated=!1;packed=!1;opt=!1;req=!1;default=void 0;fields=[];_lookup;constructor(e){this.name=e,this.localName=Ae(e)}addField(e){h(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}};function Ue(e,t){let n=[],r;for(let i of typeof e==`function`?e():e){let e=i;if(e.localName=ke(i.name,i.oneof!==void 0),e.jsonName=i.jsonName??Ve(i.name),e.repeated=i.repeated??!1,i.kind==`scalar`&&(e.L=i.L??b.BIGINT,e.utf8=i.utf8??!1),i.kind==`map`&&(e.keyUtf8=i.keyUtf8??!1),e.delimited=i.delimited??!1,e.req=i.req??!1,e.opt=i.opt??!1,i.packed===void 0&&(e.packed=t?i.kind==`enum`||i.kind==`scalar`&&i.T!=y.BYTES&&i.T!=y.STRING:!1),i.oneof!==void 0){let t=typeof i.oneof==`string`?i.oneof:i.oneof.name;(!r||r.name!=t)&&(r=new He(t)),e.oneof=r,r.addField(e)}n.push(e)}return n}function We(e){return Array.isArray(e)}function Ge(e){return!Array.isArray(e)}function Ke(e){let t=[];for(let n of Object.keys(e)){let r=e[n];typeof r==`number`&&t.push({no:r,name:n})}return t}function qe(e,t){let n=Object.create(null),r=Object.create(null),i=Ge(t)?Ke(t):t,a=[];for(let e of i){let t=We(e)?{no:e[0],name:e[1],localName:e[1]}:`localName`in e?e:{...e,localName:e.name};a.push(t),n[t.name]=t,r[t.no]=t}return{typeName:e,values:a,findName(e){return n[e]},findNumber(e){return r[e]}}}function Je(e){if(e.values.length<1)throw Error(`invalid enum: missing at least one value`);return e.values[0].no}function Ye(e,t){let n=Je(e);if(t==null||t===``||t===n)return n;if(typeof t==`string`){let n=e.findName(t);if(!n)throw Error(`enum ${e.typeName}: invalid value: "${t}"`);return n.no}return t}function E(){return{}}function D(){return Object.create(null)}function O(e){return e}function k(e,t,n,r=!1){if(e==null||t==null)return;let i=O(t),a=O(e);for(let e of n.byMember()){let t=e.localName;if(w(t),!(t in a)||a[t]===void 0)continue;let n=a[t];if(n===null){delete i[t];continue}switch(e.kind){case`oneof`:{if(typeof n!=`object`)throw Error(`field ${t}: invalid oneof: must be an object with case and value`);let{case:a,value:o}=n,s=a==null?null:e.findField(a),c=t in i?i[t]:void 0;if(typeof c!=`object`&&(c=E()),a!=null&&s==null)throw Error(`field ${t}: invalid oneof case: ${a}`);if(c.case=a,(c.case!==a||a==null)&&delete c.value,i[t]=c,!s)break;if(s.kind===`message`){let e=c.value;if(typeof e!=`object`&&(e=c.value=E()),o!=null){let t=T(s.T);k(o,e,t.fields)}}else s.kind===`scalar`?c.value=C(s.T,o,r):c.value=o;break}case`scalar`:if(e.repeated){if(!Array.isArray(n))throw Error(`field ${t}: invalid value: must be array`);let a=t in i?i[t]:null;(a==null||!Array.isArray(a))&&(a=i[t]=[]),a.push(...n.map(t=>C(e.T,t,r)));break}i[t]=C(e.T,n,r);break;case`enum`:i[t]=Ye(e.T,n);break;case`map`:{if(typeof n!=`object`)throw Error(`field ${e.localName}: invalid value: must be object`);let a=i[t];typeof a!=`object`&&(a=i[t]=D()),Xe(n,a,e.V,r);break}case`message`:{let r=T(e.T);if(e.repeated){if(!Array.isArray(n))throw Error(`field ${t}: invalid value: must be array`);let e=i[t];Array.isArray(e)||(e=i[t]=[]);for(let t of n)t!=null&&(r.fieldWrapper?e.push(r.fieldWrapper.unwrapField(r.fieldWrapper.wrapField(t))):e.push(r.create(t)));break}if(r.fieldWrapper)i[t]=r.fieldWrapper.unwrapField(r.fieldWrapper.wrapField(n));else{if(typeof n!=`object`)throw Error(`field ${e.localName}: invalid value: must be object`);let a=i[t];typeof a!=`object`&&(a=i[t]=E()),k(n,a,r.fields)}break}}}}function Xe(e,t,n,r){if(e!=null){if(typeof e!=`object`)throw Error(`invalid map: must be object`);switch(n.kind){case`scalar`:for(let[i,a]of Object.entries(e))w(i),a===void 0?delete t[i]:t[i]=C(n.T,a,r);break;case`enum`:for(let[r,i]of Object.entries(e))w(r),i===void 0?delete t[r]:t[r]=Ye(n.T,i);break;case`message`:{let r=T(n.T);for(let[n,i]of Object.entries(e)){if(w(n),i===void 0){delete t[n];continue}if(typeof i!=`object`)throw Error(`invalid value: must be object`);let e=t[n];r.fieldWrapper?e=t[n]=It(r.fields):typeof e!=`object`&&(e=t[n]=E()),k(i,e,r.fields)}break}}}}const A=Symbol(`@aptre/protobuf-es-lite/unknown-fields`);function Ze(e,t,n,r){if(typeof e!=`object`)return;let i=e;Array.isArray(i[A])||(i[A]=[]),i[A].push({no:t,wireType:n,data:r})}function Qe(e,t){return e?e.wrapField(t):t}function j(e,t){return e?e.unwrapField(t):t}y.DATE,y.DOUBLE,y.FLOAT,y.INT64,y.UINT64,y.INT32,y.UINT32,y.BOOL,y.STRING,y.BYTES;var M;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(M||={});var $e=class{chunks;buf;stack=[];textEncoder;constructor(e){this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw Error(`invalid state, fork stack empty`);return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(de(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return g(e),Se(e,this.buf),this}bool(e){return this.buf.push(+!!e),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){fe(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){de(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){g(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return g(e),e=(e<<1^e>>31)>>>0,Se(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=v.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=v.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=v.enc(e);return me(t.lo,t.hi,this.buf),this}sint64(e){let t=v.enc(e),n=t.hi>>31;return me(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=v.uEnc(e);return me(t.lo,t.hi,this.buf),this}},et=class{pos;len;buf;view;textDecoder;fatalTextDecoder;constructor(e,t,n){this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder,this.fatalTextDecoder=n}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw Error(`illegal tag: field no `+t+` wire type `+n);return[t,n]}skip(e){let t=this.pos;switch(e){case M.Varint:for(;this.buf[this.pos++]&128;);break;case M.Bit64:this.pos+=4;case M.Bit32:this.pos+=4;break;case M.LengthDelimited:let t=this.uint32();this.pos+=t;break;case M.StartGroup:let n;for(;(n=this.tag()[1])!==M.EndGroup;)this.skip(n);break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}varint64=pe;assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}uint32=Ce;int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return v.dec(...this.varint64())}uint64(){return v.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,v.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return v.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return v.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(e=!1){return(e?this.fatalTextDecoder??=new TextDecoder(`utf-8`,{fatal:!0}):this.textDecoder).decode(this.bytes())}};const tt={readUnknownFields:!0,readerFactory:e=>new et(e)},nt={writeUnknownFields:!0,writerFactory:()=>new $e};function rt(e){return e?{...tt,...e}:tt}function it(e){return e?{...nt,...e}:nt}function at(e,t,n,r,i){let{repeated:a}=n,{localName:o}=n;if(n.oneof){let t=e[n.oneof.localName];t||=e[n.oneof.localName]=E(),e=t,e.case!=o&&delete e.value,e.case=o,o=`value`}switch(n.kind){case`scalar`:case`enum`:{let i=n.kind==`enum`?y.INT32:n.T,s=N,c=n.kind==`scalar`&&n.utf8;if(n.kind==`scalar`&&n.L>0&&(s=st),a){let n=e[o];if(Array.isArray(n)||(n=e[o]=[]),r==M.LengthDelimited&&i!=y.STRING&&i!=y.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(s(t,i,c))}else n.push(s(t,i,c))}else e[o]=s(t,i,c);break}case`message`:{let r=n.T,s=r instanceof Function?r():r;if(a){let r=e[o];Array.isArray(r)||(r=e[o]=[]),r.push(j(s.fieldWrapper,ct(t,E(),s.fields,i,n)))}else e[o]=j(s.fieldWrapper,ct(t,E(),s.fields,i,n));break}case`map`:{let[r,a]=ot(n,t,i);typeof e[o]!=`object`&&(e[o]=D()),e[o][r]=a;break}}}function ot(e,t,n){let r=t.uint32(),i=t.pos+r,a,o;for(;t.pos<i;){let[r]=t.tag();switch(r){case 1:a=N(t,e.K,e.keyUtf8);break;case 2:switch(e.V.kind){case`scalar`:o=N(t,e.V.T,e.V.utf8===!0);break;case`enum`:o=t.int32();break;case`message`:o=ct(t,E(),T(e.V.T).fields,n,void 0)}}}if(a===void 0&&(a=S(e.K,b.BIGINT)),typeof a!=`string`&&typeof a!=`number`&&(a=a?.toString()??``),o===void 0)switch(e.V.kind){case`scalar`:o=S(e.V.T,b.BIGINT);break;case`enum`:o=e.V.T.values[0].no;break;case`message`:o=E()}return[a,o]}function N(e,t,n=!1){switch(t){case y.STRING:return e.string(n);case y.BOOL:return e.bool();case y.DOUBLE:return e.double();case y.FLOAT:return e.float();case y.INT32:return e.int32();case y.INT64:return e.int64();case y.UINT64:return e.uint64();case y.FIXED64:return e.fixed64();case y.BYTES:return e.bytes();case y.FIXED32:return e.fixed32();case y.SFIXED32:return e.sfixed32();case y.SFIXED64:return e.sfixed64();case y.SINT64:return e.sint64();case y.UINT32:return e.uint32();case y.SINT32:return e.sint32();case y.DATE:throw Error(`cannot read a date with readScalar`);default:throw Error(`unknown scalar type`)}}function st(e,t,n=!1){let r=N(e,t,n);return typeof r==`bigint`?r.toString():r}function ct(e,t,n,r,i){return lt(t,n,e,i?.delimited?i.no:e.uint32(),r,i?.delimited??!1),t}function lt(e,t,n,r,i,a){let o=a?n.len:n.pos+r,s,c;for(;n.pos<o&&([s,c]=n.tag(),c!=M.EndGroup);){let r=t.find(s);if(!r){let t=n.skip(c);i.readUnknownFields&&Ze(e,s,c,t);continue}at(e,n,r,c,i)}if(a&&(c!=M.EndGroup||s!==r))throw Error(`invalid end group tag`)}function ut(e,t,n,r){for(let i of t.byNumber()){let t=e;if(!Be(i,t)){if(i.req)throw Error(`cannot encode field ${i.name} to binary: required field not set`);continue}let a=i.oneof?t[i.oneof.localName].value:t[i.localName];a!==void 0&&dt(i,a,n,r)}r.writeUnknownFields&&ft(e,n)}function dt(e,t,n,r){h(t!==void 0);let i=e.repeated;switch(e.kind){case`scalar`:case`enum`:{let r=e.kind==`enum`?y.INT32:e.T;if(i){if(h(Array.isArray(t)),e.packed)mt(n,r,e.no,t);else for(let i of t)P(n,r,e.no,i)}else P(n,r,e.no,t);break}case`message`:if(i){h(Array.isArray(t));for(let i of t)pt(n,r,e,i)}else pt(n,r,e,t);break;case`map`:h(typeof t==`object`&&!!t);for(let[i,a]of Object.entries(t))gt(n,r,e,i,a)}}function ft(e,t){let n=e[A];if(n)for(let e of n)t.tag(e.no,e.wireType).raw(e.data)}function pt(e,t,n,r){let i=T(n.T),a=Qe(i.fieldWrapper,r);n.delimited?e.tag(n.no,M.StartGroup).raw(i.toBinary(a,t)).tag(n.no,M.EndGroup):e.tag(n.no,M.LengthDelimited).bytes(i.toBinary(a,t))}function P(e,t,n,r){h(r!==void 0);let[i,a]=ht(t);e.tag(n,i)[a](r)}function mt(e,t,n,r){if(!r.length)return;e.tag(n,M.LengthDelimited).fork();let[,i]=ht(t);for(let t=0;t<r.length;t++)e[i](r[t]);e.join()}function ht(e){let t=M.Varint;switch(e){case y.BYTES:case y.STRING:t=M.LengthDelimited;break;case y.DOUBLE:case y.FIXED64:case y.SFIXED64:t=M.Bit64;break;case y.FIXED32:case y.SFIXED32:case y.FLOAT:t=M.Bit32}let n=y[e].toLowerCase();return[t,n]}function gt(e,t,n,r,i){e.tag(n.no,M.LengthDelimited),e.fork();let a=r;switch(n.K){case y.INT32:case y.FIXED32:case y.UINT32:case y.SFIXED32:case y.SINT32:a=Number.parseInt(r);break;case y.BOOL:h(r==`true`||r==`false`),a=r==`true`}switch(P(e,n.K,1,a),n.V.kind){case`scalar`:P(e,n.V.T,2,i);break;case`enum`:P(e,y.INT32,2,i);break;case`message`:{h(i!==void 0);let r=T(n.V.T);e.tag(2,M.LengthDelimited).bytes(r.toBinary(i,t));break}}e.join()}let F=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),I=[];for(let e=0;e<F.length;e++)I[F[e].charCodeAt(0)]=e;I[45]=F.indexOf(`+`),I[95]=F.indexOf(`/`);const _t={dec(e){let t=e.length*3/4;e[e.length-2]==`=`?t-=2:e[e.length-1]==`=`&&--t;let n=new Uint8Array(t),r=0,i=0,a,o=0;for(let t=0;t<e.length;t++){if(a=I[e.charCodeAt(t)],a===void 0)switch(e[t]){case`=`:i=0;case`
|
|
1
|
+
var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);const t=`ERR_RPC_ABORT`;function n(e){return typeof e==`object`&&e.message===t}var r=class extends Error{rpcService;rpcMethod;rpcError;constructor(e,t,n){super(n),this.name=`RemoteRPCError`,this.rpcService=e,this.rpcMethod=t,this.rpcError=n}};function i(e,t){if(t||=`error`,!e)return Error(t);if(typeof e==`string`)return Error(e);let n=e;if(n.message)return n;if(e.toString){let t=e.toString();if(t)return Error(t)}return Error(t)}function a(){let e={};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e}var o=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw Error(`Max size for a FixedFIFO should be a power of two`);this.buffer=Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]===void 0&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},s=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new o(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength==null?1:e.byteLength}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new o(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}},c=class extends Error{type;code;constructor(e,t){super(e??`The operation was aborted`),this.type=`aborted`,this.code=t??`ABORT_ERR`}};function l(e={}){return u(e=>{let t=e.shift();if(t==null)return{done:!0};if(t.error!=null)throw t.error;return{done:t.done===!0,value:t.value}},e)}function u(e,t){t??={};let n=t.onEnd,r=new s,i,o,l,u=a(),ee=async()=>{try{return r.isEmpty()?l?{done:!0}:await new Promise((t,n)=>{o=a=>{o=null,r.push(a);try{t(e(r))}catch(e){n(e)}return i}}):e(r)}finally{r.isEmpty()&&queueMicrotask(()=>{u.resolve(),u=a()})}},d=e=>o==null?(r.push(e),i):o(e),te=e=>(r=new s,o==null?(r.push({error:e}),i):o({error:e})),ne=e=>{if(l)return i;if(t?.objectMode!==!0&&e?.byteLength==null)throw Error(`objectMode was not true but tried to push non-Uint8Array value`);return d({done:!1,value:e})},f=e=>l?i:(l=!0,e==null?d({done:!0}):te(e)),re=()=>(r=new s,f(),{done:!0}),ie=e=>(f(e),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:ee,return:re,throw:ie,push:ne,end:f,get readableLength(){return r.size},onEmpty:async e=>{let t=e?.signal;if(t?.throwIfAborted(),r.isEmpty())return;let n,i;t!=null&&(n=new Promise((e,n)=>{i=()=>{n(new c)},t.addEventListener(`abort`,i)}));try{await Promise.race([u.promise,n])}finally{i!=null&&t!=null&&t?.removeEventListener(`abort`,i)}}},n==null)return i;let p=i;return i={[Symbol.asyncIterator](){return this},next(){return p.next()},throw(e){return p.throw(e),n!=null&&(n(e),n=void 0),{done:!0}},return(){return p.return(),n!=null&&(n(),n=void 0),{done:!0}},push:ne,end(e){return p.end(e),n!=null&&(n(e),n=void 0),i},get readableLength(){return p.readableLength},onEmpty:e=>p.onEmpty(e)},i}var ee=class extends Error{type;code;constructor(e,t,n){super(e??`The operation was aborted`),this.type=`aborted`,this.name=n??`AbortError`,this.code=t??`ABORT_ERR`}};async function d(e,t,n){if(t==null)return e;if(t.aborted)return e.catch(()=>{}),Promise.reject(new ee(n?.errorMessage,n?.errorCode,n?.errorName));let r,i=new ee(n?.errorMessage,n?.errorCode,n?.errorName);try{return await Promise.race([e,new Promise((e,n)=>{r=()=>{n(i)},t.addEventListener(`abort`,r)})])}finally{r!=null&&t.removeEventListener(`abort`,r)}}var te=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=a(),this.haveNext=a()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult??await this.haveNext.promise,this.nextResult==null)throw Error(`HaveNext promise resolved but nextResult was undefined`);let e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=a(),e}async throw(e){return this.ended=!0,this.error=e,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,t){await this._push(e,t)}async end(e,t){e==null?await this._push(void 0,t):await this.throw(e)}async _push(e,t){if(e!=null&&this.ended)throw this.error??Error(`Cannot push value onto an ended pushable`);for(;this.nextResult!=null;)await this.readNext.promise;e==null?(this.ended=!0,this.nextResult={done:!0,value:void 0}):this.nextResult={done:!1,value:e},this.haveNext.resolve(),this.haveNext=a(),await d(this.readNext.promise,t?.signal,t)}};function ne(){return new te}function f(e){return e[Symbol.asyncIterator]!=null}async function re(e,t,n){try{await Promise.all(e.map(async e=>{for await(let r of e)await t.push(r,{signal:n}),n.throwIfAborted()})),await t.end(void 0,{signal:n})}catch(e){await t.end(e,{signal:n}).catch(()=>{})}}async function*ie(e){let t=new AbortController,n=ne();re(e,n,t.signal).catch(()=>{});try{yield*n}finally{t.abort()}}function*p(e){for(let t of e)yield*t}function ae(...e){let t=[];for(let n of e)f(n)||t.push(n);return t.length===e.length?p(t):ie(e)}function m(e,...t){if(e==null)throw Error(`Empty pipeline`);if(le(e)){let t=e;e=()=>t.source}else if(ce(e)||se(e)){let t=e;e=()=>t}let n=[e,...t];if(n.length>1&&le(n[n.length-1])&&(n[n.length-1]=n[n.length-1].sink),n.length>2)for(let e=1;e<n.length-1;e++)le(n[e])&&(n[e]=ue(n[e]));return oe(...n)}const oe=(...e)=>{let t;for(;e.length>0;)t=e.shift()(t);return t},se=e=>e?.[Symbol.asyncIterator]!=null,ce=e=>e?.[Symbol.iterator]!=null,le=e=>e!=null&&e.sink!=null&&e.source!=null,ue=e=>t=>{let n=e.sink(t);if(n?.then!=null){let t=l({objectMode:!0});n.then(()=>{t.end()},e=>{t.end(e)});let r,i=e.source;if(se(i))r=async function*(){yield*i,t.end()};else if(ce(i))r=function*(){yield*i,t.end()};else throw Error(`Unknown duplex source type - must be Iterable or AsyncIterable`);return ae(t,r())}return e.source};function h(e,t){if(!e)throw Error(t)}function g(e){if(typeof e!=`number`)throw Error(`invalid int 32: `+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw Error(`invalid int 32: `+e)}function de(e){if(typeof e!=`number`)throw Error(`invalid uint 32: `+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw Error(`invalid uint 32: `+e)}function fe(e){if(typeof e!=`number`)throw Error(`invalid float 32: `+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw Error(`invalid float 32: `+e)}function pe(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(n&15)<<28,t=(n&112)>>4,!(n&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}throw Error(`invalid varint`)}function me(e,t,n){for(let r=0;r<28;r+=7){let i=e>>>r,a=!(!(i>>>7)&&t==0),o=(a?i|128:i)&255;if(n.push(o),!a)return}let r=e>>>28&15|(t&7)<<4,i=!!(t>>3);if(n.push((i?r|128:r)&255),i){for(let e=3;e<31;e+=7){let r=t>>>e,i=!!(r>>>7),a=(i?r|128:r)&255;if(n.push(a),!i)return}n.push(t>>>31&1)}}const _=4294967296;function he(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=_&&(i+=r/_|0,r%=_)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?be(r,i):ye(r,i)}function ge(e,t){let n=ye(e,t),r=n.hi&2147483648;r&&(n=be(n.lo,n.hi));let i=_e(n.lo,n.hi);return r?`-`+i:i}function _e(e,t){if({lo:e,hi:t}=ve(e,t),t<=2097151)return String(_*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+xe(o)+xe(a)}function ve(e,t){return{lo:e>>>0,hi:t>>>0}}function ye(e,t){return{lo:e|0,hi:t|0}}function be(e,t){return t=~t,e?e=~e+1:t+=1,ye(e,t)}const xe=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function Se(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function Ce(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}function we(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(typeof process!=`object`||typeof process.env!=`object`||process.env.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`int64 invalid: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`uint64 invalid: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}let t=e=>h(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>h(/^[0-9]+$/.test(e),`uint64 invalid: ${e}`);return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),t(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),n(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),t(e),he(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),n(e),he(e)},dec(e,t){return ge(e,t)},uDec(e,t){return _e(e,t)}}}const v=we();var y;(function(e){e[e.DOUBLE=1]=`DOUBLE`,e[e.FLOAT=2]=`FLOAT`,e[e.INT64=3]=`INT64`,e[e.UINT64=4]=`UINT64`,e[e.INT32=5]=`INT32`,e[e.FIXED64=6]=`FIXED64`,e[e.FIXED32=7]=`FIXED32`,e[e.BOOL=8]=`BOOL`,e[e.STRING=9]=`STRING`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`,e[e.DATE=100]=`DATE`})(y||={});var b;(function(e){e[e.BIGINT=0]=`BIGINT`,e[e.STRING=1]=`STRING`})(b||={});function x(e,t,n){if(t===n)return!0;if(t==null||n==null)return t===n;if(e==y.BYTES){if(!(t instanceof Uint8Array)||!(n instanceof Uint8Array)||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}if(e==y.DATE){let e=Oe(t,!1),r=Oe(n,!1);return e==null||r==null?e===r:e!=null&&r!=null&&+e==+r}switch(e){case y.UINT64:case y.FIXED64:case y.INT64:case y.SFIXED64:case y.SINT64:return t==n}return!1}function S(e,t){switch(e){case y.BOOL:return!1;case y.UINT64:case y.FIXED64:case y.INT64:case y.SFIXED64:case y.SINT64:return t==0?v.zero:`0`;case y.DOUBLE:case y.FLOAT:return 0;case y.BYTES:return new Uint8Array;case y.STRING:return``;case y.DATE:return null;default:return 0}}const Te=+new Date(0);function Ee(e,t){if(t==null)return!0;switch(e){case y.DATE:return+t===Te;case y.BOOL:return t===!1;case y.STRING:return t===``;case y.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return t==0}}function C(e,t,n,r=b.BIGINT){return t==null?S(e,r):e===y.BYTES?De(t,n):Ee(e,t)?S(e,r):e===y.DATE?Oe(t,n):t}function De(e,t){return!t&&e instanceof Uint8Array?e:new Uint8Array(e)}function Oe(e,t){if(e instanceof Date)return t?new Date(e.getTime()):e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function ke(e,t){let n=je(e);return t?n:Ie(Fe(n))}function Ae(e){return ke(e,!1)}function je(e){let t=!1,n=[];for(let r=0;r<e.length;r++){let i=e.charAt(r);switch(i){case`_`:t=!0;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n.push(i),t=!1;break;default:t&&(t=!1,i=i.toUpperCase()),n.push(i)}}return n.join(``)}const Me=new Set([`constructor`,`toString`,`toJSON`,`valueOf`,`__proto__`,`prototype`]),Ne=new Set([`__proto__`]),Pe=e=>`${e}$`,Fe=e=>Ne.has(e)?Pe(e):e,Ie=e=>Me.has(e)?Pe(e):e;function Le(e){return typeof e==`string`&&!!e.length&&!Me.has(e)}function w(e){if(typeof e!=`string`)throw Error(`illegal non-string object key: `+typeof e);if(!Le(e))throw Error(`illegal object key: `+e)}var Re=class{_fields;_normalizer;all;numbersAsc;jsonNames;numbers;members;constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){let e={};for(let t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){let e={};for(let t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||=this._normalizer(this._fields),this.all}byNumber(){return this.numbersAsc||=this.list().concat().sort((e,t)=>e.no-t.no),this.numbersAsc}byMember(){if(!this.members){this.members=[];let e=this.members,t;for(let n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}};function ze(e,t){return new Re(e,e=>Ue(e,t))}function Be(e,t){let n=e.localName;if(!t)return!1;if(e.repeated)return!!t[n]?.length;if(e.oneof)return t[e.oneof.localName]?.case===n;switch(e.kind){case`enum`:case`scalar`:return e.opt||e.req?t[n]!=null:e.kind==`enum`?t[n]!==e.T.values[0].no:!Ee(e.T,t[n]);case`message`:return t[n]!=null;case`map`:return t[n]!=null&&!!Object.keys(t[n]).length}}const Ve=je;function T(e){return e instanceof Function?e():e}var He=class{kind=`oneof`;name;localName;repeated=!1;packed=!1;opt=!1;req=!1;default=void 0;fields=[];_lookup;constructor(e){this.name=e,this.localName=Ae(e)}addField(e){h(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}};function Ue(e,t){let n=[],r;for(let i of typeof e==`function`?e():e){let e=i;if(e.localName=ke(i.name,i.oneof!==void 0),e.jsonName=i.jsonName??Ve(i.name),e.repeated=i.repeated??!1,i.kind==`scalar`&&(e.L=i.L??b.BIGINT,e.utf8=i.utf8??!1),i.kind==`map`&&(e.keyUtf8=i.keyUtf8??!1),e.delimited=i.delimited??!1,e.req=i.req??!1,e.opt=i.opt??!1,i.packed===void 0&&(e.packed=t?i.kind==`enum`||i.kind==`scalar`&&i.T!=y.BYTES&&i.T!=y.STRING:!1),i.oneof!==void 0){let t=typeof i.oneof==`string`?i.oneof:i.oneof.name;(!r||r.name!=t)&&(r=new He(t)),e.oneof=r,r.addField(e)}n.push(e)}return n}function We(e){return Array.isArray(e)}function Ge(e){return!Array.isArray(e)}function Ke(e,t){let n=[];for(let r of Object.keys(e)){let i=e[r];typeof i==`number`&&n.push({no:i,name:t+r,localName:r})}return n}function qe(e,t,n=``){let r=Object.create(null),i=Object.create(null),a=Ge(t)?Ke(t,n):t,o=[];for(let e of a){let t=We(e)?{no:e[0],name:e[1],localName:e[1]}:`localName`in e?e:{...e,localName:e.name};o.push(t),r[t.name]=t,i[t.no]=t}return{typeName:e,values:o,findName(e){return r[e]},findNumber(e){return i[e]}}}function Je(e){if(e.values.length<1)throw Error(`invalid enum: missing at least one value`);return e.values[0].no}function Ye(e,t){let n=Je(e);if(t==null||t===``||t===n)return n;if(typeof t==`string`){let n=e.findName(t);if(!n)throw Error(`enum ${e.typeName}: invalid value: "${t}"`);return n.no}return t}function E(){return{}}function D(){return Object.create(null)}function O(e){return e}function k(e,t,n,r=!1){if(e==null||t==null)return;let i=O(t),a=O(e);for(let e of n.byMember()){let t=e.localName;if(w(t),!(t in a)||a[t]===void 0)continue;let n=a[t];if(n===null){delete i[t];continue}switch(e.kind){case`oneof`:{if(typeof n!=`object`)throw Error(`field ${t}: invalid oneof: must be an object with case and value`);let{case:a,value:o}=n,s=a==null?null:e.findField(a),c=t in i?i[t]:void 0;if(typeof c!=`object`&&(c=E()),a!=null&&s==null)throw Error(`field ${t}: invalid oneof case: ${a}`);if(c.case=a,(c.case!==a||a==null)&&delete c.value,i[t]=c,!s)break;if(s.kind===`message`){let e=c.value;if(typeof e!=`object`&&(e=c.value=E()),o!=null){let t=T(s.T);k(o,e,t.fields)}}else s.kind===`scalar`?c.value=C(s.T,o,r):c.value=o;break}case`scalar`:if(e.repeated){if(!Array.isArray(n))throw Error(`field ${t}: invalid value: must be array`);let a=t in i?i[t]:null;(a==null||!Array.isArray(a))&&(a=i[t]=[]),a.push(...n.map(t=>C(e.T,t,r)));break}i[t]=C(e.T,n,r);break;case`enum`:i[t]=Ye(e.T,n);break;case`map`:{if(typeof n!=`object`)throw Error(`field ${e.localName}: invalid value: must be object`);let a=i[t];typeof a!=`object`&&(a=i[t]=D()),Xe(n,a,e.V,r);break}case`message`:{let r=T(e.T);if(e.repeated){if(!Array.isArray(n))throw Error(`field ${t}: invalid value: must be array`);let e=i[t];Array.isArray(e)||(e=i[t]=[]);for(let t of n)t!=null&&(r.fieldWrapper?e.push(r.fieldWrapper.unwrapField(r.fieldWrapper.wrapField(t))):e.push(r.create(t)));break}if(r.fieldWrapper)i[t]=r.fieldWrapper.unwrapField(r.fieldWrapper.wrapField(n));else{if(typeof n!=`object`)throw Error(`field ${e.localName}: invalid value: must be object`);let a=i[t];typeof a!=`object`&&(a=i[t]=E()),k(n,a,r.fields)}break}}}}function Xe(e,t,n,r){if(e!=null){if(typeof e!=`object`)throw Error(`invalid map: must be object`);switch(n.kind){case`scalar`:for(let[i,a]of Object.entries(e))w(i),a===void 0?delete t[i]:t[i]=C(n.T,a,r);break;case`enum`:for(let[r,i]of Object.entries(e))w(r),i===void 0?delete t[r]:t[r]=Ye(n.T,i);break;case`message`:{let r=T(n.T);for(let[n,i]of Object.entries(e)){if(w(n),i===void 0){delete t[n];continue}if(typeof i!=`object`)throw Error(`invalid value: must be object`);let e=t[n];r.fieldWrapper?e=t[n]=It(r.fields):typeof e!=`object`&&(e=t[n]=E()),k(i,e,r.fields)}break}}}}const A=Symbol(`@aptre/protobuf-es-lite/unknown-fields`);function Ze(e,t,n,r){if(typeof e!=`object`)return;let i=e;Array.isArray(i[A])||(i[A]=[]),i[A].push({no:t,wireType:n,data:r})}function Qe(e,t){return e?e.wrapField(t):t}function j(e,t){return e?e.unwrapField(t):t}y.DATE,y.DOUBLE,y.FLOAT,y.INT64,y.UINT64,y.INT32,y.UINT32,y.BOOL,y.STRING,y.BYTES;var M;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(M||={});var $e=class{chunks;buf;stack=[];textEncoder;constructor(e){this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw Error(`invalid state, fork stack empty`);return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(de(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return g(e),Se(e,this.buf),this}bool(e){return this.buf.push(+!!e),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){fe(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){de(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){g(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return g(e),e=(e<<1^e>>31)>>>0,Se(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=v.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=v.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=v.enc(e);return me(t.lo,t.hi,this.buf),this}sint64(e){let t=v.enc(e),n=t.hi>>31;return me(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=v.uEnc(e);return me(t.lo,t.hi,this.buf),this}},et=class{pos;len;buf;view;textDecoder;fatalTextDecoder;constructor(e,t,n){this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder,this.fatalTextDecoder=n}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw Error(`illegal tag: field no `+t+` wire type `+n);return[t,n]}skip(e){let t=this.pos;switch(e){case M.Varint:for(;this.buf[this.pos++]&128;);break;case M.Bit64:this.pos+=4;case M.Bit32:this.pos+=4;break;case M.LengthDelimited:let t=this.uint32();this.pos+=t;break;case M.StartGroup:let n;for(;(n=this.tag()[1])!==M.EndGroup;)this.skip(n);break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}varint64=pe;assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}uint32=Ce;int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return v.dec(...this.varint64())}uint64(){return v.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,v.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return v.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return v.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(e=!1){return(e?this.fatalTextDecoder??=new TextDecoder(`utf-8`,{fatal:!0}):this.textDecoder).decode(this.bytes())}};const tt={readUnknownFields:!0,readerFactory:e=>new et(e)},nt={writeUnknownFields:!0,writerFactory:()=>new $e};function rt(e){return e?{...tt,...e}:tt}function it(e){return e?{...nt,...e}:nt}function at(e,t,n,r,i){let{repeated:a}=n,{localName:o}=n;if(n.oneof){let t=e[n.oneof.localName];t||=e[n.oneof.localName]=E(),e=t,e.case!=o&&delete e.value,e.case=o,o=`value`}switch(n.kind){case`scalar`:case`enum`:{let i=n.kind==`enum`?y.INT32:n.T,s=N,c=n.kind==`scalar`&&n.utf8;if(n.kind==`scalar`&&n.L>0&&(s=st),a){let n=e[o];if(Array.isArray(n)||(n=e[o]=[]),r==M.LengthDelimited&&i!=y.STRING&&i!=y.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(s(t,i,c))}else n.push(s(t,i,c))}else e[o]=s(t,i,c);break}case`message`:{let r=n.T,s=r instanceof Function?r():r;if(a){let r=e[o];Array.isArray(r)||(r=e[o]=[]),r.push(j(s.fieldWrapper,ct(t,E(),s.fields,i,n)))}else e[o]=j(s.fieldWrapper,ct(t,E(),s.fields,i,n));break}case`map`:{let[r,a]=ot(n,t,i);typeof e[o]!=`object`&&(e[o]=D()),e[o][r]=a;break}}}function ot(e,t,n){let r=t.uint32(),i=t.pos+r,a,o;for(;t.pos<i;){let[r]=t.tag();switch(r){case 1:a=N(t,e.K,e.keyUtf8);break;case 2:switch(e.V.kind){case`scalar`:o=N(t,e.V.T,e.V.utf8===!0);break;case`enum`:o=t.int32();break;case`message`:o=ct(t,E(),T(e.V.T).fields,n,void 0)}}}if(a===void 0&&(a=S(e.K,b.BIGINT)),typeof a!=`string`&&typeof a!=`number`&&(a=a?.toString()??``),o===void 0)switch(e.V.kind){case`scalar`:o=S(e.V.T,b.BIGINT);break;case`enum`:o=e.V.T.values[0].no;break;case`message`:o=E()}return[a,o]}function N(e,t,n=!1){switch(t){case y.STRING:return e.string(n);case y.BOOL:return e.bool();case y.DOUBLE:return e.double();case y.FLOAT:return e.float();case y.INT32:return e.int32();case y.INT64:return e.int64();case y.UINT64:return e.uint64();case y.FIXED64:return e.fixed64();case y.BYTES:return e.bytes();case y.FIXED32:return e.fixed32();case y.SFIXED32:return e.sfixed32();case y.SFIXED64:return e.sfixed64();case y.SINT64:return e.sint64();case y.UINT32:return e.uint32();case y.SINT32:return e.sint32();case y.DATE:throw Error(`cannot read a date with readScalar`);default:throw Error(`unknown scalar type`)}}function st(e,t,n=!1){let r=N(e,t,n);return typeof r==`bigint`?r.toString():r}function ct(e,t,n,r,i){return lt(t,n,e,i?.delimited?i.no:e.uint32(),r,i?.delimited??!1),t}function lt(e,t,n,r,i,a){let o=a?n.len:n.pos+r,s,c;for(;n.pos<o&&([s,c]=n.tag(),c!=M.EndGroup);){let r=t.find(s);if(!r){let t=n.skip(c);i.readUnknownFields&&Ze(e,s,c,t);continue}at(e,n,r,c,i)}if(a&&(c!=M.EndGroup||s!==r))throw Error(`invalid end group tag`)}function ut(e,t,n,r){for(let i of t.byNumber()){let t=e;if(!Be(i,t)){if(i.req)throw Error(`cannot encode field ${i.name} to binary: required field not set`);continue}let a=i.oneof?t[i.oneof.localName].value:t[i.localName];a!==void 0&&dt(i,a,n,r)}r.writeUnknownFields&&ft(e,n)}function dt(e,t,n,r){h(t!==void 0);let i=e.repeated;switch(e.kind){case`scalar`:case`enum`:{let r=e.kind==`enum`?y.INT32:e.T;if(i){if(h(Array.isArray(t)),e.packed)mt(n,r,e.no,t);else for(let i of t)P(n,r,e.no,i)}else P(n,r,e.no,t);break}case`message`:if(i){h(Array.isArray(t));for(let i of t)pt(n,r,e,i)}else pt(n,r,e,t);break;case`map`:h(typeof t==`object`&&!!t);for(let[i,a]of Object.entries(t))gt(n,r,e,i,a)}}function ft(e,t){let n=e[A];if(n)for(let e of n)t.tag(e.no,e.wireType).raw(e.data)}function pt(e,t,n,r){let i=T(n.T),a=Qe(i.fieldWrapper,r);n.delimited?e.tag(n.no,M.StartGroup).raw(i.toBinary(a,t)).tag(n.no,M.EndGroup):e.tag(n.no,M.LengthDelimited).bytes(i.toBinary(a,t))}function P(e,t,n,r){h(r!==void 0);let[i,a]=ht(t);e.tag(n,i)[a](r)}function mt(e,t,n,r){if(!r.length)return;e.tag(n,M.LengthDelimited).fork();let[,i]=ht(t);for(let t=0;t<r.length;t++)e[i](r[t]);e.join()}function ht(e){let t=M.Varint;switch(e){case y.BYTES:case y.STRING:t=M.LengthDelimited;break;case y.DOUBLE:case y.FIXED64:case y.SFIXED64:t=M.Bit64;break;case y.FIXED32:case y.SFIXED32:case y.FLOAT:t=M.Bit32}let n=y[e].toLowerCase();return[t,n]}function gt(e,t,n,r,i){e.tag(n.no,M.LengthDelimited),e.fork();let a=r;switch(n.K){case y.INT32:case y.FIXED32:case y.UINT32:case y.SFIXED32:case y.SINT32:a=Number.parseInt(r);break;case y.BOOL:h(r==`true`||r==`false`),a=r==`true`}switch(P(e,n.K,1,a),n.V.kind){case`scalar`:P(e,n.V.T,2,i);break;case`enum`:P(e,y.INT32,2,i);break;case`message`:{h(i!==void 0);let r=T(n.V.T);e.tag(2,M.LengthDelimited).bytes(r.toBinary(i,t));break}}e.join()}let F=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),I=[];for(let e=0;e<F.length;e++)I[F[e].charCodeAt(0)]=e;I[45]=F.indexOf(`+`),I[95]=F.indexOf(`/`);const _t={dec(e){let t=e.length*3/4;e[e.length-2]==`=`?t-=2:e[e.length-1]==`=`&&--t;let n=new Uint8Array(t),r=0,i=0,a,o=0;for(let t=0;t<e.length;t++){if(a=I[e.charCodeAt(t)],a===void 0)switch(e[t]){case`=`:i=0;case`
|
|
2
2
|
`:case`\r`:case` `:case` `:continue;default:throw Error(`invalid base64 string.`)}switch(i){case 0:o=a,i=1;break;case 1:n[r++]=o<<2|(a&48)>>4,o=a,i=2;break;case 2:n[r++]=(o&15)<<4|(a&60)>>2,o=a,i=3;break;case 3:n[r++]=(o&3)<<6|a,i=0}}if(i==1)throw Error(`invalid base64 string.`);return n.subarray(0,r)},enc(e){let t=``,n=0,r,i=0;for(let a=0;a<e.length;a++)switch(r=e[a],n){case 0:t+=F[r>>2],i=(r&3)<<4,n=1;break;case 1:t+=F[i|r>>4],i=(r&15)<<2,n=2;break;case 2:t+=F[i|r>>6],t+=F[r&63],n=0}return n&&(t+=F[i],t+=`=`,n==1&&(t+=`=`)),t}},vt={ignoreUnknownFields:!1},yt={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function bt(e){return e?{...vt,...e}:vt}function xt(e){return e?{...yt,...e}:yt}function L(e){if(e===null)return`null`;switch(typeof e){case`object`:return Array.isArray(e)?`array`:`object`;case`string`:return e.length>100?`string`:`"${e.split(`"`).join(`\\"`)}"`;default:return String(e)}}function St(e,t,n,r,i){if(n==null||Array.isArray(n)||typeof n!=`object`)throw Error(`cannot decode message ${t} from JSON: ${L(n)}`);let a=new Map;for(let[o,s]of Object.entries(n)){let n=e.findJsonName(o);if(n){if(n.oneof){if(s===null&&n.kind==`scalar`)continue;let e=a.get(n.oneof);if(e!==void 0)throw Error(`cannot decode message ${t} from JSON: multiple keys for oneof "${n.oneof.name}" present: "${e}", "${o}"`);a.set(n.oneof,o)}wt(i,s,n,r)}else if(!r.ignoreUnknownFields)throw Error(`cannot decode message ${t} from JSON: key "${o}" is unknown`)}return i}function Ct(e,t,n){let r=Object.create(null),i;try{for(i of t.byNumber()){let t=e;if(!Be(i,t)){if(i.req)throw`required field not set`;if(!n.emitDefaultValues||!Ot(i))continue}let a=i.oneof?t[i.oneof.localName].value:t[i.localName],o=kt(i,a,n);o!==void 0&&(r[n.useProtoFieldName?i.name:i.jsonName]=o)}}catch(e){let t=i?`cannot encode field ${i.name} to JSON`:`cannot encode message to JSON`,n=e instanceof Error?e.message:String(e);throw Error(t+(n.length>0?`: ${n}`:``),{cause:e})}return r}function wt(e,t,n,r){let i=n.localName;if(n.repeated){if(h(n.kind!=`map`),t===null)return;if(!Array.isArray(t))throw Error(`cannot decode field ${n.name} from JSON: ${L(t)}`);let a=e[i];Array.isArray(a)||(a=e[i]=[]);for(let e of t){if(e===null)throw Error(`cannot decode field ${n.name} from JSON: ${L(e)}`);switch(n.kind){case`message`:{let t=T(n.T);a.push(j(t.fieldWrapper,t.fromJson(e,r)));break}case`enum`:{let t=Tt(n.T,e,r.ignoreUnknownFields,!0);t!==z&&a.push(t);break}case`scalar`:try{a.push(B(n.T,e,n.L,!0))}catch(t){let r=`cannot decode field ${n.name} from JSON: ${L(e)}`;throw t instanceof Error&&t.message.length>0&&(r+=`: ${t.message}`),Error(r,{cause:t})}}}}else if(n.kind==`map`){if(t===null)return;if(typeof t!=`object`||Array.isArray(t))throw Error(`cannot decode field ${n.name} from JSON: ${L(t)}`);let a=e[i];typeof a!=`object`&&(a=e[i]=D());for(let[e,i]of Object.entries(t)){if(i===null)throw Error(`cannot decode field ${n.name} from JSON: map value null`);let o;try{o=Et(n.K,e)}catch(e){let r=`cannot decode map key for field ${n.name} from JSON: ${L(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r,{cause:e})}switch(w(o),n.V.kind){case`message`:{let e=T(n.V.T);a[o]=e.fromJson(i,r);break}case`enum`:{let e=Tt(n.V.T,i,r.ignoreUnknownFields,!0);e!==z&&(a[o]=e);break}case`scalar`:try{a[o]=B(n.V.T,i,b.BIGINT,!0)}catch(e){let r=`cannot decode map value for field ${n.name} from JSON: ${L(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r,{cause:e})}}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:i},i=`value`),n.kind){case`message`:{let a=T(n.T);if(t===null&&a.typeName!=`google.protobuf.Value`)return;e[i]=j(a.fieldWrapper,a.fromJson(t,r));break}case`enum`:{let a=Tt(n.T,t,r.ignoreUnknownFields,!1);switch(a){case R:Dt(n,e);break;case z:break;default:e[i]=a}break}case`scalar`:try{let r=B(n.T,t,n.L,!1);switch(r){case R:Dt(n,e);break;default:e[i]=r}}catch(e){let r=`cannot decode field ${n.name} from JSON: ${L(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r,{cause:e})}}}const R=Symbol(),z=Symbol();function Tt(e,t,n,r){if(t===null)return e.typeName==`google.protobuf.NullValue`?0:r?e.values[0].no:R;switch(typeof t){case`number`:if(Number.isInteger(t))return t;break;case`string`:{let r=e.findName(t);if(r!==void 0)return r.no;if(n)return z;break}}throw Error(`cannot decode enum ${e.typeName} from JSON: ${L(t)}`)}function B(e,t,n=b.BIGINT,r=!0){if(t==null)return r?S(e,n):R;switch(e){case y.DOUBLE:case y.FLOAT:{if(t===`NaN`)return NaN;if(t===`Infinity`)return 1/0;if(t===`-Infinity`)return-1/0;if(t===``||typeof t==`string`&&t.trim().length!==t.length||typeof t!=`string`&&typeof t!=`number`)break;let n=Number(t);if(Number.isNaN(n)||!Number.isFinite(n))break;return e==y.FLOAT&&fe(n),n}case y.INT32:case y.FIXED32:case y.SFIXED32:case y.SINT32:case y.UINT32:{let n;if(typeof t==`number`?n=t:typeof t==`string`&&t.length>0&&t.trim().length===t.length&&(n=Number(t)),n===void 0)break;return e==y.UINT32||e==y.FIXED32?de(n):g(n),n}case y.INT64:case y.SFIXED64:case y.SINT64:{if(typeof t!=`number`&&typeof t!=`string`)break;let e=v.parse(t);return n?e.toString():e}case y.FIXED64:case y.UINT64:{if(typeof t!=`number`&&typeof t!=`string`)break;let e=v.uParse(t);return n?e.toString():e}case y.BOOL:if(typeof t!=`boolean`)break;return t;case y.STRING:if(typeof t!=`string`)break;return t;case y.BYTES:if(t===``)return new Uint8Array;if(typeof t!=`string`)break;return _t.dec(t)}throw Error()}function Et(e,t){if(e===y.BOOL)switch(t){case`true`:t=!0;break;case`false`:t=!1}return B(e,t,b.BIGINT,!0)?.toString()??``}function Dt(e,t){let n=e.localName,r=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case`map`:t[n]=D();break;case`enum`:t[n]=r?e.T.values[0].no:void 0;break;case`scalar`:t[n]=r?S(e.T,e.L):void 0;break;case`message`:t[n]=void 0}}function Ot(e){return e.repeated||e.kind==`map`?!0:!(e.oneof||e.kind==`message`||e.opt||e.req)}function kt(e,t,n){if(e.kind==`map`){let r=Object.create(null);h(!t||typeof t==`object`);let i=t?Object.entries(t):[];switch(e.V.kind){case`scalar`:for(let[t,n]of i)r[t.toString()]=At(e.V.T,n);break;case`message`:for(let[t,a]of i){let i=T(e.V.T);r[t.toString()]=i.toJson(a,n)}break;case`enum`:{let t=e.V.T;for(let[e,a]of i)r[e.toString()]=jt(t,a,n.enumAsInteger);break}}return n.emitDefaultValues||i.length>0?r:void 0}if(e.repeated){h(!t||Array.isArray(t));let r=[],i=t;if(i&&i.length)switch(e.kind){case`scalar`:for(let t=0;t<i.length;t++)r.push(At(e.T,i[t]));break;case`enum`:for(let t=0;t<i.length;t++)r.push(jt(e.T,i[t],n.enumAsInteger));break;case`message`:{let t=T(e.T);for(let e=0;e<i.length;e++)r.push(t.toJson(Qe(t.fieldWrapper,i[e])));break}}return n.emitDefaultValues||r.length>0?r:void 0}switch(e.kind){case`scalar`:{let r=C(e.T,t,!1);return!n.emitDefaultValues&&Ee(e.T,r)?void 0:At(e.T,t)}case`enum`:{let r=Ye(e.T,t);return!n.emitDefaultValues&&Je(e.T)===r?void 0:jt(e.T,t,n.enumAsInteger)}case`message`:{if(!n.emitDefaultValues&&t==null)return;let r=T(e.T);return r.toJson(Qe(r.fieldWrapper,t))}}}function At(e,t){switch(e){case y.INT32:case y.SFIXED32:case y.SINT32:case y.FIXED32:case y.UINT32:return h(typeof t==`number`),t;case y.FLOAT:case y.DOUBLE:return h(typeof t==`number`),Number.isNaN(t)?`NaN`:t===1/0?`Infinity`:t===-1/0?`-Infinity`:t;case y.STRING:return h(typeof t==`string`),t;case y.BOOL:return h(typeof t==`boolean`),t;case y.UINT64:case y.FIXED64:case y.INT64:case y.SFIXED64:case y.SINT64:return h(typeof t==`bigint`||typeof t==`string`||typeof t==`number`),t.toString();case y.BYTES:return h(t instanceof Uint8Array),_t.enc(t);case y.DATE:throw Error(`cannot write date with writeScalar`);default:throw Error(`unknown scalar type`)}}function jt(e,t,n){return h(typeof t==`number`),e.typeName==`google.protobuf.NullValue`?null:n?t:e.findNumber(t)?.name??t}const Mt=[];function V(e,t){let{fields:n,typeName:r,delimitedMessageEncoding:i,fieldWrapper:a}=e,o=ze(n,e.packedByDefault??!0),s={typeName:r,fields:o,fieldWrapper:a,create(e){let t=E();return k(e,t,o),t},createComplete(e){let t=It(o);return k(e,t,o),t},equals(e,t){return Pt(o,e,t)},clone(e){return e==null?e:Ft(e,o)},fromBinary(e,t){let n={};if(e&&e.length){let r=rt(t);lt(n,o,r.readerFactory(e),e.byteLength,r,i??!1)}return n},fromJson(e,t){let n={};if(e!=null){let i=bt(t);St(o,r,e,i,n)}return n},fromJsonString(e,t){let n=null;if(e)try{n=JSON.parse(e)}catch(e){throw Error(`cannot decode ${r} from JSON: ${e instanceof Error?e.message:String(e)}`,{cause:e})}return s.fromJson(n,t)},toBinary(e,t){if(e==null)return new Uint8Array;let n=it(t),r=n.writerFactory();return ut(e,o,r,n),r.finish()},toJson(e,t){let n=xt(t);return Ct(e,o,n)},toJsonString(e,t){let n=s.toJson(e,t);return JSON.stringify(n,null,t?.prettySpaces??0)},...t??{}};return s}function Nt(e,t){return V({typeName:e,fields:Mt,packedByDefault:t})}function Pt(e,t,n){return t==null&&n==null||t===n?!0:!t||!n?!1:e.byMember().every(e=>{let r=O(t)[e.localName],i=O(n)[e.localName];if(e.repeated){let t=r,n=i;if((t?.length??0)!==(n?.length??0))return!1;if(!t?.length)return!0;switch(e.kind){case`message`:{let r=T(e.T),i=t,a=n;return i.every((e,t)=>r.equals(e,a[t]))}case`scalar`:return t.every((t,r)=>x(e.T,t,n?.[r]));case`enum`:return t.every((e,t)=>x(y.INT32,e,n?.[t]))}throw Error(`repeated cannot contain ${e.kind}`)}switch(e.kind){case`message`:return T(e.T).equals(r,i);case`enum`:return x(y.INT32,r,i);case`scalar`:return x(e.T,r,i);case`oneof`:{let t=r,n=i;if(t?.case!==n?.case)return!1;if(t==null)return!0;let a=t.case;if(a===void 0)return!0;let o=e.findField(a);if(o===void 0)return!0;switch(o.kind){case`message`:return T(o.T).equals(t.value,n?.value);case`enum`:return x(y.INT32,t.value,n?.value);case`scalar`:return x(o.T,t.value,n?.value)}throw Error(`oneof cannot contain ${o.kind}`)}case`map`:{let t=r??{},n=i??{},a=Object.keys(t).concat(Object.keys(n));switch(e.V.kind){case`message`:{let r=T(e.V.T);return a.every(e=>r.equals(t[e],n[e]))}case`enum`:return a.every(e=>x(y.INT32,t[e],n[e]));case`scalar`:{let r=e.V.T;return a.every(e=>x(r,t[e],n[e]))}}}}})}function Ft(e,t){if(e==null)return null;let n=E();return k(e,n,t,!0),n}function It(e){let t={};for(let n of e.byMember()){let{localName:e,kind:r}=n;switch(w(e),r){case`oneof`:t[e]=E(),t[e].case=void 0;break;case`scalar`:t[e]=n.repeated?[]:S(n.T,b.BIGINT);break;case`enum`:t[e]=n.repeated?[]:Je(n.T);break;case`message`:{if(n.oneof)break;if(n.repeated){t[e]=[];break}let r=T(n.T);t[e]=r.fieldWrapper?r.fieldWrapper.unwrapField(null):It(r.fields);break}case`map`:t[e]=D()}}return t}const Lt=V({typeName:`srpc.CallStart`,fields:[{no:1,name:`rpc_service`,kind:`scalar`,T:y.STRING},{no:2,name:`rpc_method`,kind:`scalar`,T:y.STRING},{no:3,name:`data`,kind:`scalar`,T:y.BYTES},{no:4,name:`data_is_zero`,kind:`scalar`,T:y.BOOL}],packedByDefault:!0}),Rt=V({typeName:`srpc.CallData`,fields:[{no:1,name:`data`,kind:`scalar`,T:y.BYTES},{no:2,name:`data_is_zero`,kind:`scalar`,T:y.BOOL},{no:3,name:`complete`,kind:`scalar`,T:y.BOOL},{no:4,name:`error`,kind:`scalar`,T:y.STRING}],packedByDefault:!0}),zt=V({typeName:`srpc.Packet`,fields:[{no:1,name:`call_start`,kind:`message`,T:()=>Lt,oneof:`body`},{no:2,name:`call_data`,kind:`message`,T:()=>Rt,oneof:`body`},{no:3,name:`call_cancel`,kind:`scalar`,T:y.BOOL,oneof:`body`}],packedByDefault:!0});var Bt=class{sink;source;rpcDataSource;_source=l({objectMode:!0});_rpcDataSource=l({objectMode:!0});service;method;closed;remoteError;invocationController=new AbortController;writeDrainAbort=new AbortController;constructor(){this.sink=this._createSink(),this.source=this._source,this.rpcDataSource=this._rpcDataSource}get isClosed(){return this.closed??!1}get invocationSignal(){return this.invocationController.signal}async writeCallData(e,t,n){await this.writeCallDataPacket(e,t,n)}async writeCallDataPacket(e,t,n,r){let i={data:e||new Uint8Array,dataIsZero:!!e&&e.length===0,complete:t||!1,error:n||``};await this.writePacket({body:{case:`callData`,value:i}},r)}async writeCallCancel(e=!1){await this.writePacket({body:{case:`callCancel`,value:!0}},{waitForDrain:!1}),e&&await this._source.onEmpty({signal:this.writeDrainAbort.signal})}async writeCallDataFromSource(e){try{for await(let t of e)await this.writeCallData(t);await this.writeCallData(void 0,!0)}catch(e){this.close(e)}}async writePacket(e,n){if(this.closed&&!n?.allowClosed)throw Error(t);if(this._source.push(e),!(n?.waitForDrain===!1||this._source.readableLength<=1))try{await this._source.onEmpty({signal:this.writeDrainAbort.signal})}catch(e){throw this.closed?Error(t,{cause:e}):e}}async handleMessage(e){return this.handlePacket(zt.fromBinary(e))}async handlePacket(e){try{switch(e?.body?.case){case`callStart`:await this.handleCallStart(e.body.value);break;case`callData`:await this.handleCallData(e.body.value);break;case`callCancel`:e.body.value&&await this.handleCallCancel()}}catch(e){let t=e;t?.message||(t=Error(`error handling packet`)),this.close(t)}}async handleCallStart(e){throw Error(`unexpected call start: ${e.rpcService}/${e.rpcMethod}`)}pushRpcData(e,t){if(t)(!e||e.length!==0)&&(e=new Uint8Array);else if(!e||e.length===0)return;this._rpcDataSource.push(e)}async handleCallData(e){if(!this.service||!this.method)throw Error(`call start must be sent before call data`);this.pushRpcData(e.data,e.dataIsZero);let t=e.error?new r(this.service,this.method,e.error):void 0;t&&(this.remoteError??=t,this.invocationController.abort()),(e.complete&&!t||t)&&this._rpcDataSource.end(t)}async handleCallCancel(){await this.close(Error(t))}async close(e){this.closed||(this.closed=e??!0,!this.remoteError&&e&&(this.remoteError=e),this.invocationController.abort(),e&&e.message&&await this.writeCallDataPacket(void 0,!0,e.message,{allowClosed:!0,waitForDrain:!1}),this.writeDrainAbort.abort(),this._source.end(),this._rpcDataSource.end(e))}_createSink(){return async e=>{try{if(Symbol.asyncIterator in e)for await(let t of e)await this.handlePacket(t);else for(let t of e)await this.handlePacket(t)}catch(e){this.close(e)}}}},Vt=class extends Bt{constructor(e,t){super(),this.service=e,this.method=t}async writeCallStart(e){if(!this.service||!this.method)throw Error(`service and method must be set`);let t={rpcService:this.service,rpcMethod:this.method,data:e||new Uint8Array,dataIsZero:!!e&&e.length===0};await this.writePacket({body:{case:`callStart`,value:t}})}async handleCallStart(e){throw Error(`unexpected server to client rpc: ${e.rpcService||`<empty>`}/${e.rpcMethod||`<empty>`}`)}};async function Ht(e,t){try{for await(let n of e)t.push(n);t.end()}catch(e){t.end(e)}}function H(e=0){return new Uint8Array(e)}function Ut(e=0){return new Uint8Array(e)}function Wt(e){return e?.buffer instanceof ArrayBuffer}function Gt(e){if(Wt(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function Kt(e,t){t??=e.reduce((e,t)=>e+t.length,0);let n=Ut(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return Gt(n)}function qt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}const Jt=Symbol.for(`@achingbrain/uint8arraylist`);function Yt(e,t){if(t==null||t<0)throw RangeError(`index is out of bounds`);let n=0;for(let r of e){let e=n+r.byteLength;if(t<e)return{buf:r,index:t-n};n=e}throw RangeError(`index is out of bounds`)}function U(e){return!!e?.[Jt]}var W=class e{bufs;length;[Jt]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(U(n)){t+=n.byteLength;for(let e of n.bufs)this.bufs.push(e)}else throw Error(`Could not append value, must be an Uint8Array or a Uint8ArrayList`);this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(U(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw Error(`Could not prepend value, must be an Uint8Array or a Uint8ArrayList`);this.length+=t}get(e){let t=Yt(this.bufs,e);return t.buf[t.index]}set(e,t){let n=Yt(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(U(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw Error(`Could not write value, must be an Uint8Array or a Uint8ArrayList`)}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:r}=this._subList(e,t);return Kt(n,r)}subarray(e,t){let{bufs:n,length:r}=this._subList(e,t);return n.length===1?n[0]:Kt(n,r)}sublist(t,n){let{bufs:r,length:i}=this._subList(t,n),a=new e;return a.length=i,a.bufs=r,a}_subList(e,t){if(e??=0,t??=this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw RangeError(`index is out of bounds`);if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],r=0;for(let i=0;i<this.bufs.length;i++){let a=this.bufs[i],o=r,s=o+a.byteLength;if(r=s,e>=s)continue;let c=e>=o&&e<s,l=t>o&&t<=s;if(c&&l){if(e===o&&t===s){n.push(a);break}let r=e-o;n.push(a.subarray(r,r+(t-e)));break}if(c){if(e===0){n.push(a);continue}n.push(a.subarray(e-o));continue}if(l){if(t===s){n.push(a);break}n.push(a.subarray(0,t-o));break}n.push(a)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!U(e)&&!(e instanceof Uint8Array))throw TypeError(`The "value" argument must be a Uint8ArrayList or Uint8Array`);let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let r=n.byteLength;if(r===0)throw TypeError(`search must be at least 1 byte long`);let i=new Int32Array(256);for(let e=0;e<256;e++)i[e]=-1;for(let e=0;e<r;e++)i[n[e]]=e;let a=i,o=this.byteLength-n.byteLength,s=n.byteLength-1,c;for(let e=t;e<=o;e+=c){c=0;for(let t=s;t>=0;t--){let r=this.get(e+t);if(n[t]!==r){c=Math.max(1,t-a[r]);break}}if(c===0)return e}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=Ut(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let r=H(2);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt16(0,t,n),this.write(r,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let r=H(4);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt32(0,t,n),this.write(r,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let r=H(8);new DataView(r.buffer,r.byteOffset,r.byteLength).setBigInt64(0,t,n),this.write(r,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=Ut(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let r=H(2);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint16(0,t,n),this.write(r,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let r=H(4);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint32(0,t,n),this.write(r,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let r=H(8);new DataView(r.buffer,r.byteOffset,r.byteLength).setBigUint64(0,t,n),this.write(r,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let r=H(4);new DataView(r.buffer,r.byteOffset,r.byteLength).setFloat32(0,t,n),this.write(r,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let r=H(8);new DataView(r.buffer,r.byteOffset,r.byteLength).setFloat64(0,t,n),this.write(r,e)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!qt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,n){let r=new e;return r.bufs=t,n??=t.reduce((e,t)=>e+t.byteLength,0),r.length=n,r}};function Xt(e){let t=e.fromBinary.bind(e);return async function*(e){for await(let n of e)if(Array.isArray(n))for(let e of n)yield*[t(e)];else yield*[t(n)]}}function Zt(e){return async function*(t){for await(let n of t)if(Array.isArray(n))for(let t of n)yield e.toBinary(t);else yield e.toBinary(n)}}const Qt=1e7,$t=Xt(zt),en=Zt(zt),tn=e=>{if(e.length<4)throw RangeError(`Could not decode int32BE`);return e.getUint32(0,!0)};tn.bytes=4;const nn=e=>{let t=new W(new Uint8Array(4));return t.setUint32(0,e,!0),t};nn.bytes=4;async function*rn(e,t){for await(let n of e){let e=n instanceof Uint8Array?n.length:n.byteLength;if(e===0||e>Qt)throw RangeError(`invalid packet length: ${e}`);yield new W(t(e),n)}}async function*an(e,t){let n=new W;for await(let r of e)for(n.append(r);n.length>=t.bytes;){let e=t(n);if(e===0||e>Qt)throw RangeError(`invalid packet length: ${e}`);let r=t.bytes+e;if(n.length<r)break;yield new W(n.slice(t.bytes,r)),n.consume(r)}if(n.length!==0)throw RangeError(`truncated packet frame`)}function on(e=nn){return t=>rn(t,e)}function sn(e=tn){return t=>an(t,e)}var cn=class{_value;_waiters;constructor(e){this._value=e||void 0,this._waiters=[]}get value(){return this._value}async wait(){let e=this._value;return e===void 0?new Promise(e=>{this.waitWithCb(t=>{e(t)})}):e}waitWithCb(e){e&&this._waiters.push(e)}set(e){if(this._value=e,e===void 0)return;let t=this._waiters;if(t.length!==0){this._waiters=[];for(let n of t)n(e)}}},ln=class extends cn{constructor(e){super(e)}get openStreamFunc(){return async()=>{let e=this.value;return e||=await this.wait(),e()}}},un=class{openStreamCtr;constructor(e){this.openStreamCtr=new ln(e||void 0)}setOpenStreamFn(e){this.openStreamCtr.set(e||void 0)}async request(e,t,n,r){let i=await this.startRpc(e,t,n,r);for await(let e of i.rpcDataSource)return i.close(),e;let a=Error(`empty response`);throw i.close(a),a}async clientStreamingRequest(e,t,n,r){let i=await this.startRpc(e,t,null,r);i.writeCallDataFromSource(n).catch(e=>i.close(e));for await(let e of i.rpcDataSource)return i.close(),e;let a=Error(`empty response`);throw i.close(a),a}serverStreamingRequest(e,t,n,r){let i=l({objectMode:!0});return this.startRpc(e,t,n,r).then(async e=>Ht(e.rpcDataSource,i)).catch(e=>i.end(e)),i}bidirectionalStreamingRequest(e,t,n,r){let i=l({objectMode:!0});return this.startRpc(e,t,null,r).then(async e=>{let t=t=>{i.end(t),e.close(t)};e.writeCallDataFromSource(n).catch(t);try{for await(let t of e.rpcDataSource)i.push(t);i.end(),e.close()}catch(e){t(e)}}).catch(e=>i.end(e)),i}async startRpc(e,n,r,i){if(i?.aborted)throw Error(t);let a=await(await this.openStreamCtr.wait())(),o=new Vt(e,n),s=()=>{if(o.isClosed)return;let e=Error(t);o.writeCallCancel().catch(()=>void 0),a.abort(e),o.close(e).catch(()=>void 0)};return i?.addEventListener(`abort`,s,{once:!0}),m(a,$t,o,en,a).then(async()=>{if(o.isClosed instanceof Error){a.abort(o.isClosed);return}await a.close(),await o.close()},async e=>{let t=e instanceof Error?e:Error(String(e));a.abort(t),await o.close(t)}).finally(()=>{i?.removeEventListener(`abort`,s)}),await o.writeCallStart(r??void 0),o}},dn=class extends Bt{lookupMethod;constructor(e){super(),this.lookupMethod=e}async handleCallStart(e){if(this.service||this.method)throw Error(`call start must be sent only once`);if(this.service=e.rpcService,this.method=e.rpcMethod,!this.service||!this.method)throw Error(`rpcService and rpcMethod cannot be empty`);if(!this.lookupMethod)throw Error(`LookupMethod is not defined`);let t=await this.lookupMethod(this.service,this.method);if(!t)throw Error(`not found: ${this.service}/${this.method}`);this.pushRpcData(e.data,e.dataIsZero),this.invokeRPC(t)}async handleCallData(e){if(!this.service||!this.method)throw Error(`call start must be sent before call data`);return super.handleCallData(e)}async invokeRPC(e){let t=this._createDataSink();try{await e(this.rpcDataSource,t,{signal:this.invocationSignal})}catch(e){this.close(e)}}_createDataSink(){return async e=>{try{for await(let t of e)await this.writeCallData(t);await this.writeCallData(void 0,!0),this.close()}catch(e){this.close(e)}}}},fn=class{lookupMethod;constructor(e){this.lookupMethod=e}get rpcStreamHandler(){return async e=>pn(e,this.startRpc())}startRpc(){return new dn(this.lookupMethod)}handlePacketStream(e){let t=this.startRpc();return pn(e,t).catch(()=>void 0),t}};async function pn(e,t){try{if(await m(e,$t,t,en,e),t.isClosed instanceof Error)throw e.abort(t.isClosed),t.isClosed;await e.close(),await t.close()}catch(n){let r=n instanceof Error?n:Error(String(n));throw e.abort(r),await t.close(r),r}}function mn(e){if(e!=null){if(typeof e[Symbol.iterator]==`function`)return e[Symbol.iterator]();if(typeof e[Symbol.asyncIterator]==`function`)return e[Symbol.asyncIterator]();if(typeof e.next==`function`)return e}throw Error(`argument is not an iterator or iterable`)}var G=class extends Error{static name=`InvalidFrameError`;constructor(e=`The frame was invalid`){super(e),this.name=`InvalidFrameError`}},hn=class extends Error{static name=`UnrequestedPingError`;constructor(e=`Unrequested ping error`){super(e),this.name=`UnrequestedPingError`}},gn=class extends Error{static name=`NotMatchingPingError`;constructor(e=`Unrequested ping error`){super(e),this.name=`NotMatchingPingError`}},_n=class extends Error{static name=`InvalidStateError`;constructor(e=`Invalid state`){super(e),this.name=`InvalidStateError`}},vn=class extends Error{static name=`StreamAlreadyExistsError`;constructor(e=`Strean already exists`){super(e),this.name=`StreamAlreadyExistsError`}},yn=class extends Error{static name=`DecodeInvalidVersionError`;constructor(e=`Decode invalid version`){super(e),this.name=`DecodeInvalidVersionError`}},bn=class extends Error{static name=`BothClientsError`;constructor(e=`Both clients`){super(e),this.name=`BothClientsError`}},xn=class extends Error{static name=`ReceiveWindowExceededError`;constructor(e=`Receive window exceeded`){super(e),this.name=`ReceiveWindowExceededError`}};const Sn=new Set([G.name,hn.name,gn.name,vn.name,yn.name,bn.name,xn.name]),Cn=262144,wn=Symbol.for(`@libp2p/service-capabilities`);var Tn=class extends Error{static name=`AbortError`;constructor(e=`The operation was aborted`){super(e),this.name=`AbortError`}},K=class extends Error{static name=`InvalidParametersError`;constructor(e=`Invalid parameters`){super(e),this.name=`InvalidParametersError`}},q=class extends Error{static name=`MuxerClosedError`;constructor(e=`The muxer is closed`){super(e),this.name=`MuxerClosedError`}},En=class extends Error{static name=`TooManyOutboundProtocolStreamsError`;constructor(e=`Too many outbound protocol streams`){super(e),this.name=`TooManyOutboundProtocolStreamsError`}};const Dn={enableKeepAlive:!0,keepAliveInterval:3e4,maxInboundStreams:1e3,maxOutboundStreams:1e3,initialStreamWindowSize:Cn,maxStreamWindowSize:16777216,maxMessageSize:65536};function On(e){if(e.keepAliveInterval<=0)throw new K(`keep-alive interval must be positive`);if(e.maxInboundStreams<0)throw new K(`max inbound streams must be larger or equal 0`);if(e.maxOutboundStreams<0)throw new K(`max outbound streams must be larger or equal 0`);if(e.initialStreamWindowSize<262144)throw new K(`InitialStreamWindowSize must be larger or equal 256 kB`);if(e.maxStreamWindowSize<e.initialStreamWindowSize)throw new K(`MaxStreamWindowSize must be larger than the InitialStreamWindowSize`);if(e.maxStreamWindowSize>2**32-1)throw new K(`MaxStreamWindowSize must be less than equal MAX_UINT32`);if(e.maxMessageSize<1024)throw new K(`MaxMessageSize must be greater than a kilobyte`)}var J;(function(e){e[e.Data=0]=`Data`,e[e.WindowUpdate=1]=`WindowUpdate`,e[e.Ping=2]=`Ping`,e[e.GoAway=3]=`GoAway`})(J||={});var Y;(function(e){e[e.SYN=1]=`SYN`,e[e.ACK=2]=`ACK`,e[e.FIN=4]=`FIN`,e[e.RST=8]=`RST`})(Y||={}),Object.values(Y).filter(e=>typeof e!=`string`);var X;(function(e){e[e.NormalTermination=0]=`NormalTermination`,e[e.ProtocolError=1]=`ProtocolError`,e[e.InternalError=2]=`InternalError`})(X||={});const kn=2**24;function An(e){if(e[0]!==0)throw new G(`Invalid frame version`);return{type:e[1],flag:(e[2]<<8)+e[3],streamID:e[4]*kn+(e[5]<<16)+(e[6]<<8)+e[7],length:e[8]*kn+(e[9]<<16)+(e[10]<<8)+e[11]}}var jn=class{source;buffer;frameInProgress;constructor(e){this.source=Mn(e),this.buffer=new W,this.frameInProgress=!1}async*emitFrames(){for await(let e of this.source)for(this.buffer.append(e);;){let e=this.readHeader();if(e===void 0)break;let{type:t,length:n}=e;t===J.Data?(this.frameInProgress=!0,yield{header:e,readData:this.readBytes.bind(this,n)}):yield{header:e}}}readHeader(){if(this.frameInProgress)throw new _n(`decoding frame already in progress`);if(this.buffer.length<12)return;let e=An(this.buffer.subarray(0,12));return this.buffer.consume(12),e}async readBytes(e){if(this.buffer.length<e){for await(let t of this.source)if(this.buffer.append(t),this.buffer.length>=e)break}let t=this.buffer.sublist(0,e);return this.buffer.consume(e),this.frameInProgress=!1,t}};function Mn(e){if(e[Symbol.iterator]!==void 0){let t=e[Symbol.iterator]();return t.return=void 0,{[Symbol.iterator](){return t}}}if(e[Symbol.asyncIterator]!==void 0){let t=e[Symbol.asyncIterator]();return t.return=void 0,{[Symbol.asyncIterator](){return t}}}throw Error(`a source must be either an iterable or an async iterable`)}function Nn(e){let 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 Pn=class extends Error{static name=`StreamResetError`;constructor(e=`The stream has been reset`){super(e),this.name=`StreamResetError`}},Fn=class extends Error{static name=`StreamStateError`;constructor(e=`The stream is in an invalid state`){super(e),this.name=`StreamStateError`}};function In(e){return e!=null&&typeof e.then==`function`&&typeof e.catch==`function`&&typeof e.finally==`function`}function Ln(e,t){let n=mn(e).return?.();In(n)&&n.catch(e=>{t.error(`could not cause iterator to return`,e)})}function Rn(e){return e!=null&&typeof e.then==`function`&&typeof e.catch==`function`&&typeof e.finally==`function`}var zn=class{id;direction;timeline;protocol;metadata;source;status;readStatus;writeStatus;log;sinkController;sinkEnd;closed;endErr;streamSource;onEnd;onCloseRead;onCloseWrite;onReset;onAbort;sendCloseWriteTimeout;sendingData;constructor(e){this.sinkController=new AbortController,this.sinkEnd=a(),this.closed=a(),this.log=e.log,this.status=`open`,this.readStatus=`ready`,this.writeStatus=`ready`,this.id=e.id,this.metadata=e.metadata??{},this.direction=e.direction,this.timeline={open:Date.now()},this.sendCloseWriteTimeout=e.sendCloseWriteTimeout??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=l({onEnd:e=>{e==null?this.log.trace(`source ended`):this.log.trace(`source ended with error`,e),this.onSourceEnd(e)}}),this.sink=this.sink.bind(this)}async sink(e){if(this.writeStatus!==`ready`)throw new Fn(`writable end state is "${this.writeStatus}" not "ready"`);try{this.writeStatus=`writing`;let t={signal:this.sinkController.signal};if(this.direction===`outbound`){let e=this.sendNewStream(t);Rn(e)&&await e}let n=()=>{Ln(e,this.log)};try{this.sinkController.signal.addEventListener(`abort`,n),this.log.trace(`sink reading from source`);for await(let n of e){n=n instanceof Uint8Array?new W(n):n;let e=this.sendData(n,t);Rn(e)&&(this.sendingData=a(),await e,this.sendingData.resolve(),this.sendingData=void 0)}}finally{this.sinkController.signal.removeEventListener(`abort`,n)}this.log.trace(`sink finished reading from source, write status is "%s"`,this.writeStatus),this.writeStatus===`writing`&&(this.writeStatus=`closing`,this.log.trace(`send close write to remote`),await this.sendCloseWrite({signal:AbortSignal.timeout(this.sendCloseWriteTimeout)}),this.writeStatus=`closed`),this.onSinkEnd()}catch(e){throw this.log.trace(`sink ended with error, calling abort with error`,e),this.abort(e),e}finally{this.log.trace(`resolve sink end`),this.sinkEnd.resolve()}}onSourceEnd(e){this.timeline.closeRead??(this.timeline.closeRead=Date.now(),this.readStatus=`closed`,e!=null&&this.endErr==null&&(this.endErr=e),this.onCloseRead?.(),this.timeline.closeWrite==null?this.log.trace(`source ended, waiting for sink to end`):(this.log.trace(`source and sink ended`),this.timeline.close=Date.now(),this.status!==`aborted`&&this.status!==`reset`&&(this.status=`closed`),this.onEnd!=null&&this.onEnd(this.endErr),this.closed.resolve()))}onSinkEnd(e){this.timeline.closeWrite??(this.timeline.closeWrite=Date.now(),this.writeStatus=`closed`,e!=null&&this.endErr==null&&(this.endErr=e),this.onCloseWrite?.(),this.timeline.closeRead==null?this.log.trace(`sink ended, waiting for source to end`):(this.log.trace(`sink and source ended`),this.timeline.close=Date.now(),this.status!==`aborted`&&this.status!==`reset`&&(this.status=`closed`),this.onEnd!=null&&this.onEnd(this.endErr),this.closed.resolve()))}async close(e){this.status===`open`&&(this.log.trace(`closing gracefully`),this.status=`closing`,await d(Promise.all([this.closeWrite(e),this.closeRead(e),this.closed.promise]),e?.signal),this.status=`closed`,this.log.trace(`closed gracefully`))}async closeRead(e={}){if(this.readStatus===`closing`||this.readStatus===`closed`)return;this.log.trace(`closing readable end of stream with starting read status "%s"`,this.readStatus);let t=this.readStatus;this.readStatus=`closing`,this.status!==`reset`&&this.status!==`aborted`&&this.timeline.closeRead==null&&(this.log.trace(`send close read to remote`),await this.sendCloseRead(e)),t===`ready`&&(this.log.trace(`ending internal source queue with %d queued bytes`,this.streamSource.readableLength),this.streamSource.end()),this.log.trace(`closed readable end of stream`)}async closeWrite(e={}){this.writeStatus!==`closing`&&this.writeStatus!==`closed`&&(this.log.trace(`closing writable end of stream with starting write status "%s"`,this.writeStatus),this.writeStatus===`ready`&&(this.log.trace(`sink was never sunk, sink an empty array`),await d(this.sink([]),e.signal)),this.writeStatus===`writing`&&(this.sendingData!=null&&await d(this.sendingData.promise,e.signal),this.log.trace(`aborting source passed to .sink`),this.sinkController.abort(),await d(this.sinkEnd.promise,e.signal)),this.writeStatus=`closed`,this.log.trace(`closed writable end of stream`))}abort(e){if(this.status===`closed`||this.status===`aborted`||this.status===`reset`)return;this.log(`abort with error`,e),this.log(`try to send reset to remote`);let t=this.sendReset();Rn(t)&&t.catch(e=>{this.log.error(`error sending reset message`,e)}),this.status=`aborted`,this.timeline.abort=Date.now(),this._closeSinkAndSource(e),this.onAbort?.(e)}reset(){if(this.status===`closed`||this.status===`aborted`||this.status===`reset`)return;let e=new Pn(`stream reset`);this.status=`reset`,this.timeline.reset=Date.now(),this._closeSinkAndSource(e),this.onReset?.()}_closeSinkAndSource(e){this._closeSink(e),this._closeSource(e)}_closeSink(e){this.writeStatus===`writing`&&(this.log.trace(`end sink source`),this.sinkController.abort()),this.onSinkEnd(e)}_closeSource(e){this.readStatus!==`closing`&&this.readStatus!==`closed`&&(this.log.trace(`ending source with %d bytes to be read by consumer`,this.streamSource.readableLength),this.readStatus=`closing`,this.streamSource.end(e))}remoteCloseWrite(){if(this.readStatus===`closing`||this.readStatus===`closed`){this.log(`received remote close write but local source is already closed`);return}this.log.trace(`remote close write`),this._closeSource()}remoteCloseRead(){if(this.writeStatus===`closing`||this.writeStatus===`closed`){this.log(`received remote close read but local sink is already closed`);return}this.log.trace(`remote close read`),this._closeSink()}destroy(){if(this.status===`closed`||this.status===`aborted`||this.status===`reset`){this.log(`received destroy but we are already closed`);return}this.log.trace(`stream destroyed`),this._closeSinkAndSource()}sourcePush(e){this.streamSource.push(e)}sourceReadableLength(){return this.streamSource.readableLength}};function Bn(e){let[t,n]=e[Symbol.asyncIterator]==null?[e[Symbol.iterator](),Symbol.iterator]:[e[Symbol.asyncIterator](),Symbol.asyncIterator],r=[];return{peek:()=>t.next(),push:e=>{r.push(e)},next:()=>r.length>0?{done:!1,value:r.shift()}:t.next(),[n](){return this}}}function Vn(e){return e[Symbol.asyncIterator]!=null}function Hn(e){return e?.then!=null}function Un(e,t){let n=0;if(Vn(e))return(async function*(){for await(let r of e){let e=t(r,n++);Hn(e)&&await e,yield r}})();let r=Bn(e),{value:i,done:a}=r.next();if(a===!0)return function*(){}();let o=t(i,n++);if(typeof o?.then==`function`)return(async function*(){await o,yield i;for(let e of r){let r=t(e,n++);Hn(r)&&await r,yield e}})();let s=t;return(function*(){yield i;for(let e of r)s(e,n++),yield e})()}var Z;(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`})(Z||={});var Wn=class extends zn{name;state;config;_id;sendWindowCapacity;sendWindowCapacityUpdate;recvWindow;recvWindowCapacity;epochStart;getRTT;sendFrame;constructor(e){super({...e,onEnd:t=>{this.state=Z.Finished,e.onEnd?.(t)}}),this.config=e.config,this._id=parseInt(e.id,10),this.name=e.name,this.state=e.state,this.sendWindowCapacity=Cn,this.recvWindow=this.config.initialStreamWindowSize,this.recvWindowCapacity=this.recvWindow,this.epochStart=Date.now(),this.getRTT=e.getRTT,this.sendFrame=e.sendFrame,this.source=Un(this.source,()=>{this.sendWindowUpdate()})}async sendNewStream(){}async sendData(e,t={}){for(e=e.sublist();e.byteLength!==0;){if(this.sendWindowCapacity===0&&(this.log?.trace(`wait for send window capacity, status %s`,this.status),await this.waitForSendWindowCapacity(t),this.status===`closed`||this.status===`aborted`||this.status===`reset`)){this.log?.trace(`%s while waiting for send window capacity`,this.status);return}let n=Math.min(this.sendWindowCapacity,this.config.maxMessageSize-12,e.length),r=this.getSendFlags();this.sendFrame({type:J.Data,flag:r,streamID:this._id,length:n},e.sublist(0,n)),this.sendWindowCapacity-=n,e.consume(n)}}sendReset(){this.sendFrame({type:J.WindowUpdate,flag:Y.RST,streamID:this._id,length:0})}async sendCloseWrite(){let e=this.getSendFlags()|Y.FIN;this.sendFrame({type:J.WindowUpdate,flag:e,streamID:this._id,length:0})}async sendCloseRead(){}async waitForSendWindowCapacity(e={}){if(this.sendWindowCapacity>0)return;let t,n,r=()=>{this.status===`open`||this.status===`closing`?n(new Tn(`Stream aborted`)):t()};e.signal?.addEventListener(`abort`,r);try{await new Promise((e,r)=>{this.sendWindowCapacityUpdate=()=>{e()},n=r,t=e})}finally{e.signal?.removeEventListener(`abort`,r)}}handleWindowUpdate(e){this.log?.trace(`stream received window update id=%s`,this._id),this.processFlags(e.flag);let t=this.sendWindowCapacity;this.sendWindowCapacity+=e.length,t===0&&e.length>0&&this.sendWindowCapacityUpdate?.()}async handleData(e,t){if(this.log?.trace(`stream received data id=%s`,this._id),this.processFlags(e.flag),this.recvWindowCapacity<e.length)throw new xn(`Receive window exceeded`);let n=await t();this.recvWindowCapacity-=e.length,this.sourcePush(n)}processFlags(e){(e&Y.ACK)===Y.ACK&&this.state===Z.SYNSent&&(this.state=Z.Established),(e&Y.FIN)===Y.FIN&&this.remoteCloseWrite(),(e&Y.RST)===Y.RST&&this.reset()}getSendFlags(){switch(this.state){case Z.Init:return this.state=Z.SYNSent,Y.SYN;case Z.SYNReceived:return this.state=Z.Established,Y.ACK;default:return 0}}sendWindowUpdate(){if(this.readStatus!==`ready`)return;let e=this.getSendFlags(),t=Date.now(),n=this.getRTT();if(e===0&&n>-1&&t-this.epochStart<n*4&&(this.recvWindow=Math.min(this.recvWindow*2,this.config.maxStreamWindowSize)),this.recvWindowCapacity>=this.recvWindow&&e===0)return;let r=this.recvWindow-this.recvWindowCapacity;this.recvWindowCapacity=this.recvWindow,this.epochStart=t,this.sendFrame({type:J.WindowUpdate,flag:e,streamID:this._id,length:r})}};const Gn=`/yamux/1.0.0`;var Kn=class{protocol=Gn;_components;_init;constructor(e,t={}){this._components=e,this._init=t}[Symbol.toStringTag]=`@chainsafe/libp2p-yamux`;[wn]=[`@libp2p/stream-multiplexing`];createStreamMuxer(e){return new qn(this._components,{...this._init,...e})}},qn=class{protocol=Gn;source;sink;config;log;logger;closeController;nextStreamID;_streams;nextPingID;activePing;rtt;client;localGoAway;remoteGoAway;numInboundStreams;numOutboundStreams;onIncomingStream;onStreamEnd;constructor(e,t){this.client=t.direction===`outbound`,this.config={...Dn,...t},this.logger=e.logger,this.log=this.logger.forComponent(`libp2p:yamux`),On(this.config),this.closeController=new AbortController,this.closeController.signal,this.onIncomingStream=t.onIncomingStream,this.onStreamEnd=t.onStreamEnd,this._streams=new Map,this.source=l({onEnd:()=>{this.log?.trace(`muxer source ended`),this._streams.forEach(e=>{e.destroy()})}}),this.sink=async e=>{let t=()=>{let t=mn(e);if(t.return!=null){let e=t.return();Jn(e)&&e.catch(e=>{this.log?.(`could not cause sink source to return`,e)})}},n,r;try{let r=new jn(e);try{this.closeController.signal.addEventListener(`abort`,t);for await(let e of r.emitFrames())await this.handleFrame(e.header,e.readData)}finally{this.closeController.signal.removeEventListener(`abort`,t)}n=X.NormalTermination}catch(e){Sn.has(e.name)?(this.log?.error(`protocol error in sink`,e),n=X.ProtocolError):(this.log?.error(`internal error in sink`,e),n=X.InternalError),r=e}this.log?.trace(`muxer sink ended`),r==null?await this.close({reason:n}):this.abort(r,n)},this.numInboundStreams=0,this.numOutboundStreams=0,this.nextStreamID=this.client?1:2,this.nextPingID=0,this.rtt=-1,this.log?.trace(`muxer created`),this.config.enableKeepAlive&&this.keepAliveLoop().catch(e=>this.log?.error(`keepalive error: %s`,e)),this.ping().catch(e=>this.log?.error(`ping error: %s`,e))}get streams(){return Array.from(this._streams.values())}newStream(e){if(this.remoteGoAway!==void 0)throw new q(`Muxer closed remotely`);if(this.localGoAway!==void 0)throw new q(`Muxer closed locally`);let t=this.nextStreamID;if(this.nextStreamID+=2,this.numOutboundStreams>=this.config.maxOutboundStreams)throw new En(`max outbound streams exceeded`);this.log?.trace(`new outgoing stream id=%s`,t);let n=this._newStream(t,e,Z.Init,`outbound`);return this._streams.set(t,n),this.numOutboundStreams++,n.sendWindowUpdate(),n}async ping(){if(this.remoteGoAway!==void 0)throw new q(`Muxer closed remotely`);if(this.localGoAway!==void 0)throw new q(`Muxer closed locally`);if(this.activePing===void 0){let e=()=>{};this.activePing={id:this.nextPingID++,promise:new Promise((t,n)=>{let r=()=>{n(new q(`Muxer closed locally`))};this.closeController.signal.addEventListener(`abort`,r,{once:!0}),e=()=>{this.closeController.signal.removeEventListener(`abort`,r),t()}}),resolve:e};let t=Date.now();this.sendPing(this.activePing.id);try{await this.activePing.promise}finally{delete this.activePing}let n=Date.now();this.rtt=n-t}else await this.activePing.promise;return this.rtt}getRTT(){return this.rtt}async close(e={}){if(this.closeController.signal.aborted)return;let t=e?.reason??X.NormalTermination;if(this.log?.trace(`muxer close reason=%s`,t),e.signal==null){let t=AbortSignal.timeout(500);e={...e,signal:t}}try{await Promise.all([...this._streams.values()].map(async t=>t.close(e))),this.sendGoAway(t),this._closeMuxer()}catch(e){this.abort(e)}}abort(e,t){if(!this.closeController.signal.aborted){t??=X.InternalError,this.log?.error(`muxer abort reason=%s error=%s`,t,e);for(let t of this._streams.values())t.abort(e);this.sendGoAway(t),this._closeMuxer()}}isClosed(){return this.closeController.signal.aborted}_closeMuxer(){this.closeController.abort(),this.source.end()}_newStream(e,t,n,r){if(this._streams.get(e)!=null)throw new K(`Stream already exists with that id`);let i=new Wn({id:e.toString(),name:t,state:n,direction:r,sendFrame:this.sendFrame.bind(this),onEnd:()=>{this.closeStream(e),this.onStreamEnd?.(i)},log:this.logger.forComponent(`libp2p:yamux:${r}:${e}`),config:this.config,getRTT:this.getRTT.bind(this)});return i}closeStream(e){this.client===(e%2==0)?this.numInboundStreams--:this.numOutboundStreams--,this._streams.delete(e)}async keepAliveLoop(){for(this.log?.trace(`muxer keepalive enabled interval=%s`,this.config.keepAliveInterval);;){let e;try{await d(new Promise(t=>{e=setTimeout(t,this.config.keepAliveInterval)}),this.closeController.signal),this.ping().catch(e=>this.log?.error(`ping error: %s`,e))}catch{clearInterval(e);return}}}async handleFrame(e,t){let{streamID:n,type:r,length:i}=e;if(this.log?.trace(`received frame %o`,e),n===0)switch(r){case J.Ping:this.handlePing(e);return;case J.GoAway:this.handleGoAway(i);return;default:throw new G(`Invalid frame type`)}else switch(e.type){case J.Data:case J.WindowUpdate:await this.handleStreamMessage(e,t);return;default:throw new G(`Invalid frame type`)}}handlePing(e){if(e.flag===Y.SYN)this.log?.trace(`received ping request pingId=%s`,e.length),this.sendPing(e.length,Y.ACK);else if(e.flag===Y.ACK)this.log?.trace(`received ping response pingId=%s`,e.length),this.handlePingResponse(e.length);else throw new G(`Invalid frame flag`)}handlePingResponse(e){if(this.activePing===void 0)throw new hn(`ping not requested`);if(this.activePing.id!==e)throw new gn(`ping doesn't match our id`);this.activePing.resolve()}handleGoAway(e){this.log?.trace(`received GoAway reason=%s`,X[e]??`unknown`),this.remoteGoAway=e;for(let e of this._streams.values())e.reset();this._closeMuxer()}async handleStreamMessage(e,t){let{streamID:n,flag:r,type:i}=e;(r&Y.SYN)===Y.SYN&&this.incomingStream(n);let a=this._streams.get(n);if(a===void 0){if(i===J.Data){if(this.log?.(`discarding data for stream id=%s`,n),t===void 0)throw Error(`unreachable`);await t()}else this.log?.trace(`frame for missing stream id=%s`,n);return}switch(i){case J.WindowUpdate:a.handleWindowUpdate(e);return;case J.Data:if(t===void 0)throw Error(`unreachable`);await a.handleData(e,t);return;default:throw Error(`unreachable`)}}incomingStream(e){if(this.client!==(e%2==0))throw new K(`Both endpoints are clients`);if(this._streams.has(e))return;if(this.log?.trace(`new incoming stream id=%s`,e),this.localGoAway!==void 0){this.sendFrame({type:J.WindowUpdate,flag:Y.RST,streamID:e,length:0});return}if(this.numInboundStreams>=this.config.maxInboundStreams){this.log?.(`maxIncomingStreams exceeded, forcing stream reset`),this.sendFrame({type:J.WindowUpdate,flag:Y.RST,streamID:e,length:0});return}let t=this._newStream(e,void 0,Z.SYNReceived,`inbound`);this.numInboundStreams++,this._streams.set(e,t),this.onIncomingStream?.(t)}sendFrame(e,t){if(this.log?.trace(`sending frame %o`,e),e.type===J.Data){if(t===void 0)throw new G(`Invalid frame`);this.source.push(new W(Nn(e),t))}else this.source.push(Nn(e))}sendPing(e,t=Y.SYN){t===Y.SYN?this.log?.trace(`sending ping request pingId=%s`,e):this.log?.trace(`sending ping response pingId=%s`,e),this.sendFrame({type:J.Ping,flag:t,streamID:0,length:e})}sendGoAway(e=X.NormalTermination){this.log?.(`sending GoAway reason=%s`,X[e]),this.localGoAway=e,this.sendFrame({type:J.GoAway,flag:0,streamID:0,length:e})}};function Jn(e){return e!=null&&typeof e.then==`function`}function Yn(e={}){return t=>new Kn(t,e)}function Xn(){return async function*(e){for await(let t of e)U(t)?yield t.subarray():yield t}}var Zn=class{_waiters=new Set;_error;_terminated=!1;get terminated(){return this._terminated}terminate(e){if(this._terminated)return!1;this._terminated=!0,this._error=e;for(let t of this._waiters)t(e);return this._waiters.clear(),!0}async wait(e){if(this._terminated)return{terminated:!0,error:this._error};let t,n=new Promise(e=>{t=t=>e({terminated:!0,error:t}),this._waiters.add(t)}),r=e.then(e=>({result:e}),e=>({error:e}));try{let e=await Promise.race([r,n]);return this._terminated?{terminated:!0,error:this._error}:e}finally{this._waiters.delete(t)}}next(e){return this.wait(e.next())}};function Qn(e){if(Symbol.asyncIterator in e)return e[Symbol.asyncIterator]();let t=e[Symbol.iterator]();return{next:async()=>t.next()}}function $n(e){e.return&&Promise.resolve(e.return()).catch(()=>void 0)}function er(e){let t=new Zn;return{close:async()=>{t.terminate()&&await e.close()},abort:n=>{t.terminate(n)&&e.abort(n)},source:(async function*(){let n=m(e,sn(),Xn())[Symbol.asyncIterator]();try{for(;;){let e=await t.next(n);if(`terminated`in e){if(e.error)throw e.error;return}if(`error`in e)throw e.error;if(e.result.done)return;yield e.result.value}}finally{$n(n)}})(),sink:async n=>{let r=Qn(m(n,on())),i=(async function*(){for(;;){let e=await t.next(r);if(`terminated`in e){if(e.error)throw e.error;return}if(`error`in e)throw e.error;if(e.result.done||t.terminated)return;yield e.result.value}})();try{let n=await t.wait(e.sink(i));if(`terminated`in n){if(n.error)throw n.error;return}if(`error`in n)throw n.error;await e.closeWrite()}catch(n){let r=n instanceof Error?n:Error(String(n));throw t.terminate(r)&&e.abort(r),r}finally{$n(r)}}}}function tr(e){let t=()=>{};return t.enabled=!1,t.color=``,t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t.debug=t,t.error=t,t.trace=t,t.newScope=()=>t,t}function nr(){return{forComponent:tr}}var rr=class{_muxer;_server;constructor(e,t){e&&(this._server=e);let n=t?.muxerFactory??Yn({enableKeepAlive:!1,...t?.yamuxParams})({logger:t?.logger??nr()});this._muxer=n.createStreamMuxer({onIncomingStream:this.handleIncomingStream.bind(this),direction:t?.direction||`outbound`})}get sink(){return this._muxer.sink}get source(){return this._muxer.source}get streams(){return this._muxer.streams}get muxer(){return this._muxer}get server(){return this._server}buildClient(){return new un(this.openStream.bind(this))}async openStream(){return er(await this.muxer.newStream())}buildOpenStreamFunc(){return this.openStream.bind(this)}handleIncomingStream(e){let t=this.server;if(!t)return e.abort(Error(`server not implemented`));t.handlePacketStream(er(e))}close(e){e?this.muxer.abort(e):this.muxer.close()}},ir=async e=>{if(e.readyState>=2)throw Error(`socket closed`);e.readyState!==1&&await new Promise((t,n)=>{function r(){e.removeEventListener(`open`,i),e.removeEventListener(`error`,a)}function i(){r(),t()}function a(t){r(),n(t.error??Error(`connect ECONNREFUSED ${e.url}`))}e.addEventListener(`open`,i),e.addEventListener(`error`,a)})},ar=(e,t)=>(t??={},t.closeOnEnd=t.closeOnEnd!==!1,async n=>{for await(let t of n){try{await ir(e)}catch(e){if(e.message===`socket closed`)break;throw e}if(e.readyState===e.CLOSING||e.readyState===e.CLOSED)break;e.send(t)}t.closeOnEnd!=null&&e.readyState<=1&&await new Promise((t,n)=>{e.addEventListener(`close`,e=>{e.wasClean||e.code===1006?t():n(Object.assign(Error(`ws error`),{event:e}))}),setTimeout(()=>{e.close()})})}),or=e((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=class{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;let t={value:e,done:!1};if(this.pullQueue.length){let e=this.pullQueue.shift();e&&e.resolve(t)}else this.pushQueue.push(Promise.resolve(t)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(let e of this.pullQueue)e.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(e){if(!this.isStopped){if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(let t of this.pullQueue)t.reject(e);this.pullQueue.length=0}else{let t=Promise.reject(e);t.catch(()=>{}),this.pushQueue.push(t)}}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:e=>{let t=this.pushQueue.shift();return t?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),t):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{this.pullQueue.push({resolve:e,reject:t})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}},n=class{constructor(e,{highWaterMark:n=100,lowWaterMark:r=1}={}){let i=new t;i.highWaterMark=n,i.lowWaterMark=r,i.removeCallback=e({push:e=>i.push(e),stop:()=>i.stop(),fail:e=>i.fail(e),on:(e,t)=>{i.eventHandlers[e]=t}})||(()=>{}),this[Symbol.asyncIterator]=()=>i[Symbol.asyncIterator](),Object.freeze(this)}};e.EventIterator=n,e.default=n})),sr=e((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=or();e.EventIterator=t.EventIterator,e.default=t.EventIterator}))();function cr(e){return e instanceof ArrayBuffer||e?.constructor?.name===`ArrayBuffer`&&typeof e?.byteLength==`number`}var lr=e=>{e.binaryType=`arraybuffer`;let t=async()=>{await new Promise((t,n)=>{if(r){t();return}if(i!=null){n(i);return}let a=t=>{e.removeEventListener(`open`,o),e.removeEventListener(`error`,s),t()},o=()=>{a(t)},s=t=>{a(()=>{n(t.error??Error(`connect ECONNREFUSED ${e.url}`))})};e.addEventListener(`open`,o),e.addEventListener(`error`,s)})},n=async function*(){let n=new sr.EventIterator(({push:t,stop:n,fail:r})=>{let i=e=>{let n=null;if(typeof e.data==`string`)throw Error(`Unsupported string encoding`);cr(e.data)&&(n=new Uint8Array(e.data)),e.data instanceof Uint8Array&&(n=e.data),n!=null&&t(n)},a=e=>{r(e.error??Error(`Socket error`))};return e.addEventListener(`message`,i),e.addEventListener(`error`,a),e.addEventListener(`close`,n),()=>{e.removeEventListener(`message`,i),e.removeEventListener(`error`,a),e.removeEventListener(`close`,n)}},{highWaterMark:1/0});await t();for await(let e of n)yield cr(e)?new Uint8Array(e):e}(),r=e.readyState===1,i;return e.addEventListener(`open`,()=>{r=!0,i=null}),e.addEventListener(`close`,()=>{r=!1,i=null}),e.addEventListener(`error`,t=>{r||(i=t.error??Error(`connect ECONNREFUSED ${e.url}`))}),Object.assign(n,{connected:t})},ur=(e,t)=>{t??={};let n=lr(e),r=t.remoteAddress,i=t.remotePort;if(e.url!=null)try{let t=new URL(e.url);r=t.hostname,i=parseInt(t.port,10)}catch{}if(r==null||i==null)throw Error(`Remote connection did not have address and/or port`);return{sink:ar(e,t),source:n,connected:async()=>{await n.connected()},close:async()=>{(e.readyState===e.CONNECTING||e.readyState===e.OPEN)&&await new Promise(t=>{e.addEventListener(`close`,()=>{t()}),e.close()})},destroy:()=>{e.terminate==null?e.close():e.terminate()},remoteAddress:r,remotePort:i,socket:e}},dr=class extends rr{socket;constructor(e,t,n){super(n,{direction:t}),this.socket=e;let r=ur(e);m(r,this,Xn(),r).catch(e=>this.close(e)).then(()=>this.close())}getSocket(){return this.socket}},Q;(function(e){e[e.Unary=0]=`Unary`,e[e.ServerStreaming=1]=`ServerStreaming`,e[e.ClientStreaming=2]=`ClientStreaming`,e[e.BiDiStreaming=3]=`BiDiStreaming`})(Q||={});var fr;(function(e){e[e.NoSideEffects=1]=`NoSideEffects`,e[e.Idempotent=2]=`Idempotent`})(fr||={});const pr=V({typeName:`rpcstream.RpcStreamInit`,fields:[{no:1,name:`component_id`,kind:`scalar`,T:y.STRING}],packedByDefault:!0}),mr=V({typeName:`rpcstream.RpcAck`,fields:[{no:1,name:`error`,kind:`scalar`,T:y.STRING}],packedByDefault:!0}),hr=V({typeName:`rpcstream.RpcStreamPacket`,fields:[{no:1,name:`init`,kind:`message`,T:()=>pr,oneof:`body`},{no:2,name:`ack`,kind:`message`,T:()=>mr,oneof:`body`},{no:3,name:`data`,kind:`scalar`,T:y.BYTES,oneof:`body`}],packedByDefault:!0}),$=V({typeName:`echo.EchoMsg`,fields:[{no:1,name:`body`,kind:`scalar`,T:y.STRING}],packedByDefault:!0}),gr=Nt(`google.protobuf.Empty`,!0);({typeName:`echo.Echoer`,methods:{Echo:{name:`Echo`,I:$,O:$,kind:Q.Unary},EchoServerStream:{name:`EchoServerStream`,I:$,O:$,kind:Q.ServerStreaming},EchoClientStream:{name:`EchoClientStream`,I:$,O:$,kind:Q.ClientStreaming},EchoBidiStream:{name:`EchoBidiStream`,I:$,O:$,kind:Q.BiDiStreaming},RpcStream:{name:`RpcStream`,I:hr,O:hr,kind:Q.BiDiStreaming},DoNothing:{name:`DoNothing`,I:gr,O:gr,kind:Q.Unary}}}).typeName;for(let e of[`dispose`,`asyncDispose`])Symbol[e]||Object.defineProperty(Symbol,e,{value:Symbol.for(`Symbol.${e}`)});const _r=Symbol.for(`spacewave.SyncError`);var vr=class extends Error{code;requestId;name=`SyncError`;[_r]=!0;static[Symbol.hasInstance](e){return e instanceof Error&&_r in e&&e[_r]===!0}constructor(e,t,n){super(t),this.code=e,this.requestId=n}};function yr(e){return e instanceof vr?e:new vr(`STORAGE`,`The data operation could not complete`)}function br(e){return Cr(e,`$`,[])}function xr(e){return new TextEncoder().encode(br(e))}function Sr(e){let t;try{t=new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{throw TypeError(`invalid JSON at $: data is not valid UTF-8`)}let n;try{n=JSON.parse(t)}catch{throw TypeError(`invalid JSON at $: data is not valid JSON`)}return br(n),n}function Cr(e,t,n){switch(typeof e){case`boolean`:return e?`true`:`false`;case`number`:if(!Number.isFinite(e))throw TypeError(`invalid JSON at ${t}: non-finite number`);return JSON.stringify(e);case`string`:return JSON.stringify(e);case`object`:if(e===null)return`null`;break;default:throw TypeError(`invalid JSON at ${t}: ${typeof e} is not a JSON value`)}for(let r of n)if(r===e)throw TypeError(`invalid JSON at ${t}: cycle`);n.push(e);let r=Array.isArray(e)?wr(e,t,n):Tr(e,t,n);return n.pop(),r}function wr(e,t,n){let r=e.length,i=Array.from({length:r}),a=Array.from({length:r},()=>!1);for(let o of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,o);if(s.get!==void 0||s.set!==void 0)throw TypeError(`invalid JSON at ${t}[${String(o)}]: accessor property`);if(typeof o==`symbol`){if(s.enumerable)throw TypeError(`invalid JSON at ${t}: enumerable symbol key is not supported`);continue}let c=Number(o);if(Number.isInteger(c)&&c>=0&&c<r&&String(c)===o){a[c]=!0,i[c]=Cr(s.value,`${t}[${c}]`,n);continue}if(s.enumerable)throw TypeError(`invalid JSON at ${t}: extra enumerable array property ${JSON.stringify(o)}`)}for(let e=0;e<r;e++)if(!a[e])throw TypeError(`invalid JSON at ${t}[${e}]: array hole (missing index)`);return`[${i.join(`,`)}]`}function Tr(e,t,n){let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw TypeError(`invalid JSON at ${t}: not a plain object`);let i=[];for(let r of Reflect.ownKeys(e)){let a=Object.getOwnPropertyDescriptor(e,r);if(a.get!==void 0||a.set!==void 0)throw TypeError(`invalid JSON at ${t}.${String(r)}: accessor property`);if(typeof r==`symbol`){if(a.enumerable)throw TypeError(`invalid JSON at ${t}: enumerable symbol key is not supported`);continue}a.enumerable&&i.push({key:r,json:Cr(a.value,`${t}.${r}`,n)})}return i.sort((e,t)=>e.key<t.key?-1:+(e.key>t.key)),`{${i.map(e=>`${JSON.stringify(e.key)}:${e.json}`).join(`,`)}}`}export{t as C,l as S,n as T,Nt as _,yr as a,y as b,rr as c,Qn as d,Xn as f,Zt as g,Xt as h,vr as i,Zn as l,un as m,Sr as n,Q as o,fn as p,xr as r,dr as s,br as t,$n as u,V as v,i as w,m as x,qe as y};
|