@influxdata/influxdb3-client 2.0.0 → 2.1.0-nightly.11532
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/index.browser.js +1 -1
- package/dist/index.browser.js.gz +0 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +1 -1
- package/dist/index.browser.mjs.gz +0 -0
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.gz +0 -0
- package/dist/index.mjs.map +1 -1
- package/dist/influxdb.js +1 -1
- package/dist/influxdb.js.gz +0 -0
- package/dist/influxdb.js.map +1 -1
- package/package.json +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
${JSON.stringify(t)}`),new Pt.GrpcWebFetchTransport({baseUrl:n,timeout:e})};var Fr={writeTransport:n=>new J(n),queryTransport:Dt},C=Fr;var G=class{constructor(e){this._options=e;d(this,"_closed",!1);d(this,"_transport");var t;this._transport=(t=this._options.transport)!=null?t:C.writeTransport(this._options),this.doWrite=this.doWrite.bind(this)}_createWritePath(e,t,r){let i=t.precision,s,o=[];return r&&o.push(`org=${encodeURIComponent(r)}`),t.noSync?(s="/api/v3/write_lp",o.push(`db=${encodeURIComponent(e)}`),o.push(`precision=${Pe(i)}`),o.push("no_sync=true")):(s="/api/v2/write",o.push(`bucket=${encodeURIComponent(e)}`),o.push(`precision=${Ae(i)}`)),`${s}?${o.join("&")}`}doWrite(e,t,r,i){if(this._closed)return Promise.reject(new Error("writeApi: already closed!"));if(e.length<=0||e.length===1&&e[0]==="")return Promise.resolve();let o,a,l=new Promise((h,x)=>{o=h,a=x}),c={..._e,...i},f,m,p={responseStarted(h,x){f=x,m=h},error(h){if(h instanceof E&&h.json&&typeof h.json.error=="string"&&h.json.error.includes("hinted handoff queue not empty")){U.warn(`Write to InfluxDB returns: ${h.json.error}`),f=204,p.complete();return}h instanceof E&&h.statusCode==405&&c.noSync&&(h=new E(h.statusCode,"Server doesn't support write with noSync=true (supported by InfluxDB 3 Core/Enterprise servers only).",h.body,h.contentType,h.headers)),U.error("Write to InfluxDB failed.",h),a(h)},complete(){if(f==null||f>=200&&f<300)o();else{let h=`2xx HTTP response status code expected, but ${f} returned`,x=new E(f,h,void 0,"0",m);x.message=h,p.error(x)}}},F={method:"POST",headers:{"content-type":"text/plain; charset=utf-8",...i==null?void 0:i.headers},gzipThreshold:c.gzipThreshold};return this._transport.send(this._createWritePath(t,c,r),e.join(`
|
|
11
11
|
`),F,p),l}async close(){this._closed=!0}};var Ie=H("apache-arrow");var rr=H("@protobuf-ts/runtime-rpc");function L(n){let e=typeof n;if(e=="object"){if(Array.isArray(n))return"array";if(n===null)return"null"}return e}function We(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}var S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),ie=[];for(let n=0;n<S.length;n++)ie[S[n].charCodeAt(0)]=n;ie[45]=S.indexOf("+");ie[95]=S.indexOf("/");function Ut(n){let e=n.length*3/4;n[n.length-2]=="="?e-=2:n[n.length-1]=="="&&(e-=1);let t=new Uint8Array(e),r=0,i=0,s,o=0;for(let a=0;a<n.length;a++){if(s=ie[n.charCodeAt(a)],s===void 0)switch(n[a]){case"=":i=0;case`
|
|
12
|
-
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(i){case 0:o=s,i=1;break;case 1:t[r++]=o<<2|(s&48)>>4,o=s,i=2;break;case 2:t[r++]=(o&15)<<4|(s&60)>>2,o=s,i=3;break;case 3:t[r++]=(o&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,r)}function Ct(n){let e="",t=0,r,i=0;for(let s=0;s<n.length;s++)switch(r=n[s],t){case 0:e+=S[r>>2],i=(r&3)<<4,t=1;break;case 1:e+=S[i|r>>4],i=(r&15)<<2,t=2;break;case 2:e+=S[i|r>>6],e+=S[r&63],t=0;break}return t&&(e+=S[i],e+="=",t==1&&(e+="=")),e}var M;(function(n){n.symbol=Symbol.for("protobuf-ts/unknown"),n.onRead=(t,r,i,s,o)=>{(e(r)?r[n.symbol]:r[n.symbol]=[]).push({no:i,wireType:s,data:o})},n.onWrite=(t,r,i)=>{for(let{no:s,wireType:o,data:a}of n.list(r))i.tag(s,o).raw(a)},n.list=(t,r)=>{if(e(t)){let i=t[n.symbol];return r?i.filter(s=>s.no==r):i}return[]},n.last=(t,r)=>n.list(t,r).slice(-1)[0];let e=t=>t&&Array.isArray(t[n.symbol])})(M||(M={}));var T;(function(n){n[n.Varint=0]="Varint",n[n.Bit64=1]="Bit64",n[n.LengthDelimited=2]="LengthDelimited",n[n.StartGroup=3]="StartGroup",n[n.EndGroup=4]="EndGroup",n[n.Bit32=5]="Bit32"})(T||(T={}));function Lt(){let n=0,e=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(n|=(i&127)<<r,(i&128)==0)return this.assertBounds(),[n,e]}let t=this.buf[this.pos++];if(n|=(t&15)<<28,e=(t&112)>>4,(t&128)==0)return this.assertBounds(),[n,e];for(let r=3;r<=31;r+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<r,(i&128)==0)return this.assertBounds(),[n,e]}throw new Error("invalid varint")}function oe(n,e,t){for(let s=0;s<28;s=s+7){let o=n>>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}let r=n>>>28&15|(e&7)<<4,i=e>>3!=0;if(t.push((i?r|128:r)&255),!!i){for(let s=3;s<31;s=s+7){let o=e>>>s,a=!!(o>>>7),l=(a?o|128:o)&255;if(t.push(l),!a)return}t.push(e>>>31&1)}}var se=65536*65536;function $e(n){let e=n[0]=="-";e&&(n=n.slice(1));let t=1e6,r=0,i=0;function s(o,a){let l=Number(n.slice(o,a));i*=t,r=r*t+l,r>=se&&(i=i+(r/se|0),r=r%se)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,r,i]}function ae(n,e){if(e>>>0<=2097151)return""+(se*e+(n>>>0));let t=n&16777215,r=(n>>>24|e<<8)>>>0&16777215,i=e>>16&65535,s=t+r*6777216+i*6710656,o=r+i*8147497,a=i*2,l=1e7;s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l);function c(f,m){let p=f?String(f):"";return m?"0000000".slice(p.length)+p:p}return c(a,0)+c(o,a)+c(s,1)}function qe(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function Bt(){let n=this.buf[this.pos++],e=n&127;if((n&128)==0)return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,(n&128)==0)return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,(n&128)==0)return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,(n&128)==0)return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;(n&128)!==0&&t<10;t++)n=this.buf[this.pos++];if((n&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var y;function xr(){let n=new DataView(new ArrayBuffer(8));y=globalThis.BigInt!==void 0&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:n}:void 0}xr();function Vt(n){if(!n)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var vt=/^-?[0-9]+$/,ue=4294967296,le=2147483648,ce=class{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*ue+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},O=class n extends ce{static from(e){if(y)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=y.C(e);case"number":if(e===0)return this.ZERO;e=y.C(e);case"bigint":if(!e)return this.ZERO;if(e<y.UMIN)throw new Error("signed value for ulong");if(e>y.UMAX)throw new Error("ulong too large");return y.V.setBigUint64(0,e,!0),new n(y.V.getInt32(0,!0),y.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!vt.test(e))throw new Error("string is no integer");let[t,r,i]=$e(e);if(t)throw new Error("signed value for ulong");return new n(r,i);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new n(e,e/ue)}throw new Error("unknown value "+typeof e)}toString(){return y?this.toBigInt().toString():ae(this.lo,this.hi)}toBigInt(){return Vt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigUint64(0,!0)}};O.ZERO=new O(0,0);var b=class n extends ce{static from(e){if(y)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=y.C(e);case"number":if(e===0)return this.ZERO;e=y.C(e);case"bigint":if(!e)return this.ZERO;if(e<y.MIN)throw new Error("signed long too small");if(e>y.MAX)throw new Error("signed long too large");return y.V.setBigInt64(0,e,!0),new n(y.V.getInt32(0,!0),y.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!vt.test(e))throw new Error("string is no integer");let[t,r,i]=$e(e);if(t){if(i>le||i==le&&r!=0)throw new Error("signed long too small")}else if(i>=le)throw new Error("signed long too large");let s=new n(r,i);return t?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new n(e,e/ue):new n(-e,-e/ue).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&le)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new n(t,e)}toString(){if(y)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+ae(e.lo,e.hi)}return ae(this.lo,this.hi)}toBigInt(){return Vt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigInt64(0,!0)}};b.ZERO=new b(0,0);var Mt={readUnknownField:!0,readerFactory:n=>new He(n)};function Wt(n){return n?Object.assign(Object.assign({},Mt),n):Mt}var He=class{constructor(e,t){this.varint64=Lt,this.uint32=Bt,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t!=null?t:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e){let t=this.pos;switch(e){case T.Varint:for(;this.buf[this.pos++]&128;);break;case T.Bit64:this.pos+=4;case T.Bit32:this.pos+=4;break;case T.LengthDelimited:let r=this.uint32();this.pos+=r;break;case T.StartGroup:let i;for(;(i=this.tag()[1])!==T.EndGroup;)this.skip(i);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new b(...this.varint64())}uint64(){return new O(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,new b(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 new O(this.sfixed32(),this.sfixed32())}sfixed64(){return new b(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(){return this.textDecoder.decode(this.bytes())}};function g(n,e){if(!n)throw new Error(e)}var Ir=34028234663852886e22,Nr=-34028234663852886e22,Er=4294967295,kr=2147483647,_r=-2147483648;function P(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>kr||n<_r)throw new Error("invalid int 32: "+n)}function B(n){if(typeof n!="number")throw new Error("invalid uint 32: "+typeof n);if(!Number.isInteger(n)||n>Er||n<0)throw new Error("invalid uint 32: "+n)}function W(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>Ir||n<Nr))throw new Error("invalid float 32: "+n)}var $t={writeUnknownFields:!0,writerFactory:()=>new Xe};function qt(n){return n?Object.assign(Object.assign({},$t),n):$t}var Xe=class{constructor(e){this.stack=[],this.textEncoder=e!=null?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let i=0;i<this.chunks.length;i++)e+=this.chunks[i].length;let t=new Uint8Array(e),r=0;for(let i=0;i<this.chunks.length;i++)t.set(this.chunks[i],r),r+=this.chunks[i].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 new 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(B(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return P(e),qe(e,this.buf),this}bool(e){return this.buf.push(e?1:0),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){W(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){B(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){P(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return P(e),e=(e<<1^e>>31)>>>0,qe(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=b.from(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=O.from(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=b.from(e);return oe(t.lo,t.hi,this.buf),this}sint64(e){let t=b.from(e),r=t.hi>>31,i=t.lo<<1^r,s=(t.hi<<1|t.lo>>>31)^r;return oe(i,s,this.buf),this}uint64(e){let t=O.from(e);return oe(t.lo,t.hi,this.buf),this}};var Ht={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Xt={ignoreUnknownFields:!1};function jt(n){return n?Object.assign(Object.assign({},Xt),n):Xt}function Jt(n){return n?Object.assign(Object.assign({},Ht),n):Ht}var fe=Symbol.for("protobuf-ts/message-type");function je(n){let e=!1,t=[];for(let r=0;r<n.length;r++){let i=n.charAt(r);i=="_"?e=!0:/\d/.test(i)?(t.push(i),e=!0):e?(t.push(i.toUpperCase()),e=!1):r==0?t.push(i.toLowerCase()):t.push(i)}return t.join("")}var u;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(u||(u={}));var I;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING",n[n.NUMBER=2]="NUMBER"})(I||(I={}));var K;(function(n){n[n.NO=0]="NO",n[n.PACKED=1]="PACKED",n[n.UNPACKED=2]="UNPACKED"})(K||(K={}));function Gt(n){var e,t,r,i;return n.localName=(e=n.localName)!==null&&e!==void 0?e:je(n.name),n.jsonName=(t=n.jsonName)!==null&&t!==void 0?t:je(n.name),n.repeat=(r=n.repeat)!==null&&r!==void 0?r:K.NO,n.opt=(i=n.opt)!==null&&i!==void 0?i:n.repeat||n.oneof?!1:n.kind=="message",n}function Kt(n){if(typeof n!="object"||n===null||!n.hasOwnProperty("oneofKind"))return!1;switch(typeof n.oneofKind){case"string":return n[n.oneofKind]===void 0?!1:Object.keys(n).length==2;case"undefined":return Object.keys(n).length==1;default:return!1}}var pe=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;let e=[],t=[],r=[];for(let i of this.fields)if(i.oneof)r.includes(i.oneof)||(r.push(i.oneof),e.push(i.oneof),t.push(i.oneof));else switch(t.push(i.localName),i.kind){case"scalar":case"enum":(!i.opt||i.repeat)&&e.push(i.localName);break;case"message":i.repeat&&e.push(i.localName);break;case"map":e.push(i.localName);break}this.data={req:e,known:t,oneofs:Object.values(r)}}is(e,t,r=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let i=Object.keys(e),s=this.data;if(i.length<s.req.length||s.req.some(o=>!i.includes(o))||!r&&i.some(o=>!s.known.includes(o)))return!1;if(t<1)return!0;for(let o of s.oneofs){let a=e[o];if(!Kt(a))return!1;if(a.oneofKind===void 0)continue;let l=this.fields.find(c=>c.localName===a.oneofKind);if(!l||!this.field(a[a.oneofKind],l,r,t))return!1}for(let o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,r,t))return!1;return!0}field(e,t,r,i){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,i,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,u.INT32,i):this.scalar(e,u.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),r,i):this.message(e,t.T(),r,i);case"map":if(typeof e!="object"||e===null)return!1;if(i<2)return!0;if(!this.mapKeys(e,t.K,i))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,i,t.V.L);case"enum":return this.scalars(Object.values(e),u.INT32,i);case"message":return this.messages(Object.values(e),t.V.T(),r,i)}break}return!0}message(e,t,r,i){return r?t.isAssignable(e,i):t.is(e,i)}messages(e,t,r,i){if(!Array.isArray(e))return!1;if(i<2)return!0;if(r){for(let s=0;s<e.length&&s<i;s++)if(!t.isAssignable(e[s],i-1))return!1}else for(let s=0;s<e.length&&s<i;s++)if(!t.is(e[s],i-1))return!1;return!0}scalar(e,t,r){let i=typeof e;switch(t){case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:switch(r){case I.BIGINT:return i=="bigint";case I.NUMBER:return i=="number"&&!isNaN(e);default:return i=="string"}case u.BOOL:return i=="boolean";case u.STRING:return i=="string";case u.BYTES:return e instanceof Uint8Array;case u.DOUBLE:case u.FLOAT:return i=="number"&&!isNaN(e);default:return i=="number"&&Number.isInteger(e)}}scalars(e,t,r,i){if(!Array.isArray(e))return!1;if(r<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<r;s++)if(!this.scalar(e[s],t,i))return!1}return!0}mapKeys(e,t,r){let i=Object.keys(e);switch(t){case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:return this.scalars(i.slice(0,r).map(s=>parseInt(s)),t,r);case u.BOOL:return this.scalars(i.slice(0,r).map(s=>s=="true"?!0:s=="false"?!1:s),t,r);default:return this.scalars(i,t,r,I.STRING)}}};function N(n,e){switch(e){case I.BIGINT:return n.toBigInt();case I.NUMBER:return n.toNumber();default:return n.toString()}}var me=class{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};let t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(let r of t)this.fMap[r.name]=r,this.fMap[r.jsonName]=r,this.fMap[r.localName]=r}}assert(e,t,r){if(!e){let i=L(r);throw(i=="number"||i=="boolean")&&(i=r.toString()),new Error(`Cannot parse JSON ${i} for ${this.info.typeName}#${t}`)}}read(e,t,r){this.prepare();let i=[];for(let[s,o]of Object.entries(e)){let a=this.fMap[s];if(!a){if(!r.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}let l=a.localName,c;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(i.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);i.push(a.oneof),c=t[a.oneof]={oneofKind:l}}else c=t;if(a.kind=="map"){if(o===null)continue;this.assert(We(o),a.name,o);let f=c[l];for(let[m,p]of Object.entries(o)){this.assert(p!==null,a.name+" map value",null);let F;switch(a.V.kind){case"message":F=a.V.T().internalJsonRead(p,r);break;case"enum":if(F=this.enum(a.V.T(),p,a.name,r.ignoreUnknownFields),F===!1)continue;break;case"scalar":F=this.scalar(p,a.V.T,a.V.L,a.name);break}this.assert(F!==void 0,a.name+" map value",p);let h=m;a.K==u.BOOL&&(h=h=="true"?!0:h=="false"?!1:h),h=this.scalar(h,a.K,I.STRING,a.name).toString(),f[h]=F}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let f=c[l];for(let m of o){this.assert(m!==null,a.name,null);let p;switch(a.kind){case"message":p=a.T().internalJsonRead(m,r);break;case"enum":if(p=this.enum(a.T(),m,a.name,r.ignoreUnknownFields),p===!1)continue;break;case"scalar":p=this.scalar(m,a.T,a.L,a.name);break}this.assert(p!==void 0,a.name,o),f.push(p)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}c[l]=a.T().internalJsonRead(o,r,c[l]);break;case"enum":if(o===null)continue;let f=this.enum(a.T(),o,a.name,r.ignoreUnknownFields);if(f===!1)continue;c[l]=f;break;case"scalar":if(o===null)continue;c[l]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,r,i){if(e[0]=="google.protobuf.NullValue"&&g(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return g(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${r}, enum can only be integral number, got ${t}.`),t;case"string":let s=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(s=t.substring(e[2].length));let o=e[1][s];return typeof o=="undefined"&&i?!1:(g(typeof o=="number",`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} has no value for "${t}".`),o)}g(!1,`Unable to parse field ${this.info.typeName}#${r}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,r,i){let s;try{switch(t){case u.DOUBLE:case u.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let o=Number(e);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return t==u.FLOAT&&W(o),o;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":a=Number(e)),a===void 0)break;return t==u.UINT32?B(a):P(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return N(b.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return N(b.from(e),r);case u.FIXED64:case u.UINT64:if(e===null)return N(O.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return N(O.from(e),r);case u.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case u.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(l){l="invalid UTF8";break}return e;case u.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return Ut(e)}}catch(o){s=o.message}this.assert(!1,i+(s?" - "+s:""),e)}};var he=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){let r={},i=e;for(let s of this.fields){if(!s.oneof){let c=this.field(s,i[s.localName],t);c!==void 0&&(r[t.useProtoFieldName?s.name:s.jsonName]=c);continue}let o=i[s.oneof];if(o.oneofKind!==s.localName)continue;let a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t,l=this.field(s,o[s.localName],a);g(l!==void 0),r[t.useProtoFieldName?s.name:s.jsonName]=l}return r}field(e,t,r){let i;if(e.kind=="map"){g(typeof t=="object"&&t!==null);let s={};switch(e.V.kind){case"scalar":for(let[l,c]of Object.entries(t)){let f=this.scalar(e.V.T,c,e.name,!1,!0);g(f!==void 0),s[l.toString()]=f}break;case"message":let o=e.V.T();for(let[l,c]of Object.entries(t)){let f=this.message(o,c,e.name,r);g(f!==void 0),s[l.toString()]=f}break;case"enum":let a=e.V.T();for(let[l,c]of Object.entries(t)){g(c===void 0||typeof c=="number");let f=this.enum(a,c,e.name,!1,!0,r.enumAsInteger);g(f!==void 0),s[l.toString()]=f}break}(r.emitDefaultValues||Object.keys(s).length>0)&&(i=s)}else if(e.repeat){g(Array.isArray(t));let s=[];switch(e.kind){case"scalar":for(let l=0;l<t.length;l++){let c=this.scalar(e.T,t[l],e.name,e.opt,!0);g(c!==void 0),s.push(c)}break;case"enum":let o=e.T();for(let l=0;l<t.length;l++){g(t[l]===void 0||typeof t[l]=="number");let c=this.enum(o,t[l],e.name,e.opt,!0,r.enumAsInteger);g(c!==void 0),s.push(c)}break;case"message":let a=e.T();for(let l=0;l<t.length;l++){let c=this.message(a,t[l],e.name,r);g(c!==void 0),s.push(c)}break}(r.emitDefaultValues||s.length>0||r.emitDefaultValues)&&(i=s)}else switch(e.kind){case"scalar":i=this.scalar(e.T,t,e.name,e.opt,r.emitDefaultValues);break;case"enum":i=this.enum(e.T(),t,e.name,e.opt,r.emitDefaultValues,r.enumAsInteger);break;case"message":i=this.message(e.T(),t,e.name,r);break}return i}enum(e,t,r,i,s,o){if(e[0]=="google.protobuf.NullValue")return!s&&!i?void 0:null;if(t===void 0){g(i);return}if(!(t===0&&!s&&!i))return g(typeof t=="number"),g(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,r,i){return t===void 0?i.emitDefaultValues?null:void 0:e.internalJsonWrite(t,i)}scalar(e,t,r,i,s){if(t===void 0){g(i);return}let o=s||i;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(P(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(B(t),t);case u.FLOAT:W(t);case u.DOUBLE:return t===0?o?0:void 0:(g(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case u.STRING:return t===""?o?"":void 0:(g(typeof t=="string"),t);case u.BOOL:return t===!1?o?!1:void 0:(g(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:g(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=O.from(t);return a.isZero()&&!o?void 0:a.toString();case u.INT64:case u.SFIXED64:case u.SINT64:g(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let l=b.from(t);return l.isZero()&&!o?void 0:l.toString();case u.BYTES:return g(t instanceof Uint8Array),t.byteLength?Ct(t):o?"":void 0}}};function Q(n,e=I.STRING){switch(n){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return N(O.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return N(b.ZERO,e);case u.DOUBLE:case u.FLOAT:return 0;case u.BYTES:return new Uint8Array(0);case u.STRING:return"";default:return 0}}var de=class{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){let t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(r=>[r.no,r]))}}read(e,t,r,i){this.prepare();let s=i===void 0?e.len:e.pos+i;for(;e.pos<s;){let[o,a]=e.tag(),l=this.fieldNoToField.get(o);if(!l){let p=r.readUnknownField;if(p=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let F=e.skip(a);p!==!1&&(p===!0?M.onRead:p)(this.info.typeName,t,o,a,F);continue}let c=t,f=l.repeat,m=l.localName;switch(l.oneof&&(c=c[l.oneof],c.oneofKind!==m&&(c=t[l.oneof]={oneofKind:m})),l.kind){case"scalar":case"enum":let p=l.kind=="enum"?u.INT32:l.T,F=l.kind=="scalar"?l.L:void 0;if(f){let D=c[m];if(a==T.LengthDelimited&&p!=u.STRING&&p!=u.BYTES){let q=e.uint32()+e.pos;for(;e.pos<q;)D.push(this.scalar(e,p,F))}else D.push(this.scalar(e,p,F))}else c[m]=this.scalar(e,p,F);break;case"message":if(f){let D=c[m],q=l.T().internalBinaryRead(e,e.uint32(),r);D.push(q)}else c[m]=l.T().internalBinaryRead(e,e.uint32(),r,c[m]);break;case"map":let[h,x]=this.mapEntry(l,e,r);c[m][h]=x;break}}}mapEntry(e,t,r){let i=t.uint32(),s=t.pos+i,o,a;for(;t.pos<s;){let[l,c]=t.tag();switch(l){case 1:e.K==u.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,I.STRING);break;case 2:switch(e.V.kind){case"scalar":a=this.scalar(t,e.V.T,e.V.L);break;case"enum":a=t.int32();break;case"message":a=e.V.T().internalBinaryRead(t,t.uint32(),r);break}break;default:throw new Error(`Unknown field ${l} (wire type ${c}) in map entry for ${this.info.typeName}#${e.name}`)}}if(o===void 0){let l=Q(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=Q(e.V.T,e.V.L);break;case"enum":a=0;break;case"message":a=e.V.T().create();break}return[o,a]}scalar(e,t,r){switch(t){case u.INT32:return e.int32();case u.STRING:return e.string();case u.BOOL:return e.bool();case u.DOUBLE:return e.double();case u.FLOAT:return e.float();case u.INT64:return N(e.int64(),r);case u.UINT64:return N(e.uint64(),r);case u.FIXED64:return N(e.fixed64(),r);case u.FIXED32:return e.fixed32();case u.BYTES:return e.bytes();case u.UINT32:return e.uint32();case u.SFIXED32:return e.sfixed32();case u.SFIXED64:return N(e.sfixed64(),r);case u.SINT32:return e.sint32();case u.SINT64:return N(e.sint64(),r)}}};var ge=class{constructor(e){this.info=e}prepare(){if(!this.fields){let e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,r)=>t.no-r.no)}}write(e,t,r){this.prepare();for(let s of this.fields){let o,a,l=s.repeat,c=s.localName;if(s.oneof){let f=e[s.oneof];if(f.oneofKind!==c)continue;o=f[c],a=!0}else o=e[c],a=!1;switch(s.kind){case"scalar":case"enum":let f=s.kind=="enum"?u.INT32:s.T;if(l)if(g(Array.isArray(o)),l==K.PACKED)this.packed(t,f,s.no,o);else for(let m of o)this.scalar(t,f,s.no,m,!0);else o===void 0?g(s.opt):this.scalar(t,f,s.no,o,a||s.opt);break;case"message":if(l){g(Array.isArray(o));for(let m of o)this.message(t,r,s.T(),s.no,m)}else this.message(t,r,s.T(),s.no,o);break;case"map":g(typeof o=="object"&&o!==null);for(let[m,p]of Object.entries(o))this.mapEntry(t,r,s,m,p);break}}let i=r.writeUnknownFields;i!==!1&&(i===!0?M.onWrite:i)(this.info.typeName,e,t)}mapEntry(e,t,r,i,s){e.tag(r.no,T.LengthDelimited),e.fork();let o=i;switch(r.K){case u.INT32:case u.FIXED32:case u.UINT32:case u.SFIXED32:case u.SINT32:o=Number.parseInt(i);break;case u.BOOL:g(i=="true"||i=="false"),o=i=="true";break}switch(this.scalar(e,r.K,1,o,!0),r.V.kind){case"scalar":this.scalar(e,r.V.T,2,s,!0);break;case"enum":this.scalar(e,u.INT32,2,s,!0);break;case"message":this.message(e,t,r.V.T(),2,s);break}e.join()}message(e,t,r,i,s){s!==void 0&&(r.internalBinaryWrite(s,e.tag(i,T.LengthDelimited).fork(),t),e.join())}scalar(e,t,r,i,s){let[o,a,l]=this.scalarInfo(t,i);(!l||s)&&(e.tag(r,o),e[a](i))}packed(e,t,r,i){if(!i.length)return;g(t!==u.BYTES&&t!==u.STRING),e.tag(r,T.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let o=0;o<i.length;o++)e[s](i[o]);e.join()}scalarInfo(e,t){let r=T.Varint,i,s=t===void 0,o=t===0;switch(e){case u.INT32:i="int32";break;case u.STRING:o=s||!t.length,r=T.LengthDelimited,i="string";break;case u.BOOL:o=t===!1,i="bool";break;case u.UINT32:i="uint32";break;case u.DOUBLE:r=T.Bit64,i="double";break;case u.FLOAT:r=T.Bit32,i="float";break;case u.INT64:o=s||b.from(t).isZero(),i="int64";break;case u.UINT64:o=s||O.from(t).isZero(),i="uint64";break;case u.FIXED64:o=s||O.from(t).isZero(),r=T.Bit64,i="fixed64";break;case u.BYTES:o=s||!t.byteLength,r=T.LengthDelimited,i="bytes";break;case u.FIXED32:r=T.Bit32,i="fixed32";break;case u.SFIXED32:r=T.Bit32,i="sfixed32";break;case u.SFIXED64:o=s||b.from(t).isZero(),r=T.Bit64,i="sfixed64";break;case u.SINT32:i="sint32";break;case u.SINT64:o=s||b.from(t).isZero(),i="sint64";break}return[r,i,s||o]}};function Qt(n){let e=n.messagePrototype?Object.create(n.messagePrototype):Object.defineProperty({},fe,{value:n});for(let t of n.fields){let r=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[r]=[];else switch(t.kind){case"scalar":e[r]=Q(t.T,t.L);break;case"enum":e[r]=0;break;case"map":e[r]={};break}}return e}function be(n,e,t){let r,i=t,s;for(let o of n.fields){let a=o.localName;if(o.oneof){let l=i[o.oneof];if((l==null?void 0:l.oneofKind)==null)continue;if(r=l[a],s=e[o.oneof],s.oneofKind=l.oneofKind,r==null){delete s[a];continue}}else if(r=i[a],s=e,r==null)continue;switch(o.repeat&&(s[a].length=r.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let c=0;c<r.length;c++)s[a][c]=r[c];else s[a]=r;break;case"message":let l=o.T();if(o.repeat)for(let c=0;c<r.length;c++)s[a][c]=l.create(r[c]);else s[a]===void 0?s[a]=l.create(r):l.mergePartial(s[a],r);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],r);break;case"message":let c=o.V.T();for(let f of Object.keys(r))s[a][f]=c.create(r[f]);break}break}}}function zt(n,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let r of n.fields){let i=r.localName,s=r.oneof?e[r.oneof][i]:e[i],o=r.oneof?t[r.oneof][i]:t[i];switch(r.kind){case"enum":case"scalar":let a=r.kind=="enum"?u.INT32:r.T;if(!(r.repeat?Zt(a,s,o):er(a,s,o)))return!1;break;case"map":if(!(r.V.kind=="message"?Yt(r.V.T(),ye(s),ye(o)):Zt(r.V.kind=="enum"?u.INT32:r.V.T,ye(s),ye(o))))return!1;break;case"message":let l=r.T();if(!(r.repeat?Yt(l,s,o):l.equals(s,o)))return!1;break}}return!0}var ye=Object.values;function er(n,e,t){if(e===t)return!0;if(n!==u.BYTES)return!1;let r=e,i=t;if(r.length!==i.length)return!1;for(let s=0;s<r.length;s++)if(r[s]!=i[s])return!1;return!0}function Zt(n,e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!er(n,e[r],t[r]))return!1;return!0}function Yt(n,e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!n.equals(e[r],t[r]))return!1;return!0}var tr=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})),Sr=tr[fe]={},w=class{constructor(e,t,r){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(Gt),this.options=r!=null?r:{},Sr.value=this,this.messagePrototype=Object.create(null,tr),this.refTypeCheck=new pe(this),this.refJsonReader=new me(this),this.refJsonWriter=new he(this),this.refBinReader=new de(this),this.refBinWriter=new ge(this)}create(e){let t=Qt(this);return e!==void 0&&be(this,t,e),t}clone(e){let t=this.create();return be(this,t,e),t}equals(e,t){return zt(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){be(this,e,t)}fromBinary(e,t){let r=Wt(t);return this.internalBinaryRead(r.readerFactory(e),e.byteLength,r)}fromJson(e,t){return this.internalJsonRead(e,jt(t))}fromJsonString(e,t){let r=JSON.parse(e);return this.fromJson(r,t)}toJson(e,t){return this.internalJsonWrite(e,Jt(t))}toJsonString(e,t){var r;let i=this.toJson(e,t);return JSON.stringify(i,null,(r=t==null?void 0:t.prettySpaces)!==null&&r!==void 0?r:0)}toBinary(e,t){let r=qt(t);return this.internalBinaryWrite(e,r.writerFactory(),r).finish()}internalJsonRead(e,t,r){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let i=r!=null?r:this.create();return this.refJsonReader.read(e,i,t),i}throw new Error(`Unable to parse message ${this.typeName} from JSON ${L(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,r){return this.refBinWriter.write(e,t,r),t}internalBinaryRead(e,t,r,i){let s=i!=null?i:this.create();return this.refBinReader.read(e,s,r,t),s}};var Je=class extends w{constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3,L:0},{no:2,name:"nanos",kind:"scalar",T:5}])}now(){let e=this.create(),t=Date.now();return e.seconds=b.from(Math.floor(t/1e3)).toBigInt(),e.nanos=t%1e3*1e6,e}toDate(e){return new Date(b.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){let t=this.create(),r=e.getTime();return t.seconds=b.from(Math.floor(r/1e3)).toBigInt(),t.nanos=r%1e3*1e6,t}internalJsonWrite(e,t){let r=b.from(e.seconds).toNumber()*1e3;if(r<Date.parse("0001-01-01T00:00:00Z")||r>Date.parse("9999-12-31T23:59:59Z"))throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(e.nanos<0)throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let i="Z";if(e.nanos>0){let s=(e.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?i="."+s.substring(0,3)+"Z":s.substring(6)==="000"?i="."+s.substring(0,6)+"Z":i="."+s+"Z"}return new Date(r).toISOString().replace(".000Z",i)}internalJsonRead(e,t,r){if(typeof e!="string")throw new Error("Unable to parse Timestamp from JSON "+L(e)+".");let i=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(!i)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let s=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(s))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(s<Date.parse("0001-01-01T00:00:00Z")||s>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return r||(r=this.create()),r.seconds=b.from(s/1e3).toBigInt(),r.nanos=0,i[7]&&(r.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),r}},Ge=new Je;var nr=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.PATH=1]="PATH",r[r.CMD=2]="CMD",r))(nr||{}),ir=(i=>(i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.CANCELLED=1]="CANCELLED",i[i.CANCELLING=2]="CANCELLING",i[i.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",i))(ir||{}),Ke=class extends w{constructor(){super("arrow.flight.protocol.HandshakeRequest",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Rr=new Ke,Qe=class extends w{constructor(){super("arrow.flight.protocol.HandshakeResponse",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Ar=new Qe,Ze=class extends w{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},hs=new Ze,Ye=class extends w{constructor(){super("arrow.flight.protocol.Empty",[])}},Pr=new Ye,ze=class extends w{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},Dr=new ze,et=class extends w{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},Ur=new et,tt=class extends w{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},Cr=new tt,rt=class extends w{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Te}])}},ds=new rt,nt=class extends w{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>sr}])}},gs=new nt,it=class extends w{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},Lr=new it,st=class extends w{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",ir,"CANCEL_STATUS_"]}])}},bs=new st,ot=class extends w{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Br=new ot,at=class extends w{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",nr]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},$=new at,lt=class extends w{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>$},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>sr},{no:4,name:"total_records",kind:"scalar",T:3,L:0},{no:5,name:"total_bytes",kind:"scalar",T:3,L:0},{no:6,name:"ordered",kind:"scalar",T:8},{no:7,name:"app_metadata",kind:"scalar",T:12}])}},Te=new lt,ut=class extends w{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>Te},{no:2,name:"flight_descriptor",kind:"message",T:()=>$},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>Ge}])}},Vr=new ut,ct=class extends w{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>Oe},{no:2,name:"location",kind:"message",repeat:1,T:()=>vr},{no:3,name:"expiration_time",kind:"message",T:()=>Ge},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},sr=new ct,ft=class extends w{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},vr=new ft,pt=class extends w{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},Oe=new pt,mt=class extends w{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>$},{no:2,name:"data_header",kind:"scalar",T:12},{no:3,name:"app_metadata",kind:"scalar",T:12},{no:1e3,name:"data_body",kind:"scalar",T:12}])}},we=new mt,ht=class extends w{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},Mr=new ht,Fe=new rr.ServiceType("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:Rr,O:Ar},{name:"ListFlights",serverStreaming:!0,options:{},I:Ur,O:Te},{name:"GetFlightInfo",options:{},I:$,O:Te},{name:"PollFlightInfo",options:{},I:$,O:Vr},{name:"GetSchema",options:{},I:$,O:Br},{name:"DoGet",serverStreaming:!0,options:{},I:Oe,O:we},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:we,O:Mr},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:we,O:we},{name:"DoAction",serverStreaming:!0,options:{},I:Cr,O:Lr},{name:"ListActions",serverStreaming:!0,options:{},I:Pr,O:Dr}]);var k=H("@protobuf-ts/runtime-rpc");var xe=class{constructor(e){this._transport=e;d(this,"typeName",Fe.typeName);d(this,"methods",Fe.methods);d(this,"options",Fe.options)}handshake(e){let t=this.methods[0],r=this._transport.mergeOptions(e);return(0,k.stackIntercept)("duplex",this._transport,t,r)}listFlights(e,t){let r=this.methods[1],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,r,i,e)}getFlightInfo(e,t){let r=this.methods[2],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("unary",this._transport,r,i,e)}pollFlightInfo(e,t){let r=this.methods[3],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("unary",this._transport,r,i,e)}getSchema(e,t){let r=this.methods[4],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("unary",this._transport,r,i,e)}doGet(e,t){let r=this.methods[5],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,r,i,e)}doPut(e){let t=this.methods[6],r=this._transport.mergeOptions(e);return(0,k.stackIntercept)("duplex",this._transport,t,r)}doExchange(e){let t=this.methods[7],r=this._transport.mergeOptions(e);return(0,k.stackIntercept)("duplex",this._transport,t,r)}doAction(e,t){let r=this.methods[8],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,r,i,e)}listActions(e,t){let r=this.methods[9],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,r,i,e)}};var or=/\$(\w+)/g;function ar(n){return!!n.match(or)}function lr(n,e){let t=n.match(or);if(t)for(let r of t)e[r.trim().replace("$","")]||V(new Error(`No parameter matching ${r} provided in the query params map`));return!0}var Wr="2.0.0",ur=`influxdb3-js/${Wr}`;var cr=H("apache-arrow/enum");function dt(n,e){if(e==null)return null;let t=n.metadata.get("iox::column::type");if(!t||n.typeId===cr.Type.Timestamp)return e;let[,,r,i]=t.split("::");if(r==="field")switch(i){case"integer":return v(e)?parseInt(e):(console.warn(`Value ${e} is not an integer`),e);case"uinteger":return At(e)?parseInt(e):(console.warn(`Value ${e} is not an unsigned integer`),e);case"float":return v(e)?parseFloat(e):(console.warn(`Value ${e} is not a float`),e);case"boolean":return typeof e=="boolean"||console.warn(`Value ${e} is not a boolean`),e;case"string":return typeof e=="string"?String(e):(console.warn(`Value ${e} is not a string`),e);default:return e}return e}var Z=class{constructor(e){this._options=e;d(this,"_closed",!1);d(this,"_flightClient");d(this,"_transport");d(this,"_defaultHeaders");let{host:t,queryTimeout:r,grpcOptions:i}=this._options;this._defaultHeaders=this._options.headers;let s={};i!==void 0&&(s=i),this._transport=C.queryTransport({host:t,timeout:r,clientOptions:{...s}}),this._flightClient=new xe(this._transport)}prepareTicket(e,t,r){let i={database:e,sql_query:t,query_type:r.type};if(r.params){let s={};for(let o of Object.keys(r.params))r.params[o]&&(s[o]=r.params[o]);i.params=s}return Oe.create({ticket:new TextEncoder().encode(JSON.stringify(i))})}prepareMetadata(e){let t={"User-Agent":ur,...this._defaultHeaders,...e},r=this._options.token;return r&&(t.authorization=`Bearer ${r}`),t}async*_queryRawBatches(e,t,r){if(r.params&&ar(e)&&lr(e,r.params),this._closed)throw new Error("queryApi: already closed!");let i=this._flightClient,s=this.prepareTicket(t,e,r),a={meta:this.prepareMetadata(r.headers)},l=i.doGet(s,a),c=(async function*(){for await(let m of l.responses)yield St(m.dataHeader.length),yield m.dataHeader,yield m.dataBody})();yield*await Ie.RecordBatchReader.from(c)}async*query(e,t,r){let i=this._queryRawBatches(e,t,r);for await(let s of i)for(let o of s){let a={};for(let l of s.schema.fields){let c=o[l.name];a[l.name]=dt(l,c)}yield a}}async*queryPoints(e,t,r){var s;let i=this._queryRawBatches(e,t,r);for await(let o of i)for(let a=0;a<o.numRows;a++){let l=new A;for(let c=0;c<o.numCols;c++){let f=o.schema.fields[c],m=f.name,p=(s=o.getChildAt(c))==null?void 0:s.get(a),F=f.typeId,h=f.metadata.get("iox::column::type");if(p==null)continue;if((m==="measurement"||m=="iox::measurement")&&typeof p=="string"){l.setMeasurement(p);continue}if(!h){m==="time"&&F===Ie.Type.Timestamp?l.setTimestamp(p):l.setField(m,p);continue}let[,,x,D]=h.split("::");if(x==="field"){if(D&&p!==void 0&&p!==null){let q=dt(f,p);l.setField(m,q,D)}}else x==="tag"?l.setTag(m,p):x==="timestamp"&&l.setTimestamp(p)}yield l}}async close(){var e,t;this._closed=!0,(t=(e=this._transport).close)==null||t.call(e)}};var gt=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
|
|
12
|
+
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(i){case 0:o=s,i=1;break;case 1:t[r++]=o<<2|(s&48)>>4,o=s,i=2;break;case 2:t[r++]=(o&15)<<4|(s&60)>>2,o=s,i=3;break;case 3:t[r++]=(o&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,r)}function Ct(n){let e="",t=0,r,i=0;for(let s=0;s<n.length;s++)switch(r=n[s],t){case 0:e+=S[r>>2],i=(r&3)<<4,t=1;break;case 1:e+=S[i|r>>4],i=(r&15)<<2,t=2;break;case 2:e+=S[i|r>>6],e+=S[r&63],t=0;break}return t&&(e+=S[i],e+="=",t==1&&(e+="=")),e}var M;(function(n){n.symbol=Symbol.for("protobuf-ts/unknown"),n.onRead=(t,r,i,s,o)=>{(e(r)?r[n.symbol]:r[n.symbol]=[]).push({no:i,wireType:s,data:o})},n.onWrite=(t,r,i)=>{for(let{no:s,wireType:o,data:a}of n.list(r))i.tag(s,o).raw(a)},n.list=(t,r)=>{if(e(t)){let i=t[n.symbol];return r?i.filter(s=>s.no==r):i}return[]},n.last=(t,r)=>n.list(t,r).slice(-1)[0];let e=t=>t&&Array.isArray(t[n.symbol])})(M||(M={}));var T;(function(n){n[n.Varint=0]="Varint",n[n.Bit64=1]="Bit64",n[n.LengthDelimited=2]="LengthDelimited",n[n.StartGroup=3]="StartGroup",n[n.EndGroup=4]="EndGroup",n[n.Bit32=5]="Bit32"})(T||(T={}));function Lt(){let n=0,e=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(n|=(i&127)<<r,(i&128)==0)return this.assertBounds(),[n,e]}let t=this.buf[this.pos++];if(n|=(t&15)<<28,e=(t&112)>>4,(t&128)==0)return this.assertBounds(),[n,e];for(let r=3;r<=31;r+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<r,(i&128)==0)return this.assertBounds(),[n,e]}throw new Error("invalid varint")}function oe(n,e,t){for(let s=0;s<28;s=s+7){let o=n>>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}let r=n>>>28&15|(e&7)<<4,i=e>>3!=0;if(t.push((i?r|128:r)&255),!!i){for(let s=3;s<31;s=s+7){let o=e>>>s,a=!!(o>>>7),l=(a?o|128:o)&255;if(t.push(l),!a)return}t.push(e>>>31&1)}}var se=65536*65536;function $e(n){let e=n[0]=="-";e&&(n=n.slice(1));let t=1e6,r=0,i=0;function s(o,a){let l=Number(n.slice(o,a));i*=t,r=r*t+l,r>=se&&(i=i+(r/se|0),r=r%se)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,r,i]}function ae(n,e){if(e>>>0<=2097151)return""+(se*e+(n>>>0));let t=n&16777215,r=(n>>>24|e<<8)>>>0&16777215,i=e>>16&65535,s=t+r*6777216+i*6710656,o=r+i*8147497,a=i*2,l=1e7;s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l);function c(f,m){let p=f?String(f):"";return m?"0000000".slice(p.length)+p:p}return c(a,0)+c(o,a)+c(s,1)}function qe(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function Bt(){let n=this.buf[this.pos++],e=n&127;if((n&128)==0)return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,(n&128)==0)return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,(n&128)==0)return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,(n&128)==0)return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;(n&128)!==0&&t<10;t++)n=this.buf[this.pos++];if((n&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var y;function xr(){let n=new DataView(new ArrayBuffer(8));y=globalThis.BigInt!==void 0&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:n}:void 0}xr();function Vt(n){if(!n)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var vt=/^-?[0-9]+$/,ue=4294967296,le=2147483648,ce=class{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*ue+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},O=class n extends ce{static from(e){if(y)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=y.C(e);case"number":if(e===0)return this.ZERO;e=y.C(e);case"bigint":if(!e)return this.ZERO;if(e<y.UMIN)throw new Error("signed value for ulong");if(e>y.UMAX)throw new Error("ulong too large");return y.V.setBigUint64(0,e,!0),new n(y.V.getInt32(0,!0),y.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!vt.test(e))throw new Error("string is no integer");let[t,r,i]=$e(e);if(t)throw new Error("signed value for ulong");return new n(r,i);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new n(e,e/ue)}throw new Error("unknown value "+typeof e)}toString(){return y?this.toBigInt().toString():ae(this.lo,this.hi)}toBigInt(){return Vt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigUint64(0,!0)}};O.ZERO=new O(0,0);var b=class n extends ce{static from(e){if(y)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=y.C(e);case"number":if(e===0)return this.ZERO;e=y.C(e);case"bigint":if(!e)return this.ZERO;if(e<y.MIN)throw new Error("signed long too small");if(e>y.MAX)throw new Error("signed long too large");return y.V.setBigInt64(0,e,!0),new n(y.V.getInt32(0,!0),y.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!vt.test(e))throw new Error("string is no integer");let[t,r,i]=$e(e);if(t){if(i>le||i==le&&r!=0)throw new Error("signed long too small")}else if(i>=le)throw new Error("signed long too large");let s=new n(r,i);return t?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new n(e,e/ue):new n(-e,-e/ue).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&le)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new n(t,e)}toString(){if(y)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+ae(e.lo,e.hi)}return ae(this.lo,this.hi)}toBigInt(){return Vt(y),y.V.setInt32(0,this.lo,!0),y.V.setInt32(4,this.hi,!0),y.V.getBigInt64(0,!0)}};b.ZERO=new b(0,0);var Mt={readUnknownField:!0,readerFactory:n=>new He(n)};function Wt(n){return n?Object.assign(Object.assign({},Mt),n):Mt}var He=class{constructor(e,t){this.varint64=Lt,this.uint32=Bt,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t!=null?t:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e){let t=this.pos;switch(e){case T.Varint:for(;this.buf[this.pos++]&128;);break;case T.Bit64:this.pos+=4;case T.Bit32:this.pos+=4;break;case T.LengthDelimited:let r=this.uint32();this.pos+=r;break;case T.StartGroup:let i;for(;(i=this.tag()[1])!==T.EndGroup;)this.skip(i);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new b(...this.varint64())}uint64(){return new O(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,new b(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 new O(this.sfixed32(),this.sfixed32())}sfixed64(){return new b(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(){return this.textDecoder.decode(this.bytes())}};function g(n,e){if(!n)throw new Error(e)}var Ir=34028234663852886e22,Nr=-34028234663852886e22,Er=4294967295,kr=2147483647,_r=-2147483648;function P(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>kr||n<_r)throw new Error("invalid int 32: "+n)}function B(n){if(typeof n!="number")throw new Error("invalid uint 32: "+typeof n);if(!Number.isInteger(n)||n>Er||n<0)throw new Error("invalid uint 32: "+n)}function W(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>Ir||n<Nr))throw new Error("invalid float 32: "+n)}var $t={writeUnknownFields:!0,writerFactory:()=>new Xe};function qt(n){return n?Object.assign(Object.assign({},$t),n):$t}var Xe=class{constructor(e){this.stack=[],this.textEncoder=e!=null?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let i=0;i<this.chunks.length;i++)e+=this.chunks[i].length;let t=new Uint8Array(e),r=0;for(let i=0;i<this.chunks.length;i++)t.set(this.chunks[i],r),r+=this.chunks[i].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 new 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(B(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return P(e),qe(e,this.buf),this}bool(e){return this.buf.push(e?1:0),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){W(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){B(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){P(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return P(e),e=(e<<1^e>>31)>>>0,qe(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=b.from(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=O.from(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=b.from(e);return oe(t.lo,t.hi,this.buf),this}sint64(e){let t=b.from(e),r=t.hi>>31,i=t.lo<<1^r,s=(t.hi<<1|t.lo>>>31)^r;return oe(i,s,this.buf),this}uint64(e){let t=O.from(e);return oe(t.lo,t.hi,this.buf),this}};var Ht={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Xt={ignoreUnknownFields:!1};function jt(n){return n?Object.assign(Object.assign({},Xt),n):Xt}function Jt(n){return n?Object.assign(Object.assign({},Ht),n):Ht}var fe=Symbol.for("protobuf-ts/message-type");function je(n){let e=!1,t=[];for(let r=0;r<n.length;r++){let i=n.charAt(r);i=="_"?e=!0:/\d/.test(i)?(t.push(i),e=!0):e?(t.push(i.toUpperCase()),e=!1):r==0?t.push(i.toLowerCase()):t.push(i)}return t.join("")}var u;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(u||(u={}));var I;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING",n[n.NUMBER=2]="NUMBER"})(I||(I={}));var K;(function(n){n[n.NO=0]="NO",n[n.PACKED=1]="PACKED",n[n.UNPACKED=2]="UNPACKED"})(K||(K={}));function Gt(n){var e,t,r,i;return n.localName=(e=n.localName)!==null&&e!==void 0?e:je(n.name),n.jsonName=(t=n.jsonName)!==null&&t!==void 0?t:je(n.name),n.repeat=(r=n.repeat)!==null&&r!==void 0?r:K.NO,n.opt=(i=n.opt)!==null&&i!==void 0?i:n.repeat||n.oneof?!1:n.kind=="message",n}function Kt(n){if(typeof n!="object"||n===null||!n.hasOwnProperty("oneofKind"))return!1;switch(typeof n.oneofKind){case"string":return n[n.oneofKind]===void 0?!1:Object.keys(n).length==2;case"undefined":return Object.keys(n).length==1;default:return!1}}var pe=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;let e=[],t=[],r=[];for(let i of this.fields)if(i.oneof)r.includes(i.oneof)||(r.push(i.oneof),e.push(i.oneof),t.push(i.oneof));else switch(t.push(i.localName),i.kind){case"scalar":case"enum":(!i.opt||i.repeat)&&e.push(i.localName);break;case"message":i.repeat&&e.push(i.localName);break;case"map":e.push(i.localName);break}this.data={req:e,known:t,oneofs:Object.values(r)}}is(e,t,r=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let i=Object.keys(e),s=this.data;if(i.length<s.req.length||s.req.some(o=>!i.includes(o))||!r&&i.some(o=>!s.known.includes(o)))return!1;if(t<1)return!0;for(let o of s.oneofs){let a=e[o];if(!Kt(a))return!1;if(a.oneofKind===void 0)continue;let l=this.fields.find(c=>c.localName===a.oneofKind);if(!l||!this.field(a[a.oneofKind],l,r,t))return!1}for(let o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,r,t))return!1;return!0}field(e,t,r,i){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,i,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,u.INT32,i):this.scalar(e,u.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),r,i):this.message(e,t.T(),r,i);case"map":if(typeof e!="object"||e===null)return!1;if(i<2)return!0;if(!this.mapKeys(e,t.K,i))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,i,t.V.L);case"enum":return this.scalars(Object.values(e),u.INT32,i);case"message":return this.messages(Object.values(e),t.V.T(),r,i)}break}return!0}message(e,t,r,i){return r?t.isAssignable(e,i):t.is(e,i)}messages(e,t,r,i){if(!Array.isArray(e))return!1;if(i<2)return!0;if(r){for(let s=0;s<e.length&&s<i;s++)if(!t.isAssignable(e[s],i-1))return!1}else for(let s=0;s<e.length&&s<i;s++)if(!t.is(e[s],i-1))return!1;return!0}scalar(e,t,r){let i=typeof e;switch(t){case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:switch(r){case I.BIGINT:return i=="bigint";case I.NUMBER:return i=="number"&&!isNaN(e);default:return i=="string"}case u.BOOL:return i=="boolean";case u.STRING:return i=="string";case u.BYTES:return e instanceof Uint8Array;case u.DOUBLE:case u.FLOAT:return i=="number"&&!isNaN(e);default:return i=="number"&&Number.isInteger(e)}}scalars(e,t,r,i){if(!Array.isArray(e))return!1;if(r<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<r;s++)if(!this.scalar(e[s],t,i))return!1}return!0}mapKeys(e,t,r){let i=Object.keys(e);switch(t){case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:return this.scalars(i.slice(0,r).map(s=>parseInt(s)),t,r);case u.BOOL:return this.scalars(i.slice(0,r).map(s=>s=="true"?!0:s=="false"?!1:s),t,r);default:return this.scalars(i,t,r,I.STRING)}}};function N(n,e){switch(e){case I.BIGINT:return n.toBigInt();case I.NUMBER:return n.toNumber();default:return n.toString()}}var me=class{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};let t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(let r of t)this.fMap[r.name]=r,this.fMap[r.jsonName]=r,this.fMap[r.localName]=r}}assert(e,t,r){if(!e){let i=L(r);throw(i=="number"||i=="boolean")&&(i=r.toString()),new Error(`Cannot parse JSON ${i} for ${this.info.typeName}#${t}`)}}read(e,t,r){this.prepare();let i=[];for(let[s,o]of Object.entries(e)){let a=this.fMap[s];if(!a){if(!r.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}let l=a.localName,c;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(i.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);i.push(a.oneof),c=t[a.oneof]={oneofKind:l}}else c=t;if(a.kind=="map"){if(o===null)continue;this.assert(We(o),a.name,o);let f=c[l];for(let[m,p]of Object.entries(o)){this.assert(p!==null,a.name+" map value",null);let F;switch(a.V.kind){case"message":F=a.V.T().internalJsonRead(p,r);break;case"enum":if(F=this.enum(a.V.T(),p,a.name,r.ignoreUnknownFields),F===!1)continue;break;case"scalar":F=this.scalar(p,a.V.T,a.V.L,a.name);break}this.assert(F!==void 0,a.name+" map value",p);let h=m;a.K==u.BOOL&&(h=h=="true"?!0:h=="false"?!1:h),h=this.scalar(h,a.K,I.STRING,a.name).toString(),f[h]=F}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let f=c[l];for(let m of o){this.assert(m!==null,a.name,null);let p;switch(a.kind){case"message":p=a.T().internalJsonRead(m,r);break;case"enum":if(p=this.enum(a.T(),m,a.name,r.ignoreUnknownFields),p===!1)continue;break;case"scalar":p=this.scalar(m,a.T,a.L,a.name);break}this.assert(p!==void 0,a.name,o),f.push(p)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}c[l]=a.T().internalJsonRead(o,r,c[l]);break;case"enum":if(o===null)continue;let f=this.enum(a.T(),o,a.name,r.ignoreUnknownFields);if(f===!1)continue;c[l]=f;break;case"scalar":if(o===null)continue;c[l]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,r,i){if(e[0]=="google.protobuf.NullValue"&&g(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return g(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${r}, enum can only be integral number, got ${t}.`),t;case"string":let s=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(s=t.substring(e[2].length));let o=e[1][s];return typeof o=="undefined"&&i?!1:(g(typeof o=="number",`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} has no value for "${t}".`),o)}g(!1,`Unable to parse field ${this.info.typeName}#${r}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,r,i){let s;try{switch(t){case u.DOUBLE:case u.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let o=Number(e);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return t==u.FLOAT&&W(o),o;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":a=Number(e)),a===void 0)break;return t==u.UINT32?B(a):P(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return N(b.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return N(b.from(e),r);case u.FIXED64:case u.UINT64:if(e===null)return N(O.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return N(O.from(e),r);case u.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case u.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(l){l="invalid UTF8";break}return e;case u.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return Ut(e)}}catch(o){s=o.message}this.assert(!1,i+(s?" - "+s:""),e)}};var he=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){let r={},i=e;for(let s of this.fields){if(!s.oneof){let c=this.field(s,i[s.localName],t);c!==void 0&&(r[t.useProtoFieldName?s.name:s.jsonName]=c);continue}let o=i[s.oneof];if(o.oneofKind!==s.localName)continue;let a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t,l=this.field(s,o[s.localName],a);g(l!==void 0),r[t.useProtoFieldName?s.name:s.jsonName]=l}return r}field(e,t,r){let i;if(e.kind=="map"){g(typeof t=="object"&&t!==null);let s={};switch(e.V.kind){case"scalar":for(let[l,c]of Object.entries(t)){let f=this.scalar(e.V.T,c,e.name,!1,!0);g(f!==void 0),s[l.toString()]=f}break;case"message":let o=e.V.T();for(let[l,c]of Object.entries(t)){let f=this.message(o,c,e.name,r);g(f!==void 0),s[l.toString()]=f}break;case"enum":let a=e.V.T();for(let[l,c]of Object.entries(t)){g(c===void 0||typeof c=="number");let f=this.enum(a,c,e.name,!1,!0,r.enumAsInteger);g(f!==void 0),s[l.toString()]=f}break}(r.emitDefaultValues||Object.keys(s).length>0)&&(i=s)}else if(e.repeat){g(Array.isArray(t));let s=[];switch(e.kind){case"scalar":for(let l=0;l<t.length;l++){let c=this.scalar(e.T,t[l],e.name,e.opt,!0);g(c!==void 0),s.push(c)}break;case"enum":let o=e.T();for(let l=0;l<t.length;l++){g(t[l]===void 0||typeof t[l]=="number");let c=this.enum(o,t[l],e.name,e.opt,!0,r.enumAsInteger);g(c!==void 0),s.push(c)}break;case"message":let a=e.T();for(let l=0;l<t.length;l++){let c=this.message(a,t[l],e.name,r);g(c!==void 0),s.push(c)}break}(r.emitDefaultValues||s.length>0||r.emitDefaultValues)&&(i=s)}else switch(e.kind){case"scalar":i=this.scalar(e.T,t,e.name,e.opt,r.emitDefaultValues);break;case"enum":i=this.enum(e.T(),t,e.name,e.opt,r.emitDefaultValues,r.enumAsInteger);break;case"message":i=this.message(e.T(),t,e.name,r);break}return i}enum(e,t,r,i,s,o){if(e[0]=="google.protobuf.NullValue")return!s&&!i?void 0:null;if(t===void 0){g(i);return}if(!(t===0&&!s&&!i))return g(typeof t=="number"),g(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,r,i){return t===void 0?i.emitDefaultValues?null:void 0:e.internalJsonWrite(t,i)}scalar(e,t,r,i,s){if(t===void 0){g(i);return}let o=s||i;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(P(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(B(t),t);case u.FLOAT:W(t);case u.DOUBLE:return t===0?o?0:void 0:(g(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case u.STRING:return t===""?o?"":void 0:(g(typeof t=="string"),t);case u.BOOL:return t===!1?o?!1:void 0:(g(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:g(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=O.from(t);return a.isZero()&&!o?void 0:a.toString();case u.INT64:case u.SFIXED64:case u.SINT64:g(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let l=b.from(t);return l.isZero()&&!o?void 0:l.toString();case u.BYTES:return g(t instanceof Uint8Array),t.byteLength?Ct(t):o?"":void 0}}};function Q(n,e=I.STRING){switch(n){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return N(O.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return N(b.ZERO,e);case u.DOUBLE:case u.FLOAT:return 0;case u.BYTES:return new Uint8Array(0);case u.STRING:return"";default:return 0}}var de=class{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){let t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(r=>[r.no,r]))}}read(e,t,r,i){this.prepare();let s=i===void 0?e.len:e.pos+i;for(;e.pos<s;){let[o,a]=e.tag(),l=this.fieldNoToField.get(o);if(!l){let p=r.readUnknownField;if(p=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let F=e.skip(a);p!==!1&&(p===!0?M.onRead:p)(this.info.typeName,t,o,a,F);continue}let c=t,f=l.repeat,m=l.localName;switch(l.oneof&&(c=c[l.oneof],c.oneofKind!==m&&(c=t[l.oneof]={oneofKind:m})),l.kind){case"scalar":case"enum":let p=l.kind=="enum"?u.INT32:l.T,F=l.kind=="scalar"?l.L:void 0;if(f){let D=c[m];if(a==T.LengthDelimited&&p!=u.STRING&&p!=u.BYTES){let q=e.uint32()+e.pos;for(;e.pos<q;)D.push(this.scalar(e,p,F))}else D.push(this.scalar(e,p,F))}else c[m]=this.scalar(e,p,F);break;case"message":if(f){let D=c[m],q=l.T().internalBinaryRead(e,e.uint32(),r);D.push(q)}else c[m]=l.T().internalBinaryRead(e,e.uint32(),r,c[m]);break;case"map":let[h,x]=this.mapEntry(l,e,r);c[m][h]=x;break}}}mapEntry(e,t,r){let i=t.uint32(),s=t.pos+i,o,a;for(;t.pos<s;){let[l,c]=t.tag();switch(l){case 1:e.K==u.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,I.STRING);break;case 2:switch(e.V.kind){case"scalar":a=this.scalar(t,e.V.T,e.V.L);break;case"enum":a=t.int32();break;case"message":a=e.V.T().internalBinaryRead(t,t.uint32(),r);break}break;default:throw new Error(`Unknown field ${l} (wire type ${c}) in map entry for ${this.info.typeName}#${e.name}`)}}if(o===void 0){let l=Q(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=Q(e.V.T,e.V.L);break;case"enum":a=0;break;case"message":a=e.V.T().create();break}return[o,a]}scalar(e,t,r){switch(t){case u.INT32:return e.int32();case u.STRING:return e.string();case u.BOOL:return e.bool();case u.DOUBLE:return e.double();case u.FLOAT:return e.float();case u.INT64:return N(e.int64(),r);case u.UINT64:return N(e.uint64(),r);case u.FIXED64:return N(e.fixed64(),r);case u.FIXED32:return e.fixed32();case u.BYTES:return e.bytes();case u.UINT32:return e.uint32();case u.SFIXED32:return e.sfixed32();case u.SFIXED64:return N(e.sfixed64(),r);case u.SINT32:return e.sint32();case u.SINT64:return N(e.sint64(),r)}}};var ge=class{constructor(e){this.info=e}prepare(){if(!this.fields){let e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,r)=>t.no-r.no)}}write(e,t,r){this.prepare();for(let s of this.fields){let o,a,l=s.repeat,c=s.localName;if(s.oneof){let f=e[s.oneof];if(f.oneofKind!==c)continue;o=f[c],a=!0}else o=e[c],a=!1;switch(s.kind){case"scalar":case"enum":let f=s.kind=="enum"?u.INT32:s.T;if(l)if(g(Array.isArray(o)),l==K.PACKED)this.packed(t,f,s.no,o);else for(let m of o)this.scalar(t,f,s.no,m,!0);else o===void 0?g(s.opt):this.scalar(t,f,s.no,o,a||s.opt);break;case"message":if(l){g(Array.isArray(o));for(let m of o)this.message(t,r,s.T(),s.no,m)}else this.message(t,r,s.T(),s.no,o);break;case"map":g(typeof o=="object"&&o!==null);for(let[m,p]of Object.entries(o))this.mapEntry(t,r,s,m,p);break}}let i=r.writeUnknownFields;i!==!1&&(i===!0?M.onWrite:i)(this.info.typeName,e,t)}mapEntry(e,t,r,i,s){e.tag(r.no,T.LengthDelimited),e.fork();let o=i;switch(r.K){case u.INT32:case u.FIXED32:case u.UINT32:case u.SFIXED32:case u.SINT32:o=Number.parseInt(i);break;case u.BOOL:g(i=="true"||i=="false"),o=i=="true";break}switch(this.scalar(e,r.K,1,o,!0),r.V.kind){case"scalar":this.scalar(e,r.V.T,2,s,!0);break;case"enum":this.scalar(e,u.INT32,2,s,!0);break;case"message":this.message(e,t,r.V.T(),2,s);break}e.join()}message(e,t,r,i,s){s!==void 0&&(r.internalBinaryWrite(s,e.tag(i,T.LengthDelimited).fork(),t),e.join())}scalar(e,t,r,i,s){let[o,a,l]=this.scalarInfo(t,i);(!l||s)&&(e.tag(r,o),e[a](i))}packed(e,t,r,i){if(!i.length)return;g(t!==u.BYTES&&t!==u.STRING),e.tag(r,T.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let o=0;o<i.length;o++)e[s](i[o]);e.join()}scalarInfo(e,t){let r=T.Varint,i,s=t===void 0,o=t===0;switch(e){case u.INT32:i="int32";break;case u.STRING:o=s||!t.length,r=T.LengthDelimited,i="string";break;case u.BOOL:o=t===!1,i="bool";break;case u.UINT32:i="uint32";break;case u.DOUBLE:r=T.Bit64,i="double";break;case u.FLOAT:r=T.Bit32,i="float";break;case u.INT64:o=s||b.from(t).isZero(),i="int64";break;case u.UINT64:o=s||O.from(t).isZero(),i="uint64";break;case u.FIXED64:o=s||O.from(t).isZero(),r=T.Bit64,i="fixed64";break;case u.BYTES:o=s||!t.byteLength,r=T.LengthDelimited,i="bytes";break;case u.FIXED32:r=T.Bit32,i="fixed32";break;case u.SFIXED32:r=T.Bit32,i="sfixed32";break;case u.SFIXED64:o=s||b.from(t).isZero(),r=T.Bit64,i="sfixed64";break;case u.SINT32:i="sint32";break;case u.SINT64:o=s||b.from(t).isZero(),i="sint64";break}return[r,i,s||o]}};function Qt(n){let e=n.messagePrototype?Object.create(n.messagePrototype):Object.defineProperty({},fe,{value:n});for(let t of n.fields){let r=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[r]=[];else switch(t.kind){case"scalar":e[r]=Q(t.T,t.L);break;case"enum":e[r]=0;break;case"map":e[r]={};break}}return e}function be(n,e,t){let r,i=t,s;for(let o of n.fields){let a=o.localName;if(o.oneof){let l=i[o.oneof];if((l==null?void 0:l.oneofKind)==null)continue;if(r=l[a],s=e[o.oneof],s.oneofKind=l.oneofKind,r==null){delete s[a];continue}}else if(r=i[a],s=e,r==null)continue;switch(o.repeat&&(s[a].length=r.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let c=0;c<r.length;c++)s[a][c]=r[c];else s[a]=r;break;case"message":let l=o.T();if(o.repeat)for(let c=0;c<r.length;c++)s[a][c]=l.create(r[c]);else s[a]===void 0?s[a]=l.create(r):l.mergePartial(s[a],r);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],r);break;case"message":let c=o.V.T();for(let f of Object.keys(r))s[a][f]=c.create(r[f]);break}break}}}function zt(n,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let r of n.fields){let i=r.localName,s=r.oneof?e[r.oneof][i]:e[i],o=r.oneof?t[r.oneof][i]:t[i];switch(r.kind){case"enum":case"scalar":let a=r.kind=="enum"?u.INT32:r.T;if(!(r.repeat?Zt(a,s,o):er(a,s,o)))return!1;break;case"map":if(!(r.V.kind=="message"?Yt(r.V.T(),ye(s),ye(o)):Zt(r.V.kind=="enum"?u.INT32:r.V.T,ye(s),ye(o))))return!1;break;case"message":let l=r.T();if(!(r.repeat?Yt(l,s,o):l.equals(s,o)))return!1;break}}return!0}var ye=Object.values;function er(n,e,t){if(e===t)return!0;if(n!==u.BYTES)return!1;let r=e,i=t;if(r.length!==i.length)return!1;for(let s=0;s<r.length;s++)if(r[s]!=i[s])return!1;return!0}function Zt(n,e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!er(n,e[r],t[r]))return!1;return!0}function Yt(n,e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!n.equals(e[r],t[r]))return!1;return!0}var tr=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})),Sr=tr[fe]={},w=class{constructor(e,t,r){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(Gt),this.options=r!=null?r:{},Sr.value=this,this.messagePrototype=Object.create(null,tr),this.refTypeCheck=new pe(this),this.refJsonReader=new me(this),this.refJsonWriter=new he(this),this.refBinReader=new de(this),this.refBinWriter=new ge(this)}create(e){let t=Qt(this);return e!==void 0&&be(this,t,e),t}clone(e){let t=this.create();return be(this,t,e),t}equals(e,t){return zt(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){be(this,e,t)}fromBinary(e,t){let r=Wt(t);return this.internalBinaryRead(r.readerFactory(e),e.byteLength,r)}fromJson(e,t){return this.internalJsonRead(e,jt(t))}fromJsonString(e,t){let r=JSON.parse(e);return this.fromJson(r,t)}toJson(e,t){return this.internalJsonWrite(e,Jt(t))}toJsonString(e,t){var r;let i=this.toJson(e,t);return JSON.stringify(i,null,(r=t==null?void 0:t.prettySpaces)!==null&&r!==void 0?r:0)}toBinary(e,t){let r=qt(t);return this.internalBinaryWrite(e,r.writerFactory(),r).finish()}internalJsonRead(e,t,r){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let i=r!=null?r:this.create();return this.refJsonReader.read(e,i,t),i}throw new Error(`Unable to parse message ${this.typeName} from JSON ${L(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,r){return this.refBinWriter.write(e,t,r),t}internalBinaryRead(e,t,r,i){let s=i!=null?i:this.create();return this.refBinReader.read(e,s,r,t),s}};var Je=class extends w{constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3,L:0},{no:2,name:"nanos",kind:"scalar",T:5}])}now(){let e=this.create(),t=Date.now();return e.seconds=b.from(Math.floor(t/1e3)).toBigInt(),e.nanos=t%1e3*1e6,e}toDate(e){return new Date(b.from(e.seconds).toNumber()*1e3+Math.ceil(e.nanos/1e6))}fromDate(e){let t=this.create(),r=e.getTime();return t.seconds=b.from(Math.floor(r/1e3)).toBigInt(),t.nanos=r%1e3*1e6,t}internalJsonWrite(e,t){let r=b.from(e.seconds).toNumber()*1e3;if(r<Date.parse("0001-01-01T00:00:00Z")||r>Date.parse("9999-12-31T23:59:59Z"))throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(e.nanos<0)throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let i="Z";if(e.nanos>0){let s=(e.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?i="."+s.substring(0,3)+"Z":s.substring(6)==="000"?i="."+s.substring(0,6)+"Z":i="."+s+"Z"}return new Date(r).toISOString().replace(".000Z",i)}internalJsonRead(e,t,r){if(typeof e!="string")throw new Error("Unable to parse Timestamp from JSON "+L(e)+".");let i=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(!i)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let s=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(s))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(s<Date.parse("0001-01-01T00:00:00Z")||s>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return r||(r=this.create()),r.seconds=b.from(s/1e3).toBigInt(),r.nanos=0,i[7]&&(r.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),r}},Ge=new Je;var nr=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.PATH=1]="PATH",r[r.CMD=2]="CMD",r))(nr||{}),ir=(i=>(i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.CANCELLED=1]="CANCELLED",i[i.CANCELLING=2]="CANCELLING",i[i.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",i))(ir||{}),Ke=class extends w{constructor(){super("arrow.flight.protocol.HandshakeRequest",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Rr=new Ke,Qe=class extends w{constructor(){super("arrow.flight.protocol.HandshakeResponse",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Ar=new Qe,Ze=class extends w{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},hs=new Ze,Ye=class extends w{constructor(){super("arrow.flight.protocol.Empty",[])}},Pr=new Ye,ze=class extends w{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},Dr=new ze,et=class extends w{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},Ur=new et,tt=class extends w{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},Cr=new tt,rt=class extends w{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Te}])}},ds=new rt,nt=class extends w{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>sr}])}},gs=new nt,it=class extends w{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},Lr=new it,st=class extends w{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",ir,"CANCEL_STATUS_"]}])}},bs=new st,ot=class extends w{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Br=new ot,at=class extends w{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",nr]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},$=new at,lt=class extends w{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>$},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>sr},{no:4,name:"total_records",kind:"scalar",T:3,L:0},{no:5,name:"total_bytes",kind:"scalar",T:3,L:0},{no:6,name:"ordered",kind:"scalar",T:8},{no:7,name:"app_metadata",kind:"scalar",T:12}])}},Te=new lt,ut=class extends w{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>Te},{no:2,name:"flight_descriptor",kind:"message",T:()=>$},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>Ge}])}},Vr=new ut,ct=class extends w{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>Oe},{no:2,name:"location",kind:"message",repeat:1,T:()=>vr},{no:3,name:"expiration_time",kind:"message",T:()=>Ge},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},sr=new ct,ft=class extends w{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},vr=new ft,pt=class extends w{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},Oe=new pt,mt=class extends w{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>$},{no:2,name:"data_header",kind:"scalar",T:12},{no:3,name:"app_metadata",kind:"scalar",T:12},{no:1e3,name:"data_body",kind:"scalar",T:12}])}},we=new mt,ht=class extends w{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},Mr=new ht,Fe=new rr.ServiceType("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:Rr,O:Ar},{name:"ListFlights",serverStreaming:!0,options:{},I:Ur,O:Te},{name:"GetFlightInfo",options:{},I:$,O:Te},{name:"PollFlightInfo",options:{},I:$,O:Vr},{name:"GetSchema",options:{},I:$,O:Br},{name:"DoGet",serverStreaming:!0,options:{},I:Oe,O:we},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:we,O:Mr},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:we,O:we},{name:"DoAction",serverStreaming:!0,options:{},I:Cr,O:Lr},{name:"ListActions",serverStreaming:!0,options:{},I:Pr,O:Dr}]);var k=H("@protobuf-ts/runtime-rpc");var xe=class{constructor(e){this._transport=e;d(this,"typeName",Fe.typeName);d(this,"methods",Fe.methods);d(this,"options",Fe.options)}handshake(e){let t=this.methods[0],r=this._transport.mergeOptions(e);return(0,k.stackIntercept)("duplex",this._transport,t,r)}listFlights(e,t){let r=this.methods[1],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,r,i,e)}getFlightInfo(e,t){let r=this.methods[2],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("unary",this._transport,r,i,e)}pollFlightInfo(e,t){let r=this.methods[3],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("unary",this._transport,r,i,e)}getSchema(e,t){let r=this.methods[4],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("unary",this._transport,r,i,e)}doGet(e,t){let r=this.methods[5],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,r,i,e)}doPut(e){let t=this.methods[6],r=this._transport.mergeOptions(e);return(0,k.stackIntercept)("duplex",this._transport,t,r)}doExchange(e){let t=this.methods[7],r=this._transport.mergeOptions(e);return(0,k.stackIntercept)("duplex",this._transport,t,r)}doAction(e,t){let r=this.methods[8],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,r,i,e)}listActions(e,t){let r=this.methods[9],i=this._transport.mergeOptions(t);return(0,k.stackIntercept)("serverStreaming",this._transport,r,i,e)}};var or=/\$(\w+)/g;function ar(n){return!!n.match(or)}function lr(n,e){let t=n.match(or);if(t)for(let r of t)e[r.trim().replace("$","")]||V(new Error(`No parameter matching ${r} provided in the query params map`));return!0}var Wr="2.1.0.nightly",ur=`influxdb3-js/${Wr}`;var cr=H("apache-arrow/enum");function dt(n,e){if(e==null)return null;let t=n.metadata.get("iox::column::type");if(!t||n.typeId===cr.Type.Timestamp)return e;let[,,r,i]=t.split("::");if(r==="field")switch(i){case"integer":return v(e)?parseInt(e):(console.warn(`Value ${e} is not an integer`),e);case"uinteger":return At(e)?parseInt(e):(console.warn(`Value ${e} is not an unsigned integer`),e);case"float":return v(e)?parseFloat(e):(console.warn(`Value ${e} is not a float`),e);case"boolean":return typeof e=="boolean"||console.warn(`Value ${e} is not a boolean`),e;case"string":return typeof e=="string"?String(e):(console.warn(`Value ${e} is not a string`),e);default:return e}return e}var Z=class{constructor(e){this._options=e;d(this,"_closed",!1);d(this,"_flightClient");d(this,"_transport");d(this,"_defaultHeaders");let{host:t,queryTimeout:r,grpcOptions:i}=this._options;this._defaultHeaders=this._options.headers;let s={};i!==void 0&&(s=i),this._transport=C.queryTransport({host:t,timeout:r,clientOptions:{...s}}),this._flightClient=new xe(this._transport)}prepareTicket(e,t,r){let i={database:e,sql_query:t,query_type:r.type};if(r.params){let s={};for(let o of Object.keys(r.params))r.params[o]&&(s[o]=r.params[o]);i.params=s}return Oe.create({ticket:new TextEncoder().encode(JSON.stringify(i))})}prepareMetadata(e){let t={"User-Agent":ur,...this._defaultHeaders,...e},r=this._options.token;return r&&(t.authorization=`Bearer ${r}`),t}async*_queryRawBatches(e,t,r){if(r.params&&ar(e)&&lr(e,r.params),this._closed)throw new Error("queryApi: already closed!");let i=this._flightClient,s=this.prepareTicket(t,e,r),a={meta:this.prepareMetadata(r.headers)},l=i.doGet(s,a),c=(async function*(){for await(let m of l.responses)yield St(m.dataHeader.length),yield m.dataHeader,yield m.dataBody})();yield*await Ie.RecordBatchReader.from(c)}async*query(e,t,r){let i=this._queryRawBatches(e,t,r);for await(let s of i)for(let o of s){let a={};for(let l of s.schema.fields){let c=o[l.name];a[l.name]=dt(l,c)}yield a}}async*queryPoints(e,t,r){var s;let i=this._queryRawBatches(e,t,r);for await(let o of i)for(let a=0;a<o.numRows;a++){let l=new A;for(let c=0;c<o.numCols;c++){let f=o.schema.fields[c],m=f.name,p=(s=o.getChildAt(c))==null?void 0:s.get(a),F=f.typeId,h=f.metadata.get("iox::column::type");if(p==null)continue;if((m==="measurement"||m=="iox::measurement")&&typeof p=="string"){l.setMeasurement(p);continue}if(!h){m==="time"&&F===Ie.Type.Timestamp?l.setTimestamp(p):l.setField(m,p);continue}let[,,x,D]=h.split("::");if(x==="field"){if(D&&p!==void 0&&p!==null){let q=dt(f,p);l.setField(m,q,D)}}else x==="tag"?l.setTag(m,p):x==="timestamp"&&l.setTimestamp(p)}yield l}}async close(){var e,t;this._closed=!0,(t=(e=this._transport).close)==null||t.call(e)}};var gt=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
|
|
13
13
|
`,Y=class{constructor(...e){d(this,"_options");d(this,"_writeApi");d(this,"_queryApi");d(this,"_transport");d(this,"_mergeWriteOptions",e=>{var i;let t={...(i=this._options.writeOptions)==null?void 0:i.headers,...e==null?void 0:e.headers},r={...this._options.writeOptions,...e};return r.headers=t,r});d(this,"_mergeQueryOptions",e=>{var s,o;let t={...(s=this._options.queryOptions)==null?void 0:s.headers,...e==null?void 0:e.headers},r={...(o=this._options.queryOptions)==null?void 0:o.params,...e==null?void 0:e.params},i={...this._options.queryOptions,...e};return i.headers=t,i.params=r,i});var i,s;let t;switch(e.length){case 0:{t=Re();break}case 1:{if(e[0]==null)throw new R("No configuration specified!");typeof e[0]=="string"?t=Se(e[0]):t=e[0];break}default:throw new R("Multiple arguments specified!")}this._options={...ke,...t},this._options.grpcOptions?this._options.queryOptions={...t.queryOptions,grpcOptions:{...this._options.grpcOptions}}:(i=t.queryOptions)!=null&&i.grpcOptions&&(this._options.grpcOptions=(s=t.queryOptions)==null?void 0:s.grpcOptions);let r=this._options.host;if(typeof r!="string")throw new R("No host specified!");if(r.endsWith("/")&&(this._options.host=r.substring(0,r.length-1)),typeof this._options.token!="string")throw new R("No token specified!");this._queryApi=new Z(this._options),this._transport=C.writeTransport(this._options),this._writeApi=new G({transport:this._transport,...this._options})}async write(e,t,r,i){var o;let s=this._mergeWriteOptions(i);await this._writeApi.doWrite(ve(e,s==null?void 0:s.defaultTags),(o=t!=null?t:this._options.database)!=null?o:V(new Error(gt)),r,s)}query(e,t,r=(i=>(i=this._options.queryOptions)!=null?i:ee)()){var o;let s=this._mergeQueryOptions(r);return this._queryApi.query(e,(o=t!=null?t:this._options.database)!=null?o:V(new Error(gt)),s)}queryPoints(e,t,r=(i=>(i=this._options.queryOptions)!=null?i:ee)()){var o;let s=this._mergeQueryOptions(r);return this._queryApi.queryPoints(e,(o=t!=null?t:this._options.database)!=null?o:V(new Error(gt)),s)}async getServerVersion(){let e;try{let t=await this._transport.request("/ping",null,{method:"GET"},(r,i)=>{var s;e=(s=r["X-Influxdb-Version"])!=null?s:r["x-influxdb-version"]});t&&!e&&(e=t.version)}catch(t){return Promise.reject(t)}return Promise.resolve(e)}async close(){await this._writeApi.close(),await this._queryApi.close()}};return br($r);})();
|
|
14
14
|
Object.defineProperty(exports, '__esModule', { value: true });Object.assign(exports, influxdb);}));
|
|
15
15
|
//# sourceMappingURL=index.browser.js.map
|
package/dist/index.browser.js.gz
CHANGED
|
Binary file
|