spacewave 0.57.16 → 0.57.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD_PARTY_NOTICES.txt +3 -3
- package/dist/build.json +1 -1
- package/dist/chunks/{json-CzK0YV3M.mjs → json-D4YdjcVu.mjs} +1 -1
- package/dist/chunks/{node.pb-C9x5fxb1.mjs → node.pb-BccNR73d.mjs} +1 -1
- package/dist/engine-worker.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/examples/task-board/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,2 +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){let t=[];for(let n of Object.keys(e)){let r=e[n];typeof r==`number`&&t.push({no:r,name:n})}return t}function b(e,t){let n=Object.create(null),r=Object.create(null),i=Oe(t)?ke(t):t,a=[];for(let e of i){let t=De(e)?{no:e[0],name:e[1],localName:e[1]}:`localName`in e?e:{...e,localName:e.name};a.push(t),n[t.name]=t,r[t.no]=t}return{typeName:e,values:a,findName(e){return n[e]},findNumber(e){return r[e]}}}function 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 Le(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 w;(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`})(w||={});var Re=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}},ze=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 w.Varint:for(;this.buf[this.pos++]&128;);break;case w.Bit64:this.pos+=4;case w.Bit32:this.pos+=4;break;case w.LengthDelimited:let t=this.uint32();this.pos+=t;break;case w.StartGroup:let n;for(;(n=this.tag()[1])!==w.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 Be={readUnknownFields:!0,readerFactory:e=>new ze(e)},Ve={writeUnknownFields:!0,writerFactory:()=>new Re};function He(e){return e?{...Be,...e}:Be}function Ue(e){return e?{...Ve,...e}:Ve}function We(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=Ke,c=n.kind==`scalar`&&n.utf8;if(n.kind==`scalar`&&n.L>0&&(s=qe),a){let n=e[o];if(Array.isArray(n)||(n=e[o]=[]),r==w.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(Le(s.fieldWrapper,Je(t,x(),s.fields,i,n)))}else e[o]=Le(s.fieldWrapper,Je(t,x(),s.fields,i,n));break}case`map`:{let[r,a]=Ge(n,t,i);typeof e[o]!=`object`&&(e[o]=S()),e[o][r]=a;break}}}function Ge(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=Ke(t,e.K,e.keyUtf8);break;case 2:switch(e.V.kind){case`scalar`:o=Ke(t,e.V.T,e.V.utf8===!0);break;case`enum`:o=t.int32();break;case`message`:o=Je(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 Ke(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 qe(e,t,n=!1){let r=Ke(e,t,n);return typeof r==`bigint`?r.toString():r}function Je(e,t,n,r,i){return Ye(t,n,e,i?.delimited?i.no:e.uint32(),r,i?.delimited??!1),t}function Ye(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!=w.EndGroup);){let r=t.find(s);if(!r){let t=n.skip(c);i.readUnknownFields&&Fe(e,s,c,t);continue}We(e,n,r,c,i)}if(a&&(c!=w.EndGroup||s!==r))throw Error(`invalid end group tag`)}function Xe(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&&Ze(i,a,n,r)}r.writeUnknownFields&&Qe(e,n)}function Ze(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)et(n,i,e.no,t);else for(let r of t)T(n,i,e.no,r)}else T(n,i,e.no,t);break}case`message`:if(a){r(Array.isArray(t));for(let r of t)$e(n,i,e,r)}else $e(n,i,e,t);break;case`map`:r(typeof t==`object`&&!!t);for(let[r,a]of Object.entries(t))nt(n,i,e,r,a)}}function Qe(e,t){let n=e[Pe];if(n)for(let e of n)t.tag(e.no,e.wireType).raw(e.data)}function $e(e,t,n,r){let i=y(n.T),a=Ie(i.fieldWrapper,r);n.delimited?e.tag(n.no,w.StartGroup).raw(i.toBinary(a,t)).tag(n.no,w.EndGroup):e.tag(n.no,w.LengthDelimited).bytes(i.toBinary(a,t))}function T(e,t,n,i){r(i!==void 0);let[a,o]=tt(t);e.tag(n,a)[o](i)}function et(e,t,n,r){if(!r.length)return;e.tag(n,w.LengthDelimited).fork();let[,i]=tt(t);for(let t=0;t<r.length;t++)e[i](r[t]);e.join()}function tt(e){let t=w.Varint;switch(e){case p.BYTES:case p.STRING:t=w.LengthDelimited;break;case p.DOUBLE:case p.FIXED64:case p.SFIXED64:t=w.Bit64;break;case p.FIXED32:case p.SFIXED32:case p.FLOAT:t=w.Bit32}let n=p[e].toLowerCase();return[t,n]}function nt(e,t,n,i,a){e.tag(n.no,w.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(T(e,n.K,1,o),n.V.kind){case`scalar`:T(e,n.V.T,2,a);break;case`enum`:T(e,p.INT32,2,a);break;case`message`:{r(a!==void 0);let i=y(n.V.T);e.tag(2,w.LengthDelimited).bytes(i.toBinary(a,t));break}}e.join()}let E=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),rt=[];for(let e=0;e<E.length;e++)rt[E[e].charCodeAt(0)]=e;rt[45]=E.indexOf(`+`),rt[95]=E.indexOf(`/`);const it={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=rt[e.charCodeAt(t)],a===void 0)switch(e[t]){case`=`:i=0;case`
|
|
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 Le(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 w;(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`})(w||={});var Re=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}},ze=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 w.Varint:for(;this.buf[this.pos++]&128;);break;case w.Bit64:this.pos+=4;case w.Bit32:this.pos+=4;break;case w.LengthDelimited:let t=this.uint32();this.pos+=t;break;case w.StartGroup:let n;for(;(n=this.tag()[1])!==w.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 Be={readUnknownFields:!0,readerFactory:e=>new ze(e)},Ve={writeUnknownFields:!0,writerFactory:()=>new Re};function He(e){return e?{...Be,...e}:Be}function Ue(e){return e?{...Ve,...e}:Ve}function We(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=Ke,c=n.kind==`scalar`&&n.utf8;if(n.kind==`scalar`&&n.L>0&&(s=qe),a){let n=e[o];if(Array.isArray(n)||(n=e[o]=[]),r==w.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(Le(s.fieldWrapper,Je(t,x(),s.fields,i,n)))}else e[o]=Le(s.fieldWrapper,Je(t,x(),s.fields,i,n));break}case`map`:{let[r,a]=Ge(n,t,i);typeof e[o]!=`object`&&(e[o]=S()),e[o][r]=a;break}}}function Ge(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=Ke(t,e.K,e.keyUtf8);break;case 2:switch(e.V.kind){case`scalar`:o=Ke(t,e.V.T,e.V.utf8===!0);break;case`enum`:o=t.int32();break;case`message`:o=Je(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 Ke(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 qe(e,t,n=!1){let r=Ke(e,t,n);return typeof r==`bigint`?r.toString():r}function Je(e,t,n,r,i){return Ye(t,n,e,i?.delimited?i.no:e.uint32(),r,i?.delimited??!1),t}function Ye(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!=w.EndGroup);){let r=t.find(s);if(!r){let t=n.skip(c);i.readUnknownFields&&Fe(e,s,c,t);continue}We(e,n,r,c,i)}if(a&&(c!=w.EndGroup||s!==r))throw Error(`invalid end group tag`)}function Xe(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&&Ze(i,a,n,r)}r.writeUnknownFields&&Qe(e,n)}function Ze(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)et(n,i,e.no,t);else for(let r of t)T(n,i,e.no,r)}else T(n,i,e.no,t);break}case`message`:if(a){r(Array.isArray(t));for(let r of t)$e(n,i,e,r)}else $e(n,i,e,t);break;case`map`:r(typeof t==`object`&&!!t);for(let[r,a]of Object.entries(t))nt(n,i,e,r,a)}}function Qe(e,t){let n=e[Pe];if(n)for(let e of n)t.tag(e.no,e.wireType).raw(e.data)}function $e(e,t,n,r){let i=y(n.T),a=Ie(i.fieldWrapper,r);n.delimited?e.tag(n.no,w.StartGroup).raw(i.toBinary(a,t)).tag(n.no,w.EndGroup):e.tag(n.no,w.LengthDelimited).bytes(i.toBinary(a,t))}function T(e,t,n,i){r(i!==void 0);let[a,o]=tt(t);e.tag(n,a)[o](i)}function et(e,t,n,r){if(!r.length)return;e.tag(n,w.LengthDelimited).fork();let[,i]=tt(t);for(let t=0;t<r.length;t++)e[i](r[t]);e.join()}function tt(e){let t=w.Varint;switch(e){case p.BYTES:case p.STRING:t=w.LengthDelimited;break;case p.DOUBLE:case p.FIXED64:case p.SFIXED64:t=w.Bit64;break;case p.FIXED32:case p.SFIXED32:case p.FLOAT:t=w.Bit32}let n=p[e].toLowerCase();return[t,n]}function nt(e,t,n,i,a){e.tag(n.no,w.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(T(e,n.K,1,o),n.V.kind){case`scalar`:T(e,n.V.T,2,a);break;case`enum`:T(e,p.INT32,2,a);break;case`message`:{r(a!==void 0);let i=y(n.V.T);e.tag(2,w.LengthDelimited).bytes(i.toBinary(a,t));break}}e.join()}let E=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),rt=[];for(let e=0;e<E.length;e++)rt[E[e].charCodeAt(0)]=e;rt[45]=E.indexOf(`+`),rt[95]=E.indexOf(`/`);const it={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=rt[e.charCodeAt(t)],a===void 0)switch(e[t]){case`=`:i=0;case`
|
|
2
2
|
`:case`\r`:case` `:case` `:continue;default:throw Error(`invalid base64 string.`)}switch(i){case 0:o=a,i=1;break;case 1:n[r++]=o<<2|(a&48)>>4,o=a,i=2;break;case 2:n[r++]=(o&15)<<4|(a&60)>>2,o=a,i=3;break;case 3:n[r++]=(o&3)<<6|a,i=0}}if(i==1)throw Error(`invalid base64 string.`);return n.subarray(0,r)},enc(e){let t=``,n=0,r,i=0;for(let a=0;a<e.length;a++)switch(r=e[a],n){case 0:t+=E[r>>2],i=(r&3)<<4,n=1;break;case 1:t+=E[i|r>>4],i=(r&15)<<2,n=2;break;case 2:t+=E[i|r>>6],t+=E[r&63],n=0}return n&&(t+=E[i],t+=`=`,n==1&&(t+=`=`)),t}},at={ignoreUnknownFields:!1},ot={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function st(e){return e?{...at,...e}:at}function ct(e){return e?{...ot,...e}:ot}function D(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 lt(e,t,n,r,i){if(n==null||Array.isArray(n)||typeof n!=`object`)throw Error(`cannot decode message ${t} from JSON: ${D(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)}dt(i,s,n,r)}else if(!r.ignoreUnknownFields)throw Error(`cannot decode message ${t} from JSON: key "${o}" is unknown`)}return i}function ut(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 dt(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: ${D(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: ${D(e)}`);switch(n.kind){case`message`:{let t=y(n.T);o.push(Le(t.fieldWrapper,t.fromJson(e,i)));break}case`enum`:{let t=mt(n.T,e,i.ignoreUnknownFields,!0);t!==pt&&o.push(t);break}case`scalar`:try{o.push(O(n.T,e,n.L,!0))}catch(t){let r=`cannot decode field ${n.name} from JSON: ${D(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: ${D(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: ${D(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=mt(n.V.T,a,i.ignoreUnknownFields,!0);e!==pt&&(r[o]=e);break}case`scalar`:try{r[o]=O(n.V.T,a,m.BIGINT,!0)}catch(e){let r=`cannot decode map value for field ${n.name} from JSON: ${D(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]=Le(r.fieldWrapper,r.fromJson(t,i));break}case`enum`:{let r=mt(n.T,t,i.ignoreUnknownFields,!1);switch(r){case ft:gt(n,e);break;case pt:break;default:e[a]=r}break}case`scalar`:try{let r=O(n.T,t,n.L,!1);switch(r){case ft:gt(n,e);break;default:e[a]=r}}catch(e){let r=`cannot decode field ${n.name} from JSON: ${D(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r,{cause:e})}}}const ft=Symbol(),pt=Symbol();function mt(e,t,n,r){if(t===null)return e.typeName==`google.protobuf.NullValue`?0:r?e.values[0].no:ft;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 pt;break}}throw Error(`cannot decode enum ${e.typeName} from JSON: ${D(t)}`)}function O(e,t,n=m.BIGINT,r=!0){if(t==null)return r?g(e,n):ft;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 it.dec(t)}throw Error()}function ht(e,t){if(e===p.BOOL)switch(t){case`true`:t=!0;break;case`false`:t=!1}return O(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),it.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=He(t);Ye(n,o,r.readerFactory(e),e.byteLength,r,i??!1)}return n},fromJson(e,t){let n={};if(e!=null){let i=st(t);lt(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=Ue(t),r=n.writerFactory();return Xe(e,o,r,n),r.finish()},toJson(e,t){let n=ct(t);return ut(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}({})),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}]}),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)},{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}({})),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}({}));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),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.NewTransactionRequest`,fields:[{no:1,name:`write`,kind:`scalar`,T:p.BOOL}]}),Ir=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}]}),Lr=A(`s4wave.world.GetSeqnoRequest`,!0),Rr=k({typeName:`s4wave.world.GetSeqnoResponse`,fields:[{no:1,name:`seqno`,kind:`scalar`,T:p.UINT64}]}),zr=k({typeName:`s4wave.world.WaitSeqnoRequest`,fields:[{no:1,name:`seqno`,kind:`scalar`,T:p.UINT64}]}),Br=k({typeName:`s4wave.world.WaitSeqnoResponse`,fields:[{no:1,name:`seqno`,kind:`scalar`,T:p.UINT64}]}),Vr=k({typeName:`s4wave.world.AccessWorldStateRequest`,fields:[{no:1,name:`ref`,kind:`message`,T:()=>F}]}),Hr=k({typeName:`s4wave.world.OpenNestedWorldRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Ur=k({typeName:`s4wave.world.OpenNestedWorldResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Wr=A(`s4wave.world.OpenOuterWorldRequest`,!0),Gr=k({typeName:`s4wave.world.OpenOuterWorldResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Kr=k({typeName:`s4wave.world.AccessWorldStateResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),qr=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}]}),Jr=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}]}),Yr=k({typeName:`s4wave.world.SetGraphQuadRequest`,fields:[{no:1,name:`quad`,kind:`message`,T:()=>I}]}),Xr=k({typeName:`s4wave.world.TransactionMutation`,fields:[{no:1,name:`create_object`,kind:`message`,T:qr,oneof:`mutation`},{no:2,name:`set_object_root`,kind:`message`,T:Jr,oneof:`mutation`},{no:3,name:`set_graph_quad`,kind:`message`,T:Yr,oneof:`mutation`}]}),Zr=k({typeName:`s4wave.world.CommitMutationsRequest`,fields:[{no:1,name:`mutations`,kind:`message`,T:Xr,repeated:!0}]}),Qr=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}]}),$r=k({typeName:`s4wave.world.SetObjectRootMutationResult`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),ei=A(`s4wave.world.SetGraphQuadResponse`,!0),ti=k({typeName:`s4wave.world.TransactionMutationResult`,fields:[{no:1,name:`create_object`,kind:`message`,T:Qr,oneof:`result`},{no:2,name:`set_object_root`,kind:`message`,T:$r,oneof:`result`},{no:3,name:`set_graph_quad`,kind:`message`,T:ei,oneof:`result`}]}),ni=k({typeName:`s4wave.world.CommitMutationsResponse`,fields:[{no:1,name:`results`,kind:`message`,T:ti,repeated:!0}]}),ri=A(`s4wave.world.CommitRequest`,!0),ii=A(`s4wave.world.CommitResponse`,!0),ai=A(`s4wave.world.DiscardRequest`,!0),oi=A(`s4wave.world.DiscardResponse`,!0),si=A(`s4wave.world.GetReadOnlyRequest`,!0),ci=k({typeName:`s4wave.world.GetReadOnlyResponse`,fields:[{no:1,name:`read_only`,kind:`scalar`,T:p.BOOL}]}),li=A(`s4wave.world.BuildStorageCursorRequest`,!0),ui=k({typeName:`s4wave.world.BuildStorageCursorResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),di=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}]}),fi=k({typeName:`s4wave.world.GetObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),pi=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}]}),mi=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}]}),hi=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}]}),gi=k({typeName:`s4wave.world.DeleteObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),_i=k({typeName:`s4wave.world.DeleteObjectResponse`,fields:[{no:1,name:`deleted`,kind:`scalar`,T:p.BOOL}]}),vi=k({typeName:`s4wave.world.IterateObjectsRequest`,fields:[{no:1,name:`prefix`,kind:`scalar`,T:p.STRING},{no:2,name:`reversed`,kind:`scalar`,T:p.BOOL}]}),yi=k({typeName:`s4wave.world.IterateObjectsResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),bi=k({typeName:`s4wave.world.DeleteGraphQuadRequest`,fields:[{no:1,name:`quad`,kind:`message`,T:()=>I}]}),xi=A(`s4wave.world.DeleteGraphQuadResponse`,!0),Si=k({typeName:`s4wave.world.LookupGraphQuadsRequest`,fields:[{no:1,name:`filter`,kind:`message`,T:()=>I},{no:2,name:`limit`,kind:`scalar`,T:p.UINT32}]}),Ci=k({typeName:`s4wave.world.LookupGraphQuadsResponse`,fields:[{no:1,name:`quads`,kind:`message`,T:()=>I,repeated:!0}]}),wi=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}]}),Ti=k({typeName:`s4wave.world.LookupGraphQuadsBatchResult`,fields:[{no:1,name:`quads`,kind:`message`,T:()=>I,repeated:!0}]}),Ei=k({typeName:`s4wave.world.LookupGraphQuadsBatchResponse`,fields:[{no:1,name:`results`,kind:`message`,T:Ti,repeated:!0}]}),Di=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}]}),Oi=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}]}),ki=k({typeName:`s4wave.world.ListGraphEdgeBucketsResponse`,fields:[{no:1,name:`buckets`,kind:`message`,T:Oi,repeated:!0}]}),Ai=k({typeName:`s4wave.world.ListObjectsWithTypeRequest`,fields:[{no:1,name:`type_id`,kind:`scalar`,T:p.STRING}]}),ji=k({typeName:`s4wave.world.ListObjectsWithTypeResponse`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Mi=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}]}),Ni=k({typeName:`s4wave.world.GetObjectRootRefsBatchRequest`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Pi=k({typeName:`s4wave.world.GetObjectRootRefsBatchResponse`,fields:[{no:1,name:`root_refs`,kind:`message`,T:Mi,repeated:!0}]}),Fi=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}]}),Ii=k({typeName:`s4wave.world.GetObjectMetadataBatchRequest`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Li=k({typeName:`s4wave.world.GetObjectMetadataBatchResponse`,fields:[{no:1,name:`metadata`,kind:`message`,T:Fi,repeated:!0}]}),Ri=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}]}),zi=k({typeName:`s4wave.world.GetObjectBodiesBatchRequest`,fields:[{no:1,name:`object_keys`,kind:`scalar`,T:p.STRING,repeated:!0}]}),Bi=k({typeName:`s4wave.world.GetObjectBodiesBatchResponse`,fields:[{no:1,name:`bodies`,kind:`message`,T:Ri,repeated:!0},{no:2,name:`world_seqno`,kind:`scalar`,T:p.UINT64}]}),Vi=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}]}),Hi=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:Vi,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}]}),Ui=k({typeName:`s4wave.world.QueryGraphPathResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Wi=k({typeName:`s4wave.world.DeleteGraphObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Gi=A(`s4wave.world.DeleteGraphObjectResponse`,!0),Ki=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}]}),qi=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}]}),Ji=A(`s4wave.world.WatchWorldStateRequest`,!0),Yi=k({typeName:`s4wave.world.WatchWorldStateResponse`,fields:[{no:1,name:`resource_id`,kind:`scalar`,T:p.UINT32}]}),Xi=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}]}),Zi=k({typeName:`s4wave.world.TrackedWorldStateSnapshot`,fields:[{no:1,name:`object_accesses`,kind:`message`,T:Xi,repeated:!0},{no:2,name:`has_quad_access`,kind:`scalar`,T:p.BOOL},{no:3,name:`initial_seqno`,kind:`scalar`,T:p.UINT64}]}),Qi=A(`s4wave.world.ErrRequest`,!0),$i=k({typeName:`s4wave.world.ErrResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING}]}),ea=A(`s4wave.world.ValidRequest`,!0),ta=k({typeName:`s4wave.world.ValidResponse`,fields:[{no:1,name:`valid`,kind:`scalar`,T:p.BOOL}]}),na=A(`s4wave.world.KeyRequest`,!0),ra=k({typeName:`s4wave.world.KeyResponse`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),ia=A(`s4wave.world.NextRequest`,!0),aa=k({typeName:`s4wave.world.NextResponse`,fields:[{no:1,name:`valid`,kind:`scalar`,T:p.BOOL}]}),oa=k({typeName:`s4wave.world.SeekRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),sa=A(`s4wave.world.SeekResponse`,!0),ca=A(`s4wave.world.CloseRequest`,!0),la=A(`s4wave.world.CloseResponse`,!0),ua=A(`s4wave.world.NextGraphPathQueryRequest`,!0),da=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}]}),fa=A(`s4wave.world.CloseGraphPathQueryRequest`,!0),pa=A(`s4wave.world.CloseGraphPathQueryResponse`,!0),ma=A(`s4wave.world.GetKeyRequest`,!0),ha=k({typeName:`s4wave.world.GetKeyResponse`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),ga=A(`s4wave.world.GetRootRefRequest`,!0),_a=k({typeName:`s4wave.world.GetRootRefResponse`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>F},{no:2,name:`rev`,kind:`scalar`,T:p.UINT64}]}),va=k({typeName:`s4wave.world.SetRootRefRequest`,fields:[{no:1,name:`root_ref`,kind:`message`,T:()=>F}]}),ya=k({typeName:`s4wave.world.SetRootRefResponse`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),ba=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}]}),xa=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}]}),Sa=A(`s4wave.world.IncrementRevRequest`,!0),Ca=k({typeName:`s4wave.world.IncrementRevResponse`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),wa=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}]}),Ta=k({typeName:`s4wave.world.WaitRevResponse`,fields:[{no:1,name:`rev`,kind:`scalar`,T:p.UINT64}]}),Ea=k({typeName:`s4wave.world.AccessTypedObjectRequest`,fields:[{no:1,name:`object_key`,kind:`scalar`,T:p.STRING}]}),Da=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}]}),Oa=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}]}),ka=k({typeName:`s4wave.world.CompareObjectRecordsRequest`,fields:[{no:1,name:`bases`,kind:`message`,T:Oa,repeated:!0}]}),Aa=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}]}),ja=k({typeName:`s4wave.world.CompareObjectRecordsResponse`,fields:[{no:1,name:`changes`,kind:`message`,T:Aa,repeated:!0}]}),Ma=b(`blob.BlobType`,function(e){return e[e.BlobType_RAW=0]=`BlobType_RAW`,e[e.BlobType_CHUNKED=1]=`BlobType_CHUNKED`,e}({})),Na=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}({})),Pa=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}]}),Fa=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}]}),Ia=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}]}),La=k({typeName:`blob.ChunkerArgs`,fields:[{no:1,name:`chunker_type`,kind:`enum`,T:Na},{no:2,name:`rabin_args`,kind:`message`,T:Fa},{no:3,name:`jc_args`,kind:`message`,T:Ia}]}),Ra=k({typeName:`blob.ChunkIndex`,fields:[{no:1,name:`chunks`,kind:`message`,T:Pa,repeated:!0},{no:2,name:`chunker_args`,kind:`message`,T:La}]}),za=k({typeName:`blob.Blob`,fields:[{no:1,name:`blob_type`,kind:`enum`,T:Ma},{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:Ra}]}),Ba=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:La}]}),Va=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:()=>za},{no:5,name:`left_child_ref`,kind:`message`,T:()=>j},{no:6,name:`right_child_ref`,kind:`message`,T:()=>j}]}),Ha=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}]}),Ua=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:()=>za}]}),Wa=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:Ua,repeated:!0}]});let Ga=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 Ka=k({typeName:`kvtx.block.KeyValueStore`,fields:[{no:1,name:`impl_type`,kind:`enum`,T:b(`kvtx.block.KVImplType`,Ga)},{no:2,name:`iavl_root`,kind:`message`,T:()=>Va},{no:3,name:`okra_root`,kind:`message`,T:()=>Ha}]}),L=b(`kvtx.rpc.KvtxRetryClass`,function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.INVALID_SNAPSHOT=1]=`INVALID_SNAPSHOT`,e}({})),qa=k({typeName:`kvtx.rpc.KvtxTransactionInit`,fields:[{no:1,name:`write`,kind:`scalar`,T:p.BOOL}]}),Ja=k({typeName:`kvtx.rpc.KvtxTransactionRequest`,fields:[{no:1,name:`init`,kind:`message`,T:qa,oneof:`body`},{no:2,name:`commit`,kind:`scalar`,T:p.BOOL,oneof:`body`},{no:3,name:`discard`,kind:`scalar`,T:p.BOOL,oneof:`body`}]}),Ya=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}]}),Xa=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}]}),Za=k({typeName:`kvtx.rpc.KvtxTransactionResponse`,fields:[{no:1,name:`ack`,kind:`message`,T:Ya,oneof:`body`},{no:2,name:`complete`,kind:`message`,T:Xa,oneof:`body`}]}),Qa=k({typeName:`kvtx.rpc.KeyCountRequest`,fields:[{no:1,name:`accept_retry_class`,kind:`scalar`,T:p.BOOL}]}),$a=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}]}),eo=k({typeName:`kvtx.rpc.KvtxKeyRequest`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES}]}),to=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}]}),no=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}]}),ro=k({typeName:`kvtx.rpc.KvtxSetKeyRequest`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES},{no:2,name:`value`,kind:`scalar`,T:p.BYTES}]}),io=k({typeName:`kvtx.rpc.KvtxSetKeyResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`retry_class`,kind:`enum`,T:L}]}),ao=k({typeName:`kvtx.rpc.KvtxDeleteKeyRequest`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES}]}),oo=k({typeName:`kvtx.rpc.KvtxDeleteKeyResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`retry_class`,kind:`enum`,T:L}]}),so=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}]}),co=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}]}),lo=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}]}),uo=k({typeName:`kvtx.rpc.KvtxWatchEntry`,fields:[{no:1,name:`key`,kind:`scalar`,T:p.BYTES},{no:2,name:`value`,kind:`scalar`,T:p.BYTES}]}),fo=k({typeName:`kvtx.rpc.KvtxWatchResponse`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING},{no:2,name:`entries`,kind:`message`,T:uo,repeated:!0},{no:3,name:`limit_exceeded`,kind:`scalar`,T:p.BOOL}]}),po=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}]}),mo=k({typeName:`kvtx.rpc.KvtxIterateRequest`,fields:[{no:1,name:`init`,kind:`message`,T:po,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`}]}),ho=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}]}),go=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:ho,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 _o=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 vo=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}},yo=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new vo(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 vo(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()}},bo=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 xo(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 xo(e,t){t??={};let n=t.onEnd,r=new yo,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 yo,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 yo,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 bo)},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 So=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 So(n?.errorMessage,n?.errorCode,n?.errorName));let r,i=new So(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 Co=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 wo(){return new Co}function To(e){return e[Symbol.asyncIterator]!=null}async function Eo(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*Do(e){let t=new AbortController,n=wo();Eo(e,n,t.signal).catch(()=>{});try{yield*n}finally{t.abort()}}function*Oo(e){for(let t of e)yield*t}function ko(...e){let t=[];for(let n of e)To(n)||t.push(n);return t.length===e.length?Oo(t):Do(e)}function H(e,...t){if(e==null)throw Error(`Empty pipeline`);if(No(e)){let t=e;e=()=>t.source}else if(Mo(e)||jo(e)){let t=e;e=()=>t}let n=[e,...t];if(n.length>1&&No(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++)No(n[e])&&(n[e]=Po(n[e]));return Ao(...n)}const Ao=(...e)=>{let t;for(;e.length>0;)t=e.shift()(t);return t},jo=e=>e?.[Symbol.asyncIterator]!=null,Mo=e=>e?.[Symbol.iterator]!=null,No=e=>e!=null&&e.sink!=null&&e.source!=null,Po=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(jo(i))r=async function*(){yield*i,t.end()};else if(Mo(i))r=function*(){yield*i,t.end()};else throw Error(`Unknown duplex source type - must be Iterable or AsyncIterable`);return ko(t,r())}return e.source},Fo=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}),Io=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}),Lo=k({typeName:`srpc.Packet`,fields:[{no:1,name:`call_start`,kind:`message`,T:()=>Fo,oneof:`body`},{no:2,name:`call_data`,kind:`message`,T:()=>Io,oneof:`body`},{no:3,name:`call_cancel`,kind:`scalar`,T:p.BOOL,oneof:`body`}],packedByDefault:!0});var Ro=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(Lo.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 _o(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)}}}},zo=class extends Ro{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 Bo(e,t){try{for await(let n of e)t.push(n);t.end()}catch(e){t.end(e)}}function Vo(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 Vo(t.alloc(e))}function Ho(e=0){return Vo(t.allocUnsafe(e))}function Uo(e,n){return Vo(t.concat(e,n))}function Wo(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 Go=Symbol.for(`@achingbrain/uint8arraylist`);function Ko(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?.[Go]}var G=class e{bufs;length;[Go]=!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=Ko(this.bufs,e);return t.buf[t.index]}set(e,t){let n=Ko(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 Uo(n,r)}subarray(e,t){let{bufs:n,length:r}=this._subList(e,t);return n.length===1?n[0]:Uo(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=Ho(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=Ho(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(!Wo(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 qo(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 Jo(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 Yo=1e7,Xo=qo(Lo),Zo=Jo(Lo),Qo=e=>{if(e.length<4)throw RangeError(`Could not decode int32BE`);return e.getUint32(0,!0)};Qo.bytes=4;const $o=e=>{let t=new G(new Uint8Array(4));return t.setUint32(0,e,!0),t};$o.bytes=4;async function*es(e,t){for await(let n of e){let e=n instanceof Uint8Array?n.length:n.byteLength;if(e===0||e>Yo)throw RangeError(`invalid packet length: ${e}`);yield new G(t(e),n)}}async function*ts(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>Yo)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 ns(e=$o){return t=>es(t,e)}function rs(e=Qo){return t=>ts(t,e)}var is=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)}}},as=class extends is{constructor(e){super(e)}get openStreamFunc(){return async()=>{let e=this.value;return e||=await this.wait(),e()}}},os=class{openStreamCtr;constructor(e){this.openStreamCtr=new as(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=>Bo(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 zo(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,Xo,a,Zo,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}},ss=class extends Ro{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)}}}},cs=class{lookupMethod;constructor(e){this.lookupMethod=e}get rpcStreamHandler(){return async e=>ls(e,this.startRpc())}startRpc(){return new ss(this.lookupMethod)}handlePacketStream(e){let t=this.startRpc();return ls(e,t).catch(()=>void 0),t}};async function ls(e,t){try{if(await H(e,Xo,t,Zo,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 us(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 ds=(e,...t)=>{try{[...t]}catch{}};var K=class extends Error{static name=`InvalidFrameError`;constructor(e=`The frame was invalid`){super(e),this.name=`InvalidFrameError`}},fs=class extends Error{static name=`UnrequestedPingError`;constructor(e=`Unrequested ping error`){super(e),this.name=`UnrequestedPingError`}},ps=class extends Error{static name=`NotMatchingPingError`;constructor(e=`Unrequested ping error`){super(e),this.name=`NotMatchingPingError`}},ms=class extends Error{static name=`InvalidStateError`;constructor(e=`Invalid state`){super(e),this.name=`InvalidStateError`}},hs=class extends Error{static name=`StreamAlreadyExistsError`;constructor(e=`Strean already exists`){super(e),this.name=`StreamAlreadyExistsError`}},gs=class extends Error{static name=`DecodeInvalidVersionError`;constructor(e=`Decode invalid version`){super(e),this.name=`DecodeInvalidVersionError`}},_s=class extends Error{static name=`BothClientsError`;constructor(e=`Both clients`){super(e),this.name=`BothClientsError`}},vs=class extends Error{static name=`ReceiveWindowExceededError`;constructor(e=`Receive window exceeded`){super(e),this.name=`ReceiveWindowExceededError`}};const ys=new Set([K.name,fs.name,ps.name,hs.name,gs.name,_s.name,vs.name]),bs=262144,xs=Symbol.for(`@libp2p/service-capabilities`);var Ss=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`}},Cs=class extends Error{static name=`TooManyOutboundProtocolStreamsError`;constructor(e=`Too many outbound protocol streams`){super(e),this.name=`TooManyOutboundProtocolStreamsError`}};const ws={enableKeepAlive:!0,keepAliveInterval:3e4,maxInboundStreams:1e3,maxOutboundStreams:1e3,initialStreamWindowSize:bs,maxStreamWindowSize:16777216,maxMessageSize:65536};function Ts(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 Es=2**24;function Ds(e){if(e[0]!==0)throw new K(`Invalid frame version`);return{type:e[1],flag:(e[2]<<8)+e[3],streamID:e[4]*Es+(e[5]<<16)+(e[6]<<8)+e[7],length:e[8]*Es+(e[9]<<16)+(e[10]<<8)+e[11]}}var Os=class{source;buffer;frameInProgress;constructor(e){this.source=ks(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 ms(`decoding frame already in progress`);if(this.buffer.length<12)return;let e=Ds(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 ks(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 As(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 js=class extends Error{static name=`StreamResetError`;constructor(e=`The stream has been reset`){super(e),this.name=`StreamResetError`}},Ms=class extends Error{static name=`StreamStateError`;constructor(e=`The stream is in an invalid state`){super(e),this.name=`StreamStateError`}};function Ns(e){return e!=null&&typeof e.then==`function`&&typeof e.catch==`function`&&typeof e.finally==`function`}function Ps(e,t){let n=us(e).return?.();Ns(n)&&n.catch(e=>{t.error(`could not cause iterator to return`,e)})}function Fs(e){return e!=null&&typeof e.then==`function`&&typeof e.catch==`function`&&typeof e.finally==`function`}var Is=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 Ms(`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);Fs(e)&&await e}let n=()=>{Ps(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);Fs(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();Fs(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 js(`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 Ls(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 Rs(e){return e[Symbol.asyncIterator]!=null}function zs(e){return e?.then!=null}function Bs(e,t){let n=0;if(Rs(e))return(async function*(){for await(let r of e){let e=t(r,n++);zs(e)&&await e,yield r}})();let r=Ls(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++);zs(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 Vs=class extends Is{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=bs,this.recvWindow=this.config.initialStreamWindowSize,this.recvWindowCapacity=this.recvWindow,this.epochStart=Date.now(),this.getRTT=e.getRTT,this.sendFrame=e.sendFrame,this.source=Bs(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 Ss(`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 vs(`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 Hs=`/yamux/1.0.0`;var Us=class{protocol=Hs;_components;_init;constructor(e,t={}){this._components=e,this._init=t}[Symbol.toStringTag]=`@chainsafe/libp2p-yamux`;[xs]=[`@libp2p/stream-multiplexing`];createStreamMuxer(e){return new Ws(this._components,{...this._init,...e})}},Ws=class{protocol=Hs;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={...ws,...t},this.logger=e.logger,this.log=this.logger.forComponent(`libp2p:yamux`),Ts(this.config),this.closeController=new AbortController,ds(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=us(e);if(t.return!=null){let e=t.return();Gs(e)&&e.catch(e=>{this.log?.(`could not cause sink source to return`,e)})}},n,r;try{let r=new Os(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){ys.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 Cs(`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);ds(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 Vs({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 fs(`ping not requested`);if(this.activePing.id!==e)throw new ps(`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(As(e),t))}else this.source.push(As(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 Gs(e){return e!=null&&typeof e.then==`function`}function Ks(e={}){return t=>new Us(t,e)}function qs(){return async function*(e){for await(let t of e)W(t)?yield t.subarray():yield t}}var Js=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 Ys(e){if(Symbol.asyncIterator in e)return e[Symbol.asyncIterator]();let t=e[Symbol.iterator]();return{next:async()=>t.next()}}function Xs(e){e.return&&Promise.resolve(e.return()).catch(()=>void 0)}function Zs(e){let t=new Js;return{close:async()=>{t.terminate()&&await e.close()},abort:n=>{t.terminate(n)&&e.abort(n)},source:(async function*(){let n=H(e,rs(),qs())[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{Xs(n)}})(),sink:async n=>{let r=Ys(H(n,ns())),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{Xs(r)}}}}function Qs(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 $s(){return{forComponent:Qs}}var ec=class{_muxer;_server;constructor(e,t){e&&(this._server=e);let n=t?.muxerFactory??Ks({enableKeepAlive:!1,...t?.yamuxParams})({logger:t?.logger??$s()});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 os(this.openStream.bind(this))}async openStream(){return Zs(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(Zs(e))}close(e){e?this.muxer.abort(e):this.muxer.close()}},tc=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)})},nc=(e,t)=>(t??={},t.closeOnEnd=t.closeOnEnd!==!1,async n=>{for await(let t of n){try{await tc(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()})})}),rc=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})),ic=e((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=rc();e.EventIterator=t.EventIterator,e.default=t.EventIterator}))();function ac(e){return e instanceof ArrayBuffer||e?.constructor?.name===`ArrayBuffer`&&typeof e?.byteLength==`number`}var oc=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 ic.EventIterator(({push:t,stop:n,fail:r})=>{let i=e=>{let n=null;if(typeof e.data==`string`)throw Error(`Unsupported string encoding`);ac(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 ac(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})},sc=(e,t)=>{t??={};let n=oc(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:nc(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 cc(e,t){let n=qo(e.I);return async(r,i,a)=>{let o=B({objectMode:!0});H(o,Jo(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 Bo(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 lc=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 uc(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]=cc(n,i))}return new lc(n,r)}function dc(){return new fc}var fc=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 pc=k({typeName:`rpcstream.RpcStreamInit`,fields:[{no:1,name:`component_id`,kind:`scalar`,T:p.STRING}],packedByDefault:!0}),mc=k({typeName:`rpcstream.RpcAck`,fields:[{no:1,name:`error`,kind:`scalar`,T:p.STRING}],packedByDefault:!0}),hc=k({typeName:`rpcstream.RpcStreamPacket`,fields:[{no:1,name:`init`,kind:`message`,T:()=>pc,oneof:`body`},{no:2,name:`ack`,kind:`message`,T:()=>mc,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}),gc=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:hc,O:hc,kind:N.BiDiStreaming},DoNothing:{name:`DoNothing`,I:gc,O:gc,kind:N.Unary}}}).typeName;function _c(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 vc=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 yc=b(`core.sync.node.RuntimeMessage.Kind`,vc),bc=k({typeName:`core.sync.node.RuntimeInit`,fields:[{no:1,name:`directory`,kind:`scalar`,T:p.STRING}]}),xc=k({typeName:`core.sync.node.RuntimeMessage`,fields:[{no:1,name:`kind`,kind:`enum`,T:yc},{no:2,name:`error`,kind:`scalar`,T:p.STRING}]});export{La as $,N as $i,wa as $n,Dn as $r,Rr as $t,eo as A,nn as Ai,Ur as An,yr as Ar,_i as At,uo as B,Bt as Bi,ei as Bn,An as Br,zi as Bt,oo as C,Cn as Ci,aa as Cn,Qn as Cr,qr as Ct,ho as D,tn as Di,Aa as Dn,ur as Dr,bi as Dt,go as E,an as Ei,Oa as En,lr as Er,Gi as Et,Ya as F,Gt as Fi,mi as Fn,Zn as Fr,$i as Ft,Ua as G,Rt as Gi,Dr as Gn,Vn as Gr,pi as Gt,fo as H,Ut as Hi,$r as Hn,Wn as Hr,Ii as Ht,Xa as I,qt as Ii,hi as In,Jn as Ir,Ar as It,Va as J,It as Ji,Xi as Jn,cn as Jr,si as Jt,Wa as K,Lt as Ki,Or as Kn,Hn as Kr,Ni as Kt,qa as L,Jt as Li,oa as Ln,Yn as Lr,jr as Lt,co as M,Kt as Mi,Gr as Mn,xr as Mr,oi as Mt,ro as N,Zt as Ni,Hi as Nn,Sr as Nr,kr as Nt,to as O,on as Oi,Mi as On,or as Or,xi as Ot,io as P,Yt as Pi,Ui as Pn,Xn as Pr,Qi as Pt,Ra as Q,Nt as Qi,ta as Qn,En as Qr,Lr as Qt,Ja as R,Qt as Ri,sa as Rn,Mn as Rr,ma as Rt,ao as S,Sn as Si,ia as Sn,tr as Sr,Qr as St,mo as T,en as Ti,Fi as Tn,cr as Tr,Wi as Tt,Ga as U,Ht as Ui,va as Un,Gn as Ur,Li as Ut,lo as V,Xt as Vi,Jr as Vn,jn as Vr,Bi as Vt,Ka as W,Wt as Wi,ya as Wn,Bn as Wr,fi as Wt,Ba as X,F as Xi,ti as Xn,fn as Xr,ga as Xt,za as Y,Ft as Yi,Xr as Yn,ln as Yr,ci as Yt,Pa as Z,Pt as Zi,ea as Zn,pn as Zr,_a as Zt,H as _,kn as _i,Ci as _n,dr as _r,ni as _t,dc as a,M as aa,Ln as ai,vi as an,Yi as ar,Kr as at,Qa as b,Pn as bi,ua as bn,ar as br,ka as bt,ec as c,Tt as ca,gn as ci,ra as cn,I as cr,Ki as ct,Ys as d,b as da,Tn as di,Ai as dn,pr as dr,ui as dt,jt as ea,Rn as ei,Nr as en,Ta as er,Ia as et,qs as f,p as fa,vn as fi,ji as fn,mr as fr,fa as ft,Jo as g,On as gi,Si as gn,rr as gr,Zr as gt,qo as h,qn as hi,Ti as hn,nr as hr,la as ht,_c as i,Ot as ia,In as ii,Ca as in,Ji as ir,Vr as it,so as j,sn as ji,Wr as jn,br as jr,ai as jt,no as k,$t as ki,Hr as kn,sr as kr,gi as kt,Js as l,A as la,_n as li,Di as ln,hr as lr,qi as lt,os as m,Kn as mi,Ei as mn,vr as mr,ca as mt,xc as n,kt as na,bn as ni,Vi as nn,Br as nr,Ea as nt,uc as o,Dt as oa,mn as oi,yi as on,Tr as or,ba as ot,cs as p,n as pa,yn as pi,wi as pn,_r as pr,pa as pt,Ha as q,zt as qi,Zi as qn,Un as qr,Pi as qt,vc as r,j as ra,xn as ri,Sa as rn,Pr as rr,Da as rt,sc as s,Et as sa,hn as si,na as sn,Mr as sr,xa as st,bc as t,At as ta,zn as ti,Oi as tn,zr as tr,Fa as tt,Xs as u,k as ua,wn as ui,ki as un,gr as ur,li as ut,B as v,un as vi,Fr as vn,fr as vr,ri as vt,po as w,rn as wi,Ri as wn,$n as wr,di as wt,$a as x,Fn as xi,da as xn,er as xr,ja as xt,R as y,dn as yi,Ir as yn,ir as yr,ii as yt,Za as z,Vt as zi,Yr as zn,Nn as zr,ha as zt};
|
package/dist/engine-worker.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./chunks/rolldown-runtime-Csi-cuKc.mjs";import{$ as t,$i as n,$n as r,$r as i,$t as a,A as o,Ai as s,An as c,Ar as l,At as u,B as d,Bn as f,Br as p,Bt as ee,C as te,Ci as ne,Cn as re,Cr as ie,Ct as ae,D as oe,Di as se,Dn as ce,Dr as le,Dt as ue,E as de,Ei as fe,En as pe,Er as me,Et as he,F as ge,Fi as _e,Fn as ve,Fr as ye,Ft as be,G as xe,Gi as Se,Gn as Ce,Gr as we,Gt as Te,H as Ee,Hi as De,Hn as Oe,Hr as ke,Ht as Ae,I as je,Ii as Me,In as Ne,Ir as Pe,It as Fe,J as Ie,Ji as Le,Jn as Re,Jr as ze,Jt as Be,K as Ve,Ki as He,Kn as Ue,Kr as We,Kt as Ge,L as Ke,Li as qe,Ln as Je,Lr as Ye,Lt as Xe,M as Ze,Mi as Qe,Mn as $e,Mr as et,Mt as tt,N as nt,Ni as rt,Nn as it,Nr as at,Nt as ot,O as st,Oi as ct,On as lt,Or as ut,Ot as dt,P as ft,Pi as pt,Pn as mt,Pr as ht,Pt as gt,Q as _t,Qi as vt,Qn as yt,Qr as bt,Qt as xt,R as St,Ri as Ct,Rn as wt,Rr as Tt,Rt as Et,S as Dt,Si as Ot,Sn as kt,Sr as At,St as jt,T as Mt,Ti as Nt,Tn as Pt,Tr as Ft,Tt as It,Ui as Lt,Un as Rt,Ur as zt,Ut as Bt,V as Vt,Vi as Ht,Vn as Ut,Vr as Wt,Vt as Gt,W as Kt,Wi as qt,Wn as Jt,Wr as Yt,Wt as Xt,X as Zt,Xi as Qt,Xn as $t,Xr as en,Xt as tn,Y as nn,Yi as rn,Yn as an,Yr as on,Yt as sn,Z as cn,Zi as ln,Zn as un,Zr as dn,Zt as fn,_i as pn,_n as mn,_r as hn,_t as gn,a as _n,aa as vn,ai as yn,an as bn,ar as xn,at as Sn,b as Cn,bi as wn,bn as Tn,br as En,bt as Dn,ca as On,ci as kn,cn as An,cr as jn,ct as Mn,da as Nn,di as Pn,dn as Fn,dr as In,dt as Ln,ea as Rn,ei as zn,en as Bn,er as Vn,et as Hn,fa as Un,fi as Wn,fn as Gn,fr as Kn,ft as qn,gi as Jn,gn as Yn,gr as Xn,gt as Zn,hi as Qn,hn as $n,hr as er,ht as tr,i as nr,ia as rr,ii as ir,in as ar,ir as or,it as sr,j as cr,ji as lr,jn as ur,jr as dr,jt as fr,k as pr,ki as mr,kn as hr,kr as gr,kt as _r,la as vr,li as yr,ln as br,lr as xr,lt as Sr,mi as Cr,mn as wr,mr as Tr,mt as Er,n as Dr,na as Or,ni as kr,nn as Ar,nr as jr,nt as Mr,o as Nr,oa as Pr,oi as Fr,on as Ir,ot as Lr,p as Rr,pa as zr,pi as Br,pn as Vr,pr as Hr,pt as Ur,q as Wr,qi as Gr,qn as Kr,qr,qt as Jr,ra as Yr,ri as Xr,rn as Zr,rr as Qr,rt as $r,sa as ei,si as ti,sn as ni,sr as ri,st as ii,t as ai,ta as oi,ti as eee,tn as si,tr as ci,tt as li,ua as ui,ui as di,un as fi,ur as pi,ut as mi,vi as hi,vn as gi,vr as _i,vt as vi,w as yi,wi as tee,wn as bi,wr as xi,wt as Si,x as Ci,xi as wi,xn as Ti,xr as Ei,xt as Di,yi as Oi,yn as ki,yr as Ai,yt as ji,z as Mi,zi as Ni,zn as Pi,zr as Fi,zt as Ii}from"./chunks/node.pb-C9x5fxb1.mjs";import{isMainThread as nee,parentPort as Li,workerData as ree}from"node:worker_threads";import{mkdirSync as iee,realpathSync as aee,rmSync as oee}from"node:fs";import{DatabaseSync as see}from"node:sqlite";import{join as cee}from"node:path";var Ri=class extends Error{value;recovered=!1;constructor(e){let t=uee(e);super(typeof t==`string`?`panic: ${t}`:`panic:`),this.value=e,typeof t!=`string`&&Promise.resolve(t).then(e=>{this.message=`panic: ${e}`})}};const zi=[];let Bi=null;function Vi(e,t){let n=Bi;Bi=e instanceof Ri?e:null;try{return t()}finally{Bi=n}}var lee=class extends Error{constructor(e){super(e),this.name=`RuntimeError`}Error(){return this.message}};function Hi(...e){let t=new Ri(e.length===1?e[0]:e);throw zi.push(t),t}function Ui(e){let t=new Ri(new lee(e));throw zi.push(t),t}function Wi(e){return e instanceof Ri?e.value:e}function uee(e){return dee(e)?e:e instanceof Error?e.message:typeof e==`object`&&e&&`Error`in e&&typeof e.Error==`function`?e.Error():String(e)}function dee(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}function Gi(){let e=Bi;if(e===null||e.recovered)return null;e.recovered=!0;let t=zi.indexOf(e);return t!==-1&&zi.splice(t,1),e.value}function Ki(e){if(e instanceof Ri&&e.recovered){let t=zi.indexOf(e);return t!==-1&&zi.splice(t,1),!0}return!1}const fee=new WeakMap,pee=new WeakMap;let mee=1;function hee(e){let t=fee.get(e);return t===void 0&&(t=mee*4294967296,mee++,fee.set(e,t)),t}function gee(e,t){return{__goOwnedPointer:!0,__goAddress:t,__goRef:()=>e}}var _ee=class{value;__isVarRef=!0;pointer;constructor(e){this.value=e}get __goPointer(){return this.pointer??=gee(this,()=>hee(this))}get __goAddress(){return this.__goPointer.__goAddress}},vee=class{target;key;__isVarRef=!0;pointer;constructor(e,t){this.target=e,this.key=t}get value(){return this.target[this.key]}set value(e){this.target[this.key]=e}get __goPointer(){return this.pointer??=gee(this,()=>hee(this))}get __goAddress(){return this.__goPointer.__goAddress}};function m(e){return new _ee(e)}function h(e,t){for(let n of t)Object.defineProperty(e,n,{get(){return this._fields[n]},set(e){this._fields[n]=e},configurable:!0,enumerable:!1})}function qi(e,t){let n=pee.get(e);n===void 0&&(n=new globalThis.Map,pee.set(e,n));let r=n.get(t);if(r!==void 0)return r;let i=new vee(e,t);return n.set(t,i),i}function g(e){return typeof e==`object`&&!!e&&e.__isVarRef===!0}function Ji(e){return typeof e==`object`&&!!e&&e.__goOwnedPointer===!0}function yee(e){return e.__goPointer}function bee(e){return e.__goAddress()}function xee(e){return e.__goRef()}function See(e){return e===null&&Ui(`runtime error: invalid memory address or nil pointer dereference`),e.value}function Cee(e){return{get value(){throw Error(`unsafe pointer dereference is not supported in JavaScript/TypeScript`)},set value(e){throw Error(`unsafe pointer dereference is not supported in JavaScript/TypeScript`)},__isVarRef:!0}}let wee=function(e){return e.Basic=`basic`,e.Interface=`interface`,e.Struct=`struct`,e.Map=`map`,e.Slice=`slice`,e.Array=`array`,e.Pointer=`pointer`,e.Function=`function`,e.Channel=`channel`,e}({});function _(e,t=[],n=[]){return{name:e,args:Tee(t,`_p`),returns:Tee(n,`_r`)}}function Tee(e,t){return e.map((e,n)=>Array.isArray(e)?{name:e[0],type:e[1]}:{name:t+n,type:e})}function v(e,t,n,r,i,a){return{name:e,key:e,type:t,index:n,offset:r,exported:i,...a}}function y(e,t){let n={kind:`basic`,name:e};return t!==void 0&&(n.typeName=t),n}function b(e){return{kind:`pointer`,elemType:e}}function x(e,t){let n={kind:`slice`,elemType:e};return t!==void 0&&(n.typeName=t),n}function Yi(e,t){return{kind:`array`,elemType:e,length:t}}function Xi(e,t){return{kind:`map`,keyType:e,elemType:t}}function Zi(e,t){return{kind:`channel`,direction:t,elemType:e}}function Qi(e){return e.kind===`struct`}function $i(e){return e.kind===`interface`}function ea(e){return e.kind===`basic`}function ta(e){return e.kind===`map`}function na(e){return e.kind===`slice`}function ra(e){return e.kind===`array`}function ia(e){return e.kind===`pointer`}function Eee(e){return e.kind===`function`}function Dee(e){return e.kind===`channel`}function Oee(e){return typeof e==`object`&&!!e&&`type`in e&&`name`in e&&!(`kind`in e)}const aa=new Map,oa=new Map;function kee(e,t){let n=aa.get(e);if(n&&n!==t){let r=oa.get(e)??[n];r.includes(t)||r.push(t),oa.set(e,r)}aa.set(e,t)}const S=(e,t,n,r,i=[])=>{let a={name:e,kind:`struct`,zeroValue:t,get methods(){return typeof n==`function`&&(n=n()),n},set methods(e){n=e},ctor:r,get fields(){return typeof i==`function`&&(i=i()),i},set fields(e){i=e}};return kee(e,a),a};function Aee(e){return typeof e==`function`?e():e}const sa=(e,t,n)=>{let r={name:e,kind:`interface`,zeroValue:t,methods:n};return kee(e,r),r};sa(`error`,null,[{name:`Error`,args:[],returns:[{type:{kind:`basic`,name:`string`}}]}]);const ca=e=>aa.get(e);function la(e){return typeof e==`string`?aa.get(e)||{kind:`basic`,name:e}:e}function ua(e){let t=la(e);switch(t.kind){case`map`:case`slice`:case`function`:return!1;case`array`:return t.elemType===void 0||ua(t.elemType);case`struct`:return t.fields.every(e=>ua(e.type));default:return!0}}function da(e){return e.typeName||e.name}function jee(e,t){let n=da(t);return n!==void 0&&e===n||Ma(e,t)}function fa(){return{seenPairs:new Set,objectIDs:new WeakMap,nextObjectID:0}}function Mee(e,t,n){let r=da(t);if(r!==void 0)return`${t.kind}:${r}`;if(typeof e==`string`)return`string:${e}`;let i=n.objectIDs.get(e);if(i!==void 0)return`object:${i}`;let a=n.nextObjectID;return n.nextObjectID+=1,n.objectIDs.set(e,a),`object:${a}`}function pa(e,t,n){return e===void 0&&t===void 0?!0:e===void 0||t===void 0?!1:ha(e,t,n)}function Nee(e,t,n=fa()){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0||e.length!==t.length)return!1;for(let[r,i]of e.entries())if(!ha(i,t[r],n))return!1;return!0}function Pee(e,t,n=fa()){return(e.isVariadic||!1)===(t.isVariadic||!1)&&Nee(e.params,t.params,n)&&Nee(e.results,t.results,n)}function ma(e,t){return ha(e,t,fa())}function ha(e,t,n){let r=la(e),i=la(t);if(r===i)return!0;if(r.kind!==i.kind||(r.typeName??``)!==(i.typeName??``)||r.name!==i.name)return!1;if(r.name!==void 0&&(r.kind===`basic`||r.kind===`struct`||r.kind===`interface`))return!0;let a=`${Mee(e,r,n)}|${Mee(t,i,n)}`;if(n.seenPairs.has(a))return!0;switch(n.seenPairs.add(a),r.kind){case`basic`:return!0;case`pointer`:return pa(r.elemType,i.elemType,n);case`slice`:return pa(r.elemType,i.elemType,n);case`array`:return r.length===i.length&&pa(r.elemType,i.elemType,n);case`map`:return pa(r.keyType,i.keyType,n)&&pa(r.elemType,i.elemType,n);case`channel`:return(r.direction||`both`)===(i.direction||`both`)&&pa(r.elemType,i.elemType,n);case`function`:return Pee(r,i,n);case`struct`:return i.kind===`struct`&&Fee(r,i,n);case`interface`:return i.kind===`interface`&&Iee(r,i,n);default:return!1}}function Fee(e,t,n){if(e.fields.length!==t.fields.length)return!1;for(let[r,i]of e.fields.entries()){let e=t.fields[r];if(e===void 0||i.name!==e.name||(i.pkgPath??``)!==(e.pkgPath??``)||(i.tag??``)!==(e.tag??``)||(i.anonymous??!1)!==(e.anonymous??!1)||!ha(i.type,e.type,n))return!1}return!0}function Iee(e,t,n){let r=Lee(e.methods),i=Lee(t.methods);if(r.length!==i.length)return!1;for(let[e,t]of r.entries()){let r=i[e];if(r===void 0||t.name!==r.name||!Ree(t.args,r.args,n)||!Ree(t.returns,r.returns,n))return!1}return!0}function Lee(e=[]){return[...e].sort((e,t)=>e.name.localeCompare(t.name))}function Ree(e,t,n){if(e.length!==t.length)return!1;for(let[r,i]of e.entries()){let e=t[r];if(e===void 0||!ha(i.type,e.type,n))return!1}return!0}function zee(e,t){if(t.kind===`basic`){if(t.name===`string`)return typeof e==`string`;if(t.name===`int`||t.name===`float64`||t.name===`number`)return typeof e==`string`?/^-?\d+(\.\d+)?$/.test(e):typeof e==`number`}return!1}function Bee(e,t){return t.name===`string`?typeof e==`string`:t.name===`int64`||t.name===`uint64`?typeof e==`bigint`:t.name===`number`||t.name===`int`||t.name===`int8`||t.name===`int16`||t.name===`int32`||t.name===`uint`||t.name===`uintptr`||t.name===`uint8`||t.name===`byte`||t.name===`uint16`||t.name===`uint32`||t.name===`float32`||t.name===`float64`?typeof e==`number`:t.name===`boolean`||t.name===`bool`?typeof e==`boolean`:!1}function Vee(e,t){if(!Qi(t))return!1;if(t.ctor&&e instanceof t.ctor)return ka(e);if(t.ctor)return!1;if(typeof e==`object`&&e&&t.fields){let n=t.fields||[],r=n.map(e=>ga(e)),i=Object.keys(e),a=r.every(t=>t in e),o=i.length===r.length,s=i.every(e=>r.includes(e));return a&&o&&s?n.every(t=>ja(e[ga(t)],la(t.type))):!1}return!1}function ga(e){return e.key||e.name}function Hee(e,t){if(!$i(t)||e==null)return!1;if(t.methods.length===0)return!0;if(typeof e!=`object`)return!1;let n=e.__isVarRef===!0&&`value`in e?e.value:e;return typeof n!=`object`&&typeof n!=`function`||n===null?!1:t.methods.every(e=>{let t=n[e.name];if(typeof t!=`function`||t.length<e.args.length&&!Uee(t,e))return!1;let r=Wee(t);if(r&&!Gee(r,e))return!1;if(n.__goTypeName){let t=aa.get(n.__goTypeName);if(t&&Qi(t)){let n=t.methods.find(t=>t.name===e.name);if(n){if(n.returns.length!==e.returns.length)return!1;for(let t=0;t<e.returns.length;t++){let r=la(e.returns[t].type),i=la(n.returns[t].type);if($i(r)){if(r.name!==i.name)return!1}else if(r.name!==i.name)return!1}}}}return!0})}function Uee(e,t){let n=Wee(e);return n!=null&&Gee(n,t)}function Wee(e){return typeof e==`function`?e.__goscriptMethodSignature??null:null}function Gee(e,t){return e.args.length===t.args.length&&e.returns.length===t.returns.length}function Kee(e,t){if(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Uint8Array||!ta(t))return!1;if(t.keyType||t.elemType){let n=e instanceof Map?Array.from(e.entries()):Object.entries(e);if(n.length===0)return!0;let r=Math.min(5,n.length);for(let e=0;e<r;e++){let[r,i]=n[e];if(t.keyType&&!zee(r,la(t.keyType))||t.elemType&&!ja(i,la(t.elemType)))return!1}}return!0}function qee(e,t){if(!ra(t)&&!na(t))return!1;if(e instanceof Uint8Array)return ra(t)&&e.length!==t.length?!1:Jee(t.elemType);if(!Array.isArray(e))return!1;if(t.elemType){let n=e;if(n.length===0)return!0;let r=Math.min(5,n.length);for(let e=0;e<r;e++)if(!ja(n[e],la(t.elemType)))return!1}return!0}function Jee(e){if(e===void 0)return!0;let t=la(e);return t.kind===`basic`&&(t.name===void 0||t.name===`number`||t.name===`int`||t.name===`uint`||t.name===`uint8`||t.name===`byte`||t.name===`float64`)}const _a=Symbol(`structValue`);function C(e){return typeof e==`object`&&e&&(e[_a]=!0),e}const va=Symbol(`anonymousStructType`);function ya(e,t){return e[va]=t,C(e)}function Yee(e){if(typeof e==`object`&&e)return e.constructor?.__typeInfo??e[va]}function Xee(e,t){let n=la(t),r={...e};if(n.kind===`struct`)for(let e of n.fields){let t=ga(e),n=r[t];if(ka(n)){r[t]=C(w(n));continue}la(e.type).kind===`array`&&(r[t]=Oa(n,e.type))}return ya(r,t)}function w(e){if(typeof e==`object`&&e){let t=e[va];if(t!==void 0)return Xee(e,t)}let t=e;if(typeof t.__goscriptClone==`function`)return t.__goscriptClone();if(typeof t.clone==`function`)return t.clone();throw Error(`runtime error: value is not cloneable`)}function ba(e){return C(w(e))}const xa=new WeakMap,Zee=new WeakMap;function Qee(e){if(g(e)){let t=e.value;return typeof t!=`object`||!t?null:{identity:e,object:t,ref:e}}return typeof e!=`object`||!e?null:{identity:e,object:e}}function Sa(e){let t=xa.get(e);return t===void 0?(xa.set(e,e),e):t}function $ee(e,t){xa.set(t,Sa(e))}function ete(e,t){let n=xa.get(e);return n!==void 0&&n===xa.get(t)}function tte(e,t){return!(!ete(e,t)||`__goType`in e&&`__goType`in t&&typeof e.__goType==`string`&&typeof t.__goType==`string`&&e.__goType!==t.__goType)}function Ca(e,t){return e===t||typeof e==`object`&&!!e&&typeof t==`object`&&!!t&&ete(e,t)}function nte(e){let t=e.ref===void 0?e.object:e.ref.value;if(typeof t==`object`&&t&&`_fields`in t)return t._fields}function rte(e,t){let n=Zee.get(e.identity);n===void 0&&(n=new WeakMap,Zee.set(e.identity,n));let r=n.get(t);if(r!==void 0)return r;let i=Object.create(t.prototype);return e.ref===void 0?Object.assign(i,e.object):Object.defineProperty(i,"_fields",{configurable:!0,enumerable:!0,get:()=>nte(e)}),n.set(t,i),$ee(e.identity,i),i}function wa(e,t){let n=Qee(e);return n===null||t===void 0?e:rte(n,t)}const Ta=Symbol(`arrayValueType`);function Ea(e,t){return e[Ta]=t??!0,e}function Da(e){return typeof e==`object`&&!!e&&Ta in e}function ite(e){let t=e[Ta];return t===!0?void 0:t}function Oa(e,t){if(e instanceof Uint8Array)return Ea(e.slice());if(!Array.isArray(e))return e;t??=ite(e);let n=t===void 0?void 0:la(t),r=n?.kind===`array`&&n.elemType!==void 0?la(n.elemType):void 0;return r?.kind===`array`?Ea(e.map(e=>Oa(e,r)),t):r?.kind===`struct`?Ea(e.map(e=>C(w(e))),t):Ea(e.slice())}function ka(e){return typeof e==`object`&&!!e&&_a in e&&e[_a]===!0}function Aa(e){if(typeof e!=`object`||!e)return e;if(Ta in e)return Oa(e,ite(e));if(!ka(e))return e;let t=e;return!(va in e)&&typeof t.__goscriptClone!=`function`&&typeof t.clone!=`function`?e:C(w(e))}function ate(e,t){if(e==null)return!0;if(typeof e!=`object`||!e||!ia(t))return!1;if(typeof e.__goType==`string`)return Ma(e.__goType,t);if(!t.elemType)return!1;let n=t.elemType,r;if(typeof n==`string`)r=n;else if(n.name)r=n.name;else return!1;let i=aa.get(r);if(i&&i.kind===`struct`&&i.ctor){if(`value`in e){let t=la(n);return ja(e.value,t)}return e instanceof i.ctor&&!ka(e)}{if(!(`value`in e))return!1;let t=la(n);return ja(e.value,t)}}function ote(e,t){if(typeof e!=`function`)return!1;let n=ste(e);return n?ma(n,t):!1}function ste(e){let t=e.__typeInfo;if(!t||t.kind!==`function`)return null;let n=typeof e.__goTypeName==`string`?e.__goTypeName:void 0;return n&&t.name&&n!==t.name?null:n&&!t.name?{...t,name:n}:t}function cte(e,t){if(typeof e!=`object`||!e)return!1;let n=e,r=`both`;return`channel`in e&&`direction`in e&&(n=e.channel,r=e.direction),!(`send`in n)||!(`receive`in n)||!(`close`in n)||typeof n.send!=`function`||typeof n.receive!=`function`||typeof n.close!=`function`||t.elemType&&(t.elemType===`string`&&`zeroValue`in n&&n.zeroValue!==``||t.elemType===`number`&&`zeroValue`in n&&typeof n.zeroValue!=`number`)?!1:!t.direction||r===t.direction}function ja(e,t){if(e==null)return!1;if(typeof e==`object`&&typeof e.__goType==`string`&&jee(e.__goType,t))return!0;switch(t.kind){case`basic`:return Bee(e,t);case`struct`:return Vee(e,t);case`interface`:return Hee(e,t);case`map`:return Kee(e,t);case`slice`:case`array`:return qee(e,t);case`pointer`:return ate(e,t);case`function`:return ote(e,t);case`channel`:return cte(e,t);default:return console.warn(`Type matching for kind '${t.kind}' not implemented.`),!1}}function Ma(e,t){let n=la(t),r=da(n);if(r!==void 0&&e===r)return!0;if(ia(n)){if(!e.startsWith(`*`))return!1;let t=e.slice(1),r=n.elemType;if(!r)return!1;if(t.startsWith(`struct{`)){let e=la(r);if(!Qi(e))return!1;let n=t.match(/^struct{(.+)}$/);if(!n)return!1;let i=n[1].split(`;`).map(e=>e.trim()),a={};for(let e of i){let t=e.match(/^(\w+)\s+(.+)$/);if(t){let[,e,n]=t;a[e]=n.trim()}}let o=e.fields||[],s=o.map(e=>e.name),c=Object.keys(a);if(s.length!==c.length)return!1;for(let e of o){let t=e.name;if(!(t in a))return!1;let n=la(e.type),r=a[t];if(ea(n)){let e=n.name||``;if(e===`string`&&r===`string`||(e===`int`||e===`number`)&&(r===`int`||r===`number`))continue;return!1}}return!0}return typeof r==`string`?t===r:Ma(t,r)}if(na(n))return!e.startsWith(`[]`)||!n.elemType?!1:Ma(e.slice(2),n.elemType);if(ra(n)){let t=e.match(/^\[(\d+)\](.+)$/);return!t||!n.elemType?!1:Number(t[1])===n.length&&Ma(t[2],n.elemType)}if(ea(n)){let t=da(n);return t===void 0?!1:e===t||t===`uint8`&&e===`byte`||t===`int32`&&e===`rune`||t===`int`&&[`byte`,`rune`,`int8`,`int16`,`int32`,`int64`,`uint`,`uint8`,`uint16`,`uint32`,`uint64`,`uintptr`].includes(e)}return!1}function T(e,t){let n=la(t);if(Fa(e)){if($i(n)&&Hee(e,n))return{value:e,ok:!0};let r=e.__goTypeInfo;if(r!==void 0)return{value:null,ok:typeof t==`string`&&e.__goType===t||ma(r,n)};let i=e.__goType;return Ma(i,n)?{value:null,ok:!0}:{value:null,ok:!1}}if(ia(n)&&e===null)return{value:null,ok:!1};if(typeof e==`object`&&e&&e.__goTypeInfo!==void 0&&!$i(n)){let r=typeof t==`string`&&e.__goType===t||ma(e.__goTypeInfo,n);return{value:r?`__goValue`in e?e.__goValue:e:null,ok:r}}if(typeof e==`object`&&e&&typeof e.__goType==`string`&&jee(e.__goType,n))return`__goValue`in e?{value:e.__goValue,ok:!0}:{value:e,ok:!0};if(ta(n)&&typeof e==`object`&&e&&!Array.isArray(e)&&!(e instanceof Uint8Array)&&(n.keyType||n.elemType)){let t=e instanceof Map?Array.from(e.entries()):Object.entries(e);if(t.length===0)return{value:e,ok:!0};let r=Math.min(5,t.length);for(let e=0;e<r;e++){let[r,i]=t[e];if(n.keyType&&!zee(r,la(n.keyType))||n.elemType&&!ja(i,la(n.elemType)))return{value:null,ok:!1}}return{value:e,ok:!0}}if(ja(e,n))return{value:e,ok:!0};if(typeof t==`string`){for(let r of oa.get(t)??[])if(r!==n&&ja(e,r))return{value:e,ok:!0}}if(typeof t==`string`){let e=aa.get(t);if(e&&e.zeroValue!==void 0)return{value:Aee(e.zeroValue),ok:!1}}else if(n.zeroValue!==void 0)return{value:Aee(n.zeroValue),ok:!1};return{value:null,ok:!1}}function Na(e,t){let{value:n,ok:r}=T(e,t);return[n,r]}function E(e,t){let{value:n,ok:r}=T(e,t);if(!r){let n=typeof t==`string`?t:t.name||JSON.stringify(t),r=typeof e;throw e&&e.constructor&&e.constructor.name&&(r=e.constructor.name),e===null&&(r=`nil`),Error(`inline type conversion panic: value is ${r}, not ${n}`)}return n}function Pa(e,t){return ja(e,la(t))}function lte(e,t,n){for(let n of t)if(n.types.length>1){if(n.types.some(t=>Pa(e,t)))return n.body(e)}else if(n.types.length===1){let t=n.types[0],{value:r,ok:i}=T(e,t);if(i)return n.body(r)}if(n)return n()}function Fa(e){return typeof e==`object`&&!!e&&`__isTypedNil`in e&&e.__isTypedNil===!0&&`__goType`in e&&typeof e.__goType==`string`}function ute(e,t){let n=Object.create(null);return n.__goType=e,n.__isTypedNil=!0,t!==void 0&&Object.defineProperty(n,"__goTypeInfo",{value:t,writable:!0,configurable:!0}),n}function D(e,t,n){if(e!=null)return typeof e==`object`&&(Object.defineProperty(e,"__goType",{value:t,writable:!0,configurable:!0}),n!==void 0&&Object.defineProperty(e,"__goTypeInfo",{value:n,writable:!0,configurable:!0})),e;let r=ute(t,n);if(!t.startsWith(`*`))return r;let i=aa.get(t.slice(1));if(!i||!Qi(i)||!i.ctor)return r;let a=i.ctor.prototype;for(let e of i.methods){let t=a[e.name];if(typeof t!=`function`)continue;let n=(...e)=>t.call(null,...e);n.__goscriptMethodSignature=e,Object.defineProperty(r,e.name,{value:n,enumerable:!0})}return r}function dte(e){return typeof e==`function`}function Ia(e,t,n,...r){(e==null||typeof e!=`object`&&typeof e!=`function`)&&Ui(`runtime error: invalid memory address or nil pointer dereference`);let i=e[t];return dte(i)||Ui(`interface method ${t} is not callable`),i.__goscriptMethodWrapper===!0?i.call(e,n,...r):i.call(e,...r)}function O(e,t,n=t){return La(e,t,{},{kind:`basic`,name:n})}function La(e,t,n,r,i){let a={__goType:t,__goValue:e,__goTypeInfo:r,valueOf:()=>e,toString:()=>String(e),[Symbol.toPrimitive]:()=>e};for(let[t,o]of Object.entries(n)){a[t]=(...t)=>o(e,...t),a[t].__goscriptMethodWrapper=!0;let n=i?.find(e=>e.name===t)??fte(t,r);n&&(a[t].__goscriptMethodSignature=n)}return a}function Ra(e){return typeof e==`object`&&!!e&&`__goValue`in e&&typeof e.__goType==`string`}function fte(e,t){return typeof t==`string`&&(t=aa.get(t)),t?Eee(t)?{name:e,args:(t.params??[]).map(e=>({type:e})),returns:(t.results??[]).map(e=>({type:e}))}:Qi(t)||$i(t)?t.methods.find(t=>t.name===e)??null:null:null}function za(e,t,n){return typeof e==`function`?Object.assign(e,n?{__goTypeName:t,__typeInfo:n}:{__goTypeName:t}):e}function k(e,t){return Object.assign(e,t.name?{__typeInfo:t,__goTypeName:t.name}:{__typeInfo:t})}const A=`goscript.genericTypeArgs`,j={};function M(e){let t=e[0];return typeof t==`object`&&t&&`goscript.genericTypeArgs`in t&&e.shift(),e}function Ba(e,t,n){let r=e?.[t]?.zero;return r?r():n}function Va(e,t,n,r,...i){let a=e?.[t]?.methods?.[n];return a?a(r,...i):r[n](...i)}var Ha=class extends Error{constructor(){super(`operation not implemented in JavaScript environment`)}};const pte=new TextEncoder,mte=new TextDecoder;function hte(){try{return Function(`return typeof require !== 'undefined' ? require : null`)()}catch{return null}}function Ua(e,t){let n=0;for(;n<t.length;){let r=e(t.subarray(n));if(!Number.isFinite(r)||r<0)throw Error(`invalid write result: ${r}`);if(r===0)throw Error(`short write`);n+=r}return t.length}function Wa(e,t){let n=pte.encode(t);n.length!==0&&Ua(e,n)}function gte(e){if(e&&typeof e.getBuiltinModule==`function`){let t=e.getBuiltinModule(`fs`);if(t&&typeof t.readSync==`function`&&typeof t.writeSync==`function`)return t}let t=hte();if(t)for(let e of[`node:fs`,`fs`])try{let n=t(e);if(n&&typeof n.readSync==`function`&&typeof n.writeSync==`function`)return n}catch{}return null}function _te(e){if(e&&typeof e.getBuiltinModule==`function`){let t=e.getBuiltinModule(`crypto`);if(t&&typeof t.createHash==`function`)return t}let t=hte();if(t)for(let e of[`node:crypto`,`crypto`])try{let n=t(e);if(n&&typeof n.createHash==`function`)return n}catch{}return null}function vte(e){return/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e)}function yte(e){return e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function bte(e){return e.replace(/\\/g,`/`)}function xte(e,t){let n=bte(e),r=t&&!n.endsWith(`/`)?`/`:``;return/^[A-Za-z]:\//.test(n)?new URL(`file:///${n}${r}`).href:new URL(`file://${n}${r}`).href}function Ga(){let e=Ja();try{if(typeof e.processObj?.cwd==`function`)return e.processObj.cwd()}catch{}try{if(typeof e.deno?.cwd==`function`)return e.deno.cwd()}catch{}return null}function Ste(e){try{if(vte(e))return new URL(e).href;if(yte(e))return xte(e,!1);let t=Ga();return t?new URL(bte(e),xte(t,!0)).href:null}catch{return null}}function Ka(){return e=>{let t=globalThis.console?.log;if(t){if(e.endsWith(`
|
|
1
|
+
import{n as e}from"./chunks/rolldown-runtime-Csi-cuKc.mjs";import{$ as t,$i as n,$n as r,$r as i,$t as a,A as o,Ai as s,An as c,Ar as l,At as u,B as d,Bn as f,Br as p,Bt as ee,C as te,Ci as ne,Cn as re,Cr as ie,Ct as ae,D as oe,Di as se,Dn as ce,Dr as le,Dt as ue,E as de,Ei as fe,En as pe,Er as me,Et as he,F as ge,Fi as _e,Fn as ve,Fr as ye,Ft as be,G as xe,Gi as Se,Gn as Ce,Gr as we,Gt as Te,H as Ee,Hi as De,Hn as Oe,Hr as ke,Ht as Ae,I as je,Ii as Me,In as Ne,Ir as Pe,It as Fe,J as Ie,Ji as Le,Jn as Re,Jr as ze,Jt as Be,K as Ve,Ki as He,Kn as Ue,Kr as We,Kt as Ge,L as Ke,Li as qe,Ln as Je,Lr as Ye,Lt as Xe,M as Ze,Mi as Qe,Mn as $e,Mr as et,Mt as tt,N as nt,Ni as rt,Nn as it,Nr as at,Nt as ot,O as st,Oi as ct,On as lt,Or as ut,Ot as dt,P as ft,Pi as pt,Pn as mt,Pr as ht,Pt as gt,Q as _t,Qi as vt,Qn as yt,Qr as bt,Qt as xt,R as St,Ri as Ct,Rn as wt,Rr as Tt,Rt as Et,S as Dt,Si as Ot,Sn as kt,Sr as At,St as jt,T as Mt,Ti as Nt,Tn as Pt,Tr as Ft,Tt as It,Ui as Lt,Un as Rt,Ur as zt,Ut as Bt,V as Vt,Vi as Ht,Vn as Ut,Vr as Wt,Vt as Gt,W as Kt,Wi as qt,Wn as Jt,Wr as Yt,Wt as Xt,X as Zt,Xi as Qt,Xn as $t,Xr as en,Xt as tn,Y as nn,Yi as rn,Yn as an,Yr as on,Yt as sn,Z as cn,Zi as ln,Zn as un,Zr as dn,Zt as fn,_i as pn,_n as mn,_r as hn,_t as gn,a as _n,aa as vn,ai as yn,an as bn,ar as xn,at as Sn,b as Cn,bi as wn,bn as Tn,br as En,bt as Dn,ca as On,ci as kn,cn as An,cr as jn,ct as Mn,da as Nn,di as Pn,dn as Fn,dr as In,dt as Ln,ea as Rn,ei as zn,en as Bn,er as Vn,et as Hn,fa as Un,fi as Wn,fn as Gn,fr as Kn,ft as qn,gi as Jn,gn as Yn,gr as Xn,gt as Zn,hi as Qn,hn as $n,hr as er,ht as tr,i as nr,ia as rr,ii as ir,in as ar,ir as or,it as sr,j as cr,ji as lr,jn as ur,jr as dr,jt as fr,k as pr,ki as mr,kn as hr,kr as gr,kt as _r,la as vr,li as yr,ln as br,lr as xr,lt as Sr,mi as Cr,mn as wr,mr as Tr,mt as Er,n as Dr,na as Or,ni as kr,nn as Ar,nr as jr,nt as Mr,o as Nr,oa as Pr,oi as Fr,on as Ir,ot as Lr,p as Rr,pa as zr,pi as Br,pn as Vr,pr as Hr,pt as Ur,q as Wr,qi as Gr,qn as Kr,qr,qt as Jr,ra as Yr,ri as Xr,rn as Zr,rr as Qr,rt as $r,sa as ei,si as ti,sn as ni,sr as ri,st as ii,t as ai,ta as oi,ti as eee,tn as si,tr as ci,tt as li,ua as ui,ui as di,un as fi,ur as pi,ut as mi,vi as hi,vn as gi,vr as _i,vt as vi,w as yi,wi as tee,wn as bi,wr as xi,wt as Si,x as Ci,xi as wi,xn as Ti,xr as Ei,xt as Di,yi as Oi,yn as ki,yr as Ai,yt as ji,z as Mi,zi as Ni,zn as Pi,zr as Fi,zt as Ii}from"./chunks/node.pb-BccNR73d.mjs";import{isMainThread as nee,parentPort as Li,workerData as ree}from"node:worker_threads";import{mkdirSync as iee,realpathSync as aee,rmSync as oee}from"node:fs";import{DatabaseSync as see}from"node:sqlite";import{join as cee}from"node:path";var Ri=class extends Error{value;recovered=!1;constructor(e){let t=uee(e);super(typeof t==`string`?`panic: ${t}`:`panic:`),this.value=e,typeof t!=`string`&&Promise.resolve(t).then(e=>{this.message=`panic: ${e}`})}};const zi=[];let Bi=null;function Vi(e,t){let n=Bi;Bi=e instanceof Ri?e:null;try{return t()}finally{Bi=n}}var lee=class extends Error{constructor(e){super(e),this.name=`RuntimeError`}Error(){return this.message}};function Hi(...e){let t=new Ri(e.length===1?e[0]:e);throw zi.push(t),t}function Ui(e){let t=new Ri(new lee(e));throw zi.push(t),t}function Wi(e){return e instanceof Ri?e.value:e}function uee(e){return dee(e)?e:e instanceof Error?e.message:typeof e==`object`&&e&&`Error`in e&&typeof e.Error==`function`?e.Error():String(e)}function dee(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}function Gi(){let e=Bi;if(e===null||e.recovered)return null;e.recovered=!0;let t=zi.indexOf(e);return t!==-1&&zi.splice(t,1),e.value}function Ki(e){if(e instanceof Ri&&e.recovered){let t=zi.indexOf(e);return t!==-1&&zi.splice(t,1),!0}return!1}const fee=new WeakMap,pee=new WeakMap;let mee=1;function hee(e){let t=fee.get(e);return t===void 0&&(t=mee*4294967296,mee++,fee.set(e,t)),t}function gee(e,t){return{__goOwnedPointer:!0,__goAddress:t,__goRef:()=>e}}var _ee=class{value;__isVarRef=!0;pointer;constructor(e){this.value=e}get __goPointer(){return this.pointer??=gee(this,()=>hee(this))}get __goAddress(){return this.__goPointer.__goAddress}},vee=class{target;key;__isVarRef=!0;pointer;constructor(e,t){this.target=e,this.key=t}get value(){return this.target[this.key]}set value(e){this.target[this.key]=e}get __goPointer(){return this.pointer??=gee(this,()=>hee(this))}get __goAddress(){return this.__goPointer.__goAddress}};function m(e){return new _ee(e)}function h(e,t){for(let n of t)Object.defineProperty(e,n,{get(){return this._fields[n]},set(e){this._fields[n]=e},configurable:!0,enumerable:!1})}function qi(e,t){let n=pee.get(e);n===void 0&&(n=new globalThis.Map,pee.set(e,n));let r=n.get(t);if(r!==void 0)return r;let i=new vee(e,t);return n.set(t,i),i}function g(e){return typeof e==`object`&&!!e&&e.__isVarRef===!0}function Ji(e){return typeof e==`object`&&!!e&&e.__goOwnedPointer===!0}function yee(e){return e.__goPointer}function bee(e){return e.__goAddress()}function xee(e){return e.__goRef()}function See(e){return e===null&&Ui(`runtime error: invalid memory address or nil pointer dereference`),e.value}function Cee(e){return{get value(){throw Error(`unsafe pointer dereference is not supported in JavaScript/TypeScript`)},set value(e){throw Error(`unsafe pointer dereference is not supported in JavaScript/TypeScript`)},__isVarRef:!0}}let wee=function(e){return e.Basic=`basic`,e.Interface=`interface`,e.Struct=`struct`,e.Map=`map`,e.Slice=`slice`,e.Array=`array`,e.Pointer=`pointer`,e.Function=`function`,e.Channel=`channel`,e}({});function _(e,t=[],n=[]){return{name:e,args:Tee(t,`_p`),returns:Tee(n,`_r`)}}function Tee(e,t){return e.map((e,n)=>Array.isArray(e)?{name:e[0],type:e[1]}:{name:t+n,type:e})}function v(e,t,n,r,i,a){return{name:e,key:e,type:t,index:n,offset:r,exported:i,...a}}function y(e,t){let n={kind:`basic`,name:e};return t!==void 0&&(n.typeName=t),n}function b(e){return{kind:`pointer`,elemType:e}}function x(e,t){let n={kind:`slice`,elemType:e};return t!==void 0&&(n.typeName=t),n}function Yi(e,t){return{kind:`array`,elemType:e,length:t}}function Xi(e,t){return{kind:`map`,keyType:e,elemType:t}}function Zi(e,t){return{kind:`channel`,direction:t,elemType:e}}function Qi(e){return e.kind===`struct`}function $i(e){return e.kind===`interface`}function ea(e){return e.kind===`basic`}function ta(e){return e.kind===`map`}function na(e){return e.kind===`slice`}function ra(e){return e.kind===`array`}function ia(e){return e.kind===`pointer`}function Eee(e){return e.kind===`function`}function Dee(e){return e.kind===`channel`}function Oee(e){return typeof e==`object`&&!!e&&`type`in e&&`name`in e&&!(`kind`in e)}const aa=new Map,oa=new Map;function kee(e,t){let n=aa.get(e);if(n&&n!==t){let r=oa.get(e)??[n];r.includes(t)||r.push(t),oa.set(e,r)}aa.set(e,t)}const S=(e,t,n,r,i=[])=>{let a={name:e,kind:`struct`,zeroValue:t,get methods(){return typeof n==`function`&&(n=n()),n},set methods(e){n=e},ctor:r,get fields(){return typeof i==`function`&&(i=i()),i},set fields(e){i=e}};return kee(e,a),a};function Aee(e){return typeof e==`function`?e():e}const sa=(e,t,n)=>{let r={name:e,kind:`interface`,zeroValue:t,methods:n};return kee(e,r),r};sa(`error`,null,[{name:`Error`,args:[],returns:[{type:{kind:`basic`,name:`string`}}]}]);const ca=e=>aa.get(e);function la(e){return typeof e==`string`?aa.get(e)||{kind:`basic`,name:e}:e}function ua(e){let t=la(e);switch(t.kind){case`map`:case`slice`:case`function`:return!1;case`array`:return t.elemType===void 0||ua(t.elemType);case`struct`:return t.fields.every(e=>ua(e.type));default:return!0}}function da(e){return e.typeName||e.name}function jee(e,t){let n=da(t);return n!==void 0&&e===n||Ma(e,t)}function fa(){return{seenPairs:new Set,objectIDs:new WeakMap,nextObjectID:0}}function Mee(e,t,n){let r=da(t);if(r!==void 0)return`${t.kind}:${r}`;if(typeof e==`string`)return`string:${e}`;let i=n.objectIDs.get(e);if(i!==void 0)return`object:${i}`;let a=n.nextObjectID;return n.nextObjectID+=1,n.objectIDs.set(e,a),`object:${a}`}function pa(e,t,n){return e===void 0&&t===void 0?!0:e===void 0||t===void 0?!1:ha(e,t,n)}function Nee(e,t,n=fa()){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0||e.length!==t.length)return!1;for(let[r,i]of e.entries())if(!ha(i,t[r],n))return!1;return!0}function Pee(e,t,n=fa()){return(e.isVariadic||!1)===(t.isVariadic||!1)&&Nee(e.params,t.params,n)&&Nee(e.results,t.results,n)}function ma(e,t){return ha(e,t,fa())}function ha(e,t,n){let r=la(e),i=la(t);if(r===i)return!0;if(r.kind!==i.kind||(r.typeName??``)!==(i.typeName??``)||r.name!==i.name)return!1;if(r.name!==void 0&&(r.kind===`basic`||r.kind===`struct`||r.kind===`interface`))return!0;let a=`${Mee(e,r,n)}|${Mee(t,i,n)}`;if(n.seenPairs.has(a))return!0;switch(n.seenPairs.add(a),r.kind){case`basic`:return!0;case`pointer`:return pa(r.elemType,i.elemType,n);case`slice`:return pa(r.elemType,i.elemType,n);case`array`:return r.length===i.length&&pa(r.elemType,i.elemType,n);case`map`:return pa(r.keyType,i.keyType,n)&&pa(r.elemType,i.elemType,n);case`channel`:return(r.direction||`both`)===(i.direction||`both`)&&pa(r.elemType,i.elemType,n);case`function`:return Pee(r,i,n);case`struct`:return i.kind===`struct`&&Fee(r,i,n);case`interface`:return i.kind===`interface`&&Iee(r,i,n);default:return!1}}function Fee(e,t,n){if(e.fields.length!==t.fields.length)return!1;for(let[r,i]of e.fields.entries()){let e=t.fields[r];if(e===void 0||i.name!==e.name||(i.pkgPath??``)!==(e.pkgPath??``)||(i.tag??``)!==(e.tag??``)||(i.anonymous??!1)!==(e.anonymous??!1)||!ha(i.type,e.type,n))return!1}return!0}function Iee(e,t,n){let r=Lee(e.methods),i=Lee(t.methods);if(r.length!==i.length)return!1;for(let[e,t]of r.entries()){let r=i[e];if(r===void 0||t.name!==r.name||!Ree(t.args,r.args,n)||!Ree(t.returns,r.returns,n))return!1}return!0}function Lee(e=[]){return[...e].sort((e,t)=>e.name.localeCompare(t.name))}function Ree(e,t,n){if(e.length!==t.length)return!1;for(let[r,i]of e.entries()){let e=t[r];if(e===void 0||!ha(i.type,e.type,n))return!1}return!0}function zee(e,t){if(t.kind===`basic`){if(t.name===`string`)return typeof e==`string`;if(t.name===`int`||t.name===`float64`||t.name===`number`)return typeof e==`string`?/^-?\d+(\.\d+)?$/.test(e):typeof e==`number`}return!1}function Bee(e,t){return t.name===`string`?typeof e==`string`:t.name===`int64`||t.name===`uint64`?typeof e==`bigint`:t.name===`number`||t.name===`int`||t.name===`int8`||t.name===`int16`||t.name===`int32`||t.name===`uint`||t.name===`uintptr`||t.name===`uint8`||t.name===`byte`||t.name===`uint16`||t.name===`uint32`||t.name===`float32`||t.name===`float64`?typeof e==`number`:t.name===`boolean`||t.name===`bool`?typeof e==`boolean`:!1}function Vee(e,t){if(!Qi(t))return!1;if(t.ctor&&e instanceof t.ctor)return ka(e);if(t.ctor)return!1;if(typeof e==`object`&&e&&t.fields){let n=t.fields||[],r=n.map(e=>ga(e)),i=Object.keys(e),a=r.every(t=>t in e),o=i.length===r.length,s=i.every(e=>r.includes(e));return a&&o&&s?n.every(t=>ja(e[ga(t)],la(t.type))):!1}return!1}function ga(e){return e.key||e.name}function Hee(e,t){if(!$i(t)||e==null)return!1;if(t.methods.length===0)return!0;if(typeof e!=`object`)return!1;let n=e.__isVarRef===!0&&`value`in e?e.value:e;return typeof n!=`object`&&typeof n!=`function`||n===null?!1:t.methods.every(e=>{let t=n[e.name];if(typeof t!=`function`||t.length<e.args.length&&!Uee(t,e))return!1;let r=Wee(t);if(r&&!Gee(r,e))return!1;if(n.__goTypeName){let t=aa.get(n.__goTypeName);if(t&&Qi(t)){let n=t.methods.find(t=>t.name===e.name);if(n){if(n.returns.length!==e.returns.length)return!1;for(let t=0;t<e.returns.length;t++){let r=la(e.returns[t].type),i=la(n.returns[t].type);if($i(r)){if(r.name!==i.name)return!1}else if(r.name!==i.name)return!1}}}}return!0})}function Uee(e,t){let n=Wee(e);return n!=null&&Gee(n,t)}function Wee(e){return typeof e==`function`?e.__goscriptMethodSignature??null:null}function Gee(e,t){return e.args.length===t.args.length&&e.returns.length===t.returns.length}function Kee(e,t){if(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Uint8Array||!ta(t))return!1;if(t.keyType||t.elemType){let n=e instanceof Map?Array.from(e.entries()):Object.entries(e);if(n.length===0)return!0;let r=Math.min(5,n.length);for(let e=0;e<r;e++){let[r,i]=n[e];if(t.keyType&&!zee(r,la(t.keyType))||t.elemType&&!ja(i,la(t.elemType)))return!1}}return!0}function qee(e,t){if(!ra(t)&&!na(t))return!1;if(e instanceof Uint8Array)return ra(t)&&e.length!==t.length?!1:Jee(t.elemType);if(!Array.isArray(e))return!1;if(t.elemType){let n=e;if(n.length===0)return!0;let r=Math.min(5,n.length);for(let e=0;e<r;e++)if(!ja(n[e],la(t.elemType)))return!1}return!0}function Jee(e){if(e===void 0)return!0;let t=la(e);return t.kind===`basic`&&(t.name===void 0||t.name===`number`||t.name===`int`||t.name===`uint`||t.name===`uint8`||t.name===`byte`||t.name===`float64`)}const _a=Symbol(`structValue`);function C(e){return typeof e==`object`&&e&&(e[_a]=!0),e}const va=Symbol(`anonymousStructType`);function ya(e,t){return e[va]=t,C(e)}function Yee(e){if(typeof e==`object`&&e)return e.constructor?.__typeInfo??e[va]}function Xee(e,t){let n=la(t),r={...e};if(n.kind===`struct`)for(let e of n.fields){let t=ga(e),n=r[t];if(ka(n)){r[t]=C(w(n));continue}la(e.type).kind===`array`&&(r[t]=Oa(n,e.type))}return ya(r,t)}function w(e){if(typeof e==`object`&&e){let t=e[va];if(t!==void 0)return Xee(e,t)}let t=e;if(typeof t.__goscriptClone==`function`)return t.__goscriptClone();if(typeof t.clone==`function`)return t.clone();throw Error(`runtime error: value is not cloneable`)}function ba(e){return C(w(e))}const xa=new WeakMap,Zee=new WeakMap;function Qee(e){if(g(e)){let t=e.value;return typeof t!=`object`||!t?null:{identity:e,object:t,ref:e}}return typeof e!=`object`||!e?null:{identity:e,object:e}}function Sa(e){let t=xa.get(e);return t===void 0?(xa.set(e,e),e):t}function $ee(e,t){xa.set(t,Sa(e))}function ete(e,t){let n=xa.get(e);return n!==void 0&&n===xa.get(t)}function tte(e,t){return!(!ete(e,t)||`__goType`in e&&`__goType`in t&&typeof e.__goType==`string`&&typeof t.__goType==`string`&&e.__goType!==t.__goType)}function Ca(e,t){return e===t||typeof e==`object`&&!!e&&typeof t==`object`&&!!t&&ete(e,t)}function nte(e){let t=e.ref===void 0?e.object:e.ref.value;if(typeof t==`object`&&t&&`_fields`in t)return t._fields}function rte(e,t){let n=Zee.get(e.identity);n===void 0&&(n=new WeakMap,Zee.set(e.identity,n));let r=n.get(t);if(r!==void 0)return r;let i=Object.create(t.prototype);return e.ref===void 0?Object.assign(i,e.object):Object.defineProperty(i,"_fields",{configurable:!0,enumerable:!0,get:()=>nte(e)}),n.set(t,i),$ee(e.identity,i),i}function wa(e,t){let n=Qee(e);return n===null||t===void 0?e:rte(n,t)}const Ta=Symbol(`arrayValueType`);function Ea(e,t){return e[Ta]=t??!0,e}function Da(e){return typeof e==`object`&&!!e&&Ta in e}function ite(e){let t=e[Ta];return t===!0?void 0:t}function Oa(e,t){if(e instanceof Uint8Array)return Ea(e.slice());if(!Array.isArray(e))return e;t??=ite(e);let n=t===void 0?void 0:la(t),r=n?.kind===`array`&&n.elemType!==void 0?la(n.elemType):void 0;return r?.kind===`array`?Ea(e.map(e=>Oa(e,r)),t):r?.kind===`struct`?Ea(e.map(e=>C(w(e))),t):Ea(e.slice())}function ka(e){return typeof e==`object`&&!!e&&_a in e&&e[_a]===!0}function Aa(e){if(typeof e!=`object`||!e)return e;if(Ta in e)return Oa(e,ite(e));if(!ka(e))return e;let t=e;return!(va in e)&&typeof t.__goscriptClone!=`function`&&typeof t.clone!=`function`?e:C(w(e))}function ate(e,t){if(e==null)return!0;if(typeof e!=`object`||!e||!ia(t))return!1;if(typeof e.__goType==`string`)return Ma(e.__goType,t);if(!t.elemType)return!1;let n=t.elemType,r;if(typeof n==`string`)r=n;else if(n.name)r=n.name;else return!1;let i=aa.get(r);if(i&&i.kind===`struct`&&i.ctor){if(`value`in e){let t=la(n);return ja(e.value,t)}return e instanceof i.ctor&&!ka(e)}{if(!(`value`in e))return!1;let t=la(n);return ja(e.value,t)}}function ote(e,t){if(typeof e!=`function`)return!1;let n=ste(e);return n?ma(n,t):!1}function ste(e){let t=e.__typeInfo;if(!t||t.kind!==`function`)return null;let n=typeof e.__goTypeName==`string`?e.__goTypeName:void 0;return n&&t.name&&n!==t.name?null:n&&!t.name?{...t,name:n}:t}function cte(e,t){if(typeof e!=`object`||!e)return!1;let n=e,r=`both`;return`channel`in e&&`direction`in e&&(n=e.channel,r=e.direction),!(`send`in n)||!(`receive`in n)||!(`close`in n)||typeof n.send!=`function`||typeof n.receive!=`function`||typeof n.close!=`function`||t.elemType&&(t.elemType===`string`&&`zeroValue`in n&&n.zeroValue!==``||t.elemType===`number`&&`zeroValue`in n&&typeof n.zeroValue!=`number`)?!1:!t.direction||r===t.direction}function ja(e,t){if(e==null)return!1;if(typeof e==`object`&&typeof e.__goType==`string`&&jee(e.__goType,t))return!0;switch(t.kind){case`basic`:return Bee(e,t);case`struct`:return Vee(e,t);case`interface`:return Hee(e,t);case`map`:return Kee(e,t);case`slice`:case`array`:return qee(e,t);case`pointer`:return ate(e,t);case`function`:return ote(e,t);case`channel`:return cte(e,t);default:return console.warn(`Type matching for kind '${t.kind}' not implemented.`),!1}}function Ma(e,t){let n=la(t),r=da(n);if(r!==void 0&&e===r)return!0;if(ia(n)){if(!e.startsWith(`*`))return!1;let t=e.slice(1),r=n.elemType;if(!r)return!1;if(t.startsWith(`struct{`)){let e=la(r);if(!Qi(e))return!1;let n=t.match(/^struct{(.+)}$/);if(!n)return!1;let i=n[1].split(`;`).map(e=>e.trim()),a={};for(let e of i){let t=e.match(/^(\w+)\s+(.+)$/);if(t){let[,e,n]=t;a[e]=n.trim()}}let o=e.fields||[],s=o.map(e=>e.name),c=Object.keys(a);if(s.length!==c.length)return!1;for(let e of o){let t=e.name;if(!(t in a))return!1;let n=la(e.type),r=a[t];if(ea(n)){let e=n.name||``;if(e===`string`&&r===`string`||(e===`int`||e===`number`)&&(r===`int`||r===`number`))continue;return!1}}return!0}return typeof r==`string`?t===r:Ma(t,r)}if(na(n))return!e.startsWith(`[]`)||!n.elemType?!1:Ma(e.slice(2),n.elemType);if(ra(n)){let t=e.match(/^\[(\d+)\](.+)$/);return!t||!n.elemType?!1:Number(t[1])===n.length&&Ma(t[2],n.elemType)}if(ea(n)){let t=da(n);return t===void 0?!1:e===t||t===`uint8`&&e===`byte`||t===`int32`&&e===`rune`||t===`int`&&[`byte`,`rune`,`int8`,`int16`,`int32`,`int64`,`uint`,`uint8`,`uint16`,`uint32`,`uint64`,`uintptr`].includes(e)}return!1}function T(e,t){let n=la(t);if(Fa(e)){if($i(n)&&Hee(e,n))return{value:e,ok:!0};let r=e.__goTypeInfo;if(r!==void 0)return{value:null,ok:typeof t==`string`&&e.__goType===t||ma(r,n)};let i=e.__goType;return Ma(i,n)?{value:null,ok:!0}:{value:null,ok:!1}}if(ia(n)&&e===null)return{value:null,ok:!1};if(typeof e==`object`&&e&&e.__goTypeInfo!==void 0&&!$i(n)){let r=typeof t==`string`&&e.__goType===t||ma(e.__goTypeInfo,n);return{value:r?`__goValue`in e?e.__goValue:e:null,ok:r}}if(typeof e==`object`&&e&&typeof e.__goType==`string`&&jee(e.__goType,n))return`__goValue`in e?{value:e.__goValue,ok:!0}:{value:e,ok:!0};if(ta(n)&&typeof e==`object`&&e&&!Array.isArray(e)&&!(e instanceof Uint8Array)&&(n.keyType||n.elemType)){let t=e instanceof Map?Array.from(e.entries()):Object.entries(e);if(t.length===0)return{value:e,ok:!0};let r=Math.min(5,t.length);for(let e=0;e<r;e++){let[r,i]=t[e];if(n.keyType&&!zee(r,la(n.keyType))||n.elemType&&!ja(i,la(n.elemType)))return{value:null,ok:!1}}return{value:e,ok:!0}}if(ja(e,n))return{value:e,ok:!0};if(typeof t==`string`){for(let r of oa.get(t)??[])if(r!==n&&ja(e,r))return{value:e,ok:!0}}if(typeof t==`string`){let e=aa.get(t);if(e&&e.zeroValue!==void 0)return{value:Aee(e.zeroValue),ok:!1}}else if(n.zeroValue!==void 0)return{value:Aee(n.zeroValue),ok:!1};return{value:null,ok:!1}}function Na(e,t){let{value:n,ok:r}=T(e,t);return[n,r]}function E(e,t){let{value:n,ok:r}=T(e,t);if(!r){let n=typeof t==`string`?t:t.name||JSON.stringify(t),r=typeof e;throw e&&e.constructor&&e.constructor.name&&(r=e.constructor.name),e===null&&(r=`nil`),Error(`inline type conversion panic: value is ${r}, not ${n}`)}return n}function Pa(e,t){return ja(e,la(t))}function lte(e,t,n){for(let n of t)if(n.types.length>1){if(n.types.some(t=>Pa(e,t)))return n.body(e)}else if(n.types.length===1){let t=n.types[0],{value:r,ok:i}=T(e,t);if(i)return n.body(r)}if(n)return n()}function Fa(e){return typeof e==`object`&&!!e&&`__isTypedNil`in e&&e.__isTypedNil===!0&&`__goType`in e&&typeof e.__goType==`string`}function ute(e,t){let n=Object.create(null);return n.__goType=e,n.__isTypedNil=!0,t!==void 0&&Object.defineProperty(n,"__goTypeInfo",{value:t,writable:!0,configurable:!0}),n}function D(e,t,n){if(e!=null)return typeof e==`object`&&(Object.defineProperty(e,"__goType",{value:t,writable:!0,configurable:!0}),n!==void 0&&Object.defineProperty(e,"__goTypeInfo",{value:n,writable:!0,configurable:!0})),e;let r=ute(t,n);if(!t.startsWith(`*`))return r;let i=aa.get(t.slice(1));if(!i||!Qi(i)||!i.ctor)return r;let a=i.ctor.prototype;for(let e of i.methods){let t=a[e.name];if(typeof t!=`function`)continue;let n=(...e)=>t.call(null,...e);n.__goscriptMethodSignature=e,Object.defineProperty(r,e.name,{value:n,enumerable:!0})}return r}function dte(e){return typeof e==`function`}function Ia(e,t,n,...r){(e==null||typeof e!=`object`&&typeof e!=`function`)&&Ui(`runtime error: invalid memory address or nil pointer dereference`);let i=e[t];return dte(i)||Ui(`interface method ${t} is not callable`),i.__goscriptMethodWrapper===!0?i.call(e,n,...r):i.call(e,...r)}function O(e,t,n=t){return La(e,t,{},{kind:`basic`,name:n})}function La(e,t,n,r,i){let a={__goType:t,__goValue:e,__goTypeInfo:r,valueOf:()=>e,toString:()=>String(e),[Symbol.toPrimitive]:()=>e};for(let[t,o]of Object.entries(n)){a[t]=(...t)=>o(e,...t),a[t].__goscriptMethodWrapper=!0;let n=i?.find(e=>e.name===t)??fte(t,r);n&&(a[t].__goscriptMethodSignature=n)}return a}function Ra(e){return typeof e==`object`&&!!e&&`__goValue`in e&&typeof e.__goType==`string`}function fte(e,t){return typeof t==`string`&&(t=aa.get(t)),t?Eee(t)?{name:e,args:(t.params??[]).map(e=>({type:e})),returns:(t.results??[]).map(e=>({type:e}))}:Qi(t)||$i(t)?t.methods.find(t=>t.name===e)??null:null:null}function za(e,t,n){return typeof e==`function`?Object.assign(e,n?{__goTypeName:t,__typeInfo:n}:{__goTypeName:t}):e}function k(e,t){return Object.assign(e,t.name?{__typeInfo:t,__goTypeName:t.name}:{__typeInfo:t})}const A=`goscript.genericTypeArgs`,j={};function M(e){let t=e[0];return typeof t==`object`&&t&&`goscript.genericTypeArgs`in t&&e.shift(),e}function Ba(e,t,n){let r=e?.[t]?.zero;return r?r():n}function Va(e,t,n,r,...i){let a=e?.[t]?.methods?.[n];return a?a(r,...i):r[n](...i)}var Ha=class extends Error{constructor(){super(`operation not implemented in JavaScript environment`)}};const pte=new TextEncoder,mte=new TextDecoder;function hte(){try{return Function(`return typeof require !== 'undefined' ? require : null`)()}catch{return null}}function Ua(e,t){let n=0;for(;n<t.length;){let r=e(t.subarray(n));if(!Number.isFinite(r)||r<0)throw Error(`invalid write result: ${r}`);if(r===0)throw Error(`short write`);n+=r}return t.length}function Wa(e,t){let n=pte.encode(t);n.length!==0&&Ua(e,n)}function gte(e){if(e&&typeof e.getBuiltinModule==`function`){let t=e.getBuiltinModule(`fs`);if(t&&typeof t.readSync==`function`&&typeof t.writeSync==`function`)return t}let t=hte();if(t)for(let e of[`node:fs`,`fs`])try{let n=t(e);if(n&&typeof n.readSync==`function`&&typeof n.writeSync==`function`)return n}catch{}return null}function _te(e){if(e&&typeof e.getBuiltinModule==`function`){let t=e.getBuiltinModule(`crypto`);if(t&&typeof t.createHash==`function`)return t}let t=hte();if(t)for(let e of[`node:crypto`,`crypto`])try{let n=t(e);if(n&&typeof n.createHash==`function`)return n}catch{}return null}function vte(e){return/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e)}function yte(e){return e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function bte(e){return e.replace(/\\/g,`/`)}function xte(e,t){let n=bte(e),r=t&&!n.endsWith(`/`)?`/`:``;return/^[A-Za-z]:\//.test(n)?new URL(`file:///${n}${r}`).href:new URL(`file://${n}${r}`).href}function Ga(){let e=Ja();try{if(typeof e.processObj?.cwd==`function`)return e.processObj.cwd()}catch{}try{if(typeof e.deno?.cwd==`function`)return e.deno.cwd()}catch{}return null}function Ste(e){try{if(vte(e))return new URL(e).href;if(yte(e))return xte(e,!1);let t=Ga();return t?new URL(bte(e),xte(t,!0)).href:null}catch{return null}}function Ka(){return e=>{let t=globalThis.console?.log;if(t){if(e.endsWith(`
|
|
2
2
|
`)){t.call(globalThis.console,e.slice(0,-1));return}t.call(globalThis.console,e)}}}function Cte(){let e=globalThis,t=e.Deno??null,n=e.process??null,r=gte(n),i=_te(n),a=e=>{if(!t)return null;switch(e){case 0:return t.stdin??null;case 1:return t.stdout??null;case 2:return t.stderr??null;default:return null}};return{deno:t,getEnv:e=>{if(t?.env?.get)try{return t.env.get(e)??``}catch{return``}return n?.env?.[e]??``},getStdioHandle:a,nodeCrypto:i,nodeFS:r,platform:t?.build?.os??n?.platform??`unknown`,processObj:n,readFD:(e,t)=>{let n=a(e);if(n&&typeof n.readSync==`function`)return n.readSync(t);if(r)return r.readSync(e,t,0,t.length,null);throw new Ha},writeFD:(e,t)=>{let n=a(e);if(n&&typeof n.writeSync==`function`)return Ua(e=>n.writeSync(e),t);if(r)return Ua(t=>r.writeSync(e,t,0,t.length,null),t);if(e===1||e===2)return Ka()(mte.decode(t)),t.length;throw new Ha},writeStderrText:e=>{let t=a(2);if(t&&typeof t.writeSync==`function`){Wa(e=>t.writeSync(e),e);return}if(r){Wa(e=>r.writeSync(2,e,0,e.length,null),e);return}Ka()(e)},writeStdoutText:e=>{let t=a(1);if(t&&typeof t.writeSync==`function`){Wa(e=>t.writeSync(e),e);return}if(r){Wa(e=>r.writeSync(1,e,0,e.length,null),e);return}Ka()(e)}}}var wte=class{detector;runtime;constructor(e=Cte){this.detector=e,this.runtime=e()}current(){return this.runtime}reset(){this.runtime=this.detector()}};const qa=new wte;function Ja(){return qa.current()}function Tte(){qa.reset()}function Ya(e){Ja().writeStdoutText(e)}function Ete(e){Ja().writeStderrText(e)}function Dte(e){if(e.main===!0)return!0;let t=Ja().processObj?.argv?.[1];if(typeof t!=`string`||t===``)return!1;let n=Ste(t);if(!n)return!1;try{return new URL(e.url).href===n}catch{return e.url===n}}var Xa=class extends String{bytes;constructor(e){super(Go(e)),this.bytes=e.slice()}toString(){return Go(this.bytes)}valueOf(){return this.toString()}[Symbol.toPrimitive](){return this.toString()}};const Ote=`goscript-bytes:`,kte=/^[\x00-\x7f]*$/;function Za(e){return typeof e==`string`||e instanceof Xa}const Ate=new TextEncoder,jte=new TextDecoder(`utf-8`,{fatal:!0});function Qa(e){return e instanceof Xa?e.bytes.slice():e.startsWith(Ote)?Qte(e.slice(16)):Ate.encode(e)}function $a(e){return typeof e==`string`?e:to(e.bytes)}function eo(e){return Za(e)?Qa(e):e instanceof Uint8Array?e:e==null?new Uint8Array:Uint8Array.from(so(e))}function to(e){try{return jte.decode(e)}catch{return Ote+Go(e)}}const no=4294967296;let ro=1;const Mte=new WeakMap,Nte=new WeakMap,Pte=new globalThis.Map;function io(e){if(typeof e!=`string`||e.length===0)return-1;let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n)-48;if(r<0||r>9)return-1;t=t*10+r}return t}function ao(e,t){e<0&&Ui(`runtime error: index out of range [${e}]`),Ui(`runtime error: index out of range [${e}] with length ${t}`)}function Fte(e){let t=e.__meta__;return t.target=e,new Proxy(e,{get(e,n,r){let i=io(n);if(i>=0){if(i<t.length)return t.backing[t.offset+i];ao(i,t.length)}return n===`length`?t.length:n===`__meta__`?t:n===`sort`?Lte(t,r):n===`slice`||n===`map`||n===`filter`||n===`reduce`||n===`forEach`||n===Symbol.iterator?Ite(t,n):Reflect.get(e,n)},set(e,n,r){let i=io(n);if(i>=0){if(i<t.length)return t.backing[t.offset+i]=r,e[i]=r,!0;ao(i,t.length)}return n===`length`||n===`__meta__`?!1:Reflect.set(e,n,r)}})}function Ite(e,t){let n=e.backing.slice(e.offset,e.offset+e.length),r=Reflect.get(n,t);return typeof r==`function`?r.bind(n):r}function Lte(e,t){return n=>{let r=e.backing.slice(e.offset,e.offset+e.length);r.sort(n);for(let t=0;t<r.length;t++)e.backing[e.offset+t]=r[t];return t}}function oo(e,t,n,r,i){let a=i??Array(n);return a.length=n,a.__meta__={backing:e,offset:t,length:n,capacity:r},Fte(a)}function so(e){if(e==null)return[];if(e instanceof Uint8Array)return Array.from(e);if(uo(e)){let t=[];for(let n=0;n<e.__meta__.length;n++)t.push(e.__meta__.backing[e.__meta__.offset+n]);return t}return Array.isArray(e)?e:[]}function co(e,t,n){return I(e)<t&&Ui(`runtime error: cannot convert slice with length ${I(e)} to array or pointer to array with length ${t}`),Ea(n===`byte`?new Uint8Array(so(e).slice(0,t)):so(e).slice(0,t))}function lo(e,t,n){I(e)<t&&Ui(`runtime error: cannot convert slice with length ${I(e)} to array or pointer to array with length ${t}`);let r=P(e,0,t),i=m(r);return Object.defineProperty(i,"value",{get:()=>r,set:e=>{R(r,e)}}),i}function uo(e){return typeof e==`object`&&!!e&&`__meta__`in e&&e.__meta__!==void 0}function fo(e){if(e!==void 0)return Number(e)}function po(e){return e.__meta__}function mo(e,t,n){(e<0||t<e||e>n||t>n)&&Ui(`runtime error: slice bounds out of range [${e}:${t}] with capacity ${n}`)}function ho(e,t,n,r){let i=e.subarray(t,t+n);return r!==n&&(i.__meta__={backing:e,offset:t,length:n,capacity:r}),i}function go(e){return uo(e)}const N=(e,t,n,r)=>{if(n===`byte`){let n=t===void 0?e:t;return(e<0||n<0||e>n)&&Ui(n<0?`runtime error: makeslice: cap out of range`:`runtime error: makeslice: len out of range`),n===e?new Uint8Array(e):ho(new Uint8Array(n),0,e,n)}let i=t===void 0?e:t;(e<0||i<0||e>i)&&Ui(i<0?`runtime error: makeslice: cap out of range`:`runtime error: makeslice: len out of range`);let a=()=>{if(r!==void 0)return r();switch(n){case`number`:return 0;case`boolean`:return!1;case`string`:return``;default:return null}},o=Array(i);for(let e=0;e<i;e++)o[e]=a();if(e===i)return o;let s=Array(e);for(let t=0;t<e;t++)s[t]=o[t];let c=s;return c.__meta__={backing:o,offset:0,length:e,capacity:i},new Proxy(c,{get(e,t){let n=io(t);if(n>=0){if(n<e.__meta__.length)return e.__meta__.backing[e.__meta__.offset+n];Ui(`Slice index out of range: ${n} >= ${e.__meta__.length}`)}return t===`length`?e.__meta__.length:t===`__meta__`?e.__meta__:Reflect.get(e,t)},set(e,t,n){let r=io(t);if(r>=0){if(r<e.__meta__.length)return e.__meta__.backing[e.__meta__.offset+r]=n,e[r]=n,!0;Ui(`Slice index out of range: ${r} >= ${e.__meta__.length}`)}return t===`length`||t===`__meta__`?!1:Reflect.set(e,t,n)}})};function P(e,t,n,r){e=Wo(e),t=fo(t),n=fo(n),r=fo(r);let i={get(e,t,n){let r=io(t);if(r>=0){if(r<e.__meta__.length)return e.__meta__.backing[e.__meta__.offset+r];Ui(`Slice index out of range: ${r} >= ${e.__meta__.length}`)}return t===`length`?e.__meta__.length:t===`__meta__`?e.__meta__:t===`sort`?Lte(e.__meta__,n):t===`slice`||t===`map`||t===`filter`||t===`reduce`||t===`forEach`||t===Symbol.iterator?Ite(e.__meta__,t):Reflect.get(e,t)},set(e,t,n){let r=io(t);if(r>=0){if(r<e.__meta__.length)return e.__meta__.backing[e.__meta__.offset+r]=n,e[r]=n,!0;if(r===e.__meta__.length&&e.__meta__.length<e.__meta__.capacity)return e.__meta__.backing[e.__meta__.offset+r]=n,e[r]=n,e.__meta__.length++,!0;Ui(`Slice index out of range: ${r} >= ${e.__meta__.length}`)}return t===`length`||t===`__meta__`?!1:Reflect.set(e,t,n)}};if(e instanceof Uint8Array){let i=po(e),a=i?.backing,o=a instanceof Uint8Array?a:e,s=i?.offset??0,c=i?.capacity??e.length,l=t??0,u=n??e.length;mo(l,u,c);let d=u-l;if(r!==void 0){(r<u||r>c)&&Ui(`runtime error: slice bounds out of range [:${u}:${r}] with capacity ${c}`);let e=r-l;return ho(o,s+l,d,e)}return ho(o,s+l,d,c-l)}if(e==null)return t??=0,n??=0,(t<0||n<t)&&Ui(`runtime error: slice bounds out of range [${t}:${n}]`),(t!==0||n!==0)&&Ui(`runtime error: slice bounds out of range [:${n}] with capacity 0`),r!==void 0&&r!==0&&Ui(`runtime error: slice bounds out of range [::${r}] with capacity 0`),null;let a=I(e);t??=0,n??=a,(t<0||n<t)&&Ui(`runtime error: slice bounds out of range [${t}:${n}]`);let o=_o(e);if(n>o&&Ui(`Slice index out of range: ${n} > ${o}`),Array.isArray(e)&&!uo(e)&&!Da(e)&&t===0&&n===e.length&&r===void 0)return e;let s,c=0,l=o;uo(e)?(s=e.__meta__.backing,c=e.__meta__.offset,l=e.__meta__.capacity):s=e;let u;r===void 0?u=uo(e)?l-t:e.length-t:(r<n&&Ui(`runtime error: slice bounds out of range [:${n}:${r}]`),uo(e)&&r>c+l&&Ui(`Slice index out of range: ${r} > ${c+l}`),!uo(e)&&r>e.length&&Ui(`Slice index out of range: ${r} > ${e.length}`),u=r-t);let d=n-t,f=c+t;if(!Da(s)&&f===0&&d===u&&s.length===d)return s;let p=Array(d);return p.__meta__={backing:s,offset:f,length:d,capacity:u},new Proxy(p,i)}const F=(e,t=1)=>{if(e==null)return[];if(e.length===0||t===1)return e;let n={__meta__:{backing:e,offset:0,length:e.length,capacity:e.length}},r={get(e,t){let n=io(t);if(n>=0){if(n<e.__meta__.length)return e.__meta__.backing[e.__meta__.offset+n];Ui(`Slice index out of range: ${n} >= ${e.__meta__.length}`)}if(t===`length`)return e.__meta__.length;if(t===`__meta__`)return e.__meta__;if(t===`slice`||t===`map`||t===`filter`||t===`reduce`||t===`forEach`||t===Symbol.iterator){let n=e.__meta__.backing.slice(e.__meta__.offset,e.__meta__.offset+e.__meta__.length);return n[t].bind(n)}return Reflect.get(e,t)},set(e,t,n){let r=io(t);if(r>=0){if(r<e.__meta__.length)return e.__meta__.backing[e.__meta__.offset+r]=n,!0;if(r===e.__meta__.length&&e.__meta__.length<e.__meta__.capacity)return e.__meta__.backing[e.__meta__.offset+r]=n,e.__meta__.length++,!0;Ui(`Slice index out of range: ${r} >= ${e.__meta__.length}`)}return t===`length`||t===`__meta__`?!1:Reflect.set(e,t,n)}};if(t>1&&e.length>0)for(let n=0;n<e.length;n++){let r=e[n];!uo(r)&&Array.isArray(r)&&(e[n]=F(r,t-1))}return new Proxy(n,r)},I=e=>{if(e=Wo(e),e==null)return 0;if(typeof e==`string`)return Vo(e);if(e instanceof Uint8Array)return e.length;if(Array.isArray(e)){let t=e.__meta__;return t===void 0?e.length:t.length}if(e instanceof Map||e instanceof Set)return e.size;if(e instanceof Xa)return Vo(e);if(uo(e))return e.__meta__.length;if(typeof e.len==`function`)return e.len();throw Error(`cannot determine len of this type`)},_o=e=>(e=Wo(e),e==null?0:uo(e)?e.__meta__.capacity:e instanceof Uint8Array||Array.isArray(e)?e.length:typeof e.cap==`function`?e.cap():0),vo=Symbol(`goscript.byteSliceHint`),yo=Symbol(`goscript.appendZeroValue`);function bo(e){return{[yo]:e}}const xo=Object.freeze({complex:bo(()=>({real:0,imag:0})),nil:bo(()=>null)});function Rte(e){if(typeof e!=`object`||!e||!(yo in e))return;let t=e[yo];return typeof t==`function`?t:void 0}function So(e,t,n){return t===0?n:Math.max(e<1024?t*2:t+Math.floor(t/4),n)}function zte(e){return e==null?new Uint8Array:e instanceof Uint8Array?e:Uint8Array.from(so(e))}function Co(e){switch(typeof e){case`bigint`:return 0n;case`boolean`:return!1;case`number`:return 0;case`string`:return``}if(e instanceof Xa)return``;if(e instanceof Uint8Array)return new Uint8Array(e.length);if(Array.isArray(e))return e.map(Co);if(typeof e==`object`&&e&&ka(e)){let t=e.constructor;if(typeof t==`function`)return C(Reflect.construct(t,[]))}return null}function L(e,...t){let n=Rte(t[t.length-1]);n!==void 0&&t.pop();let r=!1;t.length>0&&t[t.length-1]===vo&&(r=!0,t.pop());let i=t.length;if(i===0)return e;if(e instanceof Uint8Array||r)return Bte(zte(e),t);let a=0,o,s=!1,c,l,u=0;if(e==null)o=0;else if(uo(e)){let t=e.__meta__;a=t.length,o=t.capacity,s=!0,c=t.backing,l=t.target,u=t.offset}else a=e.length,o=a;let d=a+i;if(s&&d<=o&&c){for(let e=0;e<i;e++){let n=Aa(t[e]);c[u+a+e]=n,l!==void 0&&(l[a+e]=n)}return oo(c,u,d,o,l)}let f=So(a,o,d),p=Array(f);a>0&&Eo(p,0,e,0,a);for(let e=0;e<i;e++)p[a+e]=Aa(t[e]);let ee=t[0];n??=()=>Co(ee);for(let e=d;e<f;e++)p[e]=n();return oo(p,0,d,f)}function wo(e,t,n){if(t==null)return e;let r=typeof t==`string`?Ko(t):t,i=n===vo&&uo(e)&&I(e)+I(r)<=_o(e);if(e instanceof Uint8Array||n===vo&&!i)return Bte(zte(e),[r]);let a=I(r);if(a===0)return e;let o=L(e);if(uo(o)){let e=o.__meta__,t=e.length,n=t+a;if(n<=e.capacity){if(Eo(e.backing,e.offset+t,r,0,a),e.target!==void 0)for(let n=0;n<a;n++)e.target[t+n]=e.backing[e.offset+t+n];return oo(e.backing,e.offset,n,e.capacity,e.target)}}let s=I(o),c=s+a,l=So(s,_o(o),c),u=Array(l);Eo(u,0,o,0,s),Eo(u,s,r,0,a);let d=r[0],f=Rte(n)??(()=>Co(d));for(let e=c;e<l;e++)u[e]=f();return oo(u,0,c,l)}function Bte(e,t){let n=po(e),r=n?.backing,i=r instanceof Uint8Array?r:e,a=n?.offset??0,o=e.length,s=n?.capacity??o,c=0;for(let e of t)c+=Vte(e);let l=o+c;if(l<=s){let e=ho(i,a,l,s);return Hte(e,o,t),e}let u=So(o,s,l),d=new Uint8Array(u);return d.set(e),Hte(d,o,t),ho(d,0,l,u)}function Vte(e){if(e instanceof Uint8Array)return e.length;if(uo(e)||Array.isArray(e))return I(e);if(typeof e!=`number`)throw Error(`Cannot produce Uint8Array: appended elements contain non-numbers.`);return 1}function Hte(e,t,n){let r=t;for(let t of n){if(t instanceof Uint8Array){e.set(t,r),r+=t.length;continue}if(uo(t)||Array.isArray(t)){let n=I(t);for(let i=0;i<n;i++){let n=t[i];if(typeof n!=`number`)throw Error(`Cannot produce Uint8Array: appended elements contain non-numbers.`);e[r]=n,r++}continue}if(typeof t!=`number`)throw Error(`Cannot produce Uint8Array: appended elements contain non-numbers.`);e[r]=t,r++}}function R(e,t){if(e===null)return 0;if(Za(t))return Ute(e,t);if(t===null)return 0;let n=e instanceof Uint8Array?e.length:I(e),r=t instanceof Uint8Array?t.length:I(t),i=Math.min(n,r);return i===0?0:e instanceof Uint8Array&&t instanceof Uint8Array?(e.set(t.subarray(0,i)),i):(Eo(e,0,t,0,i),i)}function To(e,t,n,r,i,a){if(!(e instanceof Uint8Array)||!(r instanceof Uint8Array))return R(P(e,t,n),P(r,i,a));let o=po(e),s=o?.backing??e,c=fo(t)??0,l=fo(n)??e.length;mo(c,l,o?.capacity??e.length);let u=po(r),d=u?.backing??r,f=fo(i)??0,p=fo(a)??r.length;mo(f,p,u?.capacity??r.length);let ee=Math.min(l-c,p-f);if(ee===0)return 0;let te=(o?.offset??0)+c,ne=(u?.offset??0)+f;return s===d?s.copyWithin(te,ne,ne+ee):s.set(d.subarray(ne,ne+ee),te),ee}function Ute(e,t){let n=e instanceof Uint8Array?e.length:I(e),r=Qa(t),i=Math.min(n,r.length);if(i===0)return 0;if(e instanceof Uint8Array)for(let t=0;t<i;t++)e[t]=r[t];else if(uo(e)){let t=e.__meta__;for(let n=0;n<i;n++){let i=r[n];t.backing[t.offset+n]=i,e[n]=i}}else if(Array.isArray(e))for(let t=0;t<i;t++)e[t]=r[t];return i}function Eo(e,t,n,r,i){if(e==null||n==null||i<=0)return;if(e instanceof Uint8Array&&n instanceof Uint8Array){e.set(n.subarray(r,r+i),t);return}let a=uo(n)?n.__meta__:void 0,o=uo(e)?e.__meta__:void 0,s=a?.backing??n,c=o?.backing??e,l=(a?.offset??0)+r,u=(o?.offset??0)+t,d=s===c&&u>l&&u<l+i;for(let e=0;e<i;e++){let n=d?i-1-e:e,r=Aa(s[l+n]);c[u+n]=r,o?.target!==void 0&&(o.target[t+n]=r)}}function Do(e,t){if(e??Ui(`runtime error: index on nil or undefined collection`),e instanceof Uint8Array)return(t<0||t>=e.length)&&ao(t,e.length),e[t];if(uo(e))return(t<0||t>=e.__meta__.length)&&ao(t,e.__meta__.length),e.__meta__.backing[e.__meta__.offset+t];if(Array.isArray(e))return(t<0||t>=e.length)&&ao(t,e.length),e[t];if(Za(e))return Bo(e,t);Ui(`runtime error: index on unsupported type`)}function z(e,t){if(e??ao(t,0),e instanceof Uint8Array)return(t<0||t>=e.length)&&ao(t,e.length),e[t];if(uo(e)){let n=e.__meta__.length;return(t<0||t>=n)&&ao(t,n),e.__meta__.backing[e.__meta__.offset+t]}if(Array.isArray(e))return(t<0||t>=e.length)&&ao(t,e.length),e[t];Ui(`runtime error: index on unsupported type`)}function Oo(e,t){if(e??Ui(`runtime error: index on nil or undefined collection`),e instanceof Uint8Array){(t<0||t>=e.length)&&ao(t,e.length);let n={get value(){return e[t]},set value(n){e[t]=n},__isVarRef:!0,__goAddress:()=>jo(e,t),__goCollection:e,__goIndex:t};return n.__goPointer=ko(n,e,t),n}if(uo(e)){(t<0||t>=e.__meta__.length)&&ao(t,e.__meta__.length);let n=e.__meta__.offset+t,r={get value(){return e.__meta__.backing[n]},set value(n){e[t]=n},__isVarRef:!0,__goAddress:()=>jo(e,t),__goCollection:e,__goIndex:t};return r.__goPointer=ko(r,e,t),r}if(Array.isArray(e)){(t<0||t>=e.length)&&ao(t,e.length);let n={get value(){return e[t]},set value(n){e[t]=n},__isVarRef:!0,__goAddress:()=>jo(e,t),__goCollection:e,__goIndex:t};return n.__goPointer=ko(n,e,t),n}Ui(`runtime error: index on unsupported type`)}function ko(e,t,n){return{__goOwnedPointer:!0,__goAddress:()=>jo(t,n),__goRef:()=>e,__goSlice:e=>(e<0&&Ui(`runtime error: unsafe slice length out of range`),P(t,n,n+e,n+e))}}function Wte(e,t){if(!Ji(e)||e.__goSlice===void 0)throw Error(`reflect.SliceAt requires a GoScript-owned pointer`);return e.__goSlice(t)}function Ao(e,t,n=1,r=n){let i=e.__goCollection;if(i===void 0)throw Error(`unsafe array pointer requires an indexed collection reference`);let a=e.__goIndex??0,o=r===1&&n>1?Jte(No(i,a,n),t):P(i,a,a+t);return{get value(){return o},set value(e){R(o,e)},__isVarRef:!0}}function jo(e,t){e??Ui(`runtime error: index on nil or undefined collection`);let n,r,i;e instanceof Uint8Array?(n=e.buffer,r=e.byteOffset+t,i=e.length):uo(e)?(n=e.__meta__.backing,r=e.__meta__.offset+t,i=e.__meta__.length):Array.isArray(e)?(n=e,r=t,i=e.length):Ui(`runtime error: index on unsupported type`),(t<0||t>=i)&&ao(t,i);let a=Mte.get(n);return a===void 0&&(a=ro*no,ro++,Mte.set(n,a)),a+r}function Gte(e,t){let n=BigInt(t*8);return typeof e==`bigint`?BigInt.asUintN(Number(n),e):typeof e==`number`&&Number.isFinite(e)?BigInt.asUintN(Number(n),BigInt(Math.trunc(e))):0n}function Kte(e,t){let n=BigInt.asUintN(t*8,e);return n<=BigInt(2**53-1)?Number(n):n}function Mo(e,t){let n=Nte.get(e);return n===void 0&&(n=ro*no,ro++,Nte.set(e,n)),Pte.set(n,t),n}function qte(e,t){let n=Math.max(1,Math.trunc(t));return{byteLength:e.length*n,getByte(t){let r=Math.trunc(t/n),i=t%n,a=Gte(e[r],n);return Number(a>>BigInt(i*8)&255n)},setByte(t,r){let i=Math.trunc(t/n),a=t%n,o=BigInt(a*8),s=255n<<o;e[i]=Kte(Gte(e[i],n)&~s|(BigInt(r)&255n)<<o,n)}}}function No(e,t,n){if(e??Ui(`runtime error: index on nil or undefined collection`),e instanceof Uint8Array){(t<0||t>=e.length)&&ao(t,e.length);let n=new Uint8Array(e.buffer);return Mo(e.buffer,{byteLength:n.length,getByte(e){return n[e]},setByte(e,t){n[e]=t}})+e.byteOffset+t}if(uo(e)){(t<0||t>=e.__meta__.length)&&ao(t,e.__meta__.length);let r=e.__meta__.backing,i=Math.max(1,Math.trunc(n));return Mo(r,qte(r,i))+(e.__meta__.offset+t)*i}if(Array.isArray(e)){(t<0||t>=e.length)&&ao(t,e.length);let r=Math.max(1,Math.trunc(n));return Mo(e,qte(e,r))+t*r}Ui(`runtime error: index on unsupported type`)}function Po(e){let t=Number(e),n=Math.floor(t/no)*no,r=Pte.get(n);if(r===void 0)throw Error(`unsafe pointer dereference is not supported in JavaScript/TypeScript`);let i=t-n;return(i<0||i>=r.byteLength)&&Ui(`runtime error: unsafe pointer address out of range`),{get value(){return r.getByte(i)},set value(e){r.setByte(i,e)},__isVarRef:!0}}function Jte(e,t){let n=Number(e),r=Array(t);return new Proxy(r,{get(e,r,i){let a=io(r);return a>=0?(a>=t&&Ui(`Slice index out of range: ${a} >= ${t}`),Po(n+a).value):Reflect.get(e,r,i)},set(e,r,i,a){let o=io(r);return o>=0?(o>=t&&Ui(`Slice index out of range: ${o} >= ${t}`),Po(n+o).value=i,!0):Reflect.set(e,r,i,a)}})}const Yte=e=>Array.from(e).map(e=>e.codePointAt(0)||0),Fo=e=>{let t=[],n=0;for(let r of e)t.push([n,r.codePointAt(0)||0]),n+=Ate.encode(r).length;return t},Io=e=>e.length===0?0:e.codePointAt(0)||0,Lo=e=>{if(!e?.length)return``;let t=``;for(let n of e)t+=Ro(n);return t};function Ro(e){return e<0||e>1114111||e>=55296&&e<=57343?`�`:String.fromCodePoint(e)}const zo=e=>e&255,Bo=(e,t)=>{if(typeof e==`string`&&Number.isInteger(t)&&kte.test(e))return(t<0||t>=e.length)&&ao(t,e.length),e.charCodeAt(t);if(!Za(e))return e instanceof Uint8Array?((t<0||t>=e.length)&&ao(t,e.length),e[t]):(e??ao(t,0),(t<0||t>=e.length)&&ao(t,e.length),e[t]);let n=Qa(e);return(t<0||t>=n.length)&&ao(t,n.length),n[t]},Vo=e=>typeof e==`string`&&kte.test(e)?e.length:Qa(e).length,Ho=(e,t,n)=>{let r=Qa(e),i=t===void 0?0:t,a=n===void 0?r.length:n;if(i<0||a<i||a>r.length){if(i===a&&i>=0&&i<=r.length)return``;Ui(`runtime error: slice bounds out of range [${i}:${a}] with length ${r.length}`)}return to(r.subarray(i,a))};function Xte(e){let t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++)t[n]=Number.parseInt(e.slice(n*2,n*2+2),16);return t}const B=e=>{if(e===null)return``;if(typeof e==`string`)return e;if(e instanceof Uint8Array)return to(e);let t;return t=uo(e)?e.__meta__.backing.slice(e.__meta__.offset,e.__meta__.offset+e.__meta__.length):e,to(Uint8Array.from(t))};function V(e,t){if(typeof e==`string`&&typeof t==`string`)return e===t;let n=eo(e),r=eo(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function Uo(e,t){if(!Za(e)&&!Za(t)){let n=Zte(e),r=Zte(t),i=n.length,a=r.length,o=Math.min(i,a);for(let e=0;e<o;e++){let t=(n.backing[n.offset+e]??0)-(r.backing[r.offset+e]??0);if(t!==0)return t}return i-a}let n=eo(e),r=eo(t),i=Math.min(n.length,r.length);for(let e=0;e<i;e++){let t=n[e]-r[e];if(t!==0)return t}return n.length-r.length}function Zte(e){if(e=Wo(e),e==null)return{backing:[],offset:0,length:0};if(e instanceof Uint8Array)return{backing:e,offset:0,length:e.length};if(Array.isArray(e)){let t=e.__meta__;return t===void 0?{backing:e,offset:0,length:e.length}:{backing:t.backing,offset:t.offset,length:t.length}}if(Za(e)){let t=Qa(e);return{backing:t,offset:0,length:t.length}}return{backing:[],offset:0,length:0}}function Wo(e){return g(e)?Wo(e.value):Fa(e)?null:typeof e==`object`&&e&&typeof e.__goType==`string`&&`__goValue`in e?Wo(e.__goValue):e}function Go(e){let t=32768,n=``;for(let r=0;r<e.length;r+=t)n+=String.fromCharCode(...e.subarray(r,r+t));return n}function Qte(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function Ko(e){return Za(e)?Qa(e):e instanceof Uint8Array?e:e==null?new Uint8Array:new Uint8Array(Array.isArray(e)?e:[])}function $te(e){return m({get Data(){return{kind:`string`,value:e.value}},set Data(e){},get Len(){return Ko(e.value).length},set Len(e){}})}function ene(e){let t=null,n=0,r=0,i=()=>{if(t===null)return;let i=Ko(t.value),a=N(n,Math.max(r,n),`byte`);a!==null&&R(a,P(i,0,Math.min(n,i.length))),e.value=a};return m({get Data(){return t},set Data(e){t=e,i()},get Len(){return n},set Len(e){n=e,i()},get Cap(){return r},set Cap(e){r=e,i()}})}function tne(e){return e==null?``:Za(e)?e:B(e)}function qo(e,t){return(t<0||t>=e.length)&&ao(t,e.length),e.charCodeAt(t)}function Jo(e,t){if(Za(e))return Bo(e,t);if(e instanceof Uint8Array)return(t<0||t>=e.length)&&ao(t,e.length),e[t];if(e===null)ao(t,0);else{let n=I(e);return(t<0||t>=n)&&ao(t,n),e[t]}}function Yo(e,t,n,r){return Za(e)?Ho(e,t,n):P(e,t,n,r)}function nne(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}function Xo(e,t){return e.some(nne)?Promise.all(e.map(e=>Promise.resolve(e))).then(e=>e.join(t)):e.join(t)}function Zo(e,t,n,r){let i=Xo(e,t);return nne(i)?Promise.resolve(i).then(e=>`${n}${e}${r}`):`${n}${i}${r}`}function rne(e){return Zo(e.map(ine),` `,``,``)}function ine(e){return Qo(e,0,!1,new WeakSet)}function Qo(e,t,n,r){if(e===null)return`null`;if(e===void 0)return`<nil>`;if(typeof e==`string`)return n?JSON.stringify(e):e;if(typeof e==`boolean`)return String(e);if(typeof e==`number`)return e===1/0?`+Inf`:e===-1/0?`-Inf`:String(e);if(typeof e==`bigint`)return e.toString();if(e instanceof Uint8Array)return ane(e);if(Array.isArray(e))return $o(e,t,r);if(go(e))return $o(so(e),t,r);if(typeof e==`function`)return e.name?`[Function: ${e.name}]`:`[Function]`;if(typeof e!=`object`)return String(e);if(r.has(e))return`[Circular]`;r.add(e);try{if(g(e))return Qo(e.value,t,n,r);if(e instanceof Map)return $o(Array.from(e.entries()).map(([e,n])=>Xo([Qo(e,t+1,!0,r),Qo(n,t+1,!0,r)],` => `)),t,r);if(e instanceof Set)return $o(Array.from(e.values()),t,r);if(e instanceof Error)return e.message||e.toString();if(typeof e.GoString==`function`)return e.GoString();if(typeof e.Error==`function`)return e.Error();if(typeof e.String==`function`)return e.String();let i=sne(e);return i.length===0?`{}`:one(i,t,r)}finally{r.delete(e)}}function ane(e){return e.length===0?`Uint8Array(0) []`:`Uint8Array(${e.length}) [ ${Array.from(e).join(`, `)} ]`}function $o(e,t,n){return e.length===0?`[]`:Zo(e.map(e=>Qo(e,t+1,!0,n)),`, `,`[ `,` ]`)}function one(e,t,n){let r=` `.repeat(t+1),i=` `.repeat(t);return Zo(e.map(([e,i])=>Xo([`${r}${e}: `,Qo(i,t+1,!0,n),`,`],``)),`
|
|
3
3
|
`,`{
|
|
4
4
|
`,`\n${i}}`)}function sne(e){let t=e._fields;return t&&typeof t==`object`&&!Array.isArray(t)?Object.entries(t):Object.entries(e).filter(([,e])=>typeof e!=`function`)}async function es(...e){Ya(e.length===0?``:await rne(e))}async function ts(...e){Ya((e.length===0?``:await rne(e))+`
|