spacewave 0.57.18 → 0.57.20

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.
@@ -861,7 +861,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
861
861
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
862
862
  SOFTWARE.
863
863
 
864
- github.com/aperturerobotics/bbolt/errors v0.0.0-20260927071131-f10d98b6e172
864
+ github.com/aperturerobotics/bbolt/errors v0.0.0-20261001214648-22e8393e6a95
865
865
  ===========================================================================
866
866
 
867
867
  The MIT License (MIT)
@@ -1241,7 +1241,7 @@ Apache License
1241
1241
  incurred by, or claims asserted against, such Contributor by reason
1242
1242
  of your accepting any such warranty or additional liability.
1243
1243
 
1244
- github.com/aperturerobotics/controllerbus v0.53.6-0.20260927093214-06e46d81f006
1244
+ github.com/aperturerobotics/controllerbus v0.53.6-0.20261001195447-86f830af47c0
1245
1245
  ===============================================================================
1246
1246
 
1247
1247
  Copyright (c) 2018-2025 Aperture Robotics, LLC.
@@ -1265,7 +1265,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1265
1265
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1266
1266
  SOFTWARE.
1267
1267
 
1268
- github.com/aperturerobotics/controllerbus/yaml v0.53.6-0.20260927093214-06e46d81f006
1268
+ github.com/aperturerobotics/controllerbus/yaml v0.53.6-0.20261001195447-86f830af47c0
1269
1269
  ====================================================================================
1270
1270
 
1271
1271
  This project is covered by two different licenses: MIT and Apache.
@@ -1600,7 +1600,7 @@ Apache License
1600
1600
  incurred by, or claims asserted against, such Contributor by reason
1601
1601
  of your accepting any such warranty or additional liability.
1602
1602
 
1603
- github.com/aperturerobotics/starpc v0.52.2-0.20260927191206-60aebb7f3a14
1603
+ github.com/aperturerobotics/starpc v0.52.2-0.20261001142944-1379b4c47855
1604
1604
  ========================================================================
1605
1605
 
1606
1606
  Copyright (c) 2022-2025 Aperture Robotics, LLC.
package/dist/build.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "revision": "b447d09c6f5bfe227f90acc1c95584d588ee48bb",
2
+ "revision": "0702e4e372c62f207d6b4ee1cc1b5c7cc7c42afd",
3
3
  "dirty": false,
4
4
  "nodeTarget": ">=24.15.0 <25",
5
5
  "bundledNotices": 110
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./rolldown-runtime-Csi-cuKc.mjs";import{Buffer as t}from"node:buffer";function n(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}function r(e,t){if(!e)throw Error(t)}function i(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 a(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 o(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 s(){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 c(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 l=4294967296;function ee(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>=l&&(i+=r/l|0,r%=l)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?d(r,i):re(r,i)}function te(e,t){let n=re(e,t),r=n.hi&2147483648;r&&(n=d(n.lo,n.hi));let i=u(n.lo,n.hi);return r?`-`+i:i}function u(e,t){if({lo:e,hi:t}=ne(e,t),t<=2097151)return String(l*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()+ie(o)+ie(a)}function ne(e,t){return{lo:e>>>0,hi:t>>>0}}function re(e,t){return{lo:e|0,hi:t|0}}function d(e,t){return t=~t,e?e=~e+1:t+=1,re(e,t)}const ie=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function ae(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 oe(){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 se(){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=>r(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>r(/^[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),ee(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),n(e),ee(e)},dec(e,t){return te(e,t)},uDec(e,t){return u(e,t)}}}const f=se();var p;(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`})(p||={});var m;(function(e){e[e.BIGINT=0]=`BIGINT`,e[e.STRING=1]=`STRING`})(m||={});function h(e,t,n){if(t===n)return!0;if(t==null||n==null)return t===n;if(e==p.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==p.DATE){let e=de(t,!1),r=de(n,!1);return e==null||r==null?e===r:e!=null&&r!=null&&+e==+r}switch(e){case p.UINT64:case p.FIXED64:case p.INT64:case p.SFIXED64:case p.SINT64:return t==n}return!1}function g(e,t){switch(e){case p.BOOL:return!1;case p.UINT64:case p.FIXED64:case p.INT64:case p.SFIXED64:case p.SINT64:return t==0?f.zero:`0`;case p.DOUBLE:case p.FLOAT:return 0;case p.BYTES:return new Uint8Array;case p.STRING:return``;case p.DATE:return null;default:return 0}}const ce=+new Date(0);function le(e,t){if(t==null)return!0;switch(e){case p.DATE:return+t===ce;case p.BOOL:return t===!1;case p.STRING:return t===``;case p.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return t==0}}function _(e,t,n,r=m.BIGINT){return t==null?g(e,r):e===p.BYTES?ue(t,n):le(e,t)?g(e,r):e===p.DATE?de(t,n):t}function ue(e,t){return!t&&e instanceof Uint8Array?e:new Uint8Array(e)}function de(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 fe(e,t){let n=me(e);return t?n:ye(ve(n))}function pe(e){return fe(e,!1)}function me(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 he=new Set([`constructor`,`toString`,`toJSON`,`valueOf`,`__proto__`,`prototype`]),ge=new Set([`__proto__`]),_e=e=>`${e}$`,ve=e=>ge.has(e)?_e(e):e,ye=e=>he.has(e)?_e(e):e;function be(e){return typeof e==`string`&&!!e.length&&!he.has(e)}function v(e){if(typeof e!=`string`)throw Error(`illegal non-string object key: `+typeof e);if(!be(e))throw Error(`illegal object key: `+e)}var xe=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 Se(e,t){return new xe(e,e=>Ee(e,t))}function Ce(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:!le(e.T,t[n]);case`message`:return t[n]!=null;case`map`:return t[n]!=null&&!!Object.keys(t[n]).length}}const we=me;function y(e){return e instanceof Function?e():e}var Te=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=pe(e)}addField(e){r(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 Ee(e,t){let n=[],r;for(let i of typeof e==`function`?e():e){let e=i;if(e.localName=fe(i.name,i.oneof!==void 0),e.jsonName=i.jsonName??we(i.name),e.repeated=i.repeated??!1,i.kind==`scalar`&&(e.L=i.L??m.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!=p.BYTES&&i.T!=p.STRING:!1),i.oneof!==void 0){let t=typeof i.oneof==`string`?i.oneof:i.oneof.name;(!r||r.name!=t)&&(r=new Te(t)),e.oneof=r,r.addField(e)}n.push(e)}return n}function De(e){return Array.isArray(e)}function Oe(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 b(e,t,n=``){let r=Object.create(null),i=Object.create(null),a=Oe(t)?ke(t,n):t,o=[];for(let e of a){let t=De(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 Ae(e){if(e.values.length<1)throw Error(`invalid enum: missing at least one value`);return e.values[0].no}function je(e,t){let n=Ae(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 x(){return{}}function S(){return Object.create(null)}function Me(e){return e}function C(e,t,n,r=!1){if(e==null||t==null)return;let i=Me(t),a=Me(e);for(let e of n.byMember()){let t=e.localName;if(v(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=x()),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=x()),o!=null){let t=y(s.T);C(o,e,t.fields)}}else s.kind===`scalar`?c.value=_(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=>_(e.T,t,r)));break}i[t]=_(e.T,n,r);break;case`enum`:i[t]=je(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]=S()),Ne(n,a,e.V,r);break}case`message`:{let r=y(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]=x()),C(n,a,r.fields)}break}}}}function Ne(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))v(i),a===void 0?delete t[i]:t[i]=_(n.T,a,r);break;case`enum`:for(let[r,i]of Object.entries(e))v(r),i===void 0?delete t[r]:t[r]=je(n.T,i);break;case`message`:{let r=y(n.T);for(let[n,i]of Object.entries(e)){if(v(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]=wt(r.fields):typeof e!=`object`&&(e=t[n]=x()),C(i,e,r.fields)}break}}}}const Pe=Symbol(`@aptre/protobuf-es-lite/unknown-fields`);function Fe(e,t,n,r){if(typeof e!=`object`)return;let i=e;Array.isArray(i[Pe])||(i[Pe]=[]),i[Pe].push({no:t,wireType:n,data:r})}function Ie(e,t){return e?e.wrapField(t):t}function w(e,t){return e?e.unwrapField(t):t}p.DATE,p.DOUBLE,p.FLOAT,p.INT64,p.UINT64,p.INT32,p.UINT32,p.BOOL,p.STRING,p.BYTES;var T;(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`})(T||={});var Le=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(a(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return i(e),ae(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){o(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){a(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){i(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return i(e),e=(e<<1^e>>31)>>>0,ae(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=f.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=f.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=f.enc(e);return c(t.lo,t.hi,this.buf),this}sint64(e){let t=f.enc(e),n=t.hi>>31;return c(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=f.uEnc(e);return c(t.lo,t.hi,this.buf),this}},Re=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 T.Varint:for(;this.buf[this.pos++]&128;);break;case T.Bit64:this.pos+=4;case T.Bit32:this.pos+=4;break;case T.LengthDelimited:let t=this.uint32();this.pos+=t;break;case T.StartGroup:let n;for(;(n=this.tag()[1])!==T.EndGroup;)this.skip(n);break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}varint64=s;assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}uint32=oe;int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return f.dec(...this.varint64())}uint64(){return f.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,f.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 f.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return f.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 ze={readUnknownFields:!0,readerFactory:e=>new Re(e)},Be={writeUnknownFields:!0,writerFactory:()=>new Le};function Ve(e){return e?{...ze,...e}:ze}function He(e){return e?{...Be,...e}:Be}function Ue(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]=x(),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`?p.INT32:n.T,s=Ge,c=n.kind==`scalar`&&n.utf8;if(n.kind==`scalar`&&n.L>0&&(s=Ke),a){let n=e[o];if(Array.isArray(n)||(n=e[o]=[]),r==T.LengthDelimited&&i!=p.STRING&&i!=p.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(w(s.fieldWrapper,qe(t,x(),s.fields,i,n)))}else e[o]=w(s.fieldWrapper,qe(t,x(),s.fields,i,n));break}case`map`:{let[r,a]=We(n,t,i);typeof e[o]!=`object`&&(e[o]=S()),e[o][r]=a;break}}}function We(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=Ge(t,e.K,e.keyUtf8);break;case 2:switch(e.V.kind){case`scalar`:o=Ge(t,e.V.T,e.V.utf8===!0);break;case`enum`:o=t.int32();break;case`message`:o=qe(t,x(),y(e.V.T).fields,n,void 0)}}}if(a===void 0&&(a=g(e.K,m.BIGINT)),typeof a!=`string`&&typeof a!=`number`&&(a=a?.toString()??``),o===void 0)switch(e.V.kind){case`scalar`:o=g(e.V.T,m.BIGINT);break;case`enum`:o=e.V.T.values[0].no;break;case`message`:o=x()}return[a,o]}function Ge(e,t,n=!1){switch(t){case p.STRING:return e.string(n);case p.BOOL:return e.bool();case p.DOUBLE:return e.double();case p.FLOAT:return e.float();case p.INT32:return e.int32();case p.INT64:return e.int64();case p.UINT64:return e.uint64();case p.FIXED64:return e.fixed64();case p.BYTES:return e.bytes();case p.FIXED32:return e.fixed32();case p.SFIXED32:return e.sfixed32();case p.SFIXED64:return e.sfixed64();case p.SINT64:return e.sint64();case p.UINT32:return e.uint32();case p.SINT32:return e.sint32();case p.DATE:throw Error(`cannot read a date with readScalar`);default:throw Error(`unknown scalar type`)}}function Ke(e,t,n=!1){let r=Ge(e,t,n);return typeof r==`bigint`?r.toString():r}function qe(e,t,n,r,i){return Je(t,n,e,i?.delimited?i.no:e.uint32(),r,i?.delimited??!1),t}function Je(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!=T.EndGroup);){let r=t.find(s);if(!r){let t=n.skip(c);i.readUnknownFields&&Fe(e,s,c,t);continue}Ue(e,n,r,c,i)}if(a&&(c!=T.EndGroup||s!==r))throw Error(`invalid end group tag`)}function Ye(e,t,n,r){for(let i of t.byNumber()){let t=e;if(!Ce(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&&Xe(i,a,n,r)}r.writeUnknownFields&&Ze(e,n)}function Xe(e,t,n,i){r(t!==void 0);let a=e.repeated;switch(e.kind){case`scalar`:case`enum`:{let i=e.kind==`enum`?p.INT32:e.T;if(a){if(r(Array.isArray(t)),e.packed)$e(n,i,e.no,t);else for(let r of t)E(n,i,e.no,r)}else E(n,i,e.no,t);break}case`message`:if(a){r(Array.isArray(t));for(let r of t)Qe(n,i,e,r)}else Qe(n,i,e,t);break;case`map`:r(typeof t==`object`&&!!t);for(let[r,a]of Object.entries(t))tt(n,i,e,r,a)}}function Ze(e,t){let n=e[Pe];if(n)for(let e of n)t.tag(e.no,e.wireType).raw(e.data)}function Qe(e,t,n,r){let i=y(n.T),a=Ie(i.fieldWrapper,r);n.delimited?e.tag(n.no,T.StartGroup).raw(i.toBinary(a,t)).tag(n.no,T.EndGroup):e.tag(n.no,T.LengthDelimited).bytes(i.toBinary(a,t))}function E(e,t,n,i){r(i!==void 0);let[a,o]=et(t);e.tag(n,a)[o](i)}function $e(e,t,n,r){if(!r.length)return;e.tag(n,T.LengthDelimited).fork();let[,i]=et(t);for(let t=0;t<r.length;t++)e[i](r[t]);e.join()}function et(e){let t=T.Varint;switch(e){case p.BYTES:case p.STRING:t=T.LengthDelimited;break;case p.DOUBLE:case p.FIXED64:case p.SFIXED64:t=T.Bit64;break;case p.FIXED32:case p.SFIXED32:case p.FLOAT:t=T.Bit32}let n=p[e].toLowerCase();return[t,n]}function tt(e,t,n,i,a){e.tag(n.no,T.LengthDelimited),e.fork();let o=i;switch(n.K){case p.INT32:case p.FIXED32:case p.UINT32:case p.SFIXED32:case p.SINT32:o=Number.parseInt(i);break;case p.BOOL:r(i==`true`||i==`false`),o=i==`true`}switch(E(e,n.K,1,o),n.V.kind){case`scalar`:E(e,n.V.T,2,a);break;case`enum`:E(e,p.INT32,2,a);break;case`message`:{r(a!==void 0);let i=y(n.V.T);e.tag(2,T.LengthDelimited).bytes(i.toBinary(a,t));break}}e.join()}let D=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),nt=[];for(let e=0;e<D.length;e++)nt[D[e].charCodeAt(0)]=e;nt[45]=D.indexOf(`+`),nt[95]=D.indexOf(`/`);const rt={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=nt[e.charCodeAt(t)],a===void 0)switch(e[t]){case`=`:i=0;case`
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+=D[r>>2],i=(r&3)<<4,n=1;break;case 1:t+=D[i|r>>4],i=(r&15)<<2,n=2;break;case 2:t+=D[i|r>>6],t+=D[r&63],n=0}return n&&(t+=D[i],t+=`=`,n==1&&(t+=`=`)),t}},it={ignoreUnknownFields:!1},at={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function ot(e){return e?{...it,...e}:it}function st(e){return e?{...at,...e}:at}function O(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 ct(e,t,n,r,i){if(n==null||Array.isArray(n)||typeof n!=`object`)throw Error(`cannot decode message ${t} from JSON: ${O(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)}ut(i,s,n,r)}else if(!r.ignoreUnknownFields)throw Error(`cannot decode message ${t} from JSON: key "${o}" is unknown`)}return i}function lt(e,t,n){let r=Object.create(null),i;try{for(i of t.byNumber()){let t=e;if(!Ce(i,t)){if(i.req)throw`required field not set`;if(!n.emitDefaultValues||!_t(i))continue}let a=i.oneof?t[i.oneof.localName].value:t[i.localName],o=vt(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 ut(e,t,n,i){let a=n.localName;if(n.repeated){if(r(n.kind!=`map`),t===null)return;if(!Array.isArray(t))throw Error(`cannot decode field ${n.name} from JSON: ${O(t)}`);let o=e[a];Array.isArray(o)||(o=e[a]=[]);for(let e of t){if(e===null)throw Error(`cannot decode field ${n.name} from JSON: ${O(e)}`);switch(n.kind){case`message`:{let t=y(n.T);o.push(w(t.fieldWrapper,t.fromJson(e,i)));break}case`enum`:{let t=pt(n.T,e,i.ignoreUnknownFields,!0);t!==ft&&o.push(t);break}case`scalar`:try{o.push(mt(n.T,e,n.L,!0))}catch(t){let r=`cannot decode field ${n.name} from JSON: ${O(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: ${O(t)}`);let r=e[a];typeof r!=`object`&&(r=e[a]=S());for(let[e,a]of Object.entries(t)){if(a===null)throw Error(`cannot decode field ${n.name} from JSON: map value null`);let o;try{o=ht(n.K,e)}catch(e){let r=`cannot decode map key for field ${n.name} from JSON: ${O(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r,{cause:e})}switch(v(o),n.V.kind){case`message`:{let e=y(n.V.T);r[o]=e.fromJson(a,i);break}case`enum`:{let e=pt(n.V.T,a,i.ignoreUnknownFields,!0);e!==ft&&(r[o]=e);break}case`scalar`:try{r[o]=mt(n.V.T,a,m.BIGINT,!0)}catch(e){let r=`cannot decode map value for field ${n.name} from JSON: ${O(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:a},a=`value`),n.kind){case`message`:{let r=y(n.T);if(t===null&&r.typeName!=`google.protobuf.Value`)return;e[a]=w(r.fieldWrapper,r.fromJson(t,i));break}case`enum`:{let r=pt(n.T,t,i.ignoreUnknownFields,!1);switch(r){case dt:gt(n,e);break;case ft:break;default:e[a]=r}break}case`scalar`:try{let r=mt(n.T,t,n.L,!1);switch(r){case dt:gt(n,e);break;default:e[a]=r}}catch(e){let r=`cannot decode field ${n.name} from JSON: ${O(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r,{cause:e})}}}const dt=Symbol(),ft=Symbol();function pt(e,t,n,r){if(t===null)return e.typeName==`google.protobuf.NullValue`?0:r?e.values[0].no:dt;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 ft;break}}throw Error(`cannot decode enum ${e.typeName} from JSON: ${O(t)}`)}function mt(e,t,n=m.BIGINT,r=!0){if(t==null)return r?g(e,n):dt;switch(e){case p.DOUBLE:case p.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==p.FLOAT&&o(n),n}case p.INT32:case p.FIXED32:case p.SFIXED32:case p.SINT32:case p.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==p.UINT32||e==p.FIXED32?a(n):i(n),n}case p.INT64:case p.SFIXED64:case p.SINT64:{if(typeof t!=`number`&&typeof t!=`string`)break;let e=f.parse(t);return n?e.toString():e}case p.FIXED64:case p.UINT64:{if(typeof t!=`number`&&typeof t!=`string`)break;let e=f.uParse(t);return n?e.toString():e}case p.BOOL:if(typeof t!=`boolean`)break;return t;case p.STRING:if(typeof t!=`string`)break;return t;case p.BYTES:if(t===``)return new Uint8Array;if(typeof t!=`string`)break;return rt.dec(t)}throw Error()}function ht(e,t){if(e===p.BOOL)switch(t){case`true`:t=!0;break;case`false`:t=!1}return mt(e,t,m.BIGINT,!0)?.toString()??``}function gt(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]=S();break;case`enum`:t[n]=r?e.T.values[0].no:void 0;break;case`scalar`:t[n]=r?g(e.T,e.L):void 0;break;case`message`:t[n]=void 0}}function _t(e){return e.repeated||e.kind==`map`?!0:!(e.oneof||e.kind==`message`||e.opt||e.req)}function vt(e,t,n){if(e.kind==`map`){let i=Object.create(null);r(!t||typeof t==`object`);let a=t?Object.entries(t):[];switch(e.V.kind){case`scalar`:for(let[t,n]of a)i[t.toString()]=yt(e.V.T,n);break;case`message`:for(let[t,r]of a){let a=y(e.V.T);i[t.toString()]=a.toJson(r,n)}break;case`enum`:{let t=e.V.T;for(let[e,r]of a)i[e.toString()]=bt(t,r,n.enumAsInteger);break}}return n.emitDefaultValues||a.length>0?i:void 0}if(e.repeated){r(!t||Array.isArray(t));let i=[],a=t;if(a&&a.length)switch(e.kind){case`scalar`:for(let t=0;t<a.length;t++)i.push(yt(e.T,a[t]));break;case`enum`:for(let t=0;t<a.length;t++)i.push(bt(e.T,a[t],n.enumAsInteger));break;case`message`:{let t=y(e.T);for(let e=0;e<a.length;e++)i.push(t.toJson(Ie(t.fieldWrapper,a[e])));break}}return n.emitDefaultValues||i.length>0?i:void 0}switch(e.kind){case`scalar`:{let r=_(e.T,t,!1);return!n.emitDefaultValues&&le(e.T,r)?void 0:yt(e.T,t)}case`enum`:{let r=je(e.T,t);return!n.emitDefaultValues&&Ae(e.T)===r?void 0:bt(e.T,t,n.enumAsInteger)}case`message`:{if(!n.emitDefaultValues&&t==null)return;let r=y(e.T);return r.toJson(Ie(r.fieldWrapper,t))}}}function yt(e,t){switch(e){case p.INT32:case p.SFIXED32:case p.SINT32:case p.FIXED32:case p.UINT32:return r(typeof t==`number`),t;case p.FLOAT:case p.DOUBLE:return r(typeof t==`number`),Number.isNaN(t)?`NaN`:t===1/0?`Infinity`:t===-1/0?`-Infinity`:t;case p.STRING:return r(typeof t==`string`),t;case p.BOOL:return r(typeof t==`boolean`),t;case p.UINT64:case p.FIXED64:case p.INT64:case p.SFIXED64:case p.SINT64:return r(typeof t==`bigint`||typeof t==`string`||typeof t==`number`),t.toString();case p.BYTES:return r(t instanceof Uint8Array),rt.enc(t);case p.DATE:throw Error(`cannot write date with writeScalar`);default:throw Error(`unknown scalar type`)}}function bt(e,t,n){return r(typeof t==`number`),e.typeName==`google.protobuf.NullValue`?null:n?t:e.findNumber(t)?.name??t}const xt=[];function k(e,t){let{fields:n,typeName:r,delimitedMessageEncoding:i,fieldWrapper:a}=e,o=Se(n,e.packedByDefault??!0),s={typeName:r,fields:o,fieldWrapper:a,create(e){let t=x();return C(e,t,o),t},createComplete(e){let t=wt(o);return C(e,t,o),t},equals(e,t){return St(o,e,t)},clone(e){return e==null?e:Ct(e,o)},fromBinary(e,t){let n={};if(e&&e.length){let r=Ve(t);Je(n,o,r.readerFactory(e),e.byteLength,r,i??!1)}return n},fromJson(e,t){let n={};if(e!=null){let i=ot(t);ct(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=He(t),r=n.writerFactory();return Ye(e,o,r,n),r.finish()},toJson(e,t){let n=st(t);return lt(e,o,n)},toJsonString(e,t){let n=s.toJson(e,t);return JSON.stringify(n,null,t?.prettySpaces??0)},...t??{}};return s}function A(e,t){return k({typeName:e,fields:xt,packedByDefault:t})}function St(e,t,n){return t==null&&n==null||t===n?!0:!t||!n?!1:e.byMember().every(e=>{let r=Me(t)[e.localName],i=Me(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=y(e.T),i=t,a=n;return i.every((e,t)=>r.equals(e,a[t]))}case`scalar`:return t.every((t,r)=>h(e.T,t,n?.[r]));case`enum`:return t.every((e,t)=>h(p.INT32,e,n?.[t]))}throw Error(`repeated cannot contain ${e.kind}`)}switch(e.kind){case`message`:return y(e.T).equals(r,i);case`enum`:return h(p.INT32,r,i);case`scalar`:return h(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 y(o.T).equals(t.value,n?.value);case`enum`:return h(p.INT32,t.value,n?.value);case`scalar`:return h(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=y(e.V.T);return a.every(e=>r.equals(t[e],n[e]))}case`enum`:return a.every(e=>h(p.INT32,t[e],n[e]));case`scalar`:{let r=e.V.T;return a.every(e=>h(r,t[e],n[e]))}}}}})}function Ct(e,t){if(e==null)return null;let n=x();return C(e,n,t,!0),n}function wt(e){let t={};for(let n of e.byMember()){let{localName:e,kind:r}=n;switch(v(e),r){case`oneof`:t[e]=x(),t[e].case=void 0;break;case`scalar`:t[e]=n.repeated?[]:g(n.T,m.BIGINT);break;case`enum`:t[e]=n.repeated?[]:Ae(n.T);break;case`message`:{if(n.oneof)break;if(n.repeated){t[e]=[];break}let r=y(n.T);t[e]=r.fieldWrapper?r.fieldWrapper.unwrapField(null):wt(r.fields);break}case`map`:t[e]=S()}}return t}const Tt=b(`hash.HashType`,function(e){return e[e.HashType_UNKNOWN=0]=`HashType_UNKNOWN`,e[e.HashType_SHA256=1]=`HashType_SHA256`,e[e.HashType_SHA1=2]=`HashType_SHA1`,e[e.HashType_BLAKE3=3]=`HashType_BLAKE3`,e}({})),Et=k({typeName:`hash.Hash`,fields:[{no:1,name:`hash_type`,kind:`enum`,T:Tt},{no:2,name:`hash`,kind:`scalar`,T:p.BYTES}]}),Dt=b(`block.StoreFeature`,function(e){return e[e.UNKNOWN=0]=`UNKNOWN`,e[e.NATIVE_BATCH_PUT=1]=`NATIVE_BATCH_PUT`,e[e.NATIVE_BATCH_EXISTS=2]=`NATIVE_BATCH_EXISTS`,e[e.SELF_BUFFERED=32]=`SELF_BUFFERED`,e}({}),`STORE_FEATURE_`),Ot=b(`block.OverlayMode`,function(e){return e[e.UPPER_ONLY=0]=`UPPER_ONLY`,e[e.LOWER_ONLY=1]=`LOWER_ONLY`,e[e.UPPER_CACHE=2]=`UPPER_CACHE`,e[e.LOWER_CACHE=3]=`LOWER_CACHE`,e[e.UPPER_READ_CACHE=4]=`UPPER_READ_CACHE`,e[e.LOWER_READ_CACHE=5]=`LOWER_READ_CACHE`,e[e.UPPER_WRITE_CACHE=6]=`UPPER_WRITE_CACHE`,e[e.LOWER_WRITE_CACHE=7]=`LOWER_WRITE_CACHE`,e[e.UPPER_READBACK_CACHE=8]=`UPPER_READBACK_CACHE`,e}({})),j=k({typeName:`block.BlockRef`,fields:[{no:1,name:`hash`,kind:`message`,T:()=>Et}]}),kt=k({typeName:`block.BlockObject`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`refs`,kind:`message`,T:j,repeated:!0}]}),M=k({typeName:`block.PutOpts`,fields:[{no:1,name:`hash_type`,kind:`enum`,T:Tt},{no:2,name:`force_block_ref`,kind:`message`,T:j},{no:3,name:`refs`,kind:`message`,T:j,repeated:!0},{no:4,name:`sync`,kind:`scalar`,T:p.BOOL},{no:5,name:`cache_fill`,kind:`scalar`,T:p.BOOL}]}),At=k({typeName:`block.transform.StepConfig`,fields:[{no:1,name:`id`,kind:`scalar`,T:p.STRING},{no:2,name:`config`,kind:`scalar`,T:p.BYTES}]}),jt=k({typeName:`block.transform.Config`,fields:[{no:1,name:`steps`,kind:`message`,T:At,repeated:!0}]});var N;(function(e){e[e.Unary=0]=`Unary`,e[e.ServerStreaming=1]=`ServerStreaming`,e[e.ClientStreaming=2]=`ClientStreaming`,e[e.BiDiStreaming=3]=`BiDiStreaming`})(N||={});var Mt;(function(e){e[e.NoSideEffects=1]=`NoSideEffects`,e[e.Idempotent=2]=`Idempotent`})(Mt||={});const Nt=k({typeName:`configset.proto.ControllerConfig`,fields:[{no:1,name:`id`,kind:`scalar`,T:p.STRING},{no:2,name:`rev`,kind:`scalar`,T:p.UINT64},{no:3,name:`config`,kind:`scalar`,T:p.BYTES}],packedByDefault:!0});k({typeName:`configset.proto.ConfigSet`,fields:[{no:1,name:`configs`,kind:`map`,K:p.STRING,V:{kind:`message`,T:()=>Nt}}],packedByDefault:!0});const P={fromJson(e){if(typeof e!=`string`)throw Error(`cannot decode google.protobuf.Timestamp(json)}`);let t=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!t)throw Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);let n=Date.parse(t[1]+`-`+t[2]+`-`+t[3]+`T`+t[4]+`:`+t[5]+`:`+t[6]+(t[8]?t[8]:`Z`));if(Number.isNaN(n))throw Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);if(n<Date.parse(`0001-01-01T00:00:00Z`)||n>Date.parse(`9999-12-31T23:59:59Z`))throw Error(`cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);return{seconds:f.parse(n/1e3),nanos:t[7]?parseInt(`1`+t[7]+`0`.repeat(9-t[7].length))-1e9:0}},toJson(e){let t=Number(e.seconds)*1e3;if(t<Date.parse(`0001-01-01T00:00:00Z`)||t>Date.parse(`9999-12-31T23:59:59Z`))throw Error(`cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);if(e.nanos!=null&&e.nanos<0)throw Error(`cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative`);let n=`Z`;if(e.nanos!=null&&e.nanos>0){let t=(e.nanos+1e9).toString().substring(1);n=t.substring(3)===`000000`?`.`+t.substring(0,3)+`Z`:t.substring(6)===`000`?`.`+t.substring(0,6)+`Z`:`.`+t+`Z`}return new Date(t).toISOString().replace(`.000Z`,n)},toDate(e){return!e?.seconds&&!e?.nanos?null:new Date(Number(e.seconds??0)*1e3+Math.ceil((e.nanos??0)/1e6))},fromDate(e){if(e==null)return{};let t=e.getTime(),n=Math.floor(t/1e3),r=t%1e3*1e6;return{seconds:f.parse(n),nanos:r}},equals(e,t){let n=e instanceof Date?e:P.toDate(e),r=t instanceof Date?t:P.toDate(t);return n===r?!0:n==null||r==null?n===r:+n==+r}},Pt=k({typeName:`google.protobuf.Timestamp`,fields:[{no:1,name:`seconds`,kind:`scalar`,T:p.INT64},{no:2,name:`nanos`,kind:`scalar`,T:p.INT32}],fieldWrapper:{wrapField(e){return e==null||e instanceof Date?P.fromDate(e):Pt.createComplete(e)},unwrapField(e){return P.toDate(e)}}},P),Ft=k({typeName:`bucket.LookupConfig`,fields:[{no:1,name:`disable`,kind:`scalar`,T:p.BOOL},{no:2,name:`controller`,kind:`message`,T:()=>Nt}]}),It=k({typeName:`bucket.Config`,fields:[{no:1,name:`id`,kind:`scalar`,T:p.STRING},{no:2,name:`rev`,kind:`scalar`,T:p.UINT32},{no:4,name:`put_opts`,kind:`message`,T:()=>M},{no:5,name:`lookup`,kind:`message`,T:Ft}]}),Lt=k({typeName:`bucket.BucketInfo`,fields:[{no:1,name:`config`,kind:`message`,T:It}]}),Rt=k({typeName:`bucket.ApplyBucketConfigResult`,fields:[{no:1,name:`volume_id`,kind:`scalar`,T:p.STRING},{no:2,name:`bucket_id`,kind:`scalar`,T:p.STRING},{no:3,name:`bucket_conf`,kind:`message`,T:It},{no:4,name:`old_bucket_conf`,kind:`message`,T:It},{no:5,name:`timestamp`,kind:`message`,T:()=>Pt},{no:6,name:`updated`,kind:`scalar`,T:p.BOOL},{no:7,name:`error`,kind:`scalar`,T:p.STRING}]}),F=k({typeName:`bucket.ObjectRef`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>j},{no:2,name:`bucket_id`,kind:`scalar`,T:p.STRING},{no:3,name:`transform_conf_ref`,kind:`message`,T:()=>j},{no:4,name:`transform_conf`,kind:`message`,T:()=>jt}]}),zt=k({typeName:`bucket.BucketOpArgs`,fields:[{no:1,name:`bucket_id`,kind:`scalar`,T:p.STRING},{no:2,name:`volume_id`,kind:`scalar`,T:p.STRING}]});let Bt=function(e){return e[e.UNKNOWN=0]=`UNKNOWN`,e[e.RESOURCE_NOT_FOUND=1]=`RESOURCE_NOT_FOUND`,e[e.CLIENT_RELEASED=2]=`CLIENT_RELEASED`,e[e.INVALID_RESOURCE_ID=3]=`INVALID_RESOURCE_ID`,e[e.INVALID_CLIENT_ID=4]=`INVALID_CLIENT_ID`,e[e.RESOURCE_OR_CLIENT_RELEASED=5]=`RESOURCE_OR_CLIENT_RELEASED`,e}({});const Vt=k({typeName:`resource.ResourceFailure`,fields:[{no:1,name:`code`,kind:`enum`,T:b(`resource.ResourceFailureCode`,Bt,`RESOURCE_FAILURE_CODE_`)},{no:2,name:`message`,kind:`scalar`,T:p.STRING}]}),Ht=k({typeName:`resource.ResourceRpcInit`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Ut=k({typeName:`resource.ResourceRpcAck`,fields:[{no:1,name:`failure`,kind:`message`,T:Vt}]}),Wt=k({typeName:`resource.ResourceRpcPacket`,fields:[{no:1,name:`init`,kind:`message`,T:Ht,oneof:`body`},{no:2,name:`ack`,kind:`message`,T:Ut,oneof:`body`},{no:3,name:`data`,kind:`scalar`,T:p.BYTES,oneof:`body`}]}),Gt=A(`resource.ResourceClientInitRequest`,!0),Kt=k({typeName:`resource.ResourceClientAdopt`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),qt=k({typeName:`resource.ResourceClientRelease`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Jt=k({typeName:`resource.ResourceClientRequest`,fields:[{no:5,name:`control_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`init`,kind:`message`,T:Gt,oneof:`body`},{no:3,name:`adopt`,kind:`message`,T:Kt,oneof:`body`},{no:4,name:`release`,kind:`message`,T:qt,oneof:`body`}]}),Yt=k({typeName:`resource.ResourceClientInit`,fields:[{no:1,name:`client_handle_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`root_resource_id`,kind:`scalar`,T:p.UINT32}]}),Xt=k({typeName:`resource.ResourceReleasedResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Zt=k({typeName:`resource.ResourceClientControlAck`,fields:[{no:1,name:`control_id`,kind:`scalar`,T:p.UINT32}]}),Qt=k({typeName:`resource.ResourceClientResponse`,fields:[{no:1,name:`init`,kind:`message`,T:Yt,oneof:`body`},{no:2,name:`resource_released`,kind:`message`,T:Xt,oneof:`body`},{no:4,name:`control_ack`,kind:`message`,T:Zt,oneof:`body`}]}),$t=k({typeName:`resource.ResourceAttachInit`,fields:[{no:1,name:`client_handle_id`,kind:`scalar`,T:p.UINT32}]}),en=k({typeName:`resource.ResourceAttachAdd`,fields:[{no:1,name:`attach_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`label`,kind:`scalar`,T:p.STRING}]}),tn=k({typeName:`resource.ResourceAttachDetach`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),nn=k({typeName:`resource.ResourceAttachRequest`,fields:[{no:1,name:`init`,kind:`message`,T:$t,oneof:`body`},{no:2,name:`add`,kind:`message`,T:en,oneof:`body`},{no:3,name:`detach`,kind:`message`,T:tn,oneof:`body`},{no:4,name:`mux_data`,kind:`scalar`,T:p.BYTES,oneof:`body`}]}),rn=k({typeName:`resource.ResourceAttachAck`,fields:[{no:1,name:`failure`,kind:`message`,T:Vt}]}),an=k({typeName:`resource.ResourceAttachAddAck`,fields:[{no:1,name:`attach_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`failure`,kind:`message`,T:Vt},{no:3,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),on=k({typeName:`resource.ResourceAttachDetachAck`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),sn=k({typeName:`resource.ResourceAttachResponse`,fields:[{no:1,name:`ack`,kind:`message`,T:rn,oneof:`body`},{no:2,name:`add_ack`,kind:`message`,T:an,oneof:`body`},{no:3,name:`detach_ack`,kind:`message`,T:on,oneof:`body`},{no:4,name:`mux_data`,kind:`scalar`,T:p.BYTES,oneof:`body`}]}),cn=A(`s4wave.block.cursor.FetchRequest`,!0),ln=k({typeName:`s4wave.block.cursor.FetchResponse`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`found`,kind:`scalar`,T:p.BOOL}]}),un=k({typeName:`s4wave.block.cursor.SetBlockRequest`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`mark_dirty`,kind:`scalar`,T:p.BOOL},{no:3,name:`block_type`,kind:`scalar`,T:p.STRING}]}),dn=A(`s4wave.block.cursor.SetBlockResponse`,!0),fn=k({typeName:`s4wave.block.cursor.FollowRefRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`blk_ref`,kind:`message`,T:()=>j}]}),pn=k({typeName:`s4wave.block.cursor.FollowRefResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),mn=A(`s4wave.block.cursor.GetRefRequest`,!0),hn=k({typeName:`s4wave.block.cursor.GetRefResponse`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>j}]}),gn=A(`s4wave.block.cursor.IsDirtyRequest`,!0),_n=k({typeName:`s4wave.block.cursor.IsDirtyResponse`,fields:[{no:1,name:`dirty`,kind:`scalar`,T:p.BOOL}]}),vn=A(`s4wave.block.cursor.MarkDirtyRequest`,!0),yn=A(`s4wave.block.cursor.MarkDirtyResponse`,!0),bn=A(`s4wave.block.cursor.GetBlockRequest`,!0),xn=k({typeName:`s4wave.block.cursor.GetBlockResponse`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`is_sub_block`,kind:`scalar`,T:p.BOOL}]}),Sn=k({typeName:`s4wave.block.cursor.UnmarshalRequest`,fields:[{no:1,name:`block_type`,kind:`scalar`,T:p.STRING}]}),Cn=k({typeName:`s4wave.block.cursor.UnmarshalResponse`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`found`,kind:`scalar`,T:p.BOOL}]}),wn=A(`s4wave.block.cursor.IsSubBlockRequest`,!0),Tn=k({typeName:`s4wave.block.cursor.IsSubBlockResponse`,fields:[{no:1,name:`is_sub_block`,kind:`scalar`,T:p.BOOL}]}),En=k({typeName:`s4wave.block.cursor.FollowSubBlockRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32}]}),Dn=k({typeName:`s4wave.block.cursor.FollowSubBlockResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),On=k({typeName:`s4wave.block.cursor.SetAsSubBlockRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`parent_resource_id`,kind:`scalar`,T:p.UINT32}]}),kn=A(`s4wave.block.cursor.SetAsSubBlockResponse`,!0),An=k({typeName:`s4wave.block.cursor.ClearRefRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32}]}),jn=A(`s4wave.block.cursor.ClearRefResponse`,!0),Mn=A(`s4wave.block.cursor.ClearAllRefsRequest`,!0),Nn=A(`s4wave.block.cursor.ClearAllRefsResponse`,!0),Pn=k({typeName:`s4wave.block.cursor.SetRefRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`target_resource_id`,kind:`scalar`,T:p.UINT32}]}),Fn=A(`s4wave.block.cursor.SetRefResponse`,!0),In=k({typeName:`s4wave.block.cursor.GetExistingRefRequest`,fields:[{no:1,name:`ref_id`,kind:`scalar`,T:p.UINT32}]}),Ln=k({typeName:`s4wave.block.cursor.GetExistingRefResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Rn=k({typeName:`s4wave.block.cursor.GetAllRefsRequest`,fields:[{no:1,name:`existing_only`,kind:`scalar`,T:p.BOOL}]}),zn=k({typeName:`s4wave.block.cursor.GetAllRefsResponse`,fields:[{no:1,name:`refs`,kind:`map`,K:p.UINT32,V:{kind:`scalar`,T:p.UINT32}}]}),Bn=k({typeName:`s4wave.block.cursor.DetachRequest`,fields:[{no:1,name:`keep_refs`,kind:`scalar`,T:p.BOOL}]}),Vn=k({typeName:`s4wave.block.cursor.DetachResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Hn=A(`s4wave.block.cursor.DetachTransactionRequest`,!0),Un=k({typeName:`s4wave.block.cursor.DetachTransactionResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Wn=k({typeName:`s4wave.block.cursor.DetachRecursiveRequest`,fields:[{no:1,name:`detach_tx`,kind:`scalar`,T:p.BOOL},{no:2,name:`clone_blocks`,kind:`scalar`,T:p.BOOL},{no:3,name:`mark_dirty`,kind:`scalar`,T:p.BOOL}]}),Gn=k({typeName:`s4wave.block.cursor.DetachRecursiveResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Kn=A(`s4wave.block.cursor.ParentsRequest`,!0),qn=k({typeName:`s4wave.block.cursor.ParentsResponse`,fields:[{no:1,name:`parent_resource_ids`,kind:`scalar`,T:p.UINT32,repeated:!0}]}),Jn=k({typeName:`s4wave.block.transaction.WriteRequest`,fields:[{no:1,name:`clear_tree`,kind:`scalar`,T:p.BOOL}]}),Yn=k({typeName:`s4wave.block.transaction.WriteResponse`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>j},{no:2,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Xn=A(`s4wave.block.transaction.GetRootCursorRequest`,!0),Zn=k({typeName:`s4wave.block.transaction.GetRootCursorResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Qn=k({typeName:`s4wave.bucket_lookup.MountBucketLookupRequest`,fields:[{no:1,name:`bucket_id`,kind:`scalar`,T:p.STRING},{no:2,name:`volume_id`,kind:`scalar`,T:p.STRING},{no:3,name:`transform_conf`,kind:`message`,T:()=>jt}]}),$n=k({typeName:`s4wave.bucket_lookup.MountBucketLookupResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`bucket_id`,kind:`scalar`,T:p.STRING},{no:3,name:`volume_id`,kind:`scalar`,T:p.STRING}]}),er=A(`s4wave.bucket_lookup.GetRefRequest`,!0),tr=k({typeName:`s4wave.bucket_lookup.GetRefResponse`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>F},{no:2,name:`bucket_id_override`,kind:`scalar`,T:p.STRING}]}),nr=k({typeName:`s4wave.bucket_lookup.FollowRefRequest`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>F}]}),rr=k({typeName:`s4wave.bucket_lookup.FollowRefResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),ir=k({typeName:`s4wave.bucket_lookup.GetBlockRequest`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>j}]}),ar=k({typeName:`s4wave.bucket_lookup.GetBlockResponse`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`found`,kind:`scalar`,T:p.BOOL}]}),or=k({typeName:`s4wave.bucket_lookup.PutBlockRequest`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`opts`,kind:`message`,T:()=>M}]}),sr=k({typeName:`s4wave.bucket_lookup.PutBlockResponse`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>j},{no:2,name:`existed`,kind:`scalar`,T:p.BOOL}]}),cr=k({typeName:`s4wave.bucket_lookup.PutBlockBatchEntry`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>j},{no:2,name:`data`,kind:`scalar`,T:p.BYTES},{no:3,name:`refs`,kind:`message`,T:()=>j,repeated:!0},{no:4,name:`tombstone`,kind:`scalar`,T:p.BOOL}]}),lr=k({typeName:`s4wave.bucket_lookup.PutBlockBatchRequest`,fields:[{no:1,name:`entries`,kind:`message`,T:cr,repeated:!0}]}),ur=A(`s4wave.bucket_lookup.PutBlockBatchResponse`,!0),dr=k({typeName:`s4wave.bucket_lookup.GetBlockExistsBatchRequest`,fields:[{no:1,name:`refs`,kind:`message`,T:()=>j,repeated:!0}]}),fr=k({typeName:`s4wave.bucket_lookup.GetBlockExistsBatchResponse`,fields:[{no:1,name:`found`,kind:`scalar`,T:p.BOOL,repeated:!0}]}),pr=k({typeName:`s4wave.bucket_lookup.BuildTransactionRequest`,fields:[{no:1,name:`put_opts`,kind:`message`,T:()=>M}]}),mr=k({typeName:`s4wave.bucket_lookup.BuildTransactionResponse`,fields:[{no:1,name:`transaction_resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`cursor_resource_id`,kind:`scalar`,T:p.UINT32}]}),hr=k({typeName:`s4wave.bucket_lookup.BuildTransactionAtRefRequest`,fields:[{no:1,name:`put_opts`,kind:`message`,T:()=>M},{no:2,name:`ref`,kind:`message`,T:()=>j}]}),gr=k({typeName:`s4wave.bucket_lookup.BuildTransactionAtRefResponse`,fields:[{no:1,name:`transaction_resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`cursor_resource_id`,kind:`scalar`,T:p.UINT32}]}),_r=A(`s4wave.bucket_lookup.CloneRequest`,!0),vr=k({typeName:`s4wave.bucket_lookup.CloneResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),yr=A(`s4wave.bucket_lookup.ReleaseRequest`,!0),br=A(`s4wave.bucket_lookup.ReleaseResponse`,!0),xr=k({typeName:`s4wave.bucket_lookup.UnmarshalRequest`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>F},{no:2,name:`data`,kind:`scalar`,T:p.BYTES},{no:3,name:`block_type`,kind:`scalar`,T:p.STRING}]}),Sr=k({typeName:`s4wave.bucket_lookup.UnmarshalResponse`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`found`,kind:`scalar`,T:p.BOOL}]}),I=k({typeName:`quad.Quad`,fields:[{no:1,name:`subject`,kind:`scalar`,T:p.STRING},{no:2,name:`predicate`,kind:`scalar`,T:p.STRING},{no:3,name:`obj`,kind:`scalar`,T:p.STRING},{no:4,name:`label`,kind:`scalar`,T:p.STRING}]}),Cr=b(`s4wave.world.GraphEdgeBucketDirection`,function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.OUT=1]=`OUT`,e[e.IN=2]=`IN`,e[e.BOTH=3]=`BOTH`,e}({}),`GRAPH_EDGE_BUCKET_DIRECTION_`),wr=b(`s4wave.world.GraphPathDirection`,function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.OUT=1]=`OUT`,e[e.IN=2]=`IN`,e[e.BOTH=3]=`BOTH`,e}({}),`GRAPH_PATH_DIRECTION_`);let Tr=function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.UNHANDLED_OP=1]=`UNHANDLED_OP`,e}({});const Er=b(`s4wave.world.WorldErrorCode`,Tr,`WORLD_ERROR_CODE_`),Dr=A(`s4wave.world.SyncRequest`,!0),Or=k({typeName:`s4wave.world.SyncResponse`,fields:[{no:1,name:`fenced`,kind:`scalar`,T:p.BOOL}]}),kr=k({typeName:`s4wave.world.EngineInfo`,fields:[{no:1,name:`engine_id`,kind:`scalar`,T:p.STRING},{no:2,name:`bucket_id`,kind:`scalar`,T:p.STRING}]}),Ar=A(`s4wave.world.GetEngineInfoRequest`,!0),jr=k({typeName:`s4wave.world.GetEngineInfoResponse`,fields:[{no:1,name:`engine_info`,kind:`message`,T:kr},{no:2,name:`session_peer_id`,kind:`scalar`,T:p.STRING}]}),Mr=k({typeName:`s4wave.world.WorldRootSnapshot`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>F},{no:2,name:`seqno`,kind:`scalar`,T:p.UINT64},{no:3,name:`engine_info`,kind:`message`,T:kr},{no:4,name:`storage_volume_id`,kind:`scalar`,T:p.STRING}]}),Nr=A(`s4wave.world.GetWorldRootSnapshotRequest`,!0),Pr=A(`s4wave.world.WatchWorldRootSnapshotsRequest`,!0),Fr=k({typeName:`s4wave.world.SetRetainedRootRequest`,fields:[{no:1,name:`name`,kind:`scalar`,T:p.STRING},{no:2,name:`root_ref`,kind:`message`,T:()=>j}]}),Ir=A(`s4wave.world.SetRetainedRootResponse`,!0),Lr=k({typeName:`s4wave.world.NewTransactionRequest`,fields:[{no:1,name:`write`,kind:`scalar`,T:p.BOOL}]}),Rr=k({typeName:`s4wave.world.NewTransactionResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`read_only`,kind:`scalar`,T:p.BOOL}]}),zr=A(`s4wave.world.GetSeqnoRequest`,!0),Br=k({typeName:`s4wave.world.GetSeqnoResponse`,fields:[{no:1,name:`seqno`,kind:`scalar`,T:p.UINT64}]}),Vr=k({typeName:`s4wave.world.WaitSeqnoRequest`,fields:[{no:1,name:`seqno`,kind:`scalar`,T:p.UINT64}]}),Hr=k({typeName:`s4wave.world.WaitSeqnoResponse`,fields:[{no:1,name:`seqno`,kind:`scalar`,T:p.UINT64}]}),Ur=k({typeName:`s4wave.world.AccessWorldStateRequest`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>F}]}),Wr=k({typeName:`s4wave.world.OpenNestedWorldRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Gr=k({typeName:`s4wave.world.OpenNestedWorldResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Kr=A(`s4wave.world.OpenOuterWorldRequest`,!0),qr=k({typeName:`s4wave.world.OpenOuterWorldResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Jr=k({typeName:`s4wave.world.AccessWorldStateResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Yr=k({typeName:`s4wave.world.CreateObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`root_ref`,kind:`message`,T:()=>F}]}),Xr=k({typeName:`s4wave.world.SetObjectRootMutation`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`root_ref`,kind:`message`,T:()=>F}]}),Zr=k({typeName:`s4wave.world.SetGraphQuadRequest`,fields:[{no:1,name:`quad`,kind:`message`,T:()=>I}]}),Qr=k({typeName:`s4wave.world.TransactionMutation`,fields:[{no:1,name:`create_object`,kind:`message`,T:Yr,oneof:`mutation`},{no:2,name:`set_object_root`,kind:`message`,T:Xr,oneof:`mutation`},{no:3,name:`set_graph_quad`,kind:`message`,T:Zr,oneof:`mutation`}]}),$r=k({typeName:`s4wave.world.CommitMutationsRequest`,fields:[{no:1,name:`mutations`,kind:`message`,T:Qr,repeated:!0}]}),ei=k({typeName:`s4wave.world.CreateObjectMutationResult`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`rev`,kind:`scalar`,T:p.UINT64}]}),ti=k({typeName:`s4wave.world.SetObjectRootMutationResult`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),ni=A(`s4wave.world.SetGraphQuadResponse`,!0),ri=k({typeName:`s4wave.world.TransactionMutationResult`,fields:[{no:1,name:`create_object`,kind:`message`,T:ei,oneof:`result`},{no:2,name:`set_object_root`,kind:`message`,T:ti,oneof:`result`},{no:3,name:`set_graph_quad`,kind:`message`,T:ni,oneof:`result`}]}),ii=k({typeName:`s4wave.world.CommitMutationsResponse`,fields:[{no:1,name:`results`,kind:`message`,T:ri,repeated:!0}]}),ai=A(`s4wave.world.CommitRequest`,!0),oi=A(`s4wave.world.CommitResponse`,!0),si=A(`s4wave.world.DiscardRequest`,!0),ci=A(`s4wave.world.DiscardResponse`,!0),li=A(`s4wave.world.GetReadOnlyRequest`,!0),ui=k({typeName:`s4wave.world.GetReadOnlyResponse`,fields:[{no:1,name:`read_only`,kind:`scalar`,T:p.BOOL}]}),di=A(`s4wave.world.BuildStorageCursorRequest`,!0),fi=k({typeName:`s4wave.world.BuildStorageCursorResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),pi=k({typeName:`s4wave.world.CreateObjectResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`object_key`,kind:`scalar`,T:p.STRING}]}),mi=k({typeName:`s4wave.world.GetObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),hi=k({typeName:`s4wave.world.GetObjectResponse`,fields:[{no:1,name:`found`,kind:`scalar`,T:p.BOOL},{no:2,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:3,name:`object_key`,kind:`scalar`,T:p.STRING}]}),gi=k({typeName:`s4wave.world.RenameObjectRequest`,fields:[{no:1,name:`old_object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`new_object_key`,kind:`scalar`,T:p.STRING},{no:3,name:`descendants`,kind:`scalar`,T:p.BOOL}]}),_i=k({typeName:`s4wave.world.RenameObjectResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`object_key`,kind:`scalar`,T:p.STRING}]}),vi=k({typeName:`s4wave.world.DeleteObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),yi=k({typeName:`s4wave.world.DeleteObjectResponse`,fields:[{no:1,name:`deleted`,kind:`scalar`,T:p.BOOL}]}),bi=k({typeName:`s4wave.world.IterateObjectsRequest`,fields:[{no:1,name:`prefix`,kind:`scalar`,T:p.STRING},{no:2,name:`reversed`,kind:`scalar`,T:p.BOOL}]}),xi=k({typeName:`s4wave.world.IterateObjectsResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Si=k({typeName:`s4wave.world.ListObjectsRequest`,fields:[{no:1,name:`prefix`,kind:`scalar`,T:p.STRING},{no:2,name:`start_after`,kind:`scalar`,T:p.STRING},{no:3,name:`limit`,kind:`scalar`,T:p.UINT32},{no:4,name:`delimiter`,kind:`scalar`,T:p.STRING}]}),Ci=k({typeName:`s4wave.world.ObjectMetadata`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`type_id`,kind:`scalar`,T:p.STRING},{no:3,name:`parent_object_key`,kind:`scalar`,T:p.STRING}]}),wi=k({typeName:`s4wave.world.ListObjectsResponse`,fields:[{no:1,name:`objects`,kind:`message`,T:Ci,repeated:!0},{no:2,name:`more`,kind:`scalar`,T:p.BOOL},{no:3,name:`prefixes`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Ti=k({typeName:`s4wave.world.DeleteGraphQuadRequest`,fields:[{no:1,name:`quad`,kind:`message`,T:()=>I}]}),Ei=A(`s4wave.world.DeleteGraphQuadResponse`,!0),Di=k({typeName:`s4wave.world.LookupGraphQuadsRequest`,fields:[{no:1,name:`filter`,kind:`message`,T:()=>I},{no:2,name:`limit`,kind:`scalar`,T:p.UINT32}]}),Oi=k({typeName:`s4wave.world.LookupGraphQuadsResponse`,fields:[{no:1,name:`quads`,kind:`message`,T:()=>I,repeated:!0}]}),ki=k({typeName:`s4wave.world.LookupGraphQuadsBatchRequest`,fields:[{no:1,name:`filters`,kind:`message`,T:()=>I,repeated:!0},{no:2,name:`limit_per_filter`,kind:`scalar`,T:p.UINT32}]}),Ai=k({typeName:`s4wave.world.LookupGraphQuadsBatchResult`,fields:[{no:1,name:`quads`,kind:`message`,T:()=>I,repeated:!0}]}),ji=k({typeName:`s4wave.world.LookupGraphQuadsBatchResponse`,fields:[{no:1,name:`results`,kind:`message`,T:Ai,repeated:!0}]}),Mi=k({typeName:`s4wave.world.ListGraphEdgeBucketsRequest`,fields:[{no:1,name:`origin_object_keys`,kind:`scalar`,T:p.STRING,repeated:!0},{no:2,name:`predicate`,kind:`scalar`,T:p.STRING},{no:3,name:`limit_per_origin`,kind:`scalar`,T:p.UINT32},{no:4,name:`direction`,kind:`enum`,T:Cr}]}),Ni=k({typeName:`s4wave.world.GraphEdgeBucket`,fields:[{no:1,name:`origin_object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`outgoing`,kind:`message`,T:()=>I,repeated:!0},{no:3,name:`incoming`,kind:`message`,T:()=>I,repeated:!0},{no:4,name:`outgoing_truncated`,kind:`scalar`,T:p.BOOL},{no:5,name:`incoming_truncated`,kind:`scalar`,T:p.BOOL}]}),Pi=k({typeName:`s4wave.world.ListGraphEdgeBucketsResponse`,fields:[{no:1,name:`buckets`,kind:`message`,T:Ni,repeated:!0}]}),Fi=k({typeName:`s4wave.world.ListObjectsWithTypeRequest`,fields:[{no:1,name:`type_id`,kind:`scalar`,T:p.STRING}]}),Ii=k({typeName:`s4wave.world.ListObjectsWithTypeResponse`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Li=k({typeName:`s4wave.world.ObjectRootRef`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`root_ref`,kind:`message`,T:()=>F},{no:3,name:`rev`,kind:`scalar`,T:p.UINT64},{no:4,name:`exists`,kind:`scalar`,T:p.BOOL}]}),Ri=k({typeName:`s4wave.world.GetObjectRootRefsBatchRequest`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),zi=k({typeName:`s4wave.world.GetObjectRootRefsBatchResponse`,fields:[{no:1,name:`root_refs`,kind:`message`,T:Li,repeated:!0}]}),Bi=k({typeName:`s4wave.world.GetObjectMetadataBatchRequest`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Vi=k({typeName:`s4wave.world.GetObjectMetadataBatchResponse`,fields:[{no:1,name:`metadata`,kind:`message`,T:Ci,repeated:!0}]}),Hi=k({typeName:`s4wave.world.ObjectBody`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`body`,kind:`scalar`,T:p.BYTES},{no:3,name:`exists`,kind:`scalar`,T:p.BOOL},{no:4,name:`rev`,kind:`scalar`,T:p.UINT64}]}),Ui=k({typeName:`s4wave.world.GetObjectBodiesBatchRequest`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Wi=k({typeName:`s4wave.world.GetObjectBodiesBatchResponse`,fields:[{no:1,name:`bodies`,kind:`message`,T:Hi,repeated:!0},{no:2,name:`world_seqno`,kind:`scalar`,T:p.UINT64}]}),Gi=k({typeName:`s4wave.world.GraphPathStep`,fields:[{no:1,name:`direction`,kind:`enum`,T:wr},{no:2,name:`predicate`,kind:`scalar`,T:p.STRING},{no:3,name:`limit`,kind:`scalar`,T:p.UINT32}]}),Ki=k({typeName:`s4wave.world.QueryGraphPathRequest`,fields:[{no:1,name:`start_keys`,kind:`scalar`,T:p.STRING,repeated:!0},{no:2,name:`steps`,kind:`message`,T:Gi,repeated:!0},{no:3,name:`result_limit`,kind:`scalar`,T:p.UINT32},{no:4,name:`include_quads`,kind:`scalar`,T:p.BOOL},{no:5,name:`page_size`,kind:`scalar`,T:p.UINT32}]}),qi=k({typeName:`s4wave.world.QueryGraphPathResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Ji=k({typeName:`s4wave.world.DeleteGraphObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Yi=A(`s4wave.world.DeleteGraphObjectResponse`,!0),Xi=k({typeName:`s4wave.world.ApplyWorldOpRequest`,fields:[{no:1,name:`op_type_id`,kind:`scalar`,T:p.STRING},{no:2,name:`op_data`,kind:`scalar`,T:p.BYTES},{no:3,name:`op_sender`,kind:`scalar`,T:p.STRING}]}),Zi=k({typeName:`s4wave.world.ApplyWorldOpResponse`,fields:[{no:1,name:`seqno`,kind:`scalar`,T:p.UINT64},{no:2,name:`sys_err`,kind:`scalar`,T:p.BOOL},{no:3,name:`error_code`,kind:`enum`,T:Er},{no:4,name:`rejection_code`,kind:`scalar`,T:p.STRING},{no:5,name:`rejection_message`,kind:`scalar`,T:p.STRING}]}),Qi=A(`s4wave.world.WatchWorldStateRequest`,!0),$i=k({typeName:`s4wave.world.WatchWorldStateResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),ea=k({typeName:`s4wave.world.TrackedWorldStateSnapshot.ObjectAccess`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.STRING},{no:2,name:`rev`,kind:`scalar`,T:p.UINT64}]}),ta=k({typeName:`s4wave.world.TrackedWorldStateSnapshot`,fields:[{no:1,name:`object_accesses`,kind:`message`,T:ea,repeated:!0},{no:2,name:`has_quad_access`,kind:`scalar`,T:p.BOOL},{no:3,name:`initial_seqno`,kind:`scalar`,T:p.UINT64}]}),na=A(`s4wave.world.ErrRequest`,!0),ra=k({typeName:`s4wave.world.ErrResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING}]}),ia=A(`s4wave.world.ValidRequest`,!0),aa=k({typeName:`s4wave.world.ValidResponse`,fields:[{no:1,name:`valid`,kind:`scalar`,T:p.BOOL}]}),oa=A(`s4wave.world.KeyRequest`,!0),sa=k({typeName:`s4wave.world.KeyResponse`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),ca=A(`s4wave.world.NextRequest`,!0),la=k({typeName:`s4wave.world.NextResponse`,fields:[{no:1,name:`valid`,kind:`scalar`,T:p.BOOL}]}),ua=k({typeName:`s4wave.world.SeekRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),da=A(`s4wave.world.SeekResponse`,!0),fa=A(`s4wave.world.CloseRequest`,!0),pa=A(`s4wave.world.CloseResponse`,!0),ma=A(`s4wave.world.NextGraphPathQueryRequest`,!0),ha=k({typeName:`s4wave.world.NextGraphPathQueryResponse`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0},{no:2,name:`quads`,kind:`message`,T:()=>I,repeated:!0},{no:3,name:`done`,kind:`scalar`,T:p.BOOL}]}),ga=A(`s4wave.world.CloseGraphPathQueryRequest`,!0),_a=A(`s4wave.world.CloseGraphPathQueryResponse`,!0),va=A(`s4wave.world.GetKeyRequest`,!0),ya=k({typeName:`s4wave.world.GetKeyResponse`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),ba=A(`s4wave.world.GetRootRefRequest`,!0),xa=k({typeName:`s4wave.world.GetRootRefResponse`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>F},{no:2,name:`rev`,kind:`scalar`,T:p.UINT64}]}),Sa=k({typeName:`s4wave.world.SetRootRefRequest`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>F}]}),Ca=k({typeName:`s4wave.world.SetRootRefResponse`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),wa=k({typeName:`s4wave.world.ApplyObjectOpRequest`,fields:[{no:1,name:`op_type_id`,kind:`scalar`,T:p.STRING},{no:2,name:`op_data`,kind:`scalar`,T:p.BYTES},{no:3,name:`op_sender`,kind:`scalar`,T:p.STRING}]}),Ta=k({typeName:`s4wave.world.ApplyObjectOpResponse`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64},{no:2,name:`sys_err`,kind:`scalar`,T:p.BOOL},{no:3,name:`error_code`,kind:`enum`,T:Er},{no:4,name:`rejection_code`,kind:`scalar`,T:p.STRING},{no:5,name:`rejection_message`,kind:`scalar`,T:p.STRING}]}),Ea=A(`s4wave.world.IncrementRevRequest`,!0),Da=k({typeName:`s4wave.world.IncrementRevResponse`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),Oa=k({typeName:`s4wave.world.WaitRevRequest`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64},{no:2,name:`ignore_not_found`,kind:`scalar`,T:p.BOOL}]}),ka=k({typeName:`s4wave.world.WaitRevResponse`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),Aa=k({typeName:`s4wave.world.AccessTypedObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),ja=k({typeName:`s4wave.world.AccessTypedObjectResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`type_id`,kind:`scalar`,T:p.STRING}]}),Ma=k({typeName:`s4wave.world.WatchTypedObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Na=k({typeName:`s4wave.world.WatchTypedObjectResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32},{no:2,name:`type_id`,kind:`scalar`,T:p.STRING}]}),Pa=k({typeName:`s4wave.world.ObjectRecordBase`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`root_ref`,kind:`message`,T:()=>F}]}),Fa=k({typeName:`s4wave.world.CompareObjectRecordsRequest`,fields:[{no:1,name:`bases`,kind:`message`,T:Pa,repeated:!0}]}),Ia=k({typeName:`s4wave.world.ObjectRecordChanges`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING},{no:2,name:`keys`,kind:`scalar`,T:p.BYTES,repeated:!0},{no:3,name:`unknown`,kind:`scalar`,T:p.BOOL}]}),La=k({typeName:`s4wave.world.CompareObjectRecordsResponse`,fields:[{no:1,name:`changes`,kind:`message`,T:Ia,repeated:!0}]}),Ra=b(`blob.BlobType`,function(e){return e[e.BlobType_RAW=0]=`BlobType_RAW`,e[e.BlobType_CHUNKED=1]=`BlobType_CHUNKED`,e}({})),za=b(`blob.ChunkerType`,function(e){return e[e.ChunkerType_DEFAULT=0]=`ChunkerType_DEFAULT`,e[e.ChunkerType_RABIN=1]=`ChunkerType_RABIN`,e[e.ChunkerType_JC=2]=`ChunkerType_JC`,e}({})),Ba=k({typeName:`blob.Chunk`,fields:[{no:1,name:`data_ref`,kind:`message`,T:()=>j},{no:2,name:`size`,kind:`scalar`,T:p.UINT64},{no:3,name:`start`,kind:`scalar`,T:p.UINT64}]}),Va=k({typeName:`blob.RabinArgs`,fields:[{no:1,name:`pol`,kind:`scalar`,T:p.UINT64},{no:4,name:`random_pol`,kind:`scalar`,T:p.BOOL},{no:2,name:`chunking_min_size`,kind:`scalar`,T:p.UINT64},{no:3,name:`chunking_max_size`,kind:`scalar`,T:p.UINT64}]}),Ha=k({typeName:`blob.JcArgs`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES},{no:2,name:`chunking_min_size`,kind:`scalar`,T:p.UINT64},{no:3,name:`chunking_target_size`,kind:`scalar`,T:p.UINT64},{no:4,name:`chunking_max_size`,kind:`scalar`,T:p.UINT64}]}),Ua=k({typeName:`blob.ChunkerArgs`,fields:[{no:1,name:`chunker_type`,kind:`enum`,T:za},{no:2,name:`rabin_args`,kind:`message`,T:Va},{no:3,name:`jc_args`,kind:`message`,T:Ha}]}),Wa=k({typeName:`blob.ChunkIndex`,fields:[{no:1,name:`chunks`,kind:`message`,T:Ba,repeated:!0},{no:2,name:`chunker_args`,kind:`message`,T:Ua},{no:3,name:`tail_start`,kind:`scalar`,T:p.UINT64}]}),Ga=k({typeName:`blob.Blob`,fields:[{no:1,name:`blob_type`,kind:`enum`,T:Ra},{no:2,name:`total_size`,kind:`scalar`,T:p.UINT64},{no:3,name:`raw_data`,kind:`scalar`,T:p.BYTES},{no:4,name:`chunk_index`,kind:`message`,T:Wa}]}),Ka=k({typeName:`blob.BuildBlobOpts`,fields:[{no:1,name:`raw_high_water_mark`,kind:`scalar`,T:p.UINT64},{no:2,name:`chunker_args`,kind:`message`,T:Ua}]}),qa=k({typeName:`kvtx.block.iavl.Node`,fields:[{no:1,name:`height`,kind:`scalar`,T:p.UINT32},{no:2,name:`size`,kind:`scalar`,T:p.UINT64},{no:3,name:`key`,kind:`scalar`,T:p.BYTES},{no:7,name:`value_ref`,kind:`message`,T:()=>j},{no:8,name:`value_blob`,kind:`message`,T:()=>Ga},{no:5,name:`left_child_ref`,kind:`message`,T:()=>j},{no:6,name:`right_child_ref`,kind:`message`,T:()=>j}]}),Ja=k({typeName:`kvtx.block.okra.Root`,fields:[{no:1,name:`size`,kind:`scalar`,T:p.UINT64},{no:2,name:`height`,kind:`scalar`,T:p.UINT32},{no:3,name:`root_hash`,kind:`scalar`,T:p.BYTES},{no:4,name:`root_page_ref`,kind:`message`,T:()=>j},{no:5,name:`hash_size`,kind:`scalar`,T:p.UINT32},{no:6,name:`fanout_degree`,kind:`scalar`,T:p.UINT32}]}),Ya=k({typeName:`kvtx.block.okra.Entry`,fields:[{no:1,name:`anchor`,kind:`scalar`,T:p.BOOL},{no:2,name:`key`,kind:`scalar`,T:p.BYTES},{no:3,name:`hash`,kind:`scalar`,T:p.BYTES},{no:4,name:`size`,kind:`scalar`,T:p.UINT64},{no:5,name:`child_ref`,kind:`message`,T:()=>j},{no:6,name:`value_ref`,kind:`message`,T:()=>j},{no:7,name:`value_is_blob`,kind:`scalar`,T:p.BOOL},{no:8,name:`value_blob`,kind:`message`,T:()=>Ga}]}),Xa=k({typeName:`kvtx.block.okra.Page`,fields:[{no:1,name:`level`,kind:`scalar`,T:p.UINT32},{no:2,name:`lower_bound`,kind:`scalar`,T:p.BYTES},{no:3,name:`upper_bound`,kind:`scalar`,T:p.BYTES},{no:4,name:`starts_at_anchor`,kind:`scalar`,T:p.BOOL},{no:5,name:`size`,kind:`scalar`,T:p.UINT64},{no:6,name:`page_hash`,kind:`scalar`,T:p.BYTES},{no:7,name:`entries`,kind:`message`,T:Ya,repeated:!0}]});let Za=function(e){return e[e.KV_IMPL_TYPE_UNKNOWN=0]=`KV_IMPL_TYPE_UNKNOWN`,e[e.KV_IMPL_TYPE_IAVL=1]=`KV_IMPL_TYPE_IAVL`,e[e.KV_IMPL_TYPE_OKRA=2]=`KV_IMPL_TYPE_OKRA`,e[e.KV_IMPL_TYPE_OKRA_INLINE=3]=`KV_IMPL_TYPE_OKRA_INLINE`,e}({});const Qa=k({typeName:`kvtx.block.KeyValueStore`,fields:[{no:1,name:`impl_type`,kind:`enum`,T:b(`kvtx.block.KVImplType`,Za)},{no:2,name:`iavl_root`,kind:`message`,T:()=>qa},{no:3,name:`okra_root`,kind:`message`,T:()=>Ja}]}),L=b(`kvtx.rpc.KvtxRetryClass`,function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.INVALID_SNAPSHOT=1]=`INVALID_SNAPSHOT`,e}({}),`KVTX_RETRY_CLASS_`),$a=k({typeName:`kvtx.rpc.KvtxTransactionInit`,fields:[{no:1,name:`write`,kind:`scalar`,T:p.BOOL}]}),eo=k({typeName:`kvtx.rpc.KvtxTransactionRequest`,fields:[{no:1,name:`init`,kind:`message`,T:$a,oneof:`body`},{no:2,name:`commit`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:3,name:`discard`,kind:`scalar`,T:p.BOOL,oneof:`body`}]}),to=k({typeName:`kvtx.rpc.KvtxTransactionAck`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`transaction_id`,kind:`scalar`,T:p.STRING},{no:3,name:`retry_class`,kind:`enum`,T:L}]}),no=k({typeName:`kvtx.rpc.KvtxTransactionComplete`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`committed`,kind:`scalar`,T:p.BOOL},{no:3,name:`discarded`,kind:`scalar`,T:p.BOOL},{no:4,name:`retry_class`,kind:`enum`,T:L}]}),ro=k({typeName:`kvtx.rpc.KvtxTransactionResponse`,fields:[{no:1,name:`ack`,kind:`message`,T:to,oneof:`body`},{no:2,name:`complete`,kind:`message`,T:no,oneof:`body`}]}),io=k({typeName:`kvtx.rpc.KeyCountRequest`,fields:[{no:1,name:`accept_retry_class`,kind:`scalar`,T:p.BOOL}]}),ao=k({typeName:`kvtx.rpc.KeyCountResponse`,fields:[{no:1,name:`key_count`,kind:`scalar`,T:p.UINT64},{no:2,name:`error`,kind:`scalar`,T:p.STRING},{no:3,name:`retry_class`,kind:`enum`,T:L}]}),oo=k({typeName:`kvtx.rpc.KvtxKeyRequest`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES}]}),so=k({typeName:`kvtx.rpc.KvtxKeyDataResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`found`,kind:`scalar`,T:p.BOOL},{no:3,name:`data`,kind:`scalar`,T:p.BYTES},{no:4,name:`retry_class`,kind:`enum`,T:L}]}),co=k({typeName:`kvtx.rpc.KvtxKeyExistsResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`found`,kind:`scalar`,T:p.BOOL},{no:3,name:`retry_class`,kind:`enum`,T:L}]}),lo=k({typeName:`kvtx.rpc.KvtxSetKeyRequest`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES},{no:2,name:`value`,kind:`scalar`,T:p.BYTES}]}),uo=k({typeName:`kvtx.rpc.KvtxSetKeyResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`retry_class`,kind:`enum`,T:L}]}),fo=k({typeName:`kvtx.rpc.KvtxDeleteKeyRequest`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES}]}),po=k({typeName:`kvtx.rpc.KvtxDeleteKeyResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`retry_class`,kind:`enum`,T:L}]}),mo=k({typeName:`kvtx.rpc.KvtxScanPrefixRequest`,fields:[{no:1,name:`prefix`,kind:`scalar`,T:p.BYTES},{no:2,name:`only_keys`,kind:`scalar`,T:p.BOOL}]}),ho=k({typeName:`kvtx.rpc.KvtxScanPrefixResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`key`,kind:`scalar`,T:p.BYTES},{no:3,name:`value`,kind:`scalar`,T:p.BYTES},{no:4,name:`retry_class`,kind:`enum`,T:L}]}),go=k({typeName:`kvtx.rpc.KvtxWatchRequest`,fields:[{no:1,name:`prefix`,kind:`scalar`,T:p.BYTES},{no:2,name:`only_keys`,kind:`scalar`,T:p.BOOL},{no:3,name:`max_records`,kind:`scalar`,T:p.UINT64},{no:4,name:`max_bytes`,kind:`scalar`,T:p.UINT64}]}),_o=k({typeName:`kvtx.rpc.KvtxWatchEntry`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES},{no:2,name:`value`,kind:`scalar`,T:p.BYTES}]}),vo=k({typeName:`kvtx.rpc.KvtxWatchResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`entries`,kind:`message`,T:_o,repeated:!0},{no:3,name:`limit_exceeded`,kind:`scalar`,T:p.BOOL}]}),yo=k({typeName:`kvtx.rpc.KvtxIterateInit`,fields:[{no:1,name:`prefix`,kind:`scalar`,T:p.BYTES},{no:2,name:`sort`,kind:`scalar`,T:p.BOOL},{no:3,name:`reverse`,kind:`scalar`,T:p.BOOL}]}),bo=k({typeName:`kvtx.rpc.KvtxIterateRequest`,fields:[{no:1,name:`init`,kind:`message`,T:yo,oneof:`body`},{no:2,name:`lookup_value`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:3,name:`next`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:4,name:`seek`,kind:`scalar`,T:p.BYTES,oneof:`body`},{no:5,name:`seek_beginning`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:6,name:`close`,kind:`scalar`,T:p.BOOL,oneof:`body`}]}),xo=k({typeName:`kvtx.rpc.KvtxIterateStatus`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`valid`,kind:`scalar`,T:p.BOOL},{no:3,name:`key`,kind:`scalar`,T:p.BYTES},{no:4,name:`retry_class`,kind:`enum`,T:L}]}),So=k({typeName:`kvtx.rpc.KvtxIterateResponse`,fields:[{no:1,name:`ack`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:2,name:`req_error`,kind:`scalar`,T:p.STRING,oneof:`body`},{no:3,name:`status`,kind:`message`,T:xo,oneof:`body`},{no:4,name:`value`,kind:`scalar`,T:p.BYTES,oneof:`body`},{no:5,name:`closed`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:6,name:`retry_class`,kind:`enum`,T:L}]}),R=`ERR_RPC_ABORT`;var Co=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 z(){let e={};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e}var wo=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}},To=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new wo(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 wo(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()}},Eo=class extends Error{type;code;constructor(e,t){super(e??`The operation was aborted`),this.type=`aborted`,this.code=t??`ABORT_ERR`}};function B(e={}){return Do(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 Do(e,t){t??={};let n=t.onEnd,r=new To,i,a,o,s=z(),c=async()=>{try{return r.isEmpty()?o?{done:!0}:await new Promise((t,n)=>{a=o=>{a=null,r.push(o);try{t(e(r))}catch(e){n(e)}return i}}):e(r)}finally{r.isEmpty()&&queueMicrotask(()=>{s.resolve(),s=z()})}},l=e=>a==null?(r.push(e),i):a(e),ee=e=>(r=new To,a==null?(r.push({error:e}),i):a({error:e})),te=e=>{if(o)return i;if(t?.objectMode!==!0&&e?.byteLength==null)throw Error(`objectMode was not true but tried to push non-Uint8Array value`);return l({done:!1,value:e})},u=e=>o?i:(o=!0,e==null?l({done:!0}):ee(e)),ne=()=>(r=new To,u(),{done:!0}),re=e=>(u(e),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:c,return:ne,throw:re,push:te,end:u,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 Eo)},t.addEventListener(`abort`,i)}));try{await Promise.race([s.promise,n])}finally{i!=null&&t!=null&&t?.removeEventListener(`abort`,i)}}},n==null)return i;let d=i;return i={[Symbol.asyncIterator](){return this},next(){return d.next()},throw(e){return d.throw(e),n!=null&&(n(e),n=void 0),{done:!0}},return(){return d.return(),n!=null&&(n(),n=void 0),{done:!0}},push:te,end(e){return d.end(e),n!=null&&(n(e),n=void 0),i},get readableLength(){return d.readableLength},onEmpty:e=>d.onEmpty(e)},i}var Oo=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 V(e,t,n){if(t==null)return e;if(t.aborted)return e.catch(()=>{}),Promise.reject(new Oo(n?.errorMessage,n?.errorCode,n?.errorName));let r,i=new Oo(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 ko=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=z(),this.haveNext=z()}[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=z(),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=z(),await V(this.readNext.promise,t?.signal,t)}};function Ao(){return new ko}function jo(e){return e[Symbol.asyncIterator]!=null}async function Mo(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*No(e){let t=new AbortController,n=Ao();Mo(e,n,t.signal).catch(()=>{});try{yield*n}finally{t.abort()}}function*Po(e){for(let t of e)yield*t}function Fo(...e){let t=[];for(let n of e)jo(n)||t.push(n);return t.length===e.length?Po(t):No(e)}function H(e,...t){if(e==null)throw Error(`Empty pipeline`);if(zo(e)){let t=e;e=()=>t.source}else if(Ro(e)||Lo(e)){let t=e;e=()=>t}let n=[e,...t];if(n.length>1&&zo(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++)zo(n[e])&&(n[e]=Bo(n[e]));return Io(...n)}const Io=(...e)=>{let t;for(;e.length>0;)t=e.shift()(t);return t},Lo=e=>e?.[Symbol.asyncIterator]!=null,Ro=e=>e?.[Symbol.iterator]!=null,zo=e=>e!=null&&e.sink!=null&&e.source!=null,Bo=e=>t=>{let n=e.sink(t);if(n?.then!=null){let t=B({objectMode:!0});n.then(()=>{t.end()},e=>{t.end(e)});let r,i=e.source;if(Lo(i))r=async function*(){yield*i,t.end()};else if(Ro(i))r=function*(){yield*i,t.end()};else throw Error(`Unknown duplex source type - must be Iterable or AsyncIterable`);return Fo(t,r())}return e.source},Vo=k({typeName:`srpc.CallStart`,fields:[{no:1,name:`rpc_service`,kind:`scalar`,T:p.STRING},{no:2,name:`rpc_method`,kind:`scalar`,T:p.STRING},{no:3,name:`data`,kind:`scalar`,T:p.BYTES},{no:4,name:`data_is_zero`,kind:`scalar`,T:p.BOOL}],packedByDefault:!0}),Ho=k({typeName:`srpc.CallData`,fields:[{no:1,name:`data`,kind:`scalar`,T:p.BYTES},{no:2,name:`data_is_zero`,kind:`scalar`,T:p.BOOL},{no:3,name:`complete`,kind:`scalar`,T:p.BOOL},{no:4,name:`error`,kind:`scalar`,T:p.STRING}],packedByDefault:!0}),Uo=k({typeName:`srpc.Packet`,fields:[{no:1,name:`call_start`,kind:`message`,T:()=>Vo,oneof:`body`},{no:2,name:`call_data`,kind:`message`,T:()=>Ho,oneof:`body`},{no:3,name:`call_cancel`,kind:`scalar`,T:p.BOOL,oneof:`body`}],packedByDefault:!0});var Wo=class{sink;source;rpcDataSource;_source=B({objectMode:!0});_rpcDataSource=B({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,t){if(this.closed&&!t?.allowClosed)throw Error(R);if(this._source.push(e),!(t?.waitForDrain===!1||this._source.readableLength<=1))try{await this._source.onEmpty({signal:this.writeDrainAbort.signal})}catch(e){throw this.closed?Error(R,{cause:e}):e}}async handleMessage(e){return this.handlePacket(Uo.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 Co(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(R))}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)}}}},Go=class extends Wo{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 Ko(e,t){try{for await(let n of e)t.push(n);t.end()}catch(e){t.end(e)}}function qo(e){if(e.buffer instanceof ArrayBuffer)return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function U(e=0){return qo(t.alloc(e))}function Jo(e=0){return qo(t.allocUnsafe(e))}function Yo(e,n){return qo(t.concat(e,n))}function Xo(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 Zo=Symbol.for(`@achingbrain/uint8arraylist`);function Qo(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 W(e){return!!e?.[Zo]}var G=class e{bufs;length;[Zo]=!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(W(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(W(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=Qo(this.bufs,e);return t.buf[t.index]}set(e,t){let n=Qo(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(W(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 Yo(n,r)}subarray(e,t){let{bufs:n,length:r}=this._subList(e,t);return n.length===1?n[0]:Yo(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(!W(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=Jo(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=U(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=U(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=U(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=Jo(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=U(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=U(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=U(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=U(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=U(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(!Xo(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 $o(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 es(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 ts=1e7,ns=$o(Uo),rs=es(Uo),is=e=>{if(e.length<4)throw RangeError(`Could not decode int32BE`);return e.getUint32(0,!0)};is.bytes=4;const as=e=>{let t=new G(new Uint8Array(4));return t.setUint32(0,e,!0),t};as.bytes=4;async function*os(e,t){for await(let n of e){let e=n instanceof Uint8Array?n.length:n.byteLength;if(e===0||e>ts)throw RangeError(`invalid packet length: ${e}`);yield new G(t(e),n)}}async function*ss(e,t){let n=new G;for await(let r of e)for(n.append(r);n.length>=t.bytes;){let e=t(n);if(e===0||e>ts)throw RangeError(`invalid packet length: ${e}`);let r=t.bytes+e;if(n.length<r)break;yield new G(n.slice(t.bytes,r)),n.consume(r)}if(n.length!==0)throw RangeError(`truncated packet frame`)}function cs(e=as){return t=>os(t,e)}function ls(e=is){return t=>ss(t,e)}var us=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)}}},ds=class extends us{constructor(e){super(e)}get openStreamFunc(){return async()=>{let e=this.value;return e||=await this.wait(),e()}}},fs=class{openStreamCtr;constructor(e){this.openStreamCtr=new ds(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=B({objectMode:!0});return this.startRpc(e,t,n,r).then(async e=>Ko(e.rpcDataSource,i)).catch(e=>i.end(e)),i}bidirectionalStreamingRequest(e,t,n,r){let i=B({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,t,n,r){if(r?.aborted)throw Error(R);let i=await(await this.openStreamCtr.wait())(),a=new Go(e,t),o=()=>{if(a.isClosed)return;let e=Error(R);a.writeCallCancel().catch(()=>void 0),i.abort(e),a.close(e).catch(()=>void 0)};return r?.addEventListener(`abort`,o,{once:!0}),H(i,ns,a,rs,i).then(async()=>{if(a.isClosed instanceof Error){i.abort(a.isClosed);return}await i.close(),await a.close()},async e=>{let t=e instanceof Error?e:Error(String(e));i.abort(t),await a.close(t)}).finally(()=>{r?.removeEventListener(`abort`,o)}),await a.writeCallStart(n??void 0),a}},ps=class extends Wo{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)}}}},ms=class{lookupMethod;constructor(e){this.lookupMethod=e}get rpcStreamHandler(){return async e=>hs(e,this.startRpc())}startRpc(){return new ps(this.lookupMethod)}handlePacketStream(e){let t=this.startRpc();return hs(e,t).catch(()=>void 0),t}};async function hs(e,t){try{if(await H(e,ns,t,rs,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 gs(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`)}const _s=(e,...t)=>{try{[...t]}catch{}};var K=class extends Error{static name=`InvalidFrameError`;constructor(e=`The frame was invalid`){super(e),this.name=`InvalidFrameError`}},vs=class extends Error{static name=`UnrequestedPingError`;constructor(e=`Unrequested ping error`){super(e),this.name=`UnrequestedPingError`}},ys=class extends Error{static name=`NotMatchingPingError`;constructor(e=`Unrequested ping error`){super(e),this.name=`NotMatchingPingError`}},bs=class extends Error{static name=`InvalidStateError`;constructor(e=`Invalid state`){super(e),this.name=`InvalidStateError`}},xs=class extends Error{static name=`StreamAlreadyExistsError`;constructor(e=`Strean already exists`){super(e),this.name=`StreamAlreadyExistsError`}},Ss=class extends Error{static name=`DecodeInvalidVersionError`;constructor(e=`Decode invalid version`){super(e),this.name=`DecodeInvalidVersionError`}},Cs=class extends Error{static name=`BothClientsError`;constructor(e=`Both clients`){super(e),this.name=`BothClientsError`}},ws=class extends Error{static name=`ReceiveWindowExceededError`;constructor(e=`Receive window exceeded`){super(e),this.name=`ReceiveWindowExceededError`}};const Ts=new Set([K.name,vs.name,ys.name,xs.name,Ss.name,Cs.name,ws.name]),Es=262144,Ds=Symbol.for(`@libp2p/service-capabilities`);var Os=class extends Error{static name=`AbortError`;constructor(e=`The operation was aborted`){super(e),this.name=`AbortError`}},q=class extends Error{static name=`InvalidParametersError`;constructor(e=`Invalid parameters`){super(e),this.name=`InvalidParametersError`}},J=class extends Error{static name=`MuxerClosedError`;constructor(e=`The muxer is closed`){super(e),this.name=`MuxerClosedError`}},ks=class extends Error{static name=`TooManyOutboundProtocolStreamsError`;constructor(e=`Too many outbound protocol streams`){super(e),this.name=`TooManyOutboundProtocolStreamsError`}};const As={enableKeepAlive:!0,keepAliveInterval:3e4,maxInboundStreams:1e3,maxOutboundStreams:1e3,initialStreamWindowSize:Es,maxStreamWindowSize:16777216,maxMessageSize:65536};function js(e){if(e.keepAliveInterval<=0)throw new q(`keep-alive interval must be positive`);if(e.maxInboundStreams<0)throw new q(`max inbound streams must be larger or equal 0`);if(e.maxOutboundStreams<0)throw new q(`max outbound streams must be larger or equal 0`);if(e.initialStreamWindowSize<262144)throw new q(`InitialStreamWindowSize must be larger or equal 256 kB`);if(e.maxStreamWindowSize<e.initialStreamWindowSize)throw new q(`MaxStreamWindowSize must be larger than the InitialStreamWindowSize`);if(e.maxStreamWindowSize>2**32-1)throw new q(`MaxStreamWindowSize must be less than equal MAX_UINT32`);if(e.maxMessageSize<1024)throw new q(`MaxMessageSize must be greater than a kilobyte`)}var Y;(function(e){e[e.Data=0]=`Data`,e[e.WindowUpdate=1]=`WindowUpdate`,e[e.Ping=2]=`Ping`,e[e.GoAway=3]=`GoAway`})(Y||={});var X;(function(e){e[e.SYN=1]=`SYN`,e[e.ACK=2]=`ACK`,e[e.FIN=4]=`FIN`,e[e.RST=8]=`RST`})(X||={}),Object.values(X).filter(e=>typeof e!=`string`);var Z;(function(e){e[e.NormalTermination=0]=`NormalTermination`,e[e.ProtocolError=1]=`ProtocolError`,e[e.InternalError=2]=`InternalError`})(Z||={});const Ms=2**24;function Ns(e){if(e[0]!==0)throw new K(`Invalid frame version`);return{type:e[1],flag:(e[2]<<8)+e[3],streamID:e[4]*Ms+(e[5]<<16)+(e[6]<<8)+e[7],length:e[8]*Ms+(e[9]<<16)+(e[10]<<8)+e[11]}}var Ps=class{source;buffer;frameInProgress;constructor(e){this.source=Fs(e),this.buffer=new G,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===Y.Data?(this.frameInProgress=!0,yield{header:e,readData:this.readBytes.bind(this,n)}):yield{header:e}}}readHeader(){if(this.frameInProgress)throw new bs(`decoding frame already in progress`);if(this.buffer.length<12)return;let e=Ns(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 Fs(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 Is(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 Ls=class extends Error{static name=`StreamResetError`;constructor(e=`The stream has been reset`){super(e),this.name=`StreamResetError`}},Rs=class extends Error{static name=`StreamStateError`;constructor(e=`The stream is in an invalid state`){super(e),this.name=`StreamStateError`}};function zs(e){return e!=null&&typeof e.then==`function`&&typeof e.catch==`function`&&typeof e.finally==`function`}function Bs(e,t){let n=gs(e).return?.();zs(n)&&n.catch(e=>{t.error(`could not cause iterator to return`,e)})}function Vs(e){return e!=null&&typeof e.then==`function`&&typeof e.catch==`function`&&typeof e.finally==`function`}var Hs=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=z(),this.closed=z(),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=B({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 Rs(`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);Vs(e)&&await e}let n=()=>{Bs(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 G(n):n;let e=this.sendData(n,t);Vs(e)&&(this.sendingData=z(),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 V(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 V(this.sink([]),e.signal)),this.writeStatus===`writing`&&(this.sendingData!=null&&await V(this.sendingData.promise,e.signal),this.log.trace(`aborting source passed to .sink`),this.sinkController.abort(),await V(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();Vs(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 Ls(`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 Us(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 Ws(e){return e[Symbol.asyncIterator]!=null}function Gs(e){return e?.then!=null}function Ks(e,t){let n=0;if(Ws(e))return(async function*(){for await(let r of e){let e=t(r,n++);Gs(e)&&await e,yield r}})();let r=Us(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++);Gs(r)&&await r,yield e}})();let s=t;return(function*(){yield i;for(let e of r)s(e,n++),yield e})()}var Q;(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`})(Q||={});var qs=class extends Hs{name;state;config;_id;sendWindowCapacity;sendWindowCapacityUpdate;recvWindow;recvWindowCapacity;epochStart;getRTT;sendFrame;constructor(e){super({...e,onEnd:t=>{this.state=Q.Finished,e.onEnd?.(t)}}),this.config=e.config,this._id=parseInt(e.id,10),this.name=e.name,this.state=e.state,this.sendWindowCapacity=Es,this.recvWindow=this.config.initialStreamWindowSize,this.recvWindowCapacity=this.recvWindow,this.epochStart=Date.now(),this.getRTT=e.getRTT,this.sendFrame=e.sendFrame,this.source=Ks(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:Y.Data,flag:r,streamID:this._id,length:n},e.sublist(0,n)),this.sendWindowCapacity-=n,e.consume(n)}}sendReset(){this.sendFrame({type:Y.WindowUpdate,flag:X.RST,streamID:this._id,length:0})}async sendCloseWrite(){let e=this.getSendFlags()|X.FIN;this.sendFrame({type:Y.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 Os(`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 ws(`Receive window exceeded`);let n=await t();this.recvWindowCapacity-=e.length,this.sourcePush(n)}processFlags(e){(e&X.ACK)===X.ACK&&this.state===Q.SYNSent&&(this.state=Q.Established),(e&X.FIN)===X.FIN&&this.remoteCloseWrite(),(e&X.RST)===X.RST&&this.reset()}getSendFlags(){switch(this.state){case Q.Init:return this.state=Q.SYNSent,X.SYN;case Q.SYNReceived:return this.state=Q.Established,X.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:Y.WindowUpdate,flag:e,streamID:this._id,length:r})}};const Js=`/yamux/1.0.0`;var Ys=class{protocol=Js;_components;_init;constructor(e,t={}){this._components=e,this._init=t}[Symbol.toStringTag]=`@chainsafe/libp2p-yamux`;[Ds]=[`@libp2p/stream-multiplexing`];createStreamMuxer(e){return new Xs(this._components,{...this._init,...e})}},Xs=class{protocol=Js;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={...As,...t},this.logger=e.logger,this.log=this.logger.forComponent(`libp2p:yamux`),js(this.config),this.closeController=new AbortController,_s(1/0,this.closeController.signal),this.onIncomingStream=t.onIncomingStream,this.onStreamEnd=t.onStreamEnd,this._streams=new Map,this.source=B({onEnd:()=>{this.log?.trace(`muxer source ended`),this._streams.forEach(e=>{e.destroy()})}}),this.sink=async e=>{let t=()=>{let t=gs(e);if(t.return!=null){let e=t.return();Zs(e)&&e.catch(e=>{this.log?.(`could not cause sink source to return`,e)})}},n,r;try{let r=new Ps(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=Z.NormalTermination}catch(e){Ts.has(e.name)?(this.log?.error(`protocol error in sink`,e),n=Z.ProtocolError):(this.log?.error(`internal error in sink`,e),n=Z.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 J(`Muxer closed remotely`);if(this.localGoAway!==void 0)throw new J(`Muxer closed locally`);let t=this.nextStreamID;if(this.nextStreamID+=2,this.numOutboundStreams>=this.config.maxOutboundStreams)throw new ks(`max outbound streams exceeded`);this.log?.trace(`new outgoing stream id=%s`,t);let n=this._newStream(t,e,Q.Init,`outbound`);return this._streams.set(t,n),this.numOutboundStreams++,n.sendWindowUpdate(),n}async ping(){if(this.remoteGoAway!==void 0)throw new J(`Muxer closed remotely`);if(this.localGoAway!==void 0)throw new J(`Muxer closed locally`);if(this.activePing===void 0){let e=()=>{};this.activePing={id:this.nextPingID++,promise:new Promise((t,n)=>{let r=()=>{n(new J(`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??Z.NormalTermination;if(this.log?.trace(`muxer close reason=%s`,t),e.signal==null){let t=AbortSignal.timeout(500);_s(1/0,t),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??=Z.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 q(`Stream already exists with that id`);let i=new qs({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 V(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 Y.Ping:this.handlePing(e);return;case Y.GoAway:this.handleGoAway(i);return;default:throw new K(`Invalid frame type`)}else switch(e.type){case Y.Data:case Y.WindowUpdate:await this.handleStreamMessage(e,t);return;default:throw new K(`Invalid frame type`)}}handlePing(e){if(e.flag===X.SYN)this.log?.trace(`received ping request pingId=%s`,e.length),this.sendPing(e.length,X.ACK);else if(e.flag===X.ACK)this.log?.trace(`received ping response pingId=%s`,e.length),this.handlePingResponse(e.length);else throw new K(`Invalid frame flag`)}handlePingResponse(e){if(this.activePing===void 0)throw new vs(`ping not requested`);if(this.activePing.id!==e)throw new ys(`ping doesn't match our id`);this.activePing.resolve()}handleGoAway(e){this.log?.trace(`received GoAway reason=%s`,Z[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&X.SYN)===X.SYN&&this.incomingStream(n);let a=this._streams.get(n);if(a===void 0){if(i===Y.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 Y.WindowUpdate:a.handleWindowUpdate(e);return;case Y.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 q(`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:Y.WindowUpdate,flag:X.RST,streamID:e,length:0});return}if(this.numInboundStreams>=this.config.maxInboundStreams){this.log?.(`maxIncomingStreams exceeded, forcing stream reset`),this.sendFrame({type:Y.WindowUpdate,flag:X.RST,streamID:e,length:0});return}let t=this._newStream(e,void 0,Q.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===Y.Data){if(t===void 0)throw new K(`Invalid frame`);this.source.push(new G(Is(e),t))}else this.source.push(Is(e))}sendPing(e,t=X.SYN){t===X.SYN?this.log?.trace(`sending ping request pingId=%s`,e):this.log?.trace(`sending ping response pingId=%s`,e),this.sendFrame({type:Y.Ping,flag:t,streamID:0,length:e})}sendGoAway(e=Z.NormalTermination){this.log?.(`sending GoAway reason=%s`,Z[e]),this.localGoAway=e,this.sendFrame({type:Y.GoAway,flag:0,streamID:0,length:e})}};function Zs(e){return e!=null&&typeof e.then==`function`}function Qs(e={}){return t=>new Ys(t,e)}function $s(){return async function*(e){for await(let t of e)W(t)?yield t.subarray():yield t}}var ec=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 tc(e){if(Symbol.asyncIterator in e)return e[Symbol.asyncIterator]();let t=e[Symbol.iterator]();return{next:async()=>t.next()}}function nc(e){e.return&&Promise.resolve(e.return()).catch(()=>void 0)}function rc(e){let t=new ec;return{close:async()=>{t.terminate()&&await e.close()},abort:n=>{t.terminate(n)&&e.abort(n)},source:(async function*(){let n=H(e,ls(),$s())[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{nc(n)}})(),sink:async n=>{let r=tc(H(n,cs())),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{nc(r)}}}}function ic(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 ac(){return{forComponent:ic}}var oc=class{_muxer;_server;constructor(e,t){e&&(this._server=e);let n=t?.muxerFactory??Qs({enableKeepAlive:!1,...t?.yamuxParams})({logger:t?.logger??ac()});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 fs(this.openStream.bind(this))}async openStream(){return rc(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(rc(e))}close(e){e?this.muxer.abort(e):this.muxer.close()}},sc=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)})},cc=(e,t)=>(t??={},t.closeOnEnd=t.closeOnEnd!==!1,async n=>{for await(let t of n){try{await sc(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()})})}),lc=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})),uc=e((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=lc();e.EventIterator=t.EventIterator,e.default=t.EventIterator}))();function dc(e){return e instanceof ArrayBuffer||e?.constructor?.name===`ArrayBuffer`&&typeof e?.byteLength==`number`}var fc=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 uc.EventIterator(({push:t,stop:n,fail:r})=>{let i=e=>{let n=null;if(typeof e.data==`string`)throw Error(`Unsupported string encoding`);dc(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 dc(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})},pc=(e,t)=>{t??={};let n=fc(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:cc(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}};function mc(e,t){let n=$o(e.I);return async(r,i,a)=>{let o=B({objectMode:!0});H(o,es(e.O),i);let s=H(r,n),c;if(e.kind===N.ClientStreaming||e.kind===N.BiDiStreaming)c=s;else for await(let e of s){c=e;break}if(!c)throw Error(`request object was empty`);try{let n=t(c,a.signal,a);if(!n)throw Error(`return value was undefined`);if(e.kind===N.ServerStreaming||e.kind===N.BiDiStreaming)return Ko(n,o);{let e=n;if(!e.then)throw Error(`expected return value to be a Promise`);let t=await e;if(!t)throw Error(`expected non-empty response object`);o.push(t),o.end()}}catch(e){let t=e;throw t?.message||(t=Error(`error calling implementation: `+e)),o.end(),t}}}var hc=class{service;methods;constructor(e,t){this.service=e,this.methods=t}getServiceID(){return this.service}getMethodIDs(){return Object.keys(this.methods)}async lookupMethod(e,t){return e&&e!==this.service?null:this.methods[t]||null}};function gc(e,t,n){n||=e.typeName;let r={};for(let n of Object.values(e.methods)){let e=n.name,i=t[e];i&&(i=i.bind(t),r[e]=mc(n,i))}return new hc(n,r)}function _c(){return new vc}var vc=class{services={};lookups=[];get lookupMethod(){return this._lookupMethod.bind(this)}register(e){let t=e?.getServiceID();if(!t)throw Error(`service id cannot be empty`);let n=this.services[t]||{},r=e.getMethodIDs();for(let t of r)n[t]=e;this.services[t]=n}registerLookupMethod(e){this.lookups.push(e)}async _lookupMethod(e,t){if(e){let n=await this.lookupViaMap(e,t);if(n)return n}return await this.lookupViaLookups(e,t)}async lookupViaMap(e,t){let n=this.services[e];if(!n)return null;let r=n[t];return r?await r.lookupMethod(e,t):null}async lookupViaLookups(e,t){for(let n of this.lookups){let r=await n(e,t);if(r)return r}return null}};const yc=k({typeName:`rpcstream.RpcStreamInit`,fields:[{no:1,name:`component_id`,kind:`scalar`,T:p.STRING}],packedByDefault:!0}),bc=k({typeName:`rpcstream.RpcAck`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING}],packedByDefault:!0}),xc=k({typeName:`rpcstream.RpcStreamPacket`,fields:[{no:1,name:`init`,kind:`message`,T:()=>yc,oneof:`body`},{no:2,name:`ack`,kind:`message`,T:()=>bc,oneof:`body`},{no:3,name:`data`,kind:`scalar`,T:p.BYTES,oneof:`body`}],packedByDefault:!0}),$=k({typeName:`echo.EchoMsg`,fields:[{no:1,name:`body`,kind:`scalar`,T:p.STRING}],packedByDefault:!0}),Sc=A(`google.protobuf.Empty`,!0);({typeName:`echo.Echoer`,methods:{Echo:{name:`Echo`,I:$,O:$,kind:N.Unary},EchoServerStream:{name:`EchoServerStream`,I:$,O:$,kind:N.ServerStreaming},EchoClientStream:{name:`EchoClientStream`,I:$,O:$,kind:N.ClientStreaming},EchoBidiStream:{name:`EchoBidiStream`,I:$,O:$,kind:N.BiDiStreaming},RpcStream:{name:`RpcStream`,I:xc,O:xc,kind:N.BiDiStreaming},DoNothing:{name:`DoNothing`,I:Sc,O:Sc,kind:N.Unary}}}).typeName;function Cc(e){let t=!1,n=!1,r=!1,i,a,o=new Promise(e=>{a=e}),s=new ReadableStream({start(e){i=e}});function c(o){t||(t=!0,a(o),n||(n=!0,o?i.error(o):i.close()),r||(r=!0,e.postMessage(null)),e.removeEventListener(`message`,l),e.close())}function l(e){t||n||(e.data===null?(n=!0,i.close(),r&&c()):e.data instanceof Uint8Array?i.enqueue(e.data):c(Error(`Go MessagePort received a non-byte packet`)))}return e.addEventListener(`message`,l),e.start(),{source:(async function*(){let e=s.getReader();try{for(;;){let t=await e.read();if(t.done)return;yield t.value}}finally{e.releaseLock()}})(),sink:async i=>{let a=Symbol.asyncIterator in i?i[Symbol.asyncIterator]():i[Symbol.iterator](),s=o.then(e=>({error:e}));try{for(;;){let n=await Promise.race([Promise.resolve(a.next()),s]);if(`error`in n){if(n.error)throw n.error;break}if(t||n.done)break;e.postMessage(n.value)}r||(r=!0,e.postMessage(null),n&&c())}catch(e){throw c(e instanceof Error?e:Error(String(e))),e}finally{Promise.resolve(a.return?.()).catch(()=>{})}},close:async()=>c(),abort:c}}let wc=function(e){return e[e.KIND_UNKNOWN=0]=`KIND_UNKNOWN`,e[e.READY=1]=`READY`,e[e.OPEN_STREAM=2]=`OPEN_STREAM`,e[e.CLOSE=3]=`CLOSE`,e[e.CLOSED=4]=`CLOSED`,e[e.FAILED=5]=`FAILED`,e}({});const Tc=b(`core.sync.node.RuntimeMessage.Kind`,wc),Ec=k({typeName:`core.sync.node.RuntimeInit`,fields:[{no:1,name:`directory`,kind:`scalar`,T:p.STRING}]}),Dc=k({typeName:`core.sync.node.RuntimeMessage`,fields:[{no:1,name:`kind`,kind:`enum`,T:Tc},{no:2,name:`error`,kind:`scalar`,T:p.STRING}]});export{Ua as $,zt as $i,Qr as $n,Un as $r,Br as $t,oo as A,rn as Ai,Li as An,$n as Ar,yi as At,_o as B,Yt as Bi,da as Bn,Xn as Br,Ui as Bt,po as C,kn as Ci,ha as Cn,dr as Cr,Yr as Ct,xo as D,Fn as Di,Ci as Dn,er as Dr,Ti as Dt,So as E,Pn as Ei,Hi as En,ar as Er,Yi as Et,to as F,$t as Fi,Ki as Fn,sr as Fr,ra as Ft,Ya as G,Vt as Gi,Fr as Gn,Nn as Gr,hi as Gt,vo as H,qt as Hi,ni as Hn,Jn as Hr,Bi as Ht,no as I,nn as Ii,qi as In,yr as Ir,Ar as It,qa as J,Ut as Ji,Ca as Jn,Wn as Jr,li as Jt,Xa as K,Bt as Ki,Ir as Kn,An as Kr,Ri as Kt,$a as L,sn as Li,gi as Ln,br as Lr,jr as Lt,ho as M,an as Mi,Gr as Mn,lr as Mr,ci as Mt,lo as N,tn as Ni,Kr as Nn,ur as Nr,kr as Nt,so as O,Sn as Oi,Pa as On,tr as Or,Ei as Ot,uo as P,on as Pi,qr as Pn,or as Pr,na as Pt,Wa as Q,Lt as Qi,ea as Qn,Hn as Qr,zr as Qt,eo as R,Kt as Ri,_i as Rn,xr as Rr,va as Rt,fo as S,On as Si,ma as Sn,rr as Sr,ei as St,bo as T,dn as Ti,la as Tn,ir as Tr,Ji as Tt,Za as U,Jt as Ui,Xr as Un,Yn as Ur,Vi as Ut,go as V,Gt as Vi,Zr as Vn,Zn as Vr,Wi as Vt,Qa as W,Qt as Wi,ti as Wn,Mn as Wr,mi as Wt,Ka as X,Wt as Xi,Or as Xn,Bn as Xr,ba as Xt,Ga as Y,Ht as Yi,Dr as Yn,Gn as Yr,ui as Yt,Ba as Z,Rt as Zi,ta as Zn,Vn as Zr,xa as Zt,H as _,b as _a,Tn as _i,Ai as _n,pr as _r,ii as _t,_c as a,N as aa,Dn as ai,bi as an,Vr as ar,Jr as at,io as b,Kn as bi,Lr as bn,vr as br,Fa as bt,oc as c,kt as ca,bn as ci,sa as cn,Na as cr,Xi as ct,tc as d,M as da,Ln as di,Si as dn,$i as dr,fi as dt,It as ea,cn as ei,Nr as en,ri as er,Ha as et,$s as f,Dt as fa,mn as fi,wi as fn,Tr as fr,ga as ft,es as g,k as ga,wn as gi,ji as gn,gr,$r as gt,$o as h,A as ha,_n as hi,ki as hn,hr,pa as ht,Cc as i,Nt as ia,En as ii,Da as in,ka as ir,Ur as it,mo as j,en as ji,Wr as jn,cr as jr,si as jt,co as k,Cn as ki,Ia as kn,Qn as kr,vi as kt,ec as l,j as la,xn as li,Mi as ln,Pr as lr,Zi as lt,fs as m,Tt as ma,gn as mi,Ii as mn,I as mr,fa as mt,Dc as n,F as na,fn as ni,Gi as nn,aa as nr,Aa as nt,gc as o,jt as oa,Rn as oi,xi as on,Hr as or,wa as ot,ms as p,Et as pa,hn as pi,Fi as pn,Mr as pr,_a as pt,Ja as q,Xt as qi,Sa as qn,jn as qr,zi as qt,wc as r,Pt as ra,pn as ri,Ea as rn,Oa as rr,ja as rt,pc as s,At as sa,zn as si,oa as sn,Ma as sr,Ta as st,Ec as t,Ft as ta,ln as ti,Ni as tn,ia as tr,Va as tt,nc as u,Ot as ua,In as ui,Pi as un,Qi as ur,di as ut,B as v,p as va,vn as vi,Di as vn,mr as vr,ai as vt,yo as w,un as wi,ca as wn,fr as wr,pi as wt,ao as x,qn as xi,Rr as xn,nr as xr,La as xt,R as y,n as ya,yn as yi,Oi as yn,_r as yr,oi as yt,ro as z,Zt as zi,ua as zn,Sr as zr,ya as zt};